medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.93k stars 2.6k forks source link

pass inputs to steps documentation not up to date with preview #9110

Closed Slepzs closed 2 months ago

Slepzs commented 2 months ago

What Medusa version and documentation are you using?

v2

Preliminary Checks

Issue Summary

After new changes to @medusajs/workflows-sdk. There has to be added more to the introduction example to have it working without type issues.

https://docs.medusajs.com/development/workflows#pass-inputs-to-steps

issue:

  1. typescript: Expected 3 type arguments, but got 2
  2. Argument of type '(input: WorkflowData) => WorkflowData<{ message: string; }>' is not assignable to parameter of type '(input: WorkflowData) => void | WorkflowResponse<WorkflowOutput, any[]
const myWorkflow = createWorkflow<WorkflowInput, WorkflowOutput, any[]>(
  "hello-world",
  function(input) {
    const str1 = step1();
    const str2 = step2(input);

    const result = transform(
      {
        str1,
        str2,
      },
      (input) => ({
        message: `${input.str1}\n${input.str2}`,
      }),
    );

    return new WorkflowResponse(result);
  },
);

How can this issue be resolved?

  1. add any[] as third agurment to createWorkflow type
  2. return result as new WorkflowResponse
  3. import workflowResponse ...

Are you interested in working on this issue?

shahednasser commented 2 months ago

Hi @Slepzs , the link you shared the Medusa v1 documentation. Instead, you should be using the Medusa v2 documentation here:

https://docs.medusajs.com/v2/basics/workflows

Closing this issue, feel free to follow up with additional comments

Slepzs commented 2 months ago

Ah my bad, and thanks!