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