@fluidgrids/workflows 2026.1028.1 → 2026.1029.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 +72 -10
- package/dist/{activation-DnhG7SmF.d.ts → activation-BnVQMv9y.d.ts} +1 -1
- package/dist/{activation-BBh1p82z.d.cts → activation-CESehfYi.d.cts} +1 -1
- package/dist/{chunk-XB53G2DK.js → chunk-25BKWR2O.js} +1 -1
- package/dist/{chunk-CBL5JSCC.cjs → chunk-2B37XAFQ.cjs} +44 -8
- package/dist/{chunk-DJYMDLV5.js → chunk-2DDULZFM.js} +93 -1
- package/dist/{chunk-623FVQSN.cjs → chunk-3FIDHONL.cjs} +104 -0
- package/dist/chunk-6QPOJZT6.cjs +1180 -0
- package/dist/chunk-7ILGCUI6.js +154 -0
- package/dist/chunk-A2OHX3UQ.js +1156 -0
- package/dist/{chunk-VOKMAAJP.js → chunk-A36CCOWS.js} +188 -19
- package/dist/{chunk-FMSW2HDF.cjs → chunk-ELL2RBML.cjs} +0 -14
- package/dist/{chunk-JD2VQIDZ.cjs → chunk-EWYADREB.cjs} +2 -2
- package/dist/{chunk-5HDSBTBX.js → chunk-FQSJI5NV.js} +1 -1
- package/dist/{chunk-ABFZWYHT.js → chunk-FWBRQWRX.js} +156 -48
- package/dist/{chunk-PZCVF76Q.cjs → chunk-I47EENR4.cjs} +209 -40
- package/dist/chunk-J3PYFGKA.cjs +166 -0
- package/dist/{chunk-C5OLWZ42.js → chunk-KXJDRQ6G.js} +1 -13
- package/dist/chunk-M272AHEX.js +25 -0
- package/dist/{chunk-3FOTFQ3J.js → chunk-MJ5TGYVG.js} +333 -65
- package/dist/{chunk-57MSZ24T.cjs → chunk-NXFBVDOI.cjs} +3 -3
- package/dist/{chunk-PDHLTDZB.js → chunk-OIX4O6UR.js} +38 -2
- package/dist/{chunk-HR3BN4C4.cjs → chunk-OKX3FYIM.cjs} +3 -3
- package/dist/{chunk-CSNWNFKU.cjs → chunk-OMY3CKUZ.cjs} +404 -136
- package/dist/chunk-PWIUEWC3.js +81 -0
- package/dist/chunk-Q4MWQNJK.cjs +28 -0
- package/dist/{chunk-P6TA5EZT.cjs → chunk-RUQIMTN5.cjs} +171 -57
- package/dist/{chunk-IISBRUWJ.js → chunk-WXXNCHUY.js} +1 -1
- package/dist/chunk-YHBVMOMK.cjs +87 -0
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/collect-BTHjQaSp.d.ts +86 -0
- package/dist/collect-CSyOg5XC.d.cts +86 -0
- package/dist/{file-yuPCFU5b.d.ts → file-cgL9l9l8.d.cts} +765 -14
- package/dist/{file-BOoHZgoQ.d.cts → file-olQudcx5.d.ts} +765 -14
- package/dist/history/index.cjs +198 -86
- package/dist/history/index.d.cts +49 -10
- package/dist/history/index.d.ts +49 -10
- package/dist/history/index.js +49 -4
- package/dist/index.cjs +64 -51
- package/dist/index.d.cts +9 -53
- package/dist/index.d.ts +9 -53
- package/dist/index.js +5 -4
- package/dist/ir/index.cjs +24 -3
- package/dist/ir/index.d.cts +43 -4
- package/dist/ir/index.d.ts +43 -4
- package/dist/ir/index.js +24 -3
- package/dist/{lower-BuSvAFqi.d.cts → lower-3S6PsqjJ.d.cts} +41 -7
- package/dist/{lower-C_Qv_34S.d.ts → lower-DmZpQ8hJ.d.ts} +41 -7
- package/dist/lower-types-DQNBfWQn.d.cts +37 -0
- package/dist/lower-types-DQNBfWQn.d.ts +37 -0
- package/dist/{manifest-C8N6HDYl.d.ts → manifest-BJjrQt77.d.ts} +1 -1
- package/dist/{manifest-0OLw0i7k.d.cts → manifest-gRI2Q5Fj.d.cts} +1 -1
- package/dist/node-evaluator-SOADN23V.js +14 -0
- package/dist/node-evaluator-YGDEXK4U.cjs +24 -0
- package/dist/quickjs/index.cjs +25 -24
- package/dist/quickjs/index.d.cts +7 -7
- package/dist/quickjs/index.d.ts +7 -7
- package/dist/quickjs/index.js +8 -7
- package/dist/roundtrip/index.cjs +245 -43
- package/dist/roundtrip/index.d.cts +88 -11
- package/dist/roundtrip/index.d.ts +88 -11
- package/dist/roundtrip/index.js +172 -8
- package/dist/runtime/index.cjs +21 -20
- package/dist/runtime/index.d.cts +49 -7
- package/dist/runtime/index.d.ts +49 -7
- package/dist/runtime/index.js +8 -7
- package/dist/testing/index.cjs +514 -74
- package/dist/testing/index.d.cts +128 -11
- package/dist/testing/index.d.ts +128 -11
- package/dist/testing/index.js +480 -42
- package/dist/{types-BGoPzgcl.d.ts → types-Bb2wRnJ5.d.cts} +20 -1
- package/dist/{types-BGoPzgcl.d.cts → types-Bb2wRnJ5.d.ts} +20 -1
- package/dist/{types-DV-HX_Gt.d.ts → types-CQKOhPTa.d.cts} +122 -14
- package/dist/{types-CpBBjaGX.d.cts → types-CnIOinoz.d.ts} +122 -14
- package/dist/{workflow-Bpr3vnA_.d.ts → workflow-8uRU9rhL.d.ts} +2 -2
- package/dist/{workflow-FXUkpIBc.d.cts → workflow-CZOXUlQ5.d.cts} +2 -2
- package/dist/{workflow-J-yYixny.d.cts → workflow-DWTPHFbt.d.ts} +124 -12
- package/dist/{workflow-C2a05WUJ.d.ts → workflow-O6e64ZcG.d.cts} +124 -12
- package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
- package/fixtures/histories/benign-failure.history.json +146 -0
- package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
- package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
- package/fixtures/histories/child-options-roundtrip.history.json +192 -0
- package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
- package/fixtures/histories/continue-as-new-options.history.json +99 -0
- package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
- package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
- package/fixtures/histories/execution-timeout-chain.history.json +98 -0
- package/fixtures/histories/external-cancel-resolved.history.json +123 -0
- package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
- package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
- package/fixtures/histories/handler-drain-warn.history.json +222 -0
- package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
- package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
- package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
- package/fixtures/histories/local-activity-completed.history.json +157 -0
- package/fixtures/histories/local-activity-failed.history.json +93 -0
- package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
- package/fixtures/histories/run-retry-last-failure.history.json +90 -0
- package/fixtures/histories/run-timeout.history.json +159 -0
- package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
- package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
- package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
- package/package.json +1 -1
- package/schema/history-file.schema.json +283 -2
- package/schema/ir-v2.schema.json +45 -0
- package/schema/run-event.schema.json +264 -2
- package/schema/workflow-command.schema.json +178 -1
- package/schema/workflow-task.schema.json +392 -4
- package/dist/assemble-BLqQ8lSu.d.cts +0 -39
- package/dist/assemble-DWgaXHd-.d.ts +0 -39
- package/dist/chunk-2DP2Y6EU.cjs +0 -832
- package/dist/chunk-2J6TF7YI.cjs +0 -86
- package/dist/chunk-7NQ37GZU.js +0 -73
- package/dist/chunk-BO6OVILK.js +0 -79
- package/dist/chunk-FQIHX7YI.cjs +0 -80
- package/dist/chunk-H7KEVW2M.js +0 -816
- package/dist/lower-types-nofRXw9c.d.cts +0 -15
- package/dist/lower-types-nofRXw9c.d.ts +0 -15
- package/dist/node-evaluator-CJNP4GHX.js +0 -12
- package/dist/node-evaluator-DMKPKUWA.cjs +0 -22
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkELL2RBML_cjs = require('./chunk-ELL2RBML.cjs');
|
|
4
|
+
var chunkQ4MWQNJK_cjs = require('./chunk-Q4MWQNJK.cjs');
|
|
4
5
|
var chunkL24YIZY7_cjs = require('./chunk-L24YIZY7.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
6
|
+
var chunkJ3PYFGKA_cjs = require('./chunk-J3PYFGKA.cjs');
|
|
7
|
+
var chunkRUQIMTN5_cjs = require('./chunk-RUQIMTN5.cjs');
|
|
8
|
+
var chunk3FIDHONL_cjs = require('./chunk-3FIDHONL.cjs');
|
|
9
|
+
var chunkYHBVMOMK_cjs = require('./chunk-YHBVMOMK.cjs');
|
|
9
10
|
|
|
10
11
|
// src/runtime/ids.ts
|
|
11
12
|
var CommandIds = class {
|
|
12
|
-
counters = {
|
|
13
|
+
counters = {
|
|
14
|
+
a: 0,
|
|
15
|
+
t: 0,
|
|
16
|
+
c: 0,
|
|
17
|
+
s: 0,
|
|
18
|
+
x: 0,
|
|
19
|
+
m: 0,
|
|
20
|
+
l: 0
|
|
21
|
+
};
|
|
13
22
|
/** The next id of a kind: `a1`, `a2`, ... */
|
|
14
23
|
next(kind) {
|
|
15
24
|
this.counters[kind] += 1;
|
|
@@ -47,7 +56,7 @@ function describeCommand(command) {
|
|
|
47
56
|
case "RECORD_MARKER":
|
|
48
57
|
return `RECORD_MARKER ${command.markerId}`;
|
|
49
58
|
case "RECORD_LOCAL_ACTIVITY":
|
|
50
|
-
return `RECORD_LOCAL_ACTIVITY ${command.localActivityId}`;
|
|
59
|
+
return `RECORD_LOCAL_ACTIVITY ${command.localActivityId}${command.nodeType !== void 0 ? ` (${command.nodeType} ${command.operation ?? ""})` : ""}`;
|
|
51
60
|
default:
|
|
52
61
|
return command.type;
|
|
53
62
|
}
|
|
@@ -57,7 +66,7 @@ function describeEvent(event) {
|
|
|
57
66
|
return `${event.type}${typeof id === "string" ? ` ${id}` : ""} (seq ${event.seq})`;
|
|
58
67
|
}
|
|
59
68
|
function mismatch(command, event) {
|
|
60
|
-
const expected =
|
|
69
|
+
const expected = chunk3FIDHONL_cjs.COMMAND_EVENT_TYPES[command.type];
|
|
61
70
|
const typeOk = command.type === "RECORD_LOCAL_ACTIVITY" ? event.type === "LOCAL_ACTIVITY_COMPLETED" || event.type === "LOCAL_ACTIVITY_FAILED" : event.type === expected;
|
|
62
71
|
const differ = () => `the code issued ${describeCommand(command)} where the history has ${describeEvent(event)}`;
|
|
63
72
|
if (!typeOk) return differ();
|
|
@@ -79,8 +88,10 @@ function mismatch(command, event) {
|
|
|
79
88
|
return field(event, "sideEffectId") === command.sideEffectId ? void 0 : differ();
|
|
80
89
|
case "RECORD_MARKER":
|
|
81
90
|
return field(event, "markerId") === command.markerId ? void 0 : differ();
|
|
82
|
-
case "RECORD_LOCAL_ACTIVITY":
|
|
83
|
-
|
|
91
|
+
case "RECORD_LOCAL_ACTIVITY": {
|
|
92
|
+
const sameOperation = field(event, "nodeType") === void 0 || field(event, "nodeType") === command.nodeType && field(event, "operation") === command.operation;
|
|
93
|
+
return field(event, "localActivityId") === command.localActivityId && sameOperation ? void 0 : differ();
|
|
94
|
+
}
|
|
84
95
|
default:
|
|
85
96
|
return void 0;
|
|
86
97
|
}
|
|
@@ -116,30 +127,6 @@ function matchActivation(commands, recorded) {
|
|
|
116
127
|
return void 0;
|
|
117
128
|
}
|
|
118
129
|
|
|
119
|
-
// src/runtime/stack.ts
|
|
120
|
-
var RUNTIME_FRAME = /fluidgrids-runtime|\/runtime\/(scheduler|index)\.|WorkflowExecution|RuntimeContext/;
|
|
121
|
-
function captureStack() {
|
|
122
|
-
const stack = new Error("stack").stack ?? "";
|
|
123
|
-
return stack.split("\n").slice(1).filter((line) => line.trim() !== "" && !RUNTIME_FRAME.test(line)).join("\n");
|
|
124
|
-
}
|
|
125
|
-
var V8_FRAME = /^\s*at (?:(.*?) \()?(.*?):(\d+):(\d+)\)?$/;
|
|
126
|
-
var QUICKJS_FRAME = /^\s*at (?:(.*?) )?\(?(.*?)(?::(\d+))?(?::(\d+))?\)?$/;
|
|
127
|
-
function parseStack(stack) {
|
|
128
|
-
const locations = [];
|
|
129
|
-
for (const line of stack.split("\n")) {
|
|
130
|
-
if (line.trim() === "") continue;
|
|
131
|
-
const match = V8_FRAME.exec(line) ?? QUICKJS_FRAME.exec(line);
|
|
132
|
-
if (!match) continue;
|
|
133
|
-
const location = {};
|
|
134
|
-
if (match[1]) location.functionName = match[1];
|
|
135
|
-
if (match[2]) location.filePath = match[2];
|
|
136
|
-
if (match[3]) location.line = Number(match[3]);
|
|
137
|
-
if (match[4]) location.column = Number(match[4]);
|
|
138
|
-
locations.push(location);
|
|
139
|
-
}
|
|
140
|
-
return locations;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
130
|
// src/runtime/scheduler.ts
|
|
144
131
|
var SDK_NAME = "@fluidgrids/workflows";
|
|
145
132
|
var ContinueAsNewRequest = class {
|
|
@@ -200,7 +187,7 @@ var Scope = class {
|
|
|
200
187
|
cancel() {
|
|
201
188
|
if (this.consideredCancelled) return;
|
|
202
189
|
this.consideredCancelled = true;
|
|
203
|
-
this.rejectRequested(new
|
|
190
|
+
this.rejectRequested(new chunkELL2RBML_cjs.CancelledFailure("Cancellation requested"));
|
|
204
191
|
const errors = [];
|
|
205
192
|
const handlers = [...this.handlers];
|
|
206
193
|
this.handlers.clear();
|
|
@@ -253,6 +240,49 @@ function messageOf(error) {
|
|
|
253
240
|
function stackTextOf(error) {
|
|
254
241
|
return error instanceof Error && typeof error.stack === "string" ? error.stack : void 0;
|
|
255
242
|
}
|
|
243
|
+
function isJsonObject(value) {
|
|
244
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
245
|
+
}
|
|
246
|
+
function asFailure(value) {
|
|
247
|
+
return isJsonObject(value) ? value : void 0;
|
|
248
|
+
}
|
|
249
|
+
function infoFromStarted(info, started) {
|
|
250
|
+
if (started?.type !== "WORKFLOW_STARTED") return { ...info };
|
|
251
|
+
const p = started.payload;
|
|
252
|
+
const out = { ...info };
|
|
253
|
+
if (Object.hasOwn(p, "lastCompletionResult")) out.lastResult = p["lastCompletionResult"] ?? null;
|
|
254
|
+
if (Object.hasOwn(p, "lastFailure")) out.lastFailure = asFailure(p["lastFailure"]) ?? null;
|
|
255
|
+
const businessId = typeof p["businessId"] === "string" ? p["businessId"] : void 0;
|
|
256
|
+
const workflowId = typeof p["workflowId"] === "string" ? p["workflowId"] : businessId;
|
|
257
|
+
if (businessId !== void 0) out.businessId = businessId;
|
|
258
|
+
if (workflowId !== void 0) out.workflowId = workflowId;
|
|
259
|
+
if (typeof p["runAttempt"] === "number") {
|
|
260
|
+
out.runAttempt = p["runAttempt"];
|
|
261
|
+
out.attempt = p["runAttempt"];
|
|
262
|
+
}
|
|
263
|
+
if (typeof p["summary"] === "string") out.summary = p["summary"];
|
|
264
|
+
if (typeof p["details"] === "string") out.details = p["details"];
|
|
265
|
+
if (isJsonObject(p["context"])) {
|
|
266
|
+
out.context = { ...p["context"] };
|
|
267
|
+
out.memo = { ...p["context"] };
|
|
268
|
+
}
|
|
269
|
+
const timeouts = {};
|
|
270
|
+
const nested = isJsonObject(p["timeouts"]) ? p["timeouts"] : {};
|
|
271
|
+
for (const key of ["executionTimeout", "runTimeout", "workflowTaskTimeout"]) {
|
|
272
|
+
const value = nested[key] ?? p[key];
|
|
273
|
+
if (typeof value === "number") timeouts[key] = value;
|
|
274
|
+
}
|
|
275
|
+
if (Object.keys(timeouts).length > 0) out.timeouts = timeouts;
|
|
276
|
+
if (p["versioningBehavior"] === "PINNED" || p["versioningBehavior"] === "AUTO_UPGRADE")
|
|
277
|
+
out.versioningBehavior = p["versioningBehavior"];
|
|
278
|
+
if (isJsonObject(p["retry"])) out.retry = p["retry"];
|
|
279
|
+
if (typeof p["priority"] === "number") out.priority = p["priority"];
|
|
280
|
+
if (typeof p["firstRunId"] === "string") out.firstRunId = p["firstRunId"];
|
|
281
|
+
if (typeof p["continuedFromRunId"] === "string") out.continuedFromRunId = p["continuedFromRunId"];
|
|
282
|
+
if (out.workflowId === void 0 && out.businessId !== void 0) out.workflowId = out.businessId;
|
|
283
|
+
if (out.runAttempt === void 0 && out.attempt !== void 0) out.runAttempt = out.attempt;
|
|
284
|
+
return out;
|
|
285
|
+
}
|
|
256
286
|
var WorkflowExecution = class {
|
|
257
287
|
request;
|
|
258
288
|
definition;
|
|
@@ -302,7 +332,16 @@ var WorkflowExecution = class {
|
|
|
302
332
|
signalHandlers = /* @__PURE__ */ new Map();
|
|
303
333
|
signalWaiters = /* @__PURE__ */ new Map();
|
|
304
334
|
defaultSignalHandler;
|
|
335
|
+
defaultSignalPolicy = "WARN_AND_ABANDON";
|
|
336
|
+
signalPolicies = /* @__PURE__ */ new Map();
|
|
305
337
|
runningHandlers = 0;
|
|
338
|
+
/** Running asynchronous handlers by name, for the drain warning (11 §2.18). */
|
|
339
|
+
running = /* @__PURE__ */ new Map();
|
|
340
|
+
unfinished;
|
|
341
|
+
recordedLocalActivities = /* @__PURE__ */ new Map();
|
|
342
|
+
localActivityResults = /* @__PURE__ */ new Map();
|
|
343
|
+
localActivities = /* @__PURE__ */ new Map();
|
|
344
|
+
memo;
|
|
306
345
|
conditions = [];
|
|
307
346
|
currentDetails;
|
|
308
347
|
context;
|
|
@@ -316,12 +355,12 @@ var WorkflowExecution = class {
|
|
|
316
355
|
this.bytesUpTo = [0];
|
|
317
356
|
let bytes = 0;
|
|
318
357
|
for (const event of history) {
|
|
319
|
-
bytes +=
|
|
358
|
+
bytes += chunkRUQIMTN5_cjs.utf8Bytes(JSON.stringify(event.payload));
|
|
320
359
|
this.bytesUpTo.push(bytes);
|
|
321
360
|
}
|
|
322
361
|
this.historyLength = history.length;
|
|
323
362
|
this.historyBytes = bytes;
|
|
324
|
-
const limit = input.request.info.historyLimit ??
|
|
363
|
+
const limit = input.request.info.historyLimit ?? chunk3FIDHONL_cjs.DEFAULT_HISTORY_LIMIT;
|
|
325
364
|
this.limitEvents = limit.events;
|
|
326
365
|
this.limitBytes = limit.bytes;
|
|
327
366
|
this.captureStacks = input.request.kind === "query";
|
|
@@ -334,17 +373,40 @@ var WorkflowExecution = class {
|
|
|
334
373
|
} else if (event.type === "MARKER_RECORDED") {
|
|
335
374
|
const id = event.payload["markerId"];
|
|
336
375
|
if (typeof id === "string") this.recordedMarkers.add(id);
|
|
376
|
+
} else if (event.type === "LOCAL_ACTIVITY_COMPLETED" || event.type === "LOCAL_ACTIVITY_FAILED") {
|
|
377
|
+
const id = event.payload["localActivityId"];
|
|
378
|
+
const failure = asFailure(event.payload["failure"]);
|
|
379
|
+
const attempts = event.payload["attempts"];
|
|
380
|
+
if (typeof id === "string")
|
|
381
|
+
this.recordedLocalActivities.set(id, {
|
|
382
|
+
...event.type === "LOCAL_ACTIVITY_FAILED" && failure ? { failure } : { result: event.payload["result"] ?? null },
|
|
383
|
+
attempts: typeof attempts === "number" ? attempts : 1
|
|
384
|
+
});
|
|
337
385
|
}
|
|
338
386
|
}
|
|
339
|
-
|
|
387
|
+
if (input.request.kind === "task")
|
|
388
|
+
for (const entry of input.request.localActivityResults ?? [])
|
|
389
|
+
this.localActivityResults.set(entry.localActivityId, {
|
|
390
|
+
...entry.failure !== void 0 ? { failure: entry.failure } : { result: entry.result ?? null },
|
|
391
|
+
attempts: entry.attempts
|
|
392
|
+
});
|
|
393
|
+
this.activations = chunkRUQIMTN5_cjs.splitActivations(
|
|
340
394
|
history,
|
|
341
395
|
input.request.nowMs,
|
|
342
396
|
input.request.kind !== "query"
|
|
343
397
|
);
|
|
344
398
|
const execution = this;
|
|
399
|
+
const snapshot = infoFromStarted(input.request.info, history[0]);
|
|
400
|
+
this.memo = { ...snapshot.memo ?? snapshot.context ?? {} };
|
|
345
401
|
this.info = {
|
|
346
|
-
...
|
|
402
|
+
...snapshot,
|
|
347
403
|
workflowFn: input.request.workflowFn,
|
|
404
|
+
get context() {
|
|
405
|
+
return { ...execution.memo };
|
|
406
|
+
},
|
|
407
|
+
get memo() {
|
|
408
|
+
return { ...execution.memo };
|
|
409
|
+
},
|
|
348
410
|
get historyLength() {
|
|
349
411
|
return execution.historyLength;
|
|
350
412
|
},
|
|
@@ -361,7 +423,7 @@ var WorkflowExecution = class {
|
|
|
361
423
|
this.context = this.contextFor(void 0);
|
|
362
424
|
}
|
|
363
425
|
continueAsNewSuggested() {
|
|
364
|
-
return this.historyLength >= this.limitEvents *
|
|
426
|
+
return this.historyLength >= this.limitEvents * chunk3FIDHONL_cjs.CONTINUE_AS_NEW_SUGGESTED_RATIO || this.historyBytes >= this.limitBytes * chunk3FIDHONL_cjs.CONTINUE_AS_NEW_SUGGESTED_RATIO;
|
|
365
427
|
}
|
|
366
428
|
/** The workflow clock. */
|
|
367
429
|
now() {
|
|
@@ -391,12 +453,24 @@ var WorkflowExecution = class {
|
|
|
391
453
|
this.checkConditions();
|
|
392
454
|
this.finishActivation();
|
|
393
455
|
}
|
|
456
|
+
const requests = this.pendingLocalActivityRequests();
|
|
457
|
+
if (requests.length > 0) {
|
|
458
|
+
const requested = {
|
|
459
|
+
protocol: chunk3FIDHONL_cjs.HISTORY_PROTOCOL,
|
|
460
|
+
outcome: "localActivityRequested",
|
|
461
|
+
commands: [],
|
|
462
|
+
localActivityRequests: requests,
|
|
463
|
+
logs: []
|
|
464
|
+
};
|
|
465
|
+
return requested;
|
|
466
|
+
}
|
|
394
467
|
const result = {
|
|
395
|
-
protocol:
|
|
468
|
+
protocol: chunk3FIDHONL_cjs.HISTORY_PROTOCOL,
|
|
396
469
|
outcome: this.failure ? "failed" : "commands",
|
|
397
470
|
commands: this.failure ? [] : this.newCommands,
|
|
398
471
|
logs: this.logs
|
|
399
472
|
};
|
|
473
|
+
if (!this.failure && this.unfinished !== void 0) result.unfinishedHandlers = this.unfinished;
|
|
400
474
|
if (this.failure) {
|
|
401
475
|
result.failure = { cause: this.failure.cause, message: this.failure.message };
|
|
402
476
|
if (this.failure.stackTrace !== void 0)
|
|
@@ -407,6 +481,15 @@ var WorkflowExecution = class {
|
|
|
407
481
|
if (this.request.kind === "query") result.queryResults = this.answerQueries();
|
|
408
482
|
return result;
|
|
409
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* The local activities the open activation waits for, when the task is a
|
|
486
|
+
* workflow task that has not failed or closed the run (a run that ends
|
|
487
|
+
* abandons a local activity it did not await).
|
|
488
|
+
*/
|
|
489
|
+
pendingLocalActivityRequests() {
|
|
490
|
+
if (this.failure || this.closed || this.request.kind !== "task") return [];
|
|
491
|
+
return [...this.localActivities.values()].filter((entry) => !entry.replayed).map((entry) => entry.request);
|
|
492
|
+
}
|
|
410
493
|
/** Fail the task (the runtime's own failures and code errors). */
|
|
411
494
|
failTask(cause, message, stackTrace, seq, errorType) {
|
|
412
495
|
if (!this.failure) this.failure = new TaskFailure(cause, message, stackTrace, seq, errorType);
|
|
@@ -436,11 +519,30 @@ var WorkflowExecution = class {
|
|
|
436
519
|
void 0,
|
|
437
520
|
found.seq
|
|
438
521
|
);
|
|
522
|
+
else this.checkReplayedLocalActivities();
|
|
439
523
|
} else {
|
|
440
524
|
this.newCommands = this.commands;
|
|
441
525
|
}
|
|
442
526
|
this.commands = [];
|
|
443
527
|
}
|
|
528
|
+
/**
|
|
529
|
+
* A local activity issued on a replayed activation without a recorded
|
|
530
|
+
* outcome is fine only when the first execution dropped it in that same
|
|
531
|
+
* activation: its scope was cancelled (the entry is gone) or the run closed.
|
|
532
|
+
* One still waiting means the first execution would have requested and
|
|
533
|
+
* recorded it, so the code diverged from the history.
|
|
534
|
+
*/
|
|
535
|
+
checkReplayedLocalActivities() {
|
|
536
|
+
if (this.closed) return;
|
|
537
|
+
for (const entry of this.localActivities.values()) {
|
|
538
|
+
if (!entry.replayed) continue;
|
|
539
|
+
this.failTask(
|
|
540
|
+
"NON_DETERMINISM",
|
|
541
|
+
`Replay of ${entry.description ?? "a local activity"} found no recorded outcome: the code issued a local activity the history does not have`
|
|
542
|
+
);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
444
546
|
// ---- inputs ---------------------------------------------------------------
|
|
445
547
|
deliver(event) {
|
|
446
548
|
const p = event.payload;
|
|
@@ -488,7 +590,7 @@ var WorkflowExecution = class {
|
|
|
488
590
|
else {
|
|
489
591
|
const failure = p["failure"];
|
|
490
592
|
pending.reject(
|
|
491
|
-
typeof failure === "object" && failure !== null && !Array.isArray(failure) ?
|
|
593
|
+
typeof failure === "object" && failure !== null && !Array.isArray(failure) ? chunkELL2RBML_cjs.failureToError(failure) : new chunkELL2RBML_cjs.ServerFailure(`${pending.description} was not delivered`)
|
|
492
594
|
);
|
|
493
595
|
}
|
|
494
596
|
return;
|
|
@@ -518,7 +620,7 @@ var WorkflowExecution = class {
|
|
|
518
620
|
pending.release?.();
|
|
519
621
|
const p = event.payload;
|
|
520
622
|
const failure = typeof p["failure"] === "object" && p["failure"] !== null && !Array.isArray(p["failure"]) ? p["failure"] : void 0;
|
|
521
|
-
const wrap = (cause) => new
|
|
623
|
+
const wrap = (cause) => new chunkELL2RBML_cjs.ActivityFailure(
|
|
522
624
|
`Activity ${activityId} (${pending.nodeType} ${pending.operation}) failed: ${cause.message}`,
|
|
523
625
|
activityId,
|
|
524
626
|
pending.nodeType,
|
|
@@ -532,19 +634,19 @@ var WorkflowExecution = class {
|
|
|
532
634
|
case "ACTIVITY_FAILED":
|
|
533
635
|
pending.reject(
|
|
534
636
|
wrap(
|
|
535
|
-
failure ?
|
|
637
|
+
failure ? chunkELL2RBML_cjs.failureToError(failure) : new chunkELL2RBML_cjs.ApplicationError("Activity failed", { errorType: "UNKNOWN" })
|
|
536
638
|
)
|
|
537
639
|
);
|
|
538
640
|
return;
|
|
539
641
|
case "ACTIVITY_TIMED_OUT": {
|
|
540
642
|
const timeoutType = typeof p["timeoutType"] === "string" ? p["timeoutType"] : "UNKNOWN";
|
|
541
643
|
pending.reject(
|
|
542
|
-
wrap(new
|
|
644
|
+
wrap(new chunkELL2RBML_cjs.TimeoutFailure(`Activity timed out (${timeoutType})`, timeoutType))
|
|
543
645
|
);
|
|
544
646
|
return;
|
|
545
647
|
}
|
|
546
648
|
default:
|
|
547
|
-
pending.reject(wrap(new
|
|
649
|
+
pending.reject(wrap(new chunkELL2RBML_cjs.CancelledFailure("Activity cancelled")));
|
|
548
650
|
}
|
|
549
651
|
}
|
|
550
652
|
settleChild(event, childId) {
|
|
@@ -562,7 +664,7 @@ var WorkflowExecution = class {
|
|
|
562
664
|
let outcome;
|
|
563
665
|
const failureValue = p["failure"];
|
|
564
666
|
const failure = typeof failureValue === "object" && failureValue !== null && !Array.isArray(failureValue) ? failureValue : void 0;
|
|
565
|
-
const wrap = (cause) => new
|
|
667
|
+
const wrap = (cause) => new chunkELL2RBML_cjs.ChildRunFailure(
|
|
566
668
|
`Child run ${childId} ${event.type.slice("CHILD_RUN_".length).toLowerCase().replace("_", " ")}: ${cause.message}`,
|
|
567
669
|
childId,
|
|
568
670
|
child.runId,
|
|
@@ -576,18 +678,18 @@ var WorkflowExecution = class {
|
|
|
576
678
|
outcome = {
|
|
577
679
|
ok: false,
|
|
578
680
|
error: wrap(
|
|
579
|
-
failure ?
|
|
681
|
+
failure ? chunkELL2RBML_cjs.failureToError(failure) : new chunkELL2RBML_cjs.ApplicationError("Child failed", { errorType: "UNKNOWN" })
|
|
580
682
|
)
|
|
581
683
|
};
|
|
582
684
|
break;
|
|
583
685
|
case "CHILD_RUN_CANCELLED":
|
|
584
|
-
outcome = { ok: false, error: wrap(new
|
|
686
|
+
outcome = { ok: false, error: wrap(new chunkELL2RBML_cjs.CancelledFailure("Child run cancelled")) };
|
|
585
687
|
break;
|
|
586
688
|
case "CHILD_RUN_TERMINATED":
|
|
587
689
|
outcome = {
|
|
588
690
|
ok: false,
|
|
589
691
|
error: wrap(
|
|
590
|
-
new
|
|
692
|
+
new chunkELL2RBML_cjs.TerminatedFailure(typeof p["reason"] === "string" ? p["reason"] : "Terminated")
|
|
591
693
|
)
|
|
592
694
|
};
|
|
593
695
|
break;
|
|
@@ -595,7 +697,7 @@ var WorkflowExecution = class {
|
|
|
595
697
|
const timeoutType = typeof p["timeoutType"] === "string" ? p["timeoutType"] : "WORKFLOW_RUN";
|
|
596
698
|
outcome = {
|
|
597
699
|
ok: false,
|
|
598
|
-
error: wrap(new
|
|
700
|
+
error: wrap(new chunkELL2RBML_cjs.TimeoutFailure(`Child run timed out (${timeoutType})`, timeoutType))
|
|
599
701
|
};
|
|
600
702
|
}
|
|
601
703
|
}
|
|
@@ -618,7 +720,7 @@ var WorkflowExecution = class {
|
|
|
618
720
|
dispatchSignal(name, payload) {
|
|
619
721
|
const handler = this.signalHandlers.get(name);
|
|
620
722
|
if (handler) {
|
|
621
|
-
this.runHandler(() => handler(payload));
|
|
723
|
+
this.runHandler(() => handler(payload), name, this.signalPolicies.get(name));
|
|
622
724
|
return;
|
|
623
725
|
}
|
|
624
726
|
const waiters = this.signalWaiters.get(name);
|
|
@@ -630,7 +732,7 @@ var WorkflowExecution = class {
|
|
|
630
732
|
}
|
|
631
733
|
if (this.defaultSignalHandler) {
|
|
632
734
|
const fallback = this.defaultSignalHandler;
|
|
633
|
-
this.runHandler(() => fallback(name, payload));
|
|
735
|
+
this.runHandler(() => fallback(name, payload), name, this.defaultSignalPolicy);
|
|
634
736
|
return;
|
|
635
737
|
}
|
|
636
738
|
const buffer = this.signalBuffers.get(name) ?? [];
|
|
@@ -646,7 +748,7 @@ var WorkflowExecution = class {
|
|
|
646
748
|
if (position >= 0) this.signalOrder.splice(position, 1);
|
|
647
749
|
return payload;
|
|
648
750
|
}
|
|
649
|
-
runHandler(call) {
|
|
751
|
+
runHandler(call, name, policy = "WARN_AND_ABANDON") {
|
|
650
752
|
let result;
|
|
651
753
|
try {
|
|
652
754
|
result = call();
|
|
@@ -656,17 +758,40 @@ var WorkflowExecution = class {
|
|
|
656
758
|
}
|
|
657
759
|
if (result instanceof Promise) {
|
|
658
760
|
this.runningHandlers += 1;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
761
|
+
const entry = this.running.get(name) ?? { count: 0, policy };
|
|
762
|
+
entry.count += 1;
|
|
763
|
+
entry.policy = policy;
|
|
764
|
+
this.running.set(name, entry);
|
|
765
|
+
const done = () => {
|
|
766
|
+
this.runningHandlers -= 1;
|
|
767
|
+
entry.count -= 1;
|
|
768
|
+
if (entry.count === 0) this.running.delete(name);
|
|
769
|
+
};
|
|
770
|
+
result.then(done, (error) => {
|
|
771
|
+
done();
|
|
772
|
+
this.onWorkflowError(error);
|
|
773
|
+
});
|
|
668
774
|
}
|
|
669
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* The drain check of 11 §2.18 when the workflow finishes: handlers still
|
|
778
|
+
* running with policy `WARN_AND_ABANDON` give one warning line and
|
|
779
|
+
* `unfinishedHandlers` in the result. A replay never reports them.
|
|
780
|
+
*/
|
|
781
|
+
checkUnfinishedHandlers(command) {
|
|
782
|
+
if (this.replaying || command.type === "CANCEL_WORKFLOW") return;
|
|
783
|
+
const unfinished = [...this.running.entries()].filter(([, entry]) => entry.count > 0 && entry.policy === "WARN_AND_ABANDON").map(([name, entry]) => ({ kind: "signal", name, count: entry.count })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
784
|
+
if (unfinished.length === 0) return;
|
|
785
|
+
this.unfinished = unfinished;
|
|
786
|
+
const total = unfinished.reduce((sum, entry) => sum + entry.count, 0);
|
|
787
|
+
this.logs.push({
|
|
788
|
+
level: "warn",
|
|
789
|
+
message: `The workflow finished while ${total} signal handler${total === 1 ? " was" : "s were"} still running (${unfinished.map((entry) => `${entry.name} x${entry.count}`).join(
|
|
790
|
+
", "
|
|
791
|
+
)}); await ctx.allHandlersFinished() before returning, or set unfinishedPolicy: 'ABANDON' on the handler`,
|
|
792
|
+
data: unfinished.map((entry) => ({ kind: entry.kind, name: entry.name, count: entry.count }))
|
|
793
|
+
});
|
|
794
|
+
}
|
|
670
795
|
// ---- the workflow function ------------------------------------------------
|
|
671
796
|
startFunction(input) {
|
|
672
797
|
let promise;
|
|
@@ -705,11 +830,11 @@ var WorkflowExecution = class {
|
|
|
705
830
|
return;
|
|
706
831
|
}
|
|
707
832
|
const name = errorName(error);
|
|
708
|
-
if (error instanceof
|
|
833
|
+
if (error instanceof chunkELL2RBML_cjs.DeterminismViolation || name === "DeterminismViolation") {
|
|
709
834
|
this.failTask("NON_DETERMINISM", messageOf(error), stackTextOf(error), void 0, name);
|
|
710
835
|
return;
|
|
711
836
|
}
|
|
712
|
-
if (error instanceof
|
|
837
|
+
if (error instanceof chunkELL2RBML_cjs.HistoryLimitExceeded) {
|
|
713
838
|
this.failTask("HISTORY_LIMIT", messageOf(error), stackTextOf(error));
|
|
714
839
|
return;
|
|
715
840
|
}
|
|
@@ -717,16 +842,16 @@ var WorkflowExecution = class {
|
|
|
717
842
|
this.failTask("ISOLATE_MEMORY", messageOf(error), stackTextOf(error), void 0, name);
|
|
718
843
|
return;
|
|
719
844
|
}
|
|
720
|
-
if (error instanceof
|
|
845
|
+
if (error instanceof chunkELL2RBML_cjs.PhaseCFeatureError) {
|
|
721
846
|
this.failTask("UNSUPPORTED_COMMAND", messageOf(error), stackTextOf(error));
|
|
722
847
|
return;
|
|
723
848
|
}
|
|
724
|
-
if (this.cancelRequested &&
|
|
849
|
+
if (this.cancelRequested && chunkELL2RBML_cjs.isCancellation(error)) {
|
|
725
850
|
this.pushTerminal({ type: "CANCEL_WORKFLOW" });
|
|
726
851
|
return;
|
|
727
852
|
}
|
|
728
|
-
if (
|
|
729
|
-
this.pushTerminal({ type: "FAIL_WORKFLOW", failure:
|
|
853
|
+
if (chunkELL2RBML_cjs.isRunFailure(error) || this.isFailureType(error)) {
|
|
854
|
+
this.pushTerminal({ type: "FAIL_WORKFLOW", failure: chunkELL2RBML_cjs.errorToFailure(error) });
|
|
730
855
|
return;
|
|
731
856
|
}
|
|
732
857
|
this.failTask(
|
|
@@ -748,8 +873,8 @@ var WorkflowExecution = class {
|
|
|
748
873
|
*/
|
|
749
874
|
checkLimit() {
|
|
750
875
|
const events = this.historyLength + this.commands.length;
|
|
751
|
-
if (events >= this.limitEvents *
|
|
752
|
-
throw new
|
|
876
|
+
if (events >= this.limitEvents * chunk3FIDHONL_cjs.HISTORY_LIMIT_EXCEEDED_RATIO || this.historyBytes >= this.limitBytes * chunk3FIDHONL_cjs.HISTORY_LIMIT_EXCEEDED_RATIO)
|
|
877
|
+
throw new chunkELL2RBML_cjs.HistoryLimitExceeded(
|
|
753
878
|
`The history has ${events} events and ${this.historyBytes} bytes, past 95 % of its limit (${this.limitEvents} events, ${this.limitBytes} bytes); continue as new`
|
|
754
879
|
);
|
|
755
880
|
}
|
|
@@ -764,9 +889,10 @@ var WorkflowExecution = class {
|
|
|
764
889
|
if (this.closed || this.failure) return;
|
|
765
890
|
this.commands.push(command);
|
|
766
891
|
this.closed = true;
|
|
892
|
+
this.checkUnfinishedHandlers(command);
|
|
767
893
|
}
|
|
768
894
|
stack() {
|
|
769
|
-
return this.captureStacks ? captureStack() : void 0;
|
|
895
|
+
return this.captureStacks ? chunkQ4MWQNJK_cjs.captureStack() : void 0;
|
|
770
896
|
}
|
|
771
897
|
never() {
|
|
772
898
|
return new Promise(() => void 0);
|
|
@@ -774,8 +900,8 @@ var WorkflowExecution = class {
|
|
|
774
900
|
scheduleActivity(scope, operation, options) {
|
|
775
901
|
if (typeof operation !== "object" || operation === null || typeof operation.nodeType !== "string")
|
|
776
902
|
throw new TypeError("ctx.run needs a node operation (from nodes.* or the generated clients)");
|
|
777
|
-
if (operation.role === "trigger" || !
|
|
778
|
-
throw new
|
|
903
|
+
if (operation.role === "trigger" || !chunk3FIDHONL_cjs.isActivityNodeTypeAllowed(operation.nodeType))
|
|
904
|
+
throw new chunkELL2RBML_cjs.ApplicationError(
|
|
779
905
|
`${operation.nodeType} cannot run as a durable activity: only store and registry nodes and internal:http, internal:datatable, internal:set and internal:code can`,
|
|
780
906
|
{ type: "durable.activityTypeNotAllowed", errorType: "VALIDATION", nonRetryable: true }
|
|
781
907
|
);
|
|
@@ -790,14 +916,14 @@ var WorkflowExecution = class {
|
|
|
790
916
|
nodeType: operation.nodeType,
|
|
791
917
|
operation: operationName,
|
|
792
918
|
args: toJson(options.args, `The args of ${operation.nodeType}`),
|
|
793
|
-
retry:
|
|
919
|
+
retry: chunkYHBVMOMK_cjs.explicitRetryPolicy(options.retry)
|
|
794
920
|
};
|
|
795
921
|
if (nodeVersion !== void 0) command.nodeVersion = nodeVersion;
|
|
796
922
|
if (options.connection !== void 0) command.connection = options.connection;
|
|
797
|
-
const startToClose =
|
|
798
|
-
const scheduleToClose =
|
|
799
|
-
const scheduleToStart =
|
|
800
|
-
const heartbeat =
|
|
923
|
+
const startToClose = chunkJ3PYFGKA_cjs.optionalMs(options.startToCloseTimeout, "startToCloseTimeout");
|
|
924
|
+
const scheduleToClose = chunkJ3PYFGKA_cjs.optionalMs(options.scheduleToCloseTimeout, "scheduleToCloseTimeout");
|
|
925
|
+
const scheduleToStart = chunkJ3PYFGKA_cjs.optionalMs(options.scheduleToStartTimeout, "scheduleToStartTimeout");
|
|
926
|
+
const heartbeat = chunkJ3PYFGKA_cjs.optionalMs(options.heartbeatTimeout, "heartbeatTimeout");
|
|
801
927
|
if (startToClose !== void 0) command.startToCloseTimeout = startToClose;
|
|
802
928
|
if (scheduleToClose !== void 0) command.scheduleToCloseTimeout = scheduleToClose;
|
|
803
929
|
if (scheduleToStart !== void 0) command.scheduleToStartTimeout = scheduleToStart;
|
|
@@ -808,7 +934,7 @@ var WorkflowExecution = class {
|
|
|
808
934
|
if (options.runOn !== void 0) command.runOn = options.runOn;
|
|
809
935
|
if (options.headers !== void 0) command.headers = { ...options.headers };
|
|
810
936
|
if (scope.consideredCancelled)
|
|
811
|
-
return Promise.reject(new
|
|
937
|
+
return Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled"));
|
|
812
938
|
if (!this.push(command)) return this.never();
|
|
813
939
|
this.issued.add(`activity:${activityId}`);
|
|
814
940
|
return new Promise((resolve, reject) => {
|
|
@@ -824,12 +950,12 @@ var WorkflowExecution = class {
|
|
|
824
950
|
if (stack !== void 0) entry.stack = stack;
|
|
825
951
|
entry.release = scope.onCancel(() => {
|
|
826
952
|
if (!this.activities.has(activityId)) return;
|
|
827
|
-
const cancelled = new
|
|
953
|
+
const cancelled = new chunkELL2RBML_cjs.ActivityFailure(
|
|
828
954
|
`Activity ${activityId} cancelled`,
|
|
829
955
|
activityId,
|
|
830
956
|
entry.nodeType,
|
|
831
957
|
entry.operation,
|
|
832
|
-
new
|
|
958
|
+
new chunkELL2RBML_cjs.CancelledFailure("Activity cancelled")
|
|
833
959
|
);
|
|
834
960
|
if (cancellationType !== "ABANDON")
|
|
835
961
|
this.push({ type: "REQUEST_CANCEL_ACTIVITY", activityId });
|
|
@@ -841,6 +967,110 @@ var WorkflowExecution = class {
|
|
|
841
967
|
this.activities.set(activityId, entry);
|
|
842
968
|
});
|
|
843
969
|
}
|
|
970
|
+
/**
|
|
971
|
+
* `ctx.localActivity` (11 §2.12). A replayed activation returns the outcome
|
|
972
|
+
* its history recorded; the open activation takes the outcome the worker
|
|
973
|
+
* passed in `localActivityResults`, or asks for the local activity
|
|
974
|
+
* (`localActivityRequested`) and waits for the same task to run again.
|
|
975
|
+
* Either way the outcome is recorded with `RECORD_LOCAL_ACTIVITY` at the
|
|
976
|
+
* call, so a replay issues the same command at the same position.
|
|
977
|
+
*/
|
|
978
|
+
localActivity(scope, operation, options) {
|
|
979
|
+
if (typeof operation === "function")
|
|
980
|
+
throw new chunkELL2RBML_cjs.PhaseCFeatureError("ctx.localActivity with a function (user local activities)");
|
|
981
|
+
if (typeof operation !== "object" || operation === null || typeof operation.nodeType !== "string")
|
|
982
|
+
throw new TypeError(
|
|
983
|
+
"ctx.localActivity needs a node operation (from nodes.* or the generated clients)"
|
|
984
|
+
);
|
|
985
|
+
const descriptor = operation;
|
|
986
|
+
if (descriptor.role === "trigger" || !chunk3FIDHONL_cjs.isActivityNodeTypeAllowed(descriptor.nodeType))
|
|
987
|
+
throw new chunkELL2RBML_cjs.ApplicationError(
|
|
988
|
+
`${descriptor.nodeType} cannot run as a durable activity: only store and registry nodes and internal:http, internal:datatable, internal:set and internal:code can`,
|
|
989
|
+
{ type: "durable.activityTypeNotAllowed", errorType: "VALIDATION", nonRetryable: true }
|
|
990
|
+
);
|
|
991
|
+
if (typeof options !== "object" || options === null)
|
|
992
|
+
throw new TypeError("ctx.localActivity needs options with args");
|
|
993
|
+
const timeout = options.startToCloseTimeout === void 0 ? chunk3FIDHONL_cjs.LOCAL_ACTIVITY_MAX_TIMEOUT_MS : chunkJ3PYFGKA_cjs.toMs(options.startToCloseTimeout, "startToCloseTimeout");
|
|
994
|
+
if (timeout < 1 || timeout > chunk3FIDHONL_cjs.LOCAL_ACTIVITY_MAX_TIMEOUT_MS)
|
|
995
|
+
throw new TypeError(
|
|
996
|
+
`A local activity's startToCloseTimeout must be between 1 ms and 30 s (got ${timeout} ms); use ctx.run for longer calls`
|
|
997
|
+
);
|
|
998
|
+
const localActivityId = this.ids.next("l");
|
|
999
|
+
const operationName = options.operation ?? descriptor.operation ?? "execute";
|
|
1000
|
+
const nodeVersion = options.nodeVersion ?? descriptor.version;
|
|
1001
|
+
const retry = chunkYHBVMOMK_cjs.explicitRetryPolicy(options.retry);
|
|
1002
|
+
const args = toJson(options.args, `The args of ${descriptor.nodeType}`);
|
|
1003
|
+
if (scope.consideredCancelled)
|
|
1004
|
+
return Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled"));
|
|
1005
|
+
const label = `local activity ${localActivityId} (${descriptor.nodeType} ${operationName})`;
|
|
1006
|
+
const wrap = (cause) => new chunkELL2RBML_cjs.ActivityFailure(
|
|
1007
|
+
`Local activity ${localActivityId} (${descriptor.nodeType} ${operationName}) failed: ${cause.message}`,
|
|
1008
|
+
localActivityId,
|
|
1009
|
+
descriptor.nodeType,
|
|
1010
|
+
operationName,
|
|
1011
|
+
cause
|
|
1012
|
+
);
|
|
1013
|
+
const record = (outcome) => {
|
|
1014
|
+
const command = {
|
|
1015
|
+
type: "RECORD_LOCAL_ACTIVITY",
|
|
1016
|
+
localActivityId,
|
|
1017
|
+
attempts: Math.max(1, Math.round(outcome.attempts)),
|
|
1018
|
+
nodeType: descriptor.nodeType,
|
|
1019
|
+
operation: operationName,
|
|
1020
|
+
...outcome.failure !== void 0 ? { failure: outcome.failure } : { result: outcome.result ?? null }
|
|
1021
|
+
};
|
|
1022
|
+
if (options.summary !== void 0) command.summary = options.summary;
|
|
1023
|
+
if (!this.push(command)) return this.never();
|
|
1024
|
+
if (outcome.failure !== void 0)
|
|
1025
|
+
return Promise.reject(wrap(chunkELL2RBML_cjs.failureToError(outcome.failure)));
|
|
1026
|
+
return Promise.resolve(outcome.result ?? null);
|
|
1027
|
+
};
|
|
1028
|
+
const replayed = this.replaying;
|
|
1029
|
+
if (replayed) {
|
|
1030
|
+
const recorded = this.recordedLocalActivities.get(localActivityId);
|
|
1031
|
+
if (recorded !== void 0) return record(recorded);
|
|
1032
|
+
}
|
|
1033
|
+
const given = replayed ? void 0 : this.localActivityResults.get(localActivityId);
|
|
1034
|
+
let attempt = 1;
|
|
1035
|
+
let backoffMs = 0;
|
|
1036
|
+
if (given !== void 0) {
|
|
1037
|
+
if (given.failure === void 0) return record(given);
|
|
1038
|
+
const decision = chunkYHBVMOMK_cjs.computeRetryDelay(retry, given.attempts, given.failure);
|
|
1039
|
+
if (!decision.retry) return record(given);
|
|
1040
|
+
attempt = given.attempts + 1;
|
|
1041
|
+
backoffMs = decision.delayMs;
|
|
1042
|
+
}
|
|
1043
|
+
const request = {
|
|
1044
|
+
localActivityId,
|
|
1045
|
+
kind: "node",
|
|
1046
|
+
nodeType: descriptor.nodeType,
|
|
1047
|
+
operation: operationName,
|
|
1048
|
+
args,
|
|
1049
|
+
retry,
|
|
1050
|
+
startToCloseTimeout: timeout,
|
|
1051
|
+
attempt,
|
|
1052
|
+
backoffMs
|
|
1053
|
+
};
|
|
1054
|
+
if (nodeVersion !== void 0) request.nodeVersion = nodeVersion;
|
|
1055
|
+
if (options.connection !== void 0) request.connection = options.connection;
|
|
1056
|
+
if (options.summary !== void 0) request.summary = options.summary;
|
|
1057
|
+
return new Promise((resolve, reject) => {
|
|
1058
|
+
const entry = {
|
|
1059
|
+
resolve,
|
|
1060
|
+
reject,
|
|
1061
|
+
description: label,
|
|
1062
|
+
request,
|
|
1063
|
+
replayed
|
|
1064
|
+
};
|
|
1065
|
+
const stack = this.stack();
|
|
1066
|
+
if (stack !== void 0) entry.stack = stack;
|
|
1067
|
+
entry.release = scope.onCancel(() => {
|
|
1068
|
+
if (!this.localActivities.delete(localActivityId)) return;
|
|
1069
|
+
reject(wrap(new chunkELL2RBML_cjs.CancelledFailure("Local activity cancelled")));
|
|
1070
|
+
});
|
|
1071
|
+
this.localActivities.set(localActivityId, entry);
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
844
1074
|
startTimer(scope, durationMs, summary) {
|
|
845
1075
|
return this.timer(scope, durationMs, summary).promise;
|
|
846
1076
|
}
|
|
@@ -848,7 +1078,7 @@ var WorkflowExecution = class {
|
|
|
848
1078
|
timer(scope, durationMs, summary) {
|
|
849
1079
|
if (durationMs <= 0) return { promise: Promise.resolve() };
|
|
850
1080
|
if (scope.consideredCancelled)
|
|
851
|
-
return { promise: Promise.reject(new
|
|
1081
|
+
return { promise: Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled")) };
|
|
852
1082
|
const timerId = this.ids.next("t");
|
|
853
1083
|
const command = {
|
|
854
1084
|
type: "START_TIMER",
|
|
@@ -870,7 +1100,7 @@ var WorkflowExecution = class {
|
|
|
870
1100
|
if (!this.timers.has(timerId)) return;
|
|
871
1101
|
this.timers.delete(timerId);
|
|
872
1102
|
this.push({ type: "CANCEL_TIMER", timerId });
|
|
873
|
-
reject(new
|
|
1103
|
+
reject(new chunkELL2RBML_cjs.CancelledFailure("Timer cancelled"));
|
|
874
1104
|
});
|
|
875
1105
|
this.timers.set(timerId, entry);
|
|
876
1106
|
});
|
|
@@ -888,14 +1118,14 @@ var WorkflowExecution = class {
|
|
|
888
1118
|
condition(scope, predicate, timeout) {
|
|
889
1119
|
if (predicate()) return Promise.resolve(true);
|
|
890
1120
|
if (scope.consideredCancelled)
|
|
891
|
-
return Promise.reject(new
|
|
1121
|
+
return Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled"));
|
|
892
1122
|
return new Promise((resolve, reject) => {
|
|
893
1123
|
const condition = { predicate, resolve, reject };
|
|
894
1124
|
const stack = this.stack();
|
|
895
1125
|
if (stack !== void 0) condition.stack = stack;
|
|
896
1126
|
this.conditions.push(condition);
|
|
897
1127
|
if (timeout !== void 0) {
|
|
898
|
-
const timer = this.timer(scope,
|
|
1128
|
+
const timer = this.timer(scope, chunkJ3PYFGKA_cjs.toMs(timeout, "condition timeout"), void 0);
|
|
899
1129
|
if (timer.timerId !== void 0) condition.timerId = timer.timerId;
|
|
900
1130
|
timer.promise.then(
|
|
901
1131
|
() => {
|
|
@@ -911,7 +1141,7 @@ var WorkflowExecution = class {
|
|
|
911
1141
|
if (!this.conditions.includes(condition)) return;
|
|
912
1142
|
this.conditions = this.conditions.filter((entry) => entry !== condition);
|
|
913
1143
|
this.cancelOwnTimer(condition.timerId);
|
|
914
|
-
reject(new
|
|
1144
|
+
reject(new chunkELL2RBML_cjs.CancelledFailure("Condition cancelled"));
|
|
915
1145
|
});
|
|
916
1146
|
});
|
|
917
1147
|
}
|
|
@@ -939,7 +1169,7 @@ var WorkflowExecution = class {
|
|
|
939
1169
|
return fired;
|
|
940
1170
|
}
|
|
941
1171
|
signalReceived(scope, signal) {
|
|
942
|
-
const name =
|
|
1172
|
+
const name = chunkELL2RBML_cjs.signalName(signal);
|
|
943
1173
|
const buffered = this.takeBuffered(name);
|
|
944
1174
|
if (buffered !== void 0) return Promise.resolve(buffered);
|
|
945
1175
|
return new Promise((resolve, reject) => {
|
|
@@ -958,17 +1188,22 @@ var WorkflowExecution = class {
|
|
|
958
1188
|
const position = list.indexOf(entry);
|
|
959
1189
|
if (position < 0) return;
|
|
960
1190
|
list.splice(position, 1);
|
|
961
|
-
reject(new
|
|
1191
|
+
reject(new chunkELL2RBML_cjs.CancelledFailure("Signal wait cancelled"));
|
|
962
1192
|
});
|
|
963
1193
|
});
|
|
964
1194
|
}
|
|
965
|
-
onSignal(signal, handler) {
|
|
966
|
-
|
|
1195
|
+
onSignal(signal, handler, options = {}) {
|
|
1196
|
+
if (typeof handler !== "function") throw new TypeError("ctx.onSignal needs a handler function");
|
|
1197
|
+
const policy = options.unfinishedPolicy ?? "WARN_AND_ABANDON";
|
|
1198
|
+
if (policy !== "WARN_AND_ABANDON" && policy !== "ABANDON")
|
|
1199
|
+
throw new TypeError("unfinishedPolicy must be WARN_AND_ABANDON or ABANDON");
|
|
1200
|
+
const name = chunkELL2RBML_cjs.signalName(signal);
|
|
967
1201
|
this.signalHandlers.set(name, handler);
|
|
1202
|
+
this.signalPolicies.set(name, policy);
|
|
968
1203
|
let payload = this.takeBuffered(name);
|
|
969
1204
|
while (payload !== void 0) {
|
|
970
1205
|
const value = payload;
|
|
971
|
-
this.runHandler(() => handler(value));
|
|
1206
|
+
this.runHandler(() => handler(value), name, policy);
|
|
972
1207
|
payload = this.takeBuffered(name);
|
|
973
1208
|
}
|
|
974
1209
|
}
|
|
@@ -978,15 +1213,43 @@ var WorkflowExecution = class {
|
|
|
978
1213
|
for (const entry of buffered) {
|
|
979
1214
|
if (this.signalHandlers.has(entry.name)) continue;
|
|
980
1215
|
const payload = this.takeBuffered(entry.name);
|
|
981
|
-
if (payload !== void 0)
|
|
1216
|
+
if (payload !== void 0)
|
|
1217
|
+
this.runHandler(() => handler(entry.name, payload), entry.name, this.defaultSignalPolicy);
|
|
982
1218
|
}
|
|
983
1219
|
}
|
|
1220
|
+
/** The command target of a run handle (11 §2.1, §2.24). */
|
|
1221
|
+
externalTarget(target) {
|
|
1222
|
+
if (typeof target === "string") {
|
|
1223
|
+
if (target === "") throw new TypeError("A run handle needs a run id");
|
|
1224
|
+
return { runId: target };
|
|
1225
|
+
}
|
|
1226
|
+
if (typeof target === "object" && target !== null) {
|
|
1227
|
+
if ("runId" in target && typeof target.runId === "string" && target.runId !== "")
|
|
1228
|
+
return { runId: target.runId };
|
|
1229
|
+
if ("workflowKey" in target && typeof target.workflowKey === "string" && target.workflowKey !== "" && typeof target.workflowId === "string" && target.workflowId !== "") {
|
|
1230
|
+
const out = { workflowKey: target.workflowKey, workflowId: target.workflowId };
|
|
1231
|
+
if (typeof target.firstRunId === "string" && target.firstRunId !== "")
|
|
1232
|
+
out.firstRunId = target.firstRunId;
|
|
1233
|
+
return out;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
throw new TypeError("A run handle needs a run id or { workflowKey, workflowId }");
|
|
1237
|
+
}
|
|
1238
|
+
runHandle(target) {
|
|
1239
|
+
const resolved = this.externalTarget(target);
|
|
1240
|
+
return {
|
|
1241
|
+
runId: "runId" in resolved ? resolved.runId : "",
|
|
1242
|
+
..."workflowId" in resolved ? { workflowKey: resolved.workflowKey, workflowId: resolved.workflowId } : {},
|
|
1243
|
+
signal: (signal, payload) => this.signalExternal(resolved, chunkELL2RBML_cjs.signalName(signal), payload),
|
|
1244
|
+
cancel: () => this.cancelExternal(resolved)
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
984
1247
|
childTarget(target) {
|
|
985
1248
|
if (typeof target === "string") {
|
|
986
1249
|
if (target === "") throw new TypeError("ctx.child needs a workflow key or function");
|
|
987
1250
|
return { workflowKey: target };
|
|
988
1251
|
}
|
|
989
|
-
if (
|
|
1252
|
+
if (chunkJ3PYFGKA_cjs.isDurableWorkflow(target)) {
|
|
990
1253
|
const exportName = this.exportNames.get(target);
|
|
991
1254
|
if (exportName === void 0)
|
|
992
1255
|
throw new TypeError(
|
|
@@ -1006,6 +1269,12 @@ var WorkflowExecution = class {
|
|
|
1006
1269
|
if (options.details !== void 0) opts["details"] = options.details;
|
|
1007
1270
|
if (options.context !== void 0)
|
|
1008
1271
|
opts["context"] = toJson(options.context, "The child context");
|
|
1272
|
+
if (options.retry !== void 0)
|
|
1273
|
+
opts["retry"] = toJson(chunkJ3PYFGKA_cjs.runRetryPolicyOf(options.retry), "The child retry policy");
|
|
1274
|
+
if (options.versioningBehavior !== void 0)
|
|
1275
|
+
opts["versioningBehavior"] = options.versioningBehavior;
|
|
1276
|
+
if (options.idReusePolicy !== void 0) opts["idReusePolicy"] = options.idReusePolicy;
|
|
1277
|
+
if (options.idConflictPolicy !== void 0) opts["idConflictPolicy"] = options.idConflictPolicy;
|
|
1009
1278
|
const durations = [
|
|
1010
1279
|
["startDelay", "startDelay"],
|
|
1011
1280
|
["executionTimeout", "executionTimeout"],
|
|
@@ -1015,7 +1284,7 @@ var WorkflowExecution = class {
|
|
|
1015
1284
|
for (const [key, name] of durations) {
|
|
1016
1285
|
const value = options[key];
|
|
1017
1286
|
if (value !== void 0 && (typeof value === "number" || typeof value === "string"))
|
|
1018
|
-
opts[name] =
|
|
1287
|
+
opts[name] = chunkJ3PYFGKA_cjs.toMs(value, name);
|
|
1019
1288
|
}
|
|
1020
1289
|
const command = {
|
|
1021
1290
|
type: "START_CHILD_RUN",
|
|
@@ -1046,12 +1315,12 @@ var WorkflowExecution = class {
|
|
|
1046
1315
|
onChildCancel(child, entry) {
|
|
1047
1316
|
return () => {
|
|
1048
1317
|
if (child.settled) return;
|
|
1049
|
-
const type = child.cancellationType ??
|
|
1050
|
-
const error = new
|
|
1318
|
+
const type = child.cancellationType ?? chunkRUQIMTN5_cjs.CHILD_DEFAULT_CANCELLATION_TYPE;
|
|
1319
|
+
const error = new chunkELL2RBML_cjs.ChildRunFailure(
|
|
1051
1320
|
`Child run ${child.childId} cancelled`,
|
|
1052
1321
|
child.childId,
|
|
1053
1322
|
child.runId,
|
|
1054
|
-
new
|
|
1323
|
+
new chunkELL2RBML_cjs.CancelledFailure("Child run cancelled")
|
|
1055
1324
|
);
|
|
1056
1325
|
if (type === "ABANDON") {
|
|
1057
1326
|
child.result = void 0;
|
|
@@ -1096,10 +1365,10 @@ var WorkflowExecution = class {
|
|
|
1096
1365
|
scope,
|
|
1097
1366
|
target,
|
|
1098
1367
|
options,
|
|
1099
|
-
|
|
1368
|
+
chunkRUQIMTN5_cjs.CHILD_DEFAULT_PARENT_CLOSE_POLICY.child
|
|
1100
1369
|
);
|
|
1101
1370
|
if (!child)
|
|
1102
|
-
return scope.consideredCancelled ? Promise.reject(new
|
|
1371
|
+
return scope.consideredCancelled ? Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled")) : this.never();
|
|
1103
1372
|
return this.childResult(child);
|
|
1104
1373
|
}
|
|
1105
1374
|
childResult(child) {
|
|
@@ -1124,10 +1393,10 @@ var WorkflowExecution = class {
|
|
|
1124
1393
|
scope,
|
|
1125
1394
|
target,
|
|
1126
1395
|
options,
|
|
1127
|
-
|
|
1396
|
+
chunkRUQIMTN5_cjs.CHILD_DEFAULT_PARENT_CLOSE_POLICY.startChild
|
|
1128
1397
|
);
|
|
1129
1398
|
if (!child)
|
|
1130
|
-
return scope.consideredCancelled ? Promise.reject(new
|
|
1399
|
+
return scope.consideredCancelled ? Promise.reject(new chunkELL2RBML_cjs.CancelledFailure("Scope is cancelled")) : this.never();
|
|
1131
1400
|
return new Promise((resolve, reject) => {
|
|
1132
1401
|
const entry = {
|
|
1133
1402
|
resolve,
|
|
@@ -1142,7 +1411,7 @@ var WorkflowExecution = class {
|
|
|
1142
1411
|
childId: child.childId,
|
|
1143
1412
|
runId: runId ?? child.runId ?? "",
|
|
1144
1413
|
result: () => this.childResult(child),
|
|
1145
|
-
signal: (signal, payload) => this.signalExternal({ childId: child.childId },
|
|
1414
|
+
signal: (signal, payload) => this.signalExternal({ childId: child.childId }, chunkELL2RBML_cjs.signalName(signal), payload),
|
|
1146
1415
|
cancel: () => this.cancelExternal({ childId: child.childId })
|
|
1147
1416
|
};
|
|
1148
1417
|
return handle;
|
|
@@ -1235,19 +1504,18 @@ var WorkflowExecution = class {
|
|
|
1235
1504
|
});
|
|
1236
1505
|
}
|
|
1237
1506
|
upsertContext(entries) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
});
|
|
1507
|
+
const json = toJson(entries, "The context entries");
|
|
1508
|
+
if (!isJsonObject(json)) throw new TypeError("ctx.upsertContext takes an object");
|
|
1509
|
+
if (this.push({ type: "UPSERT_CONTEXT", entries: json })) this.memo = { ...this.memo, ...json };
|
|
1242
1510
|
}
|
|
1243
1511
|
/** The request a `ctx.continueAsNew` call throws; the run ends with `CONTINUE_AS_NEW`. */
|
|
1244
1512
|
continueAsNew(input, options) {
|
|
1245
1513
|
const opts = {};
|
|
1246
1514
|
if (options.taskQueue !== void 0) opts["taskQueue"] = options.taskQueue;
|
|
1247
1515
|
if (options.retry !== void 0)
|
|
1248
|
-
opts["retry"] = toJson(
|
|
1516
|
+
opts["retry"] = toJson(chunkJ3PYFGKA_cjs.continueAsNewRetryOf(options.retry), "retry");
|
|
1249
1517
|
if (options.workflowTaskTimeout !== void 0)
|
|
1250
|
-
opts["workflowTaskTimeout"] =
|
|
1518
|
+
opts["workflowTaskTimeout"] = chunkJ3PYFGKA_cjs.toMs(options.workflowTaskTimeout, "workflowTaskTimeout");
|
|
1251
1519
|
if (options.context !== void 0) opts["context"] = toJson(options.context, "context");
|
|
1252
1520
|
if (options.versioningBehavior !== void 0)
|
|
1253
1521
|
opts["versioningBehavior"] = options.versioningBehavior;
|
|
@@ -1257,7 +1525,7 @@ var WorkflowExecution = class {
|
|
|
1257
1525
|
const scope = new Scope(parent, options.nonCancellable === true);
|
|
1258
1526
|
let timerId;
|
|
1259
1527
|
if (options.timeout !== void 0) {
|
|
1260
|
-
const timer = this.timer(parent,
|
|
1528
|
+
const timer = this.timer(parent, chunkJ3PYFGKA_cjs.toMs(options.timeout, "scope timeout"), void 0);
|
|
1261
1529
|
timerId = timer.timerId;
|
|
1262
1530
|
timer.promise.then(
|
|
1263
1531
|
() => scope.cancel(),
|
|
@@ -1294,6 +1562,7 @@ var WorkflowExecution = class {
|
|
|
1294
1562
|
out.push({ description: entry.description ?? fallback, stack: entry.stack ?? "" });
|
|
1295
1563
|
};
|
|
1296
1564
|
for (const entry of this.activities.values()) add(entry, "activity");
|
|
1565
|
+
for (const entry of this.localActivities.values()) add(entry, "local activity");
|
|
1297
1566
|
for (const entry of this.timers.values()) add(entry, "timer");
|
|
1298
1567
|
for (const child of this.children.values()) {
|
|
1299
1568
|
add(child.started, "child start");
|
|
@@ -1313,7 +1582,7 @@ var WorkflowExecution = class {
|
|
|
1313
1582
|
}
|
|
1314
1583
|
answerQueries() {
|
|
1315
1584
|
return (this.request.queries ?? []).map((query) => {
|
|
1316
|
-
if (!
|
|
1585
|
+
if (!chunk3FIDHONL_cjs.BUILT_IN_QUERIES.includes(query.name))
|
|
1317
1586
|
return {
|
|
1318
1587
|
queryId: query.queryId,
|
|
1319
1588
|
error: `Unknown query ${String(query.name)}; custom queries are Phase C`
|
|
@@ -1333,7 +1602,7 @@ ${entry.stack}`).join("\n\n")
|
|
|
1333
1602
|
sdk: { name: SDK_NAME, version: this.sdkVersion },
|
|
1334
1603
|
stacks: this.pendingStacks().map((entry) => ({
|
|
1335
1604
|
description: entry.description,
|
|
1336
|
-
locations: parseStack(entry.stack).map((location) => {
|
|
1605
|
+
locations: chunkQ4MWQNJK_cjs.parseStack(entry.stack).map((location) => {
|
|
1337
1606
|
const out = {};
|
|
1338
1607
|
if (location.filePath !== void 0) out["filePath"] = location.filePath;
|
|
1339
1608
|
if (location.line !== void 0) out["line"] = location.line;
|
|
@@ -1379,27 +1648,28 @@ ${entry.stack}`).join("\n\n")
|
|
|
1379
1648
|
const scopeFn = ((fn, options = {}) => this.cancellationScope(scope(), fn, options));
|
|
1380
1649
|
scopeFn.current = () => scope();
|
|
1381
1650
|
const phaseC = (feature) => () => {
|
|
1382
|
-
throw new
|
|
1651
|
+
throw new chunkELL2RBML_cjs.PhaseCFeatureError(feature);
|
|
1383
1652
|
};
|
|
1384
1653
|
const context = {
|
|
1385
1654
|
info: this.info,
|
|
1386
1655
|
log: logger,
|
|
1387
1656
|
run: (operation, options) => this.scheduleActivity(scope(), operation, options),
|
|
1388
|
-
sleep: (duration, options = {}) => this.startTimer(scope(),
|
|
1657
|
+
sleep: (duration, options = {}) => this.startTimer(scope(), chunkJ3PYFGKA_cjs.toMs(duration, "sleep duration"), options.summary),
|
|
1389
1658
|
condition: (predicate, timeout) => this.condition(scope(), predicate, timeout),
|
|
1390
1659
|
signalReceived: (signal) => this.signalReceived(scope(), signal),
|
|
1391
|
-
onSignal: (signal,
|
|
1660
|
+
onSignal: ((signal, optionsOrHandler, maybeHandler) => {
|
|
1661
|
+
if (typeof optionsOrHandler === "function") this.onSignal(signal, optionsOrHandler);
|
|
1662
|
+
else if (maybeHandler !== void 0)
|
|
1663
|
+
this.onSignal(signal, maybeHandler, optionsOrHandler ?? {});
|
|
1664
|
+
else throw new TypeError("ctx.onSignal needs a handler function");
|
|
1665
|
+
}),
|
|
1392
1666
|
setDefaultSignalHandler: (handler) => this.setDefaultSignalHandler(handler),
|
|
1393
1667
|
child: (target, options = {}) => this.child(scope(), target, options),
|
|
1394
1668
|
startChild: (target, options = {}) => this.startChild(scope(), target, options),
|
|
1395
|
-
signalRun: (
|
|
1396
|
-
signalParent: (signal, payload) => this.signalExternal({ parent: true },
|
|
1397
|
-
getRunHandle: (
|
|
1398
|
-
|
|
1399
|
-
signal: (signal, payload) => this.signalExternal({ runId }, chunkFMSW2HDF_cjs.signalName(signal), payload),
|
|
1400
|
-
cancel: () => this.cancelExternal({ runId })
|
|
1401
|
-
}),
|
|
1402
|
-
cancelRun: (runId) => this.cancelExternal({ runId }),
|
|
1669
|
+
signalRun: (target, signal, payload) => this.signalExternal(this.externalTarget(target), chunkELL2RBML_cjs.signalName(signal), payload),
|
|
1670
|
+
signalParent: (signal, payload) => this.signalExternal({ parent: true }, chunkELL2RBML_cjs.signalName(signal), payload),
|
|
1671
|
+
getRunHandle: (target) => this.runHandle(target),
|
|
1672
|
+
cancelRun: (target) => this.cancelExternal(this.externalTarget(target)),
|
|
1403
1673
|
now: () => this.clock,
|
|
1404
1674
|
random: () => this.random(),
|
|
1405
1675
|
uuid: () => chunkL24YIZY7_cjs.uuidFrom(this.random),
|
|
@@ -1428,7 +1698,7 @@ ${entry.stack}`).join("\n\n")
|
|
|
1428
1698
|
}
|
|
1429
1699
|
});
|
|
1430
1700
|
},
|
|
1431
|
-
isCancellation: (error) =>
|
|
1701
|
+
isCancellation: (error) => chunkELL2RBML_cjs.isCancellation(error),
|
|
1432
1702
|
saga: () => {
|
|
1433
1703
|
const compensations = [];
|
|
1434
1704
|
return {
|
|
@@ -1453,9 +1723,7 @@ ${entry.stack}`).join("\n\n")
|
|
|
1453
1723
|
},
|
|
1454
1724
|
allHandlersFinished: () => this.allHandlersFinished(),
|
|
1455
1725
|
activity: phaseC("ctx.activity (user activities)"),
|
|
1456
|
-
localActivity:
|
|
1457
|
-
"ctx.localActivity (local activities)"
|
|
1458
|
-
),
|
|
1726
|
+
localActivity: ((operation, options) => this.localActivity(scope(), operation, options)),
|
|
1459
1727
|
handleQuery: phaseC("ctx.handleQuery (custom queries)"),
|
|
1460
1728
|
handleUpdate: phaseC("ctx.handleUpdate (updates)"),
|
|
1461
1729
|
upsertSearchAttributes: phaseC("ctx.upsertSearchAttributes (search attributes)")
|
|
@@ -1473,7 +1741,7 @@ function buildWorkflowRegistry(modules) {
|
|
|
1473
1741
|
for (const [, namespace] of modules) {
|
|
1474
1742
|
for (const exportName of Object.keys(namespace).sort()) {
|
|
1475
1743
|
const value = namespace[exportName];
|
|
1476
|
-
if (!
|
|
1744
|
+
if (!chunkJ3PYFGKA_cjs.isDurableWorkflow(value)) continue;
|
|
1477
1745
|
const existing = byName.get(exportName);
|
|
1478
1746
|
if (existing && existing !== value) ambiguous.add(exportName);
|
|
1479
1747
|
byName.set(exportName, value);
|
|
@@ -1484,7 +1752,7 @@ function buildWorkflowRegistry(modules) {
|
|
|
1484
1752
|
}
|
|
1485
1753
|
function failedResult(cause, message) {
|
|
1486
1754
|
return {
|
|
1487
|
-
protocol:
|
|
1755
|
+
protocol: chunk3FIDHONL_cjs.HISTORY_PROTOCOL,
|
|
1488
1756
|
outcome: "failed",
|
|
1489
1757
|
commands: [],
|
|
1490
1758
|
failure: { cause, message },
|
|
@@ -1517,14 +1785,14 @@ function createWorkflowRuntime(registry, shims = void 0) {
|
|
|
1517
1785
|
const internalFailure = (error) => {
|
|
1518
1786
|
const message = error instanceof Error ? error.message : String(error);
|
|
1519
1787
|
const stack = error instanceof Error ? error.stack : void 0;
|
|
1520
|
-
if (error instanceof
|
|
1521
|
-
else if (error instanceof
|
|
1788
|
+
if (error instanceof chunkELL2RBML_cjs.HistoryLimitExceeded) execution?.failTask("HISTORY_LIMIT", message, stack);
|
|
1789
|
+
else if (error instanceof chunkELL2RBML_cjs.DeterminismViolation || error instanceof Error && error.name === "DeterminismViolation")
|
|
1522
1790
|
execution?.failTask("NON_DETERMINISM", message, stack);
|
|
1523
1791
|
else execution?.failTask("INTERNAL", message, stack);
|
|
1524
1792
|
};
|
|
1525
1793
|
return Object.freeze({
|
|
1526
|
-
protocol:
|
|
1527
|
-
sdkVersion:
|
|
1794
|
+
protocol: chunk3FIDHONL_cjs.HISTORY_PROTOCOL,
|
|
1795
|
+
sdkVersion: chunkJ3PYFGKA_cjs.SDK_VERSION,
|
|
1528
1796
|
start(requestJson) {
|
|
1529
1797
|
shims?.detach();
|
|
1530
1798
|
execution = void 0;
|
|
@@ -1539,10 +1807,10 @@ function createWorkflowRuntime(registry, shims = void 0) {
|
|
|
1539
1807
|
);
|
|
1540
1808
|
return;
|
|
1541
1809
|
}
|
|
1542
|
-
if (isObject(parsed) && parsed["protocol"] !==
|
|
1810
|
+
if (isObject(parsed) && parsed["protocol"] !== chunk3FIDHONL_cjs.HISTORY_PROTOCOL) {
|
|
1543
1811
|
early = failedResult(
|
|
1544
1812
|
"PROTOCOL_MISMATCH",
|
|
1545
|
-
`This bundle speaks runtime protocol ${
|
|
1813
|
+
`This bundle speaks runtime protocol ${chunk3FIDHONL_cjs.HISTORY_PROTOCOL}; the request uses ${String(parsed["protocol"])}`
|
|
1546
1814
|
);
|
|
1547
1815
|
return;
|
|
1548
1816
|
}
|
|
@@ -1571,7 +1839,7 @@ function createWorkflowRuntime(registry, shims = void 0) {
|
|
|
1571
1839
|
definition,
|
|
1572
1840
|
exportNames: registry.exportNames,
|
|
1573
1841
|
request,
|
|
1574
|
-
sdkVersion:
|
|
1842
|
+
sdkVersion: chunkJ3PYFGKA_cjs.SDK_VERSION
|
|
1575
1843
|
});
|
|
1576
1844
|
execution = created;
|
|
1577
1845
|
shims?.attach({ now: () => created.now(), random: () => created.nextRandom() });
|