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