@povio/openapi-codegen-cli 3.0.0-rc.8 → 3.0.0-rc.9

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.
@@ -1,4 +1,4 @@
1
- import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-DGox5gzo.mjs";
1
+ import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-NA2XZmIv.mjs";
2
2
  import path from "path";
3
3
  import SwaggerParser from "@apidevtools/swagger-parser";
4
4
 
@@ -990,7 +990,6 @@ function resolveZodSchemaName({ schema, zodSchema, fallbackName, resolver, tag }
990
990
  if (zodSchema.complexity < COMPLEXITY_THRESHOLD) return result;
991
991
  const zodSchemaName = getZodSchemaName(fallbackName, resolver.options.schemaSuffix);
992
992
  while (resolver.getCodeByZodSchemaName(zodSchemaName)) if (resolver.getZodSchemaNamesByCompositeCode(result)?.includes(zodSchemaName)) return zodSchemaName;
993
- else if (result === zodSchemaName || result.startsWith(`${zodSchemaName}.`)) return zodSchemaName;
994
993
  else if (resolver.getCodeByZodSchemaName(zodSchemaName) === zodSchemaName) return zodSchemaName;
995
994
  else throw new Error(`Can't uniquely resolve zod schema name: ${zodSchemaName}`);
996
995
  resolver.setZodSchema(zodSchemaName, result, tag);
@@ -1574,7 +1573,7 @@ function getSchemaDescriptions(schemaObj) {
1574
1573
  const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(zodSchemaName, options.schemaSuffix);
1575
1574
  const getImportedZodSchemaName = (resolver, zodSchemaName, namespaceTag) => {
1576
1575
  if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName;
1577
- const tag = namespaceTag && resolver.options.modelsInCommon && resolver.options.splitByTags ? namespaceTag : resolver.getTagByZodSchemaName(zodSchemaName);
1576
+ const tag = namespaceTag ?? resolver.getTagByZodSchemaName(zodSchemaName);
1578
1577
  return `${resolver.options.tsNamespaces ? `${getNamespaceName({
1579
1578
  type: GenerateType.Models,
1580
1579
  tag,
@@ -2387,6 +2386,7 @@ function getEndpointsFromOpenAPIDoc(resolver) {
2387
2386
  } else if (statusCode !== "default" && !Number.isNaN(status) && isErrorStatus(status)) {
2388
2387
  const rawSchema = schemaObject;
2389
2388
  const domainStr = rawSchema["x-domain-error-domain"];
2389
+ const domainName = rawSchema["x-domain-error-name"];
2390
2390
  const codeEnumArr = ((rawSchema?.properties)?.code)?.enum;
2391
2391
  const domainCode = Array.isArray(codeEnumArr) && codeEnumArr.length === 1 && typeof codeEnumArr[0] === "number" ? codeEnumArr[0] : void 0;
2392
2392
  endpoint.errors.push({
@@ -2395,7 +2395,8 @@ function getEndpointsFromOpenAPIDoc(resolver) {
2395
2395
  description: responseObj?.description,
2396
2396
  ...typeof domainStr === "string" && domainCode !== void 0 ? { domainError: {
2397
2397
  domain: domainStr,
2398
- code: domainCode
2398
+ code: domainCode,
2399
+ ...typeof domainName === "string" ? { name: domainName } : {}
2399
2400
  } } : {}
2400
2401
  });
2401
2402
  }
@@ -3851,7 +3852,7 @@ function generateEndpoints({ resolver, data, tag }) {
3851
3852
  const endpointConfig = renderEndpointConfig(resolver, endpoint, tag);
3852
3853
  lines.push(`export const ${getEndpointName(endpoint)} = (${endpointParams}${hasAxiosRequestConfig ? `${AXIOS_REQUEST_CONFIG_NAME}?: ${AXIOS_REQUEST_CONFIG_TYPE}` : ""}) => {`);
3853
3854
  lines.push(` return ${APP_REST_CLIENT_NAME}.${endpoint.method}(`);
3854
- lines.push(` { resSchema: ${getImportedZodSchemaName(resolver, endpoint.response, tag)} },`);
3855
+ lines.push(` { resSchema: ${getImportedZodSchemaName(resolver, endpoint.response)} },`);
3855
3856
  lines.push(` \`${getEndpointPath(endpoint)}\`,`);
3856
3857
  if (endpointBody) lines.push(` ${generateParse ? renderEndpointParamParse(resolver, endpointBody, endpointBody.name, tag) : endpointBody.name},`);
3857
3858
  else if (hasUndefinedEndpointBody) lines.push(" undefined,");
@@ -4779,6 +4780,7 @@ function generateDomainErrors({ data }) {
4779
4780
  const domainMap = byDomain.get(domain);
4780
4781
  if (!domainMap.has(code)) domainMap.set(code, {
4781
4782
  code,
4783
+ name: error.domainError.name,
4782
4784
  description: error.description
4783
4785
  });
4784
4786
  }
@@ -4786,8 +4788,8 @@ function generateDomainErrors({ data }) {
4786
4788
  const blocks = [];
4787
4789
  for (const [domain, codes] of [...byDomain.entries()].sort(([a], [b]) => a.localeCompare(b))) {
4788
4790
  const pascalName = domainToPascalCase(domain);
4789
- const entries = [...codes.values()].sort((a, b) => a.code - b.code).map(({ code, description }) => {
4790
- return `${description ? ` /** ${description} */\n ` : " "}ERROR_${code}: ${code}`;
4791
+ const entries = [...codes.values()].sort((a, b) => a.code - b.code).map(({ code, name, description }) => {
4792
+ return `${description ? ` /** ${description} */\n ` : " "}${name ?? `ERROR_${code}`}: ${code}`;
4791
4793
  }).join(",\n");
4792
4794
  blocks.push(`export const ${pascalName}DomainErrors = {\n${entries},\n} as const;`);
4793
4795
  blocks.push(`export type ${pascalName}DomainErrorCode = (typeof ${pascalName}DomainErrors)[keyof typeof ${pascalName}DomainErrors];`);
@@ -1,4 +1,4 @@
1
- import { _ as getNamespaceName, a as getDataFromOpenAPIDoc, b as isParamMediaTypeAllowed, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, g as invalidVariableNameCharactersToCamel, l as getTsTypeBase, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as GenerateType, x as formatTag, y as isMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-DGox5gzo.mjs";
1
+ import { _ as getNamespaceName, a as getDataFromOpenAPIDoc, b as isParamMediaTypeAllowed, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, g as invalidVariableNameCharactersToCamel, l as getTsTypeBase, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as GenerateType, x as formatTag, y as isMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-NA2XZmIv.mjs";
2
2
  import SwaggerParser from "@apidevtools/swagger-parser";
3
3
 
4
4
  //#region src/generators/core/getMetadataFromOpenAPIDoc.ts
package/dist/sh.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, a as getDataFromOpenAPIDoc, m as groupByType, n as getOutputFileName, u as getTagFileName, v as GenerateType } from "./generateCodeFromOpenAPIDoc-DGox5gzo.mjs";
3
- import { n as resolveConfig, t as runGenerate } from "./generate.runner-C94-P4xF.mjs";
2
+ import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, a as getDataFromOpenAPIDoc, m as groupByType, n as getOutputFileName, u as getTagFileName, v as GenerateType } from "./generateCodeFromOpenAPIDoc-NA2XZmIv.mjs";
3
+ import { n as resolveConfig, t as runGenerate } from "./generate.runner-DSZ2ivlU.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import yargs from "yargs";
6
6
  import { hideBin } from "yargs/helpers";
@@ -39,7 +39,7 @@ function logBanner(message) {
39
39
  * Fetch the version from package.json
40
40
  */
41
41
  function getVersion() {
42
- return "3.0.0-rc.8";
42
+ return "3.0.0-rc.9";
43
43
  }
44
44
 
45
45
  //#endregion
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Profiler } from "./generateCodeFromOpenAPIDoc-DGox5gzo.mjs";
2
- import { t as runGenerate } from "./generate.runner-C94-P4xF.mjs";
1
+ import { S as Profiler } from "./generateCodeFromOpenAPIDoc-NA2XZmIv.mjs";
2
+ import { t as runGenerate } from "./generate.runner-DSZ2ivlU.mjs";
3
3
  import path from "path";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "3.0.0-rc.8",
3
+ "version": "3.0.0-rc.9",
4
4
  "keywords": [
5
5
  "codegen",
6
6
  "openapi",