@fluidgrids/workflows 2026.1028.2 → 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-XHXIDVEC.js → chunk-25BKWR2O.js} +1 -1
- package/dist/{chunk-UK3WM7YZ.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-HWJZVOG7.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-VRHHBPT6.js → chunk-MJ5TGYVG.js} +333 -65
- package/dist/{chunk-SAOBPYYJ.cjs → chunk-NXFBVDOI.cjs} +3 -3
- package/dist/{chunk-XKJA7KX3.js → chunk-OIX4O6UR.js} +38 -2
- package/dist/{chunk-FEW3JBYA.cjs → chunk-OKX3FYIM.cjs} +3 -3
- package/dist/{chunk-M4BBAERY.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-BOoHZgoQ.d.cts → file-cgL9l9l8.d.cts} +765 -14
- package/dist/{file-yuPCFU5b.d.ts → 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-BzmUz0sq.d.cts → lower-3S6PsqjJ.d.cts} +40 -6
- package/dist/{lower-_-iT4HYs.d.ts → lower-DmZpQ8hJ.d.ts} +40 -6
- 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 +6 -6
- package/dist/quickjs/index.d.ts +6 -6
- package/dist/quickjs/index.js +8 -7
- package/dist/roundtrip/index.cjs +245 -43
- package/dist/roundtrip/index.d.cts +86 -9
- package/dist/roundtrip/index.d.ts +86 -9
- 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 +127 -10
- package/dist/testing/index.d.ts +127 -10
- 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-C2a05WUJ.d.ts → workflow-DWTPHFbt.d.ts} +124 -12
- package/dist/{workflow-J-yYixny.d.cts → 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-2J6TF7YI.cjs +0 -86
- package/dist/chunk-BO6OVILK.js +0 -79
- package/dist/chunk-DHTLALBL.cjs +0 -80
- package/dist/chunk-I5LR3D2K.js +0 -869
- package/dist/chunk-N23SKIG4.js +0 -73
- package/dist/chunk-QQ6ULXHI.cjs +0 -885
- package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
- package/dist/node-evaluator-SX4LEYQC.js +0 -12
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { durationMs } from './chunk-LNUQE6D6.js';
|
|
2
|
+
import { explicitRunRetryPolicy, explicitRetryPolicy } from './chunk-PWIUEWC3.js';
|
|
3
|
+
|
|
4
|
+
// src/durable/durations.ts
|
|
5
|
+
function toMs(value, what = "duration") {
|
|
6
|
+
const ms = durationMs(value, "ms");
|
|
7
|
+
if (ms === void 0) throw new TypeError(`${what} "${String(value)}" is not a duration`);
|
|
8
|
+
return Math.round(ms);
|
|
9
|
+
}
|
|
10
|
+
function optionalMs(value, what) {
|
|
11
|
+
return value === void 0 ? void 0 : toMs(value, what);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/durable/workflow.ts
|
|
15
|
+
var DURABLE_MARKER = "fluidgrids.durable-workflow";
|
|
16
|
+
var MAX_WORKFLOW_TASK_TIMEOUT_MS = 12e4;
|
|
17
|
+
function checkRunOptions(name, options) {
|
|
18
|
+
const where = `workflow("${name}")`;
|
|
19
|
+
for (const key of ["executionTimeout", "runTimeout", "workflowTaskTimeout"]) {
|
|
20
|
+
const value = options[key];
|
|
21
|
+
if (value !== void 0) toMs(value, `${where} ${key}`);
|
|
22
|
+
}
|
|
23
|
+
if (options.workflowTaskTimeout !== void 0 && toMs(options.workflowTaskTimeout) > MAX_WORKFLOW_TASK_TIMEOUT_MS)
|
|
24
|
+
throw new TypeError(`${where}: workflowTaskTimeout may be at most 120 s`);
|
|
25
|
+
if (options.versioningBehavior !== void 0 && options.versioningBehavior !== "PINNED" && options.versioningBehavior !== "AUTO_UPGRADE")
|
|
26
|
+
throw new TypeError(`${where}: versioningBehavior must be PINNED or AUTO_UPGRADE`);
|
|
27
|
+
const retry = options.retry;
|
|
28
|
+
if (retry !== void 0) {
|
|
29
|
+
checkRunRetryKeys(retry, `${where} retry`);
|
|
30
|
+
if (retry.maxAttempts !== void 0 && (!Number.isInteger(retry.maxAttempts) || retry.maxAttempts < 1))
|
|
31
|
+
throw new TypeError(`${where}: retry.maxAttempts must be a positive integer`);
|
|
32
|
+
if (retry.initialDelay !== void 0) toMs(retry.initialDelay, `${where} retry.initialDelay`);
|
|
33
|
+
if (retry.maxDelay !== void 0) toMs(retry.maxDelay, `${where} retry.maxDelay`);
|
|
34
|
+
if (retry.backoffMultiplier !== void 0 && !(Number.isFinite(retry.backoffMultiplier) && retry.backoffMultiplier >= 1))
|
|
35
|
+
throw new TypeError(`${where}: retry.backoffMultiplier must be at least 1`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var KEY = /^[a-z0-9][a-z0-9_-]{0,127}$/;
|
|
39
|
+
function workflow(name, optionsOrFn, maybeFn) {
|
|
40
|
+
if (typeof name !== "string" || !KEY.test(name))
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`workflow() needs a key of lowercase letters, digits, "-" and "_" (got "${String(name)}")`
|
|
43
|
+
);
|
|
44
|
+
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
45
|
+
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
|
|
46
|
+
if (typeof fn !== "function") throw new TypeError(`workflow("${name}") needs a function`);
|
|
47
|
+
checkRunOptions(name, options);
|
|
48
|
+
return Object.freeze({ __fluidgrids: DURABLE_MARKER, name, options, fn });
|
|
49
|
+
}
|
|
50
|
+
function isDurableWorkflow(value) {
|
|
51
|
+
return typeof value === "object" && value !== null && value.__fluidgrids === DURABLE_MARKER && typeof value.fn === "function";
|
|
52
|
+
}
|
|
53
|
+
function isJsonValue(value, depth = 0) {
|
|
54
|
+
if (depth > 64) return false;
|
|
55
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
56
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
57
|
+
if (Array.isArray(value)) return value.every((item) => isJsonValue(item, depth + 1));
|
|
58
|
+
if (typeof value === "object") {
|
|
59
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
60
|
+
return false;
|
|
61
|
+
return Object.values(value).every((item) => isJsonValue(item, depth + 1));
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
function jsonSchemaOf(schema) {
|
|
66
|
+
if (schema === void 0) return void 0;
|
|
67
|
+
const method = schema.toJSONSchema;
|
|
68
|
+
if (typeof method === "function") {
|
|
69
|
+
const produced = method.call(schema);
|
|
70
|
+
return isJsonValue(produced) && typeof produced === "object" && !Array.isArray(produced) && produced !== null ? produced : void 0;
|
|
71
|
+
}
|
|
72
|
+
return isJsonValue(schema) && !Array.isArray(schema) && schema !== null && typeof schema === "object" ? schema : void 0;
|
|
73
|
+
}
|
|
74
|
+
function interfaceOf(definition) {
|
|
75
|
+
const out = {};
|
|
76
|
+
const input = jsonSchemaOf(definition.options.input);
|
|
77
|
+
const output = jsonSchemaOf(definition.options.output);
|
|
78
|
+
if (input) out.input = input;
|
|
79
|
+
if (output) out.output = output;
|
|
80
|
+
const signals = definition.options.signals ?? [];
|
|
81
|
+
if (signals.length > 0) {
|
|
82
|
+
out.signals = {};
|
|
83
|
+
for (const signal of signals) {
|
|
84
|
+
const entry = {};
|
|
85
|
+
const payload = jsonSchemaOf(signal.schema);
|
|
86
|
+
if (payload) entry.payload = payload;
|
|
87
|
+
if (signal.description !== void 0) entry.description = signal.description;
|
|
88
|
+
out.signals[signal.name] = entry;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const queries = definition.options.queries ?? [];
|
|
92
|
+
if (queries.length > 0) {
|
|
93
|
+
out.queries = {};
|
|
94
|
+
for (const query of queries)
|
|
95
|
+
out.queries[query.name] = query.description !== void 0 ? { description: query.description } : {};
|
|
96
|
+
}
|
|
97
|
+
const updates = definition.options.updates ?? [];
|
|
98
|
+
if (updates.length > 0) {
|
|
99
|
+
out.updates = {};
|
|
100
|
+
for (const update of updates)
|
|
101
|
+
out.updates[update.name] = update.description !== void 0 ? { description: update.description } : {};
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
var RUN_RETRY_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
106
|
+
"maxAttempts",
|
|
107
|
+
"initialDelay",
|
|
108
|
+
"backoffMultiplier",
|
|
109
|
+
"maxDelay",
|
|
110
|
+
"nonRetryableErrorTypes"
|
|
111
|
+
]);
|
|
112
|
+
var ACTIVITY_RETRY_ONLY_KEYS = /* @__PURE__ */ new Set([
|
|
113
|
+
"retryDelay",
|
|
114
|
+
"maxRetries",
|
|
115
|
+
"retryOnErrorTypes"
|
|
116
|
+
]);
|
|
117
|
+
function checkRunRetryKeys(retry, where) {
|
|
118
|
+
if (typeof retry !== "object" || retry === null || Array.isArray(retry))
|
|
119
|
+
throw new TypeError(`${where} must be an object`);
|
|
120
|
+
for (const key of Object.keys(retry)) {
|
|
121
|
+
if (RUN_RETRY_OPTION_KEYS.has(key)) continue;
|
|
122
|
+
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)" : "";
|
|
123
|
+
throw new TypeError(`${where} has an unknown option "${key}"${hint}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function runRetryPolicyOf(retry) {
|
|
127
|
+
checkRunRetryKeys(retry, "retry");
|
|
128
|
+
const policy = {};
|
|
129
|
+
if (retry.maxAttempts !== void 0) policy.maxAttempts = retry.maxAttempts;
|
|
130
|
+
if (retry.initialDelay !== void 0)
|
|
131
|
+
policy.initialDelayMs = toMs(retry.initialDelay, "retry.initialDelay");
|
|
132
|
+
if (retry.backoffMultiplier !== void 0) policy.backoffMultiplier = retry.backoffMultiplier;
|
|
133
|
+
if (retry.maxDelay !== void 0) policy.maxDelayMs = toMs(retry.maxDelay, "retry.maxDelay");
|
|
134
|
+
if (retry.nonRetryableErrorTypes !== void 0)
|
|
135
|
+
policy.nonRetryableErrorTypes = [...retry.nonRetryableErrorTypes];
|
|
136
|
+
return explicitRunRetryPolicy(policy);
|
|
137
|
+
}
|
|
138
|
+
function continueAsNewRetryOf(retry) {
|
|
139
|
+
if (typeof retry !== "object" || retry === null || Array.isArray(retry))
|
|
140
|
+
throw new TypeError("continueAsNew retry must be an object");
|
|
141
|
+
const keys = Object.keys(retry);
|
|
142
|
+
const legacy = keys.some((key) => ACTIVITY_RETRY_ONLY_KEYS.has(key));
|
|
143
|
+
if (!legacy) return runRetryPolicyOf(retry);
|
|
144
|
+
if (keys.includes("maxAttempts") || keys.includes("initialDelay"))
|
|
145
|
+
throw new TypeError(
|
|
146
|
+
"continueAsNew retry mixes the activity retry shape (retryDelay, maxRetries) with the run-level one (maxAttempts, initialDelay); use the run-level keys"
|
|
147
|
+
);
|
|
148
|
+
return explicitRetryPolicy(retry);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/generated/version.ts
|
|
152
|
+
var SDK_VERSION = "2026.1029.1";
|
|
153
|
+
|
|
154
|
+
export { DURABLE_MARKER, MAX_WORKFLOW_TASK_TIMEOUT_MS, SDK_VERSION, continueAsNewRetryOf, interfaceOf, isDurableWorkflow, jsonSchemaOf, optionalMs, runRetryPolicyOf, toMs, workflow };
|