@voltro/workflow 0.83.1 → 0.85.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,148 +0,0 @@
1
- import { Activity as e } from "@effect/workflow";
2
- import { Effect as t, FiberRef as n, ParseResult as r, Schema as i, SchemaAST as a } from "effect";
3
- //#region src/journalEncryption.ts
4
- var o = () => void 0, s = (e) => {
5
- o = typeof e == "function" ? e : () => e;
6
- }, c = () => o(), l = n.unsafeMake(!1), u = { column: "workflow-journal" }, d = /* @__PURE__ */ new Set(), f = (e) => {
7
- d.add(e);
8
- }, p = /* @__PURE__ */ new Set(), m = (e) => {
9
- p.add(e);
10
- }, h = (e) => p.has(e), g = (e) => d.has(e), _ = (e) => typeof e == "string" && (e.startsWith("enc:v1:") || e.startsWith("enc:v2:")), v = (e) => /* @__PURE__ */ Error(`${e}: the workflow is declared encrypted, but no field-encryption key is registered — set VOLTRO_FIELD_ENCRYPTION_KEY (\`voltro secret generate field-encryption\`). Nothing was written in plaintext instead.`), y = (e, t, n = u) => {
11
- if (e == null) return e;
12
- let r = o();
13
- if (r === void 0) throw v(t);
14
- return r.encrypt(JSON.stringify(e), n);
15
- }, b = (e, t, n = u) => {
16
- if (!_(e)) return e;
17
- let r = o();
18
- if (r === void 0) throw v(t);
19
- return JSON.parse(r.decrypt(e, n));
20
- }, x = (e) => a.isVoidKeyword(e) || a.isNeverKeyword(e) || a.isUndefinedKeyword(e), S = (e, t) => x(e.ast) ? e : i.transformOrFail(i.Unknown, e, {
21
- strict: !0,
22
- decode: (e, n, i) => {
23
- try {
24
- return r.succeed(Array.isArray(e) ? e.map((e) => b(e, t)) : b(e, t));
25
- } catch (t) {
26
- return r.fail(new r.Type(i, e, t.message));
27
- }
28
- },
29
- encode: (e, n, i) => {
30
- try {
31
- return r.succeed(e === void 0 ? void 0 : y(e, t));
32
- } catch (t) {
33
- return r.fail(new r.Type(i, e, t.message));
34
- }
35
- }
36
- }), C = (e, t) => {
37
- let n = i.isSchema(t) ? t.fields : t, r = `workflow '${e}' payload`, a = {};
38
- for (let [t, o] of Object.entries(n)) {
39
- if (i.isSchema(o)) {
40
- a[t] = S(o, `${r}.${t}`);
41
- continue;
42
- }
43
- let n = o.ast;
44
- if (n._tag === "PropertySignatureDeclaration" && n.defaultValue === void 0) {
45
- let e = S(i.make(n.type), `${r}.${t}`);
46
- a[t] = n.isOptional ? i.optional(e) : e;
47
- continue;
48
- }
49
- throw Error(`workflow '${e}' is declared encrypted, but payload field '${t}' is a property-signature transformation (a default or a renamed key), which the encryption cannot wrap without changing it. Declare the field as a plain schema (or \`Schema.optional(...)\`) and apply the default in the body.`);
50
- }
51
- return a;
52
- }, w = (e) => typeof e == "object" && !!e && !Array.isArray(e), T = (e, t) => {
53
- if (!w(e)) return b(e, t);
54
- let n = {};
55
- for (let [r, i] of Object.entries(e)) n[r] = b(i, `${t}.${r}`);
56
- return n;
57
- }, E = (e, t) => {
58
- let n = {};
59
- for (let [r, i] of Object.entries(e)) n[r] = y(i, `${t}.${r}`);
60
- return n;
61
- }, D = "VoltroSealedDefect", O = (e, t) => {
62
- if (e instanceof Error && e.name === "VoltroSealedDefect") return e;
63
- let n = e instanceof Error ? {
64
- name: e.name,
65
- message: e.message,
66
- ...e.stack === void 0 ? {} : { stack: e.stack }
67
- } : {
68
- name: "Defect",
69
- message: typeof e == "string" ? e : A(e)
70
- }, r = Error(String(y(n, t)));
71
- return r.name = D, r.stack = `${D}: ${r.message}`, r;
72
- }, k = (e, t) => {
73
- let n = e?.name, r = e?.message;
74
- if (n !== "VoltroSealedDefect" || typeof r != "string" || !_(r)) return e;
75
- try {
76
- let e = b(r, t), n = Error(e.message ?? "");
77
- return n.name = e.name ?? "Error", e.stack !== void 0 && (n.stack = e.stack), n;
78
- } catch {
79
- return e;
80
- }
81
- }, A = (e) => {
82
- try {
83
- return JSON.stringify(e) ?? String(e);
84
- } catch {
85
- return String(e);
86
- }
87
- }, j = () => d.size > 0, M = (e, t) => t == null ? null : g(e) ? String(y(t, `workflow '${e}' error message`)) : t, N = (e, t) => {
88
- try {
89
- return b(e, t);
90
- } catch {
91
- return e;
92
- }
93
- }, P = (e) => {
94
- if (e == null) return null;
95
- let t = N(e, "workflow error message");
96
- return typeof t == "string" ? t : e;
97
- }, F = [
98
- "value",
99
- "result",
100
- "errorMessage"
101
- ], I = (e, t) => {
102
- if (t == null) return null;
103
- if (!g(e)) return t;
104
- let n = { ...t };
105
- for (let t of F) t in n && n[t] !== void 0 && n[t] !== null && !_(n[t]) && (n[t] = y(n[t], `workflow '${e}' event ${t}`));
106
- return n;
107
- }, L = (e) => {
108
- if (!w(e)) return e;
109
- let t = { ...e };
110
- for (let e of F) _(t[e]) && (t[e] = N(t[e], `workflow event ${e}`));
111
- return t;
112
- }, R = (r) => {
113
- let i = e.make(r), a, o = `wait '${r.name}'`, s = () => a ??= e.make({
114
- ...r,
115
- success: S(r.success, `${o} value`),
116
- execute: r.execute.pipe(t.catchAllDefect((e) => t.die(O(e, `${o} defect`))))
117
- }), c = i;
118
- return {
119
- ...i,
120
- commit: () => t.flatMap(n.get(l), (e) => e ? s().pipe(t.catchAllDefect((e) => t.die(k(e, `${o} defect`)))) : c)
121
- };
122
- }, z = { column: "_voltro_workflow_run_steps:payload" }, B = (e) => {
123
- if (!_(e)) return e;
124
- try {
125
- return b(e, "workflow step value", z);
126
- } catch {
127
- return e;
128
- }
129
- }, V = (e) => {
130
- if (!w(e)) return e;
131
- let t = { ...e };
132
- if ("eventType" in t) return "payload" in t && (t.payload = L(t.payload)), t;
133
- if ("stepName" in t && ("input" in t || "errorCause" in t)) {
134
- for (let e of [
135
- "input",
136
- "output",
137
- "errorCause",
138
- "errorMessage"
139
- ]) e in t && (t[e] = B(t[e]));
140
- return t;
141
- }
142
- if ("payload" in t) try {
143
- t.payload = T(t.payload, "workflow run payload");
144
- } catch {}
145
- return "output" in t && (t.output = N(t.output, "workflow run result")), typeof t.errorMessage == "string" && (t.errorMessage = P(t.errorMessage)), t;
146
- }, H = (e, t) => e === void 0 || !g(e) ? String(t) : `${t instanceof Error ? t.name : typeof t}: [withheld — workflow '${e}' is declared encrypted; the full cause is recorded sealed on its row]`;
147
- //#endregion
148
- export { E as C, N as D, s as E, y as S, S as T, T as _, R as a, M as b, _ as c, m as d, f, b as g, L as h, j as i, g as l, P as m, z as n, c as o, k as p, u as r, h as s, l as t, H as u, V as v, C as w, I as x, O as y };