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