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