@fluidgrids/workflows 2026.1027.0 → 2026.1028.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.
- package/README.md +170 -18
- package/dist/activation-BBh1p82z.d.cts +57 -0
- package/dist/activation-DnhG7SmF.d.ts +57 -0
- package/dist/assemble-BLqQ8lSu.d.cts +39 -0
- package/dist/assemble-DWgaXHd-.d.ts +39 -0
- package/dist/chunk-2DP2Y6EU.cjs +832 -0
- package/dist/chunk-2J6TF7YI.cjs +86 -0
- package/dist/chunk-3FOTFQ3J.js +1622 -0
- package/dist/chunk-4LYSEANA.js +199 -0
- package/dist/{chunk-KUTMY2IO.cjs → chunk-57MSZ24T.cjs} +162 -98
- package/dist/{chunk-BWSLWF2E.js → chunk-5HDSBTBX.js} +99 -32
- package/dist/chunk-623FVQSN.cjs +251 -0
- package/dist/{chunk-4DPEGDPW.js → chunk-6FSHT5IL.js} +4 -4
- package/dist/{chunk-REV7ZOA4.js → chunk-7AAZGVKD.js} +1 -35
- package/dist/chunk-7NQ37GZU.js +73 -0
- package/dist/chunk-ABFZWYHT.js +612 -0
- package/dist/{chunk-SS4LT2IP.js → chunk-BD7ZPG53.js} +5 -10
- package/dist/chunk-BO6OVILK.js +79 -0
- package/dist/chunk-C5OLWZ42.js +245 -0
- package/dist/chunk-CBL5JSCC.cjs +75 -0
- package/dist/{chunk-LSKSBVL4.cjs → chunk-CPDK3K5N.cjs} +6 -6
- package/dist/chunk-CSNWNFKU.cjs +1635 -0
- package/dist/chunk-DJYMDLV5.js +227 -0
- package/dist/{chunk-X4HKU3MX.js → chunk-E2VK7J2C.js} +3 -1
- package/dist/chunk-FMSW2HDF.cjs +267 -0
- package/dist/chunk-FQIHX7YI.cjs +80 -0
- package/dist/chunk-FR7KYWRO.cjs +41 -0
- package/dist/{chunk-AU3YW7FZ.cjs → chunk-GBQ33SIZ.cjs} +46 -51
- package/dist/{chunk-RRQ5HOBF.cjs → chunk-GVTZMA5C.cjs} +4 -4
- package/dist/chunk-H7KEVW2M.js +816 -0
- package/dist/chunk-HR3BN4C4.cjs +27 -0
- package/dist/chunk-IISBRUWJ.js +13 -0
- package/dist/chunk-JD2VQIDZ.cjs +15 -0
- package/dist/{chunk-PL73GJR4.js → chunk-JZ4TOOLN.js} +1 -1
- package/dist/chunk-L24YIZY7.cjs +207 -0
- package/dist/chunk-LNUQE6D6.js +39 -0
- package/dist/{chunk-BYJ7QTLY.cjs → chunk-NEIUQASE.cjs} +13 -13
- package/dist/chunk-P6TA5EZT.cjs +634 -0
- package/dist/chunk-PDHLTDZB.js +72 -0
- package/dist/chunk-PMCM2OH4.js +46 -0
- package/dist/chunk-PZCVF76Q.cjs +868 -0
- package/dist/{chunk-GO34UHSY.js → chunk-QAN5MZEM.js} +3 -3
- package/dist/{chunk-27HASETB.cjs → chunk-QKZL3ONM.cjs} +3 -1
- package/dist/chunk-SAENRNBJ.cjs +52 -0
- package/dist/{chunk-LMX35GNQ.js → chunk-SMCANK3F.js} +5 -4
- package/dist/{chunk-IZQNUNSU.cjs → chunk-SX2PNKKT.cjs} +18 -17
- package/dist/{chunk-LRM6JXJA.cjs → chunk-TBDXTV22.cjs} +0 -37
- package/dist/chunk-VOKMAAJP.js +848 -0
- package/dist/chunk-XB53G2DK.js +25 -0
- package/dist/chunk-Z2Y65YOY.cjs +7 -0
- package/dist/codegen/index.cjs +9 -7
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/codegen/index.js +6 -5
- package/dist/file-BOoHZgoQ.d.cts +1557 -0
- package/dist/file-yuPCFU5b.d.ts +1557 -0
- package/dist/history/index.cjs +287 -0
- package/dist/history/index.d.cts +157 -0
- package/dist/history/index.d.ts +157 -0
- package/dist/history/index.js +5 -0
- package/dist/index.cjs +134 -36
- package/dist/index.d.cts +137 -9
- package/dist/index.d.ts +137 -9
- package/dist/index.js +8 -3
- package/dist/ir/index.cjs +161 -165
- package/dist/ir/index.d.cts +32 -12
- package/dist/ir/index.d.ts +32 -12
- package/dist/ir/index.js +54 -61
- package/dist/lower-BuSvAFqi.d.cts +129 -0
- package/dist/lower-C_Qv_34S.d.ts +129 -0
- package/dist/lower-types-nofRXw9c.d.cts +15 -0
- package/dist/lower-types-nofRXw9c.d.ts +15 -0
- package/dist/{manifest-Duf-gHdO.d.cts → manifest-0OLw0i7k.d.cts} +1 -1
- package/dist/{manifest-Bp9ZJlav.d.ts → manifest-C8N6HDYl.d.ts} +1 -1
- package/dist/node-evaluator-CJNP4GHX.js +12 -0
- package/dist/node-evaluator-DMKPKUWA.cjs +22 -0
- package/dist/quickjs/index.cjs +256 -78
- package/dist/quickjs/index.d.cts +48 -7
- package/dist/quickjs/index.d.ts +48 -7
- package/dist/quickjs/index.js +254 -79
- package/dist/roundtrip/index.cjs +404 -129
- package/dist/roundtrip/index.d.cts +43 -8
- package/dist/roundtrip/index.d.ts +43 -8
- package/dist/roundtrip/index.js +260 -19
- package/dist/runtime/index.cjs +90 -0
- package/dist/runtime/index.d.cts +297 -0
- package/dist/runtime/index.d.ts +297 -0
- package/dist/runtime/index.js +8 -0
- package/dist/testing/index.cjs +1057 -0
- package/dist/testing/index.d.cts +305 -0
- package/dist/testing/index.d.ts +305 -0
- package/dist/testing/index.js +1037 -0
- package/dist/{types-Dr2Fn1Ax.d.ts → types-BGoPzgcl.d.cts} +1 -1
- package/dist/{types-Dr2Fn1Ax.d.cts → types-BGoPzgcl.d.ts} +1 -1
- package/dist/types-CpBBjaGX.d.cts +380 -0
- package/dist/types-DV-HX_Gt.d.ts +380 -0
- package/dist/{assemble-DMOuaxRI.d.ts → workflow-Bpr3vnA_.d.ts} +60 -162
- package/dist/workflow-C2a05WUJ.d.ts +444 -0
- package/dist/{assemble-BJo9TECS.d.cts → workflow-FXUkpIBc.d.cts} +60 -162
- package/dist/workflow-J-yYixny.d.cts +444 -0
- package/fixtures/README.md +128 -0
- package/fixtures/histories/activity-failure-fails-run.history.json +163 -0
- package/fixtures/histories/activity-retry-then-success.history.json +147 -0
- package/fixtures/histories/cancel-activity-abandon.history.json +126 -0
- package/fixtures/histories/cancel-activity-compensate.history.json +307 -0
- package/fixtures/histories/cancel-concurrent-non-cancellable.history.json +234 -0
- package/fixtures/histories/cancel-concurrent-scope-timeout.history.json +184 -0
- package/fixtures/histories/cancel-condition-after-cancel.history.json +200 -0
- package/fixtures/histories/cancel-during-timer.history.json +123 -0
- package/fixtures/histories/cancel-saga-compensations.history.json +325 -0
- package/fixtures/histories/cancel-scope-timeout.history.json +148 -0
- package/fixtures/histories/child-abandon-outlives-parent.history.json +191 -0
- package/fixtures/histories/child-cancel-default.history.json +234 -0
- package/fixtures/histories/child-cancel-request.history.json +206 -0
- package/fixtures/histories/child-durable-child-side.history.json +124 -0
- package/fixtures/histories/child-durable-result.history.json +163 -0
- package/fixtures/histories/child-failure-caught.history.json +166 -0
- package/fixtures/histories/child-graph-by-key.history.json +138 -0
- package/fixtures/histories/child-terminated-by-parent-close.history.json +85 -0
- package/fixtures/histories/continue-as-new-first-run.history.json +146 -0
- package/fixtures/histories/continue-as-new-history-limit.history.json +489 -0
- package/fixtures/histories/continue-as-new-last-run.history.json +147 -0
- package/fixtures/histories/continue-as-new-suggested.history.json +352 -0
- package/fixtures/histories/details-and-context.history.json +176 -0
- package/fixtures/histories/deterministic-values.history.json +128 -0
- package/fixtures/histories/engine-builtins.history.json +172 -0
- package/fixtures/histories/gather-activities.history.json +291 -0
- package/fixtures/histories/gather-all-settled.history.json +219 -0
- package/fixtures/histories/gather-mixed.history.json +281 -0
- package/fixtures/histories/input-during-running-task.history.json +111 -0
- package/fixtures/histories/nondeterminism-reordered.history.json +218 -0
- package/fixtures/histories/patched-deprecated.history.json +271 -0
- package/fixtures/histories/patched-new-run.history.json +270 -0
- package/fixtures/histories/patched-old-history.history.json +190 -0
- package/fixtures/histories/race-activity-wins.history.json +152 -0
- package/fixtures/histories/race-signal-beats-child.history.json +161 -0
- package/fixtures/histories/race-timeout-wins.history.json +118 -0
- package/fixtures/histories/side-effect-recorded.history.json +153 -0
- package/fixtures/histories/signal-buffered-at-start.history.json +157 -0
- package/fixtures/histories/signal-default-handler.history.json +187 -0
- package/fixtures/histories/signal-handler.history.json +191 -0
- package/fixtures/histories/signal-parent-child-side.history.json +132 -0
- package/fixtures/histories/signal-parent.history.json +202 -0
- package/fixtures/histories/signal-run-delivered.history.json +128 -0
- package/fixtures/histories/signal-run-undelivered.history.json +134 -0
- package/fixtures/histories/signal-wait.history.json +111 -0
- package/fixtures/histories/task-failure-code-error.history.json +137 -0
- package/fixtures/histories/task-failure-then-transient-attempt.history.json +140 -0
- package/fixtures/histories/timer-condition-met.history.json +201 -0
- package/fixtures/histories/timer-condition-timeout.history.json +118 -0
- package/fixtures/histories/timer-sleep-once.history.json +118 -0
- package/fixtures/histories/timer-sleep-sequence.history.json +210 -0
- package/fixtures/histories/update-accepted-completed.history.json +149 -0
- package/fixtures/histories/update-with-start-rejected-validation.history.json +91 -0
- package/package.json +85 -20
- package/schema/history-file.schema.json +2544 -0
- package/schema/ir-v2.schema.json +16 -0
- package/schema/run-event.schema.json +2374 -0
- package/schema/workflow-command.schema.json +1095 -0
- package/schema/workflow-task.schema.json +3560 -0
- package/dist/chunk-265J2FCH.cjs +0 -33
- package/dist/chunk-LUXCXFOE.cjs +0 -269
- package/dist/chunk-S34NJE3A.js +0 -262
- package/dist/chunk-SRQRLWOS.js +0 -31
- package/dist/lower-DcOY8ux0.d.cts +0 -49
- package/dist/lower-Dw5grNrI.d.ts +0 -49
- package/dist/node-evaluator-2GTUZVPK.cjs +0 -17
- package/dist/node-evaluator-RMYEWCXZ.js +0 -8
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk623FVQSN_cjs = require('./chunk-623FVQSN.cjs');
|
|
4
|
+
var chunk2J6TF7YI_cjs = require('./chunk-2J6TF7YI.cjs');
|
|
5
|
+
|
|
6
|
+
// src/history/commands.ts
|
|
7
|
+
function isCommandEnabled(type, enabled = "core") {
|
|
8
|
+
if (chunk623FVQSN_cjs.PHASE_C_COMMANDS.has(type)) return false;
|
|
9
|
+
if (chunk623FVQSN_cjs.PHASE_B_CORE_COMMANDS.has(type)) return true;
|
|
10
|
+
return enabled === "parity" && chunk623FVQSN_cjs.PHASE_B_PARITY_COMMANDS.has(type);
|
|
11
|
+
}
|
|
12
|
+
function isWorkflowCommandEnabled(command, enabled = "core") {
|
|
13
|
+
if (command.type === "REQUEST_CANCEL_EXTERNAL_RUN" && "childId" in command.target) return true;
|
|
14
|
+
return isCommandEnabled(command.type, enabled);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/history/activation.ts
|
|
18
|
+
function timeOf(event) {
|
|
19
|
+
const startedAt = event.payload["startedAt"];
|
|
20
|
+
const text = typeof startedAt === "string" ? startedAt : event.createdAt;
|
|
21
|
+
const ms = Date.parse(text);
|
|
22
|
+
return Number.isFinite(ms) ? ms : 0;
|
|
23
|
+
}
|
|
24
|
+
function cutoffOf(event) {
|
|
25
|
+
const leased = event.payload["historyLength"];
|
|
26
|
+
return typeof leased === "number" && leased < event.seq ? leased : event.seq;
|
|
27
|
+
}
|
|
28
|
+
function walk(history) {
|
|
29
|
+
const activations = [];
|
|
30
|
+
let pending = [];
|
|
31
|
+
let started;
|
|
32
|
+
let afterStarted = [];
|
|
33
|
+
let last;
|
|
34
|
+
for (const event of history) {
|
|
35
|
+
switch (event.type) {
|
|
36
|
+
case "WORKFLOW_TASK_STARTED":
|
|
37
|
+
if (started) pending.push(...afterStarted);
|
|
38
|
+
started = event;
|
|
39
|
+
afterStarted = [];
|
|
40
|
+
continue;
|
|
41
|
+
case "WORKFLOW_TASK_FAILED":
|
|
42
|
+
case "WORKFLOW_TASK_TIMED_OUT":
|
|
43
|
+
if (started) pending.push(...afterStarted);
|
|
44
|
+
started = void 0;
|
|
45
|
+
afterStarted = [];
|
|
46
|
+
continue;
|
|
47
|
+
case "WORKFLOW_TASK_COMPLETED": {
|
|
48
|
+
const taskId = typeof event.payload["taskId"] === "string" ? event.payload["taskId"] : "";
|
|
49
|
+
const boundary = started !== void 0 && started.payload["taskId"] === event.payload["taskId"] ? started : event;
|
|
50
|
+
const cutoff = boundary === event ? event.seq : cutoffOf(boundary);
|
|
51
|
+
const seen = pending.filter((input) => input.seq <= cutoff);
|
|
52
|
+
const later = pending.filter((input) => input.seq > cutoff);
|
|
53
|
+
last = {
|
|
54
|
+
inputs: seen,
|
|
55
|
+
recorded: [],
|
|
56
|
+
timeMs: timeOf(boundary),
|
|
57
|
+
taskId,
|
|
58
|
+
historyLength: cutoff
|
|
59
|
+
};
|
|
60
|
+
activations.push(last);
|
|
61
|
+
pending = [...later, ...afterStarted];
|
|
62
|
+
started = void 0;
|
|
63
|
+
afterStarted = [];
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (chunk623FVQSN_cjs.isInputEvent(event)) {
|
|
68
|
+
if (started) afterStarted.push(event);
|
|
69
|
+
else pending.push(event);
|
|
70
|
+
} else if (chunk623FVQSN_cjs.isCommandEvent(event) && last?.recorded) {
|
|
71
|
+
last.recorded.push(event);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { activations, pending, started, afterStarted };
|
|
75
|
+
}
|
|
76
|
+
function splitActivations(history, nowMs, includeOpen) {
|
|
77
|
+
const { activations, pending, started } = walk(history);
|
|
78
|
+
if (includeOpen) {
|
|
79
|
+
const cutoff = started ? cutoffOf(started) : history.length;
|
|
80
|
+
const inputs = pending.filter((input) => input.seq <= cutoff);
|
|
81
|
+
activations.push({ inputs, recorded: void 0, timeMs: nowMs, historyLength: cutoff });
|
|
82
|
+
}
|
|
83
|
+
return activations;
|
|
84
|
+
}
|
|
85
|
+
function unseenInputs(history) {
|
|
86
|
+
const { pending, afterStarted } = walk(history);
|
|
87
|
+
return [...pending, ...afterStarted].sort((a, b) => a.seq - b.seq);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/history/apply.ts
|
|
91
|
+
var HistoryStateError = class extends Error {
|
|
92
|
+
constructor(message, seq) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.seq = seq;
|
|
95
|
+
this.name = "HistoryStateError";
|
|
96
|
+
}
|
|
97
|
+
seq;
|
|
98
|
+
};
|
|
99
|
+
function initialRunState() {
|
|
100
|
+
return {
|
|
101
|
+
status: "RUNNING",
|
|
102
|
+
historyLength: 0,
|
|
103
|
+
historyBytes: 0,
|
|
104
|
+
cancelRequested: false,
|
|
105
|
+
task: { state: "NONE", attempt: 0 },
|
|
106
|
+
completedTasks: 0,
|
|
107
|
+
taskFailures: 0,
|
|
108
|
+
activities: {},
|
|
109
|
+
timers: {},
|
|
110
|
+
children: {},
|
|
111
|
+
externals: {},
|
|
112
|
+
sideEffects: {},
|
|
113
|
+
markers: {},
|
|
114
|
+
signalsReceived: 0,
|
|
115
|
+
context: {}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function utf8Bytes(text) {
|
|
119
|
+
let bytes = 0;
|
|
120
|
+
for (let index = 0; index < text.length; index++) {
|
|
121
|
+
const unit = text.charCodeAt(index);
|
|
122
|
+
if (unit < 128) bytes += 1;
|
|
123
|
+
else if (unit < 2048) bytes += 2;
|
|
124
|
+
else if (unit >= 55296 && unit <= 56319 && index + 1 < text.length) {
|
|
125
|
+
const next = text.charCodeAt(index + 1);
|
|
126
|
+
if (next >= 56320 && next <= 57343) {
|
|
127
|
+
bytes += 4;
|
|
128
|
+
index++;
|
|
129
|
+
} else bytes += 3;
|
|
130
|
+
} else bytes += 3;
|
|
131
|
+
}
|
|
132
|
+
return bytes;
|
|
133
|
+
}
|
|
134
|
+
function str(payload, key) {
|
|
135
|
+
const value = payload[key];
|
|
136
|
+
return typeof value === "string" ? value : "";
|
|
137
|
+
}
|
|
138
|
+
function failureOf(payload) {
|
|
139
|
+
const value = payload["failure"];
|
|
140
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
var OPEN_ACTIVITY = /* @__PURE__ */ new Set([
|
|
144
|
+
"SCHEDULED",
|
|
145
|
+
"STARTED",
|
|
146
|
+
"CANCEL_REQUESTED"
|
|
147
|
+
]);
|
|
148
|
+
function isActivityOpen(activity2) {
|
|
149
|
+
return OPEN_ACTIVITY.has(activity2.status);
|
|
150
|
+
}
|
|
151
|
+
function isChildOpen(child2) {
|
|
152
|
+
return child2.status === "INITIATED" || child2.status === "STARTED";
|
|
153
|
+
}
|
|
154
|
+
function activity(state, event) {
|
|
155
|
+
const id = str(event.payload, "activityId");
|
|
156
|
+
const found = state.activities[id];
|
|
157
|
+
if (!found) throw new HistoryStateError(`${event.type} for unknown activity "${id}"`, event.seq);
|
|
158
|
+
return found;
|
|
159
|
+
}
|
|
160
|
+
function child(state, event) {
|
|
161
|
+
const id = str(event.payload, "childId");
|
|
162
|
+
const found = state.children[id];
|
|
163
|
+
if (!found) throw new HistoryStateError(`${event.type} for unknown child "${id}"`, event.seq);
|
|
164
|
+
return found;
|
|
165
|
+
}
|
|
166
|
+
function timer(state, event) {
|
|
167
|
+
const id = str(event.payload, "timerId");
|
|
168
|
+
const found = state.timers[id];
|
|
169
|
+
if (!found) throw new HistoryStateError(`${event.type} for unknown timer "${id}"`, event.seq);
|
|
170
|
+
return found;
|
|
171
|
+
}
|
|
172
|
+
function applyEvent(state, event) {
|
|
173
|
+
if (event.seq !== state.historyLength + 1)
|
|
174
|
+
throw new HistoryStateError(
|
|
175
|
+
`Event seq ${event.seq} follows ${state.historyLength}; history must be gapless`,
|
|
176
|
+
event.seq
|
|
177
|
+
);
|
|
178
|
+
if (state.status !== "RUNNING" && event.type !== "WORKFLOW_TASK_FAILED")
|
|
179
|
+
throw new HistoryStateError(`${event.type} after the run ended (${state.status})`, event.seq);
|
|
180
|
+
state.historyLength = event.seq;
|
|
181
|
+
state.historyBytes += utf8Bytes(JSON.stringify(event.payload));
|
|
182
|
+
state.lastEventAt = event.createdAt;
|
|
183
|
+
const p = event.payload;
|
|
184
|
+
switch (event.type) {
|
|
185
|
+
case "WORKFLOW_STARTED":
|
|
186
|
+
if (event.seq !== 1)
|
|
187
|
+
throw new HistoryStateError("WORKFLOW_STARTED must be the first event", event.seq);
|
|
188
|
+
state.workflowFn = str(p, "workflowFn");
|
|
189
|
+
state.input = p["input"] ?? null;
|
|
190
|
+
if (typeof p["context"] === "object" && p["context"] !== null && !Array.isArray(p["context"]))
|
|
191
|
+
state.context = { ...p["context"] };
|
|
192
|
+
break;
|
|
193
|
+
case "WORKFLOW_TASK_SCHEDULED":
|
|
194
|
+
state.task = { state: "SCHEDULED", taskId: str(p, "taskId"), attempt: state.task.attempt };
|
|
195
|
+
break;
|
|
196
|
+
case "WORKFLOW_TASK_STARTED": {
|
|
197
|
+
const attempt = typeof p["attempt"] === "number" ? p["attempt"] : 1;
|
|
198
|
+
state.task = { state: "STARTED", taskId: str(p, "taskId"), attempt };
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "WORKFLOW_TASK_COMPLETED":
|
|
202
|
+
state.task = { state: "NONE", attempt: 0 };
|
|
203
|
+
state.completedTasks += 1;
|
|
204
|
+
state.taskFailures = 0;
|
|
205
|
+
break;
|
|
206
|
+
case "WORKFLOW_TASK_FAILED":
|
|
207
|
+
case "WORKFLOW_TASK_TIMED_OUT":
|
|
208
|
+
state.taskFailures += 1;
|
|
209
|
+
if (state.status === "RUNNING")
|
|
210
|
+
state.task = { state: "SCHEDULED", taskId: str(p, "taskId"), attempt: state.task.attempt };
|
|
211
|
+
break;
|
|
212
|
+
case "ACTIVITY_SCHEDULED": {
|
|
213
|
+
const id = str(p, "activityId");
|
|
214
|
+
if (state.activities[id])
|
|
215
|
+
throw new HistoryStateError(`Activity "${id}" is scheduled twice`, event.seq);
|
|
216
|
+
state.activities[id] = {
|
|
217
|
+
status: "SCHEDULED",
|
|
218
|
+
attempt: 0,
|
|
219
|
+
nodeType: str(p, "nodeType"),
|
|
220
|
+
operation: str(p, "operation"),
|
|
221
|
+
scheduledSeq: event.seq,
|
|
222
|
+
...typeof p["cancellationType"] === "string" ? { cancellationType: p["cancellationType"] } : {},
|
|
223
|
+
...typeof p["summary"] === "string" ? { summary: p["summary"] } : {}
|
|
224
|
+
};
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "ACTIVITY_STARTED": {
|
|
228
|
+
const found = activity(state, event);
|
|
229
|
+
if (found.status === "SCHEDULED") found.status = "STARTED";
|
|
230
|
+
found.attempt = typeof p["attempt"] === "number" ? p["attempt"] : found.attempt + 1;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case "ACTIVITY_HEARTBEAT":
|
|
234
|
+
case "ACTIVITY_PAUSED":
|
|
235
|
+
case "ACTIVITY_UNPAUSED":
|
|
236
|
+
case "ACTIVITY_RESET":
|
|
237
|
+
case "ACTIVITY_OPTIONS_UPDATED":
|
|
238
|
+
activity(state, event);
|
|
239
|
+
break;
|
|
240
|
+
case "ACTIVITY_COMPLETED":
|
|
241
|
+
case "ACTIVITY_FAILED":
|
|
242
|
+
case "ACTIVITY_TIMED_OUT":
|
|
243
|
+
case "ACTIVITY_CANCELLED": {
|
|
244
|
+
const found = activity(state, event);
|
|
245
|
+
if (!isActivityOpen(found))
|
|
246
|
+
throw new HistoryStateError(
|
|
247
|
+
`${event.type} for activity "${str(p, "activityId")}" that is already ${found.status}`,
|
|
248
|
+
event.seq
|
|
249
|
+
);
|
|
250
|
+
found.status = event.type === "ACTIVITY_COMPLETED" ? "COMPLETED" : event.type === "ACTIVITY_FAILED" ? "FAILED" : event.type === "ACTIVITY_TIMED_OUT" ? "TIMED_OUT" : "CANCELLED";
|
|
251
|
+
if (typeof p["attempt"] === "number") found.attempt = p["attempt"];
|
|
252
|
+
const failure = failureOf(p);
|
|
253
|
+
if (failure) found.lastFailure = failure;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case "ACTIVITY_CANCEL_REQUESTED": {
|
|
257
|
+
const found = activity(state, event);
|
|
258
|
+
if (isActivityOpen(found)) found.status = "CANCEL_REQUESTED";
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case "TIMER_STARTED": {
|
|
262
|
+
const id = str(p, "timerId");
|
|
263
|
+
if (state.timers[id])
|
|
264
|
+
throw new HistoryStateError(`Timer "${id}" is started twice`, event.seq);
|
|
265
|
+
state.timers[id] = {
|
|
266
|
+
status: "PENDING",
|
|
267
|
+
durationMs: typeof p["durationMs"] === "number" ? p["durationMs"] : 0,
|
|
268
|
+
fireAt: str(p, "fireAt"),
|
|
269
|
+
startedSeq: event.seq,
|
|
270
|
+
...typeof p["summary"] === "string" ? { summary: p["summary"] } : {}
|
|
271
|
+
};
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case "TIMER_FIRED":
|
|
275
|
+
case "TIMER_CANCELLED": {
|
|
276
|
+
const found = timer(state, event);
|
|
277
|
+
if (found.status !== "PENDING")
|
|
278
|
+
throw new HistoryStateError(
|
|
279
|
+
`${event.type} for timer "${str(p, "timerId")}" that is already ${found.status}`,
|
|
280
|
+
event.seq
|
|
281
|
+
);
|
|
282
|
+
found.status = event.type === "TIMER_FIRED" ? "FIRED" : "CANCELLED";
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
case "SIGNAL_RECEIVED":
|
|
286
|
+
state.signalsReceived += 1;
|
|
287
|
+
break;
|
|
288
|
+
case "CHILD_RUN_INITIATED": {
|
|
289
|
+
const id = str(p, "childId");
|
|
290
|
+
if (state.children[id])
|
|
291
|
+
throw new HistoryStateError(`Child "${id}" is started twice`, event.seq);
|
|
292
|
+
const options = p["options"];
|
|
293
|
+
const policy = typeof options === "object" && options !== null && !Array.isArray(options) ? options["parentClosePolicy"] : void 0;
|
|
294
|
+
state.children[id] = {
|
|
295
|
+
status: "INITIATED",
|
|
296
|
+
parentClosePolicy: policy === "ABANDON" || policy === "REQUEST_CANCEL" ? policy : "TERMINATE",
|
|
297
|
+
initiatedSeq: event.seq,
|
|
298
|
+
...typeof p["workflowKey"] === "string" ? { workflowKey: p["workflowKey"] } : {},
|
|
299
|
+
...typeof p["workflowFn"] === "string" ? { workflowFn: p["workflowFn"] } : {},
|
|
300
|
+
...typeof p["childRunId"] === "string" ? { childRunId: p["childRunId"] } : {}
|
|
301
|
+
};
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
case "CHILD_RUN_STARTED": {
|
|
305
|
+
const found = child(state, event);
|
|
306
|
+
if (found.status !== "INITIATED")
|
|
307
|
+
throw new HistoryStateError(`Child "${str(p, "childId")}" started twice`, event.seq);
|
|
308
|
+
found.status = "STARTED";
|
|
309
|
+
found.childRunId = str(p, "childRunId");
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case "CHILD_RUN_COMPLETED":
|
|
313
|
+
case "CHILD_RUN_FAILED":
|
|
314
|
+
case "CHILD_RUN_CANCELLED":
|
|
315
|
+
case "CHILD_RUN_TERMINATED":
|
|
316
|
+
case "CHILD_RUN_TIMED_OUT": {
|
|
317
|
+
const found = child(state, event);
|
|
318
|
+
if (!isChildOpen(found))
|
|
319
|
+
throw new HistoryStateError(
|
|
320
|
+
`${event.type} for child "${str(p, "childId")}" that is already ${found.status}`,
|
|
321
|
+
event.seq
|
|
322
|
+
);
|
|
323
|
+
found.status = event.type.slice("CHILD_RUN_".length);
|
|
324
|
+
if (typeof p["childRunId"] === "string") found.childRunId = p["childRunId"];
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case "EXTERNAL_RUN_SIGNALED":
|
|
328
|
+
case "EXTERNAL_RUN_CANCEL_REQUESTED":
|
|
329
|
+
case "EXTERNAL_RUN_CANCEL_RESOLVED": {
|
|
330
|
+
const id = str(p, "externalId");
|
|
331
|
+
const resolving = event.type === "EXTERNAL_RUN_CANCEL_RESOLVED" || event.type === "EXTERNAL_RUN_SIGNALED" && p["resolved"] === true;
|
|
332
|
+
if (resolving) {
|
|
333
|
+
const found = state.externals[id];
|
|
334
|
+
if (!found || found.status !== "PENDING")
|
|
335
|
+
throw new HistoryStateError(`${event.type} for unknown or resolved "${id}"`, event.seq);
|
|
336
|
+
found.status = "RESOLVED";
|
|
337
|
+
found.ok = p["ok"] === true;
|
|
338
|
+
} else {
|
|
339
|
+
if (state.externals[id])
|
|
340
|
+
throw new HistoryStateError(`External operation "${id}" is issued twice`, event.seq);
|
|
341
|
+
state.externals[id] = {
|
|
342
|
+
kind: event.type === "EXTERNAL_RUN_SIGNALED" ? "signal" : "cancel",
|
|
343
|
+
status: "PENDING"
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
case "SIDE_EFFECT_RECORDED":
|
|
349
|
+
state.sideEffects[str(p, "sideEffectId")] = p["value"] ?? null;
|
|
350
|
+
break;
|
|
351
|
+
case "MARKER_RECORDED":
|
|
352
|
+
state.markers[str(p, "markerId")] = p["data"] ?? null;
|
|
353
|
+
break;
|
|
354
|
+
case "CONTEXT_UPSERTED": {
|
|
355
|
+
const entries = p["entries"];
|
|
356
|
+
if (typeof entries === "object" && entries !== null && !Array.isArray(entries))
|
|
357
|
+
state.context = { ...state.context, ...entries };
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "WORKFLOW_CANCEL_REQUESTED":
|
|
361
|
+
state.cancelRequested = true;
|
|
362
|
+
break;
|
|
363
|
+
case "WORKFLOW_COMPLETED":
|
|
364
|
+
state.status = "COMPLETED";
|
|
365
|
+
state.output = p["output"] ?? null;
|
|
366
|
+
break;
|
|
367
|
+
case "WORKFLOW_FAILED": {
|
|
368
|
+
state.status = "FAILED";
|
|
369
|
+
const failure = failureOf(p);
|
|
370
|
+
if (failure) state.failure = failure;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
case "WORKFLOW_CANCELLED":
|
|
374
|
+
state.status = "CANCELLED";
|
|
375
|
+
break;
|
|
376
|
+
case "WORKFLOW_TERMINATED":
|
|
377
|
+
state.status = "TERMINATED";
|
|
378
|
+
break;
|
|
379
|
+
case "WORKFLOW_TIMED_OUT":
|
|
380
|
+
state.status = "TIMED_OUT";
|
|
381
|
+
break;
|
|
382
|
+
case "WORKFLOW_CONTINUED_AS_NEW":
|
|
383
|
+
state.status = "CONTINUED_AS_NEW";
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
if (state.status !== "RUNNING") state.task = { state: "NONE", attempt: 0 };
|
|
387
|
+
return state;
|
|
388
|
+
}
|
|
389
|
+
function projectRunState(history) {
|
|
390
|
+
const state = initialRunState();
|
|
391
|
+
for (const event of history) applyEvent(state, event);
|
|
392
|
+
return state;
|
|
393
|
+
}
|
|
394
|
+
function pendingCounts(state) {
|
|
395
|
+
return {
|
|
396
|
+
activities: Object.values(state.activities).filter(isActivityOpen).length,
|
|
397
|
+
timers: Object.values(state.timers).filter((t) => t.status === "PENDING").length,
|
|
398
|
+
children: Object.values(state.children).filter(isChildOpen).length
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function payloadOf(command) {
|
|
402
|
+
const out = {};
|
|
403
|
+
for (const [key, value] of Object.entries(command)) {
|
|
404
|
+
if (key === "type" || value === void 0) continue;
|
|
405
|
+
out[key] = value;
|
|
406
|
+
}
|
|
407
|
+
return out;
|
|
408
|
+
}
|
|
409
|
+
function eventsForCommands(state, commands, context) {
|
|
410
|
+
const issues = [];
|
|
411
|
+
const events = [];
|
|
412
|
+
const reject = (index, code, message) => {
|
|
413
|
+
issues.push({ index, code, message });
|
|
414
|
+
};
|
|
415
|
+
if (state.status !== "RUNNING" && commands.length > 0)
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
cause: "INVALID_REQUEST",
|
|
419
|
+
issues: [{ index: 0, code: "run.closed", message: `The run is ${state.status}` }]
|
|
420
|
+
};
|
|
421
|
+
const activities = new Map(Object.entries(state.activities).map(([id, a]) => [id, a.status]));
|
|
422
|
+
const timers = new Map(Object.entries(state.timers).map(([id, t]) => [id, t.status]));
|
|
423
|
+
const children = new Set(Object.keys(state.children));
|
|
424
|
+
const externals = new Set(Object.keys(state.externals));
|
|
425
|
+
const sideEffects = new Set(Object.keys(state.sideEffects));
|
|
426
|
+
let unsupported = false;
|
|
427
|
+
commands.forEach((command, index) => {
|
|
428
|
+
if (!isWorkflowCommandEnabled(command, context.enabled)) {
|
|
429
|
+
unsupported = true;
|
|
430
|
+
reject(index, "commands.unsupported", `${command.type} is not supported in this release`);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (chunk623FVQSN_cjs.TERMINAL_COMMANDS.has(command.type) && index !== commands.length - 1)
|
|
434
|
+
reject(index, "commands.terminalNotLast", `${command.type} must be last`);
|
|
435
|
+
const base = { taskId: context.taskId };
|
|
436
|
+
switch (command.type) {
|
|
437
|
+
case "SCHEDULE_ACTIVITY":
|
|
438
|
+
if (activities.has(command.activityId))
|
|
439
|
+
reject(index, "activity.duplicate", `Activity "${command.activityId}" already exists`);
|
|
440
|
+
if (!chunk2J6TF7YI_cjs.isActivityNodeTypeAllowed(command.nodeType))
|
|
441
|
+
reject(
|
|
442
|
+
index,
|
|
443
|
+
"durable.activityTypeNotAllowed",
|
|
444
|
+
`${command.nodeType} cannot run as a durable activity`
|
|
445
|
+
);
|
|
446
|
+
activities.set(command.activityId, "SCHEDULED");
|
|
447
|
+
events.push({ ...base, type: "ACTIVITY_SCHEDULED", payload: payloadOf(command) });
|
|
448
|
+
break;
|
|
449
|
+
case "REQUEST_CANCEL_ACTIVITY": {
|
|
450
|
+
const status = activities.get(command.activityId);
|
|
451
|
+
if (status === void 0 || !OPEN_ACTIVITY.has(status))
|
|
452
|
+
reject(index, "activity.notOpen", `Activity "${command.activityId}" is not open`);
|
|
453
|
+
activities.set(command.activityId, "CANCEL_REQUESTED");
|
|
454
|
+
events.push({ ...base, type: "ACTIVITY_CANCEL_REQUESTED", payload: payloadOf(command) });
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
case "START_TIMER":
|
|
458
|
+
if (timers.has(command.timerId))
|
|
459
|
+
reject(index, "timer.duplicate", `Timer "${command.timerId}" already exists`);
|
|
460
|
+
timers.set(command.timerId, "PENDING");
|
|
461
|
+
events.push({
|
|
462
|
+
...base,
|
|
463
|
+
type: "TIMER_STARTED",
|
|
464
|
+
payload: {
|
|
465
|
+
...payloadOf(command),
|
|
466
|
+
fireAt: new Date(context.nowMs + command.durationMs).toISOString()
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
break;
|
|
470
|
+
case "CANCEL_TIMER":
|
|
471
|
+
if (timers.get(command.timerId) !== "PENDING")
|
|
472
|
+
reject(index, "timer.notPending", `Timer "${command.timerId}" is not pending`);
|
|
473
|
+
timers.set(command.timerId, "CANCELLED");
|
|
474
|
+
events.push({ ...base, type: "TIMER_CANCELLED", payload: payloadOf(command) });
|
|
475
|
+
break;
|
|
476
|
+
case "START_CHILD_RUN":
|
|
477
|
+
if (children.has(command.childId))
|
|
478
|
+
reject(index, "child.duplicate", `Child "${command.childId}" already exists`);
|
|
479
|
+
children.add(command.childId);
|
|
480
|
+
events.push({ ...base, type: "CHILD_RUN_INITIATED", payload: payloadOf(command) });
|
|
481
|
+
break;
|
|
482
|
+
case "SIGNAL_RUN":
|
|
483
|
+
case "REQUEST_CANCEL_EXTERNAL_RUN":
|
|
484
|
+
if (externals.has(command.externalId))
|
|
485
|
+
reject(index, "external.duplicate", `"${command.externalId}" already exists`);
|
|
486
|
+
if ("childId" in command.target && !children.has(command.target.childId))
|
|
487
|
+
reject(index, "external.unknownChild", `Unknown child "${command.target.childId}"`);
|
|
488
|
+
externals.add(command.externalId);
|
|
489
|
+
events.push({
|
|
490
|
+
...base,
|
|
491
|
+
type: command.type === "SIGNAL_RUN" ? "EXTERNAL_RUN_SIGNALED" : "EXTERNAL_RUN_CANCEL_REQUESTED",
|
|
492
|
+
payload: payloadOf(command)
|
|
493
|
+
});
|
|
494
|
+
break;
|
|
495
|
+
case "RECORD_SIDE_EFFECT":
|
|
496
|
+
if (sideEffects.has(command.sideEffectId))
|
|
497
|
+
reject(index, "sideEffect.duplicate", `"${command.sideEffectId}" is already recorded`);
|
|
498
|
+
sideEffects.add(command.sideEffectId);
|
|
499
|
+
events.push({ ...base, type: "SIDE_EFFECT_RECORDED", payload: payloadOf(command) });
|
|
500
|
+
break;
|
|
501
|
+
case "RECORD_MARKER":
|
|
502
|
+
events.push({ ...base, type: "MARKER_RECORDED", payload: payloadOf(command) });
|
|
503
|
+
break;
|
|
504
|
+
case "COMPLETE_WORKFLOW":
|
|
505
|
+
events.push({
|
|
506
|
+
...base,
|
|
507
|
+
type: "WORKFLOW_COMPLETED",
|
|
508
|
+
payload: { output: command.output ?? null }
|
|
509
|
+
});
|
|
510
|
+
break;
|
|
511
|
+
case "FAIL_WORKFLOW":
|
|
512
|
+
events.push({ ...base, type: "WORKFLOW_FAILED", payload: payloadOf(command) });
|
|
513
|
+
break;
|
|
514
|
+
case "CANCEL_WORKFLOW":
|
|
515
|
+
events.push({ ...base, type: "WORKFLOW_CANCELLED", payload: {} });
|
|
516
|
+
break;
|
|
517
|
+
case "UPSERT_CONTEXT":
|
|
518
|
+
events.push({ ...base, type: "CONTEXT_UPSERTED", payload: payloadOf(command) });
|
|
519
|
+
break;
|
|
520
|
+
case "RECORD_LOCAL_ACTIVITY":
|
|
521
|
+
events.push({
|
|
522
|
+
...base,
|
|
523
|
+
type: command.failure ? "LOCAL_ACTIVITY_FAILED" : "LOCAL_ACTIVITY_COMPLETED",
|
|
524
|
+
payload: payloadOf(command)
|
|
525
|
+
});
|
|
526
|
+
break;
|
|
527
|
+
case "CONTINUE_AS_NEW":
|
|
528
|
+
events.push({ ...base, type: "WORKFLOW_CONTINUED_AS_NEW", payload: payloadOf(command) });
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
if (issues.length > 0)
|
|
533
|
+
return { ok: false, cause: unsupported ? "UNSUPPORTED_COMMAND" : "INVALID_REQUEST", issues };
|
|
534
|
+
return { ok: true, events };
|
|
535
|
+
}
|
|
536
|
+
function taskCompletedEvents(options) {
|
|
537
|
+
const extra = {};
|
|
538
|
+
if (options.buildId !== void 0) extra["buildId"] = options.buildId;
|
|
539
|
+
if (options.workerId !== void 0) extra["workerId"] = options.workerId;
|
|
540
|
+
const events = [];
|
|
541
|
+
if (options.transient)
|
|
542
|
+
events.push({
|
|
543
|
+
type: "WORKFLOW_TASK_STARTED",
|
|
544
|
+
taskId: options.taskId,
|
|
545
|
+
payload: {
|
|
546
|
+
taskId: options.taskId,
|
|
547
|
+
attempt: options.attempt,
|
|
548
|
+
startedAt: options.startedAt,
|
|
549
|
+
historyLength: options.historyLength,
|
|
550
|
+
...extra
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
events.push({
|
|
554
|
+
type: "WORKFLOW_TASK_COMPLETED",
|
|
555
|
+
taskId: options.taskId,
|
|
556
|
+
payload: { taskId: options.taskId, ...extra }
|
|
557
|
+
});
|
|
558
|
+
return events;
|
|
559
|
+
}
|
|
560
|
+
function hasUnprocessedInput(history) {
|
|
561
|
+
return unseenInputs(history).length > 0;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/history/retry.ts
|
|
565
|
+
var DEFAULT_ACTIVITY_RETRY = Object.freeze({
|
|
566
|
+
retryDelay: 1e3,
|
|
567
|
+
backoffMultiplier: 2,
|
|
568
|
+
maxDelay: 1e5
|
|
569
|
+
});
|
|
570
|
+
var FINAL_TIMEOUTS = /* @__PURE__ */ new Set(["SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE"]);
|
|
571
|
+
function computeRetryDelay(policy, attempt, failure) {
|
|
572
|
+
if (failure?.nonRetryable === true) return { retry: false, reason: "nonRetryable" };
|
|
573
|
+
if (failure?.timeoutType !== void 0 && FINAL_TIMEOUTS.has(failure.timeoutType))
|
|
574
|
+
return { retry: false, reason: "finalTimeout" };
|
|
575
|
+
if (failure?.type !== void 0 && policy.nonRetryableErrorTypes !== void 0 && policy.nonRetryableErrorTypes.includes(failure.type))
|
|
576
|
+
return { retry: false, reason: "typeDenied" };
|
|
577
|
+
if (failure !== void 0 && policy.retryOnErrorTypes !== void 0 && policy.retryOnErrorTypes.length > 0 && !policy.retryOnErrorTypes.includes(failure.errorType))
|
|
578
|
+
return { retry: false, reason: "errorTypeNotListed" };
|
|
579
|
+
if (policy.maxRetries !== void 0 && attempt > policy.maxRetries)
|
|
580
|
+
return { retry: false, reason: "maxRetries" };
|
|
581
|
+
if (failure?.nextRetryDelayMs !== void 0)
|
|
582
|
+
return { retry: true, delayMs: Math.max(0, Math.round(failure.nextRetryDelayMs)) };
|
|
583
|
+
const base = Math.max(0, policy.retryDelay);
|
|
584
|
+
const multiplier = policy.backoffMultiplier ?? 2;
|
|
585
|
+
const cap = policy.maxDelay ?? base * 100;
|
|
586
|
+
const exponent = Math.max(0, attempt - 1);
|
|
587
|
+
const delay = Math.min(base * Math.pow(multiplier, exponent), cap);
|
|
588
|
+
return { retry: true, delayMs: Math.round(Number.isFinite(delay) ? delay : cap) };
|
|
589
|
+
}
|
|
590
|
+
function explicitRetryPolicy(policy) {
|
|
591
|
+
const retryDelay = policy?.retryDelay ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
|
|
592
|
+
const out = {
|
|
593
|
+
retryDelay,
|
|
594
|
+
backoffMultiplier: policy?.backoffMultiplier ?? DEFAULT_ACTIVITY_RETRY.backoffMultiplier ?? 2,
|
|
595
|
+
maxDelay: policy?.maxDelay ?? (policy?.retryDelay === void 0 ? 1e5 : Math.max(retryDelay, retryDelay * 100))
|
|
596
|
+
};
|
|
597
|
+
if (policy?.maxRetries !== void 0) out.maxRetries = policy.maxRetries;
|
|
598
|
+
if (policy?.retryOnErrorTypes !== void 0)
|
|
599
|
+
out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
|
|
600
|
+
if (policy?.nonRetryableErrorTypes !== void 0)
|
|
601
|
+
out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
|
|
602
|
+
return out;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// src/history/defaults.ts
|
|
606
|
+
function codeWorkflowParentClosePolicy(state) {
|
|
607
|
+
const policy = state.parentClosePolicy;
|
|
608
|
+
if (policy === "TERMINATE" || policy === "ABANDON" || policy === "REQUEST_CANCEL") return policy;
|
|
609
|
+
return state.waitForCompletion === false ? "ABANDON" : "TERMINATE";
|
|
610
|
+
}
|
|
611
|
+
var CHILD_DEFAULT_PARENT_CLOSE_POLICY = Object.freeze({ child: "TERMINATE", startChild: "ABANDON" });
|
|
612
|
+
var CHILD_DEFAULT_CANCELLATION_TYPE = "WAIT_CANCELLATION_COMPLETED";
|
|
613
|
+
|
|
614
|
+
exports.CHILD_DEFAULT_CANCELLATION_TYPE = CHILD_DEFAULT_CANCELLATION_TYPE;
|
|
615
|
+
exports.CHILD_DEFAULT_PARENT_CLOSE_POLICY = CHILD_DEFAULT_PARENT_CLOSE_POLICY;
|
|
616
|
+
exports.DEFAULT_ACTIVITY_RETRY = DEFAULT_ACTIVITY_RETRY;
|
|
617
|
+
exports.HistoryStateError = HistoryStateError;
|
|
618
|
+
exports.applyEvent = applyEvent;
|
|
619
|
+
exports.codeWorkflowParentClosePolicy = codeWorkflowParentClosePolicy;
|
|
620
|
+
exports.computeRetryDelay = computeRetryDelay;
|
|
621
|
+
exports.eventsForCommands = eventsForCommands;
|
|
622
|
+
exports.explicitRetryPolicy = explicitRetryPolicy;
|
|
623
|
+
exports.hasUnprocessedInput = hasUnprocessedInput;
|
|
624
|
+
exports.initialRunState = initialRunState;
|
|
625
|
+
exports.isActivityOpen = isActivityOpen;
|
|
626
|
+
exports.isChildOpen = isChildOpen;
|
|
627
|
+
exports.isCommandEnabled = isCommandEnabled;
|
|
628
|
+
exports.isWorkflowCommandEnabled = isWorkflowCommandEnabled;
|
|
629
|
+
exports.pendingCounts = pendingCounts;
|
|
630
|
+
exports.projectRunState = projectRunState;
|
|
631
|
+
exports.splitActivations = splitActivations;
|
|
632
|
+
exports.taskCompletedEvents = taskCompletedEvents;
|
|
633
|
+
exports.unseenInputs = unseenInputs;
|
|
634
|
+
exports.utf8Bytes = utf8Bytes;
|