@adhd/apigen-engine-runtime 0.3.1 → 0.3.2
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 +12 -0
- package/README.md +23 -6
- package/index.js +1 -1
- package/index.mjs +329 -264
- package/lib/dispatch-for-plan.d.ts +1 -1
- package/lib/invoke.d.ts +8 -1
- package/lib/transport-adapter.d.ts +2 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -75,7 +75,7 @@ function p(e, t, n) {
|
|
|
75
75
|
if (Array.isArray(a)) return p(e, ee(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 _(e, t, n);
|
|
79
79
|
let r = t.items;
|
|
80
80
|
if (!r) return e.map((e) => b(e));
|
|
81
81
|
let i = n.path;
|
|
@@ -91,7 +91,7 @@ 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 _(e, t, n);
|
|
95
95
|
let r = t.properties;
|
|
96
96
|
if (!r) return b(e);
|
|
97
97
|
let i = n.path, a = {};
|
|
@@ -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 ? _(e, t, n) : b(e);
|
|
108
108
|
}
|
|
109
109
|
function m(e, t, n) {
|
|
110
110
|
let r = n.registry.resolve(t);
|
|
@@ -167,11 +167,11 @@ function ee(e, t, n, r) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let a =
|
|
170
|
+
let a = ne(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 = g(e, h(n, r), r);
|
|
175
175
|
t !== null && t > s && (s = t, o = n);
|
|
176
176
|
}
|
|
177
177
|
return o === void 0 ? t[0] ?? {} : o;
|
|
@@ -180,47 +180,47 @@ function h(e, t) {
|
|
|
180
180
|
let n = e.$ref;
|
|
181
181
|
return typeof n == "string" ? t.resolve(n) : e;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function te(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 ne(e, t, n) {
|
|
189
189
|
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
190
190
|
let r = e, i = t.map((e) => h(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)) te(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 ? te(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 && g(e, i[u], n) !== null) return t[u];
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function re(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 g(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 = g(e, h(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 = re(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 _(e, t, n) {
|
|
|
239
239
|
}
|
|
240
240
|
return c;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function _(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,15 +247,15 @@ function v(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) => _(e, {}, n));
|
|
251
|
+
if (v(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] = _(i, {}, n));
|
|
254
254
|
return t;
|
|
255
255
|
}
|
|
256
256
|
return b(e);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function v(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;
|
|
@@ -266,7 +266,7 @@ function y(e, t) {
|
|
|
266
266
|
if (a) return a.decode(n.v, a.schema, t);
|
|
267
267
|
}
|
|
268
268
|
if (Array.isArray(e)) return e.map((e) => y(e, t));
|
|
269
|
-
if (
|
|
269
|
+
if (v(e)) {
|
|
270
270
|
let n = {};
|
|
271
271
|
for (let [r, i] of Object.entries(e)) n[r] = y(i, t);
|
|
272
272
|
return n;
|
|
@@ -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 oe(e) {
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
|
-
var
|
|
392
|
+
var C = {
|
|
393
393
|
id: "decimal",
|
|
394
394
|
kind: "scalar",
|
|
395
395
|
schema: {
|
|
@@ -405,12 +405,12 @@ var w = {
|
|
|
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 oe(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 oe(e);
|
|
412
412
|
}
|
|
413
|
-
},
|
|
413
|
+
}, w = {
|
|
414
414
|
id: "byte",
|
|
415
415
|
kind: "scalar",
|
|
416
416
|
schema: {
|
|
@@ -434,7 +434,7 @@ var w = {
|
|
|
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
|
+
}, se = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, T = {
|
|
438
438
|
id: "uuid",
|
|
439
439
|
kind: "scalar",
|
|
440
440
|
schema: {
|
|
@@ -452,14 +452,14 @@ var w = {
|
|
|
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" && !se.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
|
-
},
|
|
458
|
+
}, E = "NaN", D = "Infinity", O = "-Infinity", ce = /* @__PURE__ */ new Set([
|
|
459
|
+
E,
|
|
459
460
|
D,
|
|
460
|
-
O
|
|
461
|
-
|
|
462
|
-
]), A = {
|
|
461
|
+
O
|
|
462
|
+
]), k = {
|
|
463
463
|
id: "number-special",
|
|
464
464
|
kind: "scalar",
|
|
465
465
|
schema: { type: "number" },
|
|
@@ -470,49 +470,49 @@ var w = {
|
|
|
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) ? E : e === Infinity ? D : e === -Infinity ? O : 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 === E) return NaN;
|
|
479
|
+
if (e === D) return Infinity;
|
|
480
|
+
if (e === O) 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 ${[...ce].join(", ")}.`);
|
|
485
485
|
return NaN;
|
|
486
486
|
}
|
|
487
|
-
},
|
|
487
|
+
}, le = [
|
|
488
488
|
x,
|
|
489
489
|
S,
|
|
490
|
+
C,
|
|
490
491
|
w,
|
|
491
492
|
T,
|
|
492
|
-
|
|
493
|
-
A
|
|
493
|
+
k
|
|
494
494
|
];
|
|
495
|
-
function
|
|
496
|
-
for (let n of
|
|
495
|
+
function ue(e, t = {}) {
|
|
496
|
+
for (let n of le) 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 de = 12;
|
|
501
|
+
function fe(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 pe(e) {
|
|
508
508
|
return Array.isArray(e) && e.length > 0 ? e[0] : void 0;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function me(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 he(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,7 +531,7 @@ function me(e) {
|
|
|
531
531
|
default: return "<string>";
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function A(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];
|
|
@@ -544,9 +544,9 @@ function ge(e, t, n) {
|
|
|
544
544
|
return r ? [j(r, t, n + 1)] : [];
|
|
545
545
|
}
|
|
546
546
|
function j(e, t = e ?? {}, n = 0) {
|
|
547
|
-
if (!e || n >
|
|
547
|
+
if (!e || n > de) return null;
|
|
548
548
|
if (typeof e.$ref == "string") {
|
|
549
|
-
let r =
|
|
549
|
+
let r = fe(e.$ref, t);
|
|
550
550
|
return r === void 0 ? null : j(r, t, n + 1);
|
|
551
551
|
}
|
|
552
552
|
if (e.const !== void 0) return e.const;
|
|
@@ -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 A({
|
|
561
561
|
...e,
|
|
562
562
|
properties: r,
|
|
563
563
|
required: i
|
|
564
564
|
}, t, n);
|
|
565
565
|
}
|
|
566
|
-
let r =
|
|
566
|
+
let r = pe(e.oneOf) ?? pe(e.anyOf);
|
|
567
567
|
if (r) return j(r, t, n + 1);
|
|
568
|
-
switch (
|
|
569
|
-
case "object": return
|
|
568
|
+
switch (me(e)) {
|
|
569
|
+
case "object": return A(e, t, n);
|
|
570
570
|
case "array": return ge(e, t, n);
|
|
571
|
-
case "string": return
|
|
571
|
+
case "string": return he(e);
|
|
572
572
|
case "integer":
|
|
573
573
|
case "number": return 0;
|
|
574
574
|
case "boolean": return !1;
|
|
@@ -581,7 +581,7 @@ function _e(e) {
|
|
|
581
581
|
let t = j(e);
|
|
582
582
|
return `Example: ${JSON.stringify(t)}`;
|
|
583
583
|
}
|
|
584
|
-
x.id, S.id,
|
|
584
|
+
x.id, S.id, C.id, w.id, T.id, k.id, Object.freeze({
|
|
585
585
|
typescript: {
|
|
586
586
|
"date-time": {
|
|
587
587
|
encode: "$.toISOString()",
|
|
@@ -805,42 +805,42 @@ x.id, S.id, w.id, T.id, E.id, A.id, Object.freeze({
|
|
|
805
805
|
});
|
|
806
806
|
//#endregion
|
|
807
807
|
//#region src/lib/dispatch.ts
|
|
808
|
-
var
|
|
809
|
-
|
|
810
|
-
var
|
|
811
|
-
function
|
|
808
|
+
var M = o();
|
|
809
|
+
ue(M);
|
|
810
|
+
var N = ae(M.freeze());
|
|
811
|
+
function P(e, t) {
|
|
812
812
|
return t in (e.input?.properties ?? {});
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function F(e) {
|
|
815
815
|
let t = e.input?.properties?.data;
|
|
816
816
|
return Object.keys(t?.properties ?? {});
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function ve(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 ye(e, t) {
|
|
823
|
+
return t === void 0 || e === void 0 ? e : N.decode(e, t);
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function I(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 : N.encode(e, n);
|
|
828
828
|
}
|
|
829
|
-
async function
|
|
830
|
-
let o =
|
|
831
|
-
if (
|
|
829
|
+
async function L(e, t, n, r, i, a) {
|
|
830
|
+
let o = F(n).map((e) => ye(a[e], ve(n, e)));
|
|
831
|
+
if (P(n, "session") && t) {
|
|
832
832
|
let a = await t({ session: i.session });
|
|
833
|
-
return
|
|
833
|
+
return I(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 I(await e[r](a, ...o), n);
|
|
838
838
|
}
|
|
839
|
-
return
|
|
839
|
+
return I(await e[r](...o), n);
|
|
840
840
|
}
|
|
841
841
|
//#endregion
|
|
842
842
|
//#region src/lib/invoke.ts
|
|
843
|
-
var
|
|
843
|
+
var R = class {
|
|
844
844
|
constructor() {
|
|
845
845
|
this._map = /* @__PURE__ */ new Map();
|
|
846
846
|
}
|
|
@@ -854,21 +854,21 @@ var N = class {
|
|
|
854
854
|
return this._map.has(e);
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
|
-
function
|
|
857
|
+
function z(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), () => L(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 be(e) {
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
869
|
//#endregion
|
|
870
870
|
//#region src/lib/event-bus.ts
|
|
871
|
-
var
|
|
871
|
+
var xe = class {
|
|
872
872
|
constructor() {
|
|
873
873
|
this.handlers = /* @__PURE__ */ new Map();
|
|
874
874
|
}
|
|
@@ -886,19 +886,19 @@ var F = 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 (Se(t, e)) for (let t of n) await t(e);
|
|
890
890
|
}
|
|
891
891
|
};
|
|
892
|
-
function
|
|
892
|
+
function Se(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 Ce(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 we(e, t, n) {
|
|
902
902
|
let r = { ...t };
|
|
903
903
|
for (let t of e) if (t.createContext) {
|
|
904
904
|
await n.emit({
|
|
@@ -933,27 +933,27 @@ async function L(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 Te = /* @__PURE__ */ new Set([
|
|
937
937
|
"string",
|
|
938
938
|
"number",
|
|
939
939
|
"boolean",
|
|
940
940
|
"integer"
|
|
941
941
|
]);
|
|
942
|
-
function
|
|
942
|
+
function Ee(e) {
|
|
943
943
|
if (typeof e != "object" || !e) return !1;
|
|
944
944
|
let t = e;
|
|
945
945
|
if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf) return !1;
|
|
946
946
|
let { type: n } = t;
|
|
947
|
-
return typeof n == "string" ?
|
|
947
|
+
return typeof n == "string" ? Te.has(n) : Array.isArray(n) ? n.every((e) => Te.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
|
|
948
948
|
"string",
|
|
949
949
|
"number",
|
|
950
950
|
"boolean"
|
|
951
951
|
].includes(typeof e)) : !1;
|
|
952
952
|
}
|
|
953
|
-
function
|
|
953
|
+
function De(e) {
|
|
954
954
|
if (!e || typeof e != "object") return !1;
|
|
955
955
|
let t = e.properties;
|
|
956
|
-
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(
|
|
956
|
+
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(Ee);
|
|
957
957
|
}
|
|
958
958
|
//#endregion
|
|
959
959
|
//#region ../apigen-core-client/src/lib/compose-schemas.ts
|
|
@@ -989,7 +989,7 @@ function Ae(e, t, n) {
|
|
|
989
989
|
properties: o,
|
|
990
990
|
additionalProperties: !1,
|
|
991
991
|
...s.length > 0 ? { required: s } : {}
|
|
992
|
-
}, f = a.safe === !0 ||
|
|
992
|
+
}, f = a.safe === !0 || De(a.input), p = a.input.definitions, m = a.input.$defs;
|
|
993
993
|
r[i] = {
|
|
994
994
|
input: {
|
|
995
995
|
type: "object",
|
|
@@ -1030,15 +1030,15 @@ var B = class extends Error {
|
|
|
1030
1030
|
};
|
|
1031
1031
|
//#endregion
|
|
1032
1032
|
//#region src/lib/api-package.ts
|
|
1033
|
-
function
|
|
1033
|
+
function Ne(e) {
|
|
1034
1034
|
for (let t of e) for (let e of Object.keys(t.eventMapping ?? {})) {
|
|
1035
1035
|
let [n] = e.split(":");
|
|
1036
1036
|
if (n !== "*" && n === t.id) throw new B(`Middleware "${t.id}" subscribes to its own events via "${e}". This would cause infinite recursion.`);
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
|
-
function
|
|
1039
|
+
function Pe(e) {
|
|
1040
1040
|
let { domainSchemas: t, middlewares: n, overrides: r = {}, strict: i = !1 } = e;
|
|
1041
|
-
|
|
1041
|
+
Ne(n);
|
|
1042
1042
|
for (let e of Object.keys(r)) if (!(e in t.schemas)) {
|
|
1043
1043
|
let t = `Override key "${e}" not found in domain schemas.`;
|
|
1044
1044
|
if (i) throw new B(t);
|
|
@@ -1050,16 +1050,16 @@ function Ne(e) {
|
|
|
1050
1050
|
if (i) throw new B(t);
|
|
1051
1051
|
console.warn("[apigen-runtime]", t);
|
|
1052
1052
|
}
|
|
1053
|
-
let o = Ae(t, n, r), s = new
|
|
1054
|
-
return
|
|
1053
|
+
let o = Ae(t, n, r), s = new xe();
|
|
1054
|
+
return Ce(n, s), {
|
|
1055
1055
|
schemas: o,
|
|
1056
|
-
createClient: async (e) =>
|
|
1056
|
+
createClient: async (e) => we(n, e, s),
|
|
1057
1057
|
dispose: () => s.clear()
|
|
1058
1058
|
};
|
|
1059
1059
|
}
|
|
1060
1060
|
//#endregion
|
|
1061
1061
|
//#region src/lib/logger.ts
|
|
1062
|
-
function
|
|
1062
|
+
function Fe(e = {}) {
|
|
1063
1063
|
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
1064
|
if (a === "pretty") return o.transport = {
|
|
1065
1065
|
target: "pino-pretty",
|
|
@@ -1082,35 +1082,35 @@ function Pe(e = {}) {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
//#endregion
|
|
1084
1084
|
//#region src/lib/describe-params.ts
|
|
1085
|
-
function
|
|
1085
|
+
function Ie(e) {
|
|
1086
1086
|
if (e?.type !== "object" || !e.properties) return;
|
|
1087
1087
|
let t = Object.entries(e.properties);
|
|
1088
1088
|
if (t.length === 0) return;
|
|
1089
1089
|
let n = new Set(e.required ?? []);
|
|
1090
|
-
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${
|
|
1090
|
+
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${V(t)}`).join(", ")} }`;
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1092
|
+
function Le(e) {
|
|
1093
1093
|
return typeof e == "string" ? `'${e}'` : JSON.stringify(e);
|
|
1094
1094
|
}
|
|
1095
|
-
function
|
|
1095
|
+
function Re(e) {
|
|
1096
1096
|
let t = e.enum ?? [];
|
|
1097
|
-
return t.length === 0 ? "unknown" : t.map(
|
|
1097
|
+
return t.length === 0 ? "unknown" : t.map(Le).join("|");
|
|
1098
1098
|
}
|
|
1099
|
-
function
|
|
1100
|
-
return e.map((e) =>
|
|
1099
|
+
function ze(e, t) {
|
|
1100
|
+
return e.map((e) => V(e, t)).join(" | ");
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1102
|
+
function V(e, t = 0) {
|
|
1103
1103
|
if (!e) return "unknown";
|
|
1104
|
-
if (e.type === "array") return `${
|
|
1105
|
-
if (e.enum) return
|
|
1104
|
+
if (e.type === "array") return `${V(e.items, 0)}[]`;
|
|
1105
|
+
if (e.enum) return Re(e);
|
|
1106
1106
|
if (e.$ref) return String(e.$ref).split("/").pop() || "object";
|
|
1107
1107
|
let n = e.anyOf ?? e.oneOf;
|
|
1108
|
-
return n ? n.length === 0 ? "unknown" : t >= 2 ?
|
|
1108
|
+
return n ? n.length === 0 ? "unknown" : t >= 2 ? ze(n, t - 1) : "union" : t >= 1 && e.type === "object" ? Ie(e) ?? "object" : e.type ?? "object";
|
|
1109
1109
|
}
|
|
1110
|
-
function
|
|
1110
|
+
function Be(e) {
|
|
1111
1111
|
let t = (e?.input ?? {}).properties?.data, n = t?.properties ?? {}, r = new Set(t?.required ?? []), i = Object.entries(n).map(([e, t]) => ({
|
|
1112
1112
|
name: e,
|
|
1113
|
-
type:
|
|
1113
|
+
type: V(t, 2),
|
|
1114
1114
|
required: r.has(e)
|
|
1115
1115
|
}));
|
|
1116
1116
|
return {
|
|
@@ -1120,16 +1120,16 @@ function U(e) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
//#endregion
|
|
1122
1122
|
//#region src/lib/coerce-query.ts
|
|
1123
|
-
function
|
|
1123
|
+
function Ve(e) {
|
|
1124
1124
|
let t;
|
|
1125
1125
|
return t = Array.isArray(e) ? e : e ? [e] : [], t.find((e) => e === "number" || e === "integer" || e === "boolean");
|
|
1126
1126
|
}
|
|
1127
|
-
function
|
|
1127
|
+
function He(e, t) {
|
|
1128
1128
|
let n = (t?.input ?? {}).properties?.data?.properties ?? {}, r = { ...e };
|
|
1129
1129
|
for (let [e, t] of Object.entries(n)) {
|
|
1130
1130
|
let n = r[e];
|
|
1131
1131
|
if (typeof n != "string") continue;
|
|
1132
|
-
let i =
|
|
1132
|
+
let i = Ve(t?.type);
|
|
1133
1133
|
if (i === "number" || i === "integer") {
|
|
1134
1134
|
let t = Number(n);
|
|
1135
1135
|
!Number.isNaN(t) && n.trim() !== "" && (r[e] = t);
|
|
@@ -1139,30 +1139,30 @@ function Be(e, t) {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
//#endregion
|
|
1141
1141
|
//#region src/lib/fn-table.ts
|
|
1142
|
-
var
|
|
1142
|
+
var Ue = /* @__PURE__ */ new Set([
|
|
1143
1143
|
"default",
|
|
1144
1144
|
"module.exports",
|
|
1145
1145
|
"__esModule"
|
|
1146
1146
|
]);
|
|
1147
|
-
function
|
|
1147
|
+
function We(e) {
|
|
1148
1148
|
let t = {}, n = (e, r) => {
|
|
1149
1149
|
for (let [i, a] of Object.entries(e)) if (typeof a == "function") {
|
|
1150
|
-
!
|
|
1150
|
+
!Ue.has(i) && !(i in t) && (t[i] = a);
|
|
1151
1151
|
let e = a.name;
|
|
1152
1152
|
e && !(e in t) && (t[e] = a);
|
|
1153
|
-
} else a && typeof a == "object" && r < 2 &&
|
|
1153
|
+
} else a && typeof a == "object" && r < 2 && Ue.has(i) && n(a, r + 1);
|
|
1154
1154
|
};
|
|
1155
1155
|
return n(e, 0), t;
|
|
1156
1156
|
}
|
|
1157
1157
|
//#endregion
|
|
1158
1158
|
//#region ../apigen-base-errors/src/lib/errors.ts
|
|
1159
|
-
var
|
|
1159
|
+
var Ge = [
|
|
1160
1160
|
"invalid_argument",
|
|
1161
1161
|
"unauthenticated",
|
|
1162
1162
|
"permission_denied",
|
|
1163
1163
|
"not_found",
|
|
1164
1164
|
"internal"
|
|
1165
|
-
],
|
|
1165
|
+
], H = class extends Error {
|
|
1166
1166
|
constructor(e, t, n) {
|
|
1167
1167
|
super(t), this.name = "ApiError", this.code = e, this.details = n, Object.setPrototypeOf(this, new.target.prototype);
|
|
1168
1168
|
}
|
|
@@ -1174,10 +1174,10 @@ var He = [
|
|
|
1174
1174
|
return this.details !== void 0 && (e.details = this.details), e;
|
|
1175
1175
|
}
|
|
1176
1176
|
};
|
|
1177
|
-
function
|
|
1178
|
-
return typeof e == "object" && !!e && e.name === "ApiError" &&
|
|
1177
|
+
function Ke(e) {
|
|
1178
|
+
return typeof e == "object" && !!e && e.name === "ApiError" && Ge.includes(e.code) && typeof e.toJSON == "function";
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1180
|
+
function qe(e, t, n = 0) {
|
|
1181
1181
|
return e === "before-first-chunk" ? {
|
|
1182
1182
|
phase: e,
|
|
1183
1183
|
error: t
|
|
@@ -1189,72 +1189,136 @@ function We(e, t, n = 0) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
//#endregion
|
|
1191
1191
|
//#region src/lib/validate-layer.ts
|
|
1192
|
-
var
|
|
1193
|
-
|
|
1192
|
+
var U = new n({
|
|
1193
|
+
allErrors: !0,
|
|
1194
|
+
verbose: !0
|
|
1195
|
+
});
|
|
1196
|
+
r(U);
|
|
1194
1197
|
for (let e of [
|
|
1195
1198
|
s,
|
|
1196
1199
|
c,
|
|
1197
1200
|
l,
|
|
1198
1201
|
u,
|
|
1199
1202
|
"discriminator"
|
|
1200
|
-
])
|
|
1203
|
+
]) U.addKeyword({
|
|
1201
1204
|
keyword: e,
|
|
1202
1205
|
valid: !0
|
|
1203
1206
|
});
|
|
1204
|
-
|
|
1205
|
-
function
|
|
1206
|
-
return e.map((e) =>
|
|
1207
|
+
U.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
|
|
1208
|
+
function Je(e) {
|
|
1209
|
+
return e ? e.replace(/^\//, "").split("/").map((e) => e.replace(/~1/g, "/").replace(/~0/g, "~")).join(".") : "(root)";
|
|
1210
|
+
}
|
|
1211
|
+
function Ye(e) {
|
|
1212
|
+
let t = e?.properties;
|
|
1213
|
+
return t ? Object.keys(t) : [];
|
|
1214
|
+
}
|
|
1215
|
+
function Xe(e, t) {
|
|
1216
|
+
let n = e.length, r = t.length;
|
|
1217
|
+
if (n === 0) return r;
|
|
1218
|
+
if (r === 0) return n;
|
|
1219
|
+
let i = Array.from({ length: r + 1 }, (e, t) => t);
|
|
1220
|
+
for (let a = 1; a <= n; a++) {
|
|
1221
|
+
let n = [a];
|
|
1222
|
+
for (let o = 1; o <= r; o++) {
|
|
1223
|
+
let r = e[a - 1] === t[o - 1] ? 0 : 1;
|
|
1224
|
+
n[o] = Math.min(i[o] + 1, n[o - 1] + 1, i[o - 1] + r);
|
|
1225
|
+
}
|
|
1226
|
+
i = n;
|
|
1227
|
+
}
|
|
1228
|
+
return i[r];
|
|
1229
|
+
}
|
|
1230
|
+
function Ze(e, t) {
|
|
1231
|
+
let n, r = Infinity;
|
|
1232
|
+
for (let i of t) {
|
|
1233
|
+
let t = Xe(e.toLowerCase(), i.toLowerCase());
|
|
1234
|
+
t < r && (r = t, n = i);
|
|
1235
|
+
}
|
|
1236
|
+
let i = Math.max(2, Math.floor(e.length / 3));
|
|
1237
|
+
return n !== void 0 && r <= i ? n : void 0;
|
|
1238
|
+
}
|
|
1239
|
+
function Qe(e) {
|
|
1240
|
+
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1241
|
+
}
|
|
1242
|
+
function $e(e) {
|
|
1243
|
+
let t = Je(e.instancePath), n = e.params ?? {};
|
|
1244
|
+
switch (e.keyword) {
|
|
1245
|
+
case "additionalProperties": {
|
|
1246
|
+
let r = String(n.additionalProperty ?? "?"), i = Ye(e.parentSchema), a = Ze(r, i);
|
|
1247
|
+
return `unknown key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}${a ? ` (did you mean '${a}'?)` : ""}`;
|
|
1248
|
+
}
|
|
1249
|
+
case "required": {
|
|
1250
|
+
let r = String(n.missingProperty ?? "?"), i = Ye(e.parentSchema);
|
|
1251
|
+
return `missing required key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}`;
|
|
1252
|
+
}
|
|
1253
|
+
case "enum": {
|
|
1254
|
+
let r = Array.isArray(n.allowedValues) ? n.allowedValues : [], i = e.data;
|
|
1255
|
+
return `value ${JSON.stringify(i)} at ${t} is not one of: ${r.map((e) => JSON.stringify(e)).join(", ")}`;
|
|
1256
|
+
}
|
|
1257
|
+
case "type": {
|
|
1258
|
+
let r = e.data;
|
|
1259
|
+
return `${t} must be ${String(n.type)} (got ${Qe(r)})`;
|
|
1260
|
+
}
|
|
1261
|
+
default: return `${t} ${e.message ?? "failed schema check"}`;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
var W = 12;
|
|
1265
|
+
function et(e) {
|
|
1266
|
+
let t = e.slice(0, W).map($e);
|
|
1267
|
+
return e.length > W && t.push(`…and ${e.length - W} more`), t.join("; ");
|
|
1207
1268
|
}
|
|
1208
|
-
function
|
|
1209
|
-
|
|
1210
|
-
return n && r.push(n), r.join(" — ");
|
|
1269
|
+
function G(e) {
|
|
1270
|
+
return e === null ? !1 : Array.isArray(e) ? e.some(G) : typeof e != "object" || Object.values(e).some(G);
|
|
1211
1271
|
}
|
|
1212
|
-
|
|
1213
|
-
let n = e
|
|
1272
|
+
function tt(e, t) {
|
|
1273
|
+
let n = [`Validation failed: ${et(e)}`], r = j(t);
|
|
1274
|
+
return G(r) && n.push(`Example: ${JSON.stringify(r)}`), n.join(" — ");
|
|
1275
|
+
}
|
|
1276
|
+
var nt = async (e, t) => {
|
|
1277
|
+
let n = e.ctx.get(rt);
|
|
1214
1278
|
if (n === void 0) return t();
|
|
1215
1279
|
let r = n[e.operation.id];
|
|
1216
1280
|
if (r === void 0) return t();
|
|
1217
1281
|
let i = {
|
|
1218
1282
|
data: e.domainArgs,
|
|
1219
1283
|
...e.envelope
|
|
1220
|
-
}, a =
|
|
1284
|
+
}, a = U.compile(r.input);
|
|
1221
1285
|
if (!a(i)) {
|
|
1222
1286
|
let e = a.errors ?? [];
|
|
1223
|
-
throw new
|
|
1287
|
+
throw new H("invalid_argument", tt(e, r.input), e);
|
|
1224
1288
|
}
|
|
1225
1289
|
return t();
|
|
1226
|
-
},
|
|
1227
|
-
function
|
|
1290
|
+
}, rt = Symbol("ValidateSchemasToken");
|
|
1291
|
+
function it(e) {
|
|
1228
1292
|
return async function(t, n) {
|
|
1229
1293
|
let r = e[t.operation.id];
|
|
1230
1294
|
if (r === void 0) return n();
|
|
1231
1295
|
let i = {
|
|
1232
1296
|
data: t.domainArgs,
|
|
1233
1297
|
...t.envelope
|
|
1234
|
-
}, a =
|
|
1298
|
+
}, a = U.compile(r.input);
|
|
1235
1299
|
if (!a(i)) {
|
|
1236
1300
|
let e = a.errors ?? [];
|
|
1237
|
-
throw new
|
|
1301
|
+
throw new H("invalid_argument", tt(e, r.input), e);
|
|
1238
1302
|
}
|
|
1239
1303
|
return n();
|
|
1240
1304
|
};
|
|
1241
1305
|
}
|
|
1242
1306
|
//#endregion
|
|
1243
1307
|
//#region src/lib/instance-registry.ts
|
|
1244
|
-
function
|
|
1308
|
+
function at() {
|
|
1245
1309
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
1246
1310
|
let t = Math.random() * 16 | 0;
|
|
1247
1311
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
1248
1312
|
});
|
|
1249
1313
|
}
|
|
1250
|
-
var
|
|
1314
|
+
var ot = class {
|
|
1251
1315
|
constructor(e = {}) {
|
|
1252
1316
|
this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = e.defaultTtlMs;
|
|
1253
1317
|
let t = null;
|
|
1254
1318
|
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?.());
|
|
1255
1319
|
}
|
|
1256
1320
|
create(e, t = [], n) {
|
|
1257
|
-
let r = new e(...t), i =
|
|
1321
|
+
let r = new e(...t), i = at(), a = n ?? this._defaultTtlMs, o = a === void 0 ? null : Date.now() + a;
|
|
1258
1322
|
return this._store.set(i, {
|
|
1259
1323
|
instance: r,
|
|
1260
1324
|
expiresAt: o
|
|
@@ -1273,12 +1337,12 @@ var Ze = class {
|
|
|
1273
1337
|
}
|
|
1274
1338
|
async dispose(e) {
|
|
1275
1339
|
let t = this._store.get(e);
|
|
1276
|
-
t && (this._store.delete(e), await
|
|
1340
|
+
t && (this._store.delete(e), await K(t.instance));
|
|
1277
1341
|
}
|
|
1278
1342
|
async disposeAll() {
|
|
1279
1343
|
this._sweeper !== null && (clearInterval(this._sweeper), this._sweeper = null);
|
|
1280
1344
|
let e = [...this._store.entries()];
|
|
1281
|
-
this._store.clear(), await Promise.all(e.map(([, e]) =>
|
|
1345
|
+
this._store.clear(), await Promise.all(e.map(([, e]) => K(e.instance)));
|
|
1282
1346
|
}
|
|
1283
1347
|
get size() {
|
|
1284
1348
|
return this._store.size;
|
|
@@ -1288,10 +1352,10 @@ var Ze = class {
|
|
|
1288
1352
|
for (let [t, n] of this._store) n.expiresAt !== null && e > n.expiresAt && this._evict(t, n);
|
|
1289
1353
|
}
|
|
1290
1354
|
_evict(e, t) {
|
|
1291
|
-
this._store.delete(e),
|
|
1355
|
+
this._store.delete(e), K(t.instance);
|
|
1292
1356
|
}
|
|
1293
1357
|
};
|
|
1294
|
-
async function
|
|
1358
|
+
async function K(e) {
|
|
1295
1359
|
if (typeof e == "object" && e && "dispose" in e) {
|
|
1296
1360
|
let t = e.dispose;
|
|
1297
1361
|
typeof t == "function" && await t.call(e);
|
|
@@ -1299,7 +1363,7 @@ async function q(e) {
|
|
|
1299
1363
|
}
|
|
1300
1364
|
//#endregion
|
|
1301
1365
|
//#region src/lib/stream.ts
|
|
1302
|
-
function
|
|
1366
|
+
function st(e) {
|
|
1303
1367
|
let { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
1304
1368
|
return { [Symbol.asyncIterator]() {
|
|
1305
1369
|
let e = t(r);
|
|
@@ -1325,12 +1389,12 @@ function Qe(e) {
|
|
|
1325
1389
|
};
|
|
1326
1390
|
} };
|
|
1327
1391
|
}
|
|
1328
|
-
async function
|
|
1392
|
+
async function ct(e) {
|
|
1329
1393
|
let t = [];
|
|
1330
1394
|
for await (let n of e) t.push(n);
|
|
1331
1395
|
return t;
|
|
1332
1396
|
}
|
|
1333
|
-
async function
|
|
1397
|
+
async function lt(e) {
|
|
1334
1398
|
let t = [];
|
|
1335
1399
|
try {
|
|
1336
1400
|
for await (let n of e) t.push(n);
|
|
@@ -1339,27 +1403,27 @@ async function et(e) {
|
|
|
1339
1403
|
chunks: t
|
|
1340
1404
|
};
|
|
1341
1405
|
} catch (e) {
|
|
1342
|
-
let n =
|
|
1406
|
+
let n = Ke(e) ? e : new H("internal", e instanceof Error ? e.message : String(e));
|
|
1343
1407
|
return t.length === 0 ? {
|
|
1344
1408
|
ok: !1,
|
|
1345
|
-
carrier:
|
|
1409
|
+
carrier: qe("before-first-chunk", n)
|
|
1346
1410
|
} : {
|
|
1347
1411
|
ok: !1,
|
|
1348
|
-
carrier:
|
|
1412
|
+
carrier: qe("after-first-chunk", n, t.length)
|
|
1349
1413
|
};
|
|
1350
1414
|
}
|
|
1351
1415
|
}
|
|
1352
|
-
function
|
|
1416
|
+
function ut(e) {
|
|
1353
1417
|
return typeof e == "object" && !!e && Symbol.asyncIterator in e;
|
|
1354
1418
|
}
|
|
1355
1419
|
//#endregion
|
|
1356
1420
|
//#region src/lib/logical/union-codec.ts
|
|
1357
|
-
var
|
|
1421
|
+
var q = class extends Error {
|
|
1358
1422
|
constructor(e, t) {
|
|
1359
1423
|
super(t), this.name = "UnionCodecError", this.code = e;
|
|
1360
1424
|
}
|
|
1361
1425
|
};
|
|
1362
|
-
function
|
|
1426
|
+
function J(e) {
|
|
1363
1427
|
let t = e.discriminator;
|
|
1364
1428
|
if (typeof t != "object" || !t || Array.isArray(t)) return;
|
|
1365
1429
|
let n = t;
|
|
@@ -1370,7 +1434,7 @@ function Y(e) {
|
|
|
1370
1434
|
mapping: r
|
|
1371
1435
|
};
|
|
1372
1436
|
}
|
|
1373
|
-
function
|
|
1437
|
+
function dt(e, t) {
|
|
1374
1438
|
let n = e[c];
|
|
1375
1439
|
if (typeof n == "string") {
|
|
1376
1440
|
let e = t.registry.get(n);
|
|
@@ -1378,15 +1442,15 @@ function nt(e, t) {
|
|
|
1378
1442
|
}
|
|
1379
1443
|
return t.registry.resolve(e);
|
|
1380
1444
|
}
|
|
1381
|
-
function
|
|
1382
|
-
let r =
|
|
1445
|
+
function ft(e, t, n) {
|
|
1446
|
+
let r = dt(t, n);
|
|
1383
1447
|
return r ? r.encode(e, t, n) : e;
|
|
1384
1448
|
}
|
|
1385
|
-
function
|
|
1386
|
-
let r =
|
|
1449
|
+
function pt(e, t, n) {
|
|
1450
|
+
let r = dt(t, n);
|
|
1387
1451
|
return r ? r.decode(e, t, n) : e;
|
|
1388
1452
|
}
|
|
1389
|
-
function
|
|
1453
|
+
function mt(e) {
|
|
1390
1454
|
let { id: t, schema: n } = e;
|
|
1391
1455
|
return {
|
|
1392
1456
|
id: t,
|
|
@@ -1395,16 +1459,16 @@ function at(e) {
|
|
|
1395
1459
|
matches(e) {
|
|
1396
1460
|
if (e["x-apigen-logical"] === "union") return !0;
|
|
1397
1461
|
let t = e.oneOf;
|
|
1398
|
-
return !Array.isArray(t) || t.length === 0 ? !1 :
|
|
1462
|
+
return !Array.isArray(t) || t.length === 0 ? !1 : J(e) !== void 0;
|
|
1399
1463
|
},
|
|
1400
1464
|
encode(e, n, r) {
|
|
1401
|
-
let i =
|
|
1402
|
-
if (!i) throw new
|
|
1465
|
+
let i = J(n);
|
|
1466
|
+
if (!i) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] schema node at "${r.path}" has no discriminator.propertyName; cannot dispatch union branch.`);
|
|
1403
1467
|
let { propertyName: a, mapping: o } = i, s = e[a];
|
|
1404
|
-
if (s == null) throw new
|
|
1468
|
+
if (s == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] value at "${r.path}" is missing the discriminator property "${a}".`);
|
|
1405
1469
|
let c = String(s), l = o[c];
|
|
1406
|
-
if (!l) throw new
|
|
1407
|
-
return
|
|
1470
|
+
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 ft(e, r.resolve(l), {
|
|
1408
1472
|
...r,
|
|
1409
1473
|
path: `${r.path}[${c}]`
|
|
1410
1474
|
});
|
|
@@ -1412,49 +1476,49 @@ function at(e) {
|
|
|
1412
1476
|
decode(e, n, r) {
|
|
1413
1477
|
if (typeof e != "object" || !e || Array.isArray(e)) {
|
|
1414
1478
|
let n;
|
|
1415
|
-
throw n = e === null ? "null" : Array.isArray(e) ? "array" : typeof e, new
|
|
1479
|
+
throw n = e === null ? "null" : Array.isArray(e) ? "array" : typeof e, new q("E_UNION_INVALID_WIRE", `[${t}] expected a JSON object on the wire at "${r.path}", got ${n}.`);
|
|
1416
1480
|
}
|
|
1417
|
-
let i = e, a =
|
|
1418
|
-
if (!a) throw new
|
|
1481
|
+
let i = e, a = J(n);
|
|
1482
|
+
if (!a) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] schema node at "${r.path}" has no discriminator.propertyName; cannot dispatch union branch.`);
|
|
1419
1483
|
let { propertyName: o, mapping: s } = a, c = i[o];
|
|
1420
|
-
if (c == null) throw new
|
|
1484
|
+
if (c == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] wire object at "${r.path}" is missing the discriminator property "${o}".`);
|
|
1421
1485
|
let l = String(c), u = s[l];
|
|
1422
|
-
if (!u) throw new
|
|
1423
|
-
return
|
|
1486
|
+
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 pt(e, r.resolve(u), {
|
|
1424
1488
|
...r,
|
|
1425
1489
|
path: `${r.path}[${l}]`
|
|
1426
1490
|
});
|
|
1427
1491
|
}
|
|
1428
1492
|
};
|
|
1429
1493
|
}
|
|
1430
|
-
var
|
|
1494
|
+
var Y = class extends Error {
|
|
1431
1495
|
constructor(e, t) {
|
|
1432
1496
|
super(t), this.name = "NominalCodecError", this.code = e;
|
|
1433
1497
|
}
|
|
1434
1498
|
};
|
|
1435
|
-
function
|
|
1499
|
+
function ht(e) {
|
|
1436
1500
|
let t = e.properties;
|
|
1437
1501
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
1438
1502
|
}
|
|
1439
|
-
function
|
|
1503
|
+
function gt(e) {
|
|
1440
1504
|
let t = e.required;
|
|
1441
1505
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
1442
1506
|
}
|
|
1443
|
-
function
|
|
1507
|
+
function _t(e, t, n) {
|
|
1444
1508
|
if (t) {
|
|
1445
1509
|
let r = n.registry.resolve(t);
|
|
1446
1510
|
if (r) return r.encode(e, t, n);
|
|
1447
1511
|
}
|
|
1448
1512
|
return e;
|
|
1449
1513
|
}
|
|
1450
|
-
function
|
|
1514
|
+
function vt(e, t, n) {
|
|
1451
1515
|
if (t) {
|
|
1452
1516
|
let r = n.registry.resolve(t);
|
|
1453
1517
|
if (r) return r.decode(e, t, n);
|
|
1454
1518
|
}
|
|
1455
1519
|
return e;
|
|
1456
1520
|
}
|
|
1457
|
-
function
|
|
1521
|
+
function yt(e) {
|
|
1458
1522
|
let { id: t, schema: n, ctor: r } = e;
|
|
1459
1523
|
return {
|
|
1460
1524
|
id: t,
|
|
@@ -1466,17 +1530,17 @@ function ut(e) {
|
|
|
1466
1530
|
encode(e, n, r) {
|
|
1467
1531
|
if (typeof e != "object" || !e) return e;
|
|
1468
1532
|
if (r.seen.has(e)) {
|
|
1469
|
-
if (r.mode === "strict") throw new
|
|
1533
|
+
if (r.mode === "strict") throw new Y("E_NOMINAL_CYCLE", `[${t}] cycle detected at "${r.path}": a nominal instance references itself. Strict mode rejects cycles (DESIGN §8.3); break the cycle or use 'lossy' mode.`);
|
|
1470
1534
|
return null;
|
|
1471
1535
|
}
|
|
1472
1536
|
r.seen.add(e);
|
|
1473
1537
|
try {
|
|
1474
|
-
let t =
|
|
1538
|
+
let t = ht(n), i = e[typeof n["x-apigen-tojson"] == "string" ? n[u] : "toJSON"];
|
|
1475
1539
|
if (typeof i == "function") {
|
|
1476
1540
|
let n = i.call(e);
|
|
1477
1541
|
if (typeof n == "object" && n && !Array.isArray(n)) {
|
|
1478
1542
|
let e = {};
|
|
1479
|
-
for (let [i, a] of Object.entries(n)) e[i] =
|
|
1543
|
+
for (let [i, a] of Object.entries(n)) e[i] = _t(a, t[i], {
|
|
1480
1544
|
...r,
|
|
1481
1545
|
path: `${r.path}/${i}`
|
|
1482
1546
|
});
|
|
@@ -1487,7 +1551,7 @@ function ut(e) {
|
|
|
1487
1551
|
let a = {}, o = Object.keys(t), s = e, c = o.length > 0 ? o : Object.keys(s);
|
|
1488
1552
|
for (let e of c) {
|
|
1489
1553
|
let n = s[e];
|
|
1490
|
-
n !== void 0 && (a[e] =
|
|
1554
|
+
n !== void 0 && (a[e] = _t(n, t[e], {
|
|
1491
1555
|
...r,
|
|
1492
1556
|
path: `${r.path}/${e}`
|
|
1493
1557
|
}));
|
|
@@ -1500,13 +1564,13 @@ function ut(e) {
|
|
|
1500
1564
|
decode(e, n, i) {
|
|
1501
1565
|
if (typeof e != "object" || !e || Array.isArray(e)) {
|
|
1502
1566
|
let n;
|
|
1503
|
-
throw n = e === null ? "null" : Array.isArray(e) ? "array" : typeof e, new
|
|
1567
|
+
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}.`);
|
|
1504
1568
|
}
|
|
1505
1569
|
let a = e;
|
|
1506
|
-
for (let e of
|
|
1507
|
-
if (n["x-apigen-instances"] === !1) throw new
|
|
1508
|
-
let o =
|
|
1509
|
-
for (let [e, t] of Object.entries(a)) s[e] =
|
|
1570
|
+
for (let e of gt(n)) if (!(e in a)) throw new Y("E_NOMINAL_INVALID_WIRE", `[${t}] required field "${e}" missing on the wire at "${i.path}".`);
|
|
1571
|
+
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 = ht(n), s = {};
|
|
1573
|
+
for (let [e, t] of Object.entries(a)) s[e] = vt(t, o[e], {
|
|
1510
1574
|
...i,
|
|
1511
1575
|
path: `${i.path}/${e}`
|
|
1512
1576
|
});
|
|
@@ -1520,21 +1584,21 @@ function ut(e) {
|
|
|
1520
1584
|
}
|
|
1521
1585
|
//#endregion
|
|
1522
1586
|
//#region src/lib/logical/host-ts.ts
|
|
1523
|
-
var
|
|
1587
|
+
var bt = [
|
|
1524
1588
|
x,
|
|
1525
1589
|
S,
|
|
1590
|
+
C,
|
|
1526
1591
|
w,
|
|
1527
1592
|
T,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
], ft = ut({
|
|
1593
|
+
k
|
|
1594
|
+
], xt = yt({
|
|
1531
1595
|
id: "ts.NominalSentinel",
|
|
1532
1596
|
schema: {
|
|
1533
1597
|
type: "object",
|
|
1534
1598
|
"x-apigen-logical": "nominal",
|
|
1535
1599
|
"x-apigen-codec": "ts.NominalSentinel"
|
|
1536
1600
|
}
|
|
1537
|
-
}),
|
|
1601
|
+
}), St = mt({
|
|
1538
1602
|
id: "ts.UnionSentinel",
|
|
1539
1603
|
schema: {
|
|
1540
1604
|
oneOf: [],
|
|
@@ -1546,22 +1610,22 @@ var dt = [
|
|
|
1546
1610
|
"x-apigen-codec": "ts.UnionSentinel"
|
|
1547
1611
|
}
|
|
1548
1612
|
});
|
|
1549
|
-
function
|
|
1613
|
+
function Ct() {
|
|
1550
1614
|
let e = [
|
|
1551
|
-
...
|
|
1552
|
-
[
|
|
1553
|
-
[
|
|
1615
|
+
...bt.map((e) => [e.id, e]),
|
|
1616
|
+
[xt.id, xt],
|
|
1617
|
+
[St.id, St]
|
|
1554
1618
|
];
|
|
1555
1619
|
return Object.freeze(new Map(e));
|
|
1556
1620
|
}
|
|
1557
|
-
var
|
|
1621
|
+
var wt = Object.freeze({
|
|
1558
1622
|
host: "ts",
|
|
1559
1623
|
logicalTypeVersion: d,
|
|
1560
|
-
codecs:
|
|
1624
|
+
codecs: Ct()
|
|
1561
1625
|
});
|
|
1562
1626
|
//#endregion
|
|
1563
1627
|
//#region src/lib/tool-description.ts
|
|
1564
|
-
function
|
|
1628
|
+
function Tt(e, t, n) {
|
|
1565
1629
|
let r = [
|
|
1566
1630
|
n,
|
|
1567
1631
|
typeof t?.input?.description == "string" ? t.input.description : void 0,
|
|
@@ -1571,7 +1635,7 @@ function ht(e, t, n) {
|
|
|
1571
1635
|
}
|
|
1572
1636
|
//#endregion
|
|
1573
1637
|
//#region src/lib/mcp-output-schema.ts
|
|
1574
|
-
function
|
|
1638
|
+
function Et(e) {
|
|
1575
1639
|
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length === 0) return {
|
|
1576
1640
|
outputSchema: void 0,
|
|
1577
1641
|
wrapped: !1
|
|
@@ -1585,25 +1649,25 @@ function gt(e) {
|
|
|
1585
1649
|
wrapped: !1
|
|
1586
1650
|
};
|
|
1587
1651
|
}
|
|
1588
|
-
function
|
|
1652
|
+
function Dt(e, t) {
|
|
1589
1653
|
if (e) return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1590
1654
|
}
|
|
1591
1655
|
//#endregion
|
|
1592
1656
|
//#region src/lib/batch.ts
|
|
1593
|
-
var
|
|
1594
|
-
function
|
|
1595
|
-
return
|
|
1657
|
+
var Ot = 4, kt = 32;
|
|
1658
|
+
function X(e) {
|
|
1659
|
+
return Ke(e) ? e : e instanceof Error ? new H("internal", e.message) : e;
|
|
1596
1660
|
}
|
|
1597
|
-
function
|
|
1661
|
+
function At(e, t) {
|
|
1598
1662
|
if (e === "serial" || e === "chained") return 1;
|
|
1599
1663
|
let n = t ?? 4;
|
|
1600
1664
|
return !Number.isFinite(n) || n < 1 ? 1 : Math.min(Math.floor(n), 32);
|
|
1601
1665
|
}
|
|
1602
|
-
function
|
|
1603
|
-
function
|
|
1666
|
+
function jt() {}
|
|
1667
|
+
function Mt(e, t) {
|
|
1604
1668
|
if (!e && !t) return {
|
|
1605
1669
|
signal: void 0,
|
|
1606
|
-
dispose:
|
|
1670
|
+
dispose: jt
|
|
1607
1671
|
};
|
|
1608
1672
|
let n = new AbortController(), r = () => {
|
|
1609
1673
|
n.abort(e?.reason);
|
|
@@ -1619,21 +1683,21 @@ function St(e, t) {
|
|
|
1619
1683
|
}
|
|
1620
1684
|
};
|
|
1621
1685
|
}
|
|
1622
|
-
async function
|
|
1623
|
-
let o =
|
|
1686
|
+
async function Nt(e, t, n, r, i, a) {
|
|
1687
|
+
let o = Mt(r.signal, a);
|
|
1624
1688
|
try {
|
|
1625
1689
|
let a = await e(t, o.signal ? {
|
|
1626
1690
|
...r,
|
|
1627
1691
|
signal: o.signal
|
|
1628
1692
|
} : r, i);
|
|
1629
|
-
if (
|
|
1630
|
-
let e = await
|
|
1693
|
+
if (ut(a)) {
|
|
1694
|
+
let e = await lt(a);
|
|
1631
1695
|
if (!e.ok) {
|
|
1632
1696
|
let t = e.carrier;
|
|
1633
1697
|
return {
|
|
1634
1698
|
index: n,
|
|
1635
1699
|
status: "rejected",
|
|
1636
|
-
reason:
|
|
1700
|
+
reason: X(t.error),
|
|
1637
1701
|
...t.phase === "after-first-chunk" ? { chunksDelivered: t.chunksDelivered } : {}
|
|
1638
1702
|
};
|
|
1639
1703
|
}
|
|
@@ -1652,17 +1716,17 @@ async function Ct(e, t, n, r, i, a) {
|
|
|
1652
1716
|
return {
|
|
1653
1717
|
index: n,
|
|
1654
1718
|
status: "rejected",
|
|
1655
|
-
reason:
|
|
1719
|
+
reason: X(e)
|
|
1656
1720
|
};
|
|
1657
1721
|
} finally {
|
|
1658
1722
|
o.dispose();
|
|
1659
1723
|
}
|
|
1660
1724
|
}
|
|
1661
|
-
async function
|
|
1662
|
-
let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s =
|
|
1725
|
+
async function Pt(e, t, n, r, i = {}) {
|
|
1726
|
+
let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s = At(a, i.concurrency), c = Array(n.length), l = (e) => ({
|
|
1663
1727
|
index: e,
|
|
1664
1728
|
status: "rejected",
|
|
1665
|
-
reason:
|
|
1729
|
+
reason: X(/* @__PURE__ */ Error("apigen/invokeBatch: not attempted — an earlier item failed and " + (a === "chained" ? "mode is \"chained\"" : "onItemError is \"abort\"")))
|
|
1666
1730
|
});
|
|
1667
1731
|
if (a === "serial" || a === "chained") {
|
|
1668
1732
|
let s = !1;
|
|
@@ -1671,7 +1735,7 @@ async function wt(e, t, n, r, i = {}) {
|
|
|
1671
1735
|
c[u] = l(u);
|
|
1672
1736
|
continue;
|
|
1673
1737
|
}
|
|
1674
|
-
let d = await
|
|
1738
|
+
let d = await Nt(e, t, u, n[u], r, i.itemTimeoutMs);
|
|
1675
1739
|
c[u] = d, d.status === "rejected" && (a === "chained" || o === "abort") && (s = !0);
|
|
1676
1740
|
}
|
|
1677
1741
|
return c;
|
|
@@ -1684,7 +1748,7 @@ async function wt(e, t, n, r, i = {}) {
|
|
|
1684
1748
|
c[a] = l(a);
|
|
1685
1749
|
continue;
|
|
1686
1750
|
}
|
|
1687
|
-
let s = await
|
|
1751
|
+
let s = await Nt(e, t, a, n[a], r, i.itemTimeoutMs);
|
|
1688
1752
|
c[a] = s, s.status === "rejected" && o === "abort" && (d = !0);
|
|
1689
1753
|
}
|
|
1690
1754
|
});
|
|
@@ -1692,17 +1756,17 @@ async function wt(e, t, n, r, i = {}) {
|
|
|
1692
1756
|
}
|
|
1693
1757
|
//#endregion
|
|
1694
1758
|
//#region ../apigen-engine-naming/src/lib/naming.ts
|
|
1695
|
-
function
|
|
1759
|
+
function Ft(e) {
|
|
1696
1760
|
return e.words.join("-");
|
|
1697
1761
|
}
|
|
1698
|
-
function
|
|
1699
|
-
return e.words.map(
|
|
1762
|
+
function It(e) {
|
|
1763
|
+
return e.words.map(Ht).join("");
|
|
1700
1764
|
}
|
|
1701
|
-
function
|
|
1765
|
+
function Lt(e) {
|
|
1702
1766
|
return e.words.join("_");
|
|
1703
1767
|
}
|
|
1704
|
-
function
|
|
1705
|
-
let n = [e.namespace, ...e.path], r = e.safe ||
|
|
1768
|
+
function Rt(e, t = {}) {
|
|
1769
|
+
let n = [e.namespace, ...e.path], r = e.safe || De(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));
|
|
1706
1770
|
return {
|
|
1707
1771
|
http: {
|
|
1708
1772
|
verb: i,
|
|
@@ -1717,100 +1781,100 @@ function Ot(e, t = {}) {
|
|
|
1717
1781
|
cli: { path: u }
|
|
1718
1782
|
};
|
|
1719
1783
|
}
|
|
1720
|
-
function
|
|
1784
|
+
function zt(e, t) {
|
|
1721
1785
|
return `x-${e}-${t}`;
|
|
1722
1786
|
}
|
|
1723
|
-
function
|
|
1787
|
+
function Bt(e, t) {
|
|
1724
1788
|
return `--${e}-${t}`;
|
|
1725
1789
|
}
|
|
1726
|
-
function
|
|
1790
|
+
function Vt(e, t) {
|
|
1727
1791
|
let n = (e) => e.toUpperCase().replace(/-/g, "_");
|
|
1728
1792
|
return e === "adhd" ? `APIGEN_${n(t)}` : `APIGEN_${n(e)}_${n(t)}`;
|
|
1729
1793
|
}
|
|
1730
|
-
function
|
|
1794
|
+
function Ht(e) {
|
|
1731
1795
|
return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
|
|
1732
1796
|
}
|
|
1733
1797
|
//#endregion
|
|
1734
1798
|
//#region src/lib/op-plan.ts
|
|
1735
|
-
function
|
|
1799
|
+
function Z(e) {
|
|
1736
1800
|
return e.anyOf ?? e.oneOf;
|
|
1737
1801
|
}
|
|
1738
|
-
function
|
|
1802
|
+
function Ut(e) {
|
|
1739
1803
|
if (!e) return !1;
|
|
1740
1804
|
if (e.type === "array" || e.type === "object") return !0;
|
|
1741
|
-
let t =
|
|
1805
|
+
let t = Z(e);
|
|
1742
1806
|
if (t) {
|
|
1743
1807
|
let e = t.filter((e) => e.type !== "null");
|
|
1744
1808
|
return e.length > 0 && e.every((e) => e.type === "array" || e.type === "object");
|
|
1745
1809
|
}
|
|
1746
1810
|
return !1;
|
|
1747
1811
|
}
|
|
1748
|
-
function
|
|
1812
|
+
function Wt(e) {
|
|
1749
1813
|
if (!e) return !1;
|
|
1750
1814
|
if (e.type === "boolean") return !0;
|
|
1751
|
-
let t =
|
|
1815
|
+
let t = Z(e);
|
|
1752
1816
|
if (t) {
|
|
1753
1817
|
let e = t.filter((e) => e.type !== "null");
|
|
1754
1818
|
return e.length > 0 && e.every((e) => e.type === "boolean");
|
|
1755
1819
|
}
|
|
1756
1820
|
return !1;
|
|
1757
1821
|
}
|
|
1758
|
-
function
|
|
1822
|
+
function Gt(e) {
|
|
1759
1823
|
if (!e) return !1;
|
|
1760
1824
|
if (e.type === "number" || e.type === "integer") return !0;
|
|
1761
|
-
let t =
|
|
1825
|
+
let t = Z(e);
|
|
1762
1826
|
if (t) {
|
|
1763
1827
|
let e = t.filter((e) => e.type !== "null");
|
|
1764
1828
|
return e.length > 0 && e.every((e) => e.type === "number" || e.type === "integer");
|
|
1765
1829
|
}
|
|
1766
1830
|
return !1;
|
|
1767
1831
|
}
|
|
1768
|
-
function
|
|
1832
|
+
function Kt(e) {
|
|
1769
1833
|
return e.replace(/[A-Z]/g, (e) => "-" + e.toLowerCase());
|
|
1770
1834
|
}
|
|
1771
|
-
function
|
|
1835
|
+
function qt(e) {
|
|
1772
1836
|
let t = e.input?.properties?.data;
|
|
1773
1837
|
return {
|
|
1774
1838
|
props: t?.properties ?? {},
|
|
1775
1839
|
required: t?.required ?? []
|
|
1776
1840
|
};
|
|
1777
1841
|
}
|
|
1778
|
-
function
|
|
1842
|
+
function Q(e) {
|
|
1779
1843
|
return typeof e.handler == "function";
|
|
1780
1844
|
}
|
|
1781
|
-
function
|
|
1845
|
+
function Jt(e) {
|
|
1782
1846
|
let t = e.input?.properties ?? {}, n = e["x-apigen-envelope"], r = [];
|
|
1783
1847
|
for (let e of Object.keys(t)) {
|
|
1784
1848
|
if (e === "data") continue;
|
|
1785
|
-
let t = n?.[e] ?? "adhd", i =
|
|
1849
|
+
let t = n?.[e] ?? "adhd", i = zt(t, e);
|
|
1786
1850
|
r.push({
|
|
1787
1851
|
field: e,
|
|
1788
1852
|
pluginId: t,
|
|
1789
1853
|
httpHeader: i,
|
|
1790
1854
|
mcpMetaKey: i,
|
|
1791
|
-
cliFlag:
|
|
1792
|
-
envVar:
|
|
1855
|
+
cliFlag: Bt(t, e),
|
|
1856
|
+
envVar: Vt(t, e)
|
|
1793
1857
|
});
|
|
1794
1858
|
}
|
|
1795
1859
|
return r;
|
|
1796
1860
|
}
|
|
1797
|
-
function
|
|
1861
|
+
function Yt(e, t, n, r) {
|
|
1798
1862
|
t === n || e.has(t) || e.set(t, {
|
|
1799
1863
|
...r,
|
|
1800
1864
|
aliasOf: n
|
|
1801
1865
|
});
|
|
1802
1866
|
}
|
|
1803
|
-
function
|
|
1804
|
-
let n = /* @__PURE__ */ new Map(), { props: r } =
|
|
1867
|
+
function Xt(e, t) {
|
|
1868
|
+
let n = /* @__PURE__ */ new Map(), { props: r } = qt(e);
|
|
1805
1869
|
for (let [e, t] of Object.entries(r)) {
|
|
1806
1870
|
let r = "string";
|
|
1807
|
-
|
|
1808
|
-
let i =
|
|
1871
|
+
Wt(t) ? r = "boolean" : (Ut(t) || Gt(t)) && (r = "json");
|
|
1872
|
+
let i = Kt(e), a = {
|
|
1809
1873
|
camelKey: e,
|
|
1810
1874
|
kind: "domain",
|
|
1811
1875
|
valueKind: r
|
|
1812
1876
|
};
|
|
1813
|
-
n.set(i, a),
|
|
1877
|
+
n.set(i, a), Yt(n, e, i, a);
|
|
1814
1878
|
}
|
|
1815
1879
|
for (let e of t) {
|
|
1816
1880
|
let t = e.cliFlag.replace(/^--/, ""), r = {
|
|
@@ -1823,8 +1887,8 @@ function Vt(e, t) {
|
|
|
1823
1887
|
}
|
|
1824
1888
|
return n;
|
|
1825
1889
|
}
|
|
1826
|
-
function
|
|
1827
|
-
let { op: t, schema: n, transport: r, projection: i } = e, a =
|
|
1890
|
+
function Zt(e) {
|
|
1891
|
+
let { op: t, schema: n, transport: r, projection: i } = e, a = Rt(t, i), o = n ? Jt(n) : [], s = n ? Xt(n, o) : /* @__PURE__ */ new Map(), c = n ? Be(n).params : void 0, l = {
|
|
1828
1892
|
op: t,
|
|
1829
1893
|
transport: r,
|
|
1830
1894
|
http: a.http,
|
|
@@ -1835,9 +1899,9 @@ function Ht(e) {
|
|
|
1835
1899
|
envelope: o,
|
|
1836
1900
|
cliFlags: s,
|
|
1837
1901
|
streaming: t.streaming,
|
|
1838
|
-
isMount:
|
|
1902
|
+
isMount: Q(t)
|
|
1839
1903
|
};
|
|
1840
|
-
if (
|
|
1904
|
+
if (Q(t)) {
|
|
1841
1905
|
let e = t.handler;
|
|
1842
1906
|
l.mountHandler = async (t) => e(t);
|
|
1843
1907
|
}
|
|
@@ -1845,35 +1909,35 @@ function Ht(e) {
|
|
|
1845
1909
|
}
|
|
1846
1910
|
//#endregion
|
|
1847
1911
|
//#region src/lib/package-invoker.ts
|
|
1848
|
-
function
|
|
1912
|
+
function Qt(e) {
|
|
1849
1913
|
let t = e.usePlugins;
|
|
1850
1914
|
return Array.isArray(t) ? t : [];
|
|
1851
1915
|
}
|
|
1852
|
-
function
|
|
1916
|
+
function $t(e) {
|
|
1853
1917
|
let t = e.exitCode;
|
|
1854
1918
|
return typeof t == "function" ? t : void 0;
|
|
1855
1919
|
}
|
|
1856
|
-
function
|
|
1920
|
+
function en(e) {
|
|
1857
1921
|
let t = e.useOptions;
|
|
1858
1922
|
return t && typeof t == "object" ? t : {};
|
|
1859
1923
|
}
|
|
1860
|
-
function
|
|
1924
|
+
function $(e) {
|
|
1861
1925
|
return async function(t, n) {
|
|
1862
1926
|
let r = Object.assign(t, { data: t.domainArgs });
|
|
1863
1927
|
return await e.layer(r, n);
|
|
1864
1928
|
};
|
|
1865
1929
|
}
|
|
1866
|
-
function
|
|
1930
|
+
function tn(e, t) {
|
|
1867
1931
|
let n = [];
|
|
1868
1932
|
for (let e of t) {
|
|
1869
1933
|
let t = e.capabilities?.layer;
|
|
1870
|
-
t && n.push(
|
|
1934
|
+
t && n.push($(t));
|
|
1871
1935
|
}
|
|
1872
|
-
return n.push(
|
|
1936
|
+
return n.push(it(e)), z(n);
|
|
1873
1937
|
}
|
|
1874
1938
|
//#endregion
|
|
1875
1939
|
//#region src/lib/dispatch-for-plan.ts
|
|
1876
|
-
function
|
|
1940
|
+
function nn() {
|
|
1877
1941
|
let e = /* @__PURE__ */ new Map();
|
|
1878
1942
|
return {
|
|
1879
1943
|
get: (t) => e.get(t),
|
|
@@ -1882,7 +1946,7 @@ function Jt() {
|
|
|
1882
1946
|
}
|
|
1883
1947
|
};
|
|
1884
1948
|
}
|
|
1885
|
-
var
|
|
1949
|
+
var rn = {
|
|
1886
1950
|
input: {
|
|
1887
1951
|
type: "object",
|
|
1888
1952
|
properties: { data: {
|
|
@@ -1892,11 +1956,12 @@ var Yt = {
|
|
|
1892
1956
|
},
|
|
1893
1957
|
output: {}
|
|
1894
1958
|
};
|
|
1895
|
-
async function
|
|
1959
|
+
async function an(e, t, n, r) {
|
|
1896
1960
|
let i = {
|
|
1897
1961
|
...n,
|
|
1898
1962
|
operation: { id: e.op.id },
|
|
1899
|
-
ctx: new
|
|
1963
|
+
ctx: new R(),
|
|
1964
|
+
transport: e.transport
|
|
1900
1965
|
};
|
|
1901
1966
|
if (e.isMount) {
|
|
1902
1967
|
let a = e.mountHandler;
|
|
@@ -1905,17 +1970,17 @@ async function Xt(e, t, n, r) {
|
|
|
1905
1970
|
operation: e.op,
|
|
1906
1971
|
data: n.domainArgs,
|
|
1907
1972
|
envelope: n.envelope,
|
|
1908
|
-
ctx:
|
|
1973
|
+
ctx: nn(),
|
|
1909
1974
|
transport: e.transport,
|
|
1910
1975
|
signal: n.signal ?? new AbortController().signal
|
|
1911
1976
|
}, s = {
|
|
1912
1977
|
...r,
|
|
1913
1978
|
fns: { [e.op.id]: () => a(o) },
|
|
1914
|
-
schemas: { [e.op.id]:
|
|
1979
|
+
schemas: { [e.op.id]: rn }
|
|
1915
1980
|
};
|
|
1916
1981
|
return t(e.op.id, i, s);
|
|
1917
1982
|
}
|
|
1918
1983
|
return t(e.op.id, i, r);
|
|
1919
1984
|
}
|
|
1920
1985
|
//#endregion
|
|
1921
|
-
export {
|
|
1986
|
+
export { Ot as BATCH_DEFAULT_CONCURRENCY, kt as BATCH_MAX_CONCURRENCY, xe as EventBus, ot as InstanceRegistry, R as LayerContext, q as UnionCodecError, rt as ValidateSchemasToken, bt as WELL_KNOWN_TS_CODECS, $ as adaptCoreLayer, Ne as assertNoSelfSubscription, we as buildContext, We as buildFnTable, Et as buildMcpOutputSchema, Zt as buildOpPlan, Tt as buildToolDescription, He as coerceQueryParams, lt as collectWithPhase, Pe as createApiPackage, z as createInvoker, Fe as createLogger, tn as createPackageInvoker, st as createStream, mt as createUnionCodec, F as dataParamNames, be as defineMiddleware, Be as describeParams, L as dispatch, an as dispatchForPlan, ct as drainStream, Pt as invokeBatch, ut as isApiStream, it as makeValidateLayer, P as needsEnvelopeField, $t as readExitCodeHook, en as readUseOptions, Qt as readUsePlugins, wt as tsHostBinding, nt as validateLayer, Ce as wireObservers, Dt as wrapMcpStructuredContent };
|