@povio/openapi-codegen-cli 3.2.0-rc.7 → 3.2.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthGuard-GbtTDXs0.d.mts +32 -0
- package/dist/AuthGuard-qpAtHaBz.mjs +24 -0
- package/dist/acl.d.mts +1 -1
- package/dist/acl.mjs +3 -2
- package/dist/{auth.context-YFWzkwoN.mjs → auth.context-COWO6ssl.mjs} +1 -19
- package/dist/auth.d.mts +2 -0
- package/dist/auth.mjs +3 -0
- package/dist/axios.d.mts +2 -0
- package/dist/axios.mjs +2 -0
- package/dist/config.d.mts +4 -0
- package/dist/config.mjs +5 -0
- package/dist/{error-handling-BMXC5P08.mjs → error-handling-BeydPL7s.mjs} +2 -36
- package/dist/{error-handling-CNOHs4Fc.d.mts → error-handling-LPEPQV1V.d.mts} +2 -38
- package/dist/errors.d.mts +3 -0
- package/dist/errors.mjs +2 -0
- package/dist/generate.runner-D8AYuEFm.mjs +184 -0
- package/dist/{generate.utils-CH2U2Dpr.cjs → generate.utils-CT-LA-gX.cjs} +6 -53
- package/dist/{generateCodeFromOpenAPIDoc-glAKBEGP.mjs → generateCodeFromOpenAPIDoc--ufinTug.mjs} +29 -4
- package/dist/{generateCodeFromOpenAPIDoc-CZT3sThI.cjs → generateCodeFromOpenAPIDoc-iEa8YAUQ.cjs} +48 -23
- package/dist/generator.mjs +4 -3
- package/dist/{getDataFromOpenAPIDoc-7RxjULpB.mjs → getDataFromOpenAPIDoc-D8w0QElH.mjs} +1 -1
- package/dist/i18n-B_brQh4X.d.mts +38 -0
- package/dist/i18n-D-FesqFb.mjs +36 -0
- package/dist/index.d.mts +10 -161
- package/dist/index.mjs +10 -257
- package/dist/metro.cjs +2 -2
- package/dist/metro.mjs +1 -1
- package/dist/{generate.runner-BvSprH6D.mjs → native-bindings-BTQGSGhU.mjs} +5 -208
- package/dist/{native-rest-interceptor-Bcc2jx4e.mjs → native-rest-interceptor-CAWR8H5Y.mjs} +24 -5
- package/dist/{native-rest-interceptor-CTBBx6B3.d.mts → native-rest-interceptor-Cz6saoq5.d.mts} +5 -2
- package/dist/native.d.mts +2 -2
- package/dist/native.mjs +1 -1
- package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
- package/dist/openapi-codegen-native-linux-x64.node +0 -0
- package/dist/openapi-codegen-native-win32-x64.node +0 -0
- package/dist/{openapi-codegen.runner-C93V7SGj.mjs → openapi-codegen.runner-6Yth6QZC.mjs} +2 -1
- package/dist/query.d.mts +3 -0
- package/dist/query.mjs +3 -0
- package/dist/queryConfig.context-CRJOgf19.d.mts +22 -0
- package/dist/queryConfig.context-CldQ5YL9.mjs +34 -0
- package/dist/rest-client-CQyFvqYC.d.mts +55 -0
- package/dist/rest-interceptor-D5NCNTm1.mjs +115 -0
- package/dist/{rest-transport.types-D0R9mvGH.d.mts → rest-transport.types-DM5-qyOJ.d.mts} +9 -2
- package/dist/rest.d.mts +1 -1
- package/dist/rest.utils-rezWAIYL.d.mts +10 -0
- package/dist/router.context-EPlMBk3G.mjs +21 -0
- package/dist/sh.mjs +4 -3
- package/dist/useMutationEffects-DIdL8tlx.d.mts +29 -0
- package/dist/useMutationEffects-PB1fvKWM.mjs +68 -0
- package/dist/vite.mjs +1 -1
- package/dist/workspace.context-XWvQ_7Hg.mjs +26 -0
- package/dist/workspace.context-isVY9ves.d.mts +23 -0
- package/dist/zod.d.mts +1 -1
- package/dist/zod.mjs +1 -1
- package/package.json +39 -2
package/dist/native.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as HttpError } from "./rest-transport.types-DxitRtsB.mjs";
|
|
2
|
-
import { n as NativeRestClient, t as NativeRestInterceptor } from "./native-rest-interceptor-
|
|
2
|
+
import { n as NativeRestClient, t as NativeRestInterceptor } from "./native-rest-interceptor-CAWR8H5Y.mjs";
|
|
3
3
|
export { HttpError, HttpError as NativeHttpError, NativeRestClient, NativeRestInterceptor };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Wn as Profiler } from "./native-bindings-BTQGSGhU.mjs";
|
|
2
|
+
import { n as runGenerate } from "./generate.runner-D8AYuEFm.mjs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
//#region src/plugins/openapi-codegen.runner.ts
|
|
4
5
|
function createOpenApiCodegenRunner(config, options = {}) {
|
package/dist/query.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as QueryModule, n as InvalidationMapFunc, r as OpenApiQueryConfig, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
|
|
2
|
+
import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-DIdL8tlx.mjs";
|
|
3
|
+
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, OpenApiQueryConfig, type QueryModule, useMutationEffects };
|
package/dist/query.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { QueryKey } from "@tanstack/react-query";
|
|
3
|
+
//#region src/lib/config/queryConfig.context.d.ts
|
|
4
|
+
type QueryModule = string | number | symbol;
|
|
5
|
+
type InvalidationMapFunc<TData = any, TVariables = any> = (data: TData, variables: TVariables) => QueryKey[];
|
|
6
|
+
type InvalidationMap<TQueryModule extends QueryModule = QueryModule, TData = any, TVariables = any> = Partial<Record<TQueryModule, InvalidationMapFunc<TData, TVariables>>>;
|
|
7
|
+
declare namespace OpenApiQueryConfig {
|
|
8
|
+
export interface Type<TQueryModule extends QueryModule = QueryModule> {
|
|
9
|
+
preferUpdate?: boolean;
|
|
10
|
+
invalidateCurrentModule?: boolean;
|
|
11
|
+
invalidationMap?: InvalidationMap<TQueryModule>;
|
|
12
|
+
crossTabInvalidation?: boolean;
|
|
13
|
+
allowInvalidResponseData?: boolean;
|
|
14
|
+
onError?: (error: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
type ProviderProps<TQueryModule extends QueryModule = QueryModule> = Type<TQueryModule>;
|
|
17
|
+
export function Provider<TQueryModule extends QueryModule = QueryModule>({ preferUpdate, invalidateCurrentModule, invalidationMap, crossTabInvalidation, allowInvalidResponseData, onError, children }: PropsWithChildren<ProviderProps<TQueryModule>>): import("react").JSX.Element;
|
|
18
|
+
export const useConfig: <TQueryModule extends QueryModule = QueryModule>() => Type<TQueryModule>;
|
|
19
|
+
export {};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { QueryModule as i, InvalidationMapFunc as n, OpenApiQueryConfig as r, InvalidationMap as t };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createContext, use, useMemo } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/lib/config/queryConfig.context.tsx
|
|
4
|
+
let OpenApiQueryConfig;
|
|
5
|
+
(function(_OpenApiQueryConfig) {
|
|
6
|
+
const Context = createContext({});
|
|
7
|
+
function Provider({ preferUpdate, invalidateCurrentModule, invalidationMap, crossTabInvalidation, allowInvalidResponseData, onError, children }) {
|
|
8
|
+
const value = useMemo(() => ({
|
|
9
|
+
preferUpdate,
|
|
10
|
+
invalidateCurrentModule,
|
|
11
|
+
invalidationMap,
|
|
12
|
+
crossTabInvalidation,
|
|
13
|
+
allowInvalidResponseData,
|
|
14
|
+
onError
|
|
15
|
+
}), [
|
|
16
|
+
preferUpdate,
|
|
17
|
+
invalidateCurrentModule,
|
|
18
|
+
invalidationMap,
|
|
19
|
+
crossTabInvalidation,
|
|
20
|
+
allowInvalidResponseData,
|
|
21
|
+
onError
|
|
22
|
+
]);
|
|
23
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
24
|
+
value,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_OpenApiQueryConfig.Provider = Provider;
|
|
29
|
+
_OpenApiQueryConfig.useConfig = () => {
|
|
30
|
+
return use(Context) ?? {};
|
|
31
|
+
};
|
|
32
|
+
})(OpenApiQueryConfig || (OpenApiQueryConfig = {}));
|
|
33
|
+
//#endregion
|
|
34
|
+
export { OpenApiQueryConfig as t };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { a as ErrorHandler, s as GeneralErrorCodes$1 } from "./error-handling-LPEPQV1V.mjs";
|
|
2
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults } from "axios";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/lib/rest/rest-interceptor.d.ts
|
|
5
|
+
declare class RestInterceptor<T extends any[]> {
|
|
6
|
+
private applyInterceptor;
|
|
7
|
+
private interceptorIdMap;
|
|
8
|
+
constructor(applyInterceptor: (client: AxiosInstance, ...args: T) => number);
|
|
9
|
+
addInterceptor(client: AxiosInstance, ...args: T): void;
|
|
10
|
+
removeInterceptor(client: AxiosInstance): void;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/lib/rest/rest-client.types.d.ts
|
|
14
|
+
type GeneralErrorCodes = string;
|
|
15
|
+
interface RequestInfo<ZOutput, ECodes extends string> {
|
|
16
|
+
resSchema: z.ZodType<ZOutput>;
|
|
17
|
+
errorHandler?: ErrorHandler<ECodes>;
|
|
18
|
+
}
|
|
19
|
+
interface RequestConfig<IsRawRes extends boolean = false> {
|
|
20
|
+
rawResponse?: IsRawRes;
|
|
21
|
+
allowInvalidResponseData?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type Response<ZOutput, IsRawRes extends boolean = false> = IsRawRes extends true ? AxiosResponse<ZOutput> : ZOutput;
|
|
24
|
+
interface RestClient$1 {
|
|
25
|
+
attachInterceptors<T extends any[]>(interceptors?: RestInterceptor<T>[], ...args: T): void;
|
|
26
|
+
attachInterceptor<T extends any[]>(interceptor: RestInterceptor<T>, ...args: T): void;
|
|
27
|
+
ejectInterceptor<T extends any[]>(interceptor: RestInterceptor<T>): void;
|
|
28
|
+
get<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
29
|
+
post<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
30
|
+
patch<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
31
|
+
put<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
32
|
+
delete<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/lib/rest/rest-client.d.ts
|
|
36
|
+
declare class RestClient implements RestClient$1 {
|
|
37
|
+
private readonly client;
|
|
38
|
+
private readonly errorHandler;
|
|
39
|
+
constructor({ config, interceptors, errorHandler }?: {
|
|
40
|
+
config?: CreateAxiosDefaults;
|
|
41
|
+
interceptors?: RestInterceptor<any[]>[];
|
|
42
|
+
errorHandler?: ErrorHandler<any>;
|
|
43
|
+
});
|
|
44
|
+
attachInterceptors<T extends any[]>(interceptors?: RestInterceptor<T>[], ...args: T): void;
|
|
45
|
+
attachInterceptor<T extends any[]>(interceptor: RestInterceptor<T>, ...args: T): void;
|
|
46
|
+
ejectInterceptor<T extends any[]>(interceptor: RestInterceptor<T>): void;
|
|
47
|
+
get<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
48
|
+
post<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
49
|
+
patch<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
50
|
+
put<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
51
|
+
delete<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
|
|
52
|
+
private makeRequest;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { RestClient$1 as a, Response as i, RequestConfig as n, RestInterceptor as o, RequestInfo as r, RestClient as t };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { i as SharedErrorHandler } from "./error-handling-BeydPL7s.mjs";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/lib/rest/rest-client.ts
|
|
5
|
+
var RestClient = class {
|
|
6
|
+
client;
|
|
7
|
+
errorHandler;
|
|
8
|
+
constructor({ config, interceptors, errorHandler } = {}) {
|
|
9
|
+
this.client = axios.create(config);
|
|
10
|
+
this.errorHandler = errorHandler ?? SharedErrorHandler;
|
|
11
|
+
this.attachInterceptors(interceptors);
|
|
12
|
+
}
|
|
13
|
+
attachInterceptors(interceptors, ...args) {
|
|
14
|
+
if (interceptors != null) interceptors.forEach((interceptor) => this.attachInterceptor(interceptor, ...args));
|
|
15
|
+
}
|
|
16
|
+
attachInterceptor(interceptor, ...args) {
|
|
17
|
+
interceptor.addInterceptor(this.client, ...args);
|
|
18
|
+
}
|
|
19
|
+
ejectInterceptor(interceptor) {
|
|
20
|
+
interceptor.removeInterceptor(this.client);
|
|
21
|
+
}
|
|
22
|
+
async get(requestInfo, url, requestConfig) {
|
|
23
|
+
return this.makeRequest(requestInfo, {
|
|
24
|
+
...requestConfig,
|
|
25
|
+
method: "get",
|
|
26
|
+
url
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async post(requestInfo, url, data, requestConfig) {
|
|
30
|
+
return this.makeRequest(requestInfo, {
|
|
31
|
+
...requestConfig,
|
|
32
|
+
method: "post",
|
|
33
|
+
url,
|
|
34
|
+
data
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async patch(requestInfo, url, data, requestConfig) {
|
|
38
|
+
return this.makeRequest(requestInfo, {
|
|
39
|
+
...requestConfig,
|
|
40
|
+
method: "patch",
|
|
41
|
+
url,
|
|
42
|
+
data
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async put(requestInfo, url, data, requestConfig) {
|
|
46
|
+
return this.makeRequest(requestInfo, {
|
|
47
|
+
...requestConfig,
|
|
48
|
+
method: "put",
|
|
49
|
+
url,
|
|
50
|
+
data
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async delete(requestInfo, url, data, requestConfig) {
|
|
54
|
+
return this.makeRequest(requestInfo, {
|
|
55
|
+
...requestConfig,
|
|
56
|
+
method: "delete",
|
|
57
|
+
url,
|
|
58
|
+
data
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async makeRequest(requestInfo, requestConfig) {
|
|
62
|
+
const errorStack = (/* @__PURE__ */ new Error()).stack;
|
|
63
|
+
try {
|
|
64
|
+
const { rawResponse, allowInvalidResponseData, ...config } = requestConfig;
|
|
65
|
+
const res = await this.client(config);
|
|
66
|
+
const responseData = res.status === 204 && res.data === "" ? void 0 : res.data;
|
|
67
|
+
const parseResult = requestInfo.resSchema.safeParse(responseData);
|
|
68
|
+
let resData;
|
|
69
|
+
if (parseResult.success) resData = parseResult.data;
|
|
70
|
+
else if (allowInvalidResponseData && config.method === "get") {
|
|
71
|
+
parseResult.error.name = "BE Response schema mismatch - ZodError";
|
|
72
|
+
parseResult.error.stack = [parseResult.error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
|
|
73
|
+
console.error(parseResult.error);
|
|
74
|
+
resData = res.data;
|
|
75
|
+
} else throw parseResult.error;
|
|
76
|
+
return rawResponse ? {
|
|
77
|
+
...res,
|
|
78
|
+
data: resData
|
|
79
|
+
} : resData;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error instanceof z.ZodError) {
|
|
82
|
+
error.name = "BE Response schema mismatch - ZodError";
|
|
83
|
+
error.stack = [error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
|
|
84
|
+
}
|
|
85
|
+
(requestInfo.errorHandler ?? this.errorHandler).rethrowError(error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/lib/rest/rest-interceptor.ts
|
|
92
|
+
var RestInterceptor = class {
|
|
93
|
+
applyInterceptor;
|
|
94
|
+
interceptorIdMap = [];
|
|
95
|
+
constructor(applyInterceptor) {
|
|
96
|
+
this.applyInterceptor = applyInterceptor;
|
|
97
|
+
}
|
|
98
|
+
addInterceptor(client, ...args) {
|
|
99
|
+
this.removeInterceptor(client);
|
|
100
|
+
const interceptorId = this.applyInterceptor(client, ...args);
|
|
101
|
+
this.interceptorIdMap.push({
|
|
102
|
+
client,
|
|
103
|
+
interceptorId
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
removeInterceptor(client) {
|
|
107
|
+
const interceptorId = this.interceptorIdMap.find((i) => i.client === client)?.interceptorId;
|
|
108
|
+
if (interceptorId != null) {
|
|
109
|
+
client.interceptors.request.eject(interceptorId);
|
|
110
|
+
this.interceptorIdMap = this.interceptorIdMap.filter((i) => i.client !== client);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { RestClient as n, RestInterceptor as t };
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
//#region src/lib/rest/rest-transport.types.d.ts
|
|
3
3
|
type GeneralTransportErrorCode = "DATA_VALIDATION_ERROR" | "NETWORK_ERROR" | "CANCELED_ERROR" | "INTERNAL_ERROR" | "UNKNOWN_ERROR";
|
|
4
4
|
type RestResponseType = "json" | "text" | "blob" | "arrayBuffer";
|
|
5
|
+
type TransportFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
5
6
|
interface UploadProgress {
|
|
6
7
|
loaded: number;
|
|
7
8
|
total: number;
|
|
@@ -34,11 +35,17 @@ interface TransportRequest {
|
|
|
34
35
|
body?: BodyInit | null;
|
|
35
36
|
signal?: AbortSignal;
|
|
36
37
|
credentials?: RequestCredentials;
|
|
38
|
+
retryCount?: number;
|
|
39
|
+
}
|
|
40
|
+
interface TransportErrorContext {
|
|
41
|
+
request: TransportRequest;
|
|
42
|
+
response?: TransportResponse<unknown>;
|
|
43
|
+
retry(request?: TransportRequest): Promise<TransportResponse<unknown>>;
|
|
37
44
|
}
|
|
38
45
|
interface RestTransportInterceptor {
|
|
39
46
|
onRequest?(request: TransportRequest): TransportRequest | Promise<TransportRequest>;
|
|
40
47
|
onResponse?<T>(response: TransportResponse<T>): TransportResponse<T> | Promise<TransportResponse<T>>;
|
|
41
|
-
onError?(error: unknown): unknown | Promise<unknown>;
|
|
48
|
+
onError?(error: unknown, context: TransportErrorContext): unknown | Promise<unknown>;
|
|
42
49
|
}
|
|
43
50
|
type TransportResult<T, IsRawRes extends boolean> = IsRawRes extends true ? TransportResponse<T> : T;
|
|
44
51
|
interface RestTransport {
|
|
@@ -56,4 +63,4 @@ declare class HttpError<T = unknown> extends Error {
|
|
|
56
63
|
constructor(message: string, response: TransportResponse<T>);
|
|
57
64
|
}
|
|
58
65
|
//#endregion
|
|
59
|
-
export { RestTransport as a,
|
|
66
|
+
export { RestTransport as a, TransportFetch as c, TransportResponse as d, TransportResult as f, RestResponseType as i, TransportRequest as l, HttpError as n, RestTransportInterceptor as o, UploadProgress as p, RestRequestInfo as r, TransportErrorContext as s, GeneralTransportErrorCode as t, TransportRequestConfig as u };
|
package/dist/rest.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RestTransport,
|
|
1
|
+
import { a as RestTransport, d as TransportResponse, f as TransportResult, i as RestResponseType, l as TransportRequest, n as HttpError, o as RestTransportInterceptor, p as UploadProgress, r as RestRequestInfo, t as GeneralTransportErrorCode, u as TransportRequestConfig } from "./rest-transport.types-DM5-qyOJ.mjs";
|
|
2
2
|
export { type GeneralTransportErrorCode, HttpError, type RestRequestInfo, type RestResponseType, type RestTransport, type RestTransportInterceptor, type TransportRequest, type TransportRequestConfig, type TransportResponse, type TransportResult, type UploadProgress };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosError, AxiosResponseHeaders } from "axios";
|
|
2
|
+
//#region src/lib/rest/rest.utils.d.ts
|
|
3
|
+
declare namespace RestUtils {
|
|
4
|
+
const extractServerResponseCode: (e: unknown) => string | number | null;
|
|
5
|
+
const doesServerErrorMessageContain: (e: AxiosError, text: string) => boolean;
|
|
6
|
+
const extractServerErrorMessage: (e: unknown) => string | null;
|
|
7
|
+
const extractContentDispositionFilename: (headers: AxiosResponseHeaders) => string | undefined;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RestUtils as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, use, useMemo } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/lib/config/router.context.tsx
|
|
4
|
+
let OpenApiRouter;
|
|
5
|
+
(function(_OpenApiRouter) {
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
_OpenApiRouter.Provider = ({ children, replace }) => {
|
|
8
|
+
const value = useMemo(() => ({ replace }), [replace]);
|
|
9
|
+
return /* @__PURE__ */ jsx(Context, {
|
|
10
|
+
value,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
_OpenApiRouter.useRouter = () => {
|
|
15
|
+
const context = use(Context);
|
|
16
|
+
if (!context) throw new Error("useRouter must be used within an OpenApiRouter.Provider");
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
})(OpenApiRouter || (OpenApiRouter = {}));
|
|
20
|
+
//#endregion
|
|
21
|
+
export { OpenApiRouter as t };
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-
|
|
3
|
-
import { D as getTagFileName,
|
|
2
|
+
import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-D8w0QElH.mjs";
|
|
3
|
+
import { D as getTagFileName, Wn as Profiler, r as getOutputFileName } from "./native-bindings-BTQGSGhU.mjs";
|
|
4
|
+
import { n as runGenerate, r as resolveConfig, t as getOpenApiDoc } from "./generate.runner-D8AYuEFm.mjs";
|
|
4
5
|
import yargs from "yargs";
|
|
5
6
|
import { hideBin } from "yargs/helpers";
|
|
6
7
|
import { styleText } from "node:util";
|
|
@@ -31,7 +32,7 @@ function logBanner(message) {
|
|
|
31
32
|
* Fetch the version from package.json
|
|
32
33
|
*/
|
|
33
34
|
function getVersion() {
|
|
34
|
-
return "3.2.0-rc.
|
|
35
|
+
return "3.2.0-rc.9";
|
|
35
36
|
}
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region src/helpers/yargs.helper.ts
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-LPEPQV1V.mjs";
|
|
2
|
+
import { i as QueryModule, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
|
|
3
|
+
import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
+
//#region src/lib/react-query.types.d.ts
|
|
5
|
+
type Function = (...args: any) => any;
|
|
6
|
+
type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
7
|
+
type IsAny<T> = IfAny<T, true, never>;
|
|
8
|
+
type IsUnknown<T, Y, N = T> = IsAny<T> extends never ? (unknown extends T ? Y : N) : N;
|
|
9
|
+
type AppQueryOptions<TFunction extends Function, TData = Awaited<ReturnType<TFunction>>, TErrorCodes = GeneralErrorCodes> = Omit<UseQueryOptions<Awaited<ReturnType<TFunction>>, ApplicationException<TErrorCodes>, IsUnknown<TData, Awaited<ReturnType<TFunction>>>>, "queryKey" | "queryFn">;
|
|
10
|
+
type AppMutationOptions<TFunction extends Function, TVariables = void, TData = Awaited<ReturnType<TFunction>>, TErrorCodes = GeneralErrorCodes> = Omit<UseMutationOptions<TData, ApplicationException<TErrorCodes>, TVariables>, "mutationKey" | "mutationFn">;
|
|
11
|
+
type AppInfiniteQueryOptions<TFunction extends Function, TData = InfiniteData<Awaited<ReturnType<TFunction>>>, TErrorCodes = GeneralErrorCodes, TQueryKey extends QueryKey = QueryKey, TPageParam = number> = Omit<UseInfiniteQueryOptions<Awaited<ReturnType<TFunction>>, ApplicationException<TErrorCodes>, IsUnknown<TData, InfiniteData<Awaited<ReturnType<TFunction>>>>, TQueryKey, TPageParam>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/lib/react-query/useMutationEffects.d.ts
|
|
14
|
+
interface MutationEffectsOptions<TQueryModule extends QueryModule = QueryModule> {
|
|
15
|
+
invalidateCurrentModule?: boolean;
|
|
16
|
+
crossTabInvalidation?: boolean;
|
|
17
|
+
invalidationMap?: InvalidationMap<TQueryModule>;
|
|
18
|
+
invalidateModules?: QueryModule[];
|
|
19
|
+
invalidateKeys?: QueryKey[];
|
|
20
|
+
preferUpdate?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface UseMutationEffectsProps<TQueryModule extends QueryModule = QueryModule> {
|
|
23
|
+
currentModule: TQueryModule;
|
|
24
|
+
}
|
|
25
|
+
declare function useMutationEffects<TQueryModule extends QueryModule = QueryModule>({ currentModule }: UseMutationEffectsProps<TQueryModule>): {
|
|
26
|
+
runMutationEffects: <TData, TVariables>(data: TData, variables: TVariables, options?: MutationEffectsOptions<TQueryModule>, updateKeys?: QueryKey[]) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AppQueryOptions as a, AppMutationOptions as i, useMutationEffects as n, AppInfiniteQueryOptions as r, MutationEffectsOptions as t };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { t as OpenApiQueryConfig } from "./queryConfig.context-CldQ5YL9.mjs";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
//#region src/lib/react-query/cross-tab-invalidation.ts
|
|
5
|
+
const CROSS_TAB_INVALIDATE_KEY = "__rq_invalidate__";
|
|
6
|
+
const broadcastQueryInvalidation = (queryKeys) => {
|
|
7
|
+
localStorage.setItem(CROSS_TAB_INVALIDATE_KEY, JSON.stringify({
|
|
8
|
+
keys: queryKeys,
|
|
9
|
+
timestamp: Date.now()
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
let isListenerSetUp = false;
|
|
13
|
+
const setupCrossTabListener = (queryClient) => {
|
|
14
|
+
if (isListenerSetUp) return;
|
|
15
|
+
isListenerSetUp = true;
|
|
16
|
+
window.addEventListener("storage", (e) => {
|
|
17
|
+
if (e.key !== CROSS_TAB_INVALIDATE_KEY || !e.newValue) return;
|
|
18
|
+
try {
|
|
19
|
+
const { keys } = JSON.parse(e.newValue);
|
|
20
|
+
for (const queryKey of keys) queryClient.invalidateQueries({ queryKey });
|
|
21
|
+
} catch {}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/lib/react-query/useMutationEffects.ts
|
|
26
|
+
function useMutationEffects({ currentModule }) {
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const config = OpenApiQueryConfig.useConfig();
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!config.crossTabInvalidation) return;
|
|
31
|
+
setupCrossTabListener(queryClient);
|
|
32
|
+
}, [queryClient, config.crossTabInvalidation]);
|
|
33
|
+
return { runMutationEffects: useCallback(async (data, variables, options = {}, updateKeys) => {
|
|
34
|
+
const { invalidateCurrentModule, invalidationMap, invalidateModules, invalidateKeys, preferUpdate } = options;
|
|
35
|
+
const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
|
|
36
|
+
const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
|
|
37
|
+
const isQueryKeyEqual = (keyA, keyB) => keyA.length === keyB.length && keyA.every((item, index) => item === keyB[index]);
|
|
38
|
+
const isQueryKeyPrefix = (queryKey, prefixKey) => prefixKey.length <= queryKey.length && prefixKey.every((item, index) => item === queryKey[index]);
|
|
39
|
+
const mappedInvalidationKeys = invalidationMap?.[currentModule]?.(data, variables) ?? config.invalidationMap?.[currentModule]?.(data, variables);
|
|
40
|
+
const shouldInvalidateQuery = (queryKey) => {
|
|
41
|
+
const isUpdateKey = updateKeys?.some((key) => isQueryKeyEqual(queryKey, key));
|
|
42
|
+
if (shouldUpdate && isUpdateKey) return false;
|
|
43
|
+
const isCurrentModule = shouldInvalidateCurrentModule && queryKey[0] === currentModule;
|
|
44
|
+
const isInvalidateModule = !!invalidateModules && invalidateModules.some((module) => queryKey[0] === module);
|
|
45
|
+
const isInvalidateKey = !!invalidateKeys && invalidateKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
46
|
+
const isMappedKey = !!mappedInvalidationKeys && mappedInvalidationKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
47
|
+
return isCurrentModule || isInvalidateModule || isInvalidateKey || isMappedKey;
|
|
48
|
+
};
|
|
49
|
+
const invalidatedQueryKeys = [];
|
|
50
|
+
const shouldBroadcast = options.crossTabInvalidation ?? config.crossTabInvalidation;
|
|
51
|
+
queryClient.invalidateQueries({ predicate: ({ queryKey }) => {
|
|
52
|
+
const shouldInvalidate = shouldInvalidateQuery(queryKey);
|
|
53
|
+
if (shouldInvalidate && shouldBroadcast) invalidatedQueryKeys.push([...queryKey]);
|
|
54
|
+
return shouldInvalidate;
|
|
55
|
+
} });
|
|
56
|
+
if (shouldBroadcast && invalidatedQueryKeys.length > 0) broadcastQueryInvalidation(invalidatedQueryKeys);
|
|
57
|
+
if (shouldUpdate && updateKeys) updateKeys.map((queryKey) => queryClient.setQueryData(queryKey, data));
|
|
58
|
+
}, [
|
|
59
|
+
queryClient,
|
|
60
|
+
currentModule,
|
|
61
|
+
config.preferUpdate,
|
|
62
|
+
config.invalidateCurrentModule,
|
|
63
|
+
config.invalidationMap,
|
|
64
|
+
config.crossTabInvalidation
|
|
65
|
+
]) };
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { useMutationEffects as t };
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-
|
|
1
|
+
import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-6Yth6QZC.mjs";
|
|
2
2
|
import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-BZ6ZLgRO.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
//#region src/vite/openapi-codegen.plugin.ts
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createContext, use, useMemo } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/lib/config/workspace.context.tsx
|
|
4
|
+
let OpenApiWorkspaceContext;
|
|
5
|
+
(function(_OpenApiWorkspaceContext) {
|
|
6
|
+
const Context = createContext({});
|
|
7
|
+
_OpenApiWorkspaceContext.Provider = ({ values, children }) => {
|
|
8
|
+
const contextValues = useMemo(() => values ?? {}, [values]);
|
|
9
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
10
|
+
value: contextValues,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
_OpenApiWorkspaceContext.useContext = () => {
|
|
15
|
+
return use(Context);
|
|
16
|
+
};
|
|
17
|
+
_OpenApiWorkspaceContext.resolveParam = (context, name, value) => {
|
|
18
|
+
if (value != null) return value;
|
|
19
|
+
const workspaceValue = context[name];
|
|
20
|
+
if (workspaceValue == null) throw new Error(`Missing workspace context param "${name}"`);
|
|
21
|
+
return workspaceValue;
|
|
22
|
+
};
|
|
23
|
+
})(OpenApiWorkspaceContext || (OpenApiWorkspaceContext = {}));
|
|
24
|
+
const useWorkspaceContext = () => OpenApiWorkspaceContext.useContext();
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useWorkspaceContext as n, OpenApiWorkspaceContext as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
//#region src/lib/config/router.context.d.ts
|
|
3
|
+
interface RouterProviderProps {
|
|
4
|
+
replace: (url: string) => void;
|
|
5
|
+
}
|
|
6
|
+
declare namespace OpenApiRouter {
|
|
7
|
+
const Provider: ({ children, replace }: PropsWithChildren<RouterProviderProps>) => import("react").JSX.Element;
|
|
8
|
+
const useRouter: () => RouterProviderProps;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/lib/config/workspace.context.d.ts
|
|
12
|
+
type WorkspaceValues = Record<string, unknown>;
|
|
13
|
+
interface WorkspaceProviderProps {
|
|
14
|
+
values?: WorkspaceValues;
|
|
15
|
+
}
|
|
16
|
+
declare namespace OpenApiWorkspaceContext {
|
|
17
|
+
const Provider: ({ values, children }: PropsWithChildren<WorkspaceProviderProps>) => import("react").JSX.Element;
|
|
18
|
+
const useContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
19
|
+
const resolveParam: <T>(context: WorkspaceValues, name: string, value: T | null | undefined) => T;
|
|
20
|
+
}
|
|
21
|
+
declare const useWorkspaceContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useWorkspaceContext as n, OpenApiRouter as r, OpenApiWorkspaceContext as t };
|
package/dist/zod.d.mts
CHANGED
package/dist/zod.mjs
CHANGED
package/package.json
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"src/assets/**"
|
|
24
24
|
],
|
|
25
25
|
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
26
27
|
"main": "./dist/index.mjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
27
29
|
"types": "./dist/index.d.mts",
|
|
28
30
|
"exports": {
|
|
29
31
|
".": {
|
|
@@ -62,6 +64,26 @@
|
|
|
62
64
|
"./rest": {
|
|
63
65
|
"types": "./dist/rest.d.mts",
|
|
64
66
|
"import": "./dist/rest.mjs"
|
|
67
|
+
},
|
|
68
|
+
"./axios": {
|
|
69
|
+
"types": "./dist/axios.d.mts",
|
|
70
|
+
"import": "./dist/axios.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./errors": {
|
|
73
|
+
"types": "./dist/errors.d.mts",
|
|
74
|
+
"import": "./dist/errors.mjs"
|
|
75
|
+
},
|
|
76
|
+
"./query": {
|
|
77
|
+
"types": "./dist/query.d.mts",
|
|
78
|
+
"import": "./dist/query.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./config": {
|
|
81
|
+
"types": "./dist/config.d.mts",
|
|
82
|
+
"import": "./dist/config.mjs"
|
|
83
|
+
},
|
|
84
|
+
"./auth": {
|
|
85
|
+
"types": "./dist/auth.d.mts",
|
|
86
|
+
"import": "./dist/auth.mjs"
|
|
65
87
|
}
|
|
66
88
|
},
|
|
67
89
|
"scripts": {
|
|
@@ -88,7 +110,8 @@
|
|
|
88
110
|
"dev:generate": "rm -rf ./output && bun run start generate --config ./test/config.mjs",
|
|
89
111
|
"dev:check": "bun run start check --config ./test/config.mjs",
|
|
90
112
|
"snapshot:openapi-localhost": "bun ./scripts/snapshot-openapi-localhost.mjs",
|
|
91
|
-
"bench:vite-codegen": "bun ./scripts/benchmark-vite-codegen.mjs"
|
|
113
|
+
"bench:vite-codegen": "bun ./scripts/benchmark-vite-codegen.mjs",
|
|
114
|
+
"verify:tree-shaking": "bun run build:ts && bun ./scripts/verify-tree-shaking.mjs"
|
|
92
115
|
},
|
|
93
116
|
"dependencies": {
|
|
94
117
|
"@orpc/contract": "^1.14.3",
|
|
@@ -110,6 +133,8 @@
|
|
|
110
133
|
"@types/react": "^19.2.14",
|
|
111
134
|
"@types/yargs": "^17.0.35",
|
|
112
135
|
"@vitejs/plugin-react": "^5.1.4",
|
|
136
|
+
"axios": "^1.13.1",
|
|
137
|
+
"i18next": "^25.8.11",
|
|
113
138
|
"oxfmt": "^0.34.0",
|
|
114
139
|
"oxlint": "1.50.0",
|
|
115
140
|
"oxlint-tsgolint": "^0.15.0",
|
|
@@ -140,6 +165,18 @@
|
|
|
140
165
|
"@casl/react": {
|
|
141
166
|
"optional": true
|
|
142
167
|
},
|
|
168
|
+
"@tanstack/react-query": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"axios": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"i18next": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"react": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
143
180
|
"vite": {
|
|
144
181
|
"optional": true
|
|
145
182
|
}
|
|
@@ -149,5 +186,5 @@
|
|
|
149
186
|
"node": ">= 18"
|
|
150
187
|
},
|
|
151
188
|
"packageManager": "bun@1.3.14",
|
|
152
|
-
"version": "3.2.0-rc.
|
|
189
|
+
"version": "3.2.0-rc.9"
|
|
153
190
|
}
|