docs: use tooling convention across docs (#10512)
This commit is contained in:
1 parent
7c76ee24cb
commit
3409953c4f
76 files changed
+283
-265
No files matched your search
@@ -18,7 +18,7 @@ Start by creating a new directory for your module. For example, `src/modules/my-
|
||||
|
||||
Create the file `src/modules/my-event/service.ts` that holds the implementation of the event service.
|
||||
|
||||
The Event Module's main service must extend the `AbstractEventBusModuleService` class imported from `@medusajs/framework/utils`:
|
||||
The Event Module's main service must extend the `AbstractEventBusModuleService` class from the Medusa Framework:
|
||||
|
||||
```ts title="src/modules/my-event/service.ts"
|
||||
import { AbstractEventBusModuleService } from "@medusajs/framework/utils"
|
||||
|
||||
@@ -10,7 +10,7 @@ The API Key Module provides API-key-related features in your Medusa and Node.js
|
||||
|
||||
## How to Use API Key Module's Service
|
||||
|
||||
Use the API Key Module's main service by resolving from the Medusa container the resource `Modules.API_KEY` imported from `@medusajs/framework/utils`.
|
||||
Use the API Key Module's main service by resolving from the Medusa container the resource `Modules.API_KEY`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ This workflow accepts the manager’s data and the associated auth identity’s
|
||||
The workflow has two steps:
|
||||
|
||||
1. Create the manager using the `createManagerStep`.
|
||||
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` step imported from `@medusajs/medusa/core-flows`. You specify the actor type `manager` in the `actorType` property of the step’s input.
|
||||
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` from Medusa's core workflows. You specify the actor type `manager` in the `actorType` property of the step’s input.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Auth Module provides authentication-related features in your Medusa and Node
|
||||
|
||||
## How to Use Auth Module's Service
|
||||
|
||||
Use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH` imported from `@medusajs/framework/utils`.
|
||||
Use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ export default defineMiddlewares({
|
||||
})
|
||||
```
|
||||
|
||||
The `additional_data` parameter validation is customized using the `defineMiddlewares` utility function. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
The `additional_data` parameter validation is customized using `defineMiddlewares`. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
|
||||
In the snippet above, you add a validation rule indicating that `custom_name` is a string that can be passed in the `additional_data` object.
|
||||
|
||||
@@ -260,9 +260,9 @@ The workflow accepts as an input the created cart and the `additional_data` para
|
||||
|
||||
In the workflow, you:
|
||||
|
||||
1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
1. Use `transform` to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
2. Create the `Custom` record using the `createCustomStep`.
|
||||
3. Use the `when-then` utility to link the cart to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
3. Use `when-then` to link the cart to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
|
||||
You'll next call the workflow in the hook handler.
|
||||
|
||||
@@ -556,7 +556,7 @@ const created = when({
|
||||
// TODO update, or delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the cart doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the cart.
|
||||
Using `when-then`, you check if the cart doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the cart.
|
||||
|
||||
To create the `Custom` record, you use the `createCustomStep` you created in an earlier section.
|
||||
|
||||
@@ -589,7 +589,7 @@ const deleted = when({
|
||||
// TODO delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the cart has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
Using `when-then`, you check if the cart has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
|
||||
Finally, replace the new `TODO` with the following:
|
||||
|
||||
@@ -614,7 +614,7 @@ return new WorkflowResponse({
|
||||
})
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the cart has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
Using `when-then`, you check if the cart has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
|
||||
You return in the workflow response the created, updated, and deleted `Custom` record.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Cart Module provides cart-related features in your Medusa and Node.js applic
|
||||
|
||||
## How to Use Cart Module's Service
|
||||
|
||||
You can use the Cart Module's main service by resolving from the Medusa container the resource `Modules.CART` imported from `@medusajs/framework/utils`.
|
||||
You can use the Cart Module's main service by resolving from the Medusa container the resource `Modules.CART`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Currency Module provides currency-related features in your Medusa and Node.j
|
||||
|
||||
## How to Use Currency Module's Service
|
||||
|
||||
You can use the Currency Module's main service by resolving from the Medusa container the resource `Modules.CURRENCY` imported from `@medusajs/framework/utils`.
|
||||
You can use the Currency Module's main service by resolving from the Medusa container the resource `Modules.CURRENCY`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ export default defineMiddlewares({
|
||||
})
|
||||
```
|
||||
|
||||
The `additional_data` parameter validation is customized using the `defineMiddlewares` utility function. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
The `additional_data` parameter validation is customized using `defineMiddlewares`. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
|
||||
In the snippet above, you add a validation rule indicating that `custom_name` is a string that can be passed in the `additional_data` object.
|
||||
|
||||
@@ -266,9 +266,9 @@ The workflow accepts as an input the created customer and the `additional_data`
|
||||
|
||||
In the workflow, you:
|
||||
|
||||
1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
1. Use `transform` to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
2. Create the `Custom` record using the `createCustomStep`.
|
||||
3. Use the `when-then` utility to link the customer to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
3. Use `when-then` to link the customer to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
|
||||
You'll next execute the workflow in the hook handler.
|
||||
|
||||
@@ -568,7 +568,7 @@ const created = when({
|
||||
// TODO update, or delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the customer doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the customer.
|
||||
Using `when-then`, you check if the customer doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the customer.
|
||||
|
||||
To create the `Custom` record, you use the `createCustomStep` you created in an earlier section.
|
||||
|
||||
@@ -601,7 +601,7 @@ const deleted = when({
|
||||
// TODO delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the customer has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
Using `when-then`, you check if the customer has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
|
||||
Finally, replace the new `TODO` with the following:
|
||||
|
||||
@@ -626,7 +626,7 @@ return new WorkflowResponse({
|
||||
})
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the customer has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
Using `when-then`, you check if the customer has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
|
||||
You return in the workflow response the created, updated, and deleted `Custom` record.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Customer Module provides customer-related features in your Medusa and Node.j
|
||||
|
||||
## How to Use Customer Module's Service
|
||||
|
||||
You can use the Customer Module's main service by resolving from the Medusa container the resource `Modules.CUSTOMER` imported from `@medusajs/framework/utils`.
|
||||
You can use the Customer Module's main service by resolving from the Medusa container the resource `Modules.CUSTOMER`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Fulfillment Module provides fulfillment-related features in your Medusa and
|
||||
|
||||
## How to Use Fulfillment Module's Service
|
||||
|
||||
You can use the Fulfillment Module's main service by resolving from the Medusa container the resource `Modules.FULFILLMENT` imported from `@medusajs/framework/utils`.
|
||||
You can use the Fulfillment Module's main service by resolving from the Medusa container the resource `Modules.FULFILLMENT`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Inventory Module provides inventory-related features in your Medusa and Node
|
||||
|
||||
## How to Use Inventory Module's Service
|
||||
|
||||
You can use the Inventory Module's main service by resolving from the Medusa container the resource `Modules.INVENTORY` imported from `@medusajs/framework/utils`.
|
||||
You can use the Inventory Module's main service by resolving from the Medusa container the resource `Modules.INVENTORY`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Order Module provides order-related features in your Medusa and Node.js appl
|
||||
|
||||
## How to Use Order Module's Service
|
||||
|
||||
You can use the Order Module's main service by resolving from the Medusa container the resource `Modules.ORDER` imported from `@medusajs/framework/utils`.
|
||||
You can use the Order Module's main service by resolving from the Medusa container the resource `Modules.ORDER`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ The Payment Module provides payment-related features in your Medusa and Node.js
|
||||
|
||||
## How to Use Payment Module's Service
|
||||
|
||||
You can use the Payment Module's main service by resolving from the Medusa container the resource `Modules.PAYMENT` imported from `@medusajs/framework/utils`.
|
||||
You can use the Payment Module's main service by resolving from the Medusa container the resource `Modules.PAYMENT`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Pricing Module provides pricing-related features in your Medusa and Node.js
|
||||
|
||||
## How to Use Pricing Module's Service
|
||||
|
||||
You can use the Pricing Module's main service by resolving from the Medusa container the resource `Modules.PRICING` imported from `@medusajs/framework/utils`.
|
||||
You can use the Pricing Module's main service by resolving from the Medusa container the resource `Modules.PRICING`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ export default defineMiddlewares({
|
||||
})
|
||||
```
|
||||
|
||||
The `additional_data` parameter validation is customized using the `defineMiddlewares` utility function. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
The `additional_data` parameter validation is customized using `defineMiddlewares`. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
|
||||
In the snippet above, you add a validation rule indicating that `custom_name` is a string that can be passed in the `additional_data` object.
|
||||
|
||||
@@ -266,9 +266,9 @@ The workflow accepts as an input the created product and the `additional_data` p
|
||||
|
||||
In the workflow, you:
|
||||
|
||||
1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
1. Use `transform` to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
2. Create the `Custom` record using the `createCustomStep`.
|
||||
3. Use the `when-then` utility to link the product to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
3. Use `when-then` to link the product to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
|
||||
You'll next execute the workflow in the hook handler.
|
||||
|
||||
@@ -574,7 +574,7 @@ const created = when({
|
||||
// TODO update, or delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the product doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the product.
|
||||
Using `when-then`, you check if the product doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the product.
|
||||
|
||||
To create the `Custom` record, you use the `createCustomStep` you created in an earlier section.
|
||||
|
||||
@@ -607,7 +607,7 @@ const deleted = when({
|
||||
// TODO delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the product has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
Using `when-then`, you check if the product has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
|
||||
Finally, replace the new `TODO` with the following:
|
||||
|
||||
@@ -632,7 +632,7 @@ return new WorkflowResponse({
|
||||
})
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the product has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
Using `when-then`, you check if the product has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
|
||||
You return in the workflow response the created, updated, and deleted `Custom` record.
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ products.forEach((product) => {
|
||||
For each product variant, you:
|
||||
|
||||
1. Retrieve its tax lines from the `taxLinesMap`.
|
||||
2. Calculate its prices with and without taxes using the `calculateAmountsWithTax` function imported from `@medusajs/framework/utils`.
|
||||
2. Calculate its prices with and without taxes using the `calculateAmountsWithTax` from the Medusa Framework.
|
||||
3. The `calculateAmountsWithTax` function returns an object having two properties:
|
||||
- `priceWithTax`: The variant's price with the taxes applied.
|
||||
- `priceWithoutTax`: The variant's price without taxes applied.
|
||||
@@ -89,6 +89,6 @@ const { data: products } = await query.graph({
|
||||
|
||||
For the context of the product variant's calculated price, you pass an object to `context` with the property `variants`, whose value is another object with the property `calculated_price`.
|
||||
|
||||
`calculated_price`'s value is created using the `QueryContext` utility function, passing it a [calculation context object](../../../pricing/price-calculation/page.mdx#calculation-context).
|
||||
`calculated_price`'s value is created using `QueryContext` from the Modules SDK, passing it a [calculation context object](../../../pricing/price-calculation/page.mdx#calculation-context).
|
||||
|
||||
Each variant in the retrieved products has a `calculated_price` object. Learn more about its properties in [this Pricing Module guide](../../../pricing/price-calculation/page.mdx#returned-price-object).
|
||||
@@ -10,7 +10,7 @@ The Product Module provides product-related features in your Medusa and Node.js
|
||||
|
||||
## How to Use Product Module's Service
|
||||
|
||||
You can use the Product Module's main service by resolving from the Medusa container the resource `Modules.PRODUCT` imported from `@medusajs/framework/utils`.
|
||||
You can use the Product Module's main service by resolving from the Medusa container the resource `Modules.PRODUCT`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ export default defineMiddlewares({
|
||||
})
|
||||
```
|
||||
|
||||
The `additional_data` parameter validation is customized using the `defineMiddlewares` utility function. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
The `additional_data` parameter validation is customized using `defineMiddlewares`. In the routes middleware configuration object, the `additionalDataValidator` property accepts [Zod](https://zod.dev/) validaiton rules.
|
||||
|
||||
In the snippet above, you add a validation rule indicating that `custom_name` is a string that can be passed in the `additional_data` object.
|
||||
|
||||
@@ -266,9 +266,9 @@ The workflow accepts as an input the created promotion and the `additional_data`
|
||||
|
||||
In the workflow, you:
|
||||
|
||||
1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
1. Use `transform` to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
2. Create the `Custom` record using the `createCustomStep`.
|
||||
3. Use the `when-then` utility to link the promotion to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
3. Use `when-then` to link the promotion to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/fundamentals/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
|
||||
|
||||
You'll next execute the workflow in the hook handler.
|
||||
|
||||
@@ -580,7 +580,7 @@ const created = when({
|
||||
// TODO update, or delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the promotion doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the promotion.
|
||||
Using `when-then`, you check if the promotion doesn't have a linked `Custom` record and the `custom_name` property is set. If so, you create a `Custom` record and link it to the promotion.
|
||||
|
||||
To create the `Custom` record, you use the `createCustomStep` you created in an earlier section.
|
||||
|
||||
@@ -613,7 +613,7 @@ const deleted = when({
|
||||
// TODO delete Custom record
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the promotion has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
Using `when-then`, you check if the promotion has a linked `Custom` record and `custom_name` is `null` or an empty string. If so, you delete the linked `Custom` record and dismiss its links.
|
||||
|
||||
Finally, replace the new `TODO` with the following:
|
||||
|
||||
@@ -638,7 +638,7 @@ return new WorkflowResponse({
|
||||
})
|
||||
```
|
||||
|
||||
Using the `when-then` utility, you check if the promotion has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
Using `when-then`, you check if the promotion has a linked `Custom` record and `custom_name` is passed in the `additional_data`. If so, you update the linked `Custom` record.
|
||||
|
||||
You return in the workflow response the created, updated, and deleted `Custom` record.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Promotion Module provides promotion-related features in your Medusa and Node
|
||||
|
||||
## How to Use the Promotion Module's Service
|
||||
|
||||
You can use the Promotion Module's main service by resolving from the Medusa container the resource `Modules.PROMOTION` imported from `@medusajs/framework/utils`.
|
||||
You can use the Promotion Module's main service by resolving from the Medusa container the resource `Modules.PROMOTION`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Region Module provides region-related features in your Medusa and Node.js ap
|
||||
|
||||
## How to Use Region Module's Service
|
||||
|
||||
You can use the Region Module's main service by resolving from the Medusa container the resource `Modules.REGION` imported from `@medusajs/framework/utils`.
|
||||
You can use the Region Module's main service by resolving from the Medusa container the resource `Modules.REGION`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Sales Channel Module provides sales-channel-related features in your Medusa
|
||||
|
||||
## How to Use Sales Channel Module's Service
|
||||
|
||||
You can use the Sales Channel Module's main service by resolving from the Medusa container the resource `Modules.SALES_CHANNEL` imported from `@medusajs/framework/utils`.
|
||||
You can use the Sales Channel Module's main service by resolving from the Medusa container the resource `Modules.SALES_CHANNEL`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Stock Location Module provides stock-location-related features in your Medus
|
||||
|
||||
## How to Use Stock Location Module's Service
|
||||
|
||||
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `Modules.STOCK_LOCATION` imported from `@medusajs/framework/utils`.
|
||||
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `Modules.STOCK_LOCATION`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Store Module provides store-related features in your Medusa and Node.js appl
|
||||
|
||||
## How to Use Store Module's Service
|
||||
|
||||
You can use the Store Module's main service by resolving from the Medusa container the resource `Modules.STORE` imported from `@medusajs/framework/utils`.
|
||||
You can use the Store Module's main service by resolving from the Medusa container the resource `Modules.STORE`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The Tax Module provides tax-related features in your Medusa and Node.js applicat
|
||||
|
||||
## How to Use Tax Module's Service
|
||||
|
||||
You can use the Tax Module's main service by resolving from the Medusa container the resource `Modules.TAX` imported from `@medusajs/framework/utils`.
|
||||
You can use the Tax Module's main service by resolving from the Medusa container the resource `Modules.TAX`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The User Module provides user-related features in your Medusa and Node.js applic
|
||||
|
||||
## How to Use User Module's Service
|
||||
|
||||
You can use the User Module's main service by resolving from the Medusa container the resource `Modules.USER` imported from `@medusajs/framework/utils`.
|
||||
You can use the User Module's main service by resolving from the Medusa container the resource `Modules.USER`.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ Learn more in [this documentation](!docs!/learn/fundamentals/api-routes/protecte
|
||||
|
||||
### Throw Errors in API Route
|
||||
|
||||
To throw errors in an API route, use the `MedusaError` utility:
|
||||
To throw errors in an API route, use `MedusaError` from the Medusa Framework:
|
||||
|
||||
```ts highlights={[["9", "MedusaError"]]}
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
@@ -2244,7 +2244,7 @@ Learn more in [this documentation](!docs!/learn/fundamentals/workflows/compensat
|
||||
|
||||
### Manipulate Variables in Workflow
|
||||
|
||||
To manipulate variables within a workflow's constructor function, use the `transform` utility:
|
||||
To manipulate variables within a workflow's constructor function, use `transform` from the Workflows SDK:
|
||||
|
||||
```ts highlights={[["14", "transform"]]}
|
||||
import {
|
||||
@@ -2274,7 +2274,7 @@ Learn more in [this documentation](!docs!/learn/fundamentals/workflows/variable-
|
||||
|
||||
### Using Conditions in Workflow
|
||||
|
||||
To perform steps or set a variable's value based on a condition, use the `when-then` utility:
|
||||
To perform steps or set a variable's value based on a condition, use `when-then` from the Workflows SDK:
|
||||
|
||||
```ts highlights={[["14", "when"]]}
|
||||
import {
|
||||
@@ -2418,7 +2418,7 @@ Learn more in [this documentation](!docs!/learn/fundamentals/workflows/retry-fai
|
||||
|
||||
### Run Steps in Parallel
|
||||
|
||||
If steps in a workflow don't depend on one another, run them in parallel using the `parallel` utility:
|
||||
If steps in a workflow don't depend on one another, run them in parallel using `parallel` from the Workflows SDK:
|
||||
|
||||
```ts highlights={[["22", "parallelize"]]}
|
||||
import {
|
||||
|
||||
@@ -287,7 +287,7 @@ class ResendNotificationProviderService extends AbstractNotificationProviderServ
|
||||
}
|
||||
```
|
||||
|
||||
In the `validateOptions` method, you throw an error if the `api_key` or `from` options aren't passed to the module. To throw errors, you use Medusa's `MedusaError` utility imported from `@medusajs/framework/utils`. This ensures errors follow Medusa's conventions and are displayed similar to Medusa's errors.
|
||||
In the `validateOptions` method, you throw an error if the `api_key` or `from` options aren't passed to the module. To throw errors, you use `MedusaError` from the Modules SDK. This ensures errors follow Medusa's conventions and are displayed similar to Medusa's errors.
|
||||
|
||||
#### Implement Template Methods
|
||||
|
||||
@@ -449,7 +449,7 @@ export default ModuleProvider(Modules.NOTIFICATION, {
|
||||
})
|
||||
```
|
||||
|
||||
You export the module provider's definition using the `ModuleProvider` utility function. It accepts as a first parameter the name of the module that this provider belongs to, which is the Notification Module. It also accepts as a second parameter an object having a `service` property indicating the provider's service.
|
||||
You export the module provider's definition using `ModuleProvider` from the Modules SDK. It accepts as a first parameter the name of the module that this provider belongs to, which is the Notification Module. It also accepts as a second parameter an object having a `service` property indicating the provider's service.
|
||||
|
||||
### Add Module to Configurations
|
||||
|
||||
@@ -737,7 +737,7 @@ export const sendOrderConfirmationWorkflow = createWorkflow(
|
||||
)
|
||||
```
|
||||
|
||||
You create a workflow using the `createWorkflow` function imported from `@medusajs/framework/workflows-sdk`. It accepts the workflow's unique name as a first parameter.
|
||||
You create a workflow using `createWorkflow` from the Workflows SDK. It accepts the workflow's unique name as a first parameter.
|
||||
|
||||
It accepts as a second parameter a constructor function, which is the workflow's implementation. The workflow has the following steps:
|
||||
|
||||
|
||||
@@ -511,7 +511,7 @@ export default Module(SANITY_MODULE, {
|
||||
|
||||
In the file, you export the `SANITY_MODULE` which is the Module's name. You'll use it later when you resolve the module from the Medusa container.
|
||||
|
||||
You also export the module definition using the `Module` utility function, which accepts as a first parameter the module's name, and as a second parameter an object having a `service` property, indicating the module's service.
|
||||
You also export the module definition using `Module` from the Modueles SDK, which accepts as a first parameter the module's name, and as a second parameter an object having a `service` property, indicating the module's service.
|
||||
|
||||
### Add Module to Configurations
|
||||
|
||||
@@ -634,7 +634,7 @@ defineLink(
|
||||
)
|
||||
```
|
||||
|
||||
You define a link using the `defineLink` utility. It accepts three parameters:
|
||||
You define a link using `defineLink` from the Modules SDK. It accepts three parameters:
|
||||
|
||||
1. The first data model part of the link. In this case, it's the Product Module's `product` data model. A module has a special `linkable` property that contain link configurations for its data models.
|
||||
2. The second data model part of the link. Since the Sanity Module doesn't have a Medusa data model, you specify the configurations in a `linkable` object that has the following properties:
|
||||
@@ -887,7 +887,7 @@ export const sanitySyncProductsWorkflow = createWorkflow(
|
||||
)
|
||||
```
|
||||
|
||||
You create a workflow using the `createWorkflow` function imported from `@medusajs/framework/workflows-sdk`. It accepts an object of options as a first parameter, where the `name` property is required and indicates the workflow's unique name.
|
||||
You create a workflow using the `createWorkflow` from the Workflows SDK. It accepts an object of options as a first parameter, where the `name` property is required and indicates the workflow's unique name.
|
||||
|
||||
The `retentionTime` property indicates how long should the workflow's progress be saved in the database. This is useful if you later want to track whether the workflow is successfully executing.
|
||||
|
||||
@@ -1638,7 +1638,7 @@ export const config = defineWidgetConfig({
|
||||
export default ProductWidget
|
||||
```
|
||||
|
||||
The file exports a `ProductWidget` component and a `config` object created with the `defineWidgetConfig` utility function. In the `config` object, you specify the zone to inject the widget into in the `zone` property.
|
||||
The file exports a `ProductWidget` component and a `config` object created with `defineWidgetConfig` from the Admin Extension SDK. In the `config` object, you specify the zone to inject the widget into in the `zone` property.
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
@@ -1910,7 +1910,7 @@ export default SanityRoute
|
||||
|
||||
The file's path relative to the `src/admin/routes` directory indicates its path in the admin dashboard. So, this adds a new route at the path `http://localhost:9000/app/sanity`.
|
||||
|
||||
The file must export the UI route's component. Also, to add an item in the sidebar for the UI route, you export a configuration object, created with the `defineRouteConfig` utility function. The function accepts the following properties:
|
||||
The file must export the UI route's component. Also, to add an item in the sidebar for the UI route, you export a configuration object, created with `defineRouteConfig` from the Admin Extension SDK. The function accepts the following properties:
|
||||
|
||||
- `label`: The sidebar item's label.
|
||||
- `icon`: The icon to the show in the sidebar.
|
||||
|
||||
@@ -90,7 +90,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
|
||||
The Query utility methods.
|
||||
Query to retrieve data across modules.
|
||||
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ChildDocs } from "docs-ui"
|
||||
|
||||
export const metadata = {
|
||||
title: `Medusa Workflows Reference`,
|
||||
title: `Medusa Core Workflows Reference`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This section of the documentation provides a reference to the workflows created by Medusa. These workflows are used in the Store and Admin API routes.
|
||||
This section of the documentation provides a reference to the core workflows created by Medusa. These workflows are used in the Store and Admin API routes, and you can use them in your customizations.
|
||||
|
||||
You can use these workflows in your customizations as well. They're available in the `@medusajs/medusa/core-flows` package.
|
||||
All workflows and steps in this reference are exported by the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
<ChildDocs childLevel={2} hideItems={["Overview", "Steps"]} />
|
||||
@@ -796,7 +796,7 @@ export const POST = async (
|
||||
|
||||
This adds a `POST` API route at `/admin/digital-products/upload/[type]` where `[type]` is either `preview` or `main`.
|
||||
|
||||
In the route handler, you use the `uploadFilesWorkflow` imported from `@medusajs/medusa/core-flows` to upload the file. If the file type is `main`, it’s uploaded with private access, as only customers who purchased it can download it. Otherwise, it’s uploaded with `public` access.
|
||||
In the route handler, you use `uploadFilesWorkflow` from Medusa's core workflows to upload the file. If the file type is `main`, it’s uploaded with private access, as only customers who purchased it can download it. Otherwise, it’s uploaded with `public` access.
|
||||
|
||||
Next, add to the file `src/api/middlewares.ts` the `multer` middleware on this API route:
|
||||
|
||||
@@ -1846,7 +1846,7 @@ In this step, you'll create a workflow that fulfills a digital order by sending
|
||||
|
||||
The workflow has the following steps:
|
||||
|
||||
1. Retrieve the digital product order's details. For this, you'll use the `useQueryGraphStep` imported from `@medusajs/medusa/core-flows`.
|
||||
1. Retrieve the digital product order's details. For this, you'll use `useQueryGraphStep` from Medusa's core workflows.
|
||||
2. Send a notification to the customer with the digital products to download.
|
||||
|
||||
So, you only need to implement the second step.
|
||||
@@ -1869,7 +1869,7 @@ export type DigitalProductOrder =
|
||||
|
||||
This adds a type for a digital product order, which you'll use next.
|
||||
|
||||
You use the `InferTypeOf` utility to infer the type of the `DigitalProductOrder` data model, and add to it the optional `order` property, which is the linked order.
|
||||
You use `InferTypeOf` to infer the type of the `DigitalProductOrder` data model, and add to it the optional `order` property, which is the linked order.
|
||||
|
||||
### Create sendDigitalOrderNotificationStep
|
||||
|
||||
@@ -2013,7 +2013,7 @@ export const fulfillDigitalOrderWorkflow = createWorkflow(
|
||||
|
||||
In the workflow, you:
|
||||
|
||||
1. Retrieve the digital product order's details using the `useQueryGraphStep` imported from `@medusajs/medusa/core-flows`.
|
||||
1. Retrieve the digital product order's details using `useQueryGraphStep` from Medusa's core workflows.
|
||||
2. Send a notification to the customer with the digital product download links using the `sendDigitalOrderNotificationStep`.
|
||||
|
||||
### Configure Notification Module Provider
|
||||
|
||||
@@ -470,7 +470,7 @@ This adds a type used for inputs in creating a restaurant. It also adds a type f
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
Since the `Restaurant` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
|
||||
Since the `Restaurant` data model is a variable, use `InferTypeOf` to infer its type.
|
||||
|
||||
</Note>
|
||||
|
||||
@@ -726,7 +726,7 @@ To implement and expose a feature that manipulates data, you create a workflow t
|
||||
So, you'll start by implementing the functionality to create a user in a workflow. The workflow has two steps:
|
||||
|
||||
1. Create the user in the database.
|
||||
2. Set the actor type of the user’s authentication identity (created by the `/auth/{actor_type}/{provider}/register` API route). For this step, you’ll use the `setAuthAppMetadataStep` step imported from the `@medusajs/medusa/core-flows` package.
|
||||
2. Set the actor type of the user’s authentication identity (created by the `/auth/{actor_type}/{provider}/register` API route). For this step, you’ll use `setAuthAppMetadataStep` from Medusa's core workflows.
|
||||
|
||||
To implement the first step, create the file `src/workflows/user/steps/create-user.ts` with the following content:
|
||||
|
||||
@@ -895,8 +895,8 @@ return new WorkflowResponse(user)
|
||||
In the workflow, you:
|
||||
|
||||
1. Use the `createUserStep` to create the user.
|
||||
2. Use the `transform` utility function to create the input to be passed to the next step.
|
||||
3. Use the `setAuthAppMetadataStep` imported from `@medusajs/medusa/core-flows` to update the authentication identity and associate it with the new user.
|
||||
2. Use `transform` to create the input to be passed to the next step.
|
||||
3. Use `setAuthAppMetadataStep` from Medusa's core workflows to update the authentication identity and associate it with the new user.
|
||||
4. Return the created user.
|
||||
|
||||
### Create API Route
|
||||
@@ -984,7 +984,7 @@ export default defineMiddlewares({
|
||||
})
|
||||
```
|
||||
|
||||
This applies the `authenticate` middleware imported from `@medusajs/medusa` on the `POST /users` API routes.
|
||||
This applies the `authenticate` middleware from the Medusa Framework on the `POST /users` API routes.
|
||||
|
||||
### Test it Out: Create Restaurant Admin
|
||||
|
||||
@@ -1182,8 +1182,8 @@ return new WorkflowResponse(input.id)
|
||||
After deleting the restaurant admin, you:
|
||||
|
||||
1. Retrieve its auth identity using Query. To do that, you filter its `app_metadata` property by checking that its `restaurant_id` property's value is the admin's ID. For drivers, you replace `restaurant_id` with `driver_id`.
|
||||
2. Check that the auth identity exists using the `transform` utility. Otherwise, throw an error.
|
||||
3. Unset the association between the auth identity and the restaurant admin using the `setAuthAppMetadataStep` imported from `@medusajs/medusa/core-flows`.
|
||||
2. Check that the auth identity exists using `transform`. Otherwise, throw an error.
|
||||
3. Unset the association between the auth identity and the restaurant admin using `setAuthAppMetadataStep` from Medusa's core workflows.
|
||||
|
||||
### Create API Route
|
||||
|
||||
@@ -1258,8 +1258,8 @@ In this step, you’ll create the API route that creates a product for a restaur
|
||||
|
||||
You’ll start by creating a workflow that creates the restaurant’s products. It has two steps:
|
||||
|
||||
1. Create the product using Medusa’s `createProductsWorkflow` as a step. It’s imported from the `@medusajs/medusa/core-flows` package.
|
||||
2. Create a link between the restaurant and the products using the `createRemoateLinkStep` imported from the `@medusajs/medusa/core-flows` package.
|
||||
1. Create the product using Medusa’s `createProductsWorkflow` as a step. This workflow is available through Medusa's core workflows.
|
||||
2. Create a link between the restaurant and the products using `createRemoateLinkStep` from Medusa's core workflows.
|
||||
|
||||
So, create the workflow in the file `src/workflows/restaurant/workflows/create-restaurant-products.ts` with the following content:
|
||||
|
||||
@@ -1320,7 +1320,7 @@ export const createRestaurantProductsWorkflow = createWorkflow(
|
||||
In the workflow, you:
|
||||
|
||||
1. Execute the `createProductsWorkflow` as a step, passing the workflow’s input as the details of the product.
|
||||
2. Use the `transform` utility to create a `links` object used to specify the links to create in the next step.
|
||||
2. Use `transform` to create a `links` object used to specify the links to create in the next step.
|
||||
3. Use the `createRemoteLinkStep` to create the links between the restaurant and the products.
|
||||
4. Return the created products.
|
||||
|
||||
@@ -1410,7 +1410,7 @@ The workflow to create a delivery has three steps:
|
||||
|
||||
1. `validateRestaurantStep` that checks whether a restaurant with the specified ID exists.
|
||||
2. `createDeliveryStep` that creates the delivery.
|
||||
3. `createRemoteLinkStep` that creates links between the different data model records. This step is imported from `@medusajs/medusa/core-flows`.
|
||||
3. `createRemoteLinkStep` that creates links between the different data model records. This step is from Medusa's core workflows.
|
||||
|
||||
### Create validateRestaurantStep
|
||||
|
||||
@@ -1549,7 +1549,7 @@ In the workflow, you:
|
||||
|
||||
1. Use the `validateRestaurantStep` to validate that the restaurant exists.
|
||||
2. Use the `createDeliveryStep` to create the delivery.
|
||||
3. Use the `transform` utility to specify the links to be created in the next step. You specify links between the delivery and cart, and between the restaurant and delivery.
|
||||
3. Use `transform` to specify the links to be created in the next step. You specify links between the delivery and cart, and between the restaurant and delivery.
|
||||
4. Use the `createRemoteLinkStep` to create the links.
|
||||
5. Return the created delivery.
|
||||
|
||||
@@ -1607,7 +1607,7 @@ Steps that have a `*` next to their names are async steps.
|
||||
{
|
||||
type: "step",
|
||||
name: "createRemoteLinkStep",
|
||||
description: "Creates the links returned by the previous step between the order and delivery. This is imported from `@medusajs/medusa/core-flows`.",
|
||||
description: "Creates the links returned by the previous step between the order and delivery. This is from Medusa's core workflows.",
|
||||
link: "/references/helper-steps/createRemoteLinkStep"
|
||||
},
|
||||
{
|
||||
@@ -2296,7 +2296,7 @@ These types are useful in the upcoming implementation steps.
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
Since the `Delivery` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
|
||||
Since the `Delivery` data model is a variable, use `InferTypeOf` to infer its type.
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ Then, create the workflow at `src/workflows/marketplace/create-vendor-admin/inde
|
||||
|
||||
export const vendorAdminWorkflowHighlights = [
|
||||
["23", "createVendorAdminStep", "Create the vendor admin."],
|
||||
["27", "setAuthAppMetadataStep", "Step is imported from `@medusajs/medusa/core-flows`."]
|
||||
["27", "setAuthAppMetadataStep", "Step is from Medusa's core workflows"]
|
||||
]
|
||||
|
||||
```ts title="src/workflows/marketplace/create-vendor-admin/index.ts" highlights={vendorAdminWorkflowHighlights}
|
||||
@@ -1045,7 +1045,7 @@ try {
|
||||
|
||||
In this snippet, you create multiple child orders for each vendor and link the orders to the vendors.
|
||||
|
||||
You use the `promiseAll` utility imported from `@medusajs/framework/utils` that loops over an array of promises and ensures that all transactions within these promises are rolled back in case an error occurs. You also wrap `promiseAll` in a try-catch block, and in the catch block you invoke and return `StepResponse.permanentFailure` which indicates that the step has failed but still invokes the compensation function that you'll implement in a bit. The first parameter of `permanentFailure` is the error message, and the second is the data to pass to the compensation function.
|
||||
You use `promiseAll` from the Workflows SDK that loops over an array of promises and ensures that all transactions within these promises are rolled back in case an error occurs. You also wrap `promiseAll` in a try-catch block, and in the catch block you invoke and return `StepResponse.permanentFailure` which indicates that the step has failed but still invokes the compensation function that you'll implement in a bit. The first parameter of `permanentFailure` is the error message, and the second is the data to pass to the compensation function.
|
||||
|
||||
If an error occurs, the created orders in the `createdOrders` array are canceled using Medusa's `cancelOrderWorkflow` from the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ export type SubscriptionData = InferTypeOf<typeof Subscription>
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
Since the `Subscription` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
|
||||
Since the `Subscription` data model is a variable, use `InferTypeOf` to infer its type.
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ChildDocs } from "docs-ui"
|
||||
|
||||
export const metadata = {
|
||||
title: `Medusa Test Functions Reference`,
|
||||
title: `Medusa's Testing Framework Reference`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This section of the documentation provides a reference to the testing functions provided by the `@medusajs/test-utils` package.
|
||||
This section of the documentation provides a reference to Medusa's Testing Framework provided by the `@medusajs/test-utils` package.
|
||||
|
||||
<ChildDocs />
|
||||
Reference in new issue
Block a user