swagger-typescript-api 13.2.2 → 13.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +2 -4
- package/dist/lib.d.ts +8 -10
- package/dist/lib.js +1 -1
- package/dist/{src-CuoIgJ3d.js → src-BYbyXNbU.js} +70 -77
- package/dist/src-BYbyXNbU.js.map +1 -0
- package/dist/{src-DD5StS7t.cjs → src-CD5LAKtC.cjs} +7 -7
- package/dist/src-CD5LAKtC.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/src-CuoIgJ3d.js.map +0 -1
- package/dist/src-DD5StS7t.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# swagger-typescript-api
|
|
2
2
|
|
|
3
|
+
## 13.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1293](https://github.com/acacode/swagger-typescript-api/pull/1293) [`a87883b`](https://github.com/acacode/swagger-typescript-api/commit/a87883bdeb3e71330b8aab7d26ae62b68b51e323) Thanks [@smorimoto](https://github.com/smorimoto)! - Bump Biome to 2.0.
|
|
8
|
+
|
|
3
9
|
## 13.2.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-CD5LAKtC.cjs');
|
|
3
3
|
const node_path = require_src.__toESM(require("node:path"));
|
|
4
4
|
const c12 = require_src.__toESM(require("c12"));
|
|
5
5
|
const citty = require_src.__toESM(require("citty"));
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-
|
|
2
|
+
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-BYbyXNbU.js";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { loadConfig } from "c12";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
package/dist/lib.cjs
CHANGED
package/dist/lib.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { OpenAPI } from "openapi-types";
|
|
2
|
-
import * as typescript$1 from "typescript";
|
|
3
2
|
import * as typescript from "typescript";
|
|
4
3
|
import * as lodash19 from "lodash";
|
|
5
|
-
import * as lodash14 from "lodash";
|
|
6
4
|
import lodash from "lodash";
|
|
7
5
|
import * as swagger_schema_official16 from "swagger-schema-official";
|
|
8
6
|
import * as eta20 from "eta";
|
|
@@ -386,7 +384,7 @@ declare class JavascriptTranslator extends Translator {
|
|
|
386
384
|
compileTSCode: (input: TranslatorIO) => Record<string, string>;
|
|
387
385
|
translate: (input: any) => Promise<{
|
|
388
386
|
fileName: any;
|
|
389
|
-
fileExtension: typescript
|
|
387
|
+
fileExtension: typescript.Extension;
|
|
390
388
|
fileContent: string;
|
|
391
389
|
}[]>;
|
|
392
390
|
}
|
|
@@ -1582,7 +1580,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1582
1580
|
eol?: boolean | undefined;
|
|
1583
1581
|
}) => string;
|
|
1584
1582
|
NameResolver: typeof NameResolver;
|
|
1585
|
-
_:
|
|
1583
|
+
_: lodash19.LoDashStatic;
|
|
1586
1584
|
require: (packageOrPath: string) => Promise<any>;
|
|
1587
1585
|
};
|
|
1588
1586
|
};
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { __export } from "./chunk-Cl8Af3a2.js";
|
|
2
|
-
import * as
|
|
3
|
-
import * as lodash14 from "lodash";
|
|
2
|
+
import * as lodash20 from "lodash";
|
|
4
3
|
import lodash from "lodash";
|
|
5
|
-
import * as typescript$1 from "typescript";
|
|
6
4
|
import * as typescript from "typescript";
|
|
7
|
-
import * as
|
|
5
|
+
import * as eta21 from "eta";
|
|
8
6
|
import { OpenAPI } from "openapi-types";
|
|
9
|
-
import * as
|
|
7
|
+
import * as swagger_schema_official17 from "swagger-schema-official";
|
|
10
8
|
|
|
11
9
|
//#region src/schema-components-map.d.ts
|
|
12
10
|
declare class SchemaComponentsMap {
|
|
@@ -385,7 +383,7 @@ declare class JavascriptTranslator extends Translator {
|
|
|
385
383
|
compileTSCode: (input: TranslatorIO) => Record<string, string>;
|
|
386
384
|
translate: (input: any) => Promise<{
|
|
387
385
|
fileName: any;
|
|
388
|
-
fileExtension: typescript
|
|
386
|
+
fileExtension: typescript.Extension;
|
|
389
387
|
fileContent: string;
|
|
390
388
|
}[]>;
|
|
391
389
|
}
|
|
@@ -913,7 +911,7 @@ type RawRouteInfo = {
|
|
|
913
911
|
description?: string;
|
|
914
912
|
tags?: string[];
|
|
915
913
|
summary?: string;
|
|
916
|
-
responses?:
|
|
914
|
+
responses?: swagger_schema_official17.Spec["responses"];
|
|
917
915
|
produces?: string[];
|
|
918
916
|
requestBody?: object;
|
|
919
917
|
consumes?: string[];
|
|
@@ -1146,7 +1144,7 @@ interface GenerateApiConfiguration {
|
|
|
1146
1144
|
fmtToJSDocLine: (line: string, params?: {
|
|
1147
1145
|
eol?: boolean;
|
|
1148
1146
|
}) => string;
|
|
1149
|
-
_:
|
|
1147
|
+
_: lodash20.LoDashStatic;
|
|
1150
1148
|
require: (path: string) => unknown;
|
|
1151
1149
|
};
|
|
1152
1150
|
}
|
|
@@ -1167,7 +1165,7 @@ interface GenerateApiOutput {
|
|
|
1167
1165
|
content: string;
|
|
1168
1166
|
withPrefix: boolean;
|
|
1169
1167
|
}) => void;
|
|
1170
|
-
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<
|
|
1168
|
+
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta21.EtaConfig>) => Promise<string> | string;
|
|
1171
1169
|
getTemplate: (params: {
|
|
1172
1170
|
fileName?: string;
|
|
1173
1171
|
name?: string;
|
|
@@ -1581,7 +1579,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1581
1579
|
eol?: boolean | undefined;
|
|
1582
1580
|
}) => string;
|
|
1583
1581
|
NameResolver: typeof NameResolver;
|
|
1584
|
-
_:
|
|
1582
|
+
_: lodash20.LoDashStatic;
|
|
1585
1583
|
require: (packageOrPath: string) => Promise<any>;
|
|
1586
1584
|
};
|
|
1587
1585
|
};
|
package/dist/lib.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { __export } from "./chunk-Cl8Af3a2.js";
|
|
2
2
|
import { consola } from "consola";
|
|
3
3
|
import lodash from "lodash";
|
|
4
|
-
import * as typescript$3 from "typescript";
|
|
5
|
-
import * as typescript$2 from "typescript";
|
|
6
|
-
import * as typescript$1 from "typescript";
|
|
7
4
|
import * as typescript from "typescript";
|
|
8
|
-
import * as path$3 from "node:path";
|
|
9
|
-
import * as path$2 from "node:path";
|
|
10
5
|
import * as path$1 from "node:path";
|
|
11
6
|
import path from "node:path";
|
|
12
7
|
import { Biome, Distribution } from "@biomejs/js-api";
|
|
13
|
-
import * as nanoid$1 from "nanoid";
|
|
14
8
|
import * as nanoid from "nanoid";
|
|
15
9
|
import * as yaml from "js-yaml";
|
|
16
10
|
import * as swagger2openapi from "swagger2openapi";
|
|
17
|
-
import * as url$2 from "node:url";
|
|
18
11
|
import * as url$1 from "node:url";
|
|
19
12
|
import url from "node:url";
|
|
20
13
|
import * as Eta from "eta";
|
|
@@ -29,11 +22,11 @@ var CodeFormatter = class {
|
|
|
29
22
|
removeUnusedImports = (content) => {
|
|
30
23
|
const tempFileName = "file.ts";
|
|
31
24
|
const host = new TsLanguageServiceHost(tempFileName, content);
|
|
32
|
-
const languageService = typescript
|
|
25
|
+
const languageService = typescript.createLanguageService(host);
|
|
33
26
|
const fileTextChanges = languageService.organizeImports({
|
|
34
27
|
type: "file",
|
|
35
28
|
fileName: tempFileName
|
|
36
|
-
}, { newLineCharacter: typescript
|
|
29
|
+
}, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
|
|
37
30
|
if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content$1, { span, newText }) => `${content$1.slice(0, span.start)}${newText}${content$1.slice(span.start + span.length)}`, content);
|
|
38
31
|
return content;
|
|
39
32
|
};
|
|
@@ -44,8 +37,8 @@ var CodeFormatter = class {
|
|
|
44
37
|
files: { maxSize: Number.MAX_SAFE_INTEGER },
|
|
45
38
|
formatter: { indentStyle: "space" }
|
|
46
39
|
});
|
|
47
|
-
const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$
|
|
48
|
-
name: nanoid
|
|
40
|
+
const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$1.format({
|
|
41
|
+
name: nanoid.nanoid(),
|
|
49
42
|
ext: "ts"
|
|
50
43
|
}) });
|
|
51
44
|
return formatted.content;
|
|
@@ -63,11 +56,11 @@ var TsLanguageServiceHost = class {
|
|
|
63
56
|
constructor(fileName, content) {
|
|
64
57
|
this.fileName = fileName;
|
|
65
58
|
this.content = content;
|
|
66
|
-
const tsconfig = typescript
|
|
67
|
-
this.compilerOptions = tsconfig ? typescript
|
|
59
|
+
const tsconfig = typescript.findConfigFile(fileName, typescript.sys.fileExists);
|
|
60
|
+
this.compilerOptions = tsconfig ? typescript.convertCompilerOptionsFromJson(typescript.readConfigFile(tsconfig, typescript.sys.readFile).config.compilerOptions, "").options : typescript.getDefaultCompilerOptions();
|
|
68
61
|
}
|
|
69
62
|
getNewLine() {
|
|
70
|
-
return "newLine" in typescript
|
|
63
|
+
return "newLine" in typescript.sys ? typescript.sys.newLine : "\n";
|
|
71
64
|
}
|
|
72
65
|
getScriptFileNames() {
|
|
73
66
|
return [this.fileName];
|
|
@@ -76,23 +69,23 @@ var TsLanguageServiceHost = class {
|
|
|
76
69
|
return this.compilerOptions;
|
|
77
70
|
}
|
|
78
71
|
getDefaultLibFileName() {
|
|
79
|
-
return typescript
|
|
72
|
+
return typescript.getDefaultLibFileName(this.getCompilationSettings());
|
|
80
73
|
}
|
|
81
74
|
getCurrentDirectory() {
|
|
82
75
|
return process.cwd();
|
|
83
76
|
}
|
|
84
77
|
getScriptVersion() {
|
|
85
|
-
return typescript
|
|
78
|
+
return typescript.version;
|
|
86
79
|
}
|
|
87
80
|
getScriptSnapshot() {
|
|
88
|
-
return typescript
|
|
81
|
+
return typescript.ScriptSnapshot.fromString(this.content);
|
|
89
82
|
}
|
|
90
83
|
readFile(fileName, encoding) {
|
|
91
84
|
if (fileName === this.fileName) return this.content;
|
|
92
|
-
return typescript
|
|
85
|
+
return typescript.sys.readFile(fileName, encoding);
|
|
93
86
|
}
|
|
94
|
-
fileExists(path$
|
|
95
|
-
return typescript
|
|
87
|
+
fileExists(path$2) {
|
|
88
|
+
return typescript.sys.fileExists(path$2);
|
|
96
89
|
}
|
|
97
90
|
};
|
|
98
91
|
|
|
@@ -184,7 +177,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
184
177
|
//#endregion
|
|
185
178
|
//#region package.json
|
|
186
179
|
var name = "swagger-typescript-api";
|
|
187
|
-
var version = "13.2.
|
|
180
|
+
var version = "13.2.3";
|
|
188
181
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
189
182
|
var homepage = "https://github.com/acacode/swagger-typescript-api";
|
|
190
183
|
var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
|
|
@@ -224,8 +217,8 @@ var scripts = {
|
|
|
224
217
|
"typedoc": "typedoc"
|
|
225
218
|
};
|
|
226
219
|
var dependencies = {
|
|
227
|
-
"@biomejs/js-api": "0.
|
|
228
|
-
"@biomejs/wasm-nodejs": "2.0.0
|
|
220
|
+
"@biomejs/js-api": "1.0.0",
|
|
221
|
+
"@biomejs/wasm-nodejs": "2.0.0",
|
|
229
222
|
"@types/swagger-schema-official": "^2.0.25",
|
|
230
223
|
"c12": "^3.0.4",
|
|
231
224
|
"citty": "^0.1.6",
|
|
@@ -239,18 +232,18 @@ var dependencies = {
|
|
|
239
232
|
"typescript": "~5.8.3"
|
|
240
233
|
};
|
|
241
234
|
var devDependencies = {
|
|
242
|
-
"@biomejs/biome": "2.0.0
|
|
235
|
+
"@biomejs/biome": "2.0.0",
|
|
243
236
|
"@changesets/changelog-github": "0.5.1",
|
|
244
237
|
"@changesets/cli": "2.29.4",
|
|
245
238
|
"@tsconfig/node18": "18.2.4",
|
|
246
239
|
"@tsconfig/strictest": "2.0.5",
|
|
247
240
|
"@types/js-yaml": "4.0.9",
|
|
248
241
|
"@types/lodash": "4.17.17",
|
|
249
|
-
"@types/node": "24.0.
|
|
242
|
+
"@types/node": "24.0.3",
|
|
250
243
|
"@types/swagger2openapi": "7.0.4",
|
|
251
244
|
"axios": "1.10.0",
|
|
252
245
|
"openapi-types": "12.1.3",
|
|
253
|
-
"tsdown": "0.12.
|
|
246
|
+
"tsdown": "0.12.8",
|
|
254
247
|
"typedoc": "0.28.5",
|
|
255
248
|
"vitest": "3.2.3"
|
|
256
249
|
};
|
|
@@ -543,10 +536,10 @@ var CodeGenConfig = class {
|
|
|
543
536
|
]
|
|
544
537
|
};
|
|
545
538
|
compilerTsConfig = {
|
|
546
|
-
module: typescript
|
|
539
|
+
module: typescript.ModuleKind.ESNext,
|
|
547
540
|
noImplicitReturns: true,
|
|
548
541
|
alwaysStrict: true,
|
|
549
|
-
target: typescript
|
|
542
|
+
target: typescript.ScriptTarget.ESNext,
|
|
550
543
|
declaration: true,
|
|
551
544
|
noImplicitAny: false,
|
|
552
545
|
sourceMap: false,
|
|
@@ -2326,8 +2319,8 @@ var SchemaWalker = class {
|
|
|
2326
2319
|
return ref.startsWith("http://") || ref.startsWith("https://");
|
|
2327
2320
|
};
|
|
2328
2321
|
_getRefDataFromSchema = (schema, ref) => {
|
|
2329
|
-
const path$
|
|
2330
|
-
const refData = lodash.get(schema, path$
|
|
2322
|
+
const path$2 = ref.replace("#", "").split("/");
|
|
2323
|
+
const refData = lodash.get(schema, path$2);
|
|
2331
2324
|
if (refData) this.caches.set(ref, refData);
|
|
2332
2325
|
return refData;
|
|
2333
2326
|
};
|
|
@@ -2340,15 +2333,15 @@ var Request = class {
|
|
|
2340
2333
|
constructor(config) {
|
|
2341
2334
|
this.config = config;
|
|
2342
2335
|
}
|
|
2343
|
-
async download({ url: url$
|
|
2336
|
+
async download({ url: url$2, authToken,...options }) {
|
|
2344
2337
|
const requestOptions = {};
|
|
2345
2338
|
if (authToken) requestOptions.headers = { Authorization: authToken };
|
|
2346
2339
|
lodash.merge(requestOptions, options, this.config.requestOptions);
|
|
2347
2340
|
try {
|
|
2348
|
-
const response = await fetch(url$
|
|
2341
|
+
const response = await fetch(url$2, requestOptions);
|
|
2349
2342
|
return await response.text();
|
|
2350
2343
|
} catch (error) {
|
|
2351
|
-
const message = `error while fetching data from URL "${url$
|
|
2344
|
+
const message = `error while fetching data from URL "${url$2}"`;
|
|
2352
2345
|
consola.error(message, error);
|
|
2353
2346
|
return message;
|
|
2354
2347
|
}
|
|
@@ -2367,9 +2360,9 @@ var SwaggerSchemaResolver = class {
|
|
|
2367
2360
|
this.request = new Request(config);
|
|
2368
2361
|
}
|
|
2369
2362
|
async create() {
|
|
2370
|
-
const { spec, patch, input, url: url$
|
|
2363
|
+
const { spec, patch, input, url: url$2, authorizationToken } = this.config;
|
|
2371
2364
|
if (spec) return await this.convertSwaggerObject(spec, { patch });
|
|
2372
|
-
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$
|
|
2365
|
+
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$2, authorizationToken);
|
|
2373
2366
|
const swaggerSchemaObject = this.processSwaggerSchemaFile(swaggerSchemaFile);
|
|
2374
2367
|
return await this.convertSwaggerObject(swaggerSchemaObject, { patch });
|
|
2375
2368
|
}
|
|
@@ -2459,12 +2452,12 @@ var TemplatesWorker = class {
|
|
|
2459
2452
|
if (this.config.silent) consola.level = 0;
|
|
2460
2453
|
}
|
|
2461
2454
|
getTemplatePaths = (config) => {
|
|
2462
|
-
const __dirname$1 = path$
|
|
2463
|
-
const baseTemplatesPath = path$
|
|
2464
|
-
const defaultTemplatesPath = path$
|
|
2465
|
-
const modularTemplatesPath = path$
|
|
2455
|
+
const __dirname$1 = path$1.dirname(url$1.fileURLToPath(import.meta.url));
|
|
2456
|
+
const baseTemplatesPath = path$1.resolve(__dirname$1, "../templates/base");
|
|
2457
|
+
const defaultTemplatesPath = path$1.resolve(__dirname$1, "../templates/default");
|
|
2458
|
+
const modularTemplatesPath = path$1.resolve(__dirname$1, "../templates/modular");
|
|
2466
2459
|
const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath;
|
|
2467
|
-
const customTemplatesPath = config.templates && path$
|
|
2460
|
+
const customTemplatesPath = config.templates && path$1.resolve(process.cwd(), config.templates);
|
|
2468
2461
|
return {
|
|
2469
2462
|
base: baseTemplatesPath,
|
|
2470
2463
|
default: defaultTemplatesPath,
|
|
@@ -2473,20 +2466,20 @@ var TemplatesWorker = class {
|
|
|
2473
2466
|
custom: customTemplatesPath
|
|
2474
2467
|
};
|
|
2475
2468
|
};
|
|
2476
|
-
cropExtension = (path$
|
|
2469
|
+
cropExtension = (path$2) => this.config.templateExtensions.reduce((path$3, ext) => path$3.endsWith(ext) ? path$3.replace(ext, "") : path$3, path$2);
|
|
2477
2470
|
getTemplateFullPath = (path_, fileName) => {
|
|
2478
|
-
const raw = path$
|
|
2471
|
+
const raw = path$1.resolve(path_, "./", this.cropExtension(fileName));
|
|
2479
2472
|
const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
|
|
2480
2473
|
return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
|
|
2481
2474
|
};
|
|
2482
2475
|
requireFnFromTemplate = async (packageOrPath) => {
|
|
2483
2476
|
const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
|
|
2484
|
-
if (isPath) return await import(path$
|
|
2477
|
+
if (isPath) return await import(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
|
|
2485
2478
|
return await import(packageOrPath);
|
|
2486
2479
|
};
|
|
2487
|
-
getTemplate = (name$1, fileName, path$
|
|
2480
|
+
getTemplate = (name$1, fileName, path$2) => {
|
|
2488
2481
|
const { templatePaths } = this.config;
|
|
2489
|
-
if (path$
|
|
2482
|
+
if (path$2) return this.fileSystem.getFileContent(path$2);
|
|
2490
2483
|
if (!fileName) return "";
|
|
2491
2484
|
const customFullPath = templatePaths.custom && this.getTemplateFullPath(templatePaths.custom, fileName);
|
|
2492
2485
|
let fileContent = customFullPath && this.fileSystem.getFileContent(customFullPath);
|
|
@@ -2509,21 +2502,21 @@ var TemplatesWorker = class {
|
|
|
2509
2502
|
[name$1]: this.getTemplate(name$1, fileName)
|
|
2510
2503
|
}), {});
|
|
2511
2504
|
};
|
|
2512
|
-
findTemplateWithExt = (path$
|
|
2513
|
-
const raw = this.cropExtension(path$
|
|
2505
|
+
findTemplateWithExt = (path$2) => {
|
|
2506
|
+
const raw = this.cropExtension(path$2);
|
|
2514
2507
|
const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
|
|
2515
2508
|
return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
|
|
2516
2509
|
};
|
|
2517
2510
|
getTemplateContent = (path_) => {
|
|
2518
2511
|
const foundTemplatePathKey = lodash.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
|
|
2519
2512
|
if (foundTemplatePathKey) {
|
|
2520
|
-
const rawPath = path$
|
|
2513
|
+
const rawPath = path$1.resolve(path_.replace(`@${foundTemplatePathKey}`, lodash.get(this.config.templatePaths, foundTemplatePathKey)));
|
|
2521
2514
|
const fixedPath = this.findTemplateWithExt(rawPath);
|
|
2522
2515
|
if (fixedPath) return this.fileSystem.getFileContent(fixedPath);
|
|
2523
2516
|
}
|
|
2524
|
-
const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$
|
|
2517
|
+
const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.custom, path_));
|
|
2525
2518
|
if (customPath) return this.fileSystem.getFileContent(customPath);
|
|
2526
|
-
const originalPath = this.findTemplateWithExt(path$
|
|
2519
|
+
const originalPath = this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.original, path_));
|
|
2527
2520
|
if (originalPath) return this.fileSystem.getFileContent(originalPath);
|
|
2528
2521
|
return "";
|
|
2529
2522
|
};
|
|
@@ -2535,8 +2528,8 @@ var TemplatesWorker = class {
|
|
|
2535
2528
|
}, {
|
|
2536
2529
|
async: false,
|
|
2537
2530
|
...options,
|
|
2538
|
-
includeFile: (path$
|
|
2539
|
-
return this.renderTemplate(this.getTemplateContent(path$
|
|
2531
|
+
includeFile: (path$2, configuration$1, options$1 = {}) => {
|
|
2532
|
+
return this.renderTemplate(this.getTemplateContent(path$2), configuration$1, options$1);
|
|
2540
2533
|
}
|
|
2541
2534
|
});
|
|
2542
2535
|
};
|
|
@@ -2562,23 +2555,23 @@ var JavascriptTranslator = class extends Translator {
|
|
|
2562
2555
|
compileTSCode = (input) => {
|
|
2563
2556
|
const fileNameFull = `${input.fileName}${input.fileExtension}`;
|
|
2564
2557
|
const output = {};
|
|
2565
|
-
const host = typescript
|
|
2558
|
+
const host = typescript.createCompilerHost(this.config.compilerTsConfig, true);
|
|
2566
2559
|
const fileNames = [fileNameFull];
|
|
2567
2560
|
const originalSourceFileGet = host.getSourceFile.bind(host);
|
|
2568
2561
|
host.getSourceFile = (sourceFileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
2569
2562
|
if (sourceFileName !== fileNameFull) return originalSourceFileGet(sourceFileName, languageVersion, onError, shouldCreateNewSourceFile);
|
|
2570
|
-
return typescript
|
|
2563
|
+
return typescript.createSourceFile(sourceFileName, input.fileContent, languageVersion, true, typescript.ScriptKind.TS);
|
|
2571
2564
|
};
|
|
2572
2565
|
host.writeFile = (fileName, contents) => {
|
|
2573
2566
|
output[fileName] = contents;
|
|
2574
2567
|
};
|
|
2575
|
-
typescript
|
|
2568
|
+
typescript.createProgram(fileNames, this.config.compilerTsConfig, host).emit();
|
|
2576
2569
|
return output;
|
|
2577
2570
|
};
|
|
2578
2571
|
translate = async (input) => {
|
|
2579
2572
|
const compiled = this.compileTSCode(input);
|
|
2580
|
-
const jsFileName = `${input.fileName}${typescript
|
|
2581
|
-
const dtsFileName = `${input.fileName}${typescript
|
|
2573
|
+
const jsFileName = `${input.fileName}${typescript.Extension.Js}`;
|
|
2574
|
+
const dtsFileName = `${input.fileName}${typescript.Extension.Dts}`;
|
|
2582
2575
|
const sourceContent = compiled[jsFileName];
|
|
2583
2576
|
const tsImportRows = input.fileContent.split("\n").filter((line) => line.startsWith("import "));
|
|
2584
2577
|
const declarationContent = compiled[dtsFileName].split("\n").map((line) => {
|
|
@@ -2587,11 +2580,11 @@ var JavascriptTranslator = class extends Translator {
|
|
|
2587
2580
|
}).join("\n");
|
|
2588
2581
|
return [{
|
|
2589
2582
|
fileName: input.fileName,
|
|
2590
|
-
fileExtension: typescript
|
|
2583
|
+
fileExtension: typescript.Extension.Js,
|
|
2591
2584
|
fileContent: await this.codeFormatter.formatCode(sourceContent)
|
|
2592
2585
|
}, {
|
|
2593
2586
|
fileName: input.fileName,
|
|
2594
|
-
fileExtension: typescript
|
|
2587
|
+
fileExtension: typescript.Extension.Dts,
|
|
2595
2588
|
fileContent: await this.codeFormatter.formatCode(declarationContent)
|
|
2596
2589
|
}];
|
|
2597
2590
|
};
|
|
@@ -2643,16 +2636,16 @@ var TypeNameFormatter = class {
|
|
|
2643
2636
|
//#endregion
|
|
2644
2637
|
//#region src/util/file-system.ts
|
|
2645
2638
|
var FileSystem = class {
|
|
2646
|
-
getFileContent = (path$
|
|
2647
|
-
return fs.readFileSync(path$
|
|
2639
|
+
getFileContent = (path$2) => {
|
|
2640
|
+
return fs.readFileSync(path$2, { encoding: "utf8" });
|
|
2648
2641
|
};
|
|
2649
|
-
readDir = (path$
|
|
2650
|
-
return fs.readdirSync(path$
|
|
2642
|
+
readDir = (path$2) => {
|
|
2643
|
+
return fs.readdirSync(path$2);
|
|
2651
2644
|
};
|
|
2652
|
-
pathIsDir = (path$
|
|
2653
|
-
if (!path$
|
|
2645
|
+
pathIsDir = (path$2) => {
|
|
2646
|
+
if (!path$2) return false;
|
|
2654
2647
|
try {
|
|
2655
|
-
const stat = fs.statSync(path$
|
|
2648
|
+
const stat = fs.statSync(path$2);
|
|
2656
2649
|
return stat.isDirectory();
|
|
2657
2650
|
} catch (e) {
|
|
2658
2651
|
return false;
|
|
@@ -2663,27 +2656,27 @@ var FileSystem = class {
|
|
|
2663
2656
|
if (fileNameParts.length > 1) fileNameParts.pop();
|
|
2664
2657
|
return fileNameParts.join(".");
|
|
2665
2658
|
};
|
|
2666
|
-
removeDir = (path$
|
|
2659
|
+
removeDir = (path$2) => {
|
|
2667
2660
|
try {
|
|
2668
|
-
if (typeof fs.rmSync === "function") fs.rmSync(path$
|
|
2669
|
-
else fs.rmdirSync(path$
|
|
2661
|
+
if (typeof fs.rmSync === "function") fs.rmSync(path$2, { recursive: true });
|
|
2662
|
+
else fs.rmdirSync(path$2, { recursive: true });
|
|
2670
2663
|
} catch (e) {
|
|
2671
2664
|
consola.debug("failed to remove dir", e);
|
|
2672
2665
|
}
|
|
2673
2666
|
};
|
|
2674
|
-
createDir = (path$
|
|
2667
|
+
createDir = (path$2) => {
|
|
2675
2668
|
try {
|
|
2676
|
-
fs.mkdirSync(path$
|
|
2669
|
+
fs.mkdirSync(path$2, { recursive: true });
|
|
2677
2670
|
} catch (e) {
|
|
2678
2671
|
consola.debug("failed to create dir", e);
|
|
2679
2672
|
}
|
|
2680
2673
|
};
|
|
2681
|
-
cleanDir = (path$
|
|
2682
|
-
this.removeDir(path$
|
|
2683
|
-
this.createDir(path$
|
|
2674
|
+
cleanDir = (path$2) => {
|
|
2675
|
+
this.removeDir(path$2);
|
|
2676
|
+
this.createDir(path$2);
|
|
2684
2677
|
};
|
|
2685
|
-
pathIsExist = (path$
|
|
2686
|
-
return !!path$
|
|
2678
|
+
pathIsExist = (path$2) => {
|
|
2679
|
+
return !!path$2 && fs.existsSync(path$2);
|
|
2687
2680
|
};
|
|
2688
2681
|
createFile = ({ path: path_, fileName, content, withPrefix }) => {
|
|
2689
2682
|
const __dirname$1 = path$1.dirname(url$1.fileURLToPath(import.meta.url));
|
|
@@ -3131,4 +3124,4 @@ async function generateApi(config) {
|
|
|
3131
3124
|
|
|
3132
3125
|
//#endregion
|
|
3133
3126
|
export { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
|
|
3134
|
-
//# sourceMappingURL=src-
|
|
3127
|
+
//# sourceMappingURL=src-BYbyXNbU.js.map
|