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