@medusajs/workflows-sdk 0.2.0-next-20231124140416

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.
Files changed (55) hide show
  1. package/dist/helper/empty-handler.d.ts +1 -0
  2. package/dist/helper/empty-handler.js +6 -0
  3. package/dist/helper/empty-handler.js.map +1 -0
  4. package/dist/helper/index.d.ts +4 -0
  5. package/dist/helper/index.js +21 -0
  6. package/dist/helper/index.js.map +1 -0
  7. package/dist/helper/merge-data.d.ts +8 -0
  8. package/dist/helper/merge-data.js +47 -0
  9. package/dist/helper/merge-data.js.map +1 -0
  10. package/dist/helper/pipe.d.ts +52 -0
  11. package/dist/helper/pipe.js +80 -0
  12. package/dist/helper/pipe.js.map +1 -0
  13. package/dist/helper/workflow-export.d.ts +16 -0
  14. package/dist/helper/workflow-export.js +69 -0
  15. package/dist/helper/workflow-export.js.map +1 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.js +33 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/utils/composer/create-step.d.ts +105 -0
  20. package/dist/utils/composer/create-step.js +153 -0
  21. package/dist/utils/composer/create-step.js.map +1 -0
  22. package/dist/utils/composer/create-workflow.d.ts +124 -0
  23. package/dist/utils/composer/create-workflow.js +136 -0
  24. package/dist/utils/composer/create-workflow.js.map +1 -0
  25. package/dist/utils/composer/helpers/index.d.ts +3 -0
  26. package/dist/utils/composer/helpers/index.js +20 -0
  27. package/dist/utils/composer/helpers/index.js.map +1 -0
  28. package/dist/utils/composer/helpers/proxy.d.ts +2 -0
  29. package/dist/utils/composer/helpers/proxy.js +27 -0
  30. package/dist/utils/composer/helpers/proxy.js.map +1 -0
  31. package/dist/utils/composer/helpers/resolve-value.d.ts +4 -0
  32. package/dist/utils/composer/helpers/resolve-value.js +59 -0
  33. package/dist/utils/composer/helpers/resolve-value.js.map +1 -0
  34. package/dist/utils/composer/helpers/step-response.d.ts +48 -0
  35. package/dist/utils/composer/helpers/step-response.js +80 -0
  36. package/dist/utils/composer/helpers/step-response.js.map +1 -0
  37. package/dist/utils/composer/helpers/symbol.d.ts +8 -0
  38. package/dist/utils/composer/helpers/symbol.js +12 -0
  39. package/dist/utils/composer/helpers/symbol.js.map +1 -0
  40. package/dist/utils/composer/hook.d.ts +94 -0
  41. package/dist/utils/composer/hook.js +125 -0
  42. package/dist/utils/composer/hook.js.map +1 -0
  43. package/dist/utils/composer/index.d.ts +9 -0
  44. package/dist/utils/composer/index.js +26 -0
  45. package/dist/utils/composer/index.js.map +1 -0
  46. package/dist/utils/composer/parallelize.d.ts +42 -0
  47. package/dist/utils/composer/parallelize.js +58 -0
  48. package/dist/utils/composer/parallelize.js.map +1 -0
  49. package/dist/utils/composer/transform.d.ts +83 -0
  50. package/dist/utils/composer/transform.js +29 -0
  51. package/dist/utils/composer/transform.js.map +1 -0
  52. package/dist/utils/composer/type.d.ts +70 -0
  53. package/dist/utils/composer/type.js +3 -0
  54. package/dist/utils/composer/type.js.map +1 -0
  55. package/package.json +41 -0
