@povio/openapi-codegen-cli 4.0.0-rc.4 → 4.0.0-rc.6
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 +38 -10
- package/dist/{config-BSYiW3xV.d.mts → config-YNXbfpMR.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/{generate.runner-BMqvEp4L.mjs → generate.runner-DVW9l3P3.mjs} +10 -3
- package/dist/{generate.utils-D4eHo3wO.cjs → generate.utils-yHZiQdu7.cjs} +9 -0
- package/dist/{generateCodeFromOpenAPIDoc-DRLE112u.cjs → generateCodeFromOpenAPIDoc-BCtqmKj6.cjs} +146 -2
- package/dist/{generateCodeFromOpenAPIDoc-oe5uj0P4.mjs → generateCodeFromOpenAPIDoc-CW9i6U7J.mjs} +147 -3
- package/dist/generator.d.mts +5 -2
- package/dist/generator.mjs +3 -3
- package/dist/{getDataFromOpenAPIDoc-BqEeVt1w.mjs → getDataFromOpenAPIDoc-D0C-UY3I.mjs} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/metro.cjs +7 -3
- package/dist/metro.d.mts +3 -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-R_Dnb1mt.mjs → openapi-codegen.runner-DmN78sag.mjs} +1 -1
- package/dist/{openapi-source.runner-DEtp4qCv.d.mts → openapi-source.runner-CqnGK_rg.d.mts} +1 -1
- package/dist/{options-BV720uS2.d.mts → options-DQabDsdb.d.mts} +3 -1
- package/dist/query.d.mts +3 -3
- package/dist/{queryConfig.context-BbLtDfIH.d.mts → queryConfig.context-DwVQWbtL.d.mts} +11 -6
- package/dist/sh.mjs +8 -3
- package/dist/tiny.d.mts +1 -1
- package/dist/{useMutationEffects-CmGB4BOV.d.mts → useMutationEffects-I4y5WUkj.d.mts} +1 -1
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -36,6 +36,31 @@ export default {
|
|
|
36
36
|
};
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Lazy schemas
|
|
40
|
+
|
|
41
|
+
With `tsNamespaces` enabled, every schema of a models namespace is built the moment the module is imported, even when the importer only needs one of them. Set `lazySchemas: true` (or pass `--lazySchemas`) to build each schema on first access instead:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// Generated with lazySchemas: true
|
|
45
|
+
const once = <T>(create: () => T) => {
|
|
46
|
+
let value: T | undefined;
|
|
47
|
+
return () => (value ??= create());
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const PetSchema = once(() => z.object({ id: z.int(), category: CategorySchema() }));
|
|
51
|
+
|
|
52
|
+
export const PetModels = {
|
|
53
|
+
get PetSchema() {
|
|
54
|
+
return PetSchema();
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
export declare namespace PetModels {
|
|
58
|
+
export type Pet = z.infer<typeof PetModels.PetSchema>;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`PetModels.PetSchema` stays a regular Zod schema (`.extend`, `.shape`, `.pick` all work and return the same instance on every access), `PetModels.Pet` keeps resolving as a type, and `modelsInCommon` proxies forward to the shared namespace lazily as well. The option requires `tsNamespaces` and is honored by both the TypeScript and native generators. It helps cold starts of apps that import large model modules but render only a slice of them.
|
|
63
|
+
|
|
39
64
|
## Configuration Files
|
|
40
65
|
|
|
41
66
|
The CLI supports TypeScript configuration files to simplify command execution and provide consistent settings with full type safety. Configuration files are automatically discovered in your project root.
|
|
@@ -100,6 +125,7 @@ bunx openapi-codegen generate --config my-config.ts
|
|
|
100
125
|
--tsPath (Requires `--importPath` to be 'ts') Typescript import path (default: '@/data')
|
|
101
126
|
--removeOperationPrefixEndingWith Remove operation name prefixes that end with the specified string (default: 'Controller_')
|
|
102
127
|
--compileSchemas Eagerly compile non-recursive Zod schemas (default: false)
|
|
128
|
+
--lazySchemas Build namespace model schemas on first access instead of at import; requires `--tsNamespaces` (default: false)
|
|
103
129
|
--extractEnums Extract enums into separate Zod schemas (default: true)
|
|
104
130
|
--modelsInCommon Keep all schema declarations in defaultTag models and emit per-module proxy exports (default: false)
|
|
105
131
|
--replaceOptionalWithNullish Replace `.optional()` chains with `.nullish()` in generated Zod schemas (default: false)
|
|
@@ -342,6 +368,8 @@ const config: OpenAPICodegenConfig = {
|
|
|
342
368
|
// modelsOnly: true,
|
|
343
369
|
// 4) Keep all model declarations in common.models and generate per-module model proxies
|
|
344
370
|
// modelsInCommon: true,
|
|
371
|
+
// 5) Build each namespace schema on first access instead of at import (requires tsNamespaces)
|
|
372
|
+
// lazySchemas: true,
|
|
345
373
|
};
|
|
346
374
|
```
|
|
347
375
|
|
|
@@ -592,17 +620,17 @@ export class JSONDto {
|
|
|
592
620
|
|
|
593
621
|
Use package subpaths for runtime imports. Pure `import type` imports may use the package root.
|
|
594
622
|
|
|
595
|
-
| Runtime exports
|
|
596
|
-
|
|
|
597
|
-
| `AuthContext`, `AuthGuard`
|
|
598
|
-
| `AbilityContext`, `useAclCheck`, `Can`, `createAclGuard`
|
|
599
|
-
| `ErrorHandler`, `SharedErrorHandler`, `ApplicationException`, `DomainErrorRegistry`
|
|
600
|
-
| `useMutationEffects`, `OpenApiQueryConfig`
|
|
623
|
+
| Runtime exports | Subpath |
|
|
624
|
+
| -------------------------------------------------------------------------------------------- | --------- |
|
|
625
|
+
| `AuthContext`, `AuthGuard` | `/auth` |
|
|
626
|
+
| `AbilityContext`, `useAclCheck`, `Can`, `createAclGuard` | `/acl` |
|
|
627
|
+
| `ErrorHandler`, `SharedErrorHandler`, `ApplicationException`, `DomainErrorRegistry` | `/errors` |
|
|
628
|
+
| `useMutationEffects`, `OpenApiQueryConfig` | `/query` |
|
|
601
629
|
| `OpenApiRouter`, `OpenApiWorkspaceContext`, `useWorkspaceContext`, translation configuration | `/config` |
|
|
602
|
-
| `ZodExtended`
|
|
603
|
-
| `HttpError`, transport types
|
|
604
|
-
| `NativeRestClient`
|
|
605
|
-
| `RestClient`, `RestInterceptor` (Axios transport)
|
|
630
|
+
| `ZodExtended` | `/zod` |
|
|
631
|
+
| `HttpError`, transport types | `/rest` |
|
|
632
|
+
| `NativeRestClient` | `/native` |
|
|
633
|
+
| `RestClient`, `RestInterceptor` (Axios transport) | `/axios` |
|
|
606
634
|
|
|
607
635
|
For example: `import { AuthContext, AuthGuard } from "@povio/openapi-codegen-cli/auth"`.
|
|
608
636
|
Custom application helpers should import error helpers from `/errors`, `AbilityContext` from `/acl`, and mutation effects from `/query`.
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as resources, n as configureTranslations, r as ns, t as TranslateFunction } from "./i18n-B_brQh4X.mjs";
|
|
2
2
|
import { n as useWorkspaceContext, r as OpenApiRouter, t as OpenApiWorkspaceContext } from "./workspace.context-isVY9ves.mjs";
|
|
3
|
-
import { a as
|
|
4
|
-
export { type InvalidationMap, type InvalidationMapFunc, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsTypes, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RegisteredQueryModule, type TranslateFunction, configureTranslations, ns, resources, useWorkspaceContext };
|
|
3
|
+
import { a as MergedMutationVariables, c as OpenApiQueryConfig, i as MergedMutationValues, l as QueryModule, n as InvalidationMapFunc, o as MutationEffectsOf, r as MergedMutationData, s as MutationEffectsTypes, t as InvalidationMap, u as RegisteredQueryModule } from "./queryConfig.context-DwVQWbtL.mjs";
|
|
4
|
+
export { type InvalidationMap, type InvalidationMapFunc, type MergedMutationData, type MergedMutationValues, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsTypes, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RegisteredQueryModule, type TranslateFunction, configureTranslations, ns, resources, useWorkspaceContext };
|
|
@@ -106,6 +106,8 @@ const removeWord = (source, wordToRemove) => {
|
|
|
106
106
|
const pattern = new RegExp(`(${decapitalize(singularWordToRemove)}|${capitalize(singularWordToRemove)})[a-z]*(?=$|[A-Z])`, "g");
|
|
107
107
|
return source.replace(pattern, "");
|
|
108
108
|
};
|
|
109
|
+
/** Removes spaces and tabs at the end of every line (formatters such as `bun fmt` keep them in comments). */
|
|
110
|
+
const trimTrailingWhitespace = (text) => text.replace(/[ \t]+$/gm, "");
|
|
109
111
|
//#endregion
|
|
110
112
|
//#region src/generators/utils/tag.utils.ts
|
|
111
113
|
const formattedTagCache = /* @__PURE__ */ new Map();
|
|
@@ -471,6 +473,7 @@ const DEFAULT_GENERATE_OPTIONS = {
|
|
|
471
473
|
modelsOnly: false,
|
|
472
474
|
standalone: false,
|
|
473
475
|
compileSchemas: false,
|
|
476
|
+
lazySchemas: false,
|
|
474
477
|
schemaSuffix: SCHEMA_SUFFIX,
|
|
475
478
|
enumSuffix: ENUM_SUFFIX,
|
|
476
479
|
modelsInCommon: false,
|
|
@@ -1345,6 +1348,7 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
1345
1348
|
workspaceContext: workspaceContext?.split(",")
|
|
1346
1349
|
});
|
|
1347
1350
|
if (resolvedConfig.modelsInCommon && resolvedConfig.modelsInModules) throw new Error("modelsInCommon and modelsInModules cannot both be enabled");
|
|
1351
|
+
if (resolvedConfig.lazySchemas && !resolvedConfig.tsNamespaces) throw new Error("lazySchemas requires tsNamespaces");
|
|
1348
1352
|
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
1349
1353
|
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
1350
1354
|
return resolvedConfig;
|
|
@@ -1425,7 +1429,10 @@ function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
|
1425
1429
|
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`));
|
|
1426
1430
|
if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
|
|
1427
1431
|
}
|
|
1428
|
-
return files
|
|
1432
|
+
return files.map((file) => ({
|
|
1433
|
+
...file,
|
|
1434
|
+
content: trimTrailingWhitespace(file.content)
|
|
1435
|
+
}));
|
|
1429
1436
|
}
|
|
1430
1437
|
function supportsCompleteNativeRender(options) {
|
|
1431
1438
|
return options.splitByTags && !options.inlineEndpoints && (options.workspaceContext?.length ?? 0) === 0;
|
|
@@ -1472,7 +1479,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
|
|
|
1472
1479
|
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
1473
1480
|
if (nativeFiles) return nativeFiles;
|
|
1474
1481
|
}
|
|
1475
|
-
const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-
|
|
1482
|
+
const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-CW9i6U7J.mjs").then((n) => n.n);
|
|
1476
1483
|
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
1477
1484
|
source: nativeInput.source,
|
|
1478
1485
|
yaml: nativeInput.yaml
|
|
@@ -1560,4 +1567,4 @@ function getGenerateStats(filesData, config) {
|
|
|
1560
1567
|
};
|
|
1561
1568
|
}
|
|
1562
1569
|
//#endregion
|
|
1563
|
-
export { getParamZodSchemaName as $, AXIOS_DEFAULT_IMPORT_NAME as $t, getAbilityConditionType as A, pathParamToVariableName as At, getImportedZodSchemaInferedTypeName as B, ALLOWED_PATH_IN as Bt, getTagFileName as C, isErrorStatus as Ct, getImportPath as D, isPathExcluded as Dt, getEndpointsImports as E, isParamMediaTypeAllowed as Et, getAbilitySubjectTypes as F, inferRequiredSchema as Ft, getZodSchemaType as G, ENUM_SCHEMA as Gt, getZodSchemaDescription as H, BLOB_SCHEMA as Ht, getAclData as I, isArraySchemaObject as It, getUniqueArray as J, STRING_SCHEMA as Jt, getSchemaDescriptions as K, INT_SCHEMA as Kt, getAppAbilitiesType as L, isReferenceObject as Lt, getAbilityDescription as M, replaceHyphenatedPath as Mt, getAbilityFunctionName as N, unwrapQuotesIfNeeded as Nt, getModelsImports as O, isPrimitiveType as Ot, getAbilitySubject as P, wrapWithQuotesIfNeeded as Pt, getEnumZodSchemaName as Q, ZOD_IMPORT as Qt, hasAbilityConditions as R, isSchemaObject as Rt, getQueryTypesImportPath as S, getSchemaRef as St, getAclImports as T, isMediaTypeAllowed as Tt, getZodSchemaInferedTypeName as U, DATETIME_SCHEMA as Ut, getImportedZodSchemaName as V, ANY_SCHEMA as Vt, getZodSchemaPropertyDescriptions as W, EMAIL_SCHEMA as Wt, invalidVariableNameCharactersToCamel as X, UUID_SCHEMA as Xt, DEFAULT_GENERATE_OPTIONS as Y, URL_SCHEMA as Yt, getBodyZodSchemaName as Z, VOID_SCHEMA as Zt, getSchemaTsMetaType as _,
|
|
1570
|
+
export { getParamZodSchemaName as $, AXIOS_DEFAULT_IMPORT_NAME as $t, getAbilityConditionType as A, pathParamToVariableName as At, getImportedZodSchemaInferedTypeName as B, ALLOWED_PATH_IN as Bt, getTagFileName as C, isErrorStatus as Ct, getImportPath as D, isPathExcluded as Dt, getEndpointsImports as E, isParamMediaTypeAllowed as Et, getAbilitySubjectTypes as F, inferRequiredSchema as Ft, getZodSchemaType as G, ENUM_SCHEMA as Gt, getZodSchemaDescription as H, BLOB_SCHEMA as Ht, getAclData as I, isArraySchemaObject as It, getUniqueArray as J, STRING_SCHEMA as Jt, getSchemaDescriptions as K, INT_SCHEMA as Kt, getAppAbilitiesType as L, isReferenceObject as Lt, getAbilityDescription as M, replaceHyphenatedPath as Mt, getAbilityFunctionName as N, unwrapQuotesIfNeeded as Nt, getModelsImports as O, isPrimitiveType as Ot, getAbilitySubject as P, wrapWithQuotesIfNeeded as Pt, getEnumZodSchemaName as Q, ZOD_IMPORT as Qt, hasAbilityConditions as R, isSchemaObject as Rt, getQueryTypesImportPath as S, getSchemaRef as St, getAclImports as T, isMediaTypeAllowed as Tt, getZodSchemaInferedTypeName as U, DATETIME_SCHEMA as Ut, getImportedZodSchemaName as V, ANY_SCHEMA as Vt, getZodSchemaPropertyDescriptions as W, EMAIL_SCHEMA as Wt, invalidVariableNameCharactersToCamel as X, UUID_SCHEMA as Xt, DEFAULT_GENERATE_OPTIONS as Y, URL_SCHEMA as Yt, getBodyZodSchemaName as Z, VOID_SCHEMA as Zt, getSchemaTsMetaType as _, trimTrailingWhitespace as _n, getNamespaceName as _t, resolveConfig as a, NATIVE_RESPONSE_TYPE as an, APP_REST_CLIENT_FILE as at, getFileNameWithExtension as b, getParameterEnumNames as bt, getEndpointBody as c, getEndpointTag as cn, MUTATION_EFFECTS as ct, getEndpointPath as d, shouldInlineEndpointsForTag as dn, QUERY_OPTIONS_TYPES as dt, AXIOS_IMPORT as en, getResponseZodSchemaName as et, getImportedEndpointName as f, capitalize as fn, ZOD_EXTENDED as ft, requiresBody as g, snakeToCamel as gn, REST_PACKAGE_IMPORT_PATH as gt, renderMediaUploadMutationBody as h, removeWord as hn, NATIVE_PACKAGE_IMPORT_PATH as ht, shouldUseNativeCodegen as i, JSON_APPLICATION_FORMAT as in, isNamedZodSchema as it, getAbilityConditionsTypes as j, pathToVariableName as jt, getAbilityAction as k, isSortingParameterObject as kt, getEndpointConfig as l, getOperationTag as ln, QUERY_MODULES_FILE as lt, mapEndpointParamsToFunctionParams as m, getMostCommonAdjacentCombinationSplit as mn, CONFIG_PACKAGE_IMPORT_PATH as mt, runGenerate as n, AXIOS_REQUEST_CONFIG_TYPE as nn, getZodSchemaOperationName as nt, getOutputFileName as o, getRequestConfigTypeName as on, APP_REST_CLIENT_NAME as ot, hasEndpointConfig as p, decapitalize as pn, AXIOS_PACKAGE_IMPORT_PATH as pt, iterateSchema as q, NUMBER_SCHEMA as qt, compileNativeData as r, BODY_PARAMETER_NAME as rn, isEnumZodSchema as rt, pick as s, formatTag as sn, DOMAIN_ERRORS_FILE as st, getOpenApiDoc as t, AXIOS_REQUEST_CONFIG_NAME as tn, getZodSchemaName as tt, getEndpointName as u, isTagIncluded as un, QUERY_MODULE_ENUM as ut, getTsTypeBase as v, Profiler as vn, autocorrectRef as vt, getTagImportPath as w, isMainResponseStatus as wt, getQueryModulesImportPath as x, getSchemaNameByRef as xt, getAppRestClientImportPath as y, escapeControlCharacters as yt, renderAclCheckCall as z, ALLOWED_METHODS as zt };
|
|
@@ -100,6 +100,7 @@ const DEFAULT_GENERATE_OPTIONS = {
|
|
|
100
100
|
modelsOnly: false,
|
|
101
101
|
standalone: false,
|
|
102
102
|
compileSchemas: false,
|
|
103
|
+
lazySchemas: false,
|
|
103
104
|
schemaSuffix: SCHEMA_SUFFIX,
|
|
104
105
|
enumSuffix: ENUM_SUFFIX,
|
|
105
106
|
modelsInCommon: false,
|
|
@@ -461,6 +462,8 @@ const removeWord = (source, wordToRemove) => {
|
|
|
461
462
|
const pattern = new RegExp(`(${decapitalize(singularWordToRemove)}|${capitalize(singularWordToRemove)})[a-z]*(?=$|[A-Z])`, "g");
|
|
462
463
|
return source.replace(pattern, "");
|
|
463
464
|
};
|
|
465
|
+
/** Removes spaces and tabs at the end of every line (formatters such as `bun fmt` keep them in comments). */
|
|
466
|
+
const trimTrailingWhitespace = (text) => text.replace(/[ \t]+$/gm, "");
|
|
464
467
|
//#endregion
|
|
465
468
|
//#region src/generators/utils/array.utils.ts
|
|
466
469
|
const getUniqueArray = (...arrs) => [...new Set(arrs.flat())];
|
|
@@ -1983,6 +1986,12 @@ Object.defineProperty(exports, "snakeToCamel", {
|
|
|
1983
1986
|
return snakeToCamel;
|
|
1984
1987
|
}
|
|
1985
1988
|
});
|
|
1989
|
+
Object.defineProperty(exports, "trimTrailingWhitespace", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function() {
|
|
1992
|
+
return trimTrailingWhitespace;
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1986
1995
|
Object.defineProperty(exports, "unwrapQuotesIfNeeded", {
|
|
1987
1996
|
enumerable: true,
|
|
1988
1997
|
get: function() {
|
package/dist/{generateCodeFromOpenAPIDoc-DRLE112u.cjs → generateCodeFromOpenAPIDoc-BCtqmKj6.cjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generate_utils = require("./generate.utils-
|
|
1
|
+
const require_generate_utils = require("./generate.utils-yHZiQdu7.cjs");
|
|
2
2
|
let openapi_types = require("openapi-types");
|
|
3
3
|
//#region src/generators/const/acl.const.ts
|
|
4
4
|
const ACL_APP_ABILITY_FILE = {
|
|
@@ -2341,6 +2341,83 @@ function renderEndpointConfig(resolver, endpoint, modelNamespaceTag) {
|
|
|
2341
2341
|
return lines.join("\n ");
|
|
2342
2342
|
}
|
|
2343
2343
|
//#endregion
|
|
2344
|
+
//#region src/generators/utils/generate/generate.lazy.utils.ts
|
|
2345
|
+
const ONCE_HELPER_LINES = [
|
|
2346
|
+
"const once = <T>(create: () => T) => {",
|
|
2347
|
+
" let value: T | undefined;",
|
|
2348
|
+
" return () => (value ??= create());",
|
|
2349
|
+
"};"
|
|
2350
|
+
];
|
|
2351
|
+
const isIdentifierChar = (char) => /[A-Za-z0-9_$]/.test(char);
|
|
2352
|
+
const findLiteralEnd = (code, start, quote) => {
|
|
2353
|
+
let index = start + 1;
|
|
2354
|
+
while (index < code.length) {
|
|
2355
|
+
const char = code[index];
|
|
2356
|
+
if (char === "\\") {
|
|
2357
|
+
index += 2;
|
|
2358
|
+
continue;
|
|
2359
|
+
}
|
|
2360
|
+
index += 1;
|
|
2361
|
+
if (char === quote) break;
|
|
2362
|
+
}
|
|
2363
|
+
return Math.min(index, code.length);
|
|
2364
|
+
};
|
|
2365
|
+
const findRegexEnd = (code, start) => {
|
|
2366
|
+
let escaped = false;
|
|
2367
|
+
let characterClass = false;
|
|
2368
|
+
for (let index = start + 1; index < code.length; index += 1) {
|
|
2369
|
+
const char = code[index];
|
|
2370
|
+
if (escaped) {
|
|
2371
|
+
escaped = false;
|
|
2372
|
+
continue;
|
|
2373
|
+
}
|
|
2374
|
+
if (char === "\\") {
|
|
2375
|
+
escaped = true;
|
|
2376
|
+
continue;
|
|
2377
|
+
}
|
|
2378
|
+
if (char === "[") characterClass = true;
|
|
2379
|
+
if (char === "]") characterClass = false;
|
|
2380
|
+
if (char === "/" && !characterClass) return index + 1;
|
|
2381
|
+
}
|
|
2382
|
+
return code.length;
|
|
2383
|
+
};
|
|
2384
|
+
/**
|
|
2385
|
+
* Rewrites bare references to sibling schemas (`PetSchema`) into factory calls (`PetSchema()`).
|
|
2386
|
+
* Member accesses (`CommonModels.PetSchema`, `.enum`), object keys and literal values are left alone.
|
|
2387
|
+
*/
|
|
2388
|
+
function callLazySchemaReferences(code, schemaNames) {
|
|
2389
|
+
let output = "";
|
|
2390
|
+
let index = 0;
|
|
2391
|
+
while (index < code.length) {
|
|
2392
|
+
const char = code[index];
|
|
2393
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
2394
|
+
const end = findLiteralEnd(code, index, char);
|
|
2395
|
+
output += code.slice(index, end);
|
|
2396
|
+
index = end;
|
|
2397
|
+
continue;
|
|
2398
|
+
}
|
|
2399
|
+
if (char === "/" && output.trimEnd().endsWith(".regex(")) {
|
|
2400
|
+
const end = findRegexEnd(code, index);
|
|
2401
|
+
output += code.slice(index, end);
|
|
2402
|
+
index = end;
|
|
2403
|
+
continue;
|
|
2404
|
+
}
|
|
2405
|
+
if (isIdentifierChar(char)) {
|
|
2406
|
+
let end = index + 1;
|
|
2407
|
+
while (end < code.length && isIdentifierChar(code[end])) end += 1;
|
|
2408
|
+
const identifier = code.slice(index, end);
|
|
2409
|
+
const isMemberAccess = output.endsWith(".");
|
|
2410
|
+
const isObjectKey = code.slice(end).trimStart().startsWith(":");
|
|
2411
|
+
output += schemaNames.has(identifier) && !isMemberAccess && !isObjectKey ? `${identifier}()` : identifier;
|
|
2412
|
+
index = end;
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
output += char;
|
|
2416
|
+
index += 1;
|
|
2417
|
+
}
|
|
2418
|
+
return output;
|
|
2419
|
+
}
|
|
2420
|
+
//#endregion
|
|
2344
2421
|
//#region src/generators/generate/generateModels.ts
|
|
2345
2422
|
function generateModels({ resolver, data, tag }) {
|
|
2346
2423
|
const nativeContent = resolver.getNativeRenderedModels?.(tag);
|
|
@@ -2376,6 +2453,12 @@ function generateModels({ resolver, data, tag }) {
|
|
|
2376
2453
|
lines.push(renderImport$1(require_generate_utils.ZOD_IMPORT));
|
|
2377
2454
|
for (const modelsImport of modelsImports) lines.push(renderImport$1(modelsImport));
|
|
2378
2455
|
lines.push("");
|
|
2456
|
+
if (resolver.options.lazySchemas && resolver.options.tsNamespaces) return renderLazyModels({
|
|
2457
|
+
resolver,
|
|
2458
|
+
tag,
|
|
2459
|
+
zodSchemasData,
|
|
2460
|
+
lines
|
|
2461
|
+
});
|
|
2379
2462
|
if (resolver.options.tsNamespaces) lines.push(`export namespace ${require_generate_utils.getNamespaceName({
|
|
2380
2463
|
type: "models",
|
|
2381
2464
|
tag,
|
|
@@ -2400,6 +2483,50 @@ function generateModels({ resolver, data, tag }) {
|
|
|
2400
2483
|
if (resolver.options.tsNamespaces) lines.push("}");
|
|
2401
2484
|
return lines.join("\n").trimEnd() + "\n";
|
|
2402
2485
|
}
|
|
2486
|
+
function renderLazyModels({ resolver, tag, zodSchemasData, lines }) {
|
|
2487
|
+
const namespace = require_generate_utils.getNamespaceName({
|
|
2488
|
+
type: "models",
|
|
2489
|
+
tag,
|
|
2490
|
+
options: resolver.options
|
|
2491
|
+
});
|
|
2492
|
+
const schemaNames = new Set(Object.keys(zodSchemasData));
|
|
2493
|
+
const members = [];
|
|
2494
|
+
const types = [];
|
|
2495
|
+
lines.push(...ONCE_HELPER_LINES, "");
|
|
2496
|
+
for (const [name, zodSchema] of Object.entries(zodSchemasData)) {
|
|
2497
|
+
const inferredTypeName = require_generate_utils.getZodSchemaInferedTypeName(name, resolver.options);
|
|
2498
|
+
const typeAnnotation = zodSchema.isCircular ? `: () => z.ZodObject<z.ZodRawShape> & z.ZodType<${namespace}.${inferredTypeName}>` : "";
|
|
2499
|
+
const schemaCode = resolver.options.compileSchemas && !zodSchema.isCircular ? `z.compile(${zodSchema.code})` : zodSchema.code;
|
|
2500
|
+
lines.push(`const ${name}${typeAnnotation} = once(() => ${callLazySchemaReferences(schemaCode, schemaNames)});`);
|
|
2501
|
+
members.push(...indent(renderModelJsDocs({
|
|
2502
|
+
name,
|
|
2503
|
+
zodSchema,
|
|
2504
|
+
tag,
|
|
2505
|
+
resolver
|
|
2506
|
+
}).split("\n")));
|
|
2507
|
+
members.push(...renderLazyMember(name, `${name}()`));
|
|
2508
|
+
if (zodSchema.isCircular && zodSchema.schemaObj) types.push(` export type ${inferredTypeName} = ${renderSchemaType(zodSchema.schemaObj, resolver)};`);
|
|
2509
|
+
else types.push(` export type ${inferredTypeName} = z.infer<typeof ${namespace}.${name}>;`);
|
|
2510
|
+
if (zodSchema.isEnum) {
|
|
2511
|
+
lines.push(`const ${inferredTypeName} = once(() => ${name}().enum);`);
|
|
2512
|
+
members.push(...renderLazyMember(inferredTypeName, `${inferredTypeName}()`));
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
lines.push("");
|
|
2516
|
+
lines.push(`export const ${namespace} = {`, ...members, "};");
|
|
2517
|
+
lines.push(`export declare namespace ${namespace} {`, ...types, "}");
|
|
2518
|
+
return lines.join("\n") + "\n";
|
|
2519
|
+
}
|
|
2520
|
+
function renderLazyMember(name, value) {
|
|
2521
|
+
return [
|
|
2522
|
+
` get ${name}() {`,
|
|
2523
|
+
` return ${value};`,
|
|
2524
|
+
` },`
|
|
2525
|
+
];
|
|
2526
|
+
}
|
|
2527
|
+
function indent(lines) {
|
|
2528
|
+
return lines.map((line) => ` ${line}`);
|
|
2529
|
+
}
|
|
2403
2530
|
function renderSchemaType(schema, resolver) {
|
|
2404
2531
|
if (require_generate_utils.isReferenceObject(schema)) {
|
|
2405
2532
|
const schemaName = resolver.getZodSchemaNameByRef(schema.$ref);
|
|
@@ -2458,6 +2585,20 @@ function renderModelsProxy({ resolver, data, tag }) {
|
|
|
2458
2585
|
})}`;
|
|
2459
2586
|
const inferredTypeNames = schemaNames.map((schemaName) => require_generate_utils.getZodSchemaInferedTypeName(schemaName, resolver.options));
|
|
2460
2587
|
const enumInferredTypeNames = schemaNames.filter((schemaName) => require_generate_utils.isEnumZodSchema(commonZodSchemas[schemaName] ?? "")).map((schemaName) => require_generate_utils.getZodSchemaInferedTypeName(schemaName, resolver.options));
|
|
2588
|
+
if (resolver.options.tsNamespaces && resolver.options.lazySchemas) {
|
|
2589
|
+
const lines = [];
|
|
2590
|
+
lines.push(`import { ${commonNamespace} } from "${commonModelsPath}";`);
|
|
2591
|
+
lines.push("");
|
|
2592
|
+
lines.push(`export const ${modelsNamespace} = {`);
|
|
2593
|
+
for (const schemaName of schemaNames) lines.push(...renderLazyMember(schemaName, `${commonNamespace}.${schemaName}`));
|
|
2594
|
+
for (const enumName of enumInferredTypeNames) lines.push(...renderLazyMember(enumName, `${commonNamespace}.${enumName}`));
|
|
2595
|
+
lines.push("};");
|
|
2596
|
+
lines.push(`export declare namespace ${modelsNamespace} {`);
|
|
2597
|
+
for (const typeName of inferredTypeNames) lines.push(` export type ${typeName} = ${commonNamespace}.${typeName};`);
|
|
2598
|
+
lines.push("}");
|
|
2599
|
+
lines.push("");
|
|
2600
|
+
return lines.join("\n");
|
|
2601
|
+
}
|
|
2461
2602
|
if (resolver.options.tsNamespaces) {
|
|
2462
2603
|
const lines = [];
|
|
2463
2604
|
lines.push(`import { ${commonNamespace} } from "${commonModelsPath}";`);
|
|
@@ -3674,7 +3815,10 @@ function generateCodeFromOpenAPIDoc(openApiDoc, options, profiler, nativeSource)
|
|
|
3674
3815
|
});
|
|
3675
3816
|
});
|
|
3676
3817
|
if (!modelsOnly) generateFilesData.push(...p.runSync("render.AclShared", () => getAclFiles(data, resolver)), ...p.runSync("render.MutationEffects", () => getMutationEffectsFiles(data, resolver)), ...p.runSync("render.ZodExtended", () => getZodExtendedFiles(data, resolver)), ...p.runSync("render.Standalone", () => getAppRestClientFiles(resolver)), ...p.runSync("render.DomainErrors", () => getDomainErrorsFiles(data, resolver)));
|
|
3677
|
-
return generateFilesData
|
|
3818
|
+
return generateFilesData.map((file) => ({
|
|
3819
|
+
...file,
|
|
3820
|
+
content: require_generate_utils.trimTrailingWhitespace(file.content)
|
|
3821
|
+
}));
|
|
3678
3822
|
}
|
|
3679
3823
|
//#endregion
|
|
3680
3824
|
exports.generateCodeFromOpenAPIDoc = generateCodeFromOpenAPIDoc;
|
package/dist/{generateCodeFromOpenAPIDoc-oe5uj0P4.mjs → generateCodeFromOpenAPIDoc-CW9i6U7J.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as isQuery, i as isMutation, n as getDestructuredVariables, r as isInfiniteQuery, s as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
2
|
-
import { $t as AXIOS_DEFAULT_IMPORT_NAME, A as getAbilityConditionType, B as getImportedZodSchemaInferedTypeName, C as getTagFileName, D as getImportPath, E as getEndpointsImports, Et as isParamMediaTypeAllowed, F as getAbilitySubjectTypes, G as getZodSchemaType, H as getZodSchemaDescription, I as getAclData, J as getUniqueArray, K as getSchemaDescriptions, L as getAppAbilitiesType, Lt as isReferenceObject, M as getAbilityDescription, N as getAbilityFunctionName, O as getModelsImports, P as getAbilitySubject, Pt as wrapWithQuotesIfNeeded, Qt as ZOD_IMPORT, R as hasAbilityConditions, Rt as isSchemaObject, S as getQueryTypesImportPath, T as getAclImports, U as getZodSchemaInferedTypeName, V as getImportedZodSchemaName, W as getZodSchemaPropertyDescriptions, X as invalidVariableNameCharactersToCamel, Y as DEFAULT_GENERATE_OPTIONS, _n as
|
|
1
|
+
import { a as isQuery, i as isMutation, n as getDestructuredVariables, r as isInfiniteQuery, s as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-D0C-UY3I.mjs";
|
|
2
|
+
import { $t as AXIOS_DEFAULT_IMPORT_NAME, A as getAbilityConditionType, B as getImportedZodSchemaInferedTypeName, C as getTagFileName, D as getImportPath, E as getEndpointsImports, Et as isParamMediaTypeAllowed, F as getAbilitySubjectTypes, G as getZodSchemaType, H as getZodSchemaDescription, I as getAclData, J as getUniqueArray, K as getSchemaDescriptions, L as getAppAbilitiesType, Lt as isReferenceObject, M as getAbilityDescription, N as getAbilityFunctionName, O as getModelsImports, P as getAbilitySubject, Pt as wrapWithQuotesIfNeeded, Qt as ZOD_IMPORT, R as hasAbilityConditions, Rt as isSchemaObject, S as getQueryTypesImportPath, T as getAclImports, U as getZodSchemaInferedTypeName, V as getImportedZodSchemaName, W as getZodSchemaPropertyDescriptions, X as invalidVariableNameCharactersToCamel, Y as DEFAULT_GENERATE_OPTIONS, _n as trimTrailingWhitespace, _t as getNamespaceName, an as NATIVE_RESPONSE_TYPE, at as APP_REST_CLIENT_FILE, b as getFileNameWithExtension, c as getEndpointBody, cn as getEndpointTag, ct as MUTATION_EFFECTS, d as getEndpointPath, dn as shouldInlineEndpointsForTag, dt as QUERY_OPTIONS_TYPES, en as AXIOS_IMPORT, f as getImportedEndpointName, fn as capitalize, ft as ZOD_EXTENDED, g as requiresBody, gn as snakeToCamel, gt as REST_PACKAGE_IMPORT_PATH, h as renderMediaUploadMutationBody, ht as NATIVE_PACKAGE_IMPORT_PATH, i as shouldUseNativeCodegen, it as isNamedZodSchema, j as getAbilityConditionsTypes, k as getAbilityAction, l as getEndpointConfig, lt as QUERY_MODULES_FILE, m as mapEndpointParamsToFunctionParams, mt as CONFIG_PACKAGE_IMPORT_PATH, nn as AXIOS_REQUEST_CONFIG_TYPE, o as getOutputFileName, on as getRequestConfigTypeName, ot as APP_REST_CLIENT_NAME, p as hasEndpointConfig, pt as AXIOS_PACKAGE_IMPORT_PATH, r as compileNativeData, rt as isEnumZodSchema, st as DOMAIN_ERRORS_FILE, tn as AXIOS_REQUEST_CONFIG_NAME, u as getEndpointName, ut as QUERY_MODULE_ENUM, vn as Profiler, w as getTagImportPath, x as getQueryModulesImportPath, y as getAppRestClientImportPath, z as renderAclCheckCall } from "./generate.runner-DVW9l3P3.mjs";
|
|
3
3
|
import "node:module";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -341,6 +341,83 @@ function renderEndpointConfig(resolver, endpoint, modelNamespaceTag) {
|
|
|
341
341
|
return lines.join("\n ");
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
|
+
//#region src/generators/utils/generate/generate.lazy.utils.ts
|
|
345
|
+
const ONCE_HELPER_LINES = [
|
|
346
|
+
"const once = <T>(create: () => T) => {",
|
|
347
|
+
" let value: T | undefined;",
|
|
348
|
+
" return () => (value ??= create());",
|
|
349
|
+
"};"
|
|
350
|
+
];
|
|
351
|
+
const isIdentifierChar = (char) => /[A-Za-z0-9_$]/.test(char);
|
|
352
|
+
const findLiteralEnd = (code, start, quote) => {
|
|
353
|
+
let index = start + 1;
|
|
354
|
+
while (index < code.length) {
|
|
355
|
+
const char = code[index];
|
|
356
|
+
if (char === "\\") {
|
|
357
|
+
index += 2;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
index += 1;
|
|
361
|
+
if (char === quote) break;
|
|
362
|
+
}
|
|
363
|
+
return Math.min(index, code.length);
|
|
364
|
+
};
|
|
365
|
+
const findRegexEnd = (code, start) => {
|
|
366
|
+
let escaped = false;
|
|
367
|
+
let characterClass = false;
|
|
368
|
+
for (let index = start + 1; index < code.length; index += 1) {
|
|
369
|
+
const char = code[index];
|
|
370
|
+
if (escaped) {
|
|
371
|
+
escaped = false;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (char === "\\") {
|
|
375
|
+
escaped = true;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (char === "[") characterClass = true;
|
|
379
|
+
if (char === "]") characterClass = false;
|
|
380
|
+
if (char === "/" && !characterClass) return index + 1;
|
|
381
|
+
}
|
|
382
|
+
return code.length;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Rewrites bare references to sibling schemas (`PetSchema`) into factory calls (`PetSchema()`).
|
|
386
|
+
* Member accesses (`CommonModels.PetSchema`, `.enum`), object keys and literal values are left alone.
|
|
387
|
+
*/
|
|
388
|
+
function callLazySchemaReferences(code, schemaNames) {
|
|
389
|
+
let output = "";
|
|
390
|
+
let index = 0;
|
|
391
|
+
while (index < code.length) {
|
|
392
|
+
const char = code[index];
|
|
393
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
394
|
+
const end = findLiteralEnd(code, index, char);
|
|
395
|
+
output += code.slice(index, end);
|
|
396
|
+
index = end;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (char === "/" && output.trimEnd().endsWith(".regex(")) {
|
|
400
|
+
const end = findRegexEnd(code, index);
|
|
401
|
+
output += code.slice(index, end);
|
|
402
|
+
index = end;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (isIdentifierChar(char)) {
|
|
406
|
+
let end = index + 1;
|
|
407
|
+
while (end < code.length && isIdentifierChar(code[end])) end += 1;
|
|
408
|
+
const identifier = code.slice(index, end);
|
|
409
|
+
const isMemberAccess = output.endsWith(".");
|
|
410
|
+
const isObjectKey = code.slice(end).trimStart().startsWith(":");
|
|
411
|
+
output += schemaNames.has(identifier) && !isMemberAccess && !isObjectKey ? `${identifier}()` : identifier;
|
|
412
|
+
index = end;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
output += char;
|
|
416
|
+
index += 1;
|
|
417
|
+
}
|
|
418
|
+
return output;
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
344
421
|
//#region src/generators/generate/generateModels.ts
|
|
345
422
|
function generateModels({ resolver, data, tag }) {
|
|
346
423
|
const nativeContent = resolver.getNativeRenderedModels?.(tag);
|
|
@@ -376,6 +453,12 @@ function generateModels({ resolver, data, tag }) {
|
|
|
376
453
|
lines.push(renderImport$1(ZOD_IMPORT));
|
|
377
454
|
for (const modelsImport of modelsImports) lines.push(renderImport$1(modelsImport));
|
|
378
455
|
lines.push("");
|
|
456
|
+
if (resolver.options.lazySchemas && resolver.options.tsNamespaces) return renderLazyModels({
|
|
457
|
+
resolver,
|
|
458
|
+
tag,
|
|
459
|
+
zodSchemasData,
|
|
460
|
+
lines
|
|
461
|
+
});
|
|
379
462
|
if (resolver.options.tsNamespaces) lines.push(`export namespace ${getNamespaceName({
|
|
380
463
|
type: "models",
|
|
381
464
|
tag,
|
|
@@ -400,6 +483,50 @@ function generateModels({ resolver, data, tag }) {
|
|
|
400
483
|
if (resolver.options.tsNamespaces) lines.push("}");
|
|
401
484
|
return lines.join("\n").trimEnd() + "\n";
|
|
402
485
|
}
|
|
486
|
+
function renderLazyModels({ resolver, tag, zodSchemasData, lines }) {
|
|
487
|
+
const namespace = getNamespaceName({
|
|
488
|
+
type: "models",
|
|
489
|
+
tag,
|
|
490
|
+
options: resolver.options
|
|
491
|
+
});
|
|
492
|
+
const schemaNames = new Set(Object.keys(zodSchemasData));
|
|
493
|
+
const members = [];
|
|
494
|
+
const types = [];
|
|
495
|
+
lines.push(...ONCE_HELPER_LINES, "");
|
|
496
|
+
for (const [name, zodSchema] of Object.entries(zodSchemasData)) {
|
|
497
|
+
const inferredTypeName = getZodSchemaInferedTypeName(name, resolver.options);
|
|
498
|
+
const typeAnnotation = zodSchema.isCircular ? `: () => z.ZodObject<z.ZodRawShape> & z.ZodType<${namespace}.${inferredTypeName}>` : "";
|
|
499
|
+
const schemaCode = resolver.options.compileSchemas && !zodSchema.isCircular ? `z.compile(${zodSchema.code})` : zodSchema.code;
|
|
500
|
+
lines.push(`const ${name}${typeAnnotation} = once(() => ${callLazySchemaReferences(schemaCode, schemaNames)});`);
|
|
501
|
+
members.push(...indent(renderModelJsDocs({
|
|
502
|
+
name,
|
|
503
|
+
zodSchema,
|
|
504
|
+
tag,
|
|
505
|
+
resolver
|
|
506
|
+
}).split("\n")));
|
|
507
|
+
members.push(...renderLazyMember(name, `${name}()`));
|
|
508
|
+
if (zodSchema.isCircular && zodSchema.schemaObj) types.push(` export type ${inferredTypeName} = ${renderSchemaType(zodSchema.schemaObj, resolver)};`);
|
|
509
|
+
else types.push(` export type ${inferredTypeName} = z.infer<typeof ${namespace}.${name}>;`);
|
|
510
|
+
if (zodSchema.isEnum) {
|
|
511
|
+
lines.push(`const ${inferredTypeName} = once(() => ${name}().enum);`);
|
|
512
|
+
members.push(...renderLazyMember(inferredTypeName, `${inferredTypeName}()`));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
lines.push("");
|
|
516
|
+
lines.push(`export const ${namespace} = {`, ...members, "};");
|
|
517
|
+
lines.push(`export declare namespace ${namespace} {`, ...types, "}");
|
|
518
|
+
return lines.join("\n") + "\n";
|
|
519
|
+
}
|
|
520
|
+
function renderLazyMember(name, value) {
|
|
521
|
+
return [
|
|
522
|
+
` get ${name}() {`,
|
|
523
|
+
` return ${value};`,
|
|
524
|
+
` },`
|
|
525
|
+
];
|
|
526
|
+
}
|
|
527
|
+
function indent(lines) {
|
|
528
|
+
return lines.map((line) => ` ${line}`);
|
|
529
|
+
}
|
|
403
530
|
function renderSchemaType(schema, resolver) {
|
|
404
531
|
if (isReferenceObject(schema)) {
|
|
405
532
|
const schemaName = resolver.getZodSchemaNameByRef(schema.$ref);
|
|
@@ -458,6 +585,20 @@ function renderModelsProxy({ resolver, data, tag }) {
|
|
|
458
585
|
})}`;
|
|
459
586
|
const inferredTypeNames = schemaNames.map((schemaName) => getZodSchemaInferedTypeName(schemaName, resolver.options));
|
|
460
587
|
const enumInferredTypeNames = schemaNames.filter((schemaName) => isEnumZodSchema(commonZodSchemas[schemaName] ?? "")).map((schemaName) => getZodSchemaInferedTypeName(schemaName, resolver.options));
|
|
588
|
+
if (resolver.options.tsNamespaces && resolver.options.lazySchemas) {
|
|
589
|
+
const lines = [];
|
|
590
|
+
lines.push(`import { ${commonNamespace} } from "${commonModelsPath}";`);
|
|
591
|
+
lines.push("");
|
|
592
|
+
lines.push(`export const ${modelsNamespace} = {`);
|
|
593
|
+
for (const schemaName of schemaNames) lines.push(...renderLazyMember(schemaName, `${commonNamespace}.${schemaName}`));
|
|
594
|
+
for (const enumName of enumInferredTypeNames) lines.push(...renderLazyMember(enumName, `${commonNamespace}.${enumName}`));
|
|
595
|
+
lines.push("};");
|
|
596
|
+
lines.push(`export declare namespace ${modelsNamespace} {`);
|
|
597
|
+
for (const typeName of inferredTypeNames) lines.push(` export type ${typeName} = ${commonNamespace}.${typeName};`);
|
|
598
|
+
lines.push("}");
|
|
599
|
+
lines.push("");
|
|
600
|
+
return lines.join("\n");
|
|
601
|
+
}
|
|
461
602
|
if (resolver.options.tsNamespaces) {
|
|
462
603
|
const lines = [];
|
|
463
604
|
lines.push(`import { ${commonNamespace} } from "${commonModelsPath}";`);
|
|
@@ -1675,7 +1816,10 @@ function generateCodeFromOpenAPIDoc(openApiDoc, options, profiler, nativeSource)
|
|
|
1675
1816
|
});
|
|
1676
1817
|
});
|
|
1677
1818
|
if (!modelsOnly) generateFilesData.push(...p.runSync("render.AclShared", () => getAclFiles(data, resolver)), ...p.runSync("render.MutationEffects", () => getMutationEffectsFiles(data, resolver)), ...p.runSync("render.ZodExtended", () => getZodExtendedFiles(data, resolver)), ...p.runSync("render.Standalone", () => getAppRestClientFiles(resolver)), ...p.runSync("render.DomainErrors", () => getDomainErrorsFiles(data, resolver)));
|
|
1678
|
-
return generateFilesData
|
|
1819
|
+
return generateFilesData.map((file) => ({
|
|
1820
|
+
...file,
|
|
1821
|
+
content: trimTrailingWhitespace(file.content)
|
|
1822
|
+
}));
|
|
1679
1823
|
}
|
|
1680
1824
|
//#endregion
|
|
1681
1825
|
export { generateCodeFromOpenAPIDoc_exports as n, getQueryName as r, generateCodeFromOpenAPIDoc as t };
|
package/dist/generator.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as GenerateOptions } from "./options-DQabDsdb.mjs";
|
|
2
2
|
import { OpenAPIV3 } from "openapi-types";
|
|
3
3
|
//#region src/generators/types/metadata.d.ts
|
|
4
4
|
interface GenerateParams {
|
|
@@ -53,6 +53,9 @@ interface GenerateMetadata {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
//#region src/generator.d.ts
|
|
55
55
|
declare function getGenerateMetadata({ input, options: genOptions }: GenerateParams): Promise<GenerateMetadata>;
|
|
56
|
-
declare function getGenerateFilesData({ input, options: genOptions }: GenerateParams): Promise<
|
|
56
|
+
declare function getGenerateFilesData({ input, options: genOptions }: GenerateParams): Promise<{
|
|
57
|
+
fileName: string;
|
|
58
|
+
content: string;
|
|
59
|
+
}[]>;
|
|
57
60
|
//#endregion
|
|
58
61
|
export { getGenerateFilesData, getGenerateMetadata };
|
package/dist/generator.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as getQueryName, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { a as isQuery, i as isMutation, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
3
|
-
import { Et as isParamMediaTypeAllowed, Tt as isMediaTypeAllowed, X as invalidVariableNameCharactersToCamel, Y as DEFAULT_GENERATE_OPTIONS, _ as getSchemaTsMetaType, _t as getNamespaceName, sn as formatTag, t as getOpenApiDoc, v as getTsTypeBase, w as getTagImportPath } from "./generate.runner-
|
|
1
|
+
import { r as getQueryName, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CW9i6U7J.mjs";
|
|
2
|
+
import { a as isQuery, i as isMutation, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-D0C-UY3I.mjs";
|
|
3
|
+
import { Et as isParamMediaTypeAllowed, Tt as isMediaTypeAllowed, X as invalidVariableNameCharactersToCamel, Y as DEFAULT_GENERATE_OPTIONS, _ as getSchemaTsMetaType, _t as getNamespaceName, sn as formatTag, t as getOpenApiDoc, v as getTsTypeBase, w as getTagImportPath } from "./generate.runner-DVW9l3P3.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 { $ as getParamZodSchemaName, At as pathParamToVariableName, Bt as ALLOWED_PATH_IN, Ct as isErrorStatus, Dt as isPathExcluded, Et as isParamMediaTypeAllowed, Ft as inferRequiredSchema, Gt as ENUM_SCHEMA, Ht as BLOB_SCHEMA, It as isArraySchemaObject, J as getUniqueArray, Jt as STRING_SCHEMA, Kt as INT_SCHEMA, Lt as isReferenceObject, Mt as replaceHyphenatedPath, Nt as unwrapQuotesIfNeeded, Ot as isPrimitiveType, Pt as wrapWithQuotesIfNeeded, Q as getEnumZodSchemaName, Rt as isSchemaObject, St as getSchemaRef, Tt as isMediaTypeAllowed, Ut as DATETIME_SCHEMA, Vt as ANY_SCHEMA, Wt as EMAIL_SCHEMA, X as invalidVariableNameCharactersToCamel, Xt as UUID_SCHEMA, Yt as URL_SCHEMA, Z as getBodyZodSchemaName, Zt as VOID_SCHEMA,
|
|
1
|
+
import { $ as getParamZodSchemaName, At as pathParamToVariableName, Bt as ALLOWED_PATH_IN, Ct as isErrorStatus, Dt as isPathExcluded, Et as isParamMediaTypeAllowed, Ft as inferRequiredSchema, Gt as ENUM_SCHEMA, Ht as BLOB_SCHEMA, It as isArraySchemaObject, J as getUniqueArray, Jt as STRING_SCHEMA, Kt as INT_SCHEMA, Lt as isReferenceObject, Mt as replaceHyphenatedPath, Nt as unwrapQuotesIfNeeded, Ot as isPrimitiveType, Pt as wrapWithQuotesIfNeeded, Q as getEnumZodSchemaName, Rt as isSchemaObject, St as getSchemaRef, Tt as isMediaTypeAllowed, Ut as DATETIME_SCHEMA, Vt as ANY_SCHEMA, Wt as EMAIL_SCHEMA, X as invalidVariableNameCharactersToCamel, Xt as UUID_SCHEMA, Yt as URL_SCHEMA, Z as getBodyZodSchemaName, Zt as VOID_SCHEMA, _t as getNamespaceName, bt as getParameterEnumNames, cn as getEndpointTag, et as getResponseZodSchemaName, fn as capitalize, gn as snakeToCamel, hn as removeWord, in as JSON_APPLICATION_FORMAT, it as isNamedZodSchema, jt as pathToVariableName, kt as isSortingParameterObject, ln as getOperationTag, m as mapEndpointParamsToFunctionParams, mn as getMostCommonAdjacentCombinationSplit, nt as getZodSchemaOperationName, pn as decapitalize, q as iterateSchema, qt as NUMBER_SCHEMA, rn as BODY_PARAMETER_NAME, s as pick, sn as formatTag, tt as getZodSchemaName, un as isTagIncluded, vn as Profiler, vt as autocorrectRef, wt as isMainResponseStatus, xt as getSchemaNameByRef, yt as escapeControlCharacters, zt as ALLOWED_METHODS } from "./generate.runner-DVW9l3P3.mjs";
|
|
2
2
|
import { OpenAPIV3 } from "openapi-types";
|
|
3
3
|
//#region src/generators/const/validation.const.ts
|
|
4
4
|
const HTTP_STATUS_CODES = {
|
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ import { a as ErrorHandler, c as GeneralErrorCodes, i as ErrorEntry, l as Shared
|
|
|
3
3
|
import { n as AuthGuardProps, r as AuthContext, t as AuthGuard } from "./AuthGuard-GbtTDXs0.mjs";
|
|
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-CbS77dei.mjs";
|
|
5
5
|
import { n as useWorkspaceContext, r as OpenApiRouter, t as OpenApiWorkspaceContext } from "./workspace.context-isVY9ves.mjs";
|
|
6
|
-
import { a as
|
|
6
|
+
import { a as MergedMutationVariables, c as OpenApiQueryConfig, i as MergedMutationValues, l as QueryModule, n as InvalidationMapFunc, o as MutationEffectsOf, r as MergedMutationData, s as MutationEffectsTypes, t as InvalidationMap, u as RegisteredQueryModule } from "./queryConfig.context-DwVQWbtL.mjs";
|
|
7
7
|
import { t as RestUtils } from "./rest.utils-DpiFIdhF.mjs";
|
|
8
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
8
|
+
import { t as OpenAPICodegenConfig } from "./config-YNXbfpMR.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-DZxdDcpz.mjs";
|
|
11
|
-
import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-
|
|
12
|
-
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type ErrorRethrower, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsOptions, type MutationEffectsTypes, HttpError as NativeHttpError, type NativeInterceptor, type TransportRequest as NativeRequest, type TransportRequestConfig as NativeRequestConfig, type TransportResponse as NativeResponse, NativeRestClient, NativeRestInterceptor, type UploadProgress as NativeUploadProgress, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RegisteredQueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, type TranslateFunction, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };
|
|
11
|
+
import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-I4y5WUkj.mjs";
|
|
12
|
+
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type ErrorRethrower, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MergedMutationData, type MergedMutationValues, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsOptions, type MutationEffectsTypes, HttpError as NativeHttpError, type NativeInterceptor, type TransportRequest as NativeRequest, type TransportRequestConfig as NativeRequestConfig, type TransportResponse as NativeResponse, NativeRestClient, NativeRestInterceptor, type UploadProgress as NativeUploadProgress, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RegisteredQueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, type TranslateFunction, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };
|
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-yHZiQdu7.cjs");
|
|
3
3
|
let fs = require("fs");
|
|
4
4
|
fs = require_generate_utils.__toESM(fs, 1);
|
|
5
5
|
let path = require("path");
|
|
@@ -15,6 +15,7 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
|
|
|
15
15
|
workspaceContext: workspaceContext?.split(",")
|
|
16
16
|
});
|
|
17
17
|
if (resolvedConfig.modelsInCommon && resolvedConfig.modelsInModules) throw new Error("modelsInCommon and modelsInModules cannot both be enabled");
|
|
18
|
+
if (resolvedConfig.lazySchemas && !resolvedConfig.tsNamespaces) throw new Error("lazySchemas requires tsNamespaces");
|
|
18
19
|
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
19
20
|
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
20
21
|
return resolvedConfig;
|
|
@@ -55,7 +56,10 @@ function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
|
55
56
|
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`));
|
|
56
57
|
if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
|
|
57
58
|
}
|
|
58
|
-
return files
|
|
59
|
+
return files.map((file) => ({
|
|
60
|
+
...file,
|
|
61
|
+
content: require_generate_utils.trimTrailingWhitespace(file.content)
|
|
62
|
+
}));
|
|
59
63
|
}
|
|
60
64
|
function supportsCompleteNativeRender(options) {
|
|
61
65
|
return options.splitByTags && !options.inlineEndpoints && (options.workspaceContext?.length ?? 0) === 0;
|
|
@@ -102,7 +106,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
|
|
|
102
106
|
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
103
107
|
if (nativeFiles) return nativeFiles;
|
|
104
108
|
}
|
|
105
|
-
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-
|
|
109
|
+
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-BCtqmKj6.cjs"));
|
|
106
110
|
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
107
111
|
source: nativeInput.source,
|
|
108
112
|
yaml: nativeInput.yaml
|
package/dist/metro.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
3
|
-
import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-
|
|
1
|
+
import { n as GenerateFileFormatter } from "./options-DQabDsdb.mjs";
|
|
2
|
+
import { t as OpenAPICodegenConfig } from "./config-YNXbfpMR.mjs";
|
|
3
|
+
import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-CqnGK_rg.mjs";
|
|
4
4
|
import { IncomingMessage, ServerResponse } from "http";
|
|
5
5
|
//#region src/metro/openapi-codegen.plugin.d.ts
|
|
6
6
|
type OpenApiCodegenMetroConfig = OpenAPICodegenConfig & {
|
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-DmN78sag.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 {
|
|
1
|
+
import { n as runGenerate, vn as Profiler } from "./generate.runner-DVW9l3P3.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
//#region src/plugins/openapi-codegen.runner.ts
|
|
4
4
|
function createOpenApiCodegenRunner(config, options = {}) {
|
|
@@ -16,6 +16,8 @@ type GenerateFileFormatter = (file: GenerateFileData) => string | Promise<string
|
|
|
16
16
|
interface ZodGenerateOptions {
|
|
17
17
|
/** Eagerly compile non-recursive schemas. Defaults to false to avoid startup work. */
|
|
18
18
|
compileSchemas?: boolean;
|
|
19
|
+
/** Build namespace model schemas on first access instead of at import. Requires tsNamespaces. */
|
|
20
|
+
lazySchemas?: boolean;
|
|
19
21
|
schemaSuffix: string;
|
|
20
22
|
enumSuffix: string;
|
|
21
23
|
modelsInCommon?: boolean;
|
|
@@ -96,4 +98,4 @@ interface BaseGenerateOptions {
|
|
|
96
98
|
}
|
|
97
99
|
interface GenerateOptions extends BaseGenerateOptions, ZodGenerateOptions, EndpointsGenerateOptions, QueriesGenerateOptions, InfiniteQueriesGenerateOptions, ACLGenerateOptions {}
|
|
98
100
|
//#endregion
|
|
99
|
-
export {
|
|
101
|
+
export { GenerateFileFormatter as n, GenerateOptions as t };
|
package/dist/query.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-
|
|
3
|
-
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, type InvalidationMap, type InvalidationMapFunc, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsOptions, type MutationEffectsTypes, OpenApiQueryConfig, type QueryModule, type RegisteredQueryModule, useMutationEffects };
|
|
1
|
+
import { a as MergedMutationVariables, c as OpenApiQueryConfig, i as MergedMutationValues, l as QueryModule, n as InvalidationMapFunc, o as MutationEffectsOf, r as MergedMutationData, s as MutationEffectsTypes, t as InvalidationMap, u as RegisteredQueryModule } from "./queryConfig.context-DwVQWbtL.mjs";
|
|
2
|
+
import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-I4y5WUkj.mjs";
|
|
3
|
+
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, type InvalidationMap, type InvalidationMapFunc, type MergedMutationData, type MergedMutationValues, type MergedMutationVariables, type MutationEffectsOf, type MutationEffectsOptions, type MutationEffectsTypes, OpenApiQueryConfig, type QueryModule, type RegisteredQueryModule, useMutationEffects };
|
|
@@ -22,13 +22,18 @@ type IsUnion<T, TAll = T> = T extends unknown ? ([TAll] extends [T] ? false : tr
|
|
|
22
22
|
type MergeableMembers<T> = T extends readonly unknown[] | ((...args: never) => unknown) | Date ? never : ObjectMembers<T>;
|
|
23
23
|
type MergedValue<T> = true extends IsUnion<MergeableMembers<T>> ? MergedObjects<MergeableMembers<T>> | Exclude<T, MergeableMembers<T>> : T;
|
|
24
24
|
type MergedObjects<T> = { [K in Extract<keyof T, PropertyKey>]: MergedValue<ValueOfUnion<T, K>>; } & { [K in Exclude<KeysOfUnion<T>, keyof T>]?: MergedValue<ValueOfUnion<T, K>>; };
|
|
25
|
+
type VoidAsUndefined<T> = [void] extends [T] ? Exclude<T, void> | undefined : T;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* depth (e.g. fields of request bodies only some mutations send).
|
|
28
|
-
*
|
|
27
|
+
* A union of a module's mutation values as one object: keys some mutations lack become optional, at any
|
|
28
|
+
* depth (e.g. fields of request bodies only some mutations send). `void` becomes `undefined`, which is
|
|
29
|
+
* what callbacks receive for mutations without one.
|
|
29
30
|
*/
|
|
30
|
-
type
|
|
31
|
-
|
|
31
|
+
type MergedMutationValues<T> = [ObjectMembers<T>] extends [never] ? VoidAsUndefined<T> : MergedObjects<ObjectMembers<T>> | VoidAsUndefined<Exclude<T, object>>;
|
|
32
|
+
/** The variables of a module's mutations as one object; see `MergedMutationValues`. */
|
|
33
|
+
type MergedMutationVariables<T> = MergedMutationValues<T>;
|
|
34
|
+
/** The responses of a module's mutations as one object; see `MergedMutationValues`. */
|
|
35
|
+
type MergedMutationData<T> = MergedMutationValues<T>;
|
|
36
|
+
type InvalidationMapFuncFor<T> = InvalidationMapFunc<MergedMutationData<T extends MutationEffectsTypes ? T["data"] : never>, MergedMutationVariables<T extends MutationEffectsTypes ? T["variables"] : never>>;
|
|
32
37
|
declare global {
|
|
33
38
|
/**
|
|
34
39
|
* Mutation types per module. The generated `queryModules.ts` extends it with `QueryModuleMutations`, so
|
|
@@ -63,4 +68,4 @@ declare namespace OpenApiQueryConfig {
|
|
|
63
68
|
export {};
|
|
64
69
|
}
|
|
65
70
|
//#endregion
|
|
66
|
-
export {
|
|
71
|
+
export { MergedMutationVariables as a, OpenApiQueryConfig as c, MergedMutationValues as i, QueryModule as l, InvalidationMapFunc as n, MutationEffectsOf as o, MergedMutationData as r, MutationEffectsTypes as s, InvalidationMap as t, RegisteredQueryModule as u };
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { c as VALIDATION_ERROR_TYPE_TITLE, o as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
3
|
-
import { C as getTagFileName,
|
|
2
|
+
import { c as VALIDATION_ERROR_TYPE_TITLE, o as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-D0C-UY3I.mjs";
|
|
3
|
+
import { C as getTagFileName, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc, vn as Profiler } from "./generate.runner-DVW9l3P3.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 "4.0.0-rc.
|
|
34
|
+
return "4.0.0-rc.6";
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/helpers/yargs.helper.ts
|
|
@@ -268,6 +268,7 @@ var GenerateOptions = class {
|
|
|
268
268
|
excludeRedundantZodSchemas;
|
|
269
269
|
importPath;
|
|
270
270
|
compileSchemas;
|
|
271
|
+
lazySchemas;
|
|
271
272
|
extractEnums;
|
|
272
273
|
modelsInCommon;
|
|
273
274
|
modelsInModules;
|
|
@@ -330,6 +331,10 @@ __decorate([YargOption({
|
|
|
330
331
|
envAlias: "compileSchemas",
|
|
331
332
|
type: "boolean"
|
|
332
333
|
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "compileSchemas", void 0);
|
|
334
|
+
__decorate([YargOption({
|
|
335
|
+
envAlias: "lazySchemas",
|
|
336
|
+
type: "boolean"
|
|
337
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "lazySchemas", void 0);
|
|
333
338
|
__decorate([YargOption({
|
|
334
339
|
envAlias: "extractEnums",
|
|
335
340
|
type: "boolean"
|
package/dist/tiny.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as getModuleOpenApiTag, A as collectApiModelSchemaExports, At as toOpenAPI30Document, B as collectReachableModelSchemas, C as applyEnumExtensions, Ct as procedureSchemaName, D as applyRobodevModuleExtensions, Dt as schemaExportName, E as applyParameterExtensions, Et as schemaComponentRef, F as collectExtraSchemas, G as findComponentEnumNames, H as compactTagName, I as collectModelSchemaExports, J as generateOpenApiFile, K as findEnumNames, L as collectModuleModelSchemaExports, M as collectContractSchemas, Mt as toOpenAPIAclRule, N as collectDbTableModelSchemaExport, Nt as toPascalCase, O as applyRobodevUserRolesExtension, Ot as sharedSchemaExportName, P as collectDbTableModelSchemaExports, Pt as visitZodSchema, Q as getModuleOpenApiController, R as collectOperationMeta, S as addContractSchema, St as operationKey, T as applyPaginatedItemSchemas, Tt as routeHasPathParameters, U as createModelSchemaNameGetter, V as collectSchemaRegistryRoots, W as defineOpenApiSchemas, X as getContractProcedureData, Y as getComponentSchemas, Z as getDerivedOperationId, _ as OpenApiSchemaRegistry, _t as namedControllerActionSchema, a as isTinyOpenApiFakeMode, at as getProcedureInputSchemaRole, b as TinyOpenApiUserRole, bt as namedOpenApiResponseSchema, c as AnyContractRouter, ct as isContractProcedure, d as GenerateOpenApiFile, dt as isObject, et as getObjectPropertySchema, f as GenerateOpenApiFileOptions, ft as isProcedureMeta, g as JsonObject, gt as namedControllerActionInputDtoSchema, h as GenerateTinyOpenApiFileOptions, ht as modelSchemaNameEntries, i as getLocalInputPath, it as getPaginatedItemSchema, j as collectContractSchemaRoots, jt as toOpenAPI30Schema, k as asStringArray, kt as stripNoContentResponseBodies, l as AnySchema, lt as isNullSchema, m as GenerateOpenApiSpec, mt as modelSchemaExportName, nt as getOperationAction, o as normalizeWatchFolders, ot as getRobodevModuleRoles, p as GenerateOpenApiFileResult, pt as isZodSchema, q as generateORPCOpenAPISpec, r as createTinyOpenApiSourceRunner, rt as getOperationController, s as AclRule, st as getStringEnumValues, t as TinyOpenApiSourceRunnerConfig, tt as getOpenApiSchemaName, u as GenerateORPCOpenAPISpecOptions, ut as isNullableOnlySchema, v as ProcedureMeta, vt as namedOpenApiOutputSchema, w as applyOperationMeta, wt as resolveOpenApiOutputPath, x as ZodSchema, xt as namedOpenApiSchema, y as TinyOpenApiModule, yt as namedOpenApiRequestSchema, z as collectOperationTags } from "./openapi-source.runner-
|
|
1
|
+
import { $ as getModuleOpenApiTag, A as collectApiModelSchemaExports, At as toOpenAPI30Document, B as collectReachableModelSchemas, C as applyEnumExtensions, Ct as procedureSchemaName, D as applyRobodevModuleExtensions, Dt as schemaExportName, E as applyParameterExtensions, Et as schemaComponentRef, F as collectExtraSchemas, G as findComponentEnumNames, H as compactTagName, I as collectModelSchemaExports, J as generateOpenApiFile, K as findEnumNames, L as collectModuleModelSchemaExports, M as collectContractSchemas, Mt as toOpenAPIAclRule, N as collectDbTableModelSchemaExport, Nt as toPascalCase, O as applyRobodevUserRolesExtension, Ot as sharedSchemaExportName, P as collectDbTableModelSchemaExports, Pt as visitZodSchema, Q as getModuleOpenApiController, R as collectOperationMeta, S as addContractSchema, St as operationKey, T as applyPaginatedItemSchemas, Tt as routeHasPathParameters, U as createModelSchemaNameGetter, V as collectSchemaRegistryRoots, W as defineOpenApiSchemas, X as getContractProcedureData, Y as getComponentSchemas, Z as getDerivedOperationId, _ as OpenApiSchemaRegistry, _t as namedControllerActionSchema, a as isTinyOpenApiFakeMode, at as getProcedureInputSchemaRole, b as TinyOpenApiUserRole, bt as namedOpenApiResponseSchema, c as AnyContractRouter, ct as isContractProcedure, d as GenerateOpenApiFile, dt as isObject, et as getObjectPropertySchema, f as GenerateOpenApiFileOptions, ft as isProcedureMeta, g as JsonObject, gt as namedControllerActionInputDtoSchema, h as GenerateTinyOpenApiFileOptions, ht as modelSchemaNameEntries, i as getLocalInputPath, it as getPaginatedItemSchema, j as collectContractSchemaRoots, jt as toOpenAPI30Schema, k as asStringArray, kt as stripNoContentResponseBodies, l as AnySchema, lt as isNullSchema, m as GenerateOpenApiSpec, mt as modelSchemaExportName, nt as getOperationAction, o as normalizeWatchFolders, ot as getRobodevModuleRoles, p as GenerateOpenApiFileResult, pt as isZodSchema, q as generateORPCOpenAPISpec, r as createTinyOpenApiSourceRunner, rt as getOperationController, s as AclRule, st as getStringEnumValues, t as TinyOpenApiSourceRunnerConfig, tt as getOpenApiSchemaName, u as GenerateORPCOpenAPISpecOptions, ut as isNullableOnlySchema, v as ProcedureMeta, vt as namedOpenApiOutputSchema, w as applyOperationMeta, wt as resolveOpenApiOutputPath, x as ZodSchema, xt as namedOpenApiSchema, y as TinyOpenApiModule, yt as namedOpenApiRequestSchema, z as collectOperationTags } from "./openapi-source.runner-CqnGK_rg.mjs";
|
|
2
2
|
export { AclRule, AnyContractRouter, AnySchema, GenerateORPCOpenAPISpecOptions, GenerateOpenApiFile, GenerateOpenApiFileOptions, GenerateOpenApiFileResult, GenerateOpenApiSpec, GenerateTinyOpenApiFileOptions, JsonObject, OpenApiSchemaRegistry, ProcedureMeta, TinyOpenApiModule, type TinyOpenApiSourceRunnerConfig, TinyOpenApiUserRole, ZodSchema, addContractSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createModelSchemaNameGetter, createTinyOpenApiSourceRunner, defineOpenApiSchemas, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getProcedureInputSchemaRole, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, modelSchemaExportName, modelSchemaNameEntries, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, procedureSchemaName, resolveOpenApiOutputPath, routeHasPathParameters, schemaComponentRef, schemaExportName, sharedSchemaExportName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as GeneralErrorCodes, t as ApplicationException } from "./error-handling-BpAQHWrU.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { l as QueryModule, t as InvalidationMap } from "./queryConfig.context-DwVQWbtL.mjs";
|
|
3
3
|
import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
//#region src/lib/react-query.types.d.ts
|
|
5
5
|
type Function = (...args: never) => unknown;
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
3
|
-
import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-
|
|
1
|
+
import { n as GenerateFileFormatter } from "./options-DQabDsdb.mjs";
|
|
2
|
+
import { t as OpenAPICodegenConfig } from "./config-YNXbfpMR.mjs";
|
|
3
|
+
import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-CqnGK_rg.mjs";
|
|
4
4
|
import { Plugin, PluginOption } from "vite";
|
|
5
5
|
//#region src/plugins/openapi-codegen.runner.d.ts
|
|
6
6
|
type OpenApiCodegenPluginConfig = OpenAPICodegenConfig & {
|
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-DmN78sag.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/package.json
CHANGED
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"@casl/ability": "6.8.0",
|
|
129
129
|
"@casl/react": "5.0.1",
|
|
130
130
|
"@tanstack/react-query": "~5.90.21",
|
|
131
|
-
"@types/bun": "1.4.
|
|
131
|
+
"@types/bun": "1.4.4",
|
|
132
132
|
"@types/node": "^25.3.0",
|
|
133
133
|
"@types/prompt-sync": "^4.2.3",
|
|
134
134
|
"@types/react": "^19.2.14",
|
|
@@ -183,9 +183,9 @@
|
|
|
183
183
|
}
|
|
184
184
|
},
|
|
185
185
|
"engines": {
|
|
186
|
-
"bun": ">= 1.4.
|
|
186
|
+
"bun": ">= 1.4.4",
|
|
187
187
|
"node": ">= 18"
|
|
188
188
|
},
|
|
189
|
-
"packageManager": "bun@1.4.
|
|
190
|
-
"version": "4.0.0-rc.
|
|
189
|
+
"packageManager": "bun@1.4.4",
|
|
190
|
+
"version": "4.0.0-rc.6"
|
|
191
191
|
}
|