@povio/openapi-codegen-cli 3.1.0-rc.5 → 3.1.0-rc.7
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/{error-handling-CDeKUFHF.d.mts → error-handling-BeRxGbwE.d.mts} +40 -9
- package/dist/{error-handling-nneQaE1_.mjs → error-handling-DG8SfTWB.mjs} +19 -29
- package/dist/{generate.runner-BXTc97I0.mjs → generate.runner-DnUDkoAZ.mjs} +1 -1
- package/dist/{generateCodeFromOpenAPIDoc-C-n0Knj8.mjs → generateCodeFromOpenAPIDoc-CbQ9gQss.mjs} +11 -6
- package/dist/generator.mjs +1 -1
- package/dist/index.d.mts +2 -36
- package/dist/index.mjs +2 -2
- package/dist/metro.cjs +46 -9
- package/dist/metro.mjs +36 -5
- package/dist/{openapi-codegen.runner-QGd35-a3.mjs → openapi-codegen.runner-BqOhUduF.mjs} +4 -3
- package/dist/sh.mjs +3 -3
- package/dist/vite.mjs +9 -5
- package/dist/zod.d.mts +1 -1
- package/dist/zod.mjs +1 -1
- package/package.json +2 -2
package/dist/acl.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ErrorHandler } from "./error-handling-
|
|
1
|
+
import { a as ErrorHandler } from "./error-handling-BeRxGbwE.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 { i as SharedErrorHandler } from "./error-handling-
|
|
1
|
+
import { i as SharedErrorHandler } from "./error-handling-DG8SfTWB.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,5 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/lib/config/i18n.d.ts
|
|
2
|
+
declare const ns = "openapi";
|
|
3
|
+
declare const resources: {
|
|
4
|
+
readonly en: {
|
|
5
|
+
readonly openapi: {
|
|
6
|
+
openapi: {
|
|
7
|
+
sharedErrors: {
|
|
8
|
+
dataValidation: string;
|
|
9
|
+
internalError: string;
|
|
10
|
+
networkError: string;
|
|
11
|
+
canceledError: string;
|
|
12
|
+
unknownError: string;
|
|
13
|
+
unknownErrorWithCode: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly sl: {
|
|
19
|
+
readonly openapi: {
|
|
20
|
+
openapi: {
|
|
21
|
+
sharedErrors: {
|
|
22
|
+
dataValidation: string;
|
|
23
|
+
internalError: string;
|
|
24
|
+
networkError: string;
|
|
25
|
+
canceledError: string;
|
|
26
|
+
unknownError: string;
|
|
27
|
+
unknownErrorWithCode: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type TranslateFunction = (key: string, options?: {
|
|
34
|
+
ns?: string;
|
|
35
|
+
}) => string;
|
|
36
|
+
declare function configureTranslations<T>(getter: () => T): void;
|
|
37
|
+
//#endregion
|
|
3
38
|
//#region src/lib/rest/error-handling.d.ts
|
|
4
39
|
type GeneralErrorCodes = "DATA_VALIDATION_ERROR" | "NETWORK_ERROR" | "CANCELED_ERROR" | "INTERNAL_ERROR" | "UNKNOWN_ERROR";
|
|
5
40
|
declare class ApplicationException<CodeT> extends Error {
|
|
@@ -10,12 +45,12 @@ declare class ApplicationException<CodeT> extends Error {
|
|
|
10
45
|
interface ErrorEntry<CodeT> {
|
|
11
46
|
code: CodeT;
|
|
12
47
|
condition?: (error: unknown) => boolean;
|
|
13
|
-
getMessage: (t:
|
|
48
|
+
getMessage: (t: TranslateFunction, error: unknown) => string;
|
|
14
49
|
}
|
|
15
50
|
interface DomainErrorEntry {
|
|
16
51
|
code: string | number;
|
|
17
52
|
condition?: (error: unknown) => boolean;
|
|
18
|
-
getMessage: (t:
|
|
53
|
+
getMessage: (t: TranslateFunction, error: unknown) => string;
|
|
19
54
|
}
|
|
20
55
|
declare class DomainErrorRegistry {
|
|
21
56
|
private static readonly entries;
|
|
@@ -27,22 +62,18 @@ declare class DomainErrorRegistry {
|
|
|
27
62
|
}
|
|
28
63
|
interface ErrorHandlerOptions<CodeT extends string | number> {
|
|
29
64
|
entries: ErrorEntry<CodeT>[];
|
|
30
|
-
t?: TFunction<string, undefined>;
|
|
31
65
|
onRethrowError?: (error: unknown, exception: ApplicationException<CodeT | GeneralErrorCodes>) => void;
|
|
32
66
|
}
|
|
33
67
|
declare class ErrorHandler<CodeT extends string | number> {
|
|
34
68
|
entries: ErrorEntry<CodeT | GeneralErrorCodes>[];
|
|
35
69
|
private readonly userEntries;
|
|
36
70
|
private readonly generalEntries;
|
|
37
|
-
private t;
|
|
38
71
|
private onRethrowError?;
|
|
39
72
|
constructor({
|
|
40
73
|
entries,
|
|
41
|
-
t,
|
|
42
74
|
onRethrowError
|
|
43
75
|
}: ErrorHandlerOptions<CodeT>);
|
|
44
76
|
private matchesEntry;
|
|
45
|
-
setTranslateFunction(t: TFunction<string, undefined>): void;
|
|
46
77
|
rethrowError(error: unknown): ApplicationException<CodeT | GeneralErrorCodes>;
|
|
47
78
|
getError(error: unknown): ApplicationException<CodeT | GeneralErrorCodes> | null;
|
|
48
79
|
getErrorCode(error: unknown): CodeT | GeneralErrorCodes | null;
|
|
@@ -50,4 +81,4 @@ declare class ErrorHandler<CodeT extends string | number> {
|
|
|
50
81
|
}
|
|
51
82
|
declare const SharedErrorHandler: ErrorHandler<never>;
|
|
52
83
|
//#endregion
|
|
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 };
|
|
84
|
+
export { ErrorHandler as a, SharedErrorHandler as c, ns as d, resources as f, ErrorEntry as i, TranslateFunction as l, DomainErrorEntry as n, ErrorHandlerOptions as o, DomainErrorRegistry as r, GeneralErrorCodes as s, ApplicationException as t, configureTranslations as u };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isAxiosError, isCancel } from "axios";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import i18next from "i18next";
|
|
4
3
|
|
|
5
4
|
//#region src/lib/assets/locales/en/translation.json
|
|
6
5
|
var translation_default$1 = { openapi: { "sharedErrors": {
|
|
@@ -30,18 +29,14 @@ const resources = {
|
|
|
30
29
|
en: { [ns]: translation_default$1 },
|
|
31
30
|
sl: { [ns]: translation_default }
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
defaultNS: ns,
|
|
42
|
-
interpolation: { escapeValue: false }
|
|
43
|
-
});
|
|
44
|
-
const defaultT = i18n.t.bind(i18n);
|
|
32
|
+
let getT = null;
|
|
33
|
+
function configureTranslations(getter) {
|
|
34
|
+
getT = () => getter();
|
|
35
|
+
}
|
|
36
|
+
function resolveT() {
|
|
37
|
+
if (!getT) throw new Error("Translations not configured. Call configureTranslations() at app startup.");
|
|
38
|
+
return getT();
|
|
39
|
+
}
|
|
45
40
|
|
|
46
41
|
//#endregion
|
|
47
42
|
//#region src/lib/rest/rest.utils.ts
|
|
@@ -106,17 +101,15 @@ var ErrorHandler = class {
|
|
|
106
101
|
entries = [];
|
|
107
102
|
userEntries;
|
|
108
103
|
generalEntries;
|
|
109
|
-
t;
|
|
110
104
|
onRethrowError;
|
|
111
|
-
constructor({ entries,
|
|
112
|
-
this.t = t;
|
|
105
|
+
constructor({ entries, onRethrowError }) {
|
|
113
106
|
this.onRethrowError = onRethrowError;
|
|
114
107
|
const dataValidationError = {
|
|
115
108
|
code: "DATA_VALIDATION_ERROR",
|
|
116
109
|
condition: (e) => {
|
|
117
110
|
return e instanceof z.ZodError;
|
|
118
111
|
},
|
|
119
|
-
getMessage: () =>
|
|
112
|
+
getMessage: () => resolveT()("openapi.sharedErrors.dataValidation", { ns })
|
|
120
113
|
};
|
|
121
114
|
const internalError = {
|
|
122
115
|
code: "INTERNAL_ERROR",
|
|
@@ -124,7 +117,7 @@ var ErrorHandler = class {
|
|
|
124
117
|
if (isAxiosError(e)) return e.response?.status != null && e.response.status >= 500 && e.response.status < 600;
|
|
125
118
|
return false;
|
|
126
119
|
},
|
|
127
|
-
getMessage: () =>
|
|
120
|
+
getMessage: () => resolveT()("openapi.sharedErrors.internalError", { ns })
|
|
128
121
|
};
|
|
129
122
|
const networkError = {
|
|
130
123
|
code: "NETWORK_ERROR",
|
|
@@ -132,7 +125,7 @@ var ErrorHandler = class {
|
|
|
132
125
|
if (isAxiosError(e)) return e.code === "ERR_NETWORK";
|
|
133
126
|
return false;
|
|
134
127
|
},
|
|
135
|
-
getMessage: () =>
|
|
128
|
+
getMessage: () => resolveT()("openapi.sharedErrors.networkError", { ns })
|
|
136
129
|
};
|
|
137
130
|
const canceledError = {
|
|
138
131
|
code: "CANCELED_ERROR",
|
|
@@ -141,7 +134,7 @@ var ErrorHandler = class {
|
|
|
141
134
|
if (isAxiosError(e) && e.code === "ECONNABORTED") return true;
|
|
142
135
|
return false;
|
|
143
136
|
},
|
|
144
|
-
getMessage: () =>
|
|
137
|
+
getMessage: () => resolveT()("openapi.sharedErrors.canceledError", { ns })
|
|
145
138
|
};
|
|
146
139
|
const unknownError = {
|
|
147
140
|
code: "UNKNOWN_ERROR",
|
|
@@ -154,7 +147,7 @@ var ErrorHandler = class {
|
|
|
154
147
|
if (serverMessage) message += ` ${serverMessage}`;
|
|
155
148
|
return message;
|
|
156
149
|
}
|
|
157
|
-
return
|
|
150
|
+
return resolveT()("openapi.sharedErrors.unknownError", { ns });
|
|
158
151
|
}
|
|
159
152
|
};
|
|
160
153
|
this.userEntries = [...entries];
|
|
@@ -171,28 +164,25 @@ var ErrorHandler = class {
|
|
|
171
164
|
if (entry.condition) return entry.condition(error);
|
|
172
165
|
return code === entry.code;
|
|
173
166
|
}
|
|
174
|
-
setTranslateFunction(t) {
|
|
175
|
-
this.t = t;
|
|
176
|
-
}
|
|
177
167
|
rethrowError(error) {
|
|
178
168
|
const code = RestUtils.extractServerResponseCode(error);
|
|
179
169
|
const serverMessage = RestUtils.extractServerErrorMessage(error);
|
|
180
170
|
const userEntry = this.userEntries.find((entry) => this.matchesEntry(error, entry, code));
|
|
181
171
|
if (userEntry) {
|
|
182
|
-
const exception = new ApplicationException(userEntry.getMessage(
|
|
172
|
+
const exception = new ApplicationException(userEntry.getMessage(resolveT(), error), userEntry.code, serverMessage);
|
|
183
173
|
this.onRethrowError?.(error, exception);
|
|
184
174
|
throw exception;
|
|
185
175
|
}
|
|
186
176
|
if (code !== null) {
|
|
187
177
|
const registryEntry = DomainErrorRegistry.getEntry(code);
|
|
188
178
|
if (registryEntry && (!registryEntry.condition || registryEntry.condition(error))) {
|
|
189
|
-
const exception = new ApplicationException(registryEntry.getMessage(
|
|
179
|
+
const exception = new ApplicationException(registryEntry.getMessage(resolveT(), error), registryEntry.code, serverMessage);
|
|
190
180
|
this.onRethrowError?.(error, exception);
|
|
191
181
|
throw exception;
|
|
192
182
|
}
|
|
193
183
|
}
|
|
194
184
|
const generalEntry = this.generalEntries.find((entry) => this.matchesEntry(error, entry, code));
|
|
195
|
-
const exception = new ApplicationException(generalEntry.getMessage(
|
|
185
|
+
const exception = new ApplicationException(generalEntry.getMessage(resolveT(), error), generalEntry.code, serverMessage);
|
|
196
186
|
this.onRethrowError?.(error, exception);
|
|
197
187
|
throw exception;
|
|
198
188
|
}
|
|
@@ -211,11 +201,11 @@ var ErrorHandler = class {
|
|
|
211
201
|
if (error.serverMessage != null) return error.serverMessage;
|
|
212
202
|
return error.message;
|
|
213
203
|
}
|
|
214
|
-
if (fallbackToUnknown) return
|
|
204
|
+
if (fallbackToUnknown) return resolveT()("openapi.sharedErrors.unknownError", { ns });
|
|
215
205
|
return null;
|
|
216
206
|
}
|
|
217
207
|
};
|
|
218
208
|
const SharedErrorHandler = new ErrorHandler({ entries: [] });
|
|
219
209
|
|
|
220
210
|
//#endregion
|
|
221
|
-
export { RestUtils as a, SharedErrorHandler as i, DomainErrorRegistry as n,
|
|
211
|
+
export { RestUtils as a, resources as c, SharedErrorHandler as i, DomainErrorRegistry as n, configureTranslations as o, ErrorHandler as r, ns 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-CbQ9gQss.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
4
|
|
package/dist/{generateCodeFromOpenAPIDoc-C-n0Knj8.mjs → generateCodeFromOpenAPIDoc-CbQ9gQss.mjs}
RENAMED
|
@@ -4507,6 +4507,9 @@ function renderInlineRequestInfo(resolver, endpoint, tag) {
|
|
|
4507
4507
|
function getRequestConfigType() {
|
|
4508
4508
|
return `${AXIOS_REQUEST_CONFIG_TYPE} & { allowInvalidResponseData?: boolean }`;
|
|
4509
4509
|
}
|
|
4510
|
+
function renderRequestConfigWithSignal(hasRequestConfigParam) {
|
|
4511
|
+
return `{ ${hasRequestConfigParam ? `...${AXIOS_REQUEST_CONFIG_NAME}, ` : ""}signal }`;
|
|
4512
|
+
}
|
|
4510
4513
|
function renderInlineEndpointParamParse(resolver, param, paramName, modelNamespaceTag) {
|
|
4511
4514
|
const addOptional = !(param.parameterObject ?? param.bodyObject)?.required && (Boolean(param.parameterSortingEnumSchemaName) || isNamedZodSchema(param.zodSchema));
|
|
4512
4515
|
const schemaValue = param.parameterSortingEnumSchemaName ? `${ZOD_EXTENDED.namespace}.${ZOD_EXTENDED.exports.sortExp}(${getImportedZodSchemaName(resolver, param.parameterSortingEnumSchemaName, modelNamespaceTag)})${getSortingPresenceChain(resolver, param)}` : `${getImportedZodSchemaName(resolver, param.zodSchema, modelNamespaceTag)}${addOptional ? ".optional()" : ""}`;
|
|
@@ -4553,7 +4556,8 @@ function renderQueryOptions({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4553
4556
|
const lines = [];
|
|
4554
4557
|
lines.push(`const ${getQueryOptionsName(endpoint)} = (${endpointParams ? `{ ${endpointArgs} }: { ${endpointParams} }` : ""}${hasRequestConfigParam ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}?: ${getRequestConfigType()}` : ""}) => ({`);
|
|
4555
4558
|
lines.push(` queryKey: keys.${getEndpointName(endpoint)}(${endpointArgs}),`);
|
|
4556
|
-
|
|
4559
|
+
const requestConfigWithSignal = renderRequestConfigWithSignal(hasRequestConfigParam);
|
|
4560
|
+
lines.push(` queryFn: ({ signal }: { signal: AbortSignal }) => ${endpointFunction}(${endpointArgs}${hasRequestConfigParam ? `${endpointArgs ? ", " : ""}${requestConfigWithSignal}` : ""}),`);
|
|
4557
4561
|
lines.push("});");
|
|
4558
4562
|
return lines.join("\n");
|
|
4559
4563
|
}
|
|
@@ -4569,7 +4573,8 @@ function renderInfiniteQueryOptions({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4569
4573
|
const lines = [];
|
|
4570
4574
|
lines.push(`const ${getInfiniteQueryOptionsName(endpoint)} = (${endpointParams ? `{ ${endpointArgsWithoutPage} }: { ${endpointParams} }` : ""}${hasRequestConfigParam ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}?: ${getRequestConfigType()}` : ""}) => ({`);
|
|
4571
4575
|
lines.push(` queryKey: keys.${getEndpointName(endpoint)}Infinite(${endpointArgsWithoutPage}),`);
|
|
4572
|
-
|
|
4576
|
+
const requestConfigWithSignal = renderRequestConfigWithSignal(hasRequestConfigParam);
|
|
4577
|
+
lines.push(` queryFn: ({ pageParam, signal }: { pageParam: number; signal: AbortSignal }) => ${endpointFunction}(${endpointArgsWithPage}${hasRequestConfigParam ? `, ${requestConfigWithSignal}` : ""}),`);
|
|
4573
4578
|
lines.push(" initialPageParam: 1,");
|
|
4574
4579
|
lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }: Awaited<ReturnType<typeof ${endpointFunction}>>) => {`);
|
|
4575
4580
|
lines.push(` const pageParam = ${resolver.options.infiniteQueryResponseParamNames.page} ?? 1;`);
|
|
@@ -4637,9 +4642,9 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4637
4642
|
lines.push(` return ${QUERY_HOOKS.query}({`);
|
|
4638
4643
|
lines.push(` ...${queryOptionsName}(${queryOptionsArgs}),`);
|
|
4639
4644
|
if (hasQueryFnOverride) {
|
|
4640
|
-
lines.push(" queryFn: async () => {");
|
|
4645
|
+
lines.push(" queryFn: async ({ signal }: { signal: AbortSignal }) => {");
|
|
4641
4646
|
if (hasAclCheck) lines.push(renderAclCheckCall(resolver, endpoint, workspaceParamReplacements, " "));
|
|
4642
|
-
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn();`);
|
|
4647
|
+
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ signal });`);
|
|
4643
4648
|
lines.push(" },");
|
|
4644
4649
|
}
|
|
4645
4650
|
lines.push(" ...options,");
|
|
@@ -4826,9 +4831,9 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4826
4831
|
lines.push(` return ${QUERY_HOOKS.infiniteQuery}({`);
|
|
4827
4832
|
lines.push(` ...${queryOptionsName}(${queryOptionsArgs}),`);
|
|
4828
4833
|
if (hasQueryFnOverride) {
|
|
4829
|
-
lines.push(" queryFn: async ({ pageParam }) => {");
|
|
4834
|
+
lines.push(" queryFn: async ({ pageParam, signal }: { pageParam: number; signal: AbortSignal }) => {");
|
|
4830
4835
|
lines.push(renderAclCheckCall(resolver, endpoint, workspaceParamReplacements, " "));
|
|
4831
|
-
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ pageParam });`);
|
|
4836
|
+
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ pageParam, signal });`);
|
|
4832
4837
|
lines.push(" },");
|
|
4833
4838
|
}
|
|
4834
4839
|
lines.push(" ...options,");
|
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-CbQ9gQss.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,9 +1,8 @@
|
|
|
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-
|
|
1
|
+
import { a as ErrorHandler, c as SharedErrorHandler, d as ns, f as resources, i as ErrorEntry, l as TranslateFunction, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException, u as configureTranslations } from "./error-handling-BeRxGbwE.mjs";
|
|
2
2
|
import "./options-CE4Koxof.mjs";
|
|
3
3
|
import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
|
|
4
4
|
import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import "i18next";
|
|
7
6
|
import * as react from "react";
|
|
8
7
|
import { PropsWithChildren, ReactNode } from "react";
|
|
9
8
|
import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
@@ -153,39 +152,6 @@ declare namespace OpenApiWorkspaceContext {
|
|
|
153
152
|
}
|
|
154
153
|
declare const useWorkspaceContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
155
154
|
//#endregion
|
|
156
|
-
//#region src/lib/config/i18n.d.ts
|
|
157
|
-
declare const ns = "openapi";
|
|
158
|
-
declare const resources: {
|
|
159
|
-
readonly en: {
|
|
160
|
-
readonly openapi: {
|
|
161
|
-
openapi: {
|
|
162
|
-
sharedErrors: {
|
|
163
|
-
dataValidation: string;
|
|
164
|
-
internalError: string;
|
|
165
|
-
networkError: string;
|
|
166
|
-
canceledError: string;
|
|
167
|
-
unknownError: string;
|
|
168
|
-
unknownErrorWithCode: string;
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
readonly sl: {
|
|
174
|
-
readonly openapi: {
|
|
175
|
-
openapi: {
|
|
176
|
-
sharedErrors: {
|
|
177
|
-
dataValidation: string;
|
|
178
|
-
internalError: string;
|
|
179
|
-
networkError: string;
|
|
180
|
-
canceledError: string;
|
|
181
|
-
unknownError: string;
|
|
182
|
-
unknownErrorWithCode: string;
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
//#endregion
|
|
189
155
|
//#region src/lib/auth/auth.context.d.ts
|
|
190
156
|
declare namespace AuthContext {
|
|
191
157
|
export interface Routes {
|
|
@@ -231,4 +197,4 @@ declare const AuthGuard: ({
|
|
|
231
197
|
children
|
|
232
198
|
}: PropsWithChildren<AuthGuardProps>) => react.ReactNode;
|
|
233
199
|
//#endregion
|
|
234
|
-
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 };
|
|
200
|
+
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, type TranslateFunction, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, o as
|
|
1
|
+
import { a as RestUtils, c as resources, i as SharedErrorHandler, n as DomainErrorRegistry, o as configureTranslations, r as ErrorHandler, s as ns, t as ApplicationException } from "./error-handling-DG8SfTWB.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";
|
|
@@ -261,4 +261,4 @@ const AuthGuard = ({ type, redirectTo, children }) => {
|
|
|
261
261
|
};
|
|
262
262
|
|
|
263
263
|
//#endregion
|
|
264
|
-
export { ApplicationException, AuthContext, AuthGuard, DomainErrorRegistry, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
|
|
264
|
+
export { ApplicationException, AuthContext, AuthGuard, DomainErrorRegistry, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };
|
package/dist/metro.cjs
CHANGED
|
@@ -4317,6 +4317,9 @@ function renderInlineRequestInfo(resolver, endpoint, tag) {
|
|
|
4317
4317
|
function getRequestConfigType() {
|
|
4318
4318
|
return `${AXIOS_REQUEST_CONFIG_TYPE} & { allowInvalidResponseData?: boolean }`;
|
|
4319
4319
|
}
|
|
4320
|
+
function renderRequestConfigWithSignal(hasRequestConfigParam) {
|
|
4321
|
+
return `{ ${hasRequestConfigParam ? `...${AXIOS_REQUEST_CONFIG_NAME}, ` : ""}signal }`;
|
|
4322
|
+
}
|
|
4320
4323
|
function renderInlineEndpointParamParse(resolver, param, paramName, modelNamespaceTag) {
|
|
4321
4324
|
const addOptional = !(param.parameterObject ?? param.bodyObject)?.required && (Boolean(param.parameterSortingEnumSchemaName) || isNamedZodSchema(param.zodSchema));
|
|
4322
4325
|
const schemaValue = param.parameterSortingEnumSchemaName ? `${ZOD_EXTENDED.namespace}.${ZOD_EXTENDED.exports.sortExp}(${getImportedZodSchemaName(resolver, param.parameterSortingEnumSchemaName, modelNamespaceTag)})${getSortingPresenceChain(resolver, param)}` : `${getImportedZodSchemaName(resolver, param.zodSchema, modelNamespaceTag)}${addOptional ? ".optional()" : ""}`;
|
|
@@ -4363,7 +4366,8 @@ function renderQueryOptions({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4363
4366
|
const lines = [];
|
|
4364
4367
|
lines.push(`const ${getQueryOptionsName(endpoint)} = (${endpointParams ? `{ ${endpointArgs} }: { ${endpointParams} }` : ""}${hasRequestConfigParam ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}?: ${getRequestConfigType()}` : ""}) => ({`);
|
|
4365
4368
|
lines.push(` queryKey: keys.${getEndpointName(endpoint)}(${endpointArgs}),`);
|
|
4366
|
-
|
|
4369
|
+
const requestConfigWithSignal = renderRequestConfigWithSignal(hasRequestConfigParam);
|
|
4370
|
+
lines.push(` queryFn: ({ signal }: { signal: AbortSignal }) => ${endpointFunction}(${endpointArgs}${hasRequestConfigParam ? `${endpointArgs ? ", " : ""}${requestConfigWithSignal}` : ""}),`);
|
|
4367
4371
|
lines.push("});");
|
|
4368
4372
|
return lines.join("\n");
|
|
4369
4373
|
}
|
|
@@ -4379,7 +4383,8 @@ function renderInfiniteQueryOptions({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4379
4383
|
const lines = [];
|
|
4380
4384
|
lines.push(`const ${getInfiniteQueryOptionsName(endpoint)} = (${endpointParams ? `{ ${endpointArgsWithoutPage} }: { ${endpointParams} }` : ""}${hasRequestConfigParam ? `${endpointParams ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}?: ${getRequestConfigType()}` : ""}) => ({`);
|
|
4381
4385
|
lines.push(` queryKey: keys.${getEndpointName(endpoint)}Infinite(${endpointArgsWithoutPage}),`);
|
|
4382
|
-
|
|
4386
|
+
const requestConfigWithSignal = renderRequestConfigWithSignal(hasRequestConfigParam);
|
|
4387
|
+
lines.push(` queryFn: ({ pageParam, signal }: { pageParam: number; signal: AbortSignal }) => ${endpointFunction}(${endpointArgsWithPage}${hasRequestConfigParam ? `, ${requestConfigWithSignal}` : ""}),`);
|
|
4383
4388
|
lines.push(" initialPageParam: 1,");
|
|
4384
4389
|
lines.push(` getNextPageParam: ({ ${resolver.options.infiniteQueryResponseParamNames.page}, ${resolver.options.infiniteQueryResponseParamNames.totalItems}, ${resolver.options.infiniteQueryResponseParamNames.limit}: limitParam }: Awaited<ReturnType<typeof ${endpointFunction}>>) => {`);
|
|
4385
4390
|
lines.push(` const pageParam = ${resolver.options.infiniteQueryResponseParamNames.page} ?? 1;`);
|
|
@@ -4447,9 +4452,9 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4447
4452
|
lines.push(` return ${QUERY_HOOKS.query}({`);
|
|
4448
4453
|
lines.push(` ...${queryOptionsName}(${queryOptionsArgs}),`);
|
|
4449
4454
|
if (hasQueryFnOverride) {
|
|
4450
|
-
lines.push(" queryFn: async () => {");
|
|
4455
|
+
lines.push(" queryFn: async ({ signal }: { signal: AbortSignal }) => {");
|
|
4451
4456
|
if (hasAclCheck) lines.push(renderAclCheckCall(resolver, endpoint, workspaceParamReplacements, " "));
|
|
4452
|
-
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn();`);
|
|
4457
|
+
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ signal });`);
|
|
4453
4458
|
lines.push(" },");
|
|
4454
4459
|
}
|
|
4455
4460
|
lines.push(" ...options,");
|
|
@@ -4636,9 +4641,9 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4636
4641
|
lines.push(` return ${QUERY_HOOKS.infiniteQuery}({`);
|
|
4637
4642
|
lines.push(` ...${queryOptionsName}(${queryOptionsArgs}),`);
|
|
4638
4643
|
if (hasQueryFnOverride) {
|
|
4639
|
-
lines.push(" queryFn: async ({ pageParam }) => {");
|
|
4644
|
+
lines.push(" queryFn: async ({ pageParam, signal }: { pageParam: number; signal: AbortSignal }) => {");
|
|
4640
4645
|
lines.push(renderAclCheckCall(resolver, endpoint, workspaceParamReplacements, " "));
|
|
4641
|
-
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ pageParam });`);
|
|
4646
|
+
lines.push(` return ${queryOptionsName}(${queryOptionsArgs}).queryFn({ pageParam, signal });`);
|
|
4642
4647
|
lines.push(" },");
|
|
4643
4648
|
}
|
|
4644
4649
|
lines.push(" ...options,");
|
|
@@ -4983,7 +4988,7 @@ function getGenerateStats(filesData, config) {
|
|
|
4983
4988
|
|
|
4984
4989
|
//#endregion
|
|
4985
4990
|
//#region src/plugins/openapi-codegen.runner.ts
|
|
4986
|
-
function createOpenApiCodegenRunner(config) {
|
|
4991
|
+
function createOpenApiCodegenRunner(config, options = {}) {
|
|
4987
4992
|
let queue = Promise.resolve();
|
|
4988
4993
|
const { formatGeneratedFile, ...fileConfig } = config;
|
|
4989
4994
|
const enqueueGenerate = (root) => {
|
|
@@ -4994,6 +4999,7 @@ function createOpenApiCodegenRunner(config) {
|
|
|
4994
4999
|
formatGeneratedFile,
|
|
4995
5000
|
profiler
|
|
4996
5001
|
});
|
|
5002
|
+
options.onGenerated?.();
|
|
4997
5003
|
});
|
|
4998
5004
|
queue = run.then(() => void 0, () => void 0);
|
|
4999
5005
|
return run;
|
|
@@ -5026,7 +5032,9 @@ function withOpenApiCodegen(metroConfig, codegenConfig, options = {}) {
|
|
|
5026
5032
|
}
|
|
5027
5033
|
function withResolvedOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
5028
5034
|
const root = path.default.resolve(options.root ?? metroConfig.projectRoot ?? process.cwd());
|
|
5029
|
-
const codegen = createOpenApiCodegenRunner(codegenConfig)
|
|
5035
|
+
const codegen = createOpenApiCodegenRunner(codegenConfig, { onGenerated() {
|
|
5036
|
+
console.info("[openapi-codegen] OpenAPI client generated successfully.");
|
|
5037
|
+
} });
|
|
5030
5038
|
const originalEnhanceMiddleware = metroConfig.server?.enhanceMiddleware;
|
|
5031
5039
|
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
5032
5040
|
let startupSucceeded = false;
|
|
@@ -5199,6 +5207,7 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
5199
5207
|
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
5200
5208
|
let startupSucceeded = false;
|
|
5201
5209
|
let inflightGenerate;
|
|
5210
|
+
let metroServer;
|
|
5202
5211
|
let watcherReady = false;
|
|
5203
5212
|
const requestGenerateAll = () => {
|
|
5204
5213
|
if (startupSucceeded) return Promise.resolve();
|
|
@@ -5215,7 +5224,9 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
5215
5224
|
};
|
|
5216
5225
|
const requestSourceChangeGenerate = () => {
|
|
5217
5226
|
startupSucceeded = false;
|
|
5218
|
-
return requestGenerateAll()
|
|
5227
|
+
return requestGenerateAll().then(() => {
|
|
5228
|
+
notifyMetroReload(metroServer);
|
|
5229
|
+
});
|
|
5219
5230
|
};
|
|
5220
5231
|
const ensureWatcher = () => {
|
|
5221
5232
|
if (watcherReady || options.watchTinyOpenApiInput === false) return;
|
|
@@ -5227,6 +5238,7 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
5227
5238
|
server: {
|
|
5228
5239
|
...metroConfig.server,
|
|
5229
5240
|
enhanceMiddleware(middleware, server) {
|
|
5241
|
+
metroServer = server;
|
|
5230
5242
|
ensureWatcher();
|
|
5231
5243
|
const enhancedMiddleware = originalEnhanceMiddleware ? originalEnhanceMiddleware(middleware, server) : middleware;
|
|
5232
5244
|
return async (request, response, next) => {
|
|
@@ -5274,6 +5286,31 @@ function reportGenerateError(error) {
|
|
|
5274
5286
|
function reportWatcherError(error) {
|
|
5275
5287
|
console.error("[tiny-openapi] Failed to watch OpenAPI inputs from Metro config.", error);
|
|
5276
5288
|
}
|
|
5289
|
+
function notifyMetroReload(server) {
|
|
5290
|
+
const serverRecord = isRecord(server) ? server : void 0;
|
|
5291
|
+
const sockets = [
|
|
5292
|
+
serverRecord?.messageSocket,
|
|
5293
|
+
serverRecord?._messageSocket,
|
|
5294
|
+
serverRecord?.websocketServer,
|
|
5295
|
+
serverRecord?._websocketServer,
|
|
5296
|
+
serverRecord?.hmrServer,
|
|
5297
|
+
serverRecord?._hmrServer
|
|
5298
|
+
];
|
|
5299
|
+
for (const socket of sockets) {
|
|
5300
|
+
if (!isRecord(socket)) continue;
|
|
5301
|
+
if (typeof socket.broadcast === "function") {
|
|
5302
|
+
socket.broadcast({ type: "reload" });
|
|
5303
|
+
return;
|
|
5304
|
+
}
|
|
5305
|
+
if (typeof socket.send === "function") {
|
|
5306
|
+
socket.send({ type: "reload" });
|
|
5307
|
+
return;
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
5311
|
+
function isRecord(value) {
|
|
5312
|
+
return typeof value === "object" && value !== null;
|
|
5313
|
+
}
|
|
5277
5314
|
|
|
5278
5315
|
//#endregion
|
|
5279
5316
|
exports.tinyOpenApiCodegenMetro = tinyOpenApiCodegenMetro;
|
package/dist/metro.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import "./generate.runner-
|
|
3
|
-
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-
|
|
1
|
+
import "./generateCodeFromOpenAPIDoc-CbQ9gQss.mjs";
|
|
2
|
+
import "./generate.runner-DnUDkoAZ.mjs";
|
|
3
|
+
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-BqOhUduF.mjs";
|
|
4
4
|
import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-wLs5vqw6.mjs";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
@@ -12,7 +12,9 @@ function withOpenApiCodegen(metroConfig, codegenConfig, options = {}) {
|
|
|
12
12
|
}
|
|
13
13
|
function withResolvedOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
14
14
|
const root = path.resolve(options.root ?? metroConfig.projectRoot ?? process.cwd());
|
|
15
|
-
const codegen = createOpenApiCodegenRunner(codegenConfig)
|
|
15
|
+
const codegen = createOpenApiCodegenRunner(codegenConfig, { onGenerated() {
|
|
16
|
+
console.info("[openapi-codegen] OpenAPI client generated successfully.");
|
|
17
|
+
} });
|
|
16
18
|
const originalEnhanceMiddleware = metroConfig.server?.enhanceMiddleware;
|
|
17
19
|
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
18
20
|
let startupSucceeded = false;
|
|
@@ -107,6 +109,7 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
107
109
|
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
108
110
|
let startupSucceeded = false;
|
|
109
111
|
let inflightGenerate;
|
|
112
|
+
let metroServer;
|
|
110
113
|
let watcherReady = false;
|
|
111
114
|
const requestGenerateAll = () => {
|
|
112
115
|
if (startupSucceeded) return Promise.resolve();
|
|
@@ -123,7 +126,9 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
123
126
|
};
|
|
124
127
|
const requestSourceChangeGenerate = () => {
|
|
125
128
|
startupSucceeded = false;
|
|
126
|
-
return requestGenerateAll()
|
|
129
|
+
return requestGenerateAll().then(() => {
|
|
130
|
+
notifyMetroReload(metroServer);
|
|
131
|
+
});
|
|
127
132
|
};
|
|
128
133
|
const ensureWatcher = () => {
|
|
129
134
|
if (watcherReady || options.watchTinyOpenApiInput === false) return;
|
|
@@ -135,6 +140,7 @@ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
|
|
|
135
140
|
server: {
|
|
136
141
|
...metroConfig.server,
|
|
137
142
|
enhanceMiddleware(middleware, server) {
|
|
143
|
+
metroServer = server;
|
|
138
144
|
ensureWatcher();
|
|
139
145
|
const enhancedMiddleware = originalEnhanceMiddleware ? originalEnhanceMiddleware(middleware, server) : middleware;
|
|
140
146
|
return async (request, response, next) => {
|
|
@@ -182,6 +188,31 @@ function reportGenerateError(error) {
|
|
|
182
188
|
function reportWatcherError(error) {
|
|
183
189
|
console.error("[tiny-openapi] Failed to watch OpenAPI inputs from Metro config.", error);
|
|
184
190
|
}
|
|
191
|
+
function notifyMetroReload(server) {
|
|
192
|
+
const serverRecord = isRecord(server) ? server : void 0;
|
|
193
|
+
const sockets = [
|
|
194
|
+
serverRecord?.messageSocket,
|
|
195
|
+
serverRecord?._messageSocket,
|
|
196
|
+
serverRecord?.websocketServer,
|
|
197
|
+
serverRecord?._websocketServer,
|
|
198
|
+
serverRecord?.hmrServer,
|
|
199
|
+
serverRecord?._hmrServer
|
|
200
|
+
];
|
|
201
|
+
for (const socket of sockets) {
|
|
202
|
+
if (!isRecord(socket)) continue;
|
|
203
|
+
if (typeof socket.broadcast === "function") {
|
|
204
|
+
socket.broadcast({ type: "reload" });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (typeof socket.send === "function") {
|
|
208
|
+
socket.send({ type: "reload" });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function isRecord(value) {
|
|
214
|
+
return typeof value === "object" && value !== null;
|
|
215
|
+
}
|
|
185
216
|
|
|
186
217
|
//#endregion
|
|
187
218
|
export { tinyOpenApiCodegenMetro, withOpenApiCodegen };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { t as runGenerate } from "./generate.runner-
|
|
1
|
+
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-CbQ9gQss.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-DnUDkoAZ.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/openapi-codegen.runner.ts
|
|
6
|
-
function createOpenApiCodegenRunner(config) {
|
|
6
|
+
function createOpenApiCodegenRunner(config, options = {}) {
|
|
7
7
|
let queue = Promise.resolve();
|
|
8
8
|
const { formatGeneratedFile, ...fileConfig } = config;
|
|
9
9
|
const enqueueGenerate = (root) => {
|
|
@@ -14,6 +14,7 @@ function createOpenApiCodegenRunner(config) {
|
|
|
14
14
|
formatGeneratedFile,
|
|
15
15
|
profiler
|
|
16
16
|
});
|
|
17
|
+
options.onGenerated?.();
|
|
17
18
|
});
|
|
18
19
|
queue = run.then(() => void 0, () => void 0);
|
|
19
20
|
return run;
|
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-CbQ9gQss.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-DnUDkoAZ.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.1.0-rc.
|
|
42
|
+
return "3.1.0-rc.7";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
package/dist/vite.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import "./generate.runner-
|
|
3
|
-
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-
|
|
1
|
+
import "./generateCodeFromOpenAPIDoc-CbQ9gQss.mjs";
|
|
2
|
+
import "./generate.runner-DnUDkoAZ.mjs";
|
|
3
|
+
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-BqOhUduF.mjs";
|
|
4
4
|
import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-wLs5vqw6.mjs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
|
|
7
7
|
//#region src/vite/openapi-codegen.plugin.ts
|
|
8
8
|
function openApiCodegen(config) {
|
|
9
9
|
let resolvedViteConfig;
|
|
10
|
-
const codegen = createOpenApiCodegenRunner(config)
|
|
10
|
+
const codegen = createOpenApiCodegenRunner(config, { onGenerated() {
|
|
11
|
+
resolvedViteConfig?.logger.info("[openapi-codegen] OpenAPI client generated successfully.");
|
|
12
|
+
} });
|
|
11
13
|
const enqueueGenerate = () => {
|
|
12
14
|
const currentConfig = resolvedViteConfig;
|
|
13
15
|
if (!currentConfig) return Promise.resolve();
|
|
@@ -69,7 +71,9 @@ function tinyOpenApiCodegenPlugin(codegenConfig, options) {
|
|
|
69
71
|
const scheduleGenerate = (server) => {
|
|
70
72
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
71
73
|
debounceTimer = setTimeout(() => {
|
|
72
|
-
enqueueGenerate().
|
|
74
|
+
enqueueGenerate().then(() => {
|
|
75
|
+
server.ws.send({ type: "full-reload" });
|
|
76
|
+
}).catch((error) => {
|
|
73
77
|
server.config.logger.error(`[tiny-openapi] ${error instanceof Error ? error.message : String(error)}`);
|
|
74
78
|
});
|
|
75
79
|
}, debounceMs);
|
package/dist/zod.d.mts
CHANGED
package/dist/zod.mjs
CHANGED
package/package.json
CHANGED
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
"@orpc/contract": "^1.14.3",
|
|
84
84
|
"@orpc/openapi": "^1.14.3",
|
|
85
85
|
"@orpc/zod": "^1.14.3",
|
|
86
|
-
"i18next": "^25.8.13",
|
|
87
86
|
"import-fresh": "^3.3.1",
|
|
88
87
|
"openapi-types": "^12.1.3",
|
|
89
88
|
"prompt-sync": "^4.2.0",
|
|
@@ -119,6 +118,7 @@
|
|
|
119
118
|
"@casl/react": "^5.0.0",
|
|
120
119
|
"@tanstack/react-query": "^5.90.21",
|
|
121
120
|
"axios": "^1.13.1",
|
|
121
|
+
"i18next": "^25.8.11",
|
|
122
122
|
"react": "^19.1.0",
|
|
123
123
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
124
124
|
"zod": "^4.1.12"
|
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
"pnpm": ">= 9"
|
|
140
140
|
},
|
|
141
141
|
"packageManager": "pnpm@10.4.0",
|
|
142
|
-
"version": "3.1.0-rc.
|
|
142
|
+
"version": "3.1.0-rc.7"
|
|
143
143
|
}
|