docs: fixes to customization docs (#9236)
Closes #9225, #9224, #9226, #9227 Closes DOCS-948, DOCS-947, DOCS-945, DOCS-946
This commit is contained in:
@@ -73,10 +73,10 @@ export default defineMiddlewares({
|
||||
method: "POST",
|
||||
matcher: "/admin/products",
|
||||
additionalDataValidator: {
|
||||
brand: z.string().optional()
|
||||
}
|
||||
}
|
||||
]
|
||||
brand: z.string().optional(),
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
@@ -154,14 +154,14 @@ createProductsWorkflow.hooks.productsCreated(
|
||||
...product,
|
||||
metadata: {
|
||||
...product.metadata,
|
||||
brand: additional_data.brand
|
||||
}
|
||||
brand: additional_data.brand,
|
||||
},
|
||||
}))
|
||||
)
|
||||
|
||||
return new StepResponse(products, {
|
||||
products,
|
||||
additional_data
|
||||
additional_data,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
@@ -160,7 +160,7 @@ export const updateAssociationHighlights = [
|
||||
const product = await helloModuleService.retrieveProduct(
|
||||
"123",
|
||||
{
|
||||
relations: ["orders"]
|
||||
relations: ["orders"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -169,7 +169,7 @@ const updatedProduct = await helloModuleService.updateProducts({
|
||||
// other properties...
|
||||
orders: [
|
||||
...product.orders.map((order) => order.id),
|
||||
"321"
|
||||
"321",
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
@@ -151,14 +151,14 @@ import { model } from "@medusajs/utils"
|
||||
const Order = model.define("order", {
|
||||
id: model.id().primaryKey(),
|
||||
products: model.manyToMany(() => Product, {
|
||||
mappedBy: "orders"
|
||||
mappedBy: "orders",
|
||||
}),
|
||||
})
|
||||
|
||||
const Product = model.define("product", {
|
||||
id: model.id().primaryKey(),
|
||||
orders: model.manyToMany(() => Order, {
|
||||
mappedBy: "products"
|
||||
mappedBy: "products",
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
@@ -142,7 +142,7 @@ const step1 = createStep(
|
||||
async () => {
|
||||
return new StepResponse(
|
||||
`Hello from step one!`,
|
||||
{ message: "Oops! Rolling back my changes..."}
|
||||
{ message: "Oops! Rolling back my changes..." }
|
||||
)
|
||||
},
|
||||
async ({ message }) => {
|
||||
@@ -180,7 +180,7 @@ const step1 = createStep(
|
||||
async () => {
|
||||
return new StepResponse(
|
||||
`Hello from step one!`,
|
||||
{ message: "Oops! Rolling back my changes..."}
|
||||
{ message: "Oops! Rolling back my changes..." }
|
||||
)
|
||||
},
|
||||
async ({ message }, { container }) => {
|
||||
|
||||
@@ -114,11 +114,11 @@ export const successStatusHighlights = [
|
||||
import {
|
||||
Modules,
|
||||
TransactionHandlerType,
|
||||
} from "@medusajs/utils";
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
StepResponse,
|
||||
createStep
|
||||
} from "@medusajs/workflows-sdk";
|
||||
createStep,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
|
||||
type SetStepSuccessStepInput = {
|
||||
transactionId: string
|
||||
@@ -132,7 +132,7 @@ export const setStepSuccessStep = createStep(
|
||||
) {
|
||||
const workflowEngineService = container.resolve(
|
||||
Modules.WORKFLOW_ENGINE
|
||||
);
|
||||
)
|
||||
|
||||
await workflowEngineService.setStepSuccess({
|
||||
idempotencyKey: {
|
||||
@@ -145,9 +145,9 @@ export const setStepSuccessStep = createStep(
|
||||
options: {
|
||||
container,
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
);
|
||||
)
|
||||
```
|
||||
|
||||
In this step (which you use in a workflow other than the long-running workflow), you resolve the Workflow Engine Module's main service and set `step-2` of the previous workflow as successful.
|
||||
@@ -232,11 +232,11 @@ export const failureStatusHighlights = [
|
||||
import {
|
||||
Modules,
|
||||
TransactionHandlerType,
|
||||
} from "@medusajs/utils";
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
StepResponse,
|
||||
createStep
|
||||
} from "@medusajs/workflows-sdk";
|
||||
createStep,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
|
||||
type SetStepFailureStepInput = {
|
||||
transactionId: string
|
||||
@@ -250,7 +250,7 @@ export const setStepFailureStep = createStep(
|
||||
) {
|
||||
const workflowEngineService = container.resolve(
|
||||
Modules.WORKFLOW_ENGINE
|
||||
);
|
||||
)
|
||||
|
||||
await workflowEngineService.setStepFailure({
|
||||
idempotencyKey: {
|
||||
@@ -263,9 +263,9 @@ export const setStepFailureStep = createStep(
|
||||
options: {
|
||||
container,
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
);
|
||||
)
|
||||
```
|
||||
|
||||
You use this step in another workflow that changes the status of an async step in a long-running workflow's execution to failed.
|
||||
|
||||
Reference in New Issue
Block a user