@voltro/protocol 0.86.0 → 0.87.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/CHANGELOG.md +5321 -0
- package/THIRD-PARTY-NOTICES.md +1130 -11
- package/dist/apiRoleEndpoints.js +108 -0
- package/dist/apiRoleObservation.js +68 -0
- package/dist/apikey.d.ts +10 -0
- package/dist/auth.js +39 -19
- package/dist/canonicalJson.js +14 -0
- package/dist/errorSchema.js +24 -0
- package/dist/event.js +51 -45
- package/dist/formCapture.js +12 -0
- package/dist/httpStreamMaxDuration.js +9 -0
- package/dist/idempotency.js +88 -33
- package/dist/idempotencyInput.js +123 -0
- package/dist/index.d.ts +876 -124
- package/dist/index.js +50 -38
- package/dist/inspect.d.ts +1 -1
- package/dist/jwt.d.ts +10 -0
- package/dist/jwt.js +1 -1
- package/dist/plugin.js +43 -17
- package/dist/pluginAccountMerge.js +88 -0
- package/dist/pluginPrivacy.js +166 -0
- package/dist/procedure.js +114 -96
- package/dist/publicApi.js +190 -209
- package/dist/queryOptionalSources.js +14 -0
- package/dist/rest.d.ts +227 -64
- package/dist/rest.js +295 -192
- package/dist/restReceipt.js +43 -0
- package/dist/revalidate.js +13 -0
- package/dist/scopes.js +71 -38
- package/dist/secretWindows.js +71 -0
- package/dist/session.d.ts +89 -6
- package/dist/session.js +55 -54
- package/dist/ssrfPolicy.js +30 -0
- package/dist/webSocketGateway.js +7 -1
- package/package.json +5 -3
package/dist/publicApi.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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";
|
|
6
9
|
//#region src/publicApi.ts
|
|
7
|
-
var
|
|
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
|
-
},
|
|
11
|
-
let n = t != null && (typeof t == "object" || typeof t == "function") && "ast" in t ?
|
|
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 = `${
|
|
16
|
+
let r = `${x(e)}Id`;
|
|
14
17
|
return n.has(r) ? r : n.has("id") ? "id" : void 0;
|
|
15
|
-
},
|
|
16
|
-
let r = (t.resource ?? "").replace(/^\/+|\/+$/g, ""), i = `/${t.version ?? "v1"}/${r}`, a =
|
|
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
|
-
},
|
|
34
|
-
if (
|
|
35
|
-
let t = e.types.filter((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
|
|
40
|
+
if (t.length !== e.types.length) return new v.Union(t);
|
|
38
41
|
}
|
|
39
42
|
return e;
|
|
40
|
-
},
|
|
41
|
-
let n =
|
|
42
|
-
if (n.encoding !== void 0) return
|
|
43
|
-
if (
|
|
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 =
|
|
48
|
+
let n = O(e, t);
|
|
46
49
|
if (n !== e) return n;
|
|
47
50
|
}
|
|
48
51
|
return e;
|
|
49
52
|
}
|
|
50
|
-
if (
|
|
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) =>
|
|
57
|
+
return r === void 0 ? t : t.map((e) => O(e, r));
|
|
55
58
|
}
|
|
56
59
|
if (typeof e != "string") return e;
|
|
57
|
-
if (
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
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" &&
|
|
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
|
-
},
|
|
67
|
+
}, k = (e, t) => {
|
|
65
68
|
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
66
|
-
let n =
|
|
67
|
-
if (!
|
|
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] =
|
|
74
|
+
t in r && (r[t] = O(r[t], e.type));
|
|
72
75
|
}
|
|
73
76
|
return r;
|
|
74
|
-
},
|
|
75
|
-
let t =
|
|
76
|
-
if (!
|
|
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,232 @@ 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] =
|
|
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] =
|
|
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 =
|
|
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
|
-
|
|
121
|
-
|
|
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
|
|
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
|
|
134
|
-
return new s
|
|
135
|
-
},
|
|
136
|
-
let
|
|
137
|
-
if (!(
|
|
138
|
-
let { error:
|
|
139
|
-
status:
|
|
140
|
-
tag:
|
|
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
|
-
...
|
|
145
|
-
status:
|
|
134
|
+
...a,
|
|
135
|
+
status: c.status
|
|
146
136
|
});
|
|
147
|
-
return new
|
|
148
|
-
...
|
|
137
|
+
return new u(c.status, p.body, {
|
|
138
|
+
...c.headers ?? {},
|
|
149
139
|
...p.headers ?? {}
|
|
150
140
|
}, p.contentType);
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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 :
|
|
150
|
+
t[r] = e === void 0 ? i : O(i, e);
|
|
168
151
|
}
|
|
169
152
|
return t;
|
|
170
153
|
};
|
|
171
|
-
},
|
|
154
|
+
}, L = (e, t) => {
|
|
172
155
|
if (e !== void 0) {
|
|
173
156
|
try {
|
|
174
|
-
return
|
|
157
|
+
return g.encodeUnknownSync(t)(e);
|
|
175
158
|
} catch {}
|
|
176
159
|
try {
|
|
177
|
-
return
|
|
160
|
+
return g.decodeUnknownSync(t)(e), e;
|
|
178
161
|
} catch {}
|
|
179
162
|
return e;
|
|
180
163
|
}
|
|
181
|
-
},
|
|
182
|
-
...e.request === void 0 ? {} : { request:
|
|
183
|
-
...e.response === void 0 ? {} : { response:
|
|
184
|
-
}),
|
|
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
|
-
},
|
|
192
|
-
let
|
|
193
|
-
if (
|
|
194
|
-
let x =
|
|
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
|
|
197
|
-
if (
|
|
198
|
-
let
|
|
199
|
-
return C.set(e.ast,
|
|
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
|
|
206
|
-
let e =
|
|
207
|
-
for (let n of
|
|
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:
|
|
214
|
-
input:
|
|
215
|
-
target:
|
|
216
|
-
},
|
|
217
|
-
if (
|
|
218
|
-
for (let
|
|
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
|
|
221
|
-
if (
|
|
222
|
-
let e =
|
|
223
|
-
for (let t of
|
|
224
|
-
|
|
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
|
|
229
|
-
query:
|
|
230
|
-
params:
|
|
231
|
-
form:
|
|
232
|
-
},
|
|
233
|
-
...
|
|
234
|
-
body:
|
|
235
|
-
}) :
|
|
236
|
-
decode:
|
|
237
|
-
let t = "body" in e ? e.body : void 0, n =
|
|
238
|
-
if (typeof n != "object" || !n || Array.isArray(n)) return
|
|
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 && !
|
|
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 =
|
|
243
|
-
return
|
|
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
|
|
228
|
+
return h.succeed({ value: {
|
|
246
229
|
...i,
|
|
247
230
|
...r
|
|
248
231
|
} });
|
|
249
232
|
}),
|
|
250
|
-
encode:
|
|
251
|
-
})),
|
|
252
|
-
|
|
253
|
-
...
|
|
254
|
-
...(
|
|
255
|
-
],
|
|
256
|
-
let
|
|
257
|
-
return typeof
|
|
258
|
-
})(),
|
|
259
|
-
tag:
|
|
260
|
-
method:
|
|
261
|
-
path:
|
|
262
|
-
query:
|
|
263
|
-
source:
|
|
264
|
-
status:
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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:
|
|
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
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
...
|
|
326
|
-
...
|
|
327
|
-
...
|
|
328
|
-
...
|
|
329
|
-
...
|
|
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
|
-
},
|
|
332
|
-
let
|
|
333
|
-
tag:
|
|
334
|
-
method:
|
|
335
|
-
path:
|
|
336
|
-
pathParams:
|
|
337
|
-
version:
|
|
338
|
-
security:
|
|
339
|
-
errors: [...
|
|
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(
|
|
322
|
+
return `${JSON.stringify(n)} ${r(t.input.ast)} ${r(t.output.ast)}`;
|
|
342
323
|
}).sort().join("\n"));
|
|
343
324
|
//#endregion
|
|
344
|
-
export {
|
|
325
|
+
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,14 @@
|
|
|
1
|
+
//#region 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
|
+
//#endregion
|
|
14
|
+
export { e as captureOptionalQuerySources };
|