@medusajs/workflow-engine-inmemory 0.0.3 → 0.0.4-next-20240429170320
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,6 +1,6 @@
|
|
|
1
1
|
import { DistributedTransaction, DistributedTransactionEvents, TransactionStep } from "@medusajs/orchestration";
|
|
2
2
|
import { ContainerLike, Context } from "@medusajs/types";
|
|
3
|
-
import { type FlowRunOptions
|
|
3
|
+
import { ReturnWorkflow, type FlowRunOptions } from "@medusajs/workflows-sdk";
|
|
4
4
|
import { InMemoryDistributedTransactionStorage } from "../utils";
|
|
5
5
|
export type WorkflowOrchestratorRunOptions<T> = FlowRunOptions<T> & {
|
|
6
6
|
transactionId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-orchestrator.d.ts","sourceRoot":"","sources":["../../src/services/workflow-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAE5B,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAmB,MAAM,iBAAiB,CAAA;AAEzE,OAAO,
|
|
1
|
+
{"version":3,"file":"workflow-orchestrator.d.ts","sourceRoot":"","sources":["../../src/services/workflow-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAE5B,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAmB,MAAM,iBAAiB,CAAA;AAEzE,OAAO,EAEL,cAAc,EAEd,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAA;AAEhE,MAAM,MAAM,8BAA8B,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG;IAClE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,E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.onStepBegin?.({ step, transaction });
|
|
260
260
|
notify({ eventType: "onStepBegin", step });
|
|
261
261
|
},
|
|
262
|
-
onStepSuccess: ({ step, transaction }) => {
|
|
263
|
-
const
|
|
262
|
+
onStepSuccess: async ({ step, transaction }) => {
|
|
263
|
+
const stepName = step.definition.action;
|
|
264
|
+
const response = await (0, workflows_sdk_1.resolveValue)(transaction.getContext().invoke[stepName], transaction);
|
|
264
265
|
customEventHandlers?.onStepSuccess?.({ step, transaction, response });
|
|
265
266
|
notify({ eventType: "onStepSuccess", step, response });
|
|
266
267
|
},
|
|
267
268
|
onStepFailure: ({ step, transaction }) => {
|
|
268
|
-
const
|
|
269
|
+
const stepName = step.definition.action;
|
|
270
|
+
const errors = transaction
|
|
271
|
+
.getErrors(orchestration_1.TransactionHandlerType.INVOKE)
|
|
272
|
+
.filter((err) => err.action === stepName);
|
|
269
273
|
customEventHandlers?.onStepFailure?.({ step, transaction, errors });
|
|
270
274
|
notify({ eventType: "onStepFailure", step, errors });
|
|
271
275
|
},
|
|
276
|
+
onStepAwaiting: ({ step, transaction }) => {
|
|
277
|
+
customEventHandlers?.onStepAwaiting?.({ step, transaction });
|
|
278
|
+
notify({ eventType: "onStepAwaiting", step });
|
|
279
|
+
},
|
|
272
280
|
onCompensateStepSuccess: ({ step, transaction }) => {
|
|
273
|
-
const
|
|
274
|
-
|
|
281
|
+
const stepName = step.definition.action;
|
|
282
|
+
const response = transaction.getContext().compensate[stepName];
|
|
283
|
+
customEventHandlers?.onCompensateStepSuccess?.({
|
|
284
|
+
step,
|
|
285
|
+
transaction,
|
|
286
|
+
response,
|
|
287
|
+
});
|
|
275
288
|
notify({ eventType: "onCompensateStepSuccess", step, response });
|
|
276
289
|
},
|
|
277
290
|
onCompensateStepFailure: ({ step, transaction }) => {
|
|
278
|
-
const
|
|
291
|
+
const stepName = step.definition.action;
|
|
292
|
+
const errors = transaction
|
|
293
|
+
.getErrors(orchestration_1.TransactionHandlerType.COMPENSATE)
|
|
294
|
+
.filter((err) => err.action === stepName);
|
|
279
295
|
customEventHandlers?.onStepFailure?.({ step, transaction, errors });
|
|
280
296
|
notify({ eventType: "onCompensateStepFailure", step, errors });
|
|
281
297
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/workflow-engine-inmemory",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-next-20240429170320",
|
|
4
4
|
"description": "Medusa Workflow Orchestrator module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
26
26
|
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
|
27
27
|
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
|
28
|
-
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src
|
|
28
|
+
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src",
|
|
29
29
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
30
30
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
|
31
31
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@mikro-orm/cli": "5.9.7",
|
|
38
38
|
"cross-env": "^5.2.1",
|
|
39
39
|
"jest": "^29.6.3",
|
|
40
|
-
"medusa-test-utils": "
|
|
40
|
+
"medusa-test-utils": "1.1.44-next-20240429170320",
|
|
41
41
|
"rimraf": "^3.0.2",
|
|
42
42
|
"ts-jest": "^29.1.1",
|
|
43
43
|
"ts-node": "^10.9.1",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"typescript": "^5.1.6"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@medusajs/modules-sdk": "
|
|
49
|
-
"@medusajs/types": "
|
|
50
|
-
"@medusajs/utils": "
|
|
51
|
-
"@medusajs/workflows-sdk": "
|
|
48
|
+
"@medusajs/modules-sdk": "1.12.11-next-20240429170320",
|
|
49
|
+
"@medusajs/types": "1.12.0-next-20240429170320",
|
|
50
|
+
"@medusajs/utils": "1.12.0-next-20240429170320",
|
|
51
|
+
"@medusajs/workflows-sdk": "0.1.6-next-20240429170320",
|
|
52
52
|
"@mikro-orm/core": "5.9.7",
|
|
53
53
|
"@mikro-orm/migrations": "5.9.7",
|
|
54
54
|
"@mikro-orm/postgresql": "5.9.7",
|