@adhd/apigen-core-client 0.1.4 → 0.2.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,7 +1,7 @@
1
- import { Project as te, Scope as R } from "ts-morph";
1
+ import { Project as te, Scope as _ } from "ts-morph";
2
2
  import $e from "node:fs";
3
3
  import * as Ae from "node:path";
4
- import Q from "node:path";
4
+ import X from "node:path";
5
5
  import { createParser as Pe, createFormatter as Ne, SchemaGenerator as Oe, AnnotatedType as ne, StringType as re } from "ts-json-schema-generator";
6
6
  const fe = Symbol.for("adhd.apigen.extraction-session");
7
7
  function pe(e, t) {
@@ -23,7 +23,7 @@ function pe(e, t) {
23
23
  }
24
24
  }
25
25
  }
26
- function ge(e) {
26
+ function me(e) {
27
27
  try {
28
28
  const t = $e.statSync(e);
29
29
  return `${t.mtimeMs}:${t.size}`;
@@ -31,26 +31,26 @@ function ge(e) {
31
31
  return "nostat";
32
32
  }
33
33
  }
34
- const C = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
34
+ const F = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map();
35
35
  function ke(e, t, r) {
36
- const o = t ?? "", n = C.get(o);
36
+ const o = t ?? "", n = F.get(o);
37
37
  let i = r;
38
38
  if (n && n.fileVersions.size > 0) {
39
- const c = [r], u = [...n.fileVersions.entries()].sort(
40
- ([l], [f]) => l.localeCompare(f)
39
+ const c = [r], f = [...n.fileVersions.entries()].sort(
40
+ ([u], [l]) => u.localeCompare(l)
41
41
  );
42
- for (const [l, f] of u)
43
- l !== e && c.push(`${l}:${f}`);
42
+ for (const [u, l] of f)
43
+ u !== e && c.push(`${u}:${l}`);
44
44
  i = c.join("|");
45
45
  }
46
46
  const s = `${e}\0${t ?? ""}`;
47
- let a = B.get(s);
48
- return (!a || a.version !== i) && (a = { version: i, schemas: /* @__PURE__ */ new Map() }, B.set(s, a)), a.schemas;
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;
49
49
  }
50
50
  function At() {
51
- C.clear(), B.clear();
51
+ F.clear(), G.clear();
52
52
  }
53
- function me() {
53
+ function ge() {
54
54
  const e = {
55
55
  projectsBuilt: 0,
56
56
  generatorsBuilt: 0,
@@ -69,26 +69,26 @@ function me() {
69
69
  if (r)
70
70
  throw new Error("apigen-core: ExtractionSession used after dispose()");
71
71
  const i = n ?? "", s = n ? this.statVersion(n) : "";
72
- let a = C.get(i);
72
+ let a = F.get(i);
73
73
  return a && a.tsconfigVersion !== s && (a = void 0), a || (a = { project: n ? new te({
74
74
  tsConfigFilePath: n,
75
75
  skipAddingFilesFromTsConfig: !0
76
- }) : new te({ skipAddingFilesFromTsConfig: !0 }), tsconfigVersion: s, fileVersions: /* @__PURE__ */ new Map() }, C.set(i, a), e.projectsBuilt++), a.project;
76
+ }) : new te({ skipAddingFilesFromTsConfig: !0 }), tsconfigVersion: s, fileVersions: /* @__PURE__ */ new Map() }, F.set(i, a), e.projectsBuilt++), a.project;
77
77
  },
78
78
  sourceFileFor(n, i) {
79
- const s = this.projectFor(i), a = C.get(i ?? ""), c = this.statVersion(n);
80
- let u = s.getSourceFile(n);
81
- if (u === void 0 ? u = s.addSourceFileAtPath(n) : a && a.fileVersions.get(n) !== c && u.refreshFromFileSystemSync(), a == null || a.fileVersions.set(n, c), a) {
82
- const l = /* @__PURE__ */ new Set([n]);
83
- pe(u, l);
84
- for (const f of l)
85
- f !== n && a.fileVersions.set(f, this.statVersion(f));
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));
86
86
  }
87
- return u;
87
+ return f;
88
88
  },
89
89
  statVersion(n) {
90
90
  let i = t.get(n);
91
- return i === void 0 && (i = ge(n), t.set(n, i)), i;
91
+ return i === void 0 && (i = me(n), t.set(n, i)), i;
92
92
  },
93
93
  dispose() {
94
94
  r = !0, this.schemaCache.clear(), this.generatorCache.clear(), t.clear();
@@ -103,7 +103,7 @@ function de(e) {
103
103
  );
104
104
  return t;
105
105
  }
