docs: use tooling convention across docs (#10512)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-12-09 19:15:29 +02:00
1 parent 7c76ee24cb
commit 3409953c4f
76 files changed
+283 -265

No files matched your search

@@ -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>