@adhd/apigen-core-client 0.2.2 → 0.3.0

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
@@ -1,70 +1,70 @@
1
- import { Project as te, Scope as L } from "ts-morph";
2
- import Ne from "node:fs";
3
- import * as Oe from "node:path";
4
- import Y from "node:path";
5
- import { createParser as ke, createFormatter as Ee, SchemaGenerator as Ce, AnnotatedType as ne, StringType as re } from "ts-json-schema-generator";
6
- function oe(e) {
1
+ import { Project as X, SyntaxKind as ae, Scope as V } from "ts-morph";
2
+ import Ee from "node:fs";
3
+ import * as Ce from "node:path";
4
+ import oe from "node:path";
5
+ import { createParser as Re, createFormatter as Le, SchemaGenerator as _e, AnnotatedType as ce, StringType as ue } from "ts-json-schema-generator";
6
+ function le(e) {
7
7
  return {
8
8
  raw: e,
9
9
  words: e.split(/(?=[A-Z])|[-_]/).map((t) => t.toLowerCase()).filter(Boolean)
10
10
  };
11
11
  }
12
- function Ie(e, t, n = {}) {
12
+ function Me(e, t, r = {}) {
13
13
  const o = e.split("/");
14
14
  if (o.length < 2 || o.some((l) => l.length === 0))
15
15
  throw new Error(
16
16
  `syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`
17
17
  );
18
- const [r, ...i] = o, s = r.replace(/^_+/, ""), a = n.kind ?? "action", c = {
18
+ const [n, ...i] = o, s = n.replace(/^_+/, ""), a = r.kind ?? "action", c = {
19
19
  id: e,
20
20
  host: t.host,
21
- namespace: oe(s),
22
- path: i.map(oe),
21
+ namespace: le(s),
22
+ path: i.map(le),
23
23
  kind: a,
24
- async: n.async ?? !1,
25
- streaming: n.streaming ?? !1,
26
- safe: n.safe ?? a === "query",
27
- input: n.input ?? {},
28
- output: n.output ?? {},
29
- envelope: n.envelope ?? {},
30
- typeText: n.typeText ?? null
24
+ async: r.async ?? !1,
25
+ streaming: r.streaming ?? !1,
26
+ safe: r.safe ?? a === "query",
27
+ input: r.input ?? {},
28
+ output: r.output ?? {},
29
+ envelope: r.envelope ?? {},
30
+ typeText: r.typeText ?? null
31
31
  };
32
- return n.hasCtx !== void 0 && (c.hasCtx = n.hasCtx), n.transports !== void 0 && (c.transports = n.transports), c;
32
+ return r.hasCtx !== void 0 && (c.hasCtx = r.hasCtx), r.transports !== void 0 && (c.transports = r.transports), c;
33
33
  }
34
- const ge = Symbol.for("adhd.apigen.extraction-session");
35
- function de(e, t) {
36
- const n = [
34
+ const ve = Symbol.for("adhd.apigen.extraction-session");
35
+ function ie(e, t) {
36
+ const r = [
37
37
  ...e.getImportDeclarations().map((o) => o.getModuleSpecifierSourceFile()),
38
38
  ...e.getExportDeclarations().map((o) => o.getModuleSpecifierSourceFile())
39
39
  ];
40
- for (const o of n) {
40
+ for (const o of r) {
41
41
  if (!o)
42
42
  continue;
43
- const r = o.getFilePath();
44
- if (!r.includes("/node_modules/") && !t.has(r)) {
45
- t.add(r);
43
+ const n = o.getFilePath();
44
+ if (!n.includes("/node_modules/") && !t.has(n)) {
45
+ t.add(n);
46
46
  try {
47
47
  o.refreshFromFileSystemSync();
48
48
  } catch {
49
49
  }
50
- de(o, t);
50
+ ie(o, t);
51
51
  }
52
52
  }
53
53
  }
54
- function ye(e) {
54
+ function xe(e) {
55
55
  try {
56
- const t = Ne.statSync(e);
56
+ const t = Ee.statSync(e);
57
57
  return `${t.mtimeMs}:${t.size}`;
58
58
  } catch {
59
59
  return "nostat";
60
60
  }
61
61
  }
62
- const F = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
63
- function Fe(e, t, n) {
64
- const o = t ?? "", r = F.get(o);
65
- let i = n;
66
- if (r && r.fileVersions.size > 0) {
67
- const c = [n], l = [...r.fileVersions.entries()].sort(
62
+ const L = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
63
+ function Ve(e, t, r) {
64
+ const o = t ?? "", n = L.get(o);
65
+ let i = r;
66
+ if (n && n.fileVersions.size > 0) {
67
+ const c = [r], l = [...n.fileVersions.entries()].sort(
68
68
  ([u], [f]) => u.localeCompare(f)
69
69
  );
70
70
  for (const [u, f] of l)
@@ -72,74 +72,91 @@ function Fe(e, t, n) {
72
72
  i = c.join("|");
73
73
  }
74
74
  const s = `${e}\0${t ?? ""}`;
75
- let a = Z.get(s);
76
- return (!a || a.version !== i) && (a = { version: i, schemas: /* @__PURE__ */ new Map() }, Z.set(s, a)), a.schemas;
77
- }
78
- function Ft() {
79
- F.clear(), Z.clear();
75
+ let a = Y.get(s);
76
+ return (!a || a.version !== i) && (a = { version: i, schemas: /* @__PURE__ */ new Map() }, Y.set(s, a)), a.schemas;
77
+ }
78
+ function zt() {
79
+ L.clear(), Y.clear(), z = void 0;
80
+ }
81
+ let z;
82
+ function Ke() {
83
+ return z || (z = new X({
84
+ skipAddingFilesFromTsConfig: !0,
85
+ compilerOptions: { noLib: !0 }
86
+ })), z;
87
+ }
88
+ function Dt(e) {
89
+ const t = Ke(), r = t.getSourceFile(e), o = r ?? t.addSourceFileAtPath(e);
90
+ if (r)
91
+ try {
92
+ r.refreshFromFileSystemSync();
93
+ } catch {
94
+ }
95
+ const n = /* @__PURE__ */ new Set([e]);
96
+ return ie(o, n), [...n].sort();
80
97
  }
81
- function he() {
98
+ function we() {
82
99
  const e = {
83
100
  projectsBuilt: 0,
84
101
  generatorsBuilt: 0,
85
102
  schemaCacheHits: 0,
86
103
  schemaCacheMisses: 0
87
104
  }, t = /* @__PURE__ */ new Map();
88
- let n = !1;
105
+ let r = !1;
89
106
  return {
90
- [ge]: !0,
107
+ [ve]: !0,
91
108
  stats: e,
92
109
  schemaCache: /* @__PURE__ */ new Map(),
93
110
  aliasCache: /* @__PURE__ */ new WeakMap(),
94
111
  zodImportCache: /* @__PURE__ */ new WeakMap(),
95
112
  generatorCache: /* @__PURE__ */ new Map(),
96
- projectFor(r) {
97
- if (n)
113
+ projectFor(n) {
114
+ if (r)
98
115
  throw new Error("apigen-core: ExtractionSession used after dispose()");
99
- const i = r ?? "", s = r ? this.statVersion(r) : "";
100
- let a = F.get(i);
101
- return a && a.tsconfigVersion !== s && (a = void 0), a || (a = { project: r ? new te({
102
- tsConfigFilePath: r,
116
+ const i = n ?? "", s = n ? this.statVersion(n) : "";
117
+ let a = L.get(i);
118
+ return a && a.tsconfigVersion !== s && (a = void 0), a || (a = { project: n ? new X({
119
+ tsConfigFilePath: n,
103
120
  skipAddingFilesFromTsConfig: !0
104
- }) : new te({ skipAddingFilesFromTsConfig: !0 }), tsconfigVersion: s, fileVersions: /* @__PURE__ */ new Map() }, F.set(i, a), e.projectsBuilt++), a.project;
121
+ }) : new X({ skipAddingFilesFromTsConfig: !0 }), tsconfigVersion: s, fileVersions: /* @__PURE__ */ new Map() }, L.set(i, a), e.projectsBuilt++), a.project;
105
122
  },
106
- sourceFileFor(r, i) {
107
- const s = this.projectFor(i), a = F.get(i ?? ""), c = this.statVersion(r);
108
- let l = s.getSourceFile(r);
109
- if (l === void 0 ? l = s.addSourceFileAtPath(r) : a && a.fileVersions.get(r) !== c && l.refreshFromFileSystemSync(), a == null || a.fileVersions.set(r, c), a) {
110
- const u = /* @__PURE__ */ new Set([r]);
111
- de(l, u);
123
+ sourceFileFor(n, i) {
124
+ const s = this.projectFor(i), a = L.get(i ?? ""), c = this.statVersion(n);
125
+ let l = s.getSourceFile(n);
126
+ if (l === void 0 ? l = s.addSourceFileAtPath(n) : a && a.fileVersions.get(n) !== c && l.refreshFromFileSystemSync(), a == null || a.fileVersions.set(n, c), a) {
127
+ const u = /* @__PURE__ */ new Set([n]);
128
+ ie(l, u);
112
129
  for (const f of u)
113
- f !== r && a.fileVersions.set(f, this.statVersion(f));
130
+ f !== n && a.fileVersions.set(f, this.statVersion(f));
114
131
  }
115
132
  return l;
116
133
  },
117
- statVersion(r) {
118
- let i = t.get(r);
119
- return i === void 0 && (i = ye(r), t.set(r, i)), i;
134
+ statVersion(n) {
135
+ let i = t.get(n);
136
+ return i === void 0 && (i = xe(n), t.set(n, i)), i;
120
137
  },
121
138
  dispose() {
122
- n = !0, this.schemaCache.clear(), this.generatorCache.clear(), t.clear();
139
+ r = !0, this.schemaCache.clear(), this.generatorCache.clear(), t.clear();
123
140
  }
124
141
  };
125
142
  }
126
- function Te(e) {
143
+ function je(e) {
127
144
  const t = e;
128
- if (t[ge] !== !0)
145
+ if (t[ve] !== !0)
129
146
  throw new Error(
130
147
  "apigen-core: unknown ExtractionSession implementation — create sessions with createExtractionSession()"
131
148
  );
132
149
  return t;
133
150
  }
134
- const K = "x-apigen-logical";
135
- function ie(e, t) {
136
- const n = /* @__PURE__ */ new Set(), o = [e];
151
+ const W = "x-apigen-logical";
152
+ function fe(e, t) {
153
+ const r = /* @__PURE__ */ new Set(), o = [e];
137
154
  for (; o.length > 0; ) {
138
- const r = o.pop();
139
- if (!r || n.has(r))
155
+ const n = o.pop();
156
+ if (!n || r.has(n))
140
157
  continue;
141
- n.add(r);
142
- const i = r.$ref;
158
+ r.add(n);
159
+ const i = n.$ref;
143
160
  if (typeof i == "string") {
144
161
  if (t) {
145
162
  const f = t[i];
@@ -153,103 +170,103 @@ function ie(e, t) {
153
170
  }
154
171
  continue;
155
172
  }
156
- const s = r.oneOf;
173
+ const s = n.oneOf;
157
174
  if (Array.isArray(s))
158
175
  for (const f of s)
159
176
  typeof f == "object" && f !== null && o.push(f);
160
- const a = r.properties;
177
+ const a = n.properties;
161
178
  if (a)
162
179
  for (const f of Object.values(a))
163
180
  o.push(f);
164
- const c = r.items;
181
+ const c = n.items;
165
182
  if (Array.isArray(c))
166
183
  for (const f of c)
167
184
  typeof f == "object" && f !== null && o.push(f);
168
185
  else
169
186
  typeof c == "object" && c !== null && o.push(c);
170
- const l = r.additionalProperties;
187
+ const l = n.additionalProperties;
171
188
  typeof l == "object" && l !== null && o.push(l);
172
- const u = r.propertyNames;
189
+ const u = n.propertyNames;
173
190
  typeof u == "object" && u !== null && o.push(u);
174
191
  }
175
192
  }
176
- const se = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
177
- function Re(e) {
193
+ const pe = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
194
+ function qe(e) {
178
195
  if (typeof e != "object" || e === null)
179
196
  return !1;
180
197
  const t = e;
181
198
  if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf)
182
199
  return !1;
183
- const { type: n } = t;
184
- return typeof n == "string" ? se.has(n) : Array.isArray(n) ? n.every((o) => se.has(o) || o === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((o) => ["string", "number", "boolean"].includes(typeof o)) : !1;
200
+ const { type: r } = t;
201
+ return typeof r == "string" ? pe.has(r) : Array.isArray(r) ? r.every((o) => pe.has(o) || o === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((o) => ["string", "number", "boolean"].includes(typeof o)) : !1;
185
202
  }
186
- function _e(e) {
203
+ function ze(e) {
187
204
  if (!e || typeof e != "object")
188
205
  return !1;
189
206
  const t = e.properties;
190
207
  return t === void 0 || typeof t != "object" || t === null ? !1 : Object.values(t).every(
191
- Re
208
+ qe
192
209
  );
193
210
  }
194
- function Rt(e) {
195
- var n, o;
211
+ function Bt(e) {
212
+ var r, o;
196
213
  const t = [];
197
- for (const r of e) {
214
+ for (const n of e) {
198
215
  const i = {
199
- ...(n = r.capabilities.layer) == null ? void 0 : n.envelopeFields,
200
- ...(o = r.capabilities.envelope) == null ? void 0 : o.request
216
+ ...(r = n.capabilities.layer) == null ? void 0 : r.envelopeFields,
217
+ ...(o = n.capabilities.envelope) == null ? void 0 : o.request
201
218
  };
202
- Object.keys(i).length > 0 && t.push({ id: r.id, envelope: i });
219
+ Object.keys(i).length > 0 && t.push({ id: n.id, envelope: i });
203
220
  }
204
221
  return t;
205
222
  }
206
- function Le(e) {
207
- const t = {}, n = (o) => {
208
- for (const r of ["definitions", "$defs"]) {
209
- const i = o[r];
223
+ function De(e) {
224
+ const t = {}, r = (o) => {
225
+ for (const n of ["definitions", "$defs"]) {
226
+ const i = o[n];
210
227
  if (i)
211
228
  for (const [s, a] of Object.entries(i)) {
212
- const c = s.startsWith("#/") ? s : `#/${r}/${s}`;
229
+ const c = s.startsWith("#/") ? s : `#/${n}/${s}`;
213
230
  t[c] = a;
214
231
  }
215
232
  }
216
233
  };
217
234
  for (const o of Object.values(e.schemas))
218
- n(o.input), n(o.output);
235
+ r(o.input), r(o.output);
219
236
  if (Object.keys(t).length !== 0)
220
- for (const [o, r] of Object.entries(e.schemas))
237
+ for (const [o, n] of Object.entries(e.schemas))
221
238
  try {
222
- ie(r.input, t), ie(r.output, t);
239
+ fe(n.input, t), fe(n.output, t);
223
240
  } catch (i) {
224
241
  throw new Error(
225
242
  `[apigen-core-client] Schema validation failed for function "${o}": ${i.message}`
226
243
  );
227
244
  }
228
245
  }
229
- function Me(e, t) {
230
- const n = [
246
+ function Be(e, t) {
247
+ const r = [
231
248
  'apigen calling convention: all domain parameters go inside a "data" envelope — e.g. { "data": { ... } }' + (t ? "." : " (an empty object for this zero-parameter tool).")
232
249
  ];
233
- return e.length > 0 && n.push(
250
+ return e.length > 0 && r.push(
234
251
  `Field(s) ${e.map((o) => `"${o}"`).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.`
235
- ), n.join(" ");
252
+ ), r.join(" ");
236
253
  }
237
- function _t(e, t, n) {
238
- Le(e);
254
+ function Wt(e, t, r) {
255
+ De(e);
239
256
  const o = {};
240
- for (const [r, i] of Object.entries(e.schemas)) {
241
- const s = (n == null ? void 0 : n[r]) ?? {}, a = i.input.properties ?? {}, c = i.input.required ?? [], l = {}, u = [], f = {};
242
- for (const b of t)
243
- if (b.envelope && s[b.id] !== !1)
244
- for (const [y, h] of Object.entries(b.envelope))
245
- l[y] = h, f[y] = b.id, u.includes(y) || u.push(y);
257
+ for (const [n, i] of Object.entries(e.schemas)) {
258
+ const s = (r == null ? void 0 : r[n]) ?? {}, a = i.input.properties ?? {}, c = i.input.required ?? [], l = {}, u = [], f = {};
259
+ for (const h of t)
260
+ if (h.envelope && s[h.id] !== !1)
261
+ for (const [y, d] of Object.entries(h.envelope))
262
+ l[y] = d, f[y] = h.id, u.includes(y) || u.push(y);
246
263
  const p = {
247
264
  type: "object",
248
265
  properties: a,
249
266
  additionalProperties: !1,
250
267
  ...c.length > 0 ? { required: c } : {}
251
- }, T = i.safe === !0 || _e(i.input), d = i.input.definitions, m = i.input.$defs;
252
- o[r] = {
268
+ }, S = i.safe === !0 || ze(i.input), T = i.input.definitions, m = i.input.$defs;
269
+ o[n] = {
253
270
  input: {
254
271
  type: "object",
255
272
  properties: { ...l, data: p },
@@ -261,17 +278,17 @@ function _t(e, t, n) {
261
278
  // field or the "data" wrapper — no silently-ignored junk params.
262
279
  additionalProperties: !1,
263
280
  // BUG-APIGEN-020: document the envelope/data calling convention inline.
264
- description: Me(
281
+ description: Be(
265
282
  Object.keys(l),
266
283
  Object.keys(a).length > 0
267
284
  ),
268
- ...d ? { definitions: d } : {},
285
+ ...T ? { definitions: T } : {},
269
286
  ...m ? { $defs: m } : {}
270
287
  },
271
288
  output: i.output,
272
289
  // Carry the ctx-param flag through to dispatch (BUG-APIGEN-001).
273
290
  ...i.hasCtx ? { hasCtx: !0 } : {},
274
- "x-apigen-safe": T,
291
+ "x-apigen-safe": S,
275
292
  // DEBT-APIGEN-ENVELOPE-CAPABILITY-UNWIRED-001: field → pluginId map,
276
293
  // read by `op-plan.ts`'s `computeEnvelopeFields`. Omitted (not an empty
277
294
  // object) when no middleware contributed an envelope field, matching
@@ -281,8 +298,8 @@ function _t(e, t, n) {
281
298
  }
282
299
  return o;
283
300
  }
284
- const Ve = 8;
285
- function qe(e, t) {
301
+ const We = 8;
302
+ function Ue(e, t) {
286
303
  try {
287
304
  return t ? e.getText(t) : e.getText();
288
305
  } catch {
@@ -293,12 +310,12 @@ function qe(e, t) {
293
310
  }
294
311
  }
295
312
  }
296
- let ze = 0;
297
- async function Ke(e, t, n, o) {
298
- const r = `__ApigenProbe_${process.pid}_${ze++}`;
313
+ let Ge = 0;
314
+ async function Ze(e, t, r, o) {
315
+ const n = `__ApigenProbe_${process.pid}_${Ge++}`;
299
316
  let i;
300
317
  try {
301
- i = t.addTypeAlias({ name: r, type: n });
318
+ i = t.addTypeAlias({ name: n, type: r });
302
319
  const s = i.getType();
303
320
  return await o(s);
304
321
  } catch {
@@ -310,8 +327,8 @@ async function Ke(e, t, n, o) {
310
327
  }
311
328
  }
312
329
  }
313
- async function be(e, t, n) {
314
- if (n > Ve)
330
+ async function Ae(e, t, r) {
331
+ if (r > We)
315
332
  return {};
316
333
  if (e.isString() || e.isStringLiteral())
317
334
  return e.isStringLiteral() ? { type: "string", enum: [e.getLiteralValue()] } : { type: "string" };
@@ -336,12 +353,12 @@ async function be(e, t, n) {
336
353
  enum: o.map((c) => c.getLiteralValue())
337
354
  };
338
355
  const s = await Promise.all(
339
- o.map((c) => be(c, t, n + 1))
340
- ), a = D(s);
356
+ o.map((c) => Ae(c, t, r + 1))
357
+ ), a = U(s);
341
358
  return {
342
359
  oneOf: s,
343
360
  ...a ? { discriminator: a } : {},
344
- [K]: "union"
361
+ [W]: "union"
345
362
  };
346
363
  }
347
364
  if (e.isArray()) {
@@ -349,34 +366,34 @@ async function be(e, t, n) {
349
366
  return { type: "array", items: o ? await t(o.getText()) : {} };
350
367
  }
351
368
  if (e.isTuple()) {
352
- const o = e.getTupleElements(), r = await Promise.all(
369
+ const o = e.getTupleElements(), n = await Promise.all(
353
370
  o.map((i) => t(i.getText()))
354
371
  );
355
372
  return {
356
373
  type: "array",
357
- items: r,
358
- minItems: r.length,
359
- maxItems: r.length
374
+ items: n,
375
+ minItems: n.length,
376
+ maxItems: n.length
360
377
  };
361
378
  }
362
379
  if (e.isObject()) {
363
- const o = e.getStringIndexType(), r = e.getNumberIndexType(), i = o ?? r, s = e.getProperties();
380
+ const o = e.getStringIndexType(), n = e.getNumberIndexType(), i = o ?? n, s = e.getProperties();
364
381
  if (i && s.length === 0)
365
382
  return { type: "object", additionalProperties: await t(i.getText()) };
366
383
  const a = {}, c = [];
367
384
  for (const l of s) {
368
385
  const u = l.getName(), p = l.getDeclarations()[0];
369
- let T;
386
+ let S;
370
387
  if (p)
371
388
  try {
372
- T = l.getTypeAtLocation(p);
389
+ S = l.getTypeAtLocation(p);
373
390
  } catch {
374
- T = void 0;
391
+ S = void 0;
375
392
  }
376
- if (T !== void 0 && T.getCallSignatures().length > 0)
393
+ if (S !== void 0 && S.getCallSignatures().length > 0)
377
394
  continue;
378
- const d = T !== void 0 ? qe(T, p) : void 0;
379
- a[u] = d !== void 0 ? await t(d) : {}, l.isOptional() || c.push(u);
395
+ const T = S !== void 0 ? Ue(S, p) : void 0;
396
+ a[u] = T !== void 0 ? await t(T) : {}, l.isOptional() || c.push(u);
380
397
  }
381
398
  return Object.keys(a).length > 0 ? {
382
399
  type: "object",
@@ -388,23 +405,23 @@ async function be(e, t, n) {
388
405
  }
389
406
  return {};
390
407
  }
391
- function D(e) {
408
+ function U(e) {
392
409
  if (e.length < 2)
393
410
  return;
394
411
  const t = [];
395
412
  for (const o of e) {
396
413
  if (o.type !== "object")
397
414
  return;
398
- const r = o.properties;
399
- if (!r || typeof r != "object")
415
+ const n = o.properties;
416
+ if (!n || typeof n != "object")
400
417
  return;
401
- t.push(r);
418
+ t.push(n);
402
419
  }
403
- const n = Object.keys(t[0]).filter(
404
- (o) => t.every((r) => Object.prototype.hasOwnProperty.call(r, o))
420
+ const r = Object.keys(t[0]).filter(
421
+ (o) => t.every((n) => Object.prototype.hasOwnProperty.call(n, o))
405
422
  );
406
- for (const o of n) {
407
- const r = [];
423
+ for (const o of r) {
424
+ const n = [];
408
425
  let i = !0;
409
426
  for (const a of t) {
410
427
  const c = a[o], l = c && (c.type === "string" || c.type === "number"), u = c == null ? void 0 : c.enum;
@@ -412,17 +429,17 @@ function D(e) {
412
429
  i = !1;
413
430
  break;
414
431
  }
415
- r.push(String(u[0]));
432
+ n.push(String(u[0]));
416
433
  }
417
- if (!i || new Set(r).size !== r.length)
434
+ if (!i || new Set(n).size !== n.length)
418
435
  continue;
419
436
  const s = {};
420
- return r.forEach((a, c) => {
437
+ return n.forEach((a, c) => {
421
438
  s[a] = `#/oneOf/${c}`;
422
439
  }), { propertyName: o, mapping: s };
423
440
  }
424
441
  }
425
- function q(e, t, n) {
442
+ function D(e, t, r) {
426
443
  if (t > 6)
427
444
  return {};
428
445
  const o = e.trim();
@@ -436,13 +453,13 @@ function q(e, t, n) {
436
453
  return { type: "null" };
437
454
  if (o === "undefined")
438
455
  return { type: "null" };
439
- const r = H[o];
440
- if (r !== void 0)
441
- return r;
442
- if (n != null && n.size) {
443
- const i = n.get(o);
456
+ const n = ee[o];
457
+ if (n !== void 0)
458
+ return n;
459
+ if (r != null && r.size) {
460
+ const i = r.get(o);
444
461
  if (i !== void 0) {
445
- const s = H[i];
462
+ const s = ee[i];
446
463
  if (s !== void 0)
447
464
  return s;
448
465
  }
@@ -450,59 +467,59 @@ function q(e, t, n) {
450
467
  if (o.endsWith("[]"))
451
468
  return {
452
469
  type: "array",
453
- items: q(o.slice(0, -2), t + 1, n)
470
+ items: D(o.slice(0, -2), t + 1, r)
454
471
  };
455
472
  if (o.includes("|")) {
456
473
  const i = o.split("|").map((c) => c.trim());
457
474
  if (i.every((c) => c.startsWith("'")))
458
475
  return { type: "string", enum: i.map((c) => c.replace(/'/g, "")) };
459
- const s = i.map((c) => q(c, t + 1, n)), a = D(s);
476
+ const s = i.map((c) => D(c, t + 1, r)), a = U(s);
460
477
  return {
461
478
  oneOf: s,
462
479
  ...a ? { discriminator: a } : {},
463
- [K]: "union"
480
+ [W]: "union"
464
481
  };
465
482
  }
466
483
  if (o.startsWith("{") && o.endsWith("}")) {
467
484
  const i = o.slice(1, -1).trim(), s = {};
468
485
  for (const a of i.split(";").filter(Boolean)) {
469
486
  const [c, l] = a.split(":").map((u) => u.trim());
470
- c && l && (s[c.replace("?", "")] = q(l, t + 1, n));
487
+ c && l && (s[c.replace("?", "")] = D(l, t + 1, r));
471
488
  }
472
489
  return { type: "object", properties: s };
473
490
  }
474
491
  return {};
475
492
  }
476
- function Se(e) {
493
+ function $e(e) {
477
494
  const t = [];
478
- let n = 0, o = 0;
495
+ let r = 0, o = 0;
479
496
  for (let i = 0; i < e.length; i++) {
480
497
  const s = e[i];
481
- s === "<" || s === "[" || s === "{" || s === "(" ? n++ : s === ">" || s === "]" || s === "}" || s === ")" ? n-- : s === "," && n === 0 && (t.push(e.slice(o, i).trim()), o = i + 1);
498
+ s === "<" || s === "[" || s === "{" || s === "(" ? r++ : s === ">" || s === "]" || s === "}" || s === ")" ? r-- : s === "," && r === 0 && (t.push(e.slice(o, i).trim()), o = i + 1);
482
499
  }
483
- const r = e.slice(o).trim();
484
- return r.length > 0 && t.push(r), t;
500
+ const n = e.slice(o).trim();
501
+ return n.length > 0 && t.push(n), t;
485
502
  }
486
- function De(e) {
503
+ function He(e) {
487
504
  const t = /^(?:Readonly)?Map<(.+)>$/.exec(e);
488
505
  return t ? t[1] : void 0;
489
506
  }
490
- function Be(e) {
507
+ function Je(e) {
491
508
  const t = /^(?:Readonly)?Set<(.+)>$/.exec(e);
492
509
  return t ? t[1] : void 0;
493
510
  }
494
- function We(e) {
511
+ function Qe(e) {
495
512
  let t = e.trim();
496
513
  if (t.startsWith("readonly ") && (t = t.slice(9).trim()), !t.startsWith("[") || !t.endsWith("]"))
497
514
  return;
498
- const n = t.slice(1, -1).trim();
499
- if (n.length !== 0)
500
- return Se(n);
515
+ const r = t.slice(1, -1).trim();
516
+ if (r.length !== 0)
517
+ return $e(r);
501
518
  }
502
- async function Ue(e, t) {
503
- const n = e.trim(), o = De(n);
519
+ async function Xe(e, t) {
520
+ const r = e.trim(), o = He(r);
504
521
  if (o !== void 0) {
505
- const s = Se(o);
522
+ const s = $e(o);
506
523
  if (s.length === 2) {
507
524
  const [a, c] = await Promise.all([
508
525
  t(s[0]),
@@ -519,10 +536,10 @@ async function Ue(e, t) {
519
536
  };
520
537
  }
521
538
  }
522
- const r = Be(n);
523
- if (r !== void 0)
524
- return { type: "array", items: await t(r), uniqueItems: !0 };
525
- const i = We(n);
539
+ const n = Je(r);
540
+ if (n !== void 0)
541
+ return { type: "array", items: await t(n), uniqueItems: !0 };
542
+ const i = Qe(r);
526
543
  if (i !== void 0) {
527
544
  const s = await Promise.all(i.map((a) => t(a)));
528
545
  return {
@@ -533,9 +550,9 @@ async function Ue(e, t) {
533
550
  };
534
551
  }
535
552
  }
536
- const xe = {
553
+ const Ne = {
537
554
  "decimal.js": "Decimal"
538
- }, H = {
555
+ }, ee = {
539
556
  Date: { type: "string", format: "date-time" },
540
557
  bigint: { type: "string", format: "int64" },
541
558
  Uint8Array: { type: "string", format: "byte" },
@@ -543,16 +560,16 @@ const xe = {
543
560
  URL: { type: "string", format: "uri" },
544
561
  RegExp: { type: "string", format: "regex" },
545
562
  Decimal: { type: "string", format: "decimal" }
546
- }, ae = {
563
+ }, me = {
547
564
  Uint8Array: "byte",
548
565
  Buffer: "byte",
549
566
  Decimal: "decimal"
550
567
  };
551
- function ce(e) {
552
- var n;
568
+ function ge(e) {
569
+ var r;
553
570
  const t = /* @__PURE__ */ new Map();
554
571
  for (const o of e.getImportDeclarations()) {
555
- const r = o.getModuleSpecifierValue(), i = xe[r];
572
+ const n = o.getModuleSpecifierValue(), i = Ne[n];
556
573
  if (!i)
557
574
  continue;
558
575
  const s = o.getDefaultImport();
@@ -561,47 +578,47 @@ function ce(e) {
561
578
  a !== i && t.set(a, i);
562
579
  }
563
580
  for (const a of o.getNamedImports()) {
564
- const c = ((n = a.getAliasNode()) == null ? void 0 : n.getText()) ?? a.getName();
581
+ const c = ((r = a.getAliasNode()) == null ? void 0 : r.getText()) ?? a.getName();
565
582
  c !== i && t.set(c, i);
566
583
  }
567
584
  }
568
585
  return t;
569
586
  }
570
- function Ge(e, t) {
571
- return (n) => {
572
- n.addNodeParser({
587
+ function Ye(e, t) {
588
+ return (r) => {
589
+ r.addNodeParser({
573
590
  supportsNode(o) {
574
591
  var i, s, a;
575
592
  if (o.kind !== t)
576
593
  return !1;
577
- const r = ((i = o.typeName) == null ? void 0 : i.escapedText) ?? ((a = (s = o.typeName) == null ? void 0 : s.right) == null ? void 0 : a.escapedText);
578
- return r !== void 0 && Object.prototype.hasOwnProperty.call(ae, r);
594
+ const n = ((i = o.typeName) == null ? void 0 : i.escapedText) ?? ((a = (s = o.typeName) == null ? void 0 : s.right) == null ? void 0 : a.escapedText);
595
+ return n !== void 0 && Object.prototype.hasOwnProperty.call(me, n);
579
596
  },
580
597
  createType(o) {
581
598
  var i, s, a;
582
- const r = ((i = o.typeName) == null ? void 0 : i.escapedText) ?? ((a = (s = o.typeName) == null ? void 0 : s.right) == null ? void 0 : a.escapedText);
583
- return new ne(
584
- new re(),
585
- { format: ae[r] },
599
+ const n = ((i = o.typeName) == null ? void 0 : i.escapedText) ?? ((a = (s = o.typeName) == null ? void 0 : s.right) == null ? void 0 : a.escapedText);
600
+ return new ce(
601
+ new ue(),
602
+ { format: me[n] },
586
603
  !1
587
604
  );
588
605
  }
589
- }), n.addNodeParser({
606
+ }), r.addNodeParser({
590
607
  supportsNode(o) {
591
608
  return o.kind === e;
592
609
  },
593
610
  createType() {
594
- return new ne(new re(), { format: "int64" }, !1);
611
+ return new ce(new ue(), { format: "int64" }, !1);
595
612
  }
596
613
  });
597
614
  };
598
615
  }
599
616
  let C;
600
- function Ze() {
617
+ function et() {
601
618
  if (C)
602
619
  return C;
603
620
  try {
604
- const e = Y.dirname(
621
+ const e = oe.dirname(
605
622
  require.resolve("ts-json-schema-generator/package.json")
606
623
  );
607
624
  C = require(require.resolve("typescript", {
@@ -613,177 +630,177 @@ function Ze() {
613
630
  return C;
614
631
  }
615
632
  const k = /* @__PURE__ */ new Map();
616
- function He() {
633
+ function tt() {
617
634
  const e = process.env.APIGEN_PROGRAM_CACHE, t = e === void 0 ? NaN : Number(e);
618
635
  return Number.isFinite(t) && t >= 0 ? t : 8;
619
636
  }
620
- function Qe(e) {
637
+ function nt(e) {
621
638
  const t = k.get(e);
622
639
  return t && (k.delete(e), k.set(e, t)), t;
623
640
  }
624
- function Je(e, t) {
625
- const n = He();
626
- if (n !== 0)
627
- for (k.delete(e), k.set(e, t); k.size > n; ) {
641
+ function rt(e, t) {
642
+ const r = tt();
643
+ if (r !== 0)
644
+ for (k.delete(e), k.set(e, t); k.size > r; ) {
628
645
  const o = k.keys().next().value;
629
646
  k.delete(o);
630
647
  }
631
648
  }
632
- function Xe(e, t) {
649
+ function ot(e, t) {
633
650
  return `${e}\0${t ?? ""}`;
634
651
  }
635
- const Ye = /* @__PURE__ */ new Set(["zod", /^zod\/./]);
636
- function et(e) {
652
+ const it = /* @__PURE__ */ new Set(["zod", /^zod\/./]);
653
+ function st(e) {
637
654
  for (const t of e.getImportDeclarations()) {
638
- const n = t.getModuleSpecifierValue();
639
- for (const o of Ye)
655
+ const r = t.getModuleSpecifierValue();
656
+ for (const o of it)
640
657
  if (typeof o == "string") {
641
- if (n === o)
658
+ if (r === o)
642
659
  return !0;
643
- } else if (o.test(n))
660
+ } else if (o.test(r))
644
661
  return !0;
645
662
  }
646
663
  return !1;
647
664
  }
648
- function tt(e) {
665
+ function at(e) {
649
666
  for (const t of ["$defs", "definitions"]) {
650
- const n = e[t];
651
- if (!n || typeof n != "object")
667
+ const r = e[t];
668
+ if (!r || typeof r != "object")
652
669
  continue;
653
- const o = Object.keys(n);
670
+ const o = Object.keys(r);
654
671
  if (o.length === 0)
655
672
  continue;
656
- const r = new Set(o.filter((i) => /zod/i.test(i)));
657
- for (const [i, s] of Object.entries(n)) {
658
- if (r.has(i) || typeof s != "object" || s === null)
673
+ const n = new Set(o.filter((i) => /zod/i.test(i)));
674
+ for (const [i, s] of Object.entries(r)) {
675
+ if (n.has(i) || typeof s != "object" || s === null)
659
676
  continue;
660
677
  const a = s, c = typeof a.$ref == "string" ? a.$ref : "";
661
678
  if (c) {
662
- for (const l of r)
679
+ for (const l of n)
663
680
  if (c.includes(l)) {
664
- r.add(i);
681
+ n.add(i);
665
682
  break;
666
683
  }
667
684
  }
668
685
  }
669
- for (const i of r)
670
- delete n[i];
686
+ for (const i of n)
687
+ delete r[i];
671
688
  }
672
- Q(e);
689
+ te(e);
673
690
  }
674
- function Q(e, t) {
691
+ function te(e, t) {
675
692
  if (!e || typeof e != "object")
676
693
  return;
677
- const n = t ?? /* @__PURE__ */ new WeakSet();
678
- if (!n.has(e)) {
679
- n.add(e);
694
+ const r = t ?? /* @__PURE__ */ new WeakSet();
695
+ if (!r.has(e)) {
696
+ r.add(e);
680
697
  for (const o of Object.keys(e))
681
698
  if (o === "$ref" && typeof e[o] == "string") {
682
- const r = e[o];
683
- /zod/i.test(r) && delete e[o];
699
+ const n = e[o];
700
+ /zod/i.test(n) && delete e[o];
684
701
  }
685
702
  for (const [, o] of Object.entries(e))
686
703
  if (typeof o == "object" && o !== null)
687
704
  if (Array.isArray(o))
688
- for (const r of o)
689
- typeof r == "object" && r !== null && Q(r, n);
705
+ for (const n of o)
706
+ typeof n == "object" && n !== null && te(n, r);
690
707
  else
691
- Q(o, n);
708
+ te(o, r);
692
709
  }
693
710
  }
694
- function nt(e) {
711
+ function ct(e) {
695
712
  const t = /* @__PURE__ */ new Set();
696
713
  for (const o of ["$defs", "definitions"]) {
697
- const r = e[o];
698
- if (r && typeof r == "object")
699
- for (const i of Object.keys(r))
714
+ const n = e[o];
715
+ if (n && typeof n == "object")
716
+ for (const i of Object.keys(n))
700
717
  t.add(i);
701
718
  }
702
- const n = J(e, t);
703
- if (n.length > 0)
719
+ const r = ne(e, t);
720
+ if (r.length > 0)
704
721
  throw new Error(
705
- `[apigen-core-client] Generated schema contains ${n.length} unresolvable $ref(s): ${n.join(", ")}. This usually means zod-internal definitions were stripped but $ref references to them remain. Check the source file's imports or the ts-json-schema-generator output.`
722
+ `[apigen-core-client] Generated schema contains ${r.length} unresolvable $ref(s): ${r.join(", ")}. This usually means zod-internal definitions were stripped but $ref references to them remain. Check the source file's imports or the ts-json-schema-generator output.`
706
723
  );
707
724
  }
708
- function J(e, t) {
725
+ function ne(e, t) {
709
726
  if (!e || typeof e != "object")
710
727
  return [];
711
- const n = [];
712
- for (const [o, r] of Object.entries(e))
713
- if (o === "$ref" && typeof r == "string") {
714
- const i = r.match(/#\/(?:\$defs|definitions)\/(.+)$/);
715
- i && !t.has(i[1]) && n.push(r);
716
- } else if (typeof r == "object" && r !== null)
717
- if (Array.isArray(r))
718
- for (const i of r)
719
- typeof i == "object" && i !== null && n.push(
720
- ...J(i, t)
728
+ const r = [];
729
+ for (const [o, n] of Object.entries(e))
730
+ if (o === "$ref" && typeof n == "string") {
731
+ const i = n.match(/#\/(?:\$defs|definitions)\/(.+)$/);
732
+ i && !t.has(i[1]) && r.push(n);
733
+ } else if (typeof n == "object" && n !== null)
734
+ if (Array.isArray(n))
735
+ for (const i of n)
736
+ typeof i == "object" && i !== null && r.push(
737
+ ...ne(i, t)
721
738
  );
722
739
  else
723
- n.push(
724
- ...J(r, t)
740
+ r.push(
741
+ ...ne(n, t)
725
742
  );
726
- return n;
743
+ return r;
727
744
  }
728
- function rt(e) {
745
+ function ut(e) {
729
746
  const t = e.anyOf;
730
747
  if (!Array.isArray(t) || t.length < 2)
731
748
  return e;
732
- const n = t, o = D(n), r = { ...e };
733
- return delete r.anyOf, {
734
- ...r,
735
- oneOf: n,
749
+ const r = t, o = U(r), n = { ...e };
750
+ return delete n.anyOf, {
751
+ ...n,
752
+ oneOf: r,
736
753
  ...o ? { discriminator: o } : {},
737
- [K]: r[K] ?? "union"
754
+ [W]: n[W] ?? "union"
738
755
  };
739
756
  }
740
- function ot(e, t, n) {
741
- const { DEFAULT_CONFIG: o } = require("ts-json-schema-generator/dist/src/Config.js"), r = { ...o, ...e }, i = r.path, s = Xe(i, r.tsconfig);
757
+ function lt(e, t, r) {
758
+ const { DEFAULT_CONFIG: o } = require("ts-json-schema-generator/dist/src/Config.js"), n = { ...o, ...e }, i = n.path, s = ot(i, n.tsconfig);
742
759
  let a;
743
- a = n ? n.statVersion(i) : ye(i);
760
+ a = r ? r.statVersion(i) : xe(i);
744
761
  let c;
745
762
  if (s !== void 0) {
746
- const u = (n == null ? void 0 : n.generatorCache.get(s)) ?? Qe(s);
763
+ const u = (r == null ? void 0 : r.generatorCache.get(s)) ?? nt(s);
747
764
  u && u.version === a && (c = u.gen);
748
765
  }
749
766
  if (!c) {
750
- const { createProgram: u } = require("ts-json-schema-generator/dist/factory/program.js"), f = Ze(), p = Ge(
767
+ const { createProgram: u } = require("ts-json-schema-generator/dist/factory/program.js"), f = et(), p = Ye(
751
768
  f.SyntaxKind.BigIntKeyword,
752
769
  f.SyntaxKind.TypeReference
753
- ), T = u(r), d = ke(
754
- T,
755
- r,
770
+ ), S = u(n), T = Re(
771
+ S,
772
+ n,
756
773
  p
757
- ), m = Ee(r);
758
- if (c = new Ce(
774
+ ), m = Le(n);
775
+ if (c = new _e(
776
+ S,
759
777
  T,
760
- d,
761
778
  m,
762
- r
763
- ), n && n.stats.generatorsBuilt++, s !== void 0 && a !== void 0) {
764
- const b = { version: a, gen: c };
765
- Je(s, b), n == null || n.generatorCache.set(s, b);
779
+ n
780
+ ), r && r.stats.generatorsBuilt++, s !== void 0 && a !== void 0) {
781
+ const h = { version: a, gen: c };
782
+ rt(s, h), r == null || r.generatorCache.set(s, h);
766
783
  }
767
784
  }
768
- const l = c.createSchema(r.type);
769
- return tt(l), nt(l), l;
770
- }
771
- function it(e, t) {
772
- let n = e.trim();
773
- if (n = we(n), t != null && t.size) {
774
- const r = t.get(n);
775
- if (r !== void 0)
776
- return r;
785
+ const l = c.createSchema(n.type);
786
+ return at(l), ct(l), l;
787
+ }
788
+ function ft(e, t) {
789
+ let r = e.trim();
790
+ if (r = Oe(r), t != null && t.size) {
791
+ const n = t.get(r);
792
+ if (n !== void 0)
793
+ return n;
777
794
  }
778
- const o = n.match(/^ReadonlyArray<(.+)>$/);
779
- for (o && (n = `${o[1].trim()}[]`); n.startsWith("readonly "); )
780
- n = n.slice(9).trim();
781
- return n;
795
+ const o = r.match(/^ReadonlyArray<(.+)>$/);
796
+ for (o && (r = `${o[1].trim()}[]`); r.startsWith("readonly "); )
797
+ r = r.slice(9).trim();
798
+ return r;
782
799
  }
783
- function ve(e) {
800
+ function Pe(e) {
784
801
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
785
802
  }
786
- const st = Object.entries(xe).map(([e, t]) => ({
803
+ const pt = Object.entries(Ne).map(([e, t]) => ({
787
804
  // Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
788
805
  // The module specifier appears inside an absolute path, so we allow any
789
806
  // characters between the quote and the specifier, and between the specifier
@@ -791,86 +808,86 @@ const st = Object.entries(xe).map(([e, t]) => ({
791
808
  // …) is matched generically (`\w+`) rather than anchored to one spelling —
792
809
  // see the doc comment above for why.
793
810
  pattern: new RegExp(
794
- `import\\(["'][^"']*${ve(e)}[^"']*["']\\)\\.\\w+`,
811
+ `import\\(["'][^"']*${Pe(e)}[^"']*["']\\)\\.\\w+`,
795
812
  "g"
796
813
  ),
797
814
  key: t
798
815
  }));
799
- function we(e) {
816
+ function Oe(e) {
800
817
  let t = e;
801
- for (const { pattern: n, key: o } of st)
802
- t = t.replace(n, o);
818
+ for (const { pattern: r, key: o } of pt)
819
+ t = t.replace(r, o);
803
820
  return t;
804
821
  }
805
- function at(e, t) {
806
- let n = we(e);
807
- for (const [o, r] of t)
808
- n = n.replace(
809
- new RegExp(`\\b${ve(o)}\\b`, "g"),
810
- r
822
+ function mt(e, t) {
823
+ let r = Oe(e);
824
+ for (const [o, n] of t)
825
+ r = r.replace(
826
+ new RegExp(`\\b${Pe(o)}\\b`, "g"),
827
+ n
811
828
  );
812
- return n;
829
+ return r;
813
830
  }
814
- async function A(e, t, n, o, r, i) {
815
- const s = t.getFilePath(), a = `${s}\0${o ?? ""}\0${n}`, c = i ?? /* @__PURE__ */ new Set();
831
+ async function N(e, t, r, o, n, i) {
832
+ const s = t.getFilePath(), a = `${s}\0${o ?? ""}\0${r}`, c = i ?? /* @__PURE__ */ new Set();
816
833
  if (c.has(a))
817
834
  return {};
818
- if (!r) {
819
- const d = new Set(c);
820
- return d.add(a), ue(
835
+ if (!n) {
836
+ const T = new Set(c);
837
+ return T.add(a), de(
821
838
  e,
822
839
  t,
823
- n,
840
+ r,
824
841
  o,
825
842
  void 0,
826
- d
843
+ T
827
844
  );
828
845
  }
829
- const l = r.schemaCache.get(a);
846
+ const l = n.schemaCache.get(a);
830
847
  if (l !== void 0)
831
- return r.stats.schemaCacheHits++, l;
832
- const u = Fe(
848
+ return n.stats.schemaCacheHits++, l;
849
+ const u = Ve(
833
850
  s,
834
851
  o,
835
- r.statVersion(s)
836
- ), f = u.get(n);
852
+ n.statVersion(s)
853
+ ), f = u.get(r);
837
854
  if (f !== void 0)
838
- return r.stats.schemaCacheHits++, r.schemaCache.set(a, Promise.resolve(f)), f;
839
- r.stats.schemaCacheMisses++;
855
+ return n.stats.schemaCacheHits++, n.schemaCache.set(a, Promise.resolve(f)), f;
856
+ n.stats.schemaCacheMisses++;
840
857
  const p = new Set(c);
841
858
  p.add(a);
842
- const T = ue(
859
+ const S = de(
843
860
  e,
844
861
  t,
845
- n,
846
- o,
847
862
  r,
863
+ o,
864
+ n,
848
865
  p
849
- ).then((d) => (u.set(n, d), d)).catch((d) => {
850
- throw r.schemaCache.delete(a), d;
866
+ ).then((T) => (u.set(r, T), T)).catch((T) => {
867
+ throw n.schemaCache.delete(a), T;
851
868
  });
852
- return r.schemaCache.set(a, T), T;
869
+ return n.schemaCache.set(a, S), S;
853
870
  }
854
- async function ue(e, t, n, o, r, i) {
855
- if (["void", "undefined", "null", "Promise<void>"].includes(n))
871
+ async function de(e, t, r, o, n, i) {
872
+ if (["void", "undefined", "null", "Promise<void>"].includes(r))
856
873
  return { type: "null" };
857
874
  let s;
858
- if (r) {
859
- const p = r.aliasCache.get(t);
860
- s = p ?? ce(t), p || r.aliasCache.set(t, s);
875
+ if (n) {
876
+ const p = n.aliasCache.get(t);
877
+ s = p ?? ge(t), p || n.aliasCache.set(t, s);
861
878
  } else
862
- s = ce(t);
863
- const a = it(n, s), c = H[a];
879
+ s = ge(t);
880
+ const a = ft(r, s), c = ee[a];
864
881
  if (c !== void 0)
865
882
  return c;
866
- const l = await Ue(
883
+ const l = await Xe(
867
884
  a,
868
- (p) => A(e, t, p, o, r, i)
885
+ (p) => N(e, t, p, o, n, i)
869
886
  );
870
887
  if (l !== void 0)
871
888
  return l;
872
- const u = (r == null ? void 0 : r.zodImportCache.get(t)) ?? et(t);
873
- if (r && r.zodImportCache.set(t, u), !u)
889
+ const u = (n == null ? void 0 : n.zodImportCache.get(t)) ?? st(t);
890
+ if (n && n.zodImportCache.set(t, u), !u)
874
891
  try {
875
892
  const p = {
876
893
  path: t.getFilePath(),
@@ -899,18 +916,18 @@ async function ue(e, t, n, o, r, i) {
899
916
  // dereference/hoist pass and is tracked separately, unresolved, in
900
917
  // BUG-APIGEN-026's BACKLOG entry.
901
918
  topRef: !1
902
- }, T = ot(p, !0, r);
903
- return rt(T);
919
+ }, S = lt(p, !0, n);
920
+ return ut(S);
904
921
  } catch {
905
922
  }
906
923
  try {
907
- const p = await Ke(
924
+ const p = await Ze(
908
925
  e,
909
926
  t,
910
927
  a,
911
- (T) => be(
912
- T,
913
- (d) => A(e, t, d, o, r, i),
928
+ (S) => Ae(
929
+ S,
930
+ (T) => N(e, t, T, o, n, i),
914
931
  0
915
932
  )
916
933
  );
@@ -918,20 +935,20 @@ async function ue(e, t, n, o, r, i) {
918
935
  return p;
919
936
  } catch {
920
937
  }
921
- const f = at(a, s);
922
- return q(f, 0, s);
938
+ const f = mt(a, s);
939
+ return D(f, 0, s);
923
940
  }
924
- function ee(e, t, n) {
941
+ function se(e, t, r) {
925
942
  if (e != null && e.hasInitializer()) {
926
943
  const o = e.getInitializer();
927
944
  if (o)
928
945
  return o.getText();
929
946
  }
930
- return ct(n, t);
947
+ return gt(r, t);
931
948
  }
932
- function ct(e, t) {
949
+ function gt(e, t) {
933
950
  var s;
934
- const n = e, o = ((s = n == null ? void 0 : n.getJsDocs) == null ? void 0 : s.call(n)) ?? [], r = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = new RegExp(`\\[\\s*${r}\\s*=\\s*([^\\]]+)\\]`);
951
+ const r = e, o = ((s = r == null ? void 0 : r.getJsDocs) == null ? void 0 : s.call(r)) ?? [], n = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = new RegExp(`\\[\\s*${n}\\s*=\\s*([^\\]]+)\\]`);
935
952
  for (const a of o)
936
953
  for (const c of a.getTags()) {
937
954
  if (c.getTagName() !== "param")
@@ -941,10 +958,10 @@ function ct(e, t) {
941
958
  return l[1].trim();
942
959
  }
943
960
  }
944
- function ut(e) {
945
- const t = e.trim(), n = t.match(/^(['"`])([\s\S]*)\1$/);
946
- if (n)
947
- return n[2];
961
+ function dt(e) {
962
+ const t = e.trim(), r = t.match(/^(['"`])([\s\S]*)\1$/);
963
+ if (r)
964
+ return r[2];
948
965
  if (t === "true")
949
966
  return !0;
950
967
  if (t === "false")
@@ -961,125 +978,160 @@ function ut(e) {
961
978
  }
962
979
  }
963
980
  }
964
- function lt(e, t) {
965
- const n = ut(t);
966
- if (n === void 0)
981
+ function yt(e, t) {
982
+ const r = dt(t);
983
+ if (r === void 0)
967
984
  return;
968
- e.default = n;
969
- const o = typeof n == "string" ? n : JSON.stringify(n), r = typeof e.description == "string" ? e.description : void 0;
970
- e.description = r ? `${r} (default: ${o})` : `(default: ${o})`;
985
+ e.default = r;
986
+ const o = typeof r == "string" ? r : JSON.stringify(r), n = typeof e.description == "string" ? e.description : void 0;
987
+ e.description = n ? `${n} (default: ${o})` : `(default: ${o})`;
971
988
  }
972
- async function Lt(e) {
973
- const t = e.session === void 0, n = Te(e.session ?? he());
989
+ function G(e) {
974
990
  try {
975
- return await ft(e, n);
991
+ if (!e || e.getKind() !== ae.TypeReference)
992
+ return;
993
+ const t = e;
994
+ if (t.getTypeArguments().length > 0)
995
+ return;
996
+ const r = t.getTypeName();
997
+ if (r.getKind() !== ae.Identifier)
998
+ return;
999
+ const n = r.getSymbol();
1000
+ if (!n)
1001
+ return;
1002
+ const i = n.getDeclarations().find((u) => u.getKindName() === "TypeAliasDeclaration");
1003
+ if (!i)
1004
+ return;
1005
+ const s = i, a = s.getType();
1006
+ if (!(a.isString() || a.isNumber() || a.isBoolean()))
1007
+ return;
1008
+ const l = s.getJsDocs();
1009
+ for (const u of l)
1010
+ for (const f of u.getTags())
1011
+ if (f.getTagName() === "format") {
1012
+ const p = f.getCommentText();
1013
+ if (p !== void 0)
1014
+ return p.trim();
1015
+ }
1016
+ return;
1017
+ } catch {
1018
+ return;
1019
+ }
1020
+ }
1021
+ async function Ut(e) {
1022
+ const t = e.session === void 0, r = je(e.session ?? we());
1023
+ try {
1024
+ return await ht(e, r);
976
1025
  } finally {
977
- t && n.dispose();
1026
+ t && r.dispose();
978
1027
  }
979
1028
  }
980
- async function ft(e, t) {
1029
+ async function ht(e, t) {
981
1030
  const {
982
- sourceFile: n,
1031
+ sourceFile: r,
983
1032
  namespace: o = "",
984
- dropFileSegment: r = !1,
1033
+ dropFileSegment: n = !1,
985
1034
  tsconfig: i
986
- } = e, s = t.projectFor(i), a = t.sourceFileFor(n, i), c = Y.basename(n), l = N(gt(c)), u = r ? null : l, f = N(o), p = [];
987
- for (const [m, b] of a.getExportedDeclarations()) {
988
- if (m === "default" || V(m))
1035
+ } = e, s = t.projectFor(i), a = t.sourceFileFor(r, i), c = oe.basename(r), l = P(bt(c)), u = n ? null : l, f = P(o), p = [];
1036
+ for (const [m, h] of a.getExportedDeclarations()) {
1037
+ if (m === "default" || q(m))
989
1038
  continue;
990
- const y = yt(b);
1039
+ const y = xt(h);
991
1040
  if (y) {
992
- const S = y.getSignature(), v = le(S, y), w = S.getReturnType().getText();
1041
+ const g = y.getSignature(), w = he(g, y), v = g.getReturnType().getText(), A = I(g);
993
1042
  p.push(
994
- await M(
1043
+ await K(
995
1044
  s,
996
1045
  a,
997
1046
  f,
998
1047
  u,
999
1048
  m,
1000
- v,
1001
1049
  w,
1050
+ v,
1002
1051
  y.isAsync(),
1003
1052
  i,
1004
- t
1053
+ t,
1054
+ A
1005
1055
  )
1006
1056
  );
1007
1057
  continue;
1008
1058
  }
1009
- const h = b.find(
1010
- (S) => S.getKindName() === "VariableDeclaration"
1059
+ const d = h.find(
1060
+ (g) => g.getKindName() === "VariableDeclaration"
1011
1061
  );
1012
- if (!h)
1062
+ if (!d)
1013
1063
  continue;
1014
- const g = h.getInitializer(), x = g == null ? void 0 : g.getKindName();
1015
- if (g && ["ArrowFunction", "FunctionExpression"].includes(x ?? "")) {
1016
- const v = h.getType().getCallSignatures();
1017
- if (v.length === 0)
1064
+ const b = d.getInitializer(), x = b == null ? void 0 : b.getKindName();
1065
+ if (b && ["ArrowFunction", "FunctionExpression"].includes(x ?? "")) {
1066
+ const w = d.getType().getCallSignatures();
1067
+ if (w.length === 0)
1018
1068
  continue;
1019
- const w = v[0], $ = fe(
1020
- w,
1021
- h,
1022
- h.getVariableStatement()
1023
- ), j = w.getReturnType().getText(), P = g.isAsync();
1069
+ const v = w[0], A = Te(
1070
+ v,
1071
+ d,
1072
+ d.getVariableStatement()
1073
+ ), j = v.getReturnType().getText(), $ = I(v), F = b.isAsync();
1024
1074
  p.push(
1025
- await M(
1075
+ await K(
1026
1076
  s,
1027
1077
  a,
1028
1078
  f,
1029
1079
  u,
1030
1080
  m,
1031
- $,
1081
+ A,
1032
1082
  j,
1033
- P,
1083
+ F,
1034
1084
  i,
1035
- t
1085
+ t,
1086
+ $
1036
1087
  )
1037
1088
  );
1038
1089
  } else if (x === "ObjectLiteralExpression") {
1039
- const S = h.getType();
1040
- for (const v of S.getProperties()) {
1041
- const w = v.getName();
1042
- if (V(w))
1090
+ const g = d.getType();
1091
+ for (const w of g.getProperties()) {
1092
+ const v = w.getName();
1093
+ if (q(v))
1043
1094
  continue;
1044
- const j = v.getTypeAtLocation(h).getCallSignatures();
1095
+ const j = w.getTypeAtLocation(d).getCallSignatures();
1045
1096
  if (j.length === 0)
1046
1097
  continue;
1047
- const P = j[0], B = fe(
1048
- P,
1049
- h,
1050
- h.getVariableStatement()
1051
- ), R = P.getReturnType().getText(), _ = [
1098
+ const $ = j[0], F = Te(
1099
+ $,
1100
+ d,
1101
+ d.getVariableStatement()
1102
+ ), _ = $.getReturnType().getText(), M = I($), Z = [
1052
1103
  ...u ? [u] : [],
1053
- N(m),
1054
- N(w)
1104
+ P(m),
1105
+ P(v)
1055
1106
  ];
1056
1107
  p.push(
1057
- await z(
1108
+ await B(
1058
1109
  s,
1059
1110
  a,
1060
1111
  f,
1112
+ Z,
1113
+ v,
1114
+ F,
1061
1115
  _,
1062
- w,
1063
- B,
1064
- R,
1065
1116
  !1,
1066
1117
  i,
1067
- t
1118
+ t,
1119
+ M
1068
1120
  )
1069
1121
  );
1070
1122
  }
1071
1123
  } else {
1072
- const S = h.getType(), v = S.getText();
1073
- if (E(S, h)) {
1074
- const w = await A(
1124
+ const g = d.getType(), w = g.getText();
1125
+ if (E(g, d)) {
1126
+ const v = await N(
1075
1127
  s,
1076
1128
  a,
1077
- v,
1129
+ w,
1078
1130
  i,
1079
1131
  t
1080
1132
  );
1081
1133
  p.push(
1082
- mt(f, u, m, w)
1134
+ St(f, u, m, v)
1083
1135
  );
1084
1136
  } else
1085
1137
  console.warn(
@@ -1087,130 +1139,134 @@ async function ft(e, t) {
1087
1139
  );
1088
1140
  }
1089
1141
  }
1090
- const T = a.getDefaultExportSymbol();
1091
- if (T) {
1092
- const m = a.getExportAssignment((b) => !b.isExportEquals());
1142
+ const S = a.getDefaultExportSymbol();
1143
+ if (S) {
1144
+ const m = a.getExportAssignment((h) => !h.isExportEquals());
1093
1145
  if (m) {
1094
- const b = m.getExpression(), y = b.getKindName();
1146
+ const h = m.getExpression(), y = h.getKindName();
1095
1147
  if (["ArrowFunction", "FunctionExpression"].includes(y)) {
1096
- const g = b.getType().getCallSignatures();
1097
- if (g.length > 0) {
1098
- const x = g[0], S = W(x, m), v = x.getReturnType().getText(), w = b.isAsync();
1148
+ const b = h.getType().getCallSignatures();
1149
+ if (b.length > 0) {
1150
+ const x = b[0], g = H(x, m), w = x.getReturnType().getText(), v = I(x), A = h.isAsync();
1099
1151
  p.push(
1100
- await M(
1152
+ await K(
1101
1153
  s,
1102
1154
  a,
1103
1155
  f,
1104
1156
  u,
1105
1157
  "default",
1106
- S,
1107
- v,
1158
+ g,
1108
1159
  w,
1160
+ A,
1109
1161
  i,
1110
- t
1162
+ t,
1163
+ v
1111
1164
  )
1112
1165
  );
1113
1166
  }
1114
1167
  } else {
1115
- const h = b.getType();
1116
- for (const g of h.getProperties()) {
1117
- const x = g.getName();
1118
- if (V(x))
1168
+ const d = h.getType();
1169
+ for (const b of d.getProperties()) {
1170
+ const x = b.getName();
1171
+ if (q(x))
1119
1172
  continue;
1120
- const v = g.getTypeAtLocation(m).getCallSignatures();
1121
- if (v.length === 0)
1173
+ const w = b.getTypeAtLocation(m).getCallSignatures();
1174
+ if (w.length === 0)
1122
1175
  continue;
1123
- const w = v[0], $ = W(w, m), j = w.getReturnType().getText(), P = [
1176
+ const v = w[0], A = H(v, m), j = v.getReturnType().getText(), $ = I(v), F = [
1124
1177
  ...u ? [u] : [],
1125
- N("default"),
1126
- N(x)
1178
+ P("default"),
1179
+ P(x)
1127
1180
  ];
1128
1181
  p.push(
1129
- await z(
1182
+ await B(
1130
1183
  s,
1131
1184
  a,
1132
1185
  f,
1133
- P,
1186
+ F,
1134
1187
  x,
1135
- $,
1188
+ A,
1136
1189
  j,
1137
1190
  !1,
1138
1191
  i,
1139
- t
1192
+ t,
1193
+ $
1140
1194
  )
1141
1195
  );
1142
1196
  }
1143
1197
  }
1144
1198
  } else {
1145
- const b = T.getDeclarations();
1146
- for (const y of b) {
1199
+ const h = S.getDeclarations();
1200
+ for (const y of h) {
1147
1201
  if (y.getKindName() !== "FunctionDeclaration")
1148
1202
  continue;
1149
- const h = y, g = h.getName(), x = g && g.length > 0 ? g : "default", S = h.getSignature(), v = le(S, h), w = S.getReturnType().getText();
1203
+ const d = y, b = d.getName(), x = b && b.length > 0 ? b : "default", g = d.getSignature(), w = he(g, d), v = g.getReturnType().getText(), A = I(g);
1150
1204
  p.push(
1151
- await M(
1205
+ await K(
1152
1206
  s,
1153
1207
  a,
1154
1208
  f,
1155
1209
  u,
1156
1210
  x,
1157
- v,
1158
1211
  w,
1159
- h.isAsync(),
1212
+ v,
1213
+ d.isAsync(),
1160
1214
  i,
1161
- t
1215
+ t,
1216
+ A
1162
1217
  )
1163
1218
  );
1164
1219
  }
1165
1220
  }
1166
1221
  }
1167
- const d = dt(a);
1168
- if (d.length > 0)
1169
- for (const { name: m, sig: b } of d) {
1170
- if (V(m))
1222
+ const T = vt(a);
1223
+ if (T.length > 0)
1224
+ for (const { name: m, sig: h } of T) {
1225
+ if (q(m))
1171
1226
  continue;
1172
- const y = W(b), h = b.getReturnType().getText(), g = [
1227
+ const y = H(h), d = h.getReturnType().getText(), b = I(h), x = [
1173
1228
  ...u ? [u] : [],
1174
- N(m)
1229
+ P(m)
1175
1230
  ];
1176
1231
  p.push(
1177
- await z(
1232
+ await B(
1178
1233
  s,
1179
1234
  a,
1180
1235
  f,
1181
- g,
1236
+ x,
1182
1237
  m,
1183
1238
  y,
1184
- h,
1239
+ d,
1185
1240
  !1,
1186
1241
  i,
1187
- t
1242
+ t,
1243
+ b
1188
1244
  )
1189
1245
  );
1190
1246
  }
1191
1247
  return p;
1192
1248
  }
1193
- function pt(e, t, n, o) {
1194
- const r = /* @__PURE__ */ new Set(), i = (s) => {
1249
+ function Tt(e, t, r, o) {
1250
+ const n = /* @__PURE__ */ new Set(), i = (s) => {
1195
1251
  if (Array.isArray(s))
1196
1252
  return s.map(i);
1197
- if (!s || typeof s != "object" || r.has(s))
1253
+ if (!s || typeof s != "object" || n.has(s))
1198
1254
  return s;
1199
- r.add(s);
1255
+ n.add(s);
1200
1256
  try {
1201
1257
  const a = s, c = {};
1202
1258
  for (const [l, u] of Object.entries(a)) {
1203
1259
  if (l === "definitions" || l === "$defs") {
1204
1260
  const f = l, p = t[f];
1205
- for (const [T, d] of Object.entries(
1261
+ for (const [S, T] of Object.entries(
1206
1262
  u
1207
1263
  )) {
1208
- const m = i(d), b = p[T];
1209
- if (b !== void 0 && JSON.stringify(b) !== JSON.stringify(m))
1264
+ const m = i(T), h = p[S];
1265
+ if (h !== void 0 && JSON.stringify(h) !== JSON.stringify(m))
1210
1266
  throw new Error(
1211
- `[apigen-core-client] Function "${n}": param "${o}" contributes a "${f}.${T}" definition that conflicts with an identically-named definition already hoisted from another param/output in the same function. Two structurally different types share the same generated definition key, so apigen cannot safely merge them into one function-level schema.`
1267
+ `[apigen-core-client] Function "${r}": param "${o}" contributes a "${f}.${S}" definition that conflicts with an identically-named definition already hoisted from another param/output in the same function. Two structurally different types share the same generated definition key, so apigen cannot safely merge them into one function-level schema.`
1212
1268
  );
1213
- p[T] = m;
1269
+ p[S] = m;
1214
1270
  }
1215
1271
  continue;
1216
1272
  }
@@ -1218,76 +1274,93 @@ function pt(e, t, n, o) {
1218
1274
  }
1219
1275
  return c;
1220
1276
  } finally {
1221
- r.delete(s);
1277
+ n.delete(s);
1222
1278
  }
1223
1279
  };
1224
1280
  return i(e);
1225
1281
  }
1226
- async function M(e, t, n, o, r, i, s, a, c, l) {
1227
- const u = N(r);
1228
- return z(
1282
+ function ye(e, t) {
1283
+ if (!t || e.format !== void 0 || "$ref" in e || "properties" in e || "items" in e)
1284
+ return;
1285
+ const r = e.type;
1286
+ (r === "string" || r === "number" || r === "integer" || r === "boolean") && (e.format = t);
1287
+ }
1288
+ function I(e) {
1289
+ var t;
1290
+ try {
1291
+ return G((t = e.getDeclaration()) == null ? void 0 : t.getReturnTypeNode());
1292
+ } catch {
1293
+ return;
1294
+ }
1295
+ }
1296
+ async function K(e, t, r, o, n, i, s, a, c, l, u) {
1297
+ const f = P(n);
1298
+ return B(
1229
1299
  e,
1230
1300
  t,
1231
- n,
1232
- o ? [o, u] : [u],
1233
1301
  r,
1302
+ o ? [o, f] : [f],
1303
+ n,
1234
1304
  i,
1235
1305
  s,
1236
1306
  a,
1237
1307
  c,
1238
- l
1308
+ l,
1309
+ u
1239
1310
  );
1240
1311
  }
1241
- async function z(e, t, n, o, r, i, s, a, c, l) {
1242
- const u = i.length > 0 && i[0].name === "ctx", f = i.filter((g) => g.name !== "ctx"), p = f.filter((g) => !g.optional).map((g) => g.name), T = {}, d = {
1312
+ async function B(e, t, r, o, n, i, s, a, c, l, u) {
1313
+ const f = i.length > 0 && i[0].name === "ctx", p = i.filter((g) => g.name !== "ctx"), S = p.filter((g) => !g.optional).map((g) => g.name), T = {}, m = {
1243
1314
  definitions: {},
1244
1315
  $defs: {}
1245
1316
  };
1246
- for (const g of f) {
1247
- const x = await A(e, t, g.type, c, l), S = pt(x, d, r, g.name);
1248
- g.defaultValue !== void 0 && lt(S, g.defaultValue), T[g.name] = S;
1317
+ for (const g of p) {
1318
+ const w = await N(e, t, g.type, c, l), v = Tt(w, m, n, g.name);
1319
+ g.defaultValue !== void 0 && yt(v, g.defaultValue), ye(v, g.format), T[g.name] = v;
1249
1320
  }
1250
- const m = s.replace(/^Promise<(.+)>$/, "$1").trim(), b = await A(
1321
+ const h = s.replace(/^Promise<(.+)>$/, "$1").trim(), y = await N(
1251
1322
  e,
1252
1323
  t,
1253
- m,
1324
+ h,
1254
1325
  c,
1255
1326
  l
1256
- ), y = {
1327
+ ), d = u ? { ...y } : y;
1328
+ ye(d, u);
1329
+ const b = {
1257
1330
  type: "object",
1258
1331
  properties: T,
1259
- required: p,
1332
+ required: S,
1260
1333
  // BUG-APIGEN-029: hoisted definitions from param fragments — see
1261
1334
  // hoistNestedDefs. Only attached when non-empty so the common
1262
1335
  // (no-recursive-type) case's schema shape is unchanged.
1263
- ...Object.keys(d.definitions).length > 0 ? { definitions: d.definitions } : {},
1264
- ...Object.keys(d.$defs).length > 0 ? { $defs: d.$defs } : {}
1336
+ ...Object.keys(m.definitions).length > 0 ? { definitions: m.definitions } : {},
1337
+ ...Object.keys(m.$defs).length > 0 ? { $defs: m.$defs } : {}
1265
1338
  };
1266
1339
  return {
1267
- id: je(n, o),
1340
+ id: ke(r, o),
1268
1341
  host: "ts",
1269
- namespace: n,
1342
+ namespace: r,
1270
1343
  path: o,
1271
1344
  kind: "action",
1272
1345
  async: a,
1273
1346
  streaming: !1,
1274
1347
  safe: !1,
1275
1348
  // action → false per §4
1276
- input: y,
1277
- output: b,
1349
+ input: b,
1350
+ output: d,
1278
1351
  envelope: {},
1279
1352
  typeText: {
1280
1353
  lang: "ts",
1281
- input: ht(i),
1282
- output: m
1354
+ input: wt(i),
1355
+ output: h
1283
1356
  },
1284
- ...u ? { hasCtx: !0 } : {}
1357
+ ...f ? { hasCtx: !0 } : {}
1285
1358
  };
1286
1359
  }
1287
- function mt(e, t, n, o) {
1288
- const r = N(n), i = t ? [t, r] : [r];
1360
+ function St(e, t, r, o) {
1361
+ const n = P(r), i = t ? [t, n] : [n];
1289
1362
  return {
1290
- id: je(e, i),
1363
+ id: ke(e, i),
1291
1364
  host: "ts",
1292
1365
  namespace: e,
1293
1366
  path: i,
@@ -1302,10 +1375,10 @@ function mt(e, t, n, o) {
1302
1375
  typeText: null
1303
1376
  };
1304
1377
  }
1305
- function je(e, t) {
1378
+ function ke(e, t) {
1306
1379
  return (e.raw ? [e, ...t] : t).map((o) => o.words.join("-")).join("/");
1307
1380
  }
1308
- function $e(e) {
1381
+ function Fe(e) {
1309
1382
  return e.split(/[-_.]+/).flatMap(
1310
1383
  (t) => (
1311
1384
  // Then split PascalCase / camelCase transitions
@@ -1313,24 +1386,24 @@ function $e(e) {
1313
1386
  )
1314
1387
  ).map((t) => t.toLowerCase()).filter(Boolean);
1315
1388
  }
1316
- function N(e) {
1317
- return { raw: e, words: $e(e) };
1389
+ function P(e) {
1390
+ return { raw: e, words: Fe(e) };
1318
1391
  }
1319
- function gt(e) {
1392
+ function bt(e) {
1320
1393
  return e.replace(/\.[^.]+$/, "").replace(/[._]+/g, "-");
1321
1394
  }
1322
- function dt(e) {
1395
+ function vt(e) {
1323
1396
  const t = [];
1324
- for (const n of e.getStatements()) {
1325
- if (n.getKindName() !== "ExpressionStatement")
1397
+ for (const r of e.getStatements()) {
1398
+ if (r.getKindName() !== "ExpressionStatement")
1326
1399
  continue;
1327
- const o = n.getExpression();
1400
+ const o = r.getExpression();
1328
1401
  if (o.getKindName() !== "BinaryExpression")
1329
1402
  continue;
1330
- const r = o;
1331
- if (r.getLeft().getText().trim() !== "module.exports" || r.getOperatorToken().getKindName() !== "EqualsToken")
1403
+ const n = o;
1404
+ if (n.getLeft().getText().trim() !== "module.exports" || n.getOperatorToken().getKindName() !== "EqualsToken")
1332
1405
  continue;
1333
- const s = r.getRight(), a = s.getType();
1406
+ const s = n.getRight(), a = s.getType();
1334
1407
  for (const c of a.getProperties()) {
1335
1408
  const u = c.getTypeAtLocation(s).getCallSignatures();
1336
1409
  u.length !== 0 && t.push({ name: c.getName(), sig: u[0] });
@@ -1338,163 +1411,183 @@ function dt(e) {
1338
1411
  }
1339
1412
  return t;
1340
1413
  }
1341
- function yt(e) {
1414
+ function xt(e) {
1342
1415
  let t;
1343
- for (const n of e) {
1344
- if (n.getKindName() !== "FunctionDeclaration")
1416
+ for (const r of e) {
1417
+ if (r.getKindName() !== "FunctionDeclaration")
1345
1418
  continue;
1346
- const o = n;
1419
+ const o = r;
1347
1420
  if (t || (t = o), o.getBody())
1348
1421
  return o;
1349
1422
  }
1350
1423
  return t;
1351
1424
  }
1352
- function le(e, t) {
1353
- return e.getParameters().map((n) => {
1425
+ function he(e, t) {
1426
+ return e.getParameters().map((r) => {
1354
1427
  var s;
1355
- const o = n.getDeclarations(), r = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = n.isOptional() || ((r == null ? void 0 : r.hasInitializer()) ?? !1) || (((s = r == null ? void 0 : r.hasQuestionToken) == null ? void 0 : s.call(r)) ?? !1);
1428
+ const o = r.getDeclarations(), n = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = r.isOptional() || ((n == null ? void 0 : n.hasInitializer()) ?? !1) || (((s = n == null ? void 0 : n.hasQuestionToken) == null ? void 0 : s.call(n)) ?? !1);
1356
1429
  return {
1357
- name: n.getName(),
1358
- type: n.getTypeAtLocation(e.getDeclaration()).getText(),
1430
+ name: r.getName(),
1431
+ type: r.getTypeAtLocation(e.getDeclaration()).getText(),
1359
1432
  optional: i,
1360
- defaultValue: ee(r, n.getName(), t)
1433
+ defaultValue: se(n, r.getName(), t),
1434
+ format: G(n == null ? void 0 : n.getTypeNode())
1361
1435
  };
1362
1436
  });
1363
1437
  }
1364
- function fe(e, t, n) {
1438
+ function Te(e, t, r) {
1365
1439
  return e.getParameters().map((o) => {
1366
1440
  var a;
1367
- const r = o.getDeclarations(), i = r.length > 0 && r[0].getKindName() === "Parameter" ? r[0] : null, s = o.isOptional() || ((i == null ? void 0 : i.hasInitializer()) ?? !1) || (((a = i == null ? void 0 : i.hasQuestionToken) == null ? void 0 : a.call(i)) ?? !1);
1441
+ const n = o.getDeclarations(), i = n.length > 0 && n[0].getKindName() === "Parameter" ? n[0] : null, s = o.isOptional() || ((i == null ? void 0 : i.hasInitializer()) ?? !1) || (((a = i == null ? void 0 : i.hasQuestionToken) == null ? void 0 : a.call(i)) ?? !1);
1368
1442
  return {
1369
1443
  name: o.getName(),
1370
1444
  type: o.getTypeAtLocation(t).getText(),
1371
1445
  optional: s,
1372
- defaultValue: ee(
1446
+ defaultValue: se(
1373
1447
  i,
1374
1448
  o.getName(),
1375
- n ?? t
1376
- )
1449
+ r ?? t
1450
+ ),
1451
+ format: G(i == null ? void 0 : i.getTypeNode())
1377
1452
  };
1378
1453
  });
1379
1454
  }
1380
- function W(e, t) {
1381
- return e.getParameters().map((n) => {
1455
+ function H(e, t) {
1456
+ return e.getParameters().map((r) => {
1382
1457
  var s, a, c;
1383
- const o = n.getDeclarations(), r = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = n.isOptional() || ((r == null ? void 0 : r.hasInitializer()) ?? !1) || (((s = r == null ? void 0 : r.hasQuestionToken) == null ? void 0 : s.call(r)) ?? !1);
1458
+ const o = r.getDeclarations(), n = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = r.isOptional() || ((n == null ? void 0 : n.hasInitializer()) ?? !1) || (((s = n == null ? void 0 : n.hasQuestionToken) == null ? void 0 : s.call(n)) ?? !1);
1384
1459
  return {
1385
- name: n.getName(),
1386
- type: r ? r.getType().getText() : ((c = (a = n.getValueDeclaration()) == null ? void 0 : a.getType()) == null ? void 0 : c.getText()) ?? "unknown",
1460
+ name: r.getName(),
1461
+ type: n ? n.getType().getText() : ((c = (a = r.getValueDeclaration()) == null ? void 0 : a.getType()) == null ? void 0 : c.getText()) ?? "unknown",
1387
1462
  optional: i,
1388
- defaultValue: ee(r, n.getName(), t)
1463
+ defaultValue: se(n, r.getName(), t),
1464
+ format: G(n == null ? void 0 : n.getTypeNode())
1389
1465
  };
1390
1466
  });
1391
1467
  }
1392
- function ht(e) {
1393
- const t = e.filter((n) => n.name !== "ctx");
1394
- return t.length === 0 ? "()" : "(" + t.map((n) => `${n.name}${n.optional ? "?" : ""}: ${n.type}`).join(", ") + ")";
1468
+ function wt(e) {
1469
+ const t = e.filter((r) => r.name !== "ctx");
1470
+ return t.length === 0 ? "()" : "(" + t.map((r) => `${r.name}${r.optional ? "?" : ""}: ${r.type}`).join(", ") + ")";
1395
1471
  }
1396
- function V(e) {
1472
+ function q(e) {
1397
1473
  return !!(e === "__samples__" || e.startsWith("__"));
1398
1474
  }
1399
- function E(e, t, n = /* @__PURE__ */ new Set()) {
1475
+ function E(e, t, r = /* @__PURE__ */ new Set()) {
1400
1476
  if (e.getCallSignatures().length > 0 || e.getConstructSignatures().length > 0)
1401
1477
  return !1;
1402
1478
  if (e.isString() || e.isNumber() || e.isBoolean() || e.isNull() || e.isUndefined() || e.isStringLiteral() || e.isNumberLiteral() || e.isBooleanLiteral() || e.isEnumLiteral())
1403
1479
  return !0;
1404
1480
  if (e.isArray() || e.isReadonlyArray()) {
1405
1481
  const o = e.getArrayElementType();
1406
- return o ? E(o, t, n) : !1;
1482
+ return o ? E(o, t, r) : !1;
1407
1483
  }
1408
1484
  if (e.isTuple())
1409
- return e.getTupleElements().every((o) => E(o, t, n));
1485
+ return e.getTupleElements().every((o) => E(o, t, r));
1410
1486
  if (e.isUnion())
1411
- return e.getUnionTypes().every((o) => E(o, t, n));
1487
+ return e.getUnionTypes().every((o) => E(o, t, r));
1412
1488
  if (e.isIntersection())
1413
- return e.getIntersectionTypes().every((o) => E(o, t, n));
1489
+ return e.getIntersectionTypes().every((o) => E(o, t, r));
1414
1490
  if (e.isObject()) {
1415
1491
  const o = e.getText(t);
1416
- if (n.has(o))
1492
+ if (r.has(o))
1417
1493
  return !0;
1418
- n.add(o);
1419
- const r = e.getStringIndexType(), i = e.getNumberIndexType();
1420
- if (r || i)
1421
- return [r, i].every(
1422
- (a) => !a || E(a, t, n)
1494
+ r.add(o);
1495
+ const n = e.getStringIndexType(), i = e.getNumberIndexType();
1496
+ if (n || i)
1497
+ return [n, i].every(
1498
+ (a) => !a || E(a, t, r)
1423
1499
  );
1424
1500
  const s = e.getProperties();
1425
1501
  return s.length === 0 ? !0 : s.every((a) => {
1426
1502
  const c = a.getTypeAtLocation(t);
1427
- return E(c, t, n);
1503
+ return E(c, t, r);
1428
1504
  });
1429
1505
  }
1430
1506
  return !1;
1431
1507
  }
1432
- async function Mt(e) {
1433
- const t = e.session === void 0, n = Te(e.session ?? he());
1508
+ function jt(e, t) {
1509
+ return async (r) => {
1510
+ let o = () => t(r);
1511
+ for (let n = e.length - 1; n >= 0; n--) {
1512
+ const i = e[n], s = o;
1513
+ o = () => i(r, s);
1514
+ }
1515
+ return o();
1516
+ };
1517
+ }
1518
+ function At(e, t) {
1519
+ return jt(e, t);
1520
+ }
1521
+ function Gt(e, t, r = {}) {
1522
+ const o = e.map((n) => n.capabilities.extractLayer).filter((n) => !!n).map((n) => n.createLayer ? n.createLayer(r) : n.layer).filter((n) => !!n);
1523
+ return At(o, t);
1524
+ }
1525
+ async function Zt(e) {
1526
+ const t = e.session === void 0, r = je(e.session ?? we());
1434
1527
  try {
1435
- return await Tt(e, n);
1528
+ return await $t(e, r);
1436
1529
  } finally {
1437
- t && n.dispose();
1530
+ t && r.dispose();
1438
1531
  }
1439
1532
  }
1440
- async function Tt(e, t) {
1533
+ async function $t(e, t) {
1441
1534
  const {
1442
- sourceFile: n,
1535
+ sourceFile: r,
1443
1536
  namespace: o = "",
1444
- tsconfig: r,
1537
+ tsconfig: n,
1445
1538
  includeInstances: i = !1
1446
- } = e, s = t.projectFor(r), a = t.sourceFileFor(n, r), c = Y.basename(n), l = I(St(c)), u = I(o), f = [];
1447
- for (const [p, T] of a.getExportedDeclarations()) {
1448
- const d = T.find(
1539
+ } = e, s = t.projectFor(n), a = t.sourceFileFor(r, n), c = oe.basename(r), l = R(Pt(c)), u = R(o), f = [];
1540
+ for (const [p, S] of a.getExportedDeclarations()) {
1541
+ const T = S.find(
1449
1542
  (y) => y.getKindName() === "ClassDeclaration"
1450
1543
  );
1451
- if (!d)
1544
+ if (!T)
1452
1545
  continue;
1453
- const m = p === "default" ? d.getName() : p;
1454
- if (!m || G(m))
1546
+ const m = p === "default" ? T.getName() : p;
1547
+ if (!m || Q(m))
1455
1548
  continue;
1456
- const b = I(m);
1457
- for (const y of d.getStaticMethods()) {
1458
- const h = y.getName();
1459
- if (G(h))
1549
+ const h = R(m);
1550
+ for (const y of T.getStaticMethods()) {
1551
+ const d = y.getName();
1552
+ if (Q(d))
1460
1553
  continue;
1461
- const g = y.getScope();
1462
- if (g === L.Private || g === L.Protected)
1554
+ const b = y.getScope();
1555
+ if (b === V.Private || b === V.Protected)
1463
1556
  continue;
1464
- const x = y.getSignature(), S = U(x, y), v = x.getReturnType().getText(), w = y.isAsync(), $ = [l, b, I(h)];
1557
+ const x = y.getSignature(), g = J(x, y), w = x.getReturnType().getText(), v = y.isAsync(), A = [l, h, R(d)];
1465
1558
  f.push(
1466
- await bt(
1559
+ await Nt(
1467
1560
  s,
1468
1561
  a,
1469
1562
  u,
1470
- $,
1471
- S,
1472
- v,
1563
+ A,
1564
+ g,
1473
1565
  w,
1474
- r,
1566
+ v,
1567
+ n,
1475
1568
  t
1476
1569
  )
1477
1570
  );
1478
1571
  }
1479
1572
  if (i) {
1480
1573
  {
1481
- const h = d.getConstructors()[0] ?? null;
1482
- let g = [];
1483
- if (h) {
1484
- const j = h.getSignature();
1485
- g = U(j, h);
1574
+ const d = T.getConstructors()[0] ?? null;
1575
+ let b = [];
1576
+ if (d) {
1577
+ const j = d.getSignature();
1578
+ b = J(j, d);
1486
1579
  }
1487
- const x = [l, b], S = X(u, x), v = g.filter((j) => j.name !== "ctx"), w = v.filter((j) => !j.optional).map((j) => j.name), $ = {};
1488
- for (const j of v)
1489
- $[j.name] = await A(
1580
+ const x = [l, h], g = re(u, x), w = b.filter((j) => j.name !== "ctx"), v = w.filter((j) => !j.optional).map((j) => j.name), A = {};
1581
+ for (const j of w)
1582
+ A[j.name] = await N(
1490
1583
  s,
1491
1584
  a,
1492
1585
  j.type,
1493
- r,
1586
+ n,
1494
1587
  t
1495
1588
  );
1496
1589
  f.push({
1497
- id: S,
1590
+ id: g,
1498
1591
  host: "ts",
1499
1592
  namespace: u,
1500
1593
  path: x,
@@ -1502,7 +1595,7 @@ async function Tt(e, t) {
1502
1595
  async: !1,
1503
1596
  streaming: !1,
1504
1597
  safe: !1,
1505
- input: { type: "object", properties: $, required: w },
1598
+ input: { type: "object", properties: A, required: v },
1506
1599
  output: {
1507
1600
  type: "object",
1508
1601
  properties: { instanceId: { type: "string" } },
@@ -1511,45 +1604,45 @@ async function Tt(e, t) {
1511
1604
  envelope: {},
1512
1605
  typeText: {
1513
1606
  lang: "ts",
1514
- input: xt(g),
1607
+ input: Ot(b),
1515
1608
  output: "{ instanceId: string }"
1516
1609
  }
1517
1610
  });
1518
1611
  }
1519
- for (const y of d.getInstanceMethods()) {
1520
- const h = y.getName();
1521
- if (G(h))
1612
+ for (const y of T.getInstanceMethods()) {
1613
+ const d = y.getName();
1614
+ if (Q(d))
1522
1615
  continue;
1523
- const g = y.getScope();
1524
- if (g === L.Private || g === L.Protected)
1616
+ const b = y.getScope();
1617
+ if (b === V.Private || b === V.Protected)
1525
1618
  continue;
1526
- const x = y.getSignature(), S = U(x, y), v = x.getReturnType().getText(), w = y.isAsync(), $ = [l, b, I(h)], j = X(u, $), P = S.filter((O) => O.name !== "ctx"), B = P.filter((O) => !O.optional).map((O) => O.name), R = {};
1527
- for (const O of P)
1528
- R[O.name] = await A(
1619
+ const x = y.getSignature(), g = J(x, y), w = x.getReturnType().getText(), v = y.isAsync(), A = [l, h, R(d)], j = re(u, A), $ = g.filter((O) => O.name !== "ctx"), F = $.filter((O) => !O.optional).map((O) => O.name), _ = {};
1620
+ for (const O of $)
1621
+ _[O.name] = await N(
1529
1622
  s,
1530
1623
  a,
1531
1624
  O.type,
1532
- r,
1625
+ n,
1533
1626
  t
1534
1627
  );
1535
- const _ = v.replace(/^Promise<(.+)>$/, "$1").trim(), Pe = await A(
1628
+ const M = w.replace(/^Promise<(.+)>$/, "$1").trim(), Z = await N(
1536
1629
  s,
1537
1630
  a,
1538
- _,
1539
- r,
1631
+ M,
1632
+ n,
1540
1633
  t
1541
1634
  );
1542
1635
  f.push({
1543
1636
  id: j,
1544
1637
  host: "ts",
1545
1638
  namespace: u,
1546
- path: $,
1639
+ path: A,
1547
1640
  kind: "instance-method",
1548
- async: w,
1641
+ async: v,
1549
1642
  streaming: !1,
1550
1643
  safe: !1,
1551
- input: { type: "object", properties: R, required: B },
1552
- output: Pe,
1644
+ input: { type: "object", properties: _, required: F },
1645
+ output: Z,
1553
1646
  envelope: {
1554
1647
  type: "object",
1555
1648
  properties: { instanceId: { type: "string" } },
@@ -1557,8 +1650,8 @@ async function Tt(e, t) {
1557
1650
  },
1558
1651
  typeText: {
1559
1652
  lang: "ts",
1560
- input: Ae(S),
1561
- output: _
1653
+ input: Ie(g),
1654
+ output: M
1562
1655
  }
1563
1656
  });
1564
1657
  }
@@ -1566,17 +1659,17 @@ async function Tt(e, t) {
1566
1659
  }
1567
1660
  return f;
1568
1661
  }
1569
- async function bt(e, t, n, o, r, i, s, a, c) {
1570
- const l = r.filter((m) => m.name !== "ctx"), u = l.filter((m) => !m.optional).map((m) => m.name), f = {};
1662
+ async function Nt(e, t, r, o, n, i, s, a, c) {
1663
+ const l = n.filter((m) => m.name !== "ctx"), u = l.filter((m) => !m.optional).map((m) => m.name), f = {};
1571
1664
  for (const m of l)
1572
- f[m.name] = await A(
1665
+ f[m.name] = await N(
1573
1666
  e,
1574
1667
  t,
1575
1668
  m.type,
1576
1669
  a,
1577
1670
  c
1578
1671
  );
1579
- const p = i.replace(/^Promise<(.+)>$/, "$1").trim(), T = await A(
1672
+ const p = i.replace(/^Promise<(.+)>$/, "$1").trim(), S = await N(
1580
1673
  e,
1581
1674
  t,
1582
1675
  p,
@@ -1584,9 +1677,9 @@ async function bt(e, t, n, o, r, i, s, a, c) {
1584
1677
  c
1585
1678
  );
1586
1679
  return {
1587
- id: X(n, o),
1680
+ id: re(r, o),
1588
1681
  host: "ts",
1589
- namespace: n,
1682
+ namespace: r,
1590
1683
  path: o,
1591
1684
  kind: "action",
1592
1685
  async: s,
@@ -1594,46 +1687,46 @@ async function bt(e, t, n, o, r, i, s, a, c) {
1594
1687
  safe: !1,
1595
1688
  // action → false per §4
1596
1689
  input: { type: "object", properties: f, required: u },
1597
- output: T,
1690
+ output: S,
1598
1691
  envelope: {},
1599
1692
  typeText: {
1600
1693
  lang: "ts",
1601
- input: Ae(r),
1694
+ input: Ie(n),
1602
1695
  output: p
1603
1696
  }
1604
1697
  };
1605
1698
  }
1606
- function X(e, t) {
1699
+ function re(e, t) {
1607
1700
  return (e.raw ? [e, ...t] : t).map((o) => o.words.join("-")).join("/");
1608
1701
  }
1609
- function I(e) {
1610
- return { raw: e, words: $e(e) };
1702
+ function R(e) {
1703
+ return { raw: e, words: Fe(e) };
1611
1704
  }
1612
- function St(e) {
1705
+ function Pt(e) {
1613
1706
  return e.replace(/\.[^.]+$/, "").replace(/[._]+/g, "-");
1614
1707
  }
1615
- function U(e, t) {
1616
- return e.getParameters().map((n) => {
1708
+ function J(e, t) {
1709
+ return e.getParameters().map((r) => {
1617
1710
  var s;
1618
- const o = n.getDeclarations(), r = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = n.isOptional() || ((r == null ? void 0 : r.hasInitializer()) ?? !1) || (((s = r == null ? void 0 : r.hasQuestionToken) == null ? void 0 : s.call(r)) ?? !1);
1711
+ const o = r.getDeclarations(), n = o.length > 0 && o[0].getKindName() === "Parameter" ? o[0] : null, i = r.isOptional() || ((n == null ? void 0 : n.hasInitializer()) ?? !1) || (((s = n == null ? void 0 : n.hasQuestionToken) == null ? void 0 : s.call(n)) ?? !1);
1619
1712
  return {
1620
- name: n.getName(),
1621
- type: n.getTypeAtLocation(t).getText(),
1713
+ name: r.getName(),
1714
+ type: r.getTypeAtLocation(t).getText(),
1622
1715
  optional: i
1623
1716
  };
1624
1717
  });
1625
1718
  }
1626
- function Ae(e) {
1627
- const t = e.filter((n) => n.name !== "ctx");
1628
- return t.length === 0 ? "()" : "(" + t.map((n) => `${n.name}${n.optional ? "?" : ""}: ${n.type}`).join(", ") + ")";
1719
+ function Ie(e) {
1720
+ const t = e.filter((r) => r.name !== "ctx");
1721
+ return t.length === 0 ? "()" : "(" + t.map((r) => `${r.name}${r.optional ? "?" : ""}: ${r.type}`).join(", ") + ")";
1629
1722
  }
1630
- function xt(e) {
1723
+ function Ot(e) {
1631
1724
  return e.length === 0 ? "()" : "(" + e.map((t) => `${t.name}${t.optional ? "?" : ""}: ${t.type}`).join(", ") + ")";
1632
1725
  }
1633
- function G(e) {
1726
+ function Q(e) {
1634
1727
  return !!(e === "__samples__" || e.startsWith("__") || e.startsWith("_"));
1635
1728
  }
1636
- const vt = /* @__PURE__ */ new Map([
1729
+ const kt = /* @__PURE__ */ new Map([
1637
1730
  // TypeScript variants
1638
1731
  [".ts", "ts"],
1639
1732
  [".tsx", "ts"],
@@ -1648,21 +1741,21 @@ const vt = /* @__PURE__ */ new Map([
1648
1741
  // Java / Kotlin (both are JVM host languages for the purposes of routing)
1649
1742
  [".java", "java"]
1650
1743
  ]);
1651
- function wt(e) {
1652
- const t = Oe.extname(e).toLowerCase();
1653
- return vt.get(t);
1744
+ function Ft(e) {
1745
+ const t = Ce.extname(e).toLowerCase();
1746
+ return kt.get(t);
1654
1747
  }
1655
- function jt(e) {
1748
+ function It(e) {
1656
1749
  return e.language ?? "ts";
1657
1750
  }
1658
- function $t(e, t) {
1659
- const n = wt(t);
1660
- return n === void 0 ? !1 : n === jt(e);
1751
+ function Et(e, t) {
1752
+ const r = Ft(t);
1753
+ return r === void 0 ? !1 : r === It(e);
1661
1754
  }
1662
- function Vt(e, t) {
1663
- return t.filter((n) => $t(e, n));
1755
+ function Ht(e, t) {
1756
+ return t.filter((r) => Et(e, r));
1664
1757
  }
1665
- function At(e) {
1758
+ function Ct(e) {
1666
1759
  return {
1667
1760
  oneOf: [
1668
1761
  {
@@ -1696,27 +1789,27 @@ function At(e) {
1696
1789
  ]
1697
1790
  };
1698
1791
  }
1699
- function Pt(e) {
1792
+ function Rt(e) {
1700
1793
  return {
1701
1794
  operationConst: e.id,
1702
1795
  itemsSchema: e.input,
1703
- resultSchema: At(e.output)
1796
+ resultSchema: Ct(e.output)
1704
1797
  };
1705
1798
  }
1706
- function Nt(e, t = {}) {
1707
- const n = new Set(t.exclude ?? []), o = /* @__PURE__ */ new Map();
1708
- for (const r of e) {
1709
- if (n.has(r.id))
1799
+ function Lt(e, t = {}) {
1800
+ const r = new Set(t.exclude ?? []), o = /* @__PURE__ */ new Map();
1801
+ for (const n of e) {
1802
+ if (r.has(n.id))
1710
1803
  continue;
1711
- const i = o.get(r.kind);
1712
- i ? i.push(r) : o.set(r.kind, [r]);
1804
+ const i = o.get(n.kind);
1805
+ i ? i.push(n) : o.set(n.kind, [n]);
1713
1806
  }
1714
1807
  return o;
1715
1808
  }
1716
- function pe(e) {
1809
+ function Se(e) {
1717
1810
  return { type: "string", enum: [e] };
1718
1811
  }
1719
- function me(e, t) {
1812
+ function be(e, t) {
1720
1813
  return {
1721
1814
  type: "object",
1722
1815
  required: ["operation", "items"],
@@ -1734,39 +1827,39 @@ function me(e, t) {
1734
1827
  additionalProperties: !0
1735
1828
  };
1736
1829
  }
1737
- function Ot(e) {
1830
+ function _t(e) {
1738
1831
  if (e.length === 0)
1739
1832
  throw new Error("buildBatchKindSchema: at least one operation is required");
1740
- const t = e.map(Pt);
1833
+ const t = e.map(Rt);
1741
1834
  if (e.length === 1) {
1742
- const [r] = e, [i] = t;
1835
+ const [n] = e, [i] = t;
1743
1836
  return {
1744
- input: me(i, pe(r.id)),
1837
+ input: be(i, Se(n.id)),
1745
1838
  output: { type: "array", items: i.resultSchema }
1746
1839
  };
1747
1840
  }
1748
- const n = e.map(
1749
- (r, i) => me(t[i], pe(r.id))
1750
- ), o = D(
1751
- n
1841
+ const r = e.map(
1842
+ (n, i) => be(t[i], Se(n.id))
1843
+ ), o = U(
1844
+ r
1752
1845
  );
1753
1846
  return {
1754
1847
  input: {
1755
- oneOf: n,
1848
+ oneOf: r,
1756
1849
  ...o ? { discriminator: o } : {}
1757
1850
  },
1758
1851
  output: {
1759
- oneOf: t.map((r) => ({ type: "array", items: r.resultSchema }))
1852
+ oneOf: t.map((n) => ({ type: "array", items: n.resultSchema }))
1760
1853
  },
1761
1854
  ...o ? { discriminator: o } : {}
1762
1855
  };
1763
1856
  }
1764
- function qt(e, t = {}) {
1765
- const n = Nt(e.operations, t), o = [];
1766
- for (const [r, i] of n) {
1767
- const { input: s, output: a } = Ot(i), c = Ie(`_batch/${r}`, e, {
1768
- kind: r,
1769
- safe: r === "query",
1857
+ function Jt(e, t = {}) {
1858
+ const r = Lt(e.operations, t), o = [];
1859
+ for (const [n, i] of r) {
1860
+ const { input: s, output: a } = _t(i), c = Me(`_batch/${n}`, e, {
1861
+ kind: n,
1862
+ safe: n === "query",
1770
1863
  input: s,
1771
1864
  output: a
1772
1865
  });
@@ -1778,21 +1871,25 @@ function qt(e, t = {}) {
1778
1871
  return o;
1779
1872
  }
1780
1873
  export {
1781
- Ot as buildBatchKindSchema,
1782
- qt as buildBatchMountedOperations,
1783
- Ft as clearPersistentProjectCache,
1784
- _t as composeSchemas,
1785
- he as createExtractionSession,
1786
- Pt as deriveBatchOperationBranch,
1787
- jt as effectiveLanguage,
1788
- Lt as extract,
1789
- Mt as extractClasses,
1790
- Nt as groupBatchableOperationsByKind,
1791
- _e as isPrimitiveOnlyInputSchema,
1792
- wt as languageOfSource,
1793
- $t as pluginConsumesSource,
1794
- Rt as pluginsToEnvelopeMiddlewares,
1795
- Vt as sourcesForPlugin,
1796
- Ie as syntheticOp,
1797
- $e as tokenize
1874
+ _t as buildBatchKindSchema,
1875
+ Jt as buildBatchMountedOperations,
1876
+ zt as clearPersistentProjectCache,
1877
+ Dt as collectLocalImportPaths,
1878
+ jt as composeOnion,
1879
+ Wt as composeSchemas,
1880
+ At as createExtractInvoker,
1881
+ Gt as createExtractInvokerFromPlugins,
1882
+ we as createExtractionSession,
1883
+ Rt as deriveBatchOperationBranch,
1884
+ It as effectiveLanguage,
1885
+ Ut as extract,
1886
+ Zt as extractClasses,
1887
+ Lt as groupBatchableOperationsByKind,
1888
+ ze as isPrimitiveOnlyInputSchema,
1889
+ Ft as languageOfSource,
1890
+ Et as pluginConsumesSource,
1891
+ Bt as pluginsToEnvelopeMiddlewares,
1892
+ Ht as sourcesForPlugin,
1893
+ Me as syntheticOp,
1894
+ Fe as tokenize
1798
1895
  };