Loading...
Was this page helpful?
This documentation provides a reference to the createStep
. It belongs to the Workflows SDK.
This function creates a StepFunction that can be used as a step in a workflow constructed by the createWorkflow function.
1import {2 createStep,3 StepResponse4} from "@medusajs/framework/workflows-sdk"5 6interface CreateProductInput {7 title: string8}9 10export const createProductStep = createStep(11 "createProductStep",12 async function (13 input: CreateProductInput,14 { container }15 ) {16 const productModuleService = container.resolve(17 "product"18 )19 const product = await productModuleService.createProducts(input)20 return new StepResponse({21 product22 }, {23 product_id: product.id24 })25 },26 async function (27 input,28 { container }29 ) {30 if (!input) {31 return32 }33 const productModuleService = container.resolve(34 "product"35 )36 await productModuleService.deleteProducts([input.product_id])37 }38)
TInvokeInput
objectOptionalTInvokeResultOutput
objectOptionalTInvokeResultCompensateInput
objectOptionalnameOrConfig
string | object & Omit<TransactionStepsDefinition, "next" | "uuid" | "action">invokeFn
InvokeFn<TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>StepResponse
constructor, the compensation function receives the first argument
passed to the StepResponse
constructor instead.StepFunction
StepFunction<TInvokeInput, TInvokeResultOutput>