@voltro/protocol 0.83.1 → 0.85.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 +1191 -0
- package/THIRD-PARTY-NOTICES.md +1 -57
- package/dist/apikey.d.ts +32 -34
- package/dist/index.d.ts +1276 -1349
- package/dist/index.js +1022 -733
- package/dist/inspect.d.ts +88 -88
- package/dist/inspect.js +103 -53
- package/dist/jwt.d.ts +32 -34
- package/dist/rest.d.ts +72 -57
- package/dist/rest.js +287 -208
- package/dist/{restFormat-EZ8k9ZcQ.js → restFormat-BlgTLxm1.js} +108 -114
- package/dist/{scopes-Di756ENh.js → scopes-ClywBij8.js} +167 -137
- package/dist/session.d.ts +90 -96
- package/dist/session.js +1 -1
- package/package.json +4 -8
package/dist/rest.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { H as e, V as t } from "./scopes-
|
|
2
|
-
import { E as n, O as r, T as i, a, c as o, d as s, f as c, i as l, k as u, l as d, n as f, o as p, r as m, s as h, t as g, u as _, v, w as y, y as b } from "./restFormat-
|
|
3
|
-
import { Effect as x,
|
|
4
|
-
import * as
|
|
1
|
+
import { H as e, V as t } from "./scopes-ClywBij8.js";
|
|
2
|
+
import { E as n, O as r, T as i, a, c as o, d as s, f as c, i as l, k as u, l as d, n as f, o as p, r as m, s as h, t as g, u as _, v, w as y, y as b } from "./restFormat-BlgTLxm1.js";
|
|
3
|
+
import { Effect as x, Schema as S, SchemaGetter as C, SchemaIssue as w } from "effect";
|
|
4
|
+
import * as T from "effect/SchemaAST";
|
|
5
5
|
//#region src/publicApi.ts
|
|
6
|
-
var
|
|
6
|
+
var E = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? A("", t, n).method : void 0) ?? (e === "query" ? "GET" : "POST"), D = (e, t, n) => j(t.path ?? (t.resource !== void 0 && n !== void 0 ? A(e, t, n).path : `/${t.version ?? "v1"}/${e.replace(/\./g, "/")}`)), O = (e) => {
|
|
7
7
|
let t = e.split("/").pop() ?? e;
|
|
8
8
|
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;
|
|
9
|
-
},
|
|
10
|
-
let n = t != null && (typeof t == "object" || typeof t == "function") && "ast" in t ?
|
|
9
|
+
}, k = (e, t) => {
|
|
10
|
+
let n = t != null && (typeof t == "object" || typeof t == "function") && "ast" in t ? re(t) : void 0;
|
|
11
11
|
if (n === void 0) return;
|
|
12
|
-
let r = `${
|
|
12
|
+
let r = `${O(e)}Id`;
|
|
13
13
|
return n.has(r) ? r : n.has("id") ? "id" : void 0;
|
|
14
|
-
},
|
|
15
|
-
let r = (t.resource ?? "").replace(/^\/+|\/+$/g, ""), i = `/${t.version ?? "v1"}/${r}`, a =
|
|
14
|
+
}, A = (e, t, n) => {
|
|
15
|
+
let r = (t.resource ?? "").replace(/^\/+|\/+$/g, ""), i = `/${t.version ?? "v1"}/${r}`, a = k(r, n.input), o = a === void 0 ? i : `${i}/:${a}`, s = e.split(".").pop() ?? e, c = n.target?.op;
|
|
16
16
|
return n.kind === "query" || n.kind === "stream" ? {
|
|
17
17
|
method: "GET",
|
|
18
18
|
path: o
|
|
@@ -29,72 +29,91 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
29
29
|
method: "POST",
|
|
30
30
|
path: `${o}/${s}`
|
|
31
31
|
};
|
|
32
|
-
},
|
|
33
|
-
if (
|
|
34
|
-
let t = e.types.filter((e) => !
|
|
32
|
+
}, j = (e) => e.replace(/\{([A-Za-z0-9_]+)\}/g, ":$1"), M = (e) => [...e.matchAll(/:([A-Za-z0-9_]+)/g)].map((e) => e[1]), N = (e) => {
|
|
33
|
+
if (T.isUnion(e)) {
|
|
34
|
+
let t = e.types.filter((e) => !T.isUndefined(e));
|
|
35
35
|
if (t.length === 1) return t[0];
|
|
36
|
-
if (t.length !== e.types.length) return
|
|
36
|
+
if (t.length !== e.types.length) return new T.Union(t);
|
|
37
37
|
}
|
|
38
38
|
return e;
|
|
39
|
-
},
|
|
40
|
-
let n =
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
39
|
+
}, P = /^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i, F = (e, t) => {
|
|
40
|
+
let n = N(t);
|
|
41
|
+
if (n.encoding !== void 0) return F(e, T.toEncoded(n));
|
|
42
|
+
if (T.isUnion(n)) {
|
|
43
43
|
for (let t of n.types) {
|
|
44
|
-
let n =
|
|
44
|
+
let n = F(e, t);
|
|
45
45
|
if (n !== e) return n;
|
|
46
46
|
}
|
|
47
47
|
return e;
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (T.isArrays(n)) {
|
|
50
50
|
let t = Array.isArray(e) ? e : e === void 0 ? void 0 : [e];
|
|
51
51
|
if (t === void 0) return e;
|
|
52
|
-
let r = n.rest[0]
|
|
53
|
-
return r === void 0 ? t : t.map((e) =>
|
|
52
|
+
let r = n.rest[0] ?? n.elements[0];
|
|
53
|
+
return r === void 0 ? t : t.map((e) => F(e, r));
|
|
54
54
|
}
|
|
55
55
|
if (typeof e != "string") return e;
|
|
56
|
-
if (
|
|
57
|
-
if (
|
|
58
|
-
if (
|
|
56
|
+
if (T.isNumber(n)) return P.test(e.trim()) ? Number(e) : e;
|
|
57
|
+
if (T.isBoolean(n)) return e === "true" || e !== "false" && e;
|
|
58
|
+
if (T.isLiteral(n)) {
|
|
59
59
|
let t = n.literal;
|
|
60
|
-
return typeof t == "number" &&
|
|
60
|
+
return typeof t == "number" && P.test(e.trim()) && Number(e) === t || typeof t == "boolean" && String(t) === e ? t : e;
|
|
61
61
|
}
|
|
62
62
|
return e;
|
|
63
|
-
},
|
|
63
|
+
}, I = (e, t) => {
|
|
64
64
|
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
65
|
-
let n =
|
|
66
|
-
if (!
|
|
65
|
+
let n = N(T.toEncoded(t.ast));
|
|
66
|
+
if (!T.isObjects(n)) return e;
|
|
67
67
|
let r = { ...e };
|
|
68
68
|
for (let e of n.propertySignatures) {
|
|
69
69
|
let t = String(e.name);
|
|
70
|
-
t in r && (r[t] =
|
|
70
|
+
t in r && (r[t] = F(r[t], e.type));
|
|
71
71
|
}
|
|
72
72
|
return r;
|
|
73
|
-
},
|
|
73
|
+
}, ee = (e) => {
|
|
74
|
+
let t = N(T.toEncoded(e.ast));
|
|
75
|
+
if (!T.isObjects(t)) return (e) => e;
|
|
76
|
+
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, {
|
|
77
|
+
type: e.type,
|
|
78
|
+
order: t
|
|
79
|
+
}), !0));
|
|
80
|
+
return (e) => {
|
|
81
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
82
|
+
let t = { ...e }, a = i ? Object.keys(t) : void 0;
|
|
83
|
+
if (a !== void 0 && a.length * 4 < n.length) {
|
|
84
|
+
let e = [];
|
|
85
|
+
for (let t of a) {
|
|
86
|
+
let n = r.get(t);
|
|
87
|
+
n !== void 0 && e.push({
|
|
88
|
+
key: t,
|
|
89
|
+
...n
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
e.sort((e, t) => e.order - t.order);
|
|
93
|
+
for (let { key: n, type: r } of e) t[n] = F(t[n], r);
|
|
94
|
+
} else for (let e of n) {
|
|
95
|
+
let n = String(e.name);
|
|
96
|
+
n in t && (t[n] = F(t[n], e.type));
|
|
97
|
+
}
|
|
98
|
+
return t;
|
|
99
|
+
};
|
|
100
|
+
}, L = (e) => {
|
|
74
101
|
let t = /* @__PURE__ */ new Set();
|
|
75
102
|
if (e === void 0) return t;
|
|
76
103
|
let n = (e) => {
|
|
77
|
-
if (
|
|
104
|
+
if (T.isUnion(e)) {
|
|
78
105
|
for (let t of e.types) n(t);
|
|
79
106
|
return;
|
|
80
107
|
}
|
|
81
|
-
if (
|
|
82
|
-
n(e.from), n(e.to);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (w.isRefinement(e)) {
|
|
86
|
-
n(e.from);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (w.isTypeLiteral(e)) {
|
|
108
|
+
if (e.encoding !== void 0 && n(T.toEncoded(e)), T.isObjects(e)) {
|
|
90
109
|
let n = e.propertySignatures.find((e) => e.name === "_tag");
|
|
91
|
-
n !== void 0 &&
|
|
110
|
+
n !== void 0 && T.isLiteral(n.type) && typeof n.type.literal == "string" && t.add(n.type.literal);
|
|
92
111
|
}
|
|
93
112
|
};
|
|
94
113
|
return n(e.ast), t;
|
|
95
|
-
},
|
|
114
|
+
}, R = (e, t, n) => {
|
|
96
115
|
if (n !== void 0) try {
|
|
97
|
-
let r =
|
|
116
|
+
let r = S.encodeUnknownSync(n)(e);
|
|
98
117
|
if (typeof r == "object" && r) return {
|
|
99
118
|
error: t,
|
|
100
119
|
...r
|
|
@@ -103,62 +122,65 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
103
122
|
let r = { error: t };
|
|
104
123
|
for (let [t, n] of Object.entries(e)) t !== "stack" && t !== "_tag" && (r[t] = n);
|
|
105
124
|
return r;
|
|
106
|
-
},
|
|
125
|
+
}, z = (e, t, n, r = []) => B(e, t, n, r, L), B = (e, t, n, r, i) => {
|
|
107
126
|
if (typeof e != "object" || !e) return e;
|
|
108
|
-
let
|
|
109
|
-
if (typeof
|
|
110
|
-
if (
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
113
|
-
let
|
|
114
|
-
return new Y(
|
|
115
|
-
},
|
|
116
|
-
let
|
|
117
|
-
if (!(
|
|
118
|
-
let { error:
|
|
119
|
-
status:
|
|
120
|
-
tag:
|
|
121
|
-
message:
|
|
122
|
-
fields:
|
|
127
|
+
let a = e._tag;
|
|
128
|
+
if (typeof a != "string" || a === "ScopeError" || a === "NoSuchResource") return e;
|
|
129
|
+
if (i(t.error).has(a)) return new Y(n.errorStatus?.[a] ?? 422, R(e, a, t.error));
|
|
130
|
+
let o = r.find((e) => i(e.schema).has(a));
|
|
131
|
+
if (o === void 0) return e;
|
|
132
|
+
let s = n.errorStatus?.[a] ?? o.rest?.status ?? 422, c = o.rest?.headers?.(e);
|
|
133
|
+
return new Y(s, R(e, a, o.schema), c);
|
|
134
|
+
}, te = (e, t, n, r, i, a, o) => {
|
|
135
|
+
let s = B(e, t, n, r, o);
|
|
136
|
+
if (!(s instanceof Y) || i.errors === "tagged" && i.encodeError === void 0) return s;
|
|
137
|
+
let { error: c, _tag: u, ...d } = s.body, f = typeof d.message == "string" ? d.message : typeof d.reason == "string" ? d.reason : "", p = l(i, {
|
|
138
|
+
status: s.status,
|
|
139
|
+
tag: c,
|
|
140
|
+
message: f,
|
|
141
|
+
fields: d
|
|
123
142
|
}, {
|
|
124
143
|
...a,
|
|
125
|
-
status:
|
|
144
|
+
status: s.status
|
|
126
145
|
});
|
|
127
|
-
return new Y(
|
|
128
|
-
...
|
|
129
|
-
...
|
|
130
|
-
},
|
|
131
|
-
},
|
|
146
|
+
return new Y(s.status, p.body, {
|
|
147
|
+
...s.headers ?? {},
|
|
148
|
+
...p.headers ?? {}
|
|
149
|
+
}, p.contentType);
|
|
150
|
+
}, V = (e, t) => {
|
|
132
151
|
if (e === void 0) return;
|
|
133
|
-
let n =
|
|
152
|
+
let n = T.isUnion(e.ast) ? e.ast.types : [e.ast];
|
|
134
153
|
for (let e of n) {
|
|
135
|
-
let n =
|
|
136
|
-
if (
|
|
137
|
-
}
|
|
138
|
-
}, te = (e) => e.split(".").map((e, t) => t === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_"), B = (e) => {
|
|
139
|
-
let t = M(w.encodedAST(e.ast));
|
|
140
|
-
return w.isTypeLiteral(t) && t.indexSignatures.length === 0 ? new Set(t.propertySignatures.map((e) => String(e.name))) : void 0;
|
|
141
|
-
}, ne = (e, t) => e === t || JSON.stringify(e) === JSON.stringify(t), re = (e, t) => {
|
|
142
|
-
let n = M(w.encodedAST(t.ast)), r = {}, i = w.isTypeLiteral(n) ? new Map(n.propertySignatures.map((e) => [String(e.name), e.type])) : /* @__PURE__ */ new Map();
|
|
143
|
-
for (let [t, n] of Object.entries(e)) {
|
|
144
|
-
let e = i.get(t);
|
|
145
|
-
r[t] = e === void 0 ? n : P(n, e);
|
|
154
|
+
let n = S.make(e);
|
|
155
|
+
if (L(n).has(t)) return n;
|
|
146
156
|
}
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
}, ne = (e) => e.split(".").map((e, t) => t === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_"), re = (e) => {
|
|
158
|
+
let t = N(T.toEncoded(e.ast));
|
|
159
|
+
return T.isObjects(t) && t.indexSignatures.length === 0 ? new Set(t.propertySignatures.map((e) => String(e.name))) : void 0;
|
|
160
|
+
}, ie = (e, t) => e === t || JSON.stringify(e) === JSON.stringify(t), ae = (e) => {
|
|
161
|
+
let t = N(T.toEncoded(e.ast)), n = T.isObjects(t) ? new Map(t.propertySignatures.map((e) => [String(e.name), e.type])) : /* @__PURE__ */ new Map();
|
|
162
|
+
return (e) => {
|
|
163
|
+
let t = {};
|
|
164
|
+
for (let [r, i] of Object.entries(e)) {
|
|
165
|
+
let e = n.get(r);
|
|
166
|
+
t[r] = e === void 0 ? i : F(i, e);
|
|
167
|
+
}
|
|
168
|
+
return t;
|
|
169
|
+
};
|
|
170
|
+
}, H = (e, t) => {
|
|
149
171
|
if (e !== void 0) {
|
|
150
172
|
try {
|
|
151
|
-
return
|
|
173
|
+
return S.encodeUnknownSync(t)(e);
|
|
152
174
|
} catch {}
|
|
153
175
|
try {
|
|
154
|
-
return
|
|
176
|
+
return S.decodeUnknownSync(t)(e), e;
|
|
155
177
|
} catch {}
|
|
156
178
|
return e;
|
|
157
179
|
}
|
|
158
|
-
},
|
|
159
|
-
...e.request === void 0 ? {} : { request:
|
|
160
|
-
...e.response === void 0 ? {} : { response:
|
|
161
|
-
}),
|
|
180
|
+
}, oe = (e, t, n) => ({
|
|
181
|
+
...e.request === void 0 ? {} : { request: H(e.request, t) },
|
|
182
|
+
...e.response === void 0 ? {} : { response: H(e.response, n) }
|
|
183
|
+
}), se = () => (e) => {
|
|
162
184
|
if (e.subject.type !== "anonymous") return;
|
|
163
185
|
let t = e.subject.credentialRejected;
|
|
164
186
|
return t === void 0 ? void 0 : {
|
|
@@ -168,118 +190,144 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
168
190
|
}, U = (e, t, n, r = {}) => {
|
|
169
191
|
let i = e.publicApi;
|
|
170
192
|
if (i === void 0) throw Error(`publicApiRoute: descriptor '${e.name}' has no publicApi annotation`);
|
|
171
|
-
let o = d(r.profile, i.format), c = r.pluginErrors ?? [], l = {
|
|
193
|
+
let o = d(r.profile, i.format), c = r.pluginErrors ?? [], l = /* @__PURE__ */ new WeakMap(), u = (e) => {
|
|
194
|
+
if (e === void 0) return /* @__PURE__ */ new Set();
|
|
195
|
+
let t = l.get(e.ast);
|
|
196
|
+
if (t !== void 0) return t;
|
|
197
|
+
let n = L(e);
|
|
198
|
+
return l.set(e.ast, n), n;
|
|
199
|
+
}, f = /* @__PURE__ */ new WeakMap(), p = (e, t) => {
|
|
200
|
+
if (e === void 0) return;
|
|
201
|
+
let n = f.get(e.ast);
|
|
202
|
+
if (n === void 0) {
|
|
203
|
+
let t = /* @__PURE__ */ new Map();
|
|
204
|
+
for (let n of T.isUnion(e.ast) ? e.ast.types : [e.ast]) {
|
|
205
|
+
let e = S.make(n);
|
|
206
|
+
for (let n of u(e)) t.has(n) || t.set(n, e);
|
|
207
|
+
}
|
|
208
|
+
n = t, f.set(e.ast, n);
|
|
209
|
+
}
|
|
210
|
+
return n.get(t);
|
|
211
|
+
}, m = {
|
|
172
212
|
kind: e.kind,
|
|
173
213
|
input: e.input,
|
|
174
214
|
target: e.target
|
|
175
|
-
},
|
|
176
|
-
if (
|
|
177
|
-
for (let t of
|
|
215
|
+
}, h = E(e.kind, i, m), g = (e) => o.naming === "snake_case" ? s(e) : e, v = D(e.name, i, m), y = v.replace(/:([A-Za-z0-9_]+)/g, (e, t) => `:${g(t)}`), b = M(y), O = _(e.input, o), k = ee(O), A = ae(O), j = re(O);
|
|
216
|
+
if (j !== void 0) {
|
|
217
|
+
for (let t of b) if (!j.has(t)) throw Error(`publicApi: descriptor '${e.name}' — path '${v}' binds ':${t}', and the input declares no field of that name` + (j.size > 0 ? ` (fields: ${[...j].join(", ")})` : " (the input declares no fields)"));
|
|
218
|
+
}
|
|
219
|
+
let N = _(e.output, o), P = S.Struct({ value: O }), F = h !== "GET" && j === void 0;
|
|
220
|
+
if (h !== "GET" && j !== void 0) {
|
|
221
|
+
let e = b.length >= 32 ? new Set(b) : void 0;
|
|
222
|
+
for (let t of j) if (!(e?.has(t) ?? b.includes(t))) {
|
|
223
|
+
F = !0;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
178
226
|
}
|
|
179
|
-
let
|
|
180
|
-
query:
|
|
181
|
-
params:
|
|
182
|
-
form:
|
|
183
|
-
},
|
|
184
|
-
...
|
|
185
|
-
body:
|
|
186
|
-
}) :
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let
|
|
192
|
-
if (
|
|
193
|
-
let t =
|
|
194
|
-
return
|
|
227
|
+
let I = {
|
|
228
|
+
query: S.Unknown,
|
|
229
|
+
params: S.Unknown,
|
|
230
|
+
form: S.Boolean
|
|
231
|
+
}, R = (F ? S.Struct({
|
|
232
|
+
...I,
|
|
233
|
+
body: S.Unknown
|
|
234
|
+
}) : S.Struct(I)).pipe(S.decodeTo(P, {
|
|
235
|
+
decode: C.transformEffect((e) => {
|
|
236
|
+
let t = "body" in e ? e.body : void 0, n = h === "GET" ? k(e.query) : e.form ? k(t ?? {}) : t ?? {}, r = typeof e.params == "object" && e.params !== null ? A(e.params) : {};
|
|
237
|
+
if (typeof n != "object" || !n || Array.isArray(n)) return x.succeed({ value: n });
|
|
238
|
+
let i = n, a = Object.keys(r), o = 0;
|
|
239
|
+
for (let e of a) e in i && !ie(i[e], r[e]) && (a[o++] = e);
|
|
240
|
+
if (a.length = o, a.length > 0) {
|
|
241
|
+
let t = h === "GET" ? "query string" : "body";
|
|
242
|
+
return x.fail(new w.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));
|
|
195
243
|
}
|
|
196
|
-
return
|
|
197
|
-
...
|
|
198
|
-
...
|
|
244
|
+
return x.succeed({ value: {
|
|
245
|
+
...i,
|
|
246
|
+
...r
|
|
199
247
|
} });
|
|
200
|
-
},
|
|
201
|
-
encode: (e) =>
|
|
202
|
-
}),
|
|
203
|
-
|
|
204
|
-
...e.openAccess === void 0 ? [
|
|
205
|
-
...(i.scopes ?? []).map((e) =>
|
|
206
|
-
],
|
|
248
|
+
}),
|
|
249
|
+
encode: C.transform((e) => e)
|
|
250
|
+
})), z = [
|
|
251
|
+
se(),
|
|
252
|
+
...e.openAccess === void 0 ? [le()] : [],
|
|
253
|
+
...(i.scopes ?? []).map((e) => ue(e))
|
|
254
|
+
], B = (() => {
|
|
207
255
|
let t = e.source;
|
|
208
256
|
return typeof t == "string" ? t : Array.isArray(t) ? t[0] : void 0;
|
|
209
|
-
})(),
|
|
257
|
+
})(), V = (t, n = 200) => ({
|
|
210
258
|
tag: e.name,
|
|
211
259
|
method: t.method,
|
|
212
260
|
path: t.path,
|
|
213
261
|
query: t.query,
|
|
214
|
-
source:
|
|
262
|
+
source: B,
|
|
215
263
|
status: n
|
|
216
|
-
}),
|
|
217
|
-
r(
|
|
264
|
+
}), H = i.stream === "sse" && e.kind === "query" && n !== void 0, U = S.encodeUnknownEffect(N), ce = H ? (e, t) => he((r) => n(e.value, t, (e) => {
|
|
265
|
+
r(ge(String(e._tag ?? "message"), e));
|
|
218
266
|
})) : async (n, r) => {
|
|
219
267
|
let s;
|
|
220
268
|
try {
|
|
221
269
|
s = await t(n.value, r);
|
|
222
270
|
} catch (t) {
|
|
223
|
-
throw
|
|
271
|
+
throw te(t, e, i, c, o, V(r), u);
|
|
224
272
|
}
|
|
225
|
-
let l = await x.runPromise(
|
|
226
|
-
return
|
|
227
|
-
...
|
|
228
|
-
...
|
|
273
|
+
let l = await x.runPromise(U(s)), d = a(o, l, V(r));
|
|
274
|
+
return q(d.body, {
|
|
275
|
+
...d.headers === void 0 ? {} : { headers: d.headers },
|
|
276
|
+
...d.contentType === void 0 ? {} : { contentType: d.contentType }
|
|
229
277
|
});
|
|
230
|
-
},
|
|
231
|
-
for (let e of
|
|
232
|
-
let t =
|
|
233
|
-
t !== void 0 &&
|
|
278
|
+
}, W = e.error, G = u(W), de = [...G], K = [];
|
|
279
|
+
for (let e of de) {
|
|
280
|
+
let t = p(W, e);
|
|
281
|
+
t !== void 0 && K.push({
|
|
234
282
|
status: i.errorStatus?.[e] ?? 422,
|
|
235
283
|
tag: e,
|
|
236
284
|
schema: t
|
|
237
285
|
});
|
|
238
286
|
}
|
|
239
|
-
for (let e of c) for (let t of
|
|
240
|
-
if (
|
|
287
|
+
for (let e of c) for (let t of u(e.schema)) {
|
|
288
|
+
if (G.has(t)) continue;
|
|
241
289
|
let n = i.errorStatus?.[t] ?? e.rest?.status;
|
|
242
290
|
if (n === void 0) continue;
|
|
243
|
-
let r =
|
|
244
|
-
|
|
291
|
+
let r = p(e.schema, t) ?? e.schema;
|
|
292
|
+
K.push({
|
|
245
293
|
status: n,
|
|
246
294
|
tag: t,
|
|
247
295
|
schema: r
|
|
248
296
|
});
|
|
249
297
|
}
|
|
250
|
-
let
|
|
298
|
+
let fe = i.security === !1 ? "none" : i.security ?? (e.openAccess === void 0 ? "required" : "optional"), J = {
|
|
251
299
|
tag: e.name,
|
|
252
300
|
kind: e.kind,
|
|
253
301
|
version: i.version ?? "v1",
|
|
254
|
-
security:
|
|
302
|
+
security: fe,
|
|
255
303
|
idempotent: i.idempotent === !0,
|
|
256
|
-
input:
|
|
257
|
-
pathParams:
|
|
258
|
-
output:
|
|
259
|
-
source:
|
|
260
|
-
errorResponses:
|
|
304
|
+
input: O,
|
|
305
|
+
pathParams: b,
|
|
306
|
+
output: N,
|
|
307
|
+
source: B,
|
|
308
|
+
errorResponses: K,
|
|
261
309
|
format: o
|
|
262
310
|
};
|
|
263
|
-
return
|
|
264
|
-
method:
|
|
265
|
-
path:
|
|
266
|
-
input:
|
|
267
|
-
output:
|
|
268
|
-
handler:
|
|
269
|
-
...
|
|
270
|
-
guards:
|
|
271
|
-
operationId: i.operationId ??
|
|
311
|
+
return me({
|
|
312
|
+
method: h,
|
|
313
|
+
path: y,
|
|
314
|
+
input: R,
|
|
315
|
+
output: S.Unknown,
|
|
316
|
+
handler: ce,
|
|
317
|
+
...H ? { streaming: !0 } : {},
|
|
318
|
+
guards: z,
|
|
319
|
+
operationId: i.operationId ?? ne(e.name),
|
|
272
320
|
tags: i.tags ?? [e.name.split(".")[0] ?? e.name],
|
|
273
|
-
projection:
|
|
274
|
-
...o.etag &&
|
|
275
|
-
...i.cache !== void 0 &&
|
|
276
|
-
...i.example === void 0 ? {} : { example:
|
|
321
|
+
projection: J,
|
|
322
|
+
...o.etag && h === "GET" && !H ? { etag: !0 } : {},
|
|
323
|
+
...i.cache !== void 0 && h === "GET" && !H ? { cache: i.cache } : {},
|
|
324
|
+
...i.example === void 0 ? {} : { example: oe(i.example, O, N) },
|
|
277
325
|
...i.summary === void 0 ? {} : { summary: i.summary },
|
|
278
326
|
...i.description === void 0 ? {} : { description: i.description },
|
|
279
327
|
...i.deprecated === void 0 ? {} : { deprecated: i.deprecated },
|
|
280
328
|
...i.sunset === void 0 ? {} : { sunset: i.sunset }
|
|
281
329
|
});
|
|
282
|
-
},
|
|
330
|
+
}, ce = (e, t = {}) => e.filter((e) => e.descriptor.publicApi !== void 0).map((e) => U(e.descriptor, e.invoke, e.subscribe, t)).sort((e, t) => e.path.localeCompare(t.path)), W = (e) => b(e.filter((e) => e.projection !== void 0).map((e) => {
|
|
283
331
|
let t = e.projection, n = {
|
|
284
332
|
tag: t.tag,
|
|
285
333
|
method: e.method,
|
|
@@ -290,52 +338,82 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
290
338
|
errors: [...t.errorResponses].map((e) => `${e.status}:${e.tag}`).sort()
|
|
291
339
|
};
|
|
292
340
|
return `${JSON.stringify(n)} ${v(t.input.ast)} ${v(t.output.ast)}`;
|
|
293
|
-
}).sort().join("\n")),
|
|
341
|
+
}).sort().join("\n")), le = () => (e) => {
|
|
294
342
|
if (e.subject.type === "anonymous") return {
|
|
295
343
|
status: 401,
|
|
296
344
|
message: e.subject.credentialRejected ?? "Authentication required"
|
|
297
345
|
};
|
|
298
|
-
},
|
|
346
|
+
}, ue = (e) => (t) => {
|
|
299
347
|
let n = t.subject.scopes;
|
|
300
348
|
if (!(n && (n.includes(e) || n.includes("admin:full")))) return {
|
|
301
349
|
status: 403,
|
|
302
350
|
message: `Missing required scope: ${e}`
|
|
303
351
|
};
|
|
304
|
-
},
|
|
352
|
+
}, G = (e) => {
|
|
353
|
+
for (let t of [
|
|
354
|
+
"includes",
|
|
355
|
+
"some",
|
|
356
|
+
Symbol.iterator
|
|
357
|
+
]) {
|
|
358
|
+
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
359
|
+
if (n !== void 0 && !("value" in n)) return !1;
|
|
360
|
+
}
|
|
361
|
+
if (Object.getPrototypeOf(e) !== Array.prototype || e.includes !== Array.prototype.includes || e.some !== Array.prototype.some || e[Symbol.iterator] !== Array.prototype[Symbol.iterator]) return !1;
|
|
362
|
+
for (let t = 0; t < e.length; t++) {
|
|
363
|
+
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
364
|
+
if (n === void 0 || !("value" in n) || typeof n.value != "string") return !1;
|
|
365
|
+
}
|
|
366
|
+
return !0;
|
|
367
|
+
}, de = (e) => (t) => {
|
|
305
368
|
let n = t.subject.scopes;
|
|
306
|
-
if (
|
|
369
|
+
if (n) {
|
|
370
|
+
if (n.includes("admin:full")) return;
|
|
371
|
+
let t = n.length >= 32 && e.length >= 256 && G(n) && G(e) ? new Set(n) : void 0;
|
|
372
|
+
if (e.some((e) => t === void 0 ? n.includes(e) : t.has(e))) return;
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
307
375
|
status: 403,
|
|
308
376
|
message: `Missing required scope: one of ${e.join(", ")}`
|
|
309
377
|
};
|
|
310
|
-
},
|
|
378
|
+
}, K = (e, t) => e.method === "GET" && e.cache !== void 0 && t.status !== 200 && t.status !== 304 ? {
|
|
379
|
+
...t,
|
|
380
|
+
headers: {
|
|
381
|
+
...t.headers,
|
|
382
|
+
"Cache-Control": "private, no-store"
|
|
383
|
+
}
|
|
384
|
+
} : t, fe = (e, t, n, r, i) => {
|
|
311
385
|
if (e === void 0) return {};
|
|
312
|
-
let
|
|
313
|
-
if (t.headers.authorization !== void 0 || t.headers.cookie !== void 0) return {
|
|
386
|
+
let a = { Vary: e.audience === void 0 ? "Authorization, Cookie" : "Authorization" };
|
|
387
|
+
if (t.headers.authorization !== void 0 || e.audience === void 0 && t.headers.cookie !== void 0) return {
|
|
314
388
|
"Cache-Control": "private, no-cache",
|
|
315
|
-
...
|
|
389
|
+
...a
|
|
390
|
+
};
|
|
391
|
+
if (e.audience !== void 0 && e.audience(n, r, i) === "private") return {
|
|
392
|
+
"Cache-Control": "private, no-store",
|
|
393
|
+
...a
|
|
316
394
|
};
|
|
317
|
-
let
|
|
395
|
+
let o = Math.max(0, Math.floor(e.maxAge)), s = [
|
|
318
396
|
"public",
|
|
319
|
-
`max-age=${
|
|
320
|
-
`s-maxage=${
|
|
397
|
+
`max-age=${o}`,
|
|
398
|
+
`s-maxage=${o}`
|
|
321
399
|
];
|
|
322
|
-
e.staleWhileRevalidate !== void 0 &&
|
|
323
|
-
let
|
|
400
|
+
e.staleWhileRevalidate !== void 0 && s.push(`stale-while-revalidate=${Math.max(0, Math.floor(e.staleWhileRevalidate))}`);
|
|
401
|
+
let c = [...new Set((e.tags?.(n, r) ?? []).filter((e) => e !== "" && !/[\s,]/.test(e)))];
|
|
324
402
|
return {
|
|
325
|
-
"Cache-Control":
|
|
326
|
-
...
|
|
327
|
-
...
|
|
328
|
-
"Cache-Tag":
|
|
329
|
-
"Surrogate-Key":
|
|
403
|
+
"Cache-Control": s.join(", "),
|
|
404
|
+
...a,
|
|
405
|
+
...c.length > 0 ? {
|
|
406
|
+
"Cache-Tag": c.join(","),
|
|
407
|
+
"Surrogate-Key": c.join(" ")
|
|
330
408
|
} : {}
|
|
331
409
|
};
|
|
332
|
-
},
|
|
410
|
+
}, q = (e, t = {}) => ({
|
|
333
411
|
__voltroRestResponse: !0,
|
|
334
412
|
status: t.status ?? 200,
|
|
335
413
|
body: e,
|
|
336
414
|
...t.headers === void 0 ? {} : { headers: t.headers },
|
|
337
415
|
...t.contentType === void 0 ? {} : { contentType: t.contentType }
|
|
338
|
-
}),
|
|
416
|
+
}), J = (e) => typeof e == "object" && !!e && e.__voltroRestResponse === !0, Y = class extends Error {
|
|
339
417
|
status;
|
|
340
418
|
body;
|
|
341
419
|
headers;
|
|
@@ -343,7 +421,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
343
421
|
constructor(e, t, n, r) {
|
|
344
422
|
super(`REST ${e}`), this.name = "RestRouteError", this.status = e, this.body = t, this.headers = n, this.contentType = r;
|
|
345
423
|
}
|
|
346
|
-
},
|
|
424
|
+
}, pe = (e, t, n) => new Y(e, t, n), me = (e) => {
|
|
347
425
|
if (e.version === void 0) return e;
|
|
348
426
|
if (!/^v\d+$/.test(e.version)) throw Error(`defineRestRoute(${e.method} ${e.path}): version "${e.version}" must be 'v' followed by digits — 'v1', 'v2', …`);
|
|
349
427
|
if ((/* @__PURE__ */ RegExp("^/v\\d+(/|$)")).test(e.path)) throw Error(`defineRestRoute(${e.method} ${e.path}): the path already starts with a version segment AND declares version: '${e.version}'. Pick one spelling — either bake the version into the path, or declare version: and keep the path bare ('/customers'). Both would mount '/${e.version}${e.path}', which is never what the author meant.`);
|
|
@@ -351,13 +429,13 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
351
429
|
...e,
|
|
352
430
|
path: `/${e.version}${e.path}`
|
|
353
431
|
};
|
|
354
|
-
},
|
|
432
|
+
}, he = (e, t = {}) => ({
|
|
355
433
|
__voltroRestStream: !0,
|
|
356
434
|
stream: {
|
|
357
435
|
subscribe: e,
|
|
358
436
|
...t.keepAliveMs === void 0 ? {} : { keepAliveMs: t.keepAliveMs }
|
|
359
437
|
}
|
|
360
|
-
}),
|
|
438
|
+
}), ge = (e, t) => `event: ${e}\n${(typeof t == "string" ? t : JSON.stringify(t)).split("\n").map((e) => `data: ${e}`).join("\n")}\n\n`, _e = (e) => typeof e == "object" && !!e && e.__voltroRestStream === !0, ve = (e, t = {}) => ({
|
|
361
439
|
__voltroRestBytes: !0,
|
|
362
440
|
byteStream: {
|
|
363
441
|
stream: e,
|
|
@@ -367,9 +445,10 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
367
445
|
...t.contentType === void 0 ? {} : { contentType: t.contentType },
|
|
368
446
|
...t.status === void 0 ? {} : { status: t.status },
|
|
369
447
|
...t.headers === void 0 ? {} : { headers: t.headers }
|
|
370
|
-
}), X = (e) => typeof e == "object" && !!e && e.__voltroRestBytes === !0,
|
|
371
|
-
let t = await globalThis.crypto.subtle.digest("SHA-1", new TextEncoder().encode(e));
|
|
372
|
-
|
|
448
|
+
}), X = (e) => typeof e == "object" && !!e && e.__voltroRestBytes === !0, ye = async (e) => {
|
|
449
|
+
let t = await globalThis.crypto.subtle.digest("SHA-1", new TextEncoder().encode(e)), n = "";
|
|
450
|
+
for (let e of new Uint8Array(t)) n += e.toString(16).padStart(2, "0");
|
|
451
|
+
return n;
|
|
373
452
|
}, Z = (e, t, n, r = "application/json; charset=utf-8") => ({
|
|
374
453
|
status: e,
|
|
375
454
|
contentType: r,
|
|
@@ -398,7 +477,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
398
477
|
...o,
|
|
399
478
|
...u.headers ?? {}
|
|
400
479
|
}, u.contentType);
|
|
401
|
-
},
|
|
480
|
+
}, be = (e) => (e.headers["content-type"] ?? "application/json").split(";")[0].trim().toLowerCase(), xe = (e, t) => {
|
|
402
481
|
if (e.length === 0) return;
|
|
403
482
|
let n = t === "application/x-www-form-urlencoded";
|
|
404
483
|
if (!n && t !== "application/json" && !/^application\/[^/;\s]+\+json$/.test(t)) return;
|
|
@@ -406,22 +485,22 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
406
485
|
if (r.trim() !== "") {
|
|
407
486
|
if (n) {
|
|
408
487
|
let e = (e) => decodeURIComponent(e.replace(/\+/g, " "));
|
|
409
|
-
return
|
|
488
|
+
return Ce((r.match(/[^&]+/g) ?? []).map((t) => {
|
|
410
489
|
let n = t.indexOf("=");
|
|
411
490
|
return n < 0 ? [e(t), ""] : [e(t.slice(0, n)), e(t.slice(n + 1))];
|
|
412
491
|
}));
|
|
413
492
|
}
|
|
414
493
|
return JSON.parse(r);
|
|
415
494
|
}
|
|
416
|
-
},
|
|
495
|
+
}, Se = (e) => Ce(new URLSearchParams(e)), Ce = (e) => {
|
|
417
496
|
let t = /* @__PURE__ */ new Map();
|
|
418
497
|
for (let [n, r] of e) {
|
|
419
498
|
let e = t.get(n);
|
|
420
499
|
e === void 0 ? t.set(n, r) : Array.isArray(e) ? e.push(r) : t.set(n, [e, r]);
|
|
421
500
|
}
|
|
422
501
|
return Object.fromEntries(t);
|
|
423
|
-
},
|
|
424
|
-
let n = e.
|
|
502
|
+
}, we = (e, t) => {
|
|
503
|
+
let n = e.match(/[^/]+/g) ?? [], r = t.match(/[^/]+/g) ?? [], i = {};
|
|
425
504
|
for (let e = 0; e < n.length; e++) {
|
|
426
505
|
let t = n[e];
|
|
427
506
|
if (t !== void 0 && t.startsWith(":")) {
|
|
@@ -434,7 +513,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
434
513
|
}
|
|
435
514
|
}
|
|
436
515
|
return i;
|
|
437
|
-
},
|
|
516
|
+
}, Te = (e, t) => {
|
|
438
517
|
let n = e.path.split("/"), r = n[n.length - 1] === "*", i = r ? n.slice(0, -1) : n, a = t.split("/");
|
|
439
518
|
if (a.length < i.length) return !1;
|
|
440
519
|
for (let e = 0; e < i.length; e++) {
|
|
@@ -444,17 +523,17 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
444
523
|
} else if (t !== n) return !1;
|
|
445
524
|
}
|
|
446
525
|
return a.length === i.length ? !0 : e.match === "exact" && !r ? !1 : a.slice(i.length).some((e) => e.length > 0);
|
|
447
|
-
},
|
|
448
|
-
query:
|
|
526
|
+
}, Ee = (e, t, n) => ({
|
|
527
|
+
query: Se(e.query),
|
|
449
528
|
params: t,
|
|
450
|
-
body: n ?
|
|
451
|
-
form:
|
|
529
|
+
body: n ? xe(e.rawBody, be(e)) : void 0,
|
|
530
|
+
form: be(e) === "application/x-www-form-urlencoded"
|
|
452
531
|
}), $ = /* @__PURE__ */ new Set([
|
|
453
532
|
"POST",
|
|
454
533
|
"PUT",
|
|
455
534
|
"PATCH",
|
|
456
535
|
"DELETE"
|
|
457
|
-
]),
|
|
536
|
+
]), De = (e, n, r, i, a) => {
|
|
458
537
|
if (e instanceof Y) return Z(e.status, e.body, {
|
|
459
538
|
...i,
|
|
460
539
|
...e.headers
|
|
@@ -484,8 +563,8 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
484
563
|
...Q(r, a, 500, "InternalServerError", "Internal Server Error", {}, { ...i }),
|
|
485
564
|
cause: e
|
|
486
565
|
};
|
|
487
|
-
},
|
|
488
|
-
let c = a.input ?
|
|
566
|
+
}, Oe = (a, o, s) => {
|
|
567
|
+
let c = a.input ? S.decodeUnknownEffect(a.input) : void 0, l = S.encodeEffect(a.output), d = a.input === void 0 ? void 0 : T.toEncoded(a.input.ast), f = d !== void 0 && (!T.isObjects(d) || d.indexSignatures.length > 0 || d.propertySignatures.some((e) => e.name === "body")), p = {};
|
|
489
568
|
a.projection !== void 0 && (p["x-voltro-rest-profile"] = a.projection.format.name);
|
|
490
569
|
let m = (e) => e.replace(/\/$/, "").split("/").length, h = m(a.path);
|
|
491
570
|
return a.deprecated !== void 0 && (p.Deprecation = "true"), a.sunset !== void 0 && (p.Sunset = a.sunset), {
|
|
@@ -512,14 +591,14 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
512
591
|
if (c) {
|
|
513
592
|
let e;
|
|
514
593
|
try {
|
|
515
|
-
e =
|
|
594
|
+
e = Ee(d, we(a.path, d.path), f);
|
|
516
595
|
} catch {
|
|
517
596
|
return Q(a, d, 400, "InvalidRequest", "Malformed request body", {}, { ...p });
|
|
518
597
|
}
|
|
519
598
|
let t = await x.runPromise(c(e).pipe(x.map((e) => ({
|
|
520
599
|
ok: !0,
|
|
521
600
|
value: e
|
|
522
|
-
})), x.
|
|
601
|
+
})), x.catch((e) => x.succeed({
|
|
523
602
|
ok: !1,
|
|
524
603
|
cause: e
|
|
525
604
|
}))));
|
|
@@ -540,7 +619,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
540
619
|
try {
|
|
541
620
|
b = o.buildContext ? await o.buildContext(v, d.headers) : void 0;
|
|
542
621
|
} catch (e) {
|
|
543
|
-
return
|
|
622
|
+
return K(a, De(e, v, a, p, d));
|
|
544
623
|
}
|
|
545
624
|
let S = typeof b == "object" && b && "store" in b ? b.store : o.store, C = {
|
|
546
625
|
subject: v,
|
|
@@ -569,7 +648,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
569
648
|
}
|
|
570
649
|
try {
|
|
571
650
|
let e = await a.handler(_, C);
|
|
572
|
-
if (
|
|
651
|
+
if (_e(e) || X(e)) return w && T && await i(w.store, E, T), X(e) ? {
|
|
573
652
|
status: e.status ?? 200,
|
|
574
653
|
headers: {
|
|
575
654
|
...p,
|
|
@@ -582,7 +661,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
582
661
|
headers: p,
|
|
583
662
|
stream: e.stream
|
|
584
663
|
};
|
|
585
|
-
let t =
|
|
664
|
+
let t = J(e) ? e : q(e), r = await x.runPromise(l(t.body)), o = a.method === "GET" && t.status === 200 ? fe(a.cache, d, r, _, v) : {}, s = {
|
|
586
665
|
...p,
|
|
587
666
|
...t.headers,
|
|
588
667
|
...o
|
|
@@ -591,7 +670,7 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
591
670
|
status: t.status,
|
|
592
671
|
body: r
|
|
593
672
|
}, Date.now()), a.etag === !0 && a.method === "GET") {
|
|
594
|
-
let e = `W/"${await
|
|
673
|
+
let e = `W/"${await ye(JSON.stringify(r))}"`, n = d.headers["if-none-match"];
|
|
595
674
|
return n !== void 0 && n.split(",").some((t) => t.trim() === e) ? {
|
|
596
675
|
status: 304,
|
|
597
676
|
headers: {
|
|
@@ -599,23 +678,23 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
599
678
|
...o,
|
|
600
679
|
ETag: e
|
|
601
680
|
}
|
|
602
|
-
} : Z(t.status, r, {
|
|
681
|
+
} : K(a, Z(t.status, r, {
|
|
603
682
|
...s,
|
|
604
683
|
ETag: e
|
|
605
|
-
}, t.contentType);
|
|
684
|
+
}, t.contentType));
|
|
606
685
|
}
|
|
607
|
-
return t.status === 204 || t.status === 304 ? {
|
|
686
|
+
return t.status === 204 || t.status === 304 ? K(a, {
|
|
608
687
|
status: t.status,
|
|
609
688
|
headers: s
|
|
610
|
-
} : Z(t.status, r, s, t.contentType);
|
|
689
|
+
}) : K(a, Z(t.status, r, s, t.contentType));
|
|
611
690
|
} catch (e) {
|
|
612
|
-
return w && T && await i(w.store, E, T),
|
|
691
|
+
return w && T && await i(w.store, E, T), K(a, De(e, v, a, p, d));
|
|
613
692
|
} finally {
|
|
614
693
|
D?.();
|
|
615
694
|
}
|
|
616
695
|
}
|
|
617
696
|
};
|
|
618
|
-
},
|
|
697
|
+
}, ke = (e, t = {}) => {
|
|
619
698
|
if (t.idempotency !== void 0) {
|
|
620
699
|
for (let t of e) if (t.streaming === !0 && $.has(t.method)) throw Error(`REST route ${t.method} ${t.path} declares \`streaming: true\` on a method the idempotency binding claims (${[...$].join("/")}). A stream cannot complete an idempotency claim — there is no replayable body to cache — so a retried request would 409 until the claim's TTL. Either serve the stream on GET, or scope the idempotency binding away from this app's streaming routes.`);
|
|
621
700
|
}
|
|
@@ -624,11 +703,11 @@ var T = (e, t, n) => t.method ?? (t.resource !== void 0 && n !== void 0 ? k("",
|
|
|
624
703
|
let e = r.get(n(t.path)) ?? [];
|
|
625
704
|
e.includes(t.method) || e.push(t.method), r.set(n(t.path), e);
|
|
626
705
|
}
|
|
627
|
-
return e.map((e) =>
|
|
628
|
-
},
|
|
706
|
+
return e.map((e) => Oe(e, t, r.get(n(e.path)).join(", ")));
|
|
707
|
+
}, Ae = async (e, t) => {
|
|
629
708
|
let n = await e[0].handle(t);
|
|
630
709
|
for (let r = 1; r < e.length && n.status === 405; r++) n = await e[r].handle(t);
|
|
631
710
|
return n;
|
|
632
711
|
};
|
|
633
712
|
//#endregion
|
|
634
|
-
export { g as JSONAPI_MEDIA_TYPE, f as PROBLEM_JSON, m as REST_PROFILE_NAMES, Y as RestRouteError,
|
|
713
|
+
export { g as JSONAPI_MEDIA_TYPE, f as PROBLEM_JSON, m as REST_PROFILE_NAMES, Y as RestRouteError, ve as bytes, I as coerceQueryObject, F as coerceQueryValue, ce as collectPublicApiRoutes, L as declaredErrorTags, me as defineRestRoute, E as derivePublicMethod, D as derivePublicPath, A as deriveResource, Ae as dispatchSharedPath, l as encodeRestError, a as encodeRestSuccess, V as errorMemberSchema, X as isRestByteResponse, J as isRestResponse, _e as isRestStreamResponse, we as matchPathParams, p as nextLink, j as normalizePathParams, ne as operationIdOf, M as pathParamNames, h as problemDetails, o as problemTypeOf, z as projectedFailure, U as publicApiRoute, W as publicSurfaceDigest, de as requireAnyScope, le as requireAuthenticated, ue as requireScope, d as resolveRestFormat, k as resourceIdField, q as response, pe as restError, ke as restRoutesToHttpRoutes, _ as restViewSchema, Te as routeAcceptsPath, he as sse, ge as sseFrame, s as toSnakeCase, oe as wireExample };
|