106
- const z = "x-apigen-logical";
106
+ const q = "x-apigen-logical";
107
107
  function oe(e, t) {
108
108
  const r = /* @__PURE__ */ new Set(), o = [e];
109
109
  for (; o.length > 0; ) {
@@ -114,35 +114,35 @@ function oe(e, t) {
114
114
  const i = n.$ref;
115
115
  if (typeof i == "string") {
116
116
  if (t) {
117
- const f = t[i];
118
- if (!f) {
119
- const d = Object.keys(t).join(", ") || "(none)";
117
+ const l = t[i];
118
+ if (!l) {
119
+ const p = Object.keys(t).join(", ") || "(none)";
120
120
  throw new Error(
121
- `[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${d}`
121
+ `[apigen-logical] $ref "${i}" cannot be resolved. Available $defs: ${p}`
122
122
  );
123
123
  }
124
- o.push(f);
124
+ o.push(l);
125
125
  }
126
126
  continue;
127
127
  }
128
128
  const s = n.oneOf;
129
129
  if (Array.isArray(s))
130
- for (const f of s)
131
- typeof f == "object" && f !== null && o.push(f);
130
+ for (const l of s)
131
+ typeof l == "object" && l !== null && o.push(l);
132
132
  const a = n.properties;
133
133
  if (a)
134
- for (const f of Object.values(a))
135
- o.push(f);
134
+ for (const l of Object.values(a))
135
+ o.push(l);
136
136
  const c = n.items;
137
137
  if (Array.isArray(c))
138
- for (const f of c)
139
- typeof f == "object" && f !== null && o.push(f);
138
+ for (const l of c)
139
+ typeof l == "object" && l !== null && o.push(l);
140
140
  else
141
141
  typeof c == "object" && c !== null && o.push(c);
142
- const u = n.additionalProperties;
142
+ const f = n.additionalProperties;
143
+ typeof f == "object" && f !== null && o.push(f);
144
+ const u = n.propertyNames;
143
145
  typeof u == "object" && u !== null && o.push(u);
144
- const l = n.propertyNames;
145
- typeof l == "object" && l !== null && o.push(l);
146
146
  }
147
147
  }
148
148
  const ie = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
@@ -210,23 +210,23 @@ function Nt(e, t, r) {
210
210
  Ce(e);
211
211
  const o = {};
212
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 ?? [], u = {}, l = [], f = {};
214
- for (const y of t)
215
- if (y.envelope && s[y.id] !== !1)
216
- for (const [m, v] of Object.entries(y.envelope))
217
- u[m] = v, f[m] = y.id, l.includes(m) || l.push(m);
218
- const d = {
213
+ const s = (r == null ? void 0 : r[n]) ?? {}, a = i.input.properties ?? {}, c = i.input.required ?? [], f = {}, u = [], l = {};
214
+ for (const T of t)
215
+ if (T.envelope && s[T.id] !== !1)
216
+ for (const [d, y] of Object.entries(T.envelope))
217
+ f[d] = y, l[d] = T.id, u.includes(d) || u.push(d);
218
+ const p = {
219
219
  type: "object",
220
220
  properties: a,
221
221
  additionalProperties: !1,
222
222
  ...c.length > 0 ? { required: c } : {}
223
- }, g = i.safe === !0 || Ie(i.input), p = i.input.definitions, T = i.input.$defs;
223
+ }, S = i.safe === !0 || Ie(i.input), h = i.input.definitions, m = i.input.$defs;
224
224
  o[n] = {
225
225
  input: {
226
226
  type: "object",
227
- properties: { ...u, data: d },
227
+ properties: { ...f, data: p },
228
228
  required: [
229
- ...l,
229
+ ...u,
230
230
  ...c.length > 0 ? ["data"] : []
231
231
  ],
232
232
  // BUG-APIGEN-017: reject any property that isn't a declared envelope
@@ -234,21 +234,21 @@ function Nt(e, t, r) {
234
234
  additionalProperties: !1,
235
235
  // BUG-APIGEN-020: document the envelope/data calling convention inline.
236
236
  description: Fe(
237
- Object.keys(u),
237
+ Object.keys(f),
238
238
  Object.keys(a).length > 0
239
239
  ),
240
- ...p ? { definitions: p } : {},
241
- ...T ? { $defs: T } : {}
240
+ ...h ? { definitions: h } : {},
241
+ ...m ? { $defs: m } : {}
242
242
  },
243
243
  output: i.output,
244
244
  // Carry the ctx-param flag through to dispatch (BUG-APIGEN-001).
245
245
  ...i.hasCtx ? { hasCtx: !0 } : {},
246
- "x-apigen-safe": g,
246
+ "x-apigen-safe": S,
247
247
  // DEBT-APIGEN-ENVELOPE-CAPABILITY-UNWIRED-001: field → pluginId map,
248
248
  // read by `op-plan.ts`'s `computeEnvelopeFields`. Omitted (not an empty
249
249
  // object) when no middleware contributed an envelope field, matching
250
250
  // `x-apigen-safe`'s own "absent means nothing to report" convention.
251
- ...Object.keys(f).length > 0 ? { "x-apigen-envelope": f } : {}
251
+ ...Object.keys(l).length > 0 ? { "x-apigen-envelope": l } : {}
252
252
  };
253
253
  }
254
254
  return o;
@@ -309,11 +309,11 @@ async function ye(e, t, r) {
309
309
  };
310
310
  const s = await Promise.all(
311
311
  o.map((c) => ye(c, t, r + 1))
312
- ), a = J(s);
312
+ ), a = Y(s);
313
313
  return {
314
314
  oneOf: s,
315
315
  ...a ? { discriminator: a } : {},
316
- [z]: "union"
316
+ [q]: "union"
317
317
  };
318
318
  }
319
319
  if (e.isArray()) {
@@ -337,24 +337,24 @@ async function ye(e, t, r) {
337
337
  return { type: "object", additionalProperties: await t(i.getText()) };
338
338
  const a = {};
339
339
  for (const c of s) {
340
- const u = c.getName(), f = c.getDeclarations()[0];
341
- let d;
342
- if (f)
340
+ const f = c.getName(), l = c.getDeclarations()[0];
341
+ let p;
342
+ if (l)
343
343
  try {
344
- d = c.getTypeAtLocation(f);
344
+ p = c.getTypeAtLocation(l);
345
345
  } catch {
346
- d = void 0;
346
+ p = void 0;
347
347
  }
348
- if (d !== void 0 && d.getCallSignatures().length > 0)
348
+ if (p !== void 0 && p.getCallSignatures().length > 0)
349
349
  continue;
350
- const g = d !== void 0 ? Le(d, f) : void 0;
351
- a[u] = g !== void 0 ? await t(g) : {};
350
+ const S = p !== void 0 ? Le(p, l) : void 0;
351
+ a[f] = S !== void 0 ? await t(S) : {};
352
352
  }
353
353
  return Object.keys(a).length > 0 ? { type: "object", properties: a } : {};
354
354
  }
355
355
  return {};
356
356
  }
357
- function J(e) {
357
+ function Y(e) {
358
358
  if (e.length < 2)
359
359
  return;
360
360
  const t = [];
@@ -373,12 +373,12 @@ function J(e) {
373
373
  const n = [];
374
374
  let i = !0;
375
375
  for (const a of t) {
376
- const c = a[o], u = c && (c.type === "string" || c.type === "number"), l = c == null ? void 0 : c.enum;
377
- if (!u || !Array.isArray(l) || l.length !== 1) {
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) {
378
378
  i = !1;
379
379
  break;
380
380
  }
381
- n.push(String(l[0]));
381
+ n.push(String(u[0]));
382
382
  }
383
383
  if (!i || new Set(n).size !== n.length)
384
384
  continue;
@@ -388,7 +388,7 @@ function J(e) {
388
388
  }), { propertyName: o, mapping: s };
389
389
  }
390
390
  }
391
- function M(e, t, r) {
391
+ function z(e, t, r) {
392
392
  if (t > 6)
393
393
  return {};
394
394
  const o = e.trim();
@@ -402,13 +402,13 @@ function M(e, t, r) {
402
402
  return { type: "null" };
403
403
  if (o === "undefined")
404
404
  return { type: "null" };
405
- const n = U[o];
405
+ const n = H[o];
406
406
  if (n !== void 0)
407
407
  return n;
408
408
  if (r != null && r.size) {
409
409
  const i = r.get(o);
410
410
  if (i !== void 0) {
411
- const s = U[i];
411
+ const s = H[i];
412
412
  if (s !== void 0)
413
413
  return s;
414
414
  }
@@ -416,24 +416,24 @@ function M(e, t, r) {
416
416
  if (o.endsWith("[]"))
417
417
  return {
418
418
  type: "array",
419
- items: M(o.slice(0, -2), t + 1, r)
419
+ items: z(o.slice(0, -2), t + 1, r)
420
420
  };
421
421
  if (o.includes("|")) {
422
422
  const i = o.split("|").map((c) => c.trim());
423
423
  if (i.every((c) => c.startsWith("'")))
424
424
  return { type: "string", enum: i.map((c) => c.replace(/'/g, "")) };
425
- const s = i.map((c) => M(c, t + 1, r)), a = J(s);
425
+ const s = i.map((c) => z(c, t + 1, r)), a = Y(s);
426
426
  return {
427
427
  oneOf: s,
428
428
  ...a ? { discriminator: a } : {},
429
- [z]: "union"
429
+ [q]: "union"
430
430
  };
431
431
  }
432
432
  if (o.startsWith("{") && o.endsWith("}")) {
433
433
  const i = o.slice(1, -1).trim(), s = {};
434
434
  for (const a of i.split(";").filter(Boolean)) {
435
- const [c, u] = a.split(":").map((l) => l.trim());
436
- c && u && (s[c.replace("?", "")] = M(u, t + 1, r));
435
+ const [c, f] = a.split(":").map((u) => u.trim());
436
+ c && f && (s[c.replace("?", "")] = z(f, t + 1, r));
437
437
  }
438
438
  return { type: "object", properties: s };
439
439
  }
@@ -501,7 +501,7 @@ async function qe(e, t) {
501
501
  }
502
502
  const Te = {
503
503
  "decimal.js": "Decimal"
504
- }, U = {
504
+ }, H = {
505
505
  Date: { type: "string", format: "date-time" },
506
506
  bigint: { type: "string", format: "int64" },
507
507
  Uint8Array: { type: "string", format: "byte" },
@@ -562,37 +562,37 @@ function De(e, t) {
562
562
  });
563
563
  };
564
564
  }
565
- let E;
565
+ let I;
566
566
  function We() {
567
- if (E)
568
- return E;
567
+ if (I)
568
+ return I;
569
569
  try {
570
- const e = Q.dirname(
570
+ const e = X.dirname(
571
571
  require.resolve("ts-json-schema-generator/package.json")
572
572
  );
573
- E = require(require.resolve("typescript", {
573
+ I = require(require.resolve("typescript", {
574
574
  paths: [e]
575
575
  }));
576
576
  } catch {
577
- E = require("typescript");
577
+ I = require("typescript");
578
578
  }
579
- return E;
579
+ return I;
580
580
  }
581
- const O = /* @__PURE__ */ new Map();
581
+ const k = /* @__PURE__ */ new Map();
582
582
  function Be() {
583
583
  const e = process.env.APIGEN_PROGRAM_CACHE, t = e === void 0 ? NaN : Number(e);
584
584
  return Number.isFinite(t) && t >= 0 ? t : 8;
585
585
  }
586
586
  function Ue(e) {
587
- const t = O.get(e);
588
- return t && (O.delete(e), O.set(e, t)), t;
587
+ const t = k.get(e);
588
+ return t && (k.delete(e), k.set(e, t)), t;
589
589
  }
590
590
  function Ge(e, t) {
591
591
  const r = Be();
592
592
  if (r !== 0)
593
- for (O.delete(e), O.set(e, t); O.size > r; ) {
594
- const o = O.keys().next().value;
595
- O.delete(o);
593
+ for (k.delete(e), k.set(e, t); k.size > r; ) {
594
+ const o = k.keys().next().value;
595
+ k.delete(o);
596
596
  }
597
597
  }
598
598
  function He(e, t) {
@@ -625,8 +625,8 @@ function Je(e) {
625
625
  continue;
626
626
  const a = s, c = typeof a.$ref == "string" ? a.$ref : "";
627
627
  if (c) {
628
- for (const u of n)
629
- if (c.includes(u)) {
628
+ for (const f of n)
629
+ if (c.includes(f)) {
630
630
  n.add(i);
631
631
  break;
632
632
  }
@@ -635,9 +635,9 @@ function Je(e) {
635
635
  for (const i of n)
636
636
  delete r[i];
637
637
  }
638
- G(e);
638
+ Z(e);
639
639
  }
640
- function G(e, t) {
640
+ function Z(e, t) {
641
641
  if (!e || typeof e != "object")
642
642
  return;
643
643
  const r = t ?? /* @__PURE__ */ new WeakSet();
@@ -652,9 +652,9 @@ function G(e, t) {
652
652
  if (typeof o == "object" && o !== null)
653
653
  if (Array.isArray(o))
654
654
  for (const n of o)
655
- typeof n == "object" && n !== null && G(n, r);
655
+ typeof n == "object" && n !== null && Z(n, r);
656
656
  else
657
- G(o, r);
657
+ Z(o, r);
658
658
  }
659
659
  }
660
660
  function Xe(e) {
@@ -665,13 +665,13 @@ function Xe(e) {
665
665
  for (const i of Object.keys(n))
666
666
  t.add(i);
667
667
  }
668
- const r = H(e, t);
668
+ const r = Q(e, t);
669
669
  if (r.length > 0)
670
670
  throw new Error(
671
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.`
672
672
  );
673
673
  }
674
- function H(e, t) {
674
+ function Q(e, t) {
675
675
  if (!e || typeof e != "object")
676
676
  return [];
677
677
  const r = [];
@@ -683,11 +683,11 @@ function H(e, t) {
683
683
  if (Array.isArray(n))
684
684
  for (const i of n)
685
685
  typeof i == "object" && i !== null && r.push(
686
- ...H(i, t)
686
+ ...Q(i, t)
687
687
  );
688
688
  else
689
689
  r.push(
690
- ...H(n, t)
690
+ ...Q(n, t)
691
691
  );
692
692
  return r;
693
693
  }
@@ -695,44 +695,44 @@ function Ye(e) {
695
695
  const t = e.anyOf;
696
696
  if (!Array.isArray(t) || t.length < 2)
697
697
  return e;
698
- const r = t, o = J(r), n = { ...e };
698
+ const r = t, o = Y(r), n = { ...e };
699
699
  return delete n.anyOf, {
700
700
  ...n,
701
701
  oneOf: r,
702
702
  ...o ? { discriminator: o } : {},
703
- [z]: n[z] ?? "union"
703
+ [q]: n[q] ?? "union"
704
704
  };
705
705
  }
706
706
  function et(e, t, r) {
707
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);
708
708
  let a;
709
- a = r ? r.statVersion(i) : ge(i);
709
+ a = r ? r.statVersion(i) : me(i);
710
710
  let c;
711
711
  if (s !== void 0) {
712
- const l = (r == null ? void 0 : r.generatorCache.get(s)) ?? Ue(s);
713
- l && l.version === a && (c = l.gen);
712
+ const u = (r == null ? void 0 : r.generatorCache.get(s)) ?? Ue(s);
713
+ u && u.version === a && (c = u.gen);
714
714
  }
715
715
  if (!c) {
716
- const { createProgram: l } = require("ts-json-schema-generator/dist/factory/program.js"), f = We(), d = De(
717
- f.SyntaxKind.BigIntKeyword,
718
- f.SyntaxKind.TypeReference
719
- ), g = l(n), p = Pe(
720
- g,
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
721
  n,
722
- d
723
- ), T = Ne(n);
722
+ p
723
+ ), m = Ne(n);
724
724
  if (c = new Oe(
725
- g,
726
- p,
727
- T,
725
+ S,
726
+ h,
727
+ m,
728
728
  n
729
729
  ), r && r.stats.generatorsBuilt++, s !== void 0 && a !== void 0) {
730
- const y = { version: a, gen: c };
731
- Ge(s, y), r == null || r.generatorCache.set(s, y);
730
+ const T = { version: a, gen: c };
731
+ Ge(s, T), r == null || r.generatorCache.set(s, T);
732
732
  }
733
733
  }
734
- const u = c.createSchema(n.type);
735
- return Je(u), Xe(u), u;
734
+ const f = c.createSchema(n.type);
735
+ return Je(f), Xe(f), f;
736
736
  }
737
737
  function tt(e, t) {
738
738
  let r = e.trim();
@@ -782,63 +782,63 @@ async function A(e, t, r, o, n, i) {
782
782
  if (c.has(a))
783
783
  return {};
784
784
  if (!n) {
785
- const p = new Set(c);
786
- return p.add(a), ce(
785
+ const h = new Set(c);
786
+ return h.add(a), ce(
787
787
  e,
788
788
  t,
789
789
  r,
790
790
  o,
791
791
  void 0,
792
- p
792
+ h
793
793
  );
794
794
  }
795
- const u = n.schemaCache.get(a);
796
- if (u !== void 0)
797
- return n.stats.schemaCacheHits++, u;
798
- const l = ke(
795
+ const f = n.schemaCache.get(a);
796
+ if (f !== void 0)
797
+ return n.stats.schemaCacheHits++, f;
798
+ const u = ke(
799
799
  s,
800
800
  o,
801
801
  n.statVersion(s)
802
- ), f = l.get(r);
803
- if (f !== void 0)
804
- return n.stats.schemaCacheHits++, n.schemaCache.set(a, Promise.resolve(f)), f;
802
+ ), l = u.get(r);
803
+ if (l !== void 0)
804
+ return n.stats.schemaCacheHits++, n.schemaCache.set(a, Promise.resolve(l)), l;
805
805
  n.stats.schemaCacheMisses++;
806
- const d = new Set(c);
807
- d.add(a);
808
- const g = ce(
806
+ const p = new Set(c);
807
+ p.add(a);
808
+ const S = ce(
809
809
  e,
810
810
  t,
811
811
  r,
812
812
  o,
813
813
  n,
814
- d
815
- ).then((p) => (l.set(r, p), p)).catch((p) => {
816
- throw n.schemaCache.delete(a), p;
814
+ p
815
+ ).then((h) => (u.set(r, h), h)).catch((h) => {
816
+ throw n.schemaCache.delete(a), h;
817
817
  });
818
- return n.schemaCache.set(a, g), g;
818
+ return n.schemaCache.set(a, S), S;
819
819
  }
820
820
  async function ce(e, t, r, o, n, i) {
821
821
  if (["void", "undefined", "null", "Promise<void>"].includes(r))
822
822
  return { type: "null" };
823
823
  let s;
824
824
  if (n) {
825
- const d = n.aliasCache.get(t);
826
- s = d ?? ae(t), d || n.aliasCache.set(t, s);
825
+ const p = n.aliasCache.get(t);
826
+ s = p ?? ae(t), p || n.aliasCache.set(t, s);
827
827
  } else
828
828
  s = ae(t);
829
- const a = tt(r, s), c = U[a];
829
+ const a = tt(r, s), c = H[a];
830
830
  if (c !== void 0)
831
831
  return c;
832
- const u = await qe(
832
+ const f = await qe(
833
833
  a,
834
- (d) => A(e, t, d, o, n, i)
834
+ (p) => A(e, t, p, o, n, i)
835
835
  );
836
- if (u !== void 0)
837
- return u;
838
- const l = (n == null ? void 0 : n.zodImportCache.get(t)) ?? Qe(t);
839
- if (n && n.zodImportCache.set(t, l), !l)
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)
840
840
  try {
841
- const d = {
841
+ const p = {
842
842
  path: t.getFilePath(),
843
843
  type: a,
844
844
  skipTypeCheck: !0,
@@ -865,29 +865,29 @@ async function ce(e, t, r, o, n, i) {
865
865
  // dereference/hoist pass and is tracked separately, unresolved, in
866
866
  // BUG-APIGEN-026's BACKLOG entry.
867
867
  topRef: !1
868
- }, g = et(d, !0, n);
869
- return Ye(g);
868
+ }, S = et(p, !0, n);
869
+ return Ye(S);
870
870
  } catch {
871
871
  }
872
872
  try {
873
- const d = await Me(
873
+ const p = await Me(
874
874
  e,
875
875
  t,
876
876
  a,
877
- (g) => ye(
878
- g,
879
- (p) => A(e, t, p, o, n, i),
877
+ (S) => ye(
878
+ S,
879
+ (h) => A(e, t, h, o, n, i),
880
880
  0
881
881
  )
882
882
  );
883
- if (d !== void 0)
884
- return d;
883
+ if (p !== void 0)
884
+ return p;
885
885
  } catch {
886
886
  }
887
- const f = rt(a, s);
888
- return M(f, 0, s);
887
+ const l = rt(a, s);
888
+ return z(l, 0, s);
889
889
  }
890
- function X(e, t, r) {
890
+ function ee(e, t, r) {
891
891
  if (e != null && e.hasInitializer()) {
892
892
  const o = e.getInitializer();
893
893
  if (o)
@@ -902,9 +902,9 @@ function ot(e, t) {
902
902
  for (const c of a.getTags()) {
903
903
  if (c.getTagName() !== "param")
904
904
  continue;
905
- const u = c.getText().match(i);
906
- if (u)
907
- return u[1].trim();
905
+ const f = c.getText().match(i);
906
+ if (f)
907
+ return f[1].trim();
908
908
  }
909
909
  }
910
910
  function it(e) {
@@ -936,7 +936,7 @@ function st(e, t) {
936
936
  e.description = n ? `${n} (default: ${o})` : `(default: ${o})`;
937
937
  }
938
938
  async function Ot(e) {
939
- const t = e.session === void 0, r = de(e.session ?? me());
939
+ const t = e.session === void 0, r = de(e.session ?? ge());
940
940
  try {
941
941
  return await at(e, r);
942
942
  } finally {
@@ -944,209 +944,217 @@ async function Ot(e) {
944
944
  }
945
945
  }
946
946
  async function at(e, t) {
947
- const { sourceFile: r, namespace: o = "", tsconfig: n } = e, i = t.projectFor(n), s = t.sourceFileFor(r, n), a = Q.basename(r), c = P(lt(a)), u = P(o), l = [];
948
- for (const [g, p] of s.getExportedDeclarations()) {
949
- if (g === "default" || _(g))
947
+ const {
948
+ sourceFile: r,
949
+ namespace: o = "",
950
+ dropFileSegment: n = !1,
951
+ 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 = [];
953
+ for (const [m, T] of a.getExportedDeclarations()) {
954
+ if (m === "default" || V(m))
950
955
  continue;
951
- const T = pt(p);
952
- if (T) {
953
- const h = T.getSignature(), S = ue(h, T), b = h.getReturnType().getText();
954
- l.push(
955
- await L(
956
- i,
956
+ const d = pt(T);
957
+ if (d) {
958
+ const b = d.getSignature(), x = ue(b, d), w = b.getReturnType().getText();
959
+ p.push(
960
+ await M(
957
961
  s,
962
+ a,
963
+ l,
958
964
  u,
959
- c,
960
- g,
961
- S,
962
- b,
963
- T.isAsync(),
964
- n,
965
+ m,
966
+ x,
967
+ w,
968
+ d.isAsync(),
969
+ i,
965
970
  t
966
971
  )
967
972
  );
968
973
  continue;
969
974
  }
970
- const y = p.find(
971
- (h) => h.getKindName() === "VariableDeclaration"
975
+ const y = T.find(
976
+ (b) => b.getKindName() === "VariableDeclaration"
972
977
  );
973
978
  if (!y)
974
979
  continue;
975
- const m = y.getInitializer(), v = m == null ? void 0 : m.getKindName();
976
- if (m && ["ArrowFunction", "FunctionExpression"].includes(v ?? "")) {
977
- const S = y.getType().getCallSignatures();
978
- if (S.length === 0)
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)
979
984
  continue;
980
- const b = S[0], $ = le(
981
- b,
985
+ const w = x[0], $ = le(
986
+ w,
982
987
  y,
983
988
  y.getVariableStatement()
984
- ), j = b.getReturnType().getText(), x = m.isAsync();
985
- l.push(
986
- await L(
987
- i,
989
+ ), j = w.getReturnType().getText(), P = g.isAsync();
990
+ p.push(
991
+ await M(
988
992
  s,
993
+ a,
994
+ l,
989
995
  u,
990
- c,
991
- g,
996
+ m,
992
997
  $,
993
998
  j,
994
- x,
995
- n,
999
+ P,
1000
+ i,
996
1001
  t
997
1002
  )
998
1003
  );
999
1004
  } else if (v === "ObjectLiteralExpression") {
1000
- const h = y.getType();
1001
- for (const S of h.getProperties()) {
1002
- const b = S.getName();
1003
- if (_(b))
1005
+ const b = y.getType();
1006
+ for (const x of b.getProperties()) {
1007
+ const w = x.getName();
1008
+ if (V(w))
1004
1009
  continue;
1005
- const j = S.getTypeAtLocation(y).getCallSignatures();
1010
+ const j = x.getTypeAtLocation(y).getCallSignatures();
1006
1011
  if (j.length === 0)
1007
1012
  continue;
1008
- const x = j[0], w = le(
1009
- x,
1013
+ const P = j[0], D = le(
1014
+ P,
1010
1015
  y,
1011
1016
  y.getVariableStatement()
1012
- ), F = x.getReturnType().getText(), K = [
1013
- c,
1014
- P(g),
1015
- P(b)
1017
+ ), R = P.getReturnType().getText(), L = [
1018
+ ...u ? [u] : [],
1019
+ N(m),
1020
+ N(w)
1016
1021
  ];
1017
- l.push(
1018
- await V(
1019
- i,
1022
+ p.push(
1023
+ await K(
1020
1024
  s,
1021
- u,
1022
- K,
1023
- b,
1025
+ a,
1026
+ l,
1027
+ L,
1024
1028
  w,
1025
- F,
1029
+ D,
1030
+ R,
1026
1031
  !1,
1027
- n,
1032
+ i,
1028
1033
  t
1029
1034
  )
1030
1035
  );
1031
1036
  }
1032
1037
  } else {
1033
- const h = y.getType(), S = h.getText();
1034
- if (k(h, y)) {
1035
- const b = await A(
1036
- i,
1038
+ const b = y.getType(), x = b.getText();
1039
+ if (E(b, y)) {
1040
+ const w = await A(
1037
1041
  s,
1038
- S,
1039
- n,
1042
+ a,
1043
+ x,
1044
+ i,
1040
1045
  t
1041
1046
  );
1042
- l.push(
1043
- ut(u, c, g, b)
1047
+ p.push(
1048
+ ut(l, u, m, w)
1044
1049
  );
1045
1050
  } else
1046
1051
  console.warn(
1047
- `[apigen-core] Skipping non-callable, non-serializable export: ${g}`
1052
+ `[apigen-core] Skipping non-callable, non-serializable export: ${m}`
1048
1053
  );
1049
1054
  }
1050
1055
  }
1051
- const f = s.getDefaultExportSymbol();
1052
- if (f) {
1053
- const g = s.getExportAssignment((p) => !p.isExportEquals());
1054
- if (g) {
1055
- const p = g.getExpression(), T = p.getKindName();
1056
- if (["ArrowFunction", "FunctionExpression"].includes(T)) {
1057
- const m = p.getType().getCallSignatures();
1058
- if (m.length > 0) {
1059
- const v = m[0], h = q(v, g), S = v.getReturnType().getText(), b = p.isAsync();
1060
- l.push(
1061
- await L(
1062
- i,
1056
+ const S = a.getDefaultExportSymbol();
1057
+ if (S) {
1058
+ const m = a.getExportAssignment((T) => !T.isExportEquals());
1059
+ if (m) {
1060
+ const T = m.getExpression(), d = T.getKindName();
1061
+ if (["ArrowFunction", "FunctionExpression"].includes(d)) {
1062
+ const g = T.getType().getCallSignatures();
1063
+ if (g.length > 0) {
1064
+ const v = g[0], b = W(v, m), x = v.getReturnType().getText(), w = T.isAsync();
1065
+ p.push(
1066
+ await M(
1063
1067
  s,
1068
+ a,
1069
+ l,
1064
1070
  u,
1065
- c,
1066
1071
  "default",
1067
- h,
1068
- S,
1069
1072
  b,
1070
- n,
1073
+ x,
1074
+ w,
1075
+ i,
1071
1076
  t
1072
1077
  )
1073
1078
  );
1074
1079
  }
1075
1080
  } else {
1076
- const y = p.getType();
1077
- for (const m of y.getProperties()) {
1078
- const v = m.getName();
1079
- if (_(v))
1081
+ const y = T.getType();
1082
+ for (const g of y.getProperties()) {
1083
+ const v = g.getName();
1084
+ if (V(v))
1080
1085
  continue;
1081
- const S = m.getTypeAtLocation(g).getCallSignatures();
1082
- if (S.length === 0)
1086
+ const x = g.getTypeAtLocation(m).getCallSignatures();
1087
+ if (x.length === 0)
1083
1088
  continue;
1084
- const b = S[0], $ = q(b, g), j = b.getReturnType().getText(), x = [
1085
- c,
1086
- P("default"),
1087
- P(v)
1089
+ const w = x[0], $ = W(w, m), j = w.getReturnType().getText(), P = [
1090
+ ...u ? [u] : [],
1091
+ N("default"),
1092
+ N(v)
1088
1093
  ];
1089
- l.push(
1090
- await V(
1091
- i,
1094
+ p.push(
1095
+ await K(
1092
1096
  s,
1093
- u,
1094
- x,
1097
+ a,
1098
+ l,
1099
+ P,
1095
1100
  v,
1096
1101
  $,
1097
1102
  j,
1098
1103
  !1,
1099
- n,
1104
+ i,
1100
1105
  t
1101
1106
  )
1102
1107
  );
1103
1108
  }
1104
1109
  }
1105
1110
  } else {
1106
- const p = f.getDeclarations();
1107
- for (const T of p) {
1108
- if (T.getKindName() !== "FunctionDeclaration")
1111
+ const T = S.getDeclarations();
1112
+ for (const d of T) {
1113
+ if (d.getKindName() !== "FunctionDeclaration")
1109
1114
  continue;
1110
- const y = T, m = y.getName(), v = m && m.length > 0 ? m : "default", h = y.getSignature(), S = ue(h, y), b = h.getReturnType().getText();
1111
- l.push(
1112
- await L(
1113
- i,
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();
1116
+ p.push(
1117
+ await M(
1114
1118
  s,
1119
+ a,
1120
+ l,
1115
1121
  u,
1116
- c,
1117
1122
  v,
1118
- S,
1119
- b,
1123
+ x,
1124
+ w,
1120
1125
  y.isAsync(),
1121
- n,
1126
+ i,
1122
1127
  t
1123
1128
  )
1124
1129
  );
1125
1130
  }
1126
1131
  }
1127
1132
  }
1128
- const d = ft(s);
1129
- if (d.length > 0)
1130
- for (const { name: g, sig: p } of d) {
1131
- if (_(g))
1133
+ const h = ft(a);
1134
+ if (h.length > 0)
1135
+ for (const { name: m, sig: T } of h) {
1136
+ if (V(m))
1132
1137
  continue;
1133
- const T = q(p), y = p.getReturnType().getText(), m = [c, P(g)];
1134
- l.push(
1135
- await V(
1136
- i,
1138
+ const d = W(T), y = T.getReturnType().getText(), g = [
1139
+ ...u ? [u] : [],
1140
+ N(m)
1141
+ ];
1142
+ p.push(
1143
+ await K(
1137
1144
  s,
1138
- u,
1139
- m,
1145
+ a,
1146
+ l,
1140
1147
  g,
1141
- T,
1148
+ m,
1149
+ d,
1142
1150
  y,
1143
1151
  !1,
1144
- n,
1152
+ i,
1145
1153
  t
1146
1154
  )
1147
1155
  );
1148
1156
  }
1149
- return l;
1157
+ return p;
1150
1158
  }
1151
1159
  function ct(e, t, r, o) {
1152
1160
  const n = /* @__PURE__ */ new Set(), i = (s) => {
@@ -1157,22 +1165,22 @@ function ct(e, t, r, o) {
1157
1165
  n.add(s);
1158
1166
  try {
1159
1167
  const a = s, c = {};
1160
- for (const [u, l] of Object.entries(a)) {
1161
- if (u === "definitions" || u === "$defs") {
1162
- const f = u, d = t[f];
1163
- for (const [g, p] of Object.entries(
1164
- l
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(
1172
+ u
1165
1173
  )) {
1166
- const T = i(p), y = d[g];
1167
- if (y !== void 0 && JSON.stringify(y) !== JSON.stringify(T))
1174
+ const m = i(h), T = p[S];
1175
+ if (T !== void 0 && JSON.stringify(T) !== JSON.stringify(m))
1168
1176
  throw new Error(
1169
- `[apigen-core-client] Function "${r}": param "${o}" contributes a "${f}.${g}" 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.`
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.`
1170
1178
  );
1171
- d[g] = T;
1179
+ p[S] = m;
1172
1180
  }
1173
1181
  continue;
1174
1182
  }
1175
- c[u] = i(l);
1183
+ c[f] = i(u);
1176
1184
  }
1177
1185
  return c;
1178
1186
  } finally {
@@ -1181,45 +1189,45 @@ function ct(e, t, r, o) {
1181
1189
  };
1182
1190
  return i(e);
1183
1191
  }
1184
- async function L(e, t, r, o, n, i, s, a, c, u) {
1185
- const l = P(n);
1186
- return V(
1192
+ async function M(e, t, r, o, n, i, s, a, c, f) {
1193
+ const u = N(n);
1194
+ return K(
1187
1195
  e,
1188
1196
  t,
1189
1197
  r,
1190
- [o, l],
1198
+ o ? [o, u] : [u],
1191
1199
  n,
1192
1200
  i,
1193
1201
  s,
1194
1202
  a,
1195
1203
  c,
1196
- u
1204
+ f
1197
1205
  );
1198
1206
  }
1199
- async function V(e, t, r, o, n, i, s, a, c, u) {
1200
- const l = i.length > 0 && i[0].name === "ctx", f = i.filter((h) => h.name !== "ctx"), d = f.filter((h) => !h.optional).map((h) => h.name), g = {}, p = {
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 = {
1201
1209
  definitions: {},
1202
1210
  $defs: {}
1203
1211
  };
1204
- for (const h of f) {
1205
- const S = await A(e, t, h.type, c, u), b = ct(S, p, n, h.name);
1206
- h.defaultValue !== void 0 && st(b, h.defaultValue), g[h.name] = b;
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;
1207
1215
  }
1208
- const T = s.replace(/^Promise<(.+)>$/, "$1").trim(), y = await A(
1216
+ const m = s.replace(/^Promise<(.+)>$/, "$1").trim(), T = await A(
1209
1217
  e,
1210
1218
  t,
1211
- T,
1219
+ m,
1212
1220
  c,
1213
- u
1214
- ), m = {
1221
+ f
1222
+ ), d = {
1215
1223
  type: "object",
1216
- properties: g,
1217
- required: d,
1224
+ properties: S,
1225
+ required: p,
1218
1226
  // BUG-APIGEN-029: hoisted definitions from param fragments — see
1219
1227
  // hoistNestedDefs. Only attached when non-empty so the common
1220
1228
  // (no-recursive-type) case's schema shape is unchanged.
1221
- ...Object.keys(p.definitions).length > 0 ? { definitions: p.definitions } : {},
1222
- ...Object.keys(p.$defs).length > 0 ? { $defs: p.$defs } : {}
1229
+ ...Object.keys(h.definitions).length > 0 ? { definitions: h.definitions } : {},
1230
+ ...Object.keys(h.$defs).length > 0 ? { $defs: h.$defs } : {}
1223
1231
  };
1224
1232
  return {
1225
1233
  id: ve(r, o),
@@ -1231,19 +1239,19 @@ async function V(e, t, r, o, n, i, s, a, c, u) {
1231
1239
  streaming: !1,
1232
1240
  safe: !1,
1233
1241
  // action → false per §4
1234
- input: m,
1235
- output: y,
1242
+ input: d,
1243
+ output: T,
1236
1244
  envelope: {},
1237
1245
  typeText: {
1238
1246
  lang: "ts",
1239
- input: gt(i),
1240
- output: T
1247
+ input: mt(i),
1248
+ output: m
1241
1249
  },
1242
- ...l ? { hasCtx: !0 } : {}
1250
+ ...u ? { hasCtx: !0 } : {}
1243
1251
  };
1244
1252
  }
1245
1253
  function ut(e, t, r, o) {
1246
- const n = P(r), i = [t, n];
1254
+ const n = N(r), i = t ? [t, n] : [n];
1247
1255
  return {
1248
1256
  id: ve(e, i),
1249
1257
  host: "ts",
@@ -1271,7 +1279,7 @@ function xe(e) {
1271
1279
  )
1272
1280
  ).map((t) => t.toLowerCase()).filter(Boolean);
1273
1281
  }
1274
- function P(e) {
1282
+ function N(e) {
1275
1283
  return { raw: e, words: xe(e) };
1276
1284
  }
1277
1285
  function lt(e) {
@@ -1290,8 +1298,8 @@ function ft(e) {
1290
1298
  continue;
1291
1299
  const s = n.getRight(), a = s.getType();
1292
1300
  for (const c of a.getProperties()) {
1293
- const l = c.getTypeAtLocation(s).getCallSignatures();
1294
- l.length !== 0 && t.push({ name: c.getName(), sig: l[0] });
1301
+ const u = c.getTypeAtLocation(s).getCallSignatures();
1302
+ u.length !== 0 && t.push({ name: c.getName(), sig: u[0] });
1295
1303
  }
1296
1304
  }
1297
1305
  return t;
@@ -1315,7 +1323,7 @@ function ue(e, t) {
1315
1323
  name: r.getName(),
1316
1324
  type: r.getTypeAtLocation(e.getDeclaration()).getText(),
1317
1325
  optional: i,
1318
- defaultValue: X(n, r.getName(), t)
1326
+ defaultValue: ee(n, r.getName(), t)
1319
1327
  };
1320
1328
  });
1321
1329
  }
@@ -1327,7 +1335,7 @@ function le(e, t, r) {
1327
1335
  name: o.getName(),
1328
1336
  type: o.getTypeAtLocation(t).getText(),
1329
1337
  optional: s,
1330
- defaultValue: X(
1338
+ defaultValue: ee(
1331
1339
  i,
1332
1340
  o.getName(),
1333
1341
  r ?? t
@@ -1335,7 +1343,7 @@ function le(e, t, r) {
1335
1343
  };
1336
1344
  });
1337
1345
  }
1338
- function q(e, t) {
1346
+ function W(e, t) {
1339
1347
  return e.getParameters().map((r) => {
1340
1348
  var s, a, c;
1341
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);
@@ -1343,32 +1351,32 @@ function q(e, t) {
1343
1351
  name: r.getName(),
1344
1352
  type: n ? n.getType().getText() : ((c = (a = r.getValueDeclaration()) == null ? void 0 : a.getType()) == null ? void 0 : c.getText()) ?? "unknown",
1345
1353
  optional: i,
1346
- defaultValue: X(n, r.getName(), t)
1354
+ defaultValue: ee(n, r.getName(), t)
1347
1355
  };
1348
1356
  });
1349
1357
  }
1350
- function gt(e) {
1358
+ function mt(e) {
1351
1359
  const t = e.filter((r) => r.name !== "ctx");
1352
1360
  return t.length === 0 ? "()" : "(" + t.map((r) => `${r.name}${r.optional ? "?" : ""}: ${r.type}`).join(", ") + ")";
1353
1361
  }
1354
- function _(e) {
1362
+ function V(e) {
1355
1363
  return !!(e === "__samples__" || e.startsWith("__"));
1356
1364
  }
1357
- function k(e, t, r = /* @__PURE__ */ new Set()) {
1365
+ function E(e, t, r = /* @__PURE__ */ new Set()) {
1358
1366
  if (e.getCallSignatures().length > 0 || e.getConstructSignatures().length > 0)
1359
1367
  return !1;
1360
1368
  if (e.isString() || e.isNumber() || e.isBoolean() || e.isNull() || e.isUndefined() || e.isStringLiteral() || e.isNumberLiteral() || e.isBooleanLiteral() || e.isEnumLiteral())
1361
1369
  return !0;
1362
1370
  if (e.isArray() || e.isReadonlyArray()) {
1363
1371
  const o = e.getArrayElementType();
1364
- return o ? k(o, t, r) : !1;
1372
+ return o ? E(o, t, r) : !1;
1365
1373
  }
1366
1374
  if (e.isTuple())
1367
- return e.getTupleElements().every((o) => k(o, t, r));
1375
+ return e.getTupleElements().every((o) => E(o, t, r));
1368
1376
  if (e.isUnion())
1369
- return e.getUnionTypes().every((o) => k(o, t, r));
1377
+ return e.getUnionTypes().every((o) => E(o, t, r));
1370
1378
  if (e.isIntersection())
1371
- return e.getIntersectionTypes().every((o) => k(o, t, r));
1379
+ return e.getIntersectionTypes().every((o) => E(o, t, r));
1372
1380
  if (e.isObject()) {
1373
1381
  const o = e.getText(t);
1374
1382
  if (r.has(o))
@@ -1377,58 +1385,58 @@ function k(e, t, r = /* @__PURE__ */ new Set()) {
1377
1385
  const n = e.getStringIndexType(), i = e.getNumberIndexType();
1378
1386
  if (n || i)
1379
1387
  return [n, i].every(
1380
- (a) => !a || k(a, t, r)
1388
+ (a) => !a || E(a, t, r)
1381
1389
  );
1382
1390
  const s = e.getProperties();
1383
1391
  return s.length === 0 ? !0 : s.every((a) => {
1384
1392
  const c = a.getTypeAtLocation(t);
1385
- return k(c, t, r);
1393
+ return E(c, t, r);
1386
1394
  });
1387
1395
  }
1388
1396
  return !1;
1389
1397
  }
1390
1398
  async function kt(e) {
1391
- const t = e.session === void 0, r = de(e.session ?? me());
1399
+ const t = e.session === void 0, r = de(e.session ?? ge());
1392
1400
  try {
1393
- return await mt(e, r);
1401
+ return await gt(e, r);
1394
1402
  } finally {
1395
1403
  t && r.dispose();
1396
1404
  }
1397
1405
  }
1398
- async function mt(e, t) {
1406
+ async function gt(e, t) {
1399
1407
  const {
1400
1408
  sourceFile: r,
1401
1409
  namespace: o = "",
1402
1410
  tsconfig: n,
1403
1411
  includeInstances: i = !1
1404
- } = e, s = t.projectFor(n), a = t.sourceFileFor(r, n), c = Q.basename(r), u = I(yt(c)), l = I(o), f = [];
1405
- for (const [d, g] of a.getExportedDeclarations()) {
1406
- const p = g.find(
1407
- (m) => m.getKindName() === "ClassDeclaration"
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(
1415
+ (d) => d.getKindName() === "ClassDeclaration"
1408
1416
  );
1409
- if (!p)
1417
+ if (!h)
1410
1418
  continue;
1411
- const T = d === "default" ? p.getName() : d;
1412
- if (!T || W(T))
1419
+ const m = p === "default" ? h.getName() : p;
1420
+ if (!m || U(m))
1413
1421
  continue;
1414
- const y = I(T);
1415
- for (const m of p.getStaticMethods()) {
1416
- const v = m.getName();
1417
- if (W(v))
1422
+ const T = C(m);
1423
+ for (const d of h.getStaticMethods()) {
1424
+ const y = d.getName();
1425
+ if (U(y))
1418
1426
  continue;
1419
- const h = m.getScope();
1420
- if (h === R.Private || h === R.Protected)
1427
+ const g = d.getScope();
1428
+ if (g === _.Private || g === _.Protected)
1421
1429
  continue;
1422
- const S = m.getSignature(), b = D(S, m), $ = S.getReturnType().getText(), j = m.isAsync(), x = [u, y, I(v)];
1423
- f.push(
1430
+ const v = d.getSignature(), b = B(v, d), x = v.getReturnType().getText(), w = d.isAsync(), $ = [f, T, C(y)];
1431
+ l.push(
1424
1432
  await dt(
1425
1433
  s,
1426
1434
  a,
1427
- l,
1428
- x,
1429
- b,
1435
+ u,
1430
1436
  $,
1431
- j,
1437
+ b,
1438
+ x,
1439
+ w,
1432
1440
  n,
1433
1441
  t
1434
1442
  )
@@ -1436,31 +1444,31 @@ async function mt(e, t) {
1436
1444
  }
1437
1445
  if (i) {
1438
1446
  {
1439
- const v = p.getConstructors()[0] ?? null;
1440
- let h = [];
1441
- if (v) {
1442
- const w = v.getSignature();
1443
- h = D(w, v);
1447
+ const y = h.getConstructors()[0] ?? null;
1448
+ let g = [];
1449
+ if (y) {
1450
+ const j = y.getSignature();
1451
+ g = B(j, y);
1444
1452
  }
1445
- const S = [u, y], b = Z(l, S), $ = h.filter((w) => w.name !== "ctx"), j = $.filter((w) => !w.optional).map((w) => w.name), x = {};
1446
- for (const w of $)
1447
- x[w.name] = await A(
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)
1455
+ $[j.name] = await A(
1448
1456
  s,
1449
1457
  a,
1450
- w.type,
1458
+ j.type,
1451
1459
  n,
1452
1460
  t
1453
1461
  );
1454
- f.push({
1462
+ l.push({
1455
1463
  id: b,
1456
1464
  host: "ts",
1457
- namespace: l,
1458
- path: S,
1465
+ namespace: u,
1466
+ path: v,
1459
1467
  kind: "constructor",
1460
1468
  async: !1,
1461
1469
  streaming: !1,
1462
1470
  safe: !1,
1463
- input: { type: "object", properties: x, required: j },
1471
+ input: { type: "object", properties: $, required: w },
1464
1472
  output: {
1465
1473
  type: "object",
1466
1474
  properties: { instanceId: { type: "string" } },
@@ -1469,44 +1477,44 @@ async function mt(e, t) {
1469
1477
  envelope: {},
1470
1478
  typeText: {
1471
1479
  lang: "ts",
1472
- input: ht(h),
1480
+ input: ht(g),
1473
1481
  output: "{ instanceId: string }"
1474
1482
  }
1475
1483
  });
1476
1484
  }
1477
- for (const m of p.getInstanceMethods()) {
1478
- const v = m.getName();
1479
- if (W(v))
1485
+ for (const d of h.getInstanceMethods()) {
1486
+ const y = d.getName();
1487
+ if (U(y))
1480
1488
  continue;
1481
- const h = m.getScope();
1482
- if (h === R.Private || h === R.Protected)
1489
+ const g = d.getScope();
1490
+ if (g === _.Private || g === _.Protected)
1483
1491
  continue;
1484
- const S = m.getSignature(), b = D(S, m), $ = S.getReturnType().getText(), j = m.isAsync(), x = [u, y, I(v)], w = Z(l, x), F = b.filter((N) => N.name !== "ctx"), K = F.filter((N) => !N.optional).map((N) => N.name), Y = {};
1485
- for (const N of F)
1486
- Y[N.name] = await A(
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 = {};
1493
+ for (const O of P)
1494
+ R[O.name] = await A(
1487
1495
  s,
1488
1496
  a,
1489
- N.type,
1497
+ O.type,
1490
1498
  n,
1491
1499
  t
1492
1500
  );
1493
- const ee = $.replace(/^Promise<(.+)>$/, "$1").trim(), je = await A(
1501
+ const L = x.replace(/^Promise<(.+)>$/, "$1").trim(), je = await A(
1494
1502
  s,
1495
1503
  a,
1496
- ee,
1504
+ L,
1497
1505
  n,
1498
1506
  t
1499
1507
  );
1500
- f.push({
1501
- id: w,
1508
+ l.push({
1509
+ id: j,
1502
1510
  host: "ts",
1503
- namespace: l,
1504
- path: x,
1511
+ namespace: u,
1512
+ path: $,
1505
1513
  kind: "instance-method",
1506
- async: j,
1514
+ async: w,
1507
1515
  streaming: !1,
1508
1516
  safe: !1,
1509
- input: { type: "object", properties: Y, required: K },
1517
+ input: { type: "object", properties: R, required: D },
1510
1518
  output: je,
1511
1519
  envelope: {
1512
1520
  type: "object",
@@ -1516,33 +1524,33 @@ async function mt(e, t) {
1516
1524
  typeText: {
1517
1525
  lang: "ts",
1518
1526
  input: we(b),
1519
- output: ee
1527
+ output: L
1520
1528
  }
1521
1529
  });
1522
1530
  }
1523
1531
  }
1524
1532
  }
1525
- return f;
1533
+ return l;
1526
1534
  }
1527
1535
  async function dt(e, t, r, o, n, i, s, a, c) {
1528
- const u = n.filter((T) => T.name !== "ctx"), l = u.filter((T) => !T.optional).map((T) => T.name), f = {};
1529
- for (const T of u)
1530
- f[T.name] = await A(
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(
1531
1539
  e,
1532
1540
  t,
1533
- T.type,
1541
+ m.type,
1534
1542
  a,
1535
1543
  c
1536
1544
  );
1537
- const d = i.replace(/^Promise<(.+)>$/, "$1").trim(), g = await A(
1545
+ const p = i.replace(/^Promise<(.+)>$/, "$1").trim(), S = await A(
1538
1546
  e,
1539
1547
  t,
1540
- d,
1548
+ p,
1541
1549
  a,
1542
1550
  c
1543
1551
  );
1544
1552
  return {
1545
- id: Z(r, o),
1553
+ id: J(r, o),
1546
1554
  host: "ts",
1547
1555
  namespace: r,
1548
1556
  path: o,
@@ -1551,26 +1559,26 @@ async function dt(e, t, r, o, n, i, s, a, c) {
1551
1559
  streaming: !1,
1552
1560
  safe: !1,
1553
1561
  // action → false per §4
1554
- input: { type: "object", properties: f, required: l },
1555
- output: g,
1562
+ input: { type: "object", properties: l, required: u },
1563
+ output: S,
1556
1564
  envelope: {},
1557
1565
  typeText: {
1558
1566
  lang: "ts",
1559
1567
  input: we(n),
1560
- output: d
1568
+ output: p
1561
1569
  }
1562
1570
  };
1563
1571
  }
1564
- function Z(e, t) {
1572
+ function J(e, t) {
1565
1573
  return (e.raw ? [e, ...t] : t).map((o) => o.words.join("-")).join("/");
1566
1574
  }
1567
- function I(e) {
1575
+ function C(e) {
1568
1576
  return { raw: e, words: xe(e) };
1569
1577
  }
1570
1578
  function yt(e) {
1571
1579
  return e.replace(/\.[^.]+$/, "").replace(/[._]+/g, "-");
1572
1580
  }
1573
- function D(e, t) {
1581
+ function B(e, t) {
1574
1582
  return e.getParameters().map((r) => {
1575
1583
  var s;
1576
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);
@@ -1588,7 +1596,7 @@ function we(e) {
1588
1596
  function ht(e) {
1589
1597
  return e.length === 0 ? "()" : "(" + e.map((t) => `${t.name}${t.optional ? "?" : ""}: ${t.type}`).join(", ") + ")";
1590
1598
  }
1591
- function W(e) {
1599
+ function U(e) {
1592
1600
  return !!(e === "__samples__" || e.startsWith("__") || e.startsWith("_"));
1593
1601
  }
1594
1602
  const Tt = /* @__PURE__ */ new Map([
@@ -1623,7 +1631,7 @@ function Et(e, t) {
1623
1631
  export {
1624
1632
  At as clearPersistentProjectCache,
1625
1633
  Nt as composeSchemas,
1626
- me as createExtractionSession,
1634
+ ge as createExtractionSession,
1627
1635
  bt as effectiveLanguage,
1628
1636
  Ot as extract,
1629
1637
  kt as extractClasses,