@povio/openapi-codegen-cli 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,6 +8,8 @@
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
10
 
11
+ ACL features require `@casl/ability@^7.1.1` and `@casl/react@^7.1.0`. When migrating to CASL 7, regenerate the client so `AppAbility` uses `Ability` instead of `PureAbility`, and update any handwritten CASL types. The runtime continues to use `createMongoAbility` for condition matching. CASL 7 treats empty conditions (`{}`) as matching everything. The `Can` helper keeps its `use` tuple and `(isAllowed, ability)` render callback.
12
+
11
13
  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.
12
14
 
13
15
  The tool partially leverages code from [openapi-zod-client](https://github.com/astahmer/openapi-zod-client) repository.
@@ -36,6 +38,10 @@ export default {
36
38
  };
37
39
  ```
38
40
 
41
+ ## JSDoc generation
42
+
43
+ JSDoc comments are omitted by default while schemas, inferred types, and runtime behavior are preserved. Set `generateJsDoc: true` in your generator configuration or pass `--generateJsDoc` to include comments. This applies to both TypeScript and native generation. Combine with `modelsOnly: true` if you only want model files.
44
+
39
45
  ## Lazy schemas
40
46
 
41
47
  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:
@@ -125,6 +131,7 @@ bunx openapi-codegen generate --config my-config.ts
125
131
  --tsPath (Requires `--importPath` to be 'ts') Typescript import path (default: '@/data')
126
132
  --removeOperationPrefixEndingWith Remove operation name prefixes that end with the specified string (default: 'Controller_')
127
133
  --compileSchemas Eagerly compile non-recursive Zod schemas (default: false)
134
+ --generateJsDoc Emit JSDoc comments (default: false; enable with --generateJsDoc)
128
135
  --lazySchemas Build namespace model schemas on first access instead of at import; requires `--tsNamespaces` (default: false)
129
136
  --extractEnums Extract enums into separate Zod schemas (default: true)
130
137
  --modelsInCommon Keep all schema declarations in defaultTag models and emit per-module proxy exports (default: false)
package/dist/acl.d.mts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { a as ErrorHandler } from "./error-handling-LPEPQV1V.mjs";
2
- import { PropsWithChildren } from "react";
3
- import { AbilityTuple, PureAbility, RawRuleOf, Subject } from "@casl/ability";
2
+ import { PropsWithChildren, ReactNode } from "react";
3
+ import { Ability, AbilityTuple, RawRuleOf, Subject } from "@casl/ability";
4
4
  import { PackRule } from "@casl/ability/extra";
5
- import { BoundCanProps } from "@casl/react";
5
+ import { CanProps } from "@casl/react";
6
6
  //#region src/lib/acl/appAbility.types.d.ts
7
7
  type AppAbilities = AbilityTuple<string, Subject>;
8
- type AppAbility = PureAbility<AppAbilities>;
8
+ type AppAbility = Ability<AppAbilities>;
9
9
  //#endregion
10
10
  //#region src/lib/acl/ability.context.d.ts
11
11
  declare namespace AbilityContext {
@@ -16,7 +16,7 @@ declare namespace AbilityContext {
16
16
  } | null;
17
17
  }
18
18
  export const Provider: ({ children }: PropsWithChildren<ProviderProps>) => import("react").JSX.Element;
19
- export const useAbility: <TAppAbilities extends AppAbilities = AppAbilities>() => PureAbility<TAppAbilities>;
19
+ export const useAbility: <TAppAbilities extends AppAbilities = AppAbilities>() => Ability<TAppAbilities>;
20
20
  export {};
21
21
  }
22
22
  //#endregion
@@ -28,11 +28,11 @@ interface AclGuardProps<TAppAbilities extends AppAbilities = AppAbilities> {
28
28
  declare const createAclGuard: <TAppAbilities extends AppAbilities = AppAbilities>() => ({ canUse, redirectTo, children }: PropsWithChildren<AclGuardProps<TAppAbilities>>) => import("react").ReactNode;
29
29
  //#endregion
30
30
  //#region src/lib/acl/Can.d.ts
31
- type CanAbility = PureAbility<AbilityTuple<AppAbilities[0], AppAbilities[1]>>;
32
- type CanProps<TAppAbilities extends AppAbilities = AppAbilities> = {
31
+ type CanProps$1<TAppAbilities extends AppAbilities = AppAbilities> = {
33
32
  use: TAppAbilities;
34
- } & Omit<BoundCanProps<CanAbility>, "do" | "I" | "on" | "a" | "an" | "this">;
35
- declare const Can: <TAppAbilities extends AppAbilities = AppAbilities>({ use, ...props }: CanProps<TAppAbilities>) => import("react").JSX.Element;
33
+ children: ReactNode | ((isAllowed: boolean, ability: AppAbility) => ReactNode);
34
+ } & Omit<CanProps<AppAbility>, "do" | "I" | "on" | "a" | "an" | "this" | "children">;
35
+ declare const Can: <TAppAbilities extends AppAbilities = AppAbilities>({ use, children, ...props }: CanProps$1<TAppAbilities>) => import("react").JSX.Element;
36
36
  //#endregion
37
37
  //#region src/lib/acl/useAclCheck.d.ts
38
38
  interface UseAclCheckProps {
package/dist/acl.mjs CHANGED
@@ -5,7 +5,7 @@ import { createContext, useCallback, useMemo } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { AbilityBuilder, createMongoAbility } from "@casl/ability";
7
7
  import { unpackRules } from "@casl/ability/extra";
8
- import { createContextualCan, useAbility } from "@casl/react";
8
+ import { AbilityProvider, Can as Can$1, useAbility } from "@casl/react";
9
9
  //#region src/lib/acl/ability.context.tsx
10
10
  let AbilityContext;
11
11
  (function(_AbilityContext) {
@@ -27,11 +27,14 @@ let AbilityContext;
27
27
  }, [user]);
28
28
  return /* @__PURE__ */ jsx(Context.Provider, {
29
29
  value: ability,
30
- children
30
+ children: /* @__PURE__ */ jsx(AbilityProvider, {
31
+ value: ability,
32
+ children
33
+ })
31
34
  });
32
35
  };
33
36
  _AbilityContext.useAbility = () => {
34
- return useAbility(Context);
37
+ return useAbility();
35
38
  };
36
39
  })(AbilityContext || (AbilityContext = {}));
37
40
  //#endregion
@@ -47,13 +50,13 @@ const createAclGuard = () => ({ canUse, redirectTo = "/", children }) => {
47
50
  };
48
51
  //#endregion
49
52
  //#region src/lib/acl/Can.tsx
50
- const ContextualCan = createContextualCan(AbilityContext.Consumer);
51
- const Can = ({ use, ...props }) => {
53
+ const Can = ({ use, children, ...props }) => {
52
54
  const [action, subject] = use;
53
- return /* @__PURE__ */ jsx(ContextualCan, {
55
+ return /* @__PURE__ */ jsx(Can$1, {
54
56
  ...props,
55
57
  do: action,
56
- on: subject
58
+ on: subject,
59
+ children: typeof children === "function" ? ({ isAllowed, ability }) => props.passThrough || isAllowed ? children(isAllowed, ability) : null : children
57
60
  });
58
61
  };
59
62
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as GenerateOptions } from "./options-rz2bcsaN.mjs";
1
+ import { t as GenerateOptions } from "./options-DH-fAG0w.mjs";
2
2
  //#region src/generators/types/config.d.ts
3
3
  type OpenAPICodegenConfig = Partial<GenerateOptions>;
4
4
  //#endregion
@@ -495,6 +495,7 @@ const DEFAULT_GENERATE_OPTIONS = {
495
495
  standalone: false,
496
496
  compileSchemas: false,
497
497
  lazySchemas: false,
498
+ generateJsDoc: false,
498
499
  schemaSuffix: SCHEMA_SUFFIX,
499
500
  enumSuffix: ENUM_SUFFIX,
500
501
  modelsInCommon: false,
@@ -1578,7 +1579,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
1578
1579
  const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
1579
1580
  if (nativeFiles) return nativeFiles;
1580
1581
  }
1581
- const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-CDyGSv2w.mjs").then((n) => n.n);
1582
+ const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-Ck2To2p7.mjs").then((n) => n.n);
1582
1583
  return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
1583
1584
  source: nativeInput.source,
1584
1585
  yaml: nativeInput.yaml
@@ -105,6 +105,7 @@ const DEFAULT_GENERATE_OPTIONS = {
105
105
  standalone: false,
106
106
  compileSchemas: false,
107
107
  lazySchemas: false,
108
+ generateJsDoc: false,
108
109
  schemaSuffix: SCHEMA_SUFFIX,
109
110
  enumSuffix: ENUM_SUFFIX,
110
111
  modelsInCommon: false,
@@ -1,5 +1,5 @@
1
- import { r as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-DYiCTWno.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-CLK1FoLT.mjs";
1
+ import { r as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-BYOBNMS6.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-CO4nuLr2.mjs";
3
3
  import "node:module";
4
4
  //#region \0rolldown/runtime.js
5
5
  var __defProp = Object.defineProperty;
@@ -22,7 +22,7 @@ const ACL_APP_ABILITIES = "AppAbilities";
22
22
  const ACL_CHECK_HOOK = "useAclCheck";
23
23
  const CASL_ABILITY_BINDING = {
24
24
  abilityTuple: "AbilityTuple",
25
- pureAbility: "PureAbility",
25
+ ability: "Ability",
26
26
  forcedSubject: "ForcedSubject",
27
27
  subjectType: "Subject",
28
28
  subject: "subject"
@@ -30,7 +30,7 @@ const CASL_ABILITY_BINDING = {
30
30
  const CASL_ABILITY_IMPORT = {
31
31
  bindings: [
32
32
  CASL_ABILITY_BINDING.abilityTuple,
33
- CASL_ABILITY_BINDING.pureAbility,
33
+ CASL_ABILITY_BINDING.ability,
34
34
  CASL_ABILITY_BINDING.forcedSubject,
35
35
  CASL_ABILITY_BINDING.subjectType,
36
36
  CASL_ABILITY_BINDING.subject
@@ -89,7 +89,7 @@ function generateAppAcl({ resolver, data }) {
89
89
  const caslAbilityTupleImport = {
90
90
  bindings: [],
91
91
  typeBindings: [
92
- CASL_ABILITY_BINDING.pureAbility,
92
+ CASL_ABILITY_BINDING.ability,
93
93
  CASL_ABILITY_BINDING.abilityTuple,
94
94
  ...!appAbilitiesType ? [CASL_ABILITY_BINDING.subjectType] : [],
95
95
  ...hasAdditionalAbilityImports ? [CASL_ABILITY_BINDING.forcedSubject] : []
@@ -106,7 +106,7 @@ function generateAppAcl({ resolver, data }) {
106
106
  for (const [action, subjects] of Object.entries(appAbilitiesType)) lines.push(`| ${CASL_ABILITY_BINDING.abilityTuple}<"${action}", ${subjects.join(" | ")}>`);
107
107
  } else lines.push(`export type ${ACL_APP_ABILITIES} = ${CASL_ABILITY_BINDING.abilityTuple}<string, ${CASL_ABILITY_BINDING.subjectType}>;`);
108
108
  lines.push("");
109
- lines.push(`export type AppAbility = PureAbility<${ACL_APP_ABILITIES}>;`);
109
+ lines.push(`export type AppAbility = ${CASL_ABILITY_BINDING.ability}<${ACL_APP_ABILITIES}>;`);
110
110
  return lines.join("\n");
111
111
  }
112
112
  function renderImport$4(importData) {
@@ -154,12 +154,14 @@ function renderAbilityFunction({ resolver, endpoint }) {
154
154
  const hasConditions = hasAbilityConditions(endpoint);
155
155
  const lines = [];
156
156
  const abilityQuery = endpoint.method === "get" ? endpoint.mediaDownload ? `\`${getQueryName(endpoint)}\` query or \`${getQueryName(endpoint, true)}\` mutation` : `\`${getQueryName(endpoint)}\` query` : `\`${getQueryName(endpoint)}\` mutation`;
157
- lines.push("/**");
158
- lines.push(` * Use for ${abilityQuery} ability. ${hasConditions ? "For global ability, omit the object parameter." : ""}${getAbilityDescription(endpoint) ? "" : ""}`);
159
- if (getAbilityDescription(endpoint)) lines.push(` * @description ${getAbilityDescription(endpoint)}`);
160
- if (hasConditions) for (const propertyType of abilityConditionsTypes) lines.push(` * @param { ${renderConditionType(resolver, endpoint, propertyType)} } object.${propertyType.name} ${propertyType.name} from ${propertyType.info}`);
161
- lines.push(` * @returns { AbilityTuple } An ability tuple indicating the user's ability to use ${abilityQuery}`);
162
- lines.push(" */");
157
+ if (resolver.options.generateJsDoc === true) {
158
+ lines.push("/**");
159
+ lines.push(` * Use for ${abilityQuery} ability. ${hasConditions ? "For global ability, omit the object parameter." : ""}${getAbilityDescription(endpoint) ? "" : ""}`);
160
+ if (getAbilityDescription(endpoint)) lines.push(` * @description ${getAbilityDescription(endpoint)}`);
161
+ if (hasConditions) for (const propertyType of abilityConditionsTypes) lines.push(` * @param { ${renderConditionType(resolver, endpoint, propertyType)} } object.${propertyType.name} ${propertyType.name} from ${propertyType.info}`);
162
+ lines.push(` * @returns { AbilityTuple } An ability tuple indicating the user's ability to use ${abilityQuery}`);
163
+ lines.push(" */");
164
+ }
163
165
  lines.push(`export const ${getAbilityFunctionName(endpoint)} = (`);
164
166
  if (hasConditions) lines.push(` object?: { ${abilityConditionsTypes.map((propertyType) => `${propertyType.name}${propertyType.required ? "" : "?"}: ${renderConditionType(resolver, endpoint, propertyType)}, `).join("")} } `);
165
167
  lines.push(") => [");
@@ -925,7 +927,7 @@ function generateModels({ resolver, data, tag }) {
925
927
  options: resolver.options
926
928
  })} {`);
927
929
  for (const [name, zodSchema] of Object.entries(zodSchemasData)) {
928
- lines.push(renderModelJsDocs({
930
+ if (resolver.options.generateJsDoc === true) lines.push(renderModelJsDocs({
929
931
  name,
930
932
  zodSchema,
931
933
  tag,
@@ -958,7 +960,7 @@ function renderLazyModels({ resolver, tag, zodSchemasData, lines }) {
958
960
  const typeAnnotation = zodSchema.isCircular ? `: () => z.ZodObject<z.ZodRawShape> & z.ZodType<${namespace}.${inferredTypeName}>` : "";
959
961
  const schemaCode = resolver.options.compileSchemas && !zodSchema.isCircular ? `z.compile(${zodSchema.code})` : zodSchema.code;
960
962
  lines.push(`const ${name}${typeAnnotation} = once(() => ${callLazySchemaReferences(schemaCode, schemaNames)});`);
961
- members.push(...indent(renderModelJsDocs({
963
+ if (resolver.options.generateJsDoc === true) members.push(...indent(renderModelJsDocs({
962
964
  name,
963
965
  zodSchema,
964
966
  tag,
@@ -1108,6 +1110,7 @@ function renderImport$1(importData) {
1108
1110
  return `import${importData.typeOnly ? " type" : ""} ${names} from "${importData.from}";`;
1109
1111
  }
1110
1112
  function renderModelJsDocs({ name, zodSchema, tag, resolver }) {
1113
+ if (resolver.options.generateJsDoc !== true) return "";
1111
1114
  const lines = [
1112
1115
  `/** `,
1113
1116
  ` * ${name} `,
@@ -1451,6 +1454,7 @@ function addAsteriskAfterNewLine(str) {
1451
1454
  return str.replace(/\n/g, "\n *");
1452
1455
  }
1453
1456
  function renderQueryJsDocs({ resolver, endpoint, mode, tag }) {
1457
+ if (resolver.options.generateJsDoc !== true) return "";
1454
1458
  const lines = ["/** "];
1455
1459
  if (mode === "infiniteQuery") lines.push(` * Infinite query \`${getInfiniteQueryName(endpoint)}${endpoint.summary ? "" : ""}`);
1456
1460
  else if (mode === "query") lines.push(` * Query \`${getQueryName(endpoint)}\`${endpoint.summary && endpoint.mediaDownload ? " - recommended when file should be cached" : ""}`);
@@ -1642,7 +1646,7 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
1642
1646
  const requestConfig = `{ ${hasAxiosRequestConfig ? `...${AXIOS_REQUEST_CONFIG_NAME}, ` : ""}allowInvalidResponseData: queryConfig.allowInvalidResponseData }`;
1643
1647
  const queryOptionsArgs = `${resolvedEndpointArgs ? `{ ${resolvedEndpointArgs} }, ` : ""}${requestConfig}`;
1644
1648
  const lines = [];
1645
- lines.push(renderQueryJsDocs({
1649
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
1646
1650
  resolver,
1647
1651
  endpoint,
1648
1652
  mode: "query",
@@ -1712,7 +1716,7 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
1712
1716
  const pathParamFirstArg = isScoped ? `{ ${scopePathParams.map((p) => p.name).join(", ")} }: { ${scopePathParams.map((p) => `${p.name}: ${p.type}`).join("; ")} }, ` : "";
1713
1717
  const mutationOptionsTypeArg = isScoped ? nonPathMutationVariablesType ? `, { ${nonPathMutationVariablesType} }` : "" : `, { ${mutationVariablesType} }`;
1714
1718
  const lines = [];
1715
- lines.push(renderQueryJsDocs({
1719
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
1716
1720
  resolver,
1717
1721
  endpoint,
1718
1722
  mode: "mutation",
@@ -1831,7 +1835,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
1831
1835
  const queryOptionsArgs = `${resolvedEndpointArgsWithoutPage ? `{ ${resolvedEndpointArgsWithoutPage} }, ` : ""}${requestConfig}`;
1832
1836
  const hasQueryFnOverride = hasAclCheck;
1833
1837
  const lines = [];
1834
- lines.push(renderQueryJsDocs({
1838
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
1835
1839
  resolver,
1836
1840
  endpoint,
1837
1841
  mode: "infiniteQuery",
@@ -1903,7 +1907,7 @@ function generateDomainErrors({ resolver, data }) {
1903
1907
  const sb = String(b.code);
1904
1908
  return sa < sb ? -1 : sa > sb ? 1 : 0;
1905
1909
  }).map(({ code, name, description }) => {
1906
- const comment = description ? ` /** ${description} */\n ` : " ";
1910
+ const comment = resolver.options.generateJsDoc === true && description ? ` /** ${description} */\n ` : " ";
1907
1911
  const key = name ?? (typeof code === "string" ? code : `ERROR_${code}`);
1908
1912
  if (!VALID_IDENTIFIER.test(key)) throw new Error(`Domain error code "${code}" produces an invalid identifier "${key}". Use the 'name' field on @ApiDomainErrorResponse to provide a valid identifier.`);
1909
1913
  return `${comment}${key}: ${typeof code === "string" ? `"${code}"` : String(code)}`;
@@ -1,4 +1,4 @@
1
- const require_generate_utils = require("./generate.utils-BSDYGp-0.cjs");
1
+ const require_generate_utils = require("./generate.utils-SfgYwPe7.cjs");
2
2
  //#region src/generators/const/acl.const.ts
3
3
  const ACL_APP_ABILITY_FILE = {
4
4
  fileName: "acl/app.ability",
@@ -8,7 +8,7 @@ const ACL_APP_ABILITIES = "AppAbilities";
8
8
  const ACL_CHECK_HOOK = "useAclCheck";
9
9
  const CASL_ABILITY_BINDING = {
10
10
  abilityTuple: "AbilityTuple",
11
- pureAbility: "PureAbility",
11
+ ability: "Ability",
12
12
  forcedSubject: "ForcedSubject",
13
13
  subjectType: "Subject",
14
14
  subject: "subject"
@@ -16,7 +16,7 @@ const CASL_ABILITY_BINDING = {
16
16
  const CASL_ABILITY_IMPORT = {
17
17
  bindings: [
18
18
  CASL_ABILITY_BINDING.abilityTuple,
19
- CASL_ABILITY_BINDING.pureAbility,
19
+ CASL_ABILITY_BINDING.ability,
20
20
  CASL_ABILITY_BINDING.forcedSubject,
21
21
  CASL_ABILITY_BINDING.subjectType,
22
22
  CASL_ABILITY_BINDING.subject
@@ -94,8 +94,9 @@ function getZodChainableNumberValidations(schema) {
94
94
  }
95
95
  function getZodChainableArrayValidations(schema) {
96
96
  const validations = [];
97
- if (schema.minItems) validations.push(`min(${schema.minItems})`);
98
- if (schema.maxItems) validations.push(`max(${schema.maxItems})`);
97
+ const tuple = Array.isArray(schema.items);
98
+ if (schema.minItems) validations.push(tuple ? `refine((value) => value.length >= ${schema.minItems})` : `min(${schema.minItems})`);
99
+ if (schema.maxItems) validations.push(tuple ? `refine((value) => value.length <= ${schema.maxItems})` : `max(${schema.maxItems})`);
99
100
  return validations.join(".");
100
101
  }
101
102
  //#endregion
@@ -302,6 +303,35 @@ function getZodSchema({ schema, resolver, meta: inheritedMeta, tag }) {
302
303
  if (primitiveZodSchema) return primitiveZodSchema;
303
304
  const readonly = resolver.options.allReadonly ? ".readonly()" : "";
304
305
  if (require_generate_utils.isArraySchemaObject(schema)) {
306
+ if (Array.isArray(schema.items)) {
307
+ const tuple = schema;
308
+ const items = schema.items.map((item, index) => {
309
+ return getZodSchema({
310
+ ...params,
311
+ schema: item
312
+ }).getCodeString(tag, resolver.options) + getZodChain({
313
+ schema: item,
314
+ meta: {
315
+ ...meta,
316
+ isRequired: true
317
+ },
318
+ options: resolver.options
319
+ }) + (index >= (schema.minItems ?? 0) ? ".optional()" : "");
320
+ });
321
+ const restSchema = typeof tuple.additionalItems === "object" ? getZodSchema({
322
+ ...params,
323
+ schema: tuple.additionalItems
324
+ }).getCodeString(tag, resolver.options) + getZodChain({
325
+ schema: tuple.additionalItems,
326
+ meta: {
327
+ ...meta,
328
+ isRequired: true
329
+ },
330
+ options: resolver.options
331
+ }) : require_generate_utils.ANY_SCHEMA;
332
+ const rest = tuple.additionalItems === false ? "" : `.rest(${restSchema})`;
333
+ return zodSchema.assign(`z.tuple([${items.join(", ")}])${rest}${readonly}`);
334
+ }
305
335
  if (schema.items) return zodSchema.assign(`z.array(${getZodSchema({
306
336
  ...params,
307
337
  schema: schema.items
@@ -2072,7 +2102,7 @@ function generateAppAcl({ resolver, data }) {
2072
2102
  const caslAbilityTupleImport = {
2073
2103
  bindings: [],
2074
2104
  typeBindings: [
2075
- CASL_ABILITY_BINDING.pureAbility,
2105
+ CASL_ABILITY_BINDING.ability,
2076
2106
  CASL_ABILITY_BINDING.abilityTuple,
2077
2107
  ...!appAbilitiesType ? [CASL_ABILITY_BINDING.subjectType] : [],
2078
2108
  ...hasAdditionalAbilityImports ? [CASL_ABILITY_BINDING.forcedSubject] : []
@@ -2089,7 +2119,7 @@ function generateAppAcl({ resolver, data }) {
2089
2119
  for (const [action, subjects] of Object.entries(appAbilitiesType)) lines.push(`| ${CASL_ABILITY_BINDING.abilityTuple}<"${action}", ${subjects.join(" | ")}>`);
2090
2120
  } else lines.push(`export type ${ACL_APP_ABILITIES} = ${CASL_ABILITY_BINDING.abilityTuple}<string, ${CASL_ABILITY_BINDING.subjectType}>;`);
2091
2121
  lines.push("");
2092
- lines.push(`export type AppAbility = PureAbility<${ACL_APP_ABILITIES}>;`);
2122
+ lines.push(`export type AppAbility = ${CASL_ABILITY_BINDING.ability}<${ACL_APP_ABILITIES}>;`);
2093
2123
  return lines.join("\n");
2094
2124
  }
2095
2125
  function renderImport$4(importData) {
@@ -2137,12 +2167,14 @@ function renderAbilityFunction({ resolver, endpoint }) {
2137
2167
  const hasConditions = require_generate_utils.hasAbilityConditions(endpoint);
2138
2168
  const lines = [];
2139
2169
  const abilityQuery = endpoint.method === "get" ? endpoint.mediaDownload ? `\`${require_generate_utils.getQueryName(endpoint)}\` query or \`${require_generate_utils.getQueryName(endpoint, true)}\` mutation` : `\`${require_generate_utils.getQueryName(endpoint)}\` query` : `\`${require_generate_utils.getQueryName(endpoint)}\` mutation`;
2140
- lines.push("/**");
2141
- lines.push(` * Use for ${abilityQuery} ability. ${hasConditions ? "For global ability, omit the object parameter." : ""}${require_generate_utils.getAbilityDescription(endpoint) ? "" : ""}`);
2142
- if (require_generate_utils.getAbilityDescription(endpoint)) lines.push(` * @description ${require_generate_utils.getAbilityDescription(endpoint)}`);
2143
- if (hasConditions) for (const propertyType of abilityConditionsTypes) lines.push(` * @param { ${renderConditionType(resolver, endpoint, propertyType)} } object.${propertyType.name} ${propertyType.name} from ${propertyType.info}`);
2144
- lines.push(` * @returns { AbilityTuple } An ability tuple indicating the user's ability to use ${abilityQuery}`);
2145
- lines.push(" */");
2170
+ if (resolver.options.generateJsDoc === true) {
2171
+ lines.push("/**");
2172
+ lines.push(` * Use for ${abilityQuery} ability. ${hasConditions ? "For global ability, omit the object parameter." : ""}${require_generate_utils.getAbilityDescription(endpoint) ? "" : ""}`);
2173
+ if (require_generate_utils.getAbilityDescription(endpoint)) lines.push(` * @description ${require_generate_utils.getAbilityDescription(endpoint)}`);
2174
+ if (hasConditions) for (const propertyType of abilityConditionsTypes) lines.push(` * @param { ${renderConditionType(resolver, endpoint, propertyType)} } object.${propertyType.name} ${propertyType.name} from ${propertyType.info}`);
2175
+ lines.push(` * @returns { AbilityTuple } An ability tuple indicating the user's ability to use ${abilityQuery}`);
2176
+ lines.push(" */");
2177
+ }
2146
2178
  lines.push(`export const ${require_generate_utils.getAbilityFunctionName(endpoint)} = (`);
2147
2179
  if (hasConditions) lines.push(` object?: { ${abilityConditionsTypes.map((propertyType) => `${propertyType.name}${propertyType.required ? "" : "?"}: ${renderConditionType(resolver, endpoint, propertyType)}, `).join("")} } `);
2148
2180
  lines.push(") => [");
@@ -2908,7 +2940,7 @@ function generateModels({ resolver, data, tag }) {
2908
2940
  options: resolver.options
2909
2941
  })} {`);
2910
2942
  for (const [name, zodSchema] of Object.entries(zodSchemasData)) {
2911
- lines.push(renderModelJsDocs({
2943
+ if (resolver.options.generateJsDoc === true) lines.push(renderModelJsDocs({
2912
2944
  name,
2913
2945
  zodSchema,
2914
2946
  tag,
@@ -2941,7 +2973,7 @@ function renderLazyModels({ resolver, tag, zodSchemasData, lines }) {
2941
2973
  const typeAnnotation = zodSchema.isCircular ? `: () => z.ZodObject<z.ZodRawShape> & z.ZodType<${namespace}.${inferredTypeName}>` : "";
2942
2974
  const schemaCode = resolver.options.compileSchemas && !zodSchema.isCircular ? `z.compile(${zodSchema.code})` : zodSchema.code;
2943
2975
  lines.push(`const ${name}${typeAnnotation} = once(() => ${callLazySchemaReferences(schemaCode, schemaNames)});`);
2944
- members.push(...indent(renderModelJsDocs({
2976
+ if (resolver.options.generateJsDoc === true) members.push(...indent(renderModelJsDocs({
2945
2977
  name,
2946
2978
  zodSchema,
2947
2979
  tag,
@@ -3091,6 +3123,7 @@ function renderImport$1(importData) {
3091
3123
  return `import${importData.typeOnly ? " type" : ""} ${names} from "${importData.from}";`;
3092
3124
  }
3093
3125
  function renderModelJsDocs({ name, zodSchema, tag, resolver }) {
3126
+ if (resolver.options.generateJsDoc !== true) return "";
3094
3127
  const lines = [
3095
3128
  `/** `,
3096
3129
  ` * ${name} `,
@@ -3434,6 +3467,7 @@ function addAsteriskAfterNewLine(str) {
3434
3467
  return str.replace(/\n/g, "\n *");
3435
3468
  }
3436
3469
  function renderQueryJsDocs({ resolver, endpoint, mode, tag }) {
3470
+ if (resolver.options.generateJsDoc !== true) return "";
3437
3471
  const lines = ["/** "];
3438
3472
  if (mode === "infiniteQuery") lines.push(` * Infinite query \`${require_generate_utils.getInfiniteQueryName(endpoint)}${endpoint.summary ? "" : ""}`);
3439
3473
  else if (mode === "query") lines.push(` * Query \`${require_generate_utils.getQueryName(endpoint)}\`${endpoint.summary && endpoint.mediaDownload ? " - recommended when file should be cached" : ""}`);
@@ -3625,7 +3659,7 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
3625
3659
  const requestConfig = `{ ${hasAxiosRequestConfig ? `...${require_generate_utils.AXIOS_REQUEST_CONFIG_NAME}, ` : ""}allowInvalidResponseData: queryConfig.allowInvalidResponseData }`;
3626
3660
  const queryOptionsArgs = `${resolvedEndpointArgs ? `{ ${resolvedEndpointArgs} }, ` : ""}${requestConfig}`;
3627
3661
  const lines = [];
3628
- lines.push(renderQueryJsDocs({
3662
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
3629
3663
  resolver,
3630
3664
  endpoint,
3631
3665
  mode: "query",
@@ -3695,7 +3729,7 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
3695
3729
  const pathParamFirstArg = isScoped ? `{ ${scopePathParams.map((p) => p.name).join(", ")} }: { ${scopePathParams.map((p) => `${p.name}: ${p.type}`).join("; ")} }, ` : "";
3696
3730
  const mutationOptionsTypeArg = isScoped ? nonPathMutationVariablesType ? `, { ${nonPathMutationVariablesType} }` : "" : `, { ${mutationVariablesType} }`;
3697
3731
  const lines = [];
3698
- lines.push(renderQueryJsDocs({
3732
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
3699
3733
  resolver,
3700
3734
  endpoint,
3701
3735
  mode: "mutation",
@@ -3814,7 +3848,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
3814
3848
  const queryOptionsArgs = `${resolvedEndpointArgsWithoutPage ? `{ ${resolvedEndpointArgsWithoutPage} }, ` : ""}${requestConfig}`;
3815
3849
  const hasQueryFnOverride = hasAclCheck;
3816
3850
  const lines = [];
3817
- lines.push(renderQueryJsDocs({
3851
+ if (resolver.options.generateJsDoc === true) lines.push(renderQueryJsDocs({
3818
3852
  resolver,
3819
3853
  endpoint,
3820
3854
  mode: "infiniteQuery",
@@ -3886,7 +3920,7 @@ function generateDomainErrors({ resolver, data }) {
3886
3920
  const sb = String(b.code);
3887
3921
  return sa < sb ? -1 : sa > sb ? 1 : 0;
3888
3922
  }).map(({ code, name, description }) => {
3889
- const comment = description ? ` /** ${description} */\n ` : " ";
3923
+ const comment = resolver.options.generateJsDoc === true && description ? ` /** ${description} */\n ` : " ";
3890
3924
  const key = name ?? (typeof code === "string" ? code : `ERROR_${code}`);
3891
3925
  if (!VALID_IDENTIFIER.test(key)) throw new Error(`Domain error code "${code}" produces an invalid identifier "${key}". Use the 'name' field on @ApiDomainErrorResponse to provide a valid identifier.`);
3892
3926
  return `${comment}${key}: ${typeof code === "string" ? `"${code}"` : String(code)}`;
@@ -1,4 +1,4 @@
1
- import { n as GenerateFileData, t as GenerateOptions } from "./options-rz2bcsaN.mjs";
1
+ import { n as GenerateFileData, t as GenerateOptions } from "./options-DH-fAG0w.mjs";
2
2
  import { OpenAPIV3 } from "openapi-types";
3
3
  //#region src/generators/types/metadata.d.ts
4
4
  interface GenerateParams {
@@ -1,6 +1,6 @@
1
- import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CDyGSv2w.mjs";
2
- import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-DYiCTWno.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-CLK1FoLT.mjs";
1
+ import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-Ck2To2p7.mjs";
2
+ import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-BYOBNMS6.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-CO4nuLr2.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-CLK1FoLT.mjs";
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-CO4nuLr2.mjs";
2
2
  //#region src/generators/const/validation.const.ts
3
3
  const HTTP_STATUS_CODES = {
4
4
  "100": "Continue",
@@ -132,8 +132,9 @@ function getZodChainableNumberValidations(schema) {
132
132
  }
133
133
  function getZodChainableArrayValidations(schema) {
134
134
  const validations = [];
135
- if (schema.minItems) validations.push(`min(${schema.minItems})`);
136
- if (schema.maxItems) validations.push(`max(${schema.maxItems})`);
135
+ const tuple = Array.isArray(schema.items);
136
+ if (schema.minItems) validations.push(tuple ? `refine((value) => value.length >= ${schema.minItems})` : `min(${schema.minItems})`);
137
+ if (schema.maxItems) validations.push(tuple ? `refine((value) => value.length <= ${schema.maxItems})` : `max(${schema.maxItems})`);
137
138
  return validations.join(".");
138
139
  }
139
140
  //#endregion
@@ -340,6 +341,35 @@ function getZodSchema({ schema, resolver, meta: inheritedMeta, tag }) {
340
341
  if (primitiveZodSchema) return primitiveZodSchema;
341
342
  const readonly = resolver.options.allReadonly ? ".readonly()" : "";
342
343
  if (isArraySchemaObject(schema)) {
344
+ if (Array.isArray(schema.items)) {
345
+ const tuple = schema;
346
+ const items = schema.items.map((item, index) => {
347
+ return getZodSchema({
348
+ ...params,
349
+ schema: item
350
+ }).getCodeString(tag, resolver.options) + getZodChain({
351
+ schema: item,
352
+ meta: {
353
+ ...meta,
354
+ isRequired: true
355
+ },
356
+ options: resolver.options
357
+ }) + (index >= (schema.minItems ?? 0) ? ".optional()" : "");
358
+ });
359
+ const restSchema = typeof tuple.additionalItems === "object" ? getZodSchema({
360
+ ...params,
361
+ schema: tuple.additionalItems
362
+ }).getCodeString(tag, resolver.options) + getZodChain({
363
+ schema: tuple.additionalItems,
364
+ meta: {
365
+ ...meta,
366
+ isRequired: true
367
+ },
368
+ options: resolver.options
369
+ }) : ANY_SCHEMA;
370
+ const rest = tuple.additionalItems === false ? "" : `.rest(${restSchema})`;
371
+ return zodSchema.assign(`z.tuple([${items.join(", ")}])${rest}${readonly}`);
372
+ }
343
373
  if (schema.items) return zodSchema.assign(`z.array(${getZodSchema({
344
374
  ...params,
345
375
  schema: schema.items
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import { a as RestClient, i as Response, n as RequestConfig, o as RestIntercepto
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
7
  import { t as RestUtils } from "./rest.utils-DpiFIdhF.mjs";
8
- import { t as OpenAPICodegenConfig } from "./config-FD2Y872S.mjs";
8
+ import { t as OpenAPICodegenConfig } from "./config-BYiBd1QI.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";
11
11
  import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-DIdL8tlx.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-BSDYGp-0.cjs");
2
+ const require_generate_utils = require("./generate.utils-SfgYwPe7.cjs");
3
3
  let fs = require("fs");
4
4
  fs = require_generate_utils.__toESM(fs, 1);
5
5
  let path = require("path");
@@ -103,7 +103,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
103
103
  const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
104
104
  if (nativeFiles) return nativeFiles;
105
105
  }
106
- const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-BypeVKIE.cjs"));
106
+ const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-dhiLYAO2.cjs"));
107
107
  return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
108
108
  source: nativeInput.source,
109
109
  yaml: nativeInput.yaml
package/dist/metro.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { r as GenerateFileFormatter } from "./options-rz2bcsaN.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-FD2Y872S.mjs";
3
- import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-Bje-tMOV.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-DH-fAG0w.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-BYiBd1QI.mjs";
3
+ import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-lmK-P6HE.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-DUqQD2B5.mjs";
1
+ import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-BQAjeonK.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";
@@ -1,4 +1,4 @@
1
- import { Wn as Profiler, n as runGenerate } from "./generate.runner-CLK1FoLT.mjs";
1
+ import { Wn as Profiler, n as runGenerate } from "./generate.runner-CO4nuLr2.mjs";
2
2
  import path from "path";
3
3
  //#region src/plugins/openapi-codegen.runner.ts
4
4
  function createOpenApiCodegenRunner(config, options = {}) {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPICodegenConfig } from "./config-FD2Y872S.mjs";
1
+ import { t as OpenAPICodegenConfig } from "./config-BYiBd1QI.mjs";
2
2
  //#region src/tiny/openapi.d.ts
3
3
  interface GenerateOpenApiFileOptions {
4
4
  argv?: readonly string[];
@@ -19,6 +19,8 @@ interface ZodGenerateOptions {
19
19
  compileSchemas?: boolean;
20
20
  /** Build namespace model schemas on first access instead of at import. Requires tsNamespaces. */
21
21
  lazySchemas?: boolean;
22
+ /** Emit JSDoc comments in generated code. Defaults to false. */
23
+ generateJsDoc?: boolean;
22
24
  schemaSuffix: string;
23
25
  enumSuffix: string;
24
26
  modelsInCommon?: boolean;
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-DYiCTWno.mjs";
3
- import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-CLK1FoLT.mjs";
2
+ import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-BYOBNMS6.mjs";
3
+ import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-CO4nuLr2.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.3.0";
34
+ return "3.3.2";
35
35
  }
36
36
  //#endregion
37
37
  //#region src/helpers/yargs.helper.ts
@@ -266,6 +266,7 @@ var GenerateOptions = class {
266
266
  importPath;
267
267
  compileSchemas;
268
268
  lazySchemas;
269
+ generateJsDoc;
269
270
  extractEnums;
270
271
  modelsInCommon;
271
272
  modelsInModules;
@@ -333,6 +334,10 @@ __decorate([YargOption({
333
334
  envAlias: "lazySchemas",
334
335
  type: "boolean"
335
336
  }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "lazySchemas", void 0);
337
+ __decorate([YargOption({
338
+ envAlias: "generateJsDoc",
339
+ type: "boolean"
340
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "generateJsDoc", void 0);
336
341
  __decorate([YargOption({
337
342
  envAlias: "extractEnums",
338
343
  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-Bje-tMOV.mjs";
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-lmK-P6HE.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 };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { r as GenerateFileFormatter } from "./options-rz2bcsaN.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-FD2Y872S.mjs";
3
- import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-Bje-tMOV.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-DH-fAG0w.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-BYiBd1QI.mjs";
3
+ import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-lmK-P6HE.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-DUqQD2B5.mjs";
1
+ import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-BQAjeonK.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
@@ -125,13 +125,14 @@
125
125
  "yargs": "^18.0.0"
126
126
  },
127
127
  "devDependencies": {
128
- "@casl/ability": "6.8.0",
129
- "@casl/react": "5.0.1",
128
+ "@casl/ability": "7.1.1",
129
+ "@casl/react": "7.1.0",
130
130
  "@tanstack/react-query": "~5.90.21",
131
131
  "@types/bun": "1.4.1",
132
132
  "@types/node": "^25.3.0",
133
133
  "@types/prompt-sync": "^4.2.3",
134
134
  "@types/react": "^19.2.14",
135
+ "@types/react-test-renderer": "^19.1.0",
135
136
  "@types/yargs": "^17.0.35",
136
137
  "@vitejs/plugin-react": "^5.1.4",
137
138
  "axios": "^1.13.1",
@@ -140,6 +141,7 @@
140
141
  "oxlint": "1.50.0",
141
142
  "oxlint-tsgolint": "^0.15.0",
142
143
  "react": "^19.2.4",
144
+ "react-test-renderer": "19.2.4",
143
145
  "tsdown": "^0.22.14",
144
146
  "tsx": "^4.21.0",
145
147
  "type-fest": "^5.4.4",
@@ -150,8 +152,8 @@
150
152
  "zod": "^4.5.0"
151
153
  },
152
154
  "peerDependencies": {
153
- "@casl/ability": "^6.7.3",
154
- "@casl/react": "^5.0.0",
155
+ "@casl/ability": "^7.1.1",
156
+ "@casl/react": "^7.1.0",
155
157
  "@tanstack/react-query": "^5.90.21",
156
158
  "axios": "^1.13.1",
157
159
  "i18next": "^25.8.11",
@@ -187,5 +189,5 @@
187
189
  "node": ">= 18"
188
190
  },
189
191
  "packageManager": "bun@1.4.1",
190
- "version": "3.3.0"
192
+ "version": "3.3.2"
191
193
  }