@@ -0,0 +1 @@
1
+ export declare const emptyHandler: any;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyHandler = void 0;
4
+ const emptyHandler = () => { };
5
+ exports.emptyHandler = emptyHandler;
6
+ //# sourceMappingURL=empty-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-handler.js","sourceRoot":"","sources":["../../src/helper/empty-handler.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAQ,GAAG,EAAE,GAAE,CAAC,CAAA;AAA5B,QAAA,YAAY,gBAAgB"}
@@ -0,0 +1,4 @@
1
+ export * from "./merge-data";
2
+ export * from "./empty-handler";
3
+ export * from "./pipe";
4
+ export * from "./workflow-export";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./merge-data"), exports);
18
+ __exportStar(require("./empty-handler"), exports);
19
+ __exportStar(require("./pipe"), exports);
20
+ __exportStar(require("./workflow-export"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,kDAA+B;AAC/B,yCAAsB;AACtB,oDAAiC"}
@@ -0,0 +1,8 @@
1
+ import { PipelineHandler } from "./pipe";
2
+ /**
3
+ * Pipe utils that merges data from an object into a new object.
4
+ * The new object will have a target key with the merged data from the keys if specified.
5
+ * @param keys
6
+ * @param target
7
+ */
8
+ export declare function mergeData<T extends Record<string, unknown> = Record<string, unknown>, TKeys extends keyof T = keyof T, Target extends "payload" | string = string>(keys?: TKeys[], target?: Target): PipelineHandler;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeData = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ /**
6
+ * Pipe utils that merges data from an object into a new object.
7
+ * The new object will have a target key with the merged data from the keys if specified.
8
+ * @param keys
9
+ * @param target
10
+ */
11
+ function mergeData(keys = [], target) {
12
+ return async function ({ data }) {
13
+ const workingKeys = (keys.length ? keys : Object.keys(data));
14
+ const value = workingKeys.reduce((acc, key) => {
15
+ let targetAcc = { ...(target ? acc[target] : acc) };
16
+ targetAcc ?? (targetAcc = {});
17
+ if (Array.isArray(data[key])) {
18
+ targetAcc[key] = data[key];
19
+ }
20
+ else if ((0, utils_1.isObject)(data[key])) {
21
+ targetAcc = {
22
+ ...targetAcc,
23
+ ...data[key],
24
+ };
25
+ }
26
+ else {
27
+ targetAcc[key] = data[key];
28
+ }
29
+ if (target) {
30
+ acc[target] = {
31
+ ...acc[target],
32
+ ...targetAcc,
33
+ };
34
+ }
35
+ else {
36
+ acc = targetAcc;
37
+ }
38
+ return acc;
39
+ }, {});
40
+ return {
41
+ alias: target,
42
+ value: target ? value[target] : value,
43
+ };
44
+ };
45
+ }
46
+ exports.mergeData = mergeData;
47
+ //# sourceMappingURL=merge-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-data.js","sourceRoot":"","sources":["../../src/helper/merge-data.ts"],"names":[],"mappings":";;;AACA,2CAA0C;AAE1C;;;;;GAKG;AACH,SAAgB,SAAS,CAIvB,OAAgB,EAAE,EAAE,MAAe;IACnC,OAAO,KAAK,WAAW,EAAE,IAAI,EAAwB;QACnD,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAY,CAAA;QACvE,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC5C,IAAI,SAAS,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;YAC7D,SAAS,KAAT,SAAS,GAAK,EAAE,EAAA;YAEhB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAa,CAAC,CAAC,EAAE;gBACtC,SAAS,CAAC,GAAa,CAAC,GAAG,IAAI,CAAC,GAAa,CAAC,CAAA;aAC/C;iBAAM,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,GAAa,CAAC,CAAC,EAAE;gBACxC,SAAS,GAAG;oBACV,GAAG,SAAS;oBACZ,GAAI,IAAI,CAAC,GAAa,CAAY;iBACnC,CAAA;aACF;iBAAM;gBACL,SAAS,CAAC,GAAa,CAAC,GAAG,IAAI,CAAC,GAAa,CAAC,CAAA;aAC/C;YAED,IAAI,MAAM,EAAE;gBACV,GAAG,CAAC,MAAgB,CAAC,GAAG;oBACtB,GAAG,GAAG,CAAC,MAAgB,CAAC;oBACxB,GAAG,SAAS;iBACb,CAAA;aACF;iBAAM;gBACL,GAAG,GAAG,SAAS,CAAA;aAChB;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,OAAO;YACL,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAgB,CAAC,CAAC,CAAC,CAAC,KAAK;SAChD,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAvCD,8BAuCC"}
@@ -0,0 +1,52 @@
1
+ import { DistributedTransaction, TransactionMetadata, WorkflowStepHandler } from "@medusajs/orchestration";
2
+ import { Context, MedusaContainer, SharedContext } from "@medusajs/types";
3
+ export type WorkflowStepMiddlewareReturn = {
4
+ alias?: string;
5
+ value: any;
6
+ };
7
+ export type WorkflowStepMiddlewareInput = {
8
+ from: string;
9
+ alias?: string;
10
+ };
11
+ interface PipelineInput {
12
+ /**
13
+ * The alias of the input data to store in
14
+ */
15
+ inputAlias?: string;
16
+ /**
17
+ * Descriptors to get the data from
18
+ */
19
+ invoke?: WorkflowStepMiddlewareInput | WorkflowStepMiddlewareInput[];
20
+ compensate?: WorkflowStepMiddlewareInput | WorkflowStepMiddlewareInput[];
21
+ onComplete?: (args: WorkflowOnCompleteArguments) => Promise<void>;
22
+ /**
23
+ * Apply the data merging
24
+ */
25
+ merge?: boolean;
26
+ /**
27
+ * Store the merged data in a new key, if this is present no need to set merge: true
28
+ */
29
+ mergeAlias?: string;
30
+ /**
31
+ * Store the merged data from the chosen aliases, if this is present no need to set merge: true
32
+ */
33
+ mergeFrom?: string[];
34
+ }
35
+ export type WorkflowArguments<T = any> = {
36
+ container: MedusaContainer;
37
+ payload: unknown;
38
+ data: T;
39
+ metadata: TransactionMetadata;
40
+ context: Context | SharedContext;
41
+ };
42
+ export type WorkflowOnCompleteArguments<T = any> = {
43
+ container: MedusaContainer;
44
+ payload: unknown;
45
+ data: T;
46
+ metadata: TransactionMetadata;
47
+ transaction: DistributedTransaction;
48
+ context: Context | SharedContext;
49
+ };
50
+ export type PipelineHandler<T extends any = undefined> = (args: WorkflowArguments) => Promise<T extends undefined ? WorkflowStepMiddlewareReturn | WorkflowStepMiddlewareReturn[] : T>;
51
+ export declare function pipe<T>(input: PipelineInput, ...functions: [...PipelineHandler[], PipelineHandler<T>]): WorkflowStepHandler;
52
+ export {};
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pipe = void 0;
4
+ const merge_data_1 = require("./merge-data");
5
+ function pipe(input, ...functions) {
6
+ // Apply the aggregator just before the last handler
7
+ if ((input.merge || input.mergeAlias || input.mergeFrom) &&
8
+ functions.length) {
9
+ const handler = functions.pop();
10
+ functions.push((0, merge_data_1.mergeData)(input.mergeFrom, input.mergeAlias), handler);
11
+ }
12
+ return async ({ container, payload, invoke, compensate, metadata, transaction, context, }) => {
13
+ let data = {};
14
+ const original = {
15
+ invoke: invoke ?? {},
16
+ compensate: compensate ?? {},
17
+ };
18
+ if (input.inputAlias) {
19
+ Object.assign(original.invoke, { [input.inputAlias]: payload });
20
+ }
21
+ const dataKeys = ["invoke", "compensate"];
22
+ for (const key of dataKeys) {
23
+ if (!input[key]) {
24
+ continue;
25
+ }
26
+ if (!Array.isArray(input[key])) {
27
+ input[key] = [input[key]];
28
+ }
29
+ for (const action of input[key]) {
30
+ if (action.alias) {
31
+ data[action.alias] = original[key][action.from];
32
+ }
33
+ else {
34
+ data[action.from] = original[key][action.from];
35
+ }
36
+ }
37
+ }
38
+ let finalResult;
39
+ for (const fn of functions) {
40
+ let result = await fn({
41
+ container,
42
+ payload,
43
+ data,
44
+ metadata,
45
+ context: context,
46
+ });
47
+ if (Array.isArray(result)) {
48
+ for (const action of result) {
49
+ if (action?.alias) {
50
+ data[action.alias] = action.value;
51
+ }
52
+ }
53
+ }
54
+ else if (result &&
55
+ "alias" in result) {
56
+ if (result.alias) {
57
+ data[result.alias] = result.value;
58
+ }
59
+ else {
60
+ data = result.value;
61
+ }
62
+ }
63
+ finalResult = result;
64
+ }
65
+ if (typeof input.onComplete === "function") {
66
+ const dataCopy = JSON.parse(JSON.stringify(data));
67
+ await input.onComplete({
68
+ container,
69
+ payload,
70
+ data: dataCopy,
71
+ metadata,
72
+ transaction,
73
+ context: context,
74
+ });
75
+ }
76
+ return finalResult;
77
+ };
78
+ }
79
+ exports.pipe = pipe;
80
+ //# sourceMappingURL=pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../src/helper/pipe.ts"],"names":[],"mappings":";;;AAMA,6CAAwC;AA8DxC,SAAgB,IAAI,CAClB,KAAoB,EACpB,GAAG,SAAqD;IAExD,oDAAoD;IACpD,IACE,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,SAAS,CAAC;QACpD,SAAS,CAAC,MAAM,EAChB;QACA,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,EAAG,CAAA;QAChC,SAAS,CAAC,IAAI,CAAC,IAAA,sBAAS,EAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAA;KACtE;IAED,OAAO,KAAK,EAAE,EACZ,SAAS,EACT,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAAQ,EACR,WAAW,EACX,O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AAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzB,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE;oBAC3B,IAAI,MAAM,EAAE,KAAK,EAAE;wBACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAA;qBAClC;iBACF;aACF;iBAAM,IACL,MAAM;gBACN,OAAO,IAAK,MAAuC,EACnD;gBACA,IAAK,MAAuC,CAAC,KAAK,EAAE;oBAClD,IAAI,CAAE,MAAuC,CAAC,KAAM,CAAC,GACnD,MACD,CAAC,KAAK,CAAA;iBACR;qBAAM;oBACL,IAAI,GAAI,MAAuC,CAAC,KAAK,CAAA;iBACtD;aACF;YAED,WAAW,GAAG,MAAM,CAAA;SACrB;QAED,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,EAAE;YAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;YACjD,MAAM,KAAK,CAAC,UAAU,CAAC;gBACrB,SAAS;gBACT,OAAO;gBACP,IAAI,EAAE,QAAQ;gBACd,QAAQ;gBACR,WAAW;gBACX,OAAO,EAAE,OAAkB;aAC5B,CAAC,CAAA;SACH;QAED,OAAO,WAAW,CAAA;IACpB,CAAC,CAAA;AACH,CAAC;AAlGD,oBAkGC"}
@@ -0,0 +1,16 @@
1
+ import { DistributedTransaction, LocalWorkflow, TransactionStepError } from "@medusajs/orchestration";
2
+ import { Context, LoadedModule, MedusaContainer } from "@medusajs/types";
3
+ export type FlowRunOptions<TData = unknown> = {
4
+ input?: TData;
5
+ context?: Context;
6
+ resultFrom?: string | string[];
7
+ throwOnError?: boolean;
8
+ };
9
+ export type WorkflowResult<TResult = unknown> = {
10
+ errors: TransactionStepError[];
11
+ transaction: DistributedTransaction;
12
+ result: TResult;
13
+ };
14
+ export declare const exportWorkflow: <TData = unknown, TResult = unknown>(workflowId: string, defaultResult?: string, dataPreparation?: ((data: TData) => Promise<unknown>) | undefined) => <TDataOverride = undefined, TResultOverride = undefined>(container?: LoadedModule[] | MedusaContainer) => Omit<LocalWorkflow, "run"> & {
15
+ run: (args?: FlowRunOptions<TDataOverride extends undefined ? TData : TDataOverride> | undefined) => Promise<WorkflowResult<TResultOverride extends undefined ? TResult : TResultOverride>>;
16
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportWorkflow = void 0;
4
+ const orchestration_1 = require("@medusajs/orchestration");
5
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
6
+ const os_1 = require("os");
7
+ const ulid_1 = require("ulid");
8
+ const composer_1 = require("../utils/composer");
9
+ const exportWorkflow = (workflowId, defaultResult, dataPreparation) => {
10
+ return function (container) {
11
+ if (!container) {
12
+ container = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.values(mod)[0]);
13
+ }
14
+ const flow = new orchestration_1.LocalWorkflow(workflowId, container);
15
+ const originalRun = flow.run.bind(flow);
16
+ const newRun = async ({ input, context, throwOnError, resultFrom } = {
17
+ throwOnError: true,
18
+ resultFrom: defaultResult,
19
+ }) => {
20
+ resultFrom ?? (resultFrom = defaultResult);
21
+ throwOnError ?? (throwOnError = true);
22
+ if (typeof dataPreparation === "function") {
23
+ try {
24
+ const copyInput = input ? JSON.parse(JSON.stringify(input)) : input;
25
+ input = await dataPreparation(copyInput);
26
+ }
27
+ catch (err) {
28
+ if (throwOnError) {
29
+ throw new Error(`Data preparation failed: ${err.message}${os_1.EOL}${err.stack}`);
30
+ }
31
+ return {
32
+ errors: [err],
33
+ };
34
+ }
35
+ }
36
+ const transaction = await originalRun(context?.transactionId ?? (0, ulid_1.ulid)(), input, context);
37
+ const errors = transaction.getErrors(orchestration_1.TransactionHandlerType.INVOKE);
38
+ const failedStatus = [orchestration_1.TransactionState.FAILED, orchestration_1.TransactionState.REVERTED];
39
+ if (failedStatus.includes(transaction.getState()) && throwOnError) {
40
+ const errorMessage = errors
41
+ ?.map((err) => `${err.error?.message}${os_1.EOL}${err.error?.stack}`)
42
+ ?.join(`${os_1.EOL}`);
43
+ throw new Error(errorMessage);
44
+ }
45
+ let result = undefined;
46
+ if (resultFrom) {
47
+ if (Array.isArray(resultFrom)) {
48
+ result = resultFrom.map((from) => {
49
+ const res = transaction.getContext().invoke?.[from];
50
+ return res?.__type === composer_1.SymbolWorkflowWorkflowData ? res.output : res;
51
+ });
52
+ }
53
+ else {
54
+ const res = transaction.getContext().invoke?.[resultFrom];
55
+ result = res?.__type === composer_1.SymbolWorkflowWorkflowData ? res.output : res;
56
+ }
57
+ }
58
+ return {
59
+ errors,
60
+ transaction,
61
+ result,
62
+ };
63
+ };
64
+ flow.run = newRun;
65
+ return flow;
66
+ };
67
+ };
68
+ exports.exportWorkflow = exportWorkflow;
69
+ //# sourceMappingURL=workflow-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-export.js","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":";;;AAAA,2DAMgC;AAGhC,uDAAoD;AACpD,2BAAwB;AACxB,+BAA2B;AAC3B,gDAA8D;AAevD,MAAM,cAAc,GAAG,CAC5B,UAAkB,EAClB,aAAsB,EACtB,eAAmD,EACnD,EAAE;IACF,OAAO,UACL,SAA4C;QAY5C,IAAI,CAAC,SAAS,EAAE;YACd,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;SACF;QAED,MAAM,IAAI,GAAG,IAAI,6BAAa,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;QAErD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvC,MAAM,MAAM,GAAG,KAAK,EAClB,EAAE,KAAK,EAAE,OA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AK,EAAE,CAAC;oBAChE,EAAE,IAAI,CAAC,GAAG,QAAG,EAAE,CAAC,CAAA;gBAClB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;aAC9B;YAED,IAAI,MAAM,GAAQ,SAAS,CAAA;YAE3B,IAAI,UAAU,EAAE;gBACd,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBAC7B,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;wBACnD,OAAO,GAAG,EAAE,MAAM,KAAK,qCAA0B,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAA;oBACtE,CAAC,CAAC,CAAA;iBACH;qBAAM;oBACL,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,CAAA;oBACzD,MAAM,GAAG,GAAG,EAAE,MAAM,KAAK,qCAA0B,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAA;iBACvE;aACF;YAED,OAAO;gBACL,MAAM;gBACN,WAAW;gBACX,MAAM;aACP,CAAA;QACH,CAAC,CAAA;QACD,IAAI,CAAC,GAAG,GAAG,MAAa,CAAA;QAExB,OAAO,IAUN,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAtGY,QAAA,cAAc,kBAsG1B"}
@@ -0,0 +1,3 @@
1
+ export * from "./helper";
2
+ export * from "./utils/composer";
3
+ export * as Composer from "./utils/composer";
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Composer = void 0;
30
+ __exportStar(require("./helper"), exports);
31
+ __exportStar(require("./utils/composer"), exports);
32
+ exports.Composer = __importStar(require("./utils/composer"));
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,mDAAgC;AAChC,6DAA4C"}
@@ -0,0 +1,105 @@
1
+ import { StepResponse } from "./helpers";
2
+ import { StepExecutionContext, StepFunction } from "./type";
3
+ /**
4
+ * The type of invocation function passed to a step.
5
+ *
6
+ * @typeParam TInput - The type of the input that the function expects.
7
+ * @typeParam TOutput - The type of the output that the function returns.
8
+ * @typeParam TCompensateInput - The type of the input that the compensation function expects.
9
+ *
10
+ * @returns The expected output based on the type parameter `TOutput`.
11
+ */
12
+ type InvokeFn<TInput extends object, TOutput, TCompensateInput> = (
13
+ /**
14
+ * The input of the step.
15
+ */
16
+ input: {
17
+ [Key in keyof TInput]: TInput[Key];
18
+ },
19
+ /**
20
+ * The step's context.
21
+ */
22
+ context: StepExecutionContext) => void | StepResponse<TOutput, TCompensateInput extends undefined ? TOutput : TCompensateInput> | Promise<void | StepResponse<TOutput, TCompensateInput extends undefined ? TOutput : TCompensateInput>>;
23
+ /**
24
+ * The type of compensation function passed to a step.
25
+ *
26
+ * @typeParam T -
27
+ * The type of the argument passed to the compensation function. If not specified, then it will be the same type as the invocation function's output.
28
+ *
29
+ * @returns There's no expected type to be returned by the compensation function.
30
+ */
31
+ type CompensateFn<T> = (
32
+ /**
33
+ * The argument passed to the compensation function.
34
+ */
35
+ input: T | undefined,
36
+ /**
37
+ * The step's context.
38
+ */
39
+ context: StepExecutionContext) => unknown | Promise<unknown>;
40
+ /**
41
+ * This function creates a {@link StepFunction} that can be used as a step in a workflow constructed by the {@link createWorkflow} function.
42
+ *
43
+ * @typeParam TInvokeInput - The type of the expected input parameter to the invocation function.
44
+ * @typeParam TInvokeResultOutput - The type of the expected output parameter of the invocation function.
45
+ * @typeParam TInvokeResultCompensateInput - The type of the expected input parameter to the compensation function.
46
+ *
47
+ * @returns A step function to be used in a workflow.
48
+ *
49
+ * @example
50
+ * import {
51
+ * createStep,
52
+ * StepResponse,
53
+ * StepExecutionContext,
54
+ * WorkflowData
55
+ * } from "@medusajs/workflows-sdk"
56
+ *
57
+ * interface CreateProductInput {
58
+ * title: string
59
+ * }
60
+ *
61
+ * export const createProductStep = createStep(
62
+ * "createProductStep",
63
+ * async function (
64
+ * input: CreateProductInput,
65
+ * context
66
+ * ) {
67
+ * const productService = context.container.resolve(
68
+ * "productService"
69
+ * )
70
+ * const product = await productService.create(input)
71
+ * return new StepResponse({
72
+ * product
73
+ * }, {
74
+ * product_id: product.id
75
+ * })
76
+ * },
77
+ * async function (
78
+ * input,
79
+ * context
80
+ * ) {
81
+ * const productService = context.container.resolve(
82
+ * "productService"
83
+ * )
84
+ * await productService.delete(input.product_id)
85
+ * }
86
+ * )
87
+ */
88
+ export declare function createStep<TInvokeInput extends object, TInvokeResultOutput, TInvokeResultCompensateInput>(
89
+ /**
90
+ * The name of the step.
91
+ */
92
+ name: string,
93
+ /**
94
+ * An invocation function that will be executed when the workflow is executed. The function must return an instance of {@link StepResponse}. The constructor of {@link StepResponse}
95
+ * accepts the output of the step as a first argument, and optionally as a second argument the data to be passed to the compensation function as a parameter.
96
+ */
97
+ invokeFn: InvokeFn<TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>,
98
+ /**
99
+ * A compensation function that's executed if an error occurs in the workflow. It's used to roll-back actions when errors occur.
100
+ * It accepts as a parameter the second argument passed to the constructor of the {@link StepResponse} instance returned by the invocation function. If the
101
+ * invocation function doesn't pass the second argument to `StepResponse` constructor, the compensation function receives the first argument
102
+ * passed to the `StepResponse` constructor instead.
103
+ */
104
+ compensateFn?: CompensateFn<TInvokeResultCompensateInput>): StepFunction<TInvokeInput, TInvokeResultOutput>;
105
+ export {};
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStep = void 0;
4
+ const helpers_1 = require("./helpers");
5
+ const proxy_1 = require("./helpers/proxy");
6
+ /**
7
+ * @internal
8
+ *
9
+ * Internal function to create the invoke and compensate handler for a step.
10
+ * This is where the inputs and context are passed to the underlying invoke and compensate function.
11
+ *
12
+ * @param stepName
13
+ * @param input
14
+ * @param invokeFn
15
+ * @param compensateFn
16
+ */
17
+ function applyStep({ stepName, input, invokeFn, compensateFn, }) {
18
+ return function () {
19
+ if (!this.workflowId) {
20
+ throw new Error("createStep must be used inside a createWorkflow definition");
21
+ }
22
+ const handler = {
23
+ invoke: async (transactionContext) => {
24
+ const executionContext = {
25
+ container: transactionContext.container,
26
+ metadata: transactionContext.metadata,
27
+ context: transactionContext.context,
28
+ };
29
+ const argInput = await (0, helpers_1.resolveValue)(input, transactionContext);
30
+ const stepResponse = await invokeFn.apply(this, [argInput, executionContext]);
31
+ const stepResponseJSON = stepResponse?.__type === helpers_1.SymbolWorkflowStepResponse
32
+ ? stepResponse.toJSON()
33
+ : stepResponse;
34
+ return {
35
+ __type: helpers_1.SymbolWorkflowWorkflowData,
36
+ output: stepResponseJSON,
37
+ };
38
+ },
39
+ compensate: compensateFn
40
+ ? async (transactionContext) => {
41
+ const executionContext = {
42
+ container: transactionContext.container,
43
+ metadata: transactionContext.metadata,
44
+ context: transactionContext.context,
45
+ };
46
+ const stepOutput = transactionContext.invoke[stepName]?.output;
47
+ const invokeResult = stepOutput?.__type === helpers_1.SymbolWorkflowStepResponse
48
+ ? stepOutput.compensateInput &&
49
+ JSON.parse(JSON.stringify(stepOutput.compensateInput))
50
+ : stepOutput && JSON.parse(JSON.stringify(stepOutput));
51
+ const args = [invokeResult, executionContext];
52
+ const output = await compensateFn.apply(this, args);
53
+ return {
54
+ output,
55
+ };
56
+ }
57
+ : undefined,
58
+ };
59
+ this.flow.addAction(stepName, {
60
+ noCompensation: !compensateFn,
61
+ });
62
+ this.handlers.set(stepName, handler);
63
+ const ret = {
64
+ __type: helpers_1.SymbolWorkflowStep,
65
+ __step__: stepName,
66
+ };
67
+ return (0, proxy_1.proxify)(ret);
68
+ };
69
+ }
70
+ /**
71
+ * This function creates a {@link StepFunction} that can be used as a step in a workflow constructed by the {@link createWorkflow} function.
72
+ *
73
+ * @typeParam TInvokeInput - The type of the expected input parameter to the invocation function.
74
+ * @typeParam TInvokeResultOutput - The type of the expected output parameter of the invocation function.
75
+ * @typeParam TInvokeResultCompensateInput - The type of the expected input parameter to the compensation function.
76
+ *
77
+ * @returns A step function to be used in a workflow.
78
+ *
79
+ * @example
80
+ * import {
81
+ * createStep,
82
+ * StepResponse,
83
+ * StepExecutionContext,
84
+ * WorkflowData
85
+ * } from "@medusajs/workflows-sdk"
86
+ *
87
+ * interface CreateProductInput {
88
+ * title: string
89
+ * }
90
+ *
91
+ * export const createProductStep = createStep(
92
+ * "createProductStep",
93
+ * async function (
94
+ * input: CreateProductInput,
95
+ * context
96
+ * ) {
97
+ * const productService = context.container.resolve(
98
+ * "productService"
99
+ * )
100
+ * const product = await productService.create(input)
101
+ * return new StepResponse({
102
+ * product
103
+ * }, {
104
+ * product_id: product.id
105
+ * })
106
+ * },
107
+ * async function (
108
+ * input,
109
+ * context
110
+ * ) {
111
+ * const productService = context.container.resolve(
112
+ * "productService"
113
+ * )
114
+ * await productService.delete(input.product_id)
115
+ * }
116
+ * )
117
+ */
118
+ function createStep(
119
+ /**
120
+ * The name of the step.
121
+ */
122
+ name,
123
+ /**
124
+ * An invocation function that will be executed when the workflow is executed. The function must return an instance of {@link StepResponse}. The constructor of {@link StepResponse}
125
+ * accepts the output of the step as a first argument, and optionally as a second argument the data to be passed to the compensation function as a parameter.
126
+ */
127
+ invokeFn,
128
+ /**
129
+ * A compensation function that's executed if an error occurs in the workflow. It's used to roll-back actions when errors occur.
130
+ * It accepts as a parameter the second argument passed to the constructor of the {@link StepResponse} instance returned by the invocation function. If the
131
+ * invocation function doesn't pass the second argument to `StepResponse` constructor, the compensation function receives the first argument
132
+ * passed to the `StepResponse` constructor instead.
133
+ */
134
+ compensateFn) {
135
+ const stepName = name ?? invokeFn.name;
136
+ const returnFn = function (input) {
137
+ if (!global[helpers_1.SymbolMedusaWorkflowComposerContext]) {
138
+ throw new Error("createStep must be used inside a createWorkflow definition");
139
+ }
140
+ const stepBinder = global[helpers_1.SymbolMedusaWorkflowComposerContext].stepBinder;
141
+ return stepBinder(applyStep({
142
+ stepName,
143
+ input,
144
+ invokeFn,
145
+ compensateFn,
146
+ }));
147
+ };
148
+ returnFn.__type = helpers_1.SymbolWorkflowStepBind;
149
+ returnFn.__step__ = stepName;
150
+ return returnFn;
151
+ }
152
+ exports.createStep = createStep;
153
+ //# sourceMappingURL=create-step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-step.js","sourceRoot":"","sources":["../../../src/utils/composer/create-step.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