@@ -1,5 +1,24 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
|
transform: {
|
||||||
|
"^.+\\.[jt]s$": [
|
||||||
|
"@swc/jest",
|
||||||
|
{
|
||||||
|
jsc: {
|
||||||
|
parser: {
|
||||||
|
syntax: "typescript",
|
||||||
|
decorators: true,
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
useDefineForClassFields: false,
|
||||||
|
legacyDecorator: true,
|
||||||
|
decoratorMetadata: true,
|
||||||
|
},
|
||||||
|
target: "ES2021",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
testPathIgnorePatterns: [`dist/`, `node_modules/`],
|
||||||
testEnvironment: `node`,
|
testEnvironment: `node`,
|
||||||
moduleFileExtensions: [`js`, `ts`],
|
moduleFileExtensions: [`js`, `ts`],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,29 +3,37 @@
|
|||||||
"version": "0.1.6",
|
"version": "0.1.6",
|
||||||
"description": "Set of workflows tooling for Medusa",
|
"description": "Set of workflows tooling for Medusa",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"exports": {
|
||||||
|
".": "./dist/index.js",
|
||||||
|
"./composer": "./dist/utils/composer/index.js"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/medusajs/medusa",
|
"url": "https://github.com/medusajs/medusa",
|
||||||
"directory": "packages/workflows"
|
"directory": "packages/workflows"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=20.0.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist",
|
||||||
|
"!dist/**/__tests__",
|
||||||
|
"!dist/**/__mocks__",
|
||||||
|
"!dist/**/__fixtures__"
|
||||||
],
|
],
|
||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "^1.11.16",
|
"@medusajs/types": "^1.11.16",
|
||||||
|
"@swc/jest": "^0.2.36",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"rimraf": "^5.0.1",
|
"rimraf": "^5.0.1",
|
||||||
"typescript": "^5.1.6"
|
"ts-jest": "^29.2.5",
|
||||||
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const workflow = createWorkflow(
|
|||||||
"sub-workflow",
|
"sub-workflow",
|
||||||
function (input: WorkflowData<{ outsideWorkflowData: string }>) {
|
function (input: WorkflowData<{ outsideWorkflowData: string }>) {
|
||||||
step1()
|
step1()
|
||||||
|
step2({ filters: { id: [] } })
|
||||||
const somethingHook = createHook("something", { id: "1" })
|
const somethingHook = createHook("something", { id: "1" })
|
||||||
step3()
|
step3()
|
||||||
return new WorkflowResponse({ id: 1 }, { hooks: [somethingHook] })
|
return new WorkflowResponse({ id: 1 }, { hooks: [somethingHook] })
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
WorkflowManager,
|
WorkflowManager,
|
||||||
WorkflowScheduler,
|
WorkflowScheduler,
|
||||||
} from "@medusajs/orchestration"
|
} from "@medusajs/orchestration"
|
||||||
|
import { IEventBusModuleService } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
Modules,
|
Modules,
|
||||||
composeMessage,
|
composeMessage,
|
||||||
@@ -138,14 +139,14 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -223,14 +224,14 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -331,14 +332,14 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -441,14 +442,14 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -557,14 +558,14 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation(function (...inputs) {
|
const mockStep2Fn = jest.fn().mockImplementation(function (...inputs) {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation(function (...inputs) {
|
const mockStep3Fn = jest.fn().mockImplementation(function (...inputs) {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -651,21 +652,21 @@ describe("Workflow composer", function () {
|
|||||||
return { inputs: [input], obj: "return from 1" }
|
return { inputs: [input], obj: "return from 1" }
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mockStep4Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep4Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 4",
|
obj: "return from 4",
|
||||||
@@ -1001,14 +1002,14 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -1093,6 +1094,7 @@ describe("Workflow composer", function () {
|
|||||||
if (!input) {
|
if (!input) {
|
||||||
return StepResponse.skip()
|
return StepResponse.skip()
|
||||||
}
|
}
|
||||||
|
return new StepResponse({ obj: "return from 2" })
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((inputs) => {
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
@@ -1140,7 +1142,7 @@ describe("Workflow composer", function () {
|
|||||||
obj: "return from 1",
|
obj: "return from 1",
|
||||||
},
|
},
|
||||||
two: {
|
two: {
|
||||||
__type: "Symbol(WorkflowWorkflowData)",
|
obj: "return from 2",
|
||||||
},
|
},
|
||||||
input: "none",
|
input: "none",
|
||||||
})
|
})
|
||||||
@@ -1151,7 +1153,7 @@ describe("Workflow composer", function () {
|
|||||||
obj: "return from 1",
|
obj: "return from 1",
|
||||||
},
|
},
|
||||||
two: {
|
two: {
|
||||||
__type: "Symbol(WorkflowWorkflowData)",
|
obj: "return from 2",
|
||||||
},
|
},
|
||||||
input: "none",
|
input: "none",
|
||||||
},
|
},
|
||||||
@@ -1164,14 +1166,14 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -1272,14 +1274,14 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -1382,14 +1384,14 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -1498,14 +1500,14 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation(function (...inputs) {
|
const mockStep2Fn = jest.fn().mockImplementation(function (...inputs) {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation(function (...inputs) {
|
const mockStep3Fn = jest.fn().mockImplementation(function (...inputs) {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
@@ -1592,21 +1594,21 @@ describe("Workflow composer", function () {
|
|||||||
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
return new StepResponse({ inputs: [input], obj: "return from 1" })
|
||||||
})
|
})
|
||||||
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep2Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 2",
|
obj: "return from 2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep3Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return new StepResponse({
|
return new StepResponse({
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 3",
|
obj: "return from 3",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const mockStep4Fn = jest.fn().mockImplementation((...inputs) => {
|
const mockStep4Fn = jest.fn().mockImplementation((...inputs) => {
|
||||||
const context = inputs.pop()
|
inputs.pop()
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
obj: "return from 4",
|
obj: "return from 4",
|
||||||
@@ -2147,7 +2149,12 @@ describe("Workflow composer", function () {
|
|||||||
expect(mockStep1Fn).toHaveBeenCalledTimes(1)
|
expect(mockStep1Fn).toHaveBeenCalledTimes(1)
|
||||||
expect(mockStep1Fn.mock.calls[0]).toHaveLength(2)
|
expect(mockStep1Fn.mock.calls[0]).toHaveLength(2)
|
||||||
|
|
||||||
const eventBusMock = container.resolve(Modules.EVENT_BUS)
|
const eventBusMock = container.resolve<
|
||||||
|
IEventBusModuleService & {
|
||||||
|
emit: jest.Mock<any, any, any>
|
||||||
|
releaseGroupedEvents: jest.Mock<any, any, any>
|
||||||
|
}
|
||||||
|
>(Modules.EVENT_BUS)
|
||||||
expect(eventBusMock.emit).toHaveBeenCalledTimes(1)
|
expect(eventBusMock.emit).toHaveBeenCalledTimes(1)
|
||||||
expect(eventBusMock.emit.mock.calls[0][0]).toEqual("event1")
|
expect(eventBusMock.emit.mock.calls[0][0]).toEqual("event1")
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createStep } from "../create-step"
|
import { createStep } from "../create-step"
|
||||||
import { createWorkflow } from "../create-workflow"
|
import { createWorkflow } from "../create-workflow"
|
||||||
import { StepResponse } from "../helpers"
|
import { StepResponse } from "../helpers"
|
||||||
|
import { WorkflowResponse } from "../helpers/workflow-response"
|
||||||
import { transform } from "../transform"
|
import { transform } from "../transform"
|
||||||
import { WorkflowData } from "../type"
|
import { WorkflowData } from "../type"
|
||||||
import { when } from "../when"
|
import { when } from "../when"
|
||||||
@@ -25,7 +26,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
step1()
|
step1()
|
||||||
return step2(input)
|
return new WorkflowResponse(step2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ describe("Workflow composer", () => {
|
|||||||
const subWorkflowRes = subWorkflow.runAsStep({
|
const subWorkflowRes = subWorkflow.runAsStep({
|
||||||
input: "hi from outside",
|
input: "hi from outside",
|
||||||
})
|
})
|
||||||
return step3(subWorkflowRes.result)
|
return new WorkflowResponse(step3(subWorkflowRes.result))
|
||||||
})
|
})
|
||||||
|
|
||||||
const { result } = await workflow.run({ input: {} })
|
const { result } = await workflow.run({ input: {} })
|
||||||
@@ -59,7 +60,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
step1()
|
step1()
|
||||||
return step2(input)
|
return new WorkflowResponse(step2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ describe("Workflow composer", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return step3(subWorkflowRes.result)
|
return new WorkflowResponse(step3(subWorkflowRes!.result))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
step1()
|
step1()
|
||||||
return step2(input)
|
return new WorkflowResponse(step2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ describe("Workflow composer", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return step3(subWorkflowRes.result)
|
return new WorkflowResponse(step3(subWorkflowRes!.result))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -169,7 +170,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
step1()
|
step1()
|
||||||
return step2(input)
|
return new WorkflowResponse(step2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ describe("Workflow composer", () => {
|
|||||||
input: "hi from outside",
|
input: "hi from outside",
|
||||||
})
|
})
|
||||||
step4WithError()
|
step4WithError()
|
||||||
return subWorkflowRes
|
return new WorkflowResponse(subWorkflowRes)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { errors } = await workflow.run({ throwOnError: false })
|
const { errors } = await workflow.run({ throwOnError: false })
|
||||||
@@ -219,7 +220,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
childWorkflowStep1()
|
childWorkflowStep1()
|
||||||
return childWorkflowStep2(input)
|
return new WorkflowResponse(childWorkflowStep2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -227,7 +228,7 @@ describe("Workflow composer", () => {
|
|||||||
const subWorkflowRes = subWorkflow.runAsStep({
|
const subWorkflowRes = subWorkflow.runAsStep({
|
||||||
input: "hi from outside",
|
input: "hi from outside",
|
||||||
})
|
})
|
||||||
return step1(subWorkflowRes.result)
|
return new WorkflowResponse(step1(subWorkflowRes.result))
|
||||||
})
|
})
|
||||||
|
|
||||||
const { result } = await workflow.run({
|
const { result } = await workflow.run({
|
||||||
@@ -271,7 +272,7 @@ describe("Workflow composer", () => {
|
|||||||
getNewWorkflowId(),
|
getNewWorkflowId(),
|
||||||
function (input: WorkflowData<string>) {
|
function (input: WorkflowData<string>) {
|
||||||
childWorkflowStep1()
|
childWorkflowStep1()
|
||||||
return childWorkflowStep2(input)
|
return new WorkflowResponse(childWorkflowStep2(input))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -279,7 +280,7 @@ describe("Workflow composer", () => {
|
|||||||
const subWorkflowRes = subWorkflow.runAsStep({
|
const subWorkflowRes = subWorkflow.runAsStep({
|
||||||
input: "hi from outside",
|
input: "hi from outside",
|
||||||
})
|
})
|
||||||
return step1(subWorkflowRes.result)
|
return new WorkflowResponse(step1(subWorkflowRes.result))
|
||||||
})
|
})
|
||||||
|
|
||||||
const { result } = await workflow.run({
|
const { result } = await workflow.run({
|
||||||
@@ -307,16 +308,19 @@ describe("Workflow composer", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const work = createWorkflow("id" as any, () => {
|
const work = createWorkflow("id" as any, () => {
|
||||||
const resStep1 = step1()
|
step1()
|
||||||
const resStep2 = step2()
|
const resStep2 = step2()
|
||||||
|
|
||||||
const transformedData = transform({ data: resStep2 }, (data) => {
|
const transformedData = transform({ data: resStep2 }, (data) => {
|
||||||
|
// @ts-expect-error "Since we are reading result from undefined"
|
||||||
return { result: data.data.result }
|
return { result: data.data.result }
|
||||||
})
|
})
|
||||||
|
|
||||||
return transform({ data: transformedData, resStep2 }, (data) => {
|
return new WorkflowResponse(
|
||||||
|
transform({ data: transformedData, resStep2 }, (data) => {
|
||||||
return { result: data.data }
|
return { result: data.data }
|
||||||
})
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { errors } = await work.run({ input: {}, throwOnError: false })
|
const { errors } = await work.run({ input: {}, throwOnError: false })
|
||||||
|
|||||||
@@ -4,27 +4,22 @@
|
|||||||
"target": "es2021",
|
"target": "es2021",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"declarationMap": true,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"strictFunctionTypes": true,
|
"strictFunctionTypes": true,
|
||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true
|
||||||
"downlevelIteration": true
|
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": [
|
"exclude": ["dist", "node_modules"]
|
||||||
"dist",
|
|
||||||
"./src/**/__tests__",
|
|
||||||
"./src/**/__mocks__",
|
|
||||||
"./src/**/__fixtures__",
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"include": ["src"],
|
|
||||||
"exclude": ["node_modules", "dist"]
|
|
||||||
}
|
|
||||||
+1
-1
@@ -3,7 +3,7 @@ import {
|
|||||||
createWorkflow,
|
createWorkflow,
|
||||||
StepResponse,
|
StepResponse,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { when } from "@medusajs/workflows-sdk/src/utils/composer"
|
import { when } from "@medusajs/workflows-sdk/composer"
|
||||||
|
|
||||||
const step_1 = createStep(
|
const step_1 = createStep(
|
||||||
"step_1",
|
"step_1",
|
||||||
|
|||||||
@@ -6824,10 +6824,12 @@ __metadata:
|
|||||||
"@medusajs/orchestration": ^0.5.7
|
"@medusajs/orchestration": ^0.5.7
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
|
"@swc/jest": ^0.2.36
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
rimraf: ^5.0.1
|
rimraf: ^5.0.1
|
||||||
typescript: ^5.1.6
|
ts-jest: ^29.2.5
|
||||||
|
typescript: ^5.6.2
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
awilix: ^8.0.1
|
awilix: ^8.0.1
|
||||||
ulid: ^2.3.0
|
ulid: ^2.3.0
|
||||||
@@ -16146,7 +16148,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"bs-logger@npm:0.x":
|
"bs-logger@npm:0.x, bs-logger@npm:^0.2.6":
|
||||||
version: 0.2.6
|
version: 0.2.6
|
||||||
resolution: "bs-logger@npm:0.2.6"
|
resolution: "bs-logger@npm:0.2.6"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -18814,7 +18816,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"ejs@npm:^3.1.8":
|
"ejs@npm:^3.1.10, ejs@npm:^3.1.8":
|
||||||
version: 3.1.10
|
version: 3.1.10
|
||||||
resolution: "ejs@npm:3.1.10"
|
resolution: "ejs@npm:3.1.10"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -24919,7 +24921,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"make-error@npm:1.x, make-error@npm:^1.1.1":
|
"make-error@npm:1.x, make-error@npm:^1.1.1, make-error@npm:^1.3.6":
|
||||||
version: 1.3.6
|
version: 1.3.6
|
||||||
resolution: "make-error@npm:1.3.6"
|
resolution: "make-error@npm:1.3.6"
|
||||||
checksum: 171e458d86854c6b3fc46610cfacf0b45149ba043782558c6875d9f42f222124384ad0b468c92e996d815a8a2003817a710c0a160e49c1c394626f76fa45396f
|
checksum: 171e458d86854c6b3fc46610cfacf0b45149ba043782558c6875d9f42f222124384ad0b468c92e996d815a8a2003817a710c0a160e49c1c394626f76fa45396f
|
||||||
@@ -30193,6 +30195,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"semver@npm:^7.6.3":
|
||||||
|
version: 7.6.3
|
||||||
|
resolution: "semver@npm:7.6.3"
|
||||||
|
bin:
|
||||||
|
semver: bin/semver.js
|
||||||
|
checksum: 88f33e148b210c153873cb08cfe1e281d518aaa9a666d4d148add6560db5cd3c582f3a08ccb91f38d5f379ead256da9931234ed122057f40bb5766e65e58adaf
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"semver@npm:~7.0.0":
|
"semver@npm:~7.0.0":
|
||||||
version: 7.0.0
|
version: 7.0.0
|
||||||
resolution: "semver@npm:7.0.0"
|
resolution: "semver@npm:7.0.0"
|
||||||
@@ -32133,6 +32144,43 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"ts-jest@npm:^29.2.5":
|
||||||
|
version: 29.2.5
|
||||||
|
resolution: "ts-jest@npm:29.2.5"
|
||||||
|
dependencies:
|
||||||
|
bs-logger: ^0.2.6
|
||||||
|
ejs: ^3.1.10
|
||||||
|
fast-json-stable-stringify: ^2.1.0
|
||||||
|
jest-util: ^29.0.0
|
||||||
|
json5: ^2.2.3
|
||||||
|
lodash.memoize: ^4.1.2
|
||||||
|
make-error: ^1.3.6
|
||||||
|
semver: ^7.6.3
|
||||||
|
yargs-parser: ^21.1.1
|
||||||
|
peerDependencies:
|
||||||
|
"@babel/core": ">=7.0.0-beta.0 <8"
|
||||||
|
"@jest/transform": ^29.0.0
|
||||||
|
"@jest/types": ^29.0.0
|
||||||
|
babel-jest: ^29.0.0
|
||||||
|
jest: ^29.0.0
|
||||||
|
typescript: ">=4.3 <6"
|
||||||
|
peerDependenciesMeta:
|
||||||
|
"@babel/core":
|
||||||
|
optional: true
|
||||||
|
"@jest/transform":
|
||||||
|
optional: true
|
||||||
|
"@jest/types":
|
||||||
|
optional: true
|
||||||
|
babel-jest:
|
||||||
|
optional: true
|
||||||
|
esbuild:
|
||||||
|
optional: true
|
||||||
|
bin:
|
||||||
|
ts-jest: cli.js
|
||||||
|
checksum: acb62d168faec073e64b20873b583974ba8acecdb94681164eb346cef82ade8fb481c5b979363e01a97ce4dd1e793baf64d9efd90720bc941ad7fc1c3d6f3f68
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"ts-log@npm:^2.2.3":
|
"ts-log@npm:^2.2.3":
|
||||||
version: 2.2.5
|
version: 2.2.5
|
||||||
resolution: "ts-log@npm:2.2.5"
|
resolution: "ts-log@npm:2.2.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user