@adhd/apigen-engine-runtime 0.3.3 → 0.3.5
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 +19 -0
- package/README.md +1 -1
- package/index.js +12 -1
- package/index.mjs +541 -420
- package/package.json +4 -4
package/index.mjs
CHANGED
|
@@ -51,10 +51,8 @@ function o(e) {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region ../apigen-base-logical/src/lib/descriptor-ext.ts
|
|
54
|
-
var s = "x-apigen-logical", c = "x-apigen-codec", l = "x-apigen-ctor", u = "x-apigen-tojson", d = "0.1.0";
|
|
55
|
-
|
|
56
|
-
//#region ../apigen-base-logical/src/lib/runmode.ts
|
|
57
|
-
function f(e, t) {
|
|
54
|
+
var s = "x-apigen-logical", c = "x-apigen-codec", l = "x-apigen-ctor", u = "x-apigen-tojson", d = "0.1.0", f = [];
|
|
55
|
+
function p(e, t) {
|
|
58
56
|
return {
|
|
59
57
|
registry: e,
|
|
60
58
|
resolve: (e) => {
|
|
@@ -66,78 +64,74 @@ function f(e, t) {
|
|
|
66
64
|
...t
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
|
-
function
|
|
70
|
-
let
|
|
71
|
-
if (
|
|
72
|
-
let
|
|
73
|
-
if (typeof
|
|
74
|
-
let
|
|
75
|
-
if (Array.isArray(
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
if (!Array.isArray(e)) return v(e, t, n);
|
|
67
|
+
function m(e, t, n, r = f) {
|
|
68
|
+
let i = n.registry.resolve(t);
|
|
69
|
+
if (i) return i.encode(e, t, n);
|
|
70
|
+
let a = t.$ref;
|
|
71
|
+
if (typeof a == "string") return re(a, r, n), m(e, ee(a, n), n, [...r, a]);
|
|
72
|
+
let o = t.oneOf;
|
|
73
|
+
if (Array.isArray(o)) return m(e, te(e, o, t, n, r), n, r);
|
|
74
|
+
let s = t.type;
|
|
75
|
+
return s === "array" ? Array.isArray(e) ? g(e, n, () => {
|
|
79
76
|
let r = t.items;
|
|
80
77
|
if (!r) return e.map((e) => x(e));
|
|
81
78
|
let i = n.path;
|
|
82
79
|
return Array.isArray(r) ? e.map((e, t) => {
|
|
83
80
|
let a = r[t];
|
|
84
|
-
return a === void 0 ? x(e) :
|
|
81
|
+
return a === void 0 ? x(e) : m(e, a, {
|
|
85
82
|
...n,
|
|
86
83
|
path: `${i}/${t}`
|
|
87
84
|
});
|
|
88
|
-
}) : e.map((e, t) =>
|
|
85
|
+
}) : e.map((e, t) => m(e, r, {
|
|
89
86
|
...n,
|
|
90
87
|
path: `${i}/${t}`
|
|
91
88
|
}));
|
|
92
|
-
}
|
|
93
|
-
if (o === "object") {
|
|
94
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return v(e, t, n);
|
|
89
|
+
}) : y(e, t, n) : s === "object" ? typeof e != "object" || !e || Array.isArray(e) ? y(e, t, n) : g(e, n, () => {
|
|
95
90
|
let r = t.properties;
|
|
96
91
|
if (!r) return x(e);
|
|
97
92
|
let i = n.path, a = {};
|
|
98
93
|
for (let [t, o] of Object.entries(r)) {
|
|
99
94
|
let r = e[t];
|
|
100
|
-
r !== void 0 && (a[t] =
|
|
95
|
+
r !== void 0 && (a[t] = m(r, o, {
|
|
101
96
|
...n,
|
|
102
97
|
path: `${i}/${t}`
|
|
103
98
|
}));
|
|
104
99
|
}
|
|
105
100
|
return a;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (o === "array") {
|
|
101
|
+
}) : s == null ? y(e, t, n) : x(e);
|
|
102
|
+
}
|
|
103
|
+
function h(e, t, n, r = f) {
|
|
104
|
+
let i = n.registry.resolve(t);
|
|
105
|
+
if (i) return i.decode(e, t, n);
|
|
106
|
+
let a = t.$ref;
|
|
107
|
+
if (typeof a == "string") return re(a, r, n), h(e, ee(a, n), n, [...r, a]);
|
|
108
|
+
let o = t.oneOf;
|
|
109
|
+
if (Array.isArray(o)) return h(e, te(e, o, t, n, r), n, r);
|
|
110
|
+
let s = t.type;
|
|
111
|
+
if (s === "array") {
|
|
118
112
|
if (!Array.isArray(e)) return e;
|
|
119
113
|
let r = t.items;
|
|
120
114
|
if (!r) return e;
|
|
121
115
|
let i = n.path;
|
|
122
116
|
return Array.isArray(r) ? e.map((e, t) => {
|
|
123
117
|
let a = r[t];
|
|
124
|
-
return a === void 0 ? e :
|
|
118
|
+
return a === void 0 ? e : h(e, a, {
|
|
125
119
|
...n,
|
|
126
120
|
path: `${i}/${t}`
|
|
127
121
|
});
|
|
128
|
-
}) : e.map((e, t) =>
|
|
122
|
+
}) : e.map((e, t) => h(e, r, {
|
|
129
123
|
...n,
|
|
130
124
|
path: `${i}/${t}`
|
|
131
125
|
}));
|
|
132
126
|
}
|
|
133
|
-
if (
|
|
127
|
+
if (s === "object") {
|
|
134
128
|
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
135
129
|
let r = t.properties;
|
|
136
130
|
if (!r) return e;
|
|
137
131
|
let i = n.path, a = {};
|
|
138
132
|
for (let [t, o] of Object.entries(r)) {
|
|
139
133
|
let r = e[t];
|
|
140
|
-
r !== void 0 && (a[t] =
|
|
134
|
+
r !== void 0 && (a[t] = h(r, o, {
|
|
141
135
|
...n,
|
|
142
136
|
path: `${i}/${t}`
|
|
143
137
|
}));
|
|
@@ -145,101 +139,142 @@ function m(e, t, n) {
|
|
|
145
139
|
for (let [t, n] of Object.entries(e)) !(t in r) && n !== void 0 && (a[t] = n);
|
|
146
140
|
return a;
|
|
147
141
|
}
|
|
148
|
-
return
|
|
142
|
+
return s == null ? b(e, n) : e;
|
|
143
|
+
}
|
|
144
|
+
function ee(e, t) {
|
|
145
|
+
let n = [e], r = t.resolve(e);
|
|
146
|
+
for (; typeof r.$ref == "string" && t.registry.resolve(r) === void 0;) {
|
|
147
|
+
let e = r.$ref;
|
|
148
|
+
if (n.includes(e)) throw Error(`[apigen-logical] $ref "${e}" at "${t.path || "#"}" is an alias cycle (${[...n, e].join(" -> ")}); a $ref chain must end at a definition that is not itself a $ref`);
|
|
149
|
+
n.push(e), r = t.resolve(e);
|
|
150
|
+
}
|
|
151
|
+
return r;
|
|
152
|
+
}
|
|
153
|
+
function g(e, t, n) {
|
|
154
|
+
if (t.seen.has(e)) throw Error(`[apigen-logical] cyclic host value at "${t.path || "#"}": the value contains a reference to one of its own ancestors, which cannot be encoded to JSON`);
|
|
155
|
+
t.seen.add(e);
|
|
156
|
+
try {
|
|
157
|
+
return n();
|
|
158
|
+
} finally {
|
|
159
|
+
t.seen.delete(e);
|
|
160
|
+
}
|
|
149
161
|
}
|
|
150
|
-
function
|
|
151
|
-
let
|
|
152
|
-
if (
|
|
153
|
-
let n =
|
|
154
|
-
if (typeof
|
|
155
|
-
if (
|
|
156
|
-
let e =
|
|
162
|
+
function te(e, t, n, r, i = f) {
|
|
163
|
+
let a = n.discriminator;
|
|
164
|
+
if (a?.propertyName) {
|
|
165
|
+
let n = a.propertyName, i = typeof e == "object" && e ? e[n] : void 0;
|
|
166
|
+
if (typeof i == "string") {
|
|
167
|
+
if (a.mapping) {
|
|
168
|
+
let e = a.mapping[i];
|
|
157
169
|
if (e) {
|
|
158
170
|
let n = t.find((t) => t.$ref === e);
|
|
159
171
|
if (n) return n;
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
174
|
for (let e of t) {
|
|
163
|
-
let t =
|
|
175
|
+
let t = ne(e, r).properties?.[n];
|
|
164
176
|
if (!t) continue;
|
|
165
|
-
let
|
|
166
|
-
if (t.const ===
|
|
177
|
+
let a = t.enum;
|
|
178
|
+
if (t.const === i || Array.isArray(a) && a.includes(i)) return e;
|
|
167
179
|
}
|
|
168
180
|
}
|
|
169
181
|
}
|
|
170
|
-
let
|
|
171
|
-
if (
|
|
172
|
-
let
|
|
182
|
+
let o = ae(e, t, r, i);
|
|
183
|
+
if (o) return o;
|
|
184
|
+
let s, c = -1;
|
|
173
185
|
for (let n of t) {
|
|
174
|
-
let t = _(
|
|
175
|
-
|
|
186
|
+
let t = _(n, r, i);
|
|
187
|
+
if (t === void 0) continue;
|
|
188
|
+
let a = v(e, t.node, r, t.viaRefs);
|
|
189
|
+
a !== null && a > c && (c = a, s = n);
|
|
176
190
|
}
|
|
177
|
-
return
|
|
191
|
+
return s === void 0 ? t[0] ?? {} : s;
|
|
178
192
|
}
|
|
179
|
-
function
|
|
193
|
+
function ne(e, t) {
|
|
180
194
|
let n = e.$ref;
|
|
181
195
|
return typeof n == "string" ? t.resolve(n) : e;
|
|
182
196
|
}
|
|
183
|
-
function
|
|
197
|
+
function _(e, t, n) {
|
|
198
|
+
let r = e.$ref;
|
|
199
|
+
if (typeof r != "string") return {
|
|
200
|
+
node: e,
|
|
201
|
+
viaRefs: n
|
|
202
|
+
};
|
|
203
|
+
if (!n.includes(r)) return {
|
|
204
|
+
node: t.resolve(r),
|
|
205
|
+
viaRefs: [...n, r]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function re(e, t, n) {
|
|
209
|
+
let r = t.indexOf(e);
|
|
210
|
+
if (r === -1) return;
|
|
211
|
+
let i = [...t.slice(r), e].join(" -> ");
|
|
212
|
+
throw Error(`[apigen-logical] E_RUNMODE_CYCLE: $ref "${e}" at "${n.path || "#"}" re-enters itself while transcoding the same value (chain ${i}); a $ref/oneOf cycle that never descends into a property or item cannot terminate`);
|
|
213
|
+
}
|
|
214
|
+
function ie(e) {
|
|
184
215
|
if ("const" in e) return e.const;
|
|
185
216
|
let t = e.enum;
|
|
186
217
|
if (Array.isArray(t) && t.length === 1) return t[0];
|
|
187
218
|
}
|
|
188
|
-
function
|
|
219
|
+
function ae(e, t, n, r = f) {
|
|
189
220
|
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
190
|
-
let
|
|
191
|
-
for (let e of
|
|
221
|
+
let i = e, a = t.map((e) => ne(e, n)), o = /* @__PURE__ */ new Set();
|
|
222
|
+
for (let e of a) {
|
|
192
223
|
let t = e.properties;
|
|
193
|
-
if (t) for (let [e, n] of Object.entries(t))
|
|
194
|
-
}
|
|
195
|
-
for (let
|
|
196
|
-
let
|
|
197
|
-
let t = e.properties?.[
|
|
198
|
-
return t ?
|
|
199
|
-
}),
|
|
200
|
-
if (
|
|
201
|
-
let
|
|
202
|
-
if (
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
224
|
+
if (t) for (let [e, n] of Object.entries(t)) ie(n) !== void 0 && o.add(e);
|
|
225
|
+
}
|
|
226
|
+
for (let s of o) {
|
|
227
|
+
let o = a.map((e) => {
|
|
228
|
+
let t = e.properties?.[s];
|
|
229
|
+
return t ? ie(t) : void 0;
|
|
230
|
+
}), c = o.filter((e) => e !== void 0), l = new Set(c);
|
|
231
|
+
if (c.length < 2 || l.size !== c.length) continue;
|
|
232
|
+
let u = i[s];
|
|
233
|
+
if (u === void 0) continue;
|
|
234
|
+
let d = o.findIndex((e) => e === u);
|
|
235
|
+
if (d === -1) continue;
|
|
236
|
+
let f = _(t[d], n, r);
|
|
237
|
+
if (f !== void 0 && v(e, f.node, n, f.viaRefs) !== null) return t[d];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function oe(e) {
|
|
208
241
|
if (e === null) return "null";
|
|
209
242
|
if (Array.isArray(e)) return "array";
|
|
210
243
|
let t = typeof e;
|
|
211
244
|
return t === "number" ? Number.isInteger(e) ? "integer" : "number" : t;
|
|
212
245
|
}
|
|
213
|
-
function
|
|
214
|
-
let
|
|
215
|
-
if (Array.isArray(
|
|
246
|
+
function v(e, t, n, r = f) {
|
|
247
|
+
let i = t.oneOf;
|
|
248
|
+
if (Array.isArray(i)) {
|
|
216
249
|
let t = null;
|
|
217
|
-
for (let
|
|
218
|
-
let
|
|
219
|
-
|
|
250
|
+
for (let a of i) {
|
|
251
|
+
let i = _(a, n, r);
|
|
252
|
+
if (i === void 0) continue;
|
|
253
|
+
let o = v(e, i.node, n, i.viaRefs);
|
|
254
|
+
o !== null && (t === null || o > t) && (t = o);
|
|
220
255
|
}
|
|
221
256
|
return t;
|
|
222
257
|
}
|
|
223
|
-
let
|
|
224
|
-
if (typeof
|
|
225
|
-
if (!(
|
|
226
|
-
} else if (Array.isArray(
|
|
227
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return +(typeof
|
|
228
|
-
let
|
|
229
|
-
if (Array.isArray(
|
|
230
|
-
for (let e of
|
|
231
|
-
if (
|
|
232
|
-
|
|
258
|
+
let a = t.type, o = oe(e);
|
|
259
|
+
if (typeof a == "string") {
|
|
260
|
+
if (!(a === o || a === "number" && o === "integer")) return null;
|
|
261
|
+
} else if (Array.isArray(a) && !a.some((e) => e === o || e === "number" && o === "integer")) return null;
|
|
262
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return +(typeof a == "string");
|
|
263
|
+
let s = e, c = t.required, l = 0;
|
|
264
|
+
if (Array.isArray(c)) {
|
|
265
|
+
for (let e of c) if (typeof e == "string") {
|
|
266
|
+
if (s[e] === void 0) return null;
|
|
267
|
+
l += 2;
|
|
233
268
|
}
|
|
234
269
|
}
|
|
235
|
-
let
|
|
236
|
-
if (
|
|
237
|
-
for (let e of Object.keys(
|
|
238
|
-
for (let e of Object.keys(
|
|
270
|
+
let u = t.properties;
|
|
271
|
+
if (u) {
|
|
272
|
+
for (let e of Object.keys(u)) s[e] !== void 0 && (l += 1);
|
|
273
|
+
for (let e of Object.keys(s)) u[e] === void 0 && --l;
|
|
239
274
|
}
|
|
240
|
-
return
|
|
275
|
+
return l;
|
|
241
276
|
}
|
|
242
|
-
function
|
|
277
|
+
function y(e, t, n) {
|
|
243
278
|
for (let t of n.registry.ids()) {
|
|
244
279
|
let r = n.registry.get(t);
|
|
245
280
|
if (r?.ownsValue?.(e)) return {
|
|
@@ -247,15 +282,15 @@ function v(e, t, n) {
|
|
|
247
282
|
v: r.encode(e, r.schema, n)
|
|
248
283
|
};
|
|
249
284
|
}
|
|
250
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
251
|
-
if (
|
|
285
|
+
if (Array.isArray(e)) return e.map((e) => y(e, {}, n));
|
|
286
|
+
if (se(e)) {
|
|
252
287
|
let t = {};
|
|
253
|
-
for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] =
|
|
288
|
+
for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] = y(i, {}, n));
|
|
254
289
|
return t;
|
|
255
290
|
}
|
|
256
291
|
return x(e);
|
|
257
292
|
}
|
|
258
|
-
function
|
|
293
|
+
function se(e) {
|
|
259
294
|
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
260
295
|
let t = Object.getPrototypeOf(e);
|
|
261
296
|
return t === Object.prototype || t === null;
|
|
@@ -266,7 +301,7 @@ function b(e, t) {
|
|
|
266
301
|
if (a) return a.decode(n.v, a.schema, t);
|
|
267
302
|
}
|
|
268
303
|
if (Array.isArray(e)) return e.map((e) => b(e, t));
|
|
269
|
-
if (
|
|
304
|
+
if (se(e)) {
|
|
270
305
|
let n = {};
|
|
271
306
|
for (let [r, i] of Object.entries(e)) n[r] = b(i, t);
|
|
272
307
|
return n;
|
|
@@ -283,7 +318,7 @@ function x(e) {
|
|
|
283
318
|
}
|
|
284
319
|
return null;
|
|
285
320
|
}
|
|
286
|
-
function
|
|
321
|
+
function ce(e, t) {
|
|
287
322
|
let n = /* @__PURE__ */ new Set(), r = [e];
|
|
288
323
|
for (; r.length > 0;) {
|
|
289
324
|
let e = r.pop();
|
|
@@ -314,17 +349,67 @@ function re(e, t) {
|
|
|
314
349
|
typeof l == "object" && l && r.push(l);
|
|
315
350
|
}
|
|
316
351
|
}
|
|
317
|
-
function
|
|
352
|
+
function le(e) {
|
|
318
353
|
return {
|
|
319
354
|
encode(t, n, r) {
|
|
320
|
-
return
|
|
355
|
+
return m(t, n, p(e, r));
|
|
321
356
|
},
|
|
322
357
|
decode(t, n, r) {
|
|
323
|
-
return
|
|
358
|
+
return h(t, n, p(e, r));
|
|
324
359
|
}
|
|
325
360
|
};
|
|
326
361
|
}
|
|
327
362
|
//#endregion
|
|
363
|
+
//#region ../apigen-base-logical/src/lib/emit.ts
|
|
364
|
+
var ue = class extends Error {
|
|
365
|
+
constructor(e, t) {
|
|
366
|
+
super(`${e} (at ${t || "#"})`), this.code = "E_EMIT", this.name = "EmitError", this.path = t;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
function de(e) {
|
|
370
|
+
return (t) => {
|
|
371
|
+
let n = /^#\/(\$defs|definitions)\/([^/]+)$/.exec(t);
|
|
372
|
+
if (!n) throw new ue(`E_EMIT: unsupported $ref form "${t}"; supported forms are "#/$defs/<name>" and "#/definitions/<name>"`, "");
|
|
373
|
+
let r = e[n[1]], i = fe(r, pe(n[2])) ?? fe(r, t);
|
|
374
|
+
if (typeof i != "object" || !i) throw new ue(`E_EMIT: $ref "${t}" has no $def target`, "");
|
|
375
|
+
return i;
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function fe(e, t) {
|
|
379
|
+
if (typeof e == "object" && e) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
380
|
+
}
|
|
381
|
+
function pe(e) {
|
|
382
|
+
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
383
|
+
}
|
|
384
|
+
`
|
|
385
|
+
function __apigenEnvelopeEncode(v) {
|
|
386
|
+
// Schema-less position: pass typed JSON through unchanged. A richer host
|
|
387
|
+
// prelude may wrap recognized runtime types as { ${JSON.stringify(i)}: id, v }.
|
|
388
|
+
return v;
|
|
389
|
+
}
|
|
390
|
+
function __apigenEnvelopeDecode(w) {
|
|
391
|
+
return w != null && typeof w === 'object' && ${JSON.stringify(i)} in w
|
|
392
|
+
? w.v
|
|
393
|
+
: w;
|
|
394
|
+
}
|
|
395
|
+
`.trim(), Object.freeze({
|
|
396
|
+
"date-time": {
|
|
397
|
+
encode: "$.toISOString()",
|
|
398
|
+
decode: "new Date($)",
|
|
399
|
+
mode: "native"
|
|
400
|
+
},
|
|
401
|
+
int64: {
|
|
402
|
+
encode: "String($)",
|
|
403
|
+
decode: "BigInt($)",
|
|
404
|
+
mode: "native"
|
|
405
|
+
},
|
|
406
|
+
byte: {
|
|
407
|
+
encode: "Buffer.from($).toString('base64')",
|
|
408
|
+
decode: "new Uint8Array(Buffer.from($, 'base64'))",
|
|
409
|
+
mode: "native"
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
//#endregion
|
|
328
413
|
//#region ../apigen-base-logical/src/lib/codecs/date-time.ts
|
|
329
414
|
var S = {
|
|
330
415
|
id: "date-time",
|
|
@@ -386,7 +471,7 @@ var S = {
|
|
|
386
471
|
};
|
|
387
472
|
//#endregion
|
|
388
473
|
//#region ../apigen-base-logical/src/lib/codecs/decimal.ts
|
|
389
|
-
function
|
|
474
|
+
function me(e) {
|
|
390
475
|
return e;
|
|
391
476
|
}
|
|
392
477
|
var w = {
|
|
@@ -405,10 +490,10 @@ var w = {
|
|
|
405
490
|
decode(e, t, n) {
|
|
406
491
|
if (typeof e != "string") {
|
|
407
492
|
if (n.mode === "strict") throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
408
|
-
return
|
|
493
|
+
return me(String(e));
|
|
409
494
|
}
|
|
410
495
|
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
|
|
496
|
+
return me(e);
|
|
412
497
|
}
|
|
413
498
|
}, T = {
|
|
414
499
|
id: "byte",
|
|
@@ -434,7 +519,7 @@ var w = {
|
|
|
434
519
|
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
520
|
return new Uint8Array(Buffer.from(e, "base64"));
|
|
436
521
|
}
|
|
437
|
-
},
|
|
522
|
+
}, he = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, E = {
|
|
438
523
|
id: "uuid",
|
|
439
524
|
kind: "scalar",
|
|
440
525
|
schema: {
|
|
@@ -452,10 +537,10 @@ var w = {
|
|
|
452
537
|
if (n.mode === "strict") throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
453
538
|
return String(e).toLowerCase();
|
|
454
539
|
}
|
|
455
|
-
if (n.mode === "strict" && !
|
|
540
|
+
if (n.mode === "strict" && !he.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
|
|
456
541
|
return e;
|
|
457
542
|
}
|
|
458
|
-
}, D = "NaN", O = "Infinity", k = "-Infinity",
|
|
543
|
+
}, D = "NaN", O = "Infinity", k = "-Infinity", ge = /* @__PURE__ */ new Set([
|
|
459
544
|
D,
|
|
460
545
|
O,
|
|
461
546
|
k
|
|
@@ -481,10 +566,10 @@ var w = {
|
|
|
481
566
|
let t = Number(e);
|
|
482
567
|
if (!Number.isNaN(t)) return t;
|
|
483
568
|
}
|
|
484
|
-
if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...
|
|
569
|
+
if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...ge].join(", ")}.`);
|
|
485
570
|
return NaN;
|
|
486
571
|
}
|
|
487
|
-
},
|
|
572
|
+
}, _e = [
|
|
488
573
|
S,
|
|
489
574
|
C,
|
|
490
575
|
w,
|
|
@@ -492,27 +577,27 @@ var w = {
|
|
|
492
577
|
E,
|
|
493
578
|
A
|
|
494
579
|
];
|
|
495
|
-
function
|
|
496
|
-
for (let n of
|
|
580
|
+
function ve(e, t = {}) {
|
|
581
|
+
for (let n of _e) e.register(n, { override: t.override ?? !1 });
|
|
497
582
|
}
|
|
498
583
|
//#endregion
|
|
499
584
|
//#region ../apigen-base-logical/src/lib/example.ts
|
|
500
|
-
var
|
|
501
|
-
function
|
|
585
|
+
var ye = 12;
|
|
586
|
+
function be(e, t) {
|
|
502
587
|
let n = /^#\/(definitions|\$defs)\/(.+)$/.exec(e);
|
|
503
588
|
if (!n) return;
|
|
504
589
|
let [, r, i] = n;
|
|
505
590
|
return (r === "$defs" ? t.$defs : t.definitions)?.[decodeURIComponent(i)];
|
|
506
591
|
}
|
|
507
|
-
function
|
|
592
|
+
function xe(e) {
|
|
508
593
|
return Array.isArray(e) && e.length > 0 ? e[0] : void 0;
|
|
509
594
|
}
|
|
510
|
-
function
|
|
595
|
+
function Se(e) {
|
|
511
596
|
if (Array.isArray(e.type)) return e.type.find((e) => e !== "null") ?? e.type[0];
|
|
512
597
|
if (typeof e.type == "string") return e.type;
|
|
513
598
|
if (e.properties) return "object";
|
|
514
599
|
}
|
|
515
|
-
function
|
|
600
|
+
function Ce(e) {
|
|
516
601
|
switch (e.format) {
|
|
517
602
|
case "date-time": return "1970-01-01T00:00:00.000Z";
|
|
518
603
|
case "date": return "1970-01-01";
|
|
@@ -531,23 +616,23 @@ function pe(e) {
|
|
|
531
616
|
default: return "<string>";
|
|
532
617
|
}
|
|
533
618
|
}
|
|
534
|
-
function
|
|
619
|
+
function we(e, t, n) {
|
|
535
620
|
let r = e.properties ?? {}, i = e.required ?? [], a = {};
|
|
536
621
|
for (let e of i) {
|
|
537
622
|
let i = r[e];
|
|
538
|
-
a[e] = i === void 0 ? `<${e}>` :
|
|
623
|
+
a[e] = i === void 0 ? `<${e}>` : j(i, t, n + 1);
|
|
539
624
|
}
|
|
540
625
|
return a;
|
|
541
626
|
}
|
|
542
|
-
function
|
|
627
|
+
function Te(e, t, n) {
|
|
543
628
|
let r = Array.isArray(e.items) ? e.items[0] : e.items;
|
|
544
|
-
return r ? [
|
|
629
|
+
return r ? [j(r, t, n + 1)] : [];
|
|
545
630
|
}
|
|
546
|
-
function
|
|
547
|
-
if (!e || n >
|
|
631
|
+
function j(e, t = e ?? {}, n = 0) {
|
|
632
|
+
if (!e || n > ye) return null;
|
|
548
633
|
if (typeof e.$ref == "string") {
|
|
549
|
-
let r =
|
|
550
|
-
return r === void 0 ? null :
|
|
634
|
+
let r = be(e.$ref, t);
|
|
635
|
+
return r === void 0 ? null : j(r, t, n + 1);
|
|
551
636
|
}
|
|
552
637
|
if (e.const !== void 0) return e.const;
|
|
553
638
|
if (Array.isArray(e.enum) && e.enum.length > 0) return e.enum[0];
|
|
@@ -557,18 +642,18 @@ function M(e, t = e ?? {}, n = 0) {
|
|
|
557
642
|
Object.assign(r, t.properties ?? {});
|
|
558
643
|
for (let e of t.required ?? []) i.includes(e) || i.push(e);
|
|
559
644
|
}
|
|
560
|
-
return
|
|
645
|
+
return we({
|
|
561
646
|
...e,
|
|
562
647
|
properties: r,
|
|
563
648
|
required: i
|
|
564
649
|
}, t, n);
|
|
565
650
|
}
|
|
566
|
-
let r =
|
|
567
|
-
if (r) return
|
|
568
|
-
switch (
|
|
569
|
-
case "object": return
|
|
570
|
-
case "array": return
|
|
571
|
-
case "string": return
|
|
651
|
+
let r = xe(e.oneOf) ?? xe(e.anyOf);
|
|
652
|
+
if (r) return j(r, t, n + 1);
|
|
653
|
+
switch (Se(e)) {
|
|
654
|
+
case "object": return we(e, t, n);
|
|
655
|
+
case "array": return Te(e, t, n);
|
|
656
|
+
case "string": return Ce(e);
|
|
572
657
|
case "integer":
|
|
573
658
|
case "number": return 0;
|
|
574
659
|
case "boolean": return !1;
|
|
@@ -576,9 +661,9 @@ function M(e, t = e ?? {}, n = 0) {
|
|
|
576
661
|
default: return null;
|
|
577
662
|
}
|
|
578
663
|
}
|
|
579
|
-
function
|
|
664
|
+
function Ee(e) {
|
|
580
665
|
if (!e) return;
|
|
581
|
-
let t =
|
|
666
|
+
let t = j(e);
|
|
582
667
|
return `Example: ${JSON.stringify(t)}`;
|
|
583
668
|
}
|
|
584
669
|
S.id, C.id, w.id, T.id, E.id, A.id, Object.freeze({
|
|
@@ -804,43 +889,149 @@ S.id, C.id, w.id, T.id, E.id, A.id, Object.freeze({
|
|
|
804
889
|
}
|
|
805
890
|
});
|
|
806
891
|
//#endregion
|
|
892
|
+
//#region ../apigen-base-errors/src/lib/errors.ts
|
|
893
|
+
var De = [
|
|
894
|
+
"invalid_argument",
|
|
895
|
+
"unauthenticated",
|
|
896
|
+
"permission_denied",
|
|
897
|
+
"not_found",
|
|
898
|
+
"internal"
|
|
899
|
+
], M = class extends Error {
|
|
900
|
+
constructor(e, t, n) {
|
|
901
|
+
super(t), this.name = "ApiError", this.code = e, this.details = n, Object.setPrototypeOf(this, new.target.prototype);
|
|
902
|
+
}
|
|
903
|
+
toJSON() {
|
|
904
|
+
let e = {
|
|
905
|
+
code: this.code,
|
|
906
|
+
message: this.message
|
|
907
|
+
};
|
|
908
|
+
return this.details !== void 0 && (e.details = this.details), e;
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
function Oe(e) {
|
|
912
|
+
return typeof e == "object" && !!e && e.name === "ApiError" && De.includes(e.code) && typeof e.toJSON == "function";
|
|
913
|
+
}
|
|
914
|
+
function ke(e, t, n = 0) {
|
|
915
|
+
return e === "before-first-chunk" ? {
|
|
916
|
+
phase: e,
|
|
917
|
+
error: t
|
|
918
|
+
} : {
|
|
919
|
+
phase: e,
|
|
920
|
+
error: t,
|
|
921
|
+
chunksDelivered: n
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region src/lib/stream.ts
|
|
926
|
+
function Ae(e) {
|
|
927
|
+
let { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
928
|
+
return { [Symbol.asyncIterator]() {
|
|
929
|
+
let e = t(r);
|
|
930
|
+
return {
|
|
931
|
+
async next() {
|
|
932
|
+
return r.aborted ? (await e.return(void 0), {
|
|
933
|
+
done: !0,
|
|
934
|
+
value: void 0
|
|
935
|
+
}) : e.next();
|
|
936
|
+
},
|
|
937
|
+
async return(t) {
|
|
938
|
+
return await e.return(t), {
|
|
939
|
+
done: !0,
|
|
940
|
+
value: void 0
|
|
941
|
+
};
|
|
942
|
+
},
|
|
943
|
+
async throw(t) {
|
|
944
|
+
return await e.throw(t), {
|
|
945
|
+
done: !0,
|
|
946
|
+
value: void 0
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
} };
|
|
951
|
+
}
|
|
952
|
+
async function je(e) {
|
|
953
|
+
let t = [];
|
|
954
|
+
for await (let n of e) t.push(n);
|
|
955
|
+
return t;
|
|
956
|
+
}
|
|
957
|
+
async function Me(e) {
|
|
958
|
+
let t = [];
|
|
959
|
+
try {
|
|
960
|
+
for await (let n of e) t.push(n);
|
|
961
|
+
return {
|
|
962
|
+
ok: !0,
|
|
963
|
+
chunks: t
|
|
964
|
+
};
|
|
965
|
+
} catch (e) {
|
|
966
|
+
let n = Oe(e) ? e : new M("internal", e instanceof Error ? e.message : String(e));
|
|
967
|
+
return t.length === 0 ? {
|
|
968
|
+
ok: !1,
|
|
969
|
+
carrier: ke("before-first-chunk", n)
|
|
970
|
+
} : {
|
|
971
|
+
ok: !1,
|
|
972
|
+
carrier: ke("after-first-chunk", n, t.length)
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function N(e) {
|
|
977
|
+
return typeof e == "object" && !!e && Symbol.asyncIterator in e;
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
807
980
|
//#region src/lib/dispatch.ts
|
|
808
|
-
var
|
|
809
|
-
|
|
810
|
-
var
|
|
811
|
-
function
|
|
981
|
+
var Ne = o();
|
|
982
|
+
ve(Ne);
|
|
983
|
+
var P = le(Ne.freeze());
|
|
984
|
+
function F(e, t) {
|
|
812
985
|
return t in (e.input?.properties ?? {});
|
|
813
986
|
}
|
|
814
|
-
function
|
|
987
|
+
function I(e) {
|
|
815
988
|
let t = e.input?.properties?.data;
|
|
816
989
|
return Object.keys(t?.properties ?? {});
|
|
817
990
|
}
|
|
818
|
-
function
|
|
991
|
+
function Pe(e, t) {
|
|
819
992
|
let n = e.input?.properties?.data?.properties?.[t];
|
|
820
993
|
return n === void 0 ? void 0 : n;
|
|
821
994
|
}
|
|
822
|
-
function
|
|
823
|
-
return t === void 0 || e === void 0 ? e :
|
|
995
|
+
function Fe(e, t, n) {
|
|
996
|
+
return t === void 0 || e === void 0 ? e : P.decode(e, t, n);
|
|
997
|
+
}
|
|
998
|
+
function L(e, t) {
|
|
999
|
+
let n = de(e);
|
|
1000
|
+
return { resolve: (e) => {
|
|
1001
|
+
try {
|
|
1002
|
+
return n(e);
|
|
1003
|
+
} catch (e) {
|
|
1004
|
+
let n = e instanceof Error ? e.message : String(e), r = /* @__PURE__ */ Error(`[apigen-engine-runtime] op "${t}": ${n}`);
|
|
1005
|
+
throw r.cause = e, r;
|
|
1006
|
+
}
|
|
1007
|
+
} };
|
|
1008
|
+
}
|
|
1009
|
+
function Ie(e, t, n) {
|
|
1010
|
+
return { [Symbol.asyncIterator]: async function* () {
|
|
1011
|
+
for await (let r of e) yield P.encode(r, t, n);
|
|
1012
|
+
} };
|
|
824
1013
|
}
|
|
825
|
-
function
|
|
826
|
-
let
|
|
827
|
-
|
|
1014
|
+
function R(e, t, n) {
|
|
1015
|
+
let r = n.output;
|
|
1016
|
+
if (!r || Object.keys(r).length === 0) return e;
|
|
1017
|
+
let i = L(r, t);
|
|
1018
|
+
return N(e) ? Ie(e, r, i) : P.encode(e, r, i);
|
|
828
1019
|
}
|
|
829
|
-
async function
|
|
830
|
-
let o =
|
|
831
|
-
if (
|
|
1020
|
+
async function z(e, t, n, r, i, a) {
|
|
1021
|
+
let o = I(n), s = L(n.input, r), c = o.map((e) => Fe(a[e], Pe(n, e), s));
|
|
1022
|
+
if (F(n, "session") && t) {
|
|
832
1023
|
let a = await t({ session: i.session });
|
|
833
|
-
return
|
|
1024
|
+
return R(await e[r](a, ...c), r, n);
|
|
834
1025
|
}
|
|
835
1026
|
if (n.hasCtx) {
|
|
836
1027
|
let a = t ? await t(i) : void 0;
|
|
837
|
-
return
|
|
1028
|
+
return R(await e[r](a, ...c), r, n);
|
|
838
1029
|
}
|
|
839
|
-
return
|
|
1030
|
+
return R(await e[r](...c), r, n);
|
|
840
1031
|
}
|
|
841
1032
|
//#endregion
|
|
842
1033
|
//#region src/lib/invoke.ts
|
|
843
|
-
var
|
|
1034
|
+
var Le = class {
|
|
844
1035
|
constructor() {
|
|
845
1036
|
this._map = /* @__PURE__ */ new Map();
|
|
846
1037
|
}
|
|
@@ -854,21 +1045,21 @@ var we = class {
|
|
|
854
1045
|
return this._map.has(e);
|
|
855
1046
|
}
|
|
856
1047
|
};
|
|
857
|
-
function
|
|
1048
|
+
function Re(e = []) {
|
|
858
1049
|
return async function(t, n, r) {
|
|
859
1050
|
let i = r.schemas[t];
|
|
860
1051
|
if (!i) throw Error(`apigen/invoke: no schema found for operation "${t}"`);
|
|
861
|
-
return e.reduceRight((e, t) => () => t(n, e), () =>
|
|
1052
|
+
return e.reduceRight((e, t) => () => t(n, e), () => z(r.fns, r.createClient, i, t, n.envelope, n.domainArgs))();
|
|
862
1053
|
};
|
|
863
1054
|
}
|
|
864
1055
|
//#endregion
|
|
865
1056
|
//#region src/lib/define-middleware.ts
|
|
866
|
-
function
|
|
1057
|
+
function ze(e) {
|
|
867
1058
|
return e;
|
|
868
1059
|
}
|
|
869
1060
|
//#endregion
|
|
870
1061
|
//#region src/lib/event-bus.ts
|
|
871
|
-
var
|
|
1062
|
+
var Be = class {
|
|
872
1063
|
constructor() {
|
|
873
1064
|
this.handlers = /* @__PURE__ */ new Map();
|
|
874
1065
|
}
|
|
@@ -886,19 +1077,19 @@ var De = class {
|
|
|
886
1077
|
this.handlers.clear();
|
|
887
1078
|
}
|
|
888
1079
|
async emit(e) {
|
|
889
|
-
for (let [t, n] of this.handlers) if (
|
|
1080
|
+
for (let [t, n] of this.handlers) if (Ve(t, e)) for (let t of n) await t(e);
|
|
890
1081
|
}
|
|
891
1082
|
};
|
|
892
|
-
function
|
|
1083
|
+
function Ve(e, t) {
|
|
893
1084
|
let [n, r, i] = e.split(":");
|
|
894
1085
|
return !(n !== "*" && n !== t.module || r && r !== "*" && r !== t.method || i && i !== "*" && i !== t.lifecycle);
|
|
895
1086
|
}
|
|
896
|
-
function
|
|
1087
|
+
function He(e, t) {
|
|
897
1088
|
for (let n of e) if (n.eventMapping) for (let [e, r] of Object.entries(n.eventMapping)) t.on(e, r);
|
|
898
1089
|
}
|
|
899
1090
|
//#endregion
|
|
900
1091
|
//#region src/lib/build-context.ts
|
|
901
|
-
async function
|
|
1092
|
+
async function Ue(e, t, n) {
|
|
902
1093
|
let r = { ...t };
|
|
903
1094
|
for (let t of e) if (t.createContext) {
|
|
904
1095
|
await n.emit({
|
|
@@ -933,31 +1124,49 @@ async function P(e, t, n) {
|
|
|
933
1124
|
e(import.meta.url);
|
|
934
1125
|
//#endregion
|
|
935
1126
|
//#region ../apigen-core-client/src/lib/get-safety.ts
|
|
936
|
-
var
|
|
1127
|
+
var B = /* @__PURE__ */ new Set([
|
|
937
1128
|
"string",
|
|
938
1129
|
"number",
|
|
939
1130
|
"boolean",
|
|
940
1131
|
"integer"
|
|
941
1132
|
]);
|
|
942
|
-
function
|
|
1133
|
+
function We(e) {
|
|
1134
|
+
if (!Array.isArray(e) || e.length < 2) return !1;
|
|
1135
|
+
let t = 0;
|
|
1136
|
+
for (let n of e) {
|
|
1137
|
+
if (typeof n != "object" || !n) return !1;
|
|
1138
|
+
let { type: e, $ref: r, oneOf: i, anyOf: a, allOf: o } = n;
|
|
1139
|
+
if (r !== void 0 || i || a || o) return !1;
|
|
1140
|
+
if (e !== "null") {
|
|
1141
|
+
if (typeof e == "string" && B.has(e)) {
|
|
1142
|
+
t++;
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
return !1;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return t === 1;
|
|
1149
|
+
}
|
|
1150
|
+
function Ge(e) {
|
|
943
1151
|
if (typeof e != "object" || !e) return !1;
|
|
944
1152
|
let t = e;
|
|
945
|
-
if (t.$ref !== void 0 || t.
|
|
1153
|
+
if (t.$ref !== void 0 || t.allOf) return !1;
|
|
1154
|
+
if (t.oneOf || t.anyOf) return We(t.oneOf ?? t.anyOf);
|
|
946
1155
|
let { type: n } = t;
|
|
947
|
-
return typeof n == "string" ?
|
|
1156
|
+
return typeof n == "string" ? B.has(n) : Array.isArray(n) ? n.every((e) => B.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
|
|
948
1157
|
"string",
|
|
949
1158
|
"number",
|
|
950
1159
|
"boolean"
|
|
951
1160
|
].includes(typeof e)) : !1;
|
|
952
1161
|
}
|
|
953
|
-
function
|
|
1162
|
+
function Ke(e) {
|
|
954
1163
|
if (!e || typeof e != "object") return !1;
|
|
955
1164
|
let t = e.properties;
|
|
956
|
-
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(
|
|
1165
|
+
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(Ge);
|
|
957
1166
|
}
|
|
958
1167
|
//#endregion
|
|
959
1168
|
//#region ../apigen-core-client/src/lib/compose-schemas.ts
|
|
960
|
-
function
|
|
1169
|
+
function qe(e) {
|
|
961
1170
|
let t = {}, n = (e) => {
|
|
962
1171
|
for (let n of ["definitions", "$defs"]) {
|
|
963
1172
|
let r = e[n];
|
|
@@ -969,17 +1178,17 @@ function je(e) {
|
|
|
969
1178
|
};
|
|
970
1179
|
for (let t of Object.values(e.schemas)) n(t.input), n(t.output);
|
|
971
1180
|
if (Object.keys(t).length !== 0) for (let [n, r] of Object.entries(e.schemas)) try {
|
|
972
|
-
|
|
1181
|
+
ce(r.input, t), ce(r.output, t);
|
|
973
1182
|
} catch (e) {
|
|
974
1183
|
throw Error(`[apigen-core-client] Schema validation failed for function "${n}": ${e.message}`);
|
|
975
1184
|
}
|
|
976
1185
|
}
|
|
977
|
-
function
|
|
1186
|
+
function Je(e, t) {
|
|
978
1187
|
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
1188
|
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
1189
|
}
|
|
981
|
-
function
|
|
982
|
-
|
|
1190
|
+
function Ye(e, t, n) {
|
|
1191
|
+
qe(e);
|
|
983
1192
|
let r = {};
|
|
984
1193
|
for (let [i, a] of Object.entries(e.schemas)) {
|
|
985
1194
|
let e = n?.[i] ?? {}, o = a.input.properties ?? {}, s = a.input.required ?? [], c = {}, l = [], u = {};
|
|
@@ -989,7 +1198,7 @@ function Ne(e, t, n) {
|
|
|
989
1198
|
properties: o,
|
|
990
1199
|
additionalProperties: !1,
|
|
991
1200
|
...s.length > 0 ? { required: s } : {}
|
|
992
|
-
}, f = a.safe === !0 ||
|
|
1201
|
+
}, f = a.safe === !0 || Ke(a.input), p = a.input.definitions, m = a.input.$defs;
|
|
993
1202
|
r[i] = {
|
|
994
1203
|
input: {
|
|
995
1204
|
type: "object",
|
|
@@ -999,7 +1208,7 @@ function Ne(e, t, n) {
|
|
|
999
1208
|
},
|
|
1000
1209
|
required: [...l, ...s.length > 0 ? ["data"] : []],
|
|
1001
1210
|
additionalProperties: !1,
|
|
1002
|
-
description:
|
|
1211
|
+
description: Je(Object.keys(c), Object.keys(o).length > 0),
|
|
1003
1212
|
...p ? { definitions: p } : {},
|
|
1004
1213
|
...m ? { $defs: m } : {}
|
|
1005
1214
|
},
|
|
@@ -1013,53 +1222,53 @@ function Ne(e, t, n) {
|
|
|
1013
1222
|
}
|
|
1014
1223
|
//#endregion
|
|
1015
1224
|
//#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
|
|
1016
|
-
var
|
|
1017
|
-
function
|
|
1225
|
+
var Xe = { "decimal.js": "Decimal" };
|
|
1226
|
+
function Ze(e) {
|
|
1018
1227
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1019
1228
|
}
|
|
1020
|
-
Object.entries(
|
|
1021
|
-
pattern: RegExp(`import\\(["'][^"']*${
|
|
1229
|
+
Object.entries(Xe).map(([e, t]) => ({
|
|
1230
|
+
pattern: RegExp(`import\\(["'][^"']*${Ze(e)}[^"']*["']\\)\\.\\w+`, "g"),
|
|
1022
1231
|
key: t
|
|
1023
1232
|
}));
|
|
1024
1233
|
//#endregion
|
|
1025
1234
|
//#region src/lib/types.ts
|
|
1026
|
-
var
|
|
1235
|
+
var V = class extends Error {
|
|
1027
1236
|
constructor(e) {
|
|
1028
1237
|
super(e), this.name = "ConfigurationError";
|
|
1029
1238
|
}
|
|
1030
1239
|
};
|
|
1031
1240
|
//#endregion
|
|
1032
1241
|
//#region src/lib/api-package.ts
|
|
1033
|
-
function
|
|
1242
|
+
function Qe(e) {
|
|
1034
1243
|
for (let t of e) for (let e of Object.keys(t.eventMapping ?? {})) {
|
|
1035
1244
|
let [n] = e.split(":");
|
|
1036
|
-
if (n !== "*" && n === t.id) throw new
|
|
1245
|
+
if (n !== "*" && n === t.id) throw new V(`Middleware "${t.id}" subscribes to its own events via "${e}". This would cause infinite recursion.`);
|
|
1037
1246
|
}
|
|
1038
1247
|
}
|
|
1039
|
-
function
|
|
1248
|
+
function $e(e) {
|
|
1040
1249
|
let { domainSchemas: t, middlewares: n, overrides: r = {}, strict: i = !1 } = e;
|
|
1041
|
-
|
|
1250
|
+
Qe(n);
|
|
1042
1251
|
for (let e of Object.keys(r)) if (!(e in t.schemas)) {
|
|
1043
1252
|
let t = `Override key "${e}" not found in domain schemas.`;
|
|
1044
|
-
if (i) throw new
|
|
1253
|
+
if (i) throw new V(t);
|
|
1045
1254
|
console.warn("[apigen-runtime]", t);
|
|
1046
1255
|
}
|
|
1047
1256
|
let a = new Set(n.map((e) => e.id));
|
|
1048
1257
|
for (let [e, t] of Object.entries(r)) for (let n of Object.keys(t ?? {})) if (!a.has(n)) {
|
|
1049
1258
|
let t = `Override key "${e}.${n}" does not match any declared middleware id.`;
|
|
1050
|
-
if (i) throw new
|
|
1259
|
+
if (i) throw new V(t);
|
|
1051
1260
|
console.warn("[apigen-runtime]", t);
|
|
1052
1261
|
}
|
|
1053
|
-
let o =
|
|
1054
|
-
return
|
|
1262
|
+
let o = Ye(t, n, r), s = new Be();
|
|
1263
|
+
return He(n, s), {
|
|
1055
1264
|
schemas: o,
|
|
1056
|
-
createClient: async (e) =>
|
|
1265
|
+
createClient: async (e) => Ue(n, e, s),
|
|
1057
1266
|
dispose: () => s.clear()
|
|
1058
1267
|
};
|
|
1059
1268
|
}
|
|
1060
1269
|
//#endregion
|
|
1061
1270
|
//#region src/lib/logger.ts
|
|
1062
|
-
function
|
|
1271
|
+
function et(e = {}) {
|
|
1063
1272
|
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
1273
|
if (a === "pretty") return o.transport = {
|
|
1065
1274
|
target: "pino-pretty",
|
|
@@ -1082,35 +1291,35 @@ function Le(e = {}) {
|
|
|
1082
1291
|
}
|
|
1083
1292
|
//#endregion
|
|
1084
1293
|
//#region src/lib/describe-params.ts
|
|
1085
|
-
function
|
|
1294
|
+
function tt(e) {
|
|
1086
1295
|
if (e?.type !== "object" || !e.properties) return;
|
|
1087
1296
|
let t = Object.entries(e.properties);
|
|
1088
1297
|
if (t.length === 0) return;
|
|
1089
1298
|
let n = new Set(e.required ?? []);
|
|
1090
|
-
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${
|
|
1299
|
+
return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${H(t)}`).join(", ")} }`;
|
|
1091
1300
|
}
|
|
1092
|
-
function
|
|
1301
|
+
function nt(e) {
|
|
1093
1302
|
return typeof e == "string" ? `'${e}'` : JSON.stringify(e);
|
|
1094
1303
|
}
|
|
1095
|
-
function
|
|
1304
|
+
function rt(e) {
|
|
1096
1305
|
let t = e.enum ?? [];
|
|
1097
|
-
return t.length === 0 ? "unknown" : t.map(
|
|
1306
|
+
return t.length === 0 ? "unknown" : t.map(nt).join("|");
|
|
1098
1307
|
}
|
|
1099
|
-
function
|
|
1100
|
-
return e.map((e) =>
|
|
1308
|
+
function it(e, t) {
|
|
1309
|
+
return e.map((e) => H(e, t)).join(" | ");
|
|
1101
1310
|
}
|
|
1102
|
-
function
|
|
1311
|
+
function H(e, t = 0) {
|
|
1103
1312
|
if (!e) return "unknown";
|
|
1104
|
-
if (e.type === "array") return `${
|
|
1105
|
-
if (e.enum) return
|
|
1313
|
+
if (e.type === "array") return `${H(e.items, 0)}[]`;
|
|
1314
|
+
if (e.enum) return rt(e);
|
|
1106
1315
|
if (e.$ref) return String(e.$ref).split("/").pop() || "object";
|
|
1107
1316
|
let n = e.anyOf ?? e.oneOf;
|
|
1108
|
-
return n ? n.length === 0 ? "unknown" : t >= 2 ?
|
|
1317
|
+
return n ? n.length === 0 ? "unknown" : t >= 2 ? it(n, t - 1) : "union" : t >= 1 && e.type === "object" ? tt(e) ?? "object" : e.type ?? "object";
|
|
1109
1318
|
}
|
|
1110
|
-
function
|
|
1319
|
+
function at(e) {
|
|
1111
1320
|
let t = (e?.input ?? {}).properties?.data, n = t?.properties ?? {}, r = new Set(t?.required ?? []), i = Object.entries(n).map(([e, t]) => ({
|
|
1112
1321
|
name: e,
|
|
1113
|
-
type:
|
|
1322
|
+
type: H(t, 2),
|
|
1114
1323
|
required: r.has(e)
|
|
1115
1324
|
}));
|
|
1116
1325
|
return {
|
|
@@ -1120,16 +1329,16 @@ function B(e) {
|
|
|
1120
1329
|
}
|
|
1121
1330
|
//#endregion
|
|
1122
1331
|
//#region src/lib/coerce-query.ts
|
|
1123
|
-
function
|
|
1332
|
+
function ot(e) {
|
|
1124
1333
|
let t;
|
|
1125
1334
|
return t = Array.isArray(e) ? e : e ? [e] : [], t.find((e) => e === "number" || e === "integer" || e === "boolean");
|
|
1126
1335
|
}
|
|
1127
|
-
function
|
|
1336
|
+
function st(e, t) {
|
|
1128
1337
|
let n = (t?.input ?? {}).properties?.data?.properties ?? {}, r = { ...e };
|
|
1129
1338
|
for (let [e, t] of Object.entries(n)) {
|
|
1130
1339
|
let n = r[e];
|
|
1131
1340
|
if (typeof n != "string") continue;
|
|
1132
|
-
let i =
|
|
1341
|
+
let i = ot(t?.type);
|
|
1133
1342
|
if (i === "number" || i === "integer") {
|
|
1134
1343
|
let t = Number(n);
|
|
1135
1344
|
!Number.isNaN(t) && n.trim() !== "" && (r[e] = t);
|
|
@@ -1139,55 +1348,22 @@ function Ue(e, t) {
|
|
|
1139
1348
|
}
|
|
1140
1349
|
//#endregion
|
|
1141
1350
|
//#region src/lib/fn-table.ts
|
|
1142
|
-
var
|
|
1351
|
+
var ct = /* @__PURE__ */ new Set([
|
|
1143
1352
|
"default",
|
|
1144
1353
|
"module.exports",
|
|
1145
1354
|
"__esModule"
|
|
1146
1355
|
]);
|
|
1147
|
-
function
|
|
1356
|
+
function lt(e) {
|
|
1148
1357
|
let t = {}, n = (e, r) => {
|
|
1149
1358
|
for (let [i, a] of Object.entries(e)) if (typeof a == "function") {
|
|
1150
|
-
!
|
|
1359
|
+
!ct.has(i) && !(i in t) && (t[i] = a);
|
|
1151
1360
|
let e = a.name;
|
|
1152
1361
|
e && !(e in t) && (t[e] = a);
|
|
1153
|
-
} else a && typeof a == "object" && r < 2 &&
|
|
1362
|
+
} else a && typeof a == "object" && r < 2 && ct.has(i) && n(a, r + 1);
|
|
1154
1363
|
};
|
|
1155
1364
|
return n(e, 0), t;
|
|
1156
1365
|
}
|
|
1157
1366
|
//#endregion
|
|
1158
|
-
//#region ../apigen-base-errors/src/lib/errors.ts
|
|
1159
|
-
var Ge = [
|
|
1160
|
-
"invalid_argument",
|
|
1161
|
-
"unauthenticated",
|
|
1162
|
-
"permission_denied",
|
|
1163
|
-
"not_found",
|
|
1164
|
-
"internal"
|
|
1165
|
-
], H = class extends Error {
|
|
1166
|
-
constructor(e, t, n) {
|
|
1167
|
-
super(t), this.name = "ApiError", this.code = e, this.details = n, Object.setPrototypeOf(this, new.target.prototype);
|
|
1168
|
-
}
|
|
1169
|
-
toJSON() {
|
|
1170
|
-
let e = {
|
|
1171
|
-
code: this.code,
|
|
1172
|
-
message: this.message
|
|
1173
|
-
};
|
|
1174
|
-
return this.details !== void 0 && (e.details = this.details), e;
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
function Ke(e) {
|
|
1178
|
-
return typeof e == "object" && !!e && e.name === "ApiError" && Ge.includes(e.code) && typeof e.toJSON == "function";
|
|
1179
|
-
}
|
|
1180
|
-
function qe(e, t, n = 0) {
|
|
1181
|
-
return e === "before-first-chunk" ? {
|
|
1182
|
-
phase: e,
|
|
1183
|
-
error: t
|
|
1184
|
-
} : {
|
|
1185
|
-
phase: e,
|
|
1186
|
-
error: t,
|
|
1187
|
-
chunksDelivered: n
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
//#endregion
|
|
1191
1367
|
//#region src/lib/validate-layer.ts
|
|
1192
1368
|
var U = new n({
|
|
1193
1369
|
allErrors: !0,
|
|
@@ -1205,14 +1381,14 @@ for (let e of [
|
|
|
1205
1381
|
valid: !0
|
|
1206
1382
|
});
|
|
1207
1383
|
U.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
|
|
1208
|
-
function
|
|
1384
|
+
function ut(e) {
|
|
1209
1385
|
return e ? e.replace(/^\//, "").split("/").map((e) => e.replace(/~1/g, "/").replace(/~0/g, "~")).join(".") : "(root)";
|
|
1210
1386
|
}
|
|
1211
|
-
function
|
|
1387
|
+
function dt(e) {
|
|
1212
1388
|
let t = e?.properties;
|
|
1213
1389
|
return t ? Object.keys(t) : [];
|
|
1214
1390
|
}
|
|
1215
|
-
function
|
|
1391
|
+
function ft(e, t) {
|
|
1216
1392
|
let n = e.length, r = t.length;
|
|
1217
1393
|
if (n === 0) return r;
|
|
1218
1394
|
if (r === 0) return n;
|
|
@@ -1227,27 +1403,27 @@ function Xe(e, t) {
|
|
|
1227
1403
|
}
|
|
1228
1404
|
return i[r];
|
|
1229
1405
|
}
|
|
1230
|
-
function
|
|
1406
|
+
function pt(e, t) {
|
|
1231
1407
|
let n, r = Infinity;
|
|
1232
1408
|
for (let i of t) {
|
|
1233
|
-
let t =
|
|
1409
|
+
let t = ft(e.toLowerCase(), i.toLowerCase());
|
|
1234
1410
|
t < r && (r = t, n = i);
|
|
1235
1411
|
}
|
|
1236
1412
|
let i = Math.max(2, Math.floor(e.length / 3));
|
|
1237
1413
|
return n !== void 0 && r <= i ? n : void 0;
|
|
1238
1414
|
}
|
|
1239
|
-
function
|
|
1415
|
+
function mt(e) {
|
|
1240
1416
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1241
1417
|
}
|
|
1242
|
-
function
|
|
1243
|
-
let t =
|
|
1418
|
+
function ht(e) {
|
|
1419
|
+
let t = ut(e.instancePath), n = e.params ?? {};
|
|
1244
1420
|
switch (e.keyword) {
|
|
1245
1421
|
case "additionalProperties": {
|
|
1246
|
-
let r = String(n.additionalProperty ?? "?"), i =
|
|
1422
|
+
let r = String(n.additionalProperty ?? "?"), i = dt(e.parentSchema), a = pt(r, i);
|
|
1247
1423
|
return `unknown key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}${a ? ` (did you mean '${a}'?)` : ""}`;
|
|
1248
1424
|
}
|
|
1249
1425
|
case "required": {
|
|
1250
|
-
let r = String(n.missingProperty ?? "?"), i =
|
|
1426
|
+
let r = String(n.missingProperty ?? "?"), i = dt(e.parentSchema);
|
|
1251
1427
|
return `missing required key '${r}' at ${t}${i.length ? `; allowed keys: ${i.join(", ")}` : ""}`;
|
|
1252
1428
|
}
|
|
1253
1429
|
case "enum": {
|
|
@@ -1256,25 +1432,25 @@ function $e(e) {
|
|
|
1256
1432
|
}
|
|
1257
1433
|
case "type": {
|
|
1258
1434
|
let r = e.data;
|
|
1259
|
-
return `${t} must be ${String(n.type)} (got ${
|
|
1435
|
+
return `${t} must be ${String(n.type)} (got ${mt(r)})`;
|
|
1260
1436
|
}
|
|
1261
1437
|
default: return `${t} ${e.message ?? "failed schema check"}`;
|
|
1262
1438
|
}
|
|
1263
1439
|
}
|
|
1264
1440
|
var W = 12;
|
|
1265
|
-
function
|
|
1266
|
-
let t = e.slice(0, W).map(
|
|
1441
|
+
function gt(e) {
|
|
1442
|
+
let t = e.slice(0, W).map(ht);
|
|
1267
1443
|
return e.length > W && t.push(`…and ${e.length - W} more`), t.join("; ");
|
|
1268
1444
|
}
|
|
1269
1445
|
function G(e) {
|
|
1270
1446
|
return e === null ? !1 : Array.isArray(e) ? e.some(G) : typeof e != "object" || Object.values(e).some(G);
|
|
1271
1447
|
}
|
|
1272
|
-
function
|
|
1273
|
-
let n = [`Validation failed: ${
|
|
1448
|
+
function _t(e, t) {
|
|
1449
|
+
let n = [`Validation failed: ${gt(e)}`], r = j(t);
|
|
1274
1450
|
return G(r) && n.push(`Example: ${JSON.stringify(r)}`), n.join(" — ");
|
|
1275
1451
|
}
|
|
1276
|
-
var
|
|
1277
|
-
let n = e.ctx.get(
|
|
1452
|
+
var vt = async (e, t) => {
|
|
1453
|
+
let n = e.ctx.get(yt);
|
|
1278
1454
|
if (n === void 0) return t();
|
|
1279
1455
|
let r = n[e.operation.id];
|
|
1280
1456
|
if (r === void 0) return t();
|
|
@@ -1284,11 +1460,11 @@ var nt = async (e, t) => {
|
|
|
1284
1460
|
}, a = U.compile(r.input);
|
|
1285
1461
|
if (!a(i)) {
|
|
1286
1462
|
let e = a.errors ?? [];
|
|
1287
|
-
throw new
|
|
1463
|
+
throw new M("invalid_argument", _t(e, r.input), e);
|
|
1288
1464
|
}
|
|
1289
1465
|
return t();
|
|
1290
|
-
},
|
|
1291
|
-
function
|
|
1466
|
+
}, yt = Symbol("ValidateSchemasToken");
|
|
1467
|
+
function bt(e) {
|
|
1292
1468
|
return async function(t, n) {
|
|
1293
1469
|
let r = e[t.operation.id];
|
|
1294
1470
|
if (r === void 0) return n();
|
|
@@ -1298,27 +1474,27 @@ function it(e) {
|
|
|
1298
1474
|
}, a = U.compile(r.input);
|
|
1299
1475
|
if (!a(i)) {
|
|
1300
1476
|
let e = a.errors ?? [];
|
|
1301
|
-
throw new
|
|
1477
|
+
throw new M("invalid_argument", _t(e, r.input), e);
|
|
1302
1478
|
}
|
|
1303
1479
|
return n();
|
|
1304
1480
|
};
|
|
1305
1481
|
}
|
|
1306
1482
|
//#endregion
|
|
1307
1483
|
//#region src/lib/instance-registry.ts
|
|
1308
|
-
function
|
|
1484
|
+
function xt() {
|
|
1309
1485
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
1310
1486
|
let t = Math.random() * 16 | 0;
|
|
1311
1487
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
1312
1488
|
});
|
|
1313
1489
|
}
|
|
1314
|
-
var
|
|
1490
|
+
var St = class {
|
|
1315
1491
|
constructor(e = {}) {
|
|
1316
1492
|
this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = e.defaultTtlMs;
|
|
1317
1493
|
let t = null;
|
|
1318
1494
|
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
1495
|
}
|
|
1320
1496
|
create(e, t = [], n) {
|
|
1321
|
-
let r = new e(...t), i =
|
|
1497
|
+
let r = new e(...t), i = xt(), a = n ?? this._defaultTtlMs, o = a === void 0 ? null : Date.now() + a;
|
|
1322
1498
|
return this._store.set(i, {
|
|
1323
1499
|
instance: r,
|
|
1324
1500
|
expiresAt: o
|
|
@@ -1362,61 +1538,6 @@ async function K(e) {
|
|
|
1362
1538
|
}
|
|
1363
1539
|
}
|
|
1364
1540
|
//#endregion
|
|
1365
|
-
//#region src/lib/stream.ts
|
|
1366
|
-
function st(e) {
|
|
1367
|
-
let { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
1368
|
-
return { [Symbol.asyncIterator]() {
|
|
1369
|
-
let e = t(r);
|
|
1370
|
-
return {
|
|
1371
|
-
async next() {
|
|
1372
|
-
return r.aborted ? (await e.return(void 0), {
|
|
1373
|
-
done: !0,
|
|
1374
|
-
value: void 0
|
|
1375
|
-
}) : e.next();
|
|
1376
|
-
},
|
|
1377
|
-
async return(t) {
|
|
1378
|
-
return await e.return(t), {
|
|
1379
|
-
done: !0,
|
|
1380
|
-
value: void 0
|
|
1381
|
-
};
|
|
1382
|
-
},
|
|
1383
|
-
async throw(t) {
|
|
1384
|
-
return await e.throw(t), {
|
|
1385
|
-
done: !0,
|
|
1386
|
-
value: void 0
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
};
|
|
1390
|
-
} };
|
|
1391
|
-
}
|
|
1392
|
-
async function ct(e) {
|
|
1393
|
-
let t = [];
|
|
1394
|
-
for await (let n of e) t.push(n);
|
|
1395
|
-
return t;
|
|
1396
|
-
}
|
|
1397
|
-
async function lt(e) {
|
|
1398
|
-
let t = [];
|
|
1399
|
-
try {
|
|
1400
|
-
for await (let n of e) t.push(n);
|
|
1401
|
-
return {
|
|
1402
|
-
ok: !0,
|
|
1403
|
-
chunks: t
|
|
1404
|
-
};
|
|
1405
|
-
} catch (e) {
|
|
1406
|
-
let n = Ke(e) ? e : new H("internal", e instanceof Error ? e.message : String(e));
|
|
1407
|
-
return t.length === 0 ? {
|
|
1408
|
-
ok: !1,
|
|
1409
|
-
carrier: qe("before-first-chunk", n)
|
|
1410
|
-
} : {
|
|
1411
|
-
ok: !1,
|
|
1412
|
-
carrier: qe("after-first-chunk", n, t.length)
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
function ut(e) {
|
|
1417
|
-
return typeof e == "object" && !!e && Symbol.asyncIterator in e;
|
|
1418
|
-
}
|
|
1419
|
-
//#endregion
|
|
1420
1541
|
//#region src/lib/logical/union-codec.ts
|
|
1421
1542
|
var q = class extends Error {
|
|
1422
1543
|
constructor(e, t) {
|
|
@@ -1434,7 +1555,7 @@ function J(e) {
|
|
|
1434
1555
|
mapping: r
|
|
1435
1556
|
};
|
|
1436
1557
|
}
|
|
1437
|
-
function
|
|
1558
|
+
function Ct(e, t) {
|
|
1438
1559
|
let n = e[c];
|
|
1439
1560
|
if (typeof n == "string") {
|
|
1440
1561
|
let e = t.registry.get(n);
|
|
@@ -1442,15 +1563,15 @@ function dt(e, t) {
|
|
|
1442
1563
|
}
|
|
1443
1564
|
return t.registry.resolve(e);
|
|
1444
1565
|
}
|
|
1445
|
-
function
|
|
1446
|
-
let r =
|
|
1566
|
+
function wt(e, t, n) {
|
|
1567
|
+
let r = Ct(t, n);
|
|
1447
1568
|
return r ? r.encode(e, t, n) : e;
|
|
1448
1569
|
}
|
|
1449
|
-
function
|
|
1450
|
-
let r =
|
|
1570
|
+
function Tt(e, t, n) {
|
|
1571
|
+
let r = Ct(t, n);
|
|
1451
1572
|
return r ? r.decode(e, t, n) : e;
|
|
1452
1573
|
}
|
|
1453
|
-
function
|
|
1574
|
+
function Et(e) {
|
|
1454
1575
|
let { id: t, schema: n } = e;
|
|
1455
1576
|
return {
|
|
1456
1577
|
id: t,
|
|
@@ -1468,7 +1589,7 @@ function mt(e) {
|
|
|
1468
1589
|
if (s == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] value at "${r.path}" is missing the discriminator property "${a}".`);
|
|
1469
1590
|
let c = String(s), l = o[c];
|
|
1470
1591
|
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
|
|
1592
|
+
return wt(e, r.resolve(l), {
|
|
1472
1593
|
...r,
|
|
1473
1594
|
path: `${r.path}[${c}]`
|
|
1474
1595
|
});
|
|
@@ -1484,7 +1605,7 @@ function mt(e) {
|
|
|
1484
1605
|
if (c == null) throw new q("E_UNION_NO_DISCRIMINATOR", `[${t}] wire object at "${r.path}" is missing the discriminator property "${o}".`);
|
|
1485
1606
|
let l = String(c), u = s[l];
|
|
1486
1607
|
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
|
|
1608
|
+
return Tt(e, r.resolve(u), {
|
|
1488
1609
|
...r,
|
|
1489
1610
|
path: `${r.path}[${l}]`
|
|
1490
1611
|
});
|
|
@@ -1496,29 +1617,29 @@ var Y = class extends Error {
|
|
|
1496
1617
|
super(t), this.name = "NominalCodecError", this.code = e;
|
|
1497
1618
|
}
|
|
1498
1619
|
};
|
|
1499
|
-
function
|
|
1620
|
+
function Dt(e) {
|
|
1500
1621
|
let t = e.properties;
|
|
1501
1622
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
1502
1623
|
}
|
|
1503
|
-
function
|
|
1624
|
+
function Ot(e) {
|
|
1504
1625
|
let t = e.required;
|
|
1505
1626
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
1506
1627
|
}
|
|
1507
|
-
function
|
|
1628
|
+
function kt(e, t, n) {
|
|
1508
1629
|
if (t) {
|
|
1509
1630
|
let r = n.registry.resolve(t);
|
|
1510
1631
|
if (r) return r.encode(e, t, n);
|
|
1511
1632
|
}
|
|
1512
1633
|
return e;
|
|
1513
1634
|
}
|
|
1514
|
-
function
|
|
1635
|
+
function At(e, t, n) {
|
|
1515
1636
|
if (t) {
|
|
1516
1637
|
let r = n.registry.resolve(t);
|
|
1517
1638
|
if (r) return r.decode(e, t, n);
|
|
1518
1639
|
}
|
|
1519
1640
|
return e;
|
|
1520
1641
|
}
|
|
1521
|
-
function
|
|
1642
|
+
function jt(e) {
|
|
1522
1643
|
let { id: t, schema: n, ctor: r } = e;
|
|
1523
1644
|
return {
|
|
1524
1645
|
id: t,
|
|
@@ -1535,12 +1656,12 @@ function yt(e) {
|
|
|
1535
1656
|
}
|
|
1536
1657
|
r.seen.add(e);
|
|
1537
1658
|
try {
|
|
1538
|
-
let t =
|
|
1659
|
+
let t = Dt(n), i = e[typeof n["x-apigen-tojson"] == "string" ? n[u] : "toJSON"];
|
|
1539
1660
|
if (typeof i == "function") {
|
|
1540
1661
|
let n = i.call(e);
|
|
1541
1662
|
if (typeof n == "object" && n && !Array.isArray(n)) {
|
|
1542
1663
|
let e = {};
|
|
1543
|
-
for (let [i, a] of Object.entries(n)) e[i] =
|
|
1664
|
+
for (let [i, a] of Object.entries(n)) e[i] = kt(a, t[i], {
|
|
1544
1665
|
...r,
|
|
1545
1666
|
path: `${r.path}/${i}`
|
|
1546
1667
|
});
|
|
@@ -1551,7 +1672,7 @@ function yt(e) {
|
|
|
1551
1672
|
let a = {}, o = Object.keys(t), s = e, c = o.length > 0 ? o : Object.keys(s);
|
|
1552
1673
|
for (let e of c) {
|
|
1553
1674
|
let n = s[e];
|
|
1554
|
-
n !== void 0 && (a[e] =
|
|
1675
|
+
n !== void 0 && (a[e] = kt(n, t[e], {
|
|
1555
1676
|
...r,
|
|
1556
1677
|
path: `${r.path}/${e}`
|
|
1557
1678
|
}));
|
|
@@ -1567,10 +1688,10 @@ function yt(e) {
|
|
|
1567
1688
|
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
1689
|
}
|
|
1569
1690
|
let a = e;
|
|
1570
|
-
for (let e of
|
|
1691
|
+
for (let e of Ot(n)) if (!(e in a)) throw new Y("E_NOMINAL_INVALID_WIRE", `[${t}] required field "${e}" missing on the wire at "${i.path}".`);
|
|
1571
1692
|
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] =
|
|
1693
|
+
let o = Dt(n), s = {};
|
|
1694
|
+
for (let [e, t] of Object.entries(a)) s[e] = At(t, o[e], {
|
|
1574
1695
|
...i,
|
|
1575
1696
|
path: `${i.path}/${e}`
|
|
1576
1697
|
});
|
|
@@ -1584,21 +1705,21 @@ function yt(e) {
|
|
|
1584
1705
|
}
|
|
1585
1706
|
//#endregion
|
|
1586
1707
|
//#region src/lib/logical/host-ts.ts
|
|
1587
|
-
var
|
|
1708
|
+
var Mt = [
|
|
1588
1709
|
S,
|
|
1589
1710
|
C,
|
|
1590
1711
|
w,
|
|
1591
1712
|
T,
|
|
1592
1713
|
E,
|
|
1593
1714
|
A
|
|
1594
|
-
],
|
|
1715
|
+
], Nt = jt({
|
|
1595
1716
|
id: "ts.NominalSentinel",
|
|
1596
1717
|
schema: {
|
|
1597
1718
|
type: "object",
|
|
1598
1719
|
"x-apigen-logical": "nominal",
|
|
1599
1720
|
"x-apigen-codec": "ts.NominalSentinel"
|
|
1600
1721
|
}
|
|
1601
|
-
}),
|
|
1722
|
+
}), Pt = Et({
|
|
1602
1723
|
id: "ts.UnionSentinel",
|
|
1603
1724
|
schema: {
|
|
1604
1725
|
oneOf: [],
|
|
@@ -1610,32 +1731,32 @@ var bt = [
|
|
|
1610
1731
|
"x-apigen-codec": "ts.UnionSentinel"
|
|
1611
1732
|
}
|
|
1612
1733
|
});
|
|
1613
|
-
function
|
|
1734
|
+
function Ft() {
|
|
1614
1735
|
let e = [
|
|
1615
|
-
...
|
|
1616
|
-
[
|
|
1617
|
-
[
|
|
1736
|
+
...Mt.map((e) => [e.id, e]),
|
|
1737
|
+
[Nt.id, Nt],
|
|
1738
|
+
[Pt.id, Pt]
|
|
1618
1739
|
];
|
|
1619
1740
|
return Object.freeze(new Map(e));
|
|
1620
1741
|
}
|
|
1621
|
-
var
|
|
1742
|
+
var It = Object.freeze({
|
|
1622
1743
|
host: "ts",
|
|
1623
1744
|
logicalTypeVersion: d,
|
|
1624
|
-
codecs:
|
|
1745
|
+
codecs: Ft()
|
|
1625
1746
|
});
|
|
1626
1747
|
//#endregion
|
|
1627
1748
|
//#region src/lib/tool-description.ts
|
|
1628
|
-
function
|
|
1749
|
+
function Lt(e, t, n) {
|
|
1629
1750
|
let r = [
|
|
1630
1751
|
n,
|
|
1631
1752
|
typeof t?.input?.description == "string" ? t.input.description : void 0,
|
|
1632
|
-
|
|
1753
|
+
Ee(t?.input)
|
|
1633
1754
|
].filter((e) => typeof e == "string" && e.length > 0);
|
|
1634
1755
|
return r.length > 0 ? r.join(" — ") : e;
|
|
1635
1756
|
}
|
|
1636
1757
|
//#endregion
|
|
1637
1758
|
//#region src/lib/mcp-output-schema.ts
|
|
1638
|
-
function
|
|
1759
|
+
function Rt(e) {
|
|
1639
1760
|
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length === 0) return {
|
|
1640
1761
|
outputSchema: void 0,
|
|
1641
1762
|
wrapped: !1
|
|
@@ -1649,25 +1770,25 @@ function Tt(e) {
|
|
|
1649
1770
|
wrapped: !1
|
|
1650
1771
|
};
|
|
1651
1772
|
}
|
|
1652
|
-
function
|
|
1773
|
+
function zt(e, t) {
|
|
1653
1774
|
if (e) return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1654
1775
|
}
|
|
1655
1776
|
//#endregion
|
|
1656
1777
|
//#region src/lib/batch.ts
|
|
1657
|
-
var
|
|
1658
|
-
function
|
|
1659
|
-
return
|
|
1778
|
+
var Bt = 4, Vt = 32;
|
|
1779
|
+
function X(e) {
|
|
1780
|
+
return Oe(e) ? e : e instanceof Error ? new M("internal", e.message) : e;
|
|
1660
1781
|
}
|
|
1661
|
-
function
|
|
1782
|
+
function Ht(e, t) {
|
|
1662
1783
|
if (e === "serial" || e === "chained") return 1;
|
|
1663
1784
|
let n = t ?? 4;
|
|
1664
1785
|
return !Number.isFinite(n) || n < 1 ? 1 : Math.min(Math.floor(n), 32);
|
|
1665
1786
|
}
|
|
1666
|
-
function
|
|
1667
|
-
function
|
|
1787
|
+
function Ut() {}
|
|
1788
|
+
function Wt(e, t) {
|
|
1668
1789
|
if (!e && !t) return {
|
|
1669
1790
|
signal: void 0,
|
|
1670
|
-
dispose:
|
|
1791
|
+
dispose: Ut
|
|
1671
1792
|
};
|
|
1672
1793
|
let n = new AbortController(), r = () => {
|
|
1673
1794
|
n.abort(e?.reason);
|
|
@@ -1683,21 +1804,21 @@ function jt(e, t) {
|
|
|
1683
1804
|
}
|
|
1684
1805
|
};
|
|
1685
1806
|
}
|
|
1686
|
-
async function
|
|
1687
|
-
let o =
|
|
1807
|
+
async function Gt(e, t, n, r, i, a) {
|
|
1808
|
+
let o = Wt(r.signal, a);
|
|
1688
1809
|
try {
|
|
1689
1810
|
let a = await e(t, o.signal ? {
|
|
1690
1811
|
...r,
|
|
1691
1812
|
signal: o.signal
|
|
1692
1813
|
} : r, i);
|
|
1693
|
-
if (
|
|
1694
|
-
let e = await
|
|
1814
|
+
if (N(a)) {
|
|
1815
|
+
let e = await Me(a);
|
|
1695
1816
|
if (!e.ok) {
|
|
1696
1817
|
let t = e.carrier;
|
|
1697
1818
|
return {
|
|
1698
1819
|
index: n,
|
|
1699
1820
|
status: "rejected",
|
|
1700
|
-
reason:
|
|
1821
|
+
reason: X(t.error),
|
|
1701
1822
|
...t.phase === "after-first-chunk" ? { chunksDelivered: t.chunksDelivered } : {}
|
|
1702
1823
|
};
|
|
1703
1824
|
}
|
|
@@ -1716,17 +1837,17 @@ async function Mt(e, t, n, r, i, a) {
|
|
|
1716
1837
|
return {
|
|
1717
1838
|
index: n,
|
|
1718
1839
|
status: "rejected",
|
|
1719
|
-
reason:
|
|
1840
|
+
reason: X(e)
|
|
1720
1841
|
};
|
|
1721
1842
|
} finally {
|
|
1722
1843
|
o.dispose();
|
|
1723
1844
|
}
|
|
1724
1845
|
}
|
|
1725
|
-
async function
|
|
1726
|
-
let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s =
|
|
1846
|
+
async function Kt(e, t, n, r, i = {}) {
|
|
1847
|
+
let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s = Ht(a, i.concurrency), c = Array(n.length), l = (e) => ({
|
|
1727
1848
|
index: e,
|
|
1728
1849
|
status: "rejected",
|
|
1729
|
-
reason:
|
|
1850
|
+
reason: X(/* @__PURE__ */ Error("apigen/invokeBatch: not attempted — an earlier item failed and " + (a === "chained" ? "mode is \"chained\"" : "onItemError is \"abort\"")))
|
|
1730
1851
|
});
|
|
1731
1852
|
if (a === "serial" || a === "chained") {
|
|
1732
1853
|
let s = !1;
|
|
@@ -1735,7 +1856,7 @@ async function Nt(e, t, n, r, i = {}) {
|
|
|
1735
1856
|
c[u] = l(u);
|
|
1736
1857
|
continue;
|
|
1737
1858
|
}
|
|
1738
|
-
let d = await
|
|
1859
|
+
let d = await Gt(e, t, u, n[u], r, i.itemTimeoutMs);
|
|
1739
1860
|
c[u] = d, d.status === "rejected" && (a === "chained" || o === "abort") && (s = !0);
|
|
1740
1861
|
}
|
|
1741
1862
|
return c;
|
|
@@ -1748,7 +1869,7 @@ async function Nt(e, t, n, r, i = {}) {
|
|
|
1748
1869
|
c[a] = l(a);
|
|
1749
1870
|
continue;
|
|
1750
1871
|
}
|
|
1751
|
-
let s = await
|
|
1872
|
+
let s = await Gt(e, t, a, n[a], r, i.itemTimeoutMs);
|
|
1752
1873
|
c[a] = s, s.status === "rejected" && o === "abort" && (d = !0);
|
|
1753
1874
|
}
|
|
1754
1875
|
});
|
|
@@ -1756,17 +1877,17 @@ async function Nt(e, t, n, r, i = {}) {
|
|
|
1756
1877
|
}
|
|
1757
1878
|
//#endregion
|
|
1758
1879
|
//#region ../apigen-engine-naming/src/lib/naming.ts
|
|
1759
|
-
function
|
|
1880
|
+
function qt(e) {
|
|
1760
1881
|
return e.words.join("-");
|
|
1761
1882
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return e.words.map(
|
|
1883
|
+
function Z(e) {
|
|
1884
|
+
return e.words.map($t).join("");
|
|
1764
1885
|
}
|
|
1765
|
-
function
|
|
1886
|
+
function Jt(e) {
|
|
1766
1887
|
return e.words.join("_");
|
|
1767
1888
|
}
|
|
1768
|
-
function
|
|
1769
|
-
let n = [e.namespace, ...e.path], r = e.safe ||
|
|
1889
|
+
function Yt(e, t = {}) {
|
|
1890
|
+
let n = [e.namespace, ...e.path], r = e.safe || Ke(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => qt(e)).join("/"), o = n.map((e) => Jt(e)).join("_"), s = n.map((e) => Jt(e)).slice(0, -1).join("."), c = Z(n[n.length - 2] ?? n[0]), l = Z(n[n.length - 1]), u = n.map((e) => qt(e));
|
|
1770
1891
|
return {
|
|
1771
1892
|
http: {
|
|
1772
1893
|
verb: i,
|
|
@@ -1781,17 +1902,17 @@ function Lt(e, t = {}) {
|
|
|
1781
1902
|
cli: { path: u }
|
|
1782
1903
|
};
|
|
1783
1904
|
}
|
|
1784
|
-
function
|
|
1905
|
+
function Xt(e, t) {
|
|
1785
1906
|
return `x-${e}-${t}`;
|
|
1786
1907
|
}
|
|
1787
|
-
function
|
|
1908
|
+
function Zt(e, t) {
|
|
1788
1909
|
return `--${e}-${t}`;
|
|
1789
1910
|
}
|
|
1790
|
-
function
|
|
1911
|
+
function Qt(e, t) {
|
|
1791
1912
|
let n = (e) => e.toUpperCase().replace(/-/g, "_");
|
|
1792
1913
|
return e === "adhd" ? `APIGEN_${n(t)}` : `APIGEN_${n(e)}_${n(t)}`;
|
|
1793
1914
|
}
|
|
1794
|
-
function
|
|
1915
|
+
function $t(e) {
|
|
1795
1916
|
return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
|
|
1796
1917
|
}
|
|
1797
1918
|
//#endregion
|
|
@@ -1799,7 +1920,7 @@ function Vt(e) {
|
|
|
1799
1920
|
function Q(e) {
|
|
1800
1921
|
return e.anyOf ?? e.oneOf;
|
|
1801
1922
|
}
|
|
1802
|
-
function
|
|
1923
|
+
function en(e) {
|
|
1803
1924
|
if (!e) return !1;
|
|
1804
1925
|
if (e.type === "array" || e.type === "object") return !0;
|
|
1805
1926
|
let t = Q(e);
|
|
@@ -1809,7 +1930,7 @@ function Ht(e) {
|
|
|
1809
1930
|
}
|
|
1810
1931
|
return !1;
|
|
1811
1932
|
}
|
|
1812
|
-
function
|
|
1933
|
+
function tn(e) {
|
|
1813
1934
|
if (!e) return !1;
|
|
1814
1935
|
if (e.type === "boolean") return !0;
|
|
1815
1936
|
let t = Q(e);
|
|
@@ -1819,7 +1940,7 @@ function Ut(e) {
|
|
|
1819
1940
|
}
|
|
1820
1941
|
return !1;
|
|
1821
1942
|
}
|
|
1822
|
-
function
|
|
1943
|
+
function nn(e) {
|
|
1823
1944
|
if (!e) return !1;
|
|
1824
1945
|
if (e.type === "number" || e.type === "integer") return !0;
|
|
1825
1946
|
let t = Q(e);
|
|
@@ -1829,52 +1950,52 @@ function Wt(e) {
|
|
|
1829
1950
|
}
|
|
1830
1951
|
return !1;
|
|
1831
1952
|
}
|
|
1832
|
-
function
|
|
1953
|
+
function rn(e) {
|
|
1833
1954
|
return e.replace(/[A-Z]/g, (e) => "-" + e.toLowerCase());
|
|
1834
1955
|
}
|
|
1835
|
-
function
|
|
1956
|
+
function an(e) {
|
|
1836
1957
|
let t = e.input?.properties?.data;
|
|
1837
1958
|
return {
|
|
1838
1959
|
props: t?.properties ?? {},
|
|
1839
1960
|
required: t?.required ?? []
|
|
1840
1961
|
};
|
|
1841
1962
|
}
|
|
1842
|
-
function
|
|
1963
|
+
function on(e) {
|
|
1843
1964
|
return typeof e.handler == "function";
|
|
1844
1965
|
}
|
|
1845
|
-
function
|
|
1966
|
+
function sn(e) {
|
|
1846
1967
|
let t = e.input?.properties ?? {}, n = e["x-apigen-envelope"], r = [];
|
|
1847
1968
|
for (let e of Object.keys(t)) {
|
|
1848
1969
|
if (e === "data") continue;
|
|
1849
|
-
let t = n?.[e] ?? "adhd", i =
|
|
1970
|
+
let t = n?.[e] ?? "adhd", i = Xt(t, e);
|
|
1850
1971
|
r.push({
|
|
1851
1972
|
field: e,
|
|
1852
1973
|
pluginId: t,
|
|
1853
1974
|
httpHeader: i,
|
|
1854
1975
|
mcpMetaKey: i,
|
|
1855
|
-
cliFlag:
|
|
1856
|
-
envVar:
|
|
1976
|
+
cliFlag: Zt(t, e),
|
|
1977
|
+
envVar: Qt(t, e)
|
|
1857
1978
|
});
|
|
1858
1979
|
}
|
|
1859
1980
|
return r;
|
|
1860
1981
|
}
|
|
1861
|
-
function
|
|
1982
|
+
function cn(e, t, n, r) {
|
|
1862
1983
|
t === n || e.has(t) || e.set(t, {
|
|
1863
1984
|
...r,
|
|
1864
1985
|
aliasOf: n
|
|
1865
1986
|
});
|
|
1866
1987
|
}
|
|
1867
|
-
function
|
|
1868
|
-
let n = /* @__PURE__ */ new Map(), { props: r } =
|
|
1988
|
+
function ln(e, t) {
|
|
1989
|
+
let n = /* @__PURE__ */ new Map(), { props: r } = an(e);
|
|
1869
1990
|
for (let [e, t] of Object.entries(r)) {
|
|
1870
1991
|
let r = "string";
|
|
1871
|
-
|
|
1872
|
-
let i =
|
|
1992
|
+
tn(t) ? r = "boolean" : (en(t) || nn(t)) && (r = "json");
|
|
1993
|
+
let i = rn(e), a = {
|
|
1873
1994
|
camelKey: e,
|
|
1874
1995
|
kind: "domain",
|
|
1875
1996
|
valueKind: r
|
|
1876
1997
|
};
|
|
1877
|
-
n.set(i, a),
|
|
1998
|
+
n.set(i, a), cn(n, e, i, a);
|
|
1878
1999
|
}
|
|
1879
2000
|
for (let e of t) {
|
|
1880
2001
|
let t = e.cliFlag.replace(/^--/, ""), r = {
|
|
@@ -1887,8 +2008,8 @@ function Xt(e, t) {
|
|
|
1887
2008
|
}
|
|
1888
2009
|
return n;
|
|
1889
2010
|
}
|
|
1890
|
-
function
|
|
1891
|
-
let { op: t, schema: n, transport: r, projection: i } = e, a =
|
|
2011
|
+
function un(e) {
|
|
2012
|
+
let { op: t, schema: n, transport: r, projection: i } = e, a = Yt(t, i), o = n ? sn(n) : [], s = n ? ln(n, o) : /* @__PURE__ */ new Map(), c = n ? at(n).params : void 0, l = {
|
|
1892
2013
|
op: t,
|
|
1893
2014
|
transport: r,
|
|
1894
2015
|
http: a.http,
|
|
@@ -1899,9 +2020,9 @@ function Zt(e) {
|
|
|
1899
2020
|
envelope: o,
|
|
1900
2021
|
cliFlags: s,
|
|
1901
2022
|
streaming: t.streaming,
|
|
1902
|
-
isMount:
|
|
2023
|
+
isMount: on(t)
|
|
1903
2024
|
};
|
|
1904
|
-
if (
|
|
2025
|
+
if (on(t)) {
|
|
1905
2026
|
let e = t.handler;
|
|
1906
2027
|
l.mountHandler = async (t) => e(t);
|
|
1907
2028
|
}
|
|
@@ -1909,35 +2030,35 @@ function Zt(e) {
|
|
|
1909
2030
|
}
|
|
1910
2031
|
//#endregion
|
|
1911
2032
|
//#region src/lib/package-invoker.ts
|
|
1912
|
-
function
|
|
2033
|
+
function dn(e) {
|
|
1913
2034
|
let t = e.usePlugins;
|
|
1914
2035
|
return Array.isArray(t) ? t : [];
|
|
1915
2036
|
}
|
|
1916
|
-
function
|
|
2037
|
+
function fn(e) {
|
|
1917
2038
|
let t = e.exitCode;
|
|
1918
2039
|
return typeof t == "function" ? t : void 0;
|
|
1919
2040
|
}
|
|
1920
|
-
function
|
|
2041
|
+
function pn(e) {
|
|
1921
2042
|
let t = e.useOptions;
|
|
1922
2043
|
return t && typeof t == "object" ? t : {};
|
|
1923
2044
|
}
|
|
1924
|
-
function
|
|
2045
|
+
function mn(e) {
|
|
1925
2046
|
return async function(t, n) {
|
|
1926
2047
|
let r = Object.assign(t, { data: t.domainArgs });
|
|
1927
2048
|
return await e.layer(r, n);
|
|
1928
2049
|
};
|
|
1929
2050
|
}
|
|
1930
|
-
function
|
|
2051
|
+
function hn(e, t) {
|
|
1931
2052
|
let n = [];
|
|
1932
2053
|
for (let e of t) {
|
|
1933
2054
|
let t = e.capabilities?.layer;
|
|
1934
|
-
t && n.push(
|
|
2055
|
+
t && n.push(mn(t));
|
|
1935
2056
|
}
|
|
1936
|
-
return n.push(
|
|
2057
|
+
return n.push(bt(e)), Re(n);
|
|
1937
2058
|
}
|
|
1938
2059
|
//#endregion
|
|
1939
2060
|
//#region src/lib/dispatch-for-plan.ts
|
|
1940
|
-
function
|
|
2061
|
+
function gn() {
|
|
1941
2062
|
let e = /* @__PURE__ */ new Map();
|
|
1942
2063
|
return {
|
|
1943
2064
|
get: (t) => e.get(t),
|
|
@@ -1946,7 +2067,7 @@ function rn() {
|
|
|
1946
2067
|
}
|
|
1947
2068
|
};
|
|
1948
2069
|
}
|
|
1949
|
-
var
|
|
2070
|
+
var _n = {
|
|
1950
2071
|
input: {
|
|
1951
2072
|
type: "object",
|
|
1952
2073
|
properties: { data: {
|
|
@@ -1956,11 +2077,11 @@ var an = {
|
|
|
1956
2077
|
},
|
|
1957
2078
|
output: {}
|
|
1958
2079
|
};
|
|
1959
|
-
async function
|
|
2080
|
+
async function vn(e, t, n, r) {
|
|
1960
2081
|
let i = {
|
|
1961
2082
|
...n,
|
|
1962
2083
|
operation: { id: e.op.id },
|
|
1963
|
-
ctx: new
|
|
2084
|
+
ctx: new Le(),
|
|
1964
2085
|
transport: e.transport
|
|
1965
2086
|
};
|
|
1966
2087
|
if (e.isMount) {
|
|
@@ -1970,13 +2091,13 @@ async function on(e, t, n, r) {
|
|
|
1970
2091
|
operation: e.op,
|
|
1971
2092
|
data: n.domainArgs,
|
|
1972
2093
|
envelope: n.envelope,
|
|
1973
|
-
ctx:
|
|
2094
|
+
ctx: gn(),
|
|
1974
2095
|
transport: e.transport,
|
|
1975
2096
|
signal: n.signal ?? new AbortController().signal
|
|
1976
2097
|
}, s = {
|
|
1977
2098
|
...r,
|
|
1978
2099
|
fns: { [e.op.id]: () => a(o) },
|
|
1979
|
-
schemas: { [e.op.id]:
|
|
2100
|
+
schemas: { [e.op.id]: _n }
|
|
1980
2101
|
};
|
|
1981
2102
|
return t(e.op.id, i, s);
|
|
1982
2103
|
}
|
|
@@ -1985,22 +2106,22 @@ async function on(e, t, n, r) {
|
|
|
1985
2106
|
//#endregion
|
|
1986
2107
|
//#region src/lib/bind-host.ts
|
|
1987
2108
|
var $ = "127.0.0.1";
|
|
1988
|
-
function
|
|
2109
|
+
function yn(e) {
|
|
1989
2110
|
let t = e.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
1990
2111
|
if (t === "localhost" || t === "::1") return !0;
|
|
1991
2112
|
let n = t.startsWith("::ffff:") ? t.slice(7) : t;
|
|
1992
2113
|
return /^127(\.\d{1,3}){3}$/.test(n);
|
|
1993
2114
|
}
|
|
1994
|
-
function
|
|
2115
|
+
function bn(e) {
|
|
1995
2116
|
if (typeof e != "string") return $;
|
|
1996
2117
|
let t = e.trim();
|
|
1997
2118
|
return t === "" ? $ : t;
|
|
1998
2119
|
}
|
|
1999
|
-
function
|
|
2000
|
-
return !
|
|
2120
|
+
function xn(e, t, n) {
|
|
2121
|
+
return !yn(e) && (n?.warn({
|
|
2001
2122
|
host: e,
|
|
2002
2123
|
host_kind: t
|
|
2003
2124
|
}, `${t} binding non-loopback host "${e}": the server will be reachable from the network. Omit the host option to bind ${$}.`), !0);
|
|
2004
2125
|
}
|
|
2005
2126
|
//#endregion
|
|
2006
|
-
export {
|
|
2127
|
+
export { Bt as BATCH_DEFAULT_CONCURRENCY, Vt as BATCH_MAX_CONCURRENCY, $ as DEFAULT_LISTEN_HOST, Be as EventBus, St as InstanceRegistry, Le as LayerContext, q as UnionCodecError, yt as ValidateSchemasToken, Mt as WELL_KNOWN_TS_CODECS, mn as adaptCoreLayer, Qe as assertNoSelfSubscription, Ue as buildContext, lt as buildFnTable, Rt as buildMcpOutputSchema, un as buildOpPlan, Lt as buildToolDescription, st as coerceQueryParams, Me as collectWithPhase, $e as createApiPackage, Re as createInvoker, et as createLogger, hn as createPackageInvoker, Ae as createStream, Et as createUnionCodec, I as dataParamNames, ze as defineMiddleware, at as describeParams, z as dispatch, vn as dispatchForPlan, je as drainStream, Kt as invokeBatch, N as isApiStream, yn as isLoopbackListenHost, bt as makeValidateLayer, F as needsEnvelopeField, fn as readExitCodeHook, pn as readUseOptions, dn as readUsePlugins, bn as resolveListenHost, It as tsHostBinding, vt as validateLayer, xn as warnIfNonLoopbackListen, He as wireObservers, zt as wrapMcpStructuredContent };
|