@povio/openapi-codegen-cli 3.3.0-rc.2 → 3.3.1
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 +132 -9
- package/dist/AuthGuard-GbtTDXs0.d.mts +32 -0
- package/dist/AuthGuard-qpAtHaBz.mjs +24 -0
- package/dist/acl.d.mts +14 -27
- package/dist/acl.mjs +17 -14
- package/dist/{auth.context-BAz8frX9.mjs → auth.context-COWO6ssl.mjs} +1 -18
- package/dist/auth.d.mts +2 -0
- package/dist/auth.mjs +3 -0
- package/dist/axios.d.mts +2 -0
- package/dist/axios.mjs +2 -0
- package/dist/{config-BQqze8rU.d.mts → config-BYiBd1QI.d.mts} +1 -2
- package/dist/config.d.mts +4 -0
- package/dist/config.mjs +5 -0
- package/dist/{error-handling-D6ZYITQ3.d.mts → error-handling-LPEPQV1V.d.mts} +3 -42
- package/dist/{error-handling-CsnufAil.mjs → error-handling-uS0DgYUR.mjs} +23 -47
- package/dist/errors.d.mts +3 -0
- package/dist/errors.mjs +2 -0
- package/dist/generate.runner-CxlaA4c5.mjs +1670 -0
- package/dist/generate.utils-SfgYwPe7.cjs +2271 -0
- package/dist/generateCodeFromOpenAPIDoc-CmN4bFjv.mjs +2246 -0
- package/dist/{generateCodeFromOpenAPIDoc-SYuVswEJ.mjs → generateCodeFromOpenAPIDoc-Dv-hqKhh.cjs} +1511 -2269
- package/dist/generator.d.mts +3 -10
- package/dist/generator.mjs +6 -4
- package/dist/getDataFromOpenAPIDoc-DzeHecv2.mjs +2016 -0
- package/dist/i18n-B_brQh4X.d.mts +38 -0
- package/dist/i18n-D-FesqFb.mjs +36 -0
- package/dist/index.d.mts +12 -198
- package/dist/index.mjs +12 -256
- package/dist/metro.cjs +118 -4862
- package/dist/metro.d.mts +3 -4
- package/dist/metro.mjs +3 -3
- package/dist/native-rest-interceptor-Np4Ov54n.mjs +215 -0
- package/dist/native-rest-interceptor-PgziZt1f.d.mts +49 -0
- package/dist/native.d.mts +3 -0
- package/dist/native.mjs +3 -0
- 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-CCXQsUum.mjs → openapi-codegen.runner-DDd4AXRT.mjs} +2 -2
- package/dist/{openapi-source.runner-8kCe-g9S.mjs → openapi-source.runner-DPUNTduQ.mjs} +25 -11
- package/dist/{openapi-source.runner-B6KKrXw7.d.mts → openapi-source.runner-lmK-P6HE.d.mts} +2 -8
- package/dist/{options-DdQJ9BSc.d.mts → options-DH-fAG0w.d.mts} +12 -1
- package/dist/query.d.mts +3 -0
- package/dist/query.mjs +3 -0
- package/dist/queryConfig.context-CRJOgf19.d.mts +22 -0
- package/dist/queryConfig.context-CldQ5YL9.mjs +34 -0
- package/dist/rest-client-CQyFvqYC.d.mts +55 -0
- package/dist/rest-interceptor-Dm9DFErh.mjs +115 -0
- package/dist/rest-transport.types-DM5-qyOJ.d.mts +66 -0
- package/dist/rest-transport.types-DxitRtsB.mjs +11 -0
- package/dist/rest.d.mts +2 -0
- package/dist/rest.mjs +2 -0
- package/dist/rest.utils-DpiFIdhF.d.mts +9 -0
- package/dist/router.context-EPlMBk3G.mjs +21 -0
- package/dist/sh.d.mts +1 -1
- package/dist/sh.mjs +55 -55
- package/dist/tiny.d.mts +1 -1
- package/dist/tiny.mjs +1 -1
- package/dist/useMutationEffects-DIdL8tlx.d.mts +29 -0
- package/dist/useMutationEffects-PB1fvKWM.mjs +68 -0
- package/dist/vite.d.mts +3 -4
- package/dist/vite.mjs +5 -4
- package/dist/workspace.context-XWvQ_7Hg.mjs +26 -0
- package/dist/workspace.context-isVY9ves.d.mts +23 -0
- package/dist/zod.d.mts +2 -7
- package/dist/zod.mjs +1 -1
- package/package.json +71 -21
- package/dist/generate.runner-B0Zm3pIl.mjs +0 -87
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
//#region src/lib/config/router.context.d.ts
|
|
3
|
+
interface RouterProviderProps {
|
|
4
|
+
replace: (url: string) => void;
|
|
5
|
+
}
|
|
6
|
+
declare namespace OpenApiRouter {
|
|
7
|
+
const Provider: ({ children, replace }: PropsWithChildren<RouterProviderProps>) => import("react").JSX.Element;
|
|
8
|
+
const useRouter: () => RouterProviderProps;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/lib/config/workspace.context.d.ts
|
|
12
|
+
type WorkspaceValues = Record<string, unknown>;
|
|
13
|
+
interface WorkspaceProviderProps {
|
|
14
|
+
values?: WorkspaceValues;
|
|
15
|
+
}
|
|
16
|
+
declare namespace OpenApiWorkspaceContext {
|
|
17
|
+
const Provider: ({ values, children }: PropsWithChildren<WorkspaceProviderProps>) => import("react").JSX.Element;
|
|
18
|
+
const useContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
19
|
+
const resolveParam: <T>(context: WorkspaceValues, name: string, value: T | null | undefined) => T;
|
|
20
|
+
}
|
|
21
|
+
declare const useWorkspaceContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useWorkspaceContext as n, OpenApiRouter as r, OpenApiWorkspaceContext as t };
|
package/dist/zod.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as ErrorHandler } from "./error-handling-
|
|
1
|
+
import { a as ErrorHandler } from "./error-handling-LPEPQV1V.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
3
|
//#region src/zod.d.ts
|
|
5
4
|
declare namespace ZodExtended {
|
|
6
5
|
interface ParseOptions {
|
|
@@ -8,11 +7,7 @@ declare namespace ZodExtended {
|
|
|
8
7
|
name?: string;
|
|
9
8
|
errorHandler?: ErrorHandler<never>;
|
|
10
9
|
}
|
|
11
|
-
export function parse<ZOutput, ZInput>(schema: z.ZodType<ZOutput, ZInput>, data: unknown, {
|
|
12
|
-
type,
|
|
13
|
-
name,
|
|
14
|
-
errorHandler
|
|
15
|
-
}?: ParseOptions): ZOutput;
|
|
10
|
+
export function parse<ZOutput, ZInput>(schema: z.ZodType<ZOutput, ZInput>, data: unknown, { type, name, errorHandler }?: ParseOptions): ZOutput;
|
|
16
11
|
export const sortExp: (enumSchema: z.ZodEnum) => z.ZodString;
|
|
17
12
|
export {};
|
|
18
13
|
}
|
package/dist/zod.mjs
CHANGED
package/package.json
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"src/assets/**"
|
|
24
24
|
],
|
|
25
25
|
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
26
27
|
"main": "./dist/index.mjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
27
29
|
"types": "./dist/index.d.mts",
|
|
28
30
|
"exports": {
|
|
29
31
|
".": {
|
|
@@ -54,14 +56,47 @@
|
|
|
54
56
|
"./zod": {
|
|
55
57
|
"types": "./dist/zod.d.mts",
|
|
56
58
|
"import": "./dist/zod.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./native": {
|
|
61
|
+
"types": "./dist/native.d.mts",
|
|
62
|
+
"import": "./dist/native.mjs"
|
|
63
|
+
},
|
|
64
|
+
"./rest": {
|
|
65
|
+
"types": "./dist/rest.d.mts",
|
|
66
|
+
"import": "./dist/rest.mjs"
|
|
67
|
+
},
|
|
68
|
+
"./axios": {
|
|
69
|
+
"types": "./dist/axios.d.mts",
|
|
70
|
+
"import": "./dist/axios.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./errors": {
|
|
73
|
+
"types": "./dist/errors.d.mts",
|
|
74
|
+
"import": "./dist/errors.mjs"
|
|
75
|
+
},
|
|
76
|
+
"./query": {
|
|
77
|
+
"types": "./dist/query.d.mts",
|
|
78
|
+
"import": "./dist/query.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./config": {
|
|
81
|
+
"types": "./dist/config.d.mts",
|
|
82
|
+
"import": "./dist/config.mjs"
|
|
83
|
+
},
|
|
84
|
+
"./auth": {
|
|
85
|
+
"types": "./dist/auth.d.mts",
|
|
86
|
+
"import": "./dist/auth.mjs"
|
|
57
87
|
}
|
|
58
88
|
},
|
|
59
89
|
"scripts": {
|
|
60
|
-
"start": "
|
|
61
|
-
"test": "
|
|
90
|
+
"start": "bun ./src/sh.ts",
|
|
91
|
+
"test": "bun run build:native && bun run test:ts && bun run test:native",
|
|
92
|
+
"test:ts": "OPENAPI_CODEGEN_NATIVE=0 vitest run",
|
|
93
|
+
"test:native": "OPENAPI_CODEGEN_NATIVE=1 OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE=1 vitest run",
|
|
94
|
+
"test:parity": "vitest run src/native/renderer-parity.test.ts src/native/renderer-parity-manifest.test.ts src/native/model-imports.test.ts src/native/configuration-parity.test.ts src/native/configuration-runtime.test.ts src/native/configuration-lifecycle.test.ts",
|
|
62
95
|
"test:watch": "vitest",
|
|
63
|
-
"build": "tsdown",
|
|
64
|
-
"
|
|
96
|
+
"build": "tsdown && bun run build:native",
|
|
97
|
+
"build:ts": "tsdown",
|
|
98
|
+
"build:native": "bun ./scripts/build-native.mjs",
|
|
99
|
+
"start:dist": "bun ./dist/sh.mjs",
|
|
65
100
|
"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",
|
|
66
101
|
"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
102
|
"test:generated-eq": "vitest run ./src/generators/generated-output-eq.test.ts",
|
|
@@ -72,50 +107,53 @@
|
|
|
72
107
|
"format": "oxfmt",
|
|
73
108
|
"format:check": "oxfmt --check",
|
|
74
109
|
"check": "bun run typecheck && bun run lint && bun run test",
|
|
75
|
-
"push": "
|
|
110
|
+
"push": "bun ./scripts/publish.mjs",
|
|
76
111
|
"dev:generate": "rm -rf ./output && bun run start generate --config ./test/config.mjs",
|
|
77
112
|
"dev:check": "bun run start check --config ./test/config.mjs",
|
|
78
|
-
"snapshot:openapi-localhost": "
|
|
79
|
-
"bench:vite-codegen": "
|
|
113
|
+
"snapshot:openapi-localhost": "bun ./scripts/snapshot-openapi-localhost.mjs",
|
|
114
|
+
"bench:vite-codegen": "bun ./scripts/benchmark-vite-codegen.mjs",
|
|
115
|
+
"verify:tree-shaking": "bun run build:ts && bun ./scripts/verify-tree-shaking.mjs"
|
|
80
116
|
},
|
|
81
117
|
"dependencies": {
|
|
82
|
-
"@apidevtools/swagger-parser": "^10.1.0",
|
|
83
118
|
"@orpc/contract": "^1.14.3",
|
|
84
119
|
"@orpc/openapi": "^1.14.3",
|
|
85
120
|
"@orpc/zod": "^1.14.3",
|
|
86
|
-
"import-fresh": "^3.3.1",
|
|
87
121
|
"openapi-types": "^12.1.3",
|
|
88
122
|
"prompt-sync": "^4.2.0",
|
|
89
123
|
"reflect-metadata": "^0.2.2",
|
|
90
|
-
"
|
|
91
|
-
"typescript": "^5.9.3",
|
|
124
|
+
"yaml": "^2.9.0",
|
|
92
125
|
"yargs": "^18.0.0"
|
|
93
126
|
},
|
|
94
127
|
"devDependencies": {
|
|
95
|
-
"@casl/ability": "
|
|
96
|
-
"@casl/react": "
|
|
128
|
+
"@casl/ability": "7.1.1",
|
|
129
|
+
"@casl/react": "7.1.0",
|
|
97
130
|
"@tanstack/react-query": "~5.90.21",
|
|
131
|
+
"@types/bun": "1.4.1",
|
|
98
132
|
"@types/node": "^25.3.0",
|
|
99
133
|
"@types/prompt-sync": "^4.2.3",
|
|
100
134
|
"@types/react": "^19.2.14",
|
|
135
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
101
136
|
"@types/yargs": "^17.0.35",
|
|
102
137
|
"@vitejs/plugin-react": "^5.1.4",
|
|
138
|
+
"axios": "^1.13.1",
|
|
139
|
+
"i18next": "^25.8.11",
|
|
103
140
|
"oxfmt": "^0.34.0",
|
|
104
|
-
"oxlint": "
|
|
141
|
+
"oxlint": "1.50.0",
|
|
105
142
|
"oxlint-tsgolint": "^0.15.0",
|
|
106
143
|
"react": "^19.2.4",
|
|
107
|
-
"
|
|
144
|
+
"react-test-renderer": "19.2.4",
|
|
145
|
+
"tsdown": "^0.22.14",
|
|
108
146
|
"tsx": "^4.21.0",
|
|
109
147
|
"type-fest": "^5.4.4",
|
|
148
|
+
"typescript": "^7.0.2",
|
|
110
149
|
"vite": "npm:rolldown-vite@^7.3.1",
|
|
111
150
|
"vite-plugin-dts": "^4.5.4",
|
|
112
151
|
"vitest": "4.0.18",
|
|
113
|
-
"yargs": "^17.7.2",
|
|
114
152
|
"zod": "^4.5.0"
|
|
115
153
|
},
|
|
116
154
|
"peerDependencies": {
|
|
117
|
-
"@casl/ability": "^
|
|
118
|
-
"@casl/react": "^
|
|
155
|
+
"@casl/ability": "^7.1.1",
|
|
156
|
+
"@casl/react": "^7.1.0",
|
|
119
157
|
"@tanstack/react-query": "^5.90.21",
|
|
120
158
|
"axios": "^1.13.1",
|
|
121
159
|
"i18next": "^25.8.11",
|
|
@@ -130,14 +168,26 @@
|
|
|
130
168
|
"@casl/react": {
|
|
131
169
|
"optional": true
|
|
132
170
|
},
|
|
171
|
+
"@tanstack/react-query": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"axios": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"i18next": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"react": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
133
183
|
"vite": {
|
|
134
184
|
"optional": true
|
|
135
185
|
}
|
|
136
186
|
},
|
|
137
187
|
"engines": {
|
|
138
188
|
"bun": ">= 1.4",
|
|
139
|
-
"node": ">=
|
|
189
|
+
"node": ">= 18"
|
|
140
190
|
},
|
|
141
|
-
"packageManager": "bun@1.4.
|
|
142
|
-
"version": "3.3.
|
|
191
|
+
"packageManager": "bun@1.4.1",
|
|
192
|
+
"version": "3.3.1"
|
|
143
193
|
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-SYuVswEJ.mjs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
|
-
//#region src/generators/core/resolveConfig.ts
|
|
5
|
-
function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, inlineEndpointsExcludeModules, workspaceContext, ...options } }) {
|
|
6
|
-
const resolvedConfig = deepMerge(DEFAULT_GENERATE_OPTIONS, fileConfig ?? {}, {
|
|
7
|
-
...options,
|
|
8
|
-
includeTags: includeTags?.split(","),
|
|
9
|
-
excludeTags: excludeTags?.split(","),
|
|
10
|
-
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(","),
|
|
11
|
-
workspaceContext: workspaceContext?.split(",")
|
|
12
|
-
});
|
|
13
|
-
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
14
|
-
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
15
|
-
return resolvedConfig;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/generators/run/generate.runner.ts
|
|
19
|
-
async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
|
|
20
|
-
const config = profiler.runSync("config.resolve", () => resolveConfig({
|
|
21
|
-
fileConfig,
|
|
22
|
-
params: params ?? {}
|
|
23
|
-
}));
|
|
24
|
-
const openApiDoc = await getOpenApiDoc(config.input, profiler);
|
|
25
|
-
const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
|
|
26
|
-
if (config.clearOutput) profiler.runSync("files.removeStaleGenerated", () => {
|
|
27
|
-
removeStaleGeneratedFiles({
|
|
28
|
-
output: config.output,
|
|
29
|
-
filesData,
|
|
30
|
-
options: config
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
await profiler.runAsync("files.write", async () => {
|
|
34
|
-
await writeGenerateFileData(filesData, { formatGeneratedFile });
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
skipped: false,
|
|
38
|
-
config,
|
|
39
|
-
stats: getGenerateStats(filesData, config)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async function getOpenApiDoc(input, profiler) {
|
|
43
|
-
const parsedDoc = await profiler.runAsync("openapi.parse", async () => await SwaggerParser.parse(input));
|
|
44
|
-
if (!profiler.runSync("openapi.detectExternalRefs", () => hasExternalRef(parsedDoc))) return parsedDoc;
|
|
45
|
-
return await profiler.runAsync("openapi.bundle", async () => await SwaggerParser.bundle(input));
|
|
46
|
-
}
|
|
47
|
-
function hasExternalRef(value) {
|
|
48
|
-
const stack = [value];
|
|
49
|
-
const visited = /* @__PURE__ */ new Set();
|
|
50
|
-
while (stack.length > 0) {
|
|
51
|
-
const current = stack.pop();
|
|
52
|
-
if (!current || typeof current !== "object") continue;
|
|
53
|
-
if (visited.has(current)) continue;
|
|
54
|
-
visited.add(current);
|
|
55
|
-
if ("$ref" in current && typeof current.$ref === "string" && !current.$ref.startsWith("#/")) return true;
|
|
56
|
-
for (const nested of Object.values(current)) if (nested && typeof nested === "object") stack.push(nested);
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
function getGenerateStats(filesData, config) {
|
|
61
|
-
const generatedFilesCount = filesData.length;
|
|
62
|
-
if (generatedFilesCount === 0) return {
|
|
63
|
-
generatedFilesCount,
|
|
64
|
-
generatedModulesCount: 0
|
|
65
|
-
};
|
|
66
|
-
if (!config.splitByTags) return {
|
|
67
|
-
generatedFilesCount,
|
|
68
|
-
generatedModulesCount: 1
|
|
69
|
-
};
|
|
70
|
-
const moduleSuffixes = new Set(Object.values(config.configs).map((generateConfig) => generateConfig.outputFileNameSuffix).filter(Boolean));
|
|
71
|
-
const modules = /* @__PURE__ */ new Set();
|
|
72
|
-
for (const file of filesData) {
|
|
73
|
-
const segments = path.relative(config.output, file.fileName).split(path.sep).filter(Boolean);
|
|
74
|
-
if (segments.length < 2) continue;
|
|
75
|
-
const moduleName = segments[0];
|
|
76
|
-
const fileName = segments[segments.length - 1];
|
|
77
|
-
if (!fileName.startsWith(`${moduleName}.`)) continue;
|
|
78
|
-
const suffix = fileName.slice(moduleName.length + 1).replace(/\.tsx?$/, "");
|
|
79
|
-
if (moduleSuffixes.has(suffix)) modules.add(moduleName);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
generatedFilesCount,
|
|
83
|
-
generatedModulesCount: modules.size
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { resolveConfig as n, runGenerate as t };
|