@povio/openapi-codegen-cli 3.0.0-rc.3 → 3.0.0-rc.5

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/dist/acl.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as ErrorHandler } from "./error-handling-CvW_FecB.mjs";
1
+ import { a as ErrorHandler } from "./error-handling-B4aYKmyL.mjs";
2
2
  import * as react from "react";
3
3
  import { PropsWithChildren } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/acl.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as SharedErrorHandler } from "./error-handling-DkPY7Asf.mjs";
1
+ import { i as SharedErrorHandler } from "./error-handling-nneQaE1_.mjs";
2
2
  import { n as OpenApiRouter, t as AuthContext } from "./auth.context-Bu5KW2sI.mjs";
3
3
  import { createContext, useCallback, useEffect, useState } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { t as GenerateOptions } from "./options-saKmD8s1.mjs";
1
+ import { t as GenerateOptions } from "./options-BPAjzilp.mjs";
2
2
 
3
3
  //#region src/generators/types/config.d.ts
4
4
  type OpenAPICodegenConfig = Partial<GenerateOptions>;
@@ -12,13 +12,28 @@ interface ErrorEntry<CodeT> {
12
12
  condition?: (error: unknown) => boolean;
13
13
  getMessage: (t: TFunction<string, undefined>, error: unknown) => string;
14
14
  }
