@medusajs/workflows-sdk 2.7.2-preview-20250509060146 → 2.7.2-preview-20250509120143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +1,40 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const zod_1 = require("zod");
|
4
3
|
const composer_1 = require("./composer");
|
5
4
|
const create_hook_1 = require("./composer/create-hook");
|
6
5
|
const workflow_response_1 = require("./composer/helpers/workflow-response");
|
7
|
-
const step1 = (0, composer_1.createStep)("step1",
|
8
|
-
return new composer_1.StepResponse(
|
9
|
-
})
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const
|
20
|
-
|
21
|
-
});
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}),
|
6
|
+
const step1 = (0, composer_1.createStep)("step1", () => {
|
7
|
+
return new composer_1.StepResponse("step1");
|
8
|
+
}, () => {
|
9
|
+
console.log("compensate step1");
|
10
|
+
});
|
11
|
+
const step2 = (0, composer_1.createStep)("step2", (input) => {
|
12
|
+
return new composer_1.StepResponse(input);
|
13
|
+
}, (input) => {
|
14
|
+
console.log("compensate step2", input);
|
15
|
+
});
|
16
|
+
const workflow = (0, composer_1.createWorkflow)("workflow", () => {
|
17
|
+
const step1Result = step1();
|
18
|
+
const step2Input = (0, composer_1.transform)({ step1Result }, (input) => {
|
19
|
+
return input;
|
20
|
+
});
|
21
|
+
const step2Result = step2(step2Input);
|
22
|
+
const hook = (0, create_hook_1.createHook)("hook", {
|
23
|
+
step2Result,
|
24
|
+
});
|
25
|
+
return new workflow_response_1.WorkflowResponse(void 0, {
|
26
|
+
hooks: [hook],
|
29
27
|
});
|
30
|
-
const step4Result = step4().config({ name: "foo" });
|
31
|
-
step4Result;
|
32
|
-
const step5Result = step5().config({ name: "foo" });
|
33
|
-
step5Result;
|
34
|
-
return new workflow_response_1.WorkflowResponse({ r: somethingHook.getResult(), step3: step3() }, { hooks: [somethingHook] });
|
35
|
-
});
|
36
|
-
workflow.hooks.something((input, context) => {
|
37
|
-
console.log("input>", input);
|
38
|
-
console.log("context>", context);
|
39
|
-
return new composer_1.StepResponse({ id: 2, foo: "bar" });
|
40
28
|
});
|
41
|
-
workflow.
|
42
|
-
|
29
|
+
workflow.hooks.hook(() => {
|
30
|
+
throw new Error("hook failed");
|
43
31
|
});
|
44
|
-
/*const workflow2 = createWorkflow("workflow", function () {
|
45
|
-
const step1Res = step1()
|
46
|
-
|
47
|
-
const step3Res = when({ value: true }, ({ value }) => {
|
48
|
-
return value
|
49
|
-
}).then(() => {
|
50
|
-
return step3()
|
51
|
-
})
|
52
|
-
|
53
|
-
transform({ step3Res }, ({ step3Res }) => {
|
54
|
-
console.log(step3Res)
|
55
|
-
})
|
56
|
-
|
57
|
-
const workflowRes = workflow.asStep({ outsideWorkflowData: step1Res.step1 })
|
58
|
-
|
59
|
-
return workflowRes
|
60
|
-
})*/
|
61
|
-
// workflow()
|
62
|
-
// .run({})
|
63
|
-
// .then((res) => {
|
64
|
-
// console.log(res.result)
|
65
|
-
// })
|
66
|
-
/*const step1 = createStep("step1", async (input: {}, context) => {
|
67
|
-
return new StepResponse({ step1: ["step1"] })
|
68
|
-
})
|
69
|
-
|
70
|
-
const step2 = createStep("step2", async (input: string[], context) => {
|
71
|
-
return new StepResponse({ step2: input })
|
72
|
-
})
|
73
|
-
|
74
|
-
const step3 = createStep("step3", async () => {
|
75
|
-
return new StepResponse({ step3: "step3" })
|
76
|
-
})
|
77
|
-
|
78
|
-
const workflow = createWorkflow("workflow", function () {
|
79
|
-
const step1Res = step1()
|
80
|
-
step3()
|
81
|
-
return step2(step1Res.step1)
|
82
|
-
})
|
83
|
-
|
84
32
|
workflow()
|
85
|
-
|
86
|
-
|
87
|
-
console.log(res
|
88
|
-
|
33
|
+
.run()
|
34
|
+
.then((res) => {
|
35
|
+
console.log(res);
|
36
|
+
})
|
37
|
+
.catch((e) => {
|
38
|
+
console.log(e);
|
39
|
+
});
|
89
40
|
//# sourceMappingURL=_playground.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"_playground.js","sourceRoot":"","sources":["../../src/utils/_playground.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"_playground.js","sourceRoot":"","sources":["../../src/utils/_playground.ts"],"names":[],"mappings":";;AAAA,yCAAgF;AAChF,wDAAmD;AACnD,4EAAuE;AAEvE,MAAM,KAAK,GAAG,IAAA,qBAAU,EACtB,OAAO,EACP,GAAG,EAAE;IACH,OAAO,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAA;AAClC,CAAC,EACD,GAAG,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AACjC,CAAC,CACF,CAAA;AAED,MAAM,KAAK,GAAG,IAAA,qBAAU,EACtB,OAAO,EACP,CAAC,KAAU,EAAE,EAAE;IACb,OAAO,IAAI,uBAAY,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;AACxC,CAAC,CACF,CAAA;AAED,MAAM,QAAQ,GAAG,IAAA,yBAAc,EAAC,UAAU,EAAE,GAAG,EAAE;IAC/C,MAAM,WAAW,GAAG,KAAK,EAAE,CAAA;IAE3B,MAAM,UAAU,GAAG,IAAA,oBAAS,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;QACtD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAA;IAErC,MAAM,IAAI,GAAG,IAAA,wBAAU,EAAC,MAAM,EAAE;QAC9B,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,IAAI,oCAAgB,CAAC,KAAK,CAAC,EAAE;QAClC,KAAK,EAAE,CAAC,IAAI,CAAC;KACd,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;IACvB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;AAChC,CAAC,CAAC,CAAA;AAEF,QAAQ,EAAE;KACP,GAAG,EAAE;KACL,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/workflows-sdk",
|
3
|
-
"version": "2.7.2-preview-
|
3
|
+
"version": "2.7.2-preview-20250509120143",
|
4
4
|
"description": "Set of workflows tooling for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"exports": {
|
@@ -42,10 +42,10 @@
|
|
42
42
|
"zod": "3.22.4"
|
43
43
|
},
|
44
44
|
"dependencies": {
|
45
|
-
"@medusajs/modules-sdk": "2.7.2-preview-
|
46
|
-
"@medusajs/orchestration": "2.7.2-preview-
|
47
|
-
"@medusajs/types": "2.7.2-preview-
|
48
|
-
"@medusajs/utils": "2.7.2-preview-
|
45
|
+
"@medusajs/modules-sdk": "2.7.2-preview-20250509120143",
|
46
|
+
"@medusajs/orchestration": "2.7.2-preview-20250509120143",
|
47
|
+
"@medusajs/types": "2.7.2-preview-20250509120143",
|
48
|
+
"@medusajs/utils": "2.7.2-preview-20250509120143",
|
49
49
|
"ulid": "^2.3.0"
|
50
50
|
},
|
51
51
|
"peerDependencies": {
|