@adhd/apigen-engine-runtime 0.1.1 → 0.1.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 +60 -0
- package/index.d.ts +6 -0
- package/index.js +1 -1
- package/index.mjs +857 -650
- package/lib/dispatch-for-plan.d.ts +9 -0
- package/lib/op-plan.d.ts +100 -0
- package/lib/package-invoker.d.ts +50 -0
- package/lib/transport-adapter.d.ts +24 -0
- package/package.json +5 -4
- package/test-support/parity-harness.d.ts +108 -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 ye from "ajv";
|
|
7
|
+
import me from "ajv-formats";
|
|
8
|
+
const k = "$apigen";
|
|
9
|
+
class z 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 he(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 z(
|
|
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 z(
|
|
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 U = "x-apigen-logical",
|
|
62
|
-
function
|
|
61
|
+
const U = "x-apigen-logical", D = "x-apigen-codec", I = "x-apigen-ctor", x = "x-apigen-tojson", ge = "0.1.0";
|
|
62
|
+
function H(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,199 +73,199 @@ function V(e, t) {
|
|
|
73
73
|
...t
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
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
|
|
83
|
-
return
|
|
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
|
|
88
|
-
return
|
|
87
|
+
const a = ie(e, i, t);
|
|
88
|
+
return v(e, a, n);
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
90
|
+
const s = t.type;
|
|
91
|
+
if (s === "array") {
|
|
92
92
|
if (!Array.isArray(e))
|
|
93
|
-
return
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
return e.map((c) =>
|
|
97
|
-
const
|
|
98
|
-
return Array.isArray(
|
|
99
|
-
const
|
|
100
|
-
return
|
|
93
|
+
return A(e, t, n);
|
|
94
|
+
const a = t.items;
|
|
95
|
+
if (!a)
|
|
96
|
+
return e.map((c) => w(c));
|
|
97
|
+
const f = n.path;
|
|
98
|
+
return Array.isArray(a) ? e.map((c, u) => {
|
|
99
|
+
const p = a[u];
|
|
100
|
+
return p === void 0 ? w(c) : v(c, p, { ...n, path: `${f}/${u}` });
|
|
101
101
|
}) : e.map(
|
|
102
|
-
(c,
|
|
102
|
+
(c, u) => v(c, a, { ...n, path: `${f}/${u}` })
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
105
|
+
if (s === "object") {
|
|
106
106
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
107
|
-
return
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
return
|
|
111
|
-
const
|
|
112
|
-
for (const [
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
...
|
|
116
|
-
path: `${
|
|
107
|
+
return A(e, t, n);
|
|
108
|
+
const a = t.properties;
|
|
109
|
+
if (!a)
|
|
110
|
+
return w(e);
|
|
111
|
+
const f = n.path, c = {};
|
|
112
|
+
for (const [u, p] of Object.entries(a)) {
|
|
113
|
+
const l = e[u];
|
|
114
|
+
l !== void 0 && (c[u] = v(l, p, {
|
|
115
|
+
...n,
|
|
116
|
+
path: `${f}/${u}`
|
|
117
117
|
}));
|
|
118
118
|
}
|
|
119
119
|
return c;
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return s == null ? A(e, t, n) : w(e);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
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
|
|
130
|
-
return
|
|
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
|
|
135
|
-
return
|
|
134
|
+
const a = ie(e, i, t);
|
|
135
|
+
return $(e, a, n);
|
|
136
136
|
}
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
137
|
+
const s = t.type;
|
|
138
|
+
if (s === "array") {
|
|
139
139
|
if (!Array.isArray(e))
|
|
140
140
|
return e;
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
141
|
+
const a = t.items;
|
|
142
|
+
if (!a)
|
|
143
143
|
return e;
|
|
144
|
-
const
|
|
145
|
-
return Array.isArray(
|
|
146
|
-
const
|
|
147
|
-
return
|
|
144
|
+
const f = n.path;
|
|
145
|
+
return Array.isArray(a) ? e.map((c, u) => {
|
|
146
|
+
const p = a[u];
|
|
147
|
+
return p === void 0 ? c : $(c, p, { ...n, path: `${f}/${u}` });
|
|
148
148
|
}) : e.map(
|
|
149
|
-
(c,
|
|
149
|
+
(c, u) => $(c, a, { ...n, path: `${f}/${u}` })
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
|
-
if (
|
|
152
|
+
if (s === "object") {
|
|
153
153
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
154
154
|
return e;
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
155
|
+
const a = t.properties;
|
|
156
|
+
if (!a)
|
|
157
157
|
return e;
|
|
158
|
-
const
|
|
159
|
-
for (const [
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
...
|
|
163
|
-
path: `${
|
|
158
|
+
const f = n.path, c = {};
|
|
159
|
+
for (const [u, p] of Object.entries(a)) {
|
|
160
|
+
const l = e[u];
|
|
161
|
+
l !== void 0 && (c[u] = $(l, p, {
|
|
162
|
+
...n,
|
|
163
|
+
path: `${f}/${u}`
|
|
164
164
|
}));
|
|
165
165
|
}
|
|
166
166
|
return c;
|
|
167
167
|
}
|
|
168
|
-
return
|
|
168
|
+
return s == null ? we(e, n) : e;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const o =
|
|
170
|
+
function ie(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) {
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
175
|
+
const s = o.mapping[i];
|
|
176
|
+
if (s) {
|
|
177
|
+
const a = t.find((f) => f.$ref === s);
|
|
178
|
+
if (a)
|
|
179
|
+
return a;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
return t[0] ?? {};
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
for (const
|
|
187
|
-
const o =
|
|
185
|
+
function A(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 { [k]: r, v: i };
|
|
192
192
|
} catch {
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
return
|
|
195
|
+
return w(e);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
if (e !== null && typeof e == "object" && !Array.isArray(e) &&
|
|
199
|
-
const
|
|
197
|
+
function we(e, t) {
|
|
198
|
+
if (e !== null && typeof e == "object" && !Array.isArray(e) && k in e) {
|
|
199
|
+
const n = e, r = n[k], 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
|
}
|
|
205
|
-
function
|
|
205
|
+
function w(e) {
|
|
206
206
|
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean")
|
|
207
207
|
return e;
|
|
208
208
|
if (Array.isArray(e))
|
|
209
|
-
return e.map(
|
|
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 be(e) {
|
|
219
219
|
return {
|
|
220
|
-
encode(t,
|
|
221
|
-
const o =
|
|
222
|
-
return
|
|
220
|
+
encode(t, n, r) {
|
|
221
|
+
const o = H(e, r);
|
|
222
|
+
return v(t, n, o);
|
|
223
223
|
},
|
|
224
|
-
decode(t,
|
|
225
|
-
const o =
|
|
226
|
-
return
|
|
224
|
+
decode(t, n, r) {
|
|
225
|
+
const o = H(e, r);
|
|
226
|
+
return $(t, n, o);
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
const
|
|
230
|
+
const L = {
|
|
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
|
+
}, R = {
|
|
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 R = {
|
|
|
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 {
|
|
@@ -283,176 +283,176 @@ const R = {
|
|
|
283
283
|
}
|
|
284
284
|
return BigInt(0);
|
|
285
285
|
}
|
|
286
|
-
},
|
|
286
|
+
}, F = {
|
|
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, 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
|
+
}, K = {
|
|
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
|
+
}, ve = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, B = {
|
|
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" && !ve.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
|
-
}, C = "NaN",
|
|
358
|
+
}, C = "NaN", M = "Infinity", T = "-Infinity", $e = /* @__PURE__ */ new Set([
|
|
359
359
|
C,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
]),
|
|
360
|
+
M,
|
|
361
|
+
T
|
|
362
|
+
]), q = {
|
|
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) ? C : e === 1 / 0 ?
|
|
369
|
+
encode(e, t, n) {
|
|
370
|
+
return Number.isNaN(e) ? C : e === 1 / 0 ? M : e === -1 / 0 ? T : 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
376
|
if (e === C)
|
|
377
377
|
return NaN;
|
|
378
|
-
if (e === T)
|
|
379
|
-
return 1 / 0;
|
|
380
378
|
if (e === M)
|
|
379
|
+
return 1 / 0;
|
|
380
|
+
if (e === T)
|
|
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 ${[...$e].join(", ")}.`
|
|
389
389
|
);
|
|
390
390
|
return NaN;
|
|
391
391
|
}
|
|
392
|
-
},
|
|
392
|
+
}, Ne = [
|
|
393
|
+
L,
|
|
393
394
|
R,
|
|
394
|
-
|
|
395
|
+
F,
|
|
396
|
+
K,
|
|
395
397
|
B,
|
|
396
|
-
q
|
|
397
|
-
z,
|
|
398
|
-
F
|
|
398
|
+
q
|
|
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 je(e, t = {}) {
|
|
401
|
+
for (const n of Ne)
|
|
402
|
+
e.register(n, { override: t.override ?? !1 });
|
|
403
|
+
}
|
|
404
|
+
L.id, // 'date-time'
|
|
405
|
+
R.id, // 'int64'
|
|
406
|
+
F.id, // 'decimal'
|
|
407
|
+
K.id, // 'byte'
|
|
408
|
+
B.id, // 'uuid'
|
|
409
|
+
q.id;
|
|
410
|
+
const se = he();
|
|
411
|
+
je(se);
|
|
412
|
+
const ae = be(se.freeze());
|
|
413
|
+
function Oe(e, t) {
|
|
414
|
+
var r;
|
|
415
|
+
const n = ((r = e.input) == null ? void 0 : r.properties) ?? {};
|
|
416
|
+
return t in n;
|
|
417
|
+
}
|
|
418
|
+
function Ae(e) {
|
|
419
|
+
var n, r;
|
|
420
|
+
const t = (r = (n = e.input) == null ? void 0 : n.properties) == null ? void 0 : r.data;
|
|
421
421
|
return Object.keys((t == null ? void 0 : t.properties) ?? {});
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
var o, i,
|
|
425
|
-
const
|
|
426
|
-
return
|
|
423
|
+
function _e(e, t) {
|
|
424
|
+
var o, i, s;
|
|
425
|
+
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];
|
|
426
|
+
return r !== void 0 ? r : void 0;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
return t === void 0 || e === void 0 ? e :
|
|
428
|
+
function Ee(e, t) {
|
|
429
|
+
return t === void 0 || e === void 0 ? e : ae.decode(e, t);
|
|
430
430
|
}
|
|
431
431
|
function _(e, t) {
|
|
432
|
-
const
|
|
433
|
-
return !
|
|
432
|
+
const n = t.output;
|
|
433
|
+
return !n || Object.keys(n).length === 0 ? e : ae.encode(e, n);
|
|
434
434
|
}
|
|
435
|
-
async function
|
|
436
|
-
const
|
|
437
|
-
(c) =>
|
|
435
|
+
async function Se(e, t, n, r, o, i) {
|
|
436
|
+
const a = Ae(n).map(
|
|
437
|
+
(c) => Ee(i[c], _e(n, c))
|
|
438
438
|
);
|
|
439
|
-
if (
|
|
440
|
-
const c = await t({ session: o.session }),
|
|
441
|
-
return _(
|
|
439
|
+
if (Oe(n, "session") && t) {
|
|
440
|
+
const c = await t({ session: o.session }), u = await e[r](c, ...a);
|
|
441
|
+
return _(u, n);
|
|
442
442
|
}
|
|
443
|
-
if (
|
|
444
|
-
const c = t ? await t(o) : void 0,
|
|
445
|
-
return _(
|
|
443
|
+
if (n.hasCtx) {
|
|
444
|
+
const c = t ? await t(o) : void 0, u = await e[r](c, ...a);
|
|
445
|
+
return _(u, n);
|
|
446
446
|
}
|
|
447
|
-
const
|
|
448
|
-
return _(
|
|
447
|
+
const f = await e[r](...a);
|
|
448
|
+
return _(f, n);
|
|
449
449
|
}
|
|
450
|
-
class
|
|
450
|
+
class ke {
|
|
451
451
|
constructor() {
|
|
452
452
|
this._map = /* @__PURE__ */ new Map();
|
|
453
453
|
}
|
|
454
|
-
set(t,
|
|
455
|
-
this._map.set(t,
|
|
454
|
+
set(t, n) {
|
|
455
|
+
this._map.set(t, n);
|
|
456
456
|
}
|
|
457
457
|
get(t) {
|
|
458
458
|
return this._map.get(t);
|
|
@@ -462,31 +462,31 @@ class nt {
|
|
|
462
462
|
return this._map.has(t);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
function
|
|
466
|
-
return async function(
|
|
467
|
-
const i = o.schemas[
|
|
465
|
+
function Ie(e = []) {
|
|
466
|
+
return async function(n, r, o) {
|
|
467
|
+
const i = o.schemas[n];
|
|
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 "${n}"`
|
|
471
471
|
);
|
|
472
|
-
const
|
|
472
|
+
const s = () => Se(
|
|
473
473
|
o.fns,
|
|
474
474
|
o.createClient,
|
|
475
475
|
i,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
n,
|
|
477
|
+
r.envelope,
|
|
478
|
+
r.domainArgs
|
|
479
479
|
);
|
|
480
480
|
return e.reduceRight(
|
|
481
|
-
(
|
|
482
|
-
|
|
481
|
+
(f, c) => () => c(r, f),
|
|
482
|
+
s
|
|
483
483
|
)();
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Et(e) {
|
|
487
487
|
return e;
|
|
488
488
|
}
|
|
489
|
-
class
|
|
489
|
+
class xe {
|
|
490
490
|
constructor() {
|
|
491
491
|
this.handlers = /* @__PURE__ */ new Map();
|
|
492
492
|
}
|
|
@@ -495,16 +495,16 @@ class Ne {
|
|
|
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, n) {
|
|
499
|
+
const r = this.handlers.get(t) ?? [];
|
|
500
|
+
return this.handlers.set(t, [...r, n]), () => this.off(t, n);
|
|
501
501
|
}
|
|
502
502
|
/** Remove a previously registered handler (no-op if absent). */
|
|
503
|
-
off(t,
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
503
|
+
off(t, n) {
|
|
504
|
+
const r = this.handlers.get(t);
|
|
505
|
+
if (!r)
|
|
506
506
|
return;
|
|
507
|
-
const o =
|
|
507
|
+
const o = r.filter((i) => i !== n);
|
|
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,191 +512,196 @@ class Ne {
|
|
|
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 [n, r] of this.handlers)
|
|
516
|
+
if (Ce(n, t))
|
|
517
|
+
for (const o of r)
|
|
518
518
|
await o(t);
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
function
|
|
522
|
-
const [
|
|
523
|
-
return !(
|
|
521
|
+
function Ce(e, t) {
|
|
522
|
+
const [n, r, o] = e.split(":");
|
|
523
|
+
return !(n !== "*" && n !== t.module || r && r !== "*" && r !== t.method || o && o !== "*" && o !== t.lifecycle);
|
|
524
524
|
}
|
|
525
|
-
function
|
|
526
|
-
for (const
|
|
527
|
-
if (
|
|
528
|
-
for (const [
|
|
529
|
-
t.on(
|
|
525
|
+
function Me(e, t) {
|
|
526
|
+
for (const n of e)
|
|
527
|
+
if (n.eventMapping)
|
|
528
|
+
for (const [r, o] of Object.entries(n.eventMapping))
|
|
529
|
+
t.on(r, o);
|
|
530
530
|
}
|
|
531
|
-
async function
|
|
532
|
-
let
|
|
531
|
+
async function Te(e, t, n) {
|
|
532
|
+
let r = { ...t };
|
|
533
533
|
for (const o of e)
|
|
534
534
|
if (o.createContext) {
|
|
535
|
-
await
|
|
535
|
+
await n.emit({
|
|
536
536
|
module: o.id,
|
|
537
537
|
method: "createContext",
|
|
538
538
|
lifecycle: "start",
|
|
539
|
-
ctx:
|
|
539
|
+
ctx: r
|
|
540
540
|
});
|
|
541
541
|
try {
|
|
542
|
-
const i = await o.createContext(
|
|
543
|
-
|
|
542
|
+
const i = await o.createContext(r);
|
|
543
|
+
r = { ...r, ...i }, await n.emit({
|
|
544
544
|
module: o.id,
|
|
545
545
|
method: "createContext",
|
|
546
546
|
lifecycle: "complete",
|
|
547
|
-
ctx:
|
|
547
|
+
ctx: r
|
|
548
548
|
});
|
|
549
549
|
} catch (i) {
|
|
550
|
-
throw await
|
|
550
|
+
throw await n.emit({
|
|
551
551
|
module: o.id,
|
|
552
552
|
method: "createContext",
|
|
553
553
|
lifecycle: "error",
|
|
554
|
-
ctx:
|
|
554
|
+
ctx: r,
|
|
555
555
|
error: i
|
|
556
556
|
}), i;
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
return
|
|
559
|
+
return r;
|
|
560
560
|
}
|
|
561
|
-
function
|
|
562
|
-
const
|
|
563
|
-
for (;
|
|
564
|
-
const o =
|
|
565
|
-
if (!o ||
|
|
561
|
+
function W(e, t) {
|
|
562
|
+
const n = /* @__PURE__ */ new Set(), r = [e];
|
|
563
|
+
for (; r.length > 0; ) {
|
|
564
|
+
const o = r.pop();
|
|
565
|
+
if (!o || n.has(o))
|
|
566
566
|
continue;
|
|
567
|
-
|
|
567
|
+
n.add(o);
|
|
568
568
|
const i = o.$ref;
|
|
569
569
|
if (typeof i == "string") {
|
|
570
570
|
if (t) {
|
|
571
|
-
const
|
|
572
|
-
if (!
|
|
573
|
-
const
|
|
571
|
+
const p = t[i];
|
|
572
|
+
if (!p) {
|
|
573
|
+
const l = Object.keys(t).join(", ") || "(none)";
|
|
574
574
|
throw new Error(
|
|
575
|
-
`[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${
|
|
575
|
+
`[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${l}`
|
|
576
576
|
);
|
|
577
577
|
}
|
|
578
|
-
|
|
578
|
+
r.push(p);
|
|
579
579
|
}
|
|
580
580
|
continue;
|
|
581
581
|
}
|
|
582
|
-
const
|
|
583
|
-
if (Array.isArray(
|
|
584
|
-
for (const
|
|
585
|
-
typeof
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
588
|
-
for (const
|
|
589
|
-
|
|
590
|
-
const
|
|
591
|
-
if (Array.isArray(
|
|
592
|
-
for (const
|
|
593
|
-
typeof
|
|
582
|
+
const s = o.oneOf;
|
|
583
|
+
if (Array.isArray(s))
|
|
584
|
+
for (const p of s)
|
|
585
|
+
typeof p == "object" && p !== null && r.push(p);
|
|
586
|
+
const a = o.properties;
|
|
587
|
+
if (a)
|
|
588
|
+
for (const p of Object.values(a))
|
|
589
|
+
r.push(p);
|
|
590
|
+
const f = o.items;
|
|
591
|
+
if (Array.isArray(f))
|
|
592
|
+
for (const p of f)
|
|
593
|
+
typeof p == "object" && p !== null && r.push(p);
|
|
594
594
|
else
|
|
595
|
-
typeof
|
|
595
|
+
typeof f == "object" && f !== null && r.push(f);
|
|
596
596
|
const c = o.additionalProperties;
|
|
597
|
-
typeof c == "object" && c !== null &&
|
|
598
|
-
const
|
|
599
|
-
typeof
|
|
597
|
+
typeof c == "object" && c !== null && r.push(c);
|
|
598
|
+
const u = o.propertyNames;
|
|
599
|
+
typeof u == "object" && u !== null && r.push(u);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
const
|
|
603
|
-
function
|
|
602
|
+
const G = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
|
|
603
|
+
function Pe(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: n } = t;
|
|
610
|
+
return typeof n == "string" ? G.has(n) : Array.isArray(n) ? n.every((r) => G.has(r) || r === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((r) => ["string", "number", "boolean"].includes(typeof r)) : !1;
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function ce(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
|
+
Pe
|
|
618
618
|
);
|
|
619
619
|
}
|
|
620
|
-
function
|
|
621
|
-
const t = {},
|
|
620
|
+
function Ue(e) {
|
|
621
|
+
const t = {}, n = (r) => {
|
|
622
622
|
for (const o of ["definitions", "$defs"]) {
|
|
623
|
-
const i =
|
|
623
|
+
const i = r[o];
|
|
624
624
|
if (i)
|
|
625
|
-
for (const [
|
|
626
|
-
const
|
|
627
|
-
t[
|
|
625
|
+
for (const [s, a] of Object.entries(i)) {
|
|
626
|
+
const f = s.startsWith("#/") ? s : `#/${o}/${s}`;
|
|
627
|
+
t[f] = a;
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
|
-
for (const
|
|
632
|
-
r
|
|
631
|
+
for (const r of Object.values(e.schemas))
|
|
632
|
+
n(r.input), n(r.output);
|
|
633
633
|
if (Object.keys(t).length !== 0)
|
|
634
|
-
for (const [
|
|
634
|
+
for (const [r, o] of Object.entries(e.schemas))
|
|
635
635
|
try {
|
|
636
|
-
|
|
636
|
+
W(o.input, t), W(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 "${r}": ${i.message}`
|
|
640
640
|
);
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
function
|
|
644
|
-
const
|
|
643
|
+
function De(e, t) {
|
|
644
|
+
const n = [
|
|
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 && n.push(
|
|
648
|
+
`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.`
|
|
649
|
+
), n.join(" ");
|
|
650
650
|
}
|
|
651
|
-
function
|
|
652
|
-
|
|
653
|
-
const
|
|
651
|
+
function Le(e, t, n) {
|
|
652
|
+
Ue(e);
|
|
653
|
+
const r = {};
|
|
654
654
|
for (const [o, i] of Object.entries(e.schemas)) {
|
|
655
|
-
const
|
|
656
|
-
for (const
|
|
657
|
-
if (
|
|
658
|
-
for (const [
|
|
659
|
-
c[
|
|
660
|
-
const
|
|
655
|
+
const s = (n == null ? void 0 : n[o]) ?? {}, a = i.input.properties ?? {}, f = i.input.required ?? [], c = {}, u = [], p = {};
|
|
656
|
+
for (const h of t)
|
|
657
|
+
if (h.envelope && s[h.id] !== !1)
|
|
658
|
+
for (const [b, le] of Object.entries(h.envelope))
|
|
659
|
+
c[b] = le, p[b] = h.id, u.includes(b) || u.push(b);
|
|
660
|
+
const l = {
|
|
661
661
|
type: "object",
|
|
662
|
-
properties:
|
|
662
|
+
properties: a,
|
|
663
663
|
additionalProperties: !1,
|
|
664
|
-
...
|
|
665
|
-
},
|
|
666
|
-
|
|
664
|
+
...f.length > 0 ? { required: f } : {}
|
|
665
|
+
}, y = i.safe === !0 || ce(i.input), d = i.input.definitions, m = i.input.$defs;
|
|
666
|
+
r[o] = {
|
|
667
667
|
input: {
|
|
668
668
|
type: "object",
|
|
669
|
-
properties: { ...c, data:
|
|
669
|
+
properties: { ...c, data: l },
|
|
670
670
|
required: [
|
|
671
|
-
...
|
|
672
|
-
...
|
|
671
|
+
...u,
|
|
672
|
+
...f.length > 0 ? ["data"] : []
|
|
673
673
|
],
|
|
674
674
|
// BUG-APIGEN-017: reject any property that isn't a declared envelope
|
|
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: De(
|
|
679
679
|
Object.keys(c),
|
|
680
|
-
Object.keys(
|
|
680
|
+
Object.keys(a).length > 0
|
|
681
681
|
),
|
|
682
|
-
...
|
|
683
|
-
...
|
|
682
|
+
...d ? { definitions: d } : {},
|
|
683
|
+
...m ? { $defs: m } : {}
|
|
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": y,
|
|
689
|
+
// DEBT-APIGEN-ENVELOPE-CAPABILITY-UNWIRED-001: field → pluginId map,
|
|
690
|
+
// read by `op-plan.ts`'s `computeEnvelopeFields`. Omitted (not an empty
|
|
691
|
+
// object) when no middleware contributed an envelope field, matching
|
|
692
|
+
// `x-apigen-safe`'s own "absent means nothing to report" convention.
|
|
693
|
+
...Object.keys(p).length > 0 ? { "x-apigen-envelope": p } : {}
|
|
689
694
|
};
|
|
690
695
|
}
|
|
691
|
-
return
|
|
696
|
+
return r;
|
|
692
697
|
}
|
|
693
|
-
const
|
|
698
|
+
const Re = {
|
|
694
699
|
"decimal.js": "Decimal"
|
|
695
700
|
};
|
|
696
|
-
function
|
|
701
|
+
function Fe(e) {
|
|
697
702
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
698
703
|
}
|
|
699
|
-
Object.entries(
|
|
704
|
+
Object.entries(Re).map(([e, t]) => ({
|
|
700
705
|
// Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
|
|
701
706
|
// The module specifier appears inside an absolute path, so we allow any
|
|
702
707
|
// characters between the quote and the specifier, and between the specifier
|
|
@@ -704,127 +709,127 @@ Object.entries(xe).map(([e, t]) => ({
|
|
|
704
709
|
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
705
710
|
// see the doc comment above for why.
|
|
706
711
|
pattern: new RegExp(
|
|
707
|
-
`import\\(["'][^"']*${
|
|
712
|
+
`import\\(["'][^"']*${Fe(e)}[^"']*["']\\)\\.\\w+`,
|
|
708
713
|
"g"
|
|
709
714
|
),
|
|
710
715
|
key: t
|
|
711
716
|
}));
|
|
712
|
-
class
|
|
717
|
+
class P extends Error {
|
|
713
718
|
constructor(t) {
|
|
714
719
|
super(t), this.name = "ConfigurationError";
|
|
715
720
|
}
|
|
716
721
|
}
|
|
717
|
-
function
|
|
722
|
+
function Ke(e) {
|
|
718
723
|
for (const t of e)
|
|
719
|
-
for (const
|
|
720
|
-
const [
|
|
721
|
-
if (
|
|
722
|
-
throw new
|
|
723
|
-
`Middleware "${t.id}" subscribes to its own events via "${
|
|
724
|
+
for (const n of Object.keys(t.eventMapping ?? {})) {
|
|
725
|
+
const [r] = n.split(":");
|
|
726
|
+
if (r !== "*" && r === t.id)
|
|
727
|
+
throw new P(
|
|
728
|
+
`Middleware "${t.id}" subscribes to its own events via "${n}". This would cause infinite recursion.`
|
|
724
729
|
);
|
|
725
730
|
}
|
|
726
731
|
}
|
|
727
|
-
function
|
|
732
|
+
function St(e) {
|
|
728
733
|
const {
|
|
729
734
|
domainSchemas: t,
|
|
730
|
-
middlewares:
|
|
731
|
-
overrides:
|
|
735
|
+
middlewares: n,
|
|
736
|
+
overrides: r = {},
|
|
732
737
|
strict: o = !1
|
|
733
738
|
} = e;
|
|
734
|
-
|
|
735
|
-
for (const c of Object.keys(
|
|
739
|
+
Ke(n);
|
|
740
|
+
for (const c of Object.keys(r))
|
|
736
741
|
if (!(c in t.schemas)) {
|
|
737
|
-
const
|
|
742
|
+
const u = `Override key "${c}" not found in domain schemas.`;
|
|
738
743
|
if (o)
|
|
739
|
-
throw new
|
|
740
|
-
console.warn("[apigen-runtime]",
|
|
744
|
+
throw new P(u);
|
|
745
|
+
console.warn("[apigen-runtime]", u);
|
|
741
746
|
}
|
|
742
|
-
const i = new Set(
|
|
743
|
-
for (const [c,
|
|
744
|
-
for (const
|
|
745
|
-
if (!i.has(
|
|
746
|
-
const
|
|
747
|
+
const i = new Set(n.map((c) => c.id));
|
|
748
|
+
for (const [c, u] of Object.entries(r))
|
|
749
|
+
for (const p of Object.keys(u ?? {}))
|
|
750
|
+
if (!i.has(p)) {
|
|
751
|
+
const l = `Override key "${c}.${p}" does not match any declared middleware id.`;
|
|
747
752
|
if (o)
|
|
748
|
-
throw new
|
|
749
|
-
console.warn("[apigen-runtime]",
|
|
753
|
+
throw new P(l);
|
|
754
|
+
console.warn("[apigen-runtime]", l);
|
|
750
755
|
}
|
|
751
|
-
const
|
|
756
|
+
const s = Le(
|
|
752
757
|
t,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
),
|
|
756
|
-
return
|
|
758
|
+
n,
|
|
759
|
+
r
|
|
760
|
+
), a = new xe();
|
|
761
|
+
return Me(n, a), { schemas: s, createClient: async (c) => Te(n, c, a), dispose: () => a.clear() };
|
|
757
762
|
}
|
|
758
|
-
function
|
|
759
|
-
const t = e.level ?? "info",
|
|
763
|
+
function kt(e = {}) {
|
|
764
|
+
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 };
|
|
760
765
|
if (o === "pretty")
|
|
761
766
|
return i.transport = {
|
|
762
767
|
target: "pino-pretty",
|
|
763
768
|
options: {
|
|
764
|
-
colorize: !
|
|
769
|
+
colorize: !n,
|
|
765
770
|
translateTime: "SYS:HH:MM:ss.l",
|
|
766
771
|
ignore: "pid,hostname",
|
|
767
|
-
...
|
|
772
|
+
...n ? { destination: e.destination, mkdir: !0 } : { destination: 2 }
|
|
768
773
|
}
|
|
769
|
-
},
|
|
770
|
-
const
|
|
771
|
-
return
|
|
774
|
+
}, j(i);
|
|
775
|
+
const s = n ? j.destination({ dest: e.destination, mkdir: !0, sync: !0 }) : j.destination(2);
|
|
776
|
+
return j(i, s);
|
|
777
|
+
}
|
|
778
|
+
function ue(e) {
|
|
779
|
+
return e ? e.type === "array" ? `${ue(e.items)}[]` : e.enum ? "enum" : e.$ref ? String(e.$ref).split("/").pop() || "object" : e.anyOf || e.oneOf ? "union" : e.type ?? "object" : "unknown";
|
|
780
|
+
}
|
|
781
|
+
function Be(e) {
|
|
782
|
+
var a;
|
|
783
|
+
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
|
+
name: f,
|
|
785
|
+
type: ue(c),
|
|
786
|
+
required: o.has(f)
|
|
787
|
+
})), s = i.map((f) => `${f.name}${f.required ? "" : "?"}: ${f.type}`).join(", ");
|
|
788
|
+
return { params: i, text: s };
|
|
772
789
|
}
|
|
773
|
-
function
|
|
774
|
-
return e ? e.type === "array" ? `${oe(e.items)}[]` : e.enum ? "enum" : e.$ref ? String(e.$ref).split("/").pop() || "object" : e.anyOf || e.oneOf ? "union" : e.type ?? "object" : "unknown";
|
|
775
|
-
}
|
|
776
|
-
function ct(e) {
|
|
777
|
-
var s;
|
|
778
|
-
const r = (s = ((e == null ? void 0 : e.input) ?? {}).properties) == null ? void 0 : s.data, n = (r == null ? void 0 : r.properties) ?? {}, o = new Set((r == null ? void 0 : r.required) ?? []), i = Object.entries(n).map(([u, c]) => ({
|
|
779
|
-
name: u,
|
|
780
|
-
type: oe(c),
|
|
781
|
-
required: o.has(u)
|
|
782
|
-
})), a = i.map((u) => `${u.name}${u.required ? "" : "?"}: ${u.type}`).join(", ");
|
|
783
|
-
return { params: i, text: a };
|
|
784
|
-
}
|
|
785
|
-
function Me(e) {
|
|
790
|
+
function qe(e) {
|
|
786
791
|
let t;
|
|
787
|
-
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((n) => n === "number" || n === "integer" || n === "boolean");
|
|
788
793
|
}
|
|
789
|
-
function
|
|
790
|
-
var i,
|
|
791
|
-
const
|
|
792
|
-
for (const [
|
|
793
|
-
const c = o[
|
|
794
|
+
function It(e, t) {
|
|
795
|
+
var i, s;
|
|
796
|
+
const r = ((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(r)) {
|
|
798
|
+
const c = o[a];
|
|
794
799
|
if (typeof c != "string")
|
|
795
800
|
continue;
|
|
796
|
-
const
|
|
797
|
-
if (
|
|
798
|
-
const
|
|
799
|
-
!Number.isNaN(
|
|
801
|
+
const u = qe(f == null ? void 0 : f.type);
|
|
802
|
+
if (u === "number" || u === "integer") {
|
|
803
|
+
const p = Number(c);
|
|
804
|
+
!Number.isNaN(p) && c.trim() !== "" && (o[a] = p);
|
|
800
805
|
} else
|
|
801
|
-
|
|
806
|
+
u === "boolean" && (c === "true" ? o[a] = !0 : c === "false" && (o[a] = !1));
|
|
802
807
|
}
|
|
803
808
|
return o;
|
|
804
809
|
}
|
|
805
|
-
const
|
|
806
|
-
function
|
|
807
|
-
const t = {},
|
|
808
|
-
for (const [i,
|
|
809
|
-
if (typeof
|
|
810
|
-
!
|
|
811
|
-
const
|
|
812
|
-
|
|
810
|
+
const J = /* @__PURE__ */ new Set(["default", "module.exports", "__esModule"]);
|
|
811
|
+
function xt(e) {
|
|
812
|
+
const t = {}, n = (r, o) => {
|
|
813
|
+
for (const [i, s] of Object.entries(r))
|
|
814
|
+
if (typeof s == "function") {
|
|
815
|
+
!J.has(i) && !(i in t) && (t[i] = s);
|
|
816
|
+
const a = s.name;
|
|
817
|
+
a && !(a in t) && (t[a] = s);
|
|
813
818
|
} else
|
|
814
|
-
|
|
819
|
+
s && typeof s == "object" && o < 2 && J.has(i) && n(s, o + 1);
|
|
815
820
|
};
|
|
816
|
-
return
|
|
821
|
+
return n(e, 0), t;
|
|
817
822
|
}
|
|
818
|
-
const
|
|
823
|
+
const Ve = [
|
|
819
824
|
"invalid_argument",
|
|
820
825
|
"unauthenticated",
|
|
821
826
|
"permission_denied",
|
|
822
827
|
"not_found",
|
|
823
828
|
"internal"
|
|
824
829
|
];
|
|
825
|
-
class
|
|
826
|
-
constructor(t,
|
|
827
|
-
super(
|
|
830
|
+
class V extends Error {
|
|
831
|
+
constructor(t, n, r) {
|
|
832
|
+
super(n), this.name = "ApiError", this.code = t, this.details = r, Object.setPrototypeOf(this, new.target.prototype);
|
|
828
833
|
}
|
|
829
834
|
/** Serialise to a plain object suitable for JSON transport. */
|
|
830
835
|
toJSON() {
|
|
@@ -835,81 +840,81 @@ class W extends Error {
|
|
|
835
840
|
return this.details !== void 0 && (t.details = this.details), t;
|
|
836
841
|
}
|
|
837
842
|
}
|
|
838
|
-
function
|
|
839
|
-
return typeof e == "object" && e !== null && e.name === "ApiError" &&
|
|
843
|
+
function ze(e) {
|
|
844
|
+
return typeof e == "object" && e !== null && e.name === "ApiError" && Ve.includes(e.code) && typeof e.toJSON == "function";
|
|
840
845
|
}
|
|
841
|
-
function Y(e, t,
|
|
842
|
-
return e === "before-first-chunk" ? { phase: e, error: t } : { phase: e, error: t, chunksDelivered:
|
|
846
|
+
function Y(e, t, n = 0) {
|
|
847
|
+
return e === "before-first-chunk" ? { phase: e, error: t } : { phase: e, error: t, chunksDelivered: n };
|
|
843
848
|
}
|
|
844
|
-
const
|
|
845
|
-
|
|
849
|
+
const N = new ye({ allErrors: !0 });
|
|
850
|
+
me(N);
|
|
846
851
|
for (const e of [
|
|
847
852
|
U,
|
|
848
|
-
|
|
849
|
-
|
|
853
|
+
D,
|
|
854
|
+
I,
|
|
850
855
|
x,
|
|
851
856
|
"discriminator"
|
|
852
857
|
])
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
function
|
|
858
|
+
N.addKeyword({ keyword: e, valid: !0 });
|
|
859
|
+
N.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
|
|
860
|
+
function fe(e) {
|
|
856
861
|
return e.map(
|
|
857
862
|
(t) => `${t.instancePath || "(root)"} ${t.message ?? "failed schema check"}`
|
|
858
863
|
).join("; ");
|
|
859
864
|
}
|
|
860
|
-
const
|
|
861
|
-
const
|
|
862
|
-
if (
|
|
865
|
+
const Ct = async (e, t) => {
|
|
866
|
+
const n = e.ctx.get(He);
|
|
867
|
+
if (n === void 0)
|
|
863
868
|
return t();
|
|
864
|
-
const
|
|
869
|
+
const r = e.operation.id, o = n[r];
|
|
865
870
|
if (o === void 0)
|
|
866
871
|
return t();
|
|
867
872
|
const i = {
|
|
868
873
|
data: e.domainArgs,
|
|
869
874
|
...e.envelope
|
|
870
|
-
},
|
|
871
|
-
if (!
|
|
872
|
-
const
|
|
873
|
-
throw new
|
|
875
|
+
}, s = N.compile(o.input);
|
|
876
|
+
if (!s(i)) {
|
|
877
|
+
const f = s.errors ?? [];
|
|
878
|
+
throw new V(
|
|
874
879
|
"invalid_argument",
|
|
875
|
-
`Validation failed: ${
|
|
876
|
-
|
|
880
|
+
`Validation failed: ${fe(f)}`,
|
|
881
|
+
f
|
|
877
882
|
);
|
|
878
883
|
}
|
|
879
884
|
return t();
|
|
880
|
-
},
|
|
881
|
-
function
|
|
882
|
-
return async function(
|
|
883
|
-
const o =
|
|
885
|
+
}, He = Symbol("ValidateSchemasToken");
|
|
886
|
+
function We(e) {
|
|
887
|
+
return async function(n, r) {
|
|
888
|
+
const o = n.operation.id, i = e[o];
|
|
884
889
|
if (i === void 0)
|
|
885
|
-
return
|
|
886
|
-
const
|
|
887
|
-
data:
|
|
888
|
-
...
|
|
889
|
-
},
|
|
890
|
-
if (!s
|
|
891
|
-
const c =
|
|
892
|
-
throw new
|
|
890
|
+
return r();
|
|
891
|
+
const s = {
|
|
892
|
+
data: n.domainArgs,
|
|
893
|
+
...n.envelope
|
|
894
|
+
}, a = N.compile(i.input);
|
|
895
|
+
if (!a(s)) {
|
|
896
|
+
const c = a.errors ?? [];
|
|
897
|
+
throw new V(
|
|
893
898
|
"invalid_argument",
|
|
894
|
-
`Validation failed: ${
|
|
899
|
+
`Validation failed: ${fe(c)}`,
|
|
895
900
|
c
|
|
896
901
|
);
|
|
897
902
|
}
|
|
898
|
-
return
|
|
903
|
+
return r();
|
|
899
904
|
};
|
|
900
905
|
}
|
|
901
|
-
function
|
|
906
|
+
function Ge() {
|
|
902
907
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
903
908
|
const t = Math.random() * 16 | 0;
|
|
904
909
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
905
910
|
});
|
|
906
911
|
}
|
|
907
|
-
class
|
|
912
|
+
class Mt {
|
|
908
913
|
constructor(t = {}) {
|
|
909
|
-
var
|
|
914
|
+
var r, o;
|
|
910
915
|
this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = t.defaultTtlMs;
|
|
911
|
-
let
|
|
912
|
-
t.sweepIntervalMs === 0 ?
|
|
916
|
+
let n = null;
|
|
917
|
+
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));
|
|
913
918
|
}
|
|
914
919
|
// ---------------------------------------------------------------------------
|
|
915
920
|
// create — construct + register
|
|
@@ -922,9 +927,9 @@ class lt {
|
|
|
922
927
|
* @param ttlMs - Per-entry TTL override. Falls back to `defaultTtlMs`.
|
|
923
928
|
* @returns `{ instanceId }` — pass this to `dispatch()` / `get()`.
|
|
924
929
|
*/
|
|
925
|
-
create(t,
|
|
926
|
-
const o = new t(...
|
|
927
|
-
return this._store.set(i, { instance: o, expiresAt:
|
|
930
|
+
create(t, n = [], r) {
|
|
931
|
+
const o = new t(...n), i = Ge(), s = r ?? this._defaultTtlMs, a = s !== void 0 ? Date.now() + s : null;
|
|
932
|
+
return this._store.set(i, { instance: o, expiresAt: a }), { instanceId: i };
|
|
928
933
|
}
|
|
929
934
|
// ---------------------------------------------------------------------------
|
|
930
935
|
// get — retrieve a live instance
|
|
@@ -935,16 +940,16 @@ class lt {
|
|
|
935
940
|
* @throws When `instanceId` is unknown or the entry has expired.
|
|
936
941
|
*/
|
|
937
942
|
get(t) {
|
|
938
|
-
const
|
|
939
|
-
if (!
|
|
943
|
+
const n = this._store.get(t);
|
|
944
|
+
if (!n)
|
|
940
945
|
throw new Error(
|
|
941
946
|
`[instance-registry] Unknown instanceId: "${t}"`
|
|
942
947
|
);
|
|
943
|
-
if (
|
|
944
|
-
throw this._evict(t,
|
|
948
|
+
if (n.expiresAt !== null && Date.now() > n.expiresAt)
|
|
949
|
+
throw this._evict(t, n), new Error(
|
|
945
950
|
`[instance-registry] Instance "${t}" has expired`
|
|
946
951
|
);
|
|
947
|
-
return
|
|
952
|
+
return n.instance;
|
|
948
953
|
}
|
|
949
954
|
// ---------------------------------------------------------------------------
|
|
950
955
|
// dispatch — call a method on a live instance
|
|
@@ -955,13 +960,13 @@ class lt {
|
|
|
955
960
|
* @throws When `instanceId` is unknown/expired, or `method` is not a function
|
|
956
961
|
* on the instance.
|
|
957
962
|
*/
|
|
958
|
-
async dispatch(t,
|
|
959
|
-
const o = this.get(t), i = o[
|
|
963
|
+
async dispatch(t, n, r = []) {
|
|
964
|
+
const o = this.get(t), i = o[n];
|
|
960
965
|
if (typeof i != "function")
|
|
961
966
|
throw new Error(
|
|
962
|
-
`[instance-registry] Method "${
|
|
967
|
+
`[instance-registry] Method "${n}" not found on instance "${t}"`
|
|
963
968
|
);
|
|
964
|
-
return i.call(o, ...
|
|
969
|
+
return i.call(o, ...r);
|
|
965
970
|
}
|
|
966
971
|
// ---------------------------------------------------------------------------
|
|
967
972
|
// dispose — explicit teardown
|
|
@@ -971,8 +976,8 @@ class lt {
|
|
|
971
976
|
* instance exposes one (opt-in lifecycle hook).
|
|
972
977
|
*/
|
|
973
978
|
async dispose(t) {
|
|
974
|
-
const
|
|
975
|
-
|
|
979
|
+
const n = this._store.get(t);
|
|
980
|
+
n && (this._store.delete(t), await E(n.instance));
|
|
976
981
|
}
|
|
977
982
|
// ---------------------------------------------------------------------------
|
|
978
983
|
// disposeAll — full teardown
|
|
@@ -984,7 +989,7 @@ class lt {
|
|
|
984
989
|
async disposeAll() {
|
|
985
990
|
this._sweeper !== null && (clearInterval(this._sweeper), this._sweeper = null);
|
|
986
991
|
const t = [...this._store.entries()];
|
|
987
|
-
this._store.clear(), await Promise.all(t.map(([,
|
|
992
|
+
this._store.clear(), await Promise.all(t.map(([, n]) => E(n.instance)));
|
|
988
993
|
}
|
|
989
994
|
// ---------------------------------------------------------------------------
|
|
990
995
|
// size — diagnostic helper
|
|
@@ -998,11 +1003,11 @@ class lt {
|
|
|
998
1003
|
// ---------------------------------------------------------------------------
|
|
999
1004
|
_sweep() {
|
|
1000
1005
|
const t = Date.now();
|
|
1001
|
-
for (const [
|
|
1002
|
-
|
|
1006
|
+
for (const [n, r] of this._store)
|
|
1007
|
+
r.expiresAt !== null && t > r.expiresAt && this._evict(n, r);
|
|
1003
1008
|
}
|
|
1004
|
-
_evict(t,
|
|
1005
|
-
this._store.delete(t), E(
|
|
1009
|
+
_evict(t, n) {
|
|
1010
|
+
this._store.delete(t), E(n.instance);
|
|
1006
1011
|
}
|
|
1007
1012
|
}
|
|
1008
1013
|
async function E(e) {
|
|
@@ -1011,14 +1016,14 @@ async function E(e) {
|
|
|
1011
1016
|
typeof t == "function" && await t.call(e);
|
|
1012
1017
|
}
|
|
1013
1018
|
}
|
|
1014
|
-
function
|
|
1015
|
-
const { produce: t, signal:
|
|
1019
|
+
function Tt(e) {
|
|
1020
|
+
const { produce: t, signal: n } = e, r = n ?? new AbortController().signal;
|
|
1016
1021
|
return {
|
|
1017
1022
|
[Symbol.asyncIterator]() {
|
|
1018
|
-
const o = t(
|
|
1023
|
+
const o = t(r);
|
|
1019
1024
|
return {
|
|
1020
1025
|
async next() {
|
|
1021
|
-
return
|
|
1026
|
+
return r.aborted ? (await o.return(void 0), { done: !0, value: void 0 }) : o.next();
|
|
1022
1027
|
},
|
|
1023
1028
|
async return(i) {
|
|
1024
1029
|
return await o.return(i), { done: !0, value: void 0 };
|
|
@@ -1030,183 +1035,183 @@ function yt(e) {
|
|
|
1030
1035
|
}
|
|
1031
1036
|
};
|
|
1032
1037
|
}
|
|
1033
|
-
async function
|
|
1038
|
+
async function Pt(e) {
|
|
1034
1039
|
const t = [];
|
|
1035
|
-
for await (const
|
|
1036
|
-
t.push(
|
|
1040
|
+
for await (const n of e)
|
|
1041
|
+
t.push(n);
|
|
1037
1042
|
return t;
|
|
1038
1043
|
}
|
|
1039
|
-
async function
|
|
1044
|
+
async function Ut(e) {
|
|
1040
1045
|
const t = [];
|
|
1041
1046
|
try {
|
|
1042
|
-
for await (const
|
|
1043
|
-
t.push(
|
|
1047
|
+
for await (const n of e)
|
|
1048
|
+
t.push(n);
|
|
1044
1049
|
return { ok: !0, chunks: t };
|
|
1045
|
-
} catch (
|
|
1046
|
-
const
|
|
1050
|
+
} catch (n) {
|
|
1051
|
+
const r = ze(n) ? n : new V(
|
|
1047
1052
|
"internal",
|
|
1048
|
-
|
|
1053
|
+
n instanceof Error ? n.message : String(n)
|
|
1049
1054
|
);
|
|
1050
1055
|
return t.length === 0 ? {
|
|
1051
1056
|
ok: !1,
|
|
1052
|
-
carrier: Y("before-first-chunk",
|
|
1057
|
+
carrier: Y("before-first-chunk", r)
|
|
1053
1058
|
} : {
|
|
1054
1059
|
ok: !1,
|
|
1055
|
-
carrier: Y("after-first-chunk",
|
|
1060
|
+
carrier: Y("after-first-chunk", r, t.length)
|
|
1056
1061
|
};
|
|
1057
1062
|
}
|
|
1058
1063
|
}
|
|
1059
|
-
function
|
|
1064
|
+
function Dt(e) {
|
|
1060
1065
|
return e !== null && typeof e == "object" && Symbol.asyncIterator in e;
|
|
1061
1066
|
}
|
|
1062
|
-
class
|
|
1063
|
-
constructor(t,
|
|
1064
|
-
super(
|
|
1067
|
+
class g extends Error {
|
|
1068
|
+
constructor(t, n) {
|
|
1069
|
+
super(n), this.name = "UnionCodecError", this.code = t;
|
|
1065
1070
|
}
|
|
1066
1071
|
}
|
|
1067
1072
|
function S(e) {
|
|
1068
1073
|
const t = e.discriminator;
|
|
1069
1074
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
1070
1075
|
return;
|
|
1071
|
-
const
|
|
1072
|
-
if (typeof
|
|
1076
|
+
const n = t;
|
|
1077
|
+
if (typeof n.propertyName != "string")
|
|
1073
1078
|
return;
|
|
1074
|
-
const
|
|
1075
|
-
if (!(
|
|
1079
|
+
const r = n.mapping;
|
|
1080
|
+
if (!(r === null || typeof r != "object" || Array.isArray(r)))
|
|
1076
1081
|
return {
|
|
1077
|
-
propertyName:
|
|
1078
|
-
mapping:
|
|
1082
|
+
propertyName: n.propertyName,
|
|
1083
|
+
mapping: r
|
|
1079
1084
|
};
|
|
1080
1085
|
}
|
|
1081
|
-
function
|
|
1082
|
-
const
|
|
1083
|
-
if (typeof
|
|
1084
|
-
const
|
|
1085
|
-
if (
|
|
1086
|
-
return
|
|
1086
|
+
function pe(e, t) {
|
|
1087
|
+
const n = e[D];
|
|
1088
|
+
if (typeof n == "string") {
|
|
1089
|
+
const r = t.registry.get(n);
|
|
1090
|
+
if (r)
|
|
1091
|
+
return r;
|
|
1087
1092
|
}
|
|
1088
1093
|
return t.registry.resolve(e);
|
|
1089
1094
|
}
|
|
1090
|
-
function
|
|
1091
|
-
const
|
|
1092
|
-
return
|
|
1095
|
+
function Je(e, t, n) {
|
|
1096
|
+
const r = pe(t, n);
|
|
1097
|
+
return r ? r.encode(e, t, n) : e;
|
|
1093
1098
|
}
|
|
1094
|
-
function
|
|
1095
|
-
const
|
|
1096
|
-
return
|
|
1099
|
+
function Ye(e, t, n) {
|
|
1100
|
+
const r = pe(t, n);
|
|
1101
|
+
return r ? r.decode(e, t, n) : e;
|
|
1097
1102
|
}
|
|
1098
|
-
function
|
|
1099
|
-
const { id: t, schema:
|
|
1103
|
+
function Qe(e) {
|
|
1104
|
+
const { id: t, schema: n } = e;
|
|
1100
1105
|
return {
|
|
1101
1106
|
id: t,
|
|
1102
1107
|
kind: "union",
|
|
1103
|
-
schema:
|
|
1108
|
+
schema: n,
|
|
1104
1109
|
/**
|
|
1105
1110
|
* Structural ownership test: the node carries both `oneOf` (non-empty array)
|
|
1106
1111
|
* and `discriminator.propertyName`. The `x-apigen-logical:"union"` hint
|
|
1107
1112
|
* accelerates the match but is advisory — the structure is authoritative.
|
|
1108
1113
|
*/
|
|
1109
|
-
matches(
|
|
1110
|
-
if (
|
|
1114
|
+
matches(r) {
|
|
1115
|
+
if (r[U] === "union")
|
|
1111
1116
|
return !0;
|
|
1112
|
-
const o =
|
|
1113
|
-
return !Array.isArray(o) || o.length === 0 ? !1 : S(
|
|
1117
|
+
const o = r.oneOf;
|
|
1118
|
+
return !Array.isArray(o) || o.length === 0 ? !1 : S(r) !== void 0;
|
|
1114
1119
|
},
|
|
1115
|
-
encode(
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
1118
|
-
throw new
|
|
1120
|
+
encode(r, o, i) {
|
|
1121
|
+
const s = S(o);
|
|
1122
|
+
if (!s)
|
|
1123
|
+
throw new g(
|
|
1119
1124
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1120
1125
|
`[${t}] schema node at "${i.path}" has no discriminator.propertyName; cannot dispatch union branch.`
|
|
1121
1126
|
);
|
|
1122
|
-
const { propertyName:
|
|
1127
|
+
const { propertyName: a, mapping: f } = s, c = r[a];
|
|
1123
1128
|
if (c == null)
|
|
1124
|
-
throw new
|
|
1129
|
+
throw new g(
|
|
1125
1130
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1126
|
-
`[${t}] value at "${i.path}" is missing the discriminator property "${
|
|
1131
|
+
`[${t}] value at "${i.path}" is missing the discriminator property "${a}".`
|
|
1127
1132
|
);
|
|
1128
|
-
const
|
|
1129
|
-
if (!
|
|
1130
|
-
throw new
|
|
1133
|
+
const u = String(c), p = f[u];
|
|
1134
|
+
if (!p)
|
|
1135
|
+
throw new g(
|
|
1131
1136
|
"E_UNION_UNKNOWN_TAG",
|
|
1132
|
-
`[${t}] discriminator tag "${
|
|
1137
|
+
`[${t}] discriminator tag "${u}" at "${i.path}" is not in the mapping (known: ${Object.keys(f).join(", ")}).`
|
|
1133
1138
|
);
|
|
1134
|
-
const
|
|
1135
|
-
return
|
|
1139
|
+
const l = i.resolve(p);
|
|
1140
|
+
return Je(r, l, {
|
|
1136
1141
|
...i,
|
|
1137
|
-
path: `${i.path}[${
|
|
1142
|
+
path: `${i.path}[${u}]`
|
|
1138
1143
|
});
|
|
1139
1144
|
},
|
|
1140
|
-
decode(
|
|
1141
|
-
if (
|
|
1142
|
-
let
|
|
1143
|
-
throw
|
|
1145
|
+
decode(r, o, i) {
|
|
1146
|
+
if (r === null || typeof r != "object" || Array.isArray(r)) {
|
|
1147
|
+
let d;
|
|
1148
|
+
throw r === null ? d = "null" : Array.isArray(r) ? d = "array" : d = typeof r, new g(
|
|
1144
1149
|
"E_UNION_INVALID_WIRE",
|
|
1145
|
-
`[${t}] expected a JSON object on the wire at "${i.path}", got ${
|
|
1150
|
+
`[${t}] expected a JSON object on the wire at "${i.path}", got ${d}.`
|
|
1146
1151
|
);
|
|
1147
1152
|
}
|
|
1148
|
-
const
|
|
1149
|
-
if (!
|
|
1150
|
-
throw new
|
|
1153
|
+
const s = r, a = S(o);
|
|
1154
|
+
if (!a)
|
|
1155
|
+
throw new g(
|
|
1151
1156
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1152
1157
|
`[${t}] schema node at "${i.path}" has no discriminator.propertyName; cannot dispatch union branch.`
|
|
1153
1158
|
);
|
|
1154
|
-
const { propertyName:
|
|
1155
|
-
if (
|
|
1156
|
-
throw new
|
|
1159
|
+
const { propertyName: f, mapping: c } = a, u = s[f];
|
|
1160
|
+
if (u == null)
|
|
1161
|
+
throw new g(
|
|
1157
1162
|
"E_UNION_NO_DISCRIMINATOR",
|
|
1158
|
-
`[${t}] wire object at "${i.path}" is missing the discriminator property "${
|
|
1163
|
+
`[${t}] wire object at "${i.path}" is missing the discriminator property "${f}".`
|
|
1159
1164
|
);
|
|
1160
|
-
const
|
|
1161
|
-
if (!
|
|
1162
|
-
throw new
|
|
1165
|
+
const p = String(u), l = c[p];
|
|
1166
|
+
if (!l)
|
|
1167
|
+
throw new g(
|
|
1163
1168
|
"E_UNION_UNKNOWN_TAG",
|
|
1164
|
-
`[${t}] discriminator tag "${
|
|
1169
|
+
`[${t}] discriminator tag "${p}" on the wire at "${i.path}" is not in the mapping (known: ${Object.keys(c).join(", ")}).`
|
|
1165
1170
|
);
|
|
1166
|
-
const
|
|
1167
|
-
return
|
|
1171
|
+
const y = i.resolve(l);
|
|
1172
|
+
return Ye(r, y, {
|
|
1168
1173
|
...i,
|
|
1169
|
-
path: `${i.path}[${
|
|
1174
|
+
path: `${i.path}[${p}]`
|
|
1170
1175
|
});
|
|
1171
1176
|
}
|
|
1172
1177
|
};
|
|
1173
1178
|
}
|
|
1174
|
-
const
|
|
1175
|
-
class
|
|
1176
|
-
constructor(t,
|
|
1177
|
-
super(
|
|
1179
|
+
const Xe = "x-apigen-instances";
|
|
1180
|
+
class O extends Error {
|
|
1181
|
+
constructor(t, n) {
|
|
1182
|
+
super(n), this.name = "NominalCodecError", this.code = t;
|
|
1178
1183
|
}
|
|
1179
1184
|
}
|
|
1180
1185
|
function Q(e) {
|
|
1181
1186
|
const t = e.properties;
|
|
1182
1187
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
1183
1188
|
}
|
|
1184
|
-
function
|
|
1189
|
+
function Ze(e) {
|
|
1185
1190
|
const t = e.required;
|
|
1186
|
-
return Array.isArray(t) ? t.filter((
|
|
1191
|
+
return Array.isArray(t) ? t.filter((n) => typeof n == "string") : [];
|
|
1187
1192
|
}
|
|
1188
|
-
function X(e, t,
|
|
1193
|
+
function X(e, t, n) {
|
|
1189
1194
|
if (t) {
|
|
1190
|
-
const
|
|
1191
|
-
if (
|
|
1192
|
-
return
|
|
1195
|
+
const r = n.registry.resolve(t);
|
|
1196
|
+
if (r)
|
|
1197
|
+
return r.encode(e, t, n);
|
|
1193
1198
|
}
|
|
1194
1199
|
return e;
|
|
1195
1200
|
}
|
|
1196
|
-
function
|
|
1201
|
+
function et(e, t, n) {
|
|
1197
1202
|
if (t) {
|
|
1198
|
-
const
|
|
1199
|
-
if (
|
|
1200
|
-
return
|
|
1203
|
+
const r = n.registry.resolve(t);
|
|
1204
|
+
if (r)
|
|
1205
|
+
return r.decode(e, t, n);
|
|
1201
1206
|
}
|
|
1202
1207
|
return e;
|
|
1203
1208
|
}
|
|
1204
|
-
function
|
|
1205
|
-
const { id: t, schema:
|
|
1209
|
+
function tt(e) {
|
|
1210
|
+
const { id: t, schema: n, ctor: r } = e;
|
|
1206
1211
|
return {
|
|
1207
1212
|
id: t,
|
|
1208
1213
|
kind: "nominal",
|
|
1209
|
-
schema:
|
|
1214
|
+
schema: n,
|
|
1210
1215
|
/**
|
|
1211
1216
|
* Structural ownership test: the node advertises `x-apigen-logical:'nominal'`
|
|
1212
1217
|
* or carries an `x-apigen-codec` matching this codec's id. Per
|
|
@@ -1215,117 +1220,117 @@ function Ke(e) {
|
|
|
1215
1220
|
* handled by the transcoder walk, not by this cheap test.
|
|
1216
1221
|
*/
|
|
1217
1222
|
matches(o) {
|
|
1218
|
-
return o[U] === "nominal" ? !0 : o[
|
|
1223
|
+
return o[U] === "nominal" ? !0 : o[D] === t;
|
|
1219
1224
|
},
|
|
1220
|
-
encode(o, i,
|
|
1225
|
+
encode(o, i, s) {
|
|
1221
1226
|
if (o === null || typeof o != "object")
|
|
1222
1227
|
return o;
|
|
1223
|
-
if (
|
|
1224
|
-
if (
|
|
1225
|
-
throw new
|
|
1228
|
+
if (s.seen.has(o)) {
|
|
1229
|
+
if (s.mode === "strict")
|
|
1230
|
+
throw new O(
|
|
1226
1231
|
"E_NOMINAL_CYCLE",
|
|
1227
|
-
`[${t}] cycle detected at "${
|
|
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.`
|
|
1228
1233
|
);
|
|
1229
1234
|
return null;
|
|
1230
1235
|
}
|
|
1231
|
-
|
|
1236
|
+
s.seen.add(o);
|
|
1232
1237
|
try {
|
|
1233
|
-
const
|
|
1238
|
+
const a = Q(i), f = typeof i[x] == "string" ? i[x] : "toJSON", c = o[f];
|
|
1234
1239
|
if (typeof c == "function") {
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
const
|
|
1238
|
-
for (const [h,
|
|
1239
|
-
|
|
1240
|
+
const d = c.call(o);
|
|
1241
|
+
if (d !== null && typeof d == "object" && !Array.isArray(d)) {
|
|
1242
|
+
const m = {};
|
|
1243
|
+
for (const [h, b] of Object.entries(
|
|
1244
|
+
d
|
|
1240
1245
|
))
|
|
1241
|
-
|
|
1242
|
-
...
|
|
1243
|
-
path: `${
|
|
1246
|
+
m[h] = X(b, a[h], {
|
|
1247
|
+
...s,
|
|
1248
|
+
path: `${s.path}/${h}`
|
|
1244
1249
|
});
|
|
1245
|
-
return
|
|
1250
|
+
return m;
|
|
1246
1251
|
}
|
|
1247
|
-
return
|
|
1252
|
+
return d;
|
|
1248
1253
|
}
|
|
1249
|
-
const
|
|
1250
|
-
for (const
|
|
1251
|
-
const
|
|
1252
|
-
|
|
1253
|
-
...
|
|
1254
|
-
path: `${
|
|
1254
|
+
const u = {}, p = Object.keys(a), l = o, y = p.length > 0 ? p : Object.keys(l);
|
|
1255
|
+
for (const d of y) {
|
|
1256
|
+
const m = l[d];
|
|
1257
|
+
m !== void 0 && (u[d] = X(m, a[d], {
|
|
1258
|
+
...s,
|
|
1259
|
+
path: `${s.path}/${d}`
|
|
1255
1260
|
}));
|
|
1256
1261
|
}
|
|
1257
|
-
return
|
|
1262
|
+
return u;
|
|
1258
1263
|
} finally {
|
|
1259
|
-
|
|
1264
|
+
s.seen.delete(o);
|
|
1260
1265
|
}
|
|
1261
1266
|
},
|
|
1262
|
-
decode(o, i,
|
|
1267
|
+
decode(o, i, s) {
|
|
1263
1268
|
if (o === null || typeof o != "object" || Array.isArray(o)) {
|
|
1264
|
-
let
|
|
1265
|
-
throw o === null ?
|
|
1269
|
+
let u;
|
|
1270
|
+
throw o === null ? u = "null" : Array.isArray(o) ? u = "array" : u = typeof o, new O(
|
|
1266
1271
|
"E_NOMINAL_INVALID_WIRE",
|
|
1267
|
-
`[${t}] expected a JSON object on the wire at "${
|
|
1272
|
+
`[${t}] expected a JSON object on the wire at "${s.path}", got ${u}.`
|
|
1268
1273
|
);
|
|
1269
1274
|
}
|
|
1270
|
-
const
|
|
1271
|
-
for (const
|
|
1272
|
-
if (!(
|
|
1273
|
-
throw new
|
|
1275
|
+
const a = o;
|
|
1276
|
+
for (const u of Ze(i))
|
|
1277
|
+
if (!(u in a))
|
|
1278
|
+
throw new O(
|
|
1274
1279
|
"E_NOMINAL_INVALID_WIRE",
|
|
1275
|
-
`[${t}] required field "${
|
|
1280
|
+
`[${t}] required field "${u}" missing on the wire at "${s.path}".`
|
|
1276
1281
|
);
|
|
1277
|
-
if (i[
|
|
1278
|
-
throw new
|
|
1282
|
+
if (i[Xe] === !1)
|
|
1283
|
+
throw new O(
|
|
1279
1284
|
"E_NOMINAL_NONRECONSTRUCTABLE",
|
|
1280
1285
|
`[${t}] is encode-only: the extractor marked it non-reconstructable (x-apigen-instances:false). It cannot be decoded back to a live instance.`
|
|
1281
1286
|
);
|
|
1282
|
-
const
|
|
1283
|
-
for (const [
|
|
1284
|
-
c[
|
|
1285
|
-
...
|
|
1286
|
-
path: `${
|
|
1287
|
+
const f = Q(i), c = {};
|
|
1288
|
+
for (const [u, p] of Object.entries(a))
|
|
1289
|
+
c[u] = et(p, f[u], {
|
|
1290
|
+
...s,
|
|
1291
|
+
path: `${s.path}/${u}`
|
|
1287
1292
|
});
|
|
1288
|
-
if (
|
|
1289
|
-
const
|
|
1290
|
-
if (typeof
|
|
1291
|
-
return
|
|
1292
|
-
|
|
1293
|
+
if (r) {
|
|
1294
|
+
const u = typeof i[I] == "string" ? i[I] : "fromJSON", p = r[u];
|
|
1295
|
+
if (typeof p == "function")
|
|
1296
|
+
return p.call(
|
|
1297
|
+
r,
|
|
1293
1298
|
c
|
|
1294
1299
|
);
|
|
1295
|
-
const
|
|
1296
|
-
return new
|
|
1300
|
+
const l = r;
|
|
1301
|
+
return new l(c);
|
|
1297
1302
|
}
|
|
1298
1303
|
return c;
|
|
1299
1304
|
}
|
|
1300
1305
|
};
|
|
1301
1306
|
}
|
|
1302
|
-
const
|
|
1307
|
+
const nt = [
|
|
1308
|
+
L,
|
|
1303
1309
|
R,
|
|
1304
|
-
|
|
1310
|
+
F,
|
|
1311
|
+
K,
|
|
1305
1312
|
B,
|
|
1306
|
-
q
|
|
1307
|
-
|
|
1308
|
-
F
|
|
1309
|
-
], Je = {
|
|
1313
|
+
q
|
|
1314
|
+
], rt = {
|
|
1310
1315
|
type: "object",
|
|
1311
1316
|
"x-apigen-logical": "nominal",
|
|
1312
1317
|
"x-apigen-codec": "ts.NominalSentinel"
|
|
1313
|
-
}, Z =
|
|
1318
|
+
}, Z = tt({
|
|
1314
1319
|
id: "ts.NominalSentinel",
|
|
1315
|
-
schema:
|
|
1316
|
-
}),
|
|
1320
|
+
schema: rt
|
|
1321
|
+
}), ot = {
|
|
1317
1322
|
oneOf: [],
|
|
1318
1323
|
discriminator: { propertyName: "kind", mapping: {} },
|
|
1319
1324
|
"x-apigen-logical": "union",
|
|
1320
1325
|
"x-apigen-codec": "ts.UnionSentinel"
|
|
1321
|
-
}, ee =
|
|
1326
|
+
}, ee = Qe({
|
|
1322
1327
|
id: "ts.UnionSentinel",
|
|
1323
|
-
schema:
|
|
1328
|
+
schema: ot
|
|
1324
1329
|
});
|
|
1325
|
-
function
|
|
1330
|
+
function it() {
|
|
1326
1331
|
const e = [
|
|
1327
1332
|
// 6 well-known scalars
|
|
1328
|
-
...
|
|
1333
|
+
...nt.map((t) => [
|
|
1329
1334
|
t.id,
|
|
1330
1335
|
t
|
|
1331
1336
|
]),
|
|
@@ -1336,19 +1341,19 @@ function Ge() {
|
|
|
1336
1341
|
];
|
|
1337
1342
|
return Object.freeze(new Map(e));
|
|
1338
1343
|
}
|
|
1339
|
-
const
|
|
1344
|
+
const Lt = Object.freeze({
|
|
1340
1345
|
host: "ts",
|
|
1341
|
-
logicalTypeVersion:
|
|
1342
|
-
codecs:
|
|
1346
|
+
logicalTypeVersion: ge,
|
|
1347
|
+
codecs: it()
|
|
1343
1348
|
});
|
|
1344
|
-
function
|
|
1349
|
+
function Rt(e, t, n) {
|
|
1345
1350
|
var i;
|
|
1346
|
-
const
|
|
1347
|
-
(
|
|
1351
|
+
const r = typeof ((i = t == null ? void 0 : t.input) == null ? void 0 : i.description) == "string" ? t.input.description : void 0, o = [n, r].filter(
|
|
1352
|
+
(s) => typeof s == "string" && s.length > 0
|
|
1348
1353
|
);
|
|
1349
1354
|
return o.length > 0 ? o.join(" — ") : e;
|
|
1350
1355
|
}
|
|
1351
|
-
function
|
|
1356
|
+
function Ft(e) {
|
|
1352
1357
|
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length === 0)
|
|
1353
1358
|
return { outputSchema: void 0, wrapped: !1 };
|
|
1354
1359
|
const t = e;
|
|
@@ -1361,38 +1366,240 @@ function vt(e) {
|
|
|
1361
1366
|
wrapped: !0
|
|
1362
1367
|
};
|
|
1363
1368
|
}
|
|
1364
|
-
function
|
|
1369
|
+
function Kt(e, t) {
|
|
1365
1370
|
return e ? { result: t } : t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1366
1371
|
}
|
|
1372
|
+
function te(e) {
|
|
1373
|
+
return e.words.join("-");
|
|
1374
|
+
}
|
|
1375
|
+
function ne(e) {
|
|
1376
|
+
return e.words.map(ft).join("");
|
|
1377
|
+
}
|
|
1378
|
+
function re(e) {
|
|
1379
|
+
return e.words.join("_");
|
|
1380
|
+
}
|
|
1381
|
+
function st(e, t = {}) {
|
|
1382
|
+
var l, y;
|
|
1383
|
+
const n = [e.namespace, ...e.path], r = e.safe || ce(e.input) ? "GET" : "POST", o = ((y = (l = t.http) == null ? void 0 : l.verb) == null ? void 0 : y[e.id]) ?? r, i = "/" + n.map((d) => te(d)).join("/"), s = n.map((d) => re(d)).join("_"), f = n.map((d) => re(d)).slice(0, -1).join("."), c = ne(n[n.length - 2] ?? n[0]), u = ne(n[n.length - 1]), p = n.map((d) => te(d));
|
|
1384
|
+
return {
|
|
1385
|
+
http: { verb: o, route: i },
|
|
1386
|
+
mcp: { name: s },
|
|
1387
|
+
grpc: { package: f, service: c, method: u },
|
|
1388
|
+
cli: { path: p }
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
function at(e, t) {
|
|
1392
|
+
return `x-${e}-${t}`;
|
|
1393
|
+
}
|
|
1394
|
+
function ct(e, t) {
|
|
1395
|
+
return `--${e}-${t}`;
|
|
1396
|
+
}
|
|
1397
|
+
function ut(e, t) {
|
|
1398
|
+
const n = (r) => r.toUpperCase().replace(/-/g, "_");
|
|
1399
|
+
return e === "adhd" ? `APIGEN_${n(t)}` : `APIGEN_${n(e)}_${n(t)}`;
|
|
1400
|
+
}
|
|
1401
|
+
function ft(e) {
|
|
1402
|
+
return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
|
|
1403
|
+
}
|
|
1404
|
+
function de(e) {
|
|
1405
|
+
return e.anyOf ?? e.oneOf;
|
|
1406
|
+
}
|
|
1407
|
+
function pt(e) {
|
|
1408
|
+
if (!e)
|
|
1409
|
+
return !1;
|
|
1410
|
+
if (e.type === "array" || e.type === "object")
|
|
1411
|
+
return !0;
|
|
1412
|
+
const t = de(e);
|
|
1413
|
+
if (t) {
|
|
1414
|
+
const n = t.filter((r) => r.type !== "null");
|
|
1415
|
+
return n.length > 0 && n.every((r) => r.type === "array" || r.type === "object");
|
|
1416
|
+
}
|
|
1417
|
+
return !1;
|
|
1418
|
+
}
|
|
1419
|
+
function dt(e) {
|
|
1420
|
+
if (!e)
|
|
1421
|
+
return !1;
|
|
1422
|
+
if (e.type === "boolean")
|
|
1423
|
+
return !0;
|
|
1424
|
+
const t = de(e);
|
|
1425
|
+
if (t) {
|
|
1426
|
+
const n = t.filter((r) => r.type !== "null");
|
|
1427
|
+
return n.length > 0 && n.every((r) => r.type === "boolean");
|
|
1428
|
+
}
|
|
1429
|
+
return !1;
|
|
1430
|
+
}
|
|
1431
|
+
function lt(e) {
|
|
1432
|
+
return e.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
1433
|
+
}
|
|
1434
|
+
function yt(e) {
|
|
1435
|
+
var o, i;
|
|
1436
|
+
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) ?? [];
|
|
1437
|
+
return { props: n, required: r };
|
|
1438
|
+
}
|
|
1439
|
+
function oe(e) {
|
|
1440
|
+
return typeof e.handler == "function";
|
|
1441
|
+
}
|
|
1442
|
+
function mt(e) {
|
|
1443
|
+
var o;
|
|
1444
|
+
const t = ((o = e.input) == null ? void 0 : o.properties) ?? {}, n = e["x-apigen-envelope"], r = [];
|
|
1445
|
+
for (const i of Object.keys(t)) {
|
|
1446
|
+
if (i === "data")
|
|
1447
|
+
continue;
|
|
1448
|
+
const s = (n == null ? void 0 : n[i]) ?? "adhd", a = at(s, i);
|
|
1449
|
+
r.push({
|
|
1450
|
+
field: i,
|
|
1451
|
+
pluginId: s,
|
|
1452
|
+
httpHeader: a,
|
|
1453
|
+
mcpMetaKey: a,
|
|
1454
|
+
cliFlag: ct(s, i),
|
|
1455
|
+
envVar: ut(s, i)
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
return r;
|
|
1459
|
+
}
|
|
1460
|
+
function ht(e, t) {
|
|
1461
|
+
const n = /* @__PURE__ */ new Map(), { props: r } = yt(e);
|
|
1462
|
+
for (const [o, i] of Object.entries(r)) {
|
|
1463
|
+
let s = "string";
|
|
1464
|
+
dt(i) ? s = "boolean" : pt(i) && (s = "json"), n.set(lt(o), {
|
|
1465
|
+
camelKey: o,
|
|
1466
|
+
kind: "domain",
|
|
1467
|
+
valueKind: s
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
for (const o of t) {
|
|
1471
|
+
const i = o.cliFlag.replace(/^--/, "");
|
|
1472
|
+
n.set(i, {
|
|
1473
|
+
camelKey: o.field,
|
|
1474
|
+
kind: "envelope",
|
|
1475
|
+
valueKind: "string",
|
|
1476
|
+
envVar: o.envVar
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
return n;
|
|
1480
|
+
}
|
|
1481
|
+
function Bt(e) {
|
|
1482
|
+
const { op: t, schema: n, transport: r, projection: o } = e, i = st(t, o), s = n ? mt(n) : [], a = n ? ht(n, s) : /* @__PURE__ */ new Map(), f = n ? Be(n).params : void 0, c = {
|
|
1483
|
+
op: t,
|
|
1484
|
+
transport: r,
|
|
1485
|
+
http: i.http,
|
|
1486
|
+
mcp: i.mcp,
|
|
1487
|
+
cli: i.cli,
|
|
1488
|
+
grpc: i.grpc,
|
|
1489
|
+
params: f,
|
|
1490
|
+
envelope: s,
|
|
1491
|
+
cliFlags: a,
|
|
1492
|
+
streaming: t.streaming,
|
|
1493
|
+
isMount: oe(t)
|
|
1494
|
+
};
|
|
1495
|
+
if (oe(t)) {
|
|
1496
|
+
const u = t.handler;
|
|
1497
|
+
c.mountHandler = async (p) => u(p);
|
|
1498
|
+
}
|
|
1499
|
+
return c;
|
|
1500
|
+
}
|
|
1501
|
+
function qt(e) {
|
|
1502
|
+
const t = e.usePlugins;
|
|
1503
|
+
return Array.isArray(t) ? t : [];
|
|
1504
|
+
}
|
|
1505
|
+
function Vt(e) {
|
|
1506
|
+
const t = e.useOptions;
|
|
1507
|
+
return t && typeof t == "object" ? t : {};
|
|
1508
|
+
}
|
|
1509
|
+
function gt(e) {
|
|
1510
|
+
return async function(n, r) {
|
|
1511
|
+
const o = Object.assign(n, { data: n.domainArgs });
|
|
1512
|
+
return await e.layer(o, r);
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function zt(e, t) {
|
|
1516
|
+
var r;
|
|
1517
|
+
const n = [];
|
|
1518
|
+
for (const o of t) {
|
|
1519
|
+
const i = (r = o.capabilities) == null ? void 0 : r.layer;
|
|
1520
|
+
i && n.push(gt(i));
|
|
1521
|
+
}
|
|
1522
|
+
return n.push(We(e)), Ie(n);
|
|
1523
|
+
}
|
|
1524
|
+
function wt() {
|
|
1525
|
+
const e = /* @__PURE__ */ new Map();
|
|
1526
|
+
return {
|
|
1527
|
+
get: (t) => e.get(t),
|
|
1528
|
+
set: (t, n) => {
|
|
1529
|
+
e.set(t, n);
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
const bt = {
|
|
1534
|
+
input: {
|
|
1535
|
+
type: "object",
|
|
1536
|
+
properties: { data: { type: "object", properties: {} } }
|
|
1537
|
+
},
|
|
1538
|
+
output: {}
|
|
1539
|
+
};
|
|
1540
|
+
async function Ht(e, t, n, r) {
|
|
1541
|
+
const o = {
|
|
1542
|
+
...n,
|
|
1543
|
+
operation: { id: e.op.id },
|
|
1544
|
+
ctx: new ke()
|
|
1545
|
+
};
|
|
1546
|
+
if (e.isMount) {
|
|
1547
|
+
const i = e.mountHandler;
|
|
1548
|
+
if (!i)
|
|
1549
|
+
throw new Error(
|
|
1550
|
+
`apigen-engine-runtime/dispatchForPlan: OpPlan for mount op "${e.op.id}" has isMount=true but no mountHandler`
|
|
1551
|
+
);
|
|
1552
|
+
const s = {
|
|
1553
|
+
operation: e.op,
|
|
1554
|
+
data: n.domainArgs,
|
|
1555
|
+
envelope: n.envelope,
|
|
1556
|
+
ctx: wt(),
|
|
1557
|
+
transport: e.transport,
|
|
1558
|
+
signal: n.signal ?? new AbortController().signal
|
|
1559
|
+
}, a = {
|
|
1560
|
+
...r,
|
|
1561
|
+
fns: { [e.op.id]: () => i(s) },
|
|
1562
|
+
schemas: { [e.op.id]: bt }
|
|
1563
|
+
};
|
|
1564
|
+
return t(e.op.id, o, a);
|
|
1565
|
+
}
|
|
1566
|
+
return t(e.op.id, o, r);
|
|
1567
|
+
}
|
|
1367
1568
|
export {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1569
|
+
xe as EventBus,
|
|
1570
|
+
Mt as InstanceRegistry,
|
|
1571
|
+
ke as LayerContext,
|
|
1572
|
+
g as UnionCodecError,
|
|
1573
|
+
He as ValidateSchemasToken,
|
|
1574
|
+
nt as WELL_KNOWN_TS_CODECS,
|
|
1575
|
+
gt as adaptCoreLayer,
|
|
1576
|
+
Ke as assertNoSelfSubscription,
|
|
1577
|
+
Te as buildContext,
|
|
1578
|
+
xt as buildFnTable,
|
|
1579
|
+
Ft as buildMcpOutputSchema,
|
|
1580
|
+
Bt as buildOpPlan,
|
|
1581
|
+
Rt as buildToolDescription,
|
|
1582
|
+
It as coerceQueryParams,
|
|
1583
|
+
Ut as collectWithPhase,
|
|
1584
|
+
St as createApiPackage,
|
|
1585
|
+
Ie as createInvoker,
|
|
1586
|
+
kt as createLogger,
|
|
1587
|
+
zt as createPackageInvoker,
|
|
1588
|
+
Tt as createStream,
|
|
1589
|
+
Qe as createUnionCodec,
|
|
1590
|
+
Ae as dataParamNames,
|
|
1591
|
+
Et as defineMiddleware,
|
|
1592
|
+
Be as describeParams,
|
|
1593
|
+
Se as dispatch,
|
|
1594
|
+
Ht as dispatchForPlan,
|
|
1595
|
+
Pt as drainStream,
|
|
1596
|
+
Dt as isApiStream,
|
|
1597
|
+
We as makeValidateLayer,
|
|
1598
|
+
Oe as needsEnvelopeField,
|
|
1599
|
+
Vt as readUseOptions,
|
|
1600
|
+
qt as readUsePlugins,
|
|
1601
|
+
Lt as tsHostBinding,
|
|
1602
|
+
Ct as validateLayer,
|
|
1603
|
+
Me as wireObservers,
|
|
1604
|
+
Kt as wrapMcpStructuredContent
|
|
1398
1605
|
};
|