@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/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 N from "pino";
6
- import ge from "ajv";
7
- import we from "ajv-formats";
8
- const C = "$apigen";
9
- class W extends Error {
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 be(e) {
14
+ function Oe(e) {
15
15
  const t = /* @__PURE__ */ new Map();
16
16
  return {
17
- register(r, n) {
18
- if (t.has(r.id) && !(n != null && n.override))
19
- throw new W(
20
- `E_DUP_CODEC: a codec is already registered for id "${r.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(r.id, r);
22
+ t.set(n.id, n);
23
23
  },
24
- resolve(r) {
25
- for (const n of t.values())
26
- if (n.matches(r))
27
- return n;
24
+ resolve(n) {
25
+ for (const r of t.values())
26
+ if (r.matches(n))
27
+ return r;
28
28
  },
29
- get(r) {
30
- return t.get(r);
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 r = new Map(t), n = {
36
+ const n = new Map(t), r = {
37
37
  register() {
38
- throw new W(
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 r.values())
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 r.get(o);
48
+ return n.get(o);
49
49
  },
50
50
  ids() {
51
- return [...r.keys()];
51
+ return [...n.keys()];
52
52
  },
53
53
  freeze() {
54
- return n;
54
+ return r;
55
55
  }
56
56
  };
57
- return n;
57
+ return r;
58
58
  }
59
59
  };
60
60
  }
61
- const L = "x-apigen-logical", R = "x-apigen-codec", S = "x-apigen-ctor", x = "x-apigen-tojson", ve = "0.1.0";
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: (r) => {
65
+ resolve: (n) => {
66
66
  throw new Error(
67
- `[apigen-logical] $ref "${r}" cannot be resolved in run-mode without a descriptor root. Supply a resolve() in the ctx override to handle $ref.`
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, r) {
77
- const n = r.registry.resolve(t);
78
- if (n)
79
- return n.encode(e, t, r);
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 = r.resolve(o);
83
- return v(e, a, r);
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 = ue(e, i, t);
88
- return v(e, a, r);
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, r);
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 = r.path;
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, { ...r, path: `${f}/${u}` });
100
+ return p === void 0 ? w(c) : v(c, p, { ...n, path: `${f}/${u}` });
101
101
  }) : e.map(
102
- (c, u) => v(c, a, { ...r, path: `${f}/${u}` })
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, r);
107
+ return _(e, t, n);
108
108
  const a = t.properties;
109
109
  if (!a)
110
110
  return w(e);
111
- const f = r.path, c = {};
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
- ...r,
115
+ ...n,
116
116
  path: `${f}/${u}`
117
117
  }));
118
118
  }
119
119
  return c;
120
120
  }
121
- return s == null ? _(e, t, r) : w(e);
121
+ return s == null ? _(e, t, n) : w(e);
122
122
  }
123
- function $(e, t, r) {
124
- const n = r.registry.resolve(t);
125
- if (n)
126
- return n.decode(e, t, r);
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 = r.resolve(o);
130
- return $(e, a, r);
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 = ue(e, i, t);
135
- return $(e, a, r);
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 = r.path;
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, { ...r, path: `${f}/${u}` });
147
+ return p === void 0 ? c : $(c, p, { ...n, path: `${f}/${u}` });
148
148
  }) : e.map(
149
- (c, u) => $(c, a, { ...r, path: `${f}/${u}` })
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 = r.path, c = {};
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
- ...r,
162
+ ...n,
163
163
  path: `${f}/${u}`
164
164
  }));
165
165
  }
166
166
  return c;
167
167
  }
168
- return s == null ? $e(e, r) : e;
168
+ return s == null ? Ne(e, n) : e;
169
169
  }
170
- function ue(e, t, r, n) {
171
- const o = r.discriminator;
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, r) {
186
- for (const n of r.registry.ids()) {
187
- const o = r.registry.get(n);
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, r);
191
- return { [C]: n, v: i };
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 $e(e, t) {
198
- if (e !== null && typeof e == "object" && !Array.isArray(e) && C in e) {
199
- const r = e, n = r[C], o = t.registry.get(n);
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(r.v, o.schema, t);
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 [r, n] of Object.entries(e))
213
- n !== void 0 && (t[r] = w(n));
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 je(e) {
218
+ function Ee(e) {
219
219
  return {
220
- encode(t, r, n) {
221
- const o = G(e, n);
222
- return v(t, r, o);
220
+ encode(t, n, r) {
221
+ const o = G(e, r);
222
+ return v(t, n, o);
223
223
  },
224
- decode(t, r, n) {
225
- const o = G(e, n);
226
- return $(t, r, o);
224
+ decode(t, n, r) {
225
+ const o = G(e, r);
226
+ return $(t, n, o);
227
227
  }
228
228
  };
229
229
  }
230
- const B = {
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, r) {
237
+ encode(e, t, n) {
238
238
  return e.toISOString();
239
239
  },
240
- decode(e, t, r) {
240
+ decode(e, t, n) {
241
241
  if (typeof e != "string") {
242
- if (r.mode === "strict")
242
+ if (n.mode === "strict")
243
243
  throw new TypeError(
244
- `[date-time] expected a string on the wire at "${r.path}", got ${typeof e}`
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 (r.mode === "strict" && Number.isNaN(new Date(e).getTime()))
248
+ if (n.mode === "strict" && Number.isNaN(new Date(e).getTime()))
249
249
  throw new TypeError(
250
- `[date-time] invalid date-time string at "${r.path}": ${JSON.stringify(e)}`
250
+ `[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`
251
251
  );
252
252
  return new Date(e);
253
253
  }
254
- }, F = {
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, r) {
261
+ encode(e, t, n) {
262
262
  return String(e);
263
263
  },
264
- decode(e, t, r) {
264
+ decode(e, t, n) {
265
265
  if (typeof e != "string") {
266
- if (r.mode === "strict")
266
+ if (n.mode === "strict")
267
267
  throw new TypeError(
268
- `[int64] expected a string on the wire at "${r.path}", got ${typeof e}`
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 (r.mode === "strict")
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, r) {
293
+ encode(e, t, n) {
294
294
  return e;
295
295
  },
296
- decode(e, t, r) {
296
+ decode(e, t, n) {
297
297
  if (typeof e != "string") {
298
- if (r.mode === "strict")
298
+ if (n.mode === "strict")
299
299
  throw new TypeError(
300
- `[decimal] expected a string on the wire at "${r.path}", got ${typeof e}`
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 (r.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e))
304
+ if (n.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e))
305
305
  throw new TypeError(
306
- `[decimal] wire value "${e}" at "${r.path}" is not a valid decimal string`
306
+ `[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`
307
307
  );
308
308
  return e;
309
309
  }
310
- }, H = {
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, r) {
317
+ encode(e, t, n) {
318
318
  return Buffer.from(e).toString("base64");
319
319
  },
320
- decode(e, t, r) {
320
+ decode(e, t, n) {
321
321
  if (typeof e != "string") {
322
- if (r.mode === "strict")
322
+ if (n.mode === "strict")
323
323
  throw new TypeError(
324
- `[byte] expected a base64 string on the wire at "${r.path}", got ${typeof e}`
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 (r.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e))
328
+ if (n.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e))
329
329
  throw new TypeError(
330
- `[byte] wire value at "${r.path}" is not standard base64 (format:byte): "${e}"`
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
- }, Ne = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, q = {
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, r) {
341
+ encode(e, t, n) {
342
342
  return e.toLowerCase();
343
343
  },
344
- decode(e, t, r) {
344
+ decode(e, t, n) {
345
345
  if (typeof e != "string") {
346
- if (r.mode === "strict")
346
+ if (n.mode === "strict")
347
347
  throw new TypeError(
348
- `[uuid] expected a string on the wire at "${r.path}", got ${typeof e}`
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 (r.mode === "strict" && !Ne.test(e))
352
+ if (n.mode === "strict" && !_e.test(e))
353
353
  throw new TypeError(
354
- `[uuid] wire value "${e}" at "${r.path}" is not a lowercase-hyphenated RFC 4122 UUID`
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
- }, M = "NaN", T = "Infinity", P = "-Infinity", Oe = /* @__PURE__ */ new Set([
359
- M,
358
+ }, T = "NaN", P = "Infinity", D = "-Infinity", ke = /* @__PURE__ */ new Set([
360
359
  T,
361
- P
362
- ]), z = {
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, r) {
370
- return Number.isNaN(e) ? M : e === 1 / 0 ? T : e === -1 / 0 ? P : 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, r) {
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 1 / 0;
377
+ return NaN;
380
378
  if (e === P)
379
+ return 1 / 0;
380
+ if (e === D)
381
381
  return -1 / 0;
382
- const n = Number(e);
383
- if (!Number.isNaN(n))
384
- return n;
382
+ const r = Number(e);
383
+ if (!Number.isNaN(r))
384
+ return r;
385
385
  }
386
- if (r.mode === "strict")
386
+ if (n.mode === "strict")
387
387
  throw new TypeError(
388
- `[number-special] unrecognized wire value at "${r.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...Oe].join(", ")}.`
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
- }, Ae = [
393
- B,
392
+ }, Ie = [
394
393
  F,
394
+ q,
395
395
  K,
396
+ z,
396
397
  H,
397
- q,
398
- z
398
+ W
399
399
  ];
400
- function _e(e, t = {}) {
401
- for (const r of Ae)
402
- e.register(r, { override: t.override ?? !1 });
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
- B.id, // 'date-time'
405
- F.id, // 'int64'
518
+ F.id, // 'date-time'
519
+ q.id, // 'int64'
406
520
  K.id, // 'decimal'
407
- H.id, // 'byte'
408
- q.id, // 'uuid'
409
- z.id;
410
- const fe = be();
411
- _e(fe);
412
- const pe = je(fe.freeze());
413
- function Ee(e, t) {
414
- var n;
415
- const r = ((n = e.input) == null ? void 0 : n.properties) ?? {};
416
- return t in r;
417
- }
418
- function ke(e) {
419
- var r, n;
420
- const t = (n = (r = e.input) == null ? void 0 : r.properties) == null ? void 0 : n.data;
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 Ie(e, t) {
537
+ function Re(e, t) {
424
538
  var o, i, s;
425
- const r = (s = (i = (o = e.input) == null ? void 0 : o.properties) == null ? void 0 : i.data) == null ? void 0 : s.properties, n = r == null ? void 0 : r[t];
426
- return n !== void 0 ? n : void 0;
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 Ce(e, t) {
429
- return t === void 0 || e === void 0 ? e : pe.decode(e, t);
542
+ function Le(e, t) {
543
+ return t === void 0 || e === void 0 ? e : me.decode(e, t);
430
544
  }
431
- function E(e, t) {
432
- const r = t.output;
433
- return !r || Object.keys(r).length === 0 ? e : pe.encode(e, r);
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 Se(e, t, r, n, o, i) {
436
- const a = ke(r).map(
437
- (c) => Ce(i[c], Ie(r, 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 (Ee(r, "session") && t) {
440
- const c = await t({ session: o.session }), u = await e[n](c, ...a);
441
- return E(u, r);
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 (r.hasCtx) {
444
- const c = t ? await t(o) : void 0, u = await e[n](c, ...a);
445
- return E(u, r);
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[n](...a);
448
- return E(f, r);
561
+ const f = await e[r](...a);
562
+ return k(f, n);
449
563
  }
450
- class xe {
564
+ class Fe {
451
565
  constructor() {
452
566
  this._map = /* @__PURE__ */ new Map();
453
567
  }
454
- set(t, r) {
455
- this._map.set(t, r);
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 Me(e = []) {
466
- return async function(r, n, o) {
467
- const i = o.schemas[r];
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 "${r}"`
584
+ `apigen/invoke: no schema found for operation "${n}"`
471
585
  );
472
- const s = () => Se(
586
+ const s = () => Be(
473
587
  o.fns,
474
588
  o.createClient,
475
589
  i,
476
- r,
477
- n.envelope,
478
- n.domainArgs
590
+ n,
591
+ r.envelope,
592
+ r.domainArgs
479
593
  );
480
594
  return e.reduceRight(
481
- (f, c) => () => c(n, f),
595
+ (f, c) => () => c(r, f),
482
596
  s
483
597
  )();
484
598
  };
485
599
  }
486
- function Kt(e) {
600
+ function Xt(e) {
487
601
  return e;
488
602
  }
489
- class Te {
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, r) {
499
- const n = this.handlers.get(t) ?? [];
500
- return this.handlers.set(t, [...n, r]), () => this.off(t, r);
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, r) {
504
- const n = this.handlers.get(t);
505
- if (!n)
617
+ off(t, n) {
618
+ const r = this.handlers.get(t);
619
+ if (!r)
506
620
  return;
507
- const o = n.filter((i) => i !== r);
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 [r, n] of this.handlers)
516
- if (Pe(r, t))
517
- for (const o of n)
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 Pe(e, t) {
522
- const [r, n, o] = e.split(":");
523
- return !(r !== "*" && r !== t.module || n && n !== "*" && n !== t.method || o && o !== "*" && o !== t.lifecycle);
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 De(e, t) {
526
- for (const r of e)
527
- if (r.eventMapping)
528
- for (const [n, o] of Object.entries(r.eventMapping))
529
- t.on(n, o);
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 Ue(e, t, r) {
532
- let n = { ...t };
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 r.emit({
649
+ await n.emit({
536
650
  module: o.id,
537
651
  method: "createContext",
538
652
  lifecycle: "start",
539
- ctx: n
653
+ ctx: r
540
654
  });
541
655
  try {
542
- const i = await o.createContext(n);
543
- n = { ...n, ...i }, await r.emit({
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: n
661
+ ctx: r
548
662
  });
549
663
  } catch (i) {
550
- throw await r.emit({
664
+ throw await n.emit({
551
665
  module: o.id,
552
666
  method: "createContext",
553
667
  lifecycle: "error",
554
- ctx: n,
668
+ ctx: r,
555
669
  error: i
556
670
  }), i;
557
671
  }
558
672
  }
559
- return n;
673
+ return r;
560
674
  }
561
- function J(e, t) {
562
- const r = /* @__PURE__ */ new Set(), n = [e];
563
- for (; n.length > 0; ) {
564
- const o = n.pop();
565
- if (!o || r.has(o))
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
- r.add(o);
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
- n.push(p);
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 && n.push(p);
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
- n.push(p);
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 && n.push(p);
707
+ typeof p == "object" && p !== null && r.push(p);
594
708
  else
595
- typeof f == "object" && f !== null && n.push(f);
709
+ typeof f == "object" && f !== null && r.push(f);
596
710
  const c = o.additionalProperties;
597
- typeof c == "object" && c !== null && n.push(c);
711
+ typeof c == "object" && c !== null && r.push(c);
598
712
  const u = o.propertyNames;
599
- typeof u == "object" && u !== null && n.push(u);
713
+ typeof u == "object" && u !== null && r.push(u);
600
714
  }
601
715
  }
602
- const Y = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
603
- function Le(e) {
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: r } = t;
610
- return typeof r == "string" ? Y.has(r) : Array.isArray(r) ? r.every((n) => Y.has(n) || n === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((n) => ["string", "number", "boolean"].includes(typeof n)) : !1;
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 Re(e) {
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
- Le
731
+ Ve
618
732
  );
619
733
  }
620
- function Be(e) {
621
- const t = {}, r = (n) => {
734
+ function Ge(e) {
735
+ const t = {}, n = (r) => {
622
736
  for (const o of ["definitions", "$defs"]) {
623
- const i = n[o];
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 n of Object.values(e.schemas))
632
- r(n.input), r(n.output);
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 [n, o] of Object.entries(e.schemas))
748
+ for (const [r, o] of Object.entries(e.schemas))
635
749
  try {
636
- J(o.input, t), J(o.output, t);
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 "${n}": ${i.message}`
753
+ `[apigen-core-client] Schema validation failed for function "${r}": ${i.message}`
640
754
  );
641
755
  }
642
756
  }
643
- function Fe(e, t) {
644
- const r = [
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 && r.push(
648
- `Field(s) ${e.map((n) => `"${n}"`).join(", ")} are transport-level envelope metadata, NOT domain data — do not nest them under "data". Over MCP they are read from arguments._meta["x-<pluginId>-<field>"] (default pluginId "adhd"); see @adhd/apigen-engine-naming's envelopeMetaKey/envelopeCliFlag/envelopeEnvVar for the HTTP-header / CLI-flag / env-var equivalents.`
649
- ), r.join(" ");
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 Ke(e, t, r) {
652
- Be(e);
653
- const n = {};
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 = (r == null ? void 0 : r[o]) ?? {}, a = i.input.properties ?? {}, f = i.input.required ?? [], c = {}, u = [], p = {};
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, he] of Object.entries(h.envelope))
659
- c[b] = he, p[b] = h.id, u.includes(b) || u.push(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 || Re(i.input), l = i.input.definitions, y = i.input.$defs;
666
- n[o] = {
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: Fe(
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 n;
810
+ return r;
697
811
  }
698
- const He = {
812
+ const Xe = {
699
813
  "decimal.js": "Decimal"
700
814
  };
701
- function qe(e) {
815
+ function Qe(e) {
702
816
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
703
817
  }
704
- Object.entries(He).map(([e, t]) => ({
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\\(["'][^"']*${qe(e)}[^"']*["']\\)\\.\\w+`,
826
+ `import\\(["'][^"']*${Qe(e)}[^"']*["']\\)\\.\\w+`,
713
827
  "g"
714
828
  ),
715
829
  key: t
716
830
  }));
717
- class D extends Error {
831
+ class U extends Error {
718
832
  constructor(t) {
719
833
  super(t), this.name = "ConfigurationError";
720
834
  }
721
835
  }
722
- function ze(e) {
836
+ function et(e) {
723
837
  for (const t of e)
724
- for (const r of Object.keys(t.eventMapping ?? {})) {
725
- const [n] = r.split(":");
726
- if (n !== "*" && n === t.id)
727
- throw new D(
728
- `Middleware "${t.id}" subscribes to its own events via "${r}". This would cause infinite recursion.`
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 Ht(e) {
846
+ function Qt(e) {
733
847
  const {
734
848
  domainSchemas: t,
735
- middlewares: r,
736
- overrides: n = {},
849
+ middlewares: n,
850
+ overrides: r = {},
737
851
  strict: o = !1
738
852
  } = e;
739
- ze(r);
740
- for (const c of Object.keys(n))
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 D(u);
858
+ throw new U(u);
745
859
  console.warn("[apigen-runtime]", u);
746
860
  }
747
- const i = new Set(r.map((c) => c.id));
748
- for (const [c, u] of Object.entries(n))
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 D(d);
867
+ throw new U(d);
754
868
  console.warn("[apigen-runtime]", d);
755
869
  }
756
- const s = Ke(
870
+ const s = Ze(
757
871
  t,
758
- r,
759
- n
760
- ), a = new Te();
761
- return De(r, a), { schemas: s, createClient: async (c) => Ue(r, c, a), dispose: () => a.clear() };
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 qt(e = {}) {
764
- const t = e.level ?? "info", r = typeof e.destination == "string" && e.destination.length > 0, n = !r && !!process.stderr.isTTY, o = e.format ?? (n ? "pretty" : "json"), i = { level: t };
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: !r,
883
+ colorize: !n,
770
884
  translateTime: "SYS:HH:MM:ss.l",
771
885
  ignore: "pid,hostname",
772
- ...r ? { destination: e.destination, mkdir: !0 } : { destination: 2 }
886
+ ...n ? { destination: e.destination, mkdir: !0 } : { destination: 2 }
773
887
  }
774
- }, N(i);
775
- const s = r ? N.destination({ dest: e.destination, mkdir: !0, sync: !0 }) : N.destination(2);
776
- return N(i, s);
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 le(e) {
779
- return e ? e.type === "array" ? `${le(e.items)}[]` : e.enum ? "enum" : e.$ref ? String(e.$ref).split("/").pop() || "object" : e.anyOf || e.oneOf ? "union" : e.type ?? "object" : "unknown";
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 Ve(e) {
895
+ function tt(e) {
782
896
  var a;
783
- const r = (a = ((e == null ? void 0 : e.input) ?? {}).properties) == null ? void 0 : a.data, n = (r == null ? void 0 : r.properties) ?? {}, o = new Set((r == null ? void 0 : r.required) ?? []), i = Object.entries(n).map(([f, c]) => ({
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: le(c),
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 We(e) {
904
+ function nt(e) {
791
905
  let t;
792
- return Array.isArray(e) ? t = e : e ? t = [e] : t = [], t.find((r) => r === "number" || r === "integer" || r === "boolean");
906
+ return Array.isArray(e) ? t = e : e ? t = [e] : t = [], t.find((n) => n === "number" || n === "integer" || n === "boolean");
793
907
  }
794
- function zt(e, t) {
908
+ function tn(e, t) {
795
909
  var i, s;
796
- const n = ((s = (i = ((t == null ? void 0 : t.input) ?? {}).properties) == null ? void 0 : i.data) == null ? void 0 : s.properties) ?? {}, o = { ...e };
797
- for (const [a, f] of Object.entries(n)) {
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 = We(f == null ? void 0 : f.type);
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 X = /* @__PURE__ */ new Set(["default", "module.exports", "__esModule"]);
811
- function Vt(e) {
812
- const t = {}, r = (n, o) => {
813
- for (const [i, s] of Object.entries(n))
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
- !X.has(i) && !(i in t) && (t[i] = s);
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 && X.has(i) && r(s, o + 1);
933
+ s && typeof s == "object" && o < 2 && ee.has(i) && n(s, o + 1);
820
934
  };
821
- return r(e, 0), t;
935
+ return n(e, 0), t;
822
936
  }
823
- const Ge = [
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 A extends Error {
831
- constructor(t, r, n) {
832
- super(r), this.name = "ApiError", this.code = t, this.details = n, Object.setPrototypeOf(this, new.target.prototype);
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 de(e) {
844
- return typeof e == "object" && e !== null && e.name === "ApiError" && Ge.includes(e.code) && typeof e.toJSON == "function";
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 Q(e, t, r = 0) {
847
- return e === "before-first-chunk" ? { phase: e, error: t } : { phase: e, error: t, chunksDelivered: r };
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 j = new ge({ allErrors: !0 });
850
- we(j);
963
+ const O = new $e({ allErrors: !0 });
964
+ Ae(O);
851
965
  for (const e of [
852
966
  L,
853
- R,
967
+ B,
854
968
  S,
855
- x,
969
+ M,
856
970
  "discriminator"
857
971
  ])
858
- j.addKeyword({ keyword: e, valid: !0 });
859
- j.addFormat("decimal", /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);
860
- function ye(e) {
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
- const Wt = async (e, t) => {
866
- const r = e.ctx.get(Je);
867
- if (r === void 0)
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 n = e.operation.id, o = r[n];
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 = j.compile(o.input);
993
+ }, s = O.compile(o.input);
876
994
  if (!s(i)) {
877
995
  const f = s.errors ?? [];
878
- throw new A(
996
+ throw new E(
879
997
  "invalid_argument",
880
- `Validation failed: ${ye(f)}`,
998
+ we(f, o.input),
881
999
  f
882
1000
  );
883
1001
  }
884
1002
  return t();
885
- }, Je = Symbol("ValidateSchemasToken");
886
- function Ye(e) {
887
- return async function(r, n) {
888
- const o = r.operation.id, i = e[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 n();
1008
+ return r();
891
1009
  const s = {
892
- data: r.domainArgs,
893
- ...r.envelope
894
- }, a = j.compile(i.input);
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 A(
1015
+ throw new E(
898
1016
  "invalid_argument",
899
- `Validation failed: ${ye(c)}`,
1017
+ we(c, i.input),
900
1018
  c
901
1019
  );
902
1020
  }
903
- return n();
1021
+ return r();
904
1022
  };
905
1023
  }
906
- function Xe() {
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 Gt {
1030
+ class on {
913
1031
  constructor(t = {}) {
914
- var n, o;
1032
+ var r, o;
915
1033
  this._store = /* @__PURE__ */ new Map(), this._sweeper = null, this._defaultTtlMs = t.defaultTtlMs;
916
- let r = null;
917
- t.sweepIntervalMs === 0 ? r = null : t.sweepIntervalMs !== void 0 ? r = t.sweepIntervalMs : this._defaultTtlMs !== void 0 ? r = Math.max(1e3, Math.floor(this._defaultTtlMs / 4)) : r = null, r !== null && r > 0 && (this._sweeper = setInterval(() => this._sweep(), r), (o = (n = this._sweeper).unref) == null || o.call(n));
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, r = [], n) {
931
- const o = new t(...r), i = Xe(), s = n ?? this._defaultTtlMs, a = s !== void 0 ? Date.now() + s : null;
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 r = this._store.get(t);
944
- if (!r)
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 (r.expiresAt !== null && Date.now() > r.expiresAt)
949
- throw this._evict(t, r), new Error(
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 r.instance;
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, r, n = []) {
964
- const o = this.get(t), i = o[r];
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 "${r}" not found on instance "${t}"`
1085
+ `[instance-registry] Method "${n}" not found on instance "${t}"`
968
1086
  );
969
- return i.call(o, ...n);
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 r = this._store.get(t);
980
- r && (this._store.delete(t), await k(r.instance));
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(([, r]) => k(r.instance)));
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 [r, n] of this._store)
1007
- n.expiresAt !== null && t > n.expiresAt && this._evict(r, n);
1124
+ for (const [n, r] of this._store)
1125
+ r.expiresAt !== null && t > r.expiresAt && this._evict(n, r);
1008
1126
  }
1009
- _evict(t, r) {
1010
- this._store.delete(t), k(r.instance);
1127
+ _evict(t, n) {
1128
+ this._store.delete(t), I(n.instance);
1011
1129
  }
1012
1130
  }
1013
- async function k(e) {
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 Jt(e) {
1020
- const { produce: t, signal: r } = e, n = r ?? new AbortController().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(n);
1141
+ const o = t(r);
1024
1142
  return {
1025
1143
  async next() {
1026
- return n.aborted ? (await o.return(void 0), { done: !0, value: void 0 }) : o.next();
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 Yt(e) {
1156
+ async function an(e) {
1039
1157
  const t = [];
1040
- for await (const r of e)
1041
- t.push(r);
1158
+ for await (const n of e)
1159
+ t.push(n);
1042
1160
  return t;
1043
1161
  }
1044
- async function Qe(e) {
1162
+ async function ct(e) {
1045
1163
  const t = [];
1046
1164
  try {
1047
- for await (const r of e)
1048
- t.push(r);
1165
+ for await (const n of e)
1166
+ t.push(n);
1049
1167
  return { ok: !0, chunks: t };
1050
- } catch (r) {
1051
- const n = de(r) ? r : new A(
1168
+ } catch (n) {
1169
+ const r = ge(n) ? n : new E(
1052
1170
  "internal",
1053
- r instanceof Error ? r.message : String(r)
1171
+ n instanceof Error ? n.message : String(n)
1054
1172
  );
1055
1173
  return t.length === 0 ? {
1056
1174
  ok: !1,
1057
- carrier: Q("before-first-chunk", n)
1175
+ carrier: te("before-first-chunk", r)
1058
1176
  } : {
1059
1177
  ok: !1,
1060
- carrier: Q("after-first-chunk", n, t.length)
1178
+ carrier: te("after-first-chunk", r, t.length)
1061
1179
  };
1062
1180
  }
1063
1181
  }
1064
- function Ze(e) {
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, r) {
1069
- super(r), this.name = "UnionCodecError", this.code = t;
1186
+ constructor(t, n) {
1187
+ super(n), this.name = "UnionCodecError", this.code = t;
1070
1188
  }
1071
1189
  }
1072
- function I(e) {
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 r = t;
1077
- if (typeof r.propertyName != "string")
1194
+ const n = t;
1195
+ if (typeof n.propertyName != "string")
1078
1196
  return;
1079
- const n = r.mapping;
1080
- if (!(n === null || typeof n != "object" || Array.isArray(n)))
1197
+ const r = n.mapping;
1198
+ if (!(r === null || typeof r != "object" || Array.isArray(r)))
1081
1199
  return {
1082
- propertyName: r.propertyName,
1083
- mapping: n
1200
+ propertyName: n.propertyName,
1201
+ mapping: r
1084
1202
  };
1085
1203
  }
1086
- function me(e, t) {
1087
- const r = e[R];
1088
- if (typeof r == "string") {
1089
- const n = t.registry.get(r);
1090
- if (n)
1091
- return n;
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 et(e, t, r) {
1096
- const n = me(t, r);
1097
- return n ? n.encode(e, t, r) : e;
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 tt(e, t, r) {
1100
- const n = me(t, r);
1101
- return n ? n.decode(e, t, r) : e;
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 rt(e) {
1104
- const { id: t, schema: r } = e;
1221
+ function lt(e) {
1222
+ const { id: t, schema: n } = e;
1105
1223
  return {
1106
1224
  id: t,
1107
1225
  kind: "union",
1108
- schema: r,
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(n) {
1115
- if (n[L] === "union")
1232
+ matches(r) {
1233
+ if (r[L] === "union")
1116
1234
  return !0;
1117
- const o = n.oneOf;
1118
- return !Array.isArray(o) || o.length === 0 ? !1 : I(n) !== void 0;
1235
+ const o = r.oneOf;
1236
+ return !Array.isArray(o) || o.length === 0 ? !1 : C(r) !== void 0;
1119
1237
  },
1120
- encode(n, o, i) {
1121
- const s = I(o);
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 = n[a];
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 et(n, d, {
1258
+ return ft(r, d, {
1141
1259
  ...i,
1142
1260
  path: `${i.path}[${u}]`
1143
1261
  });
1144
1262
  },
1145
- decode(n, o, i) {
1146
- if (n === null || typeof n != "object" || Array.isArray(n)) {
1263
+ decode(r, o, i) {
1264
+ if (r === null || typeof r != "object" || Array.isArray(r)) {
1147
1265
  let l;
1148
- throw n === null ? l = "null" : Array.isArray(n) ? l = "array" : l = typeof n, new g(
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 = n, a = I(o);
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 tt(n, m, {
1290
+ return pt(r, m, {
1173
1291
  ...i,
1174
1292
  path: `${i.path}[${p}]`
1175
1293
  });
1176
1294
  }
1177
1295
  };
1178
1296
  }
1179
- const nt = "x-apigen-instances";
1180
- class O extends Error {
1181
- constructor(t, r) {
1182
- super(r), this.name = "NominalCodecError", this.code = t;
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 Z(e) {
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 ot(e) {
1307
+ function yt(e) {
1190
1308
  const t = e.required;
1191
- return Array.isArray(t) ? t.filter((r) => typeof r == "string") : [];
1309
+ return Array.isArray(t) ? t.filter((n) => typeof n == "string") : [];
1192
1310
  }
1193
- function ee(e, t, r) {
1311
+ function re(e, t, n) {
1194
1312
  if (t) {
1195
- const n = r.registry.resolve(t);
1196
- if (n)
1197
- return n.encode(e, t, r);
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 it(e, t, r) {
1319
+ function mt(e, t, n) {
1202
1320
  if (t) {
1203
- const n = r.registry.resolve(t);
1204
- if (n)
1205
- return n.decode(e, t, r);
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 st(e) {
1210
- const { id: t, schema: r, ctor: n } = e;
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: r,
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[R] === t;
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 O(
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 = Z(i), f = typeof i[x] == "string" ? i[x] : "toJSON", c = o[f];
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] = ee(b, a[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] = ee(y, a[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 O(
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 ot(i))
1394
+ for (const u of yt(i))
1277
1395
  if (!(u in a))
1278
- throw new O(
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[nt] === !1)
1283
- throw new O(
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 = Z(i), c = {};
1405
+ const f = ne(i), c = {};
1288
1406
  for (const [u, p] of Object.entries(a))
1289
- c[u] = it(p, f[u], {
1407
+ c[u] = mt(p, f[u], {
1290
1408
  ...s,
1291
1409
  path: `${s.path}/${u}`
1292
1410
  });
1293
- if (n) {
1294
- const u = typeof i[S] == "string" ? i[S] : "fromJSON", p = n[u];
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
- n,
1415
+ r,
1298
1416
  c
1299
1417
  );
1300
- const d = n;
1418
+ const d = r;
1301
1419
  return new d(c);
1302
1420
  }
1303
1421
  return c;
1304
1422
  }
1305
1423
  };
1306
1424
  }
1307
- const at = [
1308
- B,
1425
+ const gt = [
1309
1426
  F,
1427
+ q,
1310
1428
  K,
1429
+ z,
1311
1430
  H,
1312
- q,
1313
- z
1314
- ], ct = {
1431
+ W
1432
+ ], wt = {
1315
1433
  type: "object",
1316
1434
  "x-apigen-logical": "nominal",
1317
1435
  "x-apigen-codec": "ts.NominalSentinel"
1318
- }, te = st({
1436
+ }, oe = ht({
1319
1437
  id: "ts.NominalSentinel",
1320
- schema: ct
1321
- }), ut = {
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
- }, re = rt({
1444
+ }, ie = lt({
1327
1445
  id: "ts.UnionSentinel",
1328
- schema: ut
1446
+ schema: bt
1329
1447
  });
1330
- function ft() {
1448
+ function vt() {
1331
1449
  const e = [
1332
1450
  // 6 well-known scalars
1333
- ...at.map((t) => [
1451
+ ...gt.map((t) => [
1334
1452
  t.id,
1335
1453
  t
1336
1454
  ]),
1337
1455
  // nominal kind sentinel
1338
- [te.id, te],
1456
+ [oe.id, oe],
1339
1457
  // union kind sentinel
1340
- [re.id, re]
1458
+ [ie.id, ie]
1341
1459
  ];
1342
1460
  return Object.freeze(new Map(e));
1343
1461
  }
1344
- const Xt = Object.freeze({
1462
+ const cn = Object.freeze({
1345
1463
  host: "ts",
1346
- logicalTypeVersion: ve,
1347
- codecs: ft()
1464
+ logicalTypeVersion: je,
1465
+ codecs: vt()
1348
1466
  });
1349
- function Qt(e, t, r) {
1350
- var i;
1351
- const n = typeof ((i = t == null ? void 0 : t.input) == null ? void 0 : i.description) == "string" ? t.input.description : void 0, o = [r, n].filter(
1352
- (s) => typeof s == "string" && s.length > 0
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 o.length > 0 ? o.join(" — ") : e;
1472
+ return i.length > 0 ? i.join(" — ") : e;
1355
1473
  }
1356
- function Zt(e) {
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 er(e, t) {
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 pt = 4, lt = 32;
1373
- function U(e) {
1374
- return de(e) ? e : e instanceof Error ? new A("internal", e.message) : e;
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 dt(e, t) {
1494
+ function Ot(e, t) {
1377
1495
  if (e === "serial" || e === "chained")
1378
1496
  return 1;
1379
- const r = t ?? pt;
1380
- return !Number.isFinite(r) || r < 1 ? 1 : Math.min(Math.floor(r), lt);
1497
+ const n = t ?? $t;
1498
+ return !Number.isFinite(n) || n < 1 ? 1 : Math.min(Math.floor(n), At);
1381
1499
  }
1382
- function yt() {
1500
+ function jt() {
1383
1501
  }
1384
- function mt(e, t) {
1502
+ function Nt(e, t) {
1385
1503
  var i;
1386
1504
  if (!e && !t)
1387
- return { signal: void 0, dispose: yt };
1388
- const r = new AbortController(), n = () => {
1389
- r.abort(e == null ? void 0 : e.reason);
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 ? r.abort(e.reason) : e.addEventListener("abort", n, { once: !0 }));
1509
+ e && (e.aborted ? n.abort(e.reason) : e.addEventListener("abort", r, { once: !0 }));
1392
1510
  let o;
1393
- return t !== void 0 && !r.signal.aborted && (o = setTimeout(() => {
1394
- r.abort(
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: r.signal,
1519
+ signal: n.signal,
1402
1520
  dispose() {
1403
- e && e.removeEventListener("abort", n), o && clearTimeout(o);
1521
+ e && e.removeEventListener("abort", r), o && clearTimeout(o);
1404
1522
  }
1405
1523
  };
1406
1524
  }
1407
- async function ne(e, t, r, n, o, i) {
1408
- const s = mt(n.signal, i);
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 ? { ...n, signal: s.signal } : n, f = await e(t, a, o);
1411
- if (Ze(f)) {
1412
- const c = await Qe(f);
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: r, status: "fulfilled", chunks: c.chunks };
1532
+ return { index: n, status: "fulfilled", chunks: c.chunks };
1415
1533
  const u = c.carrier;
1416
1534
  return {
1417
- index: r,
1535
+ index: n,
1418
1536
  status: "rejected",
1419
- reason: U(u.error),
1537
+ reason: R(u.error),
1420
1538
  ...u.phase === "after-first-chunk" ? { chunksDelivered: u.chunksDelivered } : {}
1421
1539
  };
1422
1540
  }
1423
- return { index: r, status: "fulfilled", value: f };
1541
+ return { index: n, status: "fulfilled", value: f };
1424
1542
  } catch (a) {
1425
- return { index: r, status: "rejected", reason: U(a) };
1543
+ return { index: n, status: "rejected", reason: R(a) };
1426
1544
  } finally {
1427
1545
  s.dispose();
1428
1546
  }
1429
1547
  }
1430
- async function tr(e, t, r, n, o = {}) {
1431
- const i = o.mode ?? "parallel", s = o.onItemError ?? "continue", a = dt(i, o.concurrency), f = new Array(r.length), c = (l) => ({
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: U(
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 < r.length; 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 ne(
1565
+ const h = await se(
1448
1566
  e,
1449
1567
  t,
1450
1568
  y,
1451
- r[y],
1452
- n,
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, r.length)), m = Array.from({ length: d }, async () => {
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 >= r.length)
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 ne(
1587
+ const y = await se(
1470
1588
  e,
1471
1589
  t,
1472
1590
  l,
1473
- r[l],
1474
- n,
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 oe = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
1483
- function ht(e) {
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: r } = t;
1490
- return typeof r == "string" ? oe.has(r) : Array.isArray(r) ? r.every((n) => oe.has(n) || n === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((n) => ["string", "number", "boolean"].includes(typeof n)) : !1;
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 gt(e) {
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
- ht
1615
+ Et
1498
1616
  );
1499
1617
  }
1500
- const wt = {
1618
+ const kt = {
1501
1619
  "decimal.js": "Decimal"
1502
1620
  };
1503
- function bt(e) {
1621
+ function It(e) {
1504
1622
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1505
1623
  }
1506
- Object.entries(wt).map(([e, t]) => ({
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\\(["'][^"']*${bt(e)}[^"']*["']\\)\\.\\w+`,
1632
+ `import\\(["'][^"']*${It(e)}[^"']*["']\\)\\.\\w+`,
1515
1633
  "g"
1516
1634
  ),
1517
1635
  key: t
1518
1636
  }));
1519
- function ie(e) {
1637
+ function ce(e) {
1520
1638
  return e.words.join("-");
1521
1639
  }
1522
- function se(e) {
1523
- return e.words.map(Ot).join("");
1640
+ function ue(e) {
1641
+ return e.words.map(Tt).join("");
1524
1642
  }
1525
- function ae(e) {
1643
+ function fe(e) {
1526
1644
  return e.words.join("_");
1527
1645
  }
1528
- function vt(e, t = {}) {
1529
- var r, n;
1530
- const o = [e.namespace, ...e.path], i = e.safe || gt(e.input) ? "GET" : "POST", s = ((n = (r = t.http) == null ? void 0 : r.verb) == null ? void 0 : n[e.id]) ?? i, a = "/" + o.map((m) => ie(m)).join("/"), f = o.map((m) => ae(m)).join("_"), c = o.map((m) => ae(m)).slice(0, -1).join("."), u = se(o[o.length - 2] ?? o[0]), p = se(o[o.length - 1]), d = o.map((m) => ie(m));
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 $t(e, t) {
1656
+ function xt(e, t) {
1539
1657
  return `x-${e}-${t}`;
1540
1658
  }
1541
- function jt(e, t) {
1659
+ function St(e, t) {
1542
1660
  return `--${e}-${t}`;
1543
1661
  }
1544
- function Nt(e, t) {
1545
- const r = (n) => n.toUpperCase().replace(/-/g, "_");
1546
- return e === "adhd" ? `APIGEN_${r(t)}` : `APIGEN_${r(e)}_${r(t)}`;
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 Ot(e) {
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 At(e) {
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 r = t.filter((n) => n.type !== "null");
1562
- return r.length > 0 && r.every((n) => n.type === "array" || n.type === "object");
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 _t(e) {
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 r = t.filter((n) => n.type !== "null");
1574
- return r.length > 0 && r.every((n) => n.type === "boolean");
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 Et(e) {
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 r = t.filter((n) => n.type !== "null");
1586
- return r.length > 0 && r.every((n) => n.type === "number" || n.type === "integer");
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 kt(e) {
1708
+ function Rt(e) {
1591
1709
  return e.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
1592
1710
  }
1593
- function It(e) {
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, r = (t == null ? void 0 : t.properties) ?? {}, n = (t == null ? void 0 : t.required) ?? [];
1596
- return { props: r, required: n };
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 ce(e) {
1716
+ function pe(e) {
1599
1717
  return typeof e.handler == "function";
1600
1718
  }
1601
- function Ct(e) {
1719
+ function Bt(e) {
1602
1720
  var o;
1603
- const t = ((o = e.input) == null ? void 0 : o.properties) ?? {}, r = e["x-apigen-envelope"], n = [];
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 = (r == null ? void 0 : r[i]) ?? "adhd", a = $t(s, i);
1608
- n.push({
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: jt(s, i),
1614
- envVar: Nt(s, i)
1731
+ cliFlag: St(s, i),
1732
+ envVar: Mt(s, i)
1615
1733
  });
1616
1734
  }
1617
- return n;
1735
+ return r;
1618
1736
  }
1619
- function St(e, t) {
1620
- const r = /* @__PURE__ */ new Map(), { props: n } = It(e);
1621
- for (const [o, i] of Object.entries(n)) {
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
- _t(i) ? s = "boolean" : (At(i) || Et(i)) && (s = "json"), r.set(kt(o), {
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
- r.set(i, {
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 r;
1756
+ return n;
1639
1757
  }
1640
- function rr(e) {
1641
- const { op: t, schema: r, transport: n, projection: o } = e, i = vt(t, o), s = r ? Ct(r) : [], a = r ? St(r, s) : /* @__PURE__ */ new Map(), f = r ? Ve(r).params : void 0, c = {
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: n,
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: ce(t)
1770
+ isMount: pe(t)
1653
1771
  };
1654
- if (ce(t)) {
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 nr(e) {
1778
+ function yn(e) {
1661
1779
  const t = e.usePlugins;
1662
1780
  return Array.isArray(t) ? t : [];
1663
1781
  }
1664
- function or(e) {
1782
+ function mn(e) {
1665
1783
  const t = e.useOptions;
1666
1784
  return t && typeof t == "object" ? t : {};
1667
1785
  }
1668
- function xt(e) {
1669
- return async function(r, n) {
1670
- const o = Object.assign(r, { data: r.domainArgs });
1671
- return await e.layer(o, n);
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 ir(e, t) {
1675
- var n;
1676
- const r = [];
1792
+ function hn(e, t) {
1793
+ var r;
1794
+ const n = [];
1677
1795
  for (const o of t) {
1678
- const i = (n = o.capabilities) == null ? void 0 : n.layer;
1679
- i && r.push(xt(i));
1796
+ const i = (r = o.capabilities) == null ? void 0 : r.layer;
1797
+ i && n.push(qt(i));
1680
1798
  }
1681
- return r.push(Ye(e)), Me(r);
1799
+ return n.push(st(e)), qe(n);
1682
1800
  }
1683
- function Mt() {
1801
+ function Kt() {
1684
1802
  const e = /* @__PURE__ */ new Map();
1685
1803
  return {
1686
1804
  get: (t) => e.get(t),
1687
- set: (t, r) => {
1688
- e.set(t, r);
1805
+ set: (t, n) => {
1806
+ e.set(t, n);
1689
1807
  }
1690
1808
  };
1691
1809
  }
1692
- const Tt = {
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 sr(e, t, r, n) {
1817
+ async function gn(e, t, n, r) {
1700
1818
  const o = {
1701
- ...r,
1819
+ ...n,
1702
1820
  operation: { id: e.op.id },
1703
- ctx: new xe()
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: r.domainArgs,
1714
- envelope: r.envelope,
1715
- ctx: Mt(),
1831
+ data: n.domainArgs,
1832
+ envelope: n.envelope,
1833
+ ctx: Kt(),
1716
1834
  transport: e.transport,
1717
- signal: r.signal ?? new AbortController().signal
1835
+ signal: n.signal ?? new AbortController().signal
1718
1836
  }, a = {
1719
- ...n,
1837
+ ...r,
1720
1838
  fns: { [e.op.id]: () => i(s) },
1721
- schemas: { [e.op.id]: Tt }
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, n);
1843
+ return t(e.op.id, o, r);
1726
1844
  }
1727
1845
  export {
1728
- pt as BATCH_DEFAULT_CONCURRENCY,
1729
- lt as BATCH_MAX_CONCURRENCY,
1730
- Te as EventBus,
1731
- Gt as InstanceRegistry,
1732
- xe as LayerContext,
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
- Je as ValidateSchemasToken,
1735
- at as WELL_KNOWN_TS_CODECS,
1736
- xt as adaptCoreLayer,
1737
- ze as assertNoSelfSubscription,
1738
- Ue as buildContext,
1739
- Vt as buildFnTable,
1740
- Zt as buildMcpOutputSchema,
1741
- rr as buildOpPlan,
1742
- Qt as buildToolDescription,
1743
- zt as coerceQueryParams,
1744
- Qe as collectWithPhase,
1745
- Ht as createApiPackage,
1746
- Me as createInvoker,
1747
- qt as createLogger,
1748
- ir as createPackageInvoker,
1749
- Jt as createStream,
1750
- rt as createUnionCodec,
1751
- ke as dataParamNames,
1752
- Kt as defineMiddleware,
1753
- Ve as describeParams,
1754
- Se as dispatch,
1755
- sr as dispatchForPlan,
1756
- Yt as drainStream,
1757
- tr as invokeBatch,
1758
- Ze as isApiStream,
1759
- Ye as makeValidateLayer,
1760
- Ee as needsEnvelopeField,
1761
- or as readUseOptions,
1762
- nr as readUsePlugins,
1763
- Xt as tsHostBinding,
1764
- Wt as validateLayer,
1765
- De as wireObservers,
1766
- er as wrapMcpStructuredContent
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
  };