15
- interface ErrorHandlerOptions<CodeT extends string> {
15
+ interface DomainErrorEntry {
16
+ code: string | number;
17
+ condition?: (error: unknown) => boolean;
18
+ getMessage: (t: TFunction<string, undefined>, error: unknown) => string;
19
+ }
20
+ declare class DomainErrorRegistry {
21
+ private static readonly entries;
22
+ static register(entry: DomainErrorEntry): void;
23
+ static register(entries: DomainErrorEntry[]): void;
24
+ static unregister(code: string | number): void;
25
+ static clear(): void;
26
+ static getEntry(code: string | number): DomainErrorEntry | undefined;
27
+ }
28
+ interface ErrorHandlerOptions<CodeT extends string | number> {
16
29
  entries: ErrorEntry<CodeT>[];
17
30
  t?: TFunction<string, undefined>;
18
31
  onRethrowError?: (error: unknown, exception: ApplicationException<CodeT | GeneralErrorCodes>) => void;
19
32
  }
20
- declare class ErrorHandler<CodeT extends string> {
33
+ declare class ErrorHandler<CodeT extends string | number> {
21
34
  entries: ErrorEntry<CodeT | GeneralErrorCodes>[];
35
+ private readonly userEntries;
36
+ private readonly generalEntries;
22
37
  private t;
23
38
  private onRethrowError?;
24
39
  constructor({
@@ -35,4 +50,4 @@ declare class ErrorHandler<CodeT extends string> {
35
50
  }
36
51
  declare const SharedErrorHandler: ErrorHandler<never>;
37
52
  //#endregion
38
- export { GeneralErrorCodes as a, ErrorHandlerOptions as i, ErrorEntry as n, SharedErrorHandler as o, ErrorHandler as r, ApplicationException as t };
53
+ export { ErrorHandler as a, SharedErrorHandler as c, ErrorEntry as i, DomainErrorEntry as n, ErrorHandlerOptions as o, DomainErrorRegistry as r, GeneralErrorCodes as s, ApplicationException as t };
@@ -53,6 +53,7 @@ let RestUtils;
53
53
  if (!e.response) return null;
54
54
  const data = e.response.data;
55
55
  if (typeof data?.code === "string") return data.code;
56
+ if (typeof data?.code === "number") return data.code;
56
57
  return null;
57
58
  };
58
59
  _RestUtils.doesServerErrorMessageContain = (e, text) => {
@@ -85,8 +86,26 @@ var ApplicationException = class extends Error {
85
86
  this.serverMessage = serverMessage;
86
87
  }
87
88
  };
89
+ var DomainErrorRegistry = class {
90
+ static entries = /* @__PURE__ */ new Map();
91
+ static register(entryOrEntries) {
92
+ const items = Array.isArray(entryOrEntries) ? entryOrEntries : [entryOrEntries];
93
+ for (const item of items) this.entries.set(item.code, item);
94
+ }
95
+ static unregister(code) {
96
+ this.entries.delete(code);
97
+ }
98
+ static clear() {
99
+ this.entries.clear();
100
+ }
101
+ static getEntry(code) {
102
+ return this.entries.get(code);
103
+ }
104
+ };
88
105
  var ErrorHandler = class {
89
106
  entries = [];
107
+ userEntries;
108
+ generalEntries;
90
109
  t;
91
110
  onRethrowError;
92
111
  constructor({ entries, t = defaultT, onRethrowError }) {
@@ -138,14 +157,15 @@ var ErrorHandler = class {
138
157
  return this.t("openapi.sharedErrors.unknownError");
139
158
  }
140
159
  };
141
- this.entries = [
142
- ...entries,
160
+ this.userEntries = [...entries];
161
+ this.generalEntries = [
143
162
  dataValidationError,
144
163
  internalError,
145
164
  networkError,
146
165
  canceledError,
147
166
  unknownError
148
167
  ];
168
+ this.entries = [...this.userEntries, ...this.generalEntries];
149
169
  }
150
170
  matchesEntry(error, entry, code) {
151
171
  if (entry.condition) return entry.condition(error);
@@ -156,9 +176,23 @@ var ErrorHandler = class {
156
176
  }
157
177
  rethrowError(error) {
158
178
  const code = RestUtils.extractServerResponseCode(error);
159
- const errorEntry = this.entries.find((entry) => this.matchesEntry(error, entry, code));
160
179
  const serverMessage = RestUtils.extractServerErrorMessage(error);
161
- const exception = new ApplicationException(errorEntry.getMessage(this.t, error), errorEntry.code, serverMessage);
180
+ const userEntry = this.userEntries.find((entry) => this.matchesEntry(error, entry, code));
181
+ if (userEntry) {
182
+ const exception = new ApplicationException(userEntry.getMessage(this.t, error), userEntry.code, serverMessage);
183
+ this.onRethrowError?.(error, exception);
184
+ throw exception;
185
+ }
186
+ if (code !== null) {
187
+ const registryEntry = DomainErrorRegistry.getEntry(code);
188
+ if (registryEntry && (!registryEntry.condition || registryEntry.condition(error))) {
189
+ const exception = new ApplicationException(registryEntry.getMessage(this.t, error), registryEntry.code, serverMessage);
190
+ this.onRethrowError?.(error, exception);
191
+ throw exception;
192
+ }
193
+ }
194
+ const generalEntry = this.generalEntries.find((entry) => this.matchesEntry(error, entry, code));
195
+ const exception = new ApplicationException(generalEntry.getMessage(this.t, error), generalEntry.code, serverMessage);
162
196
  this.onRethrowError?.(error, exception);
163
197
  throw exception;
164
198
  }
@@ -184,4 +218,4 @@ var ErrorHandler = class {
184
218
  const SharedErrorHandler = new ErrorHandler({ entries: [] });
185
219
 
186
220
  //#endregion
187
- export { ns as a, RestUtils as i, ErrorHandler as n, resources as o, SharedErrorHandler as r, ApplicationException as t };
221
+ export { RestUtils as a, SharedErrorHandler as i, DomainErrorRegistry as n, ns as o, ErrorHandler as r, resources as s, ApplicationException as t };
@@ -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-D-UDIQX5.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-C0O8NiqP.mjs";
2
2
  import path from "path";
3
3
  import SwaggerParser from "@apidevtools/swagger-parser";
4
4
 
@@ -915,6 +915,10 @@ const APP_REST_CLIENT_FILE = {
915
915
  fileName: "app-rest-client",
916
916
  extension: "ts"
917
917
  };
918
+ const DOMAIN_ERRORS_FILE = {
919
+ fileName: "domain-errors",
920
+ extension: "ts"
921
+ };
918
922
  const QUERY_OPTIONS_TYPES = {
919
923
  query: "AppQueryOptions",
920
924
  infiniteQuery: "AppInfiniteQueryOptions",
@@ -1717,26 +1721,12 @@ function getAclImports({ tag, endpoints, options }) {
1717
1721
  options
1718
1722
  });
1719
1723
  }
1720
- function normalizeOutputPath(output) {
1721
- return output.replace(/\\/g, "/").replace(/\/$/, "");
1722
- }
1723
- function outputMatchesTsPath(options) {
1724
- const normalizedOutput = normalizeOutputPath(options.output);
1725
- if (options.tsPath.startsWith("@/")) {
1726
- const physicalPath = `src/${options.tsPath.slice(2)}`;
1727
- return normalizedOutput === physicalPath || normalizedOutput.endsWith(`/${physicalPath}`);
1728
- }
1729
- return normalizedOutput === options.tsPath;
1730
- }
1731
- function shouldUseRelativeImports(options) {
1732
- return options.importPath === "ts" && options.tsPath === "@/data" && !outputMatchesTsPath(options);
1733
- }
1734
1724
  function getImportPath(options, fromRoot = false) {
1735
- if (options.importPath === "relative") return `${fromRoot ? "./" : "../"}`.replace(/\/\//g, "/");
1736
- if (options.importPath === "absolute") return `${options.output}/`.replace(/\/\//g, "/");
1737
- if (new RegExp(`${TEMPLATE_DATA_FILE_PATH}`, "g").test(options.output)) return `${options.output.replace(new RegExp(`.*${TEMPLATE_DATA_FILE_PATH}`, "g"), options.tsPath)}/`.replace(/\/\//g, "/");
1738
- if (shouldUseRelativeImports(options)) return `${fromRoot ? "./" : "../"}`.replace(/\/\//g, "/");
1739
- return `${options.tsPath}/`.replace(/\/\//g, "/");
1725
+ let importPath = options.tsPath;
1726
+ if (options.importPath === "relative") importPath = fromRoot ? "./" : "../";
1727
+ else if (options.importPath === "absolute") importPath = options.output;
1728
+ else if (new RegExp(`${TEMPLATE_DATA_FILE_PATH}`, "g").test(options.output)) importPath = options.output.replace(new RegExp(`.*${TEMPLATE_DATA_FILE_PATH}`, "g"), options.tsPath);
1729
+ return `${importPath}/`.replace(/\/\//g, "/");
1740
1730
  }
1741
1731
  function getImports({ type = GenerateType.Models, tag: currentTag, entities, getTag, getEntityName, options }) {
1742
1732
  const imports = /* @__PURE__ */ new Map();
@@ -2221,16 +2211,9 @@ function getEndpointBody({ resolver, operation, operationName, isUniqueOperation
2221
2211
  };
2222
2212
  }
2223
2213
 
2224
- //#endregion
2225
- //#region src/generators/utils/query-filter-component-names.utils.ts
2226
- function resolveQueryFilterComponentName(operationId, queryFilterComponentNames) {
2227
- if (!operationId || !queryFilterComponentNames) return;
2228
- return queryFilterComponentNames[operationId];
2229
- }
2230
-
2231
2214
  //#endregion
2232
2215
  //#region src/generators/core/endpoints/getEndpointParameter.ts
2233
- function getEndpointParameter({ resolver, param, operationName, operationId, isUniqueOperationName, tag }) {
2216
+ function getEndpointParameter({ resolver, param, operationName, isUniqueOperationName, tag }) {
2234
2217
  const paramObj = resolver.resolveObject(param);
2235
2218
  if (!ALLOWED_PATH_IN.includes(paramObj.in)) return;
2236
2219
  let schema = {};
@@ -2243,8 +2226,7 @@ function getEndpointParameter({ resolver, param, operationName, operationId, isU
2243
2226
  schema = mediaTypeObject?.schema ?? mediaTypeObject;
2244
2227
  } else if (paramObj.schema) schema = paramObj.schema;
2245
2228
  if (resolver.options.withDescription && schema) schema.description = (paramObj.description ?? "").trim();
2246
- const zodSchemaOperationName = getZodSchemaOperationName(operationName, isUniqueOperationName, tag);
2247
- const fallbackName = (paramObj.name === resolver.options.filterParamName && !isReferenceObject(schema) && resolver.options.queryFilterComponentNames ? resolveQueryFilterComponentName(operationId, resolver.options.queryFilterComponentNames) : void 0) ?? getParamZodSchemaName(zodSchemaOperationName, paramObj.name);
2229
+ const fallbackName = getParamZodSchemaName(getZodSchemaOperationName(operationName, isUniqueOperationName, tag), paramObj.name);
2248
2230
  let parameterSortingEnumSchemaName = void 0;
2249
2231
  if (isSortingParameterObject(paramObj)) {
2250
2232
  const enumZodSchemaName = getEnumZodSchemaName(fallbackName, resolver.options.enumSuffix, resolver.options.schemaSuffix);
@@ -2343,7 +2325,6 @@ function getEndpointsFromOpenAPIDoc(resolver) {
2343
2325
  resolver,
2344
2326
  param,
2345
2327
  operationName,
2346
- operationId: operation.operationId,
2347
2328
  isUniqueOperationName,
2348
2329
  tag
2349
2330
  });
@@ -2402,11 +2383,21 @@ function getEndpointsFromOpenAPIDoc(resolver) {
2402
2383
  endpoint.response = responseZodSchema;
2403
2384
  endpoint.responseObject = responseObj;
2404
2385
  endpoint.responseDescription = responseObj?.description;
2405
- } else if (statusCode !== "default" && !Number.isNaN(status) && isErrorStatus(status)) endpoint.errors.push({
2406
- zodSchema: responseZodSchema,
2407
- status,
2408
- description: responseObj?.description
2409
- });
2386
+ } else if (statusCode !== "default" && !Number.isNaN(status) && isErrorStatus(status)) {
2387
+ const rawSchema = schemaObject;
2388
+ const domainStr = rawSchema["x-domain-error-domain"];
2389
+ const codeEnumArr = ((rawSchema?.properties)?.code)?.enum;
2390
+ const domainCode = Array.isArray(codeEnumArr) && codeEnumArr.length === 1 && typeof codeEnumArr[0] === "number" ? codeEnumArr[0] : void 0;
2391
+ endpoint.errors.push({
2392
+ zodSchema: responseZodSchema,
2393
+ status,
2394
+ description: responseObj?.description,
2395
+ ...typeof domainStr === "string" && domainCode !== void 0 ? { domainError: {
2396
+ domain: domainStr,
2397
+ code: domainCode
2398
+ } } : {}
2399
+ });
2400
+ }
2410
2401
  } else {
2411
2402
  const status = Number(statusCode);
2412
2403
  const responseZodSchema = VOID_SCHEMA;
@@ -2602,6 +2593,7 @@ function resolveExtractedEnumZodSchemaTags(resolver) {
2602
2593
  //#endregion
2603
2594
  //#region src/generators/core/zod/enumExtraction/updateExtractedEnumZodSchemaData.ts
2604
2595
  function updateExtractedEnumZodSchemaData({ schema, nameSegments = [], includeSelf, ...params }) {
2596
+ if (!isReferenceObject(schema) && schema?.["x-domain-error-domain"]) return;
2605
2597
  if (includeSelf) handleExtractedEnumZodSchemaDataUpdate({
2606
2598
  schema,
2607
2599
  nameSegments,
@@ -3071,7 +3063,7 @@ function sortZodSchemasByTopology(resolver, zodSchemas) {
3071
3063
  function getDataFromOpenAPIDoc(openApiDoc, options, profiler) {
3072
3064
  const p = profiler ?? new Profiler(false);
3073
3065
  const resolver = p.runSync("data.resolver.init", () => new SchemaResolver(openApiDoc, options, p));
3074
- const endpoints = p.runSync("data.endpoints.extract", () => getEndpointsFromOpenAPIDoc(resolver, p));
3066
+ const endpoints = p.runSync("data.endpoints.extract", () => getEndpointsFromOpenAPIDoc(resolver));
3075
3067
  const zodSchemasFromDocSchemas = p.runSync("data.zod.extract", () => getZodSchemasFromOpenAPIDoc(resolver, p));
3076
3068
  let zodSchemas = {
3077
3069
  ...zodSchemasFromDocSchemas.zodSchemas,
@@ -3858,7 +3850,7 @@ function generateEndpoints({ resolver, data, tag }) {
3858
3850
  const endpointConfig = renderEndpointConfig(resolver, endpoint, tag);
3859
3851
  lines.push(`export const ${getEndpointName(endpoint)} = (${endpointParams}${hasAxiosRequestConfig ? `${AXIOS_REQUEST_CONFIG_NAME}?: ${AXIOS_REQUEST_CONFIG_TYPE}` : ""}) => {`);
3860
3852
  lines.push(` return ${APP_REST_CLIENT_NAME}.${endpoint.method}(`);
3861
- lines.push(` { resSchema: ${getImportedZodSchemaName(resolver, endpoint.response, tag)} },`);
3853
+ lines.push(` { resSchema: ${getImportedZodSchemaName(resolver, endpoint.response)} },`);
3862
3854
  lines.push(` \`${getEndpointPath(endpoint)}\`,`);
3863
3855
  if (endpointBody) lines.push(` ${generateParse ? renderEndpointParamParse(resolver, endpointBody, endpointBody.name, tag) : endpointBody.name},`);
3864
3856
  else if (hasUndefinedEndpointBody) lines.push(" undefined,");
@@ -4475,7 +4467,7 @@ function renderInfiniteQueryOptions({ resolver, endpoint, inlineEndpoints }) {
4475
4467
  lines.push(` queryKey: keys.${getEndpointName(endpoint)}Infinite(${endpointArgsWithoutPage}),`);
4476
4468
  lines.push(` queryFn: ({ pageParam }: { pageParam: number }) => ${endpointFunction}(${endpointArgsWithPage}${hasAxiosRequestConfig ? `, ${AXIOS_REQUEST_CONFIG_NAME}` : ""}),`);
4477
4469
  lines.push(" initialPageParam: 1,");
4478
- lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }) => {`);
4470
+ lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }: Awaited<ReturnType<typeof ${endpointFunction}>>) => {`);
4479
4471
  lines.push(` const pageParam = ${resolver.options.infiniteQueryResponseParamNames.page} ?? 1;`);
4480
4472
  lines.push(` return pageParam * limitParam < ${resolver.options.infiniteQueryResponseParamNames.totalItems} ? pageParam + 1 : null;`);
4481
4473
  lines.push(" },");
@@ -4499,9 +4491,10 @@ function renderPrefetchInfiniteQuery({ resolver, endpoint }) {
4499
4491
  modelNamespaceTag: getEndpointTag(endpoint, resolver.options)
4500
4492
  });
4501
4493
  const endpointArgs = renderEndpointArgs(resolver, endpoint, { excludePageParam: true });
4494
+ const optionsArgs = `${endpointParams ? `{ ${endpointArgs} }` : ""}${hasAxiosRequestConfig ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""}`;
4502
4495
  const lines = [];
4503
4496
  lines.push(`export const ${getPrefetchInfiniteQueryName(endpoint)} = (queryClient: QueryClient, ${endpointParams ? `{ ${endpointArgs} }: { ${endpointParams} }, ` : ""}${hasAxiosRequestConfig ? `${AXIOS_REQUEST_CONFIG_NAME}: ${AXIOS_REQUEST_CONFIG_TYPE}, ` : ""}options?: Omit<Parameters<QueryClient["prefetchInfiniteQuery"]>[0], "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">): void => {`);
4504
- lines.push(` void queryClient.prefetchInfiniteQuery({ ...${getInfiniteQueryOptionsName(endpoint)}(${endpointParams ? `{ ${endpointArgs} }` : ""}${hasAxiosRequestConfig ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""}), ...options });`);
4497
+ lines.push(` void queryClient.prefetchInfiniteQuery({ ...${getInfiniteQueryOptionsName(endpoint)}(${optionsArgs}), ...(options as {}) });`);
4505
4498
  lines.push("};");
4506
4499
  return lines.join("\n");
4507
4500
  }
@@ -4604,7 +4597,7 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
4604
4597
  paramTypes: workspaceParamTypes,
4605
4598
  indent: " "
4606
4599
  }));
4607
- if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<typeof ${QUERY_MODULE_ENUM}.${tag}>({ currentModule: ${QUERIES_MODULE_NAME} });`);
4600
+ if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<${QUERY_MODULE_ENUM}.${tag}>({ currentModule: ${QUERIES_MODULE_NAME} });`);
4608
4601
  lines.push("");
4609
4602
  lines.push(` return ${QUERY_HOOKS.mutation}({`);
4610
4603
  const nonPathDestructuredArgs = isScoped ? renderEndpointArgs(resolver, endpoint, {
@@ -4771,6 +4764,36 @@ export const ${APP_REST_CLIENT_NAME} = new RestClient({
4771
4764
  `;
4772
4765
  }
4773
4766
 
4767
+ //#endregion
4768
+ //#region src/generators/generate/generateDomainErrors.ts
4769
+ function domainToPascalCase(domain) {
4770
+ return domain.split(/[-_]/).map(capitalize).join("");
4771
+ }
4772
+ function generateDomainErrors({ data }) {
4773
+ const byDomain = /* @__PURE__ */ new Map();
4774
+ for (const { endpoints } of data.values()) for (const endpoint of endpoints) for (const error of endpoint.errors) {
4775
+ if (!error.domainError) continue;
4776
+ const { domain, code } = error.domainError;
4777
+ if (!byDomain.has(domain)) byDomain.set(domain, /* @__PURE__ */ new Map());
4778
+ const domainMap = byDomain.get(domain);
4779
+ if (!domainMap.has(code)) domainMap.set(code, {
4780
+ code,
4781
+ description: error.description
4782
+ });
4783
+ }
4784
+ if (byDomain.size === 0) return void 0;
4785
+ const blocks = [];
4786
+ for (const [domain, codes] of [...byDomain.entries()].sort(([a], [b]) => a.localeCompare(b))) {
4787
+ const pascalName = domainToPascalCase(domain);
4788
+ const entries = [...codes.values()].sort((a, b) => a.code - b.code).map(({ code, description }) => {
4789
+ return `${description ? ` /** ${description} */\n ` : " "}ERROR_${code}: ${code}`;
4790
+ }).join(",\n");
4791
+ blocks.push(`export const ${pascalName}DomainErrors = {\n${entries},\n} as const;`);
4792
+ blocks.push(`export type ${pascalName}DomainErrorCode = (typeof ${pascalName}DomainErrors)[keyof typeof ${pascalName}DomainErrors];`);
4793
+ }
4794
+ return blocks.join("\n\n") + "\n";
4795
+ }
4796
+
4774
4797
  //#endregion
4775
4798
  //#region src/generators/generate/generateQueryModules.ts
4776
4799
  function generateQueryModules({ resolver, data }) {
@@ -4825,6 +4848,20 @@ function getMutationEffectsFiles(data, resolver) {
4825
4848
  function getZodExtendedFiles(_data, _resolver) {
4826
4849
  return [];
4827
4850
  }
4851
+ function getDomainErrorsFiles(data, resolver) {
4852
+ const content = generateDomainErrors({
4853
+ resolver,
4854
+ data
4855
+ });
4856
+ if (!content) return [];
4857
+ return [{
4858
+ fileName: getOutputFileName({
4859
+ output: resolver.options.output,
4860
+ fileName: getFileNameWithExtension(DOMAIN_ERRORS_FILE)
4861
+ }),
4862
+ content
4863
+ }];
4864
+ }
4828
4865
  function getAppRestClientFiles(resolver) {
4829
4866
  if (resolver.options.restClientImportPath !== DEFAULT_GENERATE_OPTIONS.restClientImportPath) return [];
4830
4867
  return [{
@@ -4887,7 +4924,7 @@ function generateCodeFromOpenAPIDoc(openApiDoc, options, profiler) {
4887
4924
  }
4888
4925
  });
4889
4926
  });
4890
- 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)));
4927
+ 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)));
4891
4928
  return generateFilesData;
4892
4929
  }
4893
4930
 
@@ -1,4 +1,4 @@
1
- import { n as GenerateFileData, t as GenerateOptions } from "./options-saKmD8s1.mjs";
1
+ import { n as GenerateFileData, t as GenerateOptions } from "./options-BPAjzilp.mjs";
2
2
  import { OpenAPIV3 } from "openapi-types";
3
3
 
4
4
  //#region src/generators/types/metadata.d.ts
@@ -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-D-UDIQX5.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-C0O8NiqP.mjs";
2
2
  import SwaggerParser from "@apidevtools/swagger-parser";
3
3
 
4
4
  //#region src/generators/core/getMetadataFromOpenAPIDoc.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-CvW_FecB.mjs";
2
- import "./options-saKmD8s1.mjs";
3
- import { t as OpenAPICodegenConfig } from "./config-1XCOTZ4a.mjs";
1
+ import { a as ErrorHandler, c as SharedErrorHandler, i as ErrorEntry, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-B4aYKmyL.mjs";
2
+ import "./options-BPAjzilp.mjs";
3
+ import { t as OpenAPICodegenConfig } from "./config-C1ME3Ay4.mjs";
4
4
  import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
5
5
  import { z } from "zod";
6
6
  import "i18next";
@@ -65,7 +65,7 @@ declare class RestClient$1 implements RestClient {
65
65
  //#endregion
66
66
  //#region src/lib/rest/rest.utils.d.ts
67
67
  declare namespace RestUtils {
68
- const extractServerResponseCode: (e: unknown) => string | null;
68
+ const extractServerResponseCode: (e: unknown) => string | number | null;
69
69
  const doesServerErrorMessageContain: (e: AxiosError, text: string) => boolean;
70
70
  const extractServerErrorMessage: (e: unknown) => string | null;
71
71
  const extractContentDispositionFilename: (headers: AxiosResponseHeaders) => string | undefined;
@@ -110,7 +110,7 @@ interface MutationEffectsOptions<TQueryModule extends QueryModule = QueryModule>
110
110
  invalidateCurrentModule?: boolean;
111
111
  crossTabInvalidation?: boolean;
112
112
  invalidationMap?: InvalidationMap<TQueryModule>;
113
- invalidateModules?: TQueryModule[];
113
+ invalidateModules?: QueryModule[];
114
114
  invalidateKeys?: QueryKey[];
115
115
  preferUpdate?: boolean;
116
116
  }
@@ -228,4 +228,4 @@ declare const AuthGuard: ({
228
228
  children
229
229
  }: PropsWithChildren<AuthGuardProps>) => react.ReactNode;
230
230
  //#endregion
231
- export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
231
+ export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ns, i as RestUtils, n as ErrorHandler, o as resources, r as SharedErrorHandler, t as ApplicationException } from "./error-handling-DkPY7Asf.mjs";
1
+ import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, o as ns, r as ErrorHandler, s as resources, t as ApplicationException } from "./error-handling-nneQaE1_.mjs";
2
2
  import { n as OpenApiRouter, t as AuthContext } from "./auth.context-Bu5KW2sI.mjs";
3
3
  import axios from "axios";
4
4
  import { z } from "zod";
@@ -250,4 +250,4 @@ const AuthGuard = ({ type, redirectTo, children }) => {
250
250
  };
251
251
 
252
252
  //#endregion
253
- export { ApplicationException, AuthContext, AuthGuard, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
253
+ export { ApplicationException, AuthContext, AuthGuard, DomainErrorRegistry, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
@@ -72,13 +72,6 @@ interface BuilderConfigsGenerateOptions {
72
72
  dynamicInputsImportPath: string;
73
73
  dynamicColumnsImportPath: string;
74
74
  }
75
- interface QueryFilterComponentNameOptions {
76
- /**
77
- * Optional map of OpenAPI operationId to stable filter schema names.
78
- * Used for inline `filter` query objects when migrating away from named filter DTO refs.
79
- */
80
- queryFilterComponentNames?: Record<string, string>;
81
- }
82
75
  interface GenerateConfig {
83
76
  outputFileNameSuffix: string;
84
77
  namespaceSuffix: string;
@@ -89,8 +82,6 @@ interface BaseGenerateOptions {
89
82
  clearOutput?: boolean;
90
83
  incremental?: boolean;
91
84
  splitByTags: boolean;
92
- /** When true, non-default tags emit proxy models that re-export from CommonModels. */
93
- modelsInCommon?: boolean;
94
85
  defaultTag: string;
95
86
  includeTags: string[];
96
87
  excludeTags: string[];
@@ -104,6 +95,6 @@ interface BaseGenerateOptions {
104
95
  modelsOnly?: boolean;
105
96
  standalone?: boolean;
106
97
  }
107
- interface GenerateOptions extends BaseGenerateOptions, ZodGenerateOptions, EndpointsGenerateOptions, QueriesGenerateOptions, InfiniteQueriesGenerateOptions, ACLGenerateOptions, BuilderConfigsGenerateOptions, QueryFilterComponentNameOptions {}
98
+ interface GenerateOptions extends BaseGenerateOptions, ZodGenerateOptions, EndpointsGenerateOptions, QueriesGenerateOptions, InfiniteQueriesGenerateOptions, ACLGenerateOptions, BuilderConfigsGenerateOptions {}
108
99
  //#endregion
109
100
  export { GenerateFileData as n, GenerateFileFormatter as r, GenerateOptions as t };
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-D-UDIQX5.mjs";
3
- import { n as resolveConfig, t as runGenerate } from "./generate.runner-CioDqx6u.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-C0O8NiqP.mjs";
3
+ import { n as resolveConfig, t as runGenerate } from "./generate.runner-n8169vZL.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.3";
42
+ return "3.0.0-rc.5";
43
43
  }
44
44
 
45
45
  //#endregion
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as GenerateFileFormatter } from "./options-saKmD8s1.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-1XCOTZ4a.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-BPAjzilp.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-C1ME3Ay4.mjs";
3
3
  import { Plugin } from "vite";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.d.ts
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Profiler } from "./generateCodeFromOpenAPIDoc-D-UDIQX5.mjs";
2
- import { t as runGenerate } from "./generate.runner-CioDqx6u.mjs";
1
+ import { S as Profiler } from "./generateCodeFromOpenAPIDoc-C0O8NiqP.mjs";
2
+ import { t as runGenerate } from "./generate.runner-n8169vZL.mjs";
3
3
  import path from "path";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.ts
package/dist/zod.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as ErrorHandler } from "./error-handling-CvW_FecB.mjs";
1
+ import { a as ErrorHandler } from "./error-handling-B4aYKmyL.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/zod.d.ts
package/dist/zod.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as SharedErrorHandler } from "./error-handling-DkPY7Asf.mjs";
1
+ import { i as SharedErrorHandler } from "./error-handling-nneQaE1_.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/zod.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "3.0.0-rc.3",
3
+ "version": "3.0.0-rc.5",
4
4
  "keywords": [
5
5
  "codegen",
6
6
  "openapi",