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