@adhd/apigen-engine-runtime 0.3.2 → 0.3.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 +15 -1
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +293 -255
- package/lib/bind-host.d.ts +25 -0
- package/package.json +3 -3
package/index.mjs
CHANGED
|
@@ -72,16 +72,16 @@ function p(e, t, n) {
|
|
|
72
72
|
let i = t.$ref;
|
|
73
73
|
if (typeof i == "string") return p(e, n.resolve(i), n);
|
|
74
74
|
let a = t.oneOf;
|
|
75
|
-
if (Array.isArray(a)) return p(e,
|
|
75
|
+
if (Array.isArray(a)) return p(e, h(e, a, t, n), n);
|
|
76
76
|
let o = t.type;
|
|
77
77
|
if (o === "array") {
|
|
78
|
-
if (!Array.isArray(e)) return
|
|
78
|
+
if (!Array.isArray(e)) return v(e, t, n);
|
|
79
79
|
let r = t.items;
|
|
80
|
-
if (!r) return e.map((e) =>
|
|
80
|
+
if (!r) return e.map((e) => x(e));
|
|
81
81
|
let i = n.path;
|
|
82
82
|
return Array.isArray(r) ? e.map((e, t) => {
|
|
83
83
|
let a = r[t];
|
|
84
|
-
return a === void 0 ?
|
|
84
|
+
return a === void 0 ? x(e) : p(e, a, {
|
|
85
85
|
...n,
|
|
86
86
|
path: `${i}/${t}`
|
|
87
87
|
});
|
|
@@ -91,9 +91,9 @@ function p(e, t, n) {
|
|
|
91
91
|
}));
|
|
92
92
|
}
|
|
93
93
|
if (o === "object") {
|
|
94
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return
|
|
94
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return v(e, t, n);
|
|
95
95
|
let r = t.properties;
|
|
96
|
-
if (!r) return
|
|
96
|
+
if (!r) return x(e);
|
|
97
97
|
let i = n.path, a = {};
|
|
98
98
|
for (let [t, o] of Object.entries(r)) {
|
|
99
99
|
let r = e[t];
|
|
@@ -104,7 +104,7 @@ function p(e, t, n) {
|
|
|
104
104
|
}
|
|
105
105
|
return a;
|
|
106
106
|
}
|
|
107
|
-
return o == null ?
|
|
107
|
+
return o == null ? v(e, t, n) : x(e);
|
|
108
108
|
}
|
|
109
109
|
function m(e, t, n) {
|
|
110
110
|
let r = n.registry.resolve(t);
|
|
@@ -112,7 +112,7 @@ function m(e, t, n) {
|
|
|
112
112
|
let i = t.$ref;
|
|
113
113
|
if (typeof i == "string") return m(e, n.resolve(i), n);
|
|
114
114
|
let a = t.oneOf;
|
|
115
|
-
if (Array.isArray(a)) return m(e,
|
|
115
|
+
if (Array.isArray(a)) return m(e, h(e, a, t, n), n);
|
|
116
116
|
let o = t.type;
|
|
117
117
|
if (o === "array") {
|
|
118
118
|
if (!Array.isArray(e)) return e;
|
|
@@ -145,9 +145,9 @@ function m(e, t, n) {
|
|
|
145
145
|
for (let [t, n] of Object.entries(e)) !(t in r) && n !== void 0 && (a[t] = n);
|
|
146
146
|
return a;
|
|
147
147
|
}
|
|
148
|
-
return o == null ?
|
|
148
|
+
return o == null ? b(e, n) : e;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function h(e, t, n, r) {
|
|
151
151
|
let i = n.discriminator;
|
|
152
152
|
if (i?.propertyName) {
|
|
153
153
|
let n = i.propertyName, a = typeof e == "object" && e ? e[n] : void 0;
|
|
@@ -160,67 +160,67 @@ function ee(e, t, n, r) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
for (let e of t) {
|
|
163
|
-
let t =
|
|
163
|
+
let t = g(e, r).properties?.[n];
|
|
164
164
|
if (!t) continue;
|
|
165
165
|
let i = t.enum;
|
|
166
166
|
if (t.const === a || Array.isArray(i) && i.includes(a)) return e;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let a =
|
|
170
|
+
let a = te(e, t, r);
|
|
171
171
|
if (a) return a;
|
|
172
172
|
let o, s = -1;
|
|
173
173
|
for (let n of t) {
|
|
174
|
-
let t =
|
|
174
|
+
let t = _(e, g(n, r), r);
|
|
175
175
|
t !== null && t > s && (s = t, o = n);
|
|
176
176
|
}
|
|
177
177
|
return o === void 0 ? t[0] ?? {} : o;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function g(e, t) {
|
|
180
180
|
let n = e.$ref;
|
|
181
181
|
return typeof n == "string" ? t.resolve(n) : e;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function ee(e) {
|
|
184
184
|
if ("const" in e) return e.const;
|
|
185
185
|
let t = e.enum;
|
|
186
186
|
if (Array.isArray(t) && t.length === 1) return t[0];
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function te(e, t, n) {
|
|
189
189
|
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
190
|
-
let r = e, i = t.map((e) =>
|
|
190
|
+
let r = e, i = t.map((e) => g(e, n)), a = /* @__PURE__ */ new Set();
|
|
191
191
|
for (let e of i) {
|
|
192
192
|
let t = e.properties;
|
|
193
|
-
if (t) for (let [e, n] of Object.entries(t))
|
|
193
|
+
if (t) for (let [e, n] of Object.entries(t)) ee(n) !== void 0 && a.add(e);
|
|
194
194
|
}
|
|
195
195
|
for (let o of a) {
|
|
196
196
|
let a = i.map((e) => {
|
|
197
197
|
let t = e.properties?.[o];
|
|
198
|
-
return t ?
|
|
198
|
+
return t ? ee(t) : void 0;
|
|
199
199
|
}), s = a.filter((e) => e !== void 0), c = new Set(s);
|
|
200
200
|
if (s.length < 2 || c.size !== s.length) continue;
|
|
201
201
|
let l = r[o];
|
|
202
202
|
if (l === void 0) continue;
|
|
203
203
|
let u = a.findIndex((e) => e === l);
|
|
204
|
-
if (u !== -1 &&
|
|
204
|
+
if (u !== -1 && _(e, i[u], n) !== null) return t[u];
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function ne(e) {
|
|
208
208
|
if (e === null) return "null";
|
|
209
209
|
if (Array.isArray(e)) return "array";
|
|
210
210
|
let t = typeof e;
|
|
211
211
|
return t === "number" ? Number.isInteger(e) ? "integer" : "number" : t;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function _(e, t, n) {
|
|
214
214
|
let r = t.oneOf;
|
|
215
215
|
if (Array.isArray(r)) {
|
|
216
216
|
let t = null;
|
|
217
217
|
for (let i of r) {
|
|
218
|
-
let r =
|
|
218
|
+
let r = _(e, g(i, n), n);
|
|
219
219
|
r !== null && (t === null || r > t) && (t = r);
|
|
220
220
|
}
|
|
221
221
|
return t;
|
|
222
222
|
}
|
|
223
|
-
let i = t.type, a =
|
|
223
|
+
let i = t.type, a = ne(e);
|
|
224
224
|
if (typeof i == "string") {
|
|
225
225
|
if (!(i === a || i === "number" && a === "integer")) return null;
|
|
226
226
|
} else if (Array.isArray(i) && !i.some((e) => e === a || e === "number" && a === "integer")) return null;
|
|
@@ -239,7 +239,7 @@ function g(e, t, n) {
|
|
|
239
239
|
}
|
|
240
240
|
return c;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function v(e, t, n) {
|
|
243
243
|
for (let t of n.registry.ids()) {
|
|
244
244
|
let r = n.registry.get(t);
|
|
245
245
|
if (r?.ownsValue?.(e)) return {
|
|
@@ -247,43 +247,43 @@ function _(e, t, n) {
|
|
|
247
247
|
v: r.encode(e, r.schema, n)
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
251
|
-
if (
|
|
250
|
+
if (Array.isArray(e)) return e.map((e) => v(e, {}, n));
|
|
251
|
+
if (y(e)) {
|
|
252
252
|
let t = {};
|
|
253
|
-
for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] =
|
|
253
|
+
for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] = v(i, {}, n));
|
|
254
254
|
return t;
|
|
255
255
|
}
|
|
256
|
-
return
|
|
256
|
+
return x(e);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function y(e) {
|
|
259
259
|
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
260
260
|
let t = Object.getPrototypeOf(e);
|
|
261
261
|
return t === Object.prototype || t === null;
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function b(e, t) {
|
|
264
264
|
if (typeof e == "object" && e && !Array.isArray(e) && "$apigen" in e) {
|
|
265
265
|
let n = e, r = n[i], a = t.registry.get(r);
|
|
266
266
|
if (a) return a.decode(n.v, a.schema, t);
|
|
267
267
|
}
|
|
268
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
269
|
-
if (
|
|
268
|
+
if (Array.isArray(e)) return e.map((e) => b(e, t));
|
|
269
|
+
if (y(e)) {
|
|
270
270
|
let n = {};
|
|
271
|
-
for (let [r, i] of Object.entries(e)) n[r] =
|
|
271
|
+
for (let [r, i] of Object.entries(e)) n[r] = b(i, t);
|
|
272
272
|
return n;
|
|
273
273
|
}
|
|
274
274
|
return e;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function x(e) {
|
|
277
277
|
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean") return e;
|
|
278
|
-
if (Array.isArray(e)) return e.map(
|
|
278
|
+
if (Array.isArray(e)) return e.map(x);
|
|
279
279
|
if (typeof e == "object") {
|
|
280
280
|
let t = {};
|
|
281
|
-
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] =
|
|
281
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = x(r));
|
|
282
282
|
return t;
|
|
283
283
|
}
|
|
284
284
|
return null;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function re(e, t) {
|
|
287
287
|
let n = /* @__PURE__ */ new Set(), r = [e];
|
|
288
288
|
for (; r.length > 0;) {
|
|
289
289
|
let e = r.pop();
|
|
@@ -314,7 +314,7 @@ function ie(e, t) {
|
|
|
314
314
|
typeof l == "object" && l && r.push(l);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function ie(e) {
|
|
318
318
|
return {
|
|
319
319
|
encode(t, n, r) {
|
|
320
320
|
return p(t, n, f(e, r));
|
|
@@ -326,7 +326,7 @@ function ae(e) {
|
|
|
326
326
|
}
|
|
327
327
|
//#endregion
|
|
328
328
|
//#region ../apigen-base-logical/src/lib/codecs/date-time.ts
|
|
329
|
-
var
|
|
329
|
+
var S = {
|
|
330
330
|
id: "date-time",
|
|
331
331
|
kind: "scalar",
|
|
332
332
|
schema: {
|
|
@@ -350,7 +350,7 @@ var x = {
|
|
|
350
350
|
if (n.mode === "strict" && Number.isNaN(new Date(e).getTime())) throw TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`);
|
|
351
351
|
return new Date(e);
|
|
352
352
|
}
|
|
353
|
-
},
|
|
353
|
+
}, C = {
|
|
354
354
|
id: "int64",
|
|
355
355
|
kind: "scalar",
|
|
356
356
|
schema: {
|
|
@@ -386,10 +386,10 @@ var x = {
|
|
|
386
386
|
};
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region ../apigen-base-logical/src/lib/codecs/decimal.ts
|
|
389
|
-
function
|
|
389
|
+
function ae(e) {
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
|
-
var
|
|
392
|
+
var w = {
|
|
393
393
|
id: "decimal",
|
|
394
394
|
kind: "scalar",
|
|
395
395
|
schema: {
|
|
@@ -405,12 +405,12 @@ var C = {
|
|
|
405
405
|
decode(e, t, n) {
|
|
406
406
|
if (typeof e != "string") {
|
|
407
407
|
if (n.mode === "strict") throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
408
|
-
return
|
|
408
|
+
return ae(String(e));
|
|
409
409
|
}
|
|
410
410
|
if (n.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e)) throw TypeError(`[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`);
|
|
411
|
-
return
|
|
411
|
+
return ae(e);
|
|
412
412
|
}
|
|
413
|
-
},
|
|
413
|
+
}, T = {
|
|
414
414
|
id: "byte",
|
|
415
415
|
kind: "scalar",
|
|
416
416
|
schema: {
|
|
@@ -434,7 +434,7 @@ var C = {
|
|
|
434
434
|
if (n.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e)) throw TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${e}"`);
|
|
435
435
|
return new Uint8Array(Buffer.from(e, "base64"));
|
|
436
436
|
}
|
|
437
|
-
},
|
|
437
|
+
}, oe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, E = {
|
|
438
438
|
id: "uuid",
|
|
439
439
|
kind: "scalar",
|
|
440
440
|
schema: {
|
|
@@ -452,14 +452,14 @@ var C = {
|
|
|
452
452
|
if (n.mode === "strict") throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
453
453
|
return String(e).toLowerCase();
|
|
454
454
|
}
|
|
455
|
-
if (n.mode === "strict" && !
|
|
455
|
+
if (n.mode === "strict" && !oe.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
|
|
456
456
|
return e;
|
|
457
457
|
}
|
|
458
|
-
},
|
|
459
|
-
E,
|
|
458
|
+
}, D = "NaN", O = "Infinity", k = "-Infinity", se = /* @__PURE__ */ new Set([
|
|
460
459
|
D,
|
|
461
|
-
O
|
|
462
|
-
|
|
460
|
+
O,
|
|
461
|
+
k
|
|
462
|
+
]), A = {
|
|
463
463
|
id: "number-special",
|
|
464
464
|
kind: "scalar",
|
|
465
465
|
schema: { type: "number" },
|
|
@@ -470,49 +470,49 @@ var C = {
|
|
|
470
470
|
return typeof e == "number" && !Number.isFinite(e);
|
|
471
471
|
},
|
|
472
472
|
encode(e, t, n) {
|
|
473
|
-
return Number.isNaN(e) ?
|
|
473
|
+
return Number.isNaN(e) ? D : e === Infinity ? O : e === -Infinity ? k : e;
|
|
474
474
|
},
|
|
475
475
|
decode(e, t, n) {
|
|
476
476
|
if (typeof e == "number") return e;
|
|
477
477
|
if (typeof e == "string") {
|
|
478
|
-
if (e ===
|
|
479
|
-
if (e ===
|
|
480
|
-
if (e ===
|
|
478
|
+
if (e === D) return NaN;
|
|
479
|
+
if (e === O) return Infinity;
|
|
480
|
+
if (e === k) return -Infinity;
|
|
481
481
|
let t = Number(e);
|
|
482
482
|
if (!Number.isNaN(t)) return t;
|
|
483
483
|
}
|
|
484
|
-
if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...
|
|
484
|
+
if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...se].join(", ")}.`);
|
|
485
485
|
return NaN;
|
|
486
486
|
}
|
|
487
|
-
},
|
|
488
|
-
x,
|
|
487
|
+
}, ce = [
|
|
489
488
|
S,
|
|
490
489
|
C,
|
|
491
490
|
w,
|
|
492
491
|
T,
|
|
493
|
-
|
|
492
|
+
E,
|
|
493
|
+
A
|
|
494
494
|
];
|
|
495
|
-
function
|
|
496
|
-
for (let n of
|
|
495
|
+
function le(e, t = {}) {
|
|
496
|
+
for (let n of ce) e.register(n, { override: t.override ?? !1 });
|
|
497
497
|
}
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region ../apigen-base-logical/src/lib/example.ts
|
|
500
|
-
var
|
|
501
|
-
function
|
|
500
|
+
var ue = 12;
|
|
501
|
+
function de(e, t) {
|
|
502
502
|
let n = /^#\/(definitions|\$defs)\/(.+)$/.exec(e);
|
|
503
503
|
if (!n) return;
|
|
504
504
|
let [, r, i] = n;
|
|
505
505
|
return (r === "$defs" ? t.$defs : t.definitions)?.[decodeURIComponent(i)];
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function j(e) {
|
|
508
508
|
return Array.isArray(e) && e.length > 0 ? e[0] : void 0;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function fe(e) {
|
|
511
511
|
if (Array.isArray(e.type)) return e.type.find((e) => e !== "null") ?? e.type[0];
|
|
512
512
|
if (typeof e.type == "string") return e.type;
|
|
513
513
|
if (e.properties) return "object";
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function pe(e) {
|
|
516
516
|
switch (e.format) {
|
|
517
517
|
case "date-time": return "1970-01-01T00:00:00.000Z";
|
|
518
518
|
case "date": return "1970-01-01";
|
|
@@ -531,23 +531,23 @@ function he(e) {
|
|
|
531
531
|
default: return "<string>";
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function me(e, t, n) {
|
|
535
535
|
let r = e.properties ?? {}, i = e.required ?? [], a = {};
|
|
536
536
|
for (let e of i) {
|
|
537
537
|
let i = r[e];
|
|
538
|
-
a[e] = i === void 0 ? `<${e}>` :
|
|
538
|
+
a[e] = i === void 0 ? `<${e}>` : M(i, t, n + 1);
|
|
539
539
|
}
|
|
540
540
|
return a;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function he(e, t, n) {
|
|
543
543
|
let r = Array.isArray(e.items) ? e.items[0] : e.items;
|
|
544
|
-
return r ? [
|
|
544
|
+
return r ? [M(r, t, n + 1)] : [];
|
|
545
545
|
}
|
|
546
|
-
function
|
|
547
|
-
if (!e || n >
|
|
546
|
+
function M(e, t = e ?? {}, n = 0) {
|
|
547
|
+
if (!e || n > ue) return null;
|
|
548
548
|
if (typeof e.$ref == "string") {
|
|
549
|
-
let r =
|
|
550
|
-
return r === void 0 ? null :
|
|
549
|
+
let r = de(e.$ref, t);
|
|
550
|
+
return r === void 0 ? null : M(r, t, n + 1);
|
|
551
551
|
}
|
|
552
552
|
if (e.const !== void 0) return e.const;
|
|
553
553
|
if (Array.isArray(e.enum) && e.enum.length > 0) return e.enum[0];
|
|
@@ -557,18 +557,18 @@ function j(e, t = e ?? {}, n = 0) {
|
|
|
557
557
|
Object.assign(r, t.properties ?? {});
|
|
558
558
|
for (let e of t.required ?? []) i.includes(e) || i.push(e);
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return me({
|
|
561
561
|
...e,
|
|
562
562
|
properties: r,
|
|
563
563
|
required: i
|
|
564
564
|
}, t, n);
|
|
565
565
|
}
|
|
566
|
-
let r =
|
|
567
|
-
if (r) return
|
|
568
|
-
switch (
|
|
569
|
-
case "object": return
|
|
570
|
-
case "array": return
|
|
571
|
-
case "string": return
|
|
566
|
+
let r = j(e.oneOf) ?? j(e.anyOf);
|
|
567
|
+
if (r) return M(r, t, n + 1);
|
|
568
|
+
switch (fe(e)) {
|
|
569
|
+
case "object": return me(e, t, n);
|
|
570
|
+
case "array": return he(e, t, n);
|
|
571
|
+
case "string": return pe(e);
|
|
572
572
|
case "integer":
|
|
573
573
|
case "number": return 0;
|
|
574
574
|
case "boolean": return !1;
|
|
@@ -576,12 +576,12 @@ function j(e, t = e ?? {}, n = 0) {
|
|
|
576
576
|
default: return null;
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function ge(e) {
|
|
580
580
|
if (!e) return;
|
|
581
|
-
let t =
|
|
581
|
+
let t = M(e);
|
|
582
582
|
return `Example: ${JSON.stringify(t)}`;
|
|
583
583
|
}
|
|
584
|
-
|
|
584
|
+
S.id, C.id, w.id, T.id, E.id, A.id, Object.freeze({
|
|
585
585
|
typescript: {
|
|
586
586
|
"date-time": {
|
|
587
587
|
encode: "$.toISOString()",
|
|
@@ -805,42 +805,42 @@ x.id, S.id, C.id, w.id, T.id, k.id, Object.freeze({
|
|
|
805
805
|
});
|
|
806
806
|
//#endregion
|
|
807
807
|
//#region src/lib/dispatch.ts
|
|
808
|
-
var
|
|
809
|
-
|
|
810
|
-
var
|
|
811
|
-
function
|
|
808
|
+
var N = o();
|
|
809
|
+
le(N);
|
|
810
|
+
var _e = ie(N.freeze());
|
|
811
|
+
function ve(e, t) {
|
|
812
812
|
return t in (e.input?.properties ?? {});
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function ye(e) {
|
|
815
815
|
let t = e.input?.properties?.data;
|
|
816
816
|
return Object.keys(t?.properties ?? {});
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function be(e, t) {
|
|
819
819
|
let n = e.input?.properties?.data?.properties?.[t];
|
|
820
820
|
return n === void 0 ? void 0 : n;
|
|
821
821
|
}
|
|
822
|
-
function
|
|
823
|
-
return t === void 0 || e === void 0 ? e :
|
|
822
|
+
function xe(e, t) {
|
|
823
|
+
return t === void 0 || e === void 0 ? e : _e.decode(e, t);
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function P(e, t) {
|
|
826
826
|
let n = t.output;
|
|
827
|
-
return !n || Object.keys(n).length === 0 ? e :
|
|
827
|
+
return !n || Object.keys(n).length === 0 ? e : _e.encode(e, n);
|
|
828
828
|
}
|
|
829
|
-
async function
|
|
830
|
-
let o =
|
|
831
|
-
if (
|
|
829
|
+
async function Se(e, t, n, r, i, a) {
|
|
830
|
+
let o = ye(n).map((e) => xe(a[e], be(n, e)));
|
|
831
|
+
if (ve(n, "session") && t) {
|
|
832
832
|
let a = await t({ session: i.session });
|
|
833
|
-
return
|
|
833
|
+
return P(await e[r](a, ...o), n);
|
|
834
834
|
}
|
|
835
835
|
if (n.hasCtx) {
|
|
836
836
|
let a = t ? await t(i) : void 0;
|
|
837
|
-
return
|
|
837
|
+
return P(await e[r](a, ...o), n);
|
|
838
838
|
}
|
|
839
|
-
return
|
|
839
|
+
return P(await e[r](...o), n);
|
|
840
840
|
}
|
|
841
841
|
//#endregion
|
|
842
842
|
//#region src/lib/invoke.ts
|
|
843
|
-
var
|
|
843
|
+
var Ce = class {
|
|
844
844
|
constructor() {
|
|
845
845
|
this._map = /* @__PURE__ */ new Map();
|
|
846
846
|
}
|
|
@@ -854,21 +854,21 @@ var R = class {
|
|
|
854
854
|
return this._map.has(e);
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
|
-
function
|
|
857
|
+
function we(e = []) {
|
|
858
858
|
return async function(t, n, r) {
|
|
859
859
|
let i = r.schemas[t];
|
|
860
860
|
if (!i) throw Error(`apigen/invoke: no schema found for operation "${t}"`);
|
|
861
|
-
return e.reduceRight((e, t) => () => t(n, e), () =>
|
|
861
|
+
return e.reduceRight((e, t) => () => t(n, e), () => Se(r.fns, r.createClient, i, t, n.envelope, n.domainArgs))();
|
|
862
862
|
};
|
|
863
863
|
}
|
|
864
864
|
//#endregion
|
|
865
865
|
//#region src/lib/define-middleware.ts
|
|
866
|
-
function
|
|
866
|
+
function Te(e) {
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
869
|
//#endregion
|
|
870
870
|
//#region src/lib/event-bus.ts
|
|
871
|
-
var
|
|
871
|
+
var Ee = class {
|
|
872
872
|
constructor() {
|
|
873
873
|
this.handlers = /* @__PURE__ */ new Map();
|
|
874
874
|
}
|
|
@@ -886,19 +886,19 @@ var xe = class {
|
|
|
886
886
|
this.handlers.clear();
|
|
887
887
|
}
|
|
888
888
|
async emit(e) {
|
|
889
|
-
for (let [t, n] of this.handlers) if (
|
|
889
|
+
for (let [t, n] of this.handlers) if (De(t, e)) for (let t of n) await t(e);
|
|
890
890
|
}
|
|
891
891
|
};
|
|
892
|
-
function
|
|
892
|
+
function De(e, t) {
|
|
893
893
|
let [n, r, i] = e.split(":");
|
|
894
894
|
return !(n !== "*" && n !== t.module || r && r !== "*" && r !== t.method || i && i !== "*" && i !== t.lifecycle);
|
|
895
895
|
}
|
|
896
|
-
function
|
|
896
|
+
function Oe(e, t) {
|
|
897
897
|
for (let n of e) if (n.eventMapping) for (let [e, r] of Object.entries(n.eventMapping)) t.on(e, r);
|
|
898
898
|
}
|
|
899
899
|
//#endregion
|
|
900
900
|
//#region src/lib/build-context.ts
|
|
901
|
-
async function
|
|
901
|
+
async function ke(e, t, n) {
|
|
902
902
|
let r = { ...t };
|
|
903
903
|
for (let t of e) if (t.createContext) {
|
|
904
904
|
await n.emit({
|
|
@@ -933,31 +933,49 @@ async function we(e, t, n) {
|
|
|
933
933
|
e(import.meta.url);
|
|
934
934
|
//#endregion
|
|
935
935
|
//#region ../apigen-core-client/src/lib/get-safety.ts
|
|
936
|
-
var
|
|
936
|
+
var F = /* @__PURE__ */ new Set([
|
|
937
937
|
"string",
|
|
938
938
|
"number",
|
|
939
939
|
"boolean",
|
|
940
940
|
"integer"
|
|
941
941
|
]);
|
|
942
|
-
function
|
|
942
|
+
function Ae(e) {
|
|
943
|
+
if (!Array.isArray(e) || e.length < 2) return !1;
|
|
944
|
+
let t = 0;
|
|
945
|
+
for (let n of e) {
|
|
946
|
+
if (typeof n != "object" || !n) return !1;
|
|
947
|
+
let { type: e, $ref: r, oneOf: i, anyOf: a, allOf: o } = n;
|
|
948
|
+
if (r !== void 0 || i || a || o) return !1;
|
|
949
|
+
if (e !== "null") {
|
|
950
|
+
if (typeof e == "string" && F.has(e)) {
|
|
951
|
+
t++;
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
return !1;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return t === 1;
|
|
958
|
+
}
|
|
959
|
+
function je(e) {
|
|
943
960
|
if (typeof e != "object" || !e) return !1;
|
|
944
961
|
let t = e;
|
|
945
|
-
if (t.$ref !== void 0 || t.
|
|
962
|
+
if (t.$ref !== void 0 || t.allOf) return !1;
|
|
963
|
+
if (t.oneOf || t.anyOf) return Ae(t.oneOf ?? t.anyOf);
|
|
946
964
|
let { type: n } = t;
|
|
947
|
-
return typeof n == "string" ?
|
|
965
|
+
return typeof n == "string" ? F.has(n) : Array.isArray(n) ? n.every((e) => F.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
|
|
948
966
|
"string",
|
|
949
967
|
"number",
|
|
950
968
|
"boolean"
|
|
951
969
|
].includes(typeof e)) : !1;
|
|
952
970
|
}
|
|
953
|
-
function
|
|
971
|
+
function I(e) {
|
|
954
972
|
if (!e || typeof e != "object") return !1;
|
|
955
973
|
let t = e.properties;
|
|
956
|
-
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(
|
|
974
|
+
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(je);
|
|
957
975
|
}
|
|
958
976
|
//#endregion
|
|
959
977
|
//#region ../apigen-core-client/src/lib/compose-schemas.ts
|
|
960
|
-
function
|
|
978
|
+
function Me(e) {
|
|
961
979
|
let t = {}, n = (e) => {
|
|
962
980
|
for (let n of ["definitions", "$defs"]) {
|
|
963
981
|
let r = e[n];
|
|
@@ -969,17 +987,17 @@ function Oe(e) {
|
|
|
969
987
|
};
|
|
970
988
|
for (let t of Object.values(e.schemas)) n(t.input), n(t.output);
|
|
971
989
|
if (Object.keys(t).length !== 0) for (let [n, r] of Object.entries(e.schemas)) try {
|
|
972
|
-
|
|
990
|
+
re(r.input, t), re(r.output, t);
|
|
973
991
|
} catch (e) {
|
|
974
992
|
throw Error(`[apigen-core-client] Schema validation failed for function "${n}": ${e.message}`);
|
|
975
993
|
}
|
|
976
994
|
}
|
|
977
|
-
function
|
|
995
|
+
function Ne(e, t) {
|
|
978
996
|
let n = ["apigen calling convention: all domain parameters go inside a \"data\" envelope — e.g. { \"data\": { ... } }" + (t ? "." : " (an empty object for this zero-parameter tool).")];
|
|
979
997
|
return e.length > 0 && n.push(`Field(s) ${e.map((e) => `"${e}"`).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.`), n.join(" ");
|
|
980
998
|
}
|
|
981
|
-
function
|
|
982
|
-
|
|
999
|
+
function Pe(e, t, n) {
|
|
1000
|
+
Me(e);
|
|
983
1001
|
let r = {};
|
|
984
1002
|
for (let [i, a] of Object.entries(e.schemas)) {
|
|
985
1003
|
let e = n?.[i] ?? {}, o = a.input.properties ?? {}, s = a.input.required ?? [], c = {}, l = [], u = {};
|
|
@@ -989,7 +1007,7 @@ function Ae(e, t, n) {
|
|
|
989
1007
|
properties: o,
|
|
990
1008
|
additionalProperties: !1,
|
|
991
1009
|
...s.length > 0 ? { required: s } : {}
|
|
992
|
-
}, f = a.safe === !0 ||
|
|
1010
|
+
}, f = a.safe === !0 || I(a.input), p = a.input.definitions, m = a.input.$defs;
|
|
993
1011
|
r[i] = {
|
|
994
1012
|
input: {
|
|
995
1013
|
type: "object",
|
|
@@ -999,7 +1017,7 @@ function Ae(e, t, n) {
|
|
|
999
1017
|
},
|
|
1000
1018
|
required: [...l, ...s.length > 0 ? ["data"] : []],
|
|
1001
1019
|
additionalProperties: !1,
|
|
1002
|
-
description:
|
|
1020
|
+
description: Ne(Object.keys(c), Object.keys(o).length > 0),
|
|
1003
1021
|
...p ? { definitions: p } : {},
|
|
1004
1022
|
...m ? { $defs: m } : {}
|
|
1005
1023
|
},
|
|
@@ -1013,53 +1031,53 @@ function Ae(e, t, n) {
|
|
|
1013
1031
|
}
|
|
1014
1032
|
//#endregion
|
|
1015
1033
|
//#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
|
|
1016
|
-
var
|
|
1017
|
-
function
|
|
1034
|
+
var Fe = { "decimal.js": "Decimal" };
|
|
1035
|
+
function Ie(e) {
|
|
1018
1036
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1019
1037
|
}
|
|
1020
|
-
Object.entries(
|
|
1021
|
-
pattern: RegExp(`import\\(["'][^"']*${
|
|
1038
|
+
Object.entries(Fe).map(([e, t]) => ({
|
|
1039
|
+
pattern: RegExp(`import\\(["'][^"']*${Ie(e)}[^"']*["']\\)\\.\\w+`, "g"),
|
|
1022
1040
|
key: t
|
|
1023
1041
|
}));
|
|
1024
1042
|
//#endregion
|
|
1025
1043
|
//#region src/lib/types.ts
|
|
1026
|
-
var
|
|
1044
|
+
var L = class extends Error {
|
|
1027
1045
|
constructor(e) {
|
|
1028
1046
|
super(e), this.name = "ConfigurationError";
|
|
1029
1047
|
}
|
|
1030
1048
|
};
|
|
1031
1049
|
//#endregion
|
|
1032
1050
|
//#region src/lib/api-package.ts
|
|
1033
|
-
function
|
|
1051
|
+
function R(e) {
|
|
1034
1052
|
for (let t of e) for (let e of Object.keys(t.eventMapping ?? {})) {
|
|
1035
1053
|
let [n] = e.split(":");
|
|
1036
|
-
if (n !== "*" && n === t.id) throw new
|
|
1054
|
+
if (n !== "*" && n === t.id) throw new L(`Middleware "${t.id}" subscribes to its own events via "${e}". This would cause infinite recursion.`);
|
|
1037
1055
|
}
|
|
1038
1056
|
}
|
|
1039
|
-
function
|
|
1057
|
+
function Le(e) {
|
|
1040
1058
|
let { domainSchemas: t, middlewares: n, overrides: r = {}, strict: i = !1 } = e;
|
|
1041
|
-
|
|
1059
|
+
R(n);
|
|
1042
1060
|
for (let e of Object.keys(r)) if (!(e in t.schemas)) {
|
|
1043
1061
|
let t = `Override key "${e}" not found in domain schemas.`;
|
|
1044
|
-
if (i) throw new
|
|
1062
|
+
if (i) throw new L(t);
|
|
1045
1063
|
console.warn("[apigen-runtime]", t);
|
|
1046
1064
|
}
|
|
1047
1065
|
let a = new Set(n.map((e) => e.id));
|
|
1048
1066
|
for (let [e, t] of Object.entries(r)) for (let n of Object.keys(t ?? {})) if (!a.has(n)) {
|
|
1049
1067
|
let t = `Override key "${e}.${n}" does not match any declared middleware id.`;
|
|
1050
|
-
if (i) throw new
|
|
1068
|
+
if (i) throw new L(t);
|
|
1051
1069
|
console.warn("[apigen-runtime]", t);
|
|
1052
1070
|
}
|
|
1053
|
-
let o =
|
|
1054
|
-
return
|
|
1071
|
+
let o = Pe(t, n, r), s = new Ee();
|
|
1072
|
+
return Oe(n, s), {
|
|
1055
1073
|
schemas: o,
|
|
1056
|
-
createClient: async (e) =>
|
|
1074
|
+
createClient: async (e) => ke(n, e, s),
|
|
1057
1075
|
dispose: () => s.clear()
|
|
1058
1076
|
};
|
|
1059
1077
|
}
|
|
1060
1078
|
//#endregion
|
|
1061
1079
|
//#region src/lib/logger.ts
|
|
1062
|
-
function
|
|
1080
|
+
function Re(e = {}) {
|
|
1063
1081
|
let n = e.level ?? "info", r = typeof e.destination == "string" && e.destination.length > 0, i = !r && !!process.stderr.isTTY, a = e.format ?? (i ? "pretty" : "json"), o = { level: n };
|
|
1064
1082
|
if (a === "pretty") return o.transport = {
|
|
1065
1083
|
target: "pino-pretty",
|
|
@@ -1082,35 +1100,35 @@ function Fe(e = {}) {
|
|
|
1082
1100
|
}
|
|
1083
1101
|
//#endregion
|
|
1084
1102
|
//#region src/lib/describe-params.ts
|
|
1085
|
-
function
|
|
1103
|
+
function ze(e) {
|
|
1086
1104
|
if (e?.type !== "object" || !e.properties) return;
|
|
1087
1105
|
let t = Object.entries(e.properties);
|
|
1088
1106
|
if (t.length === 0) return;
|
|
1089
1107
|
let n = new Set(e.required ?? []);
|
|
1090
|
-
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${
|
|
1108
|
+
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${z(t)}`).join(", ")} }`;
|
|
1091
1109
|
}
|
|
1092
|
-
function
|
|
1110
|
+
function Be(e) {
|
|
1093
1111
|
return typeof e == "string" ? `'${e}'` : JSON.stringify(e);
|
|
1094
1112
|
}
|
|
1095
|
-
function
|
|
1113
|
+
function Ve(e) {
|
|
1096
1114
|
let t = e.enum ?? [];
|
|
1097
|
-
return t.length === 0 ? "unknown" : t.map(
|
|
1115
|
+
return t.length === 0 ? "unknown" : t.map(Be).join("|");
|
|
1098
1116
|
}
|
|
1099
|
-
function
|
|
1100
|
-
return e.map((e) =>
|
|
1117
|
+
function He(e, t) {
|
|
1118
|
+
return e.map((e) => z(e, t)).join(" | ");
|
|
1101
1119
|
}
|
|
1102
|
-
function
|
|
1120
|
+
function z(e, t = 0) {
|
|
1103
1121
|
if (!e) return "unknown";
|
|
1104
|
-
if (e.type === "array") return `${
|
|
1105
|
-
if (e.enum) return
|
|
1122
|
+
if (e.type === "array") return `${z(e.items, 0)}[]`;
|
|
1123
|
+
if (e.enum) return Ve(e);
|
|
1106
1124
|
if (e.$ref) return String(e.$ref).split("/").pop() || "object";
|
|
1107
1125
|
let n = e.anyOf ?? e.oneOf;
|
|
1108
|
-
return n ? n.length === 0 ? "unknown" : t >= 2 ?
|
|
1126
|
+
return n ? n.length === 0 ? "unknown" : t >= 2 ? He(n, t - 1) : "union" : t >= 1 && e.type === "object" ? ze(e) ?? "object" : e.type ?? "object";
|
|
1109
1127
|
}
|
|
1110
|
-
function
|
|
1128
|
+
function B(e) {
|
|
1111
1129
|
let t = (e?.input ?? {}).properties?.data, n = t?.properties ?? {}, r = new Set(t?.required ?? []), i = Object.entries(n).map(([e, t]) => ({
|
|
1112
1130
|
name: e,
|
|
1113
|
-
type:
|
|
1131
|
+
type: z(t, 2),
|
|
1114
1132
|
required: r.has(e)
|
|
1115
1133
|
}));
|
|
1116
1134
|
return {
|
|
@@ -1120,16 +1138,16 @@ function Be(e) {
|
|
|
1120
1138
|
}
|
|
1121
1139
|
//#endregion
|
|
1122
1140
|
//#region src/lib/coerce-query.ts
|
|
1123
|
-
function
|
|
1141
|
+
function Ue(e) {
|
|
1124
1142
|
let t;
|
|
1125
1143
|
return t = Array.isArray(e) ? e : e ? [e] : [], t.find((e) => e === "number" || e === "integer" || e === "boolean");
|
|
1126
1144
|
}
|
|
1127
|
-
function
|
|
1145
|
+
function We(e, t) {
|
|
1128
1146
|
let n = (t?.input ?? {}).properties?.data?.properties ?? {}, r = { ...e };
|
|
1129
1147
|
for (let [e, t] of Object.entries(n)) {
|
|
1130
1148
|
let n = r[e];
|
|
1131
1149
|
if (typeof n != "string") continue;
|
|
1132
|
-
let i =
|
|
1150
|
+
let i = Ue(t?.type);
|
|
1133
1151
|
if (i === "number" || i === "integer") {
|
|
1134
1152
|
let t = Number(n);
|
|
1135
1153
|
!Number.isNaN(t) && n.trim() !== "" && (r[e] = t);
|
|
@@ -1139,24 +1157,24 @@ function He(e, t) {
|
|
|
1139
1157
|
}
|
|
1140
1158
|
//#endregion
|
|
1141
1159
|
//#region src/lib/fn-table.ts
|
|
1142
|
-
var
|
|
1160
|
+
var V = /* @__PURE__ */ new Set([
|
|
1143
1161
|
"default",
|
|
1144
1162
|
"module.exports",
|
|
1145
1163
|
"__esModule"
|
|
1146
1164
|
]);
|
|
1147
|
-
function
|
|
1165
|
+
function Ge(e) {
|
|
1148
1166
|
let t = {}, n = (e, r) => {
|
|
1149
1167
|
for (let [i, a] of Object.entries(e)) if (typeof a == "function") {
|
|
1150
|
-
!
|
|
1168
|
+
!V.has(i) && !(i in t) && (t[i] = a);
|
|
1151
1169
|
let e = a.name;
|
|
1152
1170
|
e && !(e in t) && (t[e] = a);
|
|
1153
|
-
} else a && typeof a == "object" && r < 2 &&
|
|
1171
|
+
} else a && typeof a == "object" && r < 2 && V.has(i) && n(a, r + 1);
|
|
1154
1172
|
};
|
|
1155
1173
|
return n(e, 0), t;
|
|
1156
1174
|
}
|
|
1157
1175
|
//#endregion
|
|
1158
1176
|
//#region ../apigen-base-errors/src/lib/errors.ts
|
|
1159
|
-
var
|
|
1177
|
+
var Ke = [
|
|
1160
1178
|
"invalid_argument",
|
|
1161
1179
|
"unauthenticated",
|
|
1162
1180
|
"permission_denied",
|
|
@@ -1174,10 +1192,10 @@ var Ge = [
|
|
|
1174
1192
|
return this.details !== void 0 && (e.details = this.details), e;
|
|
1175
1193
|
}
|
|
1176
1194
|
};
|
|
1177
|
-
function
|
|
1178
|
-
return typeof e == "object" && !!e && e.name === "ApiError" &&
|
|
1195
|
+
function qe(e) {
|
|
1196
|
+
return typeof e == "object" && !!e && e.name === "ApiError" && Ke.includes(e.code) && typeof e.toJSON == "function";
|
|
1179
1197
|
}
|
|
1180
|
-
function
|
|
1198
|
+
function Je(e, t, n = 0) {
|
|
1181
1199
|
return e === "before-first-chunk" ? {
|
|
1182
1200
|
phase: e,
|
|
1183
1201
|
error: t
|
|
@@ -1205,14 +1223,14 @@ for (let e of [
|
|
|
1205
1223
|
valid: !0
|
|
1206
1224
|
});
|
|
1207
1225
|
U.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
|
|
1208
|
-
function
|
|
1226
|
+
function Ye(e) {
|
|
1209
1227
|
return e ? e.replace(/^\//, "").split("/").map((e) => e.replace(/~1/g, "/").replace(/~0/g, "~")).join(".") : "(root)";
|
|
1210
1228
|
}
|
|
1211
|
-
function
|
|
1229
|
+
function Xe(e) {
|
|
1212
1230
|
let t = e?.properties;
|
|
1213
1231
|
return t ? Object.keys(t) : [];
|
|
1214
1232
|
}
|
|
1215
|
-
function
|
|
1233
|
+
function Ze(e, t) {
|
|
1216
1234
|
let n = e.length, r = t.length;
|
|
1217
1235
|
if (n === 0) return r;
|
|
1218
1236
|
if (r === 0) return n;
|
|
@@ -1227,27 +1245,27 @@ function Xe(e, t) {
|
|
|
1227
1245
|
}
|
|
1228
1246
|
return i[r];
|
|
1229
1247
|
}
|
|
1230
|
-
function
|
|
1248
|
+
function Qe(e, t) {
|
|
1231
1249
|
let n, r = Infinity;
|
|
1232
1250
|
for (let i of t) {
|
|
1233
|
-
let t =
|
|
1251
|
+
let t = Ze(e.toLowerCase(), i.toLowerCase());
|
|
1234
1252
|
t < r && (r = t, n = i);
|
|
1235
1253
|
}
|
|
1236
1254
|
let i = Math.max(2, Math.floor(e.length / 3));
|
|
1237
1255
|
return n !== void 0 && r <= i ? n : void 0;
|
|
1238
1256
|
}
|
|
1239
|
-
function
|
|
1257
|
+
function $e(e) {
|
|
1240
1258
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1241
1259
|
}
|
|
1242
|
-
function
|
|
1243
|
-
let t =
|
|
1260
|
+
function et(e) {
|
|
1261
|
+
let t = Ye(e.instancePath), n = e.params ?? {};
|
|
1244
1262
|
switch (e.keyword) {
|
|
1245
1263
|
case "additionalProperties": {
|
|
1246
|
-
let r = String(n.additionalProperty ?? "?"), i =
|
|
1264
|
+
let r = String(n.additionalProperty ?? "?"), i = Xe(e.parentSchema), a = Qe(r, i);
|
|
1247
1265
|
return `unknown key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}${a ? ` (did you mean '${a}'?)` : ""}`;
|
|
1248
1266
|
}
|
|
1249
1267
|
case "required": {
|
|
1250
|
-
let r = String(n.missingProperty ?? "?"), i =
|
|
1268
|
+
let r = String(n.missingProperty ?? "?"), i = Xe(e.parentSchema);
|
|
1251
1269
|
return `missing required key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}`;
|
|
1252
1270
|
}
|
|
1253
1271
|
case "enum": {
|
|
@@ -1256,25 +1274,25 @@ function $e(e) {
|
|
|
1256
1274
|
}
|
|
1257
1275
|
case "type": {
|
|
1258
1276
|
let r = e.data;
|
|
1259
|
-
return `${t} must be ${String(n.type)} (got ${
|
|
1277
|
+
return `${t} must be ${String(n.type)} (got ${$e(r)})`;
|
|
1260
1278
|
}
|
|
1261
1279
|
default: return `${t} ${e.message ?? "failed schema check"}`;
|
|
1262
1280
|
}
|
|
1263
1281
|
}
|
|
1264
1282
|
var W = 12;
|
|
1265
|
-
function
|
|
1266
|
-
let t = e.slice(0, W).map(
|
|
1283
|
+
function tt(e) {
|
|
1284
|
+
let t = e.slice(0, W).map(et);
|
|
1267
1285
|
return e.length > W && t.push(`…and ${e.length - W} more`), t.join("; ");
|
|
1268
1286
|
}
|
|
1269
1287
|
function G(e) {
|
|
1270
1288
|
return e === null ? !1 : Array.isArray(e) ? e.some(G) : typeof e != "object" || Object.values(e).some(G);
|
|
1271
1289
|
}
|
|
1272
|
-
function
|
|
1273
|
-
let n = [`Validation failed: ${
|
|
1290
|
+
function nt(e, t) {
|
|
1291
|
+
let n = [`Validation failed: ${tt(e)}`], r = M(t);
|
|
1274
1292
|
return G(r) && n.push(`Example: ${JSON.stringify(r)}`), n.join(" — ");
|
|
1275
1293
|
}
|
|
1276
|
-
var
|
|
1277
|
-
let n = e.ctx.get(
|
|
1294
|
+
var rt = async (e, t) => {
|
|
1295
|
+
let n = e.ctx.get(it);
|
|
1278
1296
|
if (n === void 0) return t();
|
|
1279
1297
|
let r = n[e.operation.id];
|
|
1280
1298
|
if (r === void 0) return t();
|
|
@@ -1284,11 +1302,11 @@ var nt = async (e, t) => {
|
|
|
1284
1302
|
}, a = U.compile(r.input);
|
|
1285
1303
|
if (!a(i)) {
|
|
1286
1304
|
let e = a.errors ?? [];
|
|
1287
|
-
throw new H("invalid_argument",
|
|
1305
|
+
throw new H("invalid_argument", nt(e, r.input), e);
|
|
1288
1306
|
}
|
|
1289
1307
|
return t();
|
|
1290
|
-
},
|
|
1291
|
-
function
|
|
1308
|
+
}, it = Symbol("ValidateSchemasToken");
|
|
1309
|
+
function at(e) {
|
|
1292
1310
|
return async function(t, n) {
|
|
1293
1311
|
let r = e[t.operation.id];
|
|
1294
1312
|
if (r === void 0) return n();
|
|
@@ -1298,27 +1316,27 @@ function it(e) {
|
|
|
1298
1316
|
}, a = U.compile(r.input);
|
|
1299
1317
|
if (!a(i)) {
|
|
1300
1318
|
let e = a.errors ?? [];
|
|
1301
|
-
throw new H("invalid_argument",
|
|
1319
|
+
throw new H("invalid_argument", nt(e, r.input), e);
|
|
1302
1320
|
}
|
|
1303
1321
|
return n();
|
|
1304
1322
|
};
|
|
1305
1323
|
}
|
|
1306
1324
|
//#endregion
|
|
1307
1325
|
//#region src/lib/instance-registry.ts
|
|
1308
|
-
function
|
|
1326
|
+
function ot() {
|
|
1309
1327
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
1310
1328
|
let t = Math.random() * 16 | 0;
|
|
1311
1329
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
1312
1330
|
});
|
|
1313
1331
|
}
|
|
1314
|
-
var
|
|
1332
|
+
var st = class {
|
|
1315
1333
|
constructor(e = {}) {
|
|
1316
1334
|
this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = e.defaultTtlMs;
|
|
1317
1335
|
let t = null;
|
|
1318
1336
|
t = e.sweepIntervalMs === 0 ? null : e.sweepIntervalMs === void 0 ? this._defaultTtlMs === void 0 ? null : Math.max(1e3, Math.floor(this._defaultTtlMs / 4)) : e.sweepIntervalMs, t !== null && t > 0 && (this._sweeper = setInterval(() => this._sweep(), t), this._sweeper.unref?.());
|
|
1319
1337
|
}
|
|
1320
1338
|
create(e, t = [], n) {
|
|
1321
|
-
let r = new e(...t), i =
|
|
1339
|
+
let r = new e(...t), i = ot(), a = n ?? this._defaultTtlMs, o = a === void 0 ? null : Date.now() + a;
|
|
1322
1340
|
return this._store.set(i, {
|
|
1323
1341
|
instance: r,
|
|
1324
1342
|
expiresAt: o
|
|
@@ -1363,7 +1381,7 @@ async function K(e) {
|
|
|
1363
1381
|
}
|
|
1364
1382
|
//#endregion
|
|
1365
1383
|
//#region src/lib/stream.ts
|
|
1366
|
-
function
|
|
1384
|
+
function ct(e) {
|
|
1367
1385
|
let { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
1368
1386
|
return { [Symbol.asyncIterator]() {
|
|
1369
1387
|
let e = t(r);
|
|
@@ -1389,12 +1407,12 @@ function st(e) {
|
|
|
1389
1407
|
};
|
|
1390
1408
|
} };
|
|
1391
1409
|
}
|
|
1392
|
-
async function
|
|
1410
|
+
async function lt(e) {
|
|
1393
1411
|
let t = [];
|
|
1394
1412
|
for await (let n of e) t.push(n);
|
|
1395
1413
|
return t;
|
|
1396
1414
|
}
|
|
1397
|
-
async function
|
|
1415
|
+
async function ut(e) {
|
|
1398
1416
|
let t = [];
|
|
1399
1417
|
try {
|
|
1400
1418
|
for await (let n of e) t.push(n);
|
|
@@ -1403,17 +1421,17 @@ async function lt(e) {
|
|
|
1403
1421
|
chunks: t
|
|
1404
1422
|
};
|
|
1405
1423
|
} catch (e) {
|
|
1406
|
-
let n =
|
|
1424
|
+
let n = qe(e) ? e : new H("internal", e instanceof Error ? e.message : String(e));
|
|
1407
1425
|
return t.length === 0 ? {
|
|
1408
1426
|
ok: !1,
|
|
1409
|
-
carrier:
|
|
1427
|
+
carrier: Je("before-first-chunk", n)
|
|
1410
1428
|
} : {
|
|
1411
1429
|
ok: !1,
|
|
1412
|
-
carrier:
|
|
1430
|
+
carrier: Je("after-first-chunk", n, t.length)
|
|
1413
1431
|
};
|
|
1414
1432
|
}
|
|
1415
1433
|
}
|
|
1416
|
-
function
|
|
1434
|
+
function dt(e) {
|
|
1417
1435
|
return typeof e == "object" && !!e && Symbol.asyncIterator in e;
|
|
1418
1436
|
}
|
|
1419
1437
|
//#endregion
|
|
@@ -1434,7 +1452,7 @@ function J(e) {
|
|
|
1434
1452
|
mapping: r
|
|
1435
1453
|
};
|
|
1436
1454
|
}
|
|
1437
|
-
function
|
|
1455
|
+
function ft(e, t) {
|
|
1438
1456
|
let n = e[c];
|
|
1439
1457
|
if (typeof n == "string") {
|
|
1440
1458
|
let e = t.registry.get(n);
|
|
@@ -1442,15 +1460,15 @@ function dt(e, t) {
|
|
|
1442
1460
|
}
|
|
1443
1461
|
return t.registry.resolve(e);
|
|
1444
1462
|
}
|
|
1445
|
-
function
|
|
1446
|
-
let r =
|
|
1463
|
+
function pt(e, t, n) {
|
|
1464
|
+
let r = ft(t, n);
|
|
1447
1465
|
return r ? r.encode(e, t, n) : e;
|
|
1448
1466
|
}
|
|
1449
|
-
function
|
|
1450
|
-
let r =
|
|
1467
|
+
function mt(e, t, n) {
|
|
1468
|
+
let r = ft(t, n);
|
|
1451
1469
|
return r ? r.decode(e, t, n) : e;
|
|
1452
1470
|
}
|
|
1453
|
-
function
|
|
1471
|
+
function ht(e) {
|
|
1454
1472
|
let { id: t, schema: n } = e;
|
|
1455
1473
|
return {
|
|
1456
1474
|
id: t,
|
|
@@ -1468,7 +1486,7 @@ function mt(e) {
|
|
|
1468
1486
|
if (s == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] value at "${r.path}" is missing the discriminator property "${a}".`);
|
|
1469
1487
|
let c = String(s), l = o[c];
|
|
1470
1488
|
if (!l) throw new q("E_UNION_UNKNOWN_TAG", `[${t}] discriminator tag "${c}" at "${r.path}" is not in the mapping (known: ${Object.keys(o).join(", ")}).`);
|
|
1471
|
-
return
|
|
1489
|
+
return pt(e, r.resolve(l), {
|
|
1472
1490
|
...r,
|
|
1473
1491
|
path: `${r.path}[${c}]`
|
|
1474
1492
|
});
|
|
@@ -1484,7 +1502,7 @@ function mt(e) {
|
|
|
1484
1502
|
if (c == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] wire object at "${r.path}" is missing the discriminator property "${o}".`);
|
|
1485
1503
|
let l = String(c), u = s[l];
|
|
1486
1504
|
if (!u) throw new q("E_UNION_UNKNOWN_TAG", `[${t}] discriminator tag "${l}" on the wire at "${r.path}" is not in the mapping (known: ${Object.keys(s).join(", ")}).`);
|
|
1487
|
-
return
|
|
1505
|
+
return mt(e, r.resolve(u), {
|
|
1488
1506
|
...r,
|
|
1489
1507
|
path: `${r.path}[${l}]`
|
|
1490
1508
|
});
|
|
@@ -1496,29 +1514,29 @@ var Y = class extends Error {
|
|
|
1496
1514
|
super(t), this.name = "NominalCodecError", this.code = e;
|
|
1497
1515
|
}
|
|
1498
1516
|
};
|
|
1499
|
-
function
|
|
1517
|
+
function gt(e) {
|
|
1500
1518
|
let t = e.properties;
|
|
1501
1519
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
1502
1520
|
}
|
|
1503
|
-
function
|
|
1521
|
+
function _t(e) {
|
|
1504
1522
|
let t = e.required;
|
|
1505
1523
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
1506
1524
|
}
|
|
1507
|
-
function
|
|
1525
|
+
function vt(e, t, n) {
|
|
1508
1526
|
if (t) {
|
|
1509
1527
|
let r = n.registry.resolve(t);
|
|
1510
1528
|
if (r) return r.encode(e, t, n);
|
|
1511
1529
|
}
|
|
1512
1530
|
return e;
|
|
1513
1531
|
}
|
|
1514
|
-
function
|
|
1532
|
+
function yt(e, t, n) {
|
|
1515
1533
|
if (t) {
|
|
1516
1534
|
let r = n.registry.resolve(t);
|
|
1517
1535
|
if (r) return r.decode(e, t, n);
|
|
1518
1536
|
}
|
|
1519
1537
|
return e;
|
|
1520
1538
|
}
|
|
1521
|
-
function
|
|
1539
|
+
function bt(e) {
|
|
1522
1540
|
let { id: t, schema: n, ctor: r } = e;
|
|
1523
1541
|
return {
|
|
1524
1542
|
id: t,
|
|
@@ -1535,12 +1553,12 @@ function yt(e) {
|
|
|
1535
1553
|
}
|
|
1536
1554
|
r.seen.add(e);
|
|
1537
1555
|
try {
|
|
1538
|
-
let t =
|
|
1556
|
+
let t = gt(n), i = e[typeof n["x-apigen-tojson"] == "string" ? n[u] : "toJSON"];
|
|
1539
1557
|
if (typeof i == "function") {
|
|
1540
1558
|
let n = i.call(e);
|
|
1541
1559
|
if (typeof n == "object" && n && !Array.isArray(n)) {
|
|
1542
1560
|
let e = {};
|
|
1543
|
-
for (let [i, a] of Object.entries(n)) e[i] =
|
|
1561
|
+
for (let [i, a] of Object.entries(n)) e[i] = vt(a, t[i], {
|
|
1544
1562
|
...r,
|
|
1545
1563
|
path: `${r.path}/${i}`
|
|
1546
1564
|
});
|
|
@@ -1551,7 +1569,7 @@ function yt(e) {
|
|
|
1551
1569
|
let a = {}, o = Object.keys(t), s = e, c = o.length > 0 ? o : Object.keys(s);
|
|
1552
1570
|
for (let e of c) {
|
|
1553
1571
|
let n = s[e];
|
|
1554
|
-
n !== void 0 && (a[e] =
|
|
1572
|
+
n !== void 0 && (a[e] = vt(n, t[e], {
|
|
1555
1573
|
...r,
|
|
1556
1574
|
path: `${r.path}/${e}`
|
|
1557
1575
|
}));
|
|
@@ -1567,10 +1585,10 @@ function yt(e) {
|
|
|
1567
1585
|
throw n = e === null ? "null" : Array.isArray(e) ? "array" : typeof e, new Y("E_NOMINAL_INVALID_WIRE", `[${t}] expected a JSON object on the wire at "${i.path}", got ${n}.`);
|
|
1568
1586
|
}
|
|
1569
1587
|
let a = e;
|
|
1570
|
-
for (let e of
|
|
1588
|
+
for (let e of _t(n)) if (!(e in a)) throw new Y("E_NOMINAL_INVALID_WIRE", `[${t}] required field "${e}" missing on the wire at "${i.path}".`);
|
|
1571
1589
|
if (n["x-apigen-instances"] === !1) throw new Y("E_NOMINAL_NONRECONSTRUCTABLE", `[${t}] is encode-only: the extractor marked it non-reconstructable (x-apigen-instances:false). It cannot be decoded back to a live instance.`);
|
|
1572
|
-
let o =
|
|
1573
|
-
for (let [e, t] of Object.entries(a)) s[e] =
|
|
1590
|
+
let o = gt(n), s = {};
|
|
1591
|
+
for (let [e, t] of Object.entries(a)) s[e] = yt(t, o[e], {
|
|
1574
1592
|
...i,
|
|
1575
1593
|
path: `${i.path}/${e}`
|
|
1576
1594
|
});
|
|
@@ -1584,21 +1602,21 @@ function yt(e) {
|
|
|
1584
1602
|
}
|
|
1585
1603
|
//#endregion
|
|
1586
1604
|
//#region src/lib/logical/host-ts.ts
|
|
1587
|
-
var
|
|
1588
|
-
x,
|
|
1605
|
+
var xt = [
|
|
1589
1606
|
S,
|
|
1590
1607
|
C,
|
|
1591
1608
|
w,
|
|
1592
1609
|
T,
|
|
1593
|
-
|
|
1594
|
-
|
|
1610
|
+
E,
|
|
1611
|
+
A
|
|
1612
|
+
], X = bt({
|
|
1595
1613
|
id: "ts.NominalSentinel",
|
|
1596
1614
|
schema: {
|
|
1597
1615
|
type: "object",
|
|
1598
1616
|
"x-apigen-logical": "nominal",
|
|
1599
1617
|
"x-apigen-codec": "ts.NominalSentinel"
|
|
1600
1618
|
}
|
|
1601
|
-
}), St =
|
|
1619
|
+
}), St = ht({
|
|
1602
1620
|
id: "ts.UnionSentinel",
|
|
1603
1621
|
schema: {
|
|
1604
1622
|
oneOf: [],
|
|
@@ -1612,8 +1630,8 @@ var bt = [
|
|
|
1612
1630
|
});
|
|
1613
1631
|
function Ct() {
|
|
1614
1632
|
let e = [
|
|
1615
|
-
...
|
|
1616
|
-
[
|
|
1633
|
+
...xt.map((e) => [e.id, e]),
|
|
1634
|
+
[X.id, X],
|
|
1617
1635
|
[St.id, St]
|
|
1618
1636
|
];
|
|
1619
1637
|
return Object.freeze(new Map(e));
|
|
@@ -1629,7 +1647,7 @@ function Tt(e, t, n) {
|
|
|
1629
1647
|
let r = [
|
|
1630
1648
|
n,
|
|
1631
1649
|
typeof t?.input?.description == "string" ? t.input.description : void 0,
|
|
1632
|
-
|
|
1650
|
+
ge(t?.input)
|
|
1633
1651
|
].filter((e) => typeof e == "string" && e.length > 0);
|
|
1634
1652
|
return r.length > 0 ? r.join(" — ") : e;
|
|
1635
1653
|
}
|
|
@@ -1655,8 +1673,8 @@ function Dt(e, t) {
|
|
|
1655
1673
|
//#endregion
|
|
1656
1674
|
//#region src/lib/batch.ts
|
|
1657
1675
|
var Ot = 4, kt = 32;
|
|
1658
|
-
function
|
|
1659
|
-
return
|
|
1676
|
+
function Z(e) {
|
|
1677
|
+
return qe(e) ? e : e instanceof Error ? new H("internal", e.message) : e;
|
|
1660
1678
|
}
|
|
1661
1679
|
function At(e, t) {
|
|
1662
1680
|
if (e === "serial" || e === "chained") return 1;
|
|
@@ -1690,14 +1708,14 @@ async function Nt(e, t, n, r, i, a) {
|
|
|
1690
1708
|
...r,
|
|
1691
1709
|
signal: o.signal
|
|
1692
1710
|
} : r, i);
|
|
1693
|
-
if (
|
|
1694
|
-
let e = await
|
|
1711
|
+
if (dt(a)) {
|
|
1712
|
+
let e = await ut(a);
|
|
1695
1713
|
if (!e.ok) {
|
|
1696
1714
|
let t = e.carrier;
|
|
1697
1715
|
return {
|
|
1698
1716
|
index: n,
|
|
1699
1717
|
status: "rejected",
|
|
1700
|
-
reason:
|
|
1718
|
+
reason: Z(t.error),
|
|
1701
1719
|
...t.phase === "after-first-chunk" ? { chunksDelivered: t.chunksDelivered } : {}
|
|
1702
1720
|
};
|
|
1703
1721
|
}
|
|
@@ -1716,7 +1734,7 @@ async function Nt(e, t, n, r, i, a) {
|
|
|
1716
1734
|
return {
|
|
1717
1735
|
index: n,
|
|
1718
1736
|
status: "rejected",
|
|
1719
|
-
reason:
|
|
1737
|
+
reason: Z(e)
|
|
1720
1738
|
};
|
|
1721
1739
|
} finally {
|
|
1722
1740
|
o.dispose();
|
|
@@ -1726,7 +1744,7 @@ async function Pt(e, t, n, r, i = {}) {
|
|
|
1726
1744
|
let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s = At(a, i.concurrency), c = Array(n.length), l = (e) => ({
|
|
1727
1745
|
index: e,
|
|
1728
1746
|
status: "rejected",
|
|
1729
|
-
reason:
|
|
1747
|
+
reason: Z(/* @__PURE__ */ Error("apigen/invokeBatch: not attempted — an earlier item failed and " + (a === "chained" ? "mode is \"chained\"" : "onItemError is \"abort\"")))
|
|
1730
1748
|
});
|
|
1731
1749
|
if (a === "serial" || a === "chained") {
|
|
1732
1750
|
let s = !1;
|
|
@@ -1766,7 +1784,7 @@ function Lt(e) {
|
|
|
1766
1784
|
return e.words.join("_");
|
|
1767
1785
|
}
|
|
1768
1786
|
function Rt(e, t = {}) {
|
|
1769
|
-
let n = [e.namespace, ...e.path], r = e.safe ||
|
|
1787
|
+
let n = [e.namespace, ...e.path], r = e.safe || I(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => Ft(e)).join("/"), o = n.map((e) => Lt(e)).join("_"), s = n.map((e) => Lt(e)).slice(0, -1).join("."), c = It(n[n.length - 2] ?? n[0]), l = It(n[n.length - 1]), u = n.map((e) => Ft(e));
|
|
1770
1788
|
return {
|
|
1771
1789
|
http: {
|
|
1772
1790
|
verb: i,
|
|
@@ -1796,13 +1814,13 @@ function Ht(e) {
|
|
|
1796
1814
|
}
|
|
1797
1815
|
//#endregion
|
|
1798
1816
|
//#region src/lib/op-plan.ts
|
|
1799
|
-
function
|
|
1817
|
+
function Q(e) {
|
|
1800
1818
|
return e.anyOf ?? e.oneOf;
|
|
1801
1819
|
}
|
|
1802
1820
|
function Ut(e) {
|
|
1803
1821
|
if (!e) return !1;
|
|
1804
1822
|
if (e.type === "array" || e.type === "object") return !0;
|
|
1805
|
-
let t =
|
|
1823
|
+
let t = Q(e);
|
|
1806
1824
|
if (t) {
|
|
1807
1825
|
let e = t.filter((e) => e.type !== "null");
|
|
1808
1826
|
return e.length > 0 && e.every((e) => e.type === "array" || e.type === "object");
|
|
@@ -1812,7 +1830,7 @@ function Ut(e) {
|
|
|
1812
1830
|
function Wt(e) {
|
|
1813
1831
|
if (!e) return !1;
|
|
1814
1832
|
if (e.type === "boolean") return !0;
|
|
1815
|
-
let t =
|
|
1833
|
+
let t = Q(e);
|
|
1816
1834
|
if (t) {
|
|
1817
1835
|
let e = t.filter((e) => e.type !== "null");
|
|
1818
1836
|
return e.length > 0 && e.every((e) => e.type === "boolean");
|
|
@@ -1822,7 +1840,7 @@ function Wt(e) {
|
|
|
1822
1840
|
function Gt(e) {
|
|
1823
1841
|
if (!e) return !1;
|
|
1824
1842
|
if (e.type === "number" || e.type === "integer") return !0;
|
|
1825
|
-
let t =
|
|
1843
|
+
let t = Q(e);
|
|
1826
1844
|
if (t) {
|
|
1827
1845
|
let e = t.filter((e) => e.type !== "null");
|
|
1828
1846
|
return e.length > 0 && e.every((e) => e.type === "number" || e.type === "integer");
|
|
@@ -1839,10 +1857,10 @@ function qt(e) {
|
|
|
1839
1857
|
required: t?.required ?? []
|
|
1840
1858
|
};
|
|
1841
1859
|
}
|
|
1842
|
-
function
|
|
1860
|
+
function Jt(e) {
|
|
1843
1861
|
return typeof e.handler == "function";
|
|
1844
1862
|
}
|
|
1845
|
-
function
|
|
1863
|
+
function Yt(e) {
|
|
1846
1864
|
let t = e.input?.properties ?? {}, n = e["x-apigen-envelope"], r = [];
|
|
1847
1865
|
for (let e of Object.keys(t)) {
|
|
1848
1866
|
if (e === "data") continue;
|
|
@@ -1858,13 +1876,13 @@ function Jt(e) {
|
|
|
1858
1876
|
}
|
|
1859
1877
|
return r;
|
|
1860
1878
|
}
|
|
1861
|
-
function
|
|
1879
|
+
function Xt(e, t, n, r) {
|
|
1862
1880
|
t === n || e.has(t) || e.set(t, {
|
|
1863
1881
|
...r,
|
|
1864
1882
|
aliasOf: n
|
|
1865
1883
|
});
|
|
1866
1884
|
}
|
|
1867
|
-
function
|
|
1885
|
+
function Zt(e, t) {
|
|
1868
1886
|
let n = /* @__PURE__ */ new Map(), { props: r } = qt(e);
|
|
1869
1887
|
for (let [e, t] of Object.entries(r)) {
|
|
1870
1888
|
let r = "string";
|
|
@@ -1874,7 +1892,7 @@ function Xt(e, t) {
|
|
|
1874
1892
|
kind: "domain",
|
|
1875
1893
|
valueKind: r
|
|
1876
1894
|
};
|
|
1877
|
-
n.set(i, a),
|
|
1895
|
+
n.set(i, a), Xt(n, e, i, a);
|
|
1878
1896
|
}
|
|
1879
1897
|
for (let e of t) {
|
|
1880
1898
|
let t = e.cliFlag.replace(/^--/, ""), r = {
|
|
@@ -1887,8 +1905,8 @@ function Xt(e, t) {
|
|
|
1887
1905
|
}
|
|
1888
1906
|
return n;
|
|
1889
1907
|
}
|
|
1890
|
-
function
|
|
1891
|
-
let { op: t, schema: n, transport: r, projection: i } = e, a = Rt(t, i), o = n ?
|
|
1908
|
+
function Qt(e) {
|
|
1909
|
+
let { op: t, schema: n, transport: r, projection: i } = e, a = Rt(t, i), o = n ? Yt(n) : [], s = n ? Zt(n, o) : /* @__PURE__ */ new Map(), c = n ? B(n).params : void 0, l = {
|
|
1892
1910
|
op: t,
|
|
1893
1911
|
transport: r,
|
|
1894
1912
|
http: a.http,
|
|
@@ -1899,9 +1917,9 @@ function Zt(e) {
|
|
|
1899
1917
|
envelope: o,
|
|
1900
1918
|
cliFlags: s,
|
|
1901
1919
|
streaming: t.streaming,
|
|
1902
|
-
isMount:
|
|
1920
|
+
isMount: Jt(t)
|
|
1903
1921
|
};
|
|
1904
|
-
if (
|
|
1922
|
+
if (Jt(t)) {
|
|
1905
1923
|
let e = t.handler;
|
|
1906
1924
|
l.mountHandler = async (t) => e(t);
|
|
1907
1925
|
}
|
|
@@ -1909,35 +1927,35 @@ function Zt(e) {
|
|
|
1909
1927
|
}
|
|
1910
1928
|
//#endregion
|
|
1911
1929
|
//#region src/lib/package-invoker.ts
|
|
1912
|
-
function
|
|
1930
|
+
function $t(e) {
|
|
1913
1931
|
let t = e.usePlugins;
|
|
1914
1932
|
return Array.isArray(t) ? t : [];
|
|
1915
1933
|
}
|
|
1916
|
-
function
|
|
1934
|
+
function en(e) {
|
|
1917
1935
|
let t = e.exitCode;
|
|
1918
1936
|
return typeof t == "function" ? t : void 0;
|
|
1919
1937
|
}
|
|
1920
|
-
function
|
|
1938
|
+
function tn(e) {
|
|
1921
1939
|
let t = e.useOptions;
|
|
1922
1940
|
return t && typeof t == "object" ? t : {};
|
|
1923
1941
|
}
|
|
1924
|
-
function
|
|
1942
|
+
function nn(e) {
|
|
1925
1943
|
return async function(t, n) {
|
|
1926
1944
|
let r = Object.assign(t, { data: t.domainArgs });
|
|
1927
1945
|
return await e.layer(r, n);
|
|
1928
1946
|
};
|
|
1929
1947
|
}
|
|
1930
|
-
function
|
|
1948
|
+
function rn(e, t) {
|
|
1931
1949
|
let n = [];
|
|
1932
1950
|
for (let e of t) {
|
|
1933
1951
|
let t = e.capabilities?.layer;
|
|
1934
|
-
t && n.push(
|
|
1952
|
+
t && n.push(nn(t));
|
|
1935
1953
|
}
|
|
1936
|
-
return n.push(
|
|
1954
|
+
return n.push(at(e)), we(n);
|
|
1937
1955
|
}
|
|
1938
1956
|
//#endregion
|
|
1939
1957
|
//#region src/lib/dispatch-for-plan.ts
|
|
1940
|
-
function
|
|
1958
|
+
function an() {
|
|
1941
1959
|
let e = /* @__PURE__ */ new Map();
|
|
1942
1960
|
return {
|
|
1943
1961
|
get: (t) => e.get(t),
|
|
@@ -1946,7 +1964,7 @@ function nn() {
|
|
|
1946
1964
|
}
|
|
1947
1965
|
};
|
|
1948
1966
|
}
|
|
1949
|
-
var
|
|
1967
|
+
var on = {
|
|
1950
1968
|
input: {
|
|
1951
1969
|
type: "object",
|
|
1952
1970
|
properties: { data: {
|
|
@@ -1956,11 +1974,11 @@ var rn = {
|
|
|
1956
1974
|
},
|
|
1957
1975
|
output: {}
|
|
1958
1976
|
};
|
|
1959
|
-
async function
|
|
1977
|
+
async function sn(e, t, n, r) {
|
|
1960
1978
|
let i = {
|
|
1961
1979
|
...n,
|
|
1962
1980
|
operation: { id: e.op.id },
|
|
1963
|
-
ctx: new
|
|
1981
|
+
ctx: new Ce(),
|
|
1964
1982
|
transport: e.transport
|
|
1965
1983
|
};
|
|
1966
1984
|
if (e.isMount) {
|
|
@@ -1970,17 +1988,37 @@ async function an(e, t, n, r) {
|
|
|
1970
1988
|
operation: e.op,
|
|
1971
1989
|
data: n.domainArgs,
|
|
1972
1990
|
envelope: n.envelope,
|
|
1973
|
-
ctx:
|
|
1991
|
+
ctx: an(),
|
|
1974
1992
|
transport: e.transport,
|
|
1975
1993
|
signal: n.signal ?? new AbortController().signal
|
|
1976
1994
|
}, s = {
|
|
1977
1995
|
...r,
|
|
1978
1996
|
fns: { [e.op.id]: () => a(o) },
|
|
1979
|
-
schemas: { [e.op.id]:
|
|
1997
|
+
schemas: { [e.op.id]: on }
|
|
1980
1998
|
};
|
|
1981
1999
|
return t(e.op.id, i, s);
|
|
1982
2000
|
}
|
|
1983
2001
|
return t(e.op.id, i, r);
|
|
1984
2002
|
}
|
|
1985
2003
|
//#endregion
|
|
1986
|
-
|
|
2004
|
+
//#region src/lib/bind-host.ts
|
|
2005
|
+
var $ = "127.0.0.1";
|
|
2006
|
+
function cn(e) {
|
|
2007
|
+
let t = e.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
2008
|
+
if (t === "localhost" || t === "::1") return !0;
|
|
2009
|
+
let n = t.startsWith("::ffff:") ? t.slice(7) : t;
|
|
2010
|
+
return /^127(\.\d{1,3}){3}$/.test(n);
|
|
2011
|
+
}
|
|
2012
|
+
function ln(e) {
|
|
2013
|
+
if (typeof e != "string") return $;
|
|
2014
|
+
let t = e.trim();
|
|
2015
|
+
return t === "" ? $ : t;
|
|
2016
|
+
}
|
|
2017
|
+
function un(e, t, n) {
|
|
2018
|
+
return !cn(e) && (n?.warn({
|
|
2019
|
+
host: e,
|
|
2020
|
+
host_kind: t
|
|
2021
|
+
}, `${t} binding non-loopback host "${e}": the server will be reachable from the network. Omit the host option to bind ${$}.`), !0);
|
|
2022
|
+
}
|
|
2023
|
+
//#endregion
|
|
2024
|
+
export { Ot as BATCH_DEFAULT_CONCURRENCY, kt as BATCH_MAX_CONCURRENCY, $ as DEFAULT_LISTEN_HOST, Ee as EventBus, st as InstanceRegistry, Ce as LayerContext, q as UnionCodecError, it as ValidateSchemasToken, xt as WELL_KNOWN_TS_CODECS, nn as adaptCoreLayer, R as assertNoSelfSubscription, ke as buildContext, Ge as buildFnTable, Et as buildMcpOutputSchema, Qt as buildOpPlan, Tt as buildToolDescription, We as coerceQueryParams, ut as collectWithPhase, Le as createApiPackage, we as createInvoker, Re as createLogger, rn as createPackageInvoker, ct as createStream, ht as createUnionCodec, ye as dataParamNames, Te as defineMiddleware, B as describeParams, Se as dispatch, sn as dispatchForPlan, lt as drainStream, Pt as invokeBatch, dt as isApiStream, cn as isLoopbackListenHost, at as makeValidateLayer, ve as needsEnvelopeField, en as readExitCodeHook, tn as readUseOptions, $t as readUsePlugins, ln as resolveListenHost, wt as tsHostBinding, rt as validateLayer, un as warnIfNonLoopbackListen, Oe as wireObservers, Dt as wrapMcpStructuredContent };
|