@voltro/workflow 0.79.1 → 0.81.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 +169 -0
- package/dist/{cluster-Doetj9Bb.js → cluster-D7VuRhM0.js} +75 -64
- package/dist/cluster.d.ts +23 -0
- package/dist/cluster.js +2 -2
- package/dist/clusterTestSuite.d.ts +8 -0
- package/dist/clusterTestSuite.js +3 -3
- package/dist/index.d.ts +30 -0
- package/dist/index.js +4 -4
- package/dist/{primitives-bv2JHUfk.js → primitives-BJBn8tiH.js} +83 -77
- package/dist/primitives.js +2 -2
- package/dist/{src-Bq0LY2Gf.js → src-D_GRCNhv.js} +171 -171
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1368,6 +1368,28 @@ export declare const CurrentWorkflowReplayShape: FiberRef.FiberRef<ReplayShapeTr
|
|
|
1368
1368
|
* `Effect.locally(CurrentWorkflowRunId, runId)`. */
|
|
1369
1369
|
export declare const CurrentWorkflowRunId: FiberRef.FiberRef<string | undefined>;
|
|
1370
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* FiberRef carrying the name of the `step()` whose body is running — set by
|
|
1373
|
+
* `step()` around its execute, `undefined` everywhere else.
|
|
1374
|
+
*
|
|
1375
|
+
* It exists so work a step does OUTSIDE the process can be deduplicated
|
|
1376
|
+
* without the author spelling a key: a call to another app of the project made
|
|
1377
|
+
* inside a step is re-sent when the step is retried after its reply was lost,
|
|
1378
|
+
* and `(executionId, step, call)` is the identity that makes the second send a
|
|
1379
|
+
* replay. Read through `currentWorkflowStep`, never directly.
|
|
1380
|
+
*/
|
|
1381
|
+
export declare const CurrentWorkflowStep: FiberRef.FiberRef<string | undefined>;
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* The step this fiber is running inside, with its durable execution — or
|
|
1385
|
+
* `undefined` outside a recorded step. Stable across replays and retries of the
|
|
1386
|
+
* same step, and different for every other step and every other run.
|
|
1387
|
+
*/
|
|
1388
|
+
export declare const currentWorkflowStep: Effect.Effect<{
|
|
1389
|
+
readonly executionId: string;
|
|
1390
|
+
readonly step: string;
|
|
1391
|
+
} | undefined>;
|
|
1392
|
+
|
|
1371
1393
|
/**
|
|
1372
1394
|
* Stop retrying an intent whose exact payload can never start.
|
|
1373
1395
|
*
|
|
@@ -1868,6 +1890,14 @@ export declare const isStartExpired: (control: ResolvedFlowControl, pending: {
|
|
|
1868
1890
|
readonly firstSeenAt: number;
|
|
1869
1891
|
}, now: number) => boolean;
|
|
1870
1892
|
|
|
1893
|
+
/**
|
|
1894
|
+
* The dispatch failed WITHOUT a definite answer: the engine may or may not have
|
|
1895
|
+
* accepted it, the submission stays durable, and recovery retries it. The
|
|
1896
|
+
* start may still happen, so a caller must not report it as failed — its
|
|
1897
|
+
* receipt follows the outcome.
|
|
1898
|
+
*/
|
|
1899
|
+
export declare const isUnacknowledgedSubmission: (cause: unknown) => boolean;
|
|
1900
|
+
|
|
1871
1901
|
export declare const isWorkflowWorkerLayer: (value: unknown) => value is WorkflowWorkerLayerBrand;
|
|
1872
1902
|
|
|
1873
1903
|
/**
|
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, F as a, G as o, H as s,
|
|
2
|
-
import { $ as
|
|
3
|
-
import { c 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, I as c, J as l, K as u, M as d, O as f, P as p, R as m, S as h, T as g, U as _, V as v, W as y, X as b, Y as x, Z as S, _ as C, a as w, b as T, c as E, d as D, f as O, g as k, h as A, i as j, j as M, k as N, l as P, m as F, n as I, o as L, p as R, q as z, r as B, s as V, t as H, u as U, v as W, w as G, x as K, y as q, z as J } from "./primitives-BJBn8tiH.js";
|
|
2
|
+
import { $ as Y, $t as X, A as Z, At as Q, B as $, Bt as ee, C as te, Cn as ne, Ct as re, D as ie, Dt as ae, E as oe, Et as se, F as ce, Ft as le, G as ue, Gt as de, H as fe, Ht as pe, I as me, It as he, J as ge, Jt as _e, K as ve, Kt as ye, L as be, Lt as xe, M as Se, Mt as Ce, N as we, Nt as Te, O as Ee, Ot as De, P as Oe, Pt as ke, Q as Ae, Qt as je, R as Me, Rt as Ne, S as Pe, Sn as Fe, St as Ie, T as Le, Tn as Re, Tt as ze, U as Be, Ut as Ve, V as He, Vt as Ue, W as We, Wt as Ge, X as Ke, Xt as qe, Y as Je, Yt as Ye, Z as Xe, Zt as Ze, _ as Qe, _n as $e, _t as et, a as tt, an as nt, at as rt, b as it, bn as at, bt as ot, c as st, cn as ct, ct as lt, d as ut, dn as dt, dt as ft, en as pt, et as mt, f as ht, fn as gt, ft as _t, g as vt, gn as yt, gt as bt, h as xt, hn as St, ht as Ct, i as wt, in as Tt, it as Et, j as Dt, jt as Ot, k as kt, kt as At, l as jt, ln as Mt, lt as Nt, m as Pt, mn as Ft, mt as It, n as Lt, nn as Rt, nt as zt, o as Bt, on as Vt, ot as Ht, p as Ut, pn as Wt, pt as Gt, q as Kt, qt, r as Jt, rn as Yt, rt as Xt, s as Zt, sn as Qt, st as $t, t as en, tn, tt as nn, u as rn, un as an, ut as on, v as sn, vn as cn, vt as ln, w as un, wn as dn, wt as fn, x as pn, xn as mn, xt as hn, y as gn, yn as _n, yt as vn, z as yn, zt as bn } from "./src-D_GRCNhv.js";
|
|
3
|
+
import { c as xn, g as Sn, l as Cn, n as wn, r as Tn, t as En, u as Dn } from "./clusterDiagnostics-Cwt-WFec.js";
|
|
4
|
+
export { It as ADMISSIONS_TABLE, pe as ADMISSION_SUBMISSION_ID_PREFIX, ht as BUDGET_HOLDS_TABLE, Ut as BudgetHoldExpired, ue as CANCEL_ON_WATERMARK, En as CLUSTER_REREAD_WINDOW_MS, wn as ClusterDiagnostics, d as CurrentWorkflowExecutionId, p as CurrentWorkflowPatches, G as CurrentWorkflowReplayShape, a as CurrentWorkflowRunId, c as CurrentWorkflowStep, Pt as DEFAULT_BUDGET_HOLD_TIMEOUT_MS, ve as DEFAULT_COLD_LOOKBACK_MS, be as DEFAULT_DRAIN_BATCH, Kt as DEFAULT_EVENT_BATCH, Ct as DEFAULT_LEASE_MS, en as DEFAULT_MAX_RUN_RECLAIMS, Lt as DEFAULT_REPLAY_SHAPE_LIMIT, He as DEFAULT_STALL_AFTER_MS, fe as DEFAULT_STALL_EVENT_LOOKBACK, Be as DEFAULT_STALL_RUN_PAGE, Se as DEFAULT_SUSPEND_HINT_MS, f as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, _ as DEFERRING_CONTROLS, ge as EVENTS_TABLE, Yt as FlowControlKeyError, bt as PAUSES_TABLE, et as PENDING_TABLE, Je as WATERMARKS_TABLE, H as WorkflowFlowControlProperty, I as WorkflowMessagesProperty, m as WorkflowRunRecorder, N as WorkflowScheduleProperty, J as WorkflowStepInterceptorTag, B as WorkflowVersionTypeId, j as WorkflowWorkerLayerTypeId, xt as _voltroBudgetHoldsTable, gt as _voltroWorkflowAdmissionLocksTable, Wt as _voltroWorkflowAdmissionsTable, Ft as _voltroWorkflowControlRequestsTable, St as _voltroWorkflowFailureReportsTable, yt as _voltroWorkflowParentClosuresTable, $e as _voltroWorkflowPausesTable, cn as _voltroWorkflowPendingTable, Fe as _voltroWorkflowRunEventsTable, ne as _voltroWorkflowRunStepsTable, dn as _voltroWorkflowRunsTable, mn as _voltroWorkflowStartContextsTable, _n as _voltroWorkflowStartReceiptsTable, at as _voltroWorkflowSubmissionsTable, nn as _voltroWorkflowWatermarksTable, Me as acceptAdmissionSubmission, xn as acceptWorkflowControlInTransaction, Ve as acknowledgeAdmissionSubmission, zt as admitStart, ln as allIntents, y as assertConsistentPools, x as attachPreparedWorkflowExecution, Z as awaitEvent, Dt as awaitSignal, te as awaitSignalSuspending, ut as awaitUpdate, Ge as beginAdmissionSubmissionDispatchInTransaction, Cn as beginWorkflowControlDispatchInTransaction, Dn as bindWorkflowResumeJournalInTransaction, Ne as bindWorkflowStartReceipts, vt as budgetHoldGeneration, Qe as budgetHoldKey, sn as budgetHoldSignalName, Ht as cancelQueuedWorkflowStartInTransaction, Nt as cancelSuspendedWorkflowRunInTransaction, Tt as comparePendingOrder, un as completeSuspendingSignal, on as completeWorkflowRunGenerationInTransaction, t as currentWorkflowStep, vn as deadLetterIntent, nt as decideAdmission, o as deferringControlsOf, ot as deleteIntent, Tn as describeStalledRun, hn as discardIntent, Ie as discardIntentInTransaction, yn as drainTick, re as dueIntents, w as durableClock, L as durableQueue, V as durableQueueModule, E as durableRateLimiterModule, ft as enterWorkflowRunGenerationInTransaction, fn as evaluateAdmission, b as executePreparedWorkflow, v as getCurrentWorkflowExecutionId, s as getCurrentWorkflowRunId, P as getWorkflowFlowControl, e as getWorkflowSchedule, U as getWorkflowVersionMetadata, X as handoffWorkflowFailureInTransaction, u as hasCancelOn, z as hasFlowControl, S as hasPreparedWorkflowExecution, gn as heldBudgets, Re as inMemoryWorkflowEngineLayer, rn as inspectWorkflow, Vt as isFinishExpired, Qt as isStartExpired, $ as isUnacknowledgedSubmission, D as isWorkflowWorkerLayer, Xt as linkExecution, jt as makeInMemoryRecorder, g as makeReplayShapeTracker, Jt as makeWorkflowRunRecorder, oe as makeWorkflowUpdateId, we as maybeHintSuspendingSignal, de as newAdmissionSubmissionId, Y as newestEventAt, ct as nextSlotAt, i as nondeterminismEventPayload, wt as normaliseWorkflowPatches, ye as noteAdmissionSubmissionFailure, ze as noteIntentAttempt, se as parkDelayedStart, O as patch, ae as pauseWorkflow, qt as pendingAdmissionSubmissions, it as pendingBudgetHolds, De as pendingSlotId, At as pendingWindow, Q as persistDefer, mt as planCancellations, Mt as pooledConcurrencyKey, _e as prepareAdmissionSubmissionExecutionInTransaction, R as processQueue, Ot as pruneAdmissions, F as queueWorker, lt as queuedCancellationRequestsTable, A as rateLimit, Ce as readAdmissionState, Ye as readAdmissionSubmission, Te as readPausedWorkflows, $t as readQueuedWorkflowCancellationInTransaction, Ke as readWatermark, Sn as readWorkflowControlInTransaction, tn as readWorkflowFailureRecord, bn as readWorkflowStartReceipt, pt as reconcileWorkflowFailureInTransaction, ke as recordAdmission, Rt as recordWorkflowFailureInTransaction, ee as recordWorkflowStartReceipt, qe as rejectAdmissionSubmissionInTransaction, pn as releaseBudgetHolds, le as releaseLease, r as reportNondeterminism, Ze as reserveAdmissionSubmission, je as reserveAdmissionSubmissionInTransaction, Oe as resetSuspendHintsForTest, an as resolveAdmissionKeys, tt as resolveRunGuardTuning, ce as resolveSuspendHintMs, ie as resolveWorkflowMessageRun, Ue as resolveWorkflowStartReceipt, he as resumeWorkflow, xe as retryDeadLetterIntent, Ee as sendWorkflowSignal, kt as sendWorkflowUpdate, Bt as serialiseWorkflowRowForWire, me as setSuspendSignalHintMs, k as sleep, C as sleepUntil, Gt as stageWorkflowParentClosureInTransaction, W as step, q as stepIdempotencyKey, T as stepModule, Pe as suspendForBudget, Le as suspendingSignalDeferredName, Xe as sweepCancelOn, We as sweepStalledRuns, Et as takeAdmittedSubmissionInTransaction, rt as takePendingAdmissionSubmission, Zt as truncateWorkflowValue, l as validateFlowControl, M as validateWorkflowSchedule, dt as withAdmissionTransaction, K as withCompensation, h as workflow, n as workflowModule, _t as workflowRestartRequestsTable, st as wrapWorkflowExecuteWithRunRecording, Ae as writeWatermark };
|
|
@@ -1,17 +1,17 @@
|
|
|
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, 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 ee, FiberRef as _, Option as v, Schedule as y, Schema as
|
|
3
|
-
import { attachWorkflowAccess as
|
|
2
|
+
import { Cause as d, Context as f, Cron as p, Duration as m, Effect as h, Either as g, Exit as ee, FiberRef as _, Option as v, Schedule as y, Schema as te } from "effect";
|
|
3
|
+
import { attachWorkflowAccess as ne, resolveWorkflowAccess as b } from "@voltro/protocol";
|
|
4
4
|
//#region src/preparedExecution.ts
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(e,
|
|
5
|
+
var x = Symbol.for("@voltro/workflow/PreparedExecution"), S = (e, t) => {
|
|
6
|
+
Object.defineProperty(e, x, {
|
|
7
7
|
value: t,
|
|
8
8
|
enumerable: !0
|
|
9
9
|
});
|
|
10
|
-
},
|
|
10
|
+
}, re = (e) => typeof e == "object" && !!e && typeof e[x] == "function", ie = (e, t, n, r) => h.suspend(() => {
|
|
11
11
|
if (n.length === 0) return h.die(/* @__PURE__ */ Error("Prepared workflow execution requires a non-empty identity"));
|
|
12
|
-
let i = e[
|
|
12
|
+
let i = e[x];
|
|
13
13
|
return typeof i == "function" ? i(t, n, r?.discard ?? !0) : h.die(/* @__PURE__ */ Error("Workflow definition has no prepared-execution capability"));
|
|
14
|
-
}),
|
|
14
|
+
}), C = (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), w = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, ae = [
|
|
15
15
|
"debounce",
|
|
16
16
|
"batch",
|
|
17
17
|
"throttle",
|
|
@@ -35,12 +35,12 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
35
35
|
}, O = (e, t, n) => {
|
|
36
36
|
if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
|
|
37
37
|
return e;
|
|
38
|
-
},
|
|
38
|
+
}, k = (e) => {
|
|
39
39
|
let t = e?.ast?.propertySignatures;
|
|
40
40
|
if (!Array.isArray(t)) return !1;
|
|
41
41
|
let n = t.find((e) => e.name === "items");
|
|
42
42
|
return n !== void 0 && n.type?._tag === "TupleType";
|
|
43
|
-
},
|
|
43
|
+
}, A = (e) => {
|
|
44
44
|
let { workflowName: t, control: n } = e;
|
|
45
45
|
if (n === void 0) return;
|
|
46
46
|
let r = { workflowName: t };
|
|
@@ -88,7 +88,7 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
88
88
|
}
|
|
89
89
|
if (n.batch !== void 0) {
|
|
90
90
|
let i = n.batch;
|
|
91
|
-
if (e.payloadSchema !== void 0 && !
|
|
91
|
+
if (e.payloadSchema !== void 0 && !k(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.`);
|
|
92
92
|
r.batch = {
|
|
93
93
|
...i.key === void 0 ? {} : { key: O(i.key, "batch.key", t) },
|
|
94
94
|
maxSize: D(i.maxSize, "batch.maxSize", t),
|
|
@@ -134,7 +134,7 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
134
134
|
}
|
|
135
135
|
if (r.timeouts?.startMs !== void 0 && T(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.`);
|
|
136
136
|
return r;
|
|
137
|
-
},
|
|
137
|
+
}, oe = (e) => {
|
|
138
138
|
let t = /* @__PURE__ */ new Map();
|
|
139
139
|
for (let n of e) {
|
|
140
140
|
let e = n?.concurrency;
|
|
@@ -147,25 +147,31 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
147
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.`);
|
|
148
148
|
else r.workflows.push(n.workflowName);
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, j = class extends f.Tag("@voltro/WorkflowRunRecorder")() {}, M = _.unsafeMake(void 0), N = _.unsafeMake(void 0), P = _.unsafeMake(void 0), se = h.gen(function* () {
|
|
151
|
+
let e = yield* _.get(N), t = yield* _.get(P);
|
|
152
|
+
return e === void 0 || t === void 0 ? void 0 : {
|
|
153
|
+
executionId: e,
|
|
154
|
+
step: t
|
|
155
|
+
};
|
|
156
|
+
}), ce = _.unsafeMake(void 0), F = _.unsafeMake(void 0), I = _.unsafeMake([]), le = () => _.get(M), L = () => _.get(N), R = class extends f.Tag("@voltro/WorkflowStepInterceptor")() {}, z = 864e5, B = /* @__PURE__ */ new Set([
|
|
151
157
|
"skip",
|
|
152
158
|
"buffer",
|
|
153
159
|
"cancelOther"
|
|
154
|
-
]),
|
|
160
|
+
]), V = /* @__PURE__ */ new Set([
|
|
155
161
|
"skip",
|
|
156
162
|
"latest",
|
|
157
163
|
"all"
|
|
158
|
-
]),
|
|
164
|
+
]), H = (e, t) => {
|
|
159
165
|
if (t === void 0) return;
|
|
160
166
|
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.`);
|
|
161
167
|
let n = p.parse(t.cron, t.timezone);
|
|
162
168
|
if (g.isLeft(n)) throw Error(`workflow '${e}': schedule.cron "${t.cron}" (tz="${t.timezone}") is not a valid cron expression — ${String(n.left)}`);
|
|
163
169
|
let r = t.onOverlap ?? "skip";
|
|
164
|
-
if (!
|
|
170
|
+
if (!B.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
|
|
165
171
|
let i = t.backfill ?? "skip";
|
|
166
|
-
if (!
|
|
167
|
-
let a =
|
|
168
|
-
return t.maxRuntime !== void 0 && (a =
|
|
172
|
+
if (!V.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
|
|
173
|
+
let a = z;
|
|
174
|
+
return t.maxRuntime !== void 0 && (a = U(t.maxRuntime, e)), {
|
|
169
175
|
cron: t.cron,
|
|
170
176
|
timezone: t.timezone,
|
|
171
177
|
...t.payload === void 0 ? {} : { payload: t.payload },
|
|
@@ -173,7 +179,7 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
173
179
|
backfill: i,
|
|
174
180
|
maxRuntimeMs: a
|
|
175
181
|
};
|
|
176
|
-
},
|
|
182
|
+
}, U = (e, t) => {
|
|
177
183
|
let n;
|
|
178
184
|
try {
|
|
179
185
|
n = m.toMillis(m.decode(e));
|
|
@@ -182,11 +188,11 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
182
188
|
}
|
|
183
189
|
if (!Number.isFinite(n) || n <= 0) throw Error(`workflow '${t}': schedule.maxRuntime must be a positive finite duration`);
|
|
184
190
|
return n;
|
|
185
|
-
},
|
|
191
|
+
}, W = "__voltroWorkflowSchedule", ue = (e) => {
|
|
186
192
|
if (typeof e != "object" || !e) return;
|
|
187
|
-
let t = e[
|
|
193
|
+
let t = e[W];
|
|
188
194
|
return t === void 0 ? void 0 : t;
|
|
189
|
-
},
|
|
195
|
+
}, de = (e) => {
|
|
190
196
|
let t = /* @__PURE__ */ new Map();
|
|
191
197
|
for (let n of e) t.set(n.stepName, (t.get(n.stepName) ?? 0) + 1);
|
|
192
198
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => !r.has(e) && (r.add(e), !0);
|
|
@@ -215,52 +221,52 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
215
221
|
return e;
|
|
216
222
|
}
|
|
217
223
|
};
|
|
218
|
-
},
|
|
224
|
+
}, G = _.unsafeMake(void 0), K = (e) => ({
|
|
219
225
|
kind: e.kind,
|
|
220
226
|
stepName: e.stepName,
|
|
221
227
|
recorded: e.recorded,
|
|
222
228
|
reached: e.reached,
|
|
223
229
|
detail: e.detail
|
|
224
|
-
}),
|
|
230
|
+
}), q = (e) => h.gen(function* () {
|
|
225
231
|
if (e.length === 0) return;
|
|
226
|
-
let t = yield* _.get(
|
|
232
|
+
let t = yield* _.get(M), n = yield* h.serviceOption(j);
|
|
227
233
|
if (t === void 0 || n._tag !== "Some") return;
|
|
228
234
|
let r = n.value;
|
|
229
235
|
for (let n of e) yield* h.promise(() => r.recordEvent({
|
|
230
236
|
runId: t,
|
|
231
237
|
eventType: "nondeterminism-suspected",
|
|
232
|
-
payload:
|
|
238
|
+
payload: K(n)
|
|
233
239
|
}).then(() => void 0).catch(() => void 0));
|
|
234
|
-
}),
|
|
240
|
+
}), fe = (e) => {
|
|
235
241
|
if (typeof e != "object" || !e) return;
|
|
236
242
|
let t = e.retryAfterMillis;
|
|
237
243
|
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return m.millis(t);
|
|
238
244
|
let n = e.retryAfter;
|
|
239
245
|
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return m.seconds(n);
|
|
240
|
-
},
|
|
246
|
+
}, J = (e) => m.decode(e), pe = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, me = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, he = (e) => {
|
|
241
247
|
if (e.retryable) return e.retryable;
|
|
242
248
|
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
243
249
|
let t = new Set(e.retryableErrors);
|
|
244
250
|
return (e) => {
|
|
245
|
-
let n =
|
|
251
|
+
let n = pe(e);
|
|
246
252
|
return n !== void 0 && t.has(n);
|
|
247
253
|
};
|
|
248
254
|
}
|
|
249
255
|
return () => !0;
|
|
250
|
-
},
|
|
251
|
-
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? y.linear(
|
|
256
|
+
}, ge = (e) => {
|
|
257
|
+
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? y.linear(J(e.step ?? t)) : n === "fixed" ? y.spaced(J(t)) : y.exponential(J(t), e.factor ?? 2);
|
|
252
258
|
if (e.maxDelay !== void 0) {
|
|
253
|
-
let t =
|
|
259
|
+
let t = J(e.maxDelay);
|
|
254
260
|
i = y.modifyDelay(i, (e, n) => m.min(n, t));
|
|
255
261
|
}
|
|
256
262
|
(e.jitter ?? !0) === !0 && (i = y.jittered(i));
|
|
257
263
|
let a = y.intersect(i, y.recurs(Math.max(0, r - 1)));
|
|
258
|
-
return e.maxElapsed !== void 0 && (a = y.upTo(
|
|
259
|
-
},
|
|
260
|
-
let n = m.toMillis(
|
|
261
|
-
return e.maxDelay !== void 0 && (i = Math.min(i, m.toMillis(
|
|
262
|
-
},
|
|
263
|
-
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : m.toMillis(
|
|
264
|
+
return e.maxElapsed !== void 0 && (a = y.upTo(J(e.maxElapsed))(a)), a;
|
|
265
|
+
}, _e = (e, t) => {
|
|
266
|
+
let n = m.toMillis(J(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + m.toMillis(J(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
267
|
+
return e.maxDelay !== void 0 && (i = Math.min(i, m.toMillis(J(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
268
|
+
}, ve = (e, t, n, r) => h.gen(function* () {
|
|
269
|
+
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : m.toMillis(J(t.maxElapsed)), o = yield* h.sync(() => Date.now()), s = 0;
|
|
264
270
|
for (;;) {
|
|
265
271
|
let c = yield* h.exit(e);
|
|
266
272
|
if (ee.isSuccess(c)) return c.value;
|
|
@@ -269,27 +275,27 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
269
275
|
let p = (yield* h.sync(() => Date.now())) - o;
|
|
270
276
|
if (s >= i || !n(f) || p >= a) return yield* h.failCause(l);
|
|
271
277
|
r?.(f);
|
|
272
|
-
let g =
|
|
278
|
+
let g = fe(f), _ = g === void 0 ? _e(t, s) : m.toMillis(g);
|
|
273
279
|
yield* h.sleep(m.millis(_));
|
|
274
280
|
}
|
|
275
|
-
}),
|
|
276
|
-
if (!
|
|
277
|
-
let r =
|
|
278
|
-
if (t.respectRetryAfter === !0) return
|
|
279
|
-
let i =
|
|
281
|
+
}), ye = (e, t, n) => {
|
|
282
|
+
if (!me(t)) return e;
|
|
283
|
+
let r = he(t);
|
|
284
|
+
if (t.respectRetryAfter === !0) return ve(e, t, r, n);
|
|
285
|
+
let i = ge(t), a = n ? h.tapError(e, (e) => h.sync(() => {
|
|
280
286
|
r(e) && n(e);
|
|
281
287
|
})) : e;
|
|
282
288
|
return h.retry(a, {
|
|
283
289
|
schedule: i,
|
|
284
290
|
while: r
|
|
285
291
|
});
|
|
286
|
-
},
|
|
292
|
+
}, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl", be = (e) => typeof e == "object" && !!e && e[Y] === !0, xe = (e) => typeof e == "object" && e && e[X] !== void 0 ? e[X] : {
|
|
287
293
|
version: "1",
|
|
288
294
|
compatibleWith: ["1"],
|
|
289
295
|
patches: []
|
|
290
|
-
},
|
|
296
|
+
}, Se = ((e) => {
|
|
291
297
|
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t;
|
|
292
|
-
|
|
298
|
+
S(n, (t, r, i) => h.gen(function* () {
|
|
293
299
|
let a = n.payloadSchema.make(t), o = yield* u.WorkflowEngine;
|
|
294
300
|
return yield* h.annotateCurrentSpan({ executionId: r }), yield* o.execute(n, {
|
|
295
301
|
executionId: r,
|
|
@@ -306,41 +312,41 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
306
312
|
signals: { ...e.messages?.signals ?? {} },
|
|
307
313
|
updates: { ...e.messages?.updates ?? {} }
|
|
308
314
|
};
|
|
309
|
-
Object.defineProperty(n,
|
|
315
|
+
Object.defineProperty(n, X, {
|
|
310
316
|
value: i,
|
|
311
317
|
enumerable: !1
|
|
312
|
-
}), Object.defineProperty(n,
|
|
318
|
+
}), Object.defineProperty(n, Z, {
|
|
313
319
|
value: a,
|
|
314
320
|
enumerable: !1
|
|
315
|
-
}),
|
|
316
|
-
let o =
|
|
321
|
+
}), ne(n, b(e.name, e));
|
|
322
|
+
let o = A({
|
|
317
323
|
workflowName: e.name,
|
|
318
324
|
payloadSchema: e.payload,
|
|
319
325
|
control: e
|
|
320
326
|
});
|
|
321
|
-
o !== void 0 && Object.defineProperty(n,
|
|
327
|
+
o !== void 0 && Object.defineProperty(n, Q, {
|
|
322
328
|
value: o,
|
|
323
329
|
enumerable: !1
|
|
324
330
|
});
|
|
325
|
-
let s =
|
|
326
|
-
return s !== void 0 && Object.defineProperty(n,
|
|
331
|
+
let s = H(e.name, e.schedule);
|
|
332
|
+
return s !== void 0 && Object.defineProperty(n, W, {
|
|
327
333
|
value: s,
|
|
328
334
|
enumerable: !1
|
|
329
335
|
}), n;
|
|
330
|
-
}),
|
|
336
|
+
}), Ce = (e) => {
|
|
331
337
|
if (typeof e != "object" || !e) return;
|
|
332
|
-
let t = e[
|
|
338
|
+
let t = e[Q];
|
|
333
339
|
return t === void 0 ? void 0 : t;
|
|
334
|
-
},
|
|
340
|
+
}, we = i.make, Te = i.process, Ee = ((...e) => {
|
|
335
341
|
let t = i.worker(...e);
|
|
336
|
-
return Object.defineProperty(t,
|
|
342
|
+
return Object.defineProperty(t, Y, {
|
|
337
343
|
value: !0,
|
|
338
344
|
enumerable: !1
|
|
339
345
|
}), t;
|
|
340
|
-
}),
|
|
341
|
-
let t = yield*
|
|
346
|
+
}), De = o.rateLimit, $ = (e) => h.gen(function* () {
|
|
347
|
+
let t = yield* M, r = yield* h.serviceOption(j), i = m.toMillis(m.decode(e.duration));
|
|
342
348
|
if (t !== void 0 && r._tag === "Some") {
|
|
343
|
-
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield*
|
|
349
|
+
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* F;
|
|
344
350
|
yield* h.promise(() => a.recordEvent({
|
|
345
351
|
runId: t,
|
|
346
352
|
eventType: "timer-set",
|
|
@@ -364,18 +370,18 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
364
370
|
return;
|
|
365
371
|
}
|
|
366
372
|
yield* n.sleep(e);
|
|
367
|
-
}),
|
|
373
|
+
}), Oe = (t) => h.gen(function* () {
|
|
368
374
|
let n = (yield* e.make({
|
|
369
375
|
name: `sleepUntil:${t.name}`,
|
|
370
|
-
success:
|
|
376
|
+
success: te.Number,
|
|
371
377
|
execute: h.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
|
|
372
378
|
})) - Date.now();
|
|
373
|
-
n <= 0 || (yield*
|
|
379
|
+
n <= 0 || (yield* $({
|
|
374
380
|
name: t.name,
|
|
375
381
|
duration: `${n} millis`
|
|
376
382
|
}));
|
|
377
|
-
}),
|
|
378
|
-
let a = yield*
|
|
383
|
+
}), ke = (t, n, r, i) => h.gen(function* () {
|
|
384
|
+
let a = yield* M, o = yield* e.CurrentAttempt, s = yield* h.serviceOption(j), c = yield* h.serviceOption(R), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
379
385
|
runId: a ?? "unrecorded",
|
|
380
386
|
stepName: t,
|
|
381
387
|
attempt: o
|
|
@@ -396,7 +402,7 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
396
402
|
}
|
|
397
403
|
}
|
|
398
404
|
let p = Date.now();
|
|
399
|
-
return yield*
|
|
405
|
+
return yield* h.locally(ye(l, i), P, t).pipe(h.tap((e) => u && f ? h.promise(async () => {
|
|
400
406
|
try {
|
|
401
407
|
await f.endStepSuccess({
|
|
402
408
|
stepRecordId: u,
|
|
@@ -420,23 +426,23 @@ var C = Symbol.for("@voltro/workflow/PreparedExecution"), w = (e, t) => {
|
|
|
420
426
|
});
|
|
421
427
|
} catch {}
|
|
422
428
|
}) : h.void));
|
|
423
|
-
}),
|
|
424
|
-
let t = yield* _.get(
|
|
429
|
+
}), Ae = (e) => h.gen(function* () {
|
|
430
|
+
let t = yield* _.get(G);
|
|
425
431
|
if (t === void 0) return;
|
|
426
432
|
let n = t.reach(e);
|
|
427
|
-
n !== void 0 && (yield*
|
|
428
|
-
}),
|
|
433
|
+
n !== void 0 && (yield* q([n]));
|
|
434
|
+
}), je = (e, t) => {
|
|
429
435
|
let n = e;
|
|
430
436
|
return {
|
|
431
437
|
...e,
|
|
432
|
-
commit: () => h.zipRight(
|
|
438
|
+
commit: () => h.zipRight(Ae(t), n)
|
|
433
439
|
};
|
|
434
|
-
},
|
|
440
|
+
}, Me = (t) => {
|
|
435
441
|
let { input: n, retry: r, ...i } = t;
|
|
436
|
-
return
|
|
442
|
+
return je(e.make({
|
|
437
443
|
...i,
|
|
438
|
-
execute:
|
|
444
|
+
execute: ke(i.name, i.execute, n, r)
|
|
439
445
|
}), i.name);
|
|
440
|
-
},
|
|
446
|
+
}, Ne = (e) => h.map(_.get(I), (t) => t.includes(e)), Pe = c.withCompensation, Fe = e.idempotencyKey;
|
|
441
447
|
//#endregion
|
|
442
|
-
export {
|
|
448
|
+
export { ue as A, se as B, l as C, q as D, K as E, M as F, T as G, le as H, P as I, A as J, w as K, F as L, N as M, ce as N, z as O, I as P, j as R, Se as S, de as T, ae as U, L as V, oe as W, ie as X, S as Y, re as Z, Oe as _, r as a, t as b, s as c, be as d, Ne as f, $ as g, De as h, Y as i, H as j, W as k, Ce as l, Ee as m, Z as n, we as o, Te as p, C as q, X as r, a as s, Q as t, xe as u, Me as v, G as w, Pe as x, Fe as y, R as z };
|
package/dist/primitives.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, G as i,
|
|
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, J as a, K as o, O as s, S as c, T as l, U as u, W as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, q 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-BJBn8tiH.js";
|
|
2
|
+
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, u as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, T as WorkflowMessagesProperty, S as WorkflowScheduleProperty, k as WorkflowVersionTypeId, b as WorkflowWorkerLayerTypeId, d as assertConsistentPools, i as deferringControlsOf, p as durableClock, E as durableQueue, A as durableQueueModule, h as durableRateLimiterModule, C as getWorkflowFlowControl, e as getWorkflowSchedule, M as getWorkflowVersionMetadata, o as hasCancelOn, O as hasFlowControl, g as isWorkflowWorkerLayer, l as makeReplayShapeTracker, r as nondeterminismEventPayload, _ as patch, D as processQueue, w as queueWorker, y as rateLimit, n as reportNondeterminism, v as sleep, f as sleepUntil, N as step, I as stepIdempotencyKey, m as stepModule, a as validateFlowControl, x as validateWorkflowSchedule, F as withCompensation, c as workflow, t as workflowModule };
|