chore(workflows-sdk): fix examples in TSDocs (#11689)

This commit is contained in:
Shahed Nasser
2025-03-03 12:20:21 +02:00
committed by GitHub
parent d1efad9bf0
commit 61a0e4f3cf
4 changed files with 27 additions and 25 deletions
@@ -334,21 +334,21 @@ function wrapConditionalStep(
* createStep, * createStep,
* StepResponse * StepResponse
* } from "@medusajs/framework/workflows-sdk" * } from "@medusajs/framework/workflows-sdk"
* *
* interface CreateProductInput { * interface CreateProductInput {
* title: string * title: string
* } * }
* *
* export const createProductStep = createStep( * export const createProductStep = createStep(
* "createProductStep", * "createProductStep",
* async function ( * async function (
* input: CreateProductInput, * input: CreateProductInput,
* context * { container }
* ) { * ) {
* const productService = context.container.resolve( * const productModuleService = container.resolve(
* "productService" * "product"
* ) * )
* const product = await productService.createProducts(input) * const product = await productModuleService.createProducts(input)
* return new StepResponse({ * return new StepResponse({
* product * product
* }, { * }, {
@@ -357,12 +357,15 @@ function wrapConditionalStep(
* }, * },
* async function ( * async function (
* input, * input,
* context * { container }
* ) { * ) {
* const productService = context.container.resolve( * if (!input) {
* "productService" * return
* }
* const productModuleService = container.resolve(
* "product"
* ) * )
* await productService.deleteProducts(input.product_id) * await productModuleService.deleteProducts([input.product_id])
* } * }
* ) * )
*/ */
@@ -46,25 +46,23 @@ global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext] = null
* import { * import {
* createProductStep, * createProductStep,
* getProductStep, * getProductStep,
* createPricesStep
* } from "./steps" * } from "./steps"
* *
* interface WorkflowInput { * interface WorkflowInput {
* title: string * title: string
* } * }
* *
* const myWorkflow = createWorkflow( * const myWorkflow = createWorkflow(
* "my-workflow", * "my-workflow",
* (input: WorkflowInput) => { * (input: WorkflowInput) => {
* // Everything here will be executed and resolved later * // Everything here will be executed and resolved later
* // during the execution. Including the data access. * // during the execution. Including the data access.
* *
* const product = createProductStep(input) * const product = createProductStep(input)
* const prices = createPricesStep(product)
* return new WorkflowResponse(getProductStep(product.id)) * return new WorkflowResponse(getProductStep(product.id))
* } * }
* ) * )
* *
* export async function GET( * export async function GET(
* req: MedusaRequest, * req: MedusaRequest,
* res: MedusaResponse * res: MedusaResponse
@@ -75,7 +73,7 @@ global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext] = null
* title: "Shirt" * title: "Shirt"
* } * }
* }) * })
* *
* res.json({ * res.json({
* product * product
* }) * })
@@ -16,27 +16,28 @@ import { OrchestrationUtils } from "@medusajs/utils"
* } from "@medusajs/framework/workflows-sdk" * } from "@medusajs/framework/workflows-sdk"
* import { * import {
* createProductStep, * createProductStep,
* getProductStep,
* createPricesStep, * createPricesStep,
* attachProductToSalesChannelStep * attachProductToSalesChannelStep
* } from "./steps" * } from "./steps"
* *
* interface WorkflowInput { * interface WorkflowInput {
* title: string * title: string
* } * }
* *
* const myWorkflow = createWorkflow( * const myWorkflow = createWorkflow(
* "my-workflow", * "my-workflow",
* (input: WorkflowInput) => { * (input: WorkflowInput) => {
* const product = createProductStep(input) * const product = createProductStep(input)
* *
* const [prices, productSalesChannel] = parallelize( * const [prices, productSalesChannel] = parallelize(
* createPricesStep(product), * createPricesStep(product),
* attachProductToSalesChannelStep(product) * attachProductToSalesChannelStep(product)
* ) * )
* *
* const id = product.id * return new WorkflowResponse({
* return new WorkflowResponse(getProductStep(product.id)) * prices,
* productSalesChannel
* })
* } * }
* ) * )
*/ */
@@ -36,7 +36,7 @@ type ThenFunc = <ThenResolver extends () => any>(
* } from "@medusajs/framework/workflows-sdk" * } from "@medusajs/framework/workflows-sdk"
* // step imports... * // step imports...
* *
* const workflow = createWorkflow( * export const workflow = createWorkflow(
* "workflow", * "workflow",
* function (input: { * function (input: {
* is_active: boolean * is_active: boolean