@voltro/protocol 0.23.0 → 0.25.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,30 +1,30 @@
1
- import { C as e, D as t, E as n, S as r, T as i, _ as a, a as o, b as ee, c as te, d as ne, f as s, g as re, h as ie, i as ae, l as oe, m as se, n as ce, o as le, p as ue, r as de, s as fe, t as pe, u as me, v as he, w as ge, x as _e, y as ve } from "./serverErrorBus-BkKWg0_x.js";
2
- import { a as ye, c as be, d as xe, f as Se, i as Ce, l as we, n as Te, o as Ee, p as De, r as Oe, s as ke, t as Ae, u as je } from "./auth-BPdyOBsd.js";
3
- import { Context as Me, Layer as Ne, Schema as c } from "effect";
1
+ import { C as e, D as t, E as n, O as r, S as i, T as a, _ as o, a as ee, b as te, c as ne, d as re, f as ie, g as ae, h as oe, i as se, l as ce, m as le, n as ue, o as de, p as s, r as fe, s as pe, t as me, u as he, v as ge, w as _e, x as ve, y as ye } from "./serverErrorBus-C3JTqgIc.js";
2
+ import { a as be, c as xe, d as Se, f as Ce, i as we, l as Te, n as Ee, o as De, p as Oe, r as ke, s as Ae, t as je, u as Me } from "./auth-BPdyOBsd.js";
3
+ import { Context as Ne, Layer as Pe, Schema as c } from "effect";
4
4
  import { Rpc as l } from "@effect/rpc";
5
5
  //#region src/rowPatch.ts
6
- var Pe = c.Union(c.String, c.Number), Fe = c.Record({
6
+ var Fe = c.Union(c.String, c.Number), u = c.Record({
7
7
  key: c.String,
8
8
  value: c.Unknown
9
- }).pipe(c.filter((e) => "id" in e, { message: () => "patch row must carry an id" })), Ie = c.Union(c.Struct({
9
+ }).pipe(c.filter((e) => "id" in e, { message: () => "patch row must carry an id" })), d = c.Union(c.Struct({
10
10
  op: c.Literal("add"),
11
11
  path: c.String,
12
- value: Fe
12
+ value: u
13
13
  }), c.Struct({
14
14
  op: c.Literal("replace"),
15
15
  path: c.String,
16
- value: Fe
16
+ value: u
17
17
  }), c.Struct({
18
18
  op: c.Literal("remove"),
19
19
  path: c.String
20
- })), u = c.Struct({
21
- ops: c.Array(Ie),
22
- order: c.Array(Pe)
23
- }), d = (e) => `/${String(e).replace(/~/g, "~0").replace(/\//g, "~1")}`, Le = (e) => (e.startsWith("/") ? e.slice(1) : e).replace(/~1/g, "/").replace(/~0/g, "~"), f = (e) => {
20
+ })), f = c.Struct({
21
+ ops: c.Array(d),
22
+ order: c.Array(Fe)
23
+ }), p = (e) => `/${String(e).replace(/~/g, "~0").replace(/\//g, "~1")}`, Ie = (e) => (e.startsWith("/") ? e.slice(1) : e).replace(/~1/g, "/").replace(/~0/g, "~"), m = (e) => {
24
24
  let t = Object.keys(e).sort(), n = {};
25
25
  for (let r of t) n[r] = e[r];
26
26
  return JSON.stringify(n);
27
- }, Re = (e, t) => f(e) === f(t), ze = (e, t) => {
27
+ }, Le = (e, t) => m(e) === m(t), Re = (e, t) => {
28
28
  let n = /* @__PURE__ */ new Map();
29
29
  for (let t of e) n.set(t.id, t);
30
30
  let r = [], i = [], a = /* @__PURE__ */ new Set();
@@ -33,26 +33,26 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
33
33
  let t = n.get(e.id);
34
34
  t === void 0 ? r.push({
35
35
  op: "add",
36
- path: d(e.id),
36
+ path: p(e.id),
37
37
  value: e
38
- }) : Re(t, e) || r.push({
38
+ }) : Le(t, e) || r.push({
39
39
  op: "replace",
40
- path: d(e.id),
40
+ path: p(e.id),
41
41
  value: e
42
42
  });
43
43
  }
44
44
  for (let t of e) a.has(t.id) || r.push({
45
45
  op: "remove",
46
- path: d(t.id)
46
+ path: p(t.id)
47
47
  });
48
48
  return {
49
49
  ops: r,
50
50
  order: i
51
51
  };
52
- }, Be = (e) => e.every((e) => {
52
+ }, ze = (e) => e.every((e) => {
53
53
  let t = e.id;
54
54
  return typeof t == "string" || typeof t == "number";
55
- }), Ve = (e, t) => {
55
+ }), Be = (e, t) => {
56
56
  let n = /* @__PURE__ */ new Map();
57
57
  for (let t of e) n.set(t.id, t);
58
58
  for (let e of t.ops) (e.op === "add" || e.op === "replace") && n.set(e.value.id, e.value);
@@ -62,7 +62,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
62
62
  t !== void 0 && r.push(t);
63
63
  }
64
64
  return r;
