import { createStep, createWorkflow, StepResponse, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" import { Modules } from "@medusajs/framework/utils" type FulfillDigitalItemsInput = { order_id: string items: { id: string; quantity: number }[] } /** * Registers a fulfillment on the order for digital items. * * Unlike createOrderFulfillmentWorkflow (which creates a physical fulfillment * record and requires a shipping method, provider, and stock location), this * step simply marks the specified items as fulfilled on the order using the * Order Module directly. */ const registerDigitalFulfillmentStep = createStep( "register-digital-fulfillment", async (input: FulfillDigitalItemsInput, { container }) => { const orderModule = container.resolve(Modules.ORDER) await orderModule.registerFulfillment({ order_id: input.order_id, items: input.items, }) return new StepResponse(void 0) } ) export const fulfillDigitalItemsWorkflow = createWorkflow( "fulfill-digital-items", function (input: FulfillDigitalItemsInput) { registerDigitalFulfillmentStep(input) return new WorkflowResponse(void 0) } )