@fluidgrids/workflows 2026.1028.2 → 2026.1030.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 +181 -11
- package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
- package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
- package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
- package/dist/chunk-3U2NU7YC.cjs +124 -0
- package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
- package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
- package/dist/chunk-5HIVIV53.js +330 -0
- package/dist/chunk-5MFVJM76.js +1222 -0
- package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
- package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
- package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
- package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
- package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
- package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
- package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
- package/dist/chunk-C4F5KJTI.js +293 -0
- package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
- package/dist/chunk-GEQDGUGB.cjs +2719 -0
- package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
- package/dist/chunk-HMZUGSMU.cjs +1554 -0
- package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
- package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
- package/dist/chunk-JSC75O5C.cjs +167 -0
- package/dist/chunk-M272AHEX.js +25 -0
- package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
- package/dist/chunk-ODZ2IAR2.cjs +1247 -0
- package/dist/chunk-Q4MWQNJK.cjs +28 -0
- package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
- package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
- package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
- package/dist/chunk-VA4OFR72.cjs +324 -0
- package/dist/chunk-VU5S5A7V.js +150 -0
- package/dist/chunk-YEHR4NNE.js +1522 -0
- package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/collect-6NIEufHd.d.ts +103 -0
- package/dist/collect-CcTCKqx6.d.cts +103 -0
- package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
- package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
- package/dist/history/index.cjs +375 -86
- package/dist/history/index.d.cts +590 -12
- package/dist/history/index.d.ts +590 -12
- package/dist/history/index.js +50 -4
- package/dist/index.cjs +156 -50
- package/dist/index.d.cts +38 -58
- package/dist/index.d.ts +38 -58
- package/dist/index.js +6 -4
- package/dist/interceptors-CNcr2dlk.d.ts +159 -0
- package/dist/interceptors-CqkNZVfI.d.cts +159 -0
- package/dist/ir/index.cjs +362 -38
- package/dist/ir/index.d.cts +282 -7
- package/dist/ir/index.d.ts +282 -7
- package/dist/ir/index.js +329 -23
- package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
- package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
- package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
- package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
- package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
- package/dist/node-evaluator-LEEVD7H7.js +14 -0
- package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
- package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
- package/dist/quickjs/index.cjs +28 -27
- package/dist/quickjs/index.d.cts +6 -6
- package/dist/quickjs/index.d.ts +6 -6
- package/dist/quickjs/index.js +10 -9
- package/dist/roundtrip/index.cjs +259 -51
- package/dist/roundtrip/index.d.cts +100 -9
- package/dist/roundtrip/index.d.ts +100 -9
- package/dist/roundtrip/index.js +177 -11
- package/dist/runtime/index.cjs +21 -20
- package/dist/runtime/index.d.cts +184 -15
- package/dist/runtime/index.d.ts +184 -15
- package/dist/runtime/index.js +8 -7
- package/dist/testing/index.cjs +1122 -115
- package/dist/testing/index.d.cts +294 -13
- package/dist/testing/index.d.ts +294 -13
- package/dist/testing/index.js +1086 -84
- package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
- package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
- package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
- package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
- package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
- package/dist/workflow-BGnv8SS6.d.ts +803 -0
- package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
- package/dist/workflow-DS32Gtws.d.cts +803 -0
- package/fixtures/histories/activity-options-updated.history.json +159 -0
- package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
- 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/codec-opaque.history.json +229 -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/dynamic-workflow.history.json +150 -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/interceptor-headers.history.json +339 -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/query-custom.history.json +213 -0
- package/fixtures/histories/query-default-handler.history.json +120 -0
- package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
- package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -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/search-attributes-upserted.history.json +177 -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/fixtures/histories/update-accepted-completed.history.json +45 -30
- package/fixtures/histories/update-default-handler.history.json +246 -0
- package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
- package/fixtures/histories/update-not-handled.history.json +138 -0
- package/fixtures/histories/update-rejected-no-event.history.json +190 -0
- package/fixtures/histories/update-with-start-admitted.history.json +150 -0
- package/fixtures/histories/user-activity-cancel.history.json +149 -0
- package/fixtures/histories/user-activity-retry.history.json +143 -0
- package/fixtures/histories/user-activity.history.json +149 -0
- package/package.json +1 -1
- package/schema/bridge-v2.schema.json +1062 -0
- package/schema/history-file.schema.json +538 -83
- package/schema/ir-v2.schema.json +290 -0
- package/schema/payload-fields.json +162 -0
- package/schema/run-event.schema.json +503 -82
- package/schema/workflow-command.schema.json +372 -69
- package/schema/workflow-task.schema.json +924 -171
- package/dist/assemble-BLqQ8lSu.d.cts +0 -39
- package/dist/assemble-DWgaXHd-.d.ts +0 -39
- package/dist/chunk-DHTLALBL.cjs +0 -80
- package/dist/chunk-DJYMDLV5.js +0 -227
- package/dist/chunk-I5LR3D2K.js +0 -869
- package/dist/chunk-M4BBAERY.cjs +0 -1635
- package/dist/chunk-N23SKIG4.js +0 -73
- package/dist/chunk-PZCVF76Q.cjs +0 -868
- package/dist/chunk-QQ6ULXHI.cjs +0 -885
- package/dist/chunk-UK3WM7YZ.cjs +0 -75
- package/dist/chunk-VOKMAAJP.js +0 -848
- package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
- package/dist/node-evaluator-SX4LEYQC.js +0 -12
- package/dist/workflow-C2a05WUJ.d.ts +0 -444
- package/dist/workflow-J-yYixny.d.cts +0 -444
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/runtime/stack.ts
|
|
4
|
+
var RUNTIME_FRAME = /fluidgrids-runtime|\/runtime\/(scheduler|index)\.|WorkflowExecution|RuntimeContext/;
|
|
5
|
+
function captureStack() {
|
|
6
|
+
const stack = new Error("stack").stack ?? "";
|
|
7
|
+
return stack.split("\n").slice(1).filter((line) => line.trim() !== "" && !RUNTIME_FRAME.test(line)).join("\n");
|
|
8
|
+
}
|
|
9
|
+
var V8_FRAME = /^\s*at (?:(.*?) \()?(.*?):(\d+):(\d+)\)?$/;
|
|
10
|
+
var QUICKJS_FRAME = /^\s*at (?:(.*?) )?\(?(.*?)(?::(\d+))?(?::(\d+))?\)?$/;
|
|
11
|
+
function parseStack(stack) {
|
|
12
|
+
const locations = [];
|
|
13
|
+
for (const line of stack.split("\n")) {
|
|
14
|
+
if (line.trim() === "") continue;
|
|
15
|
+
const match = V8_FRAME.exec(line) ?? QUICKJS_FRAME.exec(line);
|
|
16
|
+
if (!match) continue;
|
|
17
|
+
const location = {};
|
|
18
|
+
if (match[1]) location.functionName = match[1];
|
|
19
|
+
if (match[2]) location.filePath = match[2];
|
|
20
|
+
if (match[3]) location.line = Number(match[3]);
|
|
21
|
+
if (match[4]) location.column = Number(match[4]);
|
|
22
|
+
locations.push(location);
|
|
23
|
+
}
|
|
24
|
+
return locations;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.captureStack = captureStack;
|
|
28
|
+
exports.parseStack = parseStack;
|
|
@@ -2,7 +2,7 @@ import { autoLayout } from './chunk-5LUIDMF4.js';
|
|
|
2
2
|
import { makeRef, isPredicate, conditionTreeOf, BuilderError, refModelOf } from './chunk-JZ4TOOLN.js';
|
|
3
3
|
import { formatRefTemplate } from './chunk-7AAZGVKD.js';
|
|
4
4
|
import { isRecord, setOwn, cloneJson, ownValue } from './chunk-PMCM2OH4.js';
|
|
5
|
-
import { isDurableWorkflow, SDK_VERSION } from './chunk-
|
|
5
|
+
import { isDurableWorkflow, SDK_VERSION } from './chunk-C4F5KJTI.js';
|
|
6
6
|
|
|
7
7
|
// src/builder/descriptors.ts
|
|
8
8
|
function op(nodeType, version, operation) {
|
|
@@ -61,7 +61,11 @@ var internalNodes = {
|
|
|
61
61
|
respondToWebhook: op("internal:respond-to-webhook"),
|
|
62
62
|
sendAndWait: op("internal:send-and-wait"),
|
|
63
63
|
codeWorkflow: op("internal:code-workflow"),
|
|
64
|
-
waitForSignal: op("internal:wait-for-signal")
|
|
64
|
+
waitForSignal: op("internal:wait-for-signal"),
|
|
65
|
+
/** Phase C: signal another run (`fluidgrids.run-control`). */
|
|
66
|
+
signalRun: op("internal:signal-run"),
|
|
67
|
+
/** Phase C: upsert the run's search attributes (`fluidgrids.search-attributes`). */
|
|
68
|
+
setSearchAttributes: op("internal:set-search-attributes")
|
|
65
69
|
};
|
|
66
70
|
var nodes = {
|
|
67
71
|
internal: internalNodes,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkODZ2IAR2_cjs = require('./chunk-ODZ2IAR2.cjs');
|
|
4
4
|
|
|
5
5
|
// src/generated/vm-worker-source.ts
|
|
6
6
|
var VM_WORKER_SOURCE = '"use strict";\n\nvar import_node_worker_threads = require("node:worker_threads");\n\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\n\nvar DETERMINISM_VIOLATION = "DeterminismViolation";\nvar DETERMINISM_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(DETERMINISM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(\n what + " is not allowed in workflow code: lowering must give the same IR on every build. Read times and random values at run time instead (for example wf.now)."\n );\n error.name = NAME;\n throw error;\n };\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return fail("Date()");\n if (args.length === 0) return fail("new Date()");\n return Reflect.construct(RealDate, args, new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now() { return fail("Date.now()"); });\n lock(LockedDate, "parse", RealDate.parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() { return fail("Math.random()"); });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n for (const name of ["getRandomValues", "randomUUID"]) {\n if (typeof crypto[name] === "function") lock(crypto, name, function () { return fail("crypto." + name + "()"); });\n }\n }\n const DateTimeFormat = typeof Intl === "object" && Intl !== null ? Intl.DateTimeFormat : undefined;\n if (typeof DateTimeFormat === "function") {\n const proto = DateTimeFormat.prototype;\n const format = Object.getOwnPropertyDescriptor(proto, "format");\n if (format && typeof format.get === "function") {\n const get = format.get;\n Object.defineProperty(proto, "format", {\n get() {\n const bound = get.call(this);\n return (date) => (date === undefined ? fail("Intl.DateTimeFormat format()") : bound(date));\n },\n enumerable: false,\n configurable: false,\n });\n }\n const formatToParts = proto.formatToParts;\n if (typeof formatToParts === "function") {\n lock(proto, "formatToParts", function (date) {\n return date === undefined ? fail("Intl.DateTimeFormat formatToParts()") : formatToParts.call(this, date);\n });\n }\n }\n})();\n`;\nfunction failure(kind, message) {\n return { ok: false, failure: kind, message };\n}\n\nvar import_node_vm = require("node:vm");\nvar import_node_util = require("node:util");\nvar BUNDLE_GLOBAL = "__fluidgridsBundle";\nfunction wrap(code) {\n return `(function () {\n const describe = (error) => {\n let name = "Error";\n let message = "";\n try {\n if (error !== null && (typeof error === "object" || typeof error === "function")) {\n const n = error.name;\n if (typeof n === "string") name = n;\n const m = error.message;\n message = typeof m === "string" ? m : m === undefined ? "" + error : "" + m;\n } else {\n message = "" + error;\n }\n } catch (_) {\n message = "a value whose message cannot be read was thrown";\n }\n return (name === ${JSON.stringify(DETERMINISM_VIOLATION)} ? "D" : "E") + message;\n };\n try {\n${code}\n;const __fluidgridsValue = ${BUNDLE_GLOBAL}.__fluidgrids;\n return typeof __fluidgridsValue === "string" ? "R" + __fluidgridsValue : "N";\n } catch (error) {\n try {\n return describe(error);\n } catch (_) {\n return "Ean error that cannot be described was thrown";\n }\n }\n})()`;\n}\nfunction hostErrorFields(error) {\n if (!import_node_util.types.isNativeError(error)) return {};\n const code = Object.getOwnPropertyDescriptor(error, "code")?.value;\n const message = Object.getOwnPropertyDescriptor(error, "message")?.value;\n return {\n ...typeof code === "string" ? { code } : {},\n ...typeof message === "string" ? { message } : {}\n };\n}\nfunction decode(result) {\n const tag = result.charAt(0);\n const rest = result.slice(1);\n if (tag === "R") return { ok: true, value: rest };\n if (tag === "N")\n return failure("no-collection", "The bundle did not export a workflow collection");\n if (tag === "D") return failure("determinism", rest);\n return failure("error", rest);\n}\nfunction runInVmContext(code, timeoutMs) {\n const context = (0, import_node_vm.createContext)(/* @__PURE__ */ Object.create(null), {\n codeGeneration: { strings: false, wasm: false },\n microtaskMode: "afterEvaluate",\n name: "fluidgrids-workflow-lowering"\n });\n const refuseImport = () => {\n throw new Error("Workflow code may not import modules at run time");\n };\n const deadline = Date.now() + timeoutMs;\n const run = (source, filename) => new import_node_vm.Script(source, { filename, importModuleDynamically: refuseImport }).runInContext(context, {\n timeout: Math.max(1, deadline - Date.now()),\n breakOnSigint: true\n });\n try {\n run(DETERMINISM_PRELUDE, "determinism-prelude.js");\n const result = run(wrap(code), "workflow-bundle.js");\n return typeof result === "string" ? decode(result) : failure("no-collection", "The bundle did not export a workflow collection");\n } catch (error) {\n const fields = hostErrorFields(error);\n if (fields.code === "ERR_SCRIPT_EXECUTION_TIMEOUT" || fields.message !== void 0 && /^Script execution timed out/.test(fields.message)) {\n return failure("timeout", `Evaluating the workflow code timed out after ${timeoutMs} ms`);\n }\n return failure("error", fields.message ?? "The workflow code could not be evaluated");\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nvar input = import_node_worker_threads.workerData;\nimport_node_worker_threads.parentPort?.postMessage(\n isRecord(input) && typeof input["code"] === "string" && typeof input["timeoutMs"] === "number" ? runInVmContext(input["code"], input["timeoutMs"]) : failure("crashed", "The evaluation worker received no bundle")\n);\n';
|
|
@@ -13,13 +13,13 @@ function createNodeVmEvaluator(options = {}) {
|
|
|
13
13
|
return {
|
|
14
14
|
format: "iife",
|
|
15
15
|
async evaluate(code) {
|
|
16
|
-
const outcome = await
|
|
16
|
+
const outcome = await chunkODZ2IAR2_cjs.runIsolateWorker({
|
|
17
17
|
source: VM_WORKER_SOURCE,
|
|
18
18
|
workerData: { code, timeoutMs },
|
|
19
19
|
timeoutMs,
|
|
20
20
|
resourceLimits: { maxOldGenerationSizeMb: Math.max(16, Math.ceil(memoryLimitBytes / MIB)) }
|
|
21
21
|
});
|
|
22
|
-
return
|
|
22
|
+
return chunkODZ2IAR2_cjs.outcomeToCollection(outcome);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -1,7 +1,89 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/history/retry.ts
|
|
4
|
+
var DEFAULT_ACTIVITY_RETRY = Object.freeze({
|
|
5
|
+
retryDelay: 1e3,
|
|
6
|
+
backoffMultiplier: 2,
|
|
7
|
+
maxDelay: 1e5
|
|
8
|
+
});
|
|
9
|
+
var FINAL_TIMEOUTS = /* @__PURE__ */ new Set(["SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE"]);
|
|
10
|
+
function computeRetryDelay(policy, attempt, failure) {
|
|
11
|
+
if (failure?.nonRetryable === true) return { retry: false, reason: "nonRetryable" };
|
|
12
|
+
if (failure?.timeoutType !== void 0 && FINAL_TIMEOUTS.has(failure.timeoutType))
|
|
13
|
+
return { retry: false, reason: "finalTimeout" };
|
|
14
|
+
if (failure?.type !== void 0 && policy.nonRetryableErrorTypes !== void 0 && policy.nonRetryableErrorTypes.includes(failure.type))
|
|
15
|
+
return { retry: false, reason: "typeDenied" };
|
|
16
|
+
if (failure !== void 0 && policy.retryOnErrorTypes !== void 0 && policy.retryOnErrorTypes.length > 0 && !policy.retryOnErrorTypes.includes(failure.errorType))
|
|
17
|
+
return { retry: false, reason: "errorTypeNotListed" };
|
|
18
|
+
if (policy.maxRetries !== void 0 && attempt > policy.maxRetries)
|
|
19
|
+
return { retry: false, reason: "maxRetries" };
|
|
20
|
+
if (failure?.nextRetryDelayMs !== void 0)
|
|
21
|
+
return { retry: true, delayMs: Math.max(0, Math.round(failure.nextRetryDelayMs)) };
|
|
22
|
+
const base = Math.max(0, policy.retryDelay);
|
|
23
|
+
const multiplier = policy.backoffMultiplier ?? 2;
|
|
24
|
+
const cap = policy.maxDelay ?? base * 100;
|
|
25
|
+
const exponent = Math.max(0, attempt - 1);
|
|
26
|
+
const delay = Math.min(base * Math.pow(multiplier, exponent), cap);
|
|
27
|
+
return { retry: true, delayMs: Math.round(Number.isFinite(delay) ? delay : cap) };
|
|
28
|
+
}
|
|
29
|
+
function explicitRetryPolicy(policy) {
|
|
30
|
+
const retryDelay = policy?.retryDelay ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
|
|
31
|
+
const out = {
|
|
32
|
+
retryDelay,
|
|
33
|
+
backoffMultiplier: policy?.backoffMultiplier ?? DEFAULT_ACTIVITY_RETRY.backoffMultiplier ?? 2,
|
|
34
|
+
maxDelay: policy?.maxDelay ?? (policy?.retryDelay === void 0 ? 1e5 : Math.max(retryDelay, retryDelay * 100))
|
|
35
|
+
};
|
|
36
|
+
if (policy?.maxRetries !== void 0) out.maxRetries = policy.maxRetries;
|
|
37
|
+
if (policy?.retryOnErrorTypes !== void 0)
|
|
38
|
+
out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
|
|
39
|
+
if (policy?.nonRetryableErrorTypes !== void 0)
|
|
40
|
+
out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function computeRunRetryDelay(policy, attempt, failure) {
|
|
44
|
+
if (policy === void 0) return { retry: false, reason: "noPolicy" };
|
|
45
|
+
if (failure.timeoutType === "WORKFLOW_EXECUTION")
|
|
46
|
+
return { retry: false, reason: "executionTimeout" };
|
|
47
|
+
if (policy.maxAttempts !== void 0 && attempt >= policy.maxAttempts)
|
|
48
|
+
return { retry: false, reason: "maxAttempts" };
|
|
49
|
+
const activityPolicy = {
|
|
50
|
+
retryDelay: policy.initialDelayMs,
|
|
51
|
+
...policy.backoffMultiplier !== void 0 ? { backoffMultiplier: policy.backoffMultiplier } : {},
|
|
52
|
+
...policy.maxDelayMs !== void 0 ? { maxDelay: policy.maxDelayMs } : {},
|
|
53
|
+
...policy.retryOnErrorTypes !== void 0 ? { retryOnErrorTypes: policy.retryOnErrorTypes } : {},
|
|
54
|
+
...policy.nonRetryableErrorTypes !== void 0 ? { nonRetryableErrorTypes: policy.nonRetryableErrorTypes } : {}
|
|
55
|
+
};
|
|
56
|
+
const classified = { ...failure };
|
|
57
|
+
if (classified.timeoutType === "WORKFLOW_RUN") delete classified.timeoutType;
|
|
58
|
+
const decision = computeRetryDelay(activityPolicy, attempt, classified);
|
|
59
|
+
if (decision.retry) return decision;
|
|
60
|
+
switch (decision.reason) {
|
|
61
|
+
case "nonRetryable":
|
|
62
|
+
case "typeDenied":
|
|
63
|
+
case "errorTypeNotListed":
|
|
64
|
+
return { retry: false, reason: decision.reason };
|
|
65
|
+
default:
|
|
66
|
+
return { retry: false, reason: "maxAttempts" };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function explicitRunRetryPolicy(policy) {
|
|
70
|
+
const initialDelayMs = policy.initialDelayMs ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
|
|
71
|
+
const out = {
|
|
72
|
+
initialDelayMs,
|
|
73
|
+
backoffMultiplier: policy.backoffMultiplier ?? 2,
|
|
74
|
+
maxDelayMs: policy.maxDelayMs ?? (policy.initialDelayMs === void 0 ? 1e5 : Math.max(initialDelayMs, initialDelayMs * 100))
|
|
75
|
+
};
|
|
76
|
+
if (policy.maxAttempts !== void 0) out.maxAttempts = policy.maxAttempts;
|
|
77
|
+
if (policy.retryOnErrorTypes !== void 0) out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
|
|
78
|
+
if (policy.nonRetryableErrorTypes !== void 0)
|
|
79
|
+
out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
3
83
|
// src/history/types.ts
|
|
4
84
|
var HISTORY_PROTOCOL = 1;
|
|
85
|
+
var RUNTIME_RELEASE = 3;
|
|
86
|
+
var RUNTIME_CAPABILITIES = ["updates", "queries", "dynamic"];
|
|
5
87
|
var EVENT_TYPES = [
|
|
6
88
|
"WORKFLOW_STARTED",
|
|
7
89
|
"WORKFLOW_TASK_SCHEDULED",
|
|
@@ -141,6 +223,26 @@ var CHILD_CANCELLATION_TYPES = [
|
|
|
141
223
|
"TRY_CANCEL",
|
|
142
224
|
"ABANDON"
|
|
143
225
|
];
|
|
226
|
+
var WORKFLOW_ID_REUSE_POLICIES = [
|
|
227
|
+
"ALLOW_DUPLICATE",
|
|
228
|
+
"ALLOW_DUPLICATE_FAILED_ONLY",
|
|
229
|
+
"REJECT_DUPLICATE"
|
|
230
|
+
];
|
|
231
|
+
var WORKFLOW_ID_CONFLICT_POLICIES = [
|
|
232
|
+
"FAIL",
|
|
233
|
+
"USE_EXISTING",
|
|
234
|
+
"TERMINATE_EXISTING"
|
|
235
|
+
];
|
|
236
|
+
var VERSIONING_BEHAVIORS = ["PINNED", "AUTO_UPGRADE"];
|
|
237
|
+
var WORKFLOW_TIMEOUT_TYPES = ["WORKFLOW_RUN", "WORKFLOW_EXECUTION"];
|
|
238
|
+
var FAIRNESS_KEY_MAX_LENGTH = 255;
|
|
239
|
+
var FAIRNESS_WEIGHT_MIN = 0.1;
|
|
240
|
+
var FAIRNESS_WEIGHT_MAX = 10;
|
|
241
|
+
var ACTIVITY_NAME_PATTERN = "^[A-Za-z_][A-Za-z0-9_.-]{0,127}$";
|
|
242
|
+
var TASK_QUEUE_NAME_PATTERN = "^[a-z0-9][a-z0-9-]{0,62}$";
|
|
243
|
+
var MAX_ACTIVITY_CONNECTIONS = 16;
|
|
244
|
+
var MAX_HEADERS_BYTES = 16 * 1024;
|
|
245
|
+
var MAX_SINK_CALLS = 256;
|
|
144
246
|
var DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };
|
|
145
247
|
var CONTINUE_AS_NEW_SUGGESTED_RATIO = 0.8;
|
|
146
248
|
var HISTORY_LIMIT_EXCEEDED_RATIO = 0.95;
|
|
@@ -149,6 +251,7 @@ var BUILT_IN_QUERIES = [
|
|
|
149
251
|
"__enhanced_stack_trace",
|
|
150
252
|
"__metadata"
|
|
151
253
|
];
|
|
254
|
+
var LOCAL_ACTIVITY_MAX_TIMEOUT_MS = 3e4;
|
|
152
255
|
var COMMAND_EVENT_TYPES = {
|
|
153
256
|
SCHEDULE_ACTIVITY: "ACTIVITY_SCHEDULED",
|
|
154
257
|
REQUEST_CANCEL_ACTIVITY: "ACTIVITY_CANCEL_REQUESTED",
|
|
@@ -227,25 +330,45 @@ function isCommandEvent(event) {
|
|
|
227
330
|
}
|
|
228
331
|
|
|
229
332
|
exports.ACTIVITY_CANCELLATION_TYPES = ACTIVITY_CANCELLATION_TYPES;
|
|
333
|
+
exports.ACTIVITY_NAME_PATTERN = ACTIVITY_NAME_PATTERN;
|
|
230
334
|
exports.BUILT_IN_QUERIES = BUILT_IN_QUERIES;
|
|
231
335
|
exports.CHILD_CANCELLATION_TYPES = CHILD_CANCELLATION_TYPES;
|
|
232
336
|
exports.COMMAND_EVENTS = COMMAND_EVENTS;
|
|
233
337
|
exports.COMMAND_EVENT_TYPES = COMMAND_EVENT_TYPES;
|
|
234
338
|
exports.COMMAND_TYPES = COMMAND_TYPES;
|
|
235
339
|
exports.CONTINUE_AS_NEW_SUGGESTED_RATIO = CONTINUE_AS_NEW_SUGGESTED_RATIO;
|
|
340
|
+
exports.DEFAULT_ACTIVITY_RETRY = DEFAULT_ACTIVITY_RETRY;
|
|
236
341
|
exports.DEFAULT_HISTORY_LIMIT = DEFAULT_HISTORY_LIMIT;
|
|
237
342
|
exports.ERROR_TYPES = ERROR_TYPES;
|
|
238
343
|
exports.EVENT_TYPES = EVENT_TYPES;
|
|
239
344
|
exports.EXECUTION_KINDS = EXECUTION_KINDS;
|
|
345
|
+
exports.FAIRNESS_KEY_MAX_LENGTH = FAIRNESS_KEY_MAX_LENGTH;
|
|
346
|
+
exports.FAIRNESS_WEIGHT_MAX = FAIRNESS_WEIGHT_MAX;
|
|
347
|
+
exports.FAIRNESS_WEIGHT_MIN = FAIRNESS_WEIGHT_MIN;
|
|
240
348
|
exports.HISTORY_LIMIT_EXCEEDED_RATIO = HISTORY_LIMIT_EXCEEDED_RATIO;
|
|
241
349
|
exports.HISTORY_PROTOCOL = HISTORY_PROTOCOL;
|
|
242
350
|
exports.INPUT_EVENTS = INPUT_EVENTS;
|
|
351
|
+
exports.LOCAL_ACTIVITY_MAX_TIMEOUT_MS = LOCAL_ACTIVITY_MAX_TIMEOUT_MS;
|
|
352
|
+
exports.MAX_ACTIVITY_CONNECTIONS = MAX_ACTIVITY_CONNECTIONS;
|
|
353
|
+
exports.MAX_HEADERS_BYTES = MAX_HEADERS_BYTES;
|
|
354
|
+
exports.MAX_SINK_CALLS = MAX_SINK_CALLS;
|
|
243
355
|
exports.PARENT_CLOSE_POLICIES = PARENT_CLOSE_POLICIES;
|
|
244
356
|
exports.PHASE_B_CORE_COMMANDS = PHASE_B_CORE_COMMANDS;
|
|
245
357
|
exports.PHASE_B_PARITY_COMMANDS = PHASE_B_PARITY_COMMANDS;
|
|
246
358
|
exports.PHASE_C_COMMANDS = PHASE_C_COMMANDS;
|
|
359
|
+
exports.RUNTIME_CAPABILITIES = RUNTIME_CAPABILITIES;
|
|
360
|
+
exports.RUNTIME_RELEASE = RUNTIME_RELEASE;
|
|
247
361
|
exports.TASK_FAILURE_CAUSES = TASK_FAILURE_CAUSES;
|
|
362
|
+
exports.TASK_QUEUE_NAME_PATTERN = TASK_QUEUE_NAME_PATTERN;
|
|
248
363
|
exports.TERMINAL_COMMANDS = TERMINAL_COMMANDS;
|
|
249
364
|
exports.TERMINAL_EVENTS = TERMINAL_EVENTS;
|
|
365
|
+
exports.VERSIONING_BEHAVIORS = VERSIONING_BEHAVIORS;
|
|
366
|
+
exports.WORKFLOW_ID_CONFLICT_POLICIES = WORKFLOW_ID_CONFLICT_POLICIES;
|
|
367
|
+
exports.WORKFLOW_ID_REUSE_POLICIES = WORKFLOW_ID_REUSE_POLICIES;
|
|
368
|
+
exports.WORKFLOW_TIMEOUT_TYPES = WORKFLOW_TIMEOUT_TYPES;
|
|
369
|
+
exports.computeRetryDelay = computeRetryDelay;
|
|
370
|
+
exports.computeRunRetryDelay = computeRunRetryDelay;
|
|
371
|
+
exports.explicitRetryPolicy = explicitRetryPolicy;
|
|
372
|
+
exports.explicitRunRetryPolicy = explicitRunRetryPolicy;
|
|
250
373
|
exports.isCommandEvent = isCommandEvent;
|
|
251
374
|
exports.isInputEvent = isInputEvent;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkFR7KYWRO_cjs = require('./chunk-FR7KYWRO.cjs');
|
|
4
|
+
var chunkTYF56RGB_cjs = require('./chunk-TYF56RGB.cjs');
|
|
5
|
+
|
|
6
|
+
// src/durable/durations.ts
|
|
7
|
+
function toMs(value, what = "duration") {
|
|
8
|
+
const ms = chunkFR7KYWRO_cjs.durationMs(value, "ms");
|
|
9
|
+
if (ms === void 0) throw new TypeError(`${what} "${String(value)}" is not a duration`);
|
|
10
|
+
return Math.round(ms);
|
|
11
|
+
}
|
|
12
|
+
function optionalMs(value, what) {
|
|
13
|
+
return value === void 0 ? void 0 : toMs(value, what);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/durable/workflow.ts
|
|
17
|
+
var DURABLE_MARKER = "fluidgrids.durable-workflow";
|
|
18
|
+
var MAX_WORKFLOW_TASK_TIMEOUT_MS = 12e4;
|
|
19
|
+
function checkRunOptions(name, options) {
|
|
20
|
+
const where = `workflow("${name}")`;
|
|
21
|
+
for (const key of ["executionTimeout", "runTimeout", "workflowTaskTimeout"]) {
|
|
22
|
+
const value = options[key];
|
|
23
|
+
if (value !== void 0) toMs(value, `${where} ${key}`);
|
|
24
|
+
}
|
|
25
|
+
if (options.workflowTaskTimeout !== void 0 && toMs(options.workflowTaskTimeout) > MAX_WORKFLOW_TASK_TIMEOUT_MS)
|
|
26
|
+
throw new TypeError(`${where}: workflowTaskTimeout may be at most 120 s`);
|
|
27
|
+
if (options.versioningBehavior !== void 0 && options.versioningBehavior !== "PINNED" && options.versioningBehavior !== "AUTO_UPGRADE")
|
|
28
|
+
throw new TypeError(`${where}: versioningBehavior must be PINNED or AUTO_UPGRADE`);
|
|
29
|
+
const retry = options.retry;
|
|
30
|
+
if (retry !== void 0) {
|
|
31
|
+
checkRunRetryKeys(retry, `${where} retry`);
|
|
32
|
+
if (retry.maxAttempts !== void 0 && (!Number.isInteger(retry.maxAttempts) || retry.maxAttempts < 1))
|
|
33
|
+
throw new TypeError(`${where}: retry.maxAttempts must be a positive integer`);
|
|
34
|
+
if (retry.initialDelay !== void 0) toMs(retry.initialDelay, `${where} retry.initialDelay`);
|
|
35
|
+
if (retry.maxDelay !== void 0) toMs(retry.maxDelay, `${where} retry.maxDelay`);
|
|
36
|
+
if (retry.backoffMultiplier !== void 0 && !(Number.isFinite(retry.backoffMultiplier) && retry.backoffMultiplier >= 1))
|
|
37
|
+
throw new TypeError(`${where}: retry.backoffMultiplier must be at least 1`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
var KEY = /^[a-z0-9][a-z0-9_-]{0,127}$/;
|
|
41
|
+
function workflow(name, optionsOrFn, maybeFn) {
|
|
42
|
+
if (typeof name !== "string" || !KEY.test(name))
|
|
43
|
+
throw new TypeError(
|
|
44
|
+
`workflow() needs a key of lowercase letters, digits, "-" and "_" (got "${String(name)}")`
|
|
45
|
+
);
|
|
46
|
+
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
47
|
+
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
|
|
48
|
+
if (typeof fn !== "function") throw new TypeError(`workflow("${name}") needs a function`);
|
|
49
|
+
checkRunOptions(name, options);
|
|
50
|
+
return Object.freeze({ __fluidgrids: DURABLE_MARKER, name, options, fn });
|
|
51
|
+
}
|
|
52
|
+
function dynamicWorkflow(name, optionsOrFn, maybeFn) {
|
|
53
|
+
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
54
|
+
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
|
|
55
|
+
if (typeof fn !== "function") throw new TypeError(`dynamicWorkflow("${name}") needs a function`);
|
|
56
|
+
const declared = workflow(
|
|
57
|
+
name,
|
|
58
|
+
options,
|
|
59
|
+
(ctx, input) => fn(ctx, ctx.info.workflowFn, input)
|
|
60
|
+
);
|
|
61
|
+
return Object.freeze({ ...declared, dynamic: true });
|
|
62
|
+
}
|
|
63
|
+
function isDurableWorkflow(value) {
|
|
64
|
+
return typeof value === "object" && value !== null && value.__fluidgrids === DURABLE_MARKER && typeof value.fn === "function";
|
|
65
|
+
}
|
|
66
|
+
function isJsonValue(value, depth = 0) {
|
|
67
|
+
if (depth > 64) return false;
|
|
68
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
69
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
70
|
+
if (Array.isArray(value)) return value.every((item) => isJsonValue(item, depth + 1));
|
|
71
|
+
if (typeof value === "object") {
|
|
72
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
73
|
+
return false;
|
|
74
|
+
return Object.values(value).every((item) => isJsonValue(item, depth + 1));
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function jsonSchemaOf(schema) {
|
|
79
|
+
if (schema === void 0) return void 0;
|
|
80
|
+
const method = schema.toJSONSchema;
|
|
81
|
+
if (typeof method === "function") {
|
|
82
|
+
const produced = method.call(schema);
|
|
83
|
+
return isJsonValue(produced) && typeof produced === "object" && !Array.isArray(produced) && produced !== null ? produced : void 0;
|
|
84
|
+
}
|
|
85
|
+
return isJsonValue(schema) && !Array.isArray(schema) && schema !== null && typeof schema === "object" ? schema : void 0;
|
|
86
|
+
}
|
|
87
|
+
function interfaceOf(definition) {
|
|
88
|
+
const out = {};
|
|
89
|
+
const input = jsonSchemaOf(definition.options.input);
|
|
90
|
+
const output = jsonSchemaOf(definition.options.output);
|
|
91
|
+
if (input) out.input = input;
|
|
92
|
+
if (output) out.output = output;
|
|
93
|
+
const signals = definition.options.signals ?? [];
|
|
94
|
+
if (signals.length > 0) {
|
|
95
|
+
out.signals = {};
|
|
96
|
+
for (const signal of signals) {
|
|
97
|
+
const entry = {};
|
|
98
|
+
const payload = jsonSchemaOf(signal.schema);
|
|
99
|
+
if (payload) entry.payload = payload;
|
|
100
|
+
if (signal.description !== void 0) entry.description = signal.description;
|
|
101
|
+
out.signals[signal.name] = entry;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const queries = definition.options.queries ?? [];
|
|
105
|
+
if (queries.length > 0) {
|
|
106
|
+
out.queries = {};
|
|
107
|
+
for (const query of queries)
|
|
108
|
+
out.queries[query.name] = query.description !== void 0 ? { description: query.description } : {};
|
|
109
|
+
}
|
|
110
|
+
const updates = definition.options.updates ?? [];
|
|
111
|
+
if (updates.length > 0) {
|
|
112
|
+
out.updates = {};
|
|
113
|
+
for (const update of updates)
|
|
114
|
+
out.updates[update.name] = update.description !== void 0 ? { description: update.description } : {};
|
|
115
|
+
}
|
|
116
|
+
const open = definition.options.open;
|
|
117
|
+
if (open !== void 0) {
|
|
118
|
+
const flags = {};
|
|
119
|
+
if (open.signals === true) flags.signals = true;
|
|
120
|
+
if (open.queries === true) flags.queries = true;
|
|
121
|
+
if (open.updates === true) flags.updates = true;
|
|
122
|
+
if (Object.keys(flags).length > 0) out.open = flags;
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
var RUN_RETRY_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
127
|
+
"maxAttempts",
|
|
128
|
+
"initialDelay",
|
|
129
|
+
"backoffMultiplier",
|
|
130
|
+
"maxDelay",
|
|
131
|
+
"nonRetryableErrorTypes"
|
|
132
|
+
]);
|
|
133
|
+
var ACTIVITY_RETRY_ONLY_KEYS = /* @__PURE__ */ new Set([
|
|
134
|
+
"retryDelay",
|
|
135
|
+
"maxRetries",
|
|
136
|
+
"retryOnErrorTypes"
|
|
137
|
+
]);
|
|
138
|
+
function checkRunRetryKeys(retry, where) {
|
|
139
|
+
if (typeof retry !== "object" || retry === null || Array.isArray(retry))
|
|
140
|
+
throw new TypeError(`${where} must be an object`);
|
|
141
|
+
for (const key of Object.keys(retry)) {
|
|
142
|
+
if (RUN_RETRY_OPTION_KEYS.has(key)) continue;
|
|
143
|
+
const hint = ACTIVITY_RETRY_ONLY_KEYS.has(key) ? " (that is the activity retry shape; a run-level retry takes maxAttempts, initialDelay, backoffMultiplier, maxDelay and nonRetryableErrorTypes)" : "";
|
|
144
|
+
throw new TypeError(`${where} has an unknown option "${key}"${hint}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function runRetryPolicyOf(retry) {
|
|
148
|
+
checkRunRetryKeys(retry, "retry");
|
|
149
|
+
const policy = {};
|
|
150
|
+
if (retry.maxAttempts !== void 0) policy.maxAttempts = retry.maxAttempts;
|
|
151
|
+
if (retry.initialDelay !== void 0)
|
|
152
|
+
policy.initialDelayMs = toMs(retry.initialDelay, "retry.initialDelay");
|
|
153
|
+
if (retry.backoffMultiplier !== void 0) policy.backoffMultiplier = retry.backoffMultiplier;
|
|
154
|
+
if (retry.maxDelay !== void 0) policy.maxDelayMs = toMs(retry.maxDelay, "retry.maxDelay");
|
|
155
|
+
if (retry.nonRetryableErrorTypes !== void 0)
|
|
156
|
+
policy.nonRetryableErrorTypes = [...retry.nonRetryableErrorTypes];
|
|
157
|
+
return chunkTYF56RGB_cjs.explicitRunRetryPolicy(policy);
|
|
158
|
+
}
|
|
159
|
+
function continueAsNewRetryOf(retry) {
|
|
160
|
+
if (typeof retry !== "object" || retry === null || Array.isArray(retry))
|
|
161
|
+
throw new TypeError("continueAsNew retry must be an object");
|
|
162
|
+
const keys = Object.keys(retry);
|
|
163
|
+
const legacy = keys.some((key) => ACTIVITY_RETRY_ONLY_KEYS.has(key));
|
|
164
|
+
if (!legacy) return runRetryPolicyOf(retry);
|
|
165
|
+
if (keys.includes("maxAttempts") || keys.includes("initialDelay"))
|
|
166
|
+
throw new TypeError(
|
|
167
|
+
"continueAsNew retry mixes the activity retry shape (retryDelay, maxRetries) with the run-level one (maxAttempts, initialDelay); use the run-level keys"
|
|
168
|
+
);
|
|
169
|
+
return chunkTYF56RGB_cjs.explicitRetryPolicy(retry);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/generated/version.ts
|
|
173
|
+
var SDK_VERSION = "2026.1030.1";
|
|
174
|
+
|
|
175
|
+
// src/durable/interceptors.ts
|
|
176
|
+
var INTERCEPTORS_MARKER = "fluidgrids.workflow-interceptors";
|
|
177
|
+
function workflowInterceptors(factory) {
|
|
178
|
+
if (typeof factory !== "function")
|
|
179
|
+
throw new TypeError("workflowInterceptors() needs a factory function");
|
|
180
|
+
return Object.freeze({ __fluidgrids: INTERCEPTORS_MARKER, factory });
|
|
181
|
+
}
|
|
182
|
+
function interceptorsFactoryOf(value) {
|
|
183
|
+
if (typeof value === "function") {
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
if (typeof value === "object" && value !== null && value.__fluidgrids === INTERCEPTORS_MARKER && typeof value.factory === "function")
|
|
187
|
+
return value.factory;
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
function resolveWorkflowInterceptors(factories) {
|
|
191
|
+
const inbound = [];
|
|
192
|
+
const outbound = [];
|
|
193
|
+
for (const factory of factories) {
|
|
194
|
+
const made = factory();
|
|
195
|
+
if (typeof made !== "object" || made === null)
|
|
196
|
+
throw new TypeError("An interceptors factory must return { inbound?, outbound? }");
|
|
197
|
+
const lists = made;
|
|
198
|
+
if (lists.inbound !== void 0) {
|
|
199
|
+
if (!Array.isArray(lists.inbound))
|
|
200
|
+
throw new TypeError("interceptors.inbound must be an array");
|
|
201
|
+
inbound.push(...lists.inbound);
|
|
202
|
+
}
|
|
203
|
+
if (lists.outbound !== void 0) {
|
|
204
|
+
if (!Array.isArray(lists.outbound))
|
|
205
|
+
throw new TypeError("interceptors.outbound must be an array");
|
|
206
|
+
outbound.push(...lists.outbound);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return { inbound, outbound };
|
|
210
|
+
}
|
|
211
|
+
function compose(interceptors, method, terminal) {
|
|
212
|
+
let next = terminal;
|
|
213
|
+
for (let index = interceptors.length - 1; index >= 0; index--) {
|
|
214
|
+
const interceptor = interceptors[index];
|
|
215
|
+
const fn = interceptor?.[method];
|
|
216
|
+
if (typeof fn !== "function") continue;
|
|
217
|
+
const inner = next;
|
|
218
|
+
const call = fn;
|
|
219
|
+
next = (input) => call.call(interceptor, input, inner);
|
|
220
|
+
}
|
|
221
|
+
return next;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/durable/activities.ts
|
|
225
|
+
var ACTIVITY_MARKER = "fluidgrids.activity";
|
|
226
|
+
var ACTIVITY_IMPL_MARKER = "fluidgrids.activity-impl";
|
|
227
|
+
var ACTIVITY_NAME = new RegExp(chunkTYF56RGB_cjs.ACTIVITY_NAME_PATTERN);
|
|
228
|
+
var TASK_QUEUE_NAME = new RegExp(chunkTYF56RGB_cjs.TASK_QUEUE_NAME_PATTERN);
|
|
229
|
+
var DYNAMIC_ACTIVITY_NAME = "*";
|
|
230
|
+
function checkActivityName(name) {
|
|
231
|
+
if (typeof name !== "string" || !ACTIVITY_NAME.test(name))
|
|
232
|
+
throw new TypeError(
|
|
233
|
+
`An activity name must match ${chunkTYF56RGB_cjs.ACTIVITY_NAME_PATTERN} (got "${String(name)}")`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
function checkTaskQueueName(queue, what = "taskQueue") {
|
|
237
|
+
if (typeof queue !== "string" || !TASK_QUEUE_NAME.test(queue))
|
|
238
|
+
throw new TypeError(`${what} must match ${chunkTYF56RGB_cjs.TASK_QUEUE_NAME_PATTERN} (got "${String(queue)}")`);
|
|
239
|
+
}
|
|
240
|
+
function declareActivity(name, options = {}) {
|
|
241
|
+
checkActivityName(name);
|
|
242
|
+
if (options.taskQueue !== void 0) checkTaskQueueName(options.taskQueue);
|
|
243
|
+
return Object.freeze({ __fluidgrids: ACTIVITY_MARKER, name, options: { ...options } });
|
|
244
|
+
}
|
|
245
|
+
function implementActivity(definition, fn) {
|
|
246
|
+
if (!isActivityDefinition(definition))
|
|
247
|
+
throw new TypeError("implementActivity() needs a declareActivity() value");
|
|
248
|
+
if (typeof fn !== "function") throw new TypeError("implementActivity() needs a function");
|
|
249
|
+
return Object.freeze({
|
|
250
|
+
__fluidgrids: ACTIVITY_MARKER,
|
|
251
|
+
name: definition.name,
|
|
252
|
+
options: definition.options,
|
|
253
|
+
implementation: ACTIVITY_IMPL_MARKER,
|
|
254
|
+
fn,
|
|
255
|
+
dynamic: false
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function defineActivity(name, optionsOrFn, maybeFn) {
|
|
259
|
+
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
260
|
+
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
|
|
261
|
+
if (typeof fn !== "function") throw new TypeError(`defineActivity("${name}") needs a function`);
|
|
262
|
+
return implementActivity(declareActivity(name, options), fn);
|
|
263
|
+
}
|
|
264
|
+
function dynamicActivity(fn, options = {}) {
|
|
265
|
+
if (typeof fn !== "function") throw new TypeError("dynamicActivity() needs a function");
|
|
266
|
+
if (options.taskQueue !== void 0) checkTaskQueueName(options.taskQueue);
|
|
267
|
+
return Object.freeze({
|
|
268
|
+
__fluidgrids: ACTIVITY_MARKER,
|
|
269
|
+
name: DYNAMIC_ACTIVITY_NAME,
|
|
270
|
+
options: { ...options },
|
|
271
|
+
implementation: ACTIVITY_IMPL_MARKER,
|
|
272
|
+
fn,
|
|
273
|
+
dynamic: true
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function isActivityDefinition(value) {
|
|
277
|
+
return typeof value === "object" && value !== null && value.__fluidgrids === ACTIVITY_MARKER && typeof value.name === "string";
|
|
278
|
+
}
|
|
279
|
+
function isActivityImplementation(value) {
|
|
280
|
+
return isActivityDefinition(value) && value.implementation === ACTIVITY_IMPL_MARKER && typeof value.fn === "function";
|
|
281
|
+
}
|
|
282
|
+
function findActivityImplementation(implementations, name) {
|
|
283
|
+
return implementations.find((impl) => !impl.dynamic && impl.name === name) ?? implementations.find((impl) => impl.dynamic);
|
|
284
|
+
}
|
|
285
|
+
function executeActivity(implementation, ctx, args, interceptors = []) {
|
|
286
|
+
const fn = implementation.fn;
|
|
287
|
+
const run = compose(
|
|
288
|
+
interceptors,
|
|
289
|
+
"execute",
|
|
290
|
+
async (input) => fn(ctx, input.args)
|
|
291
|
+
);
|
|
292
|
+
return run({ args, headers: ctx.info.headers, info: ctx.info });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
exports.ACTIVITY_IMPL_MARKER = ACTIVITY_IMPL_MARKER;
|
|
296
|
+
exports.ACTIVITY_MARKER = ACTIVITY_MARKER;
|
|
297
|
+
exports.DURABLE_MARKER = DURABLE_MARKER;
|
|
298
|
+
exports.DYNAMIC_ACTIVITY_NAME = DYNAMIC_ACTIVITY_NAME;
|
|
299
|
+
exports.INTERCEPTORS_MARKER = INTERCEPTORS_MARKER;
|
|
300
|
+
exports.MAX_WORKFLOW_TASK_TIMEOUT_MS = MAX_WORKFLOW_TASK_TIMEOUT_MS;
|
|
301
|
+
exports.SDK_VERSION = SDK_VERSION;
|
|
302
|
+
exports.checkActivityName = checkActivityName;
|
|
303
|
+
exports.checkTaskQueueName = checkTaskQueueName;
|
|
304
|
+
exports.compose = compose;
|
|
305
|
+
exports.continueAsNewRetryOf = continueAsNewRetryOf;
|
|
306
|
+
exports.declareActivity = declareActivity;
|
|
307
|
+
exports.defineActivity = defineActivity;
|
|
308
|
+
exports.dynamicActivity = dynamicActivity;
|
|
309
|
+
exports.dynamicWorkflow = dynamicWorkflow;
|
|
310
|
+
exports.executeActivity = executeActivity;
|
|
311
|
+
exports.findActivityImplementation = findActivityImplementation;
|
|
312
|
+
exports.implementActivity = implementActivity;
|
|
313
|
+
exports.interceptorsFactoryOf = interceptorsFactoryOf;
|
|
314
|
+
exports.interfaceOf = interfaceOf;
|
|
315
|
+
exports.isActivityDefinition = isActivityDefinition;
|
|
316
|
+
exports.isActivityImplementation = isActivityImplementation;
|
|
317
|
+
exports.isDurableWorkflow = isDurableWorkflow;
|
|
318
|
+
exports.jsonSchemaOf = jsonSchemaOf;
|
|
319
|
+
exports.optionalMs = optionalMs;
|
|
320
|
+
exports.resolveWorkflowInterceptors = resolveWorkflowInterceptors;
|
|
321
|
+
exports.runRetryPolicyOf = runRetryPolicyOf;
|
|
322
|
+
exports.toMs = toMs;
|
|
323
|
+
exports.workflow = workflow;
|
|
324
|
+
exports.workflowInterceptors = workflowInterceptors;
|