@povio/openapi-codegen-cli 3.3.1 → 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.
@@ -1579,7 +1579,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
1579
1579
  const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
1580
1580
  if (nativeFiles) return nativeFiles;
1581
1581
  }
1582
- const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-CmN4bFjv.mjs").then((n) => n.n);
1582
+ const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-Ck2To2p7.mjs").then((n) => n.n);
1583
1583
  return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
1584
1584
  source: nativeInput.source,
1585
1585
  yaml: nativeInput.yaml
@@ -1,5 +1,5 @@
1
- import { r as getZodSchemaRefs, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-DzeHecv2.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-CxlaA4c5.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;
@@ -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
@@ -1,6 +1,6 @@
1
- import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CmN4bFjv.mjs";
2
- import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-DzeHecv2.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-CxlaA4c5.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-CxlaA4c5.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/metro.cjs CHANGED
@@ -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-Dv-hqKhh.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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-DDd4AXRT.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-CxlaA4c5.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 = {}) {
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-DzeHecv2.mjs";
3
- import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-CxlaA4c5.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.1";
34
+ return "3.3.2";
35
35
  }
36
36
  //#endregion
37
37
  //#region src/helpers/yargs.helper.ts
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-DDd4AXRT.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
@@ -189,5 +189,5 @@
189
189
  "node": ">= 18"
190
190
  },
191
191
  "packageManager": "bun@1.4.1",
192
- "version": "3.3.1"
192
+ "version": "3.3.2"
193
193
  }