@medusajs/workflows-sdk 3.0.0-snapshot-20250410105645 → 3.0.0-snapshot-20251104004624
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.
- package/dist/helper/type.d.ts +6 -1
- package/dist/helper/type.d.ts.map +1 -1
- package/dist/helper/workflow-export.d.ts.map +1 -1
- package/dist/helper/workflow-export.js +63 -24
- package/dist/helper/workflow-export.js.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/medusa-workflow.d.ts.map +1 -1
- package/dist/medusa-workflow.js +3 -0
- package/dist/medusa-workflow.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/_playground.js +28 -67
- package/dist/utils/_playground.js.map +1 -1
- package/dist/utils/composer/create-hook.d.ts +3 -3
- package/dist/utils/composer/create-hook.d.ts.map +1 -1
- package/dist/utils/composer/create-hook.js +10 -6
- package/dist/utils/composer/create-hook.js.map +1 -1
- package/dist/utils/composer/create-step.d.ts +11 -11
- package/dist/utils/composer/create-step.d.ts.map +1 -1
- package/dist/utils/composer/create-step.js +33 -19
- package/dist/utils/composer/create-step.js.map +1 -1
- package/dist/utils/composer/create-workflow.d.ts.map +1 -1
- package/dist/utils/composer/create-workflow.js +68 -22
- package/dist/utils/composer/create-workflow.js.map +1 -1
- package/dist/utils/composer/helpers/create-step-handler.d.ts.map +1 -1
- package/dist/utils/composer/helpers/create-step-handler.js +32 -6
- package/dist/utils/composer/helpers/create-step-handler.js.map +1 -1
- package/dist/utils/composer/helpers/proxy.d.ts.map +1 -1
- package/dist/utils/composer/helpers/proxy.js +3 -10
- package/dist/utils/composer/helpers/proxy.js.map +1 -1
- package/dist/utils/composer/helpers/resolve-value.d.ts +7 -4
- package/dist/utils/composer/helpers/resolve-value.d.ts.map +1 -1
- package/dist/utils/composer/helpers/resolve-value.js +177 -30
- package/dist/utils/composer/helpers/resolve-value.js.map +1 -1
- package/dist/utils/composer/helpers/step-response.d.ts.map +1 -1
- package/dist/utils/composer/helpers/step-response.js +1 -1
- package/dist/utils/composer/helpers/step-response.js.map +1 -1
- package/dist/utils/composer/transform.d.ts.map +1 -1
- package/dist/utils/composer/transform.js +15 -8
- package/dist/utils/composer/transform.js.map +1 -1
- package/dist/utils/composer/type.d.ts +22 -2
- package/dist/utils/composer/type.d.ts.map +1 -1
- package/dist/utils/composer/when.js +12 -1
- package/dist/utils/composer/when.js.map +1 -1
- package/package.json +9 -31
package/dist/helper/type.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DistributedTransactionEvents, DistributedTransactionType, LocalWorkflow
|
|
|
2
2
|
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types";
|
|
3
3
|
type BaseFlowRunOptions = {
|
|
4
4
|
context?: Context;
|
|
5
|
-
resultFrom?: string |
|
|
5
|
+
resultFrom?: string | Symbol;
|
|
6
6
|
throwOnError?: boolean;
|
|
7
7
|
logOnError?: boolean;
|
|
8
8
|
events?: DistributedTransactionEvents;
|
|
@@ -15,9 +15,13 @@ export type FlowRegisterStepSuccessOptions<TData = unknown> = BaseFlowRunOptions
|
|
|
15
15
|
idempotencyKey: string;
|
|
16
16
|
response?: TData;
|
|
17
17
|
};
|
|
18
|
+
export type FlowRetryStepOptions = Omit<BaseFlowRunOptions, "resultFrom"> & {
|
|
19
|
+
idempotencyKey: string;
|
|
20
|
+
};
|
|
18
21
|
export type FlowRegisterStepFailureOptions<TData = unknown> = BaseFlowRunOptions & {
|
|
19
22
|
idempotencyKey: string;
|
|
20
23
|
response?: TData;
|
|
24
|
+
forcePermanentFailure?: boolean;
|
|
21
25
|
};
|
|
22
26
|
export type FlowCancelOptions = {
|
|
23
27
|
transaction?: DistributedTransactionType;
|
|
@@ -49,6 +53,7 @@ export type ExportedWorkflow<TData = unknown, TResult = unknown, TDataOverride =
|
|
|
49
53
|
run: (args?: FlowRunOptions<TDataOverride extends undefined ? TData : TDataOverride>) => Promise<WorkflowResult<TResultOverride extends undefined ? TResult : TResultOverride>>;
|
|
50
54
|
registerStepSuccess: (args?: FlowRegisterStepSuccessOptions<TDataOverride extends undefined ? TData : TDataOverride>) => Promise<WorkflowResult<TResultOverride extends undefined ? TResult : TResultOverride>>;
|
|
51
55
|
registerStepFailure: (args?: FlowRegisterStepFailureOptions<TDataOverride extends undefined ? TData : TDataOverride>) => Promise<WorkflowResult<TResultOverride extends undefined ? TResult : TResultOverride>>;
|
|
56
|
+
retryStep: (args?: FlowRetryStepOptions) => Promise<WorkflowResult>;
|
|
52
57
|
cancel: (args?: FlowCancelOptions) => Promise<WorkflowResult>;
|
|
53
58
|
};
|
|
54
59
|
export type MainExportedWorkflow<TData = unknown, TResult = unknown> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/helper/type.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,aAAa,EACb,oBAAoB,EACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAExE,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/helper/type.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,aAAa,EACb,oBAAoB,EACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAExE,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,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;;OAEG;IAEH,GAAG,CAAC,aAAa,GAAG,SAAS,EAAE,eAAe,GAAG,SAAS,EACxD,IAAI,CAAC,EAAE,cAAc,CACnB,aAAa,SAAS,SAAS,GAAG,KAAK,GAAG,aAAa,CACxD,GACA,OAAO,CACR,cAAc,CACZ,eAAe,SAAS,SAAS,GAAG,OAAO,GAAG,eAAe,CAC9D,CACF,CAAA;IAED,mBAAmB,CAAC,aAAa,GAAG,SAAS,EAAE,eAAe,GAAG,SAAS,EACxE,IAAI,CAAC,EAAE,8BAA8B,CACnC,aAAa,SAAS,SAAS,GAAG,KAAK,GAAG,aAAa,CACxD,GACA,OAAO,CACR,cAAc,CACZ,eAAe,SAAS,SAAS,GAAG,OAAO,GAAG,eAAe,CAC9D,CACF,CAAA;IAED,mBAAmB,CAAC,aAAa,GAAG,SAAS,EAAE,eAAe,GAAG,SAAS,EACxE,IAAI,CAAC,EAAE,8BAA8B,CACnC,aAAa,SAAS,SAAS,GAAG,KAAK,GAAG,aAAa,CACxD,GACA,OAAO,CACR,cAAc,CACZ,eAAe,SAAS,SAAS,GAAG,OAAO,GAAG,eAAe,CAC9D,CACF,CAAA;IAED,MAAM,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAC1D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-export.d.ts","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":"AAyBA,OAAO,
|
|
1
|
+
{"version":3,"file":"workflow-export.d.ts","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":"AAyBA,OAAO,EAOL,oBAAoB,EAErB,MAAM,QAAQ,CAAA;AA0Xf,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC/D,YAAY,MAAM,EAClB,gBAAgB,MAAM,GAAG,MAAM,EAC/B,UAAU;IACR,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,KACA,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAwKrC,CAAA"}
|
|
@@ -8,23 +8,32 @@ const os_1 = require("os");
|
|
|
8
8
|
const ulid_1 = require("ulid");
|
|
9
9
|
const medusa_workflow_1 = require("../medusa-workflow");
|
|
10
10
|
const resolve_value_1 = require("../utils/composer/helpers/resolve-value");
|
|
11
|
+
// Cache for loaded modules to avoid repeated traversal
|
|
12
|
+
let cachedLoadedModules = null;
|
|
13
|
+
function getCachedLoadedModules() {
|
|
14
|
+
if (!cachedLoadedModules) {
|
|
15
|
+
cachedLoadedModules = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.values(mod)[0]);
|
|
16
|
+
}
|
|
17
|
+
return cachedLoadedModules;
|
|
18
|
+
}
|
|
11
19
|
function createContextualWorkflowRunner({ workflowId, defaultResult, options, container, }) {
|
|
12
20
|
const flow = new orchestration_1.LocalWorkflow(workflowId, container);
|
|
13
21
|
const originalRun = flow.run.bind(flow);
|
|
14
22
|
const originalRegisterStepSuccess = flow.registerStepSuccess.bind(flow);
|
|
15
23
|
const originalRegisterStepFailure = flow.registerStepFailure.bind(flow);
|
|
16
24
|
const originalCancel = flow.cancel.bind(flow);
|
|
17
|
-
const
|
|
25
|
+
const originalRetryStep = flow.retryStep.bind(flow);
|
|
26
|
+
const originalExecution = async (method, { throwOnError, logOnError = false, resultFrom, isCancel = false, container: executionContainer, forcePermanentFailure, }, transactionOrIdOrIdempotencyKey, input, context, events = {}) => {
|
|
18
27
|
if (!executionContainer) {
|
|
19
28
|
const container_ = flow.container;
|
|
20
29
|
if (!container_ || !(0, utils_1.isPresent)(container_?.registrations)) {
|
|
21
|
-
executionContainer =
|
|
30
|
+
executionContainer = getCachedLoadedModules();
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
if (executionContainer) {
|
|
25
34
|
flow.container = executionContainer;
|
|
26
35
|
}
|
|
27
|
-
const { eventGroupId, parentStepIdempotencyKey, preventReleaseEvents } = context;
|
|
36
|
+
const { eventGroupId, parentStepIdempotencyKey, preventReleaseEvents, cancelingFromParentStep, } = context;
|
|
28
37
|
if (!preventReleaseEvents) {
|
|
29
38
|
attachOnFinishReleaseEvents(events, flow, { logOnError });
|
|
30
39
|
}
|
|
@@ -32,14 +41,18 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, options, co
|
|
|
32
41
|
eventGroupId,
|
|
33
42
|
parentStepIdempotencyKey,
|
|
34
43
|
sourcePath: options?.sourcePath,
|
|
44
|
+
preventReleaseEvents,
|
|
45
|
+
cancelingFromParentStep,
|
|
35
46
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
context.isCancelling = isCancel;
|
|
48
|
+
const args = [transactionOrIdOrIdempotencyKey, input, context, events];
|
|
49
|
+
if (method === originalRegisterStepFailure) {
|
|
50
|
+
// Only available on registerStepFailure
|
|
51
|
+
args.push(forcePermanentFailure);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
args.push(flowMetadata);
|
|
55
|
+
}
|
|
43
56
|
const transaction = (await method.apply(method, args));
|
|
44
57
|
let errors = transaction.getErrors(utils_1.TransactionHandlerType.INVOKE);
|
|
45
58
|
const failedStatus = [orchestration_1.TransactionState.FAILED, orchestration_1.TransactionState.REVERTED];
|
|
@@ -71,7 +84,8 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, options, co
|
|
|
71
84
|
}
|
|
72
85
|
}
|
|
73
86
|
else {
|
|
74
|
-
result =
|
|
87
|
+
result =
|
|
88
|
+
resultFrom && transaction.getContext().invoke?.[resultFrom.toString()];
|
|
75
89
|
}
|
|
76
90
|
return {
|
|
77
91
|
errors,
|
|
@@ -88,8 +102,9 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, options, co
|
|
|
88
102
|
...outerContext,
|
|
89
103
|
__type: utils_1.MedusaContextType,
|
|
90
104
|
};
|
|
91
|
-
|
|
92
|
-
context.
|
|
105
|
+
const uniqId = (0, ulid_1.ulid)();
|
|
106
|
+
context.transactionId ??= "auto-" + uniqId;
|
|
107
|
+
context.eventGroupId ??= uniqId;
|
|
93
108
|
return await originalExecution(originalRun, {
|
|
94
109
|
throwOnError,
|
|
95
110
|
resultFrom,
|
|
@@ -120,7 +135,7 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, options, co
|
|
|
120
135
|
}, idempotencyKey, response, context, events);
|
|
121
136
|
};
|
|
122
137
|
flow.registerStepSuccess = newRegisterStepSuccess;
|
|
123
|
-
const newRegisterStepFailure = async ({ response, idempotencyKey, context: outerContext, throwOnError, logOnError, resultFrom, events, container, } = {
|
|
138
|
+
const newRegisterStepFailure = async ({ response, idempotencyKey, context: outerContext, throwOnError, logOnError, resultFrom, events, container, forcePermanentFailure, } = {
|
|
124
139
|
idempotencyKey: "",
|
|
125
140
|
}) => {
|
|
126
141
|
idempotencyKey ??= "";
|
|
@@ -139,9 +154,30 @@ function createContextualWorkflowRunner({ workflowId, defaultResult, options, co
|
|
|
139
154
|
resultFrom,
|
|
140
155
|
container,
|
|
141
156
|
logOnError,
|
|
157
|
+
forcePermanentFailure,
|
|
142
158
|
}, idempotencyKey, response, context, events);
|
|
143
159
|
};
|
|
144
160
|
flow.registerStepFailure = newRegisterStepFailure;
|
|
161
|
+
const newRetryStep = async ({ idempotencyKey, context: outerContext, throwOnError, logOnError, events, container, } = {
|
|
162
|
+
idempotencyKey: "",
|
|
163
|
+
}) => {
|
|
164
|
+
idempotencyKey ??= "";
|
|
165
|
+
throwOnError ??= true;
|
|
166
|
+
logOnError ??= false;
|
|
167
|
+
const [, transactionId] = idempotencyKey.split(":");
|
|
168
|
+
const context = {
|
|
169
|
+
...outerContext,
|
|
170
|
+
transactionId,
|
|
171
|
+
__type: utils_1.MedusaContextType,
|
|
172
|
+
};
|
|
173
|
+
context.eventGroupId ??= (0, ulid_1.ulid)();
|
|
174
|
+
return await originalExecution(originalRetryStep, {
|
|
175
|
+
throwOnError,
|
|
176
|
+
container,
|
|
177
|
+
logOnError,
|
|
178
|
+
}, idempotencyKey, undefined, context, events);
|
|
179
|
+
};
|
|
180
|
+
flow.retryStep = newRetryStep;
|
|
145
181
|
const newCancel = async ({ transaction, transactionId, context: outerContext, throwOnError, logOnError, events, container, } = {}) => {
|
|
146
182
|
throwOnError ??= true;
|
|
147
183
|
logOnError ??= false;
|
|
@@ -185,26 +221,28 @@ const exportWorkflow = (workflowId, defaultResult, options) => {
|
|
|
185
221
|
exportedWorkflow.run = async (args) => {
|
|
186
222
|
const container = args?.container;
|
|
187
223
|
delete args?.container;
|
|
188
|
-
|
|
189
|
-
return await buildRunnerFn("run", container)(inputArgs);
|
|
224
|
+
return await buildRunnerFn("run", container)(args);
|
|
190
225
|
};
|
|
191
226
|
exportedWorkflow.registerStepSuccess = async (args) => {
|
|
192
227
|
const container = args?.container;
|
|
193
228
|
delete args?.container;
|
|
194
|
-
|
|
195
|
-
return await buildRunnerFn("registerStepSuccess", container)(inputArgs);
|
|
229
|
+
return await buildRunnerFn("registerStepSuccess", container)(args);
|
|
196
230
|
};
|
|
197
231
|
exportedWorkflow.registerStepFailure = async (args) => {
|
|
232
|
+
const container = args?.container;
|
|
233
|
+
delete args?.container;
|
|
234
|
+
return await buildRunnerFn("registerStepFailure", container)(args);
|
|
235
|
+
};
|
|
236
|
+
exportedWorkflow.retryStep = async (args) => {
|
|
198
237
|
const container = args?.container;
|
|
199
238
|
delete args?.container;
|
|
200
239
|
const inputArgs = { ...args };
|
|
201
|
-
return await buildRunnerFn("
|
|
240
|
+
return await buildRunnerFn("retryStep", container)(inputArgs);
|
|
202
241
|
};
|
|
203
242
|
exportedWorkflow.cancel = async (args) => {
|
|
204
243
|
const container = args?.container;
|
|
205
244
|
delete args?.container;
|
|
206
|
-
|
|
207
|
-
return await buildRunnerFn("cancel", container)(inputArgs);
|
|
245
|
+
return await buildRunnerFn("cancel", container)(args);
|
|
208
246
|
};
|
|
209
247
|
medusa_workflow_1.MedusaWorkflow.registerWorkflow(workflowId, exportedWorkflow);
|
|
210
248
|
return exportedWorkflow;
|
|
@@ -218,9 +256,10 @@ function attachOnFinishReleaseEvents(events = {}, flow, { logOnError, } = {}) {
|
|
|
218
256
|
const logger = flow.container.resolve(utils_1.ContainerRegistrationKeys.LOGGER, { allowUnregistered: true }) || console;
|
|
219
257
|
if (logOnError) {
|
|
220
258
|
const workflowName = transaction.getFlow().modelId;
|
|
221
|
-
transaction
|
|
222
|
-
|
|
223
|
-
|
|
259
|
+
transaction.getErrors().forEach((err) => {
|
|
260
|
+
const errMsg = err?.error?.message ? " - " + err?.error?.message : "";
|
|
261
|
+
logger.error(`${workflowName}:${err?.action}:${err?.handlerType}${errMsg}${os_1.EOL}${err?.error?.stack}`);
|
|
262
|
+
});
|
|
224
263
|
}
|
|
225
264
|
const eventBusService = flow.container.resolve(utils_1.Modules.EVENT_BUS, {
|
|
226
265
|
allowUnregistered: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-export.js","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2DAKgC;AAQhC,2CAMwB;AACxB,2BAAwB;AACxB,+BAA2B;AAC3B,wDAAmD;AACnD,2EAAsE;
|
|
1
|
+
{"version":3,"file":"workflow-export.js","sourceRoot":"","sources":["../../src/helper/workflow-export.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2DAKgC;AAQhC,2CAMwB;AACxB,2BAAwB;AACxB,+BAA2B;AAC3B,wDAAmD;AACnD,2EAAsE;AAYtE,uDAAuD;AACvD,IAAI,mBAAmB,GAA0B,IAAI,CAAA;AAErD,SAAS,sBAAsB;IAC7B,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,mBAAmB,GAAG,0BAAY,CAAC,gBAAgB,EAAE,CAAC,GAAG,CACvD,CAAC,GAAG,EAAE,EAAE,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,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,eAAe,GACnB,IAAI,CAAC,SACN,CAAC,OAAO,CAAyB,eAAO,CAAC,SAAS,EAAE;YACnD,iBAAiB,EAAE,IAAI;SACxB,CAAC,CAAA;QAEF,IAAI,CAAC,eAAe,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1C,MAAM,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;YACtB,OAAM;QACR,CAAC;QAED,MAAM,YAAY,GAAG,CAAC,gCAAgB,CAAC,MAAM,EAAE,gCAAgB,CAAC,QAAQ,CAAC,CAAA;QAEzE,IAAI,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;YAClD,OAAO,MAAM,eAAe;iBACzB,kBAAkB,CAAC,gBAAgB,CAAC;iBACpC,KAAK,CAAC,GAAG,EAAE;gBACV,MAAM,CAAC,IAAI,CACT,6CAA6C,gBAAgB,EAAE,CAChE,CAAA;YACH,CAAC,CAAC,CAAA;QACN,CAAC;QAED,MAAM,eAAe;aAClB,oBAAoB,CAAC,gBAAgB,CAAC;aACtC,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,CAAC,KAAK,CACV,sDAAsD,gBAAgB,EAAE,EACxE,CAAC,CACF,CAAA;YAED,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,MAAM,CAAC,QAAQ,GAAG,eAAe,CAAA;AACnC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.Composer = void 0;
|
|
30
40
|
__exportStar(require("./helper"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,oDAAiC;AACjC,mDAAgC;AAChC,6DAA4C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medusa-workflow.d.ts","sourceRoot":"","sources":["../src/medusa-workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"medusa-workflow.d.ts","sourceRoot":"","sources":["../src/medusa-workflow.ts"],"names":[],"mappings":"AAkCA,QAAA,MAAM,oBAAoB,KAAwB,CAAA;AAElD,OAAO,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAA"}
|
package/dist/medusa-workflow.js
CHANGED
|
@@ -8,6 +8,9 @@ class MedusaWorkflow {
|
|
|
8
8
|
}
|
|
9
9
|
MedusaWorkflow.workflows[workflowId] = exportedWorkflow;
|
|
10
10
|
}
|
|
11
|
+
static unregisterWorkflow(workflowId) {
|
|
12
|
+
delete MedusaWorkflow.workflows[workflowId];
|
|
13
|
+
}
|
|
11
14
|
static getWorkflow(workflowId) {
|
|
12
15
|
return MedusaWorkflow.workflows[workflowId];
|
|
13
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medusa-workflow.js","sourceRoot":"","sources":["../src/medusa-workflow.ts"],"names":[],"mappings":";;;AAIA,MAAM,cAAc;IAYlB,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB;QAClD,IAAI,UAAU,IAAI,cAAc,CAAC,SAAS,EAAE,CAAC;YAC3C,OAAM;QACR,CAAC;QAED,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAA;IACzD,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,UAAU;QAC3B,OAAO,cAAc,CAAC,SAAS,CAAC,UAAU,CAAgC,CAAA;IAC5E,CAAC;;
|
|
1
|
+
{"version":3,"file":"medusa-workflow.js","sourceRoot":"","sources":["../src/medusa-workflow.ts"],"names":[],"mappings":";;;AAIA,MAAM,cAAc;IAYlB,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB;QAClD,IAAI,UAAU,IAAI,cAAc,CAAC,SAAS,EAAE,CAAC;YAC3C,OAAM;QACR,CAAC;QAED,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAA;IACzD,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,UAAU;QAClC,OAAO,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,UAAU;QAC3B,OAAO,cAAc,CAAC,SAAS,CAAC,UAAU,CAAgC,CAAA;IAC5E,CAAC;;AAzBM,wBAAS,GASZ,EAAE,CAAA;AAmBR,MAAM,CAAC,cAAc,KAAK,cAAc,CAAA;AACxC,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAA;AAEjB,8CAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/medusa-workflow.ts","../src/helper/index.ts","../src/helper/type.ts","../src/helper/workflow-export.ts","../src/utils/_playground.ts","../src/utils/composer/create-hook.ts","../src/utils/composer/create-step.ts","../src/utils/composer/create-workflow.ts","../src/utils/composer/index.ts","../src/utils/composer/parallelize.ts","../src/utils/composer/transform.ts","../src/utils/composer/type.ts","../src/utils/composer/when.ts","../src/utils/composer/__tests__/compose.ts","../src/utils/composer/__tests__/index.spec.ts","../src/utils/composer/helpers/create-step-handler.ts","../src/utils/composer/helpers/index.ts","../src/utils/composer/helpers/proxy.ts","../src/utils/composer/helpers/resolve-value.ts","../src/utils/composer/helpers/step-response.ts","../src/utils/composer/helpers/workflow-response.ts"],"version":"5.
|
|
1
|
+
{"root":["../src/index.ts","../src/medusa-workflow.ts","../src/helper/index.ts","../src/helper/type.ts","../src/helper/workflow-export.ts","../src/utils/_playground.ts","../src/utils/composer/create-hook.ts","../src/utils/composer/create-step.ts","../src/utils/composer/create-workflow.ts","../src/utils/composer/index.ts","../src/utils/composer/parallelize.ts","../src/utils/composer/transform.ts","../src/utils/composer/type.ts","../src/utils/composer/when.ts","../src/utils/composer/__tests__/compose.spec.ts","../src/utils/composer/__tests__/index.spec.ts","../src/utils/composer/helpers/create-step-handler.ts","../src/utils/composer/helpers/index.ts","../src/utils/composer/helpers/proxy.ts","../src/utils/composer/helpers/resolve-value.ts","../src/utils/composer/helpers/step-response.ts","../src/utils/composer/helpers/workflow-response.ts"],"version":"5.9.3"}
|
|
@@ -1,79 +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(
|
|
6
|
+
const step1 = (0, composer_1.createStep)("step1", () => {
|
|
7
|
+
return new composer_1.StepResponse("step1");
|
|
8
|
+
}, () => {
|
|
9
|
+
console.log("compensate step1");
|
|
9
10
|
});
|
|
10
|
-
const step2 = (0, composer_1.createStep)("step2",
|
|
11
|
-
return new composer_1.StepResponse(
|
|
11
|
+
const step2 = (0, composer_1.createStep)("step2", (input) => {
|
|
12
|
+
return new composer_1.StepResponse(input);
|
|
13
|
+
}, (input) => {
|
|
14
|
+
console.log("compensate step2", input);
|
|
12
15
|
});
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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],
|
|
23
27
|
});
|
|
24
|
-
return new workflow_response_1.WorkflowResponse({ r: somethingHook.getResult(), step3: step3() }, { hooks: [somethingHook] });
|
|
25
|
-
});
|
|
26
|
-
workflow.hooks.something((input, context) => {
|
|
27
|
-
console.log("input>", input);
|
|
28
|
-
console.log("context>", context);
|
|
29
|
-
return new composer_1.StepResponse({ id: 2, foo: "bar" });
|
|
30
28
|
});
|
|
31
|
-
workflow.
|
|
32
|
-
|
|
29
|
+
workflow.hooks.hook(() => {
|
|
30
|
+
throw new Error("hook failed");
|
|
33
31
|
});
|
|
34
|
-
/*const workflow2 = createWorkflow("workflow", function () {
|
|
35
|
-
const step1Res = step1()
|
|
36
|
-
|
|
37
|
-
const step3Res = when({ value: true }, ({ value }) => {
|
|
38
|
-
return value
|
|
39
|
-
}).then(() => {
|
|
40
|
-
return step3()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
transform({ step3Res }, ({ step3Res }) => {
|
|
44
|
-
console.log(step3Res)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const workflowRes = workflow.asStep({ outsideWorkflowData: step1Res.step1 })
|
|
48
|
-
|
|
49
|
-
return workflowRes
|
|
50
|
-
})*/
|
|
51
|
-
// workflow()
|
|
52
|
-
// .run({})
|
|
53
|
-
// .then((res) => {
|
|
54
|
-
// console.log(res.result)
|
|
55
|
-
// })
|
|
56
|
-
/*const step1 = createStep("step1", async (input: {}, context) => {
|
|
57
|
-
return new StepResponse({ step1: ["step1"] })
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
const step2 = createStep("step2", async (input: string[], context) => {
|
|
61
|
-
return new StepResponse({ step2: input })
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const step3 = createStep("step3", async () => {
|
|
65
|
-
return new StepResponse({ step3: "step3" })
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
const workflow = createWorkflow("workflow", function () {
|
|
69
|
-
const step1Res = step1()
|
|
70
|
-
step3()
|
|
71
|
-
return step2(step1Res.step1)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
32
|
workflow()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.log(res
|
|
78
|
-
|
|
33
|
+
.run()
|
|
34
|
+
.then((res) => {
|
|
35
|
+
console.log(res);
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
console.log(e);
|
|
39
|
+
});
|
|
79
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ZodSchema } from "zod";
|
|
2
1
|
import { OrchestrationUtils } from "@medusajs/utils";
|
|
2
|
+
import { type ZodSchema } from "zod";
|
|
3
3
|
/**
|
|
4
4
|
* Representation of a hook definition.
|
|
5
5
|
*/
|
|
@@ -27,7 +27,7 @@ export type Hook<Name extends string, Input, Output> = {
|
|
|
27
27
|
* Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks).
|
|
28
28
|
*
|
|
29
29
|
* @param name - The hook's name. This is used when the hook handler is registered to consume the workflow.
|
|
30
|
-
* @param
|
|
30
|
+
* @param hookInput - The input to pass to the hook handler.
|
|
31
31
|
* @returns A workflow hook.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
@@ -54,7 +54,7 @@ export type Hook<Name extends string, Input, Output> = {
|
|
|
54
54
|
* }
|
|
55
55
|
* )
|
|
56
56
|
*/
|
|
57
|
-
export declare function createHook<Name extends string, TInvokeInput, TInvokeOutput>(name: Name,
|
|
57
|
+
export declare function createHook<Name extends string, TInvokeInput, TInvokeOutput>(name: Name, hookInput: TInvokeInput, options?: {
|
|
58
58
|
resultValidator?: ZodSchema<TInvokeOutput>;
|
|
59
59
|
}): Hook<Name, TInvokeInput, TInvokeOutput>;
|
|
60
60
|
//# sourceMappingURL=create-hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-hook.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/create-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-hook.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/create-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAapC;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI;IACrD,MAAM,EAAE,OAAO,kBAAkB,CAAC,kBAAkB,CAAA;IACpD,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS,CAAA;IAE/B;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,KAAK,CAAA;CAChB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,YAAY,EAAE,aAAa,EACzE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,YAAY,EACvB,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;CACtC,GACL,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CA0EzC"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createHook = createHook;
|
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
|
5
5
|
const create_step_1 = require("./create-step");
|
|
6
|
-
const create_step_handler_1 = require("./helpers/create-step-handler");
|
|
7
6
|
const helpers_1 = require("./helpers");
|
|
7
|
+
const create_step_handler_1 = require("./helpers/create-step-handler");
|
|
8
8
|
const NOOP_RESULT = Symbol.for("NOOP");
|
|
9
9
|
/**
|
|
10
10
|
* Expose a hook in your workflow where you can inject custom functionality as a step function.
|
|
@@ -14,7 +14,7 @@ const NOOP_RESULT = Symbol.for("NOOP");
|
|
|
14
14
|
* Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks).
|
|
15
15
|
*
|
|
16
16
|
* @param name - The hook's name. This is used when the hook handler is registered to consume the workflow.
|
|
17
|
-
* @param
|
|
17
|
+
* @param hookInput - The input to pass to the hook handler.
|
|
18
18
|
* @returns A workflow hook.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
@@ -41,7 +41,7 @@ const NOOP_RESULT = Symbol.for("NOOP");
|
|
|
41
41
|
* }
|
|
42
42
|
* )
|
|
43
43
|
*/
|
|
44
|
-
function createHook(name,
|
|
44
|
+
function createHook(name, hookInput, options = {}) {
|
|
45
45
|
const context = global[utils_1.OrchestrationUtils.SymbolMedusaWorkflowComposerContext];
|
|
46
46
|
const getHookResultStep = (0, create_step_1.createStep)(`get-${name}-result`, (_, context) => {
|
|
47
47
|
const result = context[" getStepResult"](name);
|
|
@@ -61,17 +61,21 @@ function createHook(name, input, options = {}) {
|
|
|
61
61
|
* We start by registering a new step within the workflow. This will be a noop
|
|
62
62
|
* step that can be replaced (optionally) by the workflow consumer.
|
|
63
63
|
*/
|
|
64
|
-
(0, create_step_1.createStep)(name, (_) => new helpers_1.StepResponse(NOOP_RESULT), () => void 0)(
|
|
64
|
+
(0, create_step_1.createStep)(name, (_) => new helpers_1.StepResponse(NOOP_RESULT), () => void 0)(hookInput);
|
|
65
65
|
function hook(invokeFn, compensateFn) {
|
|
66
66
|
const handlers = create_step_handler_1.createStepHandler.bind(this)({
|
|
67
67
|
stepName: name,
|
|
68
|
-
input,
|
|
68
|
+
input: hookInput,
|
|
69
69
|
invokeFn,
|
|
70
|
-
compensateFn,
|
|
70
|
+
compensateFn: compensateFn ?? (() => void 0),
|
|
71
71
|
});
|
|
72
72
|
if (this.hooks_.registered.includes(name)) {
|
|
73
73
|
throw new Error(`Cannot define multiple hook handlers for the ${name} hook`);
|
|
74
74
|
}
|
|
75
|
+
const conditional = this.stepConditions_[name];
|
|
76
|
+
if (conditional) {
|
|
77
|
+
(0, create_step_1.wrapConditionalStep)(conditional.input, conditional.condition, handlers);
|
|
78
|
+
}
|
|
75
79
|
this.hooks_.registered.push(name);
|
|
76
80
|
this.handlers.set(name, handlers);
|
|
77
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-hook.js","sourceRoot":"","sources":["../../../src/utils/composer/create-hook.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-hook.js","sourceRoot":"","sources":["../../../src/utils/composer/create-hook.ts"],"names":[],"mappings":";;AAuEA,gCAgFC;AAvJD,2CAAoD;AAEpD,+CAKsB;AACtB,uCAAwC;AACxC,uEAAiE;AAGjE,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAwBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,UAAU,CACxB,IAAU,EACV,SAAuB,EACvB,UAEI,EAAE;IAEN,MAAM,OAAO,GAAG,MAAM,CACpB,0BAAkB,CAAC,mCAAmC,CACtB,CAAA;IAElC,MAAM,iBAAiB,GAAG,IAAA,wBAAU,EAClC,OAAO,IAAI,SAAS,EACpB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;QACb,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;YAC3B,OAAO,IAAI,sBAAY,CAAC,SAAS,CAAC,CAAA;QACpC,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AA;YACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACnC,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,0BAAkB,CAAC,kBAAkB;QAC7C,IAAI;QACJ,SAAS;YACP,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,YAAY,CAAA;YAC1B,CAAC;YACD,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAA;YAClC,IAAI,CAAC,cAAc,CAAC,GAAG,MAAM,CAAA;YAC7B,OAAO,MAAM,CAAA;QACf,CAAC;KACyC,CAAA;AAC9C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransactionStepsDefinition } from "@medusajs/orchestration";
|
|
1
|
+
import { TransactionStepsDefinition, WorkflowStepHandler } from "@medusajs/orchestration";
|
|
2
2
|
import { StepResponse } from "./helpers";
|
|
3
3
|
import { StepExecutionContext, StepFunction, StepFunctionResult, WorkflowData } from "./type";
|
|
4
4
|
/**
|
|
@@ -48,21 +48,21 @@ export interface ApplyStepOptions<TStepInputs extends {
|
|
|
48
48
|
invokeFn: InvokeFn<TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>;
|
|
49
49
|
compensateFn?: CompensateFn<TInvokeResultCompensateInput>;
|
|
50
50
|
}
|
|
51
|
+
export declare function applyStep<TInvokeInput, TStepInput extends {
|
|
52
|
+
[K in keyof TInvokeInput]: WorkflowData<TInvokeInput[K]>;
|
|
53
|
+
}, TInvokeResultOutput, TInvokeResultCompensateInput>({ stepName, stepConfig, input, invokeFn, compensateFn, }: ApplyStepOptions<TStepInput, TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>): StepFunctionResult<TInvokeResultOutput>;
|
|
51
54
|
/**
|
|
52
55
|
* @internal
|
|
53
56
|
*
|
|
54
|
-
* Internal function to
|
|
55
|
-
* This is where the inputs and context are passed to the underlying invoke and compensate function.
|
|
57
|
+
* Internal function to handle conditional steps.
|
|
56
58
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param input
|
|
60
|
-
* @param invokeFn
|
|
61
|
-
* @param compensateFn
|
|
59
|
+
* @param condition
|
|
60
|
+
* @param handle
|
|
62
61
|
*/
|
|
63
|
-
export declare function
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
export declare function wrapConditionalStep(input: any, condition: (...args: any) => boolean | WorkflowData, handle: {
|
|
63
|
+
invoke: WorkflowStepHandler;
|
|
64
|
+
compensate?: WorkflowStepHandler;
|
|
65
|
+
}): void;
|
|
66
66
|
/**
|
|
67
67
|
* This function creates a {@link StepFunction} that can be used as a step in a workflow constructed by the {@link createWorkflow} function.
|
|
68
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-step.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/create-step.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,
|
|
1
|
+
{"version":3,"file":"create-step.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/create-step.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE1B,mBAAmB,EAEpB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAgB,YAAY,EAAE,MAAM,WAAW,CAAA;AAGtD,OAAO,EAEL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACb,MAAM,QAAQ,CAAA;AAEf;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,gBAAgB,IAAI;AACxD;;GAEG;AACH,KAAK,EAAE,MAAM;AACb;;GAEG;AACH,OAAO,EAAE,oBAAoB,KAE3B,IAAI,GACJ,YAAY,CACV,OAAO,EACP,gBAAgB,SAAS,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAChE,GACD,OAAO,CAAC,IAAI,GAAG,YAAY,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