@medusajs/workflows-sdk 0.1.2 → 0.1.3-next-20240208080225
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.
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.exportWorkflow = void 0;
|
|
4
4
|
const orchestration_1 = require("@medusajs/orchestration");
|
|
5
5
|
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
6
|
+
const utils_1 = require("@medusajs/utils");
|
|
6
7
|
const os_1 = require("os");
|
|
7
8
|
const ulid_1 = require("ulid");
|
|
8
9
|
const medusa_workflow_1 = require("../medusa-workflow");
|
|
@@ -38,12 +39,17 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, dataPrepara
|
|
|
38
39
|
result,
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
|
-
const newRun = async ({ input, context, throwOnError, resultFrom, events } = {
|
|
42
|
+
const newRun = async ({ input, context: outerContext, throwOnError, resultFrom, events, } = {
|
|
42
43
|
throwOnError: true,
|
|
43
44
|
resultFrom: defaultResult,
|
|
44
45
|
}) => {
|
|
45
46
|
resultFrom ?? (resultFrom = defaultResult);
|
|
46
47
|
throwOnError ?? (throwOnError = true);
|
|
48
|
+
const context = {
|
|
49
|
+
...outerContext,
|
|
50
|
+
__type: utils_1.MedusaContextType,
|
|
51
|
+
};
|
|
52
|
+
context.transactionId ?? (context.transactionId = (0, ulid_1.ulid)());
|
|
47
53
|
if (typeof dataPreparation === "function") {
|
|
48
54
|
try {
|
|
49
55
|
const copyInput = input ? JSON.parse(JSON.stringify(input)) : input;
|
|
@@ -58,26 +64,38 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, dataPrepara
|
|
|
58
64
|
};
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
return await originalExecution(originalRun, { throwOnError, resultFrom }, context
|
|
67
|
+
return await originalExecution(originalRun, { throwOnError, resultFrom }, context.transactionId, input, context, events);
|
|
62
68
|
};
|
|
63
69
|
flow.run = newRun;
|
|
64
|
-
const newRegisterStepSuccess = async ({ response, idempotencyKey, context, throwOnError, resultFrom, events, } = {
|
|
70
|
+
const newRegisterStepSuccess = async ({ response, idempotencyKey, context: outerContext, throwOnError, resultFrom, events, } = {
|
|
65
71
|
idempotencyKey: "",
|
|
66
72
|
throwOnError: true,
|
|
67
73
|
resultFrom: defaultResult,
|
|
68
74
|
}) => {
|
|
69
75
|
resultFrom ?? (resultFrom = defaultResult);
|
|
70
76
|
throwOnError ?? (throwOnError = true);
|
|
77
|
+
const [, transactionId] = idempotencyKey.split(":");
|
|
78
|
+
const context = {
|
|
79
|
+
...outerContext,
|
|
80
|
+
transactionId,
|
|
81
|
+
__type: utils_1.MedusaContextType,
|
|
82
|
+
};
|
|
71
83
|
return await originalExecution(originalRegisterStepSuccess, { throwOnError, resultFrom }, idempotencyKey, response, context, events);
|
|
72
84
|
};
|
|
73
85
|
flow.registerStepSuccess = newRegisterStepSuccess;
|
|
74
|
-
const newRegisterStepFailure = async ({ response, idempotencyKey, context, throwOnError, resultFrom, events, } = {
|
|
86
|
+
const newRegisterStepFailure = async ({ response, idempotencyKey, context: outerContext, throwOnError, resultFrom, events, } = {
|
|
75
87
|
idempotencyKey: "",
|
|
76
88
|
throwOnError: true,
|
|
77
89
|
resultFrom: defaultResult,
|
|
78
90
|
}) => {
|
|
79
91
|
resultFrom ?? (resultFrom = defaultResult);
|
|
80
92
|
throwOnError ?? (throwOnError = true);
|
|
93
|
+
const [, transactionId] = idempotencyKey.split(":");
|
|
94
|
+
const context = {
|
|
95
|
+
...outerContext,
|
|
96
|
+
transactionId,
|
|
97
|
+
__type: utils_1.MedusaContextType,
|
|
98
|
+
};
|
|
81
99
|
return await originalExecution(originalRegisterStepFailure, { throwOnError, resultFrom }, idempotencyKey, response, context, events);
|
|
82
100
|
};
|
|
83
101
|
flow.registerStepFailure = newRegisterStepFailure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-export.js","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":";;;AAAA,2DAOgC;AAGhC,uDAAoD;AACpD,2BAAwB;AACxB,+BAA2B;AAC3B,wDAAmD;AACnD,gDAAgD;AAwHhD,SAAS,8BAA8B,CAKrC,EACA,UAAU,EACV,aAAa,EACb,eAAe,EACf,OAAO,EACP,SAAS,GASV;IAEC,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,0BAAY,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAC7C,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,CAAA;KACF;IAED,MAAM,IAAI,GAAG,IAAI,6BAAa,CAAC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"workflow-export.js","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":";;;AAAA,2DAOgC;AAGhC,uDAAoD;AACpD,2CAAmD;AACnD,2BAAwB;AACxB,+BAA2B;AAC3B,wDAAmD;AACnD,gDAAgD;AAwHhD,SAAS,8BAA8B,CAKrC,EACA,UAAU,EACV,aAAa,EACb,eAAe,EACf,OAAO,EACP,SAAS,GASV;IAEC,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,0BAAY,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAC7C,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,CAAA;KACF;IAED,MAAM,IAAI,GAAG,IAAI,6BAAa,CAAC,UAAU,EAAE,SAAU,CAAC,CAAA;IAEtD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvC,MAAM,2BAA2B,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvE,MAAM,2BAA2B,GAA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AKxB,qBAAqB,EACrB,SAAS,CACV,CAAC,SAAS,CAAC,CAAA;IACd,CAAC,CAAA;IAED,gCAAc,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAA;IAC7D,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AArJY,QAAA,cAAc,kBAqJ1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/workflows-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-next-20240208080225",
|
|
4
4
|
"description": "Set of workflows tooling for Medusa",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "Medusa",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@medusajs/types": "
|
|
24
|
+
"@medusajs/types": "1.11.12-next-20240208080225",
|
|
25
25
|
"cross-env": "^5.2.1",
|
|
26
26
|
"jest": "^29.6.3",
|
|
27
27
|
"rimraf": "^5.0.1",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"typescript": "^5.1.6"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@medusajs/modules-sdk": "
|
|
33
|
-
"@medusajs/orchestration": "
|
|
34
|
-
"@medusajs/utils": "
|
|
32
|
+
"@medusajs/modules-sdk": "1.12.8-next-20240208080225",
|
|
33
|
+
"@medusajs/orchestration": "0.5.4-next-20240208080225",
|
|
34
|
+
"@medusajs/utils": "1.11.5-next-20240208080225",
|
|
35
35
|
"awilix": "^8.0.1",
|
|
36
36
|
"ulid": "^2.3.0"
|
|
37
37
|
},
|