@voltro/protocol 0.86.0 → 0.88.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 (78) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/THIRD-PARTY-NOTICES.md +3 -227
  3. package/dist/apiRoleEndpoints.js +107 -0
  4. package/dist/apiRoleObservation.js +67 -0
  5. package/dist/apikey.d.ts +10 -0
  6. package/dist/apikey.js +1 -2
  7. package/dist/approval.js +1 -2
  8. package/dist/approvalDescriptors.js +1 -2
  9. package/dist/auth.js +40 -21
  10. package/dist/boundedRing.js +1 -2
  11. package/dist/businessRule.js +1 -2
  12. package/dist/canonicalJson.js +13 -0
  13. package/dist/connection.js +1 -2
  14. package/dist/devActivity.js +1 -2
  15. package/dist/errorSchema.js +23 -0
  16. package/dist/errorValue.js +1 -2
  17. package/dist/event.js +52 -47
  18. package/dist/formCapture.js +11 -0
  19. package/dist/httpStreamMaxDuration.js +8 -0
  20. package/dist/idempotency.js +89 -35
  21. package/dist/idempotencyInput.js +122 -0
  22. package/dist/identity.js +1 -2
  23. package/dist/index.d.ts +876 -124
  24. package/dist/index.js +51 -40
  25. package/dist/inspect.d.ts +1 -1
  26. package/dist/inspect.js +1 -2
  27. package/dist/inspectBackfill.js +1 -2
  28. package/dist/inspectCommandRejection.js +1 -2
  29. package/dist/inspectProjection.js +1 -2
  30. package/dist/inspectStorageProjection.js +1 -2
  31. package/dist/inspectValueIdentity.js +1 -2
  32. package/dist/inspectWorkflowExecution.js +1 -2
  33. package/dist/inspectWorkflowQueuedStart.js +1 -2
  34. package/dist/jsonSchema.js +1 -2
  35. package/dist/jwt.d.ts +10 -0
  36. package/dist/jwt.js +2 -3
  37. package/dist/outbox.js +1 -2
  38. package/dist/pairing.js +1 -2
  39. package/dist/plugin.js +44 -19
  40. package/dist/pluginAccountMerge.js +87 -0
  41. package/dist/pluginNaming.js +1 -2
  42. package/dist/pluginPrivacy.js +165 -0
  43. package/dist/procedure.js +115 -98
  44. package/dist/publicApi.js +191 -211
  45. package/dist/queryOptionalSources.js +13 -0
  46. package/dist/reactivityChannel.js +1 -2
  47. package/dist/rest.d.ts +227 -64
  48. package/dist/rest.js +296 -194
  49. package/dist/restFormat.js +1 -2
  50. package/dist/restReceipt.js +42 -0
  51. package/dist/revalidate.js +12 -0
  52. package/dist/rowEquality.js +1 -2
  53. package/dist/rowPatch.js +1 -2
  54. package/dist/schemaShape.js +1 -2
  55. package/dist/scopes.js +72 -40
  56. package/dist/secretWindows.js +70 -0
  57. package/dist/serverErrorBus.js +1 -2
  58. package/dist/serviceCall.js +1 -2
  59. package/dist/session.d.ts +89 -6
  60. package/dist/session.js +56 -56
  61. package/dist/sessionHeader.js +1 -2
  62. package/dist/ssrfPolicy.js +29 -0
  63. package/dist/storageAccess.js +1 -2
  64. package/dist/storeErrors.js +1 -2
  65. package/dist/storeScreenshots.js +1 -2
  66. package/dist/strictInput.js +1 -2
  67. package/dist/subscriptionEvent.js +1 -2
  68. package/dist/tenantSelection.js +1 -2
  69. package/dist/time.js +1 -2
  70. package/dist/undo.js +1 -2
  71. package/dist/validation.js +1 -2
  72. package/dist/webSocketGateway.js +8 -3
  73. package/dist/workflow.js +1 -2
  74. package/dist/workflowAccess.js +1 -2
  75. package/dist/workflowRestart.js +1 -2
  76. package/dist/workflowRetry.js +1 -2
  77. package/dist/workflowStartOutcome.js +1 -2
  78. package/package.json +7 -5
