@povio/openapi-codegen-cli 3.0.0-rc.3 → 3.0.0-rc.4
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 +1 -1
- package/dist/acl.mjs +1 -1
- package/dist/{config-1XCOTZ4a.d.mts → config-C1ME3Ay4.d.mts} +1 -1
- package/dist/{error-handling-CvW_FecB.d.mts → error-handling-B4aYKmyL.d.mts} +18 -3
- package/dist/{error-handling-DkPY7Asf.mjs → error-handling-nneQaE1_.mjs} +39 -5
- package/dist/{generate.runner-CioDqx6u.mjs → generate.runner-DaqNnVkP.mjs} +1 -1
- package/dist/{generateCodeFromOpenAPIDoc-D-UDIQX5.mjs → generateCodeFromOpenAPIDoc-CjVJQDyw.mjs} +75 -39
- package/dist/generator.d.mts +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/{options-saKmD8s1.d.mts → options-BPAjzilp.d.mts} +1 -10
- package/dist/sh.mjs +3 -3
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +2 -2
- package/dist/zod.d.mts +1 -1
- package/dist/zod.mjs +1 -1
- package/package.json +1 -1
package/dist/acl.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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";
|
|
@@ -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
|
|
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 {
|
|
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.
|
|
142
|
-
|
|
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
|
|
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 {
|
|
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-
|
|
1
|
+
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CjVJQDyw.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
4
|
|
package/dist/{generateCodeFromOpenAPIDoc-D-UDIQX5.mjs → generateCodeFromOpenAPIDoc-CjVJQDyw.mjs}
RENAMED
|
@@ -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
|
-
|
|
1736
|
-
if (options.importPath === "
|
|
1737
|
-
if (
|
|
1738
|
-
if (
|
|
1739
|
-
return `${
|
|
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,
|
|
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
|
|
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))
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
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;
|
|
@@ -4475,7 +4466,7 @@ function renderInfiniteQueryOptions({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4475
4466
|
lines.push(` queryKey: keys.${getEndpointName(endpoint)}Infinite(${endpointArgsWithoutPage}),`);
|
|
4476
4467
|
lines.push(` queryFn: ({ pageParam }: { pageParam: number }) => ${endpointFunction}(${endpointArgsWithPage}${hasAxiosRequestConfig ? `, ${AXIOS_REQUEST_CONFIG_NAME}` : ""}),`);
|
|
4477
4468
|
lines.push(" initialPageParam: 1,");
|
|
4478
|
-
lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }) => {`);
|
|
4469
|
+
lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }: Awaited<ReturnType<typeof ${endpointFunction}>>) => {`);
|
|
4479
4470
|
lines.push(` const pageParam = ${resolver.options.infiniteQueryResponseParamNames.page} ?? 1;`);
|
|
4480
4471
|
lines.push(` return pageParam * limitParam < ${resolver.options.infiniteQueryResponseParamNames.totalItems} ? pageParam + 1 : null;`);
|
|
4481
4472
|
lines.push(" },");
|
|
@@ -4499,9 +4490,10 @@ function renderPrefetchInfiniteQuery({ resolver, endpoint }) {
|
|
|
4499
4490
|
modelNamespaceTag: getEndpointTag(endpoint, resolver.options)
|
|
4500
4491
|
});
|
|
4501
4492
|
const endpointArgs = renderEndpointArgs(resolver, endpoint, { excludePageParam: true });
|
|
4493
|
+
const optionsArgs = `${endpointParams ? `{ ${endpointArgs} }` : ""}${hasAxiosRequestConfig ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""}`;
|
|
4502
4494
|
const lines = [];
|
|
4503
4495
|
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)}(${
|
|
4496
|
+
lines.push(` void queryClient.prefetchInfiniteQuery({ ...${getInfiniteQueryOptionsName(endpoint)}(${optionsArgs}), ...(options as {}) });`);
|
|
4505
4497
|
lines.push("};");
|
|
4506
4498
|
return lines.join("\n");
|
|
4507
4499
|
}
|
|
@@ -4604,7 +4596,7 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
|
|
|
4604
4596
|
paramTypes: workspaceParamTypes,
|
|
4605
4597
|
indent: " "
|
|
4606
4598
|
}));
|
|
4607
|
-
if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects
|
|
4599
|
+
if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<${QUERY_MODULE_ENUM}.${tag}>({ currentModule: ${QUERIES_MODULE_NAME} });`);
|
|
4608
4600
|
lines.push("");
|
|
4609
4601
|
lines.push(` return ${QUERY_HOOKS.mutation}({`);
|
|
4610
4602
|
const nonPathDestructuredArgs = isScoped ? renderEndpointArgs(resolver, endpoint, {
|
|
@@ -4771,6 +4763,36 @@ export const ${APP_REST_CLIENT_NAME} = new RestClient({
|
|
|
4771
4763
|
`;
|
|
4772
4764
|
}
|
|
4773
4765
|
|
|
4766
|
+
//#endregion
|
|
4767
|
+
//#region src/generators/generate/generateDomainErrors.ts
|
|
4768
|
+
function domainToPascalCase(domain) {
|
|
4769
|
+
return domain.split(/[-_]/).map(capitalize).join("");
|
|
4770
|
+
}
|
|
4771
|
+
function generateDomainErrors({ data }) {
|
|
4772
|
+
const byDomain = /* @__PURE__ */ new Map();
|
|
4773
|
+
for (const { endpoints } of data.values()) for (const endpoint of endpoints) for (const error of endpoint.errors) {
|
|
4774
|
+
if (!error.domainError) continue;
|
|
4775
|
+
const { domain, code } = error.domainError;
|
|
4776
|
+
if (!byDomain.has(domain)) byDomain.set(domain, /* @__PURE__ */ new Map());
|
|
4777
|
+
const domainMap = byDomain.get(domain);
|
|
4778
|
+
if (!domainMap.has(code)) domainMap.set(code, {
|
|
4779
|
+
code,
|
|
4780
|
+
description: error.description
|
|
4781
|
+
});
|
|
4782
|
+
}
|
|
4783
|
+
if (byDomain.size === 0) return void 0;
|
|
4784
|
+
const blocks = [];
|
|
4785
|
+
for (const [domain, codes] of [...byDomain.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
4786
|
+
const pascalName = domainToPascalCase(domain);
|
|
4787
|
+
const entries = [...codes.values()].sort((a, b) => a.code - b.code).map(({ code, description }) => {
|
|
4788
|
+
return `${description ? ` /** ${description} */\n ` : " "}ERROR_${code}: ${code}`;
|
|
4789
|
+
}).join(",\n");
|
|
4790
|
+
blocks.push(`export const ${pascalName}DomainErrors = {\n${entries},\n} as const;`);
|
|
4791
|
+
blocks.push(`export type ${pascalName}DomainErrorCode = (typeof ${pascalName}DomainErrors)[keyof typeof ${pascalName}DomainErrors];`);
|
|
4792
|
+
}
|
|
4793
|
+
return blocks.join("\n\n") + "\n";
|
|
4794
|
+
}
|
|
4795
|
+
|
|
4774
4796
|
//#endregion
|
|
4775
4797
|
//#region src/generators/generate/generateQueryModules.ts
|
|
4776
4798
|
function generateQueryModules({ resolver, data }) {
|
|
@@ -4825,6 +4847,20 @@ function getMutationEffectsFiles(data, resolver) {
|
|
|
4825
4847
|
function getZodExtendedFiles(_data, _resolver) {
|
|
4826
4848
|
return [];
|
|
4827
4849
|
}
|
|
4850
|
+
function getDomainErrorsFiles(data, resolver) {
|
|
4851
|
+
const content = generateDomainErrors({
|
|
4852
|
+
resolver,
|
|
4853
|
+
data
|
|
4854
|
+
});
|
|
4855
|
+
if (!content) return [];
|
|
4856
|
+
return [{
|
|
4857
|
+
fileName: getOutputFileName({
|
|
4858
|
+
output: resolver.options.output,
|
|
4859
|
+
fileName: getFileNameWithExtension(DOMAIN_ERRORS_FILE)
|
|
4860
|
+
}),
|
|
4861
|
+
content
|
|
4862
|
+
}];
|
|
4863
|
+
}
|
|
4828
4864
|
function getAppRestClientFiles(resolver) {
|
|
4829
4865
|
if (resolver.options.restClientImportPath !== DEFAULT_GENERATE_OPTIONS.restClientImportPath) return [];
|
|
4830
4866
|
return [{
|
|
@@ -4887,7 +4923,7 @@ function generateCodeFromOpenAPIDoc(openApiDoc, options, profiler) {
|
|
|
4887
4923
|
}
|
|
4888
4924
|
});
|
|
4889
4925
|
});
|
|
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)));
|
|
4926
|
+
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
4927
|
return generateFilesData;
|
|
4892
4928
|
}
|
|
4893
4929
|
|
package/dist/generator.d.mts
CHANGED
package/dist/generator.mjs
CHANGED
|
@@ -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-
|
|
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-CjVJQDyw.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
|
|
2
|
-
import "./options-
|
|
3
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
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?:
|
|
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
|
|
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
|
|
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-
|
|
3
|
-
import { n as resolveConfig, t as runGenerate } from "./generate.runner-
|
|
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-CjVJQDyw.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-DaqNnVkP.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.
|
|
42
|
+
return "3.0.0-rc.4";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as GenerateFileFormatter } from "./options-
|
|
2
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
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-
|
|
2
|
-
import { t as runGenerate } from "./generate.runner-
|
|
1
|
+
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-CjVJQDyw.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-DaqNnVkP.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.ts
|
package/dist/zod.d.mts
CHANGED
package/dist/zod.mjs
CHANGED