@acmekit/orchestration 2.13.1

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 (74) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +20 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/joiner/helpers.d.ts +3 -0
  6. package/dist/joiner/helpers.d.ts.map +1 -0
  7. package/dist/joiner/helpers.js +69 -0
  8. package/dist/joiner/helpers.js.map +1 -0
  9. package/dist/joiner/index.d.ts +3 -0
  10. package/dist/joiner/index.d.ts.map +1 -0
  11. package/dist/joiner/index.js +19 -0
  12. package/dist/joiner/index.js.map +1 -0
  13. package/dist/joiner/remote-joiner.d.ts +43 -0
  14. package/dist/joiner/remote-joiner.d.ts.map +1 -0
  15. package/dist/joiner/remote-joiner.js +1279 -0
  16. package/dist/joiner/remote-joiner.js.map +1 -0
  17. package/dist/transaction/datastore/abstract-storage.d.ts +44 -0
  18. package/dist/transaction/datastore/abstract-storage.d.ts.map +1 -0
  19. package/dist/transaction/datastore/abstract-storage.js +52 -0
  20. package/dist/transaction/datastore/abstract-storage.js.map +1 -0
  21. package/dist/transaction/datastore/base-in-memory-storage.d.ts +12 -0
  22. package/dist/transaction/datastore/base-in-memory-storage.d.ts.map +1 -0
  23. package/dist/transaction/datastore/base-in-memory-storage.js +35 -0
  24. package/dist/transaction/datastore/base-in-memory-storage.js.map +1 -0
  25. package/dist/transaction/distributed-transaction.d.ts +116 -0
  26. package/dist/transaction/distributed-transaction.d.ts.map +1 -0
  27. package/dist/transaction/distributed-transaction.js +488 -0
  28. package/dist/transaction/distributed-transaction.js.map +1 -0
  29. package/dist/transaction/errors.d.ts +41 -0
  30. package/dist/transaction/errors.d.ts.map +1 -0
  31. package/dist/transaction/errors.js +117 -0
  32. package/dist/transaction/errors.js.map +1 -0
  33. package/dist/transaction/index.d.ts +8 -0
  34. package/dist/transaction/index.d.ts.map +1 -0
  35. package/dist/transaction/index.js +24 -0
  36. package/dist/transaction/index.js.map +1 -0
  37. package/dist/transaction/orchestrator-builder.d.ts +36 -0
  38. package/dist/transaction/orchestrator-builder.d.ts.map +1 -0
  39. package/dist/transaction/orchestrator-builder.js +300 -0
  40. package/dist/transaction/orchestrator-builder.js.map +1 -0
  41. package/dist/transaction/transaction-orchestrator.d.ts +207 -0
  42. package/dist/transaction/transaction-orchestrator.d.ts.map +1 -0
  43. package/dist/transaction/transaction-orchestrator.js +1292 -0
  44. package/dist/transaction/transaction-orchestrator.js.map +1 -0
  45. package/dist/transaction/transaction-step.d.ts +69 -0
  46. package/dist/transaction/transaction-step.d.ts.map +1 -0
  47. package/dist/transaction/transaction-step.js +153 -0
  48. package/dist/transaction/transaction-step.js.map +1 -0
  49. package/dist/transaction/types.d.ts +264 -0
  50. package/dist/transaction/types.d.ts.map +1 -0
  51. package/dist/transaction/types.js +23 -0
  52. package/dist/transaction/types.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -0
  54. package/dist/workflow/global-workflow.d.ts +14 -0
  55. package/dist/workflow/global-workflow.d.ts.map +1 -0
  56. package/dist/workflow/global-workflow.js +105 -0
  57. package/dist/workflow/global-workflow.js.map +1 -0
  58. package/dist/workflow/index.d.ts +5 -0
  59. package/dist/workflow/index.d.ts.map +1 -0
  60. package/dist/workflow/index.js +21 -0
  61. package/dist/workflow/index.js.map +1 -0
  62. package/dist/workflow/local-workflow.d.ts +47 -0
  63. package/dist/workflow/local-workflow.d.ts.map +1 -0
  64. package/dist/workflow/local-workflow.js +390 -0
  65. package/dist/workflow/local-workflow.js.map +1 -0
  66. package/dist/workflow/scheduler.d.ts +12 -0
  67. package/dist/workflow/scheduler.d.ts.map +1 -0
  68. package/dist/workflow/scheduler.js +35 -0
  69. package/dist/workflow/scheduler.js.map +1 -0
  70. package/dist/workflow/workflow-manager.d.ts +38 -0
  71. package/dist/workflow/workflow-manager.d.ts.map +1 -0
  72. package/dist/workflow/workflow-manager.js +124 -0
  73. package/dist/workflow/workflow-manager.js.map +1 -0
  74. package/package.json +41 -0
