@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Durable workflows for Voltro — the workflow() descriptor + step() / awaitSignal primitives over @effect/cluster, with a browser-safe define subpath.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@effect/cluster": "^0.60.0",
|
|
51
51
|
"@effect/sql": "^0.52.0",
|
|
52
52
|
"@effect/workflow": "^0.19.0",
|
|
53
|
-
"@voltro/database": "0.
|
|
54
|
-
"@voltro/protocol": "0.
|
|
53
|
+
"@voltro/database": "0.30.0",
|
|
54
|
+
"@voltro/protocol": "0.30.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"effect": "^3.22.0",
|
|
@@ -1,164 +0,0 @@
|
|
|
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 _ } from "effect";
|
|
3
|
-
//#region src/recorder.ts
|
|
4
|
-
var v = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, y = h.unsafeMake(void 0), b = h.unsafeMake(void 0), x = h.unsafeMake(void 0), S = () => h.get(y), C = () => h.get(b), w = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, T = (e) => {
|
|
5
|
-
if (typeof e != "object" || !e) return;
|
|
6
|
-
let t = e.retryAfterMillis;
|
|
7
|
-
if (typeof t == "number" && Number.isFinite(t) && t >= 0) return f.millis(t);
|
|
8
|
-
let n = e.retryAfter;
|
|
9
|
-
if (typeof n == "number" && Number.isFinite(n) && n >= 0) return f.seconds(n);
|
|
10
|
-
}, E = (e) => f.decode(e), D = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, O = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, k = (e) => {
|
|
11
|
-
if (e.retryable) return e.retryable;
|
|
12
|
-
if (e.retryableErrors && e.retryableErrors.length > 0) {
|
|
13
|
-
let t = new Set(e.retryableErrors);
|
|
14
|
-
return (e) => {
|
|
15
|
-
let n = D(e);
|
|
16
|
-
return n !== void 0 && t.has(n);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return () => !0;
|
|
20
|
-
}, A = (e) => {
|
|
21
|
-
let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? _.linear(E(e.step ?? t)) : n === "fixed" ? _.spaced(E(t)) : _.exponential(E(t), e.factor ?? 2);
|
|
22
|
-
if (e.maxDelay !== void 0) {
|
|
23
|
-
let t = E(e.maxDelay);
|
|
24
|
-
i = _.modifyDelay(i, (e, n) => f.min(n, t));
|
|
25
|
-
}
|
|
26
|
-
(e.jitter ?? !0) === !0 && (i = _.jittered(i));
|
|
27
|
-
let a = _.intersect(i, _.recurs(Math.max(0, r - 1)));
|
|
28
|
-
return e.maxElapsed !== void 0 && (a = _.upTo(E(e.maxElapsed))(a)), a;
|
|
29
|
-
}, j = (e, t) => {
|
|
30
|
-
let n = f.toMillis(E(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + f.toMillis(E(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
|
|
31
|
-
return e.maxDelay !== void 0 && (i = Math.min(i, f.toMillis(E(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
|
|
32
|
-
}, M = (e, t, n, r) => p.gen(function* () {
|
|
33
|
-
let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : f.toMillis(E(t.maxElapsed)), o = yield* p.sync(() => Date.now()), s = 0;
|
|
34
|
-
for (;;) {
|
|
35
|
-
let c = yield* p.exit(e);
|
|
36
|
-
if (m.isSuccess(c)) return c.value;
|
|
37
|
-
let l = c.cause, d = u.failureOption(l), h = g.isSome(d) ? d.value : u.squash(l);
|
|
38
|
-
s += 1;
|
|
39
|
-
let _ = (yield* p.sync(() => Date.now())) - o;
|
|
40
|
-
if (s >= i || !n(h) || _ >= a) return yield* p.failCause(l);
|
|
41
|
-
r?.(h);
|
|
42
|
-
let v = T(h), y = v === void 0 ? j(t, s) : f.toMillis(v);
|
|
43
|
-
yield* p.sleep(f.millis(y));
|
|
44
|
-
}
|
|
45
|
-
}), N = (e, t, n) => {
|
|
46
|
-
if (!O(t)) return e;
|
|
47
|
-
let r = k(t);
|
|
48
|
-
if (t.respectRetryAfter === !0) return M(e, t, r, n);
|
|
49
|
-
let i = A(t), a = n ? p.tapError(e, (e) => p.sync(() => {
|
|
50
|
-
r(e) && n(e);
|
|
51
|
-
})) : e;
|
|
52
|
-
return p.retry(a, {
|
|
53
|
-
schedule: i,
|
|
54
|
-
while: r
|
|
55
|
-
});
|
|
56
|
-
}, P = Symbol.for("voltro.workflow.workerLayer"), F = Symbol.for("voltro.workflow.version"), I = "__voltroWorkflowMessages", L = (e) => typeof e == "object" && !!e && e[P] === !0, R = (e) => typeof e == "object" && e && e[F] !== void 0 ? e[F] : {
|
|
57
|
-
version: "1",
|
|
58
|
-
compatibleWith: ["1"],
|
|
59
|
-
patches: []
|
|
60
|
-
}, z = ((e) => {
|
|
61
|
-
let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t, r = String(e.version ?? "1"), i = {
|
|
62
|
-
version: r,
|
|
63
|
-
compatibleWith: (e.compatibleWith ?? [r]).map(String),
|
|
64
|
-
patches: [...e.patches ?? []]
|
|
65
|
-
}, a = {
|
|
66
|
-
signals: { ...e.messages?.signals ?? {} },
|
|
67
|
-
updates: { ...e.messages?.updates ?? {} },
|
|
68
|
-
queries: { ...e.messages?.queries ?? {} }
|
|
69
|
-
};
|
|
70
|
-
return Object.defineProperty(n, F, {
|
|
71
|
-
value: i,
|
|
72
|
-
enumerable: !1
|
|
73
|
-
}), Object.defineProperty(n, I, {
|
|
74
|
-
value: a,
|
|
75
|
-
enumerable: !1
|
|
76
|
-
}), n;
|
|
77
|
-
}), B = i.make, V = i.process, H = ((...e) => {
|
|
78
|
-
let t = i.worker(...e);
|
|
79
|
-
return Object.defineProperty(t, P, {
|
|
80
|
-
value: !0,
|
|
81
|
-
enumerable: !1
|
|
82
|
-
}), t;
|
|
83
|
-
}), U = o.rateLimit, W = (e) => p.gen(function* () {
|
|
84
|
-
let t = yield* y, r = yield* p.serviceOption(v), i = f.toMillis(f.decode(e.duration));
|
|
85
|
-
if (t !== void 0 && r._tag === "Some") {
|
|
86
|
-
let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* x;
|
|
87
|
-
yield* p.promise(() => a.recordEvent({
|
|
88
|
-
runId: t,
|
|
89
|
-
eventType: "timer-set",
|
|
90
|
-
payload: {
|
|
91
|
-
name: e.name,
|
|
92
|
-
durationMs: i,
|
|
93
|
-
scheduledWakeAt: o,
|
|
94
|
-
...s === void 0 ? {} : { tenantId: s }
|
|
95
|
-
}
|
|
96
|
-
}).catch(() => {}));
|
|
97
|
-
let c = Date.now();
|
|
98
|
-
yield* n.sleep(e), yield* p.promise(() => a.recordEvent({
|
|
99
|
-
runId: t,
|
|
100
|
-
eventType: "timer-fired",
|
|
101
|
-
payload: {
|
|
102
|
-
name: e.name,
|
|
103
|
-
actualDurationMs: Date.now() - c,
|
|
104
|
-
...s === void 0 ? {} : { tenantId: s }
|
|
105
|
-
}
|
|
106
|
-
}).catch(() => {}));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
yield* n.sleep(e);
|
|
110
|
-
}), G = (t, n, r, i) => p.gen(function* () {
|
|
111
|
-
let a = yield* y, o = yield* e.CurrentAttempt, s = yield* p.serviceOption(v), c = yield* p.serviceOption(w), l = c._tag === "Some" ? c.value.interceptor(n, {
|
|
112
|
-
runId: a ?? "unrecorded",
|
|
113
|
-
stepName: t,
|
|
114
|
-
attempt: o
|
|
115
|
-
}) : n, d, f;
|
|
116
|
-
if (a !== void 0 && s._tag === "Some") {
|
|
117
|
-
f = s.value;
|
|
118
|
-
let e = i === void 0 ? void 0 : (({ retryable: e, ...t }) => t)(i);
|
|
119
|
-
try {
|
|
120
|
-
d = yield* p.promise(() => f.startStep({
|
|
121
|
-
runId: a,
|
|
122
|
-
stepName: t,
|
|
123
|
-
attempt: o,
|
|
124
|
-
stepInput: r,
|
|
125
|
-
...e === void 0 ? {} : { retryPolicy: e }
|
|
126
|
-
}));
|
|
127
|
-
} catch {
|
|
128
|
-
d = void 0;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
let m = Date.now();
|
|
132
|
-
return yield* N(l, i).pipe(p.tap((e) => d && f ? p.promise(async () => {
|
|
133
|
-
try {
|
|
134
|
-
await f.endStepSuccess({
|
|
135
|
-
stepRecordId: d,
|
|
136
|
-
output: e,
|
|
137
|
-
durationMs: Date.now() - m
|
|
138
|
-
});
|
|
139
|
-
} catch {}
|
|
140
|
-
}) : p.void), p.tapErrorCause((e) => d && f && !u.isInterruptedOnly(e) ? p.promise(async () => {
|
|
141
|
-
try {
|
|
142
|
-
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;
|
|
143
|
-
await f.endStepFailure({
|
|
144
|
-
stepRecordId: d,
|
|
145
|
-
errorTag: o,
|
|
146
|
-
errorMessage: a,
|
|
147
|
-
errorCause: {
|
|
148
|
-
pretty: u.pretty(e),
|
|
149
|
-
failures: n,
|
|
150
|
-
defects: r
|
|
151
|
-
},
|
|
152
|
-
durationMs: Date.now() - m
|
|
153
|
-
});
|
|
154
|
-
} catch {}
|
|
155
|
-
}) : p.void));
|
|
156
|
-
}), K = (t) => {
|
|
157
|
-
let { input: n, retry: r, ...i } = t;
|
|
158
|
-
return e.make({
|
|
159
|
-
...i,
|
|
160
|
-
execute: G(i.name, i.execute, n, r)
|
|
161
|
-
});
|
|
162
|
-
}, q = c.withCompensation, J = e.idempotencyKey;
|
|
163
|
-
//#endregion
|
|
164
|
-
export { v as C, S as E, x as S, C as T, q as _, B as a, b, R as c, H as d, U as f, t as g, J as h, r as i, L as l, K as m, F as n, a as o, W as p, P as r, s, I as t, V as u, z as v, w, y as x, l as y };
|