@adhd/apigen-core-client 0.2.1 → 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 T of t)
243
- if (T.envelope && s[T.id] !== !1)
244
- for (const [d, y] of Object.entries(T.envelope))
245
- l[d] = y, f[d] = T.id, u.includes(d) || u.push(d);
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
- }, b = i.safe === !0 || _e(i.input), h = 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
- ...h ? { definitions: h } : {},
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": b,
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,56 +366,62 @@ 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
- const a = {};
367
- for (const c of s) {
368
- const l = c.getName(), f = c.getDeclarations()[0];
369
- let p;
370
- if (f)
383
+ const a = {}, c = [];
384
+ for (const l of s) {
385
+ const u = l.getName(), p = l.getDeclarations()[0];
386
+ let S;
387
+ if (p)
371
388
  try {
372
- p = c.getTypeAtLocation(f);
389
+ S = l.getTypeAtLocation(p);
373
390
  } catch {
374
- p = void 0;
391
+ S = void 0;
375
392
  }
376
- if (p !== void 0 && p.getCallSignatures().length > 0)
393
+ if (S !== void 0 && S.getCallSignatures().length > 0)
377
394
  continue;
378
- const b = p !== void 0 ? qe(p, f) : void 0;
379
- a[l] = b !== void 0 ? await t(b) : {};
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
- return Object.keys(a).length > 0 ? { type: "object", properties: a } : {};
398
+ return Object.keys(a).length > 0 ? {
399
+ type: "object",
400
+ properties: a,
401
+ // Match ts-json-schema-generator's own convention: omit `required`
402
+ // entirely when no property is required, rather than emitting `[]`.
403
+ ...c.length > 0 ? { required: c } : {}
404
+ } : {};
382
405
  }
383
406
  return {};
384
407
  }