@@ -0,0 +1,488 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _a, _TransactionCheckpoint_ALLOWED_STATE_TRANSITIONS, _TransactionCheckpoint_ALLOWED_STATUS_TRANSITIONS, _TransactionCheckpoint_mergeFlow, _TransactionCheckpoint_shouldUpdateStepState, _TransactionCheckpoint_mergeErrors, _DistributedTransaction_instances, _DistributedTransaction_temporaryStorage, _DistributedTransaction_serializeCheckpointData;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DistributedTransactionType = exports.DistributedTransaction = exports.TransactionPayload = exports.TransactionCheckpoint = exports.TransactionStepError = exports.TransactionContext = void 0;
10
+ const utils_1 = require("@acmekit/utils");
11
+ const events_1 = require("events");
12
+ const promises_1 = require("node:timers/promises");
13
+ const base_in_memory_storage_1 = require("./datastore/base-in-memory-storage");
14
+ const errors_1 = require("./errors");
15
+ const transaction_orchestrator_1 = require("./transaction-orchestrator");
16
+ const types_1 = require("./types");
17
+ const flowMergeableProperties = [
18
+ "state",
19
+ "hasFailedSteps",
20
+ "hasSkippedOnFailureSteps",
21
+ "hasSkippedSteps",
22
+ "hasRevertedSteps",
23
+ "cancelledAt",
24
+ "startedAt",
25
+ "hasAsyncSteps",
26
+ "_v",
27
+ "timedOutAt",
28
+ ];
29
+ const mergeStep = (currentStep, storedStep) => {
30
+ const mergeProperties = [
31
+ "attempts",
32
+ "failures",
33
+ "temporaryFailedAt",
34
+ "retryRescheduledAt",
35
+ "hasScheduledRetry",
36
+ "lastAttempt",
37
+ "_v",
38
+ "stepFailed",
39
+ "startedAt",
40
+ ];
41
+ for (const prop of mergeProperties) {
42
+ if (prop === "hasScheduledRetry" || prop === "stepFailed") {
43
+ currentStep[prop] = storedStep[prop] ?? currentStep[prop];
44
+ continue;
45
+ }
46
+ currentStep[prop] =
47
+ storedStep[prop] || currentStep[prop]
48
+ ? Math.max(storedStep[prop] ?? 0, currentStep[prop] ?? 0)
49
+ : currentStep[prop] ?? storedStep[prop];
50
+ }
51
+ };
52
+ const getErrorSignature = (err) => `${err.action}:${err.handlerType}:${err.error?.message}`;
53
+ /**
54
+ * @typedef TransactionContext
55
+ * @property payload - Object containing the initial payload.
56
+ * @property invoke - Object containing responses of Invoke handlers on steps flagged with saveResponse.
57
+ * @property compensate - Object containing responses of Compensate handlers on steps flagged with saveResponse.
58
+ */
59
+ class TransactionContext {
60
+ constructor(payload = undefined, invoke = {}, compensate = {}) {
61
+ this.payload = payload;
62
+ this.invoke = invoke;
63
+ this.compensate = compensate;
64
+ }
65
+ }
66
+ exports.TransactionContext = TransactionContext;
67
+ class TransactionStepError {
68
+ constructor(action, handlerType, error) {
69
+ this.action = action;
70
+ this.handlerType = handlerType;
71
+ this.error = error;
72
+ }
73
+ }
74
+ exports.TransactionStepError = TransactionStepError;
75
+ const stateFlowOrder = [
76
+ types_1.TransactionState.NOT_STARTED,
77
+ types_1.TransactionState.INVOKING,
78
+ types_1.TransactionState.DONE,
79
+ types_1.TransactionState.WAITING_TO_COMPENSATE,
80
+ types_1.TransactionState.COMPENSATING,
81
+ types_1.TransactionState.REVERTED,
82
+ types_1.TransactionState.FAILED,
83
+ ];
84
+ const stateFlowOrderMap = new Map(stateFlowOrder.map((state, index) => [state, index]));
85
+ const finishedStatesSet = new Set([
86
+ types_1.TransactionState.DONE,
87
+ types_1.TransactionState.REVERTED,
88
+ types_1.TransactionState.FAILED,
89
+ ]);
90
+ class TransactionCheckpoint {
91
+ constructor(flow, context, errors = []) {
92
+ this.flow = flow;
93
+ this.context = context;
94
+ this.errors = errors;
95
+ }
96
+ /**
97
+ * Merge the current checkpoint with incoming data from a concurrent save operation.
98
+ * This handles race conditions when multiple steps complete simultaneously.
99
+ *
100
+ * @param storedData - The checkpoint data being saved
101
+ * @param savingStepId - Optional step ID if this is a step-specific save
102
+ */
103
+ static mergeCheckpoints(currentTransactionData, storedData) {
104
+ if (!currentTransactionData || !storedData) {
105
+ return currentTransactionData;
106
+ }
107
+ __classPrivateFieldGet(_a, _a, "m", _TransactionCheckpoint_mergeFlow).call(_a, currentTransactionData, storedData);
108
+ __classPrivateFieldGet(_a, _a, "m", _TransactionCheckpoint_mergeErrors).call(_a, currentTransactionData.errors ?? [], storedData.errors);
109
+ return currentTransactionData;
110
+ }
111
+ }
112
+ exports.TransactionCheckpoint = TransactionCheckpoint;
113
+ _a = TransactionCheckpoint, _TransactionCheckpoint_mergeFlow = function _TransactionCheckpoint_mergeFlow(currentTransactionData, storedData) {
114
+ const currentTransactionContext = currentTransactionData.context;
115
+ const storedContext = storedData.context;
116
+ if (currentTransactionData.flow._v >= storedData.flow._v) {
117
+ for (const prop of flowMergeableProperties) {
118
+ if (prop === "startedAt" ||
119
+ prop === "cancelledAt" ||
120
+ prop === "timedOutAt") {
121
+ currentTransactionData.flow[prop] =
122
+ storedData.flow[prop] || currentTransactionData.flow[prop]
123
+ ? Math.max(storedData.flow[prop] ?? 0, currentTransactionData.flow[prop] ?? 0)
124
+ : currentTransactionData.flow[prop] ??
125
+ storedData.flow[prop] ??
126
+ undefined;
127
+ }
128
+ else if (prop === "_v") {
129
+ currentTransactionData.flow[prop] = Math.max(storedData.flow[prop] ?? 0, currentTransactionData.flow[prop] ?? 0);
130
+ }
131
+ else if (prop === "state") {
132
+ const currentStateIndex = stateFlowOrderMap.get(currentTransactionData.flow.state) ?? -1;
133
+ const storedStateIndex = stateFlowOrderMap.get(storedData.flow.state) ?? -1;
134
+ if (storedStateIndex > currentStateIndex) {
135
+ currentTransactionData.flow.state = storedData.flow.state;
136
+ }
137
+ else if (currentStateIndex < storedStateIndex &&
138
+ currentTransactionData.flow.state !==
139
+ types_1.TransactionState.WAITING_TO_COMPENSATE) {
140
+ throw new errors_1.SkipExecutionError(`Transaction is behind another execution`);
141
+ }
142
+ }
143
+ else if (storedData.flow[prop] &&
144
+ !currentTransactionData.flow[prop]) {
145
+ currentTransactionData.flow[prop] = storedData.flow[prop];
146
+ }
147
+ }
148
+ }
149
+ const storedSteps = Object.values(storedData.flow.steps);
150
+ for (const storedStep of storedSteps) {
151
+ if (storedStep.id === "_root") {
152
+ continue;
153
+ }
154
+ const stepName = storedStep.definition.action;
155
+ const stepId = storedStep.id;
156
+ // Merge context responses
157
+ if (storedContext.invoke[stepName] &&
158
+ !currentTransactionContext.invoke[stepName]) {
159
+ currentTransactionContext.invoke[stepName] =
160
+ storedContext.invoke[stepName];
161
+ }
162
+ if (storedContext.compensate[stepName] &&
163
+ !currentTransactionContext.compensate[stepName]) {
164
+ currentTransactionContext.compensate[stepName] =
165
+ storedContext.compensate[stepName];
166
+ }
167
+ const currentStepVersion = currentTransactionData.flow.steps[stepId]._v;
168
+ const storedStepVersion = storedData.flow.steps[stepId]._v;
169
+ if (storedStepVersion > currentStepVersion) {
170
+ throw new errors_1.SkipExecutionError(`Transaction is behind another execution`);
171
+ }
172
+ // Determine which state is further along in the process
173
+ const shouldUpdateInvoke = __classPrivateFieldGet(_a, _a, "m", _TransactionCheckpoint_shouldUpdateStepState).call(_a, currentTransactionData.flow.steps[stepId].invoke, storedStep.invoke);
174
+ const shouldUpdateCompensate = __classPrivateFieldGet(_a, _a, "m", _TransactionCheckpoint_shouldUpdateStepState).call(_a, currentTransactionData.flow.steps[stepId].compensate, storedStep.compensate);
175
+ if (shouldUpdateInvoke) {
176
+ currentTransactionData.flow.steps[stepId].invoke = storedStep.invoke;
177
+ }
178
+ if (shouldUpdateCompensate) {
179
+ currentTransactionData.flow.steps[stepId].compensate =
180
+ storedStep.compensate;
181
+ }
182
+ mergeStep(currentTransactionData.flow.steps[stepId], storedStep);
183
+ }
184
+ }, _TransactionCheckpoint_shouldUpdateStepState = function _TransactionCheckpoint_shouldUpdateStepState(currentStepState, storedStepState) {
185
+ if (currentStepState.state === storedStepState.state &&
186
+ currentStepState.status === storedStepState.status) {
187
+ return false;
188
+ }
189
+ // Check if state transition from stored to current is allowed
190
+ const allowedStatesFromCurrent = __classPrivateFieldGet(_a, _a, "f", _TransactionCheckpoint_ALLOWED_STATE_TRANSITIONS)[currentStepState.state] || [];
191
+ const isStateTransitionValid = allowedStatesFromCurrent.includes(storedStepState.state);
192
+ if (currentStepState.state !== storedStepState.state) {
193
+ return isStateTransitionValid;
194
+ }
195
+ // States are the same, check status transition
196
+ // Special case: WAITING status can always be transitioned
197
+ if (currentStepState.status === types_1.TransactionStepStatus.WAITING) {
198
+ return true;
199
+ }
200
+ // Check if status transition from stored to current is allowed
201
+ const allowedStatusesFromCurrent = __classPrivateFieldGet(_a, _a, "f", _TransactionCheckpoint_ALLOWED_STATUS_TRANSITIONS)[currentStepState.status] || [];
202
+ return allowedStatusesFromCurrent.includes(storedStepState.status);
203
+ }, _TransactionCheckpoint_mergeErrors = function _TransactionCheckpoint_mergeErrors(currentErrors, incomingErrors) {
204
+ const existingErrorSignatures = new Set(currentErrors.map(getErrorSignature));
205
+ for (const error of incomingErrors) {
206
+ if (!existingErrorSignatures.has(getErrorSignature(error))) {
207
+ currentErrors.push(error);
208
+ existingErrorSignatures.add(getErrorSignature(error));
209
+ }
210
+ }
211
+ };
212
+ _TransactionCheckpoint_ALLOWED_STATE_TRANSITIONS = { value: {
213
+ [utils_1.TransactionStepState.DORMANT]: [utils_1.TransactionStepState.NOT_STARTED],
214
+ [utils_1.TransactionStepState.NOT_STARTED]: [
215
+ utils_1.TransactionStepState.INVOKING,
216
+ utils_1.TransactionStepState.COMPENSATING,
217
+ utils_1.TransactionStepState.FAILED,
218
+ utils_1.TransactionStepState.SKIPPED,
219
+ utils_1.TransactionStepState.SKIPPED_FAILURE,
220
+ ],
221
+ [utils_1.TransactionStepState.INVOKING]: [
222
+ utils_1.TransactionStepState.FAILED,
223
+ utils_1.TransactionStepState.DONE,
224
+ utils_1.TransactionStepState.TIMEOUT,
225
+ utils_1.TransactionStepState.SKIPPED,
226
+ ],
227
+ [utils_1.TransactionStepState.COMPENSATING]: [
228
+ utils_1.TransactionStepState.REVERTED,
229
+ utils_1.TransactionStepState.FAILED,
230
+ ],
231
+ [utils_1.TransactionStepState.DONE]: [utils_1.TransactionStepState.COMPENSATING],
232
+ } };
233
+ _TransactionCheckpoint_ALLOWED_STATUS_TRANSITIONS = { value: {
234
+ [types_1.TransactionStepStatus.WAITING]: [
235
+ types_1.TransactionStepStatus.OK,
236
+ types_1.TransactionStepStatus.TEMPORARY_FAILURE,
237
+ types_1.TransactionStepStatus.PERMANENT_FAILURE,
238
+ ],
239
+ [types_1.TransactionStepStatus.TEMPORARY_FAILURE]: [
240
+ types_1.TransactionStepStatus.IDLE,
241
+ types_1.TransactionStepStatus.PERMANENT_FAILURE,
242
+ ],
243
+ [types_1.TransactionStepStatus.PERMANENT_FAILURE]: [types_1.TransactionStepStatus.IDLE],
244
+ } };
245
+ class TransactionPayload {
246
+ /**
247
+ * @param metadata - The metadata of the transaction.
248
+ * @param data - The initial payload data to begin a transation.
249
+ * @param context - Object gathering responses of all steps flagged with saveResponse.
250
+ */
251
+ constructor(metadata, data, context) {
252
+ this.metadata = metadata;
253
+ this.data = data;
254
+ this.context = context;
255
+ }
256
+ }
257
+ exports.TransactionPayload = TransactionPayload;
258
+ /**
259
+ * DistributedTransaction represents a distributed transaction, which is a transaction that is composed of multiple steps that are executed in a specific order.
260
+ */
261
+ class DistributedTransaction extends events_1.EventEmitter {
262
+ static setStorage(storage) {
263
+ this.keyValueStore = storage;
264
+ }
265
+ constructor(flow, handler, payload, errors, context) {
266
+ super();
267
+ _DistributedTransaction_instances.add(this);
268
+ this.flow = flow;
269
+ this.handler = handler;
270
+ this.payload = payload;
271
+ this.errors = [];
272
+ this.context = new TransactionContext();
273
+ /**
274
+ * Store data during the life cycle of the current transaction execution.
275
+ * Store non persistent data such as transformers results, temporary data, etc.
276
+ *
277
+ * @private
278
+ */
279
+ _DistributedTransaction_temporaryStorage.set(this, new Map());
280
+ this.transactionId = flow.transactionId;
281
+ this.modelId = flow.modelId;
282
+ this.runId = flow.runId;
283
+ if (errors) {
284
+ this.errors = errors;
285
+ }
286
+ this.context.payload = payload;
287
+ if (context) {
288
+ this.context = { ...context };
289
+ }
290
+ }
291
+ getFlow() {
292
+ return this.flow;
293
+ }
294
+ getContext() {
295
+ return this.context;
296
+ }
297
+ getErrors(handlerType) {
298
+ if (!(0, utils_1.isDefined)(handlerType)) {
299
+ return this.errors;
300
+ }
301
+ return this.errors.filter((error) => error.handlerType === handlerType);
302
+ }
303
+ addError(action, handlerType, error) {
304
+ this.errors.push({
305
+ action,
306
+ handlerType,
307
+ error,
308
+ });
309
+ }
310
+ addResponse(action, handlerType, response) {
311
+ this.context[handlerType][action] = response;
312
+ }
313
+ hasFinished() {
314
+ return finishedStatesSet.has(this.getState());
315
+ }
316
+ getState() {
317
+ return this.getFlow().state;
318
+ }
319
+ get isPartiallyCompleted() {
320
+ return !!this.getFlow().hasFailedSteps || !!this.getFlow().hasSkippedSteps;
321
+ }
322
+ canInvoke() {
323
+ return (this.getFlow().state === types_1.TransactionState.NOT_STARTED ||
324
+ this.getFlow().state === types_1.TransactionState.INVOKING);
325
+ }
326
+ canRevert() {
327
+ return (this.getFlow().state === types_1.TransactionState.DONE ||
328
+ this.getFlow().state === types_1.TransactionState.COMPENSATING);
329
+ }
330
+ hasTimeout() {
331
+ return !!this.getTimeout();
332
+ }
333
+ getTimeout() {
334
+ return this.getFlow().options?.timeout;
335
+ }
336
+ async saveCheckpoint({ ttl = 0, parallelSteps = 0, stepId, _v, } = {}) {
337
+ const options = {
338
+ ...(transaction_orchestrator_1.TransactionOrchestrator.getWorkflowOptions(this.modelId) ??
339
+ this.getFlow().options),
340
+ };
341
+ if (!options?.store) {
342
+ return;
343
+ }
344
+ options.stepId = stepId;
345
+ if (_v) {
346
+ options.parallelSteps = parallelSteps;
347
+ options._v = _v;
348
+ }
349
+ const key = transaction_orchestrator_1.TransactionOrchestrator.getKeyName(DistributedTransaction.keyPrefix, this.modelId, this.transactionId);
350
+ let checkpoint;
351
+ let retries = 0;
352
+ let backoffMs = 50;
353
+ const maxRetries = (options?.parallelSteps || 1) + 2;
354
+ while (retries < maxRetries) {
355
+ checkpoint = __classPrivateFieldGet(this, _DistributedTransaction_instances, "m", _DistributedTransaction_serializeCheckpointData).call(this);
356
+ try {
357
+ const savedCheckpoint = await DistributedTransaction.keyValueStore.save(key, checkpoint, ttl, options);
358
+ return savedCheckpoint;
359
+ }
360
+ catch (error) {
361
+ if (transaction_orchestrator_1.TransactionOrchestrator.isExpectedError(error)) {
362
+ throw error;
363
+ }
364
+ else if (checkpoint.flow.state === types_1.TransactionState.NOT_STARTED) {
365
+ throw new errors_1.SkipExecutionError("Transaction already started for transactionId: " +
366
+ this.transactionId);
367
+ }
368
+ retries++;
369
+ // Exponential backoff with jitter
370
+ const jitter = Math.random() * backoffMs;
371
+ await (0, promises_1.setTimeout)(backoffMs + jitter);
372
+ backoffMs = Math.min(backoffMs * 2, 500);
373
+ const lastCheckpoint = await DistributedTransaction.loadTransaction(this.modelId, this.transactionId);
374
+ if (!lastCheckpoint) {
375
+ throw new errors_1.SkipExecutionError("Transaction already finished");
376
+ }
377
+ TransactionCheckpoint.mergeCheckpoints(checkpoint, lastCheckpoint);
378
+ const [steps] = transaction_orchestrator_1.TransactionOrchestrator.buildSteps(checkpoint.flow.definition, checkpoint.flow.steps);
379
+ checkpoint.flow.steps = steps;
380
+ this.flow = checkpoint.flow;
381
+ this.errors = checkpoint.errors;
382
+ this.context = checkpoint.context;
383
+ continue;
384
+ }
385
+ }
386
+ throw new Error(`Max retries (${maxRetries}) exceeded for saving checkpoint due to version conflicts`);
387
+ }
388
+ static async loadTransaction(modelId, transactionId, options) {
389
+ const key = transaction_orchestrator_1.TransactionOrchestrator.getKeyName(DistributedTransaction.keyPrefix, modelId, transactionId);
390
+ const workflowOptions = transaction_orchestrator_1.TransactionOrchestrator.getWorkflowOptions(modelId);
391
+ const loadedData = await DistributedTransaction.keyValueStore.get(key, {
392
+ ...workflowOptions,
393
+ isCancelling: options?.isCancelling,
394
+ });
395
+ if (loadedData) {
396
+ return loadedData;
397
+ }
398
+ return null;
399
+ }
400
+ async scheduleRetry(step, interval) {
401
+ if (this.hasFinished()) {
402
+ return;
403
+ }
404
+ await DistributedTransaction.keyValueStore.scheduleRetry(this, step, Date.now(), interval);
405
+ }
406
+ async clearRetry(step) {
407
+ await DistributedTransaction.keyValueStore.clearRetry(this, step);
408
+ }
409
+ async scheduleTransactionTimeout(interval) {
410
+ // schedule transaction timeout only if there are async steps
411
+ if (!this.getFlow().hasAsyncSteps) {
412
+ return;
413
+ }
414
+ await DistributedTransaction.keyValueStore.scheduleTransactionTimeout(this, Date.now(), interval);
415
+ }
416
+ async clearTransactionTimeout() {
417
+ if (!this.getFlow().hasAsyncSteps) {
418
+ return;
419
+ }
420
+ await DistributedTransaction.keyValueStore.clearTransactionTimeout(this);
421
+ }
422
+ async scheduleStepTimeout(step, interval) {
423
+ // schedule step timeout only if the step is async
424
+ if (!step.definition.async) {
425
+ return;
426
+ }
427
+ await this.saveCheckpoint();
428
+ await DistributedTransaction.keyValueStore.scheduleStepTimeout(this, step, Date.now(), interval);
429
+ }
430
+ async clearStepTimeout(step) {
431
+ if (!step.definition.async || step.isCompensating()) {
432
+ return;
433
+ }
434
+ await DistributedTransaction.keyValueStore.clearStepTimeout(this, step);
435
+ }
436
+ setTemporaryData(key, value) {
437
+ __classPrivateFieldGet(this, _DistributedTransaction_temporaryStorage, "f").set(key, value);
438
+ }
439
+ getTemporaryData(key) {
440
+ return __classPrivateFieldGet(this, _DistributedTransaction_temporaryStorage, "f").get(key);
441
+ }
442
+ hasTemporaryData(key) {
443
+ return __classPrivateFieldGet(this, _DistributedTransaction_temporaryStorage, "f").has(key);
444
+ }
445
+ }
446
+ exports.DistributedTransactionType = DistributedTransaction;
447
+ _DistributedTransaction_temporaryStorage = new WeakMap(), _DistributedTransaction_instances = new WeakSet(), _DistributedTransaction_serializeCheckpointData = function _DistributedTransaction_serializeCheckpointData() {
448
+ try {
449
+ JSON.stringify(this.context);
450
+ }
451
+ catch {
452
+ throw new errors_1.NonSerializableCheckPointError("Unable to serialize context object. Please make sure the workflow input and steps response are serializable.");
453
+ }
454
+ let errorsToUse = this.getErrors();
455
+ try {
456
+ JSON.stringify(errorsToUse);
457
+ }
458
+ catch {
459
+ // Sanitize non-serializable errors
460
+ const sanitizedErrors = [];
461
+ for (const error of this.errors) {
462
+ try {
463
+ JSON.stringify(error);
464
+ sanitizedErrors.push(error);
465
+ }
466
+ catch {
467
+ sanitizedErrors.push({
468
+ action: error.action,
469
+ handlerType: error.handlerType,
470
+ error: {
471
+ name: error.error?.name || "Error",
472
+ message: error.error?.message || String(error.error),
473
+ stack: error.error?.stack,
474
+ },
475
+ });
476
+ }
477
+ }
478
+ errorsToUse = sanitizedErrors;
479
+ this.errors = sanitizedErrors;
480
+ }
481
+ return new TransactionCheckpoint(JSON.parse(JSON.stringify(this.getFlow())), this.getContext(), [...errorsToUse]);
482
+ };
483
+ DistributedTransaction.keyPrefix = "dtrx";
484
+ DistributedTransaction.setStorage(new base_in_memory_storage_1.BaseInMemoryDistributedTransactionStorage());
485
+ global.DistributedTransaction ??= DistributedTransaction;
486
+ const GlobalDistributedTransaction = global.DistributedTransaction;
487
+ exports.DistributedTransaction = GlobalDistributedTransaction;
488
+ //# sourceMappingURL=distributed-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributed-transaction.js","sourceRoot":"","sources":["../../src/transaction/distributed-transaction.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0CAAgE;AAChE,mCAAqC;AACrC,mDAAsE;AAEtE,+EAA8F;AAC9F,qCAA6E;AAC7E,yEAAoE;AAEpE,mCAKgB;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AT,CAAS;AAyVlC,sBAAsB,CAAC,UAAU,CAC/B,IAAI,kEAAyC,EAAE,CAChD,CAAA;AAED,MAAM,CAAC,sBAAsB,KAAK,sBAAsB,CAAA;AACxD,MAAM,4BAA4B,GAChC,MAAM,CAAC,sBAAuD,CAAA;AAG9B,8DAAsB"}
@@ -0,0 +1,41 @@
1
+ declare class BaseStepErrror extends Error {
2
+ #private;
3
+ constructor(name: any, message?: string, stepResponse?: unknown);
4
+ getStepResponse(): unknown;
5
+ }
6
+ export declare class PermanentStepFailureError extends BaseStepErrror {
7
+ static isPermanentStepFailureError(error: Error): error is PermanentStepFailureError;
8
+ constructor(message?: string, stepResponse?: unknown);
9
+ }
10
+ export declare class SkipStepResponse extends BaseStepErrror {
11
+ static isSkipStepResponse(error: Error): error is SkipStepResponse;
12
+ constructor(message?: string, stepResponse?: unknown);
13
+ }
14
+ export declare class TransactionStepTimeoutError extends BaseStepErrror {
15
+ static isTransactionStepTimeoutError(error: Error): error is TransactionStepTimeoutError;
16
+ constructor(message?: string, stepResponse?: unknown);
17
+ }
18
+ export declare class TransactionTimeoutError extends BaseStepErrror {
19
+ static isTransactionTimeoutError(error: Error): error is TransactionTimeoutError;
20
+ constructor(message?: string, stepResponse?: unknown);
21
+ }
22
+ export declare class NonSerializableCheckPointError extends Error {
23
+ static isNonSerializableCheckPointError(error: Error): error is NonSerializableCheckPointError;
24
+ constructor(message?: string);
25
+ }
26
+ export declare class SkipExecutionError extends Error {
27
+ static isSkipExecutionError(error: Error): error is SkipExecutionError;
28
+ constructor(message?: string);
29
+ }
30
+ export declare class SkipStepAlreadyFinishedError extends Error {
31
+ static isSkipStepAlreadyFinishedError(error: Error): error is SkipStepAlreadyFinishedError;
32
+ constructor(message?: string);
33
+ }
34
+ export declare class SkipCancelledExecutionError extends Error {
35
+ #private;
36
+ get __type(): string;
37
+ static isSkipCancelledExecutionError(error: Error): error is SkipCancelledExecutionError;
38
+ constructor(message?: string);
39
+ }
40
+ export {};
41
+ //# sour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