65
- }, p = (e) => c.Union(c.Struct({
65
+ }, h = (e) => c.Union(c.Struct({
66
66
  _tag: c.Literal("snapshot"),
67
67
  revision: c.Number,
68
68
  data: e,
@@ -71,17 +71,17 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
71
71
  _tag: c.Literal("delta"),
72
72
  revision: c.Number,
73
73
  emittedAt: c.Number,
74
- patch: u
74
+ patch: f
75
75
  }), c.Struct({
76
76
  _tag: c.Literal("error"),
77
77
  error: c.Unknown,
78
78
  revision: c.optional(c.Number)
79
- })), He = (e) => e.internal !== !0, m = (e) => {
79
+ })), Ve = (e) => e.internal !== !0, g = (e) => {
80
80
  if (e.internal !== !0) return e;
81
81
  let t = [e.publicApi === void 0 ? void 0 : "publicApi", e.exposeAsTool === void 0 ? void 0 : "exposeAsTool"].filter((e) => e !== void 0);
82
82
  if (t.length === 0) return e;
83
83
  throw Error(`${e.name}: \`internal: true\` cannot be combined with ${t.map((e) => `\`${e}\``).join(" or ")}. \`internal\` takes the procedure OFF the wire; those put it back ON a different one (${t.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 ${t.join(" / ")} annotation if it is not.`);
84
- }, Ue = (e) => e.action !== void 0 && e.resourceType !== void 0, h = (e) => m({
84
+ }, He = (e) => e.action !== void 0 && e.resourceType !== void 0, _ = (e) => g({
85
85
  kind: "query",
86
86
  name: e.name,
87
87
  input: e.input,
@@ -93,7 +93,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
93
93
  publicApi: e.publicApi,
94
94
  exposeAsTool: e.exposeAsTool,
95
95
  internal: e.internal
96
- }), g = (e) => m({
96
+ }), v = (e) => g({
97
97
  kind: "mutation",
98
98
  name: e.name,
99
99
  input: e.input,
@@ -104,7 +104,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
104
104
  publicApi: e.publicApi,
105
105
  exposeAsTool: e.exposeAsTool,
106
106
  internal: e.internal
107
- }), _ = (e) => m({
107
+ }), y = (e) => g({
108
108
  kind: "action",
109
109
  name: e.name,
110
110
  input: e.input,
@@ -116,43 +116,43 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
116
116
  publicApi: e.publicApi,
117
117
  exposeAsTool: e.exposeAsTool,
118
118
  internal: e.internal
119
- }), We = (e) => m({
119
+ }), Ue = (e) => g({
120
120
  kind: "stream",
121
121
  name: e.name,
122
122
  input: e.input,
123
123
  element: e.element,
124
124
  error: e.error ?? c.Never,
125
125
  internal: e.internal
126
- }), v = (e, t) => t && t.length > 0 ? c.Union(e, ...t) : e, y = (e, t) => t && t.length > 0 ? c.Union(e, s) : e, b = (e, t) => l.make(e.name, {
126
+ }), b = (e, t) => t && t.length > 0 ? c.Union(e, ...t) : e, x = (e, t) => t && t.length > 0 ? c.Union(e, s) : e, S = (e, t) => l.make(e.name, {
127
127
  payload: e.input,
128
- success: p(e.output),
129
- error: v(y(e.error, e.guards), t),
128
+ success: h(e.output),
129
+ error: b(x(e.error, e.guards), t),
130
130
  stream: !0
131
- }), x = (e, t) => l.make(e.name, {
131
+ }), We = (e, t) => l.make(e.name, {
132
132
  payload: e.input,
133
133
  success: e.output,
134
- error: v(y(e.error, e.guards), t)
135
- }), S = (e, t) => l.make(e.name, {
134
+ error: b(x(e.error, e.guards), t)
135
+ }), Ge = (e, t) => l.make(e.name, {
136
136
  payload: e.input,
137
137
  success: e.output,
138
- error: v(y(e.error, e.guards), t)
139
- }), C = (e, t) => l.make(e.name, {
138
+ error: b(x(e.error, e.guards), t)
139
+ }), Ke = (e, t) => l.make(e.name, {
140
140
  payload: e.input,
141
141
  success: e.element,
142
- error: v(e.error, t),
142
+ error: b(e.error, t),
143
143
  stream: !0
144
- }), Ge = (e) => {
144
+ }), qe = (e) => {
145
145
  if (typeof e != "object" || !e) return;
146
146
  let t = e._tag;
147
147
  return typeof t == "string" ? t : void 0;
148
- }, Ke = (e) => {
148
+ }, Je = (e) => {
149
149
  switch (e.kind) {
150
- case "query": return b(e);
151
- case "mutation": return x(e);
152
- case "action": return S(e);
153
- case "stream": return C(e);
150
+ case "query": return S(e);
151
+ case "mutation": return We(e);
152
+ case "action": return Ge(e);
153
+ case "stream": return Ke(e);
154
154
  }
155
- }, qe = (e) => {
155
+ }, Ye = (e) => {
156
156
  let t = e.input, n = t === void 0 ? {} : { input: t }, r = e.output, i = r === void 0 ? {} : { output: r };
157
157
  if (e.kind === "query") return {
158
158
  kind: "query",
@@ -193,17 +193,84 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
193
193
  ..."shapeItem" in e && e.shapeItem !== void 0 ? { shapeItem: e.shapeItem } : {}
194
194
  }))
195
195
  };
196
- }, Je = (e) => e, Ye = (e) => e, Xe = (e) => {
196
+ }, Xe = 7500, Ze = (e) => typeof e == "object" && !!e && e.kind === "event", Qe = (e) => {
197
+ if (e.name.length === 0) throw Error("defineEvent: `name` must not be empty");
198
+ if (e.delivery === "latest" && e.webhook !== void 0) throw Error(`defineEvent(${e.name}): \`delivery: 'latest'\` cannot be combined with \`webhook\`.\n \`latest\` means a superseded delivery did not matter — but a webhook delivery is a
199
+ durable side effect at a third party, and one already sent cannot be superseded.
200
+ A high-rate event with an HTTP audience is also 60 deliveries per second per target;
201
+ the rate limit DEFERS the excess as pending rows, so it grows a table instead of failing.
202
+ Split them: publish the high-rate event for clients, and publish a separate, coarser
203
+ event (a summary, a state change) for the outside world.`);
204
+ return {
205
+ kind: "event",
206
+ name: e.name,
207
+ key: e.key,
208
+ payload: e.payload,
209
+ guards: e.guards,
210
+ rewind: e.rewind,
211
+ webhook: e.webhook,
212
+ delivery: e.delivery
213
+ };
214
+ }, C = (e) => c.Struct({
215
+ _tag: c.Literal("event"),
216
+ origin: c.String,
217
+ n: c.Number,
218
+ emittedAt: c.Number,
219
+ payload: e
220
+ }), w = c.Struct({
221
+ _tag: c.Literal("gap"),
222
+ missed: c.Number,
223
+ reason: c.Literal("buffer", "resume")
224
+ }), T = c.Struct({ _tag: c.Literal("attached") }), E = (e) => c.Union(T, C(e), w), D = c.Struct({
225
+ origin: c.String,
226
+ n: c.Number
227
+ }), O = (e) => c.Struct({
228
+ key: e,
229
+ resume: c.optional(c.Array(D))
230
+ }), $e = (e, t) => {
231
+ let n = e.guards && e.guards.length > 0 ? s : c.Never, r = t && t.length > 0 ? c.Union(n, ...t) : n;
232
+ return l.make(e.name, {
233
+ payload: O(e.key),
234
+ success: E(e.payload),
235
+ error: r,
236
+ stream: !0
237
+ });
238
+ }, et = class extends c.TaggedError()("EventPayloadInvalid", {
239
+ event: c.String,
240
+ message: c.String
241
+ }) {}, tt = class extends c.TaggedError()("EventKeyInvalid", {
242
+ event: c.String,
243
+ message: c.String
244
+ }) {}, nt = class extends c.TaggedError()("EventPayloadTooLarge", {
245
+ event: c.String,
246
+ bytes: c.Number,
247
+ limit: c.Number
248
+ }) {}, k = (e) => {
249
+ if (typeof e != "object" || !e) return JSON.stringify(e) ?? "null";
250
+ let t = Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t));
251
+ return JSON.stringify(t);
252
+ }, rt = "\0", it = (e, t, n) => [
253
+ e ?? "~",
254
+ t,
255
+ k(n)
256
+ ].join("\0"), at = (e) => {
257
+ let [t = "~", n = "", r = ""] = e.split("\0");
258
+ return {
259
+ tenantId: t === "~" ? null : t,
260
+ event: n,
261
+ key: r
262
+ };
263
+ }, ot = (e) => e.split("\0").join(" · "), st = (e) => e, ct = (e) => e, lt = (e) => {
197
264
  if (e.length !== 0) return (t, n) => e.reduceRight((e, t) => t(e, n), t);
198
- }, Ze = (e, t) => {
199
- let n = Me.GenericTag(e);
265
+ }, ut = (e, t) => {
266
+ let n = Ne.GenericTag(e);
200
267
  return {
201
268
  Tag: n,
202
- Live: Ne.succeed(n, t)
269
+ Live: Pe.succeed(n, t)
203
270
  };
204
- }, Qe = (e, t, n) => {
271
+ }, dt = (e, t, n) => {
205
272
  if (!t) return { ok: !0 };
206
- let r = w(n);
273
+ let r = A(n);
207
274
  if (!r) return {
208
275
  ok: !1,
209
276
  reason: `cannot parse runningVersion "${n}"`
@@ -211,12 +278,12 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
211
278
  let i = t.trim();
212
279
  if (i === "*" || i === "") return { ok: !0 };
213
280
  let a = i.split(/\s+/).filter((e) => e.length > 0);
214
- for (let i of a) if (!$e(i, r)) return {
281
+ for (let i of a) if (!ft(i, r)) return {
215
282
  ok: !1,
216
283
  reason: `plugin "${e}" requires framework ${t}, running ${n}`
217
284
  };
218
285
  return { ok: !0 };
219
- }, w = (e) => {
286
+ }, A = (e) => {
220
287
  let t = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?$/.exec(e.trim());
221
288
  return t ? {
222
289
  major: Number(t[1]),
@@ -224,38 +291,38 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
224
291
  patch: Number(t[3]),
225
292
  pre: t[4] ?? ""
226
293
  } : null;
227
- }, T = (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, $e = (e, t) => {
294
+ }, j = (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, ft = (e, t) => {
228
295
  if (e === "*") return !0;
229
296
  if (e.startsWith("^")) {
230
- let n = w(e.slice(1));
231
- return !n || t.major !== n.major ? !1 : T(t, n) >= 0;
297
+ let n = A(e.slice(1));
298
+ return !n || t.major !== n.major ? !1 : j(t, n) >= 0;
232
299
  }
233
300
  if (e.startsWith("~")) {
234
- let n = w(e.slice(1));
235
- return !n || t.major !== n.major || t.minor !== n.minor ? !1 : T(t, n) >= 0;
301
+ let n = A(e.slice(1));
302
+ return !n || t.major !== n.major || t.minor !== n.minor ? !1 : j(t, n) >= 0;
236
303
  }
237
304
  let n = /^(>=|<=|>|<)(.+)$/.exec(e);
238
305
  if (n) {
239
- let e = n[1], r = w(n[2]);
306
+ let e = n[1], r = A(n[2]);
240
307
  if (!r) return !1;
241
- let i = T(t, r);
308
+ let i = j(t, r);
242
309
  if (e === ">=") return i >= 0;
243
310
  if (e === "<=") return i <= 0;
244
311
  if (e === ">") return i > 0;
245
312
  if (e === "<") return i < 0;
246
313
  }
247
- let r = w(e);
248
- return r ? T(t, r) === 0 : !1;
249
- }, E = c.Literal("running", "succeeded", "failed", "cancelled", "suspended"), D = c.Literal("cancel", "terminate", "abandon"), et = c.Struct({
314
+ let r = A(e);
315
+ return r ? j(t, r) === 0 : !1;
316
+ }, M = c.Literal("running", "succeeded", "failed", "cancelled", "suspended"), N = c.Literal("cancel", "terminate", "abandon"), pt = c.Struct({
250
317
  id: c.String,
251
318
  workflowName: c.String,
252
319
  executionId: c.String,
253
320
  status: c.Literal("running")
254
- }), O = c.Struct({
321
+ }), P = c.Struct({
255
322
  id: c.String,
256
323
  tag: c.String,
257
324
  executionId: c.String,
258
- status: E,
325
+ status: M,
259
326
  payload: c.Unknown,
260
327
  workflowVersion: c.NullOr(c.String),
261
328
  workflowPatches: c.NullOr(c.Unknown),
@@ -270,12 +337,12 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
270
337
  durationMs: c.NullOr(c.Number),
271
338
  traceId: c.NullOr(c.String),
272
339
  parentExecutionId: c.NullOr(c.String),
273
- parentClosePolicy: c.NullOr(D)
274
- }), k = c.Struct({
340
+ parentClosePolicy: c.NullOr(N)
341
+ }), F = c.Struct({
275
342
  tag: c.optional(c.String),
276
- status: c.optional(E),
343
+ status: c.optional(M),
277
344
  limit: c.optional(c.Number)
278
- }), A = c.Struct({
345
+ }), I = c.Struct({
279
346
  id: c.String,
280
347
  runId: c.String,
281
348
  stepName: c.String,
@@ -290,7 +357,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
290
357
  startedAt: c.Date,
291
358
  completedAt: c.NullOr(c.Date),
292
359
  durationMs: c.NullOr(c.Number)
293
- }), j = c.Struct({
360
+ }), L = c.Struct({
294
361
  id: c.String,
295
362
  runId: c.String,
296
363
  eventType: c.String,
@@ -298,7 +365,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
298
365
  occurredAt: c.Date,
299
366
  stepName: c.NullOr(c.String),
300
367
  attempt: c.NullOr(c.Number)
301
- }), M = c.Struct({
368
+ }), R = c.Struct({
302
369
  id: c.String,
303
370
  name: c.String,
304
371
  payload: c.Unknown,
@@ -306,7 +373,7 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
306
373
  subject: c.NullOr(c.Unknown),
307
374
  traceId: c.NullOr(c.String),
308
375
  occurredAt: c.Date
309
- }), N = c.Struct({
376
+ }), z = c.Struct({
310
377
  id: c.String,
311
378
  eventId: c.String,
312
379
  eventName: c.String,
@@ -319,123 +386,123 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
319
386
  errorMessage: c.NullOr(c.String),
320
387
  createdAt: c.Date,
321
388
  completedAt: c.NullOr(c.Date)
322
- }), P = c.Struct({ id: c.String }), F = c.Struct({ runId: c.String }), I = c.Struct({
389
+ }), B = c.Struct({ id: c.String }), V = c.Struct({ runId: c.String }), mt = c.Struct({
323
390
  name: c.optional(c.String),
324
391
  limit: c.optional(c.Number)
325
- }), L = c.Struct({ eventId: c.String }), R = c.Struct({
392
+ }), H = c.Struct({ eventId: c.String }), U = c.Struct({
326
393
  workflowName: c.String,
327
394
  executionId: c.String
328
- }), z = c.Struct({
395
+ }), W = c.Struct({
329
396
  id: c.String,
330
397
  signalName: c.String,
331
398
  payload: c.optional(c.Unknown)
332
- }), B = c.Struct({
399
+ }), G = c.Struct({
333
400
  id: c.String,
334
401
  updateName: c.String,
335
402
  payload: c.optional(c.Unknown),
336
403
  timeoutMs: c.optional(c.Number)
337
- }), V = c.Struct({
404
+ }), K = c.Struct({
338
405
  eventId: c.String,
339
406
  updateId: c.String,
340
407
  completedEventId: c.String,
341
408
  result: c.Unknown
342
- }), tt = h({
409
+ }), ht = _({
343
410
  name: "__voltro.workflow.run",
344
411
  source: "_voltro_workflow_runs",
345
- input: P,
346
- output: c.Array(O)
347
- }), nt = h({
412
+ input: B,
413
+ output: c.Array(P)
414
+ }), gt = _({
348
415
  name: "__voltro.workflow.runs",
349
416
  source: "_voltro_workflow_runs",
350
- input: k,
351
- output: c.Array(O)
352
- }), rt = h({
417
+ input: F,
418
+ output: c.Array(P)
419
+ }), _t = _({
353
420
  name: "__voltro.workflow.run.steps",
354
421
  source: "_voltro_workflow_run_steps",
355
- input: F,
356
- output: c.Array(A)
357
- }), it = h({
422
+ input: V,
423
+ output: c.Array(I)
424
+ }), vt = _({
358
425
  name: "__voltro.workflow.run.events",
359
426
  source: "_voltro_workflow_run_events",
360
- input: F,
361
- output: c.Array(j)
362
- }), at = h({
427
+ input: V,
428
+ output: c.Array(L)
429
+ }), yt = _({
363
430
  name: "__voltro.workflow.domainEvents",
364
431
  source: "_voltro_workflow_events",
365
- input: I,
366
- output: c.Array(M)
367
- }), ot = h({
432
+ input: mt,
433
+ output: c.Array(R)
434
+ }), bt = _({
368
435
  name: "__voltro.workflow.event.deliveries",
369
436
  source: "_voltro_workflow_event_deliveries",
370
- input: L,
371
- output: c.Array(N)
372
- }), st = _({
437
+ input: H,
438
+ output: c.Array(z)
439
+ }), xt = y({
373
440
  name: "__voltro.workflow.cancel",
374
- input: R,
441
+ input: U,
375
442
  output: c.Struct({ ok: c.Boolean })
376
- }), ct = _({
443
+ }), St = y({
377
444
  name: "__voltro.workflow.resume",
378
- input: R,
445
+ input: U,
379
446
  output: c.Struct({ ok: c.Boolean })
380
- }), lt = _({
447
+ }), Ct = y({
381
448
  name: "__voltro.workflow.signal",
382
- input: z,
449
+ input: W,
383
450
  output: c.Struct({ eventId: c.String })
384
- }), ut = _({
451
+ }), wt = y({
385
452
  name: "__voltro.workflow.update",
386
- input: B,
387
- output: V
388
- }), dt = "__voltro.undo.log", H = "__voltro.undo.apply", U = "__voltro.undo.redo", W = c.Struct({
453
+ input: G,
454
+ output: K
455
+ }), q = "__voltro.undo.log", J = "__voltro.undo.apply", Y = "__voltro.undo.redo", X = c.Struct({
389
456
  id: c.String,
390
457
  tag: c.String,
391
458
  label: c.NullOr(c.String),
392
459
  undone: c.Boolean,
393
460
  crossesAction: c.Boolean,
394
461
  createdAt: c.String
395
- }), G = class extends c.TaggedError()("UndoNotFound", { invocationId: c.String }) {}, K = class extends c.TaggedError()("UndoForbidden", { invocationId: c.String }) {}, q = class extends c.TaggedError()("UndoConflict", {
462
+ }), Tt = class extends c.TaggedError()("UndoNotFound", { invocationId: c.String }) {}, Et = class extends c.TaggedError()("UndoForbidden", { invocationId: c.String }) {}, Dt = class extends c.TaggedError()("UndoConflict", {
396
463
  invocationId: c.String,
397
464
  reason: c.Literal("conflict", "action")
398
- }) {}, J = c.Union(G, K, q), ft = h({
399
- name: dt,
465
+ }) {}, Ot = c.Union(Tt, Et, Dt), kt = _({
466
+ name: q,
400
467
  source: "_voltro_undo_log",
401
468
  input: c.Struct({ limit: c.optional(c.Number) }),
402
- output: c.Array(W)
403
- }), pt = g({
404
- name: H,
469
+ output: c.Array(X)
470
+ }), At = v({
471
+ name: J,
405
472
  input: c.Struct({ invocationId: c.String }),
406
473
  output: c.Struct({ ok: c.Boolean }),
407
- error: J
408
- }), mt = g({
409
- name: U,
474
+ error: Ot
475
+ }), jt = v({
476
+ name: Y,
410
477
  input: c.Struct({ invocationId: c.String }),
411
478
  output: c.Struct({ ok: c.Boolean }),
412
- error: J
413
- }), Y = "__voltro.connections.list", X = "__voltro.connections.start", Z = "__voltro.connections.submitToken", ht = "__voltro.connections.disconnect", Q = c.Literal("oauth2", "pat"), gt = c.Literal("disconnected", "connected", "expired", "revoked", "error"), _t = c.Struct({
479
+ error: Ot
480
+ }), Mt = "__voltro.connections.list", Z = "__voltro.connections.start", Nt = "__voltro.connections.submitToken", Pt = "__voltro.connections.disconnect", Q = c.Literal("oauth2", "pat"), Ft = c.Literal("disconnected", "connected", "expired", "revoked", "error"), It = c.Struct({
414
481
  connectionId: c.String,
415
482
  kind: Q,
416
483
  label: c.String,
417
- status: gt,
484
+ status: Ft,
418
485
  accountId: c.NullOr(c.String),
419
486
  accountLabel: c.NullOr(c.String),
420
487
  scopes: c.Array(c.String),
421
488
  expiresAt: c.NullOr(c.String),
422
489
  lastError: c.NullOr(c.String),
423
490
  connectedAt: c.NullOr(c.String)
424
- }), vt = class extends c.TaggedError()("ConnectionNotDeclared", { connectionId: c.String }) {}, yt = class extends c.TaggedError()("ConnectionSubjectRequired", { connectionId: c.String }) {}, bt = class extends c.TaggedError()("ConnectionKindMismatch", {
491
+ }), Lt = class extends c.TaggedError()("ConnectionNotDeclared", { connectionId: c.String }) {}, Rt = class extends c.TaggedError()("ConnectionSubjectRequired", { connectionId: c.String }) {}, zt = class extends c.TaggedError()("ConnectionKindMismatch", {
425
492
  connectionId: c.String,
426
493
  expected: Q,
427
494
  actual: Q
428
- }) {}, xt = class extends c.TaggedError()("ConnectionHandshakeFailed", {
495
+ }) {}, Bt = class extends c.TaggedError()("ConnectionHandshakeFailed", {
429
496
  connectionId: c.String,
430
497
  reason: c.String,
431
498
  transient: c.Boolean
432
- }) {}, $ = c.Union(vt, yt, bt, xt), St = h({
433
- name: Y,
499
+ }) {}, $ = c.Union(Lt, Rt, zt, Bt), Vt = _({
500
+ name: Mt,
434
501
  source: "_voltro_connections",
435
502
  input: c.Struct({}),
436
- output: c.Array(_t)
437
- }), Ct = _({
438
- name: X,
503
+ output: c.Array(It)
504
+ }), Ht = y({
505
+ name: Z,
439
506
  input: c.Struct({
440
507
  connectionId: c.String,
441
508
  redirectTo: c.optional(c.String)
@@ -445,22 +512,22 @@ var Pe = c.Union(c.String, c.Number), Fe = c.Record({
445
512
  state: c.String
446
513
  }),
447
514
  error: $
448
- }), wt = g({
449
- name: Z,
515
+ }), Ut = v({
516
+ name: Nt,
450
517
  input: c.Struct({
451
518
  connectionId: c.String,
452
519
  token: c.String
453
520
  }),
454
521
  output: c.Struct({ ok: c.Boolean }),
455
522
  error: $
456
- }), Tt = g({
457
- name: ht,
523
+ }), Wt = v({
524
+ name: Pt,
458
525
  input: c.Struct({ connectionId: c.String }),
459
526
  output: c.Struct({ ok: c.Boolean }),
460
527
  error: $
461
- }), Et = (e) => {
528
+ }), Gt = (e) => {
462
529
  let t = e instanceof Date ? e.getTime() : typeof e == "number" ? e : typeof e == "string" ? new Date(e).getTime() : 0;
463
530
  return Number.isNaN(t) ? 0 : t;
464
- }, Dt = 1;
531
+ }, Kt = 1;
465
532
  //#endregion
466
- export { te as ADMIN_SCOPE, oe as APIKEY_ISSUE_ORG_SCOPE, me as APIKEY_ISSUE_OTHER_SCOPE, ne as APIKEY_ISSUE_SELF_SCOPE, Ae as AuthMiddleware, Y as CONNECTIONS_LIST_TAG, ht as CONNECTION_DISCONNECT_TAG, X as CONNECTION_START_TAG, Z as CONNECTION_SUBMIT_TOKEN_TAG, xt as ConnectionHandshakeFailed, Te as ConnectionInfo, Oe as ConnectionInfoMiddleware, Q as ConnectionKind, bt as ConnectionKindMismatch, vt as ConnectionNotDeclared, _t as ConnectionState, gt as ConnectionStatus, yt as ConnectionSubjectRequired, Dt as PROTOCOL_VERSION, s as ScopeError, Ce as Subject, ye as SubjectService, H as UNDO_APPLY_TAG, dt as UNDO_LOG_TAG, U as UNDO_REDO_TAG, Ee as Unauthenticated, q as UndoConflict, K as UndoForbidden, W as UndoLogEntry, G as UndoNotFound, R as WorkflowControlInputSchema, M as WorkflowDomainEventRowSchema, I as WorkflowDomainEventsInputSchema, L as WorkflowEventDeliveriesInputSchema, N as WorkflowEventDeliveryRowSchema, D as WorkflowParentClosePolicySchema, j as WorkflowRunEventRowSchema, et as WorkflowRunHandleSchema, P as WorkflowRunRefSchema, O as WorkflowRunRowSchema, E as WorkflowRunStatusSchema, A as WorkflowRunStepRowSchema, F as WorkflowRunTableRefSchema, k as WorkflowRunsInputSchema, z as WorkflowSignalInputSchema, B as WorkflowUpdateInputSchema, V as WorkflowUpdateResultSchema, S as actionToRpc, ue as advisoryResourceGuardWarning, ke as anonymousSubject, Ve as applyRowPatch, be as assertAuthenticated, de as beginIdempotent, Qe as checkFrameworkCompat, se as checkGuards, ie as checkGuardsEffect, we as composeAuthStrategies, Xe as composeRpcInterceptors, Tt as connectionDisconnectDescriptor, Ct as connectionStartDescriptor, wt as connectionSubmitTokenDescriptor, St as connectionsListQueryDescriptor, _ as defineAction, g as defineMutation, Je as definePlugin, Ye as definePluginRoute, Ze as definePluginService, h as defineQuery, We as defineStream, ze as diffRows, re as effectiveScopes, Ge as errorTag, ae as failIdempotent, a as findAdvisoryResourceGuards, o as finishIdempotent, he as getPolicyGuardResolver, ve as getResourceScopeResolver, je as hasCallbackRoutes, ee as hasEffectiveScope, _e as hasScope, d as idToPath, le as idempotencyScope, Be as isIdKeyed, r as isPolicyCheck, Ue as isPolicyGuard, xe as isSystemSubject, He as isWireReachable, fe as memoryIdempotencyStore, x as mutationToRpc, qe as normalizeDescriptor, Le as pathToId, pe as publishServerError, b as queryToRpc, e as requireScope, Ie as rowPatchOpSchema, u as rowPatchSchema, ge as setEffectiveScopes, i as setPolicyGuardResolver, n as setResourceScopeResolver, C as streamToRpc, t as subjectScopes, ce as subscribeServerErrors, p as subscriptionEvent, Se as systemSubject, De as tenantScopedSubject, Ke as toRpc, Et as tsMs, pt as undoApplyDescriptor, ft as undoLogQueryDescriptor, mt as undoRedoDescriptor, st as workflowCancelDescriptor, at as workflowDomainEventsQueryDescriptor, ot as workflowEventDeliveriesQueryDescriptor, ct as workflowResumeDescriptor, it as workflowRunEventsQueryDescriptor, tt as workflowRunQueryDescriptor, rt as workflowRunStepsQueryDescriptor, nt as workflowRunsQueryDescriptor, lt as workflowSignalDescriptor, ut as workflowUpdateDescriptor };
533
+ export { ce as ADMIN_SCOPE, he as APIKEY_ISSUE_ORG_SCOPE, re as APIKEY_ISSUE_OTHER_SCOPE, ie as APIKEY_ISSUE_SELF_SCOPE, je as AuthMiddleware, Mt as CONNECTIONS_LIST_TAG, Pt as CONNECTION_DISCONNECT_TAG, Z as CONNECTION_START_TAG, Nt as CONNECTION_SUBMIT_TOKEN_TAG, Bt as ConnectionHandshakeFailed, Ee as ConnectionInfo, ke as ConnectionInfoMiddleware, Q as ConnectionKind, zt as ConnectionKindMismatch, Lt as ConnectionNotDeclared, It as ConnectionState, Ft as ConnectionStatus, Rt as ConnectionSubjectRequired, rt as EVENT_ROUTE_SEP, tt as EventKeyInvalid, et as EventPayloadInvalid, nt as EventPayloadTooLarge, Xe as MAX_EVENT_ENVELOPE_BYTES, Kt as PROTOCOL_VERSION, s as ScopeError, we as Subject, be as SubjectService, J as UNDO_APPLY_TAG, q as UNDO_LOG_TAG, Y as UNDO_REDO_TAG, De as Unauthenticated, Dt as UndoConflict, Et as UndoForbidden, X as UndoLogEntry, Tt as UndoNotFound, U as WorkflowControlInputSchema, R as WorkflowDomainEventRowSchema, mt as WorkflowDomainEventsInputSchema, H as WorkflowEventDeliveriesInputSchema, z as WorkflowEventDeliveryRowSchema, N as WorkflowParentClosePolicySchema, L as WorkflowRunEventRowSchema, pt as WorkflowRunHandleSchema, B as WorkflowRunRefSchema, P as WorkflowRunRowSchema, M as WorkflowRunStatusSchema, I as WorkflowRunStepRowSchema, V as WorkflowRunTableRefSchema, F as WorkflowRunsInputSchema, W as WorkflowSignalInputSchema, G as WorkflowUpdateInputSchema, K as WorkflowUpdateResultSchema, Ge as actionToRpc, le as advisoryResourceGuardWarning, Ae as anonymousSubject, Be as applyRowPatch, xe as assertAuthenticated, fe as beginIdempotent, dt as checkFrameworkCompat, oe as checkGuards, ae as checkGuardsEffect, Te as composeAuthStrategies, lt as composeRpcInterceptors, Wt as connectionDisconnectDescriptor, Ht as connectionStartDescriptor, Ut as connectionSubmitTokenDescriptor, Vt as connectionsListQueryDescriptor, y as defineAction, Qe as defineEvent, v as defineMutation, st as definePlugin, ct as definePluginRoute, ut as definePluginService, _ as defineQuery, Ue as defineStream, Re as diffRows, o as effectiveScopes, k as encodeEventKey, qe as errorTag, T as eventAttached, C as eventEnvelope, w as eventGap, D as eventResumePoint, it as eventRoute, E as eventStreamEvent, O as eventSubscribeInput, $e as eventToRpc, se as failIdempotent, ge as findAdvisoryResourceGuards, ee as finishIdempotent, ot as formatEventRoute, ye as getPolicyGuardResolver, te as getResourceScopeResolver, Me as hasCallbackRoutes, ve as hasEffectiveScope, i as hasScope, p as idToPath, de as idempotencyScope, Ze as isEventDescriptor, ze as isIdKeyed, e as isPolicyCheck, He as isPolicyGuard, Se as isSystemSubject, Ve as isWireReachable, pe as memoryIdempotencyStore, We as mutationToRpc, Ye as normalizeDescriptor, at as parseEventRoute, Ie as pathToId, me as publishServerError, S as queryToRpc, _e as requireScope, d as rowPatchOpSchema, f as rowPatchSchema, a as setEffectiveScopes, n as setPolicyGuardResolver, t as setResourceScopeResolver, Ke as streamToRpc, r as subjectScopes, ue as subscribeServerErrors, h as subscriptionEvent, Ce as systemSubject, Oe as tenantScopedSubject, Je as toRpc, Gt as tsMs, At as undoApplyDescriptor, kt as undoLogQueryDescriptor, jt as undoRedoDescriptor, xt as workflowCancelDescriptor, yt as workflowDomainEventsQueryDescriptor, bt as workflowEventDeliveriesQueryDescriptor, St as workflowResumeDescriptor, vt as workflowRunEventsQueryDescriptor, ht as workflowRunQueryDescriptor, _t as workflowRunStepsQueryDescriptor, gt as workflowRunsQueryDescriptor, Ct as workflowSignalDescriptor, wt as workflowUpdateDescriptor, ne as wsMutationIdempotencyScope };
package/dist/rest.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, i as t, o as n, r, t as i } from "./serverErrorBus-BkKWg0_x.js";
1
+ import { a as e, i as t, o as n, r, t as i } from "./serverErrorBus-C3JTqgIc.js";
2
2
  import { s as a } from "./auth-BPdyOBsd.js";
3
3
  import { Effect as o, Schema as s } from "effect";
4
4
  //#region src/publicApi.ts
@@ -113,13 +113,13 @@ var n = "admin:full", r = "apikeys:issue:self", i = "apikeys:issue:org", a = "ap
113
113
  }
114
114
  return null;
115
115
  });
116
- }, D = (e, t, n) => `${e ?? "(global)"}|${t.toUpperCase()}|${n}`, O = async (e, t, n, r, i) => {
116
+ }, D = (e, t, n) => `${e ?? "(global)"}|${t.toUpperCase()}|${n}`, O = (e, t, n) => `${e ?? "(global)"}|${t ?? "(anon)"}|WS|${n}`, k = async (e, t, n, r, i) => {
117
117
  let a = await e.claim(t, n, i, r);
118
118
  return a === "claimed" ? { kind: "fresh" } : a.status === "completed" && a.response ? {
119
119
  kind: "replay",
120
120
  response: a.response
121
121
  } : { kind: "conflict" };
122
- }, k = (e, t, n, r, i) => e.complete(t, n, r, i), A = (e, t, n) => e.release(t, n), j = () => {
122
+ }, A = (e, t, n, r, i) => e.complete(t, n, r, i), j = (e, t, n) => e.release(t, n), M = () => {
123
123
  let e = /* @__PURE__ */ new Map(), t = (e, t) => `${e}\u0000${t}`;
124
124
  return {
125
125
  get: async (n, r) => e.get(t(n, r)) ?? null,
@@ -146,12 +146,12 @@ var n = "admin:full", r = "apikeys:issue:self", i = "apikeys:issue:org", a = "ap
146
146
  e.delete(t(n, r));
147
147
  }
148
148
  };
149
- }, M = /* @__PURE__ */ new Set(), N = (e) => {
150
- for (let t of M) try {
149
+ }, N = /* @__PURE__ */ new Set(), P = (e) => {
150
+ for (let t of N) try {
151
151
  t(e);
152
152
  } catch {}
153
- }, P = (e) => (M.add(e), () => {
154
- M.delete(e);
153
+ }, F = (e) => (N.add(e), () => {
154
+ N.delete(e);
155
155
  });
156
156
  //#endregion
157
- export { p as C, s as D, _ as E, m as S, S as T, v as _, k as a, d as b, n as c, r as d, o as f, u as g, E as h, A as i, i as l, w as m, P as n, D as o, y as p, O as r, j as s, N as t, a as u, C as v, l as w, f as x, b as y };
157
+ export { m as C, _ as D, S as E, s as O, f as S, l as T, u as _, A as a, b, O as c, a as d, r as f, E as g, w as h, j as i, n as l, y as m, F as n, D as o, o as p, k as r, M as s, P as t, i as u, v, p as w, d as x, C as y };