@povio/openapi-codegen-cli 3.2.2 → 3.2.4-rc.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 +33 -7
- package/dist/acl.mjs +1 -1
- package/dist/axios.mjs +1 -1
- package/dist/{error-handling-BeydPL7s.mjs → error-handling-uS0DgYUR.mjs} +2 -2
- package/dist/errors.d.mts +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{generate.runner-BD9BbYIx.mjs → generate.runner-C3n76bDK.mjs} +15 -9
- package/dist/{generate.utils-BqlgVd-i.cjs → generate.utils-wn-hR9hY.cjs} +13 -12
- package/dist/{generateCodeFromOpenAPIDoc-idp1RVDa.mjs → generateCodeFromOpenAPIDoc-eP5cooBd.mjs} +6 -6
- package/dist/{generateCodeFromOpenAPIDoc-CkVgg5Zy.cjs → generateCodeFromOpenAPIDoc-ejdqJZ2M.cjs} +5 -5
- package/dist/generator.mjs +3 -3
- package/dist/{getDataFromOpenAPIDoc-Cyrm3VKA.mjs → getDataFromOpenAPIDoc-Cya5Q-2W.mjs} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/metro.cjs +8 -3
- package/dist/metro.mjs +1 -1
- 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-BZH4V6rq.mjs → openapi-codegen.runner-kQNEh1Mb.mjs} +1 -1
- package/dist/{rest-interceptor-D5NCNTm1.mjs → rest-interceptor-Dm9DFErh.mjs} +1 -1
- package/dist/rest.utils-DpiFIdhF.d.mts +9 -0
- package/dist/sh.mjs +3 -3
- package/dist/vite.mjs +1 -1
- package/dist/zod.mjs +1 -1
- package/package.json +2 -2
- package/dist/rest.utils-rezWAIYL.d.mts +0 -10
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
**NOTE:** Version 1+ requires zod v4 and is not compatible with zod v3.
|
|
6
6
|
|
|
7
|
-
**NOTE:**
|
|
7
|
+
**NOTE:** The package includes supporting classes, types, components, and auth utilities. Zod is a required peer dependency. Axios, @tanstack/react-query, react, i18next, @casl/ability, @casl/react, and Vite are optional peers; install the ones used by your chosen features.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Axios is required when using the Axios transport (the default) or the `/axios` entry point. Projects using the native transport can omit Axios: generate with `--restClient native` and import `NativeRestClient` from `@povio/openapi-codegen-cli/native`. The root exports remain available for compatibility and support tree-shaking in consumer bundles. For direct runtime imports without bundling, use `/native` and `/errors` to avoid loading the Axios client. The `/axios` entry point is also available for Axios-specific imports. CLI-only usage and the `/generator`, `/tiny`, `/vite`, and `/metro` entry points do not require Axios.
|
|
10
|
+
|
|
11
|
+
Use this tool to generate code (Zod schemas, TypeScript types, API definitions, and React queries) from an OpenAPI v3 specification. API definitions use a REST client wrapper with either Axios or the native transport. React queries are generated in alignment with our code standards, without the need for explicit types.
|
|
10
12
|
|
|
11
13
|
The tool partially leverages code from [openapi-zod-client](https://github.com/astahmer/openapi-zod-client) repository.
|
|
12
14
|
|
|
@@ -33,7 +35,7 @@ The CLI supports TypeScript configuration files to simplify command execution an
|
|
|
33
35
|
Create an `openapi-codegen.config.ts` file:
|
|
34
36
|
|
|
35
37
|
```typescript
|
|
36
|
-
import { OpenAPICodegenConfig } from "@povio/openapi-codegen-cli";
|
|
38
|
+
import type { OpenAPICodegenConfig } from "@povio/openapi-codegen-cli";
|
|
37
39
|
|
|
38
40
|
const config: OpenAPICodegenConfig = {
|
|
39
41
|
input: "http://localhost:4000/docs-json/",
|
|
@@ -159,6 +161,10 @@ Set `OPENAPI_CODEGEN_NATIVE=0` to force the TypeScript path, or `OPENAPI_CODEGEN
|
|
|
159
161
|
|
|
160
162
|
Release packages include native binaries for Linux x64, macOS arm64, and Windows x64. Build a binary for the current platform with `bun run build:native`.
|
|
161
163
|
|
|
164
|
+
Run `bun run test:parity` after building the addon to compare every generated file across 64 layout combinations and representative values for every other renderer option. The matrix uses both `test/petstore.yaml` and `test/configuration.yaml`, exercises complete native and hybrid native generation, and loads generated models to check runtime references. The contradictory combination `modelsInCommon: true` with `modelsInModules: true` is rejected explicitly. Arbitrary strings and lists are covered by representative cases, not every possible value.
|
|
165
|
+
|
|
166
|
+
The separate Renderer parity workflow generates this matrix with JavaScript and native on Linux and macOS, then compares exact file lists and SHA-256 hashes. Artifacts include route reports identifying complete versus hybrid native generation. Runner integration tests cover input/output, stale-file cleanup, and unchanged files; `incremental` is currently retained as a compatibility option and does not change the writer's unchanged-file optimization.
|
|
167
|
+
|
|
162
168
|
## Common Issues
|
|
163
169
|
|
|
164
170
|
### App REST Client Interceptors
|
|
@@ -206,7 +212,7 @@ directly in query callbacks, error boundaries, or their own normalization layer.
|
|
|
206
212
|
In order to add interceptors to the used REST client, you must create your own instance of a RestClient and pass your implemented interceptors into the constructor. Make sure to set `restClientImportPath` in your openapi generation configuration too.
|
|
207
213
|
|
|
208
214
|
```ts
|
|
209
|
-
import { RestInterceptor } from "@povio/openapi-codegen-cli";
|
|
215
|
+
import { RestInterceptor } from "@povio/openapi-codegen-cli/axios";
|
|
210
216
|
|
|
211
217
|
import { ACCESS_TOKEN_KEY } from "@/config/jwt.config";
|
|
212
218
|
|
|
@@ -223,7 +229,7 @@ export const AuthorizationHeaderInterceptor = new RestInterceptor((client) => {
|
|
|
223
229
|
```
|
|
224
230
|
|
|
225
231
|
```ts
|
|
226
|
-
import { RestClient } from "@povio/openapi-codegen-cli";
|
|
232
|
+
import { RestClient } from "@povio/openapi-codegen-cli/axios";
|
|
227
233
|
|
|
228
234
|
import { AuthorizationHeaderInterceptor } from "@/clients/rest/interceptors/authorization-header.interceptor";
|
|
229
235
|
import { AppConfig } from "@/config/app.config";
|
|
@@ -252,7 +258,8 @@ export default config;
|
|
|
252
258
|
Set `mutationDefaultOnError: true` in codegen config (or pass `--mutationDefaultOnError`) to let generated mutation hooks fall back to `OpenApiQueryConfig.Provider` when a mutation call does not define its own `onError`.
|
|
253
259
|
|
|
254
260
|
```tsx
|
|
255
|
-
import { ErrorHandler
|
|
261
|
+
import { ErrorHandler } from "@povio/openapi-codegen-cli/errors";
|
|
262
|
+
import { OpenApiQueryConfig } from "@povio/openapi-codegen-cli/query";
|
|
256
263
|
|
|
257
264
|
<OpenApiQueryConfig.Provider
|
|
258
265
|
onError={(error) => {
|
|
@@ -278,7 +285,7 @@ Use `OpenApiQueryConfig.Provider` to allow generated GET query hooks to return i
|
|
|
278
285
|
Set `workspaceContext` to a list of param names in codegen config (or pass `--workspaceContext officeId,projectId`) and wrap your app subtree with `OpenApiWorkspaceContext.Provider` if generated hooks frequently repeat workspace-scoped params.
|
|
279
286
|
|
|
280
287
|
```tsx
|
|
281
|
-
import { OpenApiWorkspaceContext } from "@povio/openapi-codegen-cli";
|
|
288
|
+
import { OpenApiWorkspaceContext } from "@povio/openapi-codegen-cli/config";
|
|
282
289
|
// openapi-codegen.config.ts -> { workspaceContext: ["officeId", "projectId"] }
|
|
283
290
|
|
|
284
291
|
<OpenApiWorkspaceContext.Provider values={{ officeId: "office_123" }}>
|
|
@@ -550,3 +557,22 @@ export class JSONDto {
|
|
|
550
557
|
nested: NestedDto;
|
|
551
558
|
}
|
|
552
559
|
```
|
|
560
|
+
|
|
561
|
+
### Runtime import paths
|
|
562
|
+
|
|
563
|
+
Use package subpaths for runtime imports. Pure `import type` imports may use the package root.
|
|
564
|
+
|
|
565
|
+
| Runtime exports | Subpath |
|
|
566
|
+
| --- | --- |
|
|
567
|
+
| `AuthContext`, `AuthGuard` | `/auth` |
|
|
568
|
+
| `AbilityContext`, `useAclCheck`, `Can`, `createAclGuard` | `/acl` |
|
|
569
|
+
| `ErrorHandler`, `SharedErrorHandler`, `ApplicationException`, `DomainErrorRegistry` | `/errors` |
|
|
570
|
+
| `useMutationEffects`, `OpenApiQueryConfig` | `/query` |
|
|
571
|
+
| `OpenApiRouter`, `OpenApiWorkspaceContext`, `useWorkspaceContext`, translation configuration | `/config` |
|
|
572
|
+
| `ZodExtended` | `/zod` |
|
|
573
|
+
| `HttpError`, transport types | `/rest` |
|
|
574
|
+
| `NativeRestClient` | `/native` |
|
|
575
|
+
| `RestClient`, `RestInterceptor` (Axios transport) | `/axios` |
|
|
576
|
+
|
|
577
|
+
For example: `import { AuthContext, AuthGuard } from "@povio/openapi-codegen-cli/auth"`.
|
|
578
|
+
Custom application helpers should import error helpers from `/errors`, `AbilityContext` from `/acl`, and mutation effects from `/query`.
|
package/dist/acl.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SharedErrorHandler } from "./error-handling-
|
|
1
|
+
import { i as SharedErrorHandler } from "./error-handling-uS0DgYUR.mjs";
|
|
2
2
|
import { t as OpenApiRouter } from "./router.context-EPlMBk3G.mjs";
|
|
3
3
|
import { t as AuthContext } from "./auth.context-COWO6ssl.mjs";
|
|
4
4
|
import { createContext, useCallback, useMemo } from "react";
|
package/dist/axios.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-
|
|
1
|
+
import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-Dm9DFErh.mjs";
|
|
2
2
|
export { RestClient, RestInterceptor };
|
|
@@ -37,8 +37,8 @@ let RestUtils;
|
|
|
37
37
|
return null;
|
|
38
38
|
};
|
|
39
39
|
_RestUtils.extractContentDispositionFilename = (headers) => {
|
|
40
|
-
const contentDisposition = headers["content-disposition"];
|
|
41
|
-
return contentDisposition ? /filename=["']?([^"';]+)/i.exec(contentDisposition)?.[1] : void 0;
|
|
40
|
+
const contentDisposition = headers instanceof Headers ? headers.get("content-disposition") : headers["content-disposition"];
|
|
41
|
+
return typeof contentDisposition === "string" ? /filename=["']?([^"';]+)/i.exec(contentDisposition)?.[1] : void 0;
|
|
42
42
|
};
|
|
43
43
|
})(RestUtils || (RestUtils = {}));
|
|
44
44
|
//#endregion
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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-
|
|
2
|
+
import { t as RestUtils } from "./rest.utils-DpiFIdhF.mjs";
|
|
3
3
|
export { ApplicationException, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, RestUtils, SharedErrorHandler };
|
package/dist/errors.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-
|
|
1
|
+
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-uS0DgYUR.mjs";
|
|
2
2
|
export { ApplicationException, DomainErrorRegistry, ErrorHandler, RestUtils, SharedErrorHandler };
|
|
@@ -367,6 +367,7 @@ const getNamespaceName = ({ type, tag, options }) => `${capitalize(tag)}${option
|
|
|
367
367
|
//#endregion
|
|
368
368
|
//#region src/generators/const/package.const.ts
|
|
369
369
|
const PACKAGE_IMPORT_PATH = "@povio/openapi-codegen-cli";
|
|
370
|
+
const AXIOS_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/axios`;
|
|
370
371
|
const NATIVE_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/native`;
|
|
371
372
|
const REST_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/rest`;
|
|
372
373
|
const QUERY_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/query`;
|
|
@@ -617,10 +618,10 @@ function getSchemaDescriptions(schemaObj) {
|
|
|
617
618
|
}
|
|
618
619
|
//#endregion
|
|
619
620
|
//#region src/generators/utils/generate/generate.zod.utils.ts
|
|
620
|
-
const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(zodSchemaName, options.schemaSuffix);
|
|
621
|
+
const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(isNamedZodSchema(zodSchemaName) ? zodSchemaName.split(".")[0] : zodSchemaName, options.schemaSuffix);
|
|
621
622
|
const getImportedZodSchemaName = (resolver, zodSchemaName, namespaceTag) => {
|
|
622
623
|
if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName;
|
|
623
|
-
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
|
|
624
|
+
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName.split(".")[0], namespaceTag);
|
|
624
625
|
return `${resolver.options.tsNamespaces ? `${getNamespaceName({
|
|
625
626
|
type: "models",
|
|
626
627
|
tag,
|
|
@@ -633,7 +634,7 @@ function getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag) {
|
|
|
633
634
|
}
|
|
634
635
|
const getImportedZodSchemaInferedTypeName = (resolver, zodSchemaName, currentTag, namespaceTag) => {
|
|
635
636
|
if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName === "z.void()" ? "void" : zodSchemaName;
|
|
636
|
-
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
|
|
637
|
+
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName.split(".")[0], namespaceTag);
|
|
637
638
|
return `${resolver.options.tsNamespaces && (Boolean(namespaceTag) || tag !== currentTag) ? `${getNamespaceName({
|
|
638
639
|
type: "models",
|
|
639
640
|
tag,
|
|
@@ -834,13 +835,13 @@ const getImportedInfiniteQueryName = (endpoint, options) => {
|
|
|
834
835
|
//#region src/generators/utils/generate/generate.imports.utils.ts
|
|
835
836
|
function getModelsImports({ resolver, tag, zodSchemas = [], zodSchemasAsTypes = [] }) {
|
|
836
837
|
const type = "models";
|
|
837
|
-
const getTag = (zodSchemaName) => resolver.getTagByZodSchemaName(zodSchemaName);
|
|
838
|
+
const getTag = (zodSchemaName) => resolver.getTagByZodSchemaName(zodSchemaName.split(".")[0]);
|
|
838
839
|
const zodSchemaImports = getImports({
|
|
839
840
|
type,
|
|
840
841
|
tag,
|
|
841
842
|
entities: zodSchemas,
|
|
842
843
|
getTag,
|
|
843
|
-
getEntityName: (zodSchema) => zodSchema,
|
|
844
|
+
getEntityName: (zodSchema) => zodSchema.split(".")[0],
|
|
844
845
|
options: resolver.options
|
|
845
846
|
});
|
|
846
847
|
const zodSchemaTypeImports = getImports({
|
|
@@ -978,7 +979,7 @@ function getQueryModulesImportPath(options) {
|
|
|
978
979
|
return `${getImportPath(options)}${QUERY_MODULES_FILE.fileName}`;
|
|
979
980
|
}
|
|
980
981
|
function getQueryTypesImportPath(options) {
|
|
981
|
-
return options.queryTypesImportPath;
|
|
982
|
+
return options.queryTypesImportPath === "@povio/openapi-codegen-cli" ? QUERY_PACKAGE_IMPORT_PATH : options.queryTypesImportPath;
|
|
982
983
|
}
|
|
983
984
|
//#endregion
|
|
984
985
|
//#region src/generators/utils/ts.utils.ts
|
|
@@ -1446,6 +1447,7 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
1446
1447
|
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(","),
|
|
1447
1448
|
workspaceContext: workspaceContext?.split(",")
|
|
1448
1449
|
});
|
|
1450
|
+
if (resolvedConfig.modelsInCommon && resolvedConfig.modelsInModules) throw new Error("modelsInCommon and modelsInModules cannot both be enabled");
|
|
1449
1451
|
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
1450
1452
|
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
1451
1453
|
return resolvedConfig;
|
|
@@ -1493,6 +1495,10 @@ function compileNativeData(source, yaml, optionsJson) {
|
|
|
1493
1495
|
//#endregion
|
|
1494
1496
|
//#region src/native/generateFilesFromNativeOpenAPI.ts
|
|
1495
1497
|
function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
1498
|
+
if (options.standalone && options.importPath === "ts") options = {
|
|
1499
|
+
...options,
|
|
1500
|
+
importPath: "relative"
|
|
1501
|
+
};
|
|
1496
1502
|
if (!supportsCompleteNativeRender(options)) {
|
|
1497
1503
|
if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
|
|
1498
1504
|
return;
|
|
@@ -1519,7 +1525,7 @@ function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
|
1519
1525
|
if (!options.modelsOnly) {
|
|
1520
1526
|
if (options.acl && nativeData.renderedShared.appAcl) files.push(outputFile(options, "acl/app.ability.ts", nativeData.renderedShared.appAcl));
|
|
1521
1527
|
if (options.mutationEffects && nativeData.renderedShared.queryModules) files.push(outputFile(options, "queryModules.ts", nativeData.renderedShared.queryModules));
|
|
1522
|
-
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`));
|
|
1528
|
+
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" : "/axios"}";\n\nexport const AppRestClient = new ${options.restClient === "native" ? "NativeRestClient" : "RestClient"}({\n config: {\n baseURL: "${nativeData.baseUrl}"\n },\n});\n`));
|
|
1523
1529
|
if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
|
|
1524
1530
|
}
|
|
1525
1531
|
return files;
|
|
@@ -1569,7 +1575,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
|
|
|
1569
1575
|
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
1570
1576
|
if (nativeFiles) return nativeFiles;
|
|
1571
1577
|
}
|
|
1572
|
-
const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-
|
|
1578
|
+
const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-eP5cooBd.mjs").then((n) => n.n);
|
|
1573
1579
|
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
1574
1580
|
source: nativeInput.source,
|
|
1575
1581
|
yaml: nativeInput.yaml
|
|
@@ -1657,4 +1663,4 @@ function getGenerateStats(filesData, config) {
|
|
|
1657
1663
|
};
|
|
1658
1664
|
}
|
|
1659
1665
|
//#endregion
|
|
1660
|
-
export { getImportedAbilityFunctionName as $, isPrimitiveType as $t, getEndpointsImports as A, NATIVE_RESPONSE_TYPE as An, APP_REST_CLIENT_NAME as At, getPrefetchInfiniteQueryName as B, getMostCommonAdjacentCombinationSplit as Bn,
|
|
1666
|
+
export { getImportedAbilityFunctionName as $, isPrimitiveType as $t, getEndpointsImports as A, NATIVE_RESPONSE_TYPE as An, APP_REST_CLIENT_NAME as At, getPrefetchInfiniteQueryName as B, getMostCommonAdjacentCombinationSplit as Bn, NATIVE_PACKAGE_IMPORT_PATH as Bt, getAppRestClientImportPath as C, ZOD_IMPORT as Cn, getParamZodSchemaName as Ct, getTagFileName as D, AXIOS_REQUEST_CONFIG_TYPE as Dn, isEnumZodSchema as Dt, getQueryTypesImportPath as E, AXIOS_REQUEST_CONFIG_NAME as En, getZodSchemaOperationName as Et, mergeImports as F, isTagIncluded as Fn, QUERY_MODULE_ENUM as Ft, getAbilityConditionType as G, getParameterEnumNames as Gt, getQueryName as H, removeWord as Hn, getNamespaceName as Ht, getImportedInfiniteQueryName as I, shouldInlineEndpointsForTag as In, QUERY_OPTIONS_TYPES as It, getAbilityFunctionName as J, isErrorStatus as Jt, getAbilityConditionsTypes as K, getSchemaNameByRef as Kt, getImportedQueryName as L, camelToSpaceSeparated as Ln, ZOD_EXTENDED as Lt, getInfiniteQueriesImports as M, formatTag as Mn, DOMAIN_ERRORS_FILE as Mt, getModelsImports as N, getEndpointTag as Nn, MUTATION_EFFECTS as Nt, getTagImportPath as O, BODY_PARAMETER_NAME as On, isNamedZodSchema as Ot, getQueriesImports as P, getOperationTag as Pn, QUERY_MODULES_FILE as Pt, getAppAbilitiesType as Q, isPathExcluded as Qt, getInfiniteQueryName as R, capitalize as Rn, AXIOS_PACKAGE_IMPORT_PATH as Rt, getTsTypeBase as S, VOID_SCHEMA as Sn, getEnumZodSchemaName as St, getQueryModulesImportPath as T, AXIOS_IMPORT as Tn, getZodSchemaName as Tt, getQueryOptionsName as U, snakeToCamel as Un, autocorrectRef as Ut, getPrefetchQueryName as V, kebabToCamel as Vn, REST_PACKAGE_IMPORT_PATH as Vt, getAbilityAction as W, Profiler as Wn, escapeControlCharacters as Wt, getAbilitySubjectTypes as X, isMediaTypeAllowed as Xt, getAbilitySubject as Y, isMainResponseStatus as Yt, getAclData as Z, isParamMediaTypeAllowed as Zt, hasEndpointConfig as _, INT_SCHEMA as _n, isReadAllEndpoint as _t, resolveConfig as a, wrapWithQuotesIfNeeded as an, getZodSchemaInferedTypeName as at, requiresBody as b, URL_SCHEMA as bn, invalidVariableNameCharactersToCamel as bt, getDestructuredVariables as c, isReferenceObject as cn, getSchemaDescriptions as ct, isQuery as d, ALLOWED_PATH_IN as dn, DEFAULT_GENERATE_OPTIONS as dt, isSortingParameterObject as en, hasAbilityConditions as et, getEndpointBody as f, ANY_SCHEMA as fn, getPathSegments as ft, getImportedEndpointName as g, ENUM_SCHEMA as gn, isPathSegmentParam as gt, getEndpointPath as h, EMAIL_SCHEMA as hn, isDeleteEndpoint as ht, shouldUseNativeCodegen as i, unwrapQuotesIfNeeded as in, getZodSchemaDescription as it, getImportPath as j, getRequestConfigTypeName as jn, BUILDERS_UTILS as jt, getAclImports as k, JSON_APPLICATION_FORMAT as kn, APP_REST_CLIENT_FILE as kt, isInfiniteQuery as l, isSchemaObject as ln, iterateSchema as lt, getEndpointName as m, DATETIME_SCHEMA as mn, isCreateEndpoint as mt, runGenerate as n, pathToVariableName as nn, getImportedZodSchemaInferedTypeName as nt, getOutputFileName as o, inferRequiredSchema as on, getZodSchemaPropertyDescriptions as ot, getEndpointConfig as p, BLOB_SCHEMA as pn, isBulkDeleteEndpoint as pt, getAbilityDescription as q, getSchemaRef as qt, compileNativeData as r, replaceHyphenatedPath as rn, getImportedZodSchemaName as rt, pick as s, isArraySchemaObject as sn, getZodSchemaType as st, getOpenApiDoc as t, pathParamToVariableName as tn, renderAclCheckCall as tt, isMutation as u, ALLOWED_METHODS as un, getUniqueArray as ut, mapEndpointParamsToFunctionParams as v, NUMBER_SCHEMA as vn, isReadEndpoint as vt, getFileNameWithExtension as w, AXIOS_DEFAULT_IMPORT_NAME as wn, getResponseZodSchemaName as wt, getSchemaTsMetaType as x, UUID_SCHEMA as xn, getBodyZodSchemaName as xt, renderMediaUploadMutationBody as y, STRING_SCHEMA as yn, isUpdateEndpoint as yt, getInfiniteQueryOptionsName as z, decapitalize as zn, CONFIG_PACKAGE_IMPORT_PATH as zt };
|
|
@@ -33,6 +33,7 @@ node_path = __toESM(node_path, 1);
|
|
|
33
33
|
let openapi_types = require("openapi-types");
|
|
34
34
|
//#region src/generators/const/package.const.ts
|
|
35
35
|
const PACKAGE_IMPORT_PATH = "@povio/openapi-codegen-cli";
|
|
36
|
+
const AXIOS_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/axios`;
|
|
36
37
|
const NATIVE_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/native`;
|
|
37
38
|
const REST_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/rest`;
|
|
38
39
|
const QUERY_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/query`;
|
|
@@ -790,10 +791,10 @@ function getSchemaDescriptions(schemaObj) {
|
|
|
790
791
|
}
|
|
791
792
|
//#endregion
|
|
792
793
|
//#region src/generators/utils/generate/generate.zod.utils.ts
|
|
793
|
-
const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(zodSchemaName, options.schemaSuffix);
|
|
794
|
+
const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(isNamedZodSchema(zodSchemaName) ? zodSchemaName.split(".")[0] : zodSchemaName, options.schemaSuffix);
|
|
794
795
|
const getImportedZodSchemaName = (resolver, zodSchemaName, namespaceTag) => {
|
|
795
796
|
if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName;
|
|
796
|
-
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
|
|
797
|
+
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName.split(".")[0], namespaceTag);
|
|
797
798
|
return `${resolver.options.tsNamespaces ? `${getNamespaceName({
|
|
798
799
|
type: "models",
|
|
799
800
|
tag,
|
|
@@ -806,7 +807,7 @@ function getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag) {
|
|
|
806
807
|
}
|
|
807
808
|
const getImportedZodSchemaInferedTypeName = (resolver, zodSchemaName, currentTag, namespaceTag) => {
|
|
808
809
|
if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName === "z.void()" ? "void" : zodSchemaName;
|
|
809
|
-
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
|
|
810
|
+
const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName.split(".")[0], namespaceTag);
|
|
810
811
|
return `${resolver.options.tsNamespaces && (Boolean(namespaceTag) || tag !== currentTag) ? `${getNamespaceName({
|
|
811
812
|
type: "models",
|
|
812
813
|
tag,
|
|
@@ -1212,13 +1213,13 @@ const getImportedInfiniteQueryName = (endpoint, options) => {
|
|
|
1212
1213
|
//#region src/generators/utils/generate/generate.imports.utils.ts
|
|
1213
1214
|
function getModelsImports({ resolver, tag, zodSchemas = [], zodSchemasAsTypes = [] }) {
|
|
1214
1215
|
const type = "models";
|
|
1215
|
-
const getTag = (zodSchemaName) => resolver.getTagByZodSchemaName(zodSchemaName);
|
|
1216
|
+
const getTag = (zodSchemaName) => resolver.getTagByZodSchemaName(zodSchemaName.split(".")[0]);
|
|
1216
1217
|
const zodSchemaImports = getImports({
|
|
1217
1218
|
type,
|
|
1218
1219
|
tag,
|
|
1219
1220
|
entities: zodSchemas,
|
|
1220
1221
|
getTag,
|
|
1221
|
-
getEntityName: (zodSchema) => zodSchema,
|
|
1222
|
+
getEntityName: (zodSchema) => zodSchema.split(".")[0],
|
|
1222
1223
|
options: resolver.options
|
|
1223
1224
|
});
|
|
1224
1225
|
const zodSchemaTypeImports = getImports({
|
|
@@ -1356,7 +1357,7 @@ function getQueryModulesImportPath(options) {
|
|
|
1356
1357
|
return `${getImportPath(options)}${QUERY_MODULES_FILE.fileName}`;
|
|
1357
1358
|
}
|
|
1358
1359
|
function getQueryTypesImportPath(options) {
|
|
1359
|
-
return options.queryTypesImportPath;
|
|
1360
|
+
return options.queryTypesImportPath === "@povio/openapi-codegen-cli" ? QUERY_PACKAGE_IMPORT_PATH : options.queryTypesImportPath;
|
|
1360
1361
|
}
|
|
1361
1362
|
//#endregion
|
|
1362
1363
|
Object.defineProperty(exports, "ALLOWED_METHODS", {
|
|
@@ -1401,6 +1402,12 @@ Object.defineProperty(exports, "AXIOS_IMPORT", {
|
|
|
1401
1402
|
return AXIOS_IMPORT;
|
|
1402
1403
|
}
|
|
1403
1404
|
});
|
|
1405
|
+
Object.defineProperty(exports, "AXIOS_PACKAGE_IMPORT_PATH", {
|
|
1406
|
+
enumerable: true,
|
|
1407
|
+
get: function() {
|
|
1408
|
+
return AXIOS_PACKAGE_IMPORT_PATH;
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1404
1411
|
Object.defineProperty(exports, "AXIOS_REQUEST_CONFIG_NAME", {
|
|
1405
1412
|
enumerable: true,
|
|
1406
1413
|
get: function() {
|
|
@@ -1503,12 +1510,6 @@ Object.defineProperty(exports, "NUMBER_SCHEMA", {
|
|
|
1503
1510
|
return NUMBER_SCHEMA;
|
|
1504
1511
|
}
|
|
1505
1512
|
});
|
|
1506
|
-
Object.defineProperty(exports, "PACKAGE_IMPORT_PATH", {
|
|
1507
|
-
enumerable: true,
|
|
1508
|
-
get: function() {
|
|
1509
|
-
return PACKAGE_IMPORT_PATH;
|
|
1510
|
-
}
|
|
1511
|
-
});
|
|
1512
1513
|
Object.defineProperty(exports, "Profiler", {
|
|
1513
1514
|
enumerable: true,
|
|
1514
1515
|
get: function() {
|
package/dist/{generateCodeFromOpenAPIDoc-idp1RVDa.mjs → generateCodeFromOpenAPIDoc-eP5cooBd.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
2
|
-
import { $ as getImportedAbilityFunctionName, A as getEndpointsImports, An as NATIVE_RESPONSE_TYPE, At as APP_REST_CLIENT_NAME, B as getPrefetchInfiniteQueryName, Bt as
|
|
1
|
+
import { r as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-Cya5Q-2W.mjs";
|
|
2
|
+
import { $ as getImportedAbilityFunctionName, A as getEndpointsImports, An as NATIVE_RESPONSE_TYPE, At as APP_REST_CLIENT_NAME, B as getPrefetchInfiniteQueryName, Bt as NATIVE_PACKAGE_IMPORT_PATH, C as getAppRestClientImportPath, Cn as ZOD_IMPORT, D as getTagFileName, Dn as AXIOS_REQUEST_CONFIG_TYPE, Dt as isEnumZodSchema, E as getQueryTypesImportPath, En as AXIOS_REQUEST_CONFIG_NAME, F as mergeImports, Ft as QUERY_MODULE_ENUM, G as getAbilityConditionType, H as getQueryName, Ht as getNamespaceName, I as getImportedInfiniteQueryName, In as shouldInlineEndpointsForTag, It as QUERY_OPTIONS_TYPES, J as getAbilityFunctionName, K as getAbilityConditionsTypes, L as getImportedQueryName, Ln as camelToSpaceSeparated, Lt as ZOD_EXTENDED, M as getInfiniteQueriesImports, Mt as DOMAIN_ERRORS_FILE, N as getModelsImports, Nn as getEndpointTag, Nt as MUTATION_EFFECTS, O as getTagImportPath, Ot as isNamedZodSchema, P as getQueriesImports, Pt as QUERY_MODULES_FILE, Q as getAppAbilitiesType, R as getInfiniteQueryName, Rn as capitalize, Rt as AXIOS_PACKAGE_IMPORT_PATH, T as getQueryModulesImportPath, Tn as AXIOS_IMPORT, U as getQueryOptionsName, V as getPrefetchQueryName, Vn as kebabToCamel, Vt as REST_PACKAGE_IMPORT_PATH, W as getAbilityAction, Wn as Profiler, X as getAbilitySubjectTypes, Y as getAbilitySubject, Z as getAclData, Zt as isParamMediaTypeAllowed, _ as hasEndpointConfig, _t as isReadAllEndpoint, an as wrapWithQuotesIfNeeded, at as getZodSchemaInferedTypeName, b as requiresBody, bt as invalidVariableNameCharactersToCamel, c as getDestructuredVariables, cn as isReferenceObject, ct as getSchemaDescriptions, d as isQuery, dt as DEFAULT_GENERATE_OPTIONS, et as hasAbilityConditions, f as getEndpointBody, fn as ANY_SCHEMA, ft as getPathSegments, g as getImportedEndpointName, gt as isPathSegmentParam, h as getEndpointPath, ht as isDeleteEndpoint, i as shouldUseNativeCodegen, it as getZodSchemaDescription, j as getImportPath, jn as getRequestConfigTypeName, jt as BUILDERS_UTILS, k as getAclImports, kn as JSON_APPLICATION_FORMAT, kt as APP_REST_CLIENT_FILE, l as isInfiniteQuery, ln as isSchemaObject, m as getEndpointName, mt as isCreateEndpoint, nt as getImportedZodSchemaInferedTypeName, o as getOutputFileName, ot as getZodSchemaPropertyDescriptions, p as getEndpointConfig, pt as isBulkDeleteEndpoint, q as getAbilityDescription, r as compileNativeData, rt as getImportedZodSchemaName, st as getZodSchemaType, tt as renderAclCheckCall, u as isMutation, ut as getUniqueArray, v as mapEndpointParamsToFunctionParams, vt as isReadEndpoint, w as getFileNameWithExtension, wn as AXIOS_DEFAULT_IMPORT_NAME, y as renderMediaUploadMutationBody, yt as isUpdateEndpoint, z as getInfiniteQueryOptionsName, zt as CONFIG_PACKAGE_IMPORT_PATH } from "./generate.runner-C3n76bDK.mjs";
|
|
3
3
|
import "node:module";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -1722,7 +1722,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
1722
1722
|
//#region src/generators/generate/generateAppRestClient.ts
|
|
1723
1723
|
function generateAppRestClient(resolver) {
|
|
1724
1724
|
const clientName = resolver.options.restClient === "native" ? "NativeRestClient" : "RestClient";
|
|
1725
|
-
return `import { ${clientName} } from "${resolver.options.restClient === "native" ? NATIVE_PACKAGE_IMPORT_PATH :
|
|
1725
|
+
return `import { ${clientName} } from "${resolver.options.restClient === "native" ? NATIVE_PACKAGE_IMPORT_PATH : AXIOS_PACKAGE_IMPORT_PATH}";
|
|
1726
1726
|
|
|
1727
1727
|
export const ${APP_REST_CLIENT_NAME} = new ${clientName}({
|
|
1728
1728
|
config: {
|
|
@@ -1916,7 +1916,7 @@ var NativeSchemaResolver = class {
|
|
|
1916
1916
|
return this.nameByRef.get(normalizeRef(ref));
|
|
1917
1917
|
}
|
|
1918
1918
|
getTagByZodSchemaName(name) {
|
|
1919
|
-
return this.options.modelsInCommon ? this.options.defaultTag : this.nativeData.schemaOwners[name];
|
|
1919
|
+
return !this.options.splitByTags || this.options.modelsInCommon ? this.options.defaultTag : this.nativeData.schemaOwners[name] ?? this.options.defaultTag;
|
|
1920
1920
|
}
|
|
1921
1921
|
isSchemaCircular(ref) {
|
|
1922
1922
|
const name = this.nameByRef.get(normalizeRef(ref));
|
|
@@ -2032,8 +2032,8 @@ function getDataFromNativeOpenAPIDoc(openApiDoc, options, nativeSource) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
for (const endpoint of nativeData.endpoints) getTagElement(getEndpointTag(endpoint, options), data).endpoints.push(endpoint);
|
|
2034
2034
|
for (const [name, code] of Object.entries(nativeData.schemas)) {
|
|
2035
|
-
const
|
|
2036
|
-
if (tag) getTagElement(tag, data).zodSchemas[name] = code;
|
|
2035
|
+
const tags = options.modelsInModules ? nativeData.schemaUsageTags[name] ?? [options.defaultTag] : [options.modelsInCommon ? options.defaultTag : nativeData.schemaOwners[name]];
|
|
2036
|
+
for (const tag of tags) if (tag) getTagElement(tag, data).zodSchemas[name] = code;
|
|
2037
2037
|
}
|
|
2038
2038
|
if (process.env.OPENAPI_NATIVE_PROFILE === "1") console.error(`native bridge load=${(afterLoad - started).toFixed(1)}ms call=${(afterNative - afterLoad).toFixed(1)}ms parse=${(afterParse - afterNative).toFixed(1)}ms facade=${(afterResolver - afterParse).toFixed(1)}ms split=${(performance.now() - afterResolver).toFixed(1)}ms`);
|
|
2039
2039
|
return {
|
package/dist/{generateCodeFromOpenAPIDoc-CkVgg5Zy.cjs → generateCodeFromOpenAPIDoc-ejdqJZ2M.cjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generate_utils = require("./generate.utils-
|
|
1
|
+
const require_generate_utils = require("./generate.utils-wn-hR9hY.cjs");
|
|
2
2
|
//#region src/generators/const/acl.const.ts
|
|
3
3
|
const ACL_APP_ABILITY_FILE = {
|
|
4
4
|
fileName: "acl/app.ability",
|
|
@@ -3705,7 +3705,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
3705
3705
|
//#region src/generators/generate/generateAppRestClient.ts
|
|
3706
3706
|
function generateAppRestClient(resolver) {
|
|
3707
3707
|
const clientName = resolver.options.restClient === "native" ? "NativeRestClient" : "RestClient";
|
|
3708
|
-
return `import { ${clientName} } from "${resolver.options.restClient === "native" ? require_generate_utils.NATIVE_PACKAGE_IMPORT_PATH : require_generate_utils.
|
|
3708
|
+
return `import { ${clientName} } from "${resolver.options.restClient === "native" ? require_generate_utils.NATIVE_PACKAGE_IMPORT_PATH : require_generate_utils.AXIOS_PACKAGE_IMPORT_PATH}";
|
|
3709
3709
|
|
|
3710
3710
|
export const ${require_generate_utils.APP_REST_CLIENT_NAME} = new ${clientName}({
|
|
3711
3711
|
config: {
|
|
@@ -3899,7 +3899,7 @@ var NativeSchemaResolver = class {
|
|
|
3899
3899
|
return this.nameByRef.get(normalizeRef(ref));
|
|
3900
3900
|
}
|
|
3901
3901
|
getTagByZodSchemaName(name) {
|
|
3902
|
-
return this.options.modelsInCommon ? this.options.defaultTag : this.nativeData.schemaOwners[name];
|
|
3902
|
+
return !this.options.splitByTags || this.options.modelsInCommon ? this.options.defaultTag : this.nativeData.schemaOwners[name] ?? this.options.defaultTag;
|
|
3903
3903
|
}
|
|
3904
3904
|
isSchemaCircular(ref) {
|
|
3905
3905
|
const name = this.nameByRef.get(normalizeRef(ref));
|
|
@@ -4015,8 +4015,8 @@ function getDataFromNativeOpenAPIDoc(openApiDoc, options, nativeSource) {
|
|
|
4015
4015
|
}
|
|
4016
4016
|
for (const endpoint of nativeData.endpoints) getTagElement(require_generate_utils.getEndpointTag(endpoint, options), data).endpoints.push(endpoint);
|
|
4017
4017
|
for (const [name, code] of Object.entries(nativeData.schemas)) {
|
|
4018
|
-
const
|
|
4019
|
-
if (tag) getTagElement(tag, data).zodSchemas[name] = code;
|
|
4018
|
+
const tags = options.modelsInModules ? nativeData.schemaUsageTags[name] ?? [options.defaultTag] : [options.modelsInCommon ? options.defaultTag : nativeData.schemaOwners[name]];
|
|
4019
|
+
for (const tag of tags) if (tag) getTagElement(tag, data).zodSchemas[name] = code;
|
|
4020
4020
|
}
|
|
4021
4021
|
if (process.env.OPENAPI_NATIVE_PROFILE === "1") console.error(`native bridge load=${(afterLoad - started).toFixed(1)}ms call=${(afterNative - afterLoad).toFixed(1)}ms parse=${(afterParse - afterNative).toFixed(1)}ms facade=${(afterResolver - afterParse).toFixed(1)}ms split=${(performance.now() - afterResolver).toFixed(1)}ms`);
|
|
4022
4022
|
return {
|
package/dist/generator.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
3
|
-
import { H as getQueryName, Ht as getNamespaceName, Mn as formatTag, O as getTagImportPath, S as getTsTypeBase, Xt as isMediaTypeAllowed, Zt as isParamMediaTypeAllowed, bt as invalidVariableNameCharactersToCamel, d as isQuery, dt as DEFAULT_GENERATE_OPTIONS, t as getOpenApiDoc, u as isMutation, x as getSchemaTsMetaType } from "./generate.runner-
|
|
1
|
+
import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-eP5cooBd.mjs";
|
|
2
|
+
import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-Cya5Q-2W.mjs";
|
|
3
|
+
import { H as getQueryName, Ht as getNamespaceName, Mn as formatTag, O as getTagImportPath, S as getTsTypeBase, Xt as isMediaTypeAllowed, Zt as isParamMediaTypeAllowed, bt as invalidVariableNameCharactersToCamel, d as isQuery, dt as DEFAULT_GENERATE_OPTIONS, t as getOpenApiDoc, u as isMutation, x as getSchemaTsMetaType } from "./generate.runner-C3n76bDK.mjs";
|
|
4
4
|
//#region src/generators/core/getMetadataFromOpenAPIDoc.ts
|
|
5
5
|
async function getMetadataFromOpenAPIDoc(openApiDoc, options) {
|
|
6
6
|
const { resolver, data } = await getDataFromOpenAPIDoc(openApiDoc, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as isPrimitiveType, Bn as getMostCommonAdjacentCombinationSplit, Ct as getParamZodSchemaName, Et as getZodSchemaOperationName, Fn as isTagIncluded, Gt as getParameterEnumNames, Hn as removeWord, Ht as getNamespaceName, Jt as isErrorStatus, Kt as getSchemaNameByRef, Mn as formatTag, Nn as getEndpointTag, On as BODY_PARAMETER_NAME, Ot as isNamedZodSchema, Pn as getOperationTag, Qt as isPathExcluded, Rn as capitalize, Sn as VOID_SCHEMA, St as getEnumZodSchemaName, Tt as getZodSchemaName, Un as snakeToCamel, Ut as autocorrectRef, Wn as Profiler, Wt as escapeControlCharacters, Xt as isMediaTypeAllowed, Yt as isMainResponseStatus, Zt as isParamMediaTypeAllowed, _n as INT_SCHEMA, an as wrapWithQuotesIfNeeded, bn as URL_SCHEMA, bt as invalidVariableNameCharactersToCamel, cn as isReferenceObject, d as isQuery, dn as ALLOWED_PATH_IN, en as isSortingParameterObject, fn as ANY_SCHEMA, gn as ENUM_SCHEMA, hn as EMAIL_SCHEMA, in as unwrapQuotesIfNeeded, kn as JSON_APPLICATION_FORMAT, ln as isSchemaObject, lt as iterateSchema, mn as DATETIME_SCHEMA, nn as pathToVariableName, on as inferRequiredSchema, pn as BLOB_SCHEMA, qt as getSchemaRef, rn as replaceHyphenatedPath, s as pick, sn as isArraySchemaObject, tn as pathParamToVariableName, un as ALLOWED_METHODS, ut as getUniqueArray, vn as NUMBER_SCHEMA, wt as getResponseZodSchemaName, xn as UUID_SCHEMA, xt as getBodyZodSchemaName, yn as STRING_SCHEMA, zn as decapitalize } from "./generate.runner-
|
|
1
|
+
import { $t as isPrimitiveType, Bn as getMostCommonAdjacentCombinationSplit, Ct as getParamZodSchemaName, Et as getZodSchemaOperationName, Fn as isTagIncluded, Gt as getParameterEnumNames, Hn as removeWord, Ht as getNamespaceName, Jt as isErrorStatus, Kt as getSchemaNameByRef, Mn as formatTag, Nn as getEndpointTag, On as BODY_PARAMETER_NAME, Ot as isNamedZodSchema, Pn as getOperationTag, Qt as isPathExcluded, Rn as capitalize, Sn as VOID_SCHEMA, St as getEnumZodSchemaName, Tt as getZodSchemaName, Un as snakeToCamel, Ut as autocorrectRef, Wn as Profiler, Wt as escapeControlCharacters, Xt as isMediaTypeAllowed, Yt as isMainResponseStatus, Zt as isParamMediaTypeAllowed, _n as INT_SCHEMA, an as wrapWithQuotesIfNeeded, bn as URL_SCHEMA, bt as invalidVariableNameCharactersToCamel, cn as isReferenceObject, d as isQuery, dn as ALLOWED_PATH_IN, en as isSortingParameterObject, fn as ANY_SCHEMA, gn as ENUM_SCHEMA, hn as EMAIL_SCHEMA, in as unwrapQuotesIfNeeded, kn as JSON_APPLICATION_FORMAT, ln as isSchemaObject, lt as iterateSchema, mn as DATETIME_SCHEMA, nn as pathToVariableName, on as inferRequiredSchema, pn as BLOB_SCHEMA, qt as getSchemaRef, rn as replaceHyphenatedPath, s as pick, sn as isArraySchemaObject, tn as pathParamToVariableName, un as ALLOWED_METHODS, ut as getUniqueArray, vn as NUMBER_SCHEMA, wt as getResponseZodSchemaName, xn as UUID_SCHEMA, xt as getBodyZodSchemaName, yn as STRING_SCHEMA, zn as decapitalize } from "./generate.runner-C3n76bDK.mjs";
|
|
2
2
|
//#region src/generators/const/validation.const.ts
|
|
3
3
|
const HTTP_STATUS_CODES = {
|
|
4
4
|
"100": "Continue",
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { n as AuthGuardProps, r as AuthContext, t as AuthGuard } from "./AuthGua
|
|
|
4
4
|
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";
|
|
5
5
|
import { n as useWorkspaceContext, r as OpenApiRouter, t as OpenApiWorkspaceContext } from "./workspace.context-isVY9ves.mjs";
|
|
6
6
|
import { i as QueryModule, n as InvalidationMapFunc, r as OpenApiQueryConfig, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
|
|
7
|
-
import { t as RestUtils } from "./rest.utils-
|
|
7
|
+
import { t as RestUtils } from "./rest.utils-DpiFIdhF.mjs";
|
|
8
8
|
import { t as OpenAPICodegenConfig } from "./config-DgrOddSC.mjs";
|
|
9
9
|
import { d as TransportResponse, l as TransportRequest, n as HttpError, p as UploadProgress, u as TransportRequestConfig } from "./rest-transport.types-DM5-qyOJ.mjs";
|
|
10
10
|
import { n as NativeRestInterceptor, r as NativeRestClient, t as NativeInterceptor } from "./native-rest-interceptor-PgziZt1f.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as resources, n as ns, t as configureTranslations } from "./i18n-D-FesqFb.mjs";
|
|
2
|
-
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-
|
|
2
|
+
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-uS0DgYUR.mjs";
|
|
3
3
|
import { t as HttpError } from "./rest-transport.types-DxitRtsB.mjs";
|
|
4
|
-
import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-
|
|
4
|
+
import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-Dm9DFErh.mjs";
|
|
5
5
|
import { n as NativeRestClient, t as NativeRestInterceptor } from "./native-rest-interceptor-Np4Ov54n.mjs";
|
|
6
6
|
import { t as OpenApiQueryConfig } from "./queryConfig.context-CldQ5YL9.mjs";
|
|
7
7
|
import { t as useMutationEffects } from "./useMutationEffects-PB1fvKWM.mjs";
|
package/dist/metro.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generate_utils = require("./generate.utils-
|
|
2
|
+
const require_generate_utils = require("./generate.utils-wn-hR9hY.cjs");
|
|
3
3
|
let fs = require("fs");
|
|
4
4
|
fs = require_generate_utils.__toESM(fs, 1);
|
|
5
5
|
let path = require("path");
|
|
@@ -14,6 +14,7 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
14
14
|
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(","),
|
|
15
15
|
workspaceContext: workspaceContext?.split(",")
|
|
16
16
|
});
|
|
17
|
+
if (resolvedConfig.modelsInCommon && resolvedConfig.modelsInModules) throw new Error("modelsInCommon and modelsInModules cannot both be enabled");
|
|
17
18
|
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
18
19
|
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
19
20
|
return resolvedConfig;
|
|
@@ -21,6 +22,10 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region src/native/generateFilesFromNativeOpenAPI.ts
|
|
23
24
|
function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
25
|
+
if (options.standalone && options.importPath === "ts") options = {
|
|
26
|
+
...options,
|
|
27
|
+
importPath: "relative"
|
|
28
|
+
};
|
|
24
29
|
if (!supportsCompleteNativeRender(options)) {
|
|
25
30
|
if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
|
|
26
31
|
return;
|
|
@@ -47,7 +52,7 @@ function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
|
47
52
|
if (!options.modelsOnly) {
|
|
48
53
|
if (options.acl && nativeData.renderedShared.appAcl) files.push(outputFile(options, "acl/app.ability.ts", nativeData.renderedShared.appAcl));
|
|
49
54
|
if (options.mutationEffects && nativeData.renderedShared.queryModules) files.push(outputFile(options, "queryModules.ts", nativeData.renderedShared.queryModules));
|
|
50
|
-
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`));
|
|
55
|
+
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" : "/axios"}";\n\nexport const AppRestClient = new ${options.restClient === "native" ? "NativeRestClient" : "RestClient"}({\n config: {\n baseURL: "${nativeData.baseUrl}"\n },\n});\n`));
|
|
51
56
|
if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
|
|
52
57
|
}
|
|
53
58
|
return files;
|
|
@@ -97,7 +102,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
|
|
|
97
102
|
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
98
103
|
if (nativeFiles) return nativeFiles;
|
|
99
104
|
}
|
|
100
|
-
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-
|
|
105
|
+
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-ejdqJZ2M.cjs"));
|
|
101
106
|
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
102
107
|
source: nativeInput.source,
|
|
103
108
|
yaml: nativeInput.yaml
|
package/dist/metro.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-
|
|
1
|
+
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-kQNEh1Mb.mjs";
|
|
2
2
|
import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-DPUNTduQ.mjs";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Wn as Profiler, n as runGenerate } from "./generate.runner-
|
|
1
|
+
import { Wn as Profiler, n as runGenerate } from "./generate.runner-C3n76bDK.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
//#region src/plugins/openapi-codegen.runner.ts
|
|
4
4
|
function createOpenApiCodegenRunner(config, options = {}) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/lib/rest/rest.utils.d.ts
|
|
2
|
+
declare namespace RestUtils {
|
|
3
|
+
const extractServerResponseCode: (e: unknown) => string | number | null;
|
|
4
|
+
const doesServerErrorMessageContain: (e: unknown, text: string) => boolean;
|
|
5
|
+
const extractServerErrorMessage: (e: unknown) => string | null;
|
|
6
|
+
const extractContentDispositionFilename: (headers: Headers | Record<string, unknown>) => string | undefined;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RestUtils as t };
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
3
|
-
import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-
|
|
2
|
+
import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-Cya5Q-2W.mjs";
|
|
3
|
+
import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-C3n76bDK.mjs";
|
|
4
4
|
import yargs from "yargs";
|
|
5
5
|
import { hideBin } from "yargs/helpers";
|
|
6
6
|
import { styleText } from "node:util";
|
|
@@ -31,7 +31,7 @@ function logBanner(message) {
|
|
|
31
31
|
* Fetch the version from package.json
|
|
32
32
|
*/
|
|
33
33
|
function getVersion() {
|
|
34
|
-
return "3.2.
|
|
34
|
+
return "3.2.4-rc.1";
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/helpers/yargs.helper.ts
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-
|
|
1
|
+
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-kQNEh1Mb.mjs";
|
|
2
2
|
import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-DPUNTduQ.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
//#region src/vite/openapi-codegen.plugin.ts
|
package/dist/zod.mjs
CHANGED
package/package.json
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"test": "bun run build:native && bun run test:ts && bun run test:native",
|
|
92
92
|
"test:ts": "OPENAPI_CODEGEN_NATIVE=0 vitest run",
|
|
93
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",
|
|
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",
|
|
95
95
|
"test:watch": "vitest",
|
|
96
96
|
"build": "tsdown && bun run build:native",
|
|
97
97
|
"build:ts": "tsdown",
|
|
@@ -187,5 +187,5 @@
|
|
|
187
187
|
"node": ">= 18"
|
|
188
188
|
},
|
|
189
189
|
"packageManager": "bun@1.4.1",
|
|
190
|
-
"version": "3.2.
|
|
190
|
+
"version": "3.2.4-rc.1"
|
|
191
191
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosResponseHeaders } from "axios";
|
|
2
|
-
//#region src/lib/rest/rest.utils.d.ts
|
|
3
|
-
declare namespace RestUtils {
|
|
4
|
-
const extractServerResponseCode: (e: unknown) => string | number | null;
|
|
5
|
-
const doesServerErrorMessageContain: (e: AxiosError, text: string) => boolean;
|
|
6
|
-
const extractServerErrorMessage: (e: unknown) => string | null;
|
|
7
|
-
const extractContentDispositionFilename: (headers: AxiosResponseHeaders) => string | undefined;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
export { RestUtils as t };
|