@voltro/workflow 0.29.0 → 0.30.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 +377 -0
- package/dist/clusterTestSuite.js +18 -18
- package/dist/index.d.ts +1567 -11
- package/dist/index.js +3 -3
- package/dist/primitives-Cwy2zQpU.js +322 -0
- package/dist/primitives.d.ts +609 -11
- package/dist/primitives.js +2 -2
- package/dist/src-CMapid4w.js +1989 -0
- package/package.json +3 -3
- package/dist/primitives-Dgu3O55Q.js +0 -164
- package/dist/src-KDx7NTsa.js +0 -854
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, M as a, N as o, O as s, P as c, S as l, _ as u, a as d, b as f, c as p, d as m, f as h, g, h as _, i as v, j as y, k as b, l as x, m as S, n as C, o as w, p as T, r as E, s as D, t as O, u as k, v as A, w as j, x as M, y as N } from "./primitives-Cwy2zQpU.js";
|
|
2
|
+
import { $ as P, A as F, B as I, C as L, D as R, E as z, F as B, G as V, H, I as U, J as W, K as G, L as K, M as q, N as J, O as Y, P as X, Q as Z, R as Q, S as $, T as ee, U as te, V as ne, W as re, X as ie, Y as ae, Z as oe, _ as se, a as ce, at as le, b as ue, c as de, ct as fe, d as pe, dt as me, et as he, f as ge, ft as _e, g as ve, h as ye, i as be, it as xe, j as Se, k as Ce, l as we, lt as Te, m as Ee, n as De, nt as Oe, o as ke, ot as Ae, p as je, pt as Me, q as Ne, r as Pe, rt as Fe, s as Ie, st as Le, t as Re, tt as ze, u as Be, ut as Ve, v as He, w as Ue, x as We, y as Ge, z as Ke } from "./src-CMapid4w.js";
|
|
3
|
+
export { J as ADMISSIONS_TABLE, ue as CANCEL_ON_WATERMARK, t as CurrentWorkflowExecutionId, j as CurrentWorkflowRunId, We as DEFAULT_COLD_LOOKBACK_MS, He as DEFAULT_DRAIN_BATCH, $ as DEFAULT_EVENT_BATCH, X as DEFAULT_LEASE_MS, e as DEFERRING_CONTROLS, L as EVENTS_TABLE, Z as FlowControlKeyError, B as PAUSES_TABLE, U as PENDING_TABLE, Ue as WATERMARKS_TABLE, O as WorkflowFlowControlProperty, C as WorkflowMessagesProperty, r as WorkflowRunRecorder, n as WorkflowStepInterceptorTag, E as WorkflowVersionTypeId, v as WorkflowWorkerLayerTypeId, Ae as _voltroWorkflowAdmissionsTable, Le as _voltroWorkflowPausesTable, fe as _voltroWorkflowPendingTable, Ve as _voltroWorkflowRunEventsTable, me as _voltroWorkflowRunStepsTable, _e as _voltroWorkflowRunsTable, Te as _voltroWorkflowStartContextsTable, F as _voltroWorkflowWatermarksTable, Se as admitStart, K as allIntents, y as assertConsistentPools, ve as awaitEvent, se as awaitSignal, we as awaitSignalSuspending, de as awaitUpdate, Pe as closeWorkflowChildrenForParent, P as comparePendingOrder, Be as completeSuspendingSignal, he as decideAdmission, a as deferringControlsOf, Q as deleteIntent, Ke as discardIntent, Ge as drainTick, I as dueIntents, d as durableClock, w as durableQueue, D as durableQueueModule, p as durableRateLimiterModule, ne as evaluateAdmission, s as getCurrentWorkflowExecutionId, b as getCurrentWorkflowRunId, x as getWorkflowFlowControl, k as getWorkflowVersionMetadata, o as hasCancelOn, c as hasFlowControl, Me as inMemoryWorkflowEngineLayer, De as inspectWorkflow, ze as isFinishExpired, Oe as isStartExpired, m as isWorkflowWorkerLayer, q as linkExecution, Re as makeInMemoryRecorder, be as makeWorkflowRunRecorder, ge as makeWorkflowUpdateId, Y as newestEventAt, Fe as nextSlotAt, H as noteIntentAttempt, te as pauseWorkflow, re as pendingSlotId, V as persistDefer, Ce as planCancellations, xe as pooledConcurrencyKey, h as processQueue, G as pruneAdmissions, T as queueWorker, S as rateLimit, Ne as readAdmissionState, W as readPausedWorkflows, ee as readWatermark, ae as recordAdmission, ie as releaseLease, le as resolveAdmissionKeys, je as resolveWorkflowMessageRun, oe as resumeWorkflow, Ee as sendWorkflowSignal, ye as sendWorkflowUpdate, ce as serialiseWorkflowRowForWire, _ as sleep, g as sleepUntil, u as step, A as stepIdempotencyKey, N as stepModule, pe as suspendingSignalDeferredName, z as sweepCancelOn, ke as truncateWorkflowValue, i as validateFlowControl, f as withCompensation, M as workflow, l as workflowModule, Ie as wrapWorkflowExecuteWithRunRecording, R as writeWatermark };
|
|
@@ -0,0 +1,322 @@
|
|
|
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, Duration as f, Effect as p, Exit as m, FiberRef as h, Option as g, Schedule as _, Schema as v } from "effect";
|
|
3
|
+
//#region src/flowControl.ts
|
|
4
|
+
var y = (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), b = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, x = [
|
|
5
|
+
"debounce",
|
|
6
|
+
"batch",
|
|
7
|
+
"throttle",
|
|
8
|
+
"concurrency"
|
|
9
|
+
], S = (e) => {
|
|
10
|
+
if (e === void 0) return [];
|
|
11
|
+
let t = [];
|
|
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
|
+
}, C = (e, t, n) => {
|
|
14
|
+
let r;
|
|
15
|
+
try {
|
|
16
|
+
r = f.toMillis(f.decode(e));
|
|
17
|
+
} catch {
|
|
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
|
+
}
|
|
20
|
+
if (!Number.isFinite(r) || r <= 0) throw Error(`workflow '${n}': ${t} must be a positive finite duration, got ${String(e)}`);
|
|
21
|
+
return r;
|
|
22
|
+
}, w = (e, t, n) => {
|
|
23
|
+
if (!Number.isInteger(e) || e <= 0) throw Error(`workflow '${n}': ${t} must be a positive integer, got ${String(e)}`);
|
|
24
|
+
return e;
|
|
25
|
+
}, T = (e, t, n) => {
|
|
26
|
+
if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
|
|
27
|
+
return e;
|
|
28
|
+
}, E = (e) => {
|
|
29
|
+
let t = e?.ast?.propertySignatures;
|
|
30
|
+
if (!Array.isArray(t)) return !1;
|
|
31
|
+
let n = t.find((e) => e.name === "items");
|
|
32
|
+
return n !== void 0 && n.type?._tag === "TupleType";
|
|
33
|
+
}, D = (e) => {
|
|
34
|
+
let { workflowName: t, control: n } = e;
|
|
35
|
+
if (n === void 0) return;
|
|
36
|
+
let r = { workflowName: t };
|
|
37
|
+
if (n.debounce !== void 0) {
|
|
38
|
+
let e = n.debounce, i = C(e.period, "debounce.period", t), a = e.timeout === void 0 ? void 0 : C(e.timeout, "debounce.timeout", t);
|
|
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
|
+
r.debounce = {
|
|
41
|
+
key: T(e.key, "debounce.key", t),
|
|
42
|
+
periodMs: i,
|
|
43
|
+
...a === void 0 ? {} : { timeoutMs: a }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (n.singleton !== void 0) {
|
|
47
|
+
let e = n.singleton;
|
|
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
|
+
r.singleton = {
|
|
50
|
+
key: T(e.key, "singleton.key", t),
|
|
51
|
+
mode: e.mode
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (n.concurrency !== void 0) {
|
|
55
|
+
let e = n.concurrency;
|
|
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
|
+
r.concurrency = {
|
|
58
|
+
limit: w(e.limit, "concurrency.limit", t),
|
|
59
|
+
...e.key === void 0 ? {} : { key: T(e.key, "concurrency.key", t) },
|
|
60
|
+
...e.pool === void 0 ? {} : { pool: e.pool.trim() }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (n.throttle !== void 0) {
|
|
64
|
+
let e = n.throttle;
|
|
65
|
+
r.throttle = {
|
|
66
|
+
limit: w(e.limit, "throttle.limit", t),
|
|
67
|
+
periodMs: C(e.period, "throttle.period", t),
|
|
68
|
+
...e.key === void 0 ? {} : { key: T(e.key, "throttle.key", t) }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (n.rateLimit !== void 0) {
|
|
72
|
+
let e = n.rateLimit;
|
|
73
|
+
r.rateLimit = {
|
|
74
|
+
limit: w(e.limit, "rateLimit.limit", t),
|
|
75
|
+
periodMs: C(e.period, "rateLimit.period", t),
|
|
76
|
+
...e.key === void 0 ? {} : { key: T(e.key, "rateLimit.key", t) }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (n.batch !== void 0) {
|
|
80
|
+
let i = n.batch;
|
|
81
|
+
if (e.payloadSchema !== void 0 && !E(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
|
+
r.batch = {
|
|
83
|
+
...i.key === void 0 ? {} : { key: T(i.key, "batch.key", t) },
|
|
84
|
+
maxSize: w(i.maxSize, "batch.maxSize", t),
|
|
85
|
+
timeoutMs: C(i.timeout, "batch.timeout", t)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (n.priority !== void 0) {
|
|
89
|
+
if (typeof n.priority != "function") throw Error(`workflow '${t}': priority must be a function of the payload`);
|
|
90
|
+
r.priority = n.priority;
|
|
91
|
+
}
|
|
92
|
+
if (n.timeouts !== void 0) {
|
|
93
|
+
let e = n.timeouts, i = e.start === void 0 ? void 0 : C(e.start, "timeouts.start", t), a = e.finish === void 0 ? void 0 : C(e.finish, "timeouts.finish", t);
|
|
94
|
+
(i !== void 0 || a !== void 0) && (r.timeouts = {
|
|
95
|
+
...i === void 0 ? {} : { startMs: i },
|
|
96
|
+
...a === void 0 ? {} : { finishMs: a }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (r.debounce !== void 0 && r.batch !== void 0) throw Error(`workflow '${t}': debounce and batch cannot both be declared. Both collect starts and admit one run, but debounce's timer RESETS on every arrival (collapse a burst, latest payload wins) while batch's does not (accumulate items until maxSize or timeout). Pick the one you mean.`);
|
|
100
|
+
if (r.throttle !== void 0 && r.rateLimit !== void 0) throw Error(`workflow '${t}': throttle and rateLimit cannot both be declared. throttle QUEUES the excess and rateLimit DROPS it; declaring both means the drop fires first and the queue is never reached. Pick whether surplus work is late or gone.`);
|
|
101
|
+
if (n.onFailure !== void 0) {
|
|
102
|
+
if (typeof n.onFailure != "string" || n.onFailure.length === 0) throw Error(`workflow '${t}': onFailure must be the NAME of another workflow. A function cannot be used — the failure may be noticed by a different replica, minutes later, after the process that held the closure is gone.`);
|
|
103
|
+
if (n.onFailure === t) throw Error(`workflow '${t}': onFailure points at itself. A workflow that fails would then start another copy of itself, which would fail, forever — one run per failure until something else breaks. Point it at a separate notifier workflow.`);
|
|
104
|
+
r.onFailure = n.onFailure;
|
|
105
|
+
}
|
|
106
|
+
if (n.encryptSteps === !0 && (r.encryptSteps = !0), n.cancelOn !== void 0) {
|
|
107
|
+
if (!Array.isArray(n.cancelOn)) throw Error(`workflow '${t}': cancelOn must be an array of { event, schema, match }`);
|
|
108
|
+
let e = n.cancelOn.map((e, n) => {
|
|
109
|
+
let r = `cancelOn[${n}]`;
|
|
110
|
+
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.`);
|
|
111
|
+
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.`);
|
|
112
|
+
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.`);
|
|
113
|
+
let i = e.within === void 0 ? void 0 : C(e.within, `${r}.within`, t);
|
|
114
|
+
return {
|
|
115
|
+
event: e.event,
|
|
116
|
+
schema: e.schema,
|
|
117
|
+
match: e.match,
|
|
118
|
+
...i === void 0 ? {} : { withinMs: i },
|
|
119
|
+
reason: e.reason ?? `cancelOn:${e.event}`
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
e.length > 0 && (r.cancelOn = e);
|
|
123
|
+
}
|
|
124
|
+
if (r.timeouts?.startMs !== void 0 && S(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.`);
|
|
125
|
+
return r;
|
|
126
|
+
}, ee = (e) => {
|
|
127
|
+
let t = /* @__PURE__ */ new Map();
|
|
128
|
+
for (let n of e) {
|
|
129
|
+
let e = n?.concurrency;
|
|
130
|
+
if (e?.pool === void 0) continue;
|
|
131
|
+
let r = t.get(e.pool);
|
|
132
|
+
if (r === void 0) t.set(e.pool, {
|
|
133
|
+
limit: e.limit,
|
|
134
|
+
workflows: [n.workflowName]
|
|
135
|
+
});
|
|
136
|
+
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.`);
|
|
137
|
+
else r.workflows.push(n.workflowName);
|
|
138
|
+
}
|
|
139
|
+
}, O = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, k = h.unsafeMake(void 0), A = h.unsafeMake(void 0), j = h.unsafeMake(void 0), M = () => h.get(k), N = () => h.get(A), P = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, F = (e) => {
|
|
140
|
+
if (typeof e != "object" || !e) return;
|
|
141
|
+
let t = e.retryAfterMillis;
|
|
142
|
+
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return f.millis(t);
|
|
143
|
+
let n = e.retryAfter;
|
|
144
|
+
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return f.seconds(n);
|
|
145
|
+
}, I = (e) => f.decode(e), L = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, R = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, z = (e) => {
|
|
146
|
+
if (e.retryable) return e.retryable;
|
|
147
|
+
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
148
|
+
let t = new Set(e.retryableErrors);
|
|
149
|
+
return (e) => {
|
|
150
|
+
let n = L(e);
|
|
151
|
+
return n !== void 0 && t.has(n);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return () => !0;
|
|
155
|
+
}, B = (e) => {
|
|
156
|
+
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? _.linear(I(e.step ?? t)) : n === "fixed" ? _.spaced(I(t)) : _.exponential(I(t), e.factor ?? 2);
|
|
157
|
+
if (e.maxDelay !== void 0) {
|
|
158
|
+
let t = I(e.maxDelay);
|
|
159
|
+
i = _.modifyDelay(i, (e, n) => f.min(n, t));
|
|
160
|
+
}
|
|
161
|
+
(e.jitter ?? !0) === !0 && (i = _.jittered(i));
|
|
162
|
+
let a = _.intersect(i, _.recurs(Math.max(0, r - 1)));
|
|
163
|
+
return e.maxElapsed !== void 0 && (a = _.upTo(I(e.maxElapsed))(a)), a;
|
|
164
|
+
}, V = (e, t) => {
|
|
165
|
+
let n = f.toMillis(I(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + f.toMillis(I(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
166
|
+
return e.maxDelay !== void 0 && (i = Math.min(i, f.toMillis(I(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
167
|
+
}, H = (e, t, n, r) => p.gen(function* () {
|
|
168
|
+
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : f.toMillis(I(t.maxElapsed)), o = yield* p.sync(() => Date.now()), s = 0;
|
|
169
|
+
for (;;) {
|
|
170
|
+
let c = yield* p.exit(e);
|
|
171
|
+
if (m.isSuccess(c)) return c.value;
|
|
172
|
+
let l = c.cause, d = u.failureOption(l), h = g.isSome(d) ? d.value : u.squash(l);
|
|
173
|
+
s += 1;
|
|
174
|
+
let _ = (yield* p.sync(() => Date.now())) - o;
|
|
175
|
+
if (s >= i || !n(h) || _ >= a) return yield* p.failCause(l);
|
|
176
|
+
r?.(h);
|
|
177
|
+
let v = F(h), y = v === void 0 ? V(t, s) : f.toMillis(v);
|
|
178
|
+
yield* p.sleep(f.millis(y));
|
|
179
|
+
}
|
|
180
|
+
}), U = (e, t, n) => {
|
|
181
|
+
if (!R(t)) return e;
|
|
182
|
+
let r = z(t);
|
|
183
|
+
if (t.respectRetryAfter === !0) return H(e, t, r, n);
|
|
184
|
+
let i = B(t), a = n ? p.tapError(e, (e) => p.sync(() => {
|
|
185
|
+
r(e) && n(e);
|
|
186
|
+
})) : e;
|
|
187
|
+
return p.retry(a, {
|
|
188
|
+
schedule: i,
|
|
189
|
+
while: r
|
|
190
|
+
});
|
|
191
|
+
}, W = Symbol.for("voltro.workflow.workerLayer"), G = Symbol.for("voltro.workflow.version"), K = "__voltroWorkflowMessages", q = "__voltroWorkflowFlowControl", J = (e) => typeof e == "object" && !!e && e[W] === !0, Y = (e) => typeof e == "object" && e && e[G] !== void 0 ? e[G] : {
|
|
192
|
+
version: "1",
|
|
193
|
+
compatibleWith: ["1"],
|
|
194
|
+
patches: []
|
|
195
|
+
}, X = ((e) => {
|
|
196
|
+
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t, r = String(e.version ?? "1"), i = {
|
|
197
|
+
version: r,
|
|
198
|
+
compatibleWith: (e.compatibleWith ?? [r]).map(String),
|
|
199
|
+
patches: [...e.patches ?? []]
|
|
200
|
+
}, a = {
|
|
201
|
+
signals: { ...e.messages?.signals ?? {} },
|
|
202
|
+
updates: { ...e.messages?.updates ?? {} },
|
|
203
|
+
queries: { ...e.messages?.queries ?? {} }
|
|
204
|
+
};
|
|
205
|
+
Object.defineProperty(n, G, {
|
|
206
|
+
value: i,
|
|
207
|
+
enumerable: !1
|
|
208
|
+
}), Object.defineProperty(n, K, {
|
|
209
|
+
value: a,
|
|
210
|
+
enumerable: !1
|
|
211
|
+
});
|
|
212
|
+
let o = D({
|
|
213
|
+
workflowName: e.name,
|
|
214
|
+
payloadSchema: e.payload,
|
|
215
|
+
control: e
|
|
216
|
+
});
|
|
217
|
+
return o !== void 0 && Object.defineProperty(n, q, {
|
|
218
|
+
value: o,
|
|
219
|
+
enumerable: !1
|
|
220
|
+
}), n;
|
|
221
|
+
}), Z = (e) => {
|
|
222
|
+
if (typeof e != "object" || !e) return;
|
|
223
|
+
let t = e[q];
|
|
224
|
+
return t === void 0 ? void 0 : t;
|
|
225
|
+
}, Q = i.make, te = i.process, ne = ((...e) => {
|
|
226
|
+
let t = i.worker(...e);
|
|
227
|
+
return Object.defineProperty(t, W, {
|
|
228
|
+
value: !0,
|
|
229
|
+
enumerable: !1
|
|
230
|
+
}), t;
|
|
231
|
+
}), re = o.rateLimit, $ = (e) => p.gen(function* () {
|
|
232
|
+
let t = yield* k, r = yield* p.serviceOption(O), i = f.toMillis(f.decode(e.duration));
|
|
233
|
+
if (t !== void 0 && r._tag === "Some") {
|
|
234
|
+
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* j;
|
|
235
|
+
yield* p.promise(() => a.recordEvent({
|
|
236
|
+
runId: t,
|
|
237
|
+
eventType: "timer-set",
|
|
238
|
+
payload: {
|
|
239
|
+
name: e.name,
|
|
240
|
+
durationMs: i,
|
|
241
|
+
scheduledWakeAt: o,
|
|
242
|
+
...s === void 0 ? {} : { tenantId: s }
|
|
243
|
+
}
|
|
244
|
+
}).catch(() => {}));
|
|
245
|
+
let c = Date.now();
|
|
246
|
+
yield* n.sleep(e), yield* p.promise(() => a.recordEvent({
|
|
247
|
+
runId: t,
|
|
248
|
+
eventType: "timer-fired",
|
|
249
|
+
payload: {
|
|
250
|
+
name: e.name,
|
|
251
|
+
actualDurationMs: Date.now() - c,
|
|
252
|
+
...s === void 0 ? {} : { tenantId: s }
|
|
253
|
+
}
|
|
254
|
+
}).catch(() => {}));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
yield* n.sleep(e);
|
|
258
|
+
}), ie = (t) => p.gen(function* () {
|
|
259
|
+
let n = (yield* e.make({
|
|
260
|
+
name: `sleepUntil:${t.name}`,
|
|
261
|
+
success: v.Number,
|
|
262
|
+
execute: p.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
|
|
263
|
+
})) - Date.now();
|
|
264
|
+
n <= 0 || (yield* $({
|
|
265
|
+
name: t.name,
|
|
266
|
+
duration: `${n} millis`
|
|
267
|
+
}));
|
|
268
|
+
}), ae = (t, n, r, i) => p.gen(function* () {
|
|
269
|
+
let a = yield* k, o = yield* e.CurrentAttempt, s = yield* p.serviceOption(O), c = yield* p.serviceOption(P), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
270
|
+
runId: a ?? "unrecorded",
|
|
271
|
+
stepName: t,
|
|
272
|
+
attempt: o
|
|
273
|
+
}) : n, d, f;
|
|
274
|
+
if (a !== void 0 && s._tag === "Some") {
|
|
275
|
+
f = s.value;
|
|
276
|
+
let e = i === void 0 ? void 0 : (({ retryable: e, ...t }) => t)(i);
|
|
277
|
+
try {
|
|
278
|
+
d = yield* p.promise(() => f.startStep({
|
|
279
|
+
runId: a,
|
|
280
|
+
stepName: t,
|
|
281
|
+
attempt: o,
|
|
282
|
+
stepInput: r,
|
|
283
|
+
...e === void 0 ? {} : { retryPolicy: e }
|
|
284
|
+
}));
|
|
285
|
+
} catch {
|
|
286
|
+
d = void 0;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
let m = Date.now();
|
|
290
|
+
return yield* U(l, i).pipe(p.tap((e) => d && f ? p.promise(async () => {
|
|
291
|
+
try {
|
|
292
|
+
await f.endStepSuccess({
|
|
293
|
+
stepRecordId: d,
|
|
294
|
+
output: e,
|
|
295
|
+
durationMs: Date.now() - m
|
|
296
|
+
});
|
|
297
|
+
} catch {}
|
|
298
|
+
}) : p.void), p.tapErrorCause((e) => d && f && !u.isInterruptedOnly(e) ? p.promise(async () => {
|
|
299
|
+
try {
|
|
300
|
+
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;
|
|
301
|
+
await f.endStepFailure({
|
|
302
|
+
stepRecordId: d,
|
|
303
|
+
errorTag: o,
|
|
304
|
+
errorMessage: a,
|
|
305
|
+
errorCause: {
|
|
306
|
+
pretty: u.pretty(e),
|
|
307
|
+
failures: n,
|
|
308
|
+
defects: r
|
|
309
|
+
},
|
|
310
|
+
durationMs: Date.now() - m
|
|
311
|
+
});
|
|
312
|
+
} catch {}
|
|
313
|
+
}) : p.void));
|
|
314
|
+
}), oe = (t) => {
|
|
315
|
+
let { input: n, retry: r, ...i } = t;
|
|
316
|
+
return e.make({
|
|
317
|
+
...i,
|
|
318
|
+
execute: ae(i.name, i.execute, n, r)
|
|
319
|
+
});
|
|
320
|
+
}, se = c.withCompensation, ce = e.idempotencyKey;
|
|
321
|
+
//#endregion
|
|
322
|
+
export { x as A, A as C, P as D, O as E, D as F, S as M, b as N, N as O, y as P, l as S, j as T, oe as _, r as a, se as b, s as c, J as d, te as f, ie as g, $ as h, W as i, ee as j, M as k, Z as l, re as m, K as n, Q as o, ne as p, G as r, a as s, q as t, Y as u, ce as v, k as w, X as x, t as y };
|