@voltro/protocol 0.84.0 → 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.
package/dist/index.js CHANGED
@@ -1,67 +1,94 @@
1
- import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as ee, J as te, K as ne, L as re, M as ie, N as ae, O as oe, P as se, Q as ce, R as le, S as ue, T as de, U as fe, V as l, W as pe, X as me, Y as he, Z as ge, _ as _e, a as ve, at as ye, b as be, c as xe, d as u, et as Se, f as Ce, g as we, h as Te, i as Ee, it as De, j as Oe, k as ke, l as Ae, m as je, n as Me, nt as Ne, o as d, ot as Pe, p as Fe, q as Ie, r as Le, rt as Re, s as f, st as ze, t as Be, tt as Ve, u as He, v as Ue, w as We, x as Ge, y as p, z as Ke } from "./scopes-Di756ENh.js";
2
- import { A as qe, C as m, D as Je, E as Ye, O as Xe, S as Ze, T as Qe, _ as $e, a as et, b as tt, c as nt, d as rt, f as it, g as at, h as ot, i as st, j as ct, k as lt, l as ut, m as dt, n as ft, o as pt, p as mt, r as ht, s as gt, t as _t, u as vt, v as yt, w as bt, x as xt, y as St } from "./restFormat-EZ8k9ZcQ.js";
3
- import { n as Ct, t as wt } from "./sessionHeader-DriTZhmv.js";
4
- import { Context as Tt, Either as Et, Encoding as Dt, Layer as Ot, Schema as h } from "effect";
5
- import { Rpc as g } from "@effect/rpc";
6
- import { VersionConflict as kt } from "@voltro/database/wire";
7
- //#region src/rowPatch.ts
8
- var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1 && typeof e.$bytes == "string", _ = h.transform(h.Unknown, h.Unknown, {
9
- strict: !0,
10
- decode: (e) => {
11
- if (!jt(e)) return e;
12
- let t = Dt.decodeBase64(e.$bytes);
13
- return Et.isRight(t) ? t.right : e;
14
- },
15
- encode: (e) => e instanceof Uint8Array ? { $bytes: Dt.encodeBase64(e) } : e
16
- }), Mt = h.Record({
17
- key: h.String,
18
- value: _
19
- }).pipe(h.filter((e) => "id" in e, { message: () => "patch row must carry an id" })), Nt = h.Union(h.Struct({
20
- op: h.Literal("add"),
21
- path: h.String,
22
- value: Mt
23
- }), h.Struct({
24
- op: h.Literal("replace"),
25
- path: h.String,
26
- value: Mt
27
- }), h.Struct({
28
- op: h.Literal("remove"),
29
- path: h.String
30
- }), h.Struct({
31
- op: h.Literal("mergeCells"),
32
- path: h.String,
33
- value: h.Record({
34
- key: h.String,
35
- value: _
1
+ import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as ee, K as te, L as ne, M as re, N as ie, O as ae, P as oe, Q as se, R as ce, S as le, T as ue, U as de, V as u, W as fe, X as pe, Y as me, Z as he, _ as ge, a as _e, at as ve, b as ye, c as be, d as xe, et as Se, f as Ce, g as we, h as Te, i as Ee, it as De, j as Oe, k as ke, l as Ae, m as je, n as Me, nt as Ne, o as d, ot as Pe, p as Fe, q as Ie, r as Le, rt as Re, s as f, st as ze, t as Be, tt as Ve, u as He, v as Ue, w as We, x as Ge, y as Ke, z as qe } from "./scopes-ClywBij8.js";
2
+ import { A as Je, C as Ye, D as Xe, E as Ze, O as Qe, S as $e, T as et, _ as tt, a as nt, b as rt, c as it, d as at, f as ot, g as st, h as ct, i as lt, j as ut, k as dt, l as ft, m as pt, n as mt, o as ht, p as gt, r as _t, s as vt, t as yt, u as bt, v as xt, w as St, x as Ct, y as wt } from "./restFormat-BlgTLxm1.js";
3
+ import { n as Tt, t as Et } from "./sessionHeader-DriTZhmv.js";
4
+ import { Context as Dt, Effect as Ot, Layer as kt, Result as At, Schema as p, SchemaAST as m, SchemaGetter as jt, SchemaIssue as Mt } from "effect";
5
+ import { Rpc as h } from "effect/rpc";
6
+ import * as Nt from "effect/encoding/Base64";
7
+ import * as g from "effect/SchemaAST";
8
+ import { VersionConflict as Pt } from "@voltro/database/wire";
9
+ //#region src/rowEquality.ts
10
+ var Ft = (e) => e instanceof Uint8Array && Object.getPrototypeOf(e) === Uint8Array.prototype && !("toJSON" in e) && Object.keys(e).length === e.length, It = (e) => {
11
+ let t = Object.getPrototypeOf(e);
12
+ return (t === null || t === Object.prototype) && !("toJSON" in e) && !("toJSON" in Object.prototype);
13
+ }, Lt = (e) => e == null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" || Ft(e), Rt = (e, t) => {
14
+ let n = typeof e == "number" && !Number.isFinite(e) ? null : e, r = typeof t == "number" && !Number.isFinite(t) ? null : t;
15
+ if (n === r) return !0;
16
+ if (n instanceof Uint8Array && r instanceof Uint8Array) {
17
+ if (n.length !== r.length) return !1;
18
+ for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return !1;
19
+ return !0;
20
+ }
21
+ return !1;
22
+ }, zt = (e, t) => {
23
+ if (!It(e) || !It(t)) return;
24
+ let n = Object.keys(e), r = e === t ? n : Object.keys(t);
25
+ if (n.length !== r.length) return;
26
+ let i = !0;
27
+ for (let r = 0; r < n.length; r++) {
28
+ let a = n[r];
29
+ if (a === "__proto__" || a in Object.prototype && Object.getOwnPropertyDescriptor(Object.prototype, a)?.set !== void 0) return;
30
+ let o = Object.getOwnPropertyDescriptor(e, a), s = e === t ? o : Object.getOwnPropertyDescriptor(t, a);
31
+ if (o === void 0 || s === void 0 || s.enumerable !== !0 || !("value" in o) || !("value" in s)) return;
32
+ let c = o.value, l = s.value;
33
+ if (!Lt(c) || !Lt(l)) return;
34
+ Rt(c, l) || (i = !1);
35
+ }
36
+ return i;
37
+ }, Bt = p.Union([p.String, p.Number]), Vt = (e) => typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1 && typeof e.$bytes == "string", Ht = p.Unknown.pipe(p.decodeTo(p.Unknown, {
38
+ decode: jt.transform((e) => {
39
+ if (!Vt(e)) return e;
40
+ let t = Nt.decode(e.$bytes);
41
+ return At.isSuccess(t) ? t.success : e;
42
+ }),
43
+ encode: jt.transform((e) => e instanceof Uint8Array ? { $bytes: Nt.encode(e) } : e instanceof Date ? e.toISOString() : e)
44
+ })), Ut = p.Record(p.String, Ht).pipe(p.refine((e) => "id" in e, { message: "patch row must carry an id" })), Wt = p.Union([
45
+ p.Struct({
46
+ op: p.Literal("add"),
47
+ path: p.String,
48
+ value: Ut
49
+ }),
50
+ p.Struct({
51
+ op: p.Literal("replace"),
52
+ path: p.String,
53
+ value: Ut
54
+ }),
55
+ p.Struct({
56
+ op: p.Literal("remove"),
57
+ path: p.String
58
+ }),
59
+ p.Struct({
60
+ op: p.Literal("mergeCells"),
61
+ path: p.String,
62
+ value: p.Record(p.String, Ht)
36
63
  })
37
- })), Pt = h.Struct({
38
- ops: h.Array(Nt),
39
- order: h.Array(At)
40
- }), v = (e) => `/${String(e).replace(/~/g, "~0").replace(/\//g, "~1")}`, y = (e) => (e.startsWith("/") ? e.slice(1) : e).replace(/~1/g, "/").replace(/~0/g, "~"), b = (e) => {
64
+ ]), Gt = p.Struct({
65
+ ops: p.Array(Wt),
66
+ order: p.NullOr(p.Array(Bt))
67
+ }), _ = (e) => `/${String(e).replace(/~/g, "~0").replace(/\//g, "~1")}`, v = (e) => (e.startsWith("/") ? e.slice(1) : e).replace(/~1/g, "/").replace(/~0/g, "~"), y = (e) => {
41
68
  let t = Object.keys(e).sort(), n = {};
42
69
  for (let r of t) n[r] = e[r];
43
70
  return JSON.stringify(n);
44
- }, Ft = (e, t) => b(e) === b(t), It = (e, t) => {
71
+ }, Kt = (e, t) => zt(e, t) ?? y(e) === y(t), qt = (e, t) => {
45
72
  if (e instanceof Uint8Array && t instanceof Uint8Array) {
46
73
  if (e.length !== t.length) return !1;
47
74
  for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
48
75
  return !0;
49
76
  }
50
- return b({
77
+ return y({
51
78
  id: 0,
52
79
  v: e
53
- }) === b({
80
+ }) === y({
54
81
  id: 0,
55
82
  v: t
56
83
  });
57
- }, Lt = (e, t, n = {}) => {
84
+ }, Jt = (e, t, n = {}) => {
58
85
  let r = /* @__PURE__ */ new Map();
59
86
  for (let t of e) r.set(t.id, t);
60
- let i = [], a = [], o = /* @__PURE__ */ new Set(), s = n.crdt, c = (e, t) => {
87
+ let i = [], a = e.length === t.length && t.every((t, n) => t.id === e[n].id) ? null : [], o = /* @__PURE__ */ new Set(), s = n.crdt, c = (e, t) => {
61
88
  if (s === void 0 || s.columns.size === 0) return;
62
89
  let n = {}, r = !1;
63
90
  for (let i of s.columns) {
64
- if (!(i in t) || It(e[i], t[i])) continue;
91
+ if (!(i in t) || qt(e[i], t[i])) continue;
65
92
  let a = s.incremental(i, e[i], t[i]);
66
93
  if (a === void 0) return;
67
94
  n[i] = a, r = !0;
@@ -75,85 +102,137 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
75
102
  };
76
103
  };
77
104
  for (let e of t) {
78
- a.push(e.id), o.add(e.id);
105
+ a?.push(e.id), o.add(e.id);
79
106
  let t = r.get(e.id);
80
107
  if (t === void 0) i.push({
81
108
  op: "add",
82
- path: v(e.id),
109
+ path: _(e.id),
83
110
  value: e
84
111
  });
85
- else if (!Ft(t, e)) {
112
+ else if (!Kt(t, e)) {
86
113
  let n = c(t, e);
87
114
  n === void 0 ? i.push({
88
115
  op: "replace",
89
- path: v(e.id),
116
+ path: _(e.id),
90
117
  value: e
91
- }) : (Ft(Object.fromEntries(Object.entries(t).filter(([e]) => !s.columns.has(e))), n.scalars) || i.push({
118
+ }) : (Kt(Object.fromEntries(Object.entries(t).filter(([e]) => !s.columns.has(e))), n.scalars) || i.push({
92
119
  op: "replace",
93
- path: v(e.id),
120
+ path: _(e.id),
94
121
  value: n.scalars
95
122
  }), i.push({
96
123
  op: "mergeCells",
97
- path: v(e.id),
124
+ path: _(e.id),
98
125
  value: n.merges
99
126
  }));
100
127
  }
101
128
  }
102
129
  for (let t of e) o.has(t.id) || i.push({
103
130
  op: "remove",
104
- path: v(t.id)
131
+ path: _(t.id)
105
132
  });
106
133
  return {
107
134
  ops: i,
108
135
  order: a
109
136
  };
110
- }, Rt = (e) => e.every((e) => {
137
+ }, Yt = (e) => e.every((e) => {
111
138
  let t = e.id;
112
139
  return typeof t == "string" || typeof t == "number";
113
- }), zt = (e, t, n = {}) => {
140
+ }), Xt = (e, t, n = {}) => {
114
141
  let r = /* @__PURE__ */ new Map();
115
142
  for (let t of e) r.set(t.id, t);
116
- let i = /* @__PURE__ */ new Map();
117
- for (let e of t.ops) e.op === "mergeCells" && i.set(y(e.path), Object.keys(e.value));
143
+ return Zt(e, t, n, r);
144
+ }, Zt = (e, t, n, r, i) => {
145
+ let a = /* @__PURE__ */ new Map();
146
+ for (let e of t.ops) e.op === "mergeCells" && a.set(v(e.path), Object.keys(e.value));
118
147
  for (let e of t.ops) {
119
148
  if (e.op === "mergeCells") {
120
- let t = y(e.path), i = r.get(t) ?? r.get(Number(t)), a = r.has(t) ? t : Number(t);
149
+ let t = v(e.path), i = r.get(t) ?? r.get(Number(t)), a = r.has(t) ? t : Number(t);
121
150
  if (i === void 0) continue;
122
151
  let o = { ...i };
123
152
  for (let [t, r] of Object.entries(e.value)) o[t] = n.mergeCell === void 0 ? r : n.mergeCell(t, i[t], r);
124
153
  r.set(a, o);
125
154
  continue;
126
155
  }
127
- if (e.op === "add" && r.set(e.value.id, e.value), e.op === "replace") {
128
- let t = r.get(e.value.id), n = (t === void 0 ? [] : i.get(String(e.value.id)) ?? []).filter((n) => !(n in e.value) && n in t);
129
- r.set(e.value.id, n.length === 0 ? e.value : {
156
+ if (e.op === "add" && (t.order !== null || r.has(e.value.id)) && r.set(e.value.id, e.value), e.op === "replace") {
157
+ let n = r.get(e.value.id), i = (n === void 0 ? [] : a.get(String(e.value.id)) ?? []).filter((t) => !(t in e.value) && t in n);
158
+ (t.order !== null || n !== void 0) && r.set(e.value.id, i.length === 0 ? e.value : {
130
159
  ...e.value,
131
- ...Object.fromEntries(n.map((e) => [e, t[e]]))
160
+ ...Object.fromEntries(i.map((e) => [e, n[e]]))
132
161
  });
133
162
  }
134
163
  }
135
- let a = [];
136
- for (let e of t.order) {
164
+ if (t.order === null && i !== void 0) {
165
+ let n = e.slice();
166
+ for (let e of t.ops) {
167
+ if (e.op === "remove") continue;
168
+ let t = e.op === "mergeCells" ? v(e.path) : void 0, a = e.op === "mergeCells" ? r.has(t) ? t : Number(t) : e.value.id, o = i.get(a), s = r.get(a);
169
+ o !== void 0 && s !== void 0 && (n[o] = s);
170
+ }
171
+ return n;
172
+ }
173
+ let o = [];
174
+ if (t.order === null) for (let t of e) {
175
+ let e = r.get(t.id);
176
+ e !== void 0 && o.push(e);
177
+ }
178
+ else for (let e of t.order) {
137
179
  let t = r.get(e);
138
- t !== void 0 && a.push(t);
180
+ t !== void 0 && o.push(t);
139
181
  }
140
- return a;
141
- }, Bt = (e) => h.Union(h.Struct({
142
- _tag: h.Literal("snapshot"),
143
- revision: h.Number,
144
- data: e,
145
- computed: h.optional(h.Boolean),
146
- reconciles: h.optional(h.String)
147
- }), h.Struct({
148
- _tag: h.Literal("delta"),
149
- revision: h.Number,
150
- emittedAt: h.Number,
151
- patch: Pt
152
- }), h.Struct({
153
- _tag: h.Literal("error"),
154
- error: h.Unknown,
155
- revision: h.optional(h.Number)
156
- })), Vt = (e, t, n) => {
182
+ return o;
183
+ }, Qt = () => {
184
+ let e, t, n, r = () => {
185
+ e = void 0, t = void 0, n = void 0;
186
+ }, i = (e) => {
187
+ let r = /* @__PURE__ */ new Map(), i = Object.getPrototypeOf(e) === Array.prototype;
188
+ for (let t = 0; t < e.length; t++) {
189
+ let n = e[t];
190
+ r.has(n.id) && (i = !1), r.set(n.id, t);
191
+ }
192
+ n = i ? r : void 0, t = i ? void 0 : new Map(e.map((e) => [e.id, e]));
193
+ };
194
+ return {
195
+ reset: r,
196
+ apply: (a, o, s = {}) => {
197
+ (a !== e || n === void 0 && t === void 0) && i(a);
198
+ try {
199
+ let r = n, c = /* @__PURE__ */ new Map(), l = Zt(a, o, s, r === void 0 ? t : {
200
+ get: (e) => {
201
+ if (c.has(e)) return c.get(e);
202
+ let t = r.get(e);
203
+ return t === void 0 ? void 0 : a[t];
204
+ },
205
+ has: (e) => c.has(e) || r.has(e),
206
+ set: (e, t) => {
207
+ c.set(e, t);
208
+ }
209
+ }, r);
210
+ return (o.order !== null || o.ops.some((e) => e.op === "mergeCells" && "id" in e.value)) && i(l), e = l, l;
211
+ } catch (e) {
212
+ throw r(), e;
213
+ }
214
+ }
215
+ };
216
+ }, $t = (e) => p.Union([
217
+ p.Struct({
218
+ _tag: p.Literal("snapshot"),
219
+ revision: p.Number,
220
+ data: e,
221
+ computed: p.optional(p.Boolean),
222
+ reconciles: p.optional(p.String)
223
+ }),
224
+ p.Struct({
225
+ _tag: p.Literal("delta"),
226
+ revision: p.Number,
227
+ emittedAt: p.Number,
228
+ patch: Gt
229
+ }),
230
+ p.Struct({
231
+ _tag: p.Literal("error"),
232
+ error: p.Unknown,
233
+ revision: p.optional(p.Number)
234
+ })
235
+ ]), en = (e, t, n) => {
157
236
  if (!t || typeof t != "object" || !("_tag" in t)) return t;
158
237
  let r = t;
159
238
  switch (r._tag) {
@@ -162,42 +241,42 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
162
241
  case "delta": throw Error(`${n} ${e}: received a 'delta' as the first event, which should be impossible — a subscription always opens with a snapshot. This is a framework bug.`);
163
242
  default: return t;
164
243
  }
165
- }, Ht = (e, t) => {
244
+ }, tn = (e, t) => {
166
245
  let n = `${e ?? "this procedure"} input`;
167
246
  return t === !0 ? `${n} (guarded — the guard did NOT run: the payload failed to decode first, so this says nothing about access)` : n;
168
- }, Ut = (e) => {
169
- let t = e.ast;
170
- return t._tag === "TypeLiteral" && (t.propertySignatures?.length ?? 0) === 0 && (t.indexSignatures?.length ?? 0) === 0;
247
+ }, nn = Mt.makeFormatterDefault(), rn = (e) => p.Never.annotate({ message: e.size === 0 ? "is unexpected: the input declares no keys" : `is unexpected: the input declares ${[...e].map(String).join(", ")}` }).ast, an = (e) => p.String.check(p.makeFilter((t) => e.has(t) ? "a declared key" : void 0)).ast, b = (e, t = /* @__PURE__ */ new Map()) => {
248
+ let n = t.get(e);
249
+ if (n !== void 0) return n;
250
+ let r = on(e, t);
251
+ return t.set(e, r), r;
252
+ }, on = (e, t) => {
253
+ if (e.encoding !== void 0) {
254
+ let n = g.toEncoded(e), r = b(n, t);
255
+ return r === n ? e : p.make(r).pipe(p.decodeTo(p.make(e))).ast;
256
+ }
257
+ if (g.isObjects(e)) {
258
+ let n = e.propertySignatures.map((e) => new g.PropertySignature(e.name, b(e.type, t))), r = new Set(n.map((e) => e.name)), i = e.indexSignatures.length > 0 ? e.indexSignatures.map((e) => new g.IndexSignature(e.parameter, b(e.type, t))) : [new g.IndexSignature(an(r), rn(r))];
259
+ return new g.Objects(n, i, e.annotations, e.checks, void 0, e.context);
260
+ }
261
+ return g.isArrays(e) ? new g.Arrays(e.isMutable, e.elements.map((e) => b(e, t)), e.rest.map((e) => b(e, t)), e.annotations, e.checks, void 0, e.context) : g.isUnion(e) ? new g.Union(e.types.map((e) => b(e, t)), e.options, e.annotations, e.checks, void 0, e.context) : g.isSuspend(e) ? new g.Suspend(() => b(e.thunk(), t), e.annotations, e.checks, void 0, e.context) : e;
171
262
  }, x = (e, t, n) => {
172
- let r = Ht(t, n), i = e.annotations({
173
- parseOptions: { onExcessProperty: "error" },
174
- parseIssueTitle: () => r
175
- });
176
- return Ut(e) ? h.filter((e) => typeof e == "object" && e && Object.keys(e).length > 0 ? `this procedure declares no input; received: ${Object.keys(e).join(", ")}` : void 0)(i).annotations({ identifier: r }) : i;
177
- }, S = class extends h.TaggedError()("BusinessRuleViolation", {
178
- rule: h.String,
179
- params: h.optional(h.Record({
180
- key: h.String,
181
- value: h.Unknown
182
- })),
183
- field: h.optional(h.String),
184
- message: h.optional(h.String),
185
- severity: h.Literal("error", "warning")
186
- }) {}, Wt = h.Struct({
187
- field: h.String,
188
- message: h.String,
189
- params: h.optional(h.Record({
190
- key: h.String,
191
- value: h.Unknown
192
- }))
193
- }), C = class extends h.TaggedError()("ValidationError", {
194
- field: h.String,
195
- message: h.String,
196
- params: h.optional(h.Record({
197
- key: h.String,
198
- value: h.Unknown
199
- }))
200
- }) {}, w = class extends h.TaggedError()("ValidationErrors", { issues: h.Array(Wt).pipe(h.minItems(1)) }) {}, Gt = (e) => {
263
+ let r = tn(t, n);
264
+ return p.make(b(e.ast)).pipe(p.middlewareDecoding((e) => Ot.catch(e, (e) => Ot.fail(new Mt.InvalidValue({ message: `${r}\n${nn(e)}` })))));
265
+ }, sn = class extends p.TaggedError()("BusinessRuleViolation", {
266
+ rule: p.String,
267
+ params: p.optional(p.Record(p.String, p.Unknown)),
268
+ field: p.optional(p.String),
269
+ message: p.optional(p.String),
270
+ severity: p.Literals(["error", "warning"])
271
+ }) {}, cn = p.Struct({
272
+ field: p.String,
273
+ message: p.String,
274
+ params: p.optional(p.Record(p.String, p.Unknown))
275
+ }), S = class extends p.TaggedError()("ValidationError", {
276
+ field: p.String,
277
+ message: p.String,
278
+ params: p.optional(p.Record(p.String, p.Unknown))
279
+ }) {}, C = class extends p.TaggedError()("ValidationErrors", { issues: p.Array(cn).pipe(p.check(p.isMinLength(1))) }) {}, ln = (e) => {
201
280
  if (typeof e != "object" || !e) return [];
202
281
  let t = e._tag;
203
282
  if (t === "ValidationError") {
@@ -223,69 +302,87 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
223
302
  }];
224
303
  }
225
304
  return [];
226
- }, Kt = class extends h.TaggedError()("ApprovalRequired", {
227
- approvalId: h.String,
228
- procedure: h.String,
229
- expiresAt: h.String,
230
- requiredScopes: h.Array(h.String),
231
- reason: h.NullOr(h.String),
232
- created: h.Boolean
233
- }) {}, qt = class extends h.TaggedError()("ApprovalNotFound", { approvalId: h.String }) {}, Jt = class extends h.TaggedError()("ApprovalSelfApproval", {
234
- approvalId: h.String,
235
- subjectId: h.NullOr(h.String)
236
- }) {}, Yt = class extends h.TaggedError()("ApprovalRejected", {
237
- approvalId: h.String,
238
- decidedBy: h.NullOr(h.String),
239
- note: h.NullOr(h.String)
240
- }) {}, T = class extends h.TaggedError()("ApprovalExpired", {
241
- approvalId: h.String,
242
- expiredAt: h.String
243
- }) {}, Xt = class extends h.TaggedError()("ApprovalNotPending", {
244
- approvalId: h.String,
245
- status: h.String
246
- }) {}, Zt = class extends h.TaggedError()("ApprovalForbidden", {
247
- approvalId: h.String,
248
- required: h.NullOr(h.String),
249
- message: h.String
250
- }) {}, E = class extends h.TaggedError()("ApprovalUnavailable", {
251
- procedure: h.String,
252
- message: h.String
253
- }) {}, Qt = h.Union(Kt, Yt, T, E), $t = h.Union(qt, Jt, T, Xt, Zt, E), en = h.Struct({
254
- id: h.String,
255
- procedure: h.String,
256
- kind: h.Literal("mutation", "action"),
257
- requestedBy: h.NullOr(h.String),
258
- status: h.Literal("pending", "approved", "rejected", "expired", "consumed"),
259
- reason: h.NullOr(h.String),
260
- requiredScopes: h.Array(h.String),
261
- requestedAt: h.String,
262
- expiresAt: h.String,
263
- decidedBy: h.NullOr(h.String),
264
- decidedAt: h.NullOr(h.String),
265
- note: h.NullOr(h.String),
266
- relation: h.Literal("to-decide", "requested")
267
- }), D = "channel:", tn = Symbol.for("@voltro/protocol/reactivityChannels"), nn = globalThis, O = nn[tn] ?? (nn[tn] = /* @__PURE__ */ new Map()), rn = /^[a-z][a-z0-9-]*(\.[a-z0-9-]+)*$/, an = (e) => {
268
- if (!rn.test(e)) throw Error(`reactivityChannel('${e}'): invalid channel name.\n Use lowercase kebab segments separated by dots — \`presence\`, \`job-queue\`,
305
+ }, un = class extends p.TaggedError()("ApprovalRequired", {
306
+ approvalId: p.String,
307
+ procedure: p.String,
308
+ expiresAt: p.String,
309
+ requiredScopes: p.Array(p.String),
310
+ reason: p.NullOr(p.String),
311
+ created: p.Boolean
312
+ }) {}, dn = class extends p.TaggedError()("ApprovalNotFound", { approvalId: p.String }) {}, fn = class extends p.TaggedError()("ApprovalSelfApproval", {
313
+ approvalId: p.String,
314
+ subjectId: p.NullOr(p.String)
315
+ }) {}, pn = class extends p.TaggedError()("ApprovalRejected", {
316
+ approvalId: p.String,
317
+ decidedBy: p.NullOr(p.String),
318
+ note: p.NullOr(p.String)
319
+ }) {}, mn = class extends p.TaggedError()("ApprovalExpired", {
320
+ approvalId: p.String,
321
+ expiredAt: p.String
322
+ }) {}, hn = class extends p.TaggedError()("ApprovalNotPending", {
323
+ approvalId: p.String,
324
+ status: p.String
325
+ }) {}, gn = class extends p.TaggedError()("ApprovalForbidden", {
326
+ approvalId: p.String,
327
+ required: p.NullOr(p.String),
328
+ message: p.String
329
+ }) {}, _n = class extends p.TaggedError()("ApprovalUnavailable", {
330
+ procedure: p.String,
331
+ message: p.String
332
+ }) {}, vn = p.Union([
333
+ un,
334
+ pn,
335
+ mn,
336
+ _n
337
+ ]), yn = p.Union([
338
+ dn,
339
+ fn,
340
+ mn,
341
+ hn,
342
+ gn,
343
+ _n
344
+ ]), bn = p.Struct({
345
+ id: p.String,
346
+ procedure: p.String,
347
+ kind: p.Literals(["mutation", "action"]),
348
+ requestedBy: p.NullOr(p.String),
349
+ status: p.Literals([
350
+ "pending",
351
+ "approved",
352
+ "rejected",
353
+ "expired",
354
+ "consumed"
355
+ ]),
356
+ reason: p.NullOr(p.String),
357
+ requiredScopes: p.Array(p.String),
358
+ requestedAt: p.String,
359
+ expiresAt: p.String,
360
+ decidedBy: p.NullOr(p.String),
361
+ decidedAt: p.NullOr(p.String),
362
+ note: p.NullOr(p.String),
363
+ relation: p.Literals(["to-decide", "requested"])
364
+ }), w = "channel:", xn = Symbol.for("@voltro/protocol/reactivityChannels"), Sn = globalThis, T = Sn[xn] ?? (Sn[xn] = /* @__PURE__ */ new Map()), Cn = /^[a-z][a-z0-9-]*(\.[a-z0-9-]+)*$/, wn = (e) => {
365
+ if (!Cn.test(e)) throw Error(`reactivityChannel('${e}'): invalid channel name.\n Use lowercase kebab segments separated by dots — \`presence\`, \`job-queue\`,
269
366
  \`billing.usage\`. A \`:\` is refused because it is the namespace separator in
270
- the routing key (\`${D}<name>\`), and an uppercase letter is\n refused because a key that differs only by case reads as one channel and
367
+ the routing key (\`${w}<name>\`), and an uppercase letter is\n refused because a key that differs only by case reads as one channel and
271
368
  routes as two.`);
272
- let t = O.get(e);
369
+ let t = T.get(e);
273
370
  if (t !== void 0) return t;
274
- let n = `${D}${e}`, r = Object.freeze({
371
+ let n = `${w}${e}`, r = Object.freeze({
275
372
  kind: "reactivity-channel",
276
373
  name: e,
277
374
  key: n,
278
375
  toString: () => n
279
376
  });
280
- return O.set(e, r), r;
281
- }, on = (e) => typeof e == "object" && !!e && e.kind === "reactivity-channel", sn = (e) => e.startsWith(D), cn = () => new Set([...O.values()].map((e) => e.key)), k = (e) => on(e) ? e.key : e, ln = (e) => e === void 0 ? [] : Array.isArray(e) ? e.map(k) : [k(e)], un = (e) => e === void 0 ? void 0 : Array.isArray(e) ? e.map(k) : k(e), dn = (e) => {
282
- let t = cn(), n = [];
283
- for (let r of e) for (let e of ln(r.source)) sn(e) && !t.has(e) && n.push({
377
+ return T.set(e, r), r;
378
+ }, Tn = (e) => typeof e == "object" && !!e && e.kind === "reactivity-channel", En = (e) => e.startsWith(w), Dn = () => new Set([...T.values()].map((e) => e.key)), E = (e) => Tn(e) ? e.key : e, On = (e) => e === void 0 ? [] : Array.isArray(e) ? e.map(E) : [E(e)], kn = (e) => e === void 0 ? void 0 : Array.isArray(e) ? e.map(E) : E(e), An = (e) => {
379
+ let t = Dn(), n = [];
380
+ for (let r of e) for (let e of On(r.source)) En(e) && !t.has(e) && n.push({
284
381
  procedure: r.name,
285
382
  key: e
286
383
  });
287
384
  return n;
288
- }, fn = (e, t) => {
385
+ }, jn = (e, t) => {
289
386
  let n = e?.injectExternalChange;
290
387
  return n !== void 0 && (n.call(e, {
291
388
  table: t.key,
@@ -294,8 +391,8 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
294
391
  old: {},
295
392
  origin: "inline"
296
393
  }), !0);
297
- }, A = (e) => e.internal !== !0, pn = (e) => e.service === void 0 ? "client" : "service", mn = (e) => A(e) && e.service === void 0, hn = (e) => A(e) && e.service !== void 0, gn = /^[a-z][a-z0-9-]{0,55}$/i, j = (e) => {
298
- if (vn(e), _n(e), e.idempotencyScope !== void 0 && e.idempotencyScope !== "subject" && e.idempotencyScope !== "connection") throw Error(`${e.name}: idempotencyScope must be 'subject' or 'connection'`);
394
+ }, Mn = (e) => e.internal !== !0, Nn = (e) => e.service === void 0 ? "client" : "service", Pn = (e) => Mn(e) && e.service === void 0, Fn = (e) => Mn(e) && e.service !== void 0, In = /^[a-z][a-z0-9-]{0,55}$/i, D = (e) => {
395
+ if (Rn(e), Ln(e), e.idempotencyScope !== void 0 && e.idempotencyScope !== "subject" && e.idempotencyScope !== "connection") throw Error(`${e.name}: idempotencyScope must be 'subject' or 'connection'`);
299
396
  let t = e.serialize;
300
397
  if (t !== void 0) {
301
398
  if (typeof t.key != "function") throw Error(`${e.name}: serialize.key must be a function of the input`);
@@ -319,13 +416,13 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
319
416
  let r = [e.publicApi === void 0 ? void 0 : "publicApi", e.exposeAsTool === void 0 ? void 0 : "exposeAsTool"].filter((e) => e !== void 0);
320
417
  if (r.length === 0) return e;
321
418
  throw Error(`${e.name}: \`internal: true\` cannot be combined with ${r.map((e) => `\`${e}\``).join(" or ")}. \`internal\` takes the procedure OFF the wire; those put it back ON a different one (${r.includes("publicApi") ? "a REST route" : "an agent tool"}), and that surface is projected without consulting the flag — so the procedure would be unreachable from your client and reachable from the internet. Drop \`internal: true\` if the wider surface is intended, or remove the ${r.join(" / ")} annotation if it is not.`);
322
- }, _n = (e) => {
419
+ }, Ln = (e) => {
323
420
  let t = e.service;
324
421
  if (t === void 0) return;
325
422
  let n = t.callers;
326
423
  if (!Array.isArray(n) || n.length === 0) throw Error(`${e.name}: \`service.callers\` is empty, so NO app may call this procedure —\n and no browser either. Name the calling app(s), e.g. \`service: { callers: ['worker'] }\`,
327
424
  or drop \`service:\` if the procedure is meant for this app's own clients.`);
328
- let r = n.filter((e) => typeof e != "string" || !gn.test(e));
425
+ let r = n.filter((e) => typeof e != "string" || !In.test(e));
329
426
  if (r.length > 0) throw Error(`${e.name}: \`service.callers\` holds ${r.map((e) => JSON.stringify(e)).join(", ")} — a caller is an\n app name (letters, digits, dashes; starting with a letter; at most 56 characters), the same name this app
330
427
  lists in \`serviceCallers\` and the caller's credential resolves to.`);
331
428
  if (new Set(n).size !== n.length) throw Error(`${e.name}: \`service.callers\` lists the same app twice`);
@@ -339,7 +436,7 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
339
436
  ].filter((e) => e !== void 0);
340
437
  if (i.length !== 0) throw Error(`${e.name}: \`service:\` cannot be combined with ${i.join("; ")}.\n A service procedure is callable only by the listed apps of this project, over the
341
438
  socket, with their service credential. Drop the other field, or drop \`service:\`.`);
342
- }, vn = (e) => {
439
+ }, Rn = (e) => {
343
440
  let t = e.requiresApproval;
344
441
  if (t !== void 0) {
345
442
  if (!Array.isArray(t.approvers) || t.approvers.length === 0) throw Error(`${e.name}: \`requiresApproval.approvers\` is empty, so NOBODY can approve this\n procedure and every call would park forever. Name the scope(s) an approver must hold
@@ -349,7 +446,7 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
349
446
  human from every other, and the second-pair-of-eyes control would enforce nothing.
350
447
  Give the procedure a \`guards:\` decision, or drop \`requiresApproval\`.`);
351
448
  }
352
- }, yn = (e) => e.action !== void 0 && e.resourceType !== void 0, bn = (e) => e.authenticated === !0, xn = (e) => e.openAccess !== void 0 || e.guards !== void 0 && e.guards.length > 0, M = (e, t, n, i) => {
449
+ }, zn = (e) => e.action !== void 0 && e.resourceType !== void 0, Bn = (e) => e.authenticated === !0, Vn = (e) => e.openAccess !== void 0 || e.guards !== void 0 && e.guards.length > 0, O = (e, t, n, i) => {
353
450
  if (i !== void 0) {
354
451
  if (n !== void 0 || t !== void 0 && t.length > 0) throw Error(`${e}: \`service:\` is an access decision of its own — only the listed apps may\n call this procedure — so it cannot sit beside \`guards:\` or \`openAccess:\`. A service
355
452
  holds no scopes, and no user may call a service procedure. Keep exactly one.`);
@@ -361,31 +458,31 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
361
458
  if (t !== void 0 && t.length > 0) throw Error(`${e}: \`openAccess\` and \`guards\` are two different access decisions, so\n declaring both says the procedure is protected AND open. Keep the guards if a
362
459
  caller must hold a scope; drop them if anyone may call it.`);
363
460
  return [r(n.trim())];
364
- }, N = (e) => j({
461
+ }, k = (e) => D({
365
462
  kind: "query",
366
463
  name: e.name,
367
464
  input: e.input,
368
465
  output: e.output,
369
- error: e.error ?? h.Never,
370
- source: un(e.source),
466
+ error: e.error ?? p.Never,
467
+ source: kn(e.source),
371
468
  cache: e.cache,
372
- guards: M(e.name, e.guards, e.openAccess, e.service),
469
+ guards: O(e.name, e.guards, e.openAccess, e.service),
373
470
  openAccess: e.openAccess,
374
471
  service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
375
472
  publicApi: e.publicApi,
376
473
  exposeAsTool: e.exposeAsTool,
377
474
  internal: e.internal,
378
475
  overridesPlugin: e.overridesPlugin
379
- }), P = (e) => j({
476
+ }), A = (e) => D({
380
477
  kind: "mutation",
381
478
  name: e.name,
382
479
  input: e.input,
383
480
  output: e.output,
384
- error: e.error ?? h.Never,
481
+ error: e.error ?? p.Never,
385
482
  ...e.idempotencyScope === void 0 ? {} : { idempotencyScope: e.idempotencyScope },
386
483
  ...e.serialize === void 0 ? {} : { serialize: e.serialize },
387
484
  target: e.target,
388
- guards: M(e.name, e.guards, e.openAccess, e.service),
485
+ guards: O(e.name, e.guards, e.openAccess, e.service),
389
486
  openAccess: e.openAccess,
390
487
  service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
391
488
  publicApi: e.publicApi,
@@ -393,13 +490,13 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
393
490
  requiresApproval: e.requiresApproval,
394
491
  internal: e.internal,
395
492
  overridesPlugin: e.overridesPlugin
396
- }), F = (e) => j({
493
+ }), j = (e) => D({
397
494
  kind: "action",
398
495
  name: e.name,
399
496
  input: e.input,
400
497
  output: e.output,
401
- error: e.error ?? h.Never,
402
- guards: M(e.name, e.guards, e.openAccess, e.service),
498
+ error: e.error ?? p.Never,
499
+ guards: O(e.name, e.guards, e.openAccess, e.service),
403
500
  openAccess: e.openAccess,
404
501
  service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
405
502
  source: e.source,
@@ -409,85 +506,97 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
409
506
  requiresApproval: e.requiresApproval,
410
507
  internal: e.internal,
411
508
  overridesPlugin: e.overridesPlugin
412
- }), Sn = (e) => j({
509
+ }), Hn = (e) => D({
413
510
  kind: "stream",
414
511
  name: e.name,
415
512
  input: e.input,
416
513
  element: e.element,
417
- error: e.error ?? h.Never,
514
+ error: e.error ?? p.Never,
418
515
  internal: e.internal,
419
516
  overridesPlugin: e.overridesPlugin,
420
- guards: M(e.name, e.guards, e.openAccess),
517
+ guards: O(e.name, e.guards, e.openAccess),
421
518
  openAccess: e.openAccess
422
- }), Cn = (e, t) => t && t.length > 0 ? h.Union(e, ...t) : e, I = (e) => e !== void 0 && e.some((e) => !p(e)), wn = (e) => h.Union(e, f, l), Tn = (e) => h.Union(e, S), En = (e) => h.Union(e, C, w), Dn = (e, t) => t === void 0 ? e : h.Union(e, Qt), On = (e, t) => u(t) ? h.Union(e, d) : e, L = (e, t, n) => Cn(kn(e, t), n), kn = (e, t) => {
423
- let n = On(wn(e.error), e.guards);
519
+ }), Un = (e, t) => t && t.length > 0 ? p.Union([e, ...t]) : e, M = (e) => e !== void 0 && e.some((e) => !Ke(e)), Wn = (e) => p.Union([
520
+ e,
521
+ f,
522
+ u
523
+ ]), Gn = (e) => p.Union([e, sn]), Kn = (e) => p.Union([
524
+ e,
525
+ S,
526
+ C
527
+ ]), qn = (e, t) => t === void 0 ? e : p.Union([e, vn]), Jn = (e, t) => xe(t) ? p.Union([e, d]) : e, N = (e, t, n) => Un(Yn(e, t), n), Yn = (e, t) => {
528
+ let n = Jn(Wn(e.error), e.guards);
424
529
  if (t === "stream" || t === "query") return n;
425
- let r = t === "mutation" ? h.Union(Tn(n), m, kt) : n;
426
- return Dn(En(t === "mutation" && e.idempotencyScope === "connection" ? h.Union(r, Ze) : r), e.requiresApproval);
427
- }, An = {
428
- query: [f, l],
429
- stream: [f, l],
530
+ let r = t === "mutation" ? p.Union([
531
+ Gn(n),
532
+ Ye,
533
+ Pt
534
+ ]) : n;
535
+ return qn(Kn(t === "mutation" && e.idempotencyScope === "connection" ? p.Union([r, $e]) : r), e.requiresApproval);
536
+ }, Xn = {
537
+ query: [f, u],
538
+ stream: [f, u],
430
539
  action: [
431
540
  f,
432
- l,
433
- C,
434
- w
541
+ u,
542
+ S,
543
+ C
435
544
  ],
436
545
  mutation: [
437
546
  f,
438
- l,
547
+ u,
548
+ sn,
549
+ Ye,
550
+ Pt,
439
551
  S,
440
- m,
441
- kt,
442
- C,
443
- w
552
+ C
444
553
  ]
445
- }, jn = (e, t) => Cn(On(wn(e.errorSchema), e.guards), t), Mn = (e, t) => ({
554
+ }, Zn = (e, t) => Un(Jn(Wn(e.errorSchema), e.guards), t), Qn = (e, t) => ({
446
555
  ...e,
447
556
  name: t
448
- }), Nn = (e, t) => g.make(e.name, {
449
- payload: x(e.input, e.name, I(e.guards)),
450
- success: Bt(e.output),
451
- error: L(e, "query", t),
557
+ }), $n = (e, t) => h.make(e.name, {
558
+ payload: x(e.input, e.name, M(e.guards)),
559
+ success: $t(e.output),
560
+ error: N(e, "query", t),
452
561
  stream: !0
453
- }), Pn = (e, t) => g.make(e.name, {
454
- payload: x(e.input, e.name, I(e.guards)),
562
+ }), er = (e, t) => h.make(e.name, {
563
+ payload: x(e.input, e.name, M(e.guards)),
455
564
  success: e.output,
456
- error: L(e, "mutation", t)
457
- }), Fn = (e, t) => g.make(e.name, {
458
- payload: x(e.input, e.name, I(e.guards)),
565
+ error: N(e, "mutation", t)
566
+ }), tr = (e, t) => h.make(e.name, {
567
+ payload: x(e.input, e.name, M(e.guards)),
459
568
  success: e.output,
460
- error: L(e, "action", t)
461
- }), In = (e, t) => g.make(e.name, {
462
- payload: x(e.input, e.name, I(e.guards)),
569
+ error: N(e, "action", t)
570
+ }), nr = (e, t) => h.make(e.name, {
571
+ payload: x(e.input, e.name, M(e.guards)),
463
572
  success: e.element,
464
- error: L(e, "stream", t),
573
+ error: N(e, "stream", t),
465
574
  stream: !0
466
- }), R = (e) => {
575
+ }), rr = (e) => {
467
576
  if (typeof e != "object" || !e) return;
468
577
  let t = e._tag;
469
578
  return typeof t == "string" ? t : void 0;
470
- }, Ln = (e) => {
579
+ }, ir = (e) => {
471
580
  if (typeof e == "string") return e;
472
581
  if (typeof e == "object" && e) {
473
582
  let t = e.message;
474
583
  if (typeof t == "string" && t !== "") return t;
475
- let n = R(e);
584
+ let n = rr(e);
476
585
  if (n !== void 0) return n;
477
586
  }
478
587
  return String(e);
479
- }, Rn = (e) => {
588
+ }, ar = (e) => {
480
589
  if (e instanceof Error) return e;
481
- let t = Error(Ln(e), { cause: e });
482
- return t.name = R(e) ?? "NonErrorThrown", t;
483
- }, zn = (e) => {
590
+ let t = Error(ir(e), { cause: e });
591
+ return t.name = rr(e) ?? "NonErrorThrown", t;
592
+ }, or = (e) => {
484
593
  switch (e.kind) {
485
- case "query": return Nn(e);
486
- case "mutation": return Pn(e);
487
- case "action": return Fn(e);
488
- case "stream": return In(e);
594
+ case "query": return $n(e);
595
+ case "mutation": return er(e);
596
+ case "action": return tr(e);
597
+ case "stream": return nr(e);
489
598
  }
490
- }, Bn = (e) => {
599
+ }, sr = (e) => {
491
600
  let t = e.input, n = t === void 0 ? {} : { input: t }, r = e.output, i = r === void 0 ? {} : { output: r };
492
601
  if (e.kind === "query") return {
493
602
  kind: "query",
@@ -533,7 +642,7 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
533
642
  ..."relations" in e && e.relations !== void 0 ? { relations: e.relations } : {}
534
643
  }))
535
644
  };
536
- }, Vn = 7500, Hn = (e) => typeof e == "object" && !!e && e.kind === "event", Un = (e) => {
645
+ }, cr = 7500, lr = (e) => typeof e == "object" && !!e && e.kind === "event", ur = (e) => {
537
646
  if (e.name.length === 0) throw Error("defineEvent: `name` must not be empty");
538
647
  if (/\s/.test(e.name)) throw Error(`defineEvent("${e.name}"): \`name\` must not contain whitespace.\n The name is used as a broker subject segment. NATS refuses a subject with
539
648
  whitespace and delivers nothing — silently, and only on that broker, so an
@@ -568,62 +677,67 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
568
677
  webhook: e.webhook,
569
678
  delivery: e.delivery
570
679
  };
571
- }, Wn = (e) => h.Struct({
572
- _tag: h.Literal("event"),
573
- origin: h.String,
574
- n: h.Number,
575
- emittedAt: h.Number,
680
+ }, dr = (e) => p.Struct({
681
+ _tag: p.Literal("event"),
682
+ origin: p.String,
683
+ n: p.Number,
684
+ emittedAt: p.Number,
576
685
  payload: e
577
- }), Gn = h.Struct({
578
- _tag: h.Literal("gap"),
579
- missed: h.Number,
580
- reason: h.Literal("buffer", "resume")
581
- }), Kn = h.Struct({ _tag: h.Literal("attached") }), qn = (e) => h.Union(Kn, Wn(e), Gn), Jn = h.Struct({
582
- origin: h.String,
583
- n: h.Number
584
- }), Yn = (e) => h.Struct({
686
+ }), fr = p.Struct({
687
+ _tag: p.Literal("gap"),
688
+ missed: p.Number,
689
+ reason: p.Literals(["buffer", "resume"])
690
+ }), pr = p.Struct({ _tag: p.Literal("attached") }), mr = (e) => p.Union([
691
+ pr,
692
+ dr(e),
693
+ fr
694
+ ]), hr = p.Struct({
695
+ origin: p.String,
696
+ n: p.Number
697
+ }), gr = (e) => p.Struct({
585
698
  key: e,
586
- resume: h.optional(h.Array(Jn))
587
- }), Xn = (e, t) => {
588
- let n = e.guards !== void 0 && e.guards.some((e) => !p(e)) ? h.Union(f, l) : l, r = u(e.guards) ? h.Union(n, d) : n, i = t && t.length > 0 ? h.Union(r, ...t) : r;
589
- return g.make(e.name, {
590
- payload: x(Yn(e.key), e.name, I(e.guards)),
591
- success: qn(e.payload),
699
+ resume: p.optional(p.Array(hr))
700
+ }), _r = (e, t) => {
701
+ let n = e.guards !== void 0 && e.guards.some((e) => !Ke(e)) ? p.Union([f, u]) : u, r = xe(e.guards) ? p.Union([n, d]) : n, i = t && t.length > 0 ? p.Union([r, ...t]) : r;
702
+ return h.make(e.name, {
703
+ payload: x(gr(e.key), e.name, M(e.guards)),
704
+ success: mr(e.payload),
592
705
  error: i,
593
706
  stream: !0
594
707
  });
595
- }, Zn = class extends h.TaggedError()("EventPayloadInvalid", {
596
- event: h.String,
597
- message: h.String
598
- }) {}, Qn = class extends h.TaggedError()("EventKeyInvalid", {
599
- event: h.String,
600
- message: h.String
601
- }) {}, $n = class extends h.TaggedError()("EventPayloadTooLarge", {
602
- event: h.String,
603
- bytes: h.Number,
604
- limit: h.Number
605
- }) {}, er = (e) => {
708
+ }, vr = class extends p.TaggedError()("EventPayloadInvalid", {
709
+ event: p.String,
710
+ message: p.String
711
+ }) {}, yr = class extends p.TaggedError()("EventKeyInvalid", {
712
+ event: p.String,
713
+ message: p.String
714
+ }) {}, br = class extends p.TaggedError()("EventPayloadTooLarge", {
715
+ event: p.String,
716
+ bytes: p.Number,
717
+ limit: p.Number
718
+ }) {}, xr = (e) => {
606
719
  if (typeof e != "object" || !e) return JSON.stringify(e) ?? "null";
607
- let t = Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t));
608
- return JSON.stringify(t);
609
- }, tr = "\0", nr = (e, t, n) => [
720
+ let t = Object.entries(e), n = 0;
721
+ for (let e of t) e[1] !== void 0 && (t[n++] = e);
722
+ return t.length = n, t.sort(([e], [t]) => e < t ? -1 : +(e > t)), JSON.stringify(t);
723
+ }, Sr = "\0", Cr = (e, t, n) => [
610
724
  e ?? "~",
611
725
  t,
612
- er(n)
613
- ].join("\0"), rr = (e) => {
726
+ xr(n)
727
+ ].join("\0"), wr = (e) => {
614
728
  let [t = "~", n = "", r = ""] = e.split("\0");
615
729
  return {
616
730
  tenantId: t === "~" ? null : t,
617
731
  event: n,
618
732
  key: r
619
733
  };
620
- }, ir = (e) => e.split("\0").join(" · "), z = Symbol.for("@voltro/protocol/workflow-access"), ar = {
734
+ }, Tr = (e) => e.split("\0").join(" · "), Er = Symbol.for("@voltro/protocol/workflow-access"), Dr = {
621
735
  guards: void 0,
622
736
  openAccess: void 0,
623
737
  internal: !1,
624
738
  controls: void 0,
625
739
  controlsOpenAccess: void 0
626
- }, or = (e, t) => {
740
+ }, Or = (e, t) => {
627
741
  let n = t.guards;
628
742
  if (n !== void 0 && n.length === 0) throw Error(`workflow("${e}"): \`guards: []\` is empty, so it enforces nothing —\n but it reads at the call site as if the start were protected. Omit the field
629
743
  and decide with \`openAccess\` or \`internal\`, or list the scopes that may start it.`);
@@ -655,17 +769,17 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
655
769
  controls: a === void 0 ? i : [r(a.trim())],
656
770
  controlsOpenAccess: a?.trim()
657
771
  };
658
- }, sr = (e, t) => {
659
- Object.defineProperty(e, z, {
772
+ }, kr = (e, t) => {
773
+ Object.defineProperty(e, Er, {
660
774
  value: t,
661
775
  enumerable: !1
662
776
  });
663
- }, B = (e) => {
664
- if (typeof e != "object" || !e) return ar;
665
- let t = e[z];
666
- return t === void 0 ? ar : t;
667
- }, cr = (e) => {
668
- let t = B(e);
777
+ }, Ar = (e) => {
778
+ if (typeof e != "object" && typeof e != "function" || e === null) return Dr;
779
+ let t = e[Er];
780
+ return t === void 0 ? Dr : t;
781
+ }, jr = (e) => {
782
+ let t = Ar(e);
669
783
  return {
670
784
  name: e.name,
671
785
  internal: t.internal,
@@ -673,38 +787,42 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
673
787
  openAccess: t.openAccess,
674
788
  controls: t.controls
675
789
  };
676
- }, lr = class extends h.TaggedError()("ApiUnavailable", {
677
- api: h.String,
678
- tag: h.String,
679
- reason: h.Literal("timeout", "transport", "closed"),
680
- message: h.String
681
- }) {}, ur = (e) => typeof e == "object" && !!e && e._tag === "ApiUnavailable", dr = (e) => e, fr = (e) => e, pr = (e) => {
790
+ }, Mr = class extends p.TaggedError()("ApiUnavailable", {
791
+ api: p.String,
792
+ tag: p.String,
793
+ reason: p.Literals([
794
+ "timeout",
795
+ "transport",
796
+ "closed"
797
+ ]),
798
+ message: p.String
799
+ }) {}, Nr = (e) => typeof e == "object" && !!e && e._tag === "ApiUnavailable", Pr = (e) => e, Fr = (e) => e, Ir = (e) => {
682
800
  let t = e.alias?.trim(), n = e.instance?.trim(), r = t !== void 0 && t !== "" ? t : e.base;
683
801
  return n !== void 0 && n !== "" ? `${r}#${n}` : r;
684
- }, mr = (e) => {
802
+ }, Lr = (e) => {
685
803
  if (e.length !== 0) return (t, n) => e.reduceRight((e, t) => t(e, n), t);
686
- }, hr = (e, t) => {
687
- let n = Tt.GenericTag(e);
804
+ }, Rr = (e, t) => {
805
+ let n = Dt.Service(e);
688
806
  return {
689
807
  Tag: n,
690
- Live: Ot.succeed(n, t)
808
+ Live: kt.succeed(n, t)
691
809
  };
692
- }, gr = (e, t, n) => {
810
+ }, zr = (e, t, n) => {
693
811
  if (!t) return { ok: !0 };
694
- let r = n === void 0 ? null : V(n);
812
+ let r = n === void 0 ? null : P(n);
695
813
  if (!r) return {
696
814
  ok: !0,
697
815
  unverified: `plugin "${e}" requires framework ${t}, but the running framework version is ${n === void 0 ? "unknown" : `unreadable ("${n}")`} — not checked.`
698
816
  };
699
817
  let i = t.trim();
700
818
  if (i === "*" || i === "") return { ok: !0 };
701
- let a = i.split(/\s+/).filter((e) => e.length > 0);
702
- for (let i of a) if (!_r(i, r)) return {
819
+ let a = i.split(/\s+/);
820
+ for (let i of a) if (!Br(i, r)) return {
703
821
  ok: !1,
704
822
  reason: `plugin "${e}" requires framework ${t}, running ${n}`
705
823
  };
706
824
  return { ok: !0 };
707
- }, V = (e) => {
825
+ }, P = (e) => {
708
826
  let t = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?$/.exec(e.trim());
709
827
  return t ? {
710
828
  major: Number(t[1]),
@@ -712,109 +830,142 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
712
830
  patch: Number(t[3]),
713
831
  pre: t[4] ?? ""
714
832
  } : null;
715
- }, H = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, _r = (e, t) => {
833
+ }, F = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, Br = (e, t) => {
716
834
  if (e === "*") return !0;
717
835
  if (e.startsWith("^")) {
718
- let n = V(e.slice(1));
719
- return !n || t.major !== n.major ? !1 : H(t, n) >= 0;
836
+ let n = P(e.slice(1));
837
+ return !n || t.major !== n.major ? !1 : F(t, n) >= 0;
720
838
  }
721
839
  if (e.startsWith("~")) {
722
- let n = V(e.slice(1));
723
- return !n || t.major !== n.major || t.minor !== n.minor ? !1 : H(t, n) >= 0;
840
+ let n = P(e.slice(1));
841
+ return !n || t.major !== n.major || t.minor !== n.minor ? !1 : F(t, n) >= 0;
724
842
  }
725
843
  let n = /^(>=|<=|>|<)(.+)$/.exec(e);
726
844
  if (n) {
727
- let e = n[1], r = V(n[2]);
845
+ let e = n[1], r = P(n[2]);
728
846
  if (!r) return !1;
729
- let i = H(t, r);
847
+ let i = F(t, r);
730
848
  if (e === ">=") return i >= 0;
731
849
  if (e === "<=") return i <= 0;
732
850
  if (e === ">") return i > 0;
733
851
  if (e === "<") return i < 0;
734
852
  }
735
- let r = V(e);
736
- return r ? H(t, r) === 0 : !1;
737
- }, vr = (e) => {
853
+ let r = P(e);
854
+ return r ? F(t, r) === 0 : !1;
855
+ }, Vr = (e) => {
738
856
  let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
739
857
  return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/-([a-zA-Z0-9])/g, (e, t) => t.toUpperCase());
740
- }, yr = (e) => {
858
+ }, Hr = (e) => {
741
859
  let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
742
860
  return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/#/g, "--").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
743
- }, br = Symbol.for("@voltro/protocol/pluginAliases"), U = () => {
744
- let e = globalThis, t = e[br];
861
+ }, Ur = Symbol.for("@voltro/protocol/pluginAliases"), I = () => {
862
+ let e = globalThis, t = e[Ur];
745
863
  if (t instanceof Map) return t;
746
864
  let n = /* @__PURE__ */ new Map();
747
- return e[br] = n, n;
748
- }, xr = (e) => {
749
- let t = U();
865
+ return e[Ur] = n, n;
866
+ }, Wr = (e) => {
867
+ let t = I();
750
868
  for (let [n, r] of Object.entries(e)) {
751
869
  if (r === "") continue;
752
870
  let e = t.get(n);
753
871
  e === void 0 ? t.set(n, /* @__PURE__ */ new Set([r])) : e.add(r);
754
872
  }
755
- }, Sr = () => {
756
- U().clear();
757
- }, Cr = (e, t) => {
758
- let n = U().get(e);
759
- if (n === void 0 || n.size === 0) return `${vr(e)}.${t}`;
760
- if (n.size === 1) return `${[...n][0]}.${t}`;
761
- let r = [...n].filter((e) => !e.includes("#"));
762
- if (r.length === 1) return `${r[0]}.${t}`;
873
+ }, Gr = () => {
874
+ I().clear();
875
+ }, Kr = (e, t) => {
876
+ let n = I().get(e);
877
+ if (n === void 0 || n.size === 0) return `${Vr(e)}.${t}`;
878
+ if (n.size === 1) for (let e of n) return `${e}.${t}`;
879
+ let r, i = 0;
880
+ for (let e of n) e.includes("#") || (r = e, i++);
881
+ if (i === 1) return `${r}.${t}`;
763
882
  throw Error(`[voltro] ${e} is installed more than once (${[...n].sort().join(", ")}) and no single install is the primary one, so a plugin hook cannot tell which of them it addresses. Call the route by its full tag instead — e.g. useSubscription(api, '${[...n].sort()[0]}.${t}').`);
764
- }, W = h.Union(h.Struct({
765
- kind: h.Literal("dropped"),
766
- at: h.Number,
767
- retryAfterMs: h.Number
768
- }), h.Struct({
769
- kind: h.Literal("skipped"),
770
- at: h.Number,
771
- executionId: h.String,
772
- runId: h.String
773
- }), h.Struct({
774
- kind: h.Literal("superseded"),
775
- at: h.Number
776
- }), h.Struct({
777
- kind: h.Literal("cancelled"),
778
- at: h.Number
779
- }), h.Struct({
780
- kind: h.Literal("abandoned"),
781
- at: h.Number,
782
- failureId: h.NonEmptyString
783
- })), G = h.Literal("running", "succeeded", "failed", "cancelled", "suspended"), K = h.Struct({
784
- id: h.String,
785
- workflowName: h.String,
786
- executionId: h.String,
787
- status: h.Union(G, h.Literal("unknown")),
788
- output: h.optional(h.Unknown),
789
- error: h.optional(h.Struct({
790
- tag: h.NullOr(h.String),
791
- message: h.String
792
- }))
793
- }), q = h.Struct({
794
- operation: h.Literal("cancel", "resume"),
795
- kind: h.Literal("accepted", "confirmed", "unknown", "already-terminal"),
796
- requestId: h.NullOr(h.NonEmptyString),
797
- snapshot: K
798
- }).pipe(h.filter((e) => e.kind === "unknown" ? !0 : e.kind === "accepted" ? e.requestId !== null && (e.snapshot.status === "running" || e.snapshot.status === "suspended") : e.kind === "already-terminal" ? e.snapshot.status === "succeeded" || e.snapshot.status === "failed" || e.snapshot.status === "cancelled" : e.operation === "cancel" ? e.snapshot.status === "cancelled" : e.requestId !== null && e.snapshot.status === "running", { message: () => "Workflow control acknowledgement contradicts its observed state or receipt identity" })), wr = h.Struct({
799
- operation: h.Literal("cancel"),
800
- workflowName: h.NonEmptyString,
801
- receiptId: h.NonEmptyString,
802
- requestId: h.NullOr(h.NonEmptyString),
803
- kind: h.Literal("accepted", "confirmed", "unknown", "already-terminal"),
804
- observation: h.Union(h.Struct({ kind: h.Literal("pending") }), h.Struct({
805
- kind: h.Literal("admission"),
806
- outcome: h.Union(W, h.Struct({
807
- kind: h.Literal("rejected"),
808
- failureId: h.NonEmptyString
809
- }))
810
- }), h.Struct({
811
- kind: h.Literal("execution"),
812
- snapshot: K
813
- }), h.Struct({
814
- kind: h.Literal("unavailable"),
815
- reason: h.Literal("missing-request", "missing-run", "unconfirmed-generation", "unbound-submission")
883
+ }, L = p.Union([
884
+ p.Struct({
885
+ kind: p.Literal("dropped"),
886
+ at: p.Number,
887
+ retryAfterMs: p.Number
888
+ }),
889
+ p.Struct({
890
+ kind: p.Literal("skipped"),
891
+ at: p.Number,
892
+ executionId: p.String,
893
+ runId: p.String
894
+ }),
895
+ p.Struct({
896
+ kind: p.Literal("superseded"),
897
+ at: p.Number
898
+ }),
899
+ p.Struct({
900
+ kind: p.Literal("cancelled"),
901
+ at: p.Number
902
+ }),
903
+ p.Struct({
904
+ kind: p.Literal("abandoned"),
905
+ at: p.Number,
906
+ failureId: p.NonEmptyString
907
+ })
908
+ ]), R = p.Literals([
909
+ "running",
910
+ "succeeded",
911
+ "failed",
912
+ "cancelled",
913
+ "suspended"
914
+ ]), z = p.Struct({
915
+ id: p.String,
916
+ workflowName: p.String,
917
+ executionId: p.String,
918
+ status: p.Union([R, p.Literal("unknown")]),
919
+ output: p.optional(p.Unknown),
920
+ error: p.optional(p.Struct({
921
+ tag: p.NullOr(p.String),
922
+ message: p.String
816
923
  }))
817
- }).pipe(h.filter((e) => {
924
+ }), B = p.Struct({
925
+ operation: p.Literals(["cancel", "resume"]),
926
+ kind: p.Literals([
927
+ "accepted",
928
+ "confirmed",
929
+ "unknown",
930
+ "already-terminal"
931
+ ]),
932
+ requestId: p.NullOr(p.NonEmptyString),
933
+ snapshot: z
934
+ }).pipe(p.check(p.makeFilter((e) => e.kind === "unknown" ? !0 : e.kind === "accepted" ? e.requestId !== null && (e.snapshot.status === "running" || e.snapshot.status === "suspended") : e.kind === "already-terminal" ? e.snapshot.status === "succeeded" || e.snapshot.status === "failed" || e.snapshot.status === "cancelled" : e.operation === "cancel" ? e.snapshot.status === "cancelled" : e.requestId !== null && e.snapshot.status === "running", { message: "Workflow control acknowledgement contradicts its observed state or receipt identity" }))), V = p.Struct({
935
+ operation: p.Literal("cancel"),
936
+ workflowName: p.NonEmptyString,
937
+ receiptId: p.NonEmptyString,
938
+ requestId: p.NullOr(p.NonEmptyString),
939
+ kind: p.Literals([
940
+ "accepted",
941
+ "confirmed",
942
+ "unknown",
943
+ "already-terminal"
944
+ ]),
945
+ observation: p.Union([
946
+ p.Struct({ kind: p.Literal("pending") }),
947
+ p.Struct({
948
+ kind: p.Literal("admission"),
949
+ outcome: p.Union([L, p.Struct({
950
+ kind: p.Literal("rejected"),
951
+ failureId: p.NonEmptyString
952
+ })])
953
+ }),
954
+ p.Struct({
955
+ kind: p.Literal("execution"),
956
+ snapshot: z
957
+ }),
958
+ p.Struct({
959
+ kind: p.Literal("unavailable"),
960
+ reason: p.Literals([
961
+ "missing-request",
962
+ "missing-run",
963
+ "unconfirmed-generation",
964
+ "unbound-submission"
965
+ ])
966
+ })
967
+ ])
968
+ }).pipe(p.check(p.makeFilter((e) => {
818
969
  let t = e.observation;
819
970
  if (t.kind === "unavailable") return e.kind === "unknown" && (t.reason === "missing-request" ? e.requestId === null : e.requestId !== null);
820
971
  if (e.requestId === null) return !1;
@@ -822,342 +973,384 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
822
973
  if (t.kind === "admission") return e.kind === (t.outcome.kind === "cancelled" ? "confirmed" : "already-terminal");
823
974
  let n = t.snapshot;
824
975
  return n.workflowName !== e.workflowName || n.id.length === 0 || n.executionId.length === 0 ? !1 : e.kind === "accepted" ? n.status === "running" || n.status === "suspended" : e.kind === "confirmed" ? n.status === "cancelled" : e.kind === "already-terminal" && (n.status === "succeeded" || n.status === "failed" || n.status === "cancelled");
825
- }, { message: () => "Queued cancellation acknowledgement contradicts its receipt or observation" })), Tr = h.Literal("cancel", "terminate", "abandon"), Er = h.Struct({
826
- mode: h.String,
827
- dueAt: h.NullOr(h.Number),
828
- retryAfterMs: h.NullOr(h.Number),
829
- intentId: h.NullOr(h.String)
830
- }), Dr = h.Struct({
831
- id: h.String,
832
- workflowName: h.String,
833
- executionId: h.NullOr(h.String),
834
- status: h.Literal("running", "succeeded", "queued", "dropped", "skipped", "replayed"),
835
- deferral: h.optional(Er)
836
- }), Or = (e, t) => {
837
- let n = B(e);
838
- return g.make(e.name, {
839
- payload: x(e.payloadSchema, e.name, I(n.guards)),
840
- success: Dr,
841
- error: jn({
976
+ }, { message: "Queued cancellation acknowledgement contradicts its receipt or observation" }))), qr = p.Literals([
977
+ "cancel",
978
+ "terminate",
979
+ "abandon"
980
+ ]), Jr = p.Struct({
981
+ mode: p.String,
982
+ dueAt: p.NullOr(p.Number),
983
+ retryAfterMs: p.NullOr(p.Number),
984
+ intentId: p.NullOr(p.String)
985
+ }), Yr = p.Struct({
986
+ id: p.String,
987
+ workflowName: p.String,
988
+ executionId: p.NullOr(p.String),
989
+ status: p.Literals([
990
+ "running",
991
+ "succeeded",
992
+ "queued",
993
+ "dropped",
994
+ "skipped",
995
+ "replayed"
996
+ ]),
997
+ deferral: p.optional(Jr)
998
+ }), Xr = (e, t) => {
999
+ let n = Ar(e);
1000
+ return h.make(e.name, {
1001
+ payload: x(e.payloadSchema, e.name, M(n.guards)),
1002
+ success: Yr,
1003
+ error: Zn({
842
1004
  errorSchema: e.errorSchema,
843
1005
  guards: n.guards
844
1006
  }, t)
845
1007
  });
846
- }, kr = h.Struct({
847
- id: h.String,
848
- tag: h.String,
849
- executionId: h.String,
850
- status: G,
851
- payload: h.Unknown,
852
- workflowVersion: h.NullOr(h.String),
853
- workflowPatches: h.NullOr(h.Unknown),
854
- output: h.NullOr(h.Unknown),
855
- subject: h.NullOr(h.Unknown),
856
- source: h.NullOr(h.String),
857
- errorTag: h.NullOr(h.String),
858
- errorMessage: h.NullOr(h.String),
859
- cancelled: h.Boolean,
860
- startedAt: h.Date,
861
- completedAt: h.NullOr(h.Date),
862
- durationMs: h.NullOr(h.Number),
863
- traceId: h.NullOr(h.String),
864
- parentExecutionId: h.NullOr(h.String),
865
- parentClosePolicy: h.NullOr(Tr)
866
- }), Ar = h.Struct({
867
- tag: h.optional(h.String),
868
- status: h.optional(G),
869
- limit: h.optional(h.Number)
870
- }), jr = h.Struct({
871
- id: h.String,
872
- runId: h.String,
873
- stepName: h.String,
874
- attempt: h.Number,
875
- status: h.Literal("running", "succeeded", "failed"),
876
- input: h.NullOr(h.Unknown),
877
- retryPolicy: h.NullOr(h.Unknown),
878
- output: h.NullOr(h.Unknown),
879
- errorTag: h.NullOr(h.String),
880
- errorMessage: h.NullOr(h.String),
881
- errorCause: h.NullOr(h.Unknown),
882
- startedAt: h.Date,
883
- completedAt: h.NullOr(h.Date),
884
- durationMs: h.NullOr(h.Number)
885
- }), Mr = h.Struct({
886
- id: h.String,
887
- runId: h.String,
888
- eventType: h.String,
889
- payload: h.NullOr(h.Unknown),
890
- occurredAt: h.Date,
891
- stepName: h.NullOr(h.String),
892
- attempt: h.NullOr(h.Number)
893
- }), Nr = h.Struct({
894
- id: h.String,
895
- name: h.String,
896
- payload: h.Unknown,
897
- source: h.String,
898
- subject: h.NullOr(h.Unknown),
899
- traceId: h.NullOr(h.String),
900
- occurredAt: h.Date
901
- }), Pr = h.Struct({
902
- id: h.String,
903
- eventId: h.String,
904
- eventName: h.String,
905
- triggerId: h.String,
906
- workflowName: h.String,
907
- executionId: h.NullOr(h.String),
908
- status: h.Literal("starting", "started", "skipped", "failed"),
909
- idempotencyKey: h.String,
910
- skipped: h.Boolean,
911
- errorMessage: h.NullOr(h.String),
912
- createdAt: h.Date,
913
- completedAt: h.NullOr(h.Date)
914
- }), Fr = h.Struct({ id: h.String }), Ir = h.Struct({ runId: h.String }), Lr = h.Struct({
915
- name: h.optional(h.String),
916
- limit: h.optional(h.Number)
917
- }), Rr = h.Struct({ eventId: h.String }), zr = h.Struct({
918
- requestId: h.NonEmptyString,
919
- cause: h.optionalWith(h.Struct({
920
- reason: h.NonEmptyString,
921
- detail: h.optional(h.Record({
922
- key: h.String,
923
- value: h.Unknown
924
- }))
925
- }), { exact: !0 })
926
- }), Br = h.Struct({
927
- workflowName: h.String,
928
- executionId: h.String,
929
- control: h.optional(zr)
930
- }), Vr = h.Struct({
931
- workflowName: h.NonEmptyString,
932
- executionId: h.NonEmptyString,
933
- operation: h.Literal("cancel", "resume"),
934
- requestId: h.NonEmptyString
935
- }), Hr = h.Struct({
936
- workflowName: h.NonEmptyString,
937
- receiptId: h.NonEmptyString,
938
- requestId: h.NonEmptyString
939
- }), Ur = h.Struct({
940
- ...Hr.fields,
941
- cause: zr.fields.cause
942
- }), Wr = F({
1008
+ }, H = p.Struct({
1009
+ id: p.String,
1010
+ tag: p.String,
1011
+ executionId: p.String,
1012
+ status: R,
1013
+ payload: p.Unknown,
1014
+ workflowVersion: p.NullOr(p.String),
1015
+ workflowPatches: p.NullOr(p.Unknown),
1016
+ output: p.NullOr(p.Unknown),
1017
+ subject: p.NullOr(p.Unknown),
1018
+ source: p.NullOr(p.String),
1019
+ errorTag: p.NullOr(p.String),
1020
+ errorMessage: p.NullOr(p.String),
1021
+ cancelled: p.Boolean,
1022
+ startedAt: p.DateFromString,
1023
+ completedAt: p.NullOr(p.DateFromString),
1024
+ durationMs: p.NullOr(p.Number),
1025
+ traceId: p.NullOr(p.String),
1026
+ parentExecutionId: p.NullOr(p.String),
1027
+ parentClosePolicy: p.NullOr(qr)
1028
+ }), Zr = p.Struct({
1029
+ tag: p.optional(p.String),
1030
+ status: p.optional(R),
1031
+ limit: p.optional(p.Number)
1032
+ }), Qr = p.Struct({
1033
+ id: p.String,
1034
+ runId: p.String,
1035
+ stepName: p.String,
1036
+ attempt: p.Number,
1037
+ status: p.Literals([
1038
+ "running",
1039
+ "succeeded",
1040
+ "failed"
1041
+ ]),
1042
+ input: p.NullOr(p.Unknown),
1043
+ retryPolicy: p.NullOr(p.Unknown),
1044
+ output: p.NullOr(p.Unknown),
1045
+ errorTag: p.NullOr(p.String),
1046
+ errorMessage: p.NullOr(p.String),
1047
+ errorCause: p.NullOr(p.Unknown),
1048
+ startedAt: p.DateFromString,
1049
+ completedAt: p.NullOr(p.DateFromString),
1050
+ durationMs: p.NullOr(p.Number)
1051
+ }), $r = p.Struct({
1052
+ id: p.String,
1053
+ runId: p.String,
1054
+ eventType: p.String,
1055
+ payload: p.NullOr(p.Unknown),
1056
+ occurredAt: p.DateFromString,
1057
+ stepName: p.NullOr(p.String),
1058
+ attempt: p.NullOr(p.Number)
1059
+ }), ei = p.Struct({
1060
+ id: p.String,
1061
+ name: p.String,
1062
+ payload: p.Unknown,
1063
+ source: p.String,
1064
+ subject: p.NullOr(p.Unknown),
1065
+ traceId: p.NullOr(p.String),
1066
+ occurredAt: p.DateFromString
1067
+ }), ti = p.Struct({
1068
+ id: p.String,
1069
+ eventId: p.String,
1070
+ eventName: p.String,
1071
+ triggerId: p.String,
1072
+ workflowName: p.String,
1073
+ executionId: p.NullOr(p.String),
1074
+ status: p.Literals([
1075
+ "starting",
1076
+ "started",
1077
+ "skipped",
1078
+ "failed"
1079
+ ]),
1080
+ idempotencyKey: p.String,
1081
+ skipped: p.Boolean,
1082
+ errorMessage: p.NullOr(p.String),
1083
+ createdAt: p.DateFromString,
1084
+ completedAt: p.NullOr(p.DateFromString)
1085
+ }), ni = p.Struct({ id: p.String }), U = p.Struct({ runId: p.String }), ri = p.Struct({
1086
+ name: p.optional(p.String),
1087
+ limit: p.optional(p.Number)
1088
+ }), ii = p.Struct({ eventId: p.String }), ai = p.Struct({
1089
+ requestId: p.NonEmptyString,
1090
+ cause: p.optionalKey(p.Struct({
1091
+ reason: p.NonEmptyString,
1092
+ detail: p.optional(p.Record(p.String, p.Unknown))
1093
+ }))
1094
+ }), oi = p.Struct({
1095
+ workflowName: p.String,
1096
+ executionId: p.String,
1097
+ control: p.optional(ai)
1098
+ }), si = p.Struct({
1099
+ workflowName: p.NonEmptyString,
1100
+ executionId: p.NonEmptyString,
1101
+ operation: p.Literals(["cancel", "resume"]),
1102
+ requestId: p.NonEmptyString
1103
+ }), ci = p.Struct({
1104
+ workflowName: p.NonEmptyString,
1105
+ receiptId: p.NonEmptyString,
1106
+ requestId: p.NonEmptyString
1107
+ }), li = p.Struct({
1108
+ ...ci.fields,
1109
+ cause: ai.fields.cause
1110
+ }), ui = j({
943
1111
  name: "__voltro.workflow.queued.cancel",
944
- input: Ur,
945
- output: wr,
1112
+ input: li,
1113
+ output: V,
946
1114
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
947
- }), Gr = N({
1115
+ }), di = k({
948
1116
  name: "__voltro.workflow.queued.control",
949
- input: Hr,
950
- output: wr,
1117
+ input: ci,
1118
+ output: V,
951
1119
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
952
- }), Kr = N({
1120
+ }), fi = k({
953
1121
  name: "__voltro.workflow.control",
954
- input: Vr,
955
- output: q,
1122
+ input: si,
1123
+ output: B,
956
1124
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
957
- }), qr = h.Struct({
958
- id: h.String,
959
- signalName: h.String,
960
- payload: h.optional(h.Unknown)
961
- }), Jr = h.Struct({
962
- id: h.String,
963
- updateName: h.String,
964
- payload: h.optional(h.Unknown),
965
- timeoutMs: h.optional(h.Number)
966
- }), Yr = h.Struct({
967
- eventId: h.String,
968
- updateId: h.String,
969
- completedEventId: h.String,
970
- result: h.Unknown
971
- }), Xr = N({
1125
+ }), pi = p.Struct({
1126
+ id: p.String,
1127
+ signalName: p.String,
1128
+ payload: p.optional(p.Unknown)
1129
+ }), mi = p.Struct({
1130
+ id: p.String,
1131
+ updateName: p.String,
1132
+ payload: p.optional(p.Unknown),
1133
+ timeoutMs: p.optional(p.Number)
1134
+ }), hi = p.Struct({
1135
+ eventId: p.String,
1136
+ updateId: p.String,
1137
+ completedEventId: p.String,
1138
+ result: p.Unknown
1139
+ }), gi = k({
972
1140
  name: "__voltro.workflow.run",
973
1141
  source: "_voltro_workflow_runs",
974
- input: Fr,
975
- output: h.Array(kr),
1142
+ input: ni,
1143
+ output: p.Array(H),
976
1144
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
977
- }), Zr = N({
1145
+ }), _i = k({
978
1146
  name: "__voltro.workflow.runs",
979
1147
  source: "_voltro_workflow_runs",
980
- input: Ar,
981
- output: h.Array(kr),
1148
+ input: Zr,
1149
+ output: p.Array(H),
982
1150
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
983
- }), Qr = N({
1151
+ }), vi = k({
984
1152
  name: "__voltro.workflow.run.steps",
985
1153
  source: "_voltro_workflow_run_steps",
986
- input: Ir,
987
- output: h.Array(jr),
1154
+ input: U,
1155
+ output: p.Array(Qr),
988
1156
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
989
- }), $r = N({
1157
+ }), yi = k({
990
1158
  name: "__voltro.workflow.run.events",
991
1159
  source: "_voltro_workflow_run_events",
992
- input: Ir,
993
- output: h.Array(Mr),
1160
+ input: U,
1161
+ output: p.Array($r),
994
1162
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
995
- }), ei = N({
1163
+ }), bi = k({
996
1164
  name: "__voltro.workflow.domainEvents",
997
1165
  source: "_voltro_workflow_events",
998
- input: Lr,
999
- output: h.Array(Nr),
1166
+ input: ri,
1167
+ output: p.Array(ei),
1000
1168
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
1001
- }), ti = N({
1169
+ }), xi = k({
1002
1170
  name: "__voltro.workflow.event.deliveries",
1003
1171
  source: "_voltro_workflow_event_deliveries",
1004
- input: Rr,
1005
- output: h.Array(Pr),
1172
+ input: ii,
1173
+ output: p.Array(ti),
1006
1174
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
1007
- }), ni = F({
1175
+ }), Si = j({
1008
1176
  name: "__voltro.workflow.cancel",
1009
- input: Br,
1010
- output: q,
1177
+ input: oi,
1178
+ output: B,
1011
1179
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
1012
- }), ri = F({
1180
+ }), Ci = j({
1013
1181
  name: "__voltro.workflow.resume",
1014
- input: Br,
1015
- output: q,
1182
+ input: oi,
1183
+ output: B,
1016
1184
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
1017
- }), ii = F({
1185
+ }), wi = j({
1018
1186
  name: "__voltro.workflow.signal",
1019
- input: qr,
1020
- output: h.Struct({ eventId: h.String }),
1187
+ input: pi,
1188
+ output: p.Struct({ eventId: p.String }),
1021
1189
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
1022
- }), ai = F({
1190
+ }), Ti = j({
1023
1191
  name: "__voltro.workflow.update",
1024
- input: Jr,
1025
- output: Yr,
1192
+ input: mi,
1193
+ output: hi,
1026
1194
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
1027
- }), oi = h.NonEmptyString.pipe(h.filter((e) => e.trim().length > 0, { message: () => "A workflow retry identity must not be blank" })), si = h.Struct({
1028
- runId: oi,
1029
- requestId: oi
1030
- }), ci = h.Struct({
1031
- ...si.fields,
1032
- payloadOverride: h.optional(h.Unknown)
1033
- }), J = {
1034
- requestId: h.NonEmptyString,
1035
- originalRunId: h.NonEmptyString,
1036
- originalExecutionId: h.NonEmptyString,
1037
- workflowName: h.NonEmptyString
1038
- }, li = h.Union(h.Struct({
1039
- ...J,
1040
- kind: h.Literal("queued"),
1041
- nextAttemptAt: h.NullOr(h.Number)
1042
- }), h.Struct({
1043
- ...J,
1044
- kind: h.Literal("accepted"),
1045
- executionId: h.NonEmptyString
1046
- }).pipe(h.filter((e) => e.executionId !== e.originalExecutionId, { message: () => "A retry cannot accept its original execution identity" })), h.Struct({
1047
- ...J,
1048
- kind: h.Literal("unconfirmed"),
1049
- automaticRetryStopped: h.Boolean,
1050
- nextAttemptAt: h.NullOr(h.Number)
1051
- }).pipe(h.filter((e) => !e.automaticRetryStopped || e.nextAttemptAt === null, { message: () => "Stopped automatic retries cannot have a next attempt" })), h.Struct({
1052
- ...J,
1053
- kind: h.Literal("not-started"),
1054
- outcome: W
1055
- }), h.Struct({
1056
- ...J,
1057
- kind: h.Literal("rejected"),
1058
- failureId: h.NonEmptyString
1059
- })), Y = h.NonEmptyString.pipe(h.filter((e) => e.trim().length > 0, { message: () => "A workflow restart identity must not be blank" })), ui = h.Union(h.Struct({ kind: h.Literal("failed-steps") }), h.Struct({
1060
- kind: h.Literal("from-step"),
1061
- stepName: Y
1062
- })), X = h.Struct({
1063
- requestId: Y.pipe(h.maxLength(64)),
1064
- runId: Y
1065
- }), di = h.Struct({
1066
- ...X.fields,
1067
- selection: ui
1068
- }), fi = {
1069
- ...di.fields,
1070
- workflowName: Y,
1071
- executionId: Y,
1072
- originalGeneration: Y,
1073
- requestedAt: h.Number.pipe(h.finite()),
1074
- dispatchAttempts: h.NonNegativeInt
1075
- }, pi = h.Union(h.Struct({
1076
- ...X.fields,
1077
- kind: h.Literal("not-found")
1078
- }), h.Struct({
1079
- ...di.fields,
1080
- kind: h.Literal("withdrawn"),
1081
- workflowName: Y,
1082
- withdrawnAt: h.Number.pipe(h.finite())
1083
- }), h.Struct({
1084
- ...fi,
1085
- kind: h.Literal("pending")
1086
- }), h.Struct({
1087
- ...fi,
1088
- kind: h.Literal("entered"),
1089
- enteredGeneration: Y
1090
- }).pipe(h.filter((e) => e.enteredGeneration !== e.originalGeneration && e.dispatchAttempts > 0, { message: () => "Restart entry requires a dispatched command and a new generation" }))), mi = h.Union(pi, h.Struct({
1091
- ...X.fields,
1092
- kind: h.Literal("not-reserved"),
1093
- reason: h.Literal("admission", "journal")
1094
- })), hi = "__voltro.undo.log", gi = "__voltro.undo.apply", _i = "__voltro.undo.redo", vi = h.Struct({
1095
- id: h.String,
1096
- tag: h.String,
1097
- label: h.NullOr(h.String),
1098
- undone: h.Boolean,
1099
- crossesAction: h.Boolean,
1100
- createdAt: h.String
1101
- }), yi = class extends h.TaggedError()("UndoNotFound", { invocationId: h.String }) {}, bi = class extends h.TaggedError()("UndoForbidden", { invocationId: h.String }) {}, xi = class extends h.TaggedError()("UndoConflict", {
1102
- invocationId: h.String,
1103
- reason: h.Literal("conflict", "action")
1104
- }) {}, Si = h.Union(yi, bi, xi), Ci = N({
1105
- name: hi,
1195
+ }), Ei = p.NonEmptyString.pipe(p.check(p.makeFilter((e) => e.trim().length > 0, { message: "A workflow retry identity must not be blank" }))), Di = p.Struct({
1196
+ runId: Ei,
1197
+ requestId: Ei
1198
+ }), Oi = p.Struct({
1199
+ ...Di.fields,
1200
+ payloadOverride: p.optional(p.Unknown)
1201
+ }), W = {
1202
+ requestId: p.NonEmptyString,
1203
+ originalRunId: p.NonEmptyString,
1204
+ originalExecutionId: p.NonEmptyString,
1205
+ workflowName: p.NonEmptyString
1206
+ }, ki = p.Union([
1207
+ p.Struct({
1208
+ ...W,
1209
+ kind: p.Literal("queued"),
1210
+ nextAttemptAt: p.NullOr(p.Number)
1211
+ }),
1212
+ p.Struct({
1213
+ ...W,
1214
+ kind: p.Literal("accepted"),
1215
+ executionId: p.NonEmptyString
1216
+ }).pipe(p.check(p.makeFilter((e) => e.executionId !== e.originalExecutionId, { message: "A retry cannot accept its original execution identity" }))),
1217
+ p.Struct({
1218
+ ...W,
1219
+ kind: p.Literal("unconfirmed"),
1220
+ automaticRetryStopped: p.Boolean,
1221
+ nextAttemptAt: p.NullOr(p.Number)
1222
+ }).pipe(p.check(p.makeFilter((e) => !e.automaticRetryStopped || e.nextAttemptAt === null, { message: "Stopped automatic retries cannot have a next attempt" }))),
1223
+ p.Struct({
1224
+ ...W,
1225
+ kind: p.Literal("not-started"),
1226
+ outcome: L
1227
+ }),
1228
+ p.Struct({
1229
+ ...W,
1230
+ kind: p.Literal("rejected"),
1231
+ failureId: p.NonEmptyString
1232
+ })
1233
+ ]), G = p.NonEmptyString.pipe(p.check(p.makeFilter((e) => e.trim().length > 0, { message: "A workflow restart identity must not be blank" }))), Ai = p.Union([p.Struct({ kind: p.Literal("failed-steps") }), p.Struct({
1234
+ kind: p.Literal("from-step"),
1235
+ stepName: G
1236
+ })]), K = p.Struct({
1237
+ requestId: G.pipe(p.check(p.isMaxLength(64))),
1238
+ runId: G
1239
+ }), ji = p.Struct({
1240
+ ...K.fields,
1241
+ selection: Ai
1242
+ }), Mi = {
1243
+ ...ji.fields,
1244
+ workflowName: G,
1245
+ executionId: G,
1246
+ originalGeneration: G,
1247
+ requestedAt: p.Number.pipe(p.check(p.isFinite())),
1248
+ dispatchAttempts: p.Number.check(p.isInt(), p.isGreaterThanOrEqualTo(0))
1249
+ }, Ni = p.Union([
1250
+ p.Struct({
1251
+ ...K.fields,
1252
+ kind: p.Literal("not-found")
1253
+ }),
1254
+ p.Struct({
1255
+ ...ji.fields,
1256
+ kind: p.Literal("withdrawn"),
1257
+ workflowName: G,
1258
+ withdrawnAt: p.Number.pipe(p.check(p.isFinite()))
1259
+ }),
1260
+ p.Struct({
1261
+ ...Mi,
1262
+ kind: p.Literal("pending")
1263
+ }),
1264
+ p.Struct({
1265
+ ...Mi,
1266
+ kind: p.Literal("entered"),
1267
+ enteredGeneration: G
1268
+ }).pipe(p.check(p.makeFilter((e) => e.enteredGeneration !== e.originalGeneration && e.dispatchAttempts > 0, { message: "Restart entry requires a dispatched command and a new generation" })))
1269
+ ]), Pi = p.Union([Ni, p.Struct({
1270
+ ...K.fields,
1271
+ kind: p.Literal("not-reserved"),
1272
+ reason: p.Literals(["admission", "journal"])
1273
+ })]), Fi = "__voltro.undo.log", Ii = "__voltro.undo.apply", Li = "__voltro.undo.redo", Ri = p.Struct({
1274
+ id: p.String,
1275
+ tag: p.String,
1276
+ label: p.NullOr(p.String),
1277
+ undone: p.Boolean,
1278
+ crossesAction: p.Boolean,
1279
+ createdAt: p.String
1280
+ }), zi = class extends p.TaggedError()("UndoNotFound", { invocationId: p.String }) {}, Bi = class extends p.TaggedError()("UndoForbidden", { invocationId: p.String }) {}, Vi = class extends p.TaggedError()("UndoConflict", {
1281
+ invocationId: p.String,
1282
+ reason: p.Literals(["conflict", "action"])
1283
+ }) {}, Hi = p.Union([
1284
+ zi,
1285
+ Bi,
1286
+ Vi
1287
+ ]), Ui = k({
1288
+ name: Fi,
1106
1289
  source: "_voltro_undo_log",
1107
- input: h.Struct({ limit: h.optional(h.Number) }),
1108
- output: h.Array(vi),
1290
+ input: p.Struct({ limit: p.optional(p.Number) }),
1291
+ output: p.Array(Ri),
1109
1292
  openAccess: "subject-scoped by construction: lists only the calling subject's own undoable actions"
1110
- }), wi = P({
1111
- name: gi,
1112
- input: h.Struct({ invocationId: h.String }),
1113
- output: h.Struct({ ok: h.Boolean }),
1114
- error: Si,
1293
+ }), Wi = A({
1294
+ name: Ii,
1295
+ input: p.Struct({ invocationId: p.String }),
1296
+ output: p.Struct({ ok: p.Boolean }),
1297
+ error: Hi,
1115
1298
  openAccess: "subject-scoped by construction: undo is per-actor — another subject's invocation fails typed with UndoForbidden"
1116
- }), Ti = P({
1117
- name: _i,
1118
- input: h.Struct({ invocationId: h.String }),
1119
- output: h.Struct({ ok: h.Boolean }),
1120
- error: Si,
1299
+ }), Gi = A({
1300
+ name: Li,
1301
+ input: p.Struct({ invocationId: p.String }),
1302
+ output: p.Struct({ ok: p.Boolean }),
1303
+ error: Hi,
1121
1304
  openAccess: "subject-scoped by construction: redo is per-actor — another subject's invocation fails typed with UndoForbidden"
1122
- }), Ei = class extends h.TaggedError()("TenantScopeViolation", {
1123
- table: h.String,
1124
- reason: h.String
1125
- }) {}, Di = class extends h.TaggedError()("StoreOperationFailed", {
1126
- operation: h.String,
1127
- table: h.String,
1128
- cause: h.String
1305
+ }), Ki = class extends p.TaggedError()("TenantScopeViolation", {
1306
+ table: p.String,
1307
+ reason: p.String
1308
+ }) {}, qi = class extends p.TaggedError()("StoreOperationFailed", {
1309
+ operation: p.String,
1310
+ table: p.String,
1311
+ cause: p.String
1129
1312
  }) {
1130
1313
  get message() {
1131
1314
  return `${this.operation} on '${this.table}' failed: ${this.cause}`;
1132
1315
  }
1133
- }, Oi = class extends h.TaggedError()("NoRowFound", {
1134
- table: h.String,
1135
- found: h.Number
1316
+ }, Ji = class extends p.TaggedError()("NoRowFound", {
1317
+ table: p.String,
1318
+ found: p.Number
1136
1319
  }) {
1137
1320
  get message() {
1138
1321
  return this.found === 0 ? `expected exactly one row in '${this.table}', found none` : `expected exactly one row in '${this.table}', found more than one`;
1139
1322
  }
1140
- }, ki = class extends h.TaggedError()("TableValidationFailed", {
1141
- table: h.String,
1142
- summary: h.String,
1143
- issues: h.Array(h.Struct({
1144
- path: h.String,
1145
- message: h.String
1323
+ }, Yi = class extends p.TaggedError()("TableValidationFailed", {
1324
+ table: p.String,
1325
+ summary: p.String,
1326
+ issues: p.Array(p.Struct({
1327
+ path: p.String,
1328
+ message: p.String
1146
1329
  }))
1147
- }) {}, Ai = class extends h.TaggedError()("TenantRowNotFound", {
1148
- table: h.String,
1149
- id: h.String,
1150
- reason: h.String
1151
- }) {}, ji = class extends h.TaggedError()("ServerOnlyColumnWrite", {
1152
- table: h.String,
1153
- columns: h.Array(h.String)
1154
- }) {}, Mi = class extends h.TaggedError()("ConstraintViolation", {
1155
- kind: h.Literal("foreignKey", "foreignKeyInUse", "unique", "notNull", "check"),
1156
- table: h.String,
1157
- operation: h.String,
1158
- constraint: h.optional(h.String),
1159
- column: h.optional(h.String),
1160
- detail: h.optional(h.String)
1330
+ }) {
1331
+ get message() {
1332
+ return this.summary;
1333
+ }
1334
+ }, Xi = class extends p.TaggedError()("TenantRowNotFound", {
1335
+ table: p.String,
1336
+ id: p.String,
1337
+ reason: p.String
1338
+ }) {}, Zi = class extends p.TaggedError()("ServerOnlyColumnWrite", {
1339
+ table: p.String,
1340
+ columns: p.Array(p.String)
1341
+ }) {}, Qi = class extends p.TaggedError()("ConstraintViolation", {
1342
+ kind: p.Literals([
1343
+ "foreignKey",
1344
+ "foreignKeyInUse",
1345
+ "unique",
1346
+ "notNull",
1347
+ "check"
1348
+ ]),
1349
+ table: p.String,
1350
+ operation: p.String,
1351
+ constraint: p.optional(p.String),
1352
+ column: p.optional(p.String),
1353
+ detail: p.optional(p.String)
1161
1354
  }) {
1162
1355
  get message() {
1163
1356
  if (this.detail !== void 0) return this.detail;
@@ -1170,86 +1363,101 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
1170
1363
  case "check": return `check constraint ${t}: the row does not satisfy it`;
1171
1364
  }
1172
1365
  }
1173
- }, Ni = "__voltro.approvals.pending", Pi = "__voltro.approvals.decide", Fi = N({
1174
- name: Ni,
1366
+ }, $i = "__voltro.approvals.pending", ea = "__voltro.approvals.decide", ta = k({
1367
+ name: $i,
1175
1368
  source: "_voltro_approvals",
1176
- input: h.Struct({ limit: h.optional(h.Number) }),
1177
- output: h.Array(en),
1369
+ input: p.Struct({ limit: p.optional(p.Number) }),
1370
+ output: p.Array(bn),
1178
1371
  openAccess: "the answer is scoped to the caller — a row appears only if they requested it or hold its recorded approver scopes, so an anonymous caller sees nothing"
1179
- }), Ii = P({
1180
- name: Pi,
1181
- input: h.Struct({
1182
- approvalId: h.String,
1183
- decision: h.Literal("approve", "reject"),
1184
- note: h.optional(h.String)
1372
+ }), na = A({
1373
+ name: ea,
1374
+ input: p.Struct({
1375
+ approvalId: p.String,
1376
+ decision: p.Literals(["approve", "reject"]),
1377
+ note: p.optional(p.String)
1185
1378
  }),
1186
- output: h.Struct({
1187
- approvalId: h.String,
1188
- status: h.Literal("approved", "rejected")
1379
+ output: p.Struct({
1380
+ approvalId: p.String,
1381
+ status: p.Literals(["approved", "rejected"])
1189
1382
  }),
1190
- error: $t,
1383
+ error: yn,
1191
1384
  openAccess: "the approver authority is the PENDING ROW's own recorded scopes (plus an unconditional self-approval refusal), checked in-handler — a descriptor-level scope would have to be the union of every approval-requiring procedure in the app"
1192
- }), Li = "__voltro.connections.list", Ri = "__voltro.connections.start", zi = "__voltro.connections.submitToken", Bi = "__voltro.connections.disconnect", Z = h.Literal("oauth2", "pat"), Vi = h.Literal("disconnected", "connected", "expired", "revoked", "error"), Hi = h.Struct({
1193
- connectionId: h.String,
1194
- kind: Z,
1195
- label: h.String,
1196
- status: Vi,
1197
- accountId: h.NullOr(h.String),
1198
- accountLabel: h.NullOr(h.String),
1199
- scopes: h.Array(h.String),
1200
- expiresAt: h.NullOr(h.String),
1201
- lastError: h.NullOr(h.String),
1202
- connectedAt: h.NullOr(h.String)
1203
- }), Ui = class extends h.TaggedError()("ConnectionNotDeclared", { connectionId: h.String }) {}, Wi = class extends h.TaggedError()("ConnectionSubjectRequired", { connectionId: h.String }) {}, Gi = class extends h.TaggedError()("ConnectionKindMismatch", {
1204
- connectionId: h.String,
1205
- expected: Z,
1206
- actual: Z
1207
- }) {}, Ki = class extends h.TaggedError()("ConnectionHandshakeFailed", {
1208
- connectionId: h.String,
1209
- reason: h.String,
1210
- transient: h.Boolean
1211
- }) {}, qi = h.Union(Ui, Wi, Gi, Ki), Ji = N({
1212
- name: Li,
1385
+ }), ra = "__voltro.connections.list", ia = "__voltro.connections.start", aa = "__voltro.connections.submitToken", oa = "__voltro.connections.disconnect", q = p.Literals(["oauth2", "pat"]), sa = p.Literals([
1386
+ "disconnected",
1387
+ "connected",
1388
+ "expired",
1389
+ "revoked",
1390
+ "error"
1391
+ ]), ca = p.Struct({
1392
+ connectionId: p.String,
1393
+ kind: q,
1394
+ label: p.String,
1395
+ status: sa,
1396
+ accountId: p.NullOr(p.String),
1397
+ accountLabel: p.NullOr(p.String),
1398
+ scopes: p.Array(p.String),
1399
+ expiresAt: p.NullOr(p.String),
1400
+ lastError: p.NullOr(p.String),
1401
+ connectedAt: p.NullOr(p.String)
1402
+ }), la = class extends p.TaggedError()("ConnectionNotDeclared", { connectionId: p.String }) {}, ua = class extends p.TaggedError()("ConnectionSubjectRequired", { connectionId: p.String }) {}, da = class extends p.TaggedError()("ConnectionKindMismatch", {
1403
+ connectionId: p.String,
1404
+ expected: q,
1405
+ actual: q
1406
+ }) {}, fa = class extends p.TaggedError()("ConnectionHandshakeFailed", {
1407
+ connectionId: p.String,
1408
+ reason: p.String,
1409
+ transient: p.Boolean
1410
+ }) {
1411
+ get message() {
1412
+ return this.reason;
1413
+ }
1414
+ }, J = p.Union([
1415
+ la,
1416
+ ua,
1417
+ da,
1418
+ fa
1419
+ ]), pa = k({
1420
+ name: ra,
1213
1421
  source: "_voltro_connections",
1214
- input: h.Struct({}),
1215
- output: h.Array(Hi),
1422
+ input: p.Struct({}),
1423
+ output: p.Array(ca),
1216
1424
  openAccess: "self-scoped read: projects the declared connections for the calling subject only (its own connect/disconnect state)"
1217
- }), Yi = F({
1218
- name: Ri,
1219
- input: h.Struct({
1220
- connectionId: h.String,
1221
- redirectTo: h.optional(h.String)
1425
+ }), ma = j({
1426
+ name: ia,
1427
+ input: p.Struct({
1428
+ connectionId: p.String,
1429
+ redirectTo: p.optional(p.String)
1222
1430
  }),
1223
- output: h.Struct({
1224
- authorizeUrl: h.String,
1225
- state: h.String
1431
+ output: p.Struct({
1432
+ authorizeUrl: p.String,
1433
+ state: p.String
1226
1434
  }),
1227
- error: qi,
1435
+ error: J,
1228
1436
  openAccess: "self-service: begins an oauth handshake that stores a credential for the calling subject only; anonymous callers fail typed with ConnectionSubjectRequired"
1229
- }), Xi = P({
1230
- name: zi,
1231
- input: h.Struct({
1232
- connectionId: h.String,
1233
- token: h.String
1437
+ }), ha = A({
1438
+ name: aa,
1439
+ input: p.Struct({
1440
+ connectionId: p.String,
1441
+ token: p.String
1234
1442
  }),
1235
- output: h.Struct({ ok: h.Boolean }),
1236
- error: qi,
1443
+ output: p.Struct({ ok: p.Boolean }),
1444
+ error: J,
1237
1445
  openAccess: "self-service: stores a pasted token as the calling subject's own credential; anonymous callers fail typed with ConnectionSubjectRequired"
1238
- }), Zi = P({
1239
- name: Bi,
1240
- input: h.Struct({ connectionId: h.String }),
1241
- output: h.Struct({ ok: h.Boolean }),
1242
- error: qi,
1446
+ }), ga = A({
1447
+ name: oa,
1448
+ input: p.Struct({ connectionId: p.String }),
1449
+ output: p.Struct({ ok: p.Boolean }),
1450
+ error: J,
1243
1451
  openAccess: "self-service: deletes only the calling subject's own credential row for this connection"
1244
- }), Qi = (e) => {
1452
+ }), _a = (e) => {
1245
1453
  let t = e instanceof Date ? e.getTime() : typeof e == "number" ? e : typeof e == "string" ? new Date(e).getTime() : 0;
1246
1454
  return Number.isNaN(t) ? 0 : t;
1247
- }, $i = [
1455
+ }, va = [
1248
1456
  "app-store",
1249
1457
  "play",
1250
1458
  "mac-app-store",
1251
1459
  "microsoft-store"
1252
- ], Q = [
1460
+ ], Y = [
1253
1461
  {
1254
1462
  name: "iphone-6.7",
1255
1463
  label: "iPhone 6.7″ — 1290×2796",
@@ -1327,39 +1535,88 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
1327
1535
  deviceScaleFactor: 1,
1328
1536
  stores: ["microsoft-store"]
1329
1537
  }
1330
- ], ea = Q.map((e) => e.name), ta = (e) => Q.find((t) => t.name === e), na = (e) => ({
1538
+ ], ya = Y.map((e) => e.name), ba = (e) => Y.find((t) => t.name === e), xa = (e) => ({
1331
1539
  width: e.viewport.width * e.deviceScaleFactor,
1332
1540
  height: e.viewport.height * e.deviceScaleFactor
1333
- }), ra = (e) => Q.filter((t) => t.stores.includes(e)), ia = 4001, aa = /* @__PURE__ */ new Set(["/rpc", "/ws"]), oa = (e) => {
1541
+ }), Sa = (e) => Y.filter((t) => t.stores.includes(e)), Ca = 4001, wa = /* @__PURE__ */ new Set(["/rpc", "/ws"]), Ta = (e) => {
1334
1542
  for (let [t, n] of Object.entries(e.limits ?? {})) if (n !== void 0 && (!Number.isSafeInteger(n) || n <= 0)) throw Error(`defineWebSocket: limits.${t} must be a positive safe integer`);
1335
1543
  if (!e.path.startsWith("/")) throw Error(`defineWebSocket: path must be absolute, got '${e.path}'`);
1336
- if (aa.has(e.path)) throw Error(`defineWebSocket: '${e.path}' is the framework's own socket surface — mount the gateway elsewhere`);
1544
+ if (wa.has(e.path)) throw Error(`defineWebSocket: '${e.path}' is the framework's own socket surface — mount the gateway elsewhere`);
1337
1545
  if (e.auth !== "subject" && e.auth !== "public") throw Error(`defineWebSocket: auth must be 'subject' or 'public' (explicitly — an unauthenticated socket has to be a decision somebody wrote down), got '${String(e.auth)}'`);
1338
1546
  return e;
1339
- }, sa = "voltro-dev", ca = "pair", $ = "voltro:pairing", la = (e) => {
1547
+ }, X = (e) => typeof e == "object" && !!e && !Array.isArray(e), Z = (e, t = /* @__PURE__ */ new Map()) => {
1548
+ let n = t.get(e);
1549
+ if (n !== void 0) return n;
1550
+ let r = Ea(e, t);
1551
+ return t.set(e, r), r;
1552
+ }, Ea = (e, t) => e.encoding === void 0 ? m.isNumber(e) ? p.make(e).check(p.isFinite()).ast : m.isObjects(e) ? new m.Objects(e.propertySignatures.map((e) => new m.PropertySignature(e.name, Z(e.type, t))), e.indexSignatures.map((e) => new m.IndexSignature(e.parameter, Z(e.type, t))), e.annotations, e.checks, void 0, e.context) : m.isArrays(e) ? new m.Arrays(e.isMutable, e.elements.map((e) => Z(e, t)), e.rest.map((e) => Z(e, t)), e.annotations, e.checks, void 0, e.context) : m.isUnion(e) ? new m.Union(e.types.map((e) => Z(e, t)), e.options, e.annotations, e.checks, void 0, e.context) : m.isSuspend(e) ? new m.Suspend(() => Z(e.thunk(), t), e.annotations, e.checks, void 0, e.context) : e : e, Q = (e) => {
1553
+ if (Array.isArray(e)) return e.map(Q);
1554
+ if (!X(e)) return e;
1555
+ let t = e.not;
1556
+ if (X(t) && t.type === "null" && Object.keys(e).length === 1) return {
1557
+ type: "object",
1558
+ properties: {},
1559
+ additionalProperties: !1
1560
+ };
1561
+ let n = e.anyOf;
1562
+ if (Array.isArray(n)) {
1563
+ if (n.length === 2) {
1564
+ let t = n.find((e) => X(e) && e.type === "number"), r = n.find((e) => X(e) && e.type === "string" && Array.isArray(e.enum) && e.enum.includes("Infinity"));
1565
+ if (X(t) && r !== void 0) {
1566
+ let { anyOf: n, ...r } = e;
1567
+ return Q({
1568
+ ...r,
1569
+ ...t
1570
+ });
1571
+ }
1572
+ }
1573
+ if (n.length === 1 && X(n[0])) {
1574
+ let { anyOf: t, ...r } = e;
1575
+ return Q({
1576
+ ...r,
1577
+ ...n[0]
1578
+ });
1579
+ }
1580
+ }
1581
+ let r = {};
1582
+ for (let [t, n] of Object.entries(e)) r[t] = Q(n);
1583
+ return r;
1584
+ }, Da = (e, t = {}) => {
1585
+ let n = p.make(Z(e.ast)), r = p.toJsonSchemaDocument(n, t.closed === !1 ? {} : { onExcessProperty: "error" });
1586
+ return {
1587
+ schema: Q(r.schema),
1588
+ definitions: Q(r.definitions)
1589
+ };
1590
+ }, Oa = (e, t = {}) => {
1591
+ let { schema: n, definitions: r } = Da(e, t);
1592
+ return Object.keys(r).length === 0 ? n : {
1593
+ ...n,
1594
+ $defs: r
1595
+ };
1596
+ }, ka = "voltro-dev", Aa = "pair", $ = "voltro:pairing", ja = (e) => {
1340
1597
  try {
1341
1598
  let t = new URL(e);
1342
1599
  return t.protocol === "http:" || t.protocol === "https:";
1343
1600
  } catch {
1344
1601
  return !1;
1345
1602
  }
1346
- }, ua = (e) => {
1603
+ }, Ma = (e) => {
1347
1604
  try {
1348
1605
  let t = new URL(e).hostname;
1349
1606
  return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]";
1350
1607
  } catch {
1351
1608
  return !1;
1352
1609
  }
1353
- }, da = (e) => {
1354
- if (!la(e.api)) throw Error(`pairingLink: api must be an http(s) url, got ${JSON.stringify(e.api)}`);
1355
- if (ua(e.api)) throw Error("pairingLink: api must be the LAN address — a device cannot reach localhost on this machine");
1610
+ }, Na = (e) => {
1611
+ if (!ja(e.api)) throw Error(`pairingLink: api must be an http(s) url, got ${JSON.stringify(e.api)}`);
1612
+ if (Ma(e.api)) throw Error("pairingLink: api must be the LAN address — a device cannot reach localhost on this machine");
1356
1613
  if (!/^[A-Za-z0-9_-]+$/.test(e.name)) throw Error(`pairingLink: name must be a plain identifier, got ${JSON.stringify(e.name)}`);
1357
1614
  let t = new URLSearchParams({
1358
1615
  api: e.api,
1359
1616
  name: e.name
1360
1617
  });
1361
- return e.token !== void 0 && e.token.length > 0 && t.set("token", e.token), `${sa}://${ca}?${t.toString()}`;
1362
- }, fa = (e) => {
1618
+ return e.token !== void 0 && e.token.length > 0 && t.set("token", e.token), `${ka}://${Aa}?${t.toString()}`;
1619
+ }, Pa = (e) => {
1363
1620
  let t;
1364
1621
  try {
1365
1622
  t = new URL(e);
@@ -1368,12 +1625,12 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
1368
1625
  }
1369
1626
  if (t.protocol !== "voltro-dev:" || (t.host || t.pathname.replace(/^\/+/, "")) !== "pair") return null;
1370
1627
  let n = t.searchParams.get("api") ?? "", r = t.searchParams.get("name") ?? "", i = t.searchParams.get("token");
1371
- return !la(n) || ua(n) || !/^[A-Za-z0-9_-]+$/.test(r) ? null : {
1628
+ return !ja(n) || Ma(n) || !/^[A-Za-z0-9_-]+$/.test(r) ? null : {
1372
1629
  api: n,
1373
1630
  name: r,
1374
1631
  ...i !== null && i.length > 0 ? { token: i } : {}
1375
1632
  };
1376
- }, pa = (e) => "getItem" in e ? {
1633
+ }, Fa = (e) => "getItem" in e ? {
1377
1634
  get: async (t) => e.getItem(t),
1378
1635
  set: async (t, n) => {
1379
1636
  await e.setItem(t, n);
@@ -1389,14 +1646,14 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
1389
1646
  remove: e.remove ? async (t) => {
1390
1647
  await e.remove(t);
1391
1648
  } : null
1392
- }, ma = async (e, t) => {
1393
- await pa(e).set($, JSON.stringify(t));
1394
- }, ha = async (e) => {
1395
- let t = await pa(e).get($);
1649
+ }, Ia = async (e, t) => {
1650
+ await Fa(e).set($, JSON.stringify(t));
1651
+ }, La = async (e) => {
1652
+ let t = await Fa(e).get($);
1396
1653
  if (t === null || t === "") return null;
1397
1654
  try {
1398
1655
  let e = JSON.parse(t);
1399
- return typeof e.api != "string" || typeof e.name != "string" || !la(e.api) ? null : {
1656
+ return typeof e.api != "string" || typeof e.name != "string" || !ja(e.api) ? null : {
1400
1657
  api: e.api,
1401
1658
  name: e.name,
1402
1659
  ...typeof e.token == "string" && e.token.length > 0 ? { token: e.token } : {}
@@ -1404,9 +1661,41 @@ var At = h.Union(h.String, h.Number), jt = (e) => typeof e == "object" && !!e &&
1404
1661
  } catch {
1405
1662
  return null;
1406
1663
  }
1407
- }, ga = async (e) => {
1408
- let t = pa(e);
1664
+ }, Ra = async (e) => {
1665
+ let t = Fa(e);
1409
1666
  t.remove ? await t.remove($) : await t.set($, "");
1410
- }, _a = 1;
1667
+ }, za = p.Struct({
1668
+ owner: p.optional(p.Boolean),
1669
+ roles: p.optional(p.Array(p.String)),
1670
+ groups: p.optional(p.Array(p.String)),
1671
+ scopes: p.optional(p.Array(p.String)),
1672
+ tenant: p.optional(p.Boolean),
1673
+ apiKey: p.optional(p.Boolean),
1674
+ password: p.optional(p.Boolean),
1675
+ guard: p.optional(p.String)
1676
+ }), Ba = p.Array(za), Va = class {
1677
+ slots = [];
1678
+ head = 0;
1679
+ size = 0;
1680
+ capacity;
1681
+ constructor(e) {
1682
+ this.capacity = Number.isNaN(e) ? Infinity : Math.max(0, Math.floor(e));
1683
+ }
1684
+ get length() {
1685
+ return this.size;
1686
+ }
1687
+ get(e) {
1688
+ if (!(!Number.isInteger(e) || e < 0 || e >= this.size)) return this.slots[(this.head + e) % this.capacity];
1689
+ }
1690
+ push(e) {
1691
+ this.capacity !== 0 && (this.size < this.capacity ? (this.slots[(this.head + this.size) % this.capacity] = e, this.size++) : (this.slots[this.head] = e, this.head = (this.head + 1) % this.capacity));
1692
+ }
1693
+ clear() {
1694
+ this.slots.length = 0, this.head = 0, this.size = 0;
1695
+ }
1696
+ *[Symbol.iterator]() {
1697
+ for (let e = 0; e < this.size; e++) yield this.get(e);
1698
+ }
1699
+ }, Ha = 2;
1411
1700
  //#endregion
1412
- export { Be as ADMIN_SCOPE, Me as APIKEY_ISSUE_ORG_SCOPE, Le as APIKEY_ISSUE_OTHER_SCOPE, Ee as APIKEY_ISSUE_SELF_SCOPE, Pi as APPROVALS_DECIDE_TAG, Ni as APPROVALS_PENDING_TAG, lr as ApiUnavailable, $t as ApprovalDecisionErrors, Qt as ApprovalErrors, T as ApprovalExpired, Zt as ApprovalForbidden, qt as ApprovalNotFound, Xt as ApprovalNotPending, Yt as ApprovalRejected, Kt as ApprovalRequired, Jt as ApprovalSelfApproval, E as ApprovalUnavailable, ie as AuthMiddleware, S as BusinessRuleViolation, Li as CONNECTIONS_LIST_TAG, Bi as CONNECTION_DISCONNECT_TAG, Ri as CONNECTION_START_TAG, zi as CONNECTION_SUBMIT_TOKEN_TAG, Ki as ConnectionHandshakeFailed, ae as ConnectionInfo, se as ConnectionInfoMiddleware, Z as ConnectionKind, Gi as ConnectionKindMismatch, Ui as ConnectionNotDeclared, Hi as ConnectionState, Vi as ConnectionStatus, Wi as ConnectionSubjectRequired, Mi as ConstraintViolation, tt as DEFAULT_IN_FLIGHT_LEASE_MS, o as DEFAULT_SCOPE_CACHE_MAX_ENTRIES, ee as DEFAULT_SCOPE_CACHE_TTL_MS, ve as DEVICES_MANAGE_SCOPE, tr as EVENT_ROUTE_SEP, Qn as EventKeyInvalid, Zn as EventPayloadInvalid, $n as EventPayloadTooLarge, An as FRAMEWORK_WIRE_ERRORS, ia as GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE, re as IMPERSONATION_METADATA_KEY, _t as JSONAPI_MEDIA_TYPE, Vn as MAX_EVENT_ENVELOPE_BYTES, xt as MUTATION_IN_FLIGHT_RETRY_AFTER_MS, Ze as MutationConnectionRequired, m as MutationInFlight, Oi as NoRowFound, d as NoSuchResource, ca as PAIRING_HOST, sa as PAIRING_SCHEME, $ as PAIRING_STORAGE_KEY, ft as PROBLEM_JSON, _a as PROTOCOL_VERSION, en as PendingApproval, D as REACTIVITY_CHANNEL_PREFIX, ht as REST_PROFILE_NAMES, gn as SERVICE_NAME_PATTERN, wt as SESSION_HEADER_NAME, Q as STORE_SCREENSHOT_PRESETS, ea as STORE_SCREENSHOT_PRESET_NAMES, $i as STORE_SCREENSHOT_STORES, f as ScopeError, ji as ServerOnlyColumnWrite, Di as StoreOperationFailed, le as Subject, Ke as SubjectIdentity, n as SubjectService, ki as TableValidationFailed, Ai as TenantRowNotFound, Ei as TenantScopeViolation, ye as TenantSelectionRefused, gi as UNDO_APPLY_TAG, hi as UNDO_LOG_TAG, _i as UNDO_REDO_TAG, l as Unauthenticated, xi as UndoConflict, bi as UndoForbidden, vi as UndoLogEntry, yi as UndoNotFound, C as ValidationError, w as ValidationErrors, Wt as ValidationIssue, z as WorkflowAccessProperty, Br as WorkflowControlInputSchema, zr as WorkflowControlIntentSchema, Vr as WorkflowControlReadInputSchema, q as WorkflowControlResultSchema, Nr as WorkflowDomainEventRowSchema, Lr as WorkflowDomainEventsInputSchema, Rr as WorkflowEventDeliveriesInputSchema, Pr as WorkflowEventDeliveryRowSchema, Tr as WorkflowParentClosePolicySchema, Ur as WorkflowQueuedCancelInputSchema, wr as WorkflowQueuedCancellationResultSchema, Hr as WorkflowQueuedControlTargetSchema, di as WorkflowRestartCommandSchema, pi as WorkflowRestartObservationSchema, mi as WorkflowRestartResultSchema, ui as WorkflowRestartSelectionSchema, X as WorkflowRestartTargetSchema, ci as WorkflowRetryCommandSchema, li as WorkflowRetryObservationSchema, si as WorkflowRetryTargetSchema, Mr as WorkflowRunEventRowSchema, Dr as WorkflowRunHandleSchema, Fr as WorkflowRunRefSchema, kr as WorkflowRunRowSchema, K as WorkflowRunSnapshotSchema, G as WorkflowRunStatusSchema, jr as WorkflowRunStepRowSchema, Ir as WorkflowRunTableRefSchema, Ar as WorkflowRunsInputSchema, qr as WorkflowSignalInputSchema, Er as WorkflowStartDeferralSchema, W as WorkflowStartTerminalOutcomeSchema, Jr as WorkflowUpdateInputSchema, Yr as WorkflowUpdateResultSchema, Fn as actionToRpc, xe as advisoryResourceGuardWarning, c as anonymousSubject, ma as applyPairing, zt as applyRowPatch, fe as applyScopeDecision, Ii as approvalsDecideDescriptor, Fi as approvalsPendingQueryDescriptor, pe as assertAuthenticated, sr as attachWorkflowAccess, bt as beginIdempotent, gr as checkFrameworkCompat, Ae as checkGuards, He as checkGuardsEffect, ga as clearPairing, ot as compareSurfaces, s as composeAuthStrategies, mr as composeRpcInterceptors, Zi as connectionDisconnectDescriptor, Yi as connectionStartDescriptor, Xi as connectionSubmitTokenDescriptor, Ji as connectionsListQueryDescriptor, cn as declaredReactivityChannelKeys, u as declaresResourceGuard, F as defineAction, Un as defineEvent, P as defineMutation, dr as definePlugin, fr as definePluginRoute, hr as definePluginService, N as defineQuery, Sn as defineStream, oa as defineWebSocket, Lt as diffRows, Ce as effectiveScopes, er as encodeEventKey, st as encodeRestError, et as encodeRestSuccess, Ln as errorMessage, R as errorTag, Kn as eventAttached, Wn as eventEnvelope, Gn as eventGap, Jn as eventResumePoint, nr as eventRoute, qn as eventStreamEvent, Yn as eventSubscribeInput, Xn as eventToRpc, Qe as failIdempotent, Gt as fieldIssuesOf, Fe as findAdvisoryResourceGuards, Ye as finishIdempotent, Vt as firstEventValue, ir as formatEventRoute, Je as freshFor, je as getPolicyGuardResolver, Te as getResourceScopeResolver, B as getWorkflowAccess, at as groupShapeDigests, xn as hasAccessDecision, ne as hasCallbackRoutes, we as hasEffectiveScope, I as hasEnforcedGuard, _e as hasScope, Xe as holdIdempotentClaim, v as idToPath, lt as idempotencyScope, Ht as inputLabel, ur as isApiUnavailable, Ue as isAuthenticatedCheck, bn as isAuthenticatedGuard, mn as isClientReachable, Hn as isEventDescriptor, Rt as isIdKeyed, Ie as isMachineSubject, p as isOpenAccess, be as isPolicyCheck, yn as isPolicyGuard, on as isReactivityChannel, sn as isReactivityChannelKey, Ge as isServiceAccess, hn as isServiceReachable, te as isServiceSubject, he as isSystemSubject, Pe as isTenantSelectable, A as isWireReachable, me as makeScopeCache, qe as memoryIdempotencyStore, ue as missingAccessDecision, Pn as mutationToRpc, pt as nextLink, Bn as normalizeDescriptor, un as normalizeSource, r as openAccessSpec, ge as orderByBearerPrefix, da as pairingLink, rr as parseEventRoute, fa as parsePairingLink, _ as patchCellSchema, y as pathToId, vr as pluginAlias, pr as pluginInstanceName, yr as pluginSlug, Cr as pluginTag, gt as problemDetails, nt as problemTypeOf, $e as procedureShapeDigest, fn as publishReactivity, it as publishServerError, Nn as queryToRpc, ce as rawImpersonationMark, an as reactivityChannel, ha as readPairing, xr as registerPluginAliases, Rn as reportableError, We as requireScope, Sr as resetPluginAliases, de as resolvePolicyAction, ut as resolveRestFormat, or as resolveWorkflowAccess, vt as restViewSchema, Nt as rowPatchOpSchema, Pt as rowPatchSchema, yt as schemaShape, e as scopeCacheKey, ze as selectSubjectTenant, a as serviceAccessSpec, i as serviceCallersOf, Se as serviceSubject, Ct as sessionValueFromHeaders, oe as setEffectiveScopes, ke as setPolicyGuardResolver, t as setResourceScopeResolver, St as shapeDigest, ln as sourceKeys, na as storeScreenshotPixels, ta as storeScreenshotPreset, ra as storeScreenshotPresetsFor, In as streamToRpc, x as strictInput, Ve as subjectAuditActorId, Ne as subjectIdentity, Oe as subjectScopes, mt as subscribeServerErrors, Bt as subscriptionEvent, Re as systemSubject, De as tenantScopedSubject, zn as toRpc, rt as toSnakeCase, Qi as tsMs, dn as undeclaredChannelKeys, wi as undoApplyDescriptor, Ci as undoLogQueryDescriptor, Ti as undoRedoDescriptor, pn as wireAudienceOf, L as wireErrorUnion, Mn as withRpcTag, dt as withheldServerError, cr as workflowAccessDescriptor, ni as workflowCancelDescriptor, Kr as workflowControlQueryDescriptor, ei as workflowDomainEventsQueryDescriptor, ti as workflowEventDeliveriesQueryDescriptor, Wr as workflowQueuedCancelDescriptor, Gr as workflowQueuedControlQueryDescriptor, ri as workflowResumeDescriptor, $r as workflowRunEventsQueryDescriptor, Xr as workflowRunQueryDescriptor, Qr as workflowRunStepsQueryDescriptor, Zr as workflowRunsQueryDescriptor, ii as workflowSignalDescriptor, Or as workflowToRpc, ai as workflowUpdateDescriptor, jn as workflowWireErrorUnion, ct as wsMutationIdempotencyScope };
1701
+ export { Be as ADMIN_SCOPE, Me as APIKEY_ISSUE_ORG_SCOPE, Le as APIKEY_ISSUE_OTHER_SCOPE, Ee as APIKEY_ISSUE_SELF_SCOPE, ea as APPROVALS_DECIDE_TAG, $i as APPROVALS_PENDING_TAG, Mr as ApiUnavailable, yn as ApprovalDecisionErrors, vn as ApprovalErrors, mn as ApprovalExpired, gn as ApprovalForbidden, dn as ApprovalNotFound, hn as ApprovalNotPending, pn as ApprovalRejected, un as ApprovalRequired, fn as ApprovalSelfApproval, _n as ApprovalUnavailable, re as AuthMiddleware, Va as BoundedRing, sn as BusinessRuleViolation, ra as CONNECTIONS_LIST_TAG, oa as CONNECTION_DISCONNECT_TAG, ia as CONNECTION_START_TAG, aa as CONNECTION_SUBMIT_TOKEN_TAG, fa as ConnectionHandshakeFailed, ie as ConnectionInfo, oe as ConnectionInfoMiddleware, q as ConnectionKind, da as ConnectionKindMismatch, la as ConnectionNotDeclared, ca as ConnectionState, sa as ConnectionStatus, ua as ConnectionSubjectRequired, Qi as ConstraintViolation, rt as DEFAULT_IN_FLIGHT_LEASE_MS, o as DEFAULT_SCOPE_CACHE_MAX_ENTRIES, l as DEFAULT_SCOPE_CACHE_TTL_MS, _e as DEVICES_MANAGE_SCOPE, Sr as EVENT_ROUTE_SEP, yr as EventKeyInvalid, vr as EventPayloadInvalid, br as EventPayloadTooLarge, Xn as FRAMEWORK_WIRE_ERRORS, Ca as GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE, ne as IMPERSONATION_METADATA_KEY, yt as JSONAPI_MEDIA_TYPE, cr as MAX_EVENT_ENVELOPE_BYTES, Ct as MUTATION_IN_FLIGHT_RETRY_AFTER_MS, $e as MutationConnectionRequired, Ye as MutationInFlight, Ji as NoRowFound, d as NoSuchResource, Aa as PAIRING_HOST, ka as PAIRING_SCHEME, $ as PAIRING_STORAGE_KEY, mt as PROBLEM_JSON, Ha as PROTOCOL_VERSION, bn as PendingApproval, w as REACTIVITY_CHANNEL_PREFIX, _t as REST_PROFILE_NAMES, In as SERVICE_NAME_PATTERN, Et as SESSION_HEADER_NAME, Y as STORE_SCREENSHOT_PRESETS, ya as STORE_SCREENSHOT_PRESET_NAMES, va as STORE_SCREENSHOT_STORES, f as ScopeError, Zi as ServerOnlyColumnWrite, Ba as StorageAccessPolicySchema, za as StorageAccessRuleSchema, qi as StoreOperationFailed, ce as Subject, qe as SubjectIdentity, n as SubjectService, Yi as TableValidationFailed, Xi as TenantRowNotFound, Ki as TenantScopeViolation, ve as TenantSelectionRefused, Ii as UNDO_APPLY_TAG, Fi as UNDO_LOG_TAG, Li as UNDO_REDO_TAG, u as Unauthenticated, Vi as UndoConflict, Bi as UndoForbidden, Ri as UndoLogEntry, zi as UndoNotFound, S as ValidationError, C as ValidationErrors, cn as ValidationIssue, Er as WorkflowAccessProperty, oi as WorkflowControlInputSchema, ai as WorkflowControlIntentSchema, si as WorkflowControlReadInputSchema, B as WorkflowControlResultSchema, ei as WorkflowDomainEventRowSchema, ri as WorkflowDomainEventsInputSchema, ii as WorkflowEventDeliveriesInputSchema, ti as WorkflowEventDeliveryRowSchema, qr as WorkflowParentClosePolicySchema, li as WorkflowQueuedCancelInputSchema, V as WorkflowQueuedCancellationResultSchema, ci as WorkflowQueuedControlTargetSchema, ji as WorkflowRestartCommandSchema, Ni as WorkflowRestartObservationSchema, Pi as WorkflowRestartResultSchema, Ai as WorkflowRestartSelectionSchema, K as WorkflowRestartTargetSchema, Oi as WorkflowRetryCommandSchema, ki as WorkflowRetryObservationSchema, Di as WorkflowRetryTargetSchema, $r as WorkflowRunEventRowSchema, Yr as WorkflowRunHandleSchema, ni as WorkflowRunRefSchema, H as WorkflowRunRowSchema, z as WorkflowRunSnapshotSchema, R as WorkflowRunStatusSchema, Qr as WorkflowRunStepRowSchema, U as WorkflowRunTableRefSchema, Zr as WorkflowRunsInputSchema, pi as WorkflowSignalInputSchema, Jr as WorkflowStartDeferralSchema, L as WorkflowStartTerminalOutcomeSchema, mi as WorkflowUpdateInputSchema, hi as WorkflowUpdateResultSchema, tr as actionToRpc, be as advisoryResourceGuardWarning, c as anonymousSubject, Ia as applyPairing, Xt as applyRowPatch, de as applyScopeDecision, na as approvalsDecideDescriptor, ta as approvalsPendingQueryDescriptor, fe as assertAuthenticated, kr as attachWorkflowAccess, St as beginIdempotent, zr as checkFrameworkCompat, Ae as checkGuards, He as checkGuardsEffect, Ra as clearPairing, ct as compareSurfaces, s as composeAuthStrategies, Lr as composeRpcInterceptors, ga as connectionDisconnectDescriptor, ma as connectionStartDescriptor, ha as connectionSubmitTokenDescriptor, pa as connectionsListQueryDescriptor, Qt as createRowPatchApplier, Dn as declaredReactivityChannelKeys, xe as declaresResourceGuard, j as defineAction, ur as defineEvent, A as defineMutation, Pr as definePlugin, Fr as definePluginRoute, Rr as definePluginService, k as defineQuery, Hn as defineStream, Ta as defineWebSocket, Jt as diffRows, Ce as effectiveScopes, xr as encodeEventKey, lt as encodeRestError, nt as encodeRestSuccess, ir as errorMessage, rr as errorTag, pr as eventAttached, dr as eventEnvelope, fr as eventGap, hr as eventResumePoint, Cr as eventRoute, mr as eventStreamEvent, gr as eventSubscribeInput, _r as eventToRpc, et as failIdempotent, ln as fieldIssuesOf, Fe as findAdvisoryResourceGuards, Ze as finishIdempotent, Z as finiteNumberView, en as firstEventValue, Tr as formatEventRoute, Xe as freshFor, je as getPolicyGuardResolver, Te as getResourceScopeResolver, Ar as getWorkflowAccess, st as groupShapeDigests, Vn as hasAccessDecision, te as hasCallbackRoutes, we as hasEffectiveScope, M as hasEnforcedGuard, ge as hasScope, Qe as holdIdempotentClaim, _ as idToPath, dt as idempotencyScope, tn as inputLabel, Nr as isApiUnavailable, Ue as isAuthenticatedCheck, Bn as isAuthenticatedGuard, Pn as isClientReachable, lr as isEventDescriptor, Yt as isIdKeyed, Ie as isMachineSubject, Ke as isOpenAccess, ye as isPolicyCheck, zn as isPolicyGuard, Tn as isReactivityChannel, En as isReactivityChannelKey, Ge as isServiceAccess, Fn as isServiceReachable, ee as isServiceSubject, me as isSystemSubject, Pe as isTenantSelectable, Mn as isWireReachable, Da as jsonSchemaDocumentOf, Oa as jsonSchemaOf, pe as makeScopeCache, Je as memoryIdempotencyStore, le as missingAccessDecision, er as mutationToRpc, ht as nextLink, sr as normalizeDescriptor, kn as normalizeSource, r as openAccessSpec, he as orderByBearerPrefix, Na as pairingLink, wr as parseEventRoute, Pa as parsePairingLink, Ht as patchCellSchema, v as pathToId, Q as plainJsonSchema, Vr as pluginAlias, Ir as pluginInstanceName, Hr as pluginSlug, Kr as pluginTag, vt as problemDetails, it as problemTypeOf, tt as procedureShapeDigest, jn as publishReactivity, ot as publishServerError, $n as queryToRpc, se as rawImpersonationMark, wn as reactivityChannel, La as readPairing, Wr as registerPluginAliases, ar as reportableError, We as requireScope, Gr as resetPluginAliases, ue as resolvePolicyAction, ft as resolveRestFormat, Or as resolveWorkflowAccess, bt as restViewSchema, Wt as rowPatchOpSchema, Gt as rowPatchSchema, xt as schemaShape, e as scopeCacheKey, ze as selectSubjectTenant, a as serviceAccessSpec, i as serviceCallersOf, Se as serviceSubject, Tt as sessionValueFromHeaders, ae as setEffectiveScopes, ke as setPolicyGuardResolver, t as setResourceScopeResolver, wt as shapeDigest, On as sourceKeys, xa as storeScreenshotPixels, ba as storeScreenshotPreset, Sa as storeScreenshotPresetsFor, nr as streamToRpc, x as strictInput, Ve as subjectAuditActorId, Ne as subjectIdentity, Oe as subjectScopes, gt as subscribeServerErrors, $t as subscriptionEvent, Re as systemSubject, De as tenantScopedSubject, or as toRpc, at as toSnakeCase, _a as tsMs, An as undeclaredChannelKeys, Wi as undoApplyDescriptor, Ui as undoLogQueryDescriptor, Gi as undoRedoDescriptor, Nn as wireAudienceOf, N as wireErrorUnion, Qn as withRpcTag, pt as withheldServerError, jr as workflowAccessDescriptor, Si as workflowCancelDescriptor, fi as workflowControlQueryDescriptor, bi as workflowDomainEventsQueryDescriptor, xi as workflowEventDeliveriesQueryDescriptor, ui as workflowQueuedCancelDescriptor, di as workflowQueuedControlQueryDescriptor, Ci as workflowResumeDescriptor, yi as workflowRunEventsQueryDescriptor, gi as workflowRunQueryDescriptor, vi as workflowRunStepsQueryDescriptor, _i as workflowRunsQueryDescriptor, wi as workflowSignalDescriptor, Xr as workflowToRpc, Ti as workflowUpdateDescriptor, Zn as workflowWireErrorUnion, ut as wsMutationIdempotencyScope };