@voltro/workflow 0.24.0 → 0.26.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.
@@ -1,111 +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, FiberRef as m } from "effect";
3
- //#region src/recorder.ts
4
- var h = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, g = m.unsafeMake(void 0), _ = m.unsafeMake(void 0), v = m.unsafeMake(void 0), y = () => m.get(g), b = () => m.get(_), x = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, S = Symbol.for("voltro.workflow.workerLayer"), C = Symbol.for("voltro.workflow.version"), w = "__voltroWorkflowMessages", T = (e) => typeof e == "object" && !!e && e[S] === !0, E = (e) => typeof e == "object" && e && e[C] !== void 0 ? e[C] : {
5
- version: "1",
6
- compatibleWith: ["1"],
7
- patches: []
8
- }, D = ((e) => {
9
- let t = c.make(e), n = String(e.version ?? "1"), r = {
10
- version: n,
11
- compatibleWith: (e.compatibleWith ?? [n]).map(String),
12
- patches: [...e.patches ?? []]
13
- }, i = {
14
- signals: { ...e.messages?.signals ?? {} },
15
- updates: { ...e.messages?.updates ?? {} },
16
- queries: { ...e.messages?.queries ?? {} }
17
- };
18
- return Object.defineProperty(t, C, {
19
- value: r,
20
- enumerable: !1
21
- }), Object.defineProperty(t, w, {
22
- value: i,
23
- enumerable: !1
24
- }), t;
25
- }), O = i.make, k = i.process, A = ((...e) => {
26
- let t = i.worker(...e);
27
- return Object.defineProperty(t, S, {
28
- value: !0,
29
- enumerable: !1
30
- }), t;
31
- }), j = o.rateLimit, M = (e) => p.gen(function* () {
32
- let t = yield* g, r = yield* p.serviceOption(h), i = f.toMillis(f.decode(e.duration));
33
- if (t !== void 0 && r._tag === "Some") {
34
- let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* v;
35
- yield* p.promise(() => a.recordEvent({
36
- runId: t,
37
- eventType: "timer-set",
38
- payload: {
39
- name: e.name,
40
- durationMs: i,
41
- scheduledWakeAt: o,
42
- ...s === void 0 ? {} : { tenantId: s }
43
- }
44
- }).catch(() => {}));
45
- let c = Date.now();
46
- yield* n.sleep(e), yield* p.promise(() => a.recordEvent({
47
- runId: t,
48
- eventType: "timer-fired",
49
- payload: {
50
- name: e.name,
51
- actualDurationMs: Date.now() - c,
52
- ...s === void 0 ? {} : { tenantId: s }
53
- }
54
- }).catch(() => {}));
55
- return;
56
- }
57
- yield* n.sleep(e);
58
- }), N = (t, n, r, i) => p.gen(function* () {
59
- let a = yield* g, o = yield* e.CurrentAttempt, s = yield* p.serviceOption(h), c = yield* p.serviceOption(x), l = c._tag === "Some" ? c.value.interceptor(n, {
60
- runId: a ?? "unrecorded",
61
- stepName: t,
62
- attempt: o
63
- }) : n, d, f;
64
- if (a !== void 0 && s._tag === "Some") {
65
- f = s.value;
66
- try {
67
- d = yield* p.promise(() => f.startStep({
68
- runId: a,
69
- stepName: t,
70
- attempt: o,
71
- stepInput: r,
72
- ...i === void 0 ? {} : { retryPolicy: i }
73
- }));
74
- } catch {
75
- d = void 0;
76
- }
77
- }
78
- let m = Date.now();
79
- return yield* l.pipe(p.tap((e) => d && f ? p.promise(async () => {
80
- try {
81
- await f.endStepSuccess({
82
- stepRecordId: d,
83
- output: e,
84
- durationMs: Date.now() - m
85
- });
86
- } catch {}
87
- }) : p.void), p.tapErrorCause((e) => d && f && !u.isInterruptedOnly(e) ? p.promise(async () => {
88
- try {
89
- 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;
90
- await f.endStepFailure({
91
- stepRecordId: d,
92
- errorTag: o,
93
- errorMessage: a,
94
- errorCause: {
95
- pretty: u.pretty(e),
96
- failures: n,
97
- defects: r
98
- },
99
- durationMs: Date.now() - m
100
- });
101
- } catch {}
102
- }) : p.void));
103
- }), P = (t) => {
104
- let { input: n, retry: r, ...i } = t;
105
- return e.make({
106
- ...i,
107
- execute: N(i.name, i.execute, n, r)
108
- });
109
- }, F = c.withCompensation, I = e.idempotencyKey;
110
- //#endregion
111
- export { h as C, y as E, v as S, b as T, F as _, O as a, _ as b, E as c, A as d, j as f, t as g, I as h, r as i, T as l, P as m, C as n, a as o, M as p, S as r, s, w as t, k as u, D as v, x as w, g as x, l as y };