@povio/openapi-codegen-cli 3.1.0-rc.7 → 3.2.0-rc.2
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/README.md +21 -14
- package/dist/acl.d.mts +6 -20
- package/dist/acl.mjs +3 -8
- package/dist/{auth.context-Bu5KW2sI.mjs → auth.context-YFWzkwoN.mjs} +3 -5
- package/dist/{config-BU7wVf7U.d.mts → config-DFpV8mjG.d.mts} +1 -2
- package/dist/{error-handling-BeRxGbwE.d.mts → error-handling-CNOHs4Fc.d.mts} +3 -4
- package/dist/{error-handling-DG8SfTWB.mjs → error-handling-DDIXMA-R.mjs} +8 -11
- package/dist/generate.runner-BGhsnDm8.mjs +1674 -0
- package/dist/generate.utils-C29zzyBl.cjs +2281 -0
- package/dist/{generateCodeFromOpenAPIDoc-CbQ9gQss.mjs → generateCodeFromOpenAPIDoc-B0Cmn2dx.cjs} +1261 -2336
- package/dist/generateCodeFromOpenAPIDoc-CLQbTTwF.mjs +2004 -0
- package/dist/generator.d.mts +3 -10
- package/dist/generator.mjs +8 -9
- package/dist/getDataFromOpenAPIDoc-fPRPa4_t.mjs +1988 -0
- package/dist/index.d.mts +9 -48
- package/dist/index.mjs +4 -11
- package/dist/metro.cjs +114 -4923
- package/dist/metro.d.mts +3 -4
- package/dist/metro.mjs +4 -9
- package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
- package/dist/openapi-codegen-native-linux-x64.node +0 -0
- package/dist/openapi-codegen-native-win32-x64.node +0 -0
- package/dist/{openapi-codegen.runner-BqOhUduF.mjs → openapi-codegen.runner-BtaqQSH2.mjs} +3 -5
- package/dist/{openapi-source.runner-wLs5vqw6.mjs → openapi-source.runner-BZ6ZLgRO.mjs} +19 -10
- package/dist/{openapi-source.runner-BSIrB6ny.d.mts → openapi-source.runner-zPcbJwpP.d.mts} +2 -8
- package/dist/{options-CE4Koxof.d.mts → options-DtAnhCLZ.d.mts} +3 -1
- package/dist/sh.d.mts +1 -1
- package/dist/sh.mjs +25 -71
- package/dist/tiny.d.mts +1 -3
- package/dist/tiny.mjs +2 -3
- package/dist/vite.d.mts +3 -4
- package/dist/vite.mjs +6 -10
- package/dist/zod.d.mts +2 -7
- package/dist/zod.mjs +2 -4
- package/package.json +28 -26
- package/dist/generate.runner-DnUDkoAZ.mjs +0 -90
package/package.json
CHANGED
|
@@ -57,60 +57,62 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
|
-
"start": "
|
|
61
|
-
"test": "
|
|
60
|
+
"start": "bun ./src/sh.ts",
|
|
61
|
+
"test": "bun run build:native && bun run test:ts && bun run test:native",
|
|
62
|
+
"test:ts": "OPENAPI_CODEGEN_NATIVE=0 vitest run",
|
|
63
|
+
"test:native": "OPENAPI_CODEGEN_NATIVE=1 OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE=1 vitest run",
|
|
62
64
|
"test:watch": "vitest",
|
|
63
|
-
"build": "tsdown",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
65
|
+
"build": "tsdown && bun run build:native",
|
|
66
|
+
"build:ts": "tsdown",
|
|
67
|
+
"build:native": "bun ./scripts/build-native.mjs",
|
|
68
|
+
"start:dist": "bun ./dist/sh.mjs",
|
|
69
|
+
"gen:base": "rm -rf ./test/generated/base && mkdir -p ./test/generated/base && bun run start generate --config ./test/config.mjs --output ./test/generated/base --no-prettier",
|
|
70
|
+
"gen:next": "rm -rf ./test/generated/next && mkdir -p ./test/generated/next && bun run start generate --config ./test/config.mjs --output ./test/generated/next --no-prettier",
|
|
67
71
|
"test:generated-eq": "vitest run ./src/generators/generated-output-eq.test.ts",
|
|
68
|
-
"gen:verify": "
|
|
72
|
+
"gen:verify": "bun run gen:base && bun run gen:next && bun run test:generated-eq",
|
|
69
73
|
"typecheck": "tsc --noEmit",
|
|
70
74
|
"lint": "oxlint --type-aware --fix",
|
|
71
75
|
"lint:check": "oxlint --type-aware",
|
|
72
76
|
"format": "oxfmt",
|
|
73
77
|
"format:check": "oxfmt --check",
|
|
74
|
-
"check": "
|
|
75
|
-
"push": "
|
|
76
|
-
"dev:generate": "rm -rf ./output &&
|
|
77
|
-
"dev:check": "
|
|
78
|
-
"snapshot:openapi-localhost": "
|
|
79
|
-
"bench:vite-codegen": "
|
|
78
|
+
"check": "bun run typecheck && bun run lint && bun run test",
|
|
79
|
+
"push": "bun ./scripts/publish.mjs",
|
|
80
|
+
"dev:generate": "rm -rf ./output && bun run start generate --config ./test/config.mjs",
|
|
81
|
+
"dev:check": "bun run start check --config ./test/config.mjs",
|
|
82
|
+
"snapshot:openapi-localhost": "bun ./scripts/snapshot-openapi-localhost.mjs",
|
|
83
|
+
"bench:vite-codegen": "bun ./scripts/benchmark-vite-codegen.mjs"
|
|
80
84
|
},
|
|
81
85
|
"dependencies": {
|
|
82
|
-
"@apidevtools/swagger-parser": "^10.1.0",
|
|
83
86
|
"@orpc/contract": "^1.14.3",
|
|
84
87
|
"@orpc/openapi": "^1.14.3",
|
|
85
88
|
"@orpc/zod": "^1.14.3",
|
|
86
|
-
"import-fresh": "^3.3.1",
|
|
87
89
|
"openapi-types": "^12.1.3",
|
|
88
90
|
"prompt-sync": "^4.2.0",
|
|
89
91
|
"reflect-metadata": "^0.2.2",
|
|
90
|
-
"
|
|
91
|
-
"typescript": "^5.9.3",
|
|
92
|
+
"yaml": "^2.9.0",
|
|
92
93
|
"yargs": "^18.0.0"
|
|
93
94
|
},
|
|
94
95
|
"devDependencies": {
|
|
95
|
-
"@casl/ability": "
|
|
96
|
-
"@casl/react": "
|
|
96
|
+
"@casl/ability": "6.8.0",
|
|
97
|
+
"@casl/react": "5.0.1",
|
|
97
98
|
"@tanstack/react-query": "~5.90.21",
|
|
99
|
+
"@types/bun": "1.3.14",
|
|
98
100
|
"@types/node": "^25.3.0",
|
|
99
101
|
"@types/prompt-sync": "^4.2.3",
|
|
100
102
|
"@types/react": "^19.2.14",
|
|
101
103
|
"@types/yargs": "^17.0.35",
|
|
102
104
|
"@vitejs/plugin-react": "^5.1.4",
|
|
103
105
|
"oxfmt": "^0.34.0",
|
|
104
|
-
"oxlint": "
|
|
106
|
+
"oxlint": "1.50.0",
|
|
105
107
|
"oxlint-tsgolint": "^0.15.0",
|
|
106
108
|
"react": "^19.2.4",
|
|
107
|
-
"tsdown": "^0.
|
|
109
|
+
"tsdown": "^0.22.14",
|
|
108
110
|
"tsx": "^4.21.0",
|
|
109
111
|
"type-fest": "^5.4.4",
|
|
112
|
+
"typescript": "^7.0.2",
|
|
110
113
|
"vite": "npm:rolldown-vite@^7.3.1",
|
|
111
114
|
"vite-plugin-dts": "^4.5.4",
|
|
112
115
|
"vitest": "4.0.18",
|
|
113
|
-
"yargs": "^17.7.2",
|
|
114
116
|
"zod": "^4.3.6"
|
|
115
117
|
},
|
|
116
118
|
"peerDependencies": {
|
|
@@ -135,9 +137,9 @@
|
|
|
135
137
|
}
|
|
136
138
|
},
|
|
137
139
|
"engines": {
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
+
"bun": ">= 1.3.14",
|
|
141
|
+
"node": ">= 18"
|
|
140
142
|
},
|
|
141
|
-
"packageManager": "
|
|
142
|
-
"version": "3.
|
|
143
|
+
"packageManager": "bun@1.3.14",
|
|
144
|
+
"version": "3.2.0-rc.2"
|
|
143
145
|
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CbQ9gQss.mjs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
|
-
|
|
5
|
-
//#region src/generators/core/resolveConfig.ts
|
|
6
|
-
function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, inlineEndpointsExcludeModules, workspaceContext, ...options } }) {
|
|
7
|
-
const resolvedConfig = deepMerge(DEFAULT_GENERATE_OPTIONS, fileConfig ?? {}, {
|
|
8
|
-
...options,
|
|
9
|
-
includeTags: includeTags?.split(","),
|
|
10
|
-
excludeTags: excludeTags?.split(","),
|
|
11
|
-
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(","),
|
|
12
|
-
workspaceContext: workspaceContext?.split(",")
|
|
13
|
-
});
|
|
14
|
-
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
15
|
-
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
16
|
-
return resolvedConfig;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/generators/run/generate.runner.ts
|
|
21
|
-
async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
|
|
22
|
-
const config = profiler.runSync("config.resolve", () => resolveConfig({
|
|
23
|
-
fileConfig,
|
|
24
|
-
params: params ?? {}
|
|
25
|
-
}));
|
|
26
|
-
const openApiDoc = await getOpenApiDoc(config.input, profiler);
|
|
27
|
-
const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
|
|
28
|
-
if (config.clearOutput) profiler.runSync("files.removeStaleGenerated", () => {
|
|
29
|
-
removeStaleGeneratedFiles({
|
|
30
|
-
output: config.output,
|
|
31
|
-
filesData,
|
|
32
|
-
options: config
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
await profiler.runAsync("files.write", async () => {
|
|
36
|
-
await writeGenerateFileData(filesData, { formatGeneratedFile });
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
skipped: false,
|
|
40
|
-
config,
|
|
41
|
-
stats: getGenerateStats(filesData, config)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async function getOpenApiDoc(input, profiler) {
|
|
45
|
-
const parsedDoc = await profiler.runAsync("openapi.parse", async () => await SwaggerParser.parse(input));
|
|
46
|
-
if (!profiler.runSync("openapi.detectExternalRefs", () => hasExternalRef(parsedDoc))) return parsedDoc;
|
|
47
|
-
return await profiler.runAsync("openapi.bundle", async () => await SwaggerParser.bundle(input));
|
|
48
|
-
}
|
|
49
|
-
function hasExternalRef(value) {
|
|
50
|
-
const stack = [value];
|
|
51
|
-
const visited = /* @__PURE__ */ new Set();
|
|
52
|
-
while (stack.length > 0) {
|
|
53
|
-
const current = stack.pop();
|
|
54
|
-
if (!current || typeof current !== "object") continue;
|
|
55
|
-
if (visited.has(current)) continue;
|
|
56
|
-
visited.add(current);
|
|
57
|
-
if ("$ref" in current && typeof current.$ref === "string" && !current.$ref.startsWith("#/")) return true;
|
|
58
|
-
for (const nested of Object.values(current)) if (nested && typeof nested === "object") stack.push(nested);
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
function getGenerateStats(filesData, config) {
|
|
63
|
-
const generatedFilesCount = filesData.length;
|
|
64
|
-
if (generatedFilesCount === 0) return {
|
|
65
|
-
generatedFilesCount,
|
|
66
|
-
generatedModulesCount: 0
|
|
67
|
-
};
|
|
68
|
-
if (!config.splitByTags) return {
|
|
69
|
-
generatedFilesCount,
|
|
70
|
-
generatedModulesCount: 1
|
|
71
|
-
};
|
|
72
|
-
const moduleSuffixes = new Set(Object.values(config.configs).map((generateConfig) => generateConfig.outputFileNameSuffix).filter(Boolean));
|
|
73
|
-
const modules = /* @__PURE__ */ new Set();
|
|
74
|
-
for (const file of filesData) {
|
|
75
|
-
const segments = path.relative(config.output, file.fileName).split(path.sep).filter(Boolean);
|
|
76
|
-
if (segments.length < 2) continue;
|
|
77
|
-
const moduleName = segments[0];
|
|
78
|
-
const fileName = segments[segments.length - 1];
|
|
79
|
-
if (!fileName.startsWith(`${moduleName}.`)) continue;
|
|
80
|
-
const suffix = fileName.slice(moduleName.length + 1).replace(/\.tsx?$/, "");
|
|
81
|
-
if (moduleSuffixes.has(suffix)) modules.add(moduleName);
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
generatedFilesCount,
|
|
85
|
-
generatedModulesCount: modules.size
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
export { resolveConfig as n, runGenerate as t };
|