@povio/openapi-codegen-cli 3.3.0-rc.2 → 3.3.0
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 +125 -9
- package/dist/AuthGuard-GbtTDXs0.d.mts +32 -0
- package/dist/AuthGuard-qpAtHaBz.mjs +24 -0
- package/dist/acl.d.mts +6 -19
- package/dist/acl.mjs +7 -7
- 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-FD2Y872S.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-CLK1FoLT.mjs +1669 -0
- package/dist/generate.utils-BSDYGp-0.cjs +2270 -0
- package/dist/{generateCodeFromOpenAPIDoc-SYuVswEJ.mjs → generateCodeFromOpenAPIDoc-BypeVKIE.cjs} +1496 -2258
- package/dist/generateCodeFromOpenAPIDoc-CDyGSv2w.mjs +2242 -0
- package/dist/generator.d.mts +3 -10
- package/dist/generator.mjs +6 -4
- package/dist/getDataFromOpenAPIDoc-DYiCTWno.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-DUqQD2B5.mjs} +2 -2
- package/dist/{openapi-source.runner-B6KKrXw7.d.mts → openapi-source.runner-Bje-tMOV.d.mts} +2 -8
- package/dist/{openapi-source.runner-8kCe-g9S.mjs → openapi-source.runner-DPUNTduQ.mjs} +25 -11
- package/dist/{options-DdQJ9BSc.d.mts → options-rz2bcsaN.d.mts} +10 -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 +50 -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 +67 -19
- 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,45 +107,46 @@
|
|
|
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": "6.8.0",
|
|
129
|
+
"@casl/react": "5.0.1",
|
|
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",
|
|
101
135
|
"@types/yargs": "^17.0.35",
|
|
102
136
|
"@vitejs/plugin-react": "^5.1.4",
|
|
137
|
+
"axios": "^1.13.1",
|
|
138
|
+
"i18next": "^25.8.11",
|
|
103
139
|
"oxfmt": "^0.34.0",
|
|
104
|
-
"oxlint": "
|
|
140
|
+
"oxlint": "1.50.0",
|
|
105
141
|
"oxlint-tsgolint": "^0.15.0",
|
|
106
142
|
"react": "^19.2.4",
|
|
107
|
-
"tsdown": "^0.
|
|
143
|
+
"tsdown": "^0.22.14",
|
|
108
144
|
"tsx": "^4.21.0",
|
|
109
145
|
"type-fest": "^5.4.4",
|
|
146
|
+
"typescript": "^7.0.2",
|
|
110
147
|
"vite": "npm:rolldown-vite@^7.3.1",
|
|
111
148
|
"vite-plugin-dts": "^4.5.4",
|
|
112
149
|
"vitest": "4.0.18",
|
|
113
|
-
"yargs": "^17.7.2",
|
|
114
150
|
"zod": "^4.5.0"
|
|
115
151
|
},
|
|
116
152
|
"peerDependencies": {
|
|
@@ -130,14 +166,26 @@
|
|
|
130
166
|
"@casl/react": {
|
|
131
167
|
"optional": true
|
|
132
168
|
},
|
|
169
|
+
"@tanstack/react-query": {
|
|
170
|
+
"optional": true
|
|
171
|
+
},
|
|
172
|
+
"axios": {
|
|
173
|
+
"optional": true
|
|
174
|
+
},
|
|
175
|
+
"i18next": {
|
|
176
|
+
"optional": true
|
|
177
|
+
},
|
|
178
|
+
"react": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
133
181
|
"vite": {
|
|
134
182
|
"optional": true
|
|
135
183
|
}
|
|
136
184
|
},
|
|
137
185
|
"engines": {
|
|
138
186
|
"bun": ">= 1.4",
|
|
139
|
-
"node": ">=
|
|
187
|
+
"node": ">= 18"
|
|
140
188
|
},
|
|
141
|
-
"packageManager": "bun@1.4.
|
|
142
|
-
"version": "3.3.0
|
|
189
|
+
"packageManager": "bun@1.4.1",
|
|
190
|
+
"version": "3.3.0"
|
|
143
191
|
}
|
|
@@ -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 };
|