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