swagger-typescript-api 13.2.15 → 13.2.17
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/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/cli.cjs +16 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/{cli.js → cli.mjs} +9 -9
- package/dist/cli.mjs.map +1 -0
- package/dist/{src-CsGSW_U0.js → generate-templates-BO-5CKCm.mjs} +365 -483
- package/dist/generate-templates-BO-5CKCm.mjs.map +1 -0
- package/dist/{src-CgtuxwSo.cjs → generate-templates-wjE78AWV.cjs} +403 -503
- package/dist/generate-templates-wjE78AWV.cjs.map +1 -0
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +103 -221
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +103 -221
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +24 -29
- package/templates/default/procedure-call.ejs +1 -1
- package/templates/modular/procedure-call.ejs +1 -1
- package/CHANGELOG.md +0 -1754
- package/dist/chunk-CTAAG5j7.js +0 -13
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/src-CgtuxwSo.cjs.map +0 -1
- package/dist/src-CsGSW_U0.js.map +0 -1
- /package/dist/{cli.d.ts → cli.d.mts} +0 -0
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
9
|
let target = {};
|
|
10
|
-
for (var name
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (var name in all) {
|
|
11
|
+
__defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!no_symbols) {
|
|
17
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
}
|
|
14
19
|
return target;
|
|
15
20
|
};
|
|
16
21
|
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
+
key = keys[i];
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: ((k) => from[k]).bind(null, key),
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
33
|
return to;
|
|
25
34
|
};
|
|
@@ -30,17 +39,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
39
|
|
|
31
40
|
//#endregion
|
|
32
41
|
let consola = require("consola");
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
let es_toolkit = require("es-toolkit");
|
|
43
|
+
es_toolkit = __toESM(es_toolkit);
|
|
44
|
+
let es_toolkit_compat = require("es-toolkit/compat");
|
|
45
|
+
es_toolkit_compat = __toESM(es_toolkit_compat);
|
|
36
46
|
let typescript = require("typescript");
|
|
37
47
|
typescript = __toESM(typescript);
|
|
38
48
|
let node_path = require("node:path");
|
|
39
49
|
node_path = __toESM(node_path);
|
|
40
|
-
let
|
|
41
|
-
__biomejs_js_api = __toESM(__biomejs_js_api);
|
|
50
|
+
let _biomejs_js_api = require("@biomejs/js-api");
|
|
42
51
|
let nanoid = require("nanoid");
|
|
43
52
|
nanoid = __toESM(nanoid);
|
|
53
|
+
let node_crypto = require("node:crypto");
|
|
54
|
+
node_crypto = __toESM(node_crypto);
|
|
44
55
|
let swagger2openapi = require("swagger2openapi");
|
|
45
56
|
swagger2openapi = __toESM(swagger2openapi);
|
|
46
57
|
let yaml = require("yaml");
|
|
@@ -50,7 +61,6 @@ node_module = __toESM(node_module);
|
|
|
50
61
|
let node_url = require("node:url");
|
|
51
62
|
node_url = __toESM(node_url);
|
|
52
63
|
let eta = require("eta");
|
|
53
|
-
eta = __toESM(eta);
|
|
54
64
|
let node_fs = require("node:fs");
|
|
55
65
|
node_fs = __toESM(node_fs);
|
|
56
66
|
|
|
@@ -67,11 +77,11 @@ var CodeFormatter = class {
|
|
|
67
77
|
type: "file",
|
|
68
78
|
fileName: tempFileName
|
|
69
79
|
}, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
|
|
70
|
-
if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content
|
|
80
|
+
if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content, { span, newText }) => `${content.slice(0, span.start)}${newText}${content.slice(span.start + span.length)}`, content);
|
|
71
81
|
return content;
|
|
72
82
|
};
|
|
73
83
|
format = async (content) => {
|
|
74
|
-
const biome = await
|
|
84
|
+
const biome = await _biomejs_js_api.Biome.create({ distribution: _biomejs_js_api.Distribution.NODE });
|
|
75
85
|
const biomeProject = biome.openProject();
|
|
76
86
|
biome.applyConfiguration(biomeProject.projectKey, {
|
|
77
87
|
files: { maxSize: Number.MAX_SAFE_INTEGER },
|
|
@@ -123,8 +133,8 @@ var TsLanguageServiceHost = class {
|
|
|
123
133
|
if (fileName === this.fileName) return this.content;
|
|
124
134
|
return typescript.sys.readFile(fileName, encoding);
|
|
125
135
|
}
|
|
126
|
-
fileExists(path
|
|
127
|
-
return typescript.sys.fileExists(path
|
|
136
|
+
fileExists(path) {
|
|
137
|
+
return typescript.sys.fileExists(path);
|
|
128
138
|
}
|
|
129
139
|
};
|
|
130
140
|
|
|
@@ -140,14 +150,14 @@ var NameResolver = class {
|
|
|
140
150
|
this.reserve(reservedNames);
|
|
141
151
|
}
|
|
142
152
|
reserve(names) {
|
|
143
|
-
const fixedNames =
|
|
144
|
-
for (const name
|
|
153
|
+
const fixedNames = (0, es_toolkit.uniq)((0, es_toolkit.compact)(names));
|
|
154
|
+
for (const name of fixedNames) if (this.reservedNames.indexOf(name) === -1) this.reservedNames.push(name);
|
|
145
155
|
}
|
|
146
156
|
unreserve(names) {
|
|
147
|
-
this.reservedNames = this.reservedNames.filter((reservedName) => !names.some((name
|
|
157
|
+
this.reservedNames = this.reservedNames.filter((reservedName) => !names.some((name) => name === reservedName));
|
|
148
158
|
}
|
|
149
|
-
isReserved(name
|
|
150
|
-
return this.reservedNames.some((reservedName) => reservedName === name
|
|
159
|
+
isReserved(name) {
|
|
160
|
+
return this.reservedNames.some((reservedName) => reservedName === name);
|
|
151
161
|
}
|
|
152
162
|
resolve(variants, resolver, extras, shouldReserve = true) {
|
|
153
163
|
if (typeof resolver === "function") {
|
|
@@ -165,7 +175,7 @@ var NameResolver = class {
|
|
|
165
175
|
}
|
|
166
176
|
if (Array.isArray(variants)) {
|
|
167
177
|
let usageName = null;
|
|
168
|
-
const uniqVariants =
|
|
178
|
+
const uniqVariants = (0, es_toolkit.uniq)((0, es_toolkit.compact)(variants));
|
|
169
179
|
for (const variant of uniqVariants) if (!usageName && (!shouldReserve || !this.isReserved(variant))) usageName = variant;
|
|
170
180
|
if (usageName) {
|
|
171
181
|
shouldReserve && this.reserve([usageName]);
|
|
@@ -181,12 +191,9 @@ var NameResolver = class {
|
|
|
181
191
|
|
|
182
192
|
//#endregion
|
|
183
193
|
//#region src/util/random.ts
|
|
184
|
-
const getRandomFloat = (min = 0, max = 1) => {
|
|
185
|
-
return Math.random() * (max - min) + min;
|
|
186
|
-
};
|
|
187
194
|
const getRandomInt = (min = 0, max = 1) => {
|
|
188
195
|
if (min === max) return min;
|
|
189
|
-
return Math.round(
|
|
196
|
+
return Math.round(Math.random() * (max - min) + min);
|
|
190
197
|
};
|
|
191
198
|
|
|
192
199
|
//#endregion
|
|
@@ -216,116 +223,12 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
216
223
|
//#endregion
|
|
217
224
|
//#region package.json
|
|
218
225
|
var name = "swagger-typescript-api";
|
|
219
|
-
var version = "13.2.
|
|
226
|
+
var version = "13.2.17";
|
|
220
227
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
221
|
-
var homepage = "https://github.com/acacode/swagger-typescript-api";
|
|
222
|
-
var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
|
|
223
|
-
var repository = "github:acacode/swagger-typescript-api";
|
|
224
|
-
var license = "MIT";
|
|
225
|
-
var author = "Sergey Volkov <js2me@outlook.com>";
|
|
226
|
-
var maintainers = ["Sora Morimoto <sora@morimoto.io>"];
|
|
227
|
-
var type = "module";
|
|
228
|
-
var exports$1 = {
|
|
229
|
-
".": {
|
|
230
|
-
"import": "./dist/index.js",
|
|
231
|
-
"require": "./dist/index.cjs"
|
|
232
|
-
},
|
|
233
|
-
"./cli": {
|
|
234
|
-
"import": "./dist/cli.js",
|
|
235
|
-
"require": "./dist/cli.cjs"
|
|
236
|
-
},
|
|
237
|
-
"./package.json": "./package.json"
|
|
238
|
-
};
|
|
239
|
-
var main = "./dist/index.cjs";
|
|
240
|
-
var module$1 = "./dist/index.js";
|
|
241
|
-
var types = "./dist/index.d.cts";
|
|
242
|
-
var bin = {
|
|
243
|
-
"sta": "./dist/cli.js",
|
|
244
|
-
"swagger-typescript-api": "./dist/cli.js"
|
|
245
|
-
};
|
|
246
|
-
var files = ["dist", "templates"];
|
|
247
|
-
var scripts = {
|
|
248
|
-
"build": "tsdown",
|
|
249
|
-
"cli:help": "node index.js -h",
|
|
250
|
-
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
|
|
251
|
-
"cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
|
|
252
|
-
"format": "biome format --write .",
|
|
253
|
-
"format:check": "biome format .",
|
|
254
|
-
"lint": "biome check",
|
|
255
|
-
"prepack": "tsdown",
|
|
256
|
-
"test": "vitest run",
|
|
257
|
-
"typedoc": "typedoc"
|
|
258
|
-
};
|
|
259
|
-
var dependencies = {
|
|
260
|
-
"@biomejs/js-api": "3.0.0",
|
|
261
|
-
"@biomejs/wasm-nodejs": "2.2.5",
|
|
262
|
-
"@types/lodash": "^4.17.20",
|
|
263
|
-
"@types/swagger-schema-official": "^2.0.25",
|
|
264
|
-
"c12": "^3.3.0",
|
|
265
|
-
"citty": "^0.1.6",
|
|
266
|
-
"consola": "^3.4.2",
|
|
267
|
-
"eta": "^4.0.1",
|
|
268
|
-
"lodash": "^4.17.21",
|
|
269
|
-
"nanoid": "^5.1.6",
|
|
270
|
-
"openapi-types": "^12.1.3",
|
|
271
|
-
"swagger-schema-official": "2.0.0-bab6bed",
|
|
272
|
-
"swagger2openapi": "^7.0.8",
|
|
273
|
-
"typescript": "~5.9.3",
|
|
274
|
-
"yaml": "^2.8.1"
|
|
275
|
-
};
|
|
276
|
-
var devDependencies = {
|
|
277
|
-
"@biomejs/biome": "2.2.5",
|
|
278
|
-
"@changesets/changelog-github": "0.5.1",
|
|
279
|
-
"@changesets/cli": "2.29.7",
|
|
280
|
-
"@tsconfig/node20": "20.1.6",
|
|
281
|
-
"@tsconfig/strictest": "2.0.6",
|
|
282
|
-
"@types/node": "24.7.0",
|
|
283
|
-
"@types/swagger2openapi": "7.0.4",
|
|
284
|
-
"axios": "1.12.2",
|
|
285
|
-
"tsdown": "0.15.6",
|
|
286
|
-
"typedoc": "0.28.13",
|
|
287
|
-
"vitest": "3.2.4"
|
|
288
|
-
};
|
|
289
|
-
var packageManager = "yarn@4.10.3";
|
|
290
|
-
var engines = { "node": ">=20" };
|
|
291
|
-
var publishConfig = {
|
|
292
|
-
"access": "public",
|
|
293
|
-
"provenance": true,
|
|
294
|
-
"registry": "https://registry.npmjs.org"
|
|
295
|
-
};
|
|
296
|
-
var typedocOptions = {
|
|
297
|
-
"entryPoints": ["src/index.ts"],
|
|
298
|
-
"skipErrorChecking": true
|
|
299
|
-
};
|
|
300
|
-
var package_default = {
|
|
301
|
-
name,
|
|
302
|
-
version,
|
|
303
|
-
description,
|
|
304
|
-
homepage,
|
|
305
|
-
bugs,
|
|
306
|
-
repository,
|
|
307
|
-
license,
|
|
308
|
-
author,
|
|
309
|
-
maintainers,
|
|
310
|
-
type,
|
|
311
|
-
exports: exports$1,
|
|
312
|
-
main,
|
|
313
|
-
module: module$1,
|
|
314
|
-
types,
|
|
315
|
-
bin,
|
|
316
|
-
files,
|
|
317
|
-
scripts,
|
|
318
|
-
dependencies,
|
|
319
|
-
devDependencies,
|
|
320
|
-
packageManager,
|
|
321
|
-
engines,
|
|
322
|
-
publishConfig,
|
|
323
|
-
typedocOptions
|
|
324
|
-
};
|
|
325
228
|
|
|
326
229
|
//#endregion
|
|
327
230
|
//#region src/constants.ts
|
|
328
|
-
var constants_exports = /* @__PURE__ */
|
|
231
|
+
var constants_exports = /* @__PURE__ */ __exportAll({
|
|
329
232
|
DEFAULT_BODY_ARG_NAME: () => DEFAULT_BODY_ARG_NAME,
|
|
330
233
|
FILE_PREFIX: () => FILE_PREFIX,
|
|
331
234
|
HTTP_CLIENT: () => HTTP_CLIENT,
|
|
@@ -355,7 +258,7 @@ const HTTP_CLIENT = {
|
|
|
355
258
|
FETCH: "fetch",
|
|
356
259
|
AXIOS: "axios"
|
|
357
260
|
};
|
|
358
|
-
const PROJECT_VERSION =
|
|
261
|
+
const PROJECT_VERSION = version;
|
|
359
262
|
const RESERVED_BODY_ARG_NAMES = [
|
|
360
263
|
"data",
|
|
361
264
|
"body",
|
|
@@ -389,16 +292,6 @@ const SCHEMA_TYPES$1 = {
|
|
|
389
292
|
COMPLEX_UNKNOWN: "__unknown"
|
|
390
293
|
};
|
|
391
294
|
|
|
392
|
-
//#endregion
|
|
393
|
-
//#region src/util/object-assign.ts
|
|
394
|
-
const objectAssign = (target, updater) => {
|
|
395
|
-
if (!updater) return;
|
|
396
|
-
const update = typeof updater === "function" ? updater(target) : updater;
|
|
397
|
-
const undefinedKeys = lodash.default.map(update, (value, key) => value === void 0 && key).filter((key) => typeof key === "string");
|
|
398
|
-
Object.assign(target, lodash.default.merge(target, update));
|
|
399
|
-
for (const key of undefinedKeys) target[key] = void 0;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
295
|
//#endregion
|
|
403
296
|
//#region src/configuration.ts
|
|
404
297
|
const TsKeyword = {
|
|
@@ -599,11 +492,11 @@ var CodeGenConfig = class {
|
|
|
599
492
|
BooleanValue: (content) => `${content}`,
|
|
600
493
|
NumberValue: (content) => `${content}`,
|
|
601
494
|
NullValue: () => "null",
|
|
602
|
-
UnionType: (contents) =>
|
|
495
|
+
UnionType: (contents) => (0, es_toolkit.uniq)(contents).join(` ${this.Ts.Keyword.Union} `),
|
|
603
496
|
ExpressionGroup: (content) => content ? `(${content})` : "",
|
|
604
|
-
IntersectionType: (contents) =>
|
|
497
|
+
IntersectionType: (contents) => (0, es_toolkit.uniq)(contents).join(` ${this.Ts.Keyword.Intersection} `),
|
|
605
498
|
RecordType: (key, value) => this.Ts.TypeWithGeneric(this.Ts.Keyword.Record, [key, value]),
|
|
606
|
-
TypeField: ({ readonly, key, optional, value }) =>
|
|
499
|
+
TypeField: ({ readonly, key, optional, value }) => (0, es_toolkit.compact)([
|
|
607
500
|
readonly && "readonly ",
|
|
608
501
|
key,
|
|
609
502
|
optional && "?",
|
|
@@ -613,12 +506,12 @@ var CodeGenConfig = class {
|
|
|
613
506
|
InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
|
|
614
507
|
EnumUsageKey: (enumStruct, key) => `${enumStruct}.${key}`,
|
|
615
508
|
EnumField: (key, value) => `${key} = ${value}`,
|
|
616
|
-
EnumFieldDescription: (description
|
|
617
|
-
if (description
|
|
509
|
+
EnumFieldDescription: (description) => {
|
|
510
|
+
if (description) return ` /** ${description} */`;
|
|
618
511
|
else return "";
|
|
619
512
|
},
|
|
620
|
-
EnumFieldsWrapper: (contents) =>
|
|
621
|
-
return [this.Ts.EnumFieldDescription(description
|
|
513
|
+
EnumFieldsWrapper: (contents) => contents.map(({ key, value, description }) => {
|
|
514
|
+
return (0, es_toolkit.compact)([this.Ts.EnumFieldDescription(description), ` ${this.Ts.EnumField(key, value)}`]).join("\n");
|
|
622
515
|
}).join(",\n"),
|
|
623
516
|
ObjectWrapper: (content) => `{\n${content}\n}`,
|
|
624
517
|
MultilineComment: (contents, formatFn) => [...contents.length === 1 ? [`/** ${contents[0]} */`] : [
|
|
@@ -708,13 +601,13 @@ var CodeGenConfig = class {
|
|
|
708
601
|
}
|
|
709
602
|
];
|
|
710
603
|
templateExtensions = [".eta", ".ejs"];
|
|
711
|
-
constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks
|
|
712
|
-
|
|
713
|
-
|
|
604
|
+
constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks, ...otherConfig }) {
|
|
605
|
+
Object.assign(this.Ts, codeGenConstructs);
|
|
606
|
+
Object.assign(this.primitiveTypes, primitiveTypeConstructs);
|
|
714
607
|
this.defaultResponseType = this.Ts.Keyword.Void;
|
|
715
608
|
this.update({
|
|
716
609
|
...otherConfig,
|
|
717
|
-
hooks:
|
|
610
|
+
hooks: (0, es_toolkit.merge)(this.hooks, hooks || {}),
|
|
718
611
|
constants: {
|
|
719
612
|
...constants_exports,
|
|
720
613
|
...constants
|
|
@@ -730,7 +623,7 @@ var CodeGenConfig = class {
|
|
|
730
623
|
this.componentTypeNameResolver = new ComponentTypeNameResolver(this, []);
|
|
731
624
|
}
|
|
732
625
|
update = (update) => {
|
|
733
|
-
|
|
626
|
+
Object.assign(this, update);
|
|
734
627
|
if (this.enumNamesAsValues) this.extractEnums = true;
|
|
735
628
|
};
|
|
736
629
|
};
|
|
@@ -754,13 +647,11 @@ var SchemaComponentsMap = class {
|
|
|
754
647
|
};
|
|
755
648
|
createComponent($ref, rawTypeData) {
|
|
756
649
|
const parsed = this.parseRef($ref);
|
|
757
|
-
const typeName = parsed[parsed.length - 1];
|
|
758
|
-
const componentName = parsed[parsed.length - 2];
|
|
759
650
|
const componentSchema = {
|
|
760
651
|
$ref,
|
|
761
|
-
typeName,
|
|
652
|
+
typeName: parsed[parsed.length - 1],
|
|
762
653
|
rawTypeData,
|
|
763
|
-
componentName,
|
|
654
|
+
componentName: parsed[parsed.length - 2],
|
|
764
655
|
typeData: null
|
|
765
656
|
};
|
|
766
657
|
const usageComponent = this.config.hooks.onCreateComponent(componentSchema) || componentSchema;
|
|
@@ -837,7 +728,7 @@ var SchemaFormatters = class {
|
|
|
837
728
|
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
838
729
|
return {
|
|
839
730
|
...parsedSchema,
|
|
840
|
-
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType(
|
|
731
|
+
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType((0, es_toolkit.compact)([...parsedSchema.content.map(({ value }) => `${value}`), parsedSchema.nullable && this.config.Ts.Keyword.Null])) || this.config.Ts.Keyword.Any
|
|
841
732
|
};
|
|
842
733
|
},
|
|
843
734
|
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
@@ -854,14 +745,14 @@ var SchemaFormatters = class {
|
|
|
854
745
|
}
|
|
855
746
|
};
|
|
856
747
|
formatSchema = (parsedSchema, formatType = "base") => {
|
|
857
|
-
const schemaType =
|
|
858
|
-
return
|
|
748
|
+
const schemaType = (0, es_toolkit_compat.get)(parsedSchema, ["schemaType"]) || (0, es_toolkit_compat.get)(parsedSchema, ["$parsed", "schemaType"]);
|
|
749
|
+
return (0, es_toolkit_compat.get)(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
|
|
859
750
|
};
|
|
860
|
-
formatDescription = (description
|
|
861
|
-
if (!description
|
|
862
|
-
if (!description
|
|
863
|
-
if (inline) return
|
|
864
|
-
return description
|
|
751
|
+
formatDescription = (description, inline) => {
|
|
752
|
+
if (!description) return "";
|
|
753
|
+
if (!description.includes("\n")) return description;
|
|
754
|
+
if (inline) return (0, es_toolkit.compact)(description.split(/\n/g).map((part) => part.trim())).join(" ");
|
|
755
|
+
return description.replace(/\n$/g, "");
|
|
865
756
|
};
|
|
866
757
|
formatObjectContent = (content) => {
|
|
867
758
|
const fields = [];
|
|
@@ -922,8 +813,8 @@ var MonoSchemaParser = class {
|
|
|
922
813
|
var ArraySchemaParser = class extends MonoSchemaParser {
|
|
923
814
|
parse() {
|
|
924
815
|
let contentType;
|
|
925
|
-
const { type
|
|
926
|
-
if (Array.isArray(items) && type
|
|
816
|
+
const { type, description, items } = this.schema || {};
|
|
817
|
+
if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) {
|
|
927
818
|
const tupleContent = [];
|
|
928
819
|
for (const item of items) tupleContent.push(this.schemaParserFabric.createSchemaParser({
|
|
929
820
|
schema: item,
|
|
@@ -945,7 +836,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
945
836
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
946
837
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
947
838
|
name: this.typeName,
|
|
948
|
-
description: this.schemaFormatters.formatDescription(description
|
|
839
|
+
description: this.schemaFormatters.formatDescription(description),
|
|
949
840
|
content: this.schemaUtils.safeAddNullToType(this.schema, contentType)
|
|
950
841
|
};
|
|
951
842
|
}
|
|
@@ -956,7 +847,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
956
847
|
var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
957
848
|
parse() {
|
|
958
849
|
const complexType = this.schemaUtils.getComplexType(this.schema);
|
|
959
|
-
const simpleSchema =
|
|
850
|
+
const simpleSchema = (0, es_toolkit.omit)(this.schema, Object.keys(this.schemaParser._complexSchemaParsers));
|
|
960
851
|
const complexSchemaContent = this.schemaParser._complexSchemaParsers[complexType](this.schema);
|
|
961
852
|
return {
|
|
962
853
|
...typeof this.schema === "object" ? this.schema : {},
|
|
@@ -966,8 +857,8 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
966
857
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
967
858
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
968
859
|
name: this.typeName,
|
|
969
|
-
description: this.schemaFormatters.formatDescription(this.schema.description ||
|
|
970
|
-
content: this.config.Ts.IntersectionType(
|
|
860
|
+
description: this.schemaFormatters.formatDescription(this.schema.description || (0, es_toolkit.compact)((this.schema[complexType] || []).map((item) => item?.description))[0] || ""),
|
|
861
|
+
content: this.config.Ts.IntersectionType((0, es_toolkit.compact)([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
971
862
|
schema: simpleSchema,
|
|
972
863
|
schemaPath: this.schemaPath
|
|
973
864
|
}).getInlineParseContent())])) || this.config.Ts.Keyword.Any
|
|
@@ -980,7 +871,7 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
980
871
|
var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
981
872
|
parse() {
|
|
982
873
|
const ts = this.config.Ts;
|
|
983
|
-
const { discriminator
|
|
874
|
+
const { discriminator, ...noDiscriminatorSchema } = this.schema;
|
|
984
875
|
if (!discriminator.mapping) return this.schemaParserFabric.createSchemaParser({
|
|
985
876
|
schema: noDiscriminatorSchema,
|
|
986
877
|
typeName: this.typeName,
|
|
@@ -992,7 +883,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
992
883
|
skipMappingType,
|
|
993
884
|
abstractSchemaStruct
|
|
994
885
|
});
|
|
995
|
-
const schemaContent = ts.IntersectionType([abstractSchemaStruct?.content, discriminatorSchemaStruct?.content]
|
|
886
|
+
const schemaContent = ts.IntersectionType((0, es_toolkit.compact)([abstractSchemaStruct?.content, discriminatorSchemaStruct?.content]));
|
|
996
887
|
return {
|
|
997
888
|
...typeof this.schema === "object" ? this.schema : {},
|
|
998
889
|
$schemaPath: this.schemaPath.slice(),
|
|
@@ -1013,7 +904,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1013
904
|
this.typeName
|
|
1014
905
|
]);
|
|
1015
906
|
const { discriminator } = this.schema;
|
|
1016
|
-
const mappingEntries =
|
|
907
|
+
const mappingEntries = Object.entries(discriminator.mapping || {});
|
|
1017
908
|
const ableToCreateMappingType = !skipMappingType && !!(abstractSchemaStruct?.typeName && mappingEntries.length);
|
|
1018
909
|
const mappingContents = [];
|
|
1019
910
|
let mappingTypeName;
|
|
@@ -1073,22 +964,24 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1073
964
|
};
|
|
1074
965
|
createMappingPropertySchemaEnumKeys = ({ abstractSchemaStruct, discPropertyName }) => {
|
|
1075
966
|
const ts = this.config.Ts;
|
|
1076
|
-
|
|
1077
|
-
let mappingPropertySchema =
|
|
967
|
+
const mappingPropertySchemaEnumKeysMap = {};
|
|
968
|
+
let mappingPropertySchema = (0, es_toolkit_compat.get)(abstractSchemaStruct?.component?.rawTypeData, ["properties", discPropertyName]);
|
|
1078
969
|
if (this.schemaUtils.isRefSchema(mappingPropertySchema)) mappingPropertySchema = this.schemaUtils.getSchemaRefType(mappingPropertySchema);
|
|
1079
970
|
const parsedEnum = mappingPropertySchema?.rawTypeData?.$parsed;
|
|
1080
|
-
if (parsedEnum?.type === SCHEMA_TYPES$1.ENUM)
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1083
|
-
const
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
971
|
+
if (parsedEnum?.type === SCHEMA_TYPES$1.ENUM) {
|
|
972
|
+
const enumEntries = (parsedEnum.enum || []).map((key, index) => [key, index]);
|
|
973
|
+
for (const [key, index] of enumEntries) {
|
|
974
|
+
const enumContent = parsedEnum.content?.[index];
|
|
975
|
+
if (this.config.generateUnionEnums) {
|
|
976
|
+
const literalValue = enumContent?.value ?? (key !== void 0 ? ts.StringValue(key) : void 0);
|
|
977
|
+
if (literalValue !== void 0) mappingPropertySchemaEnumKeysMap[key] = literalValue;
|
|
978
|
+
} else if (parsedEnum.typeName && enumContent?.key) mappingPropertySchemaEnumKeysMap[key] = ts.EnumUsageKey(parsedEnum.typeName, enumContent.key);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
1088
981
|
return mappingPropertySchemaEnumKeysMap;
|
|
1089
982
|
};
|
|
1090
983
|
mutateMappingDependentSchema = ({ discPropertyName, abstractSchemaStruct, mappingSchema, refPath, mappingPropertySchemaEnumKeysMap }) => {
|
|
1091
|
-
const complexSchemaKeys =
|
|
984
|
+
const complexSchemaKeys = Object.keys(this.schemaParser._complexSchemaParsers);
|
|
1092
985
|
if (mappingSchema.$ref && abstractSchemaStruct?.component?.$ref) {
|
|
1093
986
|
const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData;
|
|
1094
987
|
if (mappingRefSchema) {
|
|
@@ -1107,11 +1000,11 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1107
1000
|
}
|
|
1108
1001
|
};
|
|
1109
1002
|
createAbstractSchemaStruct = () => {
|
|
1110
|
-
const { discriminator
|
|
1111
|
-
const complexSchemaKeys =
|
|
1112
|
-
const schema =
|
|
1003
|
+
const { discriminator, ...noDiscriminatorSchema } = this.schema;
|
|
1004
|
+
const complexSchemaKeys = Object.keys(this.schemaParser._complexSchemaParsers);
|
|
1005
|
+
const schema = (0, es_toolkit.omit)(structuredClone(noDiscriminatorSchema), complexSchemaKeys);
|
|
1113
1006
|
const schemaIsAny = this.schemaParserFabric.getInlineParseContent(structuredClone(schema)) === this.config.Ts.Keyword.Any;
|
|
1114
|
-
if (!
|
|
1007
|
+
if (!Object.keys(schema).length || schemaIsAny) return null;
|
|
1115
1008
|
const typeName = this.schemaUtils.resolveTypeName(this.typeName, {
|
|
1116
1009
|
prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,
|
|
1117
1010
|
resolver: this.config.extractingOptions.discriminatorAbstractResolver
|
|
@@ -1124,14 +1017,13 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1124
1017
|
...schema,
|
|
1125
1018
|
internal: true
|
|
1126
1019
|
});
|
|
1127
|
-
const content = this.schemaParserFabric.createSchemaParser({
|
|
1128
|
-
schema: component,
|
|
1129
|
-
schemaPath: this.schemaPath
|
|
1130
|
-
}).getInlineParseContent();
|
|
1131
1020
|
return {
|
|
1132
1021
|
typeName,
|
|
1133
1022
|
component,
|
|
1134
|
-
content
|
|
1023
|
+
content: this.schemaParserFabric.createSchemaParser({
|
|
1024
|
+
schema: component,
|
|
1025
|
+
schemaPath: this.schemaPath
|
|
1026
|
+
}).getInlineParseContent()
|
|
1135
1027
|
};
|
|
1136
1028
|
};
|
|
1137
1029
|
createComplexSchemaStruct = () => {
|
|
@@ -1181,9 +1073,9 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1181
1073
|
const refType = this.schemaUtils.getSchemaRefType(this.schema);
|
|
1182
1074
|
const $ref = refType?.$ref || null;
|
|
1183
1075
|
if (Array.isArray(this.schema.enum)) this.schema.enum = this.schema.enum.filter((key) => key != null);
|
|
1184
|
-
if (Array.isArray(this.schema.enum) && Array.isArray(this.schema.enum[0])) return this.schemaParserFabric.parseSchema({ oneOf: this.schema.enum.map((enumNames
|
|
1076
|
+
if (Array.isArray(this.schema.enum) && Array.isArray(this.schema.enum[0])) return this.schemaParserFabric.parseSchema({ oneOf: this.schema.enum.map((enumNames) => ({
|
|
1185
1077
|
type: "array",
|
|
1186
|
-
items: enumNames
|
|
1078
|
+
items: enumNames.map((enumName) => ({
|
|
1187
1079
|
type: "string",
|
|
1188
1080
|
enum: [enumName]
|
|
1189
1081
|
}))
|
|
@@ -1208,8 +1100,8 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1208
1100
|
default: return this.config.Ts.StringValue(value);
|
|
1209
1101
|
}
|
|
1210
1102
|
};
|
|
1211
|
-
if (Array.isArray(enumNames) &&
|
|
1212
|
-
const enumValue =
|
|
1103
|
+
if (Array.isArray(enumNames) && enumNames.length > 0) content = enumNames.map((enumName, index) => {
|
|
1104
|
+
const enumValue = (0, es_toolkit_compat.get)(this.schema.enum, index);
|
|
1213
1105
|
const formattedKey = this.formatEnumKey({
|
|
1214
1106
|
key: enumName,
|
|
1215
1107
|
value: enumValue
|
|
@@ -1277,21 +1169,24 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1277
1169
|
}
|
|
1278
1170
|
getObjectSchemaContent = (schema) => {
|
|
1279
1171
|
const { properties, additionalProperties } = schema || {};
|
|
1280
|
-
const propertiesContent =
|
|
1281
|
-
|
|
1282
|
-
const
|
|
1172
|
+
const propertiesContent = [];
|
|
1173
|
+
for (const [name, property] of Object.entries(properties || {})) {
|
|
1174
|
+
const required = this.schemaUtils.isPropertyRequired(name, property, schema);
|
|
1175
|
+
const rawTypeData = (0, es_toolkit_compat.get)(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {});
|
|
1283
1176
|
const nullable = !!(rawTypeData.nullable || property.nullable);
|
|
1284
|
-
const fieldName = this.typeNameFormatter.isValidName(name
|
|
1177
|
+
const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name);
|
|
1285
1178
|
const fieldValue = this.schemaParserFabric.createSchemaParser({
|
|
1286
1179
|
schema: property,
|
|
1287
|
-
schemaPath: [...this.schemaPath, name
|
|
1180
|
+
schemaPath: [...this.schemaPath, name]
|
|
1288
1181
|
}).getInlineParseContent();
|
|
1289
1182
|
const readOnly = property.readOnly;
|
|
1290
|
-
|
|
1183
|
+
const complexType = this.schemaUtils.getComplexType(property);
|
|
1184
|
+
const rawDataComplexType = this.schemaUtils.getComplexType(rawTypeData);
|
|
1185
|
+
propertiesContent.push({
|
|
1291
1186
|
...property,
|
|
1292
1187
|
$$raw: property,
|
|
1293
1188
|
title: property.title,
|
|
1294
|
-
description: property.description ||
|
|
1189
|
+
description: property.description || (0, es_toolkit.compact)((property[complexType] || []).map((item) => item?.description))[0] || rawTypeData.description || (0, es_toolkit.compact)((rawTypeData[rawDataComplexType] || []).map((item) => item?.description))[0] || "",
|
|
1295
1190
|
isRequired: required,
|
|
1296
1191
|
isNullable: nullable,
|
|
1297
1192
|
name: fieldName,
|
|
@@ -1302,8 +1197,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1302
1197
|
key: fieldName,
|
|
1303
1198
|
value: fieldValue
|
|
1304
1199
|
})
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1307
1202
|
if (additionalProperties) {
|
|
1308
1203
|
const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(schema);
|
|
1309
1204
|
let interfaceKeysContent;
|
|
@@ -1328,8 +1223,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1328
1223
|
var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
1329
1224
|
parse() {
|
|
1330
1225
|
let contentType = null;
|
|
1331
|
-
const { additionalProperties, type
|
|
1332
|
-
if (type
|
|
1226
|
+
const { additionalProperties, type, description, items } = this.schema || {};
|
|
1227
|
+
if (type === this.config.Ts.Keyword.Object && additionalProperties) {
|
|
1333
1228
|
const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
|
|
1334
1229
|
let recordKeysContent;
|
|
1335
1230
|
let recordValuesContent;
|
|
@@ -1345,11 +1240,11 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1345
1240
|
else recordValuesContent = this.config.Ts.Keyword.Any;
|
|
1346
1241
|
contentType = this.config.Ts.RecordType(recordKeysContent, recordValuesContent);
|
|
1347
1242
|
}
|
|
1348
|
-
if (Array.isArray(type
|
|
1243
|
+
if (Array.isArray(type) && type.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
|
|
1349
1244
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1350
|
-
oneOf: type
|
|
1245
|
+
oneOf: type.map((type) => ({ type }))
|
|
1351
1246
|
});
|
|
1352
|
-
if (Array.isArray(items) && type
|
|
1247
|
+
if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1353
1248
|
schema: item,
|
|
1354
1249
|
schemaPath: this.schemaPath
|
|
1355
1250
|
}).getInlineParseContent()));
|
|
@@ -1361,8 +1256,8 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1361
1256
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1362
1257
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
1363
1258
|
name: this.typeName,
|
|
1364
|
-
description: this.schemaFormatters.formatDescription(description
|
|
1365
|
-
content: type
|
|
1259
|
+
description: this.schemaFormatters.formatDescription(description),
|
|
1260
|
+
content: type === this.config.Ts.Keyword.Null ? type : contentType || this.schemaUtils.getSchemaType(this.schema)
|
|
1366
1261
|
};
|
|
1367
1262
|
}
|
|
1368
1263
|
};
|
|
@@ -1374,8 +1269,8 @@ var AllOfSchemaParser = class extends MonoSchemaParser {
|
|
|
1374
1269
|
const ignoreTypes = [this.config.Ts.Keyword.Any];
|
|
1375
1270
|
const combined = this.schema.allOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
|
|
1376
1271
|
const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
|
|
1377
|
-
const type
|
|
1378
|
-
return this.schemaUtils.safeAddNullToType(this.schema, type
|
|
1272
|
+
const type = this.config.Ts.IntersectionType(filtered);
|
|
1273
|
+
return this.schemaUtils.safeAddNullToType(this.schema, type);
|
|
1379
1274
|
}
|
|
1380
1275
|
};
|
|
1381
1276
|
|
|
@@ -1386,8 +1281,8 @@ var AnyOfSchemaParser = class extends MonoSchemaParser {
|
|
|
1386
1281
|
const ignoreTypes = [this.config.Ts.Keyword.Any];
|
|
1387
1282
|
const combined = this.schema.anyOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
|
|
1388
1283
|
const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
|
|
1389
|
-
const type
|
|
1390
|
-
return this.schemaUtils.safeAddNullToType(this.schema, type
|
|
1284
|
+
const type = this.config.Ts.UnionType(filtered);
|
|
1285
|
+
return this.schemaUtils.safeAddNullToType(this.schema, type);
|
|
1391
1286
|
}
|
|
1392
1287
|
};
|
|
1393
1288
|
|
|
@@ -1406,8 +1301,8 @@ var OneOfSchemaParser = class extends MonoSchemaParser {
|
|
|
1406
1301
|
const ignoreTypes = [this.config.Ts.Keyword.Any];
|
|
1407
1302
|
const combined = this.schema.oneOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
|
|
1408
1303
|
const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
|
|
1409
|
-
const type
|
|
1410
|
-
return this.schemaUtils.safeAddNullToType(this.schema, type
|
|
1304
|
+
const type = this.config.Ts.UnionType(filtered);
|
|
1305
|
+
return this.schemaUtils.safeAddNullToType(this.schema, type);
|
|
1411
1306
|
}
|
|
1412
1307
|
};
|
|
1413
1308
|
|
|
@@ -1496,7 +1391,7 @@ var SchemaParser = class {
|
|
|
1496
1391
|
}
|
|
1497
1392
|
schemaType = this.schemaUtils.getInternalSchemaType(this.schema);
|
|
1498
1393
|
this.schemaPath.push(this.typeName);
|
|
1499
|
-
|
|
1394
|
+
(0, es_toolkit.merge)(this.schema, this.config.hooks.onPreParseSchema(this.schema, this.typeName, schemaType) || {});
|
|
1500
1395
|
parsedSchema = this._baseSchemaParsers[schemaType](this.schema, this.typeName);
|
|
1501
1396
|
this.schema.$parsed = this.config.hooks.onParseSchema(this.schema, parsedSchema) || parsedSchema;
|
|
1502
1397
|
if (this.config.sortTypes && Array.isArray(this.schema.$parsed?.content)) this.schema.$parsed.content = this.schema.$parsed.content.sort(sortByProperty("name"));
|
|
@@ -1513,28 +1408,23 @@ var SchemaParser = class {
|
|
|
1513
1408
|
return this.schemaFormatters.formatSchema(parsedSchema, "base").content;
|
|
1514
1409
|
};
|
|
1515
1410
|
extractSchemaFromResponseStruct = (responseStruct) => {
|
|
1516
|
-
const { content
|
|
1517
|
-
const firstResponse =
|
|
1518
|
-
const firstSchema =
|
|
1411
|
+
const { content, ...extras } = responseStruct;
|
|
1412
|
+
const firstResponse = Object.values(content || {})[0];
|
|
1413
|
+
const firstSchema = (0, es_toolkit_compat.get)(firstResponse, "schema");
|
|
1519
1414
|
if (!firstSchema) return;
|
|
1415
|
+
const { schema: _, ...restResponse } = firstResponse || {};
|
|
1520
1416
|
return {
|
|
1521
1417
|
...extras,
|
|
1522
|
-
...
|
|
1418
|
+
...restResponse,
|
|
1523
1419
|
...firstSchema
|
|
1524
1420
|
};
|
|
1525
1421
|
};
|
|
1526
1422
|
};
|
|
1527
1423
|
|
|
1528
|
-
//#endregion
|
|
1529
|
-
//#region src/util/internal-case.ts
|
|
1530
|
-
function internalCase(value) {
|
|
1531
|
-
return lodash.default.camelCase(lodash.default.lowerCase(value));
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
1424
|
//#endregion
|
|
1535
1425
|
//#region src/util/pascal-case.ts
|
|
1536
1426
|
function pascalCase(value) {
|
|
1537
|
-
return
|
|
1427
|
+
return (0, es_toolkit_compat.upperFirst)((0, es_toolkit_compat.camelCase)(value));
|
|
1538
1428
|
}
|
|
1539
1429
|
|
|
1540
1430
|
//#endregion
|
|
@@ -1551,7 +1441,7 @@ var SchemaUtils = class {
|
|
|
1551
1441
|
this.schemaWalker = schemaWalker;
|
|
1552
1442
|
}
|
|
1553
1443
|
getRequiredProperties = (schema) => {
|
|
1554
|
-
return
|
|
1444
|
+
return (0, es_toolkit.uniq)(schema && Array.isArray(schema.required) && schema.required || []);
|
|
1555
1445
|
};
|
|
1556
1446
|
isRefSchema = (schema) => {
|
|
1557
1447
|
return !!schema?.$ref;
|
|
@@ -1570,29 +1460,29 @@ var SchemaUtils = class {
|
|
|
1570
1460
|
if (!this.isRefSchema(schema)) return null;
|
|
1571
1461
|
return this.schemaComponentsMap.get(schema.$ref);
|
|
1572
1462
|
};
|
|
1573
|
-
isPropertyRequired = (name
|
|
1463
|
+
isPropertyRequired = (name, propertySchema, rootSchema) => {
|
|
1574
1464
|
if (propertySchema["x-omitempty"] === false) return true;
|
|
1575
|
-
const isRequired = typeof propertySchema.required === "boolean" ? !!propertySchema.required : Array.isArray(rootSchema.required) ? rootSchema.required.includes(name
|
|
1465
|
+
const isRequired = typeof propertySchema.required === "boolean" ? !!propertySchema.required : Array.isArray(rootSchema.required) ? rootSchema.required.includes(name) : !!rootSchema.required;
|
|
1576
1466
|
if (this.config.convertedFromSwagger2) return typeof propertySchema.nullable === this.config.Ts.Keyword.Undefined ? isRequired : !propertySchema.nullable;
|
|
1577
1467
|
return isRequired;
|
|
1578
1468
|
};
|
|
1579
|
-
isNullMissingInType = (schema, type
|
|
1469
|
+
isNullMissingInType = (schema, type) => {
|
|
1580
1470
|
const { nullable, type: schemaType } = schema || {};
|
|
1581
|
-
return (nullable || !!
|
|
1471
|
+
return (nullable || !!(0, es_toolkit_compat.get)(schema, "x-nullable") || schemaType === this.config.Ts.Keyword.Null) && typeof type === "string" && !type.includes(` ${this.config.Ts.Keyword.Null}`) && !type.includes(`${this.config.Ts.Keyword.Null} `);
|
|
1582
1472
|
};
|
|
1583
|
-
safeAddNullToType = (schema, type
|
|
1584
|
-
if (this.isNullMissingInType(schema, type
|
|
1585
|
-
return type
|
|
1473
|
+
safeAddNullToType = (schema, type) => {
|
|
1474
|
+
if (this.isNullMissingInType(schema, type)) return this.config.Ts.UnionType([type, this.config.Ts.Keyword.Null]);
|
|
1475
|
+
return type;
|
|
1586
1476
|
};
|
|
1587
1477
|
getSchemaPrimitiveType = (rawSchema) => {
|
|
1588
1478
|
const schema = rawSchema || {};
|
|
1589
|
-
if (schema.type) return
|
|
1479
|
+
if (schema.type) return (0, es_toolkit_compat.camelCase)(schema.type);
|
|
1590
1480
|
if (schema.enum) {
|
|
1591
1481
|
const enumFieldType = typeof schema.enum[0];
|
|
1592
1482
|
if (enumFieldType === this.config.Ts.Keyword.Undefined) return;
|
|
1593
|
-
return
|
|
1483
|
+
return (0, es_toolkit_compat.camelCase)(enumFieldType);
|
|
1594
1484
|
}
|
|
1595
|
-
if (
|
|
1485
|
+
if (Object.keys(schema.properties || {}).length) return SCHEMA_TYPES$1.OBJECT;
|
|
1596
1486
|
if (schema.items) return SCHEMA_TYPES$1.ARRAY;
|
|
1597
1487
|
return null;
|
|
1598
1488
|
};
|
|
@@ -1605,10 +1495,10 @@ var SchemaUtils = class {
|
|
|
1605
1495
|
};
|
|
1606
1496
|
makeAddRequiredToChildSchema = (parentSchema, childSchema) => {
|
|
1607
1497
|
if (!childSchema) return childSchema;
|
|
1608
|
-
const required =
|
|
1498
|
+
const required = (0, es_toolkit.uniq)([...this.getRequiredProperties(parentSchema), ...this.getRequiredProperties(childSchema)]);
|
|
1609
1499
|
const refData = this.getSchemaRefType(childSchema);
|
|
1610
1500
|
if (refData) {
|
|
1611
|
-
const existedRequiredKeys =
|
|
1501
|
+
const existedRequiredKeys = Object.keys(refData.rawTypeData?.properties || {}).filter((key) => required.includes(key));
|
|
1612
1502
|
if (!existedRequiredKeys.length) return childSchema;
|
|
1613
1503
|
return {
|
|
1614
1504
|
...childSchema,
|
|
@@ -1616,17 +1506,17 @@ var SchemaUtils = class {
|
|
|
1616
1506
|
};
|
|
1617
1507
|
}
|
|
1618
1508
|
if (childSchema.properties) {
|
|
1619
|
-
const existedRequiredKeys =
|
|
1509
|
+
const existedRequiredKeys = Object.keys(childSchema.properties).filter((key) => required.includes(key));
|
|
1620
1510
|
if (!existedRequiredKeys.length) return childSchema;
|
|
1621
1511
|
return {
|
|
1622
|
-
required:
|
|
1512
|
+
required: (0, es_toolkit.uniq)([...this.getRequiredProperties(childSchema), ...existedRequiredKeys]),
|
|
1623
1513
|
...childSchema
|
|
1624
1514
|
};
|
|
1625
1515
|
}
|
|
1626
1516
|
return childSchema;
|
|
1627
1517
|
};
|
|
1628
1518
|
filterSchemaContents = (contents, filterFn) => {
|
|
1629
|
-
return
|
|
1519
|
+
return (0, es_toolkit.uniq)(contents.filter((type) => filterFn(type)));
|
|
1630
1520
|
};
|
|
1631
1521
|
resolveTypeName = (typeName, { suffixes, resolver, prefixes, shouldReserve = true }) => {
|
|
1632
1522
|
if (resolver) return this.config.componentTypeNameResolver.resolve([], (reserved) => {
|
|
@@ -1642,10 +1532,10 @@ var SchemaUtils = class {
|
|
|
1642
1532
|
return SCHEMA_TYPES$1.COMPLEX_UNKNOWN;
|
|
1643
1533
|
};
|
|
1644
1534
|
getInternalSchemaType = (schema) => {
|
|
1645
|
-
if (
|
|
1535
|
+
if (schema.enum && schema.enum.length > 0 || this.getEnumNames(schema) && this.getEnumNames(schema).length > 0) return SCHEMA_TYPES$1.ENUM;
|
|
1646
1536
|
if (schema.discriminator) return SCHEMA_TYPES$1.DISCRIMINATOR;
|
|
1647
1537
|
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES$1.COMPLEX;
|
|
1648
|
-
if (
|
|
1538
|
+
if (schema.properties && Object.keys(schema.properties).length > 0) return SCHEMA_TYPES$1.OBJECT;
|
|
1649
1539
|
if (schema.type === SCHEMA_TYPES$1.ARRAY) return SCHEMA_TYPES$1.ARRAY;
|
|
1650
1540
|
return SCHEMA_TYPES$1.PRIMITIVE;
|
|
1651
1541
|
};
|
|
@@ -1658,7 +1548,7 @@ var SchemaUtils = class {
|
|
|
1658
1548
|
else {
|
|
1659
1549
|
const primitiveType = this.getSchemaPrimitiveType(schema);
|
|
1660
1550
|
if (primitiveType == null) return this.config.Ts.Keyword.Any;
|
|
1661
|
-
const typeAlias =
|
|
1551
|
+
const typeAlias = (0, es_toolkit_compat.get)(this.config.primitiveTypes, [primitiveType, schema.format]) || (0, es_toolkit_compat.get)(this.config.primitiveTypes, [primitiveType, "$default"]) || this.config.primitiveTypes[primitiveType];
|
|
1662
1552
|
if (typeof typeAlias === "function") resultType = typeAlias(schema, this);
|
|
1663
1553
|
else resultType = typeAlias || primitiveType;
|
|
1664
1554
|
}
|
|
@@ -1666,9 +1556,9 @@ var SchemaUtils = class {
|
|
|
1666
1556
|
return this.checkAndAddRequiredKeys(schema, this.safeAddNullToType(schema, resultType));
|
|
1667
1557
|
};
|
|
1668
1558
|
buildTypeNameFromPath = (schemaPath) => {
|
|
1669
|
-
schemaPath =
|
|
1559
|
+
schemaPath = (0, es_toolkit.uniq)((0, es_toolkit.compact)(schemaPath || []));
|
|
1670
1560
|
if (!schemaPath || !schemaPath[0]) return null;
|
|
1671
|
-
return pascalCase(
|
|
1561
|
+
return pascalCase((0, es_toolkit.uniq)([schemaPath[0], schemaPath[schemaPath.length - 1]]).join("_"));
|
|
1672
1562
|
};
|
|
1673
1563
|
isConstantSchema(schema) {
|
|
1674
1564
|
return "const" in schema;
|
|
@@ -1711,7 +1601,7 @@ var SchemaParserFabric = class {
|
|
|
1711
1601
|
schemaPath
|
|
1712
1602
|
});
|
|
1713
1603
|
};
|
|
1714
|
-
createSchema = ({ content, linkedSchema = {}, linkedComponent, schemaPath
|
|
1604
|
+
createSchema = ({ content, linkedSchema = {}, linkedComponent, schemaPath, ...otherSchemaProps }) => {
|
|
1715
1605
|
const parser = this.createSchemaParser({
|
|
1716
1606
|
schema: linkedComponent || linkedSchema,
|
|
1717
1607
|
schemaPath
|
|
@@ -1759,8 +1649,7 @@ var SchemaParserFabric = class {
|
|
|
1759
1649
|
|
|
1760
1650
|
//#endregion
|
|
1761
1651
|
//#region src/util/id.ts
|
|
1762
|
-
const
|
|
1763
|
-
const generateId = nanoid.customAlphabet(ALPHABET, 12);
|
|
1652
|
+
const generateId = () => node_crypto.randomUUID();
|
|
1764
1653
|
|
|
1765
1654
|
//#endregion
|
|
1766
1655
|
//#region src/schema-routes/util/specific-arg-name-resolver.ts
|
|
@@ -1805,7 +1694,7 @@ var SchemaRoutes = class {
|
|
|
1805
1694
|
this.typeNameFormatter = typeNameFormatter;
|
|
1806
1695
|
this.schemaComponentsMap = schemaComponentsMap;
|
|
1807
1696
|
this.templatesWorker = templatesWorker;
|
|
1808
|
-
this.FORM_DATA_TYPES =
|
|
1697
|
+
this.FORM_DATA_TYPES = (0, es_toolkit.uniq)([this.schemaUtils.getSchemaType({
|
|
1809
1698
|
type: "string",
|
|
1810
1699
|
format: "file"
|
|
1811
1700
|
}), this.schemaUtils.getSchemaType({
|
|
@@ -1813,49 +1702,50 @@ var SchemaRoutes = class {
|
|
|
1813
1702
|
format: "binary"
|
|
1814
1703
|
})]);
|
|
1815
1704
|
}
|
|
1816
|
-
createRequestsMap = (
|
|
1817
|
-
const parameters =
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1705
|
+
createRequestsMap = (routesByMethod) => {
|
|
1706
|
+
const parameters = (0, es_toolkit_compat.get)(routesByMethod, "parameters");
|
|
1707
|
+
const result = {};
|
|
1708
|
+
for (const [method, requestInfo] of Object.entries(routesByMethod)) {
|
|
1709
|
+
if (method.startsWith("x-") || ["parameters", "$ref"].includes(method)) continue;
|
|
1710
|
+
result[method] = {
|
|
1821
1711
|
...requestInfo,
|
|
1822
|
-
parameters:
|
|
1712
|
+
parameters: (0, es_toolkit.compact)([...parameters || [], ...requestInfo.parameters || []])
|
|
1823
1713
|
};
|
|
1824
|
-
|
|
1825
|
-
|
|
1714
|
+
}
|
|
1715
|
+
return result;
|
|
1826
1716
|
};
|
|
1827
|
-
parseRouteName = (
|
|
1828
|
-
const routeName = this.config.hooks.onPreBuildRoutePath(
|
|
1717
|
+
parseRouteName = (rawRoute) => {
|
|
1718
|
+
const routeName = this.config.hooks.onPreBuildRoutePath(rawRoute) || rawRoute;
|
|
1829
1719
|
const pathParamMatches = (routeName || "").match(/({[\w[\\\]^`][-_.\w]*})|(:[\w[\\\]^`][-_.\w]*:?)/g);
|
|
1830
|
-
const pathParams =
|
|
1720
|
+
const pathParams = [];
|
|
1721
|
+
for (const match of pathParamMatches || []) {
|
|
1831
1722
|
const paramName = match.replace(/\{|\}|:/g, "");
|
|
1832
|
-
if (!paramName)
|
|
1723
|
+
if (!paramName) continue;
|
|
1833
1724
|
if (paramName.includes("-")) consola.consola.warn("wrong path param name", paramName);
|
|
1834
|
-
pathParams
|
|
1725
|
+
pathParams.push({
|
|
1835
1726
|
$match: match,
|
|
1836
|
-
name:
|
|
1727
|
+
name: (0, es_toolkit_compat.camelCase)(paramName),
|
|
1837
1728
|
required: true,
|
|
1838
1729
|
type: "string",
|
|
1839
1730
|
description: "",
|
|
1840
1731
|
schema: { type: "string" },
|
|
1841
1732
|
in: "path"
|
|
1842
1733
|
});
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
return fixedRoute$1.replace(pathParam.$match, `\${${insertion}}`);
|
|
1734
|
+
}
|
|
1735
|
+
let fixedRoute = pathParams.reduce((fixedRoute, pathParam, i, arr) => {
|
|
1736
|
+
const insertion = this.config.hooks.onInsertPathParam(pathParam.name, i, arr, fixedRoute) || pathParam.name;
|
|
1737
|
+
return fixedRoute.replace(pathParam.$match, `\${${insertion}}`);
|
|
1848
1738
|
}, routeName || "");
|
|
1849
1739
|
const queryParamMatches = fixedRoute.match(/(\{\?.*\})/g);
|
|
1850
1740
|
const queryParams = [];
|
|
1851
1741
|
if (queryParamMatches?.length) {
|
|
1852
1742
|
for (const match of queryParamMatches) fixedRoute = fixedRoute.replace(match, "");
|
|
1853
|
-
const paramNames =
|
|
1743
|
+
const paramNames = (0, es_toolkit.uniq)(queryParamMatches.join(",").replace(/(\{\?)|(\})|\s/g, "").split(","));
|
|
1854
1744
|
for (const paramName of paramNames) {
|
|
1855
|
-
if (paramName.includes("-")) consola.consola.warn("wrong query param name", paramName);
|
|
1745
|
+
if (typeof paramName === "string" && paramName.includes("-")) consola.consola.warn("wrong query param name", paramName);
|
|
1856
1746
|
queryParams.push({
|
|
1857
1747
|
$match: paramName,
|
|
1858
|
-
name:
|
|
1748
|
+
name: typeof paramName === "string" ? (0, es_toolkit_compat.camelCase)(paramName) : (0, es_toolkit_compat.camelCase)(String(paramName)),
|
|
1859
1749
|
required: true,
|
|
1860
1750
|
type: "string",
|
|
1861
1751
|
description: "",
|
|
@@ -1865,7 +1755,7 @@ var SchemaRoutes = class {
|
|
|
1865
1755
|
}
|
|
1866
1756
|
}
|
|
1867
1757
|
const result = {
|
|
1868
|
-
originalRoute:
|
|
1758
|
+
originalRoute: rawRoute || "",
|
|
1869
1759
|
route: fixedRoute,
|
|
1870
1760
|
pathParams,
|
|
1871
1761
|
queryParams
|
|
@@ -1882,7 +1772,7 @@ var SchemaRoutes = class {
|
|
|
1882
1772
|
formData: [],
|
|
1883
1773
|
cookie: []
|
|
1884
1774
|
};
|
|
1885
|
-
|
|
1775
|
+
for (const parameter of parameters || []) {
|
|
1886
1776
|
const refTypeInfo = this.schemaParserFabric.schemaUtils.getSchemaRefType(parameter);
|
|
1887
1777
|
let routeParam = null;
|
|
1888
1778
|
if (refTypeInfo?.rawTypeData.in && refTypeInfo.rawTypeData) {
|
|
@@ -1893,7 +1783,7 @@ var SchemaRoutes = class {
|
|
|
1893
1783
|
};
|
|
1894
1784
|
if (parameter?.required && !routeParam.required) routeParam.required = parameter.required;
|
|
1895
1785
|
} else {
|
|
1896
|
-
if (!parameter.in)
|
|
1786
|
+
if (!parameter.in) continue;
|
|
1897
1787
|
if (!routeParams[parameter.in]) routeParams[parameter.in] = [];
|
|
1898
1788
|
routeParam = {
|
|
1899
1789
|
...parameter,
|
|
@@ -1901,16 +1791,19 @@ var SchemaRoutes = class {
|
|
|
1901
1791
|
};
|
|
1902
1792
|
}
|
|
1903
1793
|
if (routeParam.in === "path") {
|
|
1904
|
-
if (!routeParam.name)
|
|
1905
|
-
routeParam.name =
|
|
1794
|
+
if (!routeParam.name) continue;
|
|
1795
|
+
routeParam.name = (0, es_toolkit_compat.camelCase)(routeParam.name);
|
|
1906
1796
|
}
|
|
1907
|
-
|
|
1908
|
-
}
|
|
1797
|
+
routeParams[routeParam.in].push(routeParam);
|
|
1798
|
+
}
|
|
1909
1799
|
for (const pathParam of pathParamsFromRouteName) if (!routeParams.path.some((parameter) => parameter.name === pathParam.name)) routeParams.path.push(pathParam);
|
|
1910
1800
|
for (const queryParam of queryParamsFromRouteName) if (!routeParams.query.some((parameter) => parameter.name === queryParam.name)) routeParams.query.push(queryParam);
|
|
1911
1801
|
return routeParams;
|
|
1912
1802
|
};
|
|
1913
|
-
getContentTypes = (requestInfo, extraContentTypes) =>
|
|
1803
|
+
getContentTypes = (requestInfo, extraContentTypes) => {
|
|
1804
|
+
const requestInfoArray = Array.isArray(requestInfo) ? requestInfo : Object.values(requestInfo || {});
|
|
1805
|
+
return (0, es_toolkit.uniq)((0, es_toolkit.compact)([...extraContentTypes || [], ...(0, es_toolkit.flattenDeep)(requestInfoArray.map((requestInfoData) => requestInfoData && Object.keys(requestInfoData?.content || {})))]));
|
|
1806
|
+
};
|
|
1914
1807
|
getContentKind = (contentTypes) => {
|
|
1915
1808
|
if (contentTypes.includes("application/vnd.api+json")) return CONTENT_KIND.JSON_API;
|
|
1916
1809
|
if (contentTypes.some((contentType) => contentType.startsWith("application/json")) || contentTypes.some((contentType) => contentType.endsWith("+json"))) return CONTENT_KIND.JSON;
|
|
@@ -1922,7 +1815,7 @@ var SchemaRoutes = class {
|
|
|
1922
1815
|
};
|
|
1923
1816
|
isSuccessStatus = (status) => this.config.defaultResponseAsSuccess && status === "default" || +status >= this.config.successResponseStatusRange[0] && +status <= this.config.successResponseStatusRange[1] || status === "2xx";
|
|
1924
1817
|
getSchemaFromRequestType = (requestInfo) => {
|
|
1925
|
-
const content =
|
|
1818
|
+
const content = (0, es_toolkit_compat.get)(requestInfo, "content");
|
|
1926
1819
|
if (!content) return null;
|
|
1927
1820
|
for (const dataType in content) if (content[dataType]?.schema) return {
|
|
1928
1821
|
...content[dataType].schema,
|
|
@@ -1936,13 +1829,13 @@ var SchemaRoutes = class {
|
|
|
1936
1829
|
if (schema) {
|
|
1937
1830
|
const content = this.schemaParserFabric.getInlineParseContent(schema, typeName, [operationId]);
|
|
1938
1831
|
const foundedSchemaByName = parsedSchemas.find((parsedSchema) => this.typeNameFormatter.format(parsedSchema.name) === content);
|
|
1939
|
-
const foundSchemaByContent = parsedSchemas.find((parsedSchema) =>
|
|
1832
|
+
const foundSchemaByContent = parsedSchemas.find((parsedSchema) => (0, es_toolkit.isEqual)(parsedSchema.content, content));
|
|
1940
1833
|
const foundSchema = foundedSchemaByName || foundSchemaByContent;
|
|
1941
1834
|
return foundSchema ? this.typeNameFormatter.format(foundSchema.name) : content;
|
|
1942
1835
|
}
|
|
1943
1836
|
if (refTypeInfo) {
|
|
1944
1837
|
const typeNameWithoutOpId = refTypeInfo.typeName.replace(operationId, "");
|
|
1945
|
-
if (parsedSchemas.find((schema
|
|
1838
|
+
if (parsedSchemas.find((schema) => schema.name === typeNameWithoutOpId)) return this.typeNameFormatter.format(typeNameWithoutOpId);
|
|
1946
1839
|
switch (refTypeInfo.componentName) {
|
|
1947
1840
|
case "schemas": return this.typeNameFormatter.format(refTypeInfo.typeName);
|
|
1948
1841
|
case "responses":
|
|
@@ -1952,23 +1845,27 @@ var SchemaRoutes = class {
|
|
|
1952
1845
|
}
|
|
1953
1846
|
return defaultType || this.config.Ts.Keyword.Any;
|
|
1954
1847
|
};
|
|
1955
|
-
getRequestInfoTypes = ({ requestInfos, parsedSchemas, operationId, defaultType }) =>
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1848
|
+
getRequestInfoTypes = ({ requestInfos, parsedSchemas, operationId, defaultType }) => {
|
|
1849
|
+
const result = [];
|
|
1850
|
+
for (const [status, requestInfo] of Object.entries(requestInfos || {})) {
|
|
1851
|
+
const contentTypes = this.getContentTypes([requestInfo], operationId);
|
|
1852
|
+
result.push({
|
|
1853
|
+
...requestInfo || {},
|
|
1854
|
+
contentTypes,
|
|
1855
|
+
contentKind: this.getContentKind(contentTypes),
|
|
1856
|
+
type: this.schemaParserFabric.schemaUtils.safeAddNullToType(requestInfo, this.getTypeFromRequestInfo({
|
|
1857
|
+
requestInfo,
|
|
1858
|
+
parsedSchemas,
|
|
1859
|
+
operationId,
|
|
1860
|
+
defaultType
|
|
1861
|
+
})),
|
|
1862
|
+
description: this.schemaParserFabric.schemaFormatters.formatDescription(requestInfo.description || "", true),
|
|
1863
|
+
status: Number.isNaN(+status) ? status : +status,
|
|
1864
|
+
isSuccess: this.isSuccessStatus(status)
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
return result;
|
|
1868
|
+
};
|
|
1972
1869
|
getResponseBodyInfo = (routeInfo, parsedSchemas) => {
|
|
1973
1870
|
const { produces, operationId, responses } = routeInfo;
|
|
1974
1871
|
const contentTypes = this.getContentTypes(responses, [...produces || [], routeInfo["x-accepts"]]);
|
|
@@ -2077,13 +1974,12 @@ var SchemaRoutes = class {
|
|
|
2077
1974
|
};
|
|
2078
1975
|
return acc;
|
|
2079
1976
|
}, {});
|
|
2080
|
-
const fixedQueryParams =
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
}, {});
|
|
1977
|
+
const fixedQueryParams = {};
|
|
1978
|
+
const queryObjectProperties = (0, es_toolkit_compat.get)(queryObjectSchema, "properties") || {};
|
|
1979
|
+
for (const [name, property] of Object.entries(queryObjectProperties)) if (name && typeof property === "object") fixedQueryParams[name] = {
|
|
1980
|
+
...property,
|
|
1981
|
+
in: "query"
|
|
1982
|
+
};
|
|
2087
1983
|
const schema = {
|
|
2088
1984
|
...queryObjectSchema,
|
|
2089
1985
|
properties: {
|
|
@@ -2126,7 +2022,7 @@ var SchemaRoutes = class {
|
|
|
2126
2022
|
successResponse.schema.contentKind = contentKind;
|
|
2127
2023
|
if (successResponse.schema.typeData) successResponse.schema.typeData.isExtractedResponseBody = true;
|
|
2128
2024
|
successResponse.type = this.schemaParserFabric.getInlineParseContent({ $ref: successResponse.schema.$ref });
|
|
2129
|
-
if (idx > -1)
|
|
2025
|
+
if (idx > -1) Object.assign(responseBodyInfo.responses[idx], {
|
|
2130
2026
|
...successResponse.schema,
|
|
2131
2027
|
type: successResponse.type
|
|
2132
2028
|
});
|
|
@@ -2139,18 +2035,18 @@ var SchemaRoutes = class {
|
|
|
2139
2035
|
suffixes: this.config.extractingOptions.responseErrorSuffix,
|
|
2140
2036
|
resolver: this.config.extractingOptions.responseErrorNameResolver
|
|
2141
2037
|
});
|
|
2142
|
-
const errorSchemas = responseBodyInfo.error.schemas.map(this.getSchemaFromRequestType)
|
|
2038
|
+
const errorSchemas = (0, es_toolkit.compact)(responseBodyInfo.error.schemas.map(this.getSchemaFromRequestType));
|
|
2143
2039
|
if (!errorSchemas.length) return;
|
|
2144
2040
|
const schema = this.schemaParserFabric.parseSchema({
|
|
2145
2041
|
oneOf: errorSchemas,
|
|
2146
|
-
title: errorSchemas.map((schema
|
|
2147
|
-
description: errorSchemas.map((schema
|
|
2042
|
+
title: (0, es_toolkit.compact)(errorSchemas.map((schema) => schema.title)).join(" "),
|
|
2043
|
+
description: (0, es_toolkit.compact)(errorSchemas.map((schema) => schema.description)).join("\n")
|
|
2148
2044
|
}, null, [routeInfo.operationId]);
|
|
2149
2045
|
const component = this.schemaComponentsMap.createComponent(this.schemaComponentsMap.createRef([
|
|
2150
2046
|
"components",
|
|
2151
2047
|
"schemas",
|
|
2152
2048
|
typeName
|
|
2153
|
-
]),
|
|
2049
|
+
]), schema);
|
|
2154
2050
|
responseBodyInfo.error.schemas = [component];
|
|
2155
2051
|
if (component.typeData) component.typeData.isExtractedResponseError = true;
|
|
2156
2052
|
responseBodyInfo.error.type = this.typeNameFormatter.format(component.typeName);
|
|
@@ -2178,11 +2074,11 @@ var SchemaRoutes = class {
|
|
|
2178
2074
|
parseRouteInfo = (rawRouteName, routeInfo, method, usageSchema, parsedSchemas) => {
|
|
2179
2075
|
const { security: globalSecurity } = usageSchema;
|
|
2180
2076
|
const { moduleNameIndex, moduleNameFirstTag, extractRequestParams } = this.config;
|
|
2181
|
-
const { operationId, requestBody, security, parameters, summary, description
|
|
2077
|
+
const { operationId, requestBody, security, parameters, summary, description, tags, responses, requestBodyName, produces, consumes, ...otherInfo } = routeInfo;
|
|
2182
2078
|
const { route, pathParams: pathParamsFromRouteName, queryParams: queryParamsFromRouteName } = this.parseRouteName(rawRouteName);
|
|
2183
2079
|
const routeId = generateId();
|
|
2184
2080
|
const firstTag = tags && tags.length > 0 ? tags[0] : null;
|
|
2185
|
-
const moduleName = moduleNameFirstTag && firstTag ?
|
|
2081
|
+
const moduleName = moduleNameFirstTag && firstTag ? (0, es_toolkit_compat.camelCase)(firstTag) : (0, es_toolkit_compat.camelCase)((0, es_toolkit.compact)(route.split("/"))[moduleNameIndex] || "");
|
|
2186
2082
|
let hasSecurity = !!globalSecurity?.length;
|
|
2187
2083
|
if (security) hasSecurity = security.length > 0;
|
|
2188
2084
|
const routeParams = this.getRouteParams(routeInfo, pathParamsFromRouteName, queryParamsFromRouteName);
|
|
@@ -2202,7 +2098,7 @@ var SchemaRoutes = class {
|
|
|
2202
2098
|
route: rawRouteName,
|
|
2203
2099
|
moduleName,
|
|
2204
2100
|
responsesTypes: responseBodyInfo.responses,
|
|
2205
|
-
description
|
|
2101
|
+
description,
|
|
2206
2102
|
tags,
|
|
2207
2103
|
summary,
|
|
2208
2104
|
responses,
|
|
@@ -2299,7 +2195,7 @@ var SchemaRoutes = class {
|
|
|
2299
2195
|
};
|
|
2300
2196
|
attachSchema = ({ usageSchema, parsedSchemas }) => {
|
|
2301
2197
|
this.config.routeNameDuplicatesMap.clear();
|
|
2302
|
-
const pathsEntries =
|
|
2198
|
+
const pathsEntries = Object.entries(usageSchema.paths || {});
|
|
2303
2199
|
for (const [rawRouteName, routeInfoByMethodsMap] of pathsEntries) {
|
|
2304
2200
|
const routeInfosMap = this.createRequestsMap(routeInfoByMethodsMap);
|
|
2305
2201
|
for (const [method, routeInfo] of Object.entries(routeInfosMap)) {
|
|
@@ -2323,37 +2219,36 @@ var SchemaRoutes = class {
|
|
|
2323
2219
|
} else modules.$outOfModule.push(route);
|
|
2324
2220
|
return modules;
|
|
2325
2221
|
}, { $outOfModule: [] });
|
|
2326
|
-
const routeGroups =
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2222
|
+
const routeGroups = {
|
|
2223
|
+
outOfModule: void 0,
|
|
2224
|
+
combined: void 0
|
|
2225
|
+
};
|
|
2226
|
+
for (const [moduleName, routesGroup] of Object.entries(groupedRoutes)) if (moduleName === "$outOfModule") routeGroups.outOfModule = routesGroup;
|
|
2227
|
+
else {
|
|
2228
|
+
if (!routeGroups.combined) routeGroups.combined = [];
|
|
2229
|
+
routeGroups.combined.push({
|
|
2230
|
+
moduleName,
|
|
2231
|
+
routes: routesGroup.map((route) => {
|
|
2232
|
+
const { original: originalName, usage: usageName } = route.routeName;
|
|
2233
|
+
if (routesGroup.length > 1 && usageName !== originalName && !routesGroup.some(({ routeName, id }) => id !== route.id && originalName === routeName.original)) return {
|
|
2234
|
+
...route,
|
|
2235
|
+
routeName: {
|
|
2236
|
+
...route.routeName,
|
|
2237
|
+
usage: originalName
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
return route;
|
|
2241
|
+
})
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2347
2244
|
if (this.config.sortRoutes) {
|
|
2348
2245
|
if (routeGroups.outOfModule) routeGroups.outOfModule = this.sortRoutes(routeGroups.outOfModule);
|
|
2349
|
-
if (routeGroups.combined)
|
|
2350
|
-
routeGroup.routes = this.sortRoutes(routeGroup.routes);
|
|
2351
|
-
});
|
|
2246
|
+
if (routeGroups.combined) for (const routeGroup of routeGroups.combined) routeGroup.routes = this.sortRoutes(routeGroup.routes);
|
|
2352
2247
|
}
|
|
2353
2248
|
return routeGroups;
|
|
2354
2249
|
};
|
|
2355
2250
|
sortRoutes = (routes) => {
|
|
2356
|
-
return
|
|
2251
|
+
return routes.slice().sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
|
|
2357
2252
|
};
|
|
2358
2253
|
};
|
|
2359
2254
|
|
|
@@ -2368,8 +2263,8 @@ var SchemaWalker = class {
|
|
|
2368
2263
|
this.config = config;
|
|
2369
2264
|
this.swaggerSchemaResolver = swaggerSchemaResolver;
|
|
2370
2265
|
}
|
|
2371
|
-
addSchema = (name
|
|
2372
|
-
this.schemas.set(name
|
|
2266
|
+
addSchema = (name, schema) => {
|
|
2267
|
+
this.schemas.set(name, structuredClone(schema));
|
|
2373
2268
|
};
|
|
2374
2269
|
_isLocalRef = (ref) => {
|
|
2375
2270
|
return ref.startsWith("#");
|
|
@@ -2378,8 +2273,7 @@ var SchemaWalker = class {
|
|
|
2378
2273
|
return ref.startsWith("http://") || ref.startsWith("https://");
|
|
2379
2274
|
};
|
|
2380
2275
|
_getRefDataFromSchema = (schema, ref) => {
|
|
2381
|
-
const
|
|
2382
|
-
const refData = lodash.default.get(schema, path$1);
|
|
2276
|
+
const refData = (0, es_toolkit_compat.get)(schema, ref.replace("#", "").split("/"));
|
|
2383
2277
|
if (refData) this.caches.set(ref, refData);
|
|
2384
2278
|
return refData;
|
|
2385
2279
|
};
|
|
@@ -2392,14 +2286,14 @@ var Request = class {
|
|
|
2392
2286
|
constructor(config) {
|
|
2393
2287
|
this.config = config;
|
|
2394
2288
|
}
|
|
2395
|
-
async download({ url
|
|
2289
|
+
async download({ url, authToken, ...options }) {
|
|
2396
2290
|
const requestOptions = {};
|
|
2397
2291
|
if (authToken) requestOptions.headers = { Authorization: authToken };
|
|
2398
|
-
|
|
2292
|
+
(0, es_toolkit.merge)((0, es_toolkit.merge)(requestOptions, options), this.config.requestOptions || {});
|
|
2399
2293
|
try {
|
|
2400
|
-
return await (await fetch(url
|
|
2294
|
+
return await (await fetch(url, requestOptions)).text();
|
|
2401
2295
|
} catch (error) {
|
|
2402
|
-
const message = `error while fetching data from URL "${url
|
|
2296
|
+
const message = `error while fetching data from URL "${url}"`;
|
|
2403
2297
|
consola.consola.error(message, error);
|
|
2404
2298
|
return message;
|
|
2405
2299
|
}
|
|
@@ -2418,21 +2312,21 @@ var SwaggerSchemaResolver = class {
|
|
|
2418
2312
|
this.request = new Request(config);
|
|
2419
2313
|
}
|
|
2420
2314
|
async create() {
|
|
2421
|
-
const { spec, patch, input, url
|
|
2315
|
+
const { spec, patch, input, url, authorizationToken } = this.config;
|
|
2422
2316
|
if (spec) return await this.convertSwaggerObject(spec, { patch });
|
|
2423
|
-
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url
|
|
2317
|
+
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url, authorizationToken);
|
|
2424
2318
|
const swaggerSchemaObject = this.processSwaggerSchemaFile(swaggerSchemaFile);
|
|
2425
2319
|
return await this.convertSwaggerObject(swaggerSchemaObject, { patch });
|
|
2426
2320
|
}
|
|
2427
2321
|
convertSwaggerObject(swaggerSchema, converterOptions) {
|
|
2428
2322
|
return new Promise((resolve) => {
|
|
2429
2323
|
const result = structuredClone(swaggerSchema);
|
|
2430
|
-
result.info =
|
|
2324
|
+
result.info = (0, es_toolkit.merge)({
|
|
2431
2325
|
title: "No title",
|
|
2432
2326
|
version: ""
|
|
2433
|
-
}, result.info);
|
|
2327
|
+
}, result.info || {});
|
|
2434
2328
|
if (!Object.hasOwn(result, "openapi")) {
|
|
2435
|
-
result.paths =
|
|
2329
|
+
result.paths = (0, es_toolkit.merge)({}, result.paths || {});
|
|
2436
2330
|
swagger2openapi.convertObj(result, {
|
|
2437
2331
|
...converterOptions,
|
|
2438
2332
|
resolveInternal: true,
|
|
@@ -2440,7 +2334,7 @@ var SwaggerSchemaResolver = class {
|
|
|
2440
2334
|
refSiblings: "preserve",
|
|
2441
2335
|
rbname: "requestBodyName"
|
|
2442
2336
|
}, (err, options) => {
|
|
2443
|
-
const parsedSwaggerSchema =
|
|
2337
|
+
const parsedSwaggerSchema = (0, es_toolkit_compat.get)(err, "options.openapi") ?? (0, es_toolkit_compat.get)(options, "openapi");
|
|
2444
2338
|
if (!parsedSwaggerSchema && err) throw err;
|
|
2445
2339
|
this.config.update({ convertedFromSwagger2: true });
|
|
2446
2340
|
resolve({
|
|
@@ -2475,23 +2369,21 @@ var SwaggerSchemaResolver = class {
|
|
|
2475
2369
|
}
|
|
2476
2370
|
}
|
|
2477
2371
|
fixSwaggerSchema({ usageSchema, originalSchema }) {
|
|
2478
|
-
const usagePaths =
|
|
2479
|
-
const originalPaths =
|
|
2480
|
-
|
|
2481
|
-
const originalPathObject =
|
|
2482
|
-
|
|
2483
|
-
const originalRouteInfo =
|
|
2484
|
-
const usageRouteParams =
|
|
2485
|
-
const originalRouteParams =
|
|
2372
|
+
const usagePaths = (0, es_toolkit_compat.get)(usageSchema, "paths") || {};
|
|
2373
|
+
const originalPaths = (0, es_toolkit_compat.get)(originalSchema, "paths") || {};
|
|
2374
|
+
for (const [route, usagePathObject] of Object.entries(usagePaths)) {
|
|
2375
|
+
const originalPathObject = (0, es_toolkit_compat.get)(originalPaths, route) || {};
|
|
2376
|
+
for (const [methodName, usageRouteInfo] of Object.entries(usagePathObject)) {
|
|
2377
|
+
const originalRouteInfo = (0, es_toolkit_compat.get)(originalPathObject, methodName) || {};
|
|
2378
|
+
const usageRouteParams = (0, es_toolkit_compat.get)(usageRouteInfo, "parameters") || [];
|
|
2379
|
+
const originalRouteParams = (0, es_toolkit_compat.get)(originalRouteInfo, "parameters") || [];
|
|
2486
2380
|
if (typeof usageRouteInfo === "object") {
|
|
2487
|
-
usageRouteInfo.consumes =
|
|
2488
|
-
usageRouteInfo.produces =
|
|
2381
|
+
usageRouteInfo.consumes = (0, es_toolkit.uniq)((0, es_toolkit.compact)([...usageRouteInfo.consumes || [], ...originalRouteInfo.consumes || []]));
|
|
2382
|
+
usageRouteInfo.produces = (0, es_toolkit.uniq)((0, es_toolkit.compact)([...usageRouteInfo.produces || [], ...originalRouteInfo.produces || []]));
|
|
2489
2383
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
});
|
|
2494
|
-
});
|
|
2384
|
+
for (const originalRouteParam of originalRouteParams) if (!usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name)) usageRouteParams.push(originalRouteParam);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2495
2387
|
}
|
|
2496
2388
|
};
|
|
2497
2389
|
|
|
@@ -2511,21 +2403,19 @@ var TemplatesWorker = class {
|
|
|
2511
2403
|
if (this.config.silent) consola.consola.level = 0;
|
|
2512
2404
|
}
|
|
2513
2405
|
getTemplatePaths = (config) => {
|
|
2514
|
-
const __dirname
|
|
2515
|
-
const baseTemplatesPath = node_path.resolve(__dirname
|
|
2516
|
-
const defaultTemplatesPath = node_path.resolve(__dirname
|
|
2517
|
-
const modularTemplatesPath = node_path.resolve(__dirname
|
|
2518
|
-
const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath;
|
|
2519
|
-
const customTemplatesPath = config.templates && node_path.resolve(process.cwd(), config.templates);
|
|
2406
|
+
const __dirname = node_path.dirname(node_url.fileURLToPath(require("url").pathToFileURL(__filename).href));
|
|
2407
|
+
const baseTemplatesPath = node_path.resolve(__dirname, "../templates/base");
|
|
2408
|
+
const defaultTemplatesPath = node_path.resolve(__dirname, "../templates/default");
|
|
2409
|
+
const modularTemplatesPath = node_path.resolve(__dirname, "../templates/modular");
|
|
2520
2410
|
return {
|
|
2521
2411
|
base: baseTemplatesPath,
|
|
2522
2412
|
default: defaultTemplatesPath,
|
|
2523
2413
|
modular: modularTemplatesPath,
|
|
2524
|
-
original:
|
|
2525
|
-
custom:
|
|
2414
|
+
original: config.modular ? modularTemplatesPath : defaultTemplatesPath,
|
|
2415
|
+
custom: config.templates && node_path.resolve(process.cwd(), config.templates)
|
|
2526
2416
|
};
|
|
2527
2417
|
};
|
|
2528
|
-
cropExtension = (path
|
|
2418
|
+
cropExtension = (path) => this.config.templateExtensions.reduce((path, ext) => path.endsWith(ext) ? path.replace(ext, "") : path, path);
|
|
2529
2419
|
getTemplateFullPath = (path_, fileName) => {
|
|
2530
2420
|
const raw = node_path.resolve(path_, "./", this.cropExtension(fileName));
|
|
2531
2421
|
return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => !!this.fileSystem.pathIsExist(variant));
|
|
@@ -2534,39 +2424,39 @@ var TemplatesWorker = class {
|
|
|
2534
2424
|
if (packageOrPath.startsWith("./") || packageOrPath.startsWith("../")) return require$1(node_path.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
|
|
2535
2425
|
return require$1(packageOrPath);
|
|
2536
2426
|
};
|
|
2537
|
-
getTemplate = (name
|
|
2427
|
+
getTemplate = (name, fileName, path) => {
|
|
2538
2428
|
const { templatePaths } = this.config;
|
|
2539
|
-
if (path
|
|
2429
|
+
if (path) return this.fileSystem.getFileContent(path);
|
|
2540
2430
|
if (!fileName) return "";
|
|
2541
2431
|
const customFullPath = templatePaths.custom && this.getTemplateFullPath(templatePaths.custom, fileName);
|
|
2542
2432
|
let fileContent = customFullPath && this.fileSystem.getFileContent(customFullPath);
|
|
2543
2433
|
if (fileContent) {
|
|
2544
|
-
consola.consola.info(`"${name
|
|
2434
|
+
consola.consola.info(`"${name.toLowerCase()}" template found in "${templatePaths.custom}"`);
|
|
2545
2435
|
return fileContent;
|
|
2546
2436
|
}
|
|
2547
2437
|
const baseFullPath = this.getTemplateFullPath(templatePaths.base, fileName);
|
|
2548
2438
|
if (baseFullPath) fileContent = this.fileSystem.getFileContent(baseFullPath);
|
|
2549
|
-
else if (templatePaths.custom) consola.consola.warn("Code generator will use the default template:", `"${name
|
|
2550
|
-
else consola.consola.info(`Code generator will use the default template for "${name
|
|
2439
|
+
else if (templatePaths.custom) consola.consola.warn("Code generator will use the default template:", `"${name.toLowerCase()}"`, "template not found in", `"${templatePaths.custom}"`);
|
|
2440
|
+
else consola.consola.info(`Code generator will use the default template for "${name.toLowerCase()}"`);
|
|
2551
2441
|
const originalFullPath = this.getTemplateFullPath(templatePaths.original, fileName);
|
|
2552
2442
|
if (originalFullPath) fileContent = this.fileSystem.getFileContent(originalFullPath);
|
|
2553
2443
|
return fileContent;
|
|
2554
2444
|
};
|
|
2555
2445
|
getTemplates = ({ templatePaths }) => {
|
|
2556
2446
|
if (templatePaths.custom) consola.consola.info(`try to read templates from directory "${templatePaths.custom}"`);
|
|
2557
|
-
return
|
|
2447
|
+
return this.config.templateInfos.reduce((acc, { name, fileName }) => ({
|
|
2558
2448
|
...acc,
|
|
2559
|
-
[name
|
|
2449
|
+
[name]: this.getTemplate(name, fileName)
|
|
2560
2450
|
}), {});
|
|
2561
2451
|
};
|
|
2562
|
-
findTemplateWithExt = (path
|
|
2563
|
-
const raw = this.cropExtension(path
|
|
2452
|
+
findTemplateWithExt = (path) => {
|
|
2453
|
+
const raw = this.cropExtension(path);
|
|
2564
2454
|
return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => this.fileSystem.pathIsExist(variant));
|
|
2565
2455
|
};
|
|
2566
2456
|
getTemplateContent = (path_) => {
|
|
2567
|
-
const foundTemplatePathKey =
|
|
2457
|
+
const foundTemplatePathKey = Object.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
|
|
2568
2458
|
if (foundTemplatePathKey) {
|
|
2569
|
-
const rawPath = node_path.resolve(path_.replace(`@${foundTemplatePathKey}`,
|
|
2459
|
+
const rawPath = node_path.resolve(path_.replace(`@${foundTemplatePathKey}`, (0, es_toolkit_compat.get)(this.config.templatePaths, foundTemplatePathKey)));
|
|
2570
2460
|
const fixedPath = this.findTemplateWithExt(rawPath);
|
|
2571
2461
|
if (fixedPath) return this.fileSystem.getFileContent(fixedPath);
|
|
2572
2462
|
}
|
|
@@ -2581,7 +2471,7 @@ var TemplatesWorker = class {
|
|
|
2581
2471
|
return eta$1.render(eta$1.compile(template, { async: false }), {
|
|
2582
2472
|
...this.getRenderTemplateData(),
|
|
2583
2473
|
...configuration
|
|
2584
|
-
}, { includeFile: (path
|
|
2474
|
+
}, { includeFile: (path, configuration) => this.renderTemplate(this.getTemplateContent(path), configuration) });
|
|
2585
2475
|
};
|
|
2586
2476
|
};
|
|
2587
2477
|
|
|
@@ -2648,51 +2538,50 @@ var TypeNameFormatter = class {
|
|
|
2648
2538
|
constructor(config) {
|
|
2649
2539
|
this.config = config;
|
|
2650
2540
|
}
|
|
2651
|
-
format = (name
|
|
2541
|
+
format = (name, options = {}) => {
|
|
2652
2542
|
const schemaType = options.type ?? "type-name";
|
|
2653
2543
|
const typePrefix = schemaType === "enum-key" ? this.config.enumKeyPrefix : this.config.typePrefix;
|
|
2654
2544
|
const typeSuffix = schemaType === "enum-key" ? this.config.enumKeySuffix : this.config.typeSuffix;
|
|
2655
|
-
const hashKey = `${typePrefix}_${name
|
|
2656
|
-
if (typeof name
|
|
2657
|
-
consola.consola.warn("wrong model name", name
|
|
2658
|
-
return name
|
|
2545
|
+
const hashKey = `${typePrefix}_${name}_${typeSuffix}`;
|
|
2546
|
+
if (typeof name !== "string") {
|
|
2547
|
+
consola.consola.warn("wrong model name", name);
|
|
2548
|
+
return name;
|
|
2659
2549
|
}
|
|
2660
|
-
if (/^(?!\d)([A-Z0-9_]{1,})$/g.test(name
|
|
2550
|
+
if (/^(?!\d)([A-Z0-9_]{1,})$/g.test(name)) return (0, es_toolkit.compact)([
|
|
2661
2551
|
typePrefix,
|
|
2662
|
-
name
|
|
2552
|
+
name,
|
|
2663
2553
|
typeSuffix
|
|
2664
2554
|
]).join("_");
|
|
2665
2555
|
if (this.formattedModelNamesMap.has(hashKey)) return this.formattedModelNamesMap.get(hashKey);
|
|
2666
|
-
const
|
|
2667
|
-
const
|
|
2668
|
-
const formattedResultName = this.config.hooks.onFormatTypeName(formattedName, name$1, schemaType) || formattedName;
|
|
2556
|
+
const formattedName = (0, es_toolkit_compat.startCase)(`${typePrefix}_${this.fixModelName(name, { type: schemaType })}_${typeSuffix}`).replace(/\s/g, "");
|
|
2557
|
+
const formattedResultName = this.config.hooks.onFormatTypeName(formattedName, name, schemaType) || formattedName;
|
|
2669
2558
|
this.formattedModelNamesMap.set(hashKey, formattedResultName);
|
|
2670
2559
|
return formattedResultName;
|
|
2671
2560
|
};
|
|
2672
|
-
isValidName = (name
|
|
2673
|
-
fixModelName = (name
|
|
2674
|
-
if (!this.isValidName(name
|
|
2675
|
-
if (!/^[a-zA-Z_$]/g.test(name
|
|
2676
|
-
if (name
|
|
2677
|
-
if (name
|
|
2561
|
+
isValidName = (name) => /^([A-Za-z$_]{1,})$/g.test(name);
|
|
2562
|
+
fixModelName = (name, options) => {
|
|
2563
|
+
if (!this.isValidName(name)) {
|
|
2564
|
+
if (!/^[a-zA-Z_$]/g.test(name)) return `${options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix} ${name}`;
|
|
2565
|
+
if (name.includes(".")) return name.replace(/Exclude_keyof[A-Za-z]+/g, () => "ExcludeKeys").replace(/%22~AND~%22/g, "And").replace(/%22~OR~%22/g, "Or").replace(/(\.?%22)|\./g, "_").replace(/__+$/, "");
|
|
2566
|
+
if (name.includes("-")) return (0, es_toolkit_compat.startCase)(name).replace(/ /g, "");
|
|
2678
2567
|
}
|
|
2679
|
-
return name
|
|
2568
|
+
return name;
|
|
2680
2569
|
};
|
|
2681
2570
|
};
|
|
2682
2571
|
|
|
2683
2572
|
//#endregion
|
|
2684
2573
|
//#region src/util/file-system.ts
|
|
2685
2574
|
var FileSystem = class {
|
|
2686
|
-
getFileContent = (path
|
|
2687
|
-
return node_fs.readFileSync(path
|
|
2575
|
+
getFileContent = (path) => {
|
|
2576
|
+
return node_fs.readFileSync(path, { encoding: "utf8" });
|
|
2688
2577
|
};
|
|
2689
|
-
readDir = (path
|
|
2690
|
-
return node_fs.readdirSync(path
|
|
2578
|
+
readDir = (path) => {
|
|
2579
|
+
return node_fs.readdirSync(path);
|
|
2691
2580
|
};
|
|
2692
|
-
pathIsDir = (path
|
|
2693
|
-
if (!path
|
|
2581
|
+
pathIsDir = (path) => {
|
|
2582
|
+
if (!path) return false;
|
|
2694
2583
|
try {
|
|
2695
|
-
return node_fs.statSync(path
|
|
2584
|
+
return node_fs.statSync(path).isDirectory();
|
|
2696
2585
|
} catch (e) {
|
|
2697
2586
|
return false;
|
|
2698
2587
|
}
|
|
@@ -2702,36 +2591,45 @@ var FileSystem = class {
|
|
|
2702
2591
|
if (fileNameParts.length > 1) fileNameParts.pop();
|
|
2703
2592
|
return fileNameParts.join(".");
|
|
2704
2593
|
};
|
|
2705
|
-
removeDir = (path
|
|
2594
|
+
removeDir = (path) => {
|
|
2706
2595
|
try {
|
|
2707
|
-
if (typeof node_fs.rmSync === "function") node_fs.rmSync(path
|
|
2708
|
-
else node_fs.rmdirSync(path
|
|
2596
|
+
if (typeof node_fs.rmSync === "function") node_fs.rmSync(path, { recursive: true });
|
|
2597
|
+
else node_fs.rmdirSync(path, { recursive: true });
|
|
2709
2598
|
} catch (e) {
|
|
2710
2599
|
consola.consola.debug("failed to remove dir", e);
|
|
2711
2600
|
}
|
|
2712
2601
|
};
|
|
2713
|
-
createDir = (path
|
|
2602
|
+
createDir = (path) => {
|
|
2714
2603
|
try {
|
|
2715
|
-
node_fs.mkdirSync(path
|
|
2604
|
+
node_fs.mkdirSync(path, { recursive: true });
|
|
2716
2605
|
} catch (e) {
|
|
2717
2606
|
consola.consola.debug("failed to create dir", e);
|
|
2718
2607
|
}
|
|
2719
2608
|
};
|
|
2720
|
-
cleanDir = (path
|
|
2721
|
-
this.removeDir(path
|
|
2722
|
-
this.createDir(path
|
|
2609
|
+
cleanDir = (path) => {
|
|
2610
|
+
this.removeDir(path);
|
|
2611
|
+
this.createDir(path);
|
|
2723
2612
|
};
|
|
2724
|
-
pathIsExist = (path
|
|
2725
|
-
return !!path
|
|
2613
|
+
pathIsExist = (path) => {
|
|
2614
|
+
return !!path && node_fs.existsSync(path);
|
|
2726
2615
|
};
|
|
2727
2616
|
createFile = ({ path: path_, fileName, content, withPrefix }) => {
|
|
2728
|
-
const __dirname
|
|
2729
|
-
const absolutePath = node_path.resolve(__dirname
|
|
2617
|
+
const __dirname = node_path.dirname(node_url.fileURLToPath(require("url").pathToFileURL(__filename).href));
|
|
2618
|
+
const absolutePath = node_path.resolve(__dirname, path_, `./${fileName}`);
|
|
2730
2619
|
const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`;
|
|
2731
2620
|
return node_fs.writeFileSync(absolutePath, fileContent);
|
|
2732
2621
|
};
|
|
2733
2622
|
};
|
|
2734
2623
|
|
|
2624
|
+
//#endregion
|
|
2625
|
+
//#region src/util/lodash-compat.ts
|
|
2626
|
+
function createLodashCompat() {
|
|
2627
|
+
return {
|
|
2628
|
+
...es_toolkit,
|
|
2629
|
+
...es_toolkit_compat
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2735
2633
|
//#endregion
|
|
2736
2634
|
//#region src/code-gen-process.ts
|
|
2737
2635
|
const PATCHABLE_INSTANCES = [
|
|
@@ -2786,16 +2684,14 @@ var CodeGenProcess = class {
|
|
|
2786
2684
|
if (this.config.swaggerSchema) swagger.usageSchema = this.config.swaggerSchema;
|
|
2787
2685
|
if (this.config.originalSchema) swagger.originalSchema = this.config.originalSchema;
|
|
2788
2686
|
this.schemaComponentsMap.clear();
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
]), rawTypeData);
|
|
2795
|
-
}));
|
|
2687
|
+
for (const [componentName, component] of Object.entries(swagger.usageSchema.components || {})) for (const [typeName, rawTypeData] of Object.entries(component)) this.schemaComponentsMap.createComponent(this.schemaComponentsMap.createRef([
|
|
2688
|
+
"components",
|
|
2689
|
+
componentName,
|
|
2690
|
+
typeName
|
|
2691
|
+
]), rawTypeData);
|
|
2796
2692
|
this.schemaComponentsMap.discriminatorsFirst();
|
|
2797
2693
|
this.schemaComponentsMap.enumsFirst();
|
|
2798
|
-
const parsedSchemas = this.schemaComponentsMap.filter(
|
|
2694
|
+
const parsedSchemas = this.schemaComponentsMap.filter((0, es_toolkit.compact)(["schemas", this.config.extractResponses && "responses"])).map((schemaComponent) => {
|
|
2799
2695
|
const parsed = this.schemaParserFabric.parseSchema(schemaComponent.rawTypeData, schemaComponent.typeName);
|
|
2800
2696
|
schemaComponent.typeData = parsed;
|
|
2801
2697
|
return parsed;
|
|
@@ -2829,8 +2725,8 @@ var CodeGenProcess = class {
|
|
|
2829
2725
|
consola.consola.debug(`path ${this.config.output} is not exist. creating dir by this path`);
|
|
2830
2726
|
this.fileSystem.createDir(this.config.output);
|
|
2831
2727
|
}
|
|
2832
|
-
const files
|
|
2833
|
-
if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files
|
|
2728
|
+
const files = await this.generateOutputFiles({ configuration });
|
|
2729
|
+
if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files) {
|
|
2834
2730
|
this.fileSystem.createFile({
|
|
2835
2731
|
path: this.config.output,
|
|
2836
2732
|
fileName: `${file.fileName}${file.fileExtension}`,
|
|
@@ -2840,7 +2736,7 @@ var CodeGenProcess = class {
|
|
|
2840
2736
|
consola.consola.success("api file", `"${file.fileName}${file.fileExtension}"`, `created in ${this.config.output}`);
|
|
2841
2737
|
}
|
|
2842
2738
|
return {
|
|
2843
|
-
files
|
|
2739
|
+
files,
|
|
2844
2740
|
configuration,
|
|
2845
2741
|
getTemplate: this.templatesWorker.getTemplate,
|
|
2846
2742
|
renderTemplate: this.templatesWorker.renderTemplate,
|
|
@@ -2853,7 +2749,7 @@ var CodeGenProcess = class {
|
|
|
2853
2749
|
utils: {
|
|
2854
2750
|
Ts: this.config.Ts,
|
|
2855
2751
|
formatDescription: this.schemaParserFabric.schemaFormatters.formatDescription,
|
|
2856
|
-
internalCase,
|
|
2752
|
+
internalCase: es_toolkit_compat.camelCase,
|
|
2857
2753
|
classNameCase: pascalCase,
|
|
2858
2754
|
pascalCase,
|
|
2859
2755
|
getInlineParseContent: this.schemaParserFabric.getInlineParseContent,
|
|
@@ -2870,7 +2766,7 @@ var CodeGenProcess = class {
|
|
|
2870
2766
|
return ` * ${line}${eol ? "\n" : ""}`;
|
|
2871
2767
|
},
|
|
2872
2768
|
NameResolver,
|
|
2873
|
-
_:
|
|
2769
|
+
_: createLodashCompat(),
|
|
2874
2770
|
require: this.templatesWorker.requireFnFromTemplate
|
|
2875
2771
|
},
|
|
2876
2772
|
config: this.config
|
|
@@ -2879,7 +2775,7 @@ var CodeGenProcess = class {
|
|
|
2879
2775
|
collectModelTypes = () => {
|
|
2880
2776
|
const components = this.schemaComponentsMap.getComponents();
|
|
2881
2777
|
let modelTypes = [];
|
|
2882
|
-
const modelTypeComponents =
|
|
2778
|
+
const modelTypeComponents = (0, es_toolkit.compact)(["schemas", this.config.extractResponses && "responses"]);
|
|
2883
2779
|
const getSchemaComponentsCount = () => this.schemaComponentsMap.filter(...modelTypeComponents).length;
|
|
2884
2780
|
let schemaComponentsCount = getSchemaComponentsCount();
|
|
2885
2781
|
let processedCount = 0;
|
|
@@ -2901,14 +2797,14 @@ var CodeGenProcess = class {
|
|
|
2901
2797
|
if (!typeInfo.typeData) typeInfo.typeData = this.schemaParserFabric.parseSchema(typeInfo.rawTypeData, typeInfo.typeName);
|
|
2902
2798
|
const rawTypeData = typeInfo.typeData;
|
|
2903
2799
|
const typeData = this.schemaParserFabric.schemaFormatters.base[rawTypeData.type] ? this.schemaParserFabric.schemaFormatters.base[rawTypeData.type](rawTypeData) : rawTypeData;
|
|
2904
|
-
const { typeIdentifier, name: originalName, content, description
|
|
2905
|
-
const name
|
|
2906
|
-
if (name
|
|
2800
|
+
const { typeIdentifier, name: originalName, content, description } = typeData;
|
|
2801
|
+
const name = this.typeNameFormatter.format(originalName);
|
|
2802
|
+
if (name === null) return null;
|
|
2907
2803
|
const preparedModelType = {
|
|
2908
2804
|
...typeData,
|
|
2909
2805
|
typeIdentifier,
|
|
2910
|
-
name
|
|
2911
|
-
description
|
|
2806
|
+
name,
|
|
2807
|
+
description,
|
|
2912
2808
|
$content: rawTypeData.content,
|
|
2913
2809
|
rawContent: rawTypeData.content,
|
|
2914
2810
|
content,
|
|
@@ -2920,7 +2816,7 @@ var CodeGenProcess = class {
|
|
|
2920
2816
|
generateOutputFiles = async ({ configuration }) => {
|
|
2921
2817
|
const { modular, templatesToRender } = this.config;
|
|
2922
2818
|
const output = modular ? await this.createMultipleFileInfos(templatesToRender, configuration) : await this.createSingleFileInfo(templatesToRender, configuration);
|
|
2923
|
-
if (
|
|
2819
|
+
if (configuration.extraTemplates?.length) for (const extraTemplate of configuration.extraTemplates) {
|
|
2924
2820
|
const content = this.templatesWorker.renderTemplate(this.fileSystem.getFileContent(extraTemplate.path), configuration);
|
|
2925
2821
|
output.push(...await this.createOutputFileInfo(configuration, extraTemplate.name, content));
|
|
2926
2822
|
}
|
|
@@ -2970,7 +2866,7 @@ var CodeGenProcess = class {
|
|
|
2970
2866
|
};
|
|
2971
2867
|
createSingleFileInfo = async (templatesToRender, configuration) => {
|
|
2972
2868
|
const { generateRouteTypes, generateClient } = configuration.config;
|
|
2973
|
-
return await this.createOutputFileInfo(configuration, configuration.fileName,
|
|
2869
|
+
return await this.createOutputFileInfo(configuration, configuration.fileName, (0, es_toolkit.compact)([
|
|
2974
2870
|
this.templatesWorker.renderTemplate(templatesToRender.dataContracts, configuration),
|
|
2975
2871
|
generateRouteTypes && this.templatesWorker.renderTemplate(templatesToRender.routeTypes, configuration),
|
|
2976
2872
|
generateClient && this.templatesWorker.renderTemplate(templatesToRender.httpClient, configuration),
|
|
@@ -3006,21 +2902,21 @@ var CodeGenProcess = class {
|
|
|
3006
2902
|
createApiConfig = (swaggerSchema) => {
|
|
3007
2903
|
const { info, servers, host, basePath, externalDocs, tags } = swaggerSchema;
|
|
3008
2904
|
const server = servers?.[0] || { url: "" };
|
|
3009
|
-
const { title = "No title", version
|
|
2905
|
+
const { title = "No title", version } = info || {};
|
|
3010
2906
|
const { url: serverUrl } = server;
|
|
3011
2907
|
return {
|
|
3012
2908
|
info: info || {},
|
|
3013
2909
|
servers: servers || [],
|
|
3014
2910
|
basePath,
|
|
3015
2911
|
host,
|
|
3016
|
-
externalDocs:
|
|
2912
|
+
externalDocs: (0, es_toolkit.merge)({
|
|
3017
2913
|
url: "",
|
|
3018
2914
|
description: ""
|
|
3019
|
-
}, externalDocs),
|
|
3020
|
-
tags:
|
|
2915
|
+
}, externalDocs || {}),
|
|
2916
|
+
tags: (0, es_toolkit.compact)(tags || []),
|
|
3021
2917
|
baseUrl: serverUrl,
|
|
3022
2918
|
title,
|
|
3023
|
-
version
|
|
2919
|
+
version
|
|
3024
2920
|
};
|
|
3025
2921
|
};
|
|
3026
2922
|
injectClassInstance = (key, value) => {
|
|
@@ -3031,28 +2927,28 @@ var CodeGenProcess = class {
|
|
|
3031
2927
|
|
|
3032
2928
|
//#endregion
|
|
3033
2929
|
//#region types/index.ts
|
|
3034
|
-
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind
|
|
3035
|
-
RequestContentKind
|
|
3036
|
-
RequestContentKind
|
|
3037
|
-
RequestContentKind
|
|
3038
|
-
RequestContentKind
|
|
3039
|
-
RequestContentKind
|
|
3040
|
-
RequestContentKind
|
|
3041
|
-
return RequestContentKind
|
|
2930
|
+
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind) {
|
|
2931
|
+
RequestContentKind["JSON"] = "JSON";
|
|
2932
|
+
RequestContentKind["URL_ENCODED"] = "URL_ENCODED";
|
|
2933
|
+
RequestContentKind["FORM_DATA"] = "FORM_DATA";
|
|
2934
|
+
RequestContentKind["IMAGE"] = "IMAGE";
|
|
2935
|
+
RequestContentKind["OTHER"] = "OTHER";
|
|
2936
|
+
RequestContentKind["TEXT"] = "TEXT";
|
|
2937
|
+
return RequestContentKind;
|
|
3042
2938
|
}({});
|
|
3043
|
-
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES
|
|
3044
|
-
SCHEMA_TYPES
|
|
3045
|
-
SCHEMA_TYPES
|
|
3046
|
-
SCHEMA_TYPES
|
|
3047
|
-
SCHEMA_TYPES
|
|
3048
|
-
SCHEMA_TYPES
|
|
3049
|
-
SCHEMA_TYPES
|
|
3050
|
-
SCHEMA_TYPES
|
|
3051
|
-
SCHEMA_TYPES
|
|
3052
|
-
SCHEMA_TYPES
|
|
3053
|
-
SCHEMA_TYPES
|
|
3054
|
-
SCHEMA_TYPES
|
|
3055
|
-
return SCHEMA_TYPES
|
|
2939
|
+
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES) {
|
|
2940
|
+
SCHEMA_TYPES["ARRAY"] = "array";
|
|
2941
|
+
SCHEMA_TYPES["OBJECT"] = "object";
|
|
2942
|
+
SCHEMA_TYPES["ENUM"] = "enum";
|
|
2943
|
+
SCHEMA_TYPES["REF"] = "$ref";
|
|
2944
|
+
SCHEMA_TYPES["PRIMITIVE"] = "primitive";
|
|
2945
|
+
SCHEMA_TYPES["COMPLEX"] = "complex";
|
|
2946
|
+
SCHEMA_TYPES["COMPLEX_ONE_OF"] = "oneOf";
|
|
2947
|
+
SCHEMA_TYPES["COMPLEX_ANY_OF"] = "anyOf";
|
|
2948
|
+
SCHEMA_TYPES["COMPLEX_ALL_OF"] = "allOf";
|
|
2949
|
+
SCHEMA_TYPES["COMPLEX_NOT"] = "not";
|
|
2950
|
+
SCHEMA_TYPES["COMPLEX_UNKNOWN"] = "__unknown";
|
|
2951
|
+
return SCHEMA_TYPES;
|
|
3056
2952
|
}({});
|
|
3057
2953
|
|
|
3058
2954
|
//#endregion
|
|
@@ -3070,7 +2966,7 @@ var TemplatesGenConfig = class {
|
|
|
3070
2966
|
this.update(config);
|
|
3071
2967
|
}
|
|
3072
2968
|
update = (update) => {
|
|
3073
|
-
|
|
2969
|
+
Object.assign(this, update);
|
|
3074
2970
|
};
|
|
3075
2971
|
};
|
|
3076
2972
|
|
|
@@ -3184,14 +3080,6 @@ async function generateTemplates(config) {
|
|
|
3184
3080
|
return await new TemplatesGenProcess(config).start();
|
|
3185
3081
|
}
|
|
3186
3082
|
|
|
3187
|
-
//#endregion
|
|
3188
|
-
//#region src/index.ts
|
|
3189
|
-
async function generateApi(config) {
|
|
3190
|
-
if (config.debug) consola.consola.level = Number.MAX_SAFE_INTEGER;
|
|
3191
|
-
if (config.silent) consola.consola.level = 0;
|
|
3192
|
-
return await new CodeGenProcess(config).start();
|
|
3193
|
-
}
|
|
3194
|
-
|
|
3195
3083
|
//#endregion
|
|
3196
3084
|
Object.defineProperty(exports, 'CodeGenConfig', {
|
|
3197
3085
|
enumerable: true,
|
|
@@ -3199,6 +3087,12 @@ Object.defineProperty(exports, 'CodeGenConfig', {
|
|
|
3199
3087
|
return CodeGenConfig;
|
|
3200
3088
|
}
|
|
3201
3089
|
});
|
|
3090
|
+
Object.defineProperty(exports, 'CodeGenProcess', {
|
|
3091
|
+
enumerable: true,
|
|
3092
|
+
get: function () {
|
|
3093
|
+
return CodeGenProcess;
|
|
3094
|
+
}
|
|
3095
|
+
});
|
|
3202
3096
|
Object.defineProperty(exports, 'HTTP_CLIENT', {
|
|
3203
3097
|
enumerable: true,
|
|
3204
3098
|
get: function () {
|
|
@@ -3235,10 +3129,10 @@ Object.defineProperty(exports, 'constants_exports', {
|
|
|
3235
3129
|
return constants_exports;
|
|
3236
3130
|
}
|
|
3237
3131
|
});
|
|
3238
|
-
Object.defineProperty(exports, '
|
|
3132
|
+
Object.defineProperty(exports, 'description', {
|
|
3239
3133
|
enumerable: true,
|
|
3240
3134
|
get: function () {
|
|
3241
|
-
return
|
|
3135
|
+
return description;
|
|
3242
3136
|
}
|
|
3243
3137
|
});
|
|
3244
3138
|
Object.defineProperty(exports, 'generateTemplates', {
|
|
@@ -3247,10 +3141,16 @@ Object.defineProperty(exports, 'generateTemplates', {
|
|
|
3247
3141
|
return generateTemplates;
|
|
3248
3142
|
}
|
|
3249
3143
|
});
|
|
3250
|
-
Object.defineProperty(exports, '
|
|
3144
|
+
Object.defineProperty(exports, 'name', {
|
|
3145
|
+
enumerable: true,
|
|
3146
|
+
get: function () {
|
|
3147
|
+
return name;
|
|
3148
|
+
}
|
|
3149
|
+
});
|
|
3150
|
+
Object.defineProperty(exports, 'version', {
|
|
3251
3151
|
enumerable: true,
|
|
3252
3152
|
get: function () {
|
|
3253
|
-
return
|
|
3153
|
+
return version;
|
|
3254
3154
|
}
|
|
3255
3155
|
});
|
|
3256
|
-
//# sourceMappingURL=
|
|
3156
|
+
//# sourceMappingURL=generate-templates-wjE78AWV.cjs.map
|