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