-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(workflows-sdk): name for when/then step (#10459)
- Loading branch information
1 parent
7ff3f15
commit 90ae187
Showing
14 changed files
with
234 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@medusajs/workflow-engine-redis": patch | ||
"@medusajs/workflows-sdk": patch | ||
"@medusajs/core-flows": patch | ||
"@medusajs/utils": patch | ||
--- | ||
|
||
fix: when/then step name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/modules/workflow-engine-redis/integration-tests/__fixtures__/workflow_when.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
createStep, | ||
createWorkflow, | ||
StepResponse, | ||
when, | ||
WorkflowData, | ||
WorkflowResponse, | ||
} from "@medusajs/framework/workflows-sdk" | ||
|
||
const step1 = createStep( | ||
{ | ||
name: "step1", | ||
async: true, | ||
}, | ||
async (_, context) => { | ||
await new Promise((resolve) => setTimeout(resolve, 2000)) | ||
return new StepResponse({ result: "step1" }) | ||
} | ||
) | ||
const step2 = createStep("step2", async (input: string, context) => { | ||
return new StepResponse({ result: input }) | ||
}) | ||
const step3 = createStep( | ||
"step3", | ||
async (input: string | undefined, context) => { | ||
return new StepResponse({ result: input ?? "default response" }) | ||
} | ||
) | ||
|
||
const subWorkflow = createWorkflow( | ||
"wf-when-sub", | ||
function (input: WorkflowData<string>) { | ||
return new WorkflowResponse(step2(input)) | ||
} | ||
) | ||
|
||
createWorkflow("wf-when", function (input: { callSubFlow: boolean }) { | ||
step1() | ||
const subWorkflowRes = when("sub-flow", { input }, ({ input }) => { | ||
return input.callSubFlow | ||
}).then(() => { | ||
const res = subWorkflow.runAsStep({ | ||
input: "hi from outside", | ||
}) | ||
|
||
return { | ||
result: res, | ||
} | ||
}) as any | ||
|
||
return new WorkflowResponse(step3(subWorkflowRes.result)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.