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