@adhd/apigen-engine-runtime 0.2.2 → 0.2.4
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 +49 -0
- package/README.md +14 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +1057 -766
- package/lib/describe-params.d.ts +12 -1
- package/lib/op-plan.d.ts +7 -0
- package/lib/package-invoker.d.ts +17 -0
- package/lib/tool-description.d.ts +8 -5
- package/package.json +25 -5
- package/test-support/parity-harness.d.ts +37 -0
package/index.mjs
CHANGED
|
@@ -1,70 +1,69 @@
|
|
|
1
|
-
import "ts-morph";
|
|
2
1
|
import "node:fs";
|
|
2
|
+
import { createRequire as he } from "node:module";
|
|
3
3
|
import "node:path";
|
|
4
|
-
import "ts-json-schema-generator";
|
|
5
4
|
import N from "pino";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
class
|
|
5
|
+
import _e from "ajv";
|
|
6
|
+
import ke from "ajv-formats";
|
|
7
|
+
const M = "$apigen";
|
|
8
|
+
let Z = class extends Error {
|
|
10
9
|
constructor(t) {
|
|
11
10
|
super(t), this.code = "E_DUP_CODEC", this.name = "CodecRegistryError";
|
|
12
11
|
}
|
|
13
|
-
}
|
|
14
|
-
function
|
|
12
|
+
};
|
|
13
|
+
function Ie(e) {
|
|
15
14
|
const t = /* @__PURE__ */ new Map();
|
|
16
15
|
return {
|
|
17
|
-
register(
|
|
18
|
-
if (t.has(
|
|
19
|
-
throw new
|
|
20
|
-
`E_DUP_CODEC: a codec is already registered for id "${
|
|
16
|
+
register(n, r) {
|
|
17
|
+
if (t.has(n.id) && !(r != null && r.override))
|
|
18
|
+
throw new Z(
|
|
19
|
+
`E_DUP_CODEC: a codec is already registered for id "${n.id}"`
|
|
21
20
|
);
|
|
22
|
-
t.set(
|
|
21
|
+
t.set(n.id, n);
|
|
23
22
|
},
|
|
24
|
-
resolve(
|
|
25
|
-
for (const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
23
|
+
resolve(n) {
|
|
24
|
+
for (const r of t.values())
|
|
25
|
+
if (r.matches(n))
|
|
26
|
+
return r;
|
|
28
27
|
},
|
|
29
|
-
get(
|
|
30
|
-
return t.get(
|
|
28
|
+
get(n) {
|
|
29
|
+
return t.get(n);
|
|
31
30
|
},
|
|
32
31
|
ids() {
|
|
33
32
|
return [...t.keys()];
|
|
34
33
|
},
|
|
35
34
|
freeze() {
|
|
36
|
-
const
|
|
35
|
+
const n = new Map(t), r = {
|
|
37
36
|
register() {
|
|
38
|
-
throw new
|
|
37
|
+
throw new Z(
|
|
39
38
|
"E_DUP_CODEC: registry is frozen and cannot accept new codecs"
|
|
40
39
|
);
|
|
41
40
|
},
|
|
42
41
|
resolve(o) {
|
|
43
|
-
for (const i of
|
|
42
|
+
for (const i of n.values())
|
|
44
43
|
if (i.matches(o))
|
|
45
44
|
return i;
|
|
46
45
|
},
|
|
47
46
|
get(o) {
|
|
48
|
-
return
|
|
47
|
+
return n.get(o);
|
|
49
48
|
},
|
|
50
49
|
ids() {
|
|
51
|
-
return [...
|
|
50
|
+
return [...n.keys()];
|
|
52
51
|
},
|
|
53
52
|
freeze() {
|
|
54
|
-
return
|
|
53
|
+
return r;
|
|
55
54
|
}
|
|
56
55
|
};
|
|
57
|
-
return
|
|
56
|
+
return r;
|
|
58
57
|
}
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
|
-
const
|
|
62
|
-
function
|
|
60
|
+
const F = "x-apigen-logical", V = "x-apigen-codec", T = "x-apigen-ctor", P = "x-apigen-tojson", Ce = "0.1.0";
|
|
61
|
+
function Q(e, t) {
|
|
63
62
|
return {
|
|
64
63
|
registry: e,
|
|
65
|
-
resolve: (
|
|
64
|
+
resolve: (n) => {
|
|
66
65
|
throw new Error(
|
|
67
|
-
`[apigen-logical] $ref "${
|
|
66
|
+
`[apigen-logical] $ref "${n}" cannot be resolved in run-mode without a descriptor root. Supply a resolve() in the ctx override to handle $ref.`
|
|
68
67
|
);
|
|
69
68
|
},
|
|
70
69
|
seen: /* @__PURE__ */ new WeakSet(),
|
|
@@ -73,66 +72,66 @@ function G(e, t) {
|
|
|
73
72
|
...t
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
function v(e, t,
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
75
|
+
function v(e, t, n) {
|
|
76
|
+
const r = n.registry.resolve(t);
|
|
77
|
+
if (r)
|
|
78
|
+
return r.encode(e, t, n);
|
|
80
79
|
const o = t.$ref;
|
|
81
80
|
if (typeof o == "string") {
|
|
82
|
-
const a =
|
|
83
|
-
return v(e, a,
|
|
81
|
+
const a = n.resolve(o);
|
|
82
|
+
return v(e, a, n);
|
|
84
83
|
}
|
|
85
84
|
const i = t.oneOf;
|
|
86
85
|
if (Array.isArray(i)) {
|
|
87
|
-
const a =
|
|
88
|
-
return v(e, a,
|
|
86
|
+
const a = ge(e, i, t, n);
|
|
87
|
+
return v(e, a, n);
|
|
89
88
|
}
|
|
90
89
|
const s = t.type;
|
|
91
90
|
if (s === "array") {
|
|
92
91
|
if (!Array.isArray(e))
|
|
93
|
-
return
|
|
92
|
+
return A(e, t, n);
|
|
94
93
|
const a = t.items;
|
|
95
94
|
if (!a)
|
|
96
|
-
return e.map((
|
|
97
|
-
const f =
|
|
98
|
-
return Array.isArray(a) ? e.map((
|
|
99
|
-
const
|
|
100
|
-
return
|
|
95
|
+
return e.map((u) => w(u));
|
|
96
|
+
const f = n.path;
|
|
97
|
+
return Array.isArray(a) ? e.map((u, c) => {
|
|
98
|
+
const l = a[c];
|
|
99
|
+
return l === void 0 ? w(u) : v(u, l, { ...n, path: `${f}/${c}` });
|
|
101
100
|
}) : e.map(
|
|
102
|
-
(
|
|
101
|
+
(u, c) => v(u, a, { ...n, path: `${f}/${c}` })
|
|
103
102
|
);
|
|
104
103
|
}
|
|
105
104
|
if (s === "object") {
|
|
106
105
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
107
|
-
return
|
|
106
|
+
return A(e, t, n);
|
|
108
107
|
const a = t.properties;
|
|
109
108
|
if (!a)
|
|
110
109
|
return w(e);
|
|
111
|
-
const f =
|
|
112
|
-
for (const [
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
...
|
|
116
|
-
path: `${f}/${
|
|
110
|
+
const f = n.path, u = {};
|
|
111
|
+
for (const [c, l] of Object.entries(a)) {
|
|
112
|
+
const p = e[c];
|
|
113
|
+
p !== void 0 && (u[c] = v(p, l, {
|
|
114
|
+
...n,
|
|
115
|
+
path: `${f}/${c}`
|
|
117
116
|
}));
|
|
118
117
|
}
|
|
119
|
-
return
|
|
118
|
+
return u;
|
|
120
119
|
}
|
|
121
|
-
return s == null ?
|
|
120
|
+
return s == null ? A(e, t, n) : w(e);
|
|
122
121
|
}
|
|
123
|
-
function $(e, t,
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
122
|
+
function $(e, t, n) {
|
|
123
|
+
const r = n.registry.resolve(t);
|
|
124
|
+
if (r)
|
|
125
|
+
return r.decode(e, t, n);
|
|
127
126
|
const o = t.$ref;
|
|
128
127
|
if (typeof o == "string") {
|
|
129
|
-
const a =
|
|
130
|
-
return $(e, a,
|
|
128
|
+
const a = n.resolve(o);
|
|
129
|
+
return $(e, a, n);
|
|
131
130
|
}
|
|
132
131
|
const i = t.oneOf;
|
|
133
132
|
if (Array.isArray(i)) {
|
|
134
|
-
const a =
|
|
135
|
-
return $(e, a,
|
|
133
|
+
const a = ge(e, i, t, n);
|
|
134
|
+
return $(e, a, n);
|
|
136
135
|
}
|
|
137
136
|
const s = t.type;
|
|
138
137
|
if (s === "array") {
|
|
@@ -141,12 +140,12 @@ function $(e, t, r) {
|
|
|
141
140
|
const a = t.items;
|
|
142
141
|
if (!a)
|
|
143
142
|
return e;
|
|
144
|
-
const f =
|
|
145
|
-
return Array.isArray(a) ? e.map((
|
|
146
|
-
const
|
|
147
|
-
return
|
|
143
|
+
const f = n.path;
|
|
144
|
+
return Array.isArray(a) ? e.map((u, c) => {
|
|
145
|
+
const l = a[c];
|
|
146
|
+
return l === void 0 ? u : $(u, l, { ...n, path: `${f}/${c}` });
|
|
148
147
|
}) : e.map(
|
|
149
|
-
(
|
|
148
|
+
(u, c) => $(u, a, { ...n, path: `${f}/${c}` })
|
|
150
149
|
);
|
|
151
150
|
}
|
|
152
151
|
if (s === "object") {
|
|
@@ -155,50 +154,176 @@ function $(e, t, r) {
|
|
|
155
154
|
const a = t.properties;
|
|
156
155
|
if (!a)
|
|
157
156
|
return e;
|
|
158
|
-
const f =
|
|
159
|
-
for (const [
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
...
|
|
163
|
-
path: `${f}/${
|
|
157
|
+
const f = n.path, u = {};
|
|
158
|
+
for (const [c, l] of Object.entries(a)) {
|
|
159
|
+
const p = e[c];
|
|
160
|
+
p !== void 0 && (u[c] = $(p, l, {
|
|
161
|
+
...n,
|
|
162
|
+
path: `${f}/${c}`
|
|
164
163
|
}));
|
|
165
164
|
}
|
|
166
|
-
|
|
165
|
+
for (const [c, l] of Object.entries(e))
|
|
166
|
+
!(c in a) && l !== void 0 && (u[c] = l);
|
|
167
|
+
return u;
|
|
167
168
|
}
|
|
168
|
-
return s == null ?
|
|
169
|
-
}
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
|
|
169
|
+
return s == null ? D(e, n) : e;
|
|
170
|
+
}
|
|
171
|
+
function ge(e, t, n, r) {
|
|
172
|
+
var o;
|
|
173
|
+
const i = n.discriminator;
|
|
174
|
+
if (i != null && i.propertyName) {
|
|
175
|
+
const u = i.propertyName, c = e !== null && typeof e == "object" ? e[u] : void 0;
|
|
176
|
+
if (typeof c == "string") {
|
|
177
|
+
if (i.mapping) {
|
|
178
|
+
const l = i.mapping[c];
|
|
179
|
+
if (l) {
|
|
180
|
+
const p = t.find((y) => y.$ref === l);
|
|
181
|
+
if (p)
|
|
182
|
+
return p;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const l of t) {
|
|
186
|
+
const p = (o = _(l, r).properties) == null ? void 0 : o[u];
|
|
187
|
+
if (!p)
|
|
188
|
+
continue;
|
|
189
|
+
const y = p.enum;
|
|
190
|
+
if (p.const === c || Array.isArray(y) && y.includes(c))
|
|
191
|
+
return l;
|
|
180
192
|
}
|
|
181
193
|
}
|
|
182
194
|
}
|
|
183
|
-
|
|
195
|
+
const s = xe(e, t, r);
|
|
196
|
+
if (s)
|
|
197
|
+
return s;
|
|
198
|
+
let a, f = -1;
|
|
199
|
+
for (const u of t) {
|
|
200
|
+
const c = _(u, r), l = we(e, c, r);
|
|
201
|
+
l !== null && l > f && (f = l, a = u);
|
|
202
|
+
}
|
|
203
|
+
return a !== void 0 ? a : t[0] ?? {};
|
|
204
|
+
}
|
|
205
|
+
function _(e, t) {
|
|
206
|
+
const n = e.$ref;
|
|
207
|
+
return typeof n == "string" ? t.resolve(n) : e;
|
|
208
|
+
}
|
|
209
|
+
function X(e) {
|
|
210
|
+
if ("const" in e)
|
|
211
|
+
return e.const;
|
|
212
|
+
const t = e.enum;
|
|
213
|
+
if (Array.isArray(t) && t.length === 1)
|
|
214
|
+
return t[0];
|
|
215
|
+
}
|
|
216
|
+
function xe(e, t, n) {
|
|
217
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
218
|
+
return;
|
|
219
|
+
const r = e, o = t.map((s) => _(s, n)), i = /* @__PURE__ */ new Set();
|
|
220
|
+
for (const s of o) {
|
|
221
|
+
const a = s.properties;
|
|
222
|
+
if (a)
|
|
223
|
+
for (const [f, u] of Object.entries(a))
|
|
224
|
+
X(u) !== void 0 && i.add(f);
|
|
225
|
+
}
|
|
226
|
+
for (const s of i) {
|
|
227
|
+
const a = o.map((p) => {
|
|
228
|
+
const y = p.properties, d = y == null ? void 0 : y[s];
|
|
229
|
+
return d ? X(d) : void 0;
|
|
230
|
+
}), f = a.filter((p) => p !== void 0), u = new Set(f);
|
|
231
|
+
if (f.length < 2 || u.size !== f.length)
|
|
232
|
+
continue;
|
|
233
|
+
const c = r[s];
|
|
234
|
+
if (c === void 0)
|
|
235
|
+
continue;
|
|
236
|
+
const l = a.findIndex((p) => p === c);
|
|
237
|
+
if (l !== -1)
|
|
238
|
+
return t[l];
|
|
239
|
+
}
|
|
184
240
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
241
|
+
function Se(e) {
|
|
242
|
+
if (e === null)
|
|
243
|
+
return "null";
|
|
244
|
+
if (Array.isArray(e))
|
|
245
|
+
return "array";
|
|
246
|
+
const t = typeof e;
|
|
247
|
+
return t === "number" ? Number.isInteger(e) ? "integer" : "number" : t;
|
|
248
|
+
}
|
|
249
|
+
function we(e, t, n) {
|
|
250
|
+
const r = t.oneOf;
|
|
251
|
+
if (Array.isArray(r)) {
|
|
252
|
+
let c = null;
|
|
253
|
+
for (const l of r) {
|
|
254
|
+
const p = we(e, _(l, n), n);
|
|
255
|
+
p !== null && (c === null || p > c) && (c = p);
|
|
256
|
+
}
|
|
257
|
+
return c;
|
|
258
|
+
}
|
|
259
|
+
const o = t.type, i = Se(e);
|
|
260
|
+
if (typeof o == "string") {
|
|
261
|
+
if (!(o === i || o === "number" && i === "integer"))
|
|
262
|
+
return null;
|
|
263
|
+
} else if (Array.isArray(o) && !o.some(
|
|
264
|
+
(c) => c === i || c === "number" && i === "integer"
|
|
265
|
+
))
|
|
266
|
+
return null;
|
|
267
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
268
|
+
return typeof o == "string" ? 1 : 0;
|
|
269
|
+
const s = e, a = t.required;
|
|
270
|
+
let f = 0;
|
|
271
|
+
if (Array.isArray(a)) {
|
|
272
|
+
for (const c of a)
|
|
273
|
+
if (typeof c == "string") {
|
|
274
|
+
if (s[c] === void 0)
|
|
275
|
+
return null;
|
|
276
|
+
f += 2;
|
|
193
277
|
}
|
|
194
278
|
}
|
|
279
|
+
const u = t.properties;
|
|
280
|
+
if (u) {
|
|
281
|
+
for (const c of Object.keys(u))
|
|
282
|
+
s[c] !== void 0 && (f += 1);
|
|
283
|
+
for (const c of Object.keys(s))
|
|
284
|
+
u[c] === void 0 && (f -= 1);
|
|
285
|
+
}
|
|
286
|
+
return f;
|
|
287
|
+
}
|
|
288
|
+
function A(e, t, n) {
|
|
289
|
+
var r;
|
|
290
|
+
for (const o of n.registry.ids()) {
|
|
291
|
+
const i = n.registry.get(o);
|
|
292
|
+
if ((r = i == null ? void 0 : i.ownsValue) != null && r.call(i, e))
|
|
293
|
+
return {
|
|
294
|
+
[M]: o,
|
|
295
|
+
v: i.encode(e, i.schema, n)
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
if (Array.isArray(e))
|
|
299
|
+
return e.map((o) => A(o, {}, n));
|
|
300
|
+
if (be(e)) {
|
|
301
|
+
const o = {};
|
|
302
|
+
for (const [i, s] of Object.entries(e))
|
|
303
|
+
s !== void 0 && (o[i] = A(s, {}, n));
|
|
304
|
+
return o;
|
|
305
|
+
}
|
|
195
306
|
return w(e);
|
|
196
307
|
}
|
|
197
|
-
function
|
|
198
|
-
if (e
|
|
199
|
-
|
|
308
|
+
function be(e) {
|
|
309
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
310
|
+
return !1;
|
|
311
|
+
const t = Object.getPrototypeOf(e);
|
|
312
|
+
return t === Object.prototype || t === null;
|
|
313
|
+
}
|
|
314
|
+
function D(e, t) {
|
|
315
|
+
if (e !== null && typeof e == "object" && !Array.isArray(e) && M in e) {
|
|
316
|
+
const n = e, r = n[M], o = t.registry.get(r);
|
|
200
317
|
if (o)
|
|
201
|
-
return o.decode(
|
|
318
|
+
return o.decode(n.v, o.schema, t);
|
|
319
|
+
}
|
|
320
|
+
if (Array.isArray(e))
|
|
321
|
+
return e.map((n) => D(n, t));
|
|
322
|
+
if (be(e)) {
|
|
323
|
+
const n = {};
|
|
324
|
+
for (const [r, o] of Object.entries(e))
|
|
325
|
+
n[r] = D(o, t);
|
|
326
|
+
return n;
|
|
202
327
|
}
|
|
203
328
|
return e;
|
|
204
329
|
}
|
|
@@ -209,63 +334,69 @@ function w(e) {
|
|
|
209
334
|
return e.map(w);
|
|
210
335
|
if (typeof e == "object") {
|
|
211
336
|
const t = {};
|
|
212
|
-
for (const [
|
|
213
|
-
|
|
337
|
+
for (const [n, r] of Object.entries(e))
|
|
338
|
+
r !== void 0 && (t[n] = w(r));
|
|
214
339
|
return t;
|
|
215
340
|
}
|
|
216
341
|
return null;
|
|
217
342
|
}
|
|
218
|
-
function
|
|
343
|
+
function Me(e) {
|
|
219
344
|
return {
|
|
220
|
-
encode(t,
|
|
221
|
-
const o =
|
|
222
|
-
return v(t,
|
|
345
|
+
encode(t, n, r) {
|
|
346
|
+
const o = Q(e, r);
|
|
347
|
+
return v(t, n, o);
|
|
223
348
|
},
|
|
224
|
-
decode(t,
|
|
225
|
-
const o =
|
|
226
|
-
return $(t,
|
|
349
|
+
decode(t, n, r) {
|
|
350
|
+
const o = Q(e, r);
|
|
351
|
+
return $(t, n, o);
|
|
227
352
|
}
|
|
228
353
|
};
|
|
229
354
|
}
|
|
230
|
-
const
|
|
355
|
+
const H = {
|
|
231
356
|
id: "date-time",
|
|
232
357
|
kind: "scalar",
|
|
233
358
|
schema: { type: "string", format: "date-time" },
|
|
234
359
|
matches(e) {
|
|
235
360
|
return e.type === "string" && e.format === "date-time";
|
|
236
361
|
},
|
|
237
|
-
|
|
362
|
+
ownsValue(e) {
|
|
363
|
+
return e instanceof Date;
|
|
364
|
+
},
|
|
365
|
+
encode(e, t, n) {
|
|
238
366
|
return e.toISOString();
|
|
239
367
|
},
|
|
240
|
-
decode(e, t,
|
|
368
|
+
decode(e, t, n) {
|
|
241
369
|
if (typeof e != "string") {
|
|
242
|
-
if (
|
|
370
|
+
if (n.mode === "strict")
|
|
243
371
|
throw new TypeError(
|
|
244
|
-
`[date-time] expected a string on the wire at "${
|
|
372
|
+
`[date-time] expected a string on the wire at "${n.path}", got ${typeof e}`
|
|
245
373
|
);
|
|
246
374
|
return new Date(String(e));
|
|
247
375
|
}
|
|
248
|
-
if (
|
|
376
|
+
if (n.mode === "strict" && Number.isNaN(new Date(e).getTime()))
|
|
249
377
|
throw new TypeError(
|
|
250
|
-
`[date-time] invalid date-time string at "${
|
|
378
|
+
`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`
|
|
251
379
|
);
|
|
252
380
|
return new Date(e);
|
|
253
381
|
}
|
|
254
|
-
},
|
|
382
|
+
}, K = {
|
|
255
383
|
id: "int64",
|
|
256
384
|
kind: "scalar",
|
|
257
385
|
schema: { type: "string", format: "int64" },
|
|
258
386
|
matches(e) {
|
|
259
387
|
return e.type === "string" && e.format === "int64";
|
|
260
388
|
},
|
|
261
|
-
|
|
389
|
+
ownsValue(e) {
|
|
390
|
+
return typeof e == "bigint";
|
|
391
|
+
},
|
|
392
|
+
encode(e, t, n) {
|
|
262
393
|
return String(e);
|
|
263
394
|
},
|
|
264
|
-
decode(e, t,
|
|
395
|
+
decode(e, t, n) {
|
|
265
396
|
if (typeof e != "string") {
|
|
266
|
-
if (
|
|
397
|
+
if (n.mode === "strict")
|
|
267
398
|
throw new TypeError(
|
|
268
|
-
`[int64] expected a string on the wire at "${
|
|
399
|
+
`[int64] expected a string on the wire at "${n.path}", got ${typeof e}`
|
|
269
400
|
);
|
|
270
401
|
try {
|
|
271
402
|
return BigInt(Math.trunc(Number(e)));
|
|
@@ -273,7 +404,7 @@ const B = {
|
|
|
273
404
|
return BigInt(0);
|
|
274
405
|
}
|
|
275
406
|
}
|
|
276
|
-
if (
|
|
407
|
+
if (n.mode === "strict")
|
|
277
408
|
return BigInt(e);
|
|
278
409
|
if (/^-?\d+$/.test(e))
|
|
279
410
|
try {
|
|
@@ -283,176 +414,296 @@ const B = {
|
|
|
283
414
|
}
|
|
284
415
|
return BigInt(0);
|
|
285
416
|
}
|
|
286
|
-
},
|
|
417
|
+
}, z = {
|
|
287
418
|
id: "decimal",
|
|
288
419
|
kind: "scalar",
|
|
289
420
|
schema: { type: "string", format: "decimal" },
|
|
290
421
|
matches(e) {
|
|
291
422
|
return e.type === "string" && e.format === "decimal";
|
|
292
423
|
},
|
|
293
|
-
encode(e, t,
|
|
424
|
+
encode(e, t, n) {
|
|
294
425
|
return e;
|
|
295
426
|
},
|
|
296
|
-
decode(e, t,
|
|
427
|
+
decode(e, t, n) {
|
|
297
428
|
if (typeof e != "string") {
|
|
298
|
-
if (
|
|
429
|
+
if (n.mode === "strict")
|
|
299
430
|
throw new TypeError(
|
|
300
|
-
`[decimal] expected a string on the wire at "${
|
|
431
|
+
`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`
|
|
301
432
|
);
|
|
302
433
|
return String(e);
|
|
303
434
|
}
|
|
304
|
-
if (
|
|
435
|
+
if (n.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e))
|
|
305
436
|
throw new TypeError(
|
|
306
|
-
`[decimal] wire value "${e}" at "${
|
|
437
|
+
`[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`
|
|
307
438
|
);
|
|
308
439
|
return e;
|
|
309
440
|
}
|
|
310
|
-
},
|
|
441
|
+
}, J = {
|
|
311
442
|
id: "byte",
|
|
312
443
|
kind: "scalar",
|
|
313
444
|
schema: { type: "string", format: "byte" },
|
|
314
445
|
matches(e) {
|
|
315
446
|
return e.type === "string" && e.format === "byte";
|
|
316
447
|
},
|
|
317
|
-
|
|
448
|
+
ownsValue(e) {
|
|
449
|
+
return e instanceof Uint8Array;
|
|
450
|
+
},
|
|
451
|
+
encode(e, t, n) {
|
|
318
452
|
return Buffer.from(e).toString("base64");
|
|
319
453
|
},
|
|
320
|
-
decode(e, t,
|
|
454
|
+
decode(e, t, n) {
|
|
321
455
|
if (typeof e != "string") {
|
|
322
|
-
if (
|
|
456
|
+
if (n.mode === "strict")
|
|
323
457
|
throw new TypeError(
|
|
324
|
-
`[byte] expected a base64 string on the wire at "${
|
|
458
|
+
`[byte] expected a base64 string on the wire at "${n.path}", got ${typeof e}`
|
|
325
459
|
);
|
|
326
460
|
return new Uint8Array(0);
|
|
327
461
|
}
|
|
328
|
-
if (
|
|
462
|
+
if (n.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e))
|
|
329
463
|
throw new TypeError(
|
|
330
|
-
`[byte] wire value at "${
|
|
464
|
+
`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${e}"`
|
|
331
465
|
);
|
|
332
466
|
return new Uint8Array(Buffer.from(e, "base64"));
|
|
333
467
|
}
|
|
334
|
-
},
|
|
468
|
+
}, Te = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, W = {
|
|
335
469
|
id: "uuid",
|
|
336
470
|
kind: "scalar",
|
|
337
471
|
schema: { type: "string", format: "uuid" },
|
|
338
472
|
matches(e) {
|
|
339
473
|
return e.type === "string" && e.format === "uuid";
|
|
340
474
|
},
|
|
341
|
-
encode(e, t,
|
|
475
|
+
encode(e, t, n) {
|
|
342
476
|
return e.toLowerCase();
|
|
343
477
|
},
|
|
344
|
-
decode(e, t,
|
|
478
|
+
decode(e, t, n) {
|
|
345
479
|
if (typeof e != "string") {
|
|
346
|
-
if (
|
|
480
|
+
if (n.mode === "strict")
|
|
347
481
|
throw new TypeError(
|
|
348
|
-
`[uuid] expected a string on the wire at "${
|
|
482
|
+
`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`
|
|
349
483
|
);
|
|
350
484
|
return String(e).toLowerCase();
|
|
351
485
|
}
|
|
352
|
-
if (
|
|
486
|
+
if (n.mode === "strict" && !Te.test(e))
|
|
353
487
|
throw new TypeError(
|
|
354
|
-
`[uuid] wire value "${e}" at "${
|
|
488
|
+
`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`
|
|
355
489
|
);
|
|
356
490
|
return e;
|
|
357
491
|
}
|
|
358
|
-
},
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
]),
|
|
492
|
+
}, U = "NaN", R = "Infinity", L = "-Infinity", Pe = /* @__PURE__ */ new Set([
|
|
493
|
+
U,
|
|
494
|
+
R,
|
|
495
|
+
L
|
|
496
|
+
]), G = {
|
|
363
497
|
id: "number-special",
|
|
364
498
|
kind: "scalar",
|
|
365
499
|
schema: { type: "number" },
|
|
366
500
|
matches(e) {
|
|
367
501
|
return e.type === "number" && e.format === void 0;
|
|
368
502
|
},
|
|
369
|
-
|
|
370
|
-
return
|
|
503
|
+
ownsValue(e) {
|
|
504
|
+
return typeof e == "number" && !Number.isFinite(e);
|
|
505
|
+
},
|
|
506
|
+
encode(e, t, n) {
|
|
507
|
+
return Number.isNaN(e) ? U : e === 1 / 0 ? R : e === -1 / 0 ? L : e;
|
|
371
508
|
},
|
|
372
|
-
decode(e, t,
|
|
509
|
+
decode(e, t, n) {
|
|
373
510
|
if (typeof e == "number")
|
|
374
511
|
return e;
|
|
375
512
|
if (typeof e == "string") {
|
|
376
|
-
if (e ===
|
|
513
|
+
if (e === U)
|
|
377
514
|
return NaN;
|
|
378
|
-
if (e ===
|
|
515
|
+
if (e === R)
|
|
379
516
|
return 1 / 0;
|
|
380
|
-
if (e ===
|
|
517
|
+
if (e === L)
|
|
381
518
|
return -1 / 0;
|
|
382
|
-
const
|
|
383
|
-
if (!Number.isNaN(
|
|
384
|
-
return
|
|
519
|
+
const r = Number(e);
|
|
520
|
+
if (!Number.isNaN(r))
|
|
521
|
+
return r;
|
|
385
522
|
}
|
|
386
|
-
if (
|
|
523
|
+
if (n.mode === "strict")
|
|
387
524
|
throw new TypeError(
|
|
388
|
-
`[number-special] unrecognized wire value at "${
|
|
525
|
+
`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...Pe].join(", ")}.`
|
|
389
526
|
);
|
|
390
527
|
return NaN;
|
|
391
528
|
}
|
|
392
|
-
},
|
|
393
|
-
B,
|
|
394
|
-
F,
|
|
395
|
-
K,
|
|
529
|
+
}, De = [
|
|
396
530
|
H,
|
|
397
|
-
|
|
398
|
-
z
|
|
531
|
+
K,
|
|
532
|
+
z,
|
|
533
|
+
J,
|
|
534
|
+
W,
|
|
535
|
+
G
|
|
399
536
|
];
|
|
400
|
-
function
|
|
401
|
-
for (const
|
|
402
|
-
e.register(
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
537
|
+
function Ue(e, t = {}) {
|
|
538
|
+
for (const n of De)
|
|
539
|
+
e.register(n, { override: t.override ?? !1 });
|
|
540
|
+
}
|
|
541
|
+
const Re = 12;
|
|
542
|
+
function Le(e, t) {
|
|
543
|
+
const n = /^#\/(definitions|\$defs)\/(.+)$/.exec(e);
|
|
544
|
+
if (!n)
|
|
545
|
+
return;
|
|
546
|
+
const [, r, o] = n, i = r === "$defs" ? t.$defs : t.definitions;
|
|
547
|
+
return i == null ? void 0 : i[decodeURIComponent(o)];
|
|
548
|
+
}
|
|
549
|
+
function ee(e) {
|
|
550
|
+
return Array.isArray(e) && e.length > 0 ? e[0] : void 0;
|
|
551
|
+
}
|
|
552
|
+
function Be(e) {
|
|
553
|
+
if (Array.isArray(e.type))
|
|
554
|
+
return e.type.find((t) => t !== "null") ?? e.type[0];
|
|
555
|
+
if (typeof e.type == "string")
|
|
556
|
+
return e.type;
|
|
557
|
+
if (e.properties)
|
|
558
|
+
return "object";
|
|
559
|
+
}
|
|
560
|
+
function qe(e) {
|
|
561
|
+
switch (e.format) {
|
|
562
|
+
case "date-time":
|
|
563
|
+
return "1970-01-01T00:00:00.000Z";
|
|
564
|
+
case "date":
|
|
565
|
+
return "1970-01-01";
|
|
566
|
+
case "time":
|
|
567
|
+
return "00:00:00Z";
|
|
568
|
+
case "uuid":
|
|
569
|
+
return "00000000-0000-0000-0000-000000000000";
|
|
570
|
+
case "email":
|
|
571
|
+
return "user@example.com";
|
|
572
|
+
case "uri":
|
|
573
|
+
case "url":
|
|
574
|
+
case "uri-reference":
|
|
575
|
+
return "https://example.com";
|
|
576
|
+
case "hostname":
|
|
577
|
+
return "example.com";
|
|
578
|
+
case "ipv4":
|
|
579
|
+
return "127.0.0.1";
|
|
580
|
+
case "ipv6":
|
|
581
|
+
return "::1";
|
|
582
|
+
case "decimal":
|
|
583
|
+
return "0";
|
|
584
|
+
case "int64":
|
|
585
|
+
return "0";
|
|
586
|
+
case "byte":
|
|
587
|
+
return "";
|
|
588
|
+
default:
|
|
589
|
+
return "<string>";
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function te(e, t, n) {
|
|
593
|
+
const r = e.properties ?? {}, o = e.required ?? [], i = {};
|
|
594
|
+
for (const s of o) {
|
|
595
|
+
const a = r[s];
|
|
596
|
+
i[s] = a !== void 0 ? j(a, t, n + 1) : `<${s}>`;
|
|
597
|
+
}
|
|
598
|
+
return i;
|
|
599
|
+
}
|
|
600
|
+
function Fe(e, t, n) {
|
|
601
|
+
const r = Array.isArray(e.items) ? e.items[0] : e.items;
|
|
602
|
+
return r ? [j(r, t, n + 1)] : [];
|
|
603
|
+
}
|
|
604
|
+
function j(e, t = e ?? {}, n = 0) {
|
|
605
|
+
if (!e || n > Re)
|
|
606
|
+
return null;
|
|
607
|
+
if (typeof e.$ref == "string") {
|
|
608
|
+
const o = Le(e.$ref, t);
|
|
609
|
+
return o !== void 0 ? j(o, t, n + 1) : null;
|
|
610
|
+
}
|
|
611
|
+
if (e.const !== void 0)
|
|
612
|
+
return e.const;
|
|
613
|
+
if (Array.isArray(e.enum) && e.enum.length > 0)
|
|
614
|
+
return e.enum[0];
|
|
615
|
+
if (Array.isArray(e.allOf) && e.allOf.length > 0) {
|
|
616
|
+
const o = {}, i = [];
|
|
617
|
+
for (const s of e.allOf) {
|
|
618
|
+
Object.assign(o, s.properties ?? {});
|
|
619
|
+
for (const a of s.required ?? [])
|
|
620
|
+
i.includes(a) || i.push(a);
|
|
621
|
+
}
|
|
622
|
+
return te(
|
|
623
|
+
{ ...e, properties: o, required: i },
|
|
624
|
+
t,
|
|
625
|
+
n
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
const r = ee(e.oneOf) ?? ee(e.anyOf);
|
|
629
|
+
if (r)
|
|
630
|
+
return j(r, t, n + 1);
|
|
631
|
+
switch (Be(e)) {
|
|
632
|
+
case "object":
|
|
633
|
+
return te(e, t, n);
|
|
634
|
+
case "array":
|
|
635
|
+
return Fe(e, t, n);
|
|
636
|
+
case "string":
|
|
637
|
+
return qe(e);
|
|
638
|
+
case "integer":
|
|
639
|
+
case "number":
|
|
640
|
+
return 0;
|
|
641
|
+
case "boolean":
|
|
642
|
+
return !1;
|
|
643
|
+
case "null":
|
|
644
|
+
return null;
|
|
645
|
+
default:
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function ve(e) {
|
|
650
|
+
if (!e)
|
|
651
|
+
return;
|
|
652
|
+
const t = j(e);
|
|
653
|
+
return `Example: ${JSON.stringify(t)}`;
|
|
654
|
+
}
|
|
655
|
+
H.id, // 'date-time'
|
|
656
|
+
K.id, // 'int64'
|
|
657
|
+
z.id, // 'decimal'
|
|
658
|
+
J.id, // 'byte'
|
|
659
|
+
W.id, // 'uuid'
|
|
660
|
+
G.id;
|
|
661
|
+
const $e = Ie();
|
|
662
|
+
Ue($e);
|
|
663
|
+
const Ae = Me($e.freeze());
|
|
664
|
+
function Ve(e, t) {
|
|
665
|
+
var r;
|
|
666
|
+
const n = ((r = e.input) == null ? void 0 : r.properties) ?? {};
|
|
667
|
+
return t in n;
|
|
668
|
+
}
|
|
669
|
+
function He(e) {
|
|
670
|
+
var n, r;
|
|
671
|
+
const t = (r = (n = e.input) == null ? void 0 : n.properties) == null ? void 0 : r.data;
|
|
421
672
|
return Object.keys((t == null ? void 0 : t.properties) ?? {});
|
|
422
673
|
}
|
|
423
|
-
function
|
|
674
|
+
function Ke(e, t) {
|
|
424
675
|
var o, i, s;
|
|
425
|
-
const
|
|
426
|
-
return
|
|
676
|
+
const n = (s = (i = (o = e.input) == null ? void 0 : o.properties) == null ? void 0 : i.data) == null ? void 0 : s.properties, r = n == null ? void 0 : n[t];
|
|
677
|
+
return r !== void 0 ? r : void 0;
|
|
427
678
|
}
|
|
428
|
-
function
|
|
429
|
-
return t === void 0 || e === void 0 ? e :
|
|
679
|
+
function ze(e, t) {
|
|
680
|
+
return t === void 0 || e === void 0 ? e : Ae.decode(e, t);
|
|
430
681
|
}
|
|
431
|
-
function
|
|
432
|
-
const
|
|
433
|
-
return !
|
|
682
|
+
function C(e, t) {
|
|
683
|
+
const n = t.output;
|
|
684
|
+
return !n || Object.keys(n).length === 0 ? e : Ae.encode(e, n);
|
|
434
685
|
}
|
|
435
|
-
async function
|
|
436
|
-
const a =
|
|
437
|
-
(
|
|
686
|
+
async function Je(e, t, n, r, o, i) {
|
|
687
|
+
const a = He(n).map(
|
|
688
|
+
(u) => ze(i[u], Ke(n, u))
|
|
438
689
|
);
|
|
439
|
-
if (
|
|
440
|
-
const
|
|
441
|
-
return
|
|
690
|
+
if (Ve(n, "session") && t) {
|
|
691
|
+
const u = await t({ session: o.session }), c = await e[r](u, ...a);
|
|
692
|
+
return C(c, n);
|
|
442
693
|
}
|
|
443
|
-
if (
|
|
444
|
-
const
|
|
445
|
-
return
|
|
694
|
+
if (n.hasCtx) {
|
|
695
|
+
const u = t ? await t(o) : void 0, c = await e[r](u, ...a);
|
|
696
|
+
return C(c, n);
|
|
446
697
|
}
|
|
447
|
-
const f = await e[
|
|
448
|
-
return
|
|
698
|
+
const f = await e[r](...a);
|
|
699
|
+
return C(f, n);
|
|
449
700
|
}
|
|
450
|
-
class
|
|
701
|
+
class We {
|
|
451
702
|
constructor() {
|
|
452
703
|
this._map = /* @__PURE__ */ new Map();
|
|
453
704
|
}
|
|
454
|
-
set(t,
|
|
455
|
-
this._map.set(t,
|
|
705
|
+
set(t, n) {
|
|
706
|
+
this._map.set(t, n);
|
|
456
707
|
}
|
|
457
708
|
get(t) {
|
|
458
709
|
return this._map.get(t);
|
|
@@ -462,31 +713,31 @@ class xe {
|
|
|
462
713
|
return this._map.has(t);
|
|
463
714
|
}
|
|
464
715
|
}
|
|
465
|
-
function
|
|
466
|
-
return async function(
|
|
467
|
-
const i = o.schemas[
|
|
716
|
+
function Ge(e = []) {
|
|
717
|
+
return async function(n, r, o) {
|
|
718
|
+
const i = o.schemas[n];
|
|
468
719
|
if (!i)
|
|
469
720
|
throw new Error(
|
|
470
|
-
`apigen/invoke: no schema found for operation "${
|
|
721
|
+
`apigen/invoke: no schema found for operation "${n}"`
|
|
471
722
|
);
|
|
472
|
-
const s = () =>
|
|
723
|
+
const s = () => Je(
|
|
473
724
|
o.fns,
|
|
474
725
|
o.createClient,
|
|
475
726
|
i,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
727
|
+
n,
|
|
728
|
+
r.envelope,
|
|
729
|
+
r.domainArgs
|
|
479
730
|
);
|
|
480
731
|
return e.reduceRight(
|
|
481
|
-
(f,
|
|
732
|
+
(f, u) => () => u(r, f),
|
|
482
733
|
s
|
|
483
734
|
)();
|
|
484
735
|
};
|
|
485
736
|
}
|
|
486
|
-
function
|
|
737
|
+
function ln(e) {
|
|
487
738
|
return e;
|
|
488
739
|
}
|
|
489
|
-
class
|
|
740
|
+
class Ye {
|
|
490
741
|
constructor() {
|
|
491
742
|
this.handlers = /* @__PURE__ */ new Map();
|
|
492
743
|
}
|
|
@@ -495,16 +746,16 @@ class Te {
|
|
|
495
746
|
* per-request/per-package MUST be removed (via the returned fn, {@link off},
|
|
496
747
|
* or {@link clear}) or they accumulate for the bus's lifetime.
|
|
497
748
|
*/
|
|
498
|
-
on(t,
|
|
499
|
-
const
|
|
500
|
-
return this.handlers.set(t, [...
|
|
749
|
+
on(t, n) {
|
|
750
|
+
const r = this.handlers.get(t) ?? [];
|
|
751
|
+
return this.handlers.set(t, [...r, n]), () => this.off(t, n);
|
|
501
752
|
}
|
|
502
753
|
/** Remove a previously registered handler (no-op if absent). */
|
|
503
|
-
off(t,
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
754
|
+
off(t, n) {
|
|
755
|
+
const r = this.handlers.get(t);
|
|
756
|
+
if (!r)
|
|
506
757
|
return;
|
|
507
|
-
const o =
|
|
758
|
+
const o = r.filter((i) => i !== n);
|
|
508
759
|
o.length === 0 ? this.handlers.delete(t) : this.handlers.set(t, o);
|
|
509
760
|
}
|
|
510
761
|
/** Remove every handler — call on package/server teardown. */
|
|
@@ -512,115 +763,116 @@ class Te {
|
|
|
512
763
|
this.handlers.clear();
|
|
513
764
|
}
|
|
514
765
|
async emit(t) {
|
|
515
|
-
for (const [
|
|
516
|
-
if (
|
|
517
|
-
for (const o of
|
|
766
|
+
for (const [n, r] of this.handlers)
|
|
767
|
+
if (Ze(n, t))
|
|
768
|
+
for (const o of r)
|
|
518
769
|
await o(t);
|
|
519
770
|
}
|
|
520
771
|
}
|
|
521
|
-
function
|
|
522
|
-
const [
|
|
523
|
-
return !(
|
|
772
|
+
function Ze(e, t) {
|
|
773
|
+
const [n, r, o] = e.split(":");
|
|
774
|
+
return !(n !== "*" && n !== t.module || r && r !== "*" && r !== t.method || o && o !== "*" && o !== t.lifecycle);
|
|
524
775
|
}
|
|
525
|
-
function
|
|
526
|
-
for (const
|
|
527
|
-
if (
|
|
528
|
-
for (const [
|
|
529
|
-
t.on(
|
|
776
|
+
function Qe(e, t) {
|
|
777
|
+
for (const n of e)
|
|
778
|
+
if (n.eventMapping)
|
|
779
|
+
for (const [r, o] of Object.entries(n.eventMapping))
|
|
780
|
+
t.on(r, o);
|
|
530
781
|
}
|
|
531
|
-
async function
|
|
532
|
-
let
|
|
782
|
+
async function Xe(e, t, n) {
|
|
783
|
+
let r = { ...t };
|
|
533
784
|
for (const o of e)
|
|
534
785
|
if (o.createContext) {
|
|
535
|
-
await
|
|
786
|
+
await n.emit({
|
|
536
787
|
module: o.id,
|
|
537
788
|
method: "createContext",
|
|
538
789
|
lifecycle: "start",
|
|
539
|
-
ctx:
|
|
790
|
+
ctx: r
|
|
540
791
|
});
|
|
541
792
|
try {
|
|
542
|
-
const i = await o.createContext(
|
|
543
|
-
|
|
793
|
+
const i = await o.createContext(r);
|
|
794
|
+
r = { ...r, ...i }, await n.emit({
|
|
544
795
|
module: o.id,
|
|
545
796
|
method: "createContext",
|
|
546
797
|
lifecycle: "complete",
|
|
547
|
-
ctx:
|
|
798
|
+
ctx: r
|
|
548
799
|
});
|
|
549
800
|
} catch (i) {
|
|
550
|
-
throw await
|
|
801
|
+
throw await n.emit({
|
|
551
802
|
module: o.id,
|
|
552
803
|
method: "createContext",
|
|
553
804
|
lifecycle: "error",
|
|
554
|
-
ctx:
|
|
805
|
+
ctx: r,
|
|
555
806
|
error: i
|
|
556
807
|
}), i;
|
|
557
808
|
}
|
|
558
809
|
}
|
|
559
|
-
return
|
|
810
|
+
return r;
|
|
560
811
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
812
|
+
he(import.meta.url);
|
|
813
|
+
function ne(e, t) {
|
|
814
|
+
const n = /* @__PURE__ */ new Set(), r = [e];
|
|
815
|
+
for (; r.length > 0; ) {
|
|
816
|
+
const o = r.pop();
|
|
817
|
+
if (!o || n.has(o))
|
|
566
818
|
continue;
|
|
567
|
-
|
|
819
|
+
n.add(o);
|
|
568
820
|
const i = o.$ref;
|
|
569
821
|
if (typeof i == "string") {
|
|
570
822
|
if (t) {
|
|
571
|
-
const
|
|
572
|
-
if (!
|
|
573
|
-
const
|
|
823
|
+
const l = t[i];
|
|
824
|
+
if (!l) {
|
|
825
|
+
const p = Object.keys(t).join(", ") || "(none)";
|
|
574
826
|
throw new Error(
|
|
575
|
-
`[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${
|
|
827
|
+
`[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${p}`
|
|
576
828
|
);
|
|
577
829
|
}
|
|
578
|
-
|
|
830
|
+
r.push(l);
|
|
579
831
|
}
|
|
580
832
|
continue;
|
|
581
833
|
}
|
|
582
834
|
const s = o.oneOf;
|
|
583
835
|
if (Array.isArray(s))
|
|
584
|
-
for (const
|
|
585
|
-
typeof
|
|
836
|
+
for (const l of s)
|
|
837
|
+
typeof l == "object" && l !== null && r.push(l);
|
|
586
838
|
const a = o.properties;
|
|
587
839
|
if (a)
|
|
588
|
-
for (const
|
|
589
|
-
|
|
840
|
+
for (const l of Object.values(a))
|
|
841
|
+
r.push(l);
|
|
590
842
|
const f = o.items;
|
|
591
843
|
if (Array.isArray(f))
|
|
592
|
-
for (const
|
|
593
|
-
typeof
|
|
844
|
+
for (const l of f)
|
|
845
|
+
typeof l == "object" && l !== null && r.push(l);
|
|
594
846
|
else
|
|
595
|
-
typeof f == "object" && f !== null &&
|
|
596
|
-
const
|
|
597
|
-
typeof
|
|
598
|
-
const
|
|
599
|
-
typeof
|
|
847
|
+
typeof f == "object" && f !== null && r.push(f);
|
|
848
|
+
const u = o.additionalProperties;
|
|
849
|
+
typeof u == "object" && u !== null && r.push(u);
|
|
850
|
+
const c = o.propertyNames;
|
|
851
|
+
typeof c == "object" && c !== null && r.push(c);
|
|
600
852
|
}
|
|
601
853
|
}
|
|
602
|
-
const
|
|
603
|
-
function
|
|
854
|
+
const re = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
|
|
855
|
+
function et(e) {
|
|
604
856
|
if (typeof e != "object" || e === null)
|
|
605
857
|
return !1;
|
|
606
858
|
const t = e;
|
|
607
859
|
if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf)
|
|
608
860
|
return !1;
|
|
609
|
-
const { type:
|
|
610
|
-
return typeof
|
|
861
|
+
const { type: n } = t;
|
|
862
|
+
return typeof n == "string" ? re.has(n) : Array.isArray(n) ? n.every((r) => re.has(r) || r === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((r) => ["string", "number", "boolean"].includes(typeof r)) : !1;
|
|
611
863
|
}
|
|
612
|
-
function
|
|
864
|
+
function tt(e) {
|
|
613
865
|
if (!e || typeof e != "object")
|
|
614
866
|
return !1;
|
|
615
867
|
const t = e.properties;
|
|
616
868
|
return t === void 0 || typeof t != "object" || t === null ? !1 : Object.values(t).every(
|
|
617
|
-
|
|
869
|
+
et
|
|
618
870
|
);
|
|
619
871
|
}
|
|
620
|
-
function
|
|
621
|
-
const t = {},
|
|
872
|
+
function nt(e) {
|
|
873
|
+
const t = {}, n = (r) => {
|
|
622
874
|
for (const o of ["definitions", "$defs"]) {
|
|
623
|
-
const i =
|
|
875
|
+
const i = r[o];
|
|
624
876
|
if (i)
|
|
625
877
|
for (const [s, a] of Object.entries(i)) {
|
|
626
878
|
const f = s.startsWith("#/") ? s : `#/${o}/${s}`;
|
|
@@ -628,80 +880,80 @@ function Be(e) {
|
|
|
628
880
|
}
|
|
629
881
|
}
|
|
630
882
|
};
|
|
631
|
-
for (const
|
|
632
|
-
r
|
|
883
|
+
for (const r of Object.values(e.schemas))
|
|
884
|
+
n(r.input), n(r.output);
|
|
633
885
|
if (Object.keys(t).length !== 0)
|
|
634
|
-
for (const [
|
|
886
|
+
for (const [r, o] of Object.entries(e.schemas))
|
|
635
887
|
try {
|
|
636
|
-
|
|
888
|
+
ne(o.input, t), ne(o.output, t);
|
|
637
889
|
} catch (i) {
|
|
638
890
|
throw new Error(
|
|
639
|
-
`[apigen-core-client] Schema validation failed for function "${
|
|
891
|
+
`[apigen-core-client] Schema validation failed for function "${r}": ${i.message}`
|
|
640
892
|
);
|
|
641
893
|
}
|
|
642
894
|
}
|
|
643
|
-
function
|
|
644
|
-
const
|
|
895
|
+
function rt(e, t) {
|
|
896
|
+
const n = [
|
|
645
897
|
'apigen calling convention: all domain parameters go inside a "data" envelope — e.g. { "data": { ... } }' + (t ? "." : " (an empty object for this zero-parameter tool).")
|
|
646
898
|
];
|
|
647
|
-
return e.length > 0 &&
|
|
648
|
-
`Field(s) ${e.map((
|
|
649
|
-
),
|
|
899
|
+
return e.length > 0 && n.push(
|
|
900
|
+
`Field(s) ${e.map((r) => `"${r}"`).join(", ")} are transport-level envelope metadata, NOT domain data — do not nest them under "data". Over MCP they are read from arguments._meta["x-<pluginId>-<field>"] (default pluginId "adhd"); see @adhd/apigen-engine-naming's envelopeMetaKey/envelopeCliFlag/envelopeEnvVar for the HTTP-header / CLI-flag / env-var equivalents.`
|
|
901
|
+
), n.join(" ");
|
|
650
902
|
}
|
|
651
|
-
function
|
|
652
|
-
|
|
653
|
-
const
|
|
903
|
+
function ot(e, t, n) {
|
|
904
|
+
nt(e);
|
|
905
|
+
const r = {};
|
|
654
906
|
for (const [o, i] of Object.entries(e.schemas)) {
|
|
655
|
-
const s = (
|
|
907
|
+
const s = (n == null ? void 0 : n[o]) ?? {}, a = i.input.properties ?? {}, f = i.input.required ?? [], u = {}, c = [], l = {};
|
|
656
908
|
for (const h of t)
|
|
657
909
|
if (h.envelope && s[h.id] !== !1)
|
|
658
|
-
for (const [b,
|
|
659
|
-
|
|
660
|
-
const
|
|
910
|
+
for (const [b, Ee] of Object.entries(h.envelope))
|
|
911
|
+
u[b] = Ee, l[b] = h.id, c.includes(b) || c.push(b);
|
|
912
|
+
const p = {
|
|
661
913
|
type: "object",
|
|
662
914
|
properties: a,
|
|
663
915
|
additionalProperties: !1,
|
|
664
916
|
...f.length > 0 ? { required: f } : {}
|
|
665
|
-
},
|
|
666
|
-
|
|
917
|
+
}, y = i.safe === !0 || tt(i.input), d = i.input.definitions, m = i.input.$defs;
|
|
918
|
+
r[o] = {
|
|
667
919
|
input: {
|
|
668
920
|
type: "object",
|
|
669
|
-
properties: { ...
|
|
921
|
+
properties: { ...u, data: p },
|
|
670
922
|
required: [
|
|
671
|
-
...
|
|
923
|
+
...c,
|
|
672
924
|
...f.length > 0 ? ["data"] : []
|
|
673
925
|
],
|
|
674
926
|
// BUG-APIGEN-017: reject any property that isn't a declared envelope
|
|
675
927
|
// field or the "data" wrapper — no silently-ignored junk params.
|
|
676
928
|
additionalProperties: !1,
|
|
677
929
|
// BUG-APIGEN-020: document the envelope/data calling convention inline.
|
|
678
|
-
description:
|
|
679
|
-
Object.keys(
|
|
930
|
+
description: rt(
|
|
931
|
+
Object.keys(u),
|
|
680
932
|
Object.keys(a).length > 0
|
|
681
933
|
),
|
|
682
|
-
...
|
|
683
|
-
...
|
|
934
|
+
...d ? { definitions: d } : {},
|
|
935
|
+
...m ? { $defs: m } : {}
|
|
684
936
|
},
|
|
685
937
|
output: i.output,
|
|
686
938
|
// Carry the ctx-param flag through to dispatch (BUG-APIGEN-001).
|
|
687
939
|
...i.hasCtx ? { hasCtx: !0 } : {},
|
|
688
|
-
"x-apigen-safe":
|
|
940
|
+
"x-apigen-safe": y,
|
|
689
941
|
// DEBT-APIGEN-ENVELOPE-CAPABILITY-UNWIRED-001: field → pluginId map,
|
|
690
942
|
// read by `op-plan.ts`'s `computeEnvelopeFields`. Omitted (not an empty
|
|
691
943
|
// object) when no middleware contributed an envelope field, matching
|
|
692
944
|
// `x-apigen-safe`'s own "absent means nothing to report" convention.
|
|
693
|
-
...Object.keys(
|
|
945
|
+
...Object.keys(l).length > 0 ? { "x-apigen-envelope": l } : {}
|
|
694
946
|
};
|
|
695
947
|
}
|
|
696
|
-
return
|
|
948
|
+
return r;
|
|
697
949
|
}
|
|
698
|
-
const
|
|
950
|
+
const it = {
|
|
699
951
|
"decimal.js": "Decimal"
|
|
700
952
|
};
|
|
701
|
-
function
|
|
953
|
+
function st(e) {
|
|
702
954
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
703
955
|
}
|
|
704
|
-
Object.entries(
|
|
956
|
+
Object.entries(it).map(([e, t]) => ({
|
|
705
957
|
// Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
|
|
706
958
|
// The module specifier appears inside an absolute path, so we allow any
|
|
707
959
|
// characters between the quote and the specifier, and between the specifier
|
|
@@ -709,127 +961,155 @@ Object.entries(He).map(([e, t]) => ({
|
|
|
709
961
|
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
710
962
|
// see the doc comment above for why.
|
|
711
963
|
pattern: new RegExp(
|
|
712
|
-
`import\\(["'][^"']*${
|
|
964
|
+
`import\\(["'][^"']*${st(e)}[^"']*["']\\)\\.\\w+`,
|
|
713
965
|
"g"
|
|
714
966
|
),
|
|
715
967
|
key: t
|
|
716
968
|
}));
|
|
717
|
-
class
|
|
969
|
+
class B extends Error {
|
|
718
970
|
constructor(t) {
|
|
719
971
|
super(t), this.name = "ConfigurationError";
|
|
720
972
|
}
|
|
721
973
|
}
|
|
722
|
-
function
|
|
974
|
+
function at(e) {
|
|
723
975
|
for (const t of e)
|
|
724
|
-
for (const
|
|
725
|
-
const [
|
|
726
|
-
if (
|
|
727
|
-
throw new
|
|
728
|
-
`Middleware "${t.id}" subscribes to its own events via "${
|
|
976
|
+
for (const n of Object.keys(t.eventMapping ?? {})) {
|
|
977
|
+
const [r] = n.split(":");
|
|
978
|
+
if (r !== "*" && r === t.id)
|
|
979
|
+
throw new B(
|
|
980
|
+
`Middleware "${t.id}" subscribes to its own events via "${n}". This would cause infinite recursion.`
|
|
729
981
|
);
|
|
730
982
|
}
|
|
731
983
|
}
|
|
732
|
-
function
|
|
984
|
+
function pn(e) {
|
|
733
985
|
const {
|
|
734
986
|
domainSchemas: t,
|
|
735
|
-
middlewares:
|
|
736
|
-
overrides:
|
|
987
|
+
middlewares: n,
|
|
988
|
+
overrides: r = {},
|
|
737
989
|
strict: o = !1
|
|
738
990
|
} = e;
|
|
739
|
-
|
|
740
|
-
for (const
|
|
741
|
-
if (!(
|
|
742
|
-
const
|
|
991
|
+
at(n);
|
|
992
|
+
for (const u of Object.keys(r))
|
|
993
|
+
if (!(u in t.schemas)) {
|
|
994
|
+
const c = `Override key "${u}" not found in domain schemas.`;
|
|
743
995
|
if (o)
|
|
744
|
-
throw new
|
|
745
|
-
console.warn("[apigen-runtime]",
|
|
996
|
+
throw new B(c);
|
|
997
|
+
console.warn("[apigen-runtime]", c);
|
|
746
998
|
}
|
|
747
|
-
const i = new Set(
|
|
748
|
-
for (const [
|
|
749
|
-
for (const
|
|
750
|
-
if (!i.has(
|
|
751
|
-
const
|
|
999
|
+
const i = new Set(n.map((u) => u.id));
|
|
1000
|
+
for (const [u, c] of Object.entries(r))
|
|
1001
|
+
for (const l of Object.keys(c ?? {}))
|
|
1002
|
+
if (!i.has(l)) {
|
|
1003
|
+
const p = `Override key "${u}.${l}" does not match any declared middleware id.`;
|
|
752
1004
|
if (o)
|
|
753
|
-
throw new
|
|
754
|
-
console.warn("[apigen-runtime]",
|
|
1005
|
+
throw new B(p);
|
|
1006
|
+
console.warn("[apigen-runtime]", p);
|
|
755
1007
|
}
|
|
756
|
-
const s =
|
|
1008
|
+
const s = ot(
|
|
757
1009
|
t,
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
), a = new
|
|
761
|
-
return
|
|
1010
|
+
n,
|
|
1011
|
+
r
|
|
1012
|
+
), a = new Ye();
|
|
1013
|
+
return Qe(n, a), { schemas: s, createClient: async (u) => Xe(n, u, a), dispose: () => a.clear() };
|
|
762
1014
|
}
|
|
763
|
-
function
|
|
764
|
-
const t = e.level ?? "info",
|
|
1015
|
+
function dn(e = {}) {
|
|
1016
|
+
const t = e.level ?? "info", n = typeof e.destination == "string" && e.destination.length > 0, r = !n && !!process.stderr.isTTY, o = e.format ?? (r ? "pretty" : "json"), i = { level: t };
|
|
765
1017
|
if (o === "pretty")
|
|
766
1018
|
return i.transport = {
|
|
767
1019
|
target: "pino-pretty",
|
|
768
1020
|
options: {
|
|
769
|
-
colorize: !
|
|
1021
|
+
colorize: !n,
|
|
770
1022
|
translateTime: "SYS:HH:MM:ss.l",
|
|
771
1023
|
ignore: "pid,hostname",
|
|
772
|
-
...
|
|
1024
|
+
...n ? { destination: e.destination, mkdir: !0 } : { destination: 2 }
|
|
773
1025
|
}
|
|
774
1026
|
}, N(i);
|
|
775
|
-
const s =
|
|
1027
|
+
const s = n ? N.destination({ dest: e.destination, mkdir: !0, sync: !0 }) : N.destination(2);
|
|
776
1028
|
return N(i, s);
|
|
777
1029
|
}
|
|
778
|
-
function
|
|
779
|
-
|
|
1030
|
+
function ct(e) {
|
|
1031
|
+
if (!e || e.type !== "object" || !e.properties)
|
|
1032
|
+
return;
|
|
1033
|
+
const t = Object.entries(e.properties);
|
|
1034
|
+
if (t.length === 0)
|
|
1035
|
+
return;
|
|
1036
|
+
const n = new Set(e.required ?? []);
|
|
1037
|
+
return `{ ${t.map(([o, i]) => `${o}${n.has(o) ? "" : "?"}: ${k(i)}`).join(", ")} }`;
|
|
1038
|
+
}
|
|
1039
|
+
function ut(e) {
|
|
1040
|
+
return typeof e == "string" ? `'${e}'` : JSON.stringify(e);
|
|
1041
|
+
}
|
|
1042
|
+
function ft(e) {
|
|
1043
|
+
const t = e.enum ?? [];
|
|
1044
|
+
return t.length === 0 ? "unknown" : t.map(ut).join("|");
|
|
780
1045
|
}
|
|
781
|
-
function
|
|
1046
|
+
function lt(e, t) {
|
|
1047
|
+
return e.map((n) => k(n, t)).join(" | ");
|
|
1048
|
+
}
|
|
1049
|
+
function k(e, t = 0) {
|
|
1050
|
+
if (!e)
|
|
1051
|
+
return "unknown";
|
|
1052
|
+
if (e.type === "array")
|
|
1053
|
+
return `${k(e.items, 0)}[]`;
|
|
1054
|
+
if (e.enum)
|
|
1055
|
+
return ft(e);
|
|
1056
|
+
if (e.$ref)
|
|
1057
|
+
return String(e.$ref).split("/").pop() || "object";
|
|
1058
|
+
const n = e.anyOf ?? e.oneOf;
|
|
1059
|
+
return n ? n.length === 0 ? "unknown" : t >= 2 ? lt(n, t - 1) : "union" : t >= 1 && e.type === "object" ? ct(e) ?? "object" : e.type ?? "object";
|
|
1060
|
+
}
|
|
1061
|
+
function pt(e) {
|
|
782
1062
|
var a;
|
|
783
|
-
const
|
|
1063
|
+
const n = (a = ((e == null ? void 0 : e.input) ?? {}).properties) == null ? void 0 : a.data, r = (n == null ? void 0 : n.properties) ?? {}, o = new Set((n == null ? void 0 : n.required) ?? []), i = Object.entries(r).map(([f, u]) => ({
|
|
784
1064
|
name: f,
|
|
785
|
-
type:
|
|
1065
|
+
type: k(u, 2),
|
|
786
1066
|
required: o.has(f)
|
|
787
1067
|
})), s = i.map((f) => `${f.name}${f.required ? "" : "?"}: ${f.type}`).join(", ");
|
|
788
1068
|
return { params: i, text: s };
|
|
789
1069
|
}
|
|
790
|
-
function
|
|
1070
|
+
function dt(e) {
|
|
791
1071
|
let t;
|
|
792
|
-
return Array.isArray(e) ? t = e : e ? t = [e] : t = [], t.find((
|
|
1072
|
+
return Array.isArray(e) ? t = e : e ? t = [e] : t = [], t.find((n) => n === "number" || n === "integer" || n === "boolean");
|
|
793
1073
|
}
|
|
794
|
-
function
|
|
1074
|
+
function yn(e, t) {
|
|
795
1075
|
var i, s;
|
|
796
|
-
const
|
|
797
|
-
for (const [a, f] of Object.entries(
|
|
798
|
-
const
|
|
799
|
-
if (typeof
|
|
1076
|
+
const r = ((s = (i = ((t == null ? void 0 : t.input) ?? {}).properties) == null ? void 0 : i.data) == null ? void 0 : s.properties) ?? {}, o = { ...e };
|
|
1077
|
+
for (const [a, f] of Object.entries(r)) {
|
|
1078
|
+
const u = o[a];
|
|
1079
|
+
if (typeof u != "string")
|
|
800
1080
|
continue;
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
const
|
|
804
|
-
!Number.isNaN(
|
|
1081
|
+
const c = dt(f == null ? void 0 : f.type);
|
|
1082
|
+
if (c === "number" || c === "integer") {
|
|
1083
|
+
const l = Number(u);
|
|
1084
|
+
!Number.isNaN(l) && u.trim() !== "" && (o[a] = l);
|
|
805
1085
|
} else
|
|
806
|
-
|
|
1086
|
+
c === "boolean" && (u === "true" ? o[a] = !0 : u === "false" && (o[a] = !1));
|
|
807
1087
|
}
|
|
808
1088
|
return o;
|
|
809
1089
|
}
|
|
810
|
-
const
|
|
811
|
-
function
|
|
812
|
-
const t = {},
|
|
813
|
-
for (const [i, s] of Object.entries(
|
|
1090
|
+
const oe = /* @__PURE__ */ new Set(["default", "module.exports", "__esModule"]);
|
|
1091
|
+
function mn(e) {
|
|
1092
|
+
const t = {}, n = (r, o) => {
|
|
1093
|
+
for (const [i, s] of Object.entries(r))
|
|
814
1094
|
if (typeof s == "function") {
|
|
815
|
-
!
|
|
1095
|
+
!oe.has(i) && !(i in t) && (t[i] = s);
|
|
816
1096
|
const a = s.name;
|
|
817
1097
|
a && !(a in t) && (t[a] = s);
|
|
818
1098
|
} else
|
|
819
|
-
s && typeof s == "object" && o < 2 &&
|
|
1099
|
+
s && typeof s == "object" && o < 2 && oe.has(i) && n(s, o + 1);
|
|
820
1100
|
};
|
|
821
|
-
return
|
|
1101
|
+
return n(e, 0), t;
|
|
822
1102
|
}
|
|
823
|
-
const
|
|
1103
|
+
const yt = [
|
|
824
1104
|
"invalid_argument",
|
|
825
1105
|
"unauthenticated",
|
|
826
1106
|
"permission_denied",
|
|
827
1107
|
"not_found",
|
|
828
1108
|
"internal"
|
|
829
1109
|
];
|
|
830
|
-
class
|
|
831
|
-
constructor(t,
|
|
832
|
-
super(
|
|
1110
|
+
class I extends Error {
|
|
1111
|
+
constructor(t, n, r) {
|
|
1112
|
+
super(n), this.name = "ApiError", this.code = t, this.details = r, Object.setPrototypeOf(this, new.target.prototype);
|
|
833
1113
|
}
|
|
834
1114
|
/** Serialise to a plain object suitable for JSON transport. */
|
|
835
1115
|
toJSON() {
|
|
@@ -840,81 +1120,85 @@ class A extends Error {
|
|
|
840
1120
|
return this.details !== void 0 && (t.details = this.details), t;
|
|
841
1121
|
}
|
|
842
1122
|
}
|
|
843
|
-
function
|
|
844
|
-
return typeof e == "object" && e !== null && e.name === "ApiError" &&
|
|
1123
|
+
function je(e) {
|
|
1124
|
+
return typeof e == "object" && e !== null && e.name === "ApiError" && yt.includes(e.code) && typeof e.toJSON == "function";
|
|
845
1125
|
}
|
|
846
|
-
function
|
|
847
|
-
return e === "before-first-chunk" ? { phase: e, error: t } : { phase: e, error: t, chunksDelivered:
|
|
1126
|
+
function ie(e, t, n = 0) {
|
|
1127
|
+
return e === "before-first-chunk" ? { phase: e, error: t } : { phase: e, error: t, chunksDelivered: n };
|
|
848
1128
|
}
|
|
849
|
-
const
|
|
850
|
-
|
|
1129
|
+
const O = new _e({ allErrors: !0 });
|
|
1130
|
+
ke(O);
|
|
851
1131
|
for (const e of [
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
1132
|
+
F,
|
|
1133
|
+
V,
|
|
1134
|
+
T,
|
|
1135
|
+
P,
|
|
856
1136
|
"discriminator"
|
|
857
1137
|
])
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
function
|
|
1138
|
+
O.addKeyword({ keyword: e, valid: !0 });
|
|
1139
|
+
O.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
|
|
1140
|
+
function mt(e) {
|
|
861
1141
|
return e.map(
|
|
862
1142
|
(t) => `${t.instancePath || "(root)"} ${t.message ?? "failed schema check"}`
|
|
863
1143
|
).join("; ");
|
|
864
1144
|
}
|
|
865
|
-
|
|
866
|
-
const r = e
|
|
867
|
-
|
|
1145
|
+
function Oe(e, t) {
|
|
1146
|
+
const n = ve(t), r = [`Validation failed: ${mt(e)}`];
|
|
1147
|
+
return n && r.push(n), r.join(" — ");
|
|
1148
|
+
}
|
|
1149
|
+
const hn = async (e, t) => {
|
|
1150
|
+
const n = e.ctx.get(ht);
|
|
1151
|
+
if (n === void 0)
|
|
868
1152
|
return t();
|
|
869
|
-
const
|
|
1153
|
+
const r = e.operation.id, o = n[r];
|
|
870
1154
|
if (o === void 0)
|
|
871
1155
|
return t();
|
|
872
1156
|
const i = {
|
|
873
1157
|
data: e.domainArgs,
|
|
874
1158
|
...e.envelope
|
|
875
|
-
}, s =
|
|
1159
|
+
}, s = O.compile(o.input);
|
|
876
1160
|
if (!s(i)) {
|
|
877
1161
|
const f = s.errors ?? [];
|
|
878
|
-
throw new
|
|
1162
|
+
throw new I(
|
|
879
1163
|
"invalid_argument",
|
|
880
|
-
|
|
1164
|
+
Oe(f, o.input),
|
|
881
1165
|
f
|
|
882
1166
|
);
|
|
883
1167
|
}
|
|
884
1168
|
return t();
|
|
885
|
-
},
|
|
886
|
-
function
|
|
887
|
-
return async function(
|
|
888
|
-
const o =
|
|
1169
|
+
}, ht = Symbol("ValidateSchemasToken");
|
|
1170
|
+
function gt(e) {
|
|
1171
|
+
return async function(n, r) {
|
|
1172
|
+
const o = n.operation.id, i = e[o];
|
|
889
1173
|
if (i === void 0)
|
|
890
|
-
return
|
|
1174
|
+
return r();
|
|
891
1175
|
const s = {
|
|
892
|
-
data:
|
|
893
|
-
...
|
|
894
|
-
}, a =
|
|
1176
|
+
data: n.domainArgs,
|
|
1177
|
+
...n.envelope
|
|
1178
|
+
}, a = O.compile(i.input);
|
|
895
1179
|
if (!a(s)) {
|
|
896
|
-
const
|
|
897
|
-
throw new
|
|
1180
|
+
const u = a.errors ?? [];
|
|
1181
|
+
throw new I(
|
|
898
1182
|
"invalid_argument",
|
|
899
|
-
|
|
900
|
-
|
|
1183
|
+
Oe(u, i.input),
|
|
1184
|
+
u
|
|
901
1185
|
);
|
|
902
1186
|
}
|
|
903
|
-
return
|
|
1187
|
+
return r();
|
|
904
1188
|
};
|
|
905
1189
|
}
|
|
906
|
-
function
|
|
1190
|
+
function wt() {
|
|
907
1191
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
908
1192
|
const t = Math.random() * 16 | 0;
|
|
909
1193
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
910
1194
|
});
|
|
911
1195
|
}
|
|
912
|
-
class
|
|
1196
|
+
class gn {
|
|
913
1197
|
constructor(t = {}) {
|
|
914
|
-
var
|
|
1198
|
+
var r, o;
|
|
915
1199
|
this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = t.defaultTtlMs;
|
|
916
|
-
let
|
|
917
|
-
t.sweepIntervalMs === 0 ?
|
|
1200
|
+
let n = null;
|
|
1201
|
+
t.sweepIntervalMs === 0 ? n = null : t.sweepIntervalMs !== void 0 ? n = t.sweepIntervalMs : this._defaultTtlMs !== void 0 ? n = Math.max(1e3, Math.floor(this._defaultTtlMs / 4)) : n = null, n !== null && n > 0 && (this._sweeper = setInterval(() => this._sweep(), n), (o = (r = this._sweeper).unref) == null || o.call(r));
|
|
918
1202
|
}
|
|
919
1203
|
// ---------------------------------------------------------------------------
|
|
920
1204
|
// create — construct + register
|
|
@@ -927,8 +1211,8 @@ class Gt {
|
|
|
927
1211
|
* @param ttlMs - Per-entry TTL override. Falls back to `defaultTtlMs`.
|
|
928
1212
|
* @returns `{ instanceId }` — pass this to `dispatch()` / `get()`.
|
|
929
1213
|
*/
|
|
930
|
-
create(t,
|
|
931
|
-
const o = new t(...
|
|
1214
|
+
create(t, n = [], r) {
|
|
1215
|
+
const o = new t(...n), i = wt(), s = r ?? this._defaultTtlMs, a = s !== void 0 ? Date.now() + s : null;
|
|
932
1216
|
return this._store.set(i, { instance: o, expiresAt: a }), { instanceId: i };
|
|
933
1217
|
}
|
|
934
1218
|
// ---------------------------------------------------------------------------
|
|
@@ -940,16 +1224,16 @@ class Gt {
|
|
|
940
1224
|
* @throws When `instanceId` is unknown or the entry has expired.
|
|
941
1225
|
*/
|
|
942
1226
|
get(t) {
|
|
943
|
-
const
|
|
944
|
-
if (!
|
|
1227
|
+
const n = this._store.get(t);
|
|
1228
|
+
if (!n)
|
|
945
1229
|
throw new Error(
|
|
946
1230
|
`[instance-registry] Unknown instanceId: "${t}"`
|
|
947
1231
|
);
|
|
948
|
-
if (
|
|
949
|
-
throw this._evict(t,
|
|
1232
|
+
if (n.expiresAt !== null && Date.now() > n.expiresAt)
|
|
1233
|
+
throw this._evict(t, n), new Error(
|
|
950
1234
|
`[instance-registry] Instance "${t}" has expired`
|
|
951
1235
|
);
|
|
952
|
-
return
|
|
1236
|
+
return n.instance;
|
|
953
1237
|
}
|
|
954
1238
|
// ---------------------------------------------------------------------------
|
|
955
1239
|
// dispatch — call a method on a live instance
|
|
@@ -960,13 +1244,13 @@ class Gt {
|
|
|
960
1244
|
* @throws When `instanceId` is unknown/expired, or `method` is not a function
|
|
961
1245
|
* on the instance.
|
|
962
1246
|
*/
|
|
963
|
-
async dispatch(t,
|
|
964
|
-
const o = this.get(t), i = o[
|
|
1247
|
+
async dispatch(t, n, r = []) {
|
|
1248
|
+
const o = this.get(t), i = o[n];
|
|
965
1249
|
if (typeof i != "function")
|
|
966
1250
|
throw new Error(
|
|
967
|
-
`[instance-registry] Method "${
|
|
1251
|
+
`[instance-registry] Method "${n}" not found on instance "${t}"`
|
|
968
1252
|
);
|
|
969
|
-
return i.call(o, ...
|
|
1253
|
+
return i.call(o, ...r);
|
|
970
1254
|
}
|
|
971
1255
|
// ---------------------------------------------------------------------------
|
|
972
1256
|
// dispose — explicit teardown
|
|
@@ -976,8 +1260,8 @@ class Gt {
|
|
|
976
1260
|
* instance exposes one (opt-in lifecycle hook).
|
|
977
1261
|
*/
|
|
978
1262
|
async dispose(t) {
|
|
979
|
-
const
|
|
980
|
-
|
|
1263
|
+
const n = this._store.get(t);
|
|
1264
|
+
n && (this._store.delete(t), await x(n.instance));
|
|
981
1265
|
}
|
|
982
1266
|
// ---------------------------------------------------------------------------
|
|
983
1267
|
// disposeAll — full teardown
|
|
@@ -989,7 +1273,7 @@ class Gt {
|
|
|
989
1273
|
async disposeAll() {
|
|
990
1274
|
this._sweeper !== null && (clearInterval(this._sweeper), this._sweeper = null);
|
|
991
1275
|
const t = [...this._store.entries()];
|
|
992
|
-
this._store.clear(), await Promise.all(t.map(([,
|
|
1276
|
+
this._store.clear(), await Promise.all(t.map(([, n]) => x(n.instance)));
|
|
993
1277
|
}
|
|
994
1278
|
// ---------------------------------------------------------------------------
|
|
995
1279
|
// size — diagnostic helper
|
|
@@ -1003,27 +1287,27 @@ class Gt {
|
|
|
1003
1287
|
// ---------------------------------------------------------------------------
|
|
1004
1288
|
_sweep() {
|
|
1005
1289
|
const t = Date.now();
|
|
1006
|
-
for (const [
|
|
1007
|
-
|
|
1290
|
+
for (const [n, r] of this._store)
|
|
1291
|
+
r.expiresAt !== null && t > r.expiresAt && this._evict(n, r);
|
|
1008
1292
|
}
|
|
1009
|
-
_evict(t,
|
|
1010
|
-
this._store.delete(t),
|
|
1293
|
+
_evict(t, n) {
|
|
1294
|
+
this._store.delete(t), x(n.instance);
|
|
1011
1295
|
}
|
|
1012
1296
|
}
|
|
1013
|
-
async function
|
|
1297
|
+
async function x(e) {
|
|
1014
1298
|
if (e !== null && typeof e == "object" && "dispose" in e) {
|
|
1015
1299
|
const t = e.dispose;
|
|
1016
1300
|
typeof t == "function" && await t.call(e);
|
|
1017
1301
|
}
|
|
1018
1302
|
}
|
|
1019
|
-
function
|
|
1020
|
-
const { produce: t, signal:
|
|
1303
|
+
function wn(e) {
|
|
1304
|
+
const { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
1021
1305
|
return {
|
|
1022
1306
|
[Symbol.asyncIterator]() {
|
|
1023
|
-
const o = t(
|
|
1307
|
+
const o = t(r);
|
|
1024
1308
|
return {
|
|
1025
1309
|
async next() {
|
|
1026
|
-
return
|
|
1310
|
+
return r.aborted ? (await o.return(void 0), { done: !0, value: void 0 }) : o.next();
|
|
1027
1311
|
},
|
|
1028
1312
|
async return(i) {
|
|
1029
1313
|
return await o.return(i), { done: !0, value: void 0 };
|
|
@@ -1035,183 +1319,183 @@ function Jt(e) {
|
|
|
1035
1319
|
}
|
|
1036
1320
|
};
|
|
1037
1321
|
}
|
|
1038
|
-
async function
|
|
1322
|
+
async function bn(e) {
|
|
1039
1323
|
const t = [];
|
|
1040
|
-
for await (const
|
|
1041
|
-
t.push(
|
|
1324
|
+
for await (const n of e)
|
|
1325
|
+
t.push(n);
|
|
1042
1326
|
return t;
|
|
1043
1327
|
}
|
|
1044
|
-
async function
|
|
1328
|
+
async function bt(e) {
|
|
1045
1329
|
const t = [];
|
|
1046
1330
|
try {
|
|
1047
|
-
for await (const
|
|
1048
|
-
t.push(
|
|
1331
|
+
for await (const n of e)
|
|
1332
|
+
t.push(n);
|
|
1049
1333
|
return { ok: !0, chunks: t };
|
|
1050
|
-
} catch (
|
|
1051
|
-
const
|
|
1334
|
+
} catch (n) {
|
|
1335
|
+
const r = je(n) ? n : new I(
|
|
1052
1336
|
"internal",
|
|
1053
|
-
|
|
1337
|
+
n instanceof Error ? n.message : String(n)
|
|
1054
1338
|
);
|
|
1055
1339
|
return t.length === 0 ? {
|
|
1056
1340
|
ok: !1,
|
|
1057
|
-
carrier:
|
|
1341
|
+
carrier: ie("before-first-chunk", r)
|
|
1058
1342
|
} : {
|
|
1059
1343
|
ok: !1,
|
|
1060
|
-
carrier:
|
|
1344
|
+
carrier: ie("after-first-chunk", r, t.length)
|
|
1061
1345
|
};
|
|
1062
1346
|
}
|
|
1063
1347
|
}
|
|
1064
|
-
function
|
|
1348
|
+
function vt(e) {
|
|
1065
1349
|
return e !== null && typeof e == "object" && Symbol.asyncIterator in e;
|
|
1066
1350
|
}
|
|
1067
1351
|
class g extends Error {
|
|
1068
|
-
constructor(t,
|
|
1069
|
-
super(
|
|
1352
|
+
constructor(t, n) {
|
|
1353
|
+
super(n), this.name = "UnionCodecError", this.code = t;
|
|
1070
1354
|
}
|
|
1071
1355
|
}
|
|
1072
|
-
function
|
|
1356
|
+
function S(e) {
|
|
1073
1357
|
const t = e.discriminator;
|
|
1074
1358
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
1075
1359
|
return;
|
|
1076
|
-
const
|
|
1077
|
-
if (typeof
|
|
1360
|
+
const n = t;
|
|
1361
|
+
if (typeof n.propertyName != "string")
|
|
1078
1362
|
return;
|
|
1079
|
-
const
|
|
1080
|
-
if (!(
|
|
1363
|
+
const r = n.mapping;
|
|
1364
|
+
if (!(r === null || typeof r != "object" || Array.isArray(r)))
|
|
1081
1365
|
return {
|
|
1082
|
-
propertyName:
|
|
1083
|
-
mapping:
|
|
1366
|
+
propertyName: n.propertyName,
|
|
1367
|
+
mapping: r
|
|
1084
1368
|
};
|
|
1085
1369
|
}
|
|
1086
|
-
function
|
|
1087
|
-
const
|
|
1088
|
-
if (typeof
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1091
|
-
return
|
|
1370
|
+
function Ne(e, t) {
|
|
1371
|
+
const n = e[V];
|
|
1372
|
+
if (typeof n == "string") {
|
|
1373
|
+
const r = t.registry.get(n);
|
|
1374
|
+
if (r)
|
|
1375
|
+
return r;
|
|
1092
1376
|
}
|
|
1093
1377
|
return t.registry.resolve(e);
|
|
1094
1378
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const
|
|
1097
|
-
return
|
|
1379
|
+
function $t(e, t, n) {
|
|
1380
|
+
const r = Ne(t, n);
|
|
1381
|
+
return r ? r.encode(e, t, n) : e;
|
|
1098
1382
|
}
|
|
1099
|
-
function
|
|
1100
|
-
const
|
|
1101
|
-
return
|
|
1383
|
+
function At(e, t, n) {
|
|
1384
|
+
const r = Ne(t, n);
|
|
1385
|
+
return r ? r.decode(e, t, n) : e;
|
|
1102
1386
|
}
|
|
1103
|
-
function
|
|
1104
|
-
const { id: t, schema:
|
|
1387
|
+
function jt(e) {
|
|
1388
|
+
const { id: t, schema: n } = e;
|
|
1105
1389
|
return {
|
|
1106
1390
|
id: t,
|
|
1107
1391
|
kind: "union",
|
|
1108
|
-
schema:
|
|
1392
|
+
schema: n,
|
|
1109
1393
|
/**
|
|
1110
1394
|
* Structural ownership test: the node carries both `oneOf` (non-empty array)
|
|
1111
1395
|
* and `discriminator.propertyName`. The `x-apigen-logical:"union"` hint
|
|
1112
1396
|
* accelerates the match but is advisory — the structure is authoritative.
|
|
1113
1397
|
*/
|
|
1114
|
-
matches(
|
|
1115
|
-
if (
|
|
1398
|
+
matches(r) {
|
|
1399
|
+
if (r[F] === "union")
|
|
1116
1400
|
return !0;
|
|
1117
|
-
const o =
|
|
1118
|
-
return !Array.isArray(o) || o.length === 0 ? !1 :
|
|
1401
|
+
const o = r.oneOf;
|
|
1402
|
+
return !Array.isArray(o) || o.length === 0 ? !1 : S(r) !== void 0;
|
|
1119
1403
|
},
|
|
1120
|
-
encode(
|
|
1121
|
-
const s =
|
|
1404
|
+
encode(r, o, i) {
|
|
1405
|
+
const s = S(o);
|
|
1122
1406
|
if (!s)
|
|
1123
1407
|
throw new g(
|
|
1124
1408
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1125
1409
|
`[${t}] schema node at "${i.path}" has no discriminator.propertyName; cannot dispatch union branch.`
|
|
1126
1410
|
);
|
|
1127
|
-
const { propertyName: a, mapping: f } = s,
|
|
1128
|
-
if (
|
|
1411
|
+
const { propertyName: a, mapping: f } = s, u = r[a];
|
|
1412
|
+
if (u == null)
|
|
1129
1413
|
throw new g(
|
|
1130
1414
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1131
1415
|
`[${t}] value at "${i.path}" is missing the discriminator property "${a}".`
|
|
1132
1416
|
);
|
|
1133
|
-
const
|
|
1134
|
-
if (!
|
|
1417
|
+
const c = String(u), l = f[c];
|
|
1418
|
+
if (!l)
|
|
1135
1419
|
throw new g(
|
|
1136
1420
|
"E_UNION_UNKNOWN_TAG",
|
|
1137
|
-
`[${t}] discriminator tag "${
|
|
1421
|
+
`[${t}] discriminator tag "${c}" at "${i.path}" is not in the mapping (known: ${Object.keys(f).join(", ")}).`
|
|
1138
1422
|
);
|
|
1139
|
-
const
|
|
1140
|
-
return
|
|
1423
|
+
const p = i.resolve(l);
|
|
1424
|
+
return $t(r, p, {
|
|
1141
1425
|
...i,
|
|
1142
|
-
path: `${i.path}[${
|
|
1426
|
+
path: `${i.path}[${c}]`
|
|
1143
1427
|
});
|
|
1144
1428
|
},
|
|
1145
|
-
decode(
|
|
1146
|
-
if (
|
|
1147
|
-
let
|
|
1148
|
-
throw
|
|
1429
|
+
decode(r, o, i) {
|
|
1430
|
+
if (r === null || typeof r != "object" || Array.isArray(r)) {
|
|
1431
|
+
let d;
|
|
1432
|
+
throw r === null ? d = "null" : Array.isArray(r) ? d = "array" : d = typeof r, new g(
|
|
1149
1433
|
"E_UNION_INVALID_WIRE",
|
|
1150
|
-
`[${t}] expected a JSON object on the wire at "${i.path}", got ${
|
|
1434
|
+
`[${t}] expected a JSON object on the wire at "${i.path}", got ${d}.`
|
|
1151
1435
|
);
|
|
1152
1436
|
}
|
|
1153
|
-
const s =
|
|
1437
|
+
const s = r, a = S(o);
|
|
1154
1438
|
if (!a)
|
|
1155
1439
|
throw new g(
|
|
1156
1440
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1157
1441
|
`[${t}] schema node at "${i.path}" has no discriminator.propertyName; cannot dispatch union branch.`
|
|
1158
1442
|
);
|
|
1159
|
-
const { propertyName: f, mapping:
|
|
1160
|
-
if (
|
|
1443
|
+
const { propertyName: f, mapping: u } = a, c = s[f];
|
|
1444
|
+
if (c == null)
|
|
1161
1445
|
throw new g(
|
|
1162
1446
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1163
1447
|
`[${t}] wire object at "${i.path}" is missing the discriminator property "${f}".`
|
|
1164
1448
|
);
|
|
1165
|
-
const
|
|
1166
|
-
if (!
|
|
1449
|
+
const l = String(c), p = u[l];
|
|
1450
|
+
if (!p)
|
|
1167
1451
|
throw new g(
|
|
1168
1452
|
"E_UNION_UNKNOWN_TAG",
|
|
1169
|
-
`[${t}] discriminator tag "${
|
|
1453
|
+
`[${t}] discriminator tag "${l}" on the wire at "${i.path}" is not in the mapping (known: ${Object.keys(u).join(", ")}).`
|
|
1170
1454
|
);
|
|
1171
|
-
const
|
|
1172
|
-
return
|
|
1455
|
+
const y = i.resolve(p);
|
|
1456
|
+
return At(r, y, {
|
|
1173
1457
|
...i,
|
|
1174
|
-
path: `${i.path}[${
|
|
1458
|
+
path: `${i.path}[${l}]`
|
|
1175
1459
|
});
|
|
1176
1460
|
}
|
|
1177
1461
|
};
|
|
1178
1462
|
}
|
|
1179
|
-
const
|
|
1180
|
-
class
|
|
1181
|
-
constructor(t,
|
|
1182
|
-
super(
|
|
1463
|
+
const Ot = "x-apigen-instances";
|
|
1464
|
+
class E extends Error {
|
|
1465
|
+
constructor(t, n) {
|
|
1466
|
+
super(n), this.name = "NominalCodecError", this.code = t;
|
|
1183
1467
|
}
|
|
1184
1468
|
}
|
|
1185
|
-
function
|
|
1469
|
+
function se(e) {
|
|
1186
1470
|
const t = e.properties;
|
|
1187
1471
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
1188
1472
|
}
|
|
1189
|
-
function
|
|
1473
|
+
function Nt(e) {
|
|
1190
1474
|
const t = e.required;
|
|
1191
|
-
return Array.isArray(t) ? t.filter((
|
|
1475
|
+
return Array.isArray(t) ? t.filter((n) => typeof n == "string") : [];
|
|
1192
1476
|
}
|
|
1193
|
-
function
|
|
1477
|
+
function ae(e, t, n) {
|
|
1194
1478
|
if (t) {
|
|
1195
|
-
const
|
|
1196
|
-
if (
|
|
1197
|
-
return
|
|
1479
|
+
const r = n.registry.resolve(t);
|
|
1480
|
+
if (r)
|
|
1481
|
+
return r.encode(e, t, n);
|
|
1198
1482
|
}
|
|
1199
1483
|
return e;
|
|
1200
1484
|
}
|
|
1201
|
-
function
|
|
1485
|
+
function Et(e, t, n) {
|
|
1202
1486
|
if (t) {
|
|
1203
|
-
const
|
|
1204
|
-
if (
|
|
1205
|
-
return
|
|
1487
|
+
const r = n.registry.resolve(t);
|
|
1488
|
+
if (r)
|
|
1489
|
+
return r.decode(e, t, n);
|
|
1206
1490
|
}
|
|
1207
1491
|
return e;
|
|
1208
1492
|
}
|
|
1209
|
-
function
|
|
1210
|
-
const { id: t, schema:
|
|
1493
|
+
function _t(e) {
|
|
1494
|
+
const { id: t, schema: n, ctor: r } = e;
|
|
1211
1495
|
return {
|
|
1212
1496
|
id: t,
|
|
1213
1497
|
kind: "nominal",
|
|
1214
|
-
schema:
|
|
1498
|
+
schema: n,
|
|
1215
1499
|
/**
|
|
1216
1500
|
* Structural ownership test: the node advertises `x-apigen-logical:'nominal'`
|
|
1217
1501
|
* or carries an `x-apigen-codec` matching this codec's id. Per
|
|
@@ -1220,14 +1504,14 @@ function st(e) {
|
|
|
1220
1504
|
* handled by the transcoder walk, not by this cheap test.
|
|
1221
1505
|
*/
|
|
1222
1506
|
matches(o) {
|
|
1223
|
-
return o[
|
|
1507
|
+
return o[F] === "nominal" ? !0 : o[V] === t;
|
|
1224
1508
|
},
|
|
1225
1509
|
encode(o, i, s) {
|
|
1226
1510
|
if (o === null || typeof o != "object")
|
|
1227
1511
|
return o;
|
|
1228
1512
|
if (s.seen.has(o)) {
|
|
1229
1513
|
if (s.mode === "strict")
|
|
1230
|
-
throw new
|
|
1514
|
+
throw new E(
|
|
1231
1515
|
"E_NOMINAL_CYCLE",
|
|
1232
1516
|
`[${t}] cycle detected at "${s.path}": a nominal instance references itself. Strict mode rejects cycles (DESIGN §8.3); break the cycle or use 'lossy' mode.`
|
|
1233
1517
|
);
|
|
@@ -1235,125 +1519,125 @@ function st(e) {
|
|
|
1235
1519
|
}
|
|
1236
1520
|
s.seen.add(o);
|
|
1237
1521
|
try {
|
|
1238
|
-
const a =
|
|
1239
|
-
if (typeof
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1242
|
-
const
|
|
1522
|
+
const a = se(i), f = typeof i[P] == "string" ? i[P] : "toJSON", u = o[f];
|
|
1523
|
+
if (typeof u == "function") {
|
|
1524
|
+
const d = u.call(o);
|
|
1525
|
+
if (d !== null && typeof d == "object" && !Array.isArray(d)) {
|
|
1526
|
+
const m = {};
|
|
1243
1527
|
for (const [h, b] of Object.entries(
|
|
1244
|
-
|
|
1528
|
+
d
|
|
1245
1529
|
))
|
|
1246
|
-
|
|
1530
|
+
m[h] = ae(b, a[h], {
|
|
1247
1531
|
...s,
|
|
1248
1532
|
path: `${s.path}/${h}`
|
|
1249
1533
|
});
|
|
1250
|
-
return
|
|
1534
|
+
return m;
|
|
1251
1535
|
}
|
|
1252
|
-
return
|
|
1536
|
+
return d;
|
|
1253
1537
|
}
|
|
1254
|
-
const
|
|
1255
|
-
for (const
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1538
|
+
const c = {}, l = Object.keys(a), p = o, y = l.length > 0 ? l : Object.keys(p);
|
|
1539
|
+
for (const d of y) {
|
|
1540
|
+
const m = p[d];
|
|
1541
|
+
m !== void 0 && (c[d] = ae(m, a[d], {
|
|
1258
1542
|
...s,
|
|
1259
|
-
path: `${s.path}/${
|
|
1543
|
+
path: `${s.path}/${d}`
|
|
1260
1544
|
}));
|
|
1261
1545
|
}
|
|
1262
|
-
return
|
|
1546
|
+
return c;
|
|
1263
1547
|
} finally {
|
|
1264
1548
|
s.seen.delete(o);
|
|
1265
1549
|
}
|
|
1266
1550
|
},
|
|
1267
1551
|
decode(o, i, s) {
|
|
1268
1552
|
if (o === null || typeof o != "object" || Array.isArray(o)) {
|
|
1269
|
-
let
|
|
1270
|
-
throw o === null ?
|
|
1553
|
+
let c;
|
|
1554
|
+
throw o === null ? c = "null" : Array.isArray(o) ? c = "array" : c = typeof o, new E(
|
|
1271
1555
|
"E_NOMINAL_INVALID_WIRE",
|
|
1272
|
-
`[${t}] expected a JSON object on the wire at "${s.path}", got ${
|
|
1556
|
+
`[${t}] expected a JSON object on the wire at "${s.path}", got ${c}.`
|
|
1273
1557
|
);
|
|
1274
1558
|
}
|
|
1275
1559
|
const a = o;
|
|
1276
|
-
for (const
|
|
1277
|
-
if (!(
|
|
1278
|
-
throw new
|
|
1560
|
+
for (const c of Nt(i))
|
|
1561
|
+
if (!(c in a))
|
|
1562
|
+
throw new E(
|
|
1279
1563
|
"E_NOMINAL_INVALID_WIRE",
|
|
1280
|
-
`[${t}] required field "${
|
|
1564
|
+
`[${t}] required field "${c}" missing on the wire at "${s.path}".`
|
|
1281
1565
|
);
|
|
1282
|
-
if (i[
|
|
1283
|
-
throw new
|
|
1566
|
+
if (i[Ot] === !1)
|
|
1567
|
+
throw new E(
|
|
1284
1568
|
"E_NOMINAL_NONRECONSTRUCTABLE",
|
|
1285
1569
|
`[${t}] is encode-only: the extractor marked it non-reconstructable (x-apigen-instances:false). It cannot be decoded back to a live instance.`
|
|
1286
1570
|
);
|
|
1287
|
-
const f =
|
|
1288
|
-
for (const [
|
|
1289
|
-
c
|
|
1571
|
+
const f = se(i), u = {};
|
|
1572
|
+
for (const [c, l] of Object.entries(a))
|
|
1573
|
+
u[c] = Et(l, f[c], {
|
|
1290
1574
|
...s,
|
|
1291
|
-
path: `${s.path}/${
|
|
1575
|
+
path: `${s.path}/${c}`
|
|
1292
1576
|
});
|
|
1293
|
-
if (
|
|
1294
|
-
const
|
|
1295
|
-
if (typeof
|
|
1296
|
-
return
|
|
1297
|
-
|
|
1298
|
-
|
|
1577
|
+
if (r) {
|
|
1578
|
+
const c = typeof i[T] == "string" ? i[T] : "fromJSON", l = r[c];
|
|
1579
|
+
if (typeof l == "function")
|
|
1580
|
+
return l.call(
|
|
1581
|
+
r,
|
|
1582
|
+
u
|
|
1299
1583
|
);
|
|
1300
|
-
const
|
|
1301
|
-
return new
|
|
1584
|
+
const p = r;
|
|
1585
|
+
return new p(u);
|
|
1302
1586
|
}
|
|
1303
|
-
return
|
|
1587
|
+
return u;
|
|
1304
1588
|
}
|
|
1305
1589
|
};
|
|
1306
1590
|
}
|
|
1307
|
-
const
|
|
1308
|
-
B,
|
|
1309
|
-
F,
|
|
1310
|
-
K,
|
|
1591
|
+
const kt = [
|
|
1311
1592
|
H,
|
|
1312
|
-
|
|
1313
|
-
z
|
|
1314
|
-
|
|
1593
|
+
K,
|
|
1594
|
+
z,
|
|
1595
|
+
J,
|
|
1596
|
+
W,
|
|
1597
|
+
G
|
|
1598
|
+
], It = {
|
|
1315
1599
|
type: "object",
|
|
1316
1600
|
"x-apigen-logical": "nominal",
|
|
1317
1601
|
"x-apigen-codec": "ts.NominalSentinel"
|
|
1318
|
-
},
|
|
1602
|
+
}, ce = _t({
|
|
1319
1603
|
id: "ts.NominalSentinel",
|
|
1320
|
-
schema:
|
|
1321
|
-
}),
|
|
1604
|
+
schema: It
|
|
1605
|
+
}), Ct = {
|
|
1322
1606
|
oneOf: [],
|
|
1323
1607
|
discriminator: { propertyName: "kind", mapping: {} },
|
|
1324
1608
|
"x-apigen-logical": "union",
|
|
1325
1609
|
"x-apigen-codec": "ts.UnionSentinel"
|
|
1326
|
-
},
|
|
1610
|
+
}, ue = jt({
|
|
1327
1611
|
id: "ts.UnionSentinel",
|
|
1328
|
-
schema:
|
|
1612
|
+
schema: Ct
|
|
1329
1613
|
});
|
|
1330
|
-
function
|
|
1614
|
+
function xt() {
|
|
1331
1615
|
const e = [
|
|
1332
1616
|
// 6 well-known scalars
|
|
1333
|
-
...
|
|
1617
|
+
...kt.map((t) => [
|
|
1334
1618
|
t.id,
|
|
1335
1619
|
t
|
|
1336
1620
|
]),
|
|
1337
1621
|
// nominal kind sentinel
|
|
1338
|
-
[
|
|
1622
|
+
[ce.id, ce],
|
|
1339
1623
|
// union kind sentinel
|
|
1340
|
-
[
|
|
1624
|
+
[ue.id, ue]
|
|
1341
1625
|
];
|
|
1342
1626
|
return Object.freeze(new Map(e));
|
|
1343
1627
|
}
|
|
1344
|
-
const
|
|
1628
|
+
const vn = Object.freeze({
|
|
1345
1629
|
host: "ts",
|
|
1346
|
-
logicalTypeVersion:
|
|
1347
|
-
codecs:
|
|
1630
|
+
logicalTypeVersion: Ce,
|
|
1631
|
+
codecs: xt()
|
|
1348
1632
|
});
|
|
1349
|
-
function
|
|
1350
|
-
var
|
|
1351
|
-
const
|
|
1352
|
-
(
|
|
1633
|
+
function $n(e, t, n) {
|
|
1634
|
+
var s;
|
|
1635
|
+
const r = typeof ((s = t == null ? void 0 : t.input) == null ? void 0 : s.description) == "string" ? t.input.description : void 0, o = ve(t == null ? void 0 : t.input), i = [n, r, o].filter(
|
|
1636
|
+
(a) => typeof a == "string" && a.length > 0
|
|
1353
1637
|
);
|
|
1354
|
-
return
|
|
1638
|
+
return i.length > 0 ? i.join(" — ") : e;
|
|
1355
1639
|
}
|
|
1356
|
-
function
|
|
1640
|
+
function An(e) {
|
|
1357
1641
|
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length === 0)
|
|
1358
1642
|
return { outputSchema: void 0, wrapped: !1 };
|
|
1359
1643
|
const t = e;
|
|
@@ -1366,144 +1650,145 @@ function Zt(e) {
|
|
|
1366
1650
|
wrapped: !0
|
|
1367
1651
|
};
|
|
1368
1652
|
}
|
|
1369
|
-
function
|
|
1653
|
+
function jn(e, t) {
|
|
1370
1654
|
return e ? { result: t } : t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1371
1655
|
}
|
|
1372
|
-
const
|
|
1373
|
-
function
|
|
1374
|
-
return
|
|
1656
|
+
const St = 4, Mt = 32;
|
|
1657
|
+
function q(e) {
|
|
1658
|
+
return je(e) ? e : e instanceof Error ? new I("internal", e.message) : e;
|
|
1375
1659
|
}
|
|
1376
|
-
function
|
|
1660
|
+
function Tt(e, t) {
|
|
1377
1661
|
if (e === "serial" || e === "chained")
|
|
1378
1662
|
return 1;
|
|
1379
|
-
const
|
|
1380
|
-
return !Number.isFinite(
|
|
1663
|
+
const n = t ?? St;
|
|
1664
|
+
return !Number.isFinite(n) || n < 1 ? 1 : Math.min(Math.floor(n), Mt);
|
|
1381
1665
|
}
|
|
1382
|
-
function
|
|
1666
|
+
function Pt() {
|
|
1383
1667
|
}
|
|
1384
|
-
function
|
|
1668
|
+
function Dt(e, t) {
|
|
1385
1669
|
var i;
|
|
1386
1670
|
if (!e && !t)
|
|
1387
|
-
return { signal: void 0, dispose:
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1671
|
+
return { signal: void 0, dispose: Pt };
|
|
1672
|
+
const n = new AbortController(), r = () => {
|
|
1673
|
+
n.abort(e == null ? void 0 : e.reason);
|
|
1390
1674
|
};
|
|
1391
|
-
e && (e.aborted ?
|
|
1675
|
+
e && (e.aborted ? n.abort(e.reason) : e.addEventListener("abort", r, { once: !0 }));
|
|
1392
1676
|
let o;
|
|
1393
|
-
return t !== void 0 && !
|
|
1394
|
-
|
|
1677
|
+
return t !== void 0 && !n.signal.aborted && (o = setTimeout(() => {
|
|
1678
|
+
n.abort(
|
|
1395
1679
|
new DOMException(
|
|
1396
1680
|
`apigen/invokeBatch: item timed out after ${t}ms`,
|
|
1397
1681
|
"TimeoutError"
|
|
1398
1682
|
)
|
|
1399
1683
|
);
|
|
1400
1684
|
}, t), (i = o.unref) == null || i.call(o)), {
|
|
1401
|
-
signal:
|
|
1685
|
+
signal: n.signal,
|
|
1402
1686
|
dispose() {
|
|
1403
|
-
e && e.removeEventListener("abort",
|
|
1687
|
+
e && e.removeEventListener("abort", r), o && clearTimeout(o);
|
|
1404
1688
|
}
|
|
1405
1689
|
};
|
|
1406
1690
|
}
|
|
1407
|
-
async function
|
|
1408
|
-
const s =
|
|
1691
|
+
async function fe(e, t, n, r, o, i) {
|
|
1692
|
+
const s = Dt(r.signal, i);
|
|
1409
1693
|
try {
|
|
1410
|
-
const a = s.signal ? { ...
|
|
1411
|
-
if (
|
|
1412
|
-
const
|
|
1413
|
-
if (
|
|
1414
|
-
return { index:
|
|
1415
|
-
const
|
|
1694
|
+
const a = s.signal ? { ...r, signal: s.signal } : r, f = await e(t, a, o);
|
|
1695
|
+
if (vt(f)) {
|
|
1696
|
+
const u = await bt(f);
|
|
1697
|
+
if (u.ok)
|
|
1698
|
+
return { index: n, status: "fulfilled", chunks: u.chunks };
|
|
1699
|
+
const c = u.carrier;
|
|
1416
1700
|
return {
|
|
1417
|
-
index:
|
|
1701
|
+
index: n,
|
|
1418
1702
|
status: "rejected",
|
|
1419
|
-
reason:
|
|
1420
|
-
...
|
|
1703
|
+
reason: q(c.error),
|
|
1704
|
+
...c.phase === "after-first-chunk" ? { chunksDelivered: c.chunksDelivered } : {}
|
|
1421
1705
|
};
|
|
1422
1706
|
}
|
|
1423
|
-
return { index:
|
|
1707
|
+
return { index: n, status: "fulfilled", value: f };
|
|
1424
1708
|
} catch (a) {
|
|
1425
|
-
return { index:
|
|
1709
|
+
return { index: n, status: "rejected", reason: q(a) };
|
|
1426
1710
|
} finally {
|
|
1427
1711
|
s.dispose();
|
|
1428
1712
|
}
|
|
1429
1713
|
}
|
|
1430
|
-
async function
|
|
1431
|
-
const i = o.mode ?? "parallel", s = o.onItemError ?? "continue", a =
|
|
1432
|
-
index:
|
|
1714
|
+
async function On(e, t, n, r, o = {}) {
|
|
1715
|
+
const i = o.mode ?? "parallel", s = o.onItemError ?? "continue", a = Tt(i, o.concurrency), f = new Array(n.length), u = (d) => ({
|
|
1716
|
+
index: d,
|
|
1433
1717
|
status: "rejected",
|
|
1434
|
-
reason:
|
|
1718
|
+
reason: q(
|
|
1435
1719
|
new Error(
|
|
1436
1720
|
"apigen/invokeBatch: not attempted — an earlier item failed and " + (i === "chained" ? 'mode is "chained"' : 'onItemError is "abort"')
|
|
1437
1721
|
)
|
|
1438
1722
|
)
|
|
1439
1723
|
});
|
|
1440
1724
|
if (i === "serial" || i === "chained") {
|
|
1441
|
-
let
|
|
1442
|
-
for (let
|
|
1443
|
-
if (
|
|
1444
|
-
f[
|
|
1725
|
+
let d = !1;
|
|
1726
|
+
for (let m = 0; m < n.length; m++) {
|
|
1727
|
+
if (d) {
|
|
1728
|
+
f[m] = u(m);
|
|
1445
1729
|
continue;
|
|
1446
1730
|
}
|
|
1447
|
-
const h = await
|
|
1731
|
+
const h = await fe(
|
|
1448
1732
|
e,
|
|
1449
1733
|
t,
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1734
|
+
m,
|
|
1735
|
+
n[m],
|
|
1736
|
+
r,
|
|
1453
1737
|
o.itemTimeoutMs
|
|
1454
1738
|
);
|
|
1455
|
-
f[
|
|
1739
|
+
f[m] = h, h.status === "rejected" && (i === "chained" || s === "abort") && (d = !0);
|
|
1456
1740
|
}
|
|
1457
1741
|
return f;
|
|
1458
1742
|
}
|
|
1459
|
-
let
|
|
1460
|
-
const
|
|
1743
|
+
let c = 0, l = !1;
|
|
1744
|
+
const p = Math.max(1, Math.min(a, n.length)), y = Array.from({ length: p }, async () => {
|
|
1461
1745
|
for (; ; ) {
|
|
1462
|
-
const
|
|
1463
|
-
if (
|
|
1746
|
+
const d = c++;
|
|
1747
|
+
if (d >= n.length)
|
|
1464
1748
|
return;
|
|
1465
|
-
if (
|
|
1466
|
-
f[
|
|
1749
|
+
if (l) {
|
|
1750
|
+
f[d] = u(d);
|
|
1467
1751
|
continue;
|
|
1468
1752
|
}
|
|
1469
|
-
const
|
|
1753
|
+
const m = await fe(
|
|
1470
1754
|
e,
|
|
1471
1755
|
t,
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1756
|
+
d,
|
|
1757
|
+
n[d],
|
|
1758
|
+
r,
|
|
1475
1759
|
o.itemTimeoutMs
|
|
1476
1760
|
);
|
|
1477
|
-
f[
|
|
1761
|
+
f[d] = m, m.status === "rejected" && s === "abort" && (l = !0);
|
|
1478
1762
|
}
|
|
1479
1763
|
});
|
|
1480
|
-
return await Promise.all(
|
|
1764
|
+
return await Promise.all(y), f;
|
|
1481
1765
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1766
|
+
he(import.meta.url);
|
|
1767
|
+
const le = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
|
|
1768
|
+
function Ut(e) {
|
|
1484
1769
|
if (typeof e != "object" || e === null)
|
|
1485
1770
|
return !1;
|
|
1486
1771
|
const t = e;
|
|
1487
1772
|
if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf)
|
|
1488
1773
|
return !1;
|
|
1489
|
-
const { type:
|
|
1490
|
-
return typeof
|
|
1774
|
+
const { type: n } = t;
|
|
1775
|
+
return typeof n == "string" ? le.has(n) : Array.isArray(n) ? n.every((r) => le.has(r) || r === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((r) => ["string", "number", "boolean"].includes(typeof r)) : !1;
|
|
1491
1776
|
}
|
|
1492
|
-
function
|
|
1777
|
+
function Rt(e) {
|
|
1493
1778
|
if (!e || typeof e != "object")
|
|
1494
1779
|
return !1;
|
|
1495
1780
|
const t = e.properties;
|
|
1496
1781
|
return t === void 0 || typeof t != "object" || t === null ? !1 : Object.values(t).every(
|
|
1497
|
-
|
|
1782
|
+
Ut
|
|
1498
1783
|
);
|
|
1499
1784
|
}
|
|
1500
|
-
const
|
|
1785
|
+
const Lt = {
|
|
1501
1786
|
"decimal.js": "Decimal"
|
|
1502
1787
|
};
|
|
1503
|
-
function
|
|
1788
|
+
function Bt(e) {
|
|
1504
1789
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1505
1790
|
}
|
|
1506
|
-
Object.entries(
|
|
1791
|
+
Object.entries(Lt).map(([e, t]) => ({
|
|
1507
1792
|
// Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
|
|
1508
1793
|
// The module specifier appears inside an absolute path, so we allow any
|
|
1509
1794
|
// characters between the quote and the specifier, and between the specifier
|
|
@@ -1511,136 +1796,137 @@ Object.entries(wt).map(([e, t]) => ({
|
|
|
1511
1796
|
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
1512
1797
|
// see the doc comment above for why.
|
|
1513
1798
|
pattern: new RegExp(
|
|
1514
|
-
`import\\(["'][^"']*${
|
|
1799
|
+
`import\\(["'][^"']*${Bt(e)}[^"']*["']\\)\\.\\w+`,
|
|
1515
1800
|
"g"
|
|
1516
1801
|
),
|
|
1517
1802
|
key: t
|
|
1518
1803
|
}));
|
|
1519
|
-
function
|
|
1804
|
+
function pe(e) {
|
|
1520
1805
|
return e.words.join("-");
|
|
1521
1806
|
}
|
|
1522
|
-
function
|
|
1523
|
-
return e.words.map(
|
|
1807
|
+
function de(e) {
|
|
1808
|
+
return e.words.map(Kt).join("");
|
|
1524
1809
|
}
|
|
1525
|
-
function
|
|
1810
|
+
function ye(e) {
|
|
1526
1811
|
return e.words.join("_");
|
|
1527
1812
|
}
|
|
1528
|
-
function
|
|
1529
|
-
var
|
|
1530
|
-
const o = [e.namespace, ...e.path], i = e.safe ||
|
|
1813
|
+
function qt(e, t = {}) {
|
|
1814
|
+
var n, r;
|
|
1815
|
+
const o = [e.namespace, ...e.path], i = e.safe || Rt(e.input) ? "GET" : "POST", s = ((r = (n = t.http) == null ? void 0 : n.verb) == null ? void 0 : r[e.id]) ?? i, a = "/" + o.map((y) => pe(y)).join("/"), f = o.map((y) => ye(y)).join("_"), u = o.map((y) => ye(y)).slice(0, -1).join("."), c = de(o[o.length - 2] ?? o[0]), l = de(o[o.length - 1]), p = o.map((y) => pe(y));
|
|
1531
1816
|
return {
|
|
1532
1817
|
http: { verb: s, route: a },
|
|
1533
1818
|
mcp: { name: f },
|
|
1534
|
-
grpc: { package:
|
|
1535
|
-
cli: { path:
|
|
1819
|
+
grpc: { package: u, service: c, method: l },
|
|
1820
|
+
cli: { path: p }
|
|
1536
1821
|
};
|
|
1537
1822
|
}
|
|
1538
|
-
function
|
|
1823
|
+
function Ft(e, t) {
|
|
1539
1824
|
return `x-${e}-${t}`;
|
|
1540
1825
|
}
|
|
1541
|
-
function
|
|
1826
|
+
function Vt(e, t) {
|
|
1542
1827
|
return `--${e}-${t}`;
|
|
1543
1828
|
}
|
|
1544
|
-
function
|
|
1545
|
-
const
|
|
1546
|
-
return e === "adhd" ? `APIGEN_${
|
|
1829
|
+
function Ht(e, t) {
|
|
1830
|
+
const n = (r) => r.toUpperCase().replace(/-/g, "_");
|
|
1831
|
+
return e === "adhd" ? `APIGEN_${n(t)}` : `APIGEN_${n(e)}_${n(t)}`;
|
|
1547
1832
|
}
|
|
1548
|
-
function
|
|
1833
|
+
function Kt(e) {
|
|
1549
1834
|
return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
|
|
1550
1835
|
}
|
|
1551
|
-
function
|
|
1836
|
+
function Y(e) {
|
|
1552
1837
|
return e.anyOf ?? e.oneOf;
|
|
1553
1838
|
}
|
|
1554
|
-
function
|
|
1839
|
+
function zt(e) {
|
|
1555
1840
|
if (!e)
|
|
1556
1841
|
return !1;
|
|
1557
1842
|
if (e.type === "array" || e.type === "object")
|
|
1558
1843
|
return !0;
|
|
1559
|
-
const t =
|
|
1844
|
+
const t = Y(e);
|
|
1560
1845
|
if (t) {
|
|
1561
|
-
const
|
|
1562
|
-
return
|
|
1846
|
+
const n = t.filter((r) => r.type !== "null");
|
|
1847
|
+
return n.length > 0 && n.every((r) => r.type === "array" || r.type === "object");
|
|
1563
1848
|
}
|
|
1564
1849
|
return !1;
|
|
1565
1850
|
}
|
|
1566
|
-
function
|
|
1851
|
+
function Jt(e) {
|
|
1567
1852
|
if (!e)
|
|
1568
1853
|
return !1;
|
|
1569
1854
|
if (e.type === "boolean")
|
|
1570
1855
|
return !0;
|
|
1571
|
-
const t =
|
|
1856
|
+
const t = Y(e);
|
|
1572
1857
|
if (t) {
|
|
1573
|
-
const
|
|
1574
|
-
return
|
|
1858
|
+
const n = t.filter((r) => r.type !== "null");
|
|
1859
|
+
return n.length > 0 && n.every((r) => r.type === "boolean");
|
|
1575
1860
|
}
|
|
1576
1861
|
return !1;
|
|
1577
1862
|
}
|
|
1578
|
-
function
|
|
1863
|
+
function Wt(e) {
|
|
1579
1864
|
if (!e)
|
|
1580
1865
|
return !1;
|
|
1581
1866
|
if (e.type === "number" || e.type === "integer")
|
|
1582
1867
|
return !0;
|
|
1583
|
-
const t =
|
|
1868
|
+
const t = Y(e);
|
|
1584
1869
|
if (t) {
|
|
1585
|
-
const
|
|
1586
|
-
return
|
|
1870
|
+
const n = t.filter((r) => r.type !== "null");
|
|
1871
|
+
return n.length > 0 && n.every((r) => r.type === "number" || r.type === "integer");
|
|
1587
1872
|
}
|
|
1588
1873
|
return !1;
|
|
1589
1874
|
}
|
|
1590
|
-
function
|
|
1875
|
+
function Gt(e) {
|
|
1591
1876
|
return e.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
1592
1877
|
}
|
|
1593
|
-
function
|
|
1878
|
+
function Yt(e) {
|
|
1594
1879
|
var o, i;
|
|
1595
|
-
const t = (i = (o = e.input) == null ? void 0 : o.properties) == null ? void 0 : i.data,
|
|
1596
|
-
return { props:
|
|
1880
|
+
const t = (i = (o = e.input) == null ? void 0 : o.properties) == null ? void 0 : i.data, n = (t == null ? void 0 : t.properties) ?? {}, r = (t == null ? void 0 : t.required) ?? [];
|
|
1881
|
+
return { props: n, required: r };
|
|
1597
1882
|
}
|
|
1598
|
-
function
|
|
1883
|
+
function me(e) {
|
|
1599
1884
|
return typeof e.handler == "function";
|
|
1600
1885
|
}
|
|
1601
|
-
function
|
|
1886
|
+
function Zt(e) {
|
|
1602
1887
|
var o;
|
|
1603
|
-
const t = ((o = e.input) == null ? void 0 : o.properties) ?? {},
|
|
1888
|
+
const t = ((o = e.input) == null ? void 0 : o.properties) ?? {}, n = e["x-apigen-envelope"], r = [];
|
|
1604
1889
|
for (const i of Object.keys(t)) {
|
|
1605
1890
|
if (i === "data")
|
|
1606
1891
|
continue;
|
|
1607
|
-
const s = (
|
|
1608
|
-
|
|
1892
|
+
const s = (n == null ? void 0 : n[i]) ?? "adhd", a = Ft(s, i);
|
|
1893
|
+
r.push({
|
|
1609
1894
|
field: i,
|
|
1610
1895
|
pluginId: s,
|
|
1611
1896
|
httpHeader: a,
|
|
1612
1897
|
mcpMetaKey: a,
|
|
1613
|
-
cliFlag:
|
|
1614
|
-
envVar:
|
|
1898
|
+
cliFlag: Vt(s, i),
|
|
1899
|
+
envVar: Ht(s, i)
|
|
1615
1900
|
});
|
|
1616
1901
|
}
|
|
1617
|
-
return
|
|
1902
|
+
return r;
|
|
1618
1903
|
}
|
|
1619
|
-
function
|
|
1620
|
-
|
|
1621
|
-
|
|
1904
|
+
function Qt(e, t, n, r) {
|
|
1905
|
+
t === n || e.has(t) || e.set(t, { ...r, aliasOf: n });
|
|
1906
|
+
}
|
|
1907
|
+
function Xt(e, t) {
|
|
1908
|
+
const n = /* @__PURE__ */ new Map(), { props: r } = Yt(e);
|
|
1909
|
+
for (const [o, i] of Object.entries(r)) {
|
|
1622
1910
|
let s = "string";
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
valueKind: s
|
|
1627
|
-
});
|
|
1911
|
+
Jt(i) ? s = "boolean" : (zt(i) || Wt(i)) && (s = "json");
|
|
1912
|
+
const a = Gt(o), f = { camelKey: o, kind: "domain", valueKind: s };
|
|
1913
|
+
n.set(a, f), Qt(n, o, a, f);
|
|
1628
1914
|
}
|
|
1629
1915
|
for (const o of t) {
|
|
1630
|
-
const i = o.cliFlag.replace(/^--/, "")
|
|
1631
|
-
r.set(i, {
|
|
1916
|
+
const i = o.cliFlag.replace(/^--/, ""), s = {
|
|
1632
1917
|
camelKey: o.field,
|
|
1633
1918
|
kind: "envelope",
|
|
1634
1919
|
valueKind: "string",
|
|
1635
1920
|
envVar: o.envVar
|
|
1636
|
-
}
|
|
1921
|
+
};
|
|
1922
|
+
n.set(i, s);
|
|
1637
1923
|
}
|
|
1638
|
-
return
|
|
1924
|
+
return n;
|
|
1639
1925
|
}
|
|
1640
|
-
function
|
|
1641
|
-
const { op: t, schema:
|
|
1926
|
+
function Nn(e) {
|
|
1927
|
+
const { op: t, schema: n, transport: r, projection: o } = e, i = qt(t, o), s = n ? Zt(n) : [], a = n ? Xt(n, s) : /* @__PURE__ */ new Map(), f = n ? pt(n).params : void 0, u = {
|
|
1642
1928
|
op: t,
|
|
1643
|
-
transport:
|
|
1929
|
+
transport: r,
|
|
1644
1930
|
http: i.http,
|
|
1645
1931
|
mcp: i.mcp,
|
|
1646
1932
|
cli: i.cli,
|
|
@@ -1649,58 +1935,62 @@ function rr(e) {
|
|
|
1649
1935
|
envelope: s,
|
|
1650
1936
|
cliFlags: a,
|
|
1651
1937
|
streaming: t.streaming,
|
|
1652
|
-
isMount:
|
|
1938
|
+
isMount: me(t)
|
|
1653
1939
|
};
|
|
1654
|
-
if (
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1940
|
+
if (me(t)) {
|
|
1941
|
+
const c = t.handler;
|
|
1942
|
+
u.mountHandler = async (l) => c(l);
|
|
1657
1943
|
}
|
|
1658
|
-
return
|
|
1944
|
+
return u;
|
|
1659
1945
|
}
|
|
1660
|
-
function
|
|
1946
|
+
function En(e) {
|
|
1661
1947
|
const t = e.usePlugins;
|
|
1662
1948
|
return Array.isArray(t) ? t : [];
|
|
1663
1949
|
}
|
|
1664
|
-
function
|
|
1950
|
+
function _n(e) {
|
|
1951
|
+
const t = e.exitCode;
|
|
1952
|
+
return typeof t == "function" ? t : void 0;
|
|
1953
|
+
}
|
|
1954
|
+
function kn(e) {
|
|
1665
1955
|
const t = e.useOptions;
|
|
1666
1956
|
return t && typeof t == "object" ? t : {};
|
|
1667
1957
|
}
|
|
1668
|
-
function
|
|
1669
|
-
return async function(
|
|
1670
|
-
const o = Object.assign(
|
|
1671
|
-
return await e.layer(o,
|
|
1958
|
+
function en(e) {
|
|
1959
|
+
return async function(n, r) {
|
|
1960
|
+
const o = Object.assign(n, { data: n.domainArgs });
|
|
1961
|
+
return await e.layer(o, r);
|
|
1672
1962
|
};
|
|
1673
1963
|
}
|
|
1674
|
-
function
|
|
1675
|
-
var
|
|
1676
|
-
const
|
|
1964
|
+
function In(e, t) {
|
|
1965
|
+
var r;
|
|
1966
|
+
const n = [];
|
|
1677
1967
|
for (const o of t) {
|
|
1678
|
-
const i = (
|
|
1679
|
-
i &&
|
|
1968
|
+
const i = (r = o.capabilities) == null ? void 0 : r.layer;
|
|
1969
|
+
i && n.push(en(i));
|
|
1680
1970
|
}
|
|
1681
|
-
return
|
|
1971
|
+
return n.push(gt(e)), Ge(n);
|
|
1682
1972
|
}
|
|
1683
|
-
function
|
|
1973
|
+
function tn() {
|
|
1684
1974
|
const e = /* @__PURE__ */ new Map();
|
|
1685
1975
|
return {
|
|
1686
1976
|
get: (t) => e.get(t),
|
|
1687
|
-
set: (t,
|
|
1688
|
-
e.set(t,
|
|
1977
|
+
set: (t, n) => {
|
|
1978
|
+
e.set(t, n);
|
|
1689
1979
|
}
|
|
1690
1980
|
};
|
|
1691
1981
|
}
|
|
1692
|
-
const
|
|
1982
|
+
const nn = {
|
|
1693
1983
|
input: {
|
|
1694
1984
|
type: "object",
|
|
1695
1985
|
properties: { data: { type: "object", properties: {} } }
|
|
1696
1986
|
},
|
|
1697
1987
|
output: {}
|
|
1698
1988
|
};
|
|
1699
|
-
async function
|
|
1989
|
+
async function Cn(e, t, n, r) {
|
|
1700
1990
|
const o = {
|
|
1701
|
-
...
|
|
1991
|
+
...n,
|
|
1702
1992
|
operation: { id: e.op.id },
|
|
1703
|
-
ctx: new
|
|
1993
|
+
ctx: new We()
|
|
1704
1994
|
};
|
|
1705
1995
|
if (e.isMount) {
|
|
1706
1996
|
const i = e.mountHandler;
|
|
@@ -1710,58 +2000,59 @@ async function sr(e, t, r, n) {
|
|
|
1710
2000
|
);
|
|
1711
2001
|
const s = {
|
|
1712
2002
|
operation: e.op,
|
|
1713
|
-
data:
|
|
1714
|
-
envelope:
|
|
1715
|
-
ctx:
|
|
2003
|
+
data: n.domainArgs,
|
|
2004
|
+
envelope: n.envelope,
|
|
2005
|
+
ctx: tn(),
|
|
1716
2006
|
transport: e.transport,
|
|
1717
|
-
signal:
|
|
2007
|
+
signal: n.signal ?? new AbortController().signal
|
|
1718
2008
|
}, a = {
|
|
1719
|
-
...
|
|
2009
|
+
...r,
|
|
1720
2010
|
fns: { [e.op.id]: () => i(s) },
|
|
1721
|
-
schemas: { [e.op.id]:
|
|
2011
|
+
schemas: { [e.op.id]: nn }
|
|
1722
2012
|
};
|
|
1723
2013
|
return t(e.op.id, o, a);
|
|
1724
2014
|
}
|
|
1725
|
-
return t(e.op.id, o,
|
|
2015
|
+
return t(e.op.id, o, r);
|
|
1726
2016
|
}
|
|
1727
2017
|
export {
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
2018
|
+
St as BATCH_DEFAULT_CONCURRENCY,
|
|
2019
|
+
Mt as BATCH_MAX_CONCURRENCY,
|
|
2020
|
+
Ye as EventBus,
|
|
2021
|
+
gn as InstanceRegistry,
|
|
2022
|
+
We as LayerContext,
|
|
1733
2023
|
g as UnionCodecError,
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
2024
|
+
ht as ValidateSchemasToken,
|
|
2025
|
+
kt as WELL_KNOWN_TS_CODECS,
|
|
2026
|
+
en as adaptCoreLayer,
|
|
2027
|
+
at as assertNoSelfSubscription,
|
|
2028
|
+
Xe as buildContext,
|
|
2029
|
+
mn as buildFnTable,
|
|
2030
|
+
An as buildMcpOutputSchema,
|
|
2031
|
+
Nn as buildOpPlan,
|
|
2032
|
+
$n as buildToolDescription,
|
|
2033
|
+
yn as coerceQueryParams,
|
|
2034
|
+
bt as collectWithPhase,
|
|
2035
|
+
pn as createApiPackage,
|
|
2036
|
+
Ge as createInvoker,
|
|
2037
|
+
dn as createLogger,
|
|
2038
|
+
In as createPackageInvoker,
|
|
2039
|
+
wn as createStream,
|
|
2040
|
+
jt as createUnionCodec,
|
|
2041
|
+
He as dataParamNames,
|
|
2042
|
+
ln as defineMiddleware,
|
|
2043
|
+
pt as describeParams,
|
|
2044
|
+
Je as dispatch,
|
|
2045
|
+
Cn as dispatchForPlan,
|
|
2046
|
+
bn as drainStream,
|
|
2047
|
+
On as invokeBatch,
|
|
2048
|
+
vt as isApiStream,
|
|
2049
|
+
gt as makeValidateLayer,
|
|
2050
|
+
Ve as needsEnvelopeField,
|
|
2051
|
+
_n as readExitCodeHook,
|
|
2052
|
+
kn as readUseOptions,
|
|
2053
|
+
En as readUsePlugins,
|
|
2054
|
+
vn as tsHostBinding,
|
|
2055
|
+
hn as validateLayer,
|
|
2056
|
+
Qe as wireObservers,
|
|
2057
|
+
jn as wrapMcpStructuredContent
|
|
1767
2058
|
};
|