385
- function D(e) {
408
+ function U(e) {
386
409
  if (e.length < 2)
387
410
  return;
388
411
  const t = [];
389
412
  for (const o of e) {
390
413
  if (o.type !== "object")
391
414
  return;
392
- const r = o.properties;
393
- if (!r || typeof r != "object")
415
+ const n = o.properties;
416
+ if (!n || typeof n != "object")
394
417
  return;
395
- t.push(r);
418
+ t.push(n);
396
419
  }
397
- const n = Object.keys(t[0]).filter(
398
- (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))
399
422
  );
400
- for (const o of n) {
401
- const r = [];
423
+ for (const o of r) {
424
+ const n = [];
402
425
  let i = !0;
403
426
  for (const a of t) {
404
427
  const c = a[o], l = c && (c.type === "string" || c.type === "number"), u = c == null ? void 0 : c.enum;
@@ -406,17 +429,17 @@ function D(e) {
406
429
  i = !1;
407
430
  break;
408
431
  }
409
- r.push(String(u[0]));
432
+ n.push(String(u[0]));
410
433
  }
411
- if (!i || new Set(r).size !== r.length)
434
+ if (!i || new Set(n).size !== n.length)
412
435
  continue;
413
436
  const s = {};
414
- return r.forEach((a, c) => {
437
+ return n.forEach((a, c) => {
415
438
  s[a] = `#/oneOf/${c}`;
416
439
  }), { propertyName: o, mapping: s };
417
440
  }
418
441
  }
419
- function q(e, t, n) {
442
+ function D(e, t, r) {
420
443
  if (t > 6)
421
444
  return {};
422
445
  const o = e.trim();
@@ -430,13 +453,13 @@ function q(e, t, n) {
430
453
  return { type: "null" };
431
454
  if (o === "undefined")
432
455
  return { type: "null" };
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);
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);
438
461
  if (i !== void 0) {
439
- const s = H[i];
462
+ const s = ee[i];
440
463
  if (s !== void 0)
441
464
  return s;
442
465
  }
@@ -444,59 +467,59 @@ function q(e, t, n) {
444
467
  if (o.endsWith("[]"))
445
468
  return {
446
469
  type: "array",
447
- items: q(o.slice(0, -2), t + 1, n)
470
+ items: D(o.slice(0, -2), t + 1, r)
448
471
  };
449
472
  if (o.includes("|")) {
450
473
  const i = o.split("|").map((c) => c.trim());
451
474
  if (i.every((c) => c.startsWith("'")))
452
475
  return { type: "string", enum: i.map((c) => c.replace(/'/g, "")) };
453
- 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);
454
477
  return {
455
478
  oneOf: s,
456
479
  ...a ? { discriminator: a } : {},
457
- [K]: "union"
480
+ [W]: "union"
458
481
  };
459
482
  }
460
483
  if (o.startsWith("{") && o.endsWith("}")) {
461
484
  const i = o.slice(1, -1).trim(), s = {};
462
485
  for (const a of i.split(";").filter(Boolean)) {
463
486
  const [c, l] = a.split(":").map((u) => u.trim());
464
- c && l && (s[c.replace("?", "")] = q(l, t + 1, n));
487
+ c && l && (s[c.replace("?", "")] = D(l, t + 1, r));
465
488
  }
466
489
  return { type: "object", properties: s };
467
490
  }
468
491
  return {};
469
492
  }
470
- function Se(e) {
493
+ function $e(e) {
471
494
  const t = [];
472
- let n = 0, o = 0;
495
+ let r = 0, o = 0;
473
496
  for (let i = 0; i < e.length; i++) {
474
497
  const s = e[i];
475
- 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);
476
499
  }
477
- const r = e.slice(o).trim();
478
- return r.length > 0 && t.push(r), t;
500
+ const n = e.slice(o).trim();
501
+ return n.length > 0 && t.push(n), t;
479
502
  }
480
- function De(e) {
503
+ function He(e) {
481
504
  const t = /^(?:Readonly)?Map<(.+)>$/.exec(e);
482
505
  return t ? t[1] : void 0;
483
506
  }
484
- function Be(e) {
507
+ function Je(e) {
485
508
  const t = /^(?:Readonly)?Set<(.+)>$/.exec(e);
486
509
  return t ? t[1] : void 0;
487
510
  }
488
- function We(e) {
511
+ function Qe(e) {
489
512
  let t = e.trim();
490
513
  if (t.startsWith("readonly ") && (t = t.slice(9).trim()), !t.startsWith("[") || !t.endsWith("]"))
491
514
  return;
492
- const n = t.slice(1, -1).trim();
493
- if (n.length !== 0)
494
- return Se(n);
515
+ const r = t.slice(1, -1).trim();
516
+ if (r.length !== 0)
517
+ return $e(r);
495
518
  }
496
- async function Ue(e, t) {
497
- const n = e.trim(), o = De(n);
519
+ async function Xe(e, t) {
520
+ const r = e.trim(), o = He(r);
498
521
  if (o !== void 0) {
499
- const s = Se(o);
522
+ const s = $e(o);
500
523
  if (s.length === 2) {
501
524
  const [a, c] = await Promise.all([
502
525
  t(s[0]),
@@ -513,10 +536,10 @@ async function Ue(e, t) {
513
536
  };
514
537
  }
515
538
  }
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);
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);
520
543
  if (i !== void 0) {
521
544
  const s = await Promise.all(i.map((a) => t(a)));
522
545
  return {
@@ -527,9 +550,9 @@ async function Ue(e, t) {
527
550
  };
528
551
  }
529
552
  }
530
- const xe = {
553
+ const Ne = {
531
554
  "decimal.js": "Decimal"
532
- }, H = {
555
+ }, ee = {
533
556
  Date: { type: "string", format: "date-time" },
534
557
  bigint: { type: "string", format: "int64" },
535
558
  Uint8Array: { type: "string", format: "byte" },
@@ -537,16 +560,16 @@ const xe = {
537
560
  URL: { type: "string", format: "uri" },
538
561
  RegExp: { type: "string", format: "regex" },
539
562
  Decimal: { type: "string", format: "decimal" }
540
- }, ae = {
563
+ }, me = {
541
564
  Uint8Array: "byte",
542
565
  Buffer: "byte",
543
566
  Decimal: "decimal"
544
567
  };
545
- function ce(e) {
546
- var n;
568
+ function ge(e) {
569
+ var r;
547
570
  const t = /* @__PURE__ */ new Map();
548
571
  for (const o of e.getImportDeclarations()) {
549
- const r = o.getModuleSpecifierValue(), i = xe[r];
572
+ const n = o.getModuleSpecifierValue(), i = Ne[n];
550
573
  if (!i)
551
574
  continue;
552
575
  const s = o.getDefaultImport();
@@ -555,47 +578,47 @@ function ce(e) {
555
578
  a !== i && t.set(a, i);
556
579
  }
557
580
  for (const a of o.getNamedImports()) {
558
- 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();
559
582
  c !== i && t.set(c, i);
560
583
  }
561
584
  }
562
585
  return t;
563
586
  }
564
- function Ge(e, t) {
565
- return (n) => {
566
- n.addNodeParser({
587
+ function Ye(e, t) {
588
+ return (r) => {
589
+ r.addNodeParser({
567
590
  supportsNode(o) {
568
591
  var i, s, a;
569
592
  if (o.kind !== t)
570
593
  return !1;
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);
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);
573
596
  },
574
597
  createType(o) {
575
598
  var i, s, a;
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);
577
- return new ne(
578
- new re(),
579
- { 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] },
580
603
  !1
581
604
  );
582
605
  }
583
- }), n.addNodeParser({
606
+ }), r.addNodeParser({
584
607
  supportsNode(o) {
585
608
  return o.kind === e;
586
609
  },
587
610
  createType() {
588
- return new ne(new re(), { format: "int64" }, !1);
611
+ return new ce(new ue(), { format: "int64" }, !1);
589
612
  }
590
613
  });
591
614
  };
592
615
  }
593
616
  let C;
594
- function Ze() {
617
+ function et() {
595
618
  if (C)
596
619
  return C;
597
620
  try {
598
- const e = Y.dirname(
621
+ const e = oe.dirname(
599
622
  require.resolve("ts-json-schema-generator/package.json")
600
623
  );
601
624
  C = require(require.resolve("typescript", {
@@ -607,177 +630,177 @@ function Ze() {
607
630
  return C;
608
631
  }
609
632
  const k = /* @__PURE__ */ new Map();
610
- function He() {
633
+ function tt() {
611
634
  const e = process.env.APIGEN_PROGRAM_CACHE, t = e === void 0 ? NaN : Number(e);
612
635
  return Number.isFinite(t) && t >= 0 ? t : 8;
613
636
  }
614
- function Qe(e) {
637
+ function nt(e) {
615
638
  const t = k.get(e);
616
639
  return t && (k.delete(e), k.set(e, t)), t;
617
640
  }
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; ) {
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; ) {
622
645
  const o = k.keys().next().value;
623
646
  k.delete(o);
624
647
  }
625
648
  }
626
- function Xe(e, t) {
649
+ function ot(e, t) {
627
650
  return `${e}\0${t ?? ""}`;
628
651
  }
629
- const Ye = /* @__PURE__ */ new Set(["zod", /^zod\/./]);
630
- function et(e) {
652
+ const it = /* @__PURE__ */ new Set(["zod", /^zod\/./]);
653
+ function st(e) {
631
654
  for (const t of e.getImportDeclarations()) {
632
- const n = t.getModuleSpecifierValue();
633
- for (const o of Ye)
655
+ const r = t.getModuleSpecifierValue();
656
+ for (const o of it)
634
657
  if (typeof o == "string") {
635
- if (n === o)
658
+ if (r === o)
636
659
  return !0;
637
- } else if (o.test(n))
660
+ } else if (o.test(r))
638
661
  return !0;
639
662
  }
640
663
  return !1;
641
664
  }
642
- function tt(e) {
665
+ function at(e) {
643
666
  for (const t of ["$defs", "definitions"]) {
644
- const n = e[t];
645
- if (!n || typeof n != "object")
667
+ const r = e[t];
668
+ if (!r || typeof r != "object")
646
669
  continue;
647
- const o = Object.keys(n);
670
+ const o = Object.keys(r);
648
671
  if (o.length === 0)
649
672
  continue;
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)
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)
653
676
  continue;
654
677
  const a = s, c = typeof a.$ref == "string" ? a.$ref : "";
655
678
  if (c) {
656
- for (const l of r)
679
+ for (const l of n)
657
680
  if (c.includes(l)) {
658
- r.add(i);
681
+ n.add(i);
659
682
  break;
660
683
  }
661
684
  }
662
685
  }
663
- for (const i of r)
664
- delete n[i];
686
+ for (const i of n)
687
+ delete r[i];
665
688
  }
666
- Q(e);
689
+ te(e);
667
690
  }
668
- function Q(e, t) {
691
+ function te(e, t) {
669
692
  if (!e || typeof e != "object")
670
693
  return;
671
- const n = t ?? /* @__PURE__ */ new WeakSet();
672
- if (!n.has(e)) {
673
- n.add(e);
694
+ const r = t ?? /* @__PURE__ */ new WeakSet();
695
+ if (!r.has(e)) {
696
+ r.add(e);
674
697
  for (const o of Object.keys(e))
675
698
  if (o === "$ref" && typeof e[o] == "string") {
676
- const r = e[o];
677
- /zod/i.test(r) && delete e[o];
699
+ const n = e[o];
700
+ /zod/i.test(n) && delete e[o];
678
701
  }
679
702
  for (const [, o] of Object.entries(e))
680
703
  if (typeof o == "object" && o !== null)
681
704
  if (Array.isArray(o))
682
- for (const r of o)
683
- typeof r == "object" && r !== null && Q(r, n);
705
+ for (const n of o)
706
+ typeof n == "object" && n !== null && te(n, r);
684
707
  else
685
- Q(o, n);
708
+ te(o, r);
686
709
  }
687
710
  }
688
- function nt(e) {
711
+ function ct(e) {
689
712
  const t = /* @__PURE__ */ new Set();
690
713
  for (const o of ["$defs", "definitions"]) {
691
- const r = e[o];
692
- if (r && typeof r == "object")
693
- 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))
694
717
  t.add(i);
695
718
  }
696
- const n = J(e, t);
697
- if (n.length > 0)
719
+ const r = ne(e, t);
720
+ if (r.length > 0)
698
721
  throw new Error(
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.`
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.`
700
723
  );
701
724
  }
702
- function J(e, t) {
725
+ function ne(e, t) {
703
726
  if (!e || typeof e != "object")
704
727
  return [];
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)
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)
715
738
  );
716
739
  else
717
- n.push(
718
- ...J(r, t)
740
+ r.push(
741
+ ...ne(n, t)
719
742
  );
720
- return n;
743
+ return r;
721
744
  }
722
- function rt(e) {
745
+ function ut(e) {
723
746
  const t = e.anyOf;
724
747
  if (!Array.isArray(t) || t.length < 2)
725
748
  return e;
726
- const n = t, o = D(n), r = { ...e };
727
- return delete r.anyOf, {
728
- ...r,
729
- oneOf: n,
749
+ const r = t, o = U(r), n = { ...e };
750
+ return delete n.anyOf, {
751
+ ...n,
752
+ oneOf: r,
730
753
  ...o ? { discriminator: o } : {},
731
- [K]: r[K] ?? "union"
754
+ [W]: n[W] ?? "union"
732
755
  };
733
756
  }
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);
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);
736
759
  let a;
737
- a = n ? n.statVersion(i) : ye(i);
760
+ a = r ? r.statVersion(i) : xe(i);
738
761
  let c;
739
762
  if (s !== void 0) {
740
- 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);
741
764
  u && u.version === a && (c = u.gen);
742
765
  }
743
766
  if (!c) {
744
- 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(
745
768
  f.SyntaxKind.BigIntKeyword,
746
769
  f.SyntaxKind.TypeReference
747
- ), b = u(r), h = ke(
748
- b,
749
- r,
770
+ ), S = u(n), T = Re(
771
+ S,
772
+ n,
750
773
  p
751
- ), m = Ee(r);
752
- if (c = new Ce(
753
- b,
754
- h,
774
+ ), m = Le(n);
775
+ if (c = new _e(
776
+ S,
777
+ T,
755
778
  m,
756
- r
757
- ), n && n.stats.generatorsBuilt++, s !== void 0 && a !== void 0) {
758
- const T = { version: a, gen: c };
759
- Je(s, T), n == null || n.generatorCache.set(s, T);
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);
760
783
  }
761
784
  }
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;
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;
771
794
  }
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;
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;
776
799
  }
777
- function ve(e) {
800
+ function Pe(e) {
778
801
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
779
802
  }
780
- const st = Object.entries(xe).map(([e, t]) => ({
803
+ const pt = Object.entries(Ne).map(([e, t]) => ({
781
804
  // Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
782
805
  // The module specifier appears inside an absolute path, so we allow any
783
806
  // characters between the quote and the specifier, and between the specifier
@@ -785,86 +808,86 @@ const st = Object.entries(xe).map(([e, t]) => ({
785
808
  // …) is matched generically (`\w+`) rather than anchored to one spelling —
786
809
  // see the doc comment above for why.
787
810
  pattern: new RegExp(
788
- `import\\(["'][^"']*${ve(e)}[^"']*["']\\)\\.\\w+`,
811
+ `import\\(["'][^"']*${Pe(e)}[^"']*["']\\)\\.\\w+`,
789
812
  "g"
790
813
  ),
791
814
  key: t
792
815
  }));
793
- function we(e) {
816
+ function Oe(e) {
794
817
  let t = e;
795
- for (const { pattern: n, key: o } of st)
796
- t = t.replace(n, o);
818
+ for (const { pattern: r, key: o } of pt)
819
+ t = t.replace(r, o);
797
820
  return t;
798
821
  }
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
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
805
828
  );
806
- return n;
829
+ return r;
807
830
  }
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();
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();
810
833
  if (c.has(a))
811
834
  return {};
812
- if (!r) {
813
- const h = new Set(c);
814
- return h.add(a), ue(
835
+ if (!n) {
836
+ const T = new Set(c);
837
+ return T.add(a), de(
815
838
  e,
816
839
  t,
817
- n,
840
+ r,
818
841
  o,
819
842
  void 0,
820
- h
843
+ T
821
844
  );
822
845
  }
823
- const l = r.schemaCache.get(a);
846
+ const l = n.schemaCache.get(a);
824
847
  if (l !== void 0)
825
- return r.stats.schemaCacheHits++, l;
826
- const u = Fe(
848
+ return n.stats.schemaCacheHits++, l;
849
+ const u = Ve(
827
850
  s,
828
851
  o,
829
- r.statVersion(s)
830
- ), f = u.get(n);
852
+ n.statVersion(s)
853
+ ), f = u.get(r);
831
854
  if (f !== void 0)
832
- return r.stats.schemaCacheHits++, r.schemaCache.set(a, Promise.resolve(f)), f;
833
- r.stats.schemaCacheMisses++;
855
+ return n.stats.schemaCacheHits++, n.schemaCache.set(a, Promise.resolve(f)), f;
856
+ n.stats.schemaCacheMisses++;
834
857
  const p = new Set(c);
835
858
  p.add(a);
836
- const b = ue(
859
+ const S = de(
837
860
  e,
838
861
  t,
839
- n,
840
- o,
841
862
  r,
863
+ o,
864
+ n,
842
865
  p
843
- ).then((h) => (u.set(n, h), h)).catch((h) => {
844
- throw r.schemaCache.delete(a), h;
866
+ ).then((T) => (u.set(r, T), T)).catch((T) => {
867
+ throw n.schemaCache.delete(a), T;
845
868
  });
846
- return r.schemaCache.set(a, b), b;
869
+ return n.schemaCache.set(a, S), S;
847
870
  }
848
- async function ue(e, t, n, o, r, i) {
849
- 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))
850
873
  return { type: "null" };
851
874
  let s;
852
- if (r) {
853
- const p = r.aliasCache.get(t);
854
- 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);
855
878
  } else
856
- s = ce(t);
857
- const a = it(n, s), c = H[a];
879
+ s = ge(t);
880
+ const a = ft(r, s), c = ee[a];
858
881
  if (c !== void 0)
859
882
  return c;
860
- const l = await Ue(
883
+ const l = await Xe(
861
884
  a,
862
- (p) => A(e, t, p, o, r, i)
885
+ (p) => N(e, t, p, o, n, i)
863
886
  );
864
887
  if (l !== void 0)
865
888
  return l;
866
- const u = (r == null ? void 0 : r.zodImportCache.get(t)) ?? et(t);
867
- 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)
868
891
  try {
869
892
  const p = {
870
893
  path: t.getFilePath(),
@@ -893,18 +916,18 @@ async function ue(e, t, n, o, r, i) {
893
916
  // dereference/hoist pass and is tracked separately, unresolved, in
894
917
  // BUG-APIGEN-026's BACKLOG entry.
895
918
  topRef: !1
896
- }, b = ot(p, !0, r);
897
- return rt(b);
919
+ }, S = lt(p, !0, n);
920
+ return ut(S);
898
921
  } catch {
899
922
  }
900
923
  try {
901
- const p = await Ke(
924
+ const p = await Ze(
902
925
  e,
903
926
  t,
904
927
  a,
905
- (b) => be(
906
- b,
907
- (h) => A(e, t, h, o, r, i),
928
+ (S) => Ae(
929
+ S,
930
+ (T) => N(e, t, T, o, n, i),
908
931
  0
909
932
  )
910
933
  );
@@ -912,20 +935,20 @@ async function ue(e, t, n, o, r, i) {
912
935
  return p;
913
936
  } catch {
914
937
  }
915
- const f = at(a, s);
916
- return q(f, 0, s);
938
+ const f = mt(a, s);
939
+ return D(f, 0, s);
917
940
  }
918
- function ee(e, t, n) {
941
+ function se(e, t, r) {
919
942
  if (e != null && e.hasInitializer()) {
920
943
  const o = e.getInitializer();
921
944
  if (o)
922
945
  return o.getText();
923
946
  }
924
- return ct(n, t);
947
+ return gt(r, t);
925
948
  }
926
- function ct(e, t) {
949
+ function gt(e, t) {
927
950
  var 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*([^\\]]+)\\]`);
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*([^\\]]+)\\]`);
929
952
  for (const a of o)
930
953
  for (const c of a.getTags()) {
931
954
  if (c.getTagName() !== "param")
@@ -935,10 +958,10 @@ function ct(e, t) {
935
958
  return l[1].trim();
936
959
  }
937
960
  }
938
- function ut(e) {
939
- const t = e.trim(), n = t.match(/^(['"`])([\s\S]*)\1$/);
940
- if (n)
941
- 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];
942
965
  if (t === "true")
943
966
  return !0;
944
967
  if (t === "false")
@@ -955,125 +978,160 @@ function ut(e) {
955
978
  }
956
979
  }
957
980
  }
958
- function lt(e, t) {
959
- const n = ut(t);
960
- if (n === void 0)
981
+ function yt(e, t) {
982
+ const r = dt(t);
983
+ if (r === void 0)
984
+ return;
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})`;
988
+ }
989
+ function G(e) {
990
+ try {
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 {
961
1018
  return;
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})`;
1019
+ }
965
1020
  }
966
- async function Lt(e) {
967
- const t = e.session === void 0, n = Te(e.session ?? he());
1021
+ async function Ut(e) {
1022
+ const t = e.session === void 0, r = je(e.session ?? we());
968
1023
  try {
969
- return await ft(e, n);
1024
+ return await ht(e, r);
970
1025
  } finally {
971
- t && n.dispose();
1026
+ t && r.dispose();
972
1027
  }
973
1028
  }
974
- async function ft(e, t) {
1029
+ async function ht(e, t) {
975
1030
  const {
976
- sourceFile: n,
1031
+ sourceFile: r,
977
1032
  namespace: o = "",
978
- dropFileSegment: r = !1,
1033
+ dropFileSegment: n = !1,
979
1034
  tsconfig: i
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 = [];
981
- for (const [m, T] of a.getExportedDeclarations()) {
982
- 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))
983
1038
  continue;
984
- const d = yt(T);
985
- if (d) {
986
- const S = d.getSignature(), v = le(S, d), w = S.getReturnType().getText();
1039
+ const y = xt(h);
1040
+ if (y) {
1041
+ const g = y.getSignature(), w = he(g, y), v = g.getReturnType().getText(), A = I(g);
987
1042
  p.push(
988
- await M(
1043
+ await K(
989
1044
  s,
990
1045
  a,
991
1046
  f,
992
1047
  u,
993
1048
  m,
994
- v,
995
1049
  w,
996
- d.isAsync(),
1050
+ v,
1051
+ y.isAsync(),
997
1052
  i,
998
- t
1053
+ t,
1054
+ A
999
1055
  )
1000
1056
  );
1001
1057
  continue;
1002
1058
  }
1003
- const y = T.find(
1004
- (S) => S.getKindName() === "VariableDeclaration"
1059
+ const d = h.find(
1060
+ (g) => g.getKindName() === "VariableDeclaration"
1005
1061
  );
1006
- if (!y)
1062
+ if (!d)
1007
1063
  continue;
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)
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)
1012
1068
  continue;
1013
- const w = v[0], $ = fe(
1014
- w,
1015
- y,
1016
- y.getVariableStatement()
1017
- ), 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();
1018
1074
  p.push(
1019
- await M(
1075
+ await K(
1020
1076
  s,
1021
1077
  a,
1022
1078
  f,
1023
1079
  u,
1024
1080
  m,
1025
- $,
1081
+ A,
1026
1082
  j,
1027
- P,
1083
+ F,
1028
1084
  i,
1029
- t
1085
+ t,
1086
+ $
1030
1087
  )
1031
1088
  );
1032
1089
  } else if (x === "ObjectLiteralExpression") {
1033
- const S = y.getType();
1034
- for (const v of S.getProperties()) {
1035
- const w = v.getName();
1036
- if (V(w))
1090
+ const g = d.getType();
1091
+ for (const w of g.getProperties()) {
1092
+ const v = w.getName();
1093
+ if (q(v))
1037
1094
  continue;
1038
- const j = v.getTypeAtLocation(y).getCallSignatures();
1095
+ const j = w.getTypeAtLocation(d).getCallSignatures();
1039
1096
  if (j.length === 0)
1040
1097
  continue;
1041
- const P = j[0], B = fe(
1042
- P,
1043
- y,
1044
- y.getVariableStatement()
1045
- ), R = P.getReturnType().getText(), _ = [
1098
+ const $ = j[0], F = Te(
1099
+ $,
1100
+ d,
1101
+ d.getVariableStatement()
1102
+ ), _ = $.getReturnType().getText(), M = I($), Z = [
1046
1103
  ...u ? [u] : [],
1047
- N(m),
1048
- N(w)
1104
+ P(m),
1105
+ P(v)
1049
1106
  ];
1050
1107
  p.push(
1051
- await z(
1108
+ await B(
1052
1109
  s,
1053
1110
  a,
1054
1111
  f,
1112
+ Z,
1113
+ v,
1114
+ F,
1055
1115
  _,
1056
- w,
1057
- B,
1058
- R,
1059
1116
  !1,
1060
1117
  i,
1061
- t
1118
+ t,
1119
+ M
1062
1120
  )
1063
1121
  );
1064
1122
  }
1065
1123
  } else {
1066
- const S = y.getType(), v = S.getText();
1067
- if (E(S, y)) {
1068
- const w = await A(
1124
+ const g = d.getType(), w = g.getText();
1125
+ if (E(g, d)) {
1126
+ const v = await N(
1069
1127
  s,
1070
1128
  a,
1071
- v,
1129
+ w,
1072
1130
  i,
1073
1131
  t
1074
1132
  );
1075
1133
  p.push(
1076
- mt(f, u, m, w)
1134
+ St(f, u, m, v)
1077
1135
  );
1078
1136
  } else
1079
1137
  console.warn(
@@ -1081,130 +1139,134 @@ async function ft(e, t) {
1081
1139
  );
1082
1140
  }
1083
1141
  }
1084
- const b = a.getDefaultExportSymbol();
1085
- if (b) {
1086
- const m = a.getExportAssignment((T) => !T.isExportEquals());
1142
+ const S = a.getDefaultExportSymbol();
1143
+ if (S) {
1144
+ const m = a.getExportAssignment((h) => !h.isExportEquals());
1087
1145
  if (m) {
1088
- const T = m.getExpression(), d = T.getKindName();
1089
- if (["ArrowFunction", "FunctionExpression"].includes(d)) {
1090
- const g = T.getType().getCallSignatures();
1091
- if (g.length > 0) {
1092
- const x = g[0], S = W(x, m), v = x.getReturnType().getText(), w = T.isAsync();
1146
+ const h = m.getExpression(), y = h.getKindName();
1147
+ if (["ArrowFunction", "FunctionExpression"].includes(y)) {
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();
1093
1151
  p.push(
1094
- await M(
1152
+ await K(
1095
1153
  s,
1096
1154
  a,
1097
1155
  f,
1098
1156
  u,
1099
1157
  "default",
1100
- S,
1101
- v,
1158
+ g,
1102
1159
  w,
1160
+ A,
1103
1161
  i,
1104
- t
1162
+ t,
1163
+ v
1105
1164
  )
1106
1165
  );
1107
1166
  }
1108
1167
  } else {
1109
- const y = T.getType();
1110
- for (const g of y.getProperties()) {
1111
- const x = g.getName();
1112
- if (V(x))
1168
+ const d = h.getType();
1169
+ for (const b of d.getProperties()) {
1170
+ const x = b.getName();
1171
+ if (q(x))
1113
1172
  continue;
1114
- const v = g.getTypeAtLocation(m).getCallSignatures();
1115
- if (v.length === 0)
1173
+ const w = b.getTypeAtLocation(m).getCallSignatures();
1174
+ if (w.length === 0)
1116
1175
  continue;
1117
- 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 = [
1118
1177
  ...u ? [u] : [],
1119
- N("default"),
1120
- N(x)
1178
+ P("default"),
1179
+ P(x)
1121
1180
  ];
1122
1181
  p.push(
1123
- await z(
1182
+ await B(
1124
1183
  s,
1125
1184
  a,
1126
1185
  f,
1127
- P,
1186
+ F,
1128
1187
  x,
1129
- $,
1188
+ A,
1130
1189
  j,
1131
1190
  !1,
1132
1191
  i,
1133
- t
1192
+ t,
1193
+ $
1134
1194
  )
1135
1195
  );
1136
1196
  }
1137
1197
  }
1138
1198
  } else {
1139
- const T = b.getDeclarations();
1140
- for (const d of T) {
1141
- if (d.getKindName() !== "FunctionDeclaration")
1199
+ const h = S.getDeclarations();
1200
+ for (const y of h) {
1201
+ if (y.getKindName() !== "FunctionDeclaration")
1142
1202
  continue;
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();
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);
1144
1204
  p.push(
1145
- await M(
1205
+ await K(
1146
1206
  s,
1147
1207
  a,
1148
1208
  f,
1149
1209
  u,
1150
1210
  x,
1151
- v,
1152
1211
  w,
1153
- y.isAsync(),
1212
+ v,
1213
+ d.isAsync(),
1154
1214
  i,
1155
- t
1215
+ t,
1216
+ A
1156
1217
  )
1157
1218
  );
1158
1219
  }
1159
1220
  }
1160
1221
  }
1161
- const h = dt(a);
1162
- if (h.length > 0)
1163
- for (const { name: m, sig: T } of h) {
1164
- 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))
1165
1226
  continue;
1166
- const d = W(T), y = T.getReturnType().getText(), g = [
1227
+ const y = H(h), d = h.getReturnType().getText(), b = I(h), x = [
1167
1228
  ...u ? [u] : [],
1168
- N(m)
1229
+ P(m)
1169
1230
  ];
1170
1231
  p.push(
1171
- await z(
1232
+ await B(
1172
1233
  s,
1173
1234
  a,
1174
1235
  f,
1175
- g,
1236
+ x,
1176
1237
  m,
1177
- d,
1178
1238
  y,
1239
+ d,
1179
1240
  !1,
1180
1241
  i,
1181
- t
1242
+ t,
1243
+ b
1182
1244
  )
1183
1245
  );
1184
1246
  }
1185
1247
  return p;
1186
1248
  }
1187
- function pt(e, t, n, o) {
1188
- const r = /* @__PURE__ */ new Set(), i = (s) => {
1249
+ function Tt(e, t, r, o) {
1250
+ const n = /* @__PURE__ */ new Set(), i = (s) => {
1189
1251
  if (Array.isArray(s))
1190
1252
  return s.map(i);
1191
- if (!s || typeof s != "object" || r.has(s))
1253
+ if (!s || typeof s != "object" || n.has(s))
1192
1254
  return s;
1193
- r.add(s);
1255
+ n.add(s);
1194
1256
  try {
1195
1257
  const a = s, c = {};
1196
1258
  for (const [l, u] of Object.entries(a)) {
1197
1259
  if (l === "definitions" || l === "$defs") {
1198
1260
  const f = l, p = t[f];
1199
- for (const [b, h] of Object.entries(
1261
+ for (const [S, T] of Object.entries(
1200
1262
  u
1201
1263
  )) {
1202
- const m = i(h), T = p[b];
1203
- if (T !== void 0 && JSON.stringify(T) !== JSON.stringify(m))
1264
+ const m = i(T), h = p[S];
1265
+ if (h !== void 0 && JSON.stringify(h) !== JSON.stringify(m))
1204
1266
  throw new Error(
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.`
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.`
1206
1268
  );
1207
- p[b] = m;
1269
+ p[S] = m;
1208
1270
  }
1209
1271
  continue;
1210
1272
  }
@@ -1212,76 +1274,93 @@ function pt(e, t, n, o) {
1212
1274
  }
1213
1275
  return c;
1214
1276
  } finally {
1215
- r.delete(s);
1277
+ n.delete(s);
1216
1278
  }
1217
1279
  };
1218
1280
  return i(e);
1219
1281
  }
1220
- async function M(e, t, n, o, r, i, s, a, c, l) {
1221
- const u = N(r);
1222
- 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(
1223
1299
  e,
1224
1300
  t,
1225
- n,
1226
- o ? [o, u] : [u],
1227
1301
  r,
1302
+ o ? [o, f] : [f],
1303
+ n,
1228
1304
  i,
1229
1305
  s,
1230
1306
  a,
1231
1307
  c,
1232
- l
1308
+ l,
1309
+ u
1233
1310
  );
1234
1311
  }
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 = {
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 = {
1237
1314
  definitions: {},
1238
1315
  $defs: {}
1239
1316
  };
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;
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;
1243
1320
  }
1244
- const m = s.replace(/^Promise<(.+)>$/, "$1").trim(), T = await A(
1321
+ const h = s.replace(/^Promise<(.+)>$/, "$1").trim(), y = await N(
1245
1322
  e,
1246
1323
  t,
1247
- m,
1324
+ h,
1248
1325
  c,
1249
1326
  l
1250
- ), d = {
1327
+ ), d = u ? { ...y } : y;
1328
+ ye(d, u);
1329
+ const b = {
1251
1330
  type: "object",
1252
- properties: b,
1253
- required: p,
1331
+ properties: T,
1332
+ required: S,
1254
1333
  // BUG-APIGEN-029: hoisted definitions from param fragments — see
1255
1334
  // hoistNestedDefs. Only attached when non-empty so the common
1256
1335
  // (no-recursive-type) case's schema shape is unchanged.
1257
- ...Object.keys(h.definitions).length > 0 ? { definitions: h.definitions } : {},
1258
- ...Object.keys(h.$defs).length > 0 ? { $defs: h.$defs } : {}
1336
+ ...Object.keys(m.definitions).length > 0 ? { definitions: m.definitions } : {},
1337
+ ...Object.keys(m.$defs).length > 0 ? { $defs: m.$defs } : {}
1259
1338
  };
1260
1339
  return {
1261
- id: je(n, o),
1340
+ id: ke(r, o),
1262
1341
  host: "ts",
1263
- namespace: n,
1342
+ namespace: r,
1264
1343
  path: o,
1265
1344
  kind: "action",
1266
1345
  async: a,
1267
1346
  streaming: !1,
1268
1347
  safe: !1,
1269
1348
  // action → false per §4
1270
- input: d,
1271
- output: T,
1349
+ input: b,
1350
+ output: d,
1272
1351
  envelope: {},
1273
1352
  typeText: {
1274
1353
  lang: "ts",
1275
- input: ht(i),
1276
- output: m
1354
+ input: wt(i),
1355
+ output: h
1277
1356
  },
1278
- ...u ? { hasCtx: !0 } : {}
1357
+ ...f ? { hasCtx: !0 } : {}
1279
1358
  };
1280
1359
  }
1281
- function mt(e, t, n, o) {
1282
- 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];
1283
1362
  return {
1284
- id: je(e, i),
1363
+ id: ke(e, i),
1285
1364
  host: "ts",
1286
1365
  namespace: e,
1287
1366
  path: i,
@@ -1296,10 +1375,10 @@ function mt(e, t, n, o) {
1296
1375
  typeText: null
1297
1376
  };
1298
1377
  }
1299
- function je(e, t) {
1378
+ function ke(e, t) {
1300
1379
  return (e.raw ? [e, ...t] : t).map((o) => o.words.join("-")).join("/");
1301
1380
  }
1302
- function $e(e) {
1381
+ function Fe(e) {
1303
1382
  return e.split(/[-_.]+/).flatMap(
1304
1383
  (t) => (
1305
1384
  // Then split PascalCase / camelCase transitions
@@ -1307,24 +1386,24 @@ function $e(e) {
1307
1386
  )
1308
1387
  ).map((t) => t.toLowerCase()).filter(Boolean);
1309
1388
  }
1310
- function N(e) {
1311
- return { raw: e, words: $e(e) };
1389
+ function P(e) {
1390
+ return { raw: e, words: Fe(e) };
1312
1391
  }
1313
- function gt(e) {
1392
+ function bt(e) {
1314
1393
  return e.replace(/\.[^.]+$/, "").replace(/[._]+/g, "-");
1315
1394
  }
1316
- function dt(e) {
1395
+ function vt(e) {
1317
1396
  const t = [];
1318
- for (const n of e.getStatements()) {
1319
- if (n.getKindName() !== "ExpressionStatement")
1397
+ for (const r of e.getStatements()) {
1398
+ if (r.getKindName() !== "ExpressionStatement")
1320
1399
  continue;
1321
- const o = n.getExpression();
1400
+ const o = r.getExpression();
1322
1401
  if (o.getKindName() !== "BinaryExpression")
1323
1402
  continue;
1324
- const r = o;
1325
- 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")
1326
1405
  continue;
1327
- const s = r.getRight(), a = s.getType();
1406
+ const s = n.getRight(), a = s.getType();
1328
1407
  for (const c of a.getProperties()) {
1329
1408
  const u = c.getTypeAtLocation(s).getCallSignatures();
1330
1409
  u.length !== 0 && t.push({ name: c.getName(), sig: u[0] });
@@ -1332,163 +1411,183 @@ function dt(e) {
1332
1411
  }
1333
1412
  return t;
1334
1413
  }
1335
- function yt(e) {
1414
+ function xt(e) {
1336
1415
  let t;
1337
- for (const n of e) {
1338
- if (n.getKindName() !== "FunctionDeclaration")
1416
+ for (const r of e) {
1417
+ if (r.getKindName() !== "FunctionDeclaration")
1339
1418
  continue;
1340
- const o = n;
1419
+ const o = r;
1341
1420
  if (t || (t = o), o.getBody())
1342
1421
  return o;
1343
1422
  }
1344
1423
  return t;
1345
1424
  }
1346
- function le(e, t) {
1347
- return e.getParameters().map((n) => {
1425
+ function he(e, t) {
1426
+ return e.getParameters().map((r) => {
1348
1427
  var s;
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);
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);
1350
1429
  return {
1351
- name: n.getName(),
1352
- type: n.getTypeAtLocation(e.getDeclaration()).getText(),
1430
+ name: r.getName(),
1431
+ type: r.getTypeAtLocation(e.getDeclaration()).getText(),
1353
1432
  optional: i,
1354
- defaultValue: ee(r, n.getName(), t)
1433
+ defaultValue: se(n, r.getName(), t),
1434
+ format: G(n == null ? void 0 : n.getTypeNode())
1355
1435
  };
1356
1436
  });
1357
1437
  }
1358
- function fe(e, t, n) {
1438
+ function Te(e, t, r) {
1359
1439
  return e.getParameters().map((o) => {
1360
1440
  var a;
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);
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);
1362
1442
  return {
1363
1443
  name: o.getName(),
1364
1444
  type: o.getTypeAtLocation(t).getText(),
1365
1445
  optional: s,
1366
- defaultValue: ee(
1446
+ defaultValue: se(
1367
1447
  i,
1368
1448
  o.getName(),
1369
- n ?? t
1370
- )
1449
+ r ?? t
1450
+ ),
1451
+ format: G(i == null ? void 0 : i.getTypeNode())
1371
1452
  };
1372
1453
  });
1373
1454
  }
1374
- function W(e, t) {
1375
- return e.getParameters().map((n) => {
1455
+ function H(e, t) {
1456
+ return e.getParameters().map((r) => {
1376
1457
  var s, a, c;
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);
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);
1378
1459
  return {
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",
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",
1381
1462
  optional: i,
1382
- defaultValue: ee(r, n.getName(), t)
1463
+ defaultValue: se(n, r.getName(), t),
1464
+ format: G(n == null ? void 0 : n.getTypeNode())
1383
1465
  };
1384
1466
  });
1385
1467
  }
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(", ") + ")";
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(", ") + ")";
1389
1471
  }
1390
- function V(e) {
1472
+ function q(e) {
1391
1473
  return !!(e === "__samples__" || e.startsWith("__"));
1392
1474
  }
1393
- function E(e, t, n = /* @__PURE__ */ new Set()) {
1475
+ function E(e, t, r = /* @__PURE__ */ new Set()) {
1394
1476
  if (e.getCallSignatures().length > 0 || e.getConstructSignatures().length > 0)
1395
1477
  return !1;
1396
1478
  if (e.isString() || e.isNumber() || e.isBoolean() || e.isNull() || e.isUndefined() || e.isStringLiteral() || e.isNumberLiteral() || e.isBooleanLiteral() || e.isEnumLiteral())
1397
1479
  return !0;
1398
1480
  if (e.isArray() || e.isReadonlyArray()) {
1399
1481
  const o = e.getArrayElementType();
1400
- return o ? E(o, t, n) : !1;
1482
+ return o ? E(o, t, r) : !1;
1401
1483
  }
1402
1484
  if (e.isTuple())
1403
- return e.getTupleElements().every((o) => E(o, t, n));
1485
+ return e.getTupleElements().every((o) => E(o, t, r));
1404
1486
  if (e.isUnion())
1405
- return e.getUnionTypes().every((o) => E(o, t, n));
1487
+ return e.getUnionTypes().every((o) => E(o, t, r));
1406
1488
  if (e.isIntersection())
1407
- return e.getIntersectionTypes().every((o) => E(o, t, n));
1489
+ return e.getIntersectionTypes().every((o) => E(o, t, r));
1408
1490
  if (e.isObject()) {
1409
1491
  const o = e.getText(t);
1410
- if (n.has(o))
1492
+ if (r.has(o))
1411
1493
  return !0;
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)
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)
1417
1499
  );
1418
1500
  const s = e.getProperties();
1419
1501
  return s.length === 0 ? !0 : s.every((a) => {
1420
1502
  const c = a.getTypeAtLocation(t);
1421
- return E(c, t, n);
1503
+ return E(c, t, r);
1422
1504
  });
1423
1505
  }
1424
1506
  return !1;
1425
1507
  }
1426
- async function Mt(e) {
1427
- 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());
1428
1527
  try {
1429
- return await Tt(e, n);
1528
+ return await $t(e, r);
1430
1529
  } finally {
1431
- t && n.dispose();
1530
+ t && r.dispose();
1432
1531
  }
1433
1532
  }
1434
- async function Tt(e, t) {
1533
+ async function $t(e, t) {
1435
1534
  const {
1436
- sourceFile: n,
1535
+ sourceFile: r,
1437
1536
  namespace: o = "",
1438
- tsconfig: r,
1537
+ tsconfig: n,
1439
1538
  includeInstances: i = !1
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(
1443
- (d) => d.getKindName() === "ClassDeclaration"
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(
1542
+ (y) => y.getKindName() === "ClassDeclaration"
1444
1543
  );
1445
- if (!h)
1544
+ if (!T)
1446
1545
  continue;
1447
- const m = p === "default" ? h.getName() : p;
1448
- if (!m || G(m))
1546
+ const m = p === "default" ? T.getName() : p;
1547
+ if (!m || Q(m))
1449
1548
  continue;
1450
- const T = I(m);
1451
- for (const d of h.getStaticMethods()) {
1452
- const y = d.getName();
1453
- if (G(y))
1549
+ const h = R(m);
1550
+ for (const y of T.getStaticMethods()) {
1551
+ const d = y.getName();
1552
+ if (Q(d))
1454
1553
  continue;
1455
- const g = d.getScope();
1456
- if (g === L.Private || g === L.Protected)
1554
+ const b = y.getScope();
1555
+ if (b === V.Private || b === V.Protected)
1457
1556
  continue;
1458
- const x = d.getSignature(), S = U(x, d), v = x.getReturnType().getText(), w = d.isAsync(), $ = [l, T, I(y)];
1557
+ const x = y.getSignature(), g = J(x, y), w = x.getReturnType().getText(), v = y.isAsync(), A = [l, h, R(d)];
1459
1558
  f.push(
1460
- await bt(
1559
+ await Nt(
1461
1560
  s,
1462
1561
  a,
1463
1562
  u,
1464
- $,
1465
- S,
1466
- v,
1563
+ A,
1564
+ g,
1467
1565
  w,
1468
- r,
1566
+ v,
1567
+ n,
1469
1568
  t
1470
1569
  )
1471
1570
  );
1472
1571
  }
1473
1572
  if (i) {
1474
1573
  {
1475
- const y = h.getConstructors()[0] ?? null;
1476
- let g = [];
1477
- if (y) {
1478
- const j = y.getSignature();
1479
- g = U(j, y);
1574
+ const d = T.getConstructors()[0] ?? null;
1575
+ let b = [];
1576
+ if (d) {
1577
+ const j = d.getSignature();
1578
+ b = J(j, d);
1480
1579
  }
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)
1483
- $[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(
1484
1583
  s,
1485
1584
  a,
1486
1585
  j.type,
1487
- r,
1586
+ n,
1488
1587
  t
1489
1588
  );
1490
1589
  f.push({
1491
- id: S,
1590
+ id: g,
1492
1591
  host: "ts",
1493
1592
  namespace: u,
1494
1593
  path: x,
@@ -1496,7 +1595,7 @@ async function Tt(e, t) {
1496
1595
  async: !1,
1497
1596
  streaming: !1,
1498
1597
  safe: !1,
1499
- input: { type: "object", properties: $, required: w },
1598
+ input: { type: "object", properties: A, required: v },
1500
1599
  output: {
1501
1600
  type: "object",
1502
1601
  properties: { instanceId: { type: "string" } },
@@ -1505,45 +1604,45 @@ async function Tt(e, t) {
1505
1604
  envelope: {},
1506
1605
  typeText: {
1507
1606
  lang: "ts",
1508
- input: xt(g),
1607
+ input: Ot(b),
1509
1608
  output: "{ instanceId: string }"
1510
1609
  }
1511
1610
  });
1512
1611
  }
1513
- for (const d of h.getInstanceMethods()) {
1514
- const y = d.getName();
1515
- if (G(y))
1612
+ for (const y of T.getInstanceMethods()) {
1613
+ const d = y.getName();
1614
+ if (Q(d))
1516
1615
  continue;
1517
- const g = d.getScope();
1518
- if (g === L.Private || g === L.Protected)
1616
+ const b = y.getScope();
1617
+ if (b === V.Private || b === V.Protected)
1519
1618
  continue;
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 = {};
1521
- for (const O of P)
1522
- 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(
1523
1622
  s,
1524
1623
  a,
1525
1624
  O.type,
1526
- r,
1625
+ n,
1527
1626
  t
1528
1627
  );
1529
- const _ = v.replace(/^Promise<(.+)>$/, "$1").trim(), Pe = await A(
1628
+ const M = w.replace(/^Promise<(.+)>$/, "$1").trim(), Z = await N(
1530
1629
  s,
1531
1630
  a,
1532
- _,
1533
- r,
1631
+ M,
1632
+ n,
1534
1633
  t
1535
1634
  );
1536
1635
  f.push({
1537
1636
  id: j,
1538
1637
  host: "ts",
1539
1638
  namespace: u,
1540
- path: $,
1639
+ path: A,
1541
1640
  kind: "instance-method",
1542
- async: w,
1641
+ async: v,
1543
1642
  streaming: !1,
1544
1643
  safe: !1,
1545
- input: { type: "object", properties: R, required: B },
1546
- output: Pe,
1644
+ input: { type: "object", properties: _, required: F },
1645
+ output: Z,
1547
1646
  envelope: {
1548
1647
  type: "object",
1549
1648
  properties: { instanceId: { type: "string" } },
@@ -1551,8 +1650,8 @@ async function Tt(e, t) {
1551
1650
  },
1552
1651
  typeText: {
1553
1652
  lang: "ts",
1554
- input: Ae(S),
1555
- output: _
1653
+ input: Ie(g),
1654
+ output: M
1556
1655
  }
1557
1656
  });
1558
1657
  }
@@ -1560,17 +1659,17 @@ async function Tt(e, t) {
1560
1659
  }
1561
1660
  return f;
1562
1661
  }
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 = {};
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 = {};
1565
1664
  for (const m of l)
1566
- f[m.name] = await A(
1665
+ f[m.name] = await N(
1567
1666
  e,
1568
1667
  t,
1569
1668
  m.type,
1570
1669
  a,
1571
1670
  c
1572
1671
  );
1573
- const p = i.replace(/^Promise<(.+)>$/, "$1").trim(), b = await A(
1672
+ const p = i.replace(/^Promise<(.+)>$/, "$1").trim(), S = await N(
1574
1673
  e,
1575
1674
  t,
1576
1675
  p,
@@ -1578,9 +1677,9 @@ async function bt(e, t, n, o, r, i, s, a, c) {
1578
1677
  c
1579
1678
  );
1580
1679
  return {
1581
- id: X(n, o),
1680
+ id: re(r, o),
1582
1681
  host: "ts",
1583
- namespace: n,
1682
+ namespace: r,
1584
1683
  path: o,
1585
1684
  kind: "action",
1586
1685
  async: s,
@@ -1588,46 +1687,46 @@ async function bt(e, t, n, o, r, i, s, a, c) {
1588
1687
  safe: !1,
1589
1688
  // action → false per §4
1590
1689
  input: { type: "object", properties: f, required: u },
1591
- output: b,
1690
+ output: S,
1592
1691
  envelope: {},
1593
1692
  typeText: {
1594
1693
  lang: "ts",
1595
- input: Ae(r),
1694
+ input: Ie(n),
1596
1695
  output: p
1597
1696
  }
1598
1697
  };
1599
1698
  }
1600
- function X(e, t) {
1699
+ function re(e, t) {
1601
1700
  return (e.raw ? [e, ...t] : t).map((o) => o.words.join("-")).join("/");
1602
1701
  }
1603
- function I(e) {
1604
- return { raw: e, words: $e(e) };
1702
+ function R(e) {
1703
+ return { raw: e, words: Fe(e) };
1605
1704
  }
1606
- function St(e) {
1705
+ function Pt(e) {
1607
1706
  return e.replace(/\.[^.]+$/, "").replace(/[._]+/g, "-");
1608
1707
  }
1609
- function U(e, t) {
1610
- return e.getParameters().map((n) => {
1708
+ function J(e, t) {
1709
+ return e.getParameters().map((r) => {
1611
1710
  var s;
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);
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);
1613
1712
  return {
1614
- name: n.getName(),
1615
- type: n.getTypeAtLocation(t).getText(),
1713
+ name: r.getName(),
1714
+ type: r.getTypeAtLocation(t).getText(),
1616
1715
  optional: i
1617
1716
  };
1618
1717
  });
1619
1718
  }
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(", ") + ")";
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(", ") + ")";
1623
1722
  }
1624
- function xt(e) {
1723
+ function Ot(e) {
1625
1724
  return e.length === 0 ? "()" : "(" + e.map((t) => `${t.name}${t.optional ? "?" : ""}: ${t.type}`).join(", ") + ")";
1626
1725
  }
1627
- function G(e) {
1726
+ function Q(e) {
1628
1727
  return !!(e === "__samples__" || e.startsWith("__") || e.startsWith("_"));
1629
1728
  }
1630
- const vt = /* @__PURE__ */ new Map([
1729
+ const kt = /* @__PURE__ */ new Map([
1631
1730
  // TypeScript variants
1632
1731
  [".ts", "ts"],
1633
1732
  [".tsx", "ts"],
@@ -1642,21 +1741,21 @@ const vt = /* @__PURE__ */ new Map([
1642
1741
  // Java / Kotlin (both are JVM host languages for the purposes of routing)
1643
1742
  [".java", "java"]
1644
1743
  ]);
1645
- function wt(e) {
1646
- const t = Oe.extname(e).toLowerCase();
1647
- return vt.get(t);
1744
+ function Ft(e) {
1745
+ const t = Ce.extname(e).toLowerCase();
1746
+ return kt.get(t);
1648
1747
  }
1649
- function jt(e) {
1748
+ function It(e) {
1650
1749
  return e.language ?? "ts";
1651
1750
  }
1652
- function $t(e, t) {
1653
- const n = wt(t);
1654
- 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);
1655
1754
  }
1656
- function Vt(e, t) {
1657
- return t.filter((n) => $t(e, n));
1755
+ function Ht(e, t) {
1756
+ return t.filter((r) => Et(e, r));
1658
1757
  }
1659
- function At(e) {
1758
+ function Ct(e) {
1660
1759
  return {
1661
1760
  oneOf: [
1662
1761
  {
@@ -1690,27 +1789,27 @@ function At(e) {
1690
1789
  ]
1691
1790
  };
1692
1791
  }
1693
- function Pt(e) {
1792
+ function Rt(e) {
1694
1793
  return {
1695
1794
  operationConst: e.id,
1696
1795
  itemsSchema: e.input,
1697
- resultSchema: At(e.output)
1796
+ resultSchema: Ct(e.output)
1698
1797
  };
1699
1798
  }
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))
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))
1704
1803
  continue;
1705
- const i = o.get(r.kind);
1706
- 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]);
1707
1806
  }
1708
1807
  return o;
1709
1808
  }
1710
- function pe(e) {
1809
+ function Se(e) {
1711
1810
  return { type: "string", enum: [e] };
1712
1811
  }
1713
- function me(e, t) {
1812
+ function be(e, t) {
1714
1813
  return {
1715
1814
  type: "object",
1716
1815
  required: ["operation", "items"],
@@ -1728,39 +1827,39 @@ function me(e, t) {
1728
1827
  additionalProperties: !0
1729
1828
  };
1730
1829
  }
1731
- function Ot(e) {
1830
+ function _t(e) {
1732
1831
  if (e.length === 0)
1733
1832
  throw new Error("buildBatchKindSchema: at least one operation is required");
1734
- const t = e.map(Pt);
1833
+ const t = e.map(Rt);
1735
1834
  if (e.length === 1) {
1736
- const [r] = e, [i] = t;
1835
+ const [n] = e, [i] = t;
1737
1836
  return {
1738
- input: me(i, pe(r.id)),
1837
+ input: be(i, Se(n.id)),
1739
1838
  output: { type: "array", items: i.resultSchema }
1740
1839
  };
1741
1840
  }
1742
- const n = e.map(
1743
- (r, i) => me(t[i], pe(r.id))
1744
- ), o = D(
1745
- n
1841
+ const r = e.map(
1842
+ (n, i) => be(t[i], Se(n.id))
1843
+ ), o = U(
1844
+ r
1746
1845
  );
1747
1846
  return {
1748
1847
  input: {
1749
- oneOf: n,
1848
+ oneOf: r,
1750
1849
  ...o ? { discriminator: o } : {}
1751
1850
  },
1752
1851
  output: {
1753
- oneOf: t.map((r) => ({ type: "array", items: r.resultSchema }))
1852
+ oneOf: t.map((n) => ({ type: "array", items: n.resultSchema }))
1754
1853
  },
1755
1854
  ...o ? { discriminator: o } : {}
1756
1855
  };
1757
1856
  }
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",
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",
1764
1863
  input: s,
1765
1864
  output: a
1766
1865
  });
@@ -1772,21 +1871,25 @@ function qt(e, t = {}) {
1772
1871
  return o;
1773
1872
  }
1774
1873
  export {
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
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
1792
1895
  };