@povio/openapi-codegen-cli 3.2.0-rc.9 → 3.3.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.
Files changed (69) hide show
  1. package/README.md +2 -51
  2. package/dist/acl.d.mts +19 -6
  3. package/dist/acl.mjs +7 -7
  4. package/dist/{auth.context-COWO6ssl.mjs → auth.context-BAz8frX9.mjs} +18 -1
  5. package/dist/{config-DgrOddSC.d.mts → config-BQqze8rU.d.mts} +2 -1
  6. package/dist/{error-handling-BeydPL7s.mjs → error-handling-CsnufAil.mjs} +45 -21
  7. package/dist/{error-handling-LPEPQV1V.d.mts → error-handling-D6ZYITQ3.d.mts} +42 -3
  8. package/dist/generate.runner-B0Zm3pIl.mjs +87 -0
  9. package/dist/{generateCodeFromOpenAPIDoc-iEa8YAUQ.cjs → generateCodeFromOpenAPIDoc-SYuVswEJ.mjs} +2341 -1393
  10. package/dist/generator.d.mts +10 -3
  11. package/dist/generator.mjs +4 -7
  12. package/dist/index.d.mts +198 -12
  13. package/dist/index.mjs +256 -12
  14. package/dist/metro.cjs +4862 -112
  15. package/dist/metro.d.mts +4 -3
  16. package/dist/metro.mjs +3 -3
  17. package/dist/{openapi-codegen.runner-6Yth6QZC.mjs → openapi-codegen.runner-CCXQsUum.mjs} +2 -3
  18. package/dist/{openapi-source.runner-BZ6ZLgRO.mjs → openapi-source.runner-8kCe-g9S.mjs} +6 -18
  19. package/dist/{openapi-source.runner-ykstqlPC.d.mts → openapi-source.runner-B6KKrXw7.d.mts} +8 -2
  20. package/dist/{options-KPf-Fti5.d.mts → options-DdQJ9BSc.d.mts} +1 -6
  21. package/dist/sh.d.mts +1 -1
  22. package/dist/sh.mjs +53 -37
  23. package/dist/tiny.d.mts +1 -1
  24. package/dist/tiny.mjs +1 -1
  25. package/dist/vite.d.mts +4 -3
  26. package/dist/vite.mjs +4 -5
  27. package/dist/zod.d.mts +7 -2
  28. package/dist/zod.mjs +1 -1
  29. package/package.json +22 -69
  30. package/dist/AuthGuard-GbtTDXs0.d.mts +0 -32
  31. package/dist/AuthGuard-qpAtHaBz.mjs +0 -24
  32. package/dist/auth.d.mts +0 -2
  33. package/dist/auth.mjs +0 -3
  34. package/dist/axios.d.mts +0 -2
  35. package/dist/axios.mjs +0 -2
  36. package/dist/config.d.mts +0 -4
  37. package/dist/config.mjs +0 -5
  38. package/dist/errors.d.mts +0 -3
  39. package/dist/errors.mjs +0 -2
  40. package/dist/generate.runner-D8AYuEFm.mjs +0 -184
  41. package/dist/generate.utils-CT-LA-gX.cjs +0 -2267
  42. package/dist/generateCodeFromOpenAPIDoc--ufinTug.mjs +0 -2061
  43. package/dist/getDataFromOpenAPIDoc-D8w0QElH.mjs +0 -2011
  44. package/dist/i18n-B_brQh4X.d.mts +0 -38
  45. package/dist/i18n-D-FesqFb.mjs +0 -36
  46. package/dist/native-bindings-BTQGSGhU.mjs +0 -1480
  47. package/dist/native-rest-interceptor-CAWR8H5Y.mjs +0 -208
  48. package/dist/native-rest-interceptor-Cz6saoq5.d.mts +0 -46
  49. package/dist/native.d.mts +0 -3
  50. package/dist/native.mjs +0 -3
  51. package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
  52. package/dist/openapi-codegen-native-linux-x64.node +0 -0
  53. package/dist/openapi-codegen-native-win32-x64.node +0 -0
  54. package/dist/query.d.mts +0 -3
  55. package/dist/query.mjs +0 -3
  56. package/dist/queryConfig.context-CRJOgf19.d.mts +0 -22
  57. package/dist/queryConfig.context-CldQ5YL9.mjs +0 -34
  58. package/dist/rest-client-CQyFvqYC.d.mts +0 -55
  59. package/dist/rest-interceptor-D5NCNTm1.mjs +0 -115
  60. package/dist/rest-transport.types-DM5-qyOJ.d.mts +0 -66
  61. package/dist/rest-transport.types-DxitRtsB.mjs +0 -11
  62. package/dist/rest.d.mts +0 -2
  63. package/dist/rest.mjs +0 -2
  64. package/dist/rest.utils-rezWAIYL.d.mts +0 -10
  65. package/dist/router.context-EPlMBk3G.mjs +0 -21
  66. package/dist/useMutationEffects-DIdL8tlx.d.mts +0 -29
  67. package/dist/useMutationEffects-PB1fvKWM.mjs +0 -68
  68. package/dist/workspace.context-XWvQ_7Hg.mjs +0 -26
  69. package/dist/workspace.context-isVY9ves.d.mts +0 -23
