@voltro/workflow 0.33.0 → 0.35.0
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/CHANGELOG.md +1968 -0
- package/dist/{cluster-CyIyBO39.js → cluster-CVyPUB9X.js} +43 -34
- package/dist/cluster.js +1 -1
- package/dist/clusterTestSuite.js +29 -29
- package/dist/index.d.ts +701 -7
- package/dist/index.js +3 -3
- package/dist/{primitives-Bp98_F5L.js → primitives-CyQZeT1t.js} +191 -92
- package/dist/primitives.d.ts +239 -5
- package/dist/primitives.js +2 -2
- package/dist/src-DPkbBZDD.js +2501 -0
- package/package.json +3 -3
- package/dist/src-CP61KZ9V.js +0 -1999
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as e,
|
|
2
|
-
import { $ as
|
|
3
|
-
export {
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, G as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, W as v, _ as y, a as b, b as x, c as S, d as C, f as w, g as T, h as E, i as D, j as O, k, l as A, m as j, n as M, o as N, p as P, r as F, s as I, t as L, u as R, v as z, w as B, x as V, y as H, z as U } from "./primitives-CyQZeT1t.js";
|
|
2
|
+
import { $ as W, A as G, At as K, B as q, C as J, Ct as Y, D as X, Dt as Z, E as Q, Et as $, F as ee, Ft as te, G as ne, H as re, I as ie, It as ae, J as oe, K as se, L as ce, Lt as le, M as ue, Mt as de, N as fe, Nt as pe, O as me, Ot as he, P as ge, Pt as _e, Q as ve, R as ye, Rt as be, S as xe, St as Se, T as Ce, Tt as we, U as Te, V as Ee, W as De, X as Oe, Y as ke, Z as Ae, _ as je, _t as Me, a as Ne, at as Pe, b as Fe, bt as Ie, c as Le, ct as Re, d as ze, dt as Be, et as Ve, f as He, ft as Ue, g as We, gt as Ge, h as Ke, ht as qe, i as Je, it as Ye, j as Xe, jt as Ze, k as Qe, kt as $e, l as et, lt as tt, m as nt, mt as rt, n as it, nt as at, o as ot, ot as st, p as ct, pt as lt, q as ut, r as dt, rt as ft, s as pt, st as mt, t as ht, tt as gt, u as _t, ut as vt, v as yt, vt as bt, w as xt, wt as St, x as Ct, xt as wt, y as Tt, yt as Et, z as Dt, zt as Ot } from "./src-DPkbBZDD.js";
|
|
3
|
+
export { ft as ADMISSIONS_TABLE, ct as BUDGET_HOLDS_TABLE, nt as BudgetHoldExpired, De as CANCEL_ON_WATERMARK, l as CurrentWorkflowExecutionId, u as CurrentWorkflowPatches, B as CurrentWorkflowReplayShape, f as CurrentWorkflowRunId, Ke as DEFAULT_BUDGET_HOLD_TIMEOUT_MS, ne as DEFAULT_COLD_LOOKBACK_MS, ye as DEFAULT_DRAIN_BATCH, se as DEFAULT_EVENT_BATCH, Ye as DEFAULT_LEASE_MS, Je as DEFAULT_MAX_RUN_RECLAIMS, Ne as DEFAULT_REPLAY_SHAPE_LIMIT, q as DEFAULT_STALL_AFTER_MS, Ee as DEFAULT_STALL_EVENT_LOOKBACK, re as DEFAULT_STALL_RUN_PAGE, fe as DEFAULT_SUSPEND_HINT_MS, d as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, t as DEFERRING_CONTROLS, ut as EVENTS_TABLE, St as FlowControlKeyError, Pe as PAUSES_TABLE, st as PENDING_TABLE, oe as WATERMARKS_TABLE, L as WorkflowFlowControlProperty, M as WorkflowMessagesProperty, s as WorkflowRunRecorder, k as WorkflowScheduleProperty, c as WorkflowStepInterceptorTag, F as WorkflowVersionTypeId, D as WorkflowWorkerLayerTypeId, We as _voltroBudgetHoldsTable, de as _voltroWorkflowAdmissionsTable, pe as _voltroWorkflowPausesTable, _e as _voltroWorkflowPendingTable, ae as _voltroWorkflowRunEventsTable, le as _voltroWorkflowRunStepsTable, be as _voltroWorkflowRunsTable, te as _voltroWorkflowStartContextsTable, Ve as _voltroWorkflowWatermarksTable, gt as admitStart, mt as allIntents, _ as assertConsistentPools, Xe as awaitEvent, ue as awaitSignal, xt as awaitSignalSuspending, He as awaitUpdate, je as budgetHoldGeneration, yt as budgetHoldKey, Tt as budgetHoldSignalName, dt as closeWorkflowChildrenForParent, we as comparePendingOrder, Ce as completeSuspendingSignal, $ as decideAdmission, o as deferringControlsOf, Re as deleteIntent, tt as discardIntent, Dt as drainTick, vt as dueIntents, b as durableClock, N as durableQueue, I as durableQueueModule, S as durableRateLimiterModule, Be as evaluateAdmission, p as getCurrentWorkflowExecutionId, U as getCurrentWorkflowRunId, A as getWorkflowFlowControl, e as getWorkflowSchedule, R as getWorkflowVersionMetadata, g as hasCancelOn, v as hasFlowControl, Fe as heldBudgets, Ot as inMemoryWorkflowEngineLayer, it as inspectWorkflow, Z as isFinishExpired, he as isStartExpired, C as isWorkflowWorkerLayer, at as linkExecution, ht as makeInMemoryRecorder, h as makeReplayShapeTracker, ot as makeWorkflowRunRecorder, X as makeWorkflowUpdateId, ge as maybeHintSuspendingSignal, ve as newestEventAt, $e as nextSlotAt, i as nondeterminismEventPayload, pt as normaliseWorkflowPatches, Ue as noteIntentAttempt, lt as parkDelayedStart, w as patch, rt as pauseWorkflow, Ct as pendingBudgetHolds, qe as pendingSlotId, Ge as pendingWindow, Me as persistDefer, W as planCancellations, K as pooledConcurrencyKey, P as processQueue, bt as pruneAdmissions, j as queueWorker, E as rateLimit, Et as readAdmissionState, Ie as readPausedWorkflows, ke as readWatermark, wt as recordAdmission, xe as releaseBudgetHolds, Se as releaseLease, r as reportNondeterminism, ee as resetSuspendHintsForTest, Ze as resolveAdmissionKeys, Le as resolveRunGuardTuning, ie as resolveSuspendHintMs, me as resolveWorkflowMessageRun, Y as resumeWorkflow, Qe as sendWorkflowSignal, G as sendWorkflowUpdate, et as serialiseWorkflowRowForWire, ce as setSuspendSignalHintMs, T as sleep, y as sleepUntil, z as step, H as stepIdempotencyKey, x as stepModule, J as suspendForBudget, Q as suspendingSignalDeferredName, Oe as sweepCancelOn, Te as sweepStalledRuns, _t as truncateWorkflowValue, a as validateFlowControl, O as validateWorkflowSchedule, V as withCompensation, m as workflow, n as workflowModule, ze as wrapWorkflowExecuteWithRunRecording, Ae as writeWatermark };
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { Activity as e, Activity as t, DurableClock as n, DurableClock as r, DurableQueue as i, DurableQueue as a, DurableRateLimiter as o, DurableRateLimiter as s, Workflow as c, Workflow as l } from "@effect/workflow";
|
|
2
|
-
import { Cause as u, Context as d,
|
|
2
|
+
import { Cause as u, Context as d, Cron as f, Duration as p, Effect as m, Either as h, Exit as ee, FiberRef as g, Option as te, Schedule as _, Schema as ne } from "effect";
|
|
3
3
|
//#region src/flowControl.ts
|
|
4
|
-
var
|
|
4
|
+
var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0 || e.concurrency !== void 0 || e.throttle !== void 0 || e.rateLimit !== void 0 || e.batch !== void 0 || e.timeouts?.startMs !== void 0 || e.timeouts?.finishMs !== void 0), v = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, y = [
|
|
5
5
|
"debounce",
|
|
6
6
|
"batch",
|
|
7
7
|
"throttle",
|
|
8
8
|
"concurrency"
|
|
9
|
-
],
|
|
9
|
+
], b = (e) => {
|
|
10
10
|
if (e === void 0) return [];
|
|
11
11
|
let t = [];
|
|
12
12
|
return e.debounce !== void 0 && t.push("debounce"), e.batch !== void 0 && t.push("batch"), e.throttle !== void 0 && t.push("throttle"), e.concurrency !== void 0 && t.push("concurrency"), t;
|
|
13
|
-
},
|
|
13
|
+
}, x = (e, t, n) => {
|
|
14
14
|
let r;
|
|
15
15
|
try {
|
|
16
|
-
r =
|
|
16
|
+
r = p.toMillis(p.decode(e));
|
|
17
17
|
} catch {
|
|
18
18
|
throw Error(`workflow '${n}': ${t} is not a duration Effect can read (got ${JSON.stringify(e)}). Use a spelled-out unit ('15 minutes', '1 hour', '30 seconds'), a number of milliseconds, or a Duration — the abbreviated forms ('15m', '1h') are NOT accepted.`);
|
|
19
19
|
}
|
|
20
20
|
if (!Number.isFinite(r) || r <= 0) throw Error(`workflow '${n}': ${t} must be a positive finite duration, got ${String(e)}`);
|
|
21
21
|
return r;
|
|
22
|
-
},
|
|
22
|
+
}, S = (e, t, n) => {
|
|
23
23
|
if (!Number.isInteger(e) || e <= 0) throw Error(`workflow '${n}': ${t} must be a positive integer, got ${String(e)}`);
|
|
24
24
|
return e;
|
|
25
|
-
},
|
|
25
|
+
}, C = (e, t, n) => {
|
|
26
26
|
if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
|
|
27
27
|
return e;
|
|
28
|
-
},
|
|
28
|
+
}, w = (e) => {
|
|
29
29
|
let t = e?.ast?.propertySignatures;
|
|
30
30
|
if (!Array.isArray(t)) return !1;
|
|
31
31
|
let n = t.find((e) => e.name === "items");
|
|
32
32
|
return n !== void 0 && n.type?._tag === "TupleType";
|
|
33
|
-
},
|
|
33
|
+
}, T = (e) => {
|
|
34
34
|
let { workflowName: t, control: n } = e;
|
|
35
35
|
if (n === void 0) return;
|
|
36
36
|
let r = { workflowName: t };
|
|
37
37
|
if (n.debounce !== void 0) {
|
|
38
|
-
let e = n.debounce, i =
|
|
38
|
+
let e = n.debounce, i = x(e.period, "debounce.period", t), a = e.timeout === void 0 ? void 0 : x(e.timeout, "debounce.timeout", t);
|
|
39
39
|
if (a !== void 0 && a < i) throw Error(`workflow '${t}': debounce.timeout (${a}ms) is shorter than debounce.period (${i}ms), so the burst can never be collapsed — the run would be admitted before the quiet period could ever elapse. Raise the timeout or lower the period.`);
|
|
40
40
|
r.debounce = {
|
|
41
|
-
key:
|
|
41
|
+
key: C(e.key, "debounce.key", t),
|
|
42
42
|
periodMs: i,
|
|
43
43
|
...a === void 0 ? {} : { timeoutMs: a }
|
|
44
44
|
};
|
|
@@ -47,7 +47,7 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
47
47
|
let e = n.singleton;
|
|
48
48
|
if (e.mode !== "skip" && e.mode !== "cancel") throw Error(`workflow '${t}': singleton.mode must be 'skip' or 'cancel'. There is no default — 'skip' discards the incoming request and 'cancel' discards the running one, and choosing for you would silently throw away work either way.`);
|
|
49
49
|
r.singleton = {
|
|
50
|
-
key:
|
|
50
|
+
key: C(e.key, "singleton.key", t),
|
|
51
51
|
mode: e.mode
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -55,34 +55,34 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
55
55
|
let e = n.concurrency;
|
|
56
56
|
if (e.pool !== void 0 && (typeof e.pool != "string" || e.pool.trim() === "")) throw Error(`workflow '${t}': concurrency.pool must be a non-empty name — it is the identity other workflows declare to share this budget, and an empty one would silently merge every empty-named pool in the deployment into one.`);
|
|
57
57
|
r.concurrency = {
|
|
58
|
-
limit:
|
|
59
|
-
...e.key === void 0 ? {} : { key:
|
|
58
|
+
limit: S(e.limit, "concurrency.limit", t),
|
|
59
|
+
...e.key === void 0 ? {} : { key: C(e.key, "concurrency.key", t) },
|
|
60
60
|
...e.pool === void 0 ? {} : { pool: e.pool.trim() }
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
if (n.throttle !== void 0) {
|
|
64
64
|
let e = n.throttle;
|
|
65
65
|
r.throttle = {
|
|
66
|
-
limit:
|
|
67
|
-
periodMs:
|
|
68
|
-
...e.key === void 0 ? {} : { key:
|
|
66
|
+
limit: S(e.limit, "throttle.limit", t),
|
|
67
|
+
periodMs: x(e.period, "throttle.period", t),
|
|
68
|
+
...e.key === void 0 ? {} : { key: C(e.key, "throttle.key", t) }
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
if (n.rateLimit !== void 0) {
|
|
72
72
|
let e = n.rateLimit;
|
|
73
73
|
r.rateLimit = {
|
|
74
|
-
limit:
|
|
75
|
-
periodMs:
|
|
76
|
-
...e.key === void 0 ? {} : { key:
|
|
74
|
+
limit: S(e.limit, "rateLimit.limit", t),
|
|
75
|
+
periodMs: x(e.period, "rateLimit.period", t),
|
|
76
|
+
...e.key === void 0 ? {} : { key: C(e.key, "rateLimit.key", t) }
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
if (n.batch !== void 0) {
|
|
80
80
|
let i = n.batch;
|
|
81
|
-
if (e.payloadSchema !== void 0 && !
|
|
81
|
+
if (e.payloadSchema !== void 0 && !w(e.payloadSchema)) throw Error(`workflow '${t}': batch is declared, so the workflow's own \`payload\` must be the BATCH shape — \`Schema.Struct({ items: Schema.Array(Item) })\` — while callers start it with a SINGLE item. Declare the item's schema as \`batch.item\`. Checked here rather than at admission because a decode failure on the batching replica is a failure nobody is watching.`);
|
|
82
82
|
r.batch = {
|
|
83
|
-
...i.key === void 0 ? {} : { key:
|
|
84
|
-
maxSize:
|
|
85
|
-
timeoutMs:
|
|
83
|
+
...i.key === void 0 ? {} : { key: C(i.key, "batch.key", t) },
|
|
84
|
+
maxSize: S(i.maxSize, "batch.maxSize", t),
|
|
85
|
+
timeoutMs: x(i.timeout, "batch.timeout", t),
|
|
86
86
|
...i.item === void 0 ? {} : { item: i.item }
|
|
87
87
|
};
|
|
88
88
|
}
|
|
@@ -91,7 +91,7 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
91
91
|
r.priority = n.priority;
|
|
92
92
|
}
|
|
93
93
|
if (n.timeouts !== void 0) {
|
|
94
|
-
let e = n.timeouts, i = e.start === void 0 ? void 0 :
|
|
94
|
+
let e = n.timeouts, i = e.start === void 0 ? void 0 : x(e.start, "timeouts.start", t), a = e.finish === void 0 ? void 0 : x(e.finish, "timeouts.finish", t);
|
|
95
95
|
(i !== void 0 || a !== void 0) && (r.timeouts = {
|
|
96
96
|
...i === void 0 ? {} : { startMs: i },
|
|
97
97
|
...a === void 0 ? {} : { finishMs: a }
|
|
@@ -111,7 +111,7 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
111
111
|
if (typeof e?.event != "string" || e.event.length === 0) throw Error(`workflow '${t}': ${r}.event must be a non-empty event name, exactly as ctx.events.publish writes it.`);
|
|
112
112
|
if (e.schema === void 0 || typeof e.schema.ast != "object") throw Error(`workflow '${t}': ${r}.schema must be a Schema for the event payload. It is decoded before \`match\` runs, so the predicate reads the domain type rather than raw JSON.`);
|
|
113
113
|
if (typeof e.match != "function") throw Error(`workflow '${t}': ${r}.match is required. Omitting it would mean "cancel every live run of this workflow whenever '${e.event}' is published" — write \`match: () => true\` if that is what you mean, so it is visible in review.`);
|
|
114
|
-
let i = e.within === void 0 ? void 0 :
|
|
114
|
+
let i = e.within === void 0 ? void 0 : x(e.within, `${r}.within`, t);
|
|
115
115
|
return {
|
|
116
116
|
event: e.event,
|
|
117
117
|
schema: e.schema,
|
|
@@ -122,9 +122,9 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
122
122
|
});
|
|
123
123
|
e.length > 0 && (r.cancelOn = e);
|
|
124
124
|
}
|
|
125
|
-
if (r.timeouts?.startMs !== void 0 &&
|
|
125
|
+
if (r.timeouts?.startMs !== void 0 && b(r).length === 0) throw Error(`workflow '${t}': timeouts.start bounds how long a run may sit in the ADMISSION queue, but this workflow declares no control that can defer one (debounce, batch, throttle, concurrency). It would never fire. Use timeouts.finish to bound the run itself.`);
|
|
126
126
|
return r;
|
|
127
|
-
},
|
|
127
|
+
}, E = (e) => {
|
|
128
128
|
let t = /* @__PURE__ */ new Map();
|
|
129
129
|
for (let n of e) {
|
|
130
130
|
let e = n?.concurrency;
|
|
@@ -137,103 +137,191 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
137
137
|
else if (r.limit !== e.limit) throw Error(`concurrency pool '${e.pool}': '${n.workflowName}' declares limit ${e.limit}, but ${r.workflows.map((e) => `'${e}'`).join(", ")} declare${r.workflows.length === 1 ? "s" : ""} limit ${r.limit}. A pool is ONE budget — every member must declare the same number, or the enforced limit would depend on which workflow's start arrived first. Align the limits, or give the workflows different pool names if they were never meant to share.`);
|
|
138
138
|
else r.workflows.push(n.workflowName);
|
|
139
139
|
}
|
|
140
|
-
},
|
|
140
|
+
}, D = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, O = g.unsafeMake(void 0), k = g.unsafeMake(void 0), A = g.unsafeMake(void 0), j = g.unsafeMake([]), M = () => g.get(O), N = () => g.get(k), P = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, F = 1440 * 6e4, ie = /* @__PURE__ */ new Set([
|
|
141
|
+
"skip",
|
|
142
|
+
"buffer",
|
|
143
|
+
"cancelOther"
|
|
144
|
+
]), ae = /* @__PURE__ */ new Set([
|
|
145
|
+
"skip",
|
|
146
|
+
"latest",
|
|
147
|
+
"all"
|
|
148
|
+
]), I = (e, t) => {
|
|
149
|
+
if (t === void 0) return;
|
|
150
|
+
if (typeof t.timezone != "string" || t.timezone.trim() === "") throw Error(`workflow '${e}': schedule.timezone is required (e.g. "UTC", "Europe/Berlin") — never server-local, which differs between your machine and the container.`);
|
|
151
|
+
let n = f.parse(t.cron, t.timezone);
|
|
152
|
+
if (h.isLeft(n)) throw Error(`workflow '${e}': schedule.cron "${t.cron}" (tz="${t.timezone}") is not a valid cron expression — ${String(n.left)}`);
|
|
153
|
+
let r = t.onOverlap ?? "skip";
|
|
154
|
+
if (!ie.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
|
|
155
|
+
let i = t.backfill ?? "skip";
|
|
156
|
+
if (!ae.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
|
|
157
|
+
let a = F;
|
|
158
|
+
return t.maxRuntime !== void 0 && (a = L(t.maxRuntime, e)), {
|
|
159
|
+
cron: t.cron,
|
|
160
|
+
timezone: t.timezone,
|
|
161
|
+
...t.payload === void 0 ? {} : { payload: t.payload },
|
|
162
|
+
onOverlap: r,
|
|
163
|
+
backfill: i,
|
|
164
|
+
maxRuntimeMs: a
|
|
165
|
+
};
|
|
166
|
+
}, L = (e, t) => {
|
|
167
|
+
let n;
|
|
168
|
+
try {
|
|
169
|
+
n = p.toMillis(p.decode(e));
|
|
170
|
+
} catch {
|
|
171
|
+
throw Error(`workflow '${t}': schedule.maxRuntime is not a duration Effect can read (got ${JSON.stringify(e)}). Use '2 hours', a number of milliseconds, or a Duration.`);
|
|
172
|
+
}
|
|
173
|
+
if (!Number.isFinite(n) || n <= 0) throw Error(`workflow '${t}': schedule.maxRuntime must be a positive finite duration`);
|
|
174
|
+
return n;
|
|
175
|
+
}, R = "__voltroWorkflowSchedule", z = (e) => {
|
|
176
|
+
if (typeof e != "object" || !e) return;
|
|
177
|
+
let t = e[R];
|
|
178
|
+
return t === void 0 ? void 0 : t;
|
|
179
|
+
}, B = (e) => {
|
|
180
|
+
let t = /* @__PURE__ */ new Map();
|
|
181
|
+
for (let n of e) t.set(n.stepName, (t.get(n.stepName) ?? 0) + 1);
|
|
182
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => r.has(e) ? !1 : (r.add(e), !0);
|
|
183
|
+
return {
|
|
184
|
+
reach: (e) => {
|
|
185
|
+
let r = (n.get(e) ?? 0) + 1;
|
|
186
|
+
n.set(e, r);
|
|
187
|
+
let a = t.get(e) ?? 0;
|
|
188
|
+
if (a !== 0 && !(r <= a) && i(`extra:${e}`)) return {
|
|
189
|
+
kind: "extra-step-occurrence",
|
|
190
|
+
stepName: e,
|
|
191
|
+
recorded: a,
|
|
192
|
+
reached: r,
|
|
193
|
+
detail: `step '${e}' was reached ${r} time(s) on this attempt but this run only ever recorded ${a} — the body may have changed how often it runs this step (a loop bound), so the journal replays a result for an iteration the code no longer means.`
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
settle: () => {
|
|
197
|
+
let e = [];
|
|
198
|
+
for (let [r, a] of t) (n.get(r) ?? 0) > 0 || i(`unreached:${r}`) && e.push({
|
|
199
|
+
kind: "unreached-step",
|
|
200
|
+
stepName: r,
|
|
201
|
+
recorded: a,
|
|
202
|
+
reached: 0,
|
|
203
|
+
detail: `step '${r}' ran on an earlier attempt of this run but the current code never reaches it — the step was renamed, removed, or moved behind a branch, so its journaled result is orphaned and any step that replaced it executed fresh.`
|
|
204
|
+
});
|
|
205
|
+
return e;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}, V = g.unsafeMake(void 0), H = (e) => ({
|
|
209
|
+
kind: e.kind,
|
|
210
|
+
stepName: e.stepName,
|
|
211
|
+
recorded: e.recorded,
|
|
212
|
+
reached: e.reached,
|
|
213
|
+
detail: e.detail
|
|
214
|
+
}), U = (e) => m.gen(function* () {
|
|
215
|
+
if (e.length === 0) return;
|
|
216
|
+
let t = yield* g.get(O), n = yield* m.serviceOption(D);
|
|
217
|
+
if (t === void 0 || n._tag !== "Some") return;
|
|
218
|
+
let r = n.value;
|
|
219
|
+
for (let n of e) yield* m.promise(() => r.recordEvent({
|
|
220
|
+
runId: t,
|
|
221
|
+
eventType: "nondeterminism-suspected",
|
|
222
|
+
payload: H(n)
|
|
223
|
+
}).then(() => void 0).catch(() => void 0));
|
|
224
|
+
}), W = (e) => {
|
|
141
225
|
if (typeof e != "object" || !e) return;
|
|
142
226
|
let t = e.retryAfterMillis;
|
|
143
|
-
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return
|
|
227
|
+
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return p.millis(t);
|
|
144
228
|
let n = e.retryAfter;
|
|
145
|
-
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return
|
|
146
|
-
},
|
|
229
|
+
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return p.seconds(n);
|
|
230
|
+
}, G = (e) => p.decode(e), K = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, q = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, J = (e) => {
|
|
147
231
|
if (e.retryable) return e.retryable;
|
|
148
232
|
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
149
233
|
let t = new Set(e.retryableErrors);
|
|
150
234
|
return (e) => {
|
|
151
|
-
let n =
|
|
235
|
+
let n = K(e);
|
|
152
236
|
return n !== void 0 && t.has(n);
|
|
153
237
|
};
|
|
154
238
|
}
|
|
155
239
|
return () => !0;
|
|
156
|
-
},
|
|
157
|
-
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? _.linear(
|
|
240
|
+
}, oe = (e) => {
|
|
241
|
+
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? _.linear(G(e.step ?? t)) : n === "fixed" ? _.spaced(G(t)) : _.exponential(G(t), e.factor ?? 2);
|
|
158
242
|
if (e.maxDelay !== void 0) {
|
|
159
|
-
let t =
|
|
160
|
-
i = _.modifyDelay(i, (e, n) =>
|
|
243
|
+
let t = G(e.maxDelay);
|
|
244
|
+
i = _.modifyDelay(i, (e, n) => p.min(n, t));
|
|
161
245
|
}
|
|
162
246
|
(e.jitter ?? !0) === !0 && (i = _.jittered(i));
|
|
163
247
|
let a = _.intersect(i, _.recurs(Math.max(0, r - 1)));
|
|
164
|
-
return e.maxElapsed !== void 0 && (a = _.upTo(
|
|
165
|
-
},
|
|
166
|
-
let n =
|
|
167
|
-
return e.maxDelay !== void 0 && (i = Math.min(i,
|
|
168
|
-
},
|
|
169
|
-
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity :
|
|
248
|
+
return e.maxElapsed !== void 0 && (a = _.upTo(G(e.maxElapsed))(a)), a;
|
|
249
|
+
}, se = (e, t) => {
|
|
250
|
+
let n = p.toMillis(G(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + p.toMillis(G(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
251
|
+
return e.maxDelay !== void 0 && (i = Math.min(i, p.toMillis(G(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
252
|
+
}, ce = (e, t, n, r) => m.gen(function* () {
|
|
253
|
+
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : p.toMillis(G(t.maxElapsed)), o = yield* m.sync(() => Date.now()), s = 0;
|
|
170
254
|
for (;;) {
|
|
171
|
-
let c = yield*
|
|
172
|
-
if (
|
|
173
|
-
let l = c.cause, d = u.failureOption(l),
|
|
255
|
+
let c = yield* m.exit(e);
|
|
256
|
+
if (ee.isSuccess(c)) return c.value;
|
|
257
|
+
let l = c.cause, d = u.failureOption(l), f = te.isSome(d) ? d.value : u.squash(l);
|
|
174
258
|
s += 1;
|
|
175
|
-
let
|
|
176
|
-
if (s >= i || !n(
|
|
177
|
-
r?.(
|
|
178
|
-
let
|
|
179
|
-
yield*
|
|
259
|
+
let h = (yield* m.sync(() => Date.now())) - o;
|
|
260
|
+
if (s >= i || !n(f) || h >= a) return yield* m.failCause(l);
|
|
261
|
+
r?.(f);
|
|
262
|
+
let g = W(f), _ = g === void 0 ? se(t, s) : p.toMillis(g);
|
|
263
|
+
yield* m.sleep(p.millis(_));
|
|
180
264
|
}
|
|
181
|
-
}),
|
|
182
|
-
if (!
|
|
183
|
-
let r =
|
|
184
|
-
if (t.respectRetryAfter === !0) return
|
|
185
|
-
let i =
|
|
265
|
+
}), le = (e, t, n) => {
|
|
266
|
+
if (!q(t)) return e;
|
|
267
|
+
let r = J(t);
|
|
268
|
+
if (t.respectRetryAfter === !0) return ce(e, t, r, n);
|
|
269
|
+
let i = oe(t), a = n ? m.tapError(e, (e) => m.sync(() => {
|
|
186
270
|
r(e) && n(e);
|
|
187
271
|
})) : e;
|
|
188
|
-
return
|
|
272
|
+
return m.retry(a, {
|
|
189
273
|
schedule: i,
|
|
190
274
|
while: r
|
|
191
275
|
});
|
|
192
|
-
},
|
|
276
|
+
}, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl", ue = (e) => typeof e == "object" && !!e && e[Y] === !0, de = (e) => typeof e == "object" && e && e[X] !== void 0 ? e[X] : {
|
|
193
277
|
version: "1",
|
|
194
278
|
compatibleWith: ["1"],
|
|
195
279
|
patches: []
|
|
196
|
-
},
|
|
280
|
+
}, fe = ((e) => {
|
|
197
281
|
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t, r = String(e.version ?? "1"), i = {
|
|
198
282
|
version: r,
|
|
199
283
|
compatibleWith: (e.compatibleWith ?? [r]).map(String),
|
|
200
284
|
patches: [...e.patches ?? []]
|
|
201
285
|
}, a = {
|
|
202
286
|
signals: { ...e.messages?.signals ?? {} },
|
|
203
|
-
updates: { ...e.messages?.updates ?? {} }
|
|
204
|
-
queries: { ...e.messages?.queries ?? {} }
|
|
287
|
+
updates: { ...e.messages?.updates ?? {} }
|
|
205
288
|
};
|
|
206
|
-
Object.defineProperty(n,
|
|
289
|
+
Object.defineProperty(n, X, {
|
|
207
290
|
value: i,
|
|
208
291
|
enumerable: !1
|
|
209
|
-
}), Object.defineProperty(n,
|
|
292
|
+
}), Object.defineProperty(n, Z, {
|
|
210
293
|
value: a,
|
|
211
294
|
enumerable: !1
|
|
212
295
|
});
|
|
213
|
-
let o =
|
|
296
|
+
let o = T({
|
|
214
297
|
workflowName: e.name,
|
|
215
298
|
payloadSchema: e.payload,
|
|
216
299
|
control: e
|
|
217
300
|
});
|
|
218
|
-
|
|
301
|
+
o !== void 0 && Object.defineProperty(n, Q, {
|
|
219
302
|
value: o,
|
|
220
303
|
enumerable: !1
|
|
304
|
+
});
|
|
305
|
+
let s = I(e.name, e.schedule);
|
|
306
|
+
return s !== void 0 && Object.defineProperty(n, R, {
|
|
307
|
+
value: s,
|
|
308
|
+
enumerable: !1
|
|
221
309
|
}), n;
|
|
222
|
-
}),
|
|
310
|
+
}), pe = (e) => {
|
|
223
311
|
if (typeof e != "object" || !e) return;
|
|
224
|
-
let t = e[
|
|
312
|
+
let t = e[Q];
|
|
225
313
|
return t === void 0 ? void 0 : t;
|
|
226
|
-
},
|
|
314
|
+
}, me = i.make, he = i.process, ge = ((...e) => {
|
|
227
315
|
let t = i.worker(...e);
|
|
228
|
-
return Object.defineProperty(t,
|
|
316
|
+
return Object.defineProperty(t, Y, {
|
|
229
317
|
value: !0,
|
|
230
318
|
enumerable: !1
|
|
231
319
|
}), t;
|
|
232
|
-
}),
|
|
233
|
-
let t = yield*
|
|
320
|
+
}), _e = o.rateLimit, $ = (e) => m.gen(function* () {
|
|
321
|
+
let t = yield* O, r = yield* m.serviceOption(D), i = p.toMillis(p.decode(e.duration));
|
|
234
322
|
if (t !== void 0 && r._tag === "Some") {
|
|
235
|
-
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield*
|
|
236
|
-
yield*
|
|
323
|
+
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* A;
|
|
324
|
+
yield* m.promise(() => a.recordEvent({
|
|
237
325
|
runId: t,
|
|
238
326
|
eventType: "timer-set",
|
|
239
327
|
payload: {
|
|
@@ -244,7 +332,7 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
244
332
|
}
|
|
245
333
|
}).catch(() => {}));
|
|
246
334
|
let c = Date.now();
|
|
247
|
-
yield* n.sleep(e), yield*
|
|
335
|
+
yield* n.sleep(e), yield* m.promise(() => a.recordEvent({
|
|
248
336
|
runId: t,
|
|
249
337
|
eventType: "timer-fired",
|
|
250
338
|
payload: {
|
|
@@ -256,18 +344,18 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
256
344
|
return;
|
|
257
345
|
}
|
|
258
346
|
yield* n.sleep(e);
|
|
259
|
-
}),
|
|
347
|
+
}), ve = (t) => m.gen(function* () {
|
|
260
348
|
let n = (yield* e.make({
|
|
261
349
|
name: `sleepUntil:${t.name}`,
|
|
262
|
-
success:
|
|
263
|
-
execute:
|
|
350
|
+
success: ne.Number,
|
|
351
|
+
execute: m.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
|
|
264
352
|
})) - Date.now();
|
|
265
353
|
n <= 0 || (yield* $({
|
|
266
354
|
name: t.name,
|
|
267
355
|
duration: `${n} millis`
|
|
268
356
|
}));
|
|
269
|
-
}),
|
|
270
|
-
let a = yield*
|
|
357
|
+
}), ye = (t, n, r, i) => m.gen(function* () {
|
|
358
|
+
let a = yield* O, o = yield* e.CurrentAttempt, s = yield* m.serviceOption(D), c = yield* m.serviceOption(P), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
271
359
|
runId: a ?? "unrecorded",
|
|
272
360
|
stepName: t,
|
|
273
361
|
attempt: o
|
|
@@ -276,7 +364,7 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
276
364
|
f = s.value;
|
|
277
365
|
let e = i === void 0 ? void 0 : (({ retryable: e, ...t }) => t)(i);
|
|
278
366
|
try {
|
|
279
|
-
d = yield*
|
|
367
|
+
d = yield* m.promise(() => f.startStep({
|
|
280
368
|
runId: a,
|
|
281
369
|
stepName: t,
|
|
282
370
|
attempt: o,
|
|
@@ -287,16 +375,16 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
287
375
|
d = void 0;
|
|
288
376
|
}
|
|
289
377
|
}
|
|
290
|
-
let
|
|
291
|
-
return yield*
|
|
378
|
+
let p = Date.now();
|
|
379
|
+
return yield* le(l, i).pipe(m.tap((e) => d && f ? m.promise(async () => {
|
|
292
380
|
try {
|
|
293
381
|
await f.endStepSuccess({
|
|
294
382
|
stepRecordId: d,
|
|
295
383
|
output: e,
|
|
296
|
-
durationMs: Date.now() -
|
|
384
|
+
durationMs: Date.now() - p
|
|
297
385
|
});
|
|
298
386
|
} catch {}
|
|
299
|
-
}) :
|
|
387
|
+
}) : m.void), m.tapErrorCause((e) => d && f && !u.isInterruptedOnly(e) ? m.promise(async () => {
|
|
300
388
|
try {
|
|
301
389
|
let t = u.failureOption(e), n = Array.from(u.failures(e)), r = Array.from(u.defects(e)), i = t._tag === "Some" ? t.value : r[0] ?? u.squash(e), a = i?.message ?? String(i), o = i && typeof i == "object" && "_tag" in i ? String(i._tag) : null;
|
|
302
390
|
await f.endStepFailure({
|
|
@@ -308,16 +396,27 @@ var y = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
308
396
|
failures: n,
|
|
309
397
|
defects: r
|
|
310
398
|
},
|
|
311
|
-
durationMs: Date.now() -
|
|
399
|
+
durationMs: Date.now() - p
|
|
312
400
|
});
|
|
313
401
|
} catch {}
|
|
314
|
-
}) :
|
|
315
|
-
}),
|
|
402
|
+
}) : m.void));
|
|
403
|
+
}), be = (e) => m.gen(function* () {
|
|
404
|
+
let t = yield* g.get(V);
|
|
405
|
+
if (t === void 0) return;
|
|
406
|
+
let n = t.reach(e);
|
|
407
|
+
n !== void 0 && (yield* U([n]));
|
|
408
|
+
}), xe = (e, t) => {
|
|
409
|
+
let n = e;
|
|
410
|
+
return {
|
|
411
|
+
...e,
|
|
412
|
+
commit: () => m.zipRight(be(t), n)
|
|
413
|
+
};
|
|
414
|
+
}, Se = (t) => {
|
|
316
415
|
let { input: n, retry: r, ...i } = t;
|
|
317
|
-
return e.make({
|
|
416
|
+
return xe(e.make({
|
|
318
417
|
...i,
|
|
319
|
-
execute:
|
|
320
|
-
});
|
|
321
|
-
},
|
|
418
|
+
execute: ye(i.name, i.execute, n, r)
|
|
419
|
+
}), i.name);
|
|
420
|
+
}, Ce = (e) => m.map(g.get(j), (t) => t.includes(e)), we = c.withCompensation, Te = e.idempotencyKey;
|
|
322
421
|
//#endregion
|
|
323
|
-
export {
|
|
422
|
+
export { z as A, y as B, l as C, U as D, H as E, A as F, T as G, b as H, D as I, P as L, k as M, j as N, F as O, O as P, N as R, fe as S, B as T, v as U, E as V, re as W, ve as _, r as a, t as b, s as c, ue as d, Ce as f, $ as g, _e as h, Y as i, I as j, R as k, pe as l, ge as m, Z as n, me as o, he as p, X as r, a as s, Q as t, de as u, Se as v, V as w, we as x, Te as y, M as z };
|