@adhd/apigen-core-client 0.2.0 → 0.2.1

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