@@ -1,24 +0,0 @@
1
- import { t as OpenApiRouter } from "./router.context-EPlMBk3G.mjs";
2
- import { t as AuthContext } from "./auth.context-COWO6ssl.mjs";
3
- import { useEffect, useState } from "react";
4
- //#region src/lib/auth/AuthGuard.tsx
5
- const AuthGuard = ({ type, redirectTo, children }) => {
6
- const { isAuthenticated, routes, loadingState } = AuthContext.useAuth();
7
- const { replace } = OpenApiRouter.useRouter();
8
- const [hasMounted, setHasMounted] = useState(false);
9
- useEffect(() => {
10
- setHasMounted(true);
11
- }, []);
12
- if (!hasMounted) return loadingState;
13
- if (type === "private" && !isAuthenticated) {
14
- replace(redirectTo || routes?.unauthenticated || "/");
15
- return null;
16
- }
17
- if (type === "public-only" && isAuthenticated) {
18
- replace(redirectTo || routes?.authenticated || "/");
19
- return null;
20
- }
21
- return children;
22
- };
23
- //#endregion
24
- export { AuthGuard as t };
package/dist/auth.d.mts DELETED
@@ -1,2 +0,0 @@
1
- import { n as AuthGuardProps, r as AuthContext, t as AuthGuard } from "./AuthGuard-GbtTDXs0.mjs";
2
- export { AuthContext, AuthGuard, type AuthGuardProps };
package/dist/auth.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { t as AuthContext } from "./auth.context-COWO6ssl.mjs";
2
- import { t as AuthGuard } from "./AuthGuard-qpAtHaBz.mjs";
3
- export { AuthContext, AuthGuard };
package/dist/axios.d.mts DELETED
@@ -1,2 +0,0 @@
1
- import { a as RestClient, i as Response, n as RequestConfig, o as RestInterceptor, r as RequestInfo, t as RestClient$1 } from "./rest-client-CQyFvqYC.mjs";
2
- export { type RestClient as IRestClient, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor };
package/dist/axios.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-D5NCNTm1.mjs";
2
- export { RestClient, RestInterceptor };
package/dist/config.d.mts DELETED
@@ -1,4 +0,0 @@
1
- import { i as resources, n as configureTranslations, r as ns, t as TranslateFunction } from "./i18n-B_brQh4X.mjs";
2
- import { n as useWorkspaceContext, r as OpenApiRouter, t as OpenApiWorkspaceContext } from "./workspace.context-isVY9ves.mjs";
3
- import { i as QueryModule, n as InvalidationMapFunc, r as OpenApiQueryConfig, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
4
- export { type InvalidationMap, type InvalidationMapFunc, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type TranslateFunction, configureTranslations, ns, resources, useWorkspaceContext };
package/dist/config.mjs DELETED
@@ -1,5 +0,0 @@
1
- import { i as resources, n as ns, t as configureTranslations } from "./i18n-D-FesqFb.mjs";
2
- import { t as OpenApiQueryConfig } from "./queryConfig.context-CldQ5YL9.mjs";
3
- import { t as OpenApiRouter } from "./router.context-EPlMBk3G.mjs";
4
- import { n as useWorkspaceContext, t as OpenApiWorkspaceContext } from "./workspace.context-XWvQ_7Hg.mjs";
5
- export { OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, configureTranslations, ns, resources, useWorkspaceContext };
package/dist/errors.d.mts DELETED
@@ -1,3 +0,0 @@
1
- import { a as ErrorHandler, c as SharedErrorHandler, i as ErrorEntry, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-LPEPQV1V.mjs";
2
- import { t as RestUtils } from "./rest.utils-rezWAIYL.mjs";
3
- export { ApplicationException, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, RestUtils, SharedErrorHandler };
package/dist/errors.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-BeydPL7s.mjs";
2
- export { ApplicationException, DomainErrorRegistry, ErrorHandler, RestUtils, SharedErrorHandler };
@@ -1,184 +0,0 @@
1
- import { D as getTagFileName, Wn as Profiler, a as writeGenerateFileData, dt as DEFAULT_GENERATE_OPTIONS, i as removeStaleGeneratedFiles, n as shouldUseNativeCodegen, o as deepMerge, r as getOutputFileName, t as compileNativeData } from "./native-bindings-BTQGSGhU.mjs";
2
- import fs from "fs";
3
- import path from "path";
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/native/generateFilesFromNativeOpenAPI.ts
19
- function generateFilesFromNativeOpenAPI(source, yaml, options) {
20
- if (!supportsCompleteNativeRender(options)) {
21
- if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
22
- return;
23
- }
24
- const nativeData = compileNativeData(source, yaml, JSON.stringify({
25
- ...options,
26
- nativeCompact: true
27
- })).data;
28
- if (!nativeData.renderedComplete) {
29
- if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
30
- return;
31
- }
32
- const files = [];
33
- const taggedRenderers = options.modelsOnly ? [["models", nativeData.renderedModels]] : [
34
- ["models", nativeData.renderedModels],
35
- ["endpoints", nativeData.renderedEndpoints],
36
- ["queries", nativeData.renderedQueries],
37
- ...options.acl ? [["acl", nativeData.renderedAcl]] : []
38
- ];
39
- for (const tag of nativeData.renderedTags) for (const [type, rendered] of taggedRenderers) {
40
- const content = rendered[tag];
41
- if (content) files.push(taggedFile(options, tag, type, content));
42
- }
43
- if (!options.modelsOnly) {
44
- if (options.acl && nativeData.renderedShared.appAcl) files.push(outputFile(options, "acl/app.ability.ts", nativeData.renderedShared.appAcl));
45
- if (options.mutationEffects && nativeData.renderedShared.queryModules) files.push(outputFile(options, "queryModules.ts", nativeData.renderedShared.queryModules));
46
- if (!options.restClientImportPath) files.push(outputFile(options, "app-rest-client.ts", `import { ${options.restClient === "native" ? "NativeRestClient" : "RestClient"} } from "@povio/openapi-codegen-cli${options.restClient === "native" ? "/native" : ""}";\n\nexport const AppRestClient = new ${options.restClient === "native" ? "NativeRestClient" : "RestClient"}({\n config: {\n baseURL: "${nativeData.baseUrl}"\n },\n});\n`));
47
- if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
48
- }
49
- return files;
50
- }
51
- function supportsCompleteNativeRender(options) {
52
- return options.splitByTags && (options.modelsInCommon && options.tsNamespaces || !options.modelsInCommon && !options.tsNamespaces) && !options.inlineEndpoints && !options.builderConfigs && (options.workspaceContext?.length ?? 0) === 0;
53
- }
54
- function taggedFile(options, tag, type, content) {
55
- return outputFile(options, getTagFileName({
56
- tag,
57
- type,
58
- options
59
- }), content);
60
- }
61
- function outputFile(options, fileName, content) {
62
- return {
63
- fileName: getOutputFileName({
64
- output: options.output,
65
- fileName
66
- }),
67
- content
68
- };
69
- }
70
- //#endregion
71
- //#region src/generators/run/generate.runner.ts
72
- async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
73
- const config = profiler.runSync("config.resolve", () => resolveConfig({
74
- fileConfig,
75
- params: params ?? {}
76
- }));
77
- const useNative = shouldUseNativeCodegen();
78
- const isJson = path.extname(new URL(config.input, "file://").pathname).toLowerCase() === ".json";
79
- const useRawNativeInput = useNative && (isJson || typeof Bun === "undefined");
80
- let nativeInput = useRawNativeInput ? await getRawOpenApiSource(config.input, profiler) : await getOpenApiSource(config.input, profiler);
81
- if (useNative && !useRawNativeInput) {
82
- const document = "document" in nativeInput ? nativeInput.document : void 0;
83
- nativeInput = {
84
- ...nativeInput,
85
- source: profiler.runSync("openapi.serialize", () => JSON.stringify(document)),
86
- yaml: false
87
- };
88
- }
89
- const openApiDoc = "document" in nativeInput ? nativeInput.document : {};
90
- const outputExists = fs.existsSync(config.output);
91
- const filesData = await profiler.runAsync("generate.total", async () => {
92
- if (useNative) {
93
- const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
94
- if (nativeFiles) return nativeFiles;
95
- }
96
- const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc--ufinTug.mjs").then((n) => n.n);
97
- return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
98
- source: nativeInput.source,
99
- yaml: nativeInput.yaml
100
- });
101
- });
102
- if (config.clearOutput) profiler.runSync("files.removeStaleGenerated", () => {
103
- removeStaleGeneratedFiles({
104
- output: config.output,
105
- filesData,
106
- options: config
107
- });
108
- });
109
- await profiler.runAsync("files.write", async () => {
110
- await writeGenerateFileData(filesData, {
111
- formatGeneratedFile,
112
- skipExistingCheck: !outputExists
113
- });
114
- });
115
- return {
116
- skipped: false,
117
- config,
118
- stats: getGenerateStats(filesData, config)
119
- };
120
- }
121
- async function getOpenApiDoc(input, profiler = new Profiler(false)) {
122
- return (await getOpenApiSource(input, profiler)).document;
123
- }
124
- async function getOpenApiSource(input, profiler = new Profiler(false)) {
125
- const raw = await getRawOpenApiSource(input, profiler);
126
- const { source } = raw;
127
- const document = await profiler.runAsync("openapi.parse", () => parseOpenApiSource(input, source));
128
- return {
129
- ...raw,
130
- document
131
- };
132
- }
133
- async function getRawOpenApiSource(input, profiler = new Profiler(false)) {
134
- return {
135
- source: await profiler.runAsync("openapi.read", () => readOpenApiSource(input)),
136
- yaml: path.extname(new URL(input, "file://").pathname).toLowerCase() !== ".json"
137
- };
138
- }
139
- async function readOpenApiSource(input) {
140
- if (/^https?:\/\//i.test(input)) {
141
- const response = await fetch(input);
142
- if (!response.ok) throw new Error(`Unable to load OpenAPI document: ${response.status} ${response.statusText}`);
143
- return response.text();
144
- }
145
- return fs.promises.readFile(input, "utf-8");
146
- }
147
- async function parseOpenApiSource(input, source) {
148
- try {
149
- return JSON.parse(source.charCodeAt(0) === 65279 ? source.slice(1) : source);
150
- } catch (error) {
151
- if (path.extname(new URL(input, "file://").pathname).toLowerCase() === ".json") throw error;
152
- if (typeof Bun !== "undefined") return Bun.YAML.parse(source);
153
- const { parse } = await import("yaml");
154
- return parse(source);
155
- }
156
- }
157
- function getGenerateStats(filesData, config) {
158
- const generatedFilesCount = filesData.length;
159
- if (generatedFilesCount === 0) return {
160
- generatedFilesCount,
161
- generatedModulesCount: 0
162
- };
163
- if (!config.splitByTags) return {
164
- generatedFilesCount,
165
- generatedModulesCount: 1
166
- };
167
- const moduleSuffixes = new Set(Object.values(config.configs).map((generateConfig) => generateConfig.outputFileNameSuffix).filter(Boolean));
168
- const modules = /* @__PURE__ */ new Set();
169
- for (const file of filesData) {
170
- const segments = path.relative(config.output, file.fileName).split(path.sep).filter(Boolean);
171
- if (segments.length < 2) continue;
172
- const moduleName = segments[0];
173
- const fileName = segments[segments.length - 1];
174
- if (!fileName.startsWith(`${moduleName}.`)) continue;
175
- const suffix = fileName.slice(moduleName.length + 1).replace(/\.tsx?$/, "");
176
- if (moduleSuffixes.has(suffix)) modules.add(moduleName);
177
- }
178
- return {
179
- generatedFilesCount,
180
- generatedModulesCount: modules.size
181
- };
182
- }
183
- //#endregion
184
- export { runGenerate as n, resolveConfig as r, getOpenApiDoc as t };