package/dist/publicApi.js CHANGED
@@ -1,19 +1,22 @@
1
- import { schemaShape as e, shapeDigest as t } from "./schemaShape.js";
2
- import { encodeRestError as n, encodeRestSuccess as r, resolveRestFormat as i, restViewSchema as a, toSnakeCase as o } from "./restFormat.js";
3
- import { RestRouteError as s, defineRestRoute as c, requireAuthenticated as l, requireScope as u, response as ee, sse as d, sseFrame as f } from "./rest.js";
4
- import { Effect as p, Schema as m, SchemaGetter as h, SchemaIssue as g } from "effect";
5
- import * as _ from "effect/SchemaAST";
6
- //#region src/publicApi.ts
7
- var v = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? S("", t, n).method : void 0) ?? (e === "query" ? "GET" : "POST"), y = (e, t, n) => C(t.path ?? (t.resource !== void 0 && n !== void 0 ? S(e, t, n).path : `/${t.version ?? "v1"}/${e.replace(/\./g, "/")}`)), b = (e) => {
1
+ import { checkGuardsEffect as e } from "./scopes.js";
2
+ import { declaredErrorTags as t, errorMemberSchema as n } from "./errorSchema.js";
3
+ import { schemaShape as r, shapeDigest as i } from "./schemaShape.js";
4
+ import { validateHttpStreamMaxDuration as a } from "./httpStreamMaxDuration.js";
5
+ import { encodeRestError as o, resolveRestFormat as s, restViewSchema as c, toSnakeCase as l } from "./restFormat.js";
6
+ import { RestRouteError as u, defineRestRoute as ee, requireAuthenticated as d, requireScope as f, response as p, sse as te, sseFrame as m } from "./rest.js";
7
+ import { Effect as h, Schema as g, SchemaGetter as _, SchemaIssue as ne } from "effect";
8
+ import * as v from "effect/SchemaAST";
9
+ // src/publicApi.ts
10
+ var y = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? C("", t, n).method : void 0) ?? (e === "query" ? "GET" : "POST"), b = (e, t, n) => w(t.path ?? (t.resource !== void 0 && n !== void 0 ? C(e, t, n).path : `/${t.version ?? "v1"}/${e.replace(/\./g, "/")}`)), x = (e) => {
8
11
  let t = e.split("/").pop() ?? e;
9
12
  return t.endsWith("ies") ? `${t.slice(0, -3)}y` : t.endsWith("ses") || t.endsWith("xes") ? t.slice(0, -2) : t.endsWith("s") ? t.slice(0, -1) : t;
10
- }, x = (e, t) => {
11
- let n = t != null && (typeof t == "object" || typeof t == "function") && "ast" in t ? L(t) : void 0;
13
+ }, S = (e, t) => {
14
+ let n = t != null && (typeof t == "object" || typeof t == "function") && "ast" in t ? F(t) : void 0;
12
15
  if (n === void 0) return;
13
- let r = `${b(e)}Id`;
16
+ let r = `${x(e)}Id`;
14
17
  return n.has(r) ? r : n.has("id") ? "id" : void 0;
15
- }, S = (e, t, n) => {
16
- let r = (t.resource ?? "").replace(/^\/+|\/+$/g, ""), i = `/${t.version ?? "v1"}/${r}`, a = x(r, n.input), o = a === void 0 ? i : `${i}/:${a}`, s = e.split(".").pop() ?? e, c = n.target?.op;
18
+ }, C = (e, t, n) => {
19
+ let r = (t.resource ?? "").replace(/^\/+|\/+$/g, ""), i = `/${t.version ?? "v1"}/${r}`, a = S(r, n.input), o = a === void 0 ? i : `${i}/:${a}`, s = e.split(".").pop() ?? e, c = n.target?.op;
17
20
  return n.kind === "query" || n.kind === "stream" ? {
18
21
  method: "GET",
19
22
  path: o
@@ -30,50 +33,50 @@ var v = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? S("",
30
33
  method: "POST",
31
34
  path: `${o}/${s}`
32
35
  };
33
- }, C = (e) => e.replace(/\{([A-Za-z0-9_]+)\}/g, ":$1"), w = (e) => [...e.matchAll(/:([A-Za-z0-9_]+)/g)].map((e) => e[1]), T = (e) => {
34
- if (_.isUnion(e)) {
35
- let t = e.types.filter((e) => !_.isUndefined(e));
36
+ }, w = (e) => e.replace(/\{([A-Za-z0-9_]+)\}/g, ":$1"), T = (e) => [...e.matchAll(/:([A-Za-z0-9_]+)/g)].map((e) => e[1]), E = (e) => {
37
+ if (v.isUnion(e)) {
38
+ let t = e.types.filter((e) => !v.isUndefined(e));
36
39
  if (t.length === 1) return t[0];
37
- if (t.length !== e.types.length) return new _.Union(t);
40
+ if (t.length !== e.types.length) return new v.Union(t);
38
41
  }
39
42
  return e;
40
- }, E = /^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i, D = (e, t) => {
41
- let n = T(t);
42
- if (n.encoding !== void 0) return D(e, _.toEncoded(n));
43
- if (_.isUnion(n)) {
43
+ }, D = /^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i, O = (e, t) => {
44
+ let n = E(t);
45
+ if (n.encoding !== void 0) return O(e, v.toEncoded(n));
46
+ if (v.isUnion(n)) {
44
47
  for (let t of n.types) {
45
- let n = D(e, t);
48
+ let n = O(e, t);
46
49
  if (n !== e) return n;
47
50
  }
48
51
  return e;
49
52
  }
50
- if (_.isArrays(n)) {
53
+ if (v.isArrays(n)) {
51
54
  let t = Array.isArray(e) ? e : e === void 0 ? void 0 : [e];
52
55
  if (t === void 0) return e;
53
56
  let r = n.rest[0] ?? n.elements[0];
54
- return r === void 0 ? t : t.map((e) => D(e, r));
57
+ return r === void 0 ? t : t.map((e) => O(e, r));
55
58
  }
56
59
  if (typeof e != "string") return e;
57
- if (_.isNumber(n)) return E.test(e.trim()) ? Number(e) : e;
58
- if (_.isBoolean(n)) return e === "true" || e !== "false" && e;
59
- if (_.isLiteral(n)) {
60
+ if (v.isNumber(n)) return D.test(e.trim()) ? Number(e) : e;
61
+ if (v.isBoolean(n)) return e === "true" || e !== "false" && e;
62
+ if (v.isLiteral(n)) {
60
63
  let t = n.literal;
61
- return typeof t == "number" && E.test(e.trim()) && Number(e) === t || typeof t == "boolean" && String(t) === e ? t : e;
64
+ return typeof t == "number" && D.test(e.trim()) && Number(e) === t || typeof t == "boolean" && String(t) === e ? t : e;
62
65
  }
63
66
  return e;
64
- }, O = (e, t) => {
67
+ }, k = (e, t) => {
65
68
  if (typeof e != "object" || !e || Array.isArray(e)) return e;
66
- let n = T(_.toEncoded(t.ast));
67
- if (!_.isObjects(n)) return e;
69
+ let n = E(v.toEncoded(t.ast));
70
+ if (!v.isObjects(n)) return e;
68
71
  let r = { ...e };
69
72
  for (let e of n.propertySignatures) {
70
73
  let t = String(e.name);
71
- t in r && (r[t] = D(r[t], e.type));
74
+ t in r && (r[t] = O(r[t], e.type));
72
75
  }
73
76
  return r;
74
- }, k = (e) => {
75
- let t = T(_.toEncoded(e.ast));
76
- if (!_.isObjects(t)) return (e) => e;
77
+ }, re = (e) => {
78
+ let t = E(v.toEncoded(e.ast));
79
+ if (!v.isObjects(t)) return (e) => e;
77
80
  let n = t.propertySignatures, r = /* @__PURE__ */ new Map(), i = n.length >= 32 && n.every((e, t) => typeof e.name != "string" || e.name in Object.prototype || r.has(e.name) ? !1 : (r.set(e.name, {
78
81
  type: e.type,
79
82
  order: t
@@ -91,254 +94,231 @@ var v = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? S("",
91
94
  });
92
95
  }
93
96
  e.sort((e, t) => e.order - t.order);
94
- for (let { key: n, type: r } of e) t[n] = D(t[n], r);
97
+ for (let { key: n, type: r } of e) t[n] = O(t[n], r);
95
98
  } else for (let e of n) {
96
99
  let n = String(e.name);
97
- n in t && (t[n] = D(t[n], e.type));
100
+ n in t && (t[n] = O(t[n], e.type));
98
101
  }
99
102
  return t;
100
103
  };
101
- }, A = (e) => {
102
- let t = /* @__PURE__ */ new Set();
103
- if (e === void 0) return t;
104
- let n = (e) => {
105
- if (_.isUnion(e)) for (let t of e.types) n(t);
106
- else if (e.encoding !== void 0 && n(_.toEncoded(e)), _.isObjects(e)) {
107
- let n = e.propertySignatures.find((e) => e.name === "_tag");
108
- n !== void 0 && _.isLiteral(n.type) && typeof n.type.literal == "string" && t.add(n.type.literal);
109
- }
110
- };
111
- return n(e.ast), t;
112
- }, j = (e, t, n) => {
104
+ }, A = (e, t, n) => {
113
105
  if (n !== void 0) try {
114
- let r = m.encodeUnknownSync(n)(e);
115
- if (typeof r == "object" && r) return {
106
+ let r = g.encodeUnknownSync(n)(e);
107
+ if (typeof r == "object" && r && !Array.isArray(r)) return {
116
108
  error: t,
117
109
  ...r
118
110
  };
119
111
  } catch {}
120
- let r = { error: t };
121
- for (let [t, n] of Object.entries(e)) t !== "stack" && t !== "_tag" && (r[t] = n);
122
- return r;
123
- }, M = (e, t, n, r = []) => N(e, t, n, r, A), N = (e, t, n, r, i) => {
112
+ throw Error("Typed REST failure is incompatible with its declared schema");
113
+ }, j = (e, n, r, i = []) => M(e, n, r, i, t), M = (e, t, n, r, i) => {
124
114
  if (typeof e != "object" || !e) return e;
125
115
  let a = e._tag;
126
116
  if (typeof a != "string" || a === "ScopeError" || a === "NoSuchResource") return e;
127
117
  if (i(t.error).has(a)) {
128
118
  let r = n.errorStatus?.[a] ?? 422;
129
- return new s(r, j(e, a, t.error));
119
+ return new u(r, A(e, a, t.error));
130
120
  }
131
121
  let o = r.find((e) => i(e.schema).has(a));
132
122
  if (o === void 0) return e;
133
- let c = n.errorStatus?.[a] ?? o.rest?.status ?? 422, l = o.rest?.headers?.(e);
134
- return new s(c, j(e, a, o.schema), l);
135
- }, P = (e, t, r, i, a, o, c) => {
136
- let l = N(e, t, r, i, c);
137
- if (!(l instanceof s) || a.errors === "tagged" && a.encodeError === void 0) return l;
138
- let { error: u, _tag: ee, ...d } = l.body, f = typeof d.message == "string" ? d.message : typeof d.reason == "string" ? d.reason : "", p = n(a, {
139
- status: l.status,
140
- tag: u,
123
+ let s = n.errorStatus?.[a] ?? o.rest?.status ?? 422, c = o.rest?.headers?.(e);
124
+ return new u(s, A(e, a, o.schema), c);
125
+ }, N = (e, t, n, r, i, a, s) => {
126
+ let c = M(e, t, n, r, s);
127
+ if (!(c instanceof u) || i.errors === "tagged" && i.encodeError === void 0) return c;
128
+ let { error: l, _tag: ee, ...d } = c.body, f = typeof d.message == "string" ? d.message : typeof d.reason == "string" ? d.reason : "", p = o(i, {
129
+ status: c.status,
130
+ tag: l,
141
131
  message: f,
142
132
  fields: d
143
133
  }, {
144
- ...o,
145
- status: l.status
134
+ ...a,
135
+ status: c.status
146
136
  });
147
- return new s(l.status, p.body, {
148
- ...l.headers ?? {},
137
+ return new u(c.status, p.body, {
138
+ ...c.headers ?? {},
149
139
  ...p.headers ?? {}
150
140
  }, p.contentType);
151
- }, F = (e, t) => {
152
- if (e === void 0) return;
153
- let n = _.isUnion(e.ast) ? e.ast.types : [e.ast];
154
- for (let e of n) {
155
- let n = m.make(e);
156
- if (A(n).has(t)) return n;
157
- }
158
- }, I = (e) => e.split(".").map((e, t) => t === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_"), L = (e) => {
159
- let t = T(_.toEncoded(e.ast));
160
- return _.isObjects(t) && t.indexSignatures.length === 0 ? new Set(t.propertySignatures.map((e) => String(e.name))) : void 0;
161
- }, R = (e, t) => e === t || JSON.stringify(e) === JSON.stringify(t), te = (e) => {
162
- let t = T(_.toEncoded(e.ast)), n = _.isObjects(t) ? new Map(t.propertySignatures.map((e) => [String(e.name), e.type])) : /* @__PURE__ */ new Map();
141
+ }, P = (e) => e.split(".").map((e, t) => t === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_"), F = (e) => {
142
+ let t = E(v.toEncoded(e.ast));
143
+ return v.isObjects(t) && t.indexSignatures.length === 0 ? new Set(t.propertySignatures.map((e) => String(e.name))) : void 0;
144
+ }, I = (e, t) => e === t || JSON.stringify(e) === JSON.stringify(t), ie = (e) => {
145
+ let t = E(v.toEncoded(e.ast)), n = v.isObjects(t) ? new Map(t.propertySignatures.map((e) => [String(e.name), e.type])) : /* @__PURE__ */ new Map();
163
146
  return (e) => {
164
147
  let t = {};
165
148
  for (let [r, i] of Object.entries(e)) {
166
149
  let e = n.get(r);
167
- t[r] = e === void 0 ? i : D(i, e);
150
+ t[r] = e === void 0 ? i : O(i, e);
168
151
  }
169
152
  return t;
170
153
  };
171
- }, z = (e, t) => {
154
+ }, L = (e, t) => {
172
155
  if (e !== void 0) {
173
156
  try {
174
- return m.encodeUnknownSync(t)(e);
157
+ return g.encodeUnknownSync(t)(e);
175
158
  } catch {}
176
159
  try {
177
- return m.decodeUnknownSync(t)(e), e;
160
+ return g.decodeUnknownSync(t)(e), e;
178
161
  } catch {}
179
162
  return e;
180
163
  }
181
- }, B = (e, t, n) => ({
182
- ...e.request === void 0 ? {} : { request: z(e.request, t) },
183
- ...e.response === void 0 ? {} : { response: z(e.response, n) }
184
- }), ne = () => (e) => {
164
+ }, R = (e, t, n) => ({
165
+ ...e.request === void 0 ? {} : { request: L(e.request, t) },
166
+ ...e.response === void 0 ? {} : { response: L(e.response, n) }
167
+ }), ae = () => (e) => {
185
168
  if (e.subject.type !== "anonymous") return;
186
169
  let t = e.subject.credentialRejected;
187
170
  return t === void 0 ? void 0 : {
188
171
  status: 401,
189
172
  message: t
190
173
  };
191
- }, V = (e, t, n, s = {}) => {
192
- let b = e.publicApi;
193
- if (b === void 0) throw Error(`publicApiRoute: descriptor '${e.name}' has no publicApi annotation`);
194
- let x = i(s.profile, b.format), S = s.pluginErrors ?? [], C = /* @__PURE__ */ new WeakMap(), T = (e) => {
174
+ }, z = (n, r, i, o = {}) => {
175
+ let u = n.publicApi;
176
+ if (u === void 0) throw Error(`publicApiRoute: descriptor '${n.name}' has no publicApi annotation`);
177
+ let x = s(o.profile, u.format), S = o.pluginErrors ?? [], C = /* @__PURE__ */ new WeakMap(), w = (e) => {
195
178
  if (e === void 0) return /* @__PURE__ */ new Set();
196
- let t = C.get(e.ast);
197
- if (t !== void 0) return t;
198
- let n = A(e);
199
- return C.set(e.ast, n), n;
179
+ let n = C.get(e.ast);
180
+ if (n !== void 0) return n;
181
+ let r = t(e);
182
+ return C.set(e.ast, r), r;
200
183
  }, E = /* @__PURE__ */ new WeakMap(), D = (e, t) => {
201
184
  if (e === void 0) return;
202
185
  let n = E.get(e.ast);
203
186
  if (n === void 0) {
204
187
  let t = /* @__PURE__ */ new Map();
205
- for (let n of _.isUnion(e.ast) ? e.ast.types : [e.ast]) {
206
- let e = m.make(n);
207
- for (let n of T(e)) t.has(n) || t.set(n, e);
188
+ for (let n of v.isUnion(e.ast) ? e.ast.types : [e.ast]) {
189
+ let e = g.make(n);
190
+ for (let n of w(e)) t.has(n) || t.set(n, e);
208
191
  }
209
192
  n = t, E.set(e.ast, n);
210
193
  }
211
194
  return n.get(t);
212
195
  }, O = {
213
- kind: e.kind,
214
- input: e.input,
215
- target: e.target
216
- }, j = v(e.kind, b, O), M = (e) => x.naming === "snake_case" ? o(e) : e, N = y(e.name, b, O), F = N.replace(/:([A-Za-z0-9_]+)/g, (e, t) => `:${M(t)}`), z = w(F), V = a(e.input, x), H = k(V), U = te(V), W = L(V);
217
- if (W !== void 0) {
218
- for (let t of z) if (!W.has(t)) throw Error(`publicApi: descriptor '${e.name}' — path '${N}' binds ':${t}', and the input declares no field of that name` + (W.size > 0 ? ` (fields: ${[...W].join(", ")})` : " (the input declares no fields)"));
196
+ kind: n.kind,
197
+ input: n.input,
198
+ target: n.target
199
+ }, k = y(n.kind, u, O), A = (e) => x.naming === "snake_case" ? l(e) : e, j = b(n.name, u, O), M = j.replace(/:([A-Za-z0-9_]+)/g, (e, t) => `:${A(t)}`), L = T(M), z = c(n.input, x), B = re(z), V = ie(z), H = F(z);
200
+ if (H !== void 0) {
201
+ for (let e of L) if (!H.has(e)) throw Error(`publicApi: descriptor '${n.name}' — path '${j}' binds ':${e}', and the input declares no field of that name` + (H.size > 0 ? ` (fields: ${[...H].join(", ")})` : " (the input declares no fields)"));
219
202
  }
220
- let G = a(e.output, x), re = m.Struct({ value: V }), K = j !== "GET" && W === void 0;
221
- if (j !== "GET" && W !== void 0) {
222
- let e = z.length >= 32 ? new Set(z) : void 0;
223
- for (let t of W) if (!(e?.has(t) ?? z.includes(t))) {
224
- K = !0;
203
+ let U = c(n.output, x), oe = g.Struct({ value: z }), W = k !== "GET" && H === void 0;
204
+ if (k !== "GET" && H !== void 0) {
205
+ let e = L.length >= 32 ? new Set(L) : void 0;
206
+ for (let t of H) if (!(e?.has(t) ?? L.includes(t))) {
207
+ W = !0;
225
208
  break;
226
209
  }
227
210
  }
228
- let q = {
229
- query: m.Unknown,
230
- params: m.Unknown,
231
- form: m.Boolean
232
- }, ie = (K ? m.Struct({
233
- ...q,
234
- body: m.Unknown
235
- }) : m.Struct(q)).pipe(m.decodeTo(re, {
236
- decode: h.transformEffect((e) => {
237
- let t = "body" in e ? e.body : void 0, n = j === "GET" ? H(e.query) : e.form ? H(t ?? {}) : t ?? {}, r = typeof e.params == "object" && e.params !== null ? U(e.params) : {};
238
- if (typeof n != "object" || !n || Array.isArray(n)) return p.succeed({ value: n });
211
+ let G = {
212
+ query: g.Unknown,
213
+ params: g.Unknown,
214
+ form: g.Boolean
215
+ }, se = (W ? g.Struct({
216
+ ...G,
217
+ body: g.Unknown
218
+ }) : g.Struct(G)).pipe(g.decodeTo(oe, {
219
+ decode: _.transformEffect((e) => {
220
+ let t = "body" in e ? e.body : void 0, n = k === "GET" ? B(e.query) : e.form ? B(t ?? {}) : t ?? {}, r = typeof e.params == "object" && e.params !== null ? V(e.params) : {};
221
+ if (typeof n != "object" || !n || Array.isArray(n)) return h.succeed({ value: n });
239
222
  let i = n, a = Object.keys(r), o = 0;
240
- for (let e of a) e in i && !R(i[e], r[e]) && (a[o++] = e);
223
+ for (let e of a) e in i && !I(i[e], r[e]) && (a[o++] = e);
241
224
  if (a.length = o, a.length > 0) {
242
- let t = j === "GET" ? "query string" : "body";
243
- return p.fail(new g.InvalidValue({ message: `${a.map((e) => `'${e}'`).join(", ")} ${a.length === 1 ? "is" : "are"} bound by the path and sent with another value in the ${t}` }, e));
225
+ let t = k === "GET" ? "query string" : "body";
226
+ return h.fail(new ne.InvalidValue({ message: `${a.map((e) => `'${e}'`).join(", ")} ${a.length === 1 ? "is" : "are"} bound by the path and sent with another value in the ${t}` }, e));
244
227
  }
245
- return p.succeed({ value: {
228
+ return h.succeed({ value: {
246
229
  ...i,
247
230
  ...r
248
231
  } });
249
232
  }),
250
- encode: h.transform((e) => e)
251
- })), ae = [
252
- ne(),
253
- ...e.openAccess === void 0 ? [l()] : [],
254
- ...(b.scopes ?? []).map((e) => u(e))
255
- ], J = (() => {
256
- let t = e.source;
257
- return typeof t == "string" ? t : Array.isArray(t) ? t[0] : void 0;
258
- })(), Y = (t, n = 200) => ({
259
- tag: e.name,
260
- method: t.method,
261
- path: t.path,
262
- query: t.query,
263
- source: J,
264
- status: n
265
- }), X = b.stream === "sse" && e.kind === "query" && n !== void 0, oe = m.encodeUnknownEffect(G), se = X ? (e, t) => d((r) => n(e.value, t, (e) => {
266
- r(f(String(e._tag ?? "message"), e));
267
- })) : async (n, i) => {
268
- let a;
269
- try {
270
- a = await t(n.value, i);
271
- } catch (t) {
272
- throw P(t, e, b, S, x, Y(i), T);
273
- }
274
- let o = await p.runPromise(oe(a)), s = r(x, o, Y(i));
275
- return ee(s.body, {
276
- ...s.headers === void 0 ? {} : { headers: s.headers },
277
- ...s.contentType === void 0 ? {} : { contentType: s.contentType }
278
- });
279
- }, Z = e.error, Q = T(Z), ce = [...Q], $ = [];
280
- for (let e of ce) {
281
- let t = D(Z, e);
282
- t !== void 0 && $.push({
283
- status: b.errorStatus?.[e] ?? 422,
233
+ encode: _.transform((e) => e)
234
+ })), K = [
235
+ ae(),
236
+ ...n.openAccess === void 0 ? [d()] : [],
237
+ ...(u.scopes ?? []).map((e) => f(e))
238
+ ], q = (() => {
239
+ let e = n.source;
240
+ return typeof e == "string" ? e : Array.isArray(e) ? e[0] : void 0;
241
+ })(), ce = (e, t = 200) => ({
242
+ tag: n.name,
243
+ method: e.method,
244
+ path: e.path,
245
+ query: e.query,
246
+ source: q,
247
+ status: t
248
+ });
249
+ K.push(async (t, r) => {
250
+ if (r === void 0 || typeof r.input != "object" || r.input === null) throw Error("Projected REST admission input is unavailable");
251
+ let i = await h.runPromise(e(t.subject, n.guards, r.input.value, {
252
+ defaultDeny: r.defaultDeny,
253
+ procedure: n.name
254
+ }));
255
+ if (i) throw i;
256
+ });
257
+ let J = u.stream === "sse" && n.kind === "query" && i !== void 0, Y = a(u.streamMaxDurationMs);
258
+ if (Y !== void 0 && !J) throw Error(`${n.name}: streamMaxDurationMs requires an SSE query subscription`);
259
+ let le = J ? (e, t) => te((n) => i(e.value, t, (e) => {
260
+ n(m(String(e._tag ?? "message"), e));
261
+ }), Y === void 0 ? {} : { maxDurationMs: Y }) : async (e, t) => {
262
+ let n = await r(e.value, t);
263
+ return p(n);
264
+ }, X = n.error, Z = w(X), ue = [...Z], Q = [];
265
+ for (let e of Object.values(u.additionalErrorStatuses ?? {})) if (e.some((e) => !Number.isInteger(e) || e < 400 || e > 599)) throw Error(`publicApi.additionalErrorStatuses for ${n.name} must contain HTTP error statuses (400–599)`);
266
+ let $ = (e, t, n) => {
267
+ for (let r of /* @__PURE__ */ new Set([t, ...u.additionalErrorStatuses?.[e] ?? []])) Q.some((t) => t.tag === e && t.status === r) || Q.push({
268
+ status: r,
284
269
  tag: e,
285
- schema: t
286
- });
287
- }
288
- for (let e of S) for (let t of T(e.schema)) {
289
- if (Q.has(t)) continue;
290
- let n = b.errorStatus?.[t] ?? e.rest?.status;
291
- if (n === void 0) continue;
292
- let r = D(e.schema, t) ?? e.schema;
293
- $.push({
294
- status: n,
295
- tag: t,
296
- schema: r
270
+ schema: n
297
271
  });
272
+ };
273
+ for (let e of ue) {
274
+ let t = D(X, e);
275
+ t !== void 0 && $(e, u.errorStatus?.[e] ?? 422, t);
298
276
  }
299
- let le = b.security === !1 ? "none" : b.security ?? (e.openAccess === void 0 ? "required" : "optional"), ue = {
300
- tag: e.name,
301
- kind: e.kind,
302
- version: b.version ?? "v1",
303
- security: le,
304
- idempotent: b.idempotent === !0,
305
- input: V,
306
- pathParams: z,
307
- output: G,
308
- source: J,
309
- errorResponses: $,
277
+ for (let e of S) for (let t of w(e.schema)) Z.has(t) || $(t, u.errorStatus?.[t] ?? e.rest?.status ?? 422, D(e.schema, t) ?? e.schema);
278
+ let de = u.security === !1 ? "none" : u.security ?? (n.openAccess === void 0 ? "required" : "optional"), fe = {
279
+ tag: n.name,
280
+ kind: n.kind,
281
+ version: u.version ?? "v1",
282
+ security: de,
283
+ idempotent: u.idempotent === !0,
284
+ input: z,
285
+ pathParams: L,
286
+ output: U,
287
+ source: q,
288
+ errorResponses: Q,
310
289
  format: x
311
290
  };
312
- return c({
313
- method: j,
314
- path: F,
315
- input: ie,
316
- output: m.Unknown,
317
- handler: se,
318
- ...X ? { streaming: !0 } : {},
319
- guards: ae,
320
- operationId: b.operationId ?? I(e.name),
321
- tags: b.tags ?? [e.name.split(".")[0] ?? e.name],
322
- projection: ue,
323
- ...x.etag && j === "GET" && !X ? { etag: !0 } : {},
324
- ...b.cache !== void 0 && j === "GET" && !X ? { cache: b.cache } : {},
325
- ...b.example === void 0 ? {} : { example: B(b.example, V, G) },
326
- ...b.summary === void 0 ? {} : { summary: b.summary },
327
- ...b.description === void 0 ? {} : { description: b.description },
328
- ...b.deprecated === void 0 ? {} : { deprecated: b.deprecated },
329
- ...b.sunset === void 0 ? {} : { sunset: b.sunset }
291
+ return ee({
292
+ publicApiDescriptor: n,
293
+ mapFailure: (e, t) => N(e, n, u, S, x, ce(t), w),
294
+ method: k,
295
+ path: M,
296
+ input: se,
297
+ output: U,
298
+ handler: le,
299
+ ...J ? { streaming: !0 } : {},
300
+ guards: K,
301
+ operationId: u.operationId ?? P(n.name),
302
+ tags: u.tags ?? [n.name.split(".")[0] ?? n.name],
303
+ projection: fe,
304
+ ...x.etag && k === "GET" && !J ? { etag: !0 } : {},
305
+ ...u.cache !== void 0 && k === "GET" && !J ? { cache: u.cache } : {},
306
+ ...u.example === void 0 ? {} : { example: R(u.example, z, U) },
307
+ ...u.summary === void 0 ? {} : { summary: u.summary },
308
+ ...u.description === void 0 ? {} : { description: u.description },
309
+ ...u.deprecated === void 0 ? {} : { deprecated: u.deprecated },
310
+ ...u.sunset === void 0 ? {} : { sunset: u.sunset }
330
311
  });
331
- }, H = (e, t = {}) => e.filter((e) => e.descriptor.publicApi !== void 0).map((e) => V(e.descriptor, e.invoke, e.subscribe, t)).sort((e, t) => e.path.localeCompare(t.path)), U = (n) => t(n.filter((e) => e.projection !== void 0).map((t) => {
332
- let n = t.projection, r = {
333
- tag: n.tag,
334
- method: t.method,
335
- path: t.path,
336
- pathParams: n.pathParams,
337
- version: n.version,
338
- security: n.security,
339
- errors: [...n.errorResponses].map((e) => `${e.status}:${e.tag}`).sort()
312
+ }, B = (e, t = {}) => e.filter((e) => e.descriptor.publicApi !== void 0).map((e) => z(e.descriptor, e.invoke, e.subscribe, t)).sort((e, t) => e.path.localeCompare(t.path)), V = (e) => i(e.filter((e) => e.projection !== void 0).map((e) => {
313
+ let t = e.projection, n = {
314
+ tag: t.tag,
315
+ method: e.method,
316
+ path: e.path,
317
+ pathParams: t.pathParams,
318
+ version: t.version,
319
+ security: t.security,
320
+ errors: [...t.errorResponses].map((e) => `${e.status}:${e.tag}`).sort()
340
321
  };
341
- return `${JSON.stringify(r)} ${e(n.input.ast)} ${e(n.output.ast)}`;
322
+ return `${JSON.stringify(n)} ${r(t.input.ast)} ${r(t.output.ast)}`;
342
323
  }).sort().join("\n"));
343
- //#endregion
344
- export { O as coerceQueryObject, D as coerceQueryValue, H as collectPublicApiRoutes, A as declaredErrorTags, v as derivePublicMethod, y as derivePublicPath, S as deriveResource, F as errorMemberSchema, C as normalizePathParams, I as operationIdOf, w as pathParamNames, M as projectedFailure, V as publicApiRoute, U as publicSurfaceDigest, x as resourceIdField, B as wireExample };
324
+ export { k as coerceQueryObject, O as coerceQueryValue, B as collectPublicApiRoutes, t as declaredErrorTags, y as derivePublicMethod, b as derivePublicPath, C as deriveResource, n as errorMemberSchema, w as normalizePathParams, P as operationIdOf, T as pathParamNames, j as projectedFailure, z as publicApiRoute, V as publicSurfaceDigest, S as resourceIdField, R as wireExample };
@@ -0,0 +1,13 @@
1
+ // src/queryOptionalSources.ts
2
+ var e = (e, t, n) => {
3
+ if (n === void 0) return;
4
+ let r = new Set(t === void 0 ? [] : typeof t == "string" ? [t] : t), i = () => /* @__PURE__ */ Error(`${e}: optionalSource must contain unique names already declared in source`);
5
+ if (!Array.isArray(n)) throw i();
6
+ let a = [];
7
+ for (let e of n) {
8
+ if (typeof e != "string" || e.length === 0 || !r.has(e) || a.includes(e)) throw i();
9
+ a.push(e);
10
+ }
11
+ return Object.freeze(a);
12
+ };
13
+ export { e as captureOptionalQuerySources };
@@ -1,4 +1,4 @@
1
- //#region src/reactivityChannel.ts
1
+ // src/reactivityChannel.ts
2
2
  var e = "channel:", t = Symbol.for("@voltro/protocol/reactivityChannels"), n = globalThis, r = n[t] ?? (n[t] = /* @__PURE__ */ new Map()), i = /^[a-z][a-z0-9-]*(\.[a-z0-9-]+)*$/, a = (t) => {
3
3
  if (!i.test(t)) throw Error(`reactivityChannel('${t}'): invalid channel name.\n Use lowercase kebab segments separated by dots — \`presence\`, \`job-queue\`,
4
4
  \`billing.usage\`. A \`:\` is refused because it is the namespace separator in
@@ -30,5 +30,4 @@ var e = "channel:", t = Symbol.for("@voltro/protocol/reactivityChannels"), n = g
30
30
  origin: "inline"
31
31
  }), !0);
32
32
  };
33
- //#endregion
34
33
  export { e as REACTIVITY_CHANNEL_PREFIX, c as declaredReactivityChannelKeys, o as isReactivityChannel, s as isReactivityChannelKey, d as normalizeSource, p as publishReactivity, a as reactivityChannel, u as sourceKeys, f as undeclaredChannelKeys };