@voltro/workflow 0.62.3 → 0.64.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 +104 -0
- package/dist/clusterTestSuite.js +2 -2
- package/dist/index.d.ts +11 -1
- package/dist/index.js +2 -2
- package/dist/{primitives-B-HlFCap.js → primitives-CqHxfASq.js} +92 -91
- package/dist/primitives.d.ts +2 -1
- package/dist/primitives.js +1 -1
- package/dist/{src-CJ56XxpW.js → src-Dj8r1Kcn.js} +228 -217
- package/package.json +4 -4
|
@@ -1,16 +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 } from "@effect/workflow";
|
|
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
|
|
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 _, Schedule as v, Schema as y } from "effect";
|
|
3
|
+
import { attachWorkflowAccess as te, resolveWorkflowAccess as ne } from "@voltro/protocol";
|
|
3
4
|
//#region src/flowControl.ts
|
|
4
|
-
var
|
|
5
|
+
var b = (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), x = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, re = [
|
|
5
6
|
"debounce",
|
|
6
7
|
"batch",
|
|
7
8
|
"throttle",
|
|
8
9
|
"concurrency"
|
|
9
|
-
],
|
|
10
|
+
], S = (e) => {
|
|
10
11
|
if (e === void 0) return [];
|
|
11
12
|
let t = [];
|
|
12
13
|
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
|
-
},
|
|
14
|
+
}, C = (e, t, n) => {
|
|
14
15
|
let r;
|
|
15
16
|
try {
|
|
16
17
|
r = p.toMillis(p.decode(e));
|
|
@@ -19,26 +20,26 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
19
20
|
}
|
|
20
21
|
if (!Number.isFinite(r) || r <= 0) throw Error(`workflow '${n}': ${t} must be a positive finite duration, got ${String(e)}`);
|
|
21
22
|
return r;
|
|
22
|
-
},
|
|
23
|
+
}, w = (e, t, n) => {
|
|
23
24
|
if (!Number.isInteger(e) || e <= 0) throw Error(`workflow '${n}': ${t} must be a positive integer, got ${String(e)}`);
|
|
24
25
|
return e;
|
|
25
|
-
},
|
|
26
|
+
}, T = (e, t, n) => {
|
|
26
27
|
if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
|
|
27
28
|
return e;
|
|
28
|
-
},
|
|
29
|
+
}, E = (e) => {
|
|
29
30
|
let t = e?.ast?.propertySignatures;
|
|
30
31
|
if (!Array.isArray(t)) return !1;
|
|
31
32
|
let n = t.find((e) => e.name === "items");
|
|
32
33
|
return n !== void 0 && n.type?._tag === "TupleType";
|
|
33
|
-
},
|
|
34
|
+
}, D = (e) => {
|
|
34
35
|
let { workflowName: t, control: n } = e;
|
|
35
36
|
if (n === void 0) return;
|
|
36
37
|
let r = { workflowName: t };
|
|
37
38
|
if (n.debounce !== void 0) {
|
|
38
|
-
let e = n.debounce, i =
|
|
39
|
+
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
40
|
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
41
|
r.debounce = {
|
|
41
|
-
key:
|
|
42
|
+
key: T(e.key, "debounce.key", t),
|
|
42
43
|
periodMs: i,
|
|
43
44
|
...a === void 0 ? {} : { timeoutMs: a }
|
|
44
45
|
};
|
|
@@ -47,7 +48,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
47
48
|
let e = n.singleton;
|
|
48
49
|
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
50
|
r.singleton = {
|
|
50
|
-
key:
|
|
51
|
+
key: T(e.key, "singleton.key", t),
|
|
51
52
|
mode: e.mode
|
|
52
53
|
};
|
|
53
54
|
}
|
|
@@ -55,34 +56,34 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
55
56
|
let e = n.concurrency;
|
|
56
57
|
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
58
|
r.concurrency = {
|
|
58
|
-
limit:
|
|
59
|
-
...e.key === void 0 ? {} : { key:
|
|
59
|
+
limit: w(e.limit, "concurrency.limit", t),
|
|
60
|
+
...e.key === void 0 ? {} : { key: T(e.key, "concurrency.key", t) },
|
|
60
61
|
...e.pool === void 0 ? {} : { pool: e.pool.trim() }
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
if (n.throttle !== void 0) {
|
|
64
65
|
let e = n.throttle;
|
|
65
66
|
r.throttle = {
|
|
66
|
-
limit:
|
|
67
|
-
periodMs:
|
|
68
|
-
...e.key === void 0 ? {} : { key:
|
|
67
|
+
limit: w(e.limit, "throttle.limit", t),
|
|
68
|
+
periodMs: C(e.period, "throttle.period", t),
|
|
69
|
+
...e.key === void 0 ? {} : { key: T(e.key, "throttle.key", t) }
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
if (n.rateLimit !== void 0) {
|
|
72
73
|
let e = n.rateLimit;
|
|
73
74
|
r.rateLimit = {
|
|
74
|
-
limit:
|
|
75
|
-
periodMs:
|
|
76
|
-
...e.key === void 0 ? {} : { key:
|
|
75
|
+
limit: w(e.limit, "rateLimit.limit", t),
|
|
76
|
+
periodMs: C(e.period, "rateLimit.period", t),
|
|
77
|
+
...e.key === void 0 ? {} : { key: T(e.key, "rateLimit.key", t) }
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
if (n.batch !== void 0) {
|
|
80
81
|
let i = n.batch;
|
|
81
|
-
if (e.payloadSchema !== void 0 && !
|
|
82
|
+
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
83
|
r.batch = {
|
|
83
|
-
...i.key === void 0 ? {} : { key:
|
|
84
|
-
maxSize:
|
|
85
|
-
timeoutMs:
|
|
84
|
+
...i.key === void 0 ? {} : { key: T(i.key, "batch.key", t) },
|
|
85
|
+
maxSize: w(i.maxSize, "batch.maxSize", t),
|
|
86
|
+
timeoutMs: C(i.timeout, "batch.timeout", t),
|
|
86
87
|
...i.item === void 0 ? {} : { item: i.item }
|
|
87
88
|
};
|
|
88
89
|
}
|
|
@@ -91,7 +92,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
91
92
|
r.priority = n.priority;
|
|
92
93
|
}
|
|
93
94
|
if (n.timeouts !== void 0) {
|
|
94
|
-
let e = n.timeouts, i = e.start === void 0 ? void 0 :
|
|
95
|
+
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);
|
|
95
96
|
(i !== void 0 || a !== void 0) && (r.timeouts = {
|
|
96
97
|
...i === void 0 ? {} : { startMs: i },
|
|
97
98
|
...a === void 0 ? {} : { finishMs: a }
|
|
@@ -111,7 +112,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
111
112
|
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
113
|
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
114
|
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 :
|
|
115
|
+
let i = e.within === void 0 ? void 0 : C(e.within, `${r}.within`, t);
|
|
115
116
|
return {
|
|
116
117
|
event: e.event,
|
|
117
118
|
schema: e.schema,
|
|
@@ -122,9 +123,9 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
122
123
|
});
|
|
123
124
|
e.length > 0 && (r.cancelOn = e);
|
|
124
125
|
}
|
|
125
|
-
if (r.timeouts?.startMs !== void 0 &&
|
|
126
|
+
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.`);
|
|
126
127
|
return r;
|
|
127
|
-
},
|
|
128
|
+
}, O = (e) => {
|
|
128
129
|
let t = /* @__PURE__ */ new Map();
|
|
129
130
|
for (let n of e) {
|
|
130
131
|
let e = n?.concurrency;
|
|
@@ -137,25 +138,25 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
137
138
|
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
139
|
else r.workflows.push(n.workflowName);
|
|
139
140
|
}
|
|
140
|
-
},
|
|
141
|
+
}, k = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, A = g.unsafeMake(void 0), j = g.unsafeMake(void 0), M = g.unsafeMake(void 0), N = g.unsafeMake([]), P = () => g.get(A), ie = () => g.get(j), F = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, I = 864e5, ae = /* @__PURE__ */ new Set([
|
|
141
142
|
"skip",
|
|
142
143
|
"buffer",
|
|
143
144
|
"cancelOther"
|
|
144
|
-
]),
|
|
145
|
+
]), L = /* @__PURE__ */ new Set([
|
|
145
146
|
"skip",
|
|
146
147
|
"latest",
|
|
147
148
|
"all"
|
|
148
|
-
]),
|
|
149
|
+
]), R = (e, t) => {
|
|
149
150
|
if (t === void 0) return;
|
|
150
151
|
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
152
|
let n = f.parse(t.cron, t.timezone);
|
|
152
153
|
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
154
|
let r = t.onOverlap ?? "skip";
|
|
154
|
-
if (!
|
|
155
|
+
if (!ae.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
|
|
155
156
|
let i = t.backfill ?? "skip";
|
|
156
|
-
if (!
|
|
157
|
-
let a =
|
|
158
|
-
return t.maxRuntime !== void 0 && (a =
|
|
157
|
+
if (!L.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
|
|
158
|
+
let a = I;
|
|
159
|
+
return t.maxRuntime !== void 0 && (a = z(t.maxRuntime, e)), {
|
|
159
160
|
cron: t.cron,
|
|
160
161
|
timezone: t.timezone,
|
|
161
162
|
...t.payload === void 0 ? {} : { payload: t.payload },
|
|
@@ -163,7 +164,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
163
164
|
backfill: i,
|
|
164
165
|
maxRuntimeMs: a
|
|
165
166
|
};
|
|
166
|
-
},
|
|
167
|
+
}, z = (e, t) => {
|
|
167
168
|
let n;
|
|
168
169
|
try {
|
|
169
170
|
n = p.toMillis(p.decode(e));
|
|
@@ -172,11 +173,11 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
172
173
|
}
|
|
173
174
|
if (!Number.isFinite(n) || n <= 0) throw Error(`workflow '${t}': schedule.maxRuntime must be a positive finite duration`);
|
|
174
175
|
return n;
|
|
175
|
-
},
|
|
176
|
+
}, B = "__voltroWorkflowSchedule", V = (e) => {
|
|
176
177
|
if (typeof e != "object" || !e) return;
|
|
177
|
-
let t = e[
|
|
178
|
+
let t = e[B];
|
|
178
179
|
return t === void 0 ? void 0 : t;
|
|
179
|
-
},
|
|
180
|
+
}, H = (e) => {
|
|
180
181
|
let t = /* @__PURE__ */ new Map();
|
|
181
182
|
for (let n of e) t.set(n.stepName, (t.get(n.stepName) ?? 0) + 1);
|
|
182
183
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => !r.has(e) && (r.add(e), !0);
|
|
@@ -205,79 +206,79 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
205
206
|
return e;
|
|
206
207
|
}
|
|
207
208
|
};
|
|
208
|
-
},
|
|
209
|
+
}, U = g.unsafeMake(void 0), W = (e) => ({
|
|
209
210
|
kind: e.kind,
|
|
210
211
|
stepName: e.stepName,
|
|
211
212
|
recorded: e.recorded,
|
|
212
213
|
reached: e.reached,
|
|
213
214
|
detail: e.detail
|
|
214
|
-
}),
|
|
215
|
+
}), G = (e) => m.gen(function* () {
|
|
215
216
|
if (e.length === 0) return;
|
|
216
|
-
let t = yield* g.get(
|
|
217
|
+
let t = yield* g.get(A), n = yield* m.serviceOption(k);
|
|
217
218
|
if (t === void 0 || n._tag !== "Some") return;
|
|
218
219
|
let r = n.value;
|
|
219
220
|
for (let n of e) yield* m.promise(() => r.recordEvent({
|
|
220
221
|
runId: t,
|
|
221
222
|
eventType: "nondeterminism-suspected",
|
|
222
|
-
payload:
|
|
223
|
+
payload: W(n)
|
|
223
224
|
}).then(() => void 0).catch(() => void 0));
|
|
224
|
-
}),
|
|
225
|
+
}), K = (e) => {
|
|
225
226
|
if (typeof e != "object" || !e) return;
|
|
226
227
|
let t = e.retryAfterMillis;
|
|
227
228
|
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return p.millis(t);
|
|
228
229
|
let n = e.retryAfter;
|
|
229
230
|
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return p.seconds(n);
|
|
230
|
-
},
|
|
231
|
+
}, q = (e) => p.decode(e), J = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, oe = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, se = (e) => {
|
|
231
232
|
if (e.retryable) return e.retryable;
|
|
232
233
|
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
233
234
|
let t = new Set(e.retryableErrors);
|
|
234
235
|
return (e) => {
|
|
235
|
-
let n =
|
|
236
|
+
let n = J(e);
|
|
236
237
|
return n !== void 0 && t.has(n);
|
|
237
238
|
};
|
|
238
239
|
}
|
|
239
240
|
return () => !0;
|
|
240
|
-
},
|
|
241
|
-
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ?
|
|
241
|
+
}, ce = (e) => {
|
|
242
|
+
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? v.linear(q(e.step ?? t)) : n === "fixed" ? v.spaced(q(t)) : v.exponential(q(t), e.factor ?? 2);
|
|
242
243
|
if (e.maxDelay !== void 0) {
|
|
243
|
-
let t =
|
|
244
|
-
i =
|
|
244
|
+
let t = q(e.maxDelay);
|
|
245
|
+
i = v.modifyDelay(i, (e, n) => p.min(n, t));
|
|
245
246
|
}
|
|
246
|
-
(e.jitter ?? !0) === !0 && (i =
|
|
247
|
-
let a =
|
|
248
|
-
return e.maxElapsed !== void 0 && (a =
|
|
249
|
-
},
|
|
250
|
-
let n = p.toMillis(
|
|
251
|
-
return e.maxDelay !== void 0 && (i = Math.min(i, p.toMillis(
|
|
252
|
-
},
|
|
253
|
-
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : p.toMillis(
|
|
247
|
+
(e.jitter ?? !0) === !0 && (i = v.jittered(i));
|
|
248
|
+
let a = v.intersect(i, v.recurs(Math.max(0, r - 1)));
|
|
249
|
+
return e.maxElapsed !== void 0 && (a = v.upTo(q(e.maxElapsed))(a)), a;
|
|
250
|
+
}, le = (e, t) => {
|
|
251
|
+
let n = p.toMillis(q(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + p.toMillis(q(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
252
|
+
return e.maxDelay !== void 0 && (i = Math.min(i, p.toMillis(q(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
253
|
+
}, ue = (e, t, n, r) => m.gen(function* () {
|
|
254
|
+
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : p.toMillis(q(t.maxElapsed)), o = yield* m.sync(() => Date.now()), s = 0;
|
|
254
255
|
for (;;) {
|
|
255
256
|
let c = yield* m.exit(e);
|
|
256
257
|
if (ee.isSuccess(c)) return c.value;
|
|
257
|
-
let l = c.cause, d = u.failureOption(l), f =
|
|
258
|
+
let l = c.cause, d = u.failureOption(l), f = _.isSome(d) ? d.value : u.squash(l);
|
|
258
259
|
s += 1;
|
|
259
260
|
let h = (yield* m.sync(() => Date.now())) - o;
|
|
260
261
|
if (s >= i || !n(f) || h >= a) return yield* m.failCause(l);
|
|
261
262
|
r?.(f);
|
|
262
|
-
let g =
|
|
263
|
-
yield* m.sleep(p.millis(
|
|
263
|
+
let g = K(f), v = g === void 0 ? le(t, s) : p.toMillis(g);
|
|
264
|
+
yield* m.sleep(p.millis(v));
|
|
264
265
|
}
|
|
265
|
-
}),
|
|
266
|
-
if (!
|
|
267
|
-
let r =
|
|
268
|
-
if (t.respectRetryAfter === !0) return
|
|
269
|
-
let i =
|
|
266
|
+
}), de = (e, t, n) => {
|
|
267
|
+
if (!oe(t)) return e;
|
|
268
|
+
let r = se(t);
|
|
269
|
+
if (t.respectRetryAfter === !0) return ue(e, t, r, n);
|
|
270
|
+
let i = ce(t), a = n ? m.tapError(e, (e) => m.sync(() => {
|
|
270
271
|
r(e) && n(e);
|
|
271
272
|
})) : e;
|
|
272
273
|
return m.retry(a, {
|
|
273
274
|
schedule: i,
|
|
274
275
|
while: r
|
|
275
276
|
});
|
|
276
|
-
}, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl",
|
|
277
|
+
}, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl", fe = (e) => typeof e == "object" && !!e && e[Y] === !0, pe = (e) => typeof e == "object" && e && e[X] !== void 0 ? e[X] : {
|
|
277
278
|
version: "1",
|
|
278
279
|
compatibleWith: ["1"],
|
|
279
280
|
patches: []
|
|
280
|
-
},
|
|
281
|
+
}, me = ((e) => {
|
|
281
282
|
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t, r = String(e.version ?? "1"), i = {
|
|
282
283
|
version: r,
|
|
283
284
|
compatibleWith: (e.compatibleWith ?? [r]).map(String),
|
|
@@ -292,8 +293,8 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
292
293
|
}), Object.defineProperty(n, Z, {
|
|
293
294
|
value: a,
|
|
294
295
|
enumerable: !1
|
|
295
|
-
});
|
|
296
|
-
let o =
|
|
296
|
+
}), te(n, ne(e.name, e));
|
|
297
|
+
let o = D({
|
|
297
298
|
workflowName: e.name,
|
|
298
299
|
payloadSchema: e.payload,
|
|
299
300
|
control: e
|
|
@@ -302,25 +303,25 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
302
303
|
value: o,
|
|
303
304
|
enumerable: !1
|
|
304
305
|
});
|
|
305
|
-
let s =
|
|
306
|
-
return s !== void 0 && Object.defineProperty(n,
|
|
306
|
+
let s = R(e.name, e.schedule);
|
|
307
|
+
return s !== void 0 && Object.defineProperty(n, B, {
|
|
307
308
|
value: s,
|
|
308
309
|
enumerable: !1
|
|
309
310
|
}), n;
|
|
310
|
-
}),
|
|
311
|
+
}), he = (e) => {
|
|
311
312
|
if (typeof e != "object" || !e) return;
|
|
312
313
|
let t = e[Q];
|
|
313
314
|
return t === void 0 ? void 0 : t;
|
|
314
|
-
},
|
|
315
|
+
}, ge = i.make, _e = i.process, ve = ((...e) => {
|
|
315
316
|
let t = i.worker(...e);
|
|
316
317
|
return Object.defineProperty(t, Y, {
|
|
317
318
|
value: !0,
|
|
318
319
|
enumerable: !1
|
|
319
320
|
}), t;
|
|
320
|
-
}),
|
|
321
|
-
let t = yield*
|
|
321
|
+
}), ye = o.rateLimit, $ = (e) => m.gen(function* () {
|
|
322
|
+
let t = yield* A, r = yield* m.serviceOption(k), i = p.toMillis(p.decode(e.duration));
|
|
322
323
|
if (t !== void 0 && r._tag === "Some") {
|
|
323
|
-
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield*
|
|
324
|
+
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* M;
|
|
324
325
|
yield* m.promise(() => a.recordEvent({
|
|
325
326
|
runId: t,
|
|
326
327
|
eventType: "timer-set",
|
|
@@ -344,18 +345,18 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
344
345
|
return;
|
|
345
346
|
}
|
|
346
347
|
yield* n.sleep(e);
|
|
347
|
-
}),
|
|
348
|
+
}), be = (t) => m.gen(function* () {
|
|
348
349
|
let n = (yield* e.make({
|
|
349
350
|
name: `sleepUntil:${t.name}`,
|
|
350
|
-
success:
|
|
351
|
+
success: y.Number,
|
|
351
352
|
execute: m.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
|
|
352
353
|
})) - Date.now();
|
|
353
354
|
n <= 0 || (yield* $({
|
|
354
355
|
name: t.name,
|
|
355
356
|
duration: `${n} millis`
|
|
356
357
|
}));
|
|
357
|
-
}),
|
|
358
|
-
let a = yield*
|
|
358
|
+
}), xe = (t, n, r, i) => m.gen(function* () {
|
|
359
|
+
let a = yield* A, o = yield* e.CurrentAttempt, s = yield* m.serviceOption(k), c = yield* m.serviceOption(F), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
359
360
|
runId: a ?? "unrecorded",
|
|
360
361
|
stepName: t,
|
|
361
362
|
attempt: o
|
|
@@ -376,7 +377,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
379
|
let p = Date.now();
|
|
379
|
-
return yield*
|
|
380
|
+
return yield* de(l, i).pipe(m.tap((e) => d && f ? m.promise(async () => {
|
|
380
381
|
try {
|
|
381
382
|
await f.endStepSuccess({
|
|
382
383
|
stepRecordId: d,
|
|
@@ -400,23 +401,23 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
|
|
|
400
401
|
});
|
|
401
402
|
} catch {}
|
|
402
403
|
}) : m.void));
|
|
403
|
-
}),
|
|
404
|
-
let t = yield* g.get(
|
|
404
|
+
}), Se = (e) => m.gen(function* () {
|
|
405
|
+
let t = yield* g.get(U);
|
|
405
406
|
if (t === void 0) return;
|
|
406
407
|
let n = t.reach(e);
|
|
407
|
-
n !== void 0 && (yield*
|
|
408
|
-
}),
|
|
408
|
+
n !== void 0 && (yield* G([n]));
|
|
409
|
+
}), Ce = (e, t) => {
|
|
409
410
|
let n = e;
|
|
410
411
|
return {
|
|
411
412
|
...e,
|
|
412
|
-
commit: () => m.zipRight(
|
|
413
|
+
commit: () => m.zipRight(Se(t), n)
|
|
413
414
|
};
|
|
414
|
-
},
|
|
415
|
+
}, we = (t) => {
|
|
415
416
|
let { input: n, retry: r, ...i } = t;
|
|
416
|
-
return
|
|
417
|
+
return Ce(e.make({
|
|
417
418
|
...i,
|
|
418
|
-
execute:
|
|
419
|
+
execute: xe(i.name, i.execute, n, r)
|
|
419
420
|
}), i.name);
|
|
420
|
-
},
|
|
421
|
+
}, Te = (e) => m.map(g.get(N), (t) => t.includes(e)), Ee = c.withCompensation, De = e.idempotencyKey;
|
|
421
422
|
//#endregion
|
|
422
|
-
export {
|
|
423
|
+
export { V as A, re as B, l as C, G as D, W as E, M as F, D as G, S as H, k as I, F as L, j as M, N, I as O, A as P, ie as R, me as S, H as T, x as U, O as V, b as W, be as _, r as a, t as b, s as c, fe as d, Te as f, $ as g, ye as h, Y as i, R as j, B as k, he as l, ve as m, Z as n, ge as o, _e as p, X as r, a as s, Q as t, pe as u, we as v, U as w, Ee as x, De as y, P as z };
|
package/dist/primitives.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Effect } from 'effect';
|
|
|
6
6
|
import { FiberRef } from 'effect';
|
|
7
7
|
import { Schema } from 'effect';
|
|
8
8
|
import { Activity as stepModule } from '@effect/workflow';
|
|
9
|
+
import { WorkflowAccessOptions } from '@voltro/protocol';
|
|
9
10
|
import { Workflow as workflowModule } from '@effect/workflow';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -881,7 +882,7 @@ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPa
|
|
|
881
882
|
readonly schedule?: WorkflowScheduleDeclaration<DecodedPayload<Payload>>;
|
|
882
883
|
} & Omit<WorkflowBaseOptions, 'name' | 'payload' | 'idempotencyKey' | 'success' | 'error'> & WorkflowVersionOptions & {
|
|
883
884
|
readonly messages?: Messages;
|
|
884
|
-
} & WorkflowFlowControl<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
|
|
885
|
+
} & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
|
|
885
886
|
|
|
886
887
|
declare type WorkflowMake = typeof workflowModule.make;
|
|
887
888
|
|
package/dist/primitives.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i, G as a, H 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-
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, G as a, H 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-CqHxfASq.js";
|
|
2
2
|
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, t as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, E as WorkflowMessagesProperty, C as WorkflowScheduleProperty, k as WorkflowVersionTypeId, x as WorkflowWorkerLayerTypeId, d as assertConsistentPools, o as deferringControlsOf, m as durableClock, D as durableQueue, A as durableQueueModule, g as durableRateLimiterModule, w as getWorkflowFlowControl, e as getWorkflowSchedule, M as getWorkflowVersionMetadata, u as hasCancelOn, f as hasFlowControl, _ as isWorkflowWorkerLayer, l as makeReplayShapeTracker, i as nondeterminismEventPayload, v as patch, O as processQueue, T as queueWorker, b as rateLimit, r as reportNondeterminism, y as sleep, p as sleepUntil, N as step, I as stepIdempotencyKey, h as stepModule, a as validateFlowControl, S as validateWorkflowSchedule, F as withCompensation, c as workflow, n as workflowModule };
|