@voltro/workflow 0.70.0 → 0.71.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 +1289 -111
- package/dist/cluster-BRSoL1tb.js +489 -0
- package/dist/cluster.d.ts +563 -6
- package/dist/cluster.js +2 -2
- package/dist/clusterDiagnostics-jpkNVay6.js +379 -0
- package/dist/clusterTestSuite.js +4 -4
- package/dist/index.d.ts +1036 -94
- package/dist/index.js +4 -4
- package/dist/{primitives-CqHxfASq.js → primitives-DsMsMr5S.js} +141 -122
- package/dist/primitives.js +2 -2
- package/dist/src-OEBqLBJl.js +4842 -0
- package/package.json +4 -4
- package/dist/cluster-CSycI4sz.js +0 -329
- package/dist/clusterDiagnostics-CNtl5LX9.js +0 -20
- package/dist/src-TRpoU54e.js +0 -2666
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i,
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as
|
|
4
|
-
export {
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, K as c, L as l, M 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, q as F, r as I, s as L, t as R, u as z, v as B, w as V, x as H, y as U, z as W } from "./primitives-DsMsMr5S.js";
|
|
2
|
+
import { $ as G, $t as K, A as q, At as J, B as Y, Bt as X, C as Z, Ct as Q, D as $, Dt as ee, E as te, Et as ne, F as re, Ft as ie, G as ae, Gt as oe, H as se, Ht as ce, I as le, It as ue, J as de, Jt as fe, K as pe, Kt as me, L as he, Lt as ge, M as _e, Mt as ve, N as ye, Nt as be, O as xe, Ot as Se, P as Ce, Pt as we, Q as Te, Qt as Ee, R as De, Rt as Oe, S as ke, St as Ae, T as je, Tt as Me, U as Ne, Ut as Pe, V as Fe, Vt as Ie, W as Le, Wt as Re, X as ze, Xt as Be, Y as Ve, Yt as He, Z as Ue, Zt as We, _ as Ge, _n as Ke, _t as qe, a as Je, an as Ye, at as Xe, b as Ze, bn as Qe, bt as $e, c as et, cn as tt, ct as nt, d as rt, dn as it, dt as at, en as ot, et as st, f as ct, fn as lt, ft as ut, g as dt, gn as ft, gt as pt, h as mt, hn as ht, ht as gt, i as _t, in as vt, it as yt, j as bt, jt as xt, k as St, kt as Ct, l as wt, ln as Tt, lt as Et, m as Dt, mn as Ot, mt as kt, n as At, nn as jt, nt as Mt, o as Nt, on as Pt, ot as Ft, p as It, pn as Lt, pt as Rt, q as zt, qt as Bt, r as Vt, rn as Ht, rt as Ut, s as Wt, sn as Gt, st as Kt, t as qt, tn as Jt, tt as Yt, u as Xt, un as Zt, ut as Qt, v as $t, vn as en, vt as tn, w as nn, wt as rn, x as an, xt as on, y as sn, yn as cn, yt as ln, z as un, zt as dn } from "./src-OEBqLBJl.js";
|
|
3
|
+
import { c as fn, l as pn, n as mn, p as hn, r as gn, s as _n, t as vn } from "./clusterDiagnostics-jpkNVay6.js";
|
|
4
|
+
export { ut as ADMISSIONS_TABLE, ct as BUDGET_HOLDS_TABLE, It as BudgetHoldExpired, Le as CANCEL_ON_WATERMARK, vn as CLUSTER_REREAD_WINDOW_MS, mn as ClusterDiagnostics, u as CurrentWorkflowExecutionId, f as CurrentWorkflowPatches, V as CurrentWorkflowReplayShape, a as CurrentWorkflowRunId, Dt as DEFAULT_BUDGET_HOLD_TIMEOUT_MS, ae as DEFAULT_COLD_LOOKBACK_MS, he as DEFAULT_DRAIN_BATCH, pe as DEFAULT_EVENT_BATCH, Rt as DEFAULT_LEASE_MS, qt as DEFAULT_MAX_RUN_RECLAIMS, At as DEFAULT_REPLAY_SHAPE_LIMIT, Y as DEFAULT_STALL_AFTER_MS, Fe as DEFAULT_STALL_EVENT_LOOKBACK, se as DEFAULT_STALL_RUN_PAGE, _e as DEFAULT_SUSPEND_HINT_MS, d as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, _ as DEFERRING_CONTROLS, zt as EVENTS_TABLE, Ee as FlowControlKeyError, kt as PAUSES_TABLE, gt as PENDING_TABLE, de as WATERMARKS_TABLE, R as WorkflowFlowControlProperty, M as WorkflowMessagesProperty, l as WorkflowRunRecorder, k as WorkflowScheduleProperty, p as WorkflowStepInterceptorTag, I as WorkflowVersionTypeId, D as WorkflowWorkerLayerTypeId, mt as _voltroBudgetHoldsTable, Gt as _voltroWorkflowAdmissionLocksTable, tt as _voltroWorkflowAdmissionsTable, Tt as _voltroWorkflowControlRequestsTable, Zt as _voltroWorkflowFailureReportsTable, it as _voltroWorkflowParentClosuresTable, lt as _voltroWorkflowPausesTable, Lt as _voltroWorkflowPendingTable, Ke as _voltroWorkflowRunEventsTable, en as _voltroWorkflowRunStepsTable, cn as _voltroWorkflowRunsTable, ft as _voltroWorkflowStartContextsTable, Ot as _voltroWorkflowStartReceiptsTable, ht as _voltroWorkflowSubmissionsTable, st as _voltroWorkflowWatermarksTable, De as acceptAdmissionSubmission, _n as acceptWorkflowControlInTransaction, X as acknowledgeAdmissionSubmission, Yt as admitStart, pt as allIntents, s as assertConsistentPools, q as awaitEvent, bt as awaitSignal, Z as awaitSignalSuspending, rt as awaitUpdate, Ie as beginAdmissionSubmissionDispatchInTransaction, fn as beginWorkflowControlDispatchInTransaction, pn as bindWorkflowResumeJournalInTransaction, ue as bindWorkflowStartReceipts, dt as budgetHoldGeneration, Ge as budgetHoldKey, $t as budgetHoldSignalName, Xe as cancelQueuedWorkflowStartInTransaction, nt as cancelSuspendedWorkflowRunInTransaction, K as comparePendingOrder, nn as completeSuspendingSignal, Et as completeWorkflowRunGenerationInTransaction, qe as deadLetterIntent, ot as decideAdmission, g as deferringControlsOf, tn as deleteIntent, gn as describeStalledRun, ln as discardIntent, $e as discardIntentInTransaction, un as drainTick, on as dueIntents, b as durableClock, N as durableQueue, L as durableQueueModule, S as durableRateLimiterModule, Qt as enterWorkflowRunGenerationInTransaction, Ae as evaluateAdmission, F as executePreparedWorkflow, W as getCurrentWorkflowExecutionId, t as getCurrentWorkflowRunId, A as getWorkflowFlowControl, e as getWorkflowSchedule, z as getWorkflowVersionMetadata, fe as handoffWorkflowFailureInTransaction, v as hasCancelOn, o as hasFlowControl, sn as heldBudgets, Qe as inMemoryWorkflowEngineLayer, Xt as inspectWorkflow, Jt as isFinishExpired, jt as isStartExpired, C as isWorkflowWorkerLayer, Mt as linkExecution, wt as makeInMemoryRecorder, h as makeReplayShapeTracker, Vt as makeWorkflowRunRecorder, te as makeWorkflowUpdateId, ye as maybeHintSuspendingSignal, Te as newestEventAt, Ht as nextSlotAt, i as nondeterminismEventPayload, _t as normaliseWorkflowPatches, ce as noteAdmissionSubmissionFailure, Q as noteIntentAttempt, rn as parkDelayedStart, w as patch, Me as pauseWorkflow, Pe as pendingAdmissionSubmissions, Ze as pendingBudgetHolds, ne as pendingSlotId, ee as pendingWindow, Se as persistDefer, G as planCancellations, vt as pooledConcurrencyKey, Re as prepareAdmissionSubmissionExecutionInTransaction, P as processQueue, Ct as pruneAdmissions, j as queueWorker, Kt as queuedCancellationRequestsTable, E as rateLimit, J as readAdmissionState, oe as readAdmissionSubmission, xt as readPausedWorkflows, Ft as readQueuedWorkflowCancellationInTransaction, Ve as readWatermark, hn as readWorkflowControlInTransaction, Be as readWorkflowFailureRecord, ge as readWorkflowStartReceipt, He as reconcileWorkflowFailureInTransaction, ve as recordAdmission, We as recordWorkflowFailureInTransaction, Oe as recordWorkflowStartReceipt, me as rejectAdmissionSubmissionInTransaction, an as releaseBudgetHolds, be as releaseLease, r as reportNondeterminism, Bt as reserveAdmissionSubmission, Ce as resetSuspendHintsForTest, Ye as resolveAdmissionKeys, Je as resolveRunGuardTuning, re as resolveSuspendHintMs, $ as resolveWorkflowMessageRun, dn as resolveWorkflowStartReceipt, we as resumeWorkflow, ie as retryDeadLetterIntent, xe as sendWorkflowSignal, St as sendWorkflowUpdate, Nt as serialiseWorkflowRowForWire, le as setSuspendSignalHintMs, T as sleep, y as sleepUntil, at as stageWorkflowParentClosureInTransaction, B as step, U as stepIdempotencyKey, x as stepModule, ke as suspendForBudget, je as suspendingSignalDeferredName, ze as sweepCancelOn, Ne as sweepStalledRuns, Ut as takeAdmittedSubmissionInTransaction, yt as takePendingAdmissionSubmission, Wt as truncateWorkflowValue, c as validateFlowControl, O as validateWorkflowSchedule, Pt as withAdmissionTransaction, H as withCompensation, m as workflow, n as workflowModule, et as wrapWorkflowExecuteWithRunRecording, Ue as writeWatermark };
|
|
@@ -1,45 +1,54 @@
|
|
|
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
|
|
3
|
-
import { attachWorkflowAccess as
|
|
4
|
-
//#region src/
|
|
5
|
-
var
|
|
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, WorkflowEngine as u } from "@effect/workflow";
|
|
2
|
+
import { Cause as d, Context as f, Cron as p, Duration as m, Effect as h, Either as g, Exit as _, FiberRef as v, Option as ee, Schedule as y, Schema as b } from "effect";
|
|
3
|
+
import { attachWorkflowAccess as x, resolveWorkflowAccess as S } from "@voltro/protocol";
|
|
4
|
+
//#region src/preparedExecution.ts
|
|
5
|
+
var C = Symbol.for("@voltro/workflow/PreparedExecution"), te = (e, t) => {
|
|
6
|
+
Object.defineProperty(e, C, {
|
|
7
|
+
value: t,
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
}, ne = (e, t, n, r) => h.suspend(() => {
|
|
11
|
+
if (n.length === 0) return h.die(/* @__PURE__ */ Error("Prepared workflow execution requires a non-empty identity"));
|
|
12
|
+
let i = e[C];
|
|
13
|
+
return typeof i == "function" ? i(t, n, r?.discard ?? !0) : h.die(/* @__PURE__ */ Error("Workflow definition has no prepared-execution capability"));
|
|
14
|
+
}), 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), ie = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, ae = [
|
|
6
15
|
"debounce",
|
|
7
16
|
"batch",
|
|
8
17
|
"throttle",
|
|
9
18
|
"concurrency"
|
|
10
|
-
],
|
|
19
|
+
], w = (e) => {
|
|
11
20
|
if (e === void 0) return [];
|
|
12
21
|
let t = [];
|
|
13
22
|
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;
|
|
14
|
-
},
|
|
23
|
+
}, T = (e, t, n) => {
|
|
15
24
|
let r;
|
|
16
25
|
try {
|
|
17
|
-
r =
|
|
26
|
+
r = m.toMillis(m.decode(e));
|
|
18
27
|
} catch {
|
|
19
28
|
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.`);
|
|
20
29
|
}
|
|
21
30
|
if (!Number.isFinite(r) || r <= 0) throw Error(`workflow '${n}': ${t} must be a positive finite duration, got ${String(e)}`);
|
|
22
31
|
return r;
|
|
23
|
-
},
|
|
32
|
+
}, E = (e, t, n) => {
|
|
24
33
|
if (!Number.isInteger(e) || e <= 0) throw Error(`workflow '${n}': ${t} must be a positive integer, got ${String(e)}`);
|
|
25
34
|
return e;
|
|
26
|
-
},
|
|
35
|
+
}, D = (e, t, n) => {
|
|
27
36
|
if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
|
|
28
37
|
return e;
|
|
29
|
-
},
|
|
38
|
+
}, O = (e) => {
|
|
30
39
|
let t = e?.ast?.propertySignatures;
|
|
31
40
|
if (!Array.isArray(t)) return !1;
|
|
32
41
|
let n = t.find((e) => e.name === "items");
|
|
33
42
|
return n !== void 0 && n.type?._tag === "TupleType";
|
|
34
|
-
},
|
|
43
|
+
}, k = (e) => {
|
|
35
44
|
let { workflowName: t, control: n } = e;
|
|
36
45
|
if (n === void 0) return;
|
|
37
46
|
let r = { workflowName: t };
|
|
38
47
|
if (n.debounce !== void 0) {
|
|
39
|
-
let e = n.debounce, i =
|
|
48
|
+
let e = n.debounce, i = T(e.period, "debounce.period", t), a = e.timeout === void 0 ? void 0 : T(e.timeout, "debounce.timeout", t);
|
|
40
49
|
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.`);
|
|
41
50
|
r.debounce = {
|
|
42
|
-
key:
|
|
51
|
+
key: D(e.key, "debounce.key", t),
|
|
43
52
|
periodMs: i,
|
|
44
53
|
...a === void 0 ? {} : { timeoutMs: a }
|
|
45
54
|
};
|
|
@@ -48,7 +57,7 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
48
57
|
let e = n.singleton;
|
|
49
58
|
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.`);
|
|
50
59
|
r.singleton = {
|
|
51
|
-
key:
|
|
60
|
+
key: D(e.key, "singleton.key", t),
|
|
52
61
|
mode: e.mode
|
|
53
62
|
};
|
|
54
63
|
}
|
|
@@ -56,34 +65,34 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
56
65
|
let e = n.concurrency;
|
|
57
66
|
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.`);
|
|
58
67
|
r.concurrency = {
|
|
59
|
-
limit:
|
|
60
|
-
...e.key === void 0 ? {} : { key:
|
|
68
|
+
limit: E(e.limit, "concurrency.limit", t),
|
|
69
|
+
...e.key === void 0 ? {} : { key: D(e.key, "concurrency.key", t) },
|
|
61
70
|
...e.pool === void 0 ? {} : { pool: e.pool.trim() }
|
|
62
71
|
};
|
|
63
72
|
}
|
|
64
73
|
if (n.throttle !== void 0) {
|
|
65
74
|
let e = n.throttle;
|
|
66
75
|
r.throttle = {
|
|
67
|
-
limit:
|
|
68
|
-
periodMs:
|
|
69
|
-
...e.key === void 0 ? {} : { key:
|
|
76
|
+
limit: E(e.limit, "throttle.limit", t),
|
|
77
|
+
periodMs: T(e.period, "throttle.period", t),
|
|
78
|
+
...e.key === void 0 ? {} : { key: D(e.key, "throttle.key", t) }
|
|
70
79
|
};
|
|
71
80
|
}
|
|
72
81
|
if (n.rateLimit !== void 0) {
|
|
73
82
|
let e = n.rateLimit;
|
|
74
83
|
r.rateLimit = {
|
|
75
|
-
limit:
|
|
76
|
-
periodMs:
|
|
77
|
-
...e.key === void 0 ? {} : { key:
|
|
84
|
+
limit: E(e.limit, "rateLimit.limit", t),
|
|
85
|
+
periodMs: T(e.period, "rateLimit.period", t),
|
|
86
|
+
...e.key === void 0 ? {} : { key: D(e.key, "rateLimit.key", t) }
|
|
78
87
|
};
|
|
79
88
|
}
|
|
80
89
|
if (n.batch !== void 0) {
|
|
81
90
|
let i = n.batch;
|
|
82
|
-
if (e.payloadSchema !== void 0 && !
|
|
91
|
+
if (e.payloadSchema !== void 0 && !O(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.`);
|
|
83
92
|
r.batch = {
|
|
84
|
-
...i.key === void 0 ? {} : { key:
|
|
85
|
-
maxSize:
|
|
86
|
-
timeoutMs:
|
|
93
|
+
...i.key === void 0 ? {} : { key: D(i.key, "batch.key", t) },
|
|
94
|
+
maxSize: E(i.maxSize, "batch.maxSize", t),
|
|
95
|
+
timeoutMs: T(i.timeout, "batch.timeout", t),
|
|
87
96
|
...i.item === void 0 ? {} : { item: i.item }
|
|
88
97
|
};
|
|
89
98
|
}
|
|
@@ -92,7 +101,7 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
92
101
|
r.priority = n.priority;
|
|
93
102
|
}
|
|
94
103
|
if (n.timeouts !== void 0) {
|
|
95
|
-
let e = n.timeouts, i = e.start === void 0 ? void 0 :
|
|
104
|
+
let e = n.timeouts, i = e.start === void 0 ? void 0 : T(e.start, "timeouts.start", t), a = e.finish === void 0 ? void 0 : T(e.finish, "timeouts.finish", t);
|
|
96
105
|
(i !== void 0 || a !== void 0) && (r.timeouts = {
|
|
97
106
|
...i === void 0 ? {} : { startMs: i },
|
|
98
107
|
...a === void 0 ? {} : { finishMs: a }
|
|
@@ -112,7 +121,7 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
112
121
|
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.`);
|
|
113
122
|
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.`);
|
|
114
123
|
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.`);
|
|
115
|
-
let i = e.within === void 0 ? void 0 :
|
|
124
|
+
let i = e.within === void 0 ? void 0 : T(e.within, `${r}.within`, t);
|
|
116
125
|
return {
|
|
117
126
|
event: e.event,
|
|
118
127
|
schema: e.schema,
|
|
@@ -123,9 +132,9 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
123
132
|
});
|
|
124
133
|
e.length > 0 && (r.cancelOn = e);
|
|
125
134
|
}
|
|
126
|
-
if (r.timeouts?.startMs !== void 0 &&
|
|
135
|
+
if (r.timeouts?.startMs !== void 0 && w(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.`);
|
|
127
136
|
return r;
|
|
128
|
-
},
|
|
137
|
+
}, oe = (e) => {
|
|
129
138
|
let t = /* @__PURE__ */ new Map();
|
|
130
139
|
for (let n of e) {
|
|
131
140
|
let e = n?.concurrency;
|
|
@@ -138,25 +147,25 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
138
147
|
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.`);
|
|
139
148
|
else r.workflows.push(n.workflowName);
|
|
140
149
|
}
|
|
141
|
-
},
|
|
150
|
+
}, A = class extends f.Tag("@voltro/WorkflowRunRecorder")() {}, j = v.unsafeMake(void 0), M = v.unsafeMake(void 0), se = v.unsafeMake(void 0), N = v.unsafeMake(void 0), P = v.unsafeMake([]), ce = () => v.get(j), le = () => v.get(M), F = class extends f.Tag("@voltro/WorkflowStepInterceptor")() {}, I = 864e5, L = /* @__PURE__ */ new Set([
|
|
142
151
|
"skip",
|
|
143
152
|
"buffer",
|
|
144
153
|
"cancelOther"
|
|
145
|
-
]),
|
|
154
|
+
]), R = /* @__PURE__ */ new Set([
|
|
146
155
|
"skip",
|
|
147
156
|
"latest",
|
|
148
157
|
"all"
|
|
149
|
-
]),
|
|
158
|
+
]), z = (e, t) => {
|
|
150
159
|
if (t === void 0) return;
|
|
151
160
|
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.`);
|
|
152
|
-
let n =
|
|
153
|
-
if (
|
|
161
|
+
let n = p.parse(t.cron, t.timezone);
|
|
162
|
+
if (g.isLeft(n)) throw Error(`workflow '${e}': schedule.cron "${t.cron}" (tz="${t.timezone}") is not a valid cron expression — ${String(n.left)}`);
|
|
154
163
|
let r = t.onOverlap ?? "skip";
|
|
155
|
-
if (!
|
|
164
|
+
if (!L.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
|
|
156
165
|
let i = t.backfill ?? "skip";
|
|
157
|
-
if (!
|
|
166
|
+
if (!R.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
|
|
158
167
|
let a = I;
|
|
159
|
-
return t.maxRuntime !== void 0 && (a =
|
|
168
|
+
return t.maxRuntime !== void 0 && (a = B(t.maxRuntime, e)), {
|
|
160
169
|
cron: t.cron,
|
|
161
170
|
timezone: t.timezone,
|
|
162
171
|
...t.payload === void 0 ? {} : { payload: t.payload },
|
|
@@ -164,20 +173,20 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
164
173
|
backfill: i,
|
|
165
174
|
maxRuntimeMs: a
|
|
166
175
|
};
|
|
167
|
-
},
|
|
176
|
+
}, B = (e, t) => {
|
|
168
177
|
let n;
|
|
169
178
|
try {
|
|
170
|
-
n =
|
|
179
|
+
n = m.toMillis(m.decode(e));
|
|
171
180
|
} catch {
|
|
172
181
|
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.`);
|
|
173
182
|
}
|
|
174
183
|
if (!Number.isFinite(n) || n <= 0) throw Error(`workflow '${t}': schedule.maxRuntime must be a positive finite duration`);
|
|
175
184
|
return n;
|
|
176
|
-
},
|
|
185
|
+
}, V = "__voltroWorkflowSchedule", H = (e) => {
|
|
177
186
|
if (typeof e != "object" || !e) return;
|
|
178
|
-
let t = e[
|
|
187
|
+
let t = e[V];
|
|
179
188
|
return t === void 0 ? void 0 : t;
|
|
180
|
-
},
|
|
189
|
+
}, U = (e) => {
|
|
181
190
|
let t = /* @__PURE__ */ new Map();
|
|
182
191
|
for (let n of e) t.set(n.stepName, (t.get(n.stepName) ?? 0) + 1);
|
|
183
192
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => !r.has(e) && (r.add(e), !0);
|
|
@@ -206,80 +215,90 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
206
215
|
return e;
|
|
207
216
|
}
|
|
208
217
|
};
|
|
209
|
-
},
|
|
218
|
+
}, W = v.unsafeMake(void 0), G = (e) => ({
|
|
210
219
|
kind: e.kind,
|
|
211
220
|
stepName: e.stepName,
|
|
212
221
|
recorded: e.recorded,
|
|
213
222
|
reached: e.reached,
|
|
214
223
|
detail: e.detail
|
|
215
|
-
}),
|
|
224
|
+
}), K = (e) => h.gen(function* () {
|
|
216
225
|
if (e.length === 0) return;
|
|
217
|
-
let t = yield*
|
|
226
|
+
let t = yield* v.get(j), n = yield* h.serviceOption(A);
|
|
218
227
|
if (t === void 0 || n._tag !== "Some") return;
|
|
219
228
|
let r = n.value;
|
|
220
|
-
for (let n of e) yield*
|
|
229
|
+
for (let n of e) yield* h.promise(() => r.recordEvent({
|
|
221
230
|
runId: t,
|
|
222
231
|
eventType: "nondeterminism-suspected",
|
|
223
|
-
payload:
|
|
232
|
+
payload: G(n)
|
|
224
233
|
}).then(() => void 0).catch(() => void 0));
|
|
225
|
-
}),
|
|
234
|
+
}), ue = (e) => {
|
|
226
235
|
if (typeof e != "object" || !e) return;
|
|
227
236
|
let t = e.retryAfterMillis;
|
|
228
|
-
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return
|
|
237
|
+
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return m.millis(t);
|
|
229
238
|
let n = e.retryAfter;
|
|
230
|
-
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return
|
|
231
|
-
}, q = (e) =>
|
|
239
|
+
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return m.seconds(n);
|
|
240
|
+
}, q = (e) => m.decode(e), de = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, fe = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, pe = (e) => {
|
|
232
241
|
if (e.retryable) return e.retryable;
|
|
233
242
|
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
234
243
|
let t = new Set(e.retryableErrors);
|
|
235
244
|
return (e) => {
|
|
236
|
-
let n =
|
|
245
|
+
let n = de(e);
|
|
237
246
|
return n !== void 0 && t.has(n);
|
|
238
247
|
};
|
|
239
248
|
}
|
|
240
249
|
return () => !0;
|
|
241
|
-
},
|
|
242
|
-
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ?
|
|
250
|
+
}, me = (e) => {
|
|
251
|
+
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? y.linear(q(e.step ?? t)) : n === "fixed" ? y.spaced(q(t)) : y.exponential(q(t), e.factor ?? 2);
|
|
243
252
|
if (e.maxDelay !== void 0) {
|
|
244
253
|
let t = q(e.maxDelay);
|
|
245
|
-
i =
|
|
254
|
+
i = y.modifyDelay(i, (e, n) => m.min(n, t));
|
|
246
255
|
}
|
|
247
|
-
(e.jitter ?? !0) === !0 && (i =
|
|
248
|
-
let a =
|
|
249
|
-
return e.maxElapsed !== void 0 && (a =
|
|
250
|
-
},
|
|
251
|
-
let n =
|
|
252
|
-
return e.maxDelay !== void 0 && (i = Math.min(i,
|
|
253
|
-
},
|
|
254
|
-
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity :
|
|
256
|
+
(e.jitter ?? !0) === !0 && (i = y.jittered(i));
|
|
257
|
+
let a = y.intersect(i, y.recurs(Math.max(0, r - 1)));
|
|
258
|
+
return e.maxElapsed !== void 0 && (a = y.upTo(q(e.maxElapsed))(a)), a;
|
|
259
|
+
}, he = (e, t) => {
|
|
260
|
+
let n = m.toMillis(q(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + m.toMillis(q(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
261
|
+
return e.maxDelay !== void 0 && (i = Math.min(i, m.toMillis(q(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
262
|
+
}, ge = (e, t, n, r) => h.gen(function* () {
|
|
263
|
+
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : m.toMillis(q(t.maxElapsed)), o = yield* h.sync(() => Date.now()), s = 0;
|
|
255
264
|
for (;;) {
|
|
256
|
-
let c = yield*
|
|
257
|
-
if (
|
|
258
|
-
let l = c.cause,
|
|
265
|
+
let c = yield* h.exit(e);
|
|
266
|
+
if (_.isSuccess(c)) return c.value;
|
|
267
|
+
let l = c.cause, u = d.failureOption(l), f = ee.isSome(u) ? u.value : d.squash(l);
|
|
259
268
|
s += 1;
|
|
260
|
-
let
|
|
261
|
-
if (s >= i || !n(f) ||
|
|
269
|
+
let p = (yield* h.sync(() => Date.now())) - o;
|
|
270
|
+
if (s >= i || !n(f) || p >= a) return yield* h.failCause(l);
|
|
262
271
|
r?.(f);
|
|
263
|
-
let g =
|
|
264
|
-
yield*
|
|
272
|
+
let g = ue(f), v = g === void 0 ? he(t, s) : m.toMillis(g);
|
|
273
|
+
yield* h.sleep(m.millis(v));
|
|
265
274
|
}
|
|
266
|
-
}),
|
|
267
|
-
if (!
|
|
268
|
-
let r =
|
|
269
|
-
if (t.respectRetryAfter === !0) return
|
|
270
|
-
let i =
|
|
275
|
+
}), _e = (e, t, n) => {
|
|
276
|
+
if (!fe(t)) return e;
|
|
277
|
+
let r = pe(t);
|
|
278
|
+
if (t.respectRetryAfter === !0) return ge(e, t, r, n);
|
|
279
|
+
let i = me(t), a = n ? h.tapError(e, (e) => h.sync(() => {
|
|
271
280
|
r(e) && n(e);
|
|
272
281
|
})) : e;
|
|
273
|
-
return
|
|
282
|
+
return h.retry(a, {
|
|
274
283
|
schedule: i,
|
|
275
284
|
while: r
|
|
276
285
|
});
|
|
277
|
-
},
|
|
286
|
+
}, J = Symbol.for("voltro.workflow.workerLayer"), Y = Symbol.for("voltro.workflow.version"), X = "__voltroWorkflowMessages", Z = "__voltroWorkflowFlowControl", ve = (e) => typeof e == "object" && !!e && e[J] === !0, ye = (e) => typeof e == "object" && e && e[Y] !== void 0 ? e[Y] : {
|
|
278
287
|
version: "1",
|
|
279
288
|
compatibleWith: ["1"],
|
|
280
289
|
patches: []
|
|
281
|
-
},
|
|
282
|
-
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t
|
|
290
|
+
}, be = ((e) => {
|
|
291
|
+
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t;
|
|
292
|
+
te(n, (t, r, i) => h.gen(function* () {
|
|
293
|
+
let a = n.payloadSchema.make(t), o = yield* u.WorkflowEngine;
|
|
294
|
+
return yield* h.annotateCurrentSpan({ executionId: r }), yield* o.execute(n, {
|
|
295
|
+
executionId: r,
|
|
296
|
+
payload: a,
|
|
297
|
+
discard: i,
|
|
298
|
+
suspendedRetrySchedule: e.suspendedRetrySchedule
|
|
299
|
+
});
|
|
300
|
+
}).pipe(h.withSpan(`${e.name}.execute`, { captureStackTrace: !1 })));
|
|
301
|
+
let r = String(e.version ?? "1"), i = {
|
|
283
302
|
version: r,
|
|
284
303
|
compatibleWith: (e.compatibleWith ?? [r]).map(String),
|
|
285
304
|
patches: [...e.patches ?? []]
|
|
@@ -287,42 +306,42 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
287
306
|
signals: { ...e.messages?.signals ?? {} },
|
|
288
307
|
updates: { ...e.messages?.updates ?? {} }
|
|
289
308
|
};
|
|
290
|
-
Object.defineProperty(n,
|
|
309
|
+
Object.defineProperty(n, Y, {
|
|
291
310
|
value: i,
|
|
292
311
|
enumerable: !1
|
|
293
|
-
}), Object.defineProperty(n,
|
|
312
|
+
}), Object.defineProperty(n, X, {
|
|
294
313
|
value: a,
|
|
295
314
|
enumerable: !1
|
|
296
|
-
}),
|
|
297
|
-
let o =
|
|
315
|
+
}), x(n, S(e.name, e));
|
|
316
|
+
let o = k({
|
|
298
317
|
workflowName: e.name,
|
|
299
318
|
payloadSchema: e.payload,
|
|
300
319
|
control: e
|
|
301
320
|
});
|
|
302
|
-
o !== void 0 && Object.defineProperty(n,
|
|
321
|
+
o !== void 0 && Object.defineProperty(n, Z, {
|
|
303
322
|
value: o,
|
|
304
323
|
enumerable: !1
|
|
305
324
|
});
|
|
306
|
-
let s =
|
|
307
|
-
return s !== void 0 && Object.defineProperty(n,
|
|
325
|
+
let s = z(e.name, e.schedule);
|
|
326
|
+
return s !== void 0 && Object.defineProperty(n, V, {
|
|
308
327
|
value: s,
|
|
309
328
|
enumerable: !1
|
|
310
329
|
}), n;
|
|
311
|
-
}),
|
|
330
|
+
}), xe = (e) => {
|
|
312
331
|
if (typeof e != "object" || !e) return;
|
|
313
|
-
let t = e[
|
|
332
|
+
let t = e[Z];
|
|
314
333
|
return t === void 0 ? void 0 : t;
|
|
315
|
-
},
|
|
334
|
+
}, Q = i.make, Se = i.process, Ce = ((...e) => {
|
|
316
335
|
let t = i.worker(...e);
|
|
317
|
-
return Object.defineProperty(t,
|
|
336
|
+
return Object.defineProperty(t, J, {
|
|
318
337
|
value: !0,
|
|
319
338
|
enumerable: !1
|
|
320
339
|
}), t;
|
|
321
|
-
}),
|
|
322
|
-
let t = yield*
|
|
340
|
+
}), we = o.rateLimit, $ = (e) => h.gen(function* () {
|
|
341
|
+
let t = yield* j, r = yield* h.serviceOption(A), i = m.toMillis(m.decode(e.duration));
|
|
323
342
|
if (t !== void 0 && r._tag === "Some") {
|
|
324
|
-
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield*
|
|
325
|
-
yield*
|
|
343
|
+
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* N;
|
|
344
|
+
yield* h.promise(() => a.recordEvent({
|
|
326
345
|
runId: t,
|
|
327
346
|
eventType: "timer-set",
|
|
328
347
|
payload: {
|
|
@@ -333,7 +352,7 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
333
352
|
}
|
|
334
353
|
}).catch(() => {}));
|
|
335
354
|
let c = Date.now();
|
|
336
|
-
yield* n.sleep(e), yield*
|
|
355
|
+
yield* n.sleep(e), yield* h.promise(() => a.recordEvent({
|
|
337
356
|
runId: t,
|
|
338
357
|
eventType: "timer-fired",
|
|
339
358
|
payload: {
|
|
@@ -345,27 +364,27 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
345
364
|
return;
|
|
346
365
|
}
|
|
347
366
|
yield* n.sleep(e);
|
|
348
|
-
}),
|
|
367
|
+
}), Te = (t) => h.gen(function* () {
|
|
349
368
|
let n = (yield* e.make({
|
|
350
369
|
name: `sleepUntil:${t.name}`,
|
|
351
|
-
success:
|
|
352
|
-
execute:
|
|
370
|
+
success: b.Number,
|
|
371
|
+
execute: h.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
|
|
353
372
|
})) - Date.now();
|
|
354
373
|
n <= 0 || (yield* $({
|
|
355
374
|
name: t.name,
|
|
356
375
|
duration: `${n} millis`
|
|
357
376
|
}));
|
|
358
|
-
}),
|
|
359
|
-
let a = yield*
|
|
377
|
+
}), Ee = (t, n, r, i) => h.gen(function* () {
|
|
378
|
+
let a = yield* j, o = yield* e.CurrentAttempt, s = yield* h.serviceOption(A), c = yield* h.serviceOption(F), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
360
379
|
runId: a ?? "unrecorded",
|
|
361
380
|
stepName: t,
|
|
362
381
|
attempt: o
|
|
363
|
-
}) : n,
|
|
382
|
+
}) : n, u, f;
|
|
364
383
|
if (a !== void 0 && s._tag === "Some") {
|
|
365
384
|
f = s.value;
|
|
366
385
|
let e = i === void 0 ? void 0 : (({ retryable: e, ...t }) => t)(i);
|
|
367
386
|
try {
|
|
368
|
-
|
|
387
|
+
u = yield* h.promise(() => f.startStep({
|
|
369
388
|
runId: a,
|
|
370
389
|
stepName: t,
|
|
371
390
|
attempt: o,
|
|
@@ -373,51 +392,51 @@ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
373
392
|
...e === void 0 ? {} : { retryPolicy: e }
|
|
374
393
|
}));
|
|
375
394
|
} catch {
|
|
376
|
-
|
|
395
|
+
u = void 0;
|
|
377
396
|
}
|
|
378
397
|
}
|
|
379
398
|
let p = Date.now();
|
|
380
|
-
return yield*
|
|
399
|
+
return yield* _e(l, i).pipe(h.tap((e) => u && f ? h.promise(async () => {
|
|
381
400
|
try {
|
|
382
401
|
await f.endStepSuccess({
|
|
383
|
-
stepRecordId:
|
|
402
|
+
stepRecordId: u,
|
|
384
403
|
output: e,
|
|
385
404
|
durationMs: Date.now() - p
|
|
386
405
|
});
|
|
387
406
|
} catch {}
|
|
388
|
-
}) :
|
|
407
|
+
}) : h.void), h.tapErrorCause((e) => u && f && !d.isInterruptedOnly(e) ? h.promise(async () => {
|
|
389
408
|
try {
|
|
390
|
-
let t =
|
|
409
|
+
let t = d.failureOption(e), n = Array.from(d.failures(e)), r = Array.from(d.defects(e)), i = t._tag === "Some" ? t.value : r[0] ?? d.squash(e), a = i?.message ?? String(i), o = i && typeof i == "object" && "_tag" in i ? String(i._tag) : null;
|
|
391
410
|
await f.endStepFailure({
|
|
392
|
-
stepRecordId:
|
|
411
|
+
stepRecordId: u,
|
|
393
412
|
errorTag: o,
|
|
394
413
|
errorMessage: a,
|
|
395
414
|
errorCause: {
|
|
396
|
-
pretty:
|
|
415
|
+
pretty: d.pretty(e),
|
|
397
416
|
failures: n,
|
|
398
417
|
defects: r
|
|
399
418
|
},
|
|
400
419
|
durationMs: Date.now() - p
|
|
401
420
|
});
|
|
402
421
|
} catch {}
|
|
403
|
-
}) :
|
|
404
|
-
}),
|
|
405
|
-
let t = yield*
|
|
422
|
+
}) : h.void));
|
|
423
|
+
}), De = (e) => h.gen(function* () {
|
|
424
|
+
let t = yield* v.get(W);
|
|
406
425
|
if (t === void 0) return;
|
|
407
426
|
let n = t.reach(e);
|
|
408
|
-
n !== void 0 && (yield*
|
|
409
|
-
}),
|
|
427
|
+
n !== void 0 && (yield* K([n]));
|
|
428
|
+
}), Oe = (e, t) => {
|
|
410
429
|
let n = e;
|
|
411
430
|
return {
|
|
412
431
|
...e,
|
|
413
|
-
commit: () =>
|
|
432
|
+
commit: () => h.zipRight(De(t), n)
|
|
414
433
|
};
|
|
415
|
-
},
|
|
434
|
+
}, ke = (t) => {
|
|
416
435
|
let { input: n, retry: r, ...i } = t;
|
|
417
|
-
return
|
|
436
|
+
return Oe(e.make({
|
|
418
437
|
...i,
|
|
419
|
-
execute:
|
|
438
|
+
execute: Ee(i.name, i.execute, n, r)
|
|
420
439
|
}), i.name);
|
|
421
|
-
},
|
|
440
|
+
}, Ae = (e) => h.map(v.get(P), (t) => t.includes(e)), je = c.withCompensation, Me = e.idempotencyKey;
|
|
422
441
|
//#endregion
|
|
423
|
-
export {
|
|
442
|
+
export { H as A, ce as B, l as C, K as D, G as E, j as F, re as G, oe as H, N as I, k as K, A as L, M, se as N, I as O, P, F as R, be as S, U as T, w as U, ae as V, ie as W, Te as _, r as a, t as b, s as c, ve as d, Ae as f, $ as g, we as h, J as i, z as j, V as k, xe as l, Ce as m, X as n, Q as o, Se as p, ne as q, Y as r, a as s, Z as t, ye as u, ke as v, W as w, je as x, Me as y, le as z };
|
package/dist/primitives.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e,
|
|
2
|
-
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS,
|
|
1
|
+
import { A as e, C as t, D as n, E as r, G as i, H as a, K as o, O as s, S as c, T as l, U as u, V as d, W as f, _ as p, a as m, b as h, c as g, d as _, f as v, g as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, u as M, v as N, w as P, x as F, y as I } from "./primitives-DsMsMr5S.js";
|
|
2
|
+
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, d as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, E as WorkflowMessagesProperty, C as WorkflowScheduleProperty, k as WorkflowVersionTypeId, x as WorkflowWorkerLayerTypeId, a as assertConsistentPools, u as deferringControlsOf, m as durableClock, D as durableQueue, A as durableQueueModule, g as durableRateLimiterModule, w as getWorkflowFlowControl, e as getWorkflowSchedule, M as getWorkflowVersionMetadata, f as hasCancelOn, i as hasFlowControl, _ as isWorkflowWorkerLayer, l as makeReplayShapeTracker, r as nondeterminismEventPayload, v as patch, O as processQueue, T as queueWorker, b as rateLimit, n as reportNondeterminism, y as sleep, p as sleepUntil, N as step, I as stepIdempotencyKey, h as stepModule, o as validateFlowControl, S as validateWorkflowSchedule, F as withCompensation, c as workflow, t as workflowModule };
|