@povio/openapi-codegen-cli 2.0.8-rc.30 → 2.0.8-rc.31
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/{config-BRQts1Ob.d.mts → config-KffSntOs.d.mts} +1 -1
- package/dist/{generate.runner-CY2Topy5.mjs → generate.runner-CXsHkwM7.mjs} +8 -55
- package/dist/{generateCodeFromOpenAPIDoc-CesDBC83.mjs → generateCodeFromOpenAPIDoc-DkNqNy-S.mjs} +1 -0
- package/dist/generator.d.mts +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/{options-DmeJPSRO.d.mts → options-D9TC-n26.d.mts} +1 -0
- package/dist/sh.mjs +8 -3
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
5
4
|
|
|
6
5
|
//#region src/generators/core/resolveConfig.ts
|
|
@@ -17,40 +16,26 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
17
16
|
|
|
18
17
|
//#endregion
|
|
19
18
|
//#region src/generators/run/generate.runner.ts
|
|
20
|
-
const CACHE_FILE_NAME = ".openapi-codegen-cache.json";
|
|
21
19
|
async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
|
|
22
20
|
const config = profiler.runSync("config.resolve", () => resolveConfig({
|
|
23
21
|
fileConfig,
|
|
24
22
|
params: params ?? {}
|
|
25
23
|
}));
|
|
26
24
|
const openApiDoc = await getOpenApiDoc(config.input, profiler);
|
|
27
|
-
const openApiHash = hashString(stableStringify(openApiDoc));
|
|
28
|
-
const optionsHash = hashString(stableStringify(getCacheableConfig(config)));
|
|
29
|
-
const cacheFilePath = path.resolve(config.output, CACHE_FILE_NAME);
|
|
30
|
-
if (config.incremental) {
|
|
31
|
-
const cached = readCache(cacheFilePath);
|
|
32
|
-
if (cached && cached.openApiHash === openApiHash && cached.optionsHash === optionsHash) return {
|
|
33
|
-
skipped: true,
|
|
34
|
-
config,
|
|
35
|
-
stats: {
|
|
36
|
-
generatedFilesCount: 0,
|
|
37
|
-
generatedModulesCount: 0
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
25
|
const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
|
|
26
|
+
if (config.clearOutput) profiler.runSync("files.clearOutput", () => {
|
|
27
|
+
fs.rmSync(config.output, {
|
|
28
|
+
force: true,
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
});
|
|
42
32
|
await profiler.runAsync("files.write", async () => {
|
|
43
33
|
await writeGenerateFileData(filesData, { formatGeneratedFile });
|
|
44
34
|
});
|
|
45
|
-
const stats = getGenerateStats(filesData, config);
|
|
46
|
-
if (config.incremental) await writeCache(cacheFilePath, {
|
|
47
|
-
openApiHash,
|
|
48
|
-
optionsHash
|
|
49
|
-
}, formatGeneratedFile);
|
|
50
35
|
return {
|
|
51
36
|
skipped: false,
|
|
52
37
|
config,
|
|
53
|
-
stats
|
|
38
|
+
stats: getGenerateStats(filesData, config)
|
|
54
39
|
};
|
|
55
40
|
}
|
|
56
41
|
async function getOpenApiDoc(input, profiler) {
|
|
@@ -71,38 +56,6 @@ function hasExternalRef(value) {
|
|
|
71
56
|
}
|
|
72
57
|
return false;
|
|
73
58
|
}
|
|
74
|
-
function getCacheableConfig(config) {
|
|
75
|
-
const { output, incremental, ...cacheableConfig } = config;
|
|
76
|
-
return cacheableConfig;
|
|
77
|
-
}
|
|
78
|
-
function readCache(filePath) {
|
|
79
|
-
if (!fs.existsSync(filePath)) return null;
|
|
80
|
-
try {
|
|
81
|
-
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
82
|
-
} catch {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function writeCache(filePath, data, formatGeneratedFile) {
|
|
87
|
-
await writeGenerateFileData([{
|
|
88
|
-
fileName: filePath,
|
|
89
|
-
content: JSON.stringify(data)
|
|
90
|
-
}], { formatGeneratedFile });
|
|
91
|
-
}
|
|
92
|
-
function hashString(input) {
|
|
93
|
-
let hash = 2166136261;
|
|
94
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
95
|
-
hash ^= input.charCodeAt(i);
|
|
96
|
-
hash = Math.imul(hash, 16777619);
|
|
97
|
-
}
|
|
98
|
-
return (hash >>> 0).toString(16);
|
|
99
|
-
}
|
|
100
|
-
function stableStringify(input) {
|
|
101
|
-
if (input === null || typeof input !== "object") return JSON.stringify(input);
|
|
102
|
-
if (Array.isArray(input)) return `[${input.map((item) => stableStringify(item)).join(",")}]`;
|
|
103
|
-
const obj = input;
|
|
104
|
-
return `{${Object.keys(obj).sort((a, b) => a.localeCompare(b)).map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`).join(",")}}`;
|
|
105
|
-
}
|
|
106
59
|
function getGenerateStats(filesData, config) {
|
|
107
60
|
const generatedFilesCount = filesData.length;
|
|
108
61
|
if (generatedFilesCount === 0) return {
|
package/dist/generator.d.mts
CHANGED
package/dist/generator.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as isMediaTypeAllowed, b as formatTag, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, h as GenerateType, i as getDataFromOpenAPIDoc, l as getTsTypeBase, m as getNamespaceName, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as isParamMediaTypeAllowed, y as invalidVariableNameCharactersToCamel } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { _ as isMediaTypeAllowed, b as formatTag, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, h as GenerateType, i as getDataFromOpenAPIDoc, l as getTsTypeBase, m as getNamespaceName, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as isParamMediaTypeAllowed, y as invalidVariableNameCharactersToCamel } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
|
|
2
2
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/core/getMetadataFromOpenAPIDoc.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-CXeVTk1T.mjs";
|
|
2
|
-
import "./options-
|
|
3
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
2
|
+
import "./options-D9TC-n26.mjs";
|
|
3
|
+
import { t as OpenAPICodegenConfig } from "./config-KffSntOs.mjs";
|
|
4
4
|
import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import "i18next";
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { S as VALIDATION_ERROR_TYPE_TITLE, g as groupByType, h as GenerateType, i as getDataFromOpenAPIDoc, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
3
|
-
import { n as resolveConfig, t as runGenerate } from "./generate.runner-
|
|
2
|
+
import { S as VALIDATION_ERROR_TYPE_TITLE, g as groupByType, h as GenerateType, i as getDataFromOpenAPIDoc, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-CXsHkwM7.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import yargs from "yargs";
|
|
6
6
|
import { hideBin } from "yargs/helpers";
|
|
@@ -39,7 +39,7 @@ function logBanner(message) {
|
|
|
39
39
|
* Fetch the version from package.json
|
|
40
40
|
*/
|
|
41
41
|
function getVersion() {
|
|
42
|
-
return "2.0.8-rc.
|
|
42
|
+
return "2.0.8-rc.31";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
@@ -300,6 +300,7 @@ var GenerateOptions = class {
|
|
|
300
300
|
config;
|
|
301
301
|
input;
|
|
302
302
|
output;
|
|
303
|
+
clearOutput;
|
|
303
304
|
incremental;
|
|
304
305
|
tsNamespaces;
|
|
305
306
|
tsPath;
|
|
@@ -332,6 +333,10 @@ var GenerateOptions = class {
|
|
|
332
333
|
__decorate([YargOption({ envAlias: "config" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "config", void 0);
|
|
333
334
|
__decorate([YargOption({ envAlias: "input" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "input", void 0);
|
|
334
335
|
__decorate([YargOption({ envAlias: "output" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "output", void 0);
|
|
336
|
+
__decorate([YargOption({
|
|
337
|
+
envAlias: "clearOutput",
|
|
338
|
+
type: "boolean"
|
|
339
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "clearOutput", void 0);
|
|
335
340
|
__decorate([YargOption({
|
|
336
341
|
envAlias: "incremental",
|
|
337
342
|
type: "boolean"
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as GenerateFileFormatter } from "./options-
|
|
2
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
1
|
+
import { r as GenerateFileFormatter } from "./options-D9TC-n26.mjs";
|
|
2
|
+
import { t as OpenAPICodegenConfig } from "./config-KffSntOs.mjs";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.d.ts
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { t as runGenerate } from "./generate.runner-
|
|
1
|
+
import { x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-CXsHkwM7.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.ts
|