@voltro/protocol 0.85.0 → 0.86.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/README.md +14 -0
  3. package/THIRD-PARTY-NOTICES.md +5 -33
  4. package/dist/approval.js +64 -0
  5. package/dist/approvalDescriptors.js +26 -0
  6. package/dist/auth.js +369 -0
  7. package/dist/boundedRing.js +27 -0
  8. package/dist/businessRule.js +11 -0
  9. package/dist/connection.js +73 -0
  10. package/dist/devActivity.js +4 -0
  11. package/dist/errorValue.js +21 -0
  12. package/dist/event.js +104 -0
  13. package/dist/idempotency.js +66 -0
  14. package/dist/identity.js +5 -9
  15. package/dist/index.d.ts +225 -21
  16. package/dist/index.js +42 -1700
  17. package/dist/inspect.js +14 -240
  18. package/dist/inspectBackfill.js +52 -0
  19. package/dist/inspectCommandRejection.js +21 -0
  20. package/dist/inspectProjection.js +133 -0
  21. package/dist/inspectStorageProjection.js +86 -0
  22. package/dist/inspectValueIdentity.js +4 -0
  23. package/dist/inspectWorkflowExecution.js +34 -0
  24. package/dist/inspectWorkflowQueuedStart.js +31 -0
  25. package/dist/jsonSchema.js +54 -0
  26. package/dist/outbox.js +10 -0
  27. package/dist/pairing.js +75 -0
  28. package/dist/plugin.js +61 -0
  29. package/dist/pluginNaming.js +32 -0
  30. package/dist/procedure.js +262 -0
  31. package/dist/publicApi.js +344 -0
  32. package/dist/reactivityChannel.js +34 -0
  33. package/dist/rest.d.ts +33 -0
  34. package/dist/rest.js +213 -470
  35. package/dist/restFormat.js +163 -0
  36. package/dist/rowEquality.js +31 -0
  37. package/dist/rowPatch.js +182 -0
  38. package/dist/schemaShape.js +67 -0
  39. package/dist/scopes.js +240 -0
  40. package/dist/serverErrorBus.js +15 -0
  41. package/dist/serviceCall.js +14 -0
  42. package/dist/session.js +13 -15
  43. package/dist/{sessionHeader-DriTZhmv.js → sessionHeader.js} +1 -1
  44. package/dist/storageAccess.js +14 -0
  45. package/dist/storeErrors.js +66 -0
  46. package/dist/storeScreenshots.js +90 -0
  47. package/dist/strictInput.js +27 -0
  48. package/dist/subscriptionEvent.js +37 -0
  49. package/dist/tenantSelection.js +40 -0
  50. package/dist/time.js +7 -0
  51. package/dist/undo.js +38 -0
  52. package/dist/validation.js +39 -0
  53. package/dist/webSocketGateway.js +10 -0
  54. package/dist/workflow.js +297 -0
  55. package/dist/workflowAccess.js +61 -0
  56. package/dist/workflowRestart.js +45 -0
  57. package/dist/workflowRetry.js +44 -0
  58. package/dist/workflowStartOutcome.js +30 -0
  59. package/package.json +3 -3
  60. package/dist/restFormat-BlgTLxm1.js +0 -298
  61. package/dist/scopes-ClywBij8.js +0 -548
@@ -1,298 +0,0 @@
1
- import { Schema as e, SchemaGetter as t, SchemaTransformation as n } from "effect";
2
- import { RpcSchema as r } from "effect/rpc";
3
- import * as i from "effect/SchemaAST";
4
- //#region src/idempotency.ts
5
- var a = (e, t, n) => `${e ?? "(global)"}|${t.toUpperCase()}|${n}`, o = (e, t, n, r) => r === void 0 ? `${e ?? "(global)"}|${t ?? "(anon)"}|WS|${n}` : `WS-connection:${JSON.stringify([
6
- e ?? null,
7
- t ?? null,
8
- n,
9
- r
10
- ])}`, s = class extends e.TaggedError()("MutationConnectionRequired", { traceId: e.String }) {
11
- get message() {
12
- return "this mutation requires a live native WebSocket connection";
13
- }
14
- }, c = async (e, t, n, r, i, a = l) => {
15
- let o = await e.claim(t, n, i, r, a);
16
- return o === "claimed" ? { kind: "fresh" } : o.status === "completed" && o.response ? {
17
- kind: "replay",
18
- response: o.response
19
- } : { kind: "conflict" };
20
- }, l = 3e4, u = (e, t, n, r = l, i = Date.now) => {
21
- let a = setInterval(() => {
22
- e.renew(t, n, i()).catch(() => {});
23
- }, Math.max(1, Math.floor(r / 3)));
24
- return a.unref?.(), () => clearInterval(a);
25
- }, d = (e, t, n, r, i) => e.complete(t, n, r, i), f = (e, t, n) => e.release(t, n), p = () => {
26
- let e = /* @__PURE__ */ new Map(), t = (e, t) => `${e}\u0000${t}`;
27
- return {
28
- get: async (n, r) => e.get(t(n, r)) ?? null,
29
- claim: async (n, r, i, a, o) => {
30
- let s = e.get(t(n, r));
31
- return s && i - s.createdAt < m(s.status, a, o) ? s : (e.set(t(n, r), {
32
- scope: n,
33
- key: r,
34
- status: "in_flight",
35
- response: null,
36
- createdAt: i
37
- }), "claimed");
38
- },
39
- complete: async (n, r, i, a) => {
40
- e.set(t(n, r), {
41
- scope: n,
42
- key: r,
43
- status: "completed",
44
- response: i,
45
- createdAt: a
46
- });
47
- },
48
- release: async (n, r) => {
49
- e.delete(t(n, r));
50
- },
51
- renew: async (n, r, i) => {
52
- let a = e.get(t(n, r));
53
- a?.status === "in_flight" && e.set(t(n, r), {
54
- ...a,
55
- createdAt: i
56
- });
57
- }
58
- };
59
- }, m = (e, t, n) => e === "completed" ? t : Math.min(t, n), h = class extends e.TaggedError()("MutationInFlight", {
60
- traceId: e.String,
61
- retryAfterMs: e.Number
62
- }) {
63
- get message() {
64
- return `a request with this idempotency key is still in flight — replay the same key after ${this.retryAfterMs}ms`;
65
- }
66
- }, g = 1e3, _ = (e) => typeof e == "object" && !!e && typeof e._tag == "string", v = 64, y = (e, t = 0) => {
67
- if (!_(e)) return String(e);
68
- if (t >= v) return "…";
69
- let n = t + 1, r = (t) => Array.isArray(e[t]) ? e[t] : [], i = r("encoding").map((e) => y(e.to, n)).join("->"), a = r("checks").length, o = (e) => _(e) && e.context?.isOptional === !0, s = () => {
70
- switch (e._tag) {
71
- case "Suspend": return "S(…)";
72
- case "Objects": {
73
- let e = r("propertySignatures").map((e) => {
74
- let t = e;
75
- return `${String(t.name)}${o(t.type) ? "?" : ""}:${y(t.type, n)}`;
76
- }).join(","), t = r("indexSignatures").map((e) => {
77
- let t = e;
78
- return `[${y(t.parameter, n)}]:${y(t.type, n)}`;
79
- }).join(",");
80
- return t === "" ? `{${e}}` : `{${e};${t}}`;
81
- }
82
- case "Union": return `U(${r("types").map((e) => y(e, n)).join("|")})`;
83
- case "Arrays": {
84
- let e = r("elements").map((e) => `${y(e, n)}${o(e) ? "?" : ""}`).join(","), t = r("rest").map((e) => y(e, n)).join(",");
85
- return `A(${e}${t === "" ? "" : `...${t}`})`;
86
- }
87
- case "Declaration": return `D(${r("typeParameters").map((e) => y(e, n)).join(",")})`;
88
- case "Literal": return `L(${String(e.literal)})`;
89
- case "Enum": return `E(${r("enums").map((e) => e.map(String).join("=")).join(",")})`;
90
- case "TemplateLiteral": return `TL(${r("parts").map((e) => y(e, n)).join(",")})`;
91
- case "UniqueSymbol": return `Y(${String(e.symbol)})`;
92
- default: return String(e);
93
- }
94
- }, c = a > 0 ? `R${a}(${s()})` : s();
95
- return i === "" ? c : `T(${i}->${c})`;
96
- }, b = (e) => {
97
- let t = 2166136261;
98
- for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619) >>> 0;
99
- return t.toString(16).padStart(8, "0");
100
- }, x = (e) => {
101
- if (e !== void 0 && r.isStreamSchema(e)) {
102
- let t = e;
103
- return `S(${y(t.success.ast)}|${y(t.error.ast)})`;
104
- }
105
- return y(e?.ast);
106
- }, S = (e) => b([
107
- y(e.payloadSchema?.ast),
108
- x(e.successSchema),
109
- y(e.errorSchema?.ast)
110
- ].join("\0")), C = (e) => {
111
- let t = {}, n = e.requests, r = n instanceof Map ? n.entries() : Array.isArray(n) ? n.map((e, t) => [t, e]) : [];
112
- for (let [, e] of r) {
113
- if (typeof e != "object" && typeof e != "function" || e === null) continue;
114
- let n = e;
115
- typeof n._tag == "string" && (t[n._tag] = S(n));
116
- }
117
- return t;
118
- }, w = (e, t) => {
119
- let n = [], r = [];
120
- for (let [i, a] of Object.entries(t)) {
121
- let t = e[i];
122
- t === void 0 ? r.push(i) : t !== a && n.push(i);
123
- }
124
- return {
125
- differing: n.sort(),
126
- missingHere: r.sort()
127
- };
128
- }, T = (e) => {
129
- let t = e.error, n = t instanceof Error ? t.name : typeof t?._tag == "string" ? String(t._tag) : "Error", r = [e.name === void 0 ? e.source : `${e.source} '${e.name}'`, ...typeof e.fields?.runId == "string" ? [`run ${e.fields.runId}`] : []].join(", "), i = /* @__PURE__ */ Error(`[message withheld: ${r} is declared encrypted — read it where the run is shown]`);
130
- i.name = n;
131
- let a = t instanceof Error && typeof t.stack == "string" ? t.stack : "", o = a.search(/^\s+at /m);
132
- return i.stack = `${n}: ${i.message}${o === -1 ? "" : `\n${a.slice(o)}`}`, i;
133
- }, E = /* @__PURE__ */ new Set(), D = (e) => {
134
- for (let t of E) try {
135
- t(e);
136
- } catch {}
137
- }, O = (e) => (E.add(e), () => {
138
- E.delete(e);
139
- }), k = {
140
- rpc: {
141
- name: "rpc",
142
- dates: "epoch-ms",
143
- errors: "tagged",
144
- envelope: "none",
145
- pagination: "body-cursor",
146
- cursorField: "nextCursor",
147
- cursorParam: "cursor",
148
- naming: "camelCase",
149
- etag: !1
150
- },
151
- standard: {
152
- name: "standard",
153
- dates: "iso",
154
- errors: "problem-details",
155
- envelope: "none",
156
- pagination: "link-header",
157
- cursorField: "nextCursor",
158
- cursorParam: "cursor",
159
- naming: "camelCase",
160
- etag: !0
161
- },
162
- jsonapi: {
163
- name: "jsonapi",
164
- dates: "iso",
165
- errors: "problem-details",
166
- envelope: "jsonapi",
167
- pagination: "link-header",
168
- cursorField: "nextCursor",
169
- cursorParam: "cursor",
170
- naming: "camelCase",
171
- etag: !0
172
- }
173
- }, A = [
174
- "rpc",
175
- "standard",
176
- "jsonapi"
177
- ], j = (e, t = void 0) => {
178
- let n = (e) => {
179
- if (e?.profile !== void 0) {
180
- if (typeof e.profile == "string") {
181
- let t = k[e.profile];
182
- if (t === void 0) throw Error(`publicApi.profile: unknown profile '${String(e.profile)}' — one of ${A.join(", ")}, or a RestFormat object`);
183
- return t;
184
- }
185
- return e.profile;
186
- }
187
- }, r = (e, t) => t === void 0 ? e : {
188
- ...e,
189
- ...t.dates === void 0 ? {} : { dates: t.dates },
190
- ...t.errors === void 0 ? {} : { errors: t.errors },
191
- ...t.envelope === void 0 ? {} : { envelope: t.envelope },
192
- ...t.pagination === void 0 ? {} : { pagination: t.pagination },
193
- ...t.cursorField === void 0 ? {} : { cursorField: t.cursorField },
194
- ...t.cursorParam === void 0 ? {} : { cursorParam: t.cursorParam },
195
- ...t.naming === void 0 ? {} : { naming: t.naming },
196
- ...t.etag === void 0 ? {} : { etag: t.etag }
197
- }, i = r(n(e) ?? k.rpc, e);
198
- return r(n(t) ?? i, t);
199
- }, M = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase(), N = (e, t) => {
200
- if (typeof e != "object" || !e || Array.isArray(e)) return e;
201
- let n = {};
202
- for (let [r, i] of Object.entries(e)) n[t(r)] = i;
203
- return n;
204
- }, P = (e) => i.isDeclaration(e) && e.encoding !== void 0 && e.annotations?.representation?.id === "effect/schema/Date" && i.isNumber(i.toEncoded(e)), F = e.String.annotate({
205
- identifier: "DateFromString",
206
- format: "date-time"
207
- }).pipe(e.decodeTo(e.Date, n.dateFromString)), I = (n, r) => {
208
- if (r.dates === "epoch-ms" && r.naming === "camelCase") return n;
209
- let a = /* @__PURE__ */ new Map(), o = (e) => {
210
- let t = a.get(e);
211
- if (t !== void 0) return t;
212
- let n = s(e);
213
- return a.set(e, n), n;
214
- }, s = (n) => {
215
- if (r.dates === "iso" && P(n)) return F.annotate(n.annotations ?? {}).ast;
216
- if (n.encoding !== void 0) return n;
217
- if (i.isUnion(n)) return new i.Union(n.types.map(o), n.options, n.annotations, n.checks, void 0, n.context);
218
- if (i.isArrays(n)) return new i.Arrays(n.isMutable, n.elements.map(o), n.rest.map(o), n.annotations, n.checks, void 0, n.context);
219
- if (i.isSuspend(n)) return new i.Suspend(() => o(n.thunk()), n.annotations, n.checks, void 0, n.context);
220
- if (i.isObjects(n)) {
221
- let a = n.propertySignatures.map((e) => new i.PropertySignature(e.name, o(e.type))), s = n.indexSignatures.map((e) => new i.IndexSignature(e.parameter, o(e.type))), c = new i.Objects(a, s, n.annotations, n.checks, void 0, n.context);
222
- if (r.naming !== "snake_case") return c;
223
- let l = a.map((e) => typeof e.name == "string" ? M(e.name) : e.name);
224
- if (l.every((e, t) => e === a[t].name)) return c;
225
- let u = new i.Objects(a.map((e, t) => new i.PropertySignature(l[t], i.toEncoded(e.type))), s.map((e) => new i.IndexSignature(e.parameter, i.toEncoded(e.type))), n.annotations, void 0, void 0, n.context), d = new Map(a.map((e, t) => [String(l[t]), String(e.name)])), f = new Map(a.map((e, t) => [String(e.name), String(l[t])]));
226
- return e.make(u).pipe(e.decodeTo(e.make(c), {
227
- decode: t.transform((e) => N(e, (e) => d.get(e) ?? e)),
228
- encode: t.transform((e) => N(e, (e) => f.get(e) ?? e))
229
- })).ast;
230
- }
231
- return n;
232
- };
233
- return e.make(o(n.ast));
234
- }, L = (e) => `urn:voltro:error:${e}`, R = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2"), z = (e) => ({
235
- type: L(e.tag),
236
- title: R(e.tag),
237
- status: e.status,
238
- ...e.message.length > 0 ? { detail: e.message } : {},
239
- ...e.fields
240
- }), B = "application/problem+json; charset=utf-8", V = "application/vnd.api+json; charset=utf-8", H = (e, t, n) => e.encodeError === void 0 ? e.errors === "problem-details" ? e.envelope === "jsonapi" ? {
241
- body: { errors: [{
242
- status: String(t.status),
243
- code: t.tag,
244
- title: R(t.tag),
245
- ...t.message.length > 0 ? { detail: t.message } : {},
246
- ...Object.keys(t.fields).length > 0 ? { meta: t.fields } : {}
247
- }] },
248
- contentType: V
249
- } : {
250
- body: z(t),
251
- contentType: B
252
- } : { body: {
253
- error: t.tag === "InvalidRequest" || t.tag === "InternalServerError" || t.tag === "Unauthorized" || t.tag === "Forbidden" || t.tag === "Gone" || t.tag === "MethodNotAllowed" || t.tag === "Conflict" ? t.message : t.tag,
254
- ...t.fields
255
- } } : e.encodeError(t, n), U = (e, t) => {
256
- if (typeof e != "object" || !e || Array.isArray(e)) return {
257
- cursor: void 0,
258
- rest: e
259
- };
260
- let n = e[t];
261
- return typeof n != "string" && typeof n != "number" ? {
262
- cursor: void 0,
263
- rest: e
264
- } : {
265
- cursor: String(n),
266
- rest: e
267
- };
268
- }, W = (e, t, n) => {
269
- let r = new URLSearchParams(e.query);
270
- return r.set(n, t), `<${e.path}?${r.toString()}>; rel="next"`;
271
- }, G = (e, t) => {
272
- if (typeof e != "object" || !e || Array.isArray(e)) return e;
273
- let { id: n, ...r } = e;
274
- return {
275
- type: t,
276
- ...n === void 0 ? {} : { id: String(n) },
277
- attributes: r
278
- };
279
- }, K = (e, t, n) => {
280
- if (e.encodeSuccess !== void 0) return e.encodeSuccess(t, n);
281
- let { cursor: r } = U(t, e.cursorField), i = e.pagination === "link-header" && r !== void 0 ? { Link: W(n, r, e.cursorParam) } : void 0, a = (e, t) => ({
282
- body: e,
283
- ...i ? { headers: i } : {},
284
- ...t ? { contentType: t } : {}
285
- });
286
- if (e.envelope === "none") return a(t);
287
- if (e.envelope === "data") return a({
288
- data: t,
289
- ...r !== void 0 && e.pagination === "link-header" ? { next: r } : {}
290
- });
291
- let o = n.source ?? n.tag.split(".")[0] ?? "resource", s = Array.isArray(t) ? t : typeof t == "object" && t && Array.isArray(t.items) ? t.items : void 0;
292
- return a({
293
- data: s === void 0 ? G(t, o) : s.map((e) => G(e, o)),
294
- ...r === void 0 ? {} : { links: { next: W(n, r, e.cursorParam).replace(/^<|>; rel="next"$/g, "") } }
295
- }, V);
296
- };
297
- //#endregion
298
- export { p as A, h as C, m as D, d as E, u as O, s as S, f as T, S as _, K as a, l as b, L as c, M as d, D as f, C as g, w as h, H as i, o as j, a as k, j as l, T as m, B as n, W as o, O as p, A as r, z as s, V as t, I as u, y as v, c as w, g as x, b as y };