@povio/openapi-codegen-cli 3.2.0-rc.8 → 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 +8 -159
- package/dist/index.mjs +9 -256
- 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/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.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/index.mjs
CHANGED
|
@@ -1,259 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as resources, n as ns, t as configureTranslations } from "./i18n-D-FesqFb.mjs";
|
|
2
|
+
import { a as RestUtils, i as SharedErrorHandler, n as DomainErrorRegistry, r as ErrorHandler, t as ApplicationException } from "./error-handling-BeydPL7s.mjs";
|
|
2
3
|
import { t as HttpError } from "./rest-transport.types-DxitRtsB.mjs";
|
|
4
|
+
import { n as RestClient, t as RestInterceptor } from "./rest-interceptor-D5NCNTm1.mjs";
|
|
3
5
|
import { n as NativeRestClient, t as NativeRestInterceptor } from "./native-rest-interceptor-CAWR8H5Y.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
//#region src/lib/rest/rest-client.ts
|
|
11
|
-
var RestClient = class {
|
|
12
|
-
client;
|
|
13
|
-
errorHandler;
|
|
14
|
-
constructor({ config, interceptors, errorHandler } = {}) {
|
|
15
|
-
this.client = axios.create(config);
|
|
16
|
-
this.errorHandler = errorHandler ?? SharedErrorHandler;
|
|
17
|
-
this.attachInterceptors(interceptors);
|
|
18
|
-
}
|
|
19
|
-
attachInterceptors(interceptors, ...args) {
|
|
20
|
-
if (interceptors != null) interceptors.forEach((interceptor) => this.attachInterceptor(interceptor, ...args));
|
|
21
|
-
}
|
|
22
|
-
attachInterceptor(interceptor, ...args) {
|
|
23
|
-
interceptor.addInterceptor(this.client, ...args);
|
|
24
|
-
}
|
|
25
|
-
ejectInterceptor(interceptor) {
|
|
26
|
-
interceptor.removeInterceptor(this.client);
|
|
27
|
-
}
|
|
28
|
-
async get(requestInfo, url, requestConfig) {
|
|
29
|
-
return this.makeRequest(requestInfo, {
|
|
30
|
-
...requestConfig,
|
|
31
|
-
method: "get",
|
|
32
|
-
url
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
async post(requestInfo, url, data, requestConfig) {
|
|
36
|
-
return this.makeRequest(requestInfo, {
|
|
37
|
-
...requestConfig,
|
|
38
|
-
method: "post",
|
|
39
|
-
url,
|
|
40
|
-
data
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async patch(requestInfo, url, data, requestConfig) {
|
|
44
|
-
return this.makeRequest(requestInfo, {
|
|
45
|
-
...requestConfig,
|
|
46
|
-
method: "patch",
|
|
47
|
-
url,
|
|
48
|
-
data
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async put(requestInfo, url, data, requestConfig) {
|
|
52
|
-
return this.makeRequest(requestInfo, {
|
|
53
|
-
...requestConfig,
|
|
54
|
-
method: "put",
|
|
55
|
-
url,
|
|
56
|
-
data
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async delete(requestInfo, url, data, requestConfig) {
|
|
60
|
-
return this.makeRequest(requestInfo, {
|
|
61
|
-
...requestConfig,
|
|
62
|
-
method: "delete",
|
|
63
|
-
url,
|
|
64
|
-
data
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
async makeRequest(requestInfo, requestConfig) {
|
|
68
|
-
const errorStack = (/* @__PURE__ */ new Error()).stack;
|
|
69
|
-
try {
|
|
70
|
-
const { rawResponse, allowInvalidResponseData, ...config } = requestConfig;
|
|
71
|
-
const res = await this.client(config);
|
|
72
|
-
const responseData = res.status === 204 && res.data === "" ? void 0 : res.data;
|
|
73
|
-
const parseResult = requestInfo.resSchema.safeParse(responseData);
|
|
74
|
-
let resData;
|
|
75
|
-
if (parseResult.success) resData = parseResult.data;
|
|
76
|
-
else if (allowInvalidResponseData && config.method === "get") {
|
|
77
|
-
parseResult.error.name = "BE Response schema mismatch - ZodError";
|
|
78
|
-
parseResult.error.stack = [parseResult.error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
|
|
79
|
-
console.error(parseResult.error);
|
|
80
|
-
resData = res.data;
|
|
81
|
-
} else throw parseResult.error;
|
|
82
|
-
return rawResponse ? {
|
|
83
|
-
...res,
|
|
84
|
-
data: resData
|
|
85
|
-
} : resData;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (error instanceof z.ZodError) {
|
|
88
|
-
error.name = "BE Response schema mismatch - ZodError";
|
|
89
|
-
error.stack = [error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
|
|
90
|
-
}
|
|
91
|
-
(requestInfo.errorHandler ?? this.errorHandler).rethrowError(error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/lib/rest/rest-interceptor.ts
|
|
98
|
-
var RestInterceptor = class {
|
|
99
|
-
applyInterceptor;
|
|
100
|
-
interceptorIdMap = [];
|
|
101
|
-
constructor(applyInterceptor) {
|
|
102
|
-
this.applyInterceptor = applyInterceptor;
|
|
103
|
-
}
|
|
104
|
-
addInterceptor(client, ...args) {
|
|
105
|
-
this.removeInterceptor(client);
|
|
106
|
-
const interceptorId = this.applyInterceptor(client, ...args);
|
|
107
|
-
this.interceptorIdMap.push({
|
|
108
|
-
client,
|
|
109
|
-
interceptorId
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
removeInterceptor(client) {
|
|
113
|
-
const interceptorId = this.interceptorIdMap.find((i) => i.client === client)?.interceptorId;
|
|
114
|
-
if (interceptorId != null) {
|
|
115
|
-
client.interceptors.request.eject(interceptorId);
|
|
116
|
-
this.interceptorIdMap = this.interceptorIdMap.filter((i) => i.client !== client);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/lib/config/queryConfig.context.tsx
|
|
122
|
-
let OpenApiQueryConfig;
|
|
123
|
-
(function(_OpenApiQueryConfig) {
|
|
124
|
-
const Context = createContext({});
|
|
125
|
-
function Provider({ preferUpdate, invalidateCurrentModule, invalidationMap, crossTabInvalidation, allowInvalidResponseData, onError, children }) {
|
|
126
|
-
const value = useMemo(() => ({
|
|
127
|
-
preferUpdate,
|
|
128
|
-
invalidateCurrentModule,
|
|
129
|
-
invalidationMap,
|
|
130
|
-
crossTabInvalidation,
|
|
131
|
-
allowInvalidResponseData,
|
|
132
|
-
onError
|
|
133
|
-
}), [
|
|
134
|
-
preferUpdate,
|
|
135
|
-
invalidateCurrentModule,
|
|
136
|
-
invalidationMap,
|
|
137
|
-
crossTabInvalidation,
|
|
138
|
-
allowInvalidResponseData,
|
|
139
|
-
onError
|
|
140
|
-
]);
|
|
141
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
142
|
-
value,
|
|
143
|
-
children
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
_OpenApiQueryConfig.Provider = Provider;
|
|
147
|
-
_OpenApiQueryConfig.useConfig = () => {
|
|
148
|
-
return use(Context) ?? {};
|
|
149
|
-
};
|
|
150
|
-
})(OpenApiQueryConfig || (OpenApiQueryConfig = {}));
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/lib/react-query/cross-tab-invalidation.ts
|
|
153
|
-
const CROSS_TAB_INVALIDATE_KEY = "__rq_invalidate__";
|
|
154
|
-
const broadcastQueryInvalidation = (queryKeys) => {
|
|
155
|
-
localStorage.setItem(CROSS_TAB_INVALIDATE_KEY, JSON.stringify({
|
|
156
|
-
keys: queryKeys,
|
|
157
|
-
timestamp: Date.now()
|
|
158
|
-
}));
|
|
159
|
-
};
|
|
160
|
-
let isListenerSetUp = false;
|
|
161
|
-
const setupCrossTabListener = (queryClient) => {
|
|
162
|
-
if (isListenerSetUp) return;
|
|
163
|
-
isListenerSetUp = true;
|
|
164
|
-
window.addEventListener("storage", (e) => {
|
|
165
|
-
if (e.key !== CROSS_TAB_INVALIDATE_KEY || !e.newValue) return;
|
|
166
|
-
try {
|
|
167
|
-
const { keys } = JSON.parse(e.newValue);
|
|
168
|
-
for (const queryKey of keys) queryClient.invalidateQueries({ queryKey });
|
|
169
|
-
} catch {}
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/lib/react-query/useMutationEffects.ts
|
|
174
|
-
function useMutationEffects({ currentModule }) {
|
|
175
|
-
const queryClient = useQueryClient();
|
|
176
|
-
const config = OpenApiQueryConfig.useConfig();
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (!config.crossTabInvalidation) return;
|
|
179
|
-
setupCrossTabListener(queryClient);
|
|
180
|
-
}, [queryClient, config.crossTabInvalidation]);
|
|
181
|
-
return { runMutationEffects: useCallback(async (data, variables, options = {}, updateKeys) => {
|
|
182
|
-
const { invalidateCurrentModule, invalidationMap, invalidateModules, invalidateKeys, preferUpdate } = options;
|
|
183
|
-
const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
|
|
184
|
-
const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
|
|
185
|
-
const isQueryKeyEqual = (keyA, keyB) => keyA.length === keyB.length && keyA.every((item, index) => item === keyB[index]);
|
|
186
|
-
const isQueryKeyPrefix = (queryKey, prefixKey) => prefixKey.length <= queryKey.length && prefixKey.every((item, index) => item === queryKey[index]);
|
|
187
|
-
const mappedInvalidationKeys = invalidationMap?.[currentModule]?.(data, variables) ?? config.invalidationMap?.[currentModule]?.(data, variables);
|
|
188
|
-
const shouldInvalidateQuery = (queryKey) => {
|
|
189
|
-
const isUpdateKey = updateKeys?.some((key) => isQueryKeyEqual(queryKey, key));
|
|
190
|
-
if (shouldUpdate && isUpdateKey) return false;
|
|
191
|
-
const isCurrentModule = shouldInvalidateCurrentModule && queryKey[0] === currentModule;
|
|
192
|
-
const isInvalidateModule = !!invalidateModules && invalidateModules.some((module) => queryKey[0] === module);
|
|
193
|
-
const isInvalidateKey = !!invalidateKeys && invalidateKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
194
|
-
const isMappedKey = !!mappedInvalidationKeys && mappedInvalidationKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
195
|
-
return isCurrentModule || isInvalidateModule || isInvalidateKey || isMappedKey;
|
|
196
|
-
};
|
|
197
|
-
const invalidatedQueryKeys = [];
|
|
198
|
-
const shouldBroadcast = options.crossTabInvalidation ?? config.crossTabInvalidation;
|
|
199
|
-
queryClient.invalidateQueries({ predicate: ({ queryKey }) => {
|
|
200
|
-
const shouldInvalidate = shouldInvalidateQuery(queryKey);
|
|
201
|
-
if (shouldInvalidate && shouldBroadcast) invalidatedQueryKeys.push([...queryKey]);
|
|
202
|
-
return shouldInvalidate;
|
|
203
|
-
} });
|
|
204
|
-
if (shouldBroadcast && invalidatedQueryKeys.length > 0) broadcastQueryInvalidation(invalidatedQueryKeys);
|
|
205
|
-
if (shouldUpdate && updateKeys) updateKeys.map((queryKey) => queryClient.setQueryData(queryKey, data));
|
|
206
|
-
}, [
|
|
207
|
-
queryClient,
|
|
208
|
-
currentModule,
|
|
209
|
-
config.preferUpdate,
|
|
210
|
-
config.invalidateCurrentModule,
|
|
211
|
-
config.invalidationMap,
|
|
212
|
-
config.crossTabInvalidation
|
|
213
|
-
]) };
|
|
214
|
-
}
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region src/lib/config/workspace.context.tsx
|
|
217
|
-
let OpenApiWorkspaceContext;
|
|
218
|
-
(function(_OpenApiWorkspaceContext) {
|
|
219
|
-
const Context = createContext({});
|
|
220
|
-
_OpenApiWorkspaceContext.Provider = ({ values, children }) => {
|
|
221
|
-
const contextValues = useMemo(() => values ?? {}, [values]);
|
|
222
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
223
|
-
value: contextValues,
|
|
224
|
-
children
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
_OpenApiWorkspaceContext.useContext = () => {
|
|
228
|
-
return use(Context);
|
|
229
|
-
};
|
|
230
|
-
_OpenApiWorkspaceContext.resolveParam = (context, name, value) => {
|
|
231
|
-
if (value != null) return value;
|
|
232
|
-
const workspaceValue = context[name];
|
|
233
|
-
if (workspaceValue == null) throw new Error(`Missing workspace context param "${name}"`);
|
|
234
|
-
return workspaceValue;
|
|
235
|
-
};
|
|
236
|
-
})(OpenApiWorkspaceContext || (OpenApiWorkspaceContext = {}));
|
|
237
|
-
const useWorkspaceContext = () => OpenApiWorkspaceContext.useContext();
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/lib/auth/AuthGuard.tsx
|
|
240
|
-
const AuthGuard = ({ type, redirectTo, children }) => {
|
|
241
|
-
const { isAuthenticated, routes, loadingState } = AuthContext.useAuth();
|
|
242
|
-
const { replace } = OpenApiRouter.useRouter();
|
|
243
|
-
const [hasMounted, setHasMounted] = useState(false);
|
|
244
|
-
useEffect(() => {
|
|
245
|
-
setHasMounted(true);
|
|
246
|
-
}, []);
|
|
247
|
-
if (!hasMounted) return loadingState;
|
|
248
|
-
if (type === "private" && !isAuthenticated) {
|
|
249
|
-
replace(redirectTo || routes?.unauthenticated || "/");
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
if (type === "public-only" && isAuthenticated) {
|
|
253
|
-
replace(redirectTo || routes?.authenticated || "/");
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
return children;
|
|
257
|
-
};
|
|
258
|
-
//#endregion
|
|
6
|
+
import { t as OpenApiQueryConfig } from "./queryConfig.context-CldQ5YL9.mjs";
|
|
7
|
+
import { t as useMutationEffects } from "./useMutationEffects-PB1fvKWM.mjs";
|
|
8
|
+
import { t as OpenApiRouter } from "./router.context-EPlMBk3G.mjs";
|
|
9
|
+
import { n as useWorkspaceContext, t as OpenApiWorkspaceContext } from "./workspace.context-XWvQ_7Hg.mjs";
|
|
10
|
+
import { t as AuthContext } from "./auth.context-COWO6ssl.mjs";
|
|
11
|
+
import { t as AuthGuard } from "./AuthGuard-qpAtHaBz.mjs";
|
|
259
12
|
export { ApplicationException, AuthContext, AuthGuard, DomainErrorRegistry, ErrorHandler, HttpError as NativeHttpError, NativeRestClient, NativeRestInterceptor, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };
|
package/dist/metro.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generate_utils = require("./generate.utils-
|
|
2
|
+
const require_generate_utils = require("./generate.utils-CT-LA-gX.cjs");
|
|
3
3
|
let fs = require("fs");
|
|
4
4
|
fs = require_generate_utils.__toESM(fs, 1);
|
|
5
5
|
let path = require("path");
|
|
@@ -97,7 +97,7 @@ async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler =
|
|
|
97
97
|
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
98
98
|
if (nativeFiles) return nativeFiles;
|
|
99
99
|
}
|
|
100
|
-
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-
|
|
100
|
+
const { generateCodeFromOpenAPIDoc } = await Promise.resolve().then(() => require("./generateCodeFromOpenAPIDoc-iEa8YAUQ.cjs"));
|
|
101
101
|
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
102
102
|
source: nativeInput.source,
|
|
103
103
|
yaml: nativeInput.yaml
|
package/dist/metro.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 fs from "fs";
|
|
4
4
|
import path from "path";
|
|
@@ -369,6 +369,8 @@ const getNamespaceName = ({ type, tag, options }) => `${capitalize(tag)}${option
|
|
|
369
369
|
const PACKAGE_IMPORT_PATH = "@povio/openapi-codegen-cli";
|
|
370
370
|
const NATIVE_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/native`;
|
|
371
371
|
const REST_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/rest`;
|
|
372
|
+
const QUERY_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/query`;
|
|
373
|
+
const CONFIG_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/config`;
|
|
372
374
|
//#endregion
|
|
373
375
|
//#region src/generators/const/deps.const.ts
|
|
374
376
|
const APP_REST_CLIENT_NAME = "AppRestClient";
|
|
@@ -449,31 +451,6 @@ const hasMatchingPath = (endpoint, readAllEndpoint) => readAllEndpoint.pathSegme
|
|
|
449
451
|
const hasMatchingPathWithoutTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length === readAllEndpoint.pathSegments.length && hasMatchingPath(endpoint, readAllEndpoint);
|
|
450
452
|
const hasMatchingPathWithTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length - 1 === readAllEndpoint.pathSegments.length && isPathSegmentParam(endpoint.pathSegments.at(-1)) && hasMatchingPath(endpoint, readAllEndpoint);
|
|
451
453
|
//#endregion
|
|
452
|
-
//#region src/generators/const/acl.const.ts
|
|
453
|
-
const ACL_APP_ABILITY_FILE = {
|
|
454
|
-
fileName: "acl/app.ability",
|
|
455
|
-
extension: "ts"
|
|
456
|
-
};
|
|
457
|
-
const ACL_APP_ABILITIES = "AppAbilities";
|
|
458
|
-
const ACL_CHECK_HOOK = "useAclCheck";
|
|
459
|
-
const CASL_ABILITY_BINDING = {
|
|
460
|
-
abilityTuple: "AbilityTuple",
|
|
461
|
-
pureAbility: "PureAbility",
|
|
462
|
-
forcedSubject: "ForcedSubject",
|
|
463
|
-
subjectType: "Subject",
|
|
464
|
-
subject: "subject"
|
|
465
|
-
};
|
|
466
|
-
const CASL_ABILITY_IMPORT = {
|
|
467
|
-
bindings: [
|
|
468
|
-
CASL_ABILITY_BINDING.abilityTuple,
|
|
469
|
-
CASL_ABILITY_BINDING.pureAbility,
|
|
470
|
-
CASL_ABILITY_BINDING.forcedSubject,
|
|
471
|
-
CASL_ABILITY_BINDING.subjectType,
|
|
472
|
-
CASL_ABILITY_BINDING.subject
|
|
473
|
-
],
|
|
474
|
-
from: "@casl/ability"
|
|
475
|
-
};
|
|
476
|
-
//#endregion
|
|
477
454
|
//#region src/generators/const/options.const.ts
|
|
478
455
|
const DEFAULT_GENERATE_OPTIONS = {
|
|
479
456
|
input: "http://localhost:4000/docs-json/",
|
|
@@ -530,8 +507,8 @@ const DEFAULT_GENERATE_OPTIONS = {
|
|
|
530
507
|
parseRequestParams: true,
|
|
531
508
|
inlineEndpoints: false,
|
|
532
509
|
inlineEndpointsExcludeModules: [],
|
|
533
|
-
queryTypesImportPath:
|
|
534
|
-
mutationEffectsImportPath:
|
|
510
|
+
queryTypesImportPath: QUERY_PACKAGE_IMPORT_PATH,
|
|
511
|
+
mutationEffectsImportPath: QUERY_PACKAGE_IMPORT_PATH,
|
|
535
512
|
axiosRequestConfig: false,
|
|
536
513
|
mutationEffects: true,
|
|
537
514
|
mutationDefaultOnError: false,
|
|
@@ -1460,20 +1437,6 @@ function removeEmptyDirectories(root) {
|
|
|
1460
1437
|
removeIfEmpty(root);
|
|
1461
1438
|
}
|
|
1462
1439
|
//#endregion
|
|
1463
|
-
//#region src/generators/core/resolveConfig.ts
|
|
1464
|
-
function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, inlineEndpointsExcludeModules, workspaceContext, ...options } }) {
|
|
1465
|
-
const resolvedConfig = deepMerge(DEFAULT_GENERATE_OPTIONS, fileConfig ?? {}, {
|
|
1466
|
-
...options,
|
|
1467
|
-
includeTags: includeTags?.split(","),
|
|
1468
|
-
excludeTags: excludeTags?.split(","),
|
|
1469
|
-
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(","),
|
|
1470
|
-
workspaceContext: workspaceContext?.split(",")
|
|
1471
|
-
});
|
|
1472
|
-
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
1473
|
-
resolvedConfig.workspaceContext = Array.from(new Set((resolvedConfig.workspaceContext ?? []).map((value) => value.trim()).filter(Boolean)));
|
|
1474
|
-
return resolvedConfig;
|
|
1475
|
-
}
|
|
1476
|
-
//#endregion
|
|
1477
1440
|
//#region src/native/native-bindings.ts
|
|
1478
1441
|
let bindings;
|
|
1479
1442
|
let nativePath;
|
|
@@ -1514,170 +1477,4 @@ function compileNativeData(source, yaml, optionsJson) {
|
|
|
1514
1477
|
return getNativeBindings().compileData(source, yaml, optionsJson);
|
|
1515
1478
|
}
|
|
1516
1479
|
//#endregion
|
|
1517
|
-
|
|
1518
|
-
function generateFilesFromNativeOpenAPI(source, yaml, options) {
|
|
1519
|
-
if (!supportsCompleteNativeRender(options)) {
|
|
1520
|
-
if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
|
|
1521
|
-
return;
|
|
1522
|
-
}
|
|
1523
|
-
const nativeData = compileNativeData(source, yaml, JSON.stringify({
|
|
1524
|
-
...options,
|
|
1525
|
-
nativeCompact: true
|
|
1526
|
-
})).data;
|
|
1527
|
-
if (!nativeData.renderedComplete) {
|
|
1528
|
-
if (process.env.OPENAPI_CODEGEN_REQUIRE_FULL_NATIVE === "1") throw new Error("The selected options are not supported by the full native renderer");
|
|
1529
|
-
return;
|
|
1530
|
-
}
|
|
1531
|
-
const files = [];
|
|
1532
|
-
const taggedRenderers = options.modelsOnly ? [["models", nativeData.renderedModels]] : [
|
|
1533
|
-
["models", nativeData.renderedModels],
|
|
1534
|
-
["endpoints", nativeData.renderedEndpoints],
|
|
1535
|
-
["queries", nativeData.renderedQueries],
|
|
1536
|
-
...options.acl ? [["acl", nativeData.renderedAcl]] : []
|
|
1537
|
-
];
|
|
1538
|
-
for (const tag of nativeData.renderedTags) for (const [type, rendered] of taggedRenderers) {
|
|
1539
|
-
const content = rendered[tag];
|
|
1540
|
-
if (content) files.push(taggedFile(options, tag, type, content));
|
|
1541
|
-
}
|
|
1542
|
-
if (!options.modelsOnly) {
|
|
1543
|
-
if (options.acl && nativeData.renderedShared.appAcl) files.push(outputFile(options, "acl/app.ability.ts", nativeData.renderedShared.appAcl));
|
|
1544
|
-
if (options.mutationEffects && nativeData.renderedShared.queryModules) files.push(outputFile(options, "queryModules.ts", nativeData.renderedShared.queryModules));
|
|
1545
|
-
if (!options.restClientImportPath) files.push(outputFile(options, "app-rest-client.ts", `import { ${options.restClient === "native" ? "NativeRestClient" : "RestClient"} } from "@povio/openapi-codegen-cli${options.restClient === "native" ? "/native" : ""}";\n\nexport const AppRestClient = new ${options.restClient === "native" ? "NativeRestClient" : "RestClient"}({\n config: {\n baseURL: "${nativeData.baseUrl}"\n },\n});\n`));
|
|
1546
|
-
if (nativeData.renderedShared.domainErrors) files.push(outputFile(options, "domain-errors.ts", nativeData.renderedShared.domainErrors));
|
|
1547
|
-
}
|
|
1548
|
-
return files;
|
|
1549
|
-
}
|
|
1550
|
-
function supportsCompleteNativeRender(options) {
|
|
1551
|
-
return options.splitByTags && (options.modelsInCommon && options.tsNamespaces || !options.modelsInCommon && !options.tsNamespaces) && !options.inlineEndpoints && !options.builderConfigs && (options.workspaceContext?.length ?? 0) === 0;
|
|
1552
|
-
}
|
|
1553
|
-
function taggedFile(options, tag, type, content) {
|
|
1554
|
-
return outputFile(options, getTagFileName({
|
|
1555
|
-
tag,
|
|
1556
|
-
type,
|
|
1557
|
-
options
|
|
1558
|
-
}), content);
|
|
1559
|
-
}
|
|
1560
|
-
function outputFile(options, fileName, content) {
|
|
1561
|
-
return {
|
|
1562
|
-
fileName: getOutputFileName({
|
|
1563
|
-
output: options.output,
|
|
1564
|
-
fileName
|
|
1565
|
-
}),
|
|
1566
|
-
content
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
|
-
//#endregion
|
|
1570
|
-
//#region src/generators/run/generate.runner.ts
|
|
1571
|
-
async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
|
|
1572
|
-
const config = profiler.runSync("config.resolve", () => resolveConfig({
|
|
1573
|
-
fileConfig,
|
|
1574
|
-
params: params ?? {}
|
|
1575
|
-
}));
|
|
1576
|
-
const useNative = shouldUseNativeCodegen();
|
|
1577
|
-
const isJson = path.extname(new URL(config.input, "file://").pathname).toLowerCase() === ".json";
|
|
1578
|
-
const useRawNativeInput = useNative && (isJson || typeof Bun === "undefined");
|
|
1579
|
-
let nativeInput = useRawNativeInput ? await getRawOpenApiSource(config.input, profiler) : await getOpenApiSource(config.input, profiler);
|
|
1580
|
-
if (useNative && !useRawNativeInput) {
|
|
1581
|
-
const document = "document" in nativeInput ? nativeInput.document : void 0;
|
|
1582
|
-
nativeInput = {
|
|
1583
|
-
...nativeInput,
|
|
1584
|
-
source: profiler.runSync("openapi.serialize", () => JSON.stringify(document)),
|
|
1585
|
-
yaml: false
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
const openApiDoc = "document" in nativeInput ? nativeInput.document : {};
|
|
1589
|
-
const outputExists = fs.existsSync(config.output);
|
|
1590
|
-
const filesData = await profiler.runAsync("generate.total", async () => {
|
|
1591
|
-
if (useNative) {
|
|
1592
|
-
const nativeFiles = generateFilesFromNativeOpenAPI(nativeInput.source, nativeInput.yaml, config);
|
|
1593
|
-
if (nativeFiles) return nativeFiles;
|
|
1594
|
-
}
|
|
1595
|
-
const { generateCodeFromOpenAPIDoc } = await import("./generateCodeFromOpenAPIDoc-glAKBEGP.mjs").then((n) => n.n);
|
|
1596
|
-
return generateCodeFromOpenAPIDoc(openApiDoc, config, profiler, {
|
|
1597
|
-
source: nativeInput.source,
|
|
1598
|
-
yaml: nativeInput.yaml
|
|
1599
|
-
});
|
|
1600
|
-
});
|
|
1601
|
-
if (config.clearOutput) profiler.runSync("files.removeStaleGenerated", () => {
|
|
1602
|
-
removeStaleGeneratedFiles({
|
|
1603
|
-
output: config.output,
|
|
1604
|
-
filesData,
|
|
1605
|
-
options: config
|
|
1606
|
-
});
|
|
1607
|
-
});
|
|
1608
|
-
await profiler.runAsync("files.write", async () => {
|
|
1609
|
-
await writeGenerateFileData(filesData, {
|
|
1610
|
-
formatGeneratedFile,
|
|
1611
|
-
skipExistingCheck: !outputExists
|
|
1612
|
-
});
|
|
1613
|
-
});
|
|
1614
|
-
return {
|
|
1615
|
-
skipped: false,
|
|
1616
|
-
config,
|
|
1617
|
-
stats: getGenerateStats(filesData, config)
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
async function getOpenApiDoc(input, profiler = new Profiler(false)) {
|
|
1621
|
-
return (await getOpenApiSource(input, profiler)).document;
|
|
1622
|
-
}
|
|
1623
|
-
async function getOpenApiSource(input, profiler = new Profiler(false)) {
|
|
1624
|
-
const raw = await getRawOpenApiSource(input, profiler);
|
|
1625
|
-
const { source } = raw;
|
|
1626
|
-
const document = await profiler.runAsync("openapi.parse", () => parseOpenApiSource(input, source));
|
|
1627
|
-
return {
|
|
1628
|
-
...raw,
|
|
1629
|
-
document
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
async function getRawOpenApiSource(input, profiler = new Profiler(false)) {
|
|
1633
|
-
return {
|
|
1634
|
-
source: await profiler.runAsync("openapi.read", () => readOpenApiSource(input)),
|
|
1635
|
-
yaml: path.extname(new URL(input, "file://").pathname).toLowerCase() !== ".json"
|
|
1636
|
-
};
|
|
1637
|
-
}
|
|
1638
|
-
async function readOpenApiSource(input) {
|
|
1639
|
-
if (/^https?:\/\//i.test(input)) {
|
|
1640
|
-
const response = await fetch(input);
|
|
1641
|
-
if (!response.ok) throw new Error(`Unable to load OpenAPI document: ${response.status} ${response.statusText}`);
|
|
1642
|
-
return response.text();
|
|
1643
|
-
}
|
|
1644
|
-
return fs.promises.readFile(input, "utf-8");
|
|
1645
|
-
}
|
|
1646
|
-
async function parseOpenApiSource(input, source) {
|
|
1647
|
-
try {
|
|
1648
|
-
return JSON.parse(source.charCodeAt(0) === 65279 ? source.slice(1) : source);
|
|
1649
|
-
} catch (error) {
|
|
1650
|
-
if (path.extname(new URL(input, "file://").pathname).toLowerCase() === ".json") throw error;
|
|
1651
|
-
if (typeof Bun !== "undefined") return Bun.YAML.parse(source);
|
|
1652
|
-
const { parse } = await import("yaml");
|
|
1653
|
-
return parse(source);
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
function getGenerateStats(filesData, config) {
|
|
1657
|
-
const generatedFilesCount = filesData.length;
|
|
1658
|
-
if (generatedFilesCount === 0) return {
|
|
1659
|
-
generatedFilesCount,
|
|
1660
|
-
generatedModulesCount: 0
|
|
1661
|
-
};
|
|
1662
|
-
if (!config.splitByTags) return {
|
|
1663
|
-
generatedFilesCount,
|
|
1664
|
-
generatedModulesCount: 1
|
|
1665
|
-
};
|
|
1666
|
-
const moduleSuffixes = new Set(Object.values(config.configs).map((generateConfig) => generateConfig.outputFileNameSuffix).filter(Boolean));
|
|
1667
|
-
const modules = /* @__PURE__ */ new Set();
|
|
1668
|
-
for (const file of filesData) {
|
|
1669
|
-
const segments = path.relative(config.output, file.fileName).split(path.sep).filter(Boolean);
|
|
1670
|
-
if (segments.length < 2) continue;
|
|
1671
|
-
const moduleName = segments[0];
|
|
1672
|
-
const fileName = segments[segments.length - 1];
|
|
1673
|
-
if (!fileName.startsWith(`${moduleName}.`)) continue;
|
|
1674
|
-
const suffix = fileName.slice(moduleName.length + 1).replace(/\.tsx?$/, "");
|
|
1675
|
-
if (moduleSuffixes.has(suffix)) modules.add(moduleName);
|
|
1676
|
-
}
|
|
1677
|
-
return {
|
|
1678
|
-
generatedFilesCount,
|
|
1679
|
-
generatedModulesCount: modules.size
|
|
1680
|
-
};
|
|
1681
|
-
}
|
|
1682
|
-
//#endregion
|
|
1683
|
-
export { getImportedAbilityFunctionName as $, isMainResponseStatus as $t, getEndpointsImports as A, AXIOS_REQUEST_CONFIG_NAME as An, getZodSchemaName as At, getPrefetchInfiniteQueryName as B, shouldInlineEndpointsForTag as Bn, QUERY_MODULE_ENUM as Bt, getAppRestClientImportPath as C, STRING_SCHEMA as Cn, isReadEndpoint as Ct, getTagFileName as D, ZOD_IMPORT as Dn, getEnumZodSchemaName as Dt, getQueryTypesImportPath as E, VOID_SCHEMA as En, getBodyZodSchemaName as Et, mergeImports as F, getRequestConfigTypeName as Fn, APP_REST_CLIENT_NAME as Ft, getAbilityConditionType as G, kebabToCamel as Gn, REST_PACKAGE_IMPORT_PATH as Gt, getQueryName as H, capitalize as Hn, ZOD_EXTENDED as Ht, getImportedInfiniteQueryName as I, formatTag as In, BUILDERS_UTILS as It, getAbilityFunctionName as J, Profiler as Jn, escapeControlCharacters as Jt, getAbilityConditionsTypes as K, removeWord as Kn, getNamespaceName as Kt, getImportedQueryName as L, getEndpointTag as Ln, DOMAIN_ERRORS_FILE as Lt, getInfiniteQueriesImports as M, BODY_PARAMETER_NAME as Mn, isEnumZodSchema as Mt, getModelsImports as N, JSON_APPLICATION_FORMAT as Nn, isNamedZodSchema as Nt, getTagImportPath as O, AXIOS_DEFAULT_IMPORT_NAME as On, getParamZodSchemaName as Ot, getQueriesImports as P, NATIVE_RESPONSE_TYPE as Pn, APP_REST_CLIENT_FILE as Pt, getAppAbilitiesType as Q, isErrorStatus as Qt, getInfiniteQueryName as R, getOperationTag as Rn, MUTATION_EFFECTS as Rt, getTsTypeBase as S, NUMBER_SCHEMA as Sn, isReadAllEndpoint as St, getQueryModulesImportPath as T, UUID_SCHEMA as Tn, invalidVariableNameCharactersToCamel as Tt, getQueryOptionsName as U, decapitalize as Un, NATIVE_PACKAGE_IMPORT_PATH as Ut, getPrefetchQueryName as V, camelToSpaceSeparated as Vn, QUERY_OPTIONS_TYPES as Vt, getAbilityAction as W, getMostCommonAdjacentCombinationSplit as Wn, PACKAGE_IMPORT_PATH as Wt, getAbilitySubjectTypes as X, getSchemaNameByRef as Xt, getAbilitySubject as Y, getParameterEnumNames as Yt, getAclData as Z, getSchemaRef as Zt, hasEndpointConfig as _, BLOB_SCHEMA as _n, getPathSegments as _t, resolveConfig as a, pathParamToVariableName as an, getZodSchemaInferedTypeName as at, requiresBody as b, ENUM_SCHEMA as bn, isDeleteEndpoint as bt, getDestructuredVariables as c, unwrapQuotesIfNeeded as cn, getSchemaDescriptions as ct, isQuery as d, isArraySchemaObject as dn, DEFAULT_GENERATE_OPTIONS as dt, isMediaTypeAllowed as en, hasAbilityConditions as et, getEndpointBody as f, isReferenceObject as fn, ACL_APP_ABILITIES as ft, getImportedEndpointName as g, ANY_SCHEMA as gn, CASL_ABILITY_IMPORT as gt, getEndpointPath as h, ALLOWED_PATH_IN as hn, CASL_ABILITY_BINDING as ht, shouldUseNativeCodegen as i, isSortingParameterObject as in, getZodSchemaDescription as it, getImportPath as j, AXIOS_REQUEST_CONFIG_TYPE as jn, getZodSchemaOperationName as jt, getAclImports as k, AXIOS_IMPORT as kn, getResponseZodSchemaName as kt, isInfiniteQuery as l, wrapWithQuotesIfNeeded as ln, iterateSchema as lt, getEndpointName as m, ALLOWED_METHODS as mn, ACL_CHECK_HOOK as mt, runGenerate as n, isPathExcluded as nn, getImportedZodSchemaInferedTypeName as nt, getOutputFileName as o, pathToVariableName as on, getZodSchemaPropertyDescriptions as ot, getEndpointConfig as p, isSchemaObject as pn, ACL_APP_ABILITY_FILE as pt, getAbilityDescription as q, snakeToCamel as qn, autocorrectRef as qt, compileNativeData as r, isPrimitiveType as rn, getImportedZodSchemaName as rt, pick as s, replaceHyphenatedPath as sn, getZodSchemaType as st, getOpenApiDoc as t, isParamMediaTypeAllowed as tn, renderAclCheckCall as tt, isMutation as u, inferRequiredSchema as un, getUniqueArray as ut, mapEndpointParamsToFunctionParams as v, DATETIME_SCHEMA as vn, isBulkDeleteEndpoint as vt, getFileNameWithExtension as w, URL_SCHEMA as wn, isUpdateEndpoint as wt, getSchemaTsMetaType as x, INT_SCHEMA as xn, isPathSegmentParam as xt, renderMediaUploadMutationBody as y, EMAIL_SCHEMA as yn, isCreateEndpoint as yt, getInfiniteQueryOptionsName as z, isTagIncluded as zn, QUERY_MODULES_FILE as zt };
|
|
1480
|
+
export { getImportedAbilityFunctionName as $, isPrimitiveType as $t, getEndpointsImports as A, NATIVE_RESPONSE_TYPE as An, APP_REST_CLIENT_NAME as At, getPrefetchInfiniteQueryName as B, getMostCommonAdjacentCombinationSplit as Bn, PACKAGE_IMPORT_PATH as Bt, getAppRestClientImportPath as C, ZOD_IMPORT as Cn, getParamZodSchemaName as Ct, getTagFileName as D, AXIOS_REQUEST_CONFIG_TYPE as Dn, isEnumZodSchema as Dt, getQueryTypesImportPath as E, AXIOS_REQUEST_CONFIG_NAME as En, getZodSchemaOperationName as Et, mergeImports as F, isTagIncluded as Fn, QUERY_MODULE_ENUM as Ft, getAbilityConditionType as G, getParameterEnumNames as Gt, getQueryName as H, removeWord as Hn, getNamespaceName as Ht, getImportedInfiniteQueryName as I, shouldInlineEndpointsForTag as In, QUERY_OPTIONS_TYPES as It, getAbilityFunctionName as J, isErrorStatus as Jt, getAbilityConditionsTypes as K, getSchemaNameByRef as Kt, getImportedQueryName as L, camelToSpaceSeparated as Ln, ZOD_EXTENDED as Lt, getInfiniteQueriesImports as M, formatTag as Mn, DOMAIN_ERRORS_FILE as Mt, getModelsImports as N, getEndpointTag as Nn, MUTATION_EFFECTS as Nt, getTagImportPath as O, BODY_PARAMETER_NAME as On, isNamedZodSchema as Ot, getQueriesImports as P, getOperationTag as Pn, QUERY_MODULES_FILE as Pt, getAppAbilitiesType as Q, isPathExcluded as Qt, getInfiniteQueryName as R, capitalize as Rn, CONFIG_PACKAGE_IMPORT_PATH as Rt, getTsTypeBase as S, VOID_SCHEMA as Sn, getEnumZodSchemaName as St, getQueryModulesImportPath as T, AXIOS_IMPORT as Tn, getZodSchemaName as Tt, getQueryOptionsName as U, snakeToCamel as Un, autocorrectRef as Ut, getPrefetchQueryName as V, kebabToCamel as Vn, REST_PACKAGE_IMPORT_PATH as Vt, getAbilityAction as W, Profiler as Wn, escapeControlCharacters as Wt, getAbilitySubjectTypes as X, isMediaTypeAllowed as Xt, getAbilitySubject as Y, isMainResponseStatus as Yt, getAclData as Z, isParamMediaTypeAllowed as Zt, hasEndpointConfig as _, INT_SCHEMA as _n, isReadAllEndpoint as _t, writeGenerateFileData as a, wrapWithQuotesIfNeeded as an, getZodSchemaInferedTypeName as at, requiresBody as b, URL_SCHEMA as bn, invalidVariableNameCharactersToCamel as bt, getDestructuredVariables as c, isReferenceObject as cn, getSchemaDescriptions as ct, isQuery as d, ALLOWED_PATH_IN as dn, DEFAULT_GENERATE_OPTIONS as dt, isSortingParameterObject as en, hasAbilityConditions as et, getEndpointBody as f, ANY_SCHEMA as fn, getPathSegments as ft, getImportedEndpointName as g, ENUM_SCHEMA as gn, isPathSegmentParam as gt, getEndpointPath as h, EMAIL_SCHEMA as hn, isDeleteEndpoint as ht, removeStaleGeneratedFiles as i, unwrapQuotesIfNeeded as in, getZodSchemaDescription as it, getImportPath as j, getRequestConfigTypeName as jn, BUILDERS_UTILS as jt, getAclImports as k, JSON_APPLICATION_FORMAT as kn, APP_REST_CLIENT_FILE as kt, isInfiniteQuery as l, isSchemaObject as ln, iterateSchema as lt, getEndpointName as m, DATETIME_SCHEMA as mn, isCreateEndpoint as mt, shouldUseNativeCodegen as n, pathToVariableName as nn, getImportedZodSchemaInferedTypeName as nt, deepMerge as o, inferRequiredSchema as on, getZodSchemaPropertyDescriptions as ot, getEndpointConfig as p, BLOB_SCHEMA as pn, isBulkDeleteEndpoint as pt, getAbilityDescription as q, getSchemaRef as qt, getOutputFileName as r, replaceHyphenatedPath as rn, getImportedZodSchemaName as rt, pick as s, isArraySchemaObject as sn, getZodSchemaType as st, compileNativeData as t, pathParamToVariableName as tn, renderAclCheckCall as tt, isMutation as u, ALLOWED_METHODS as un, getUniqueArray as ut, mapEndpointParamsToFunctionParams as v, NUMBER_SCHEMA as vn, isReadEndpoint as vt, getFileNameWithExtension as w, AXIOS_DEFAULT_IMPORT_NAME as wn, getResponseZodSchemaName as wt, getSchemaTsMetaType as x, UUID_SCHEMA as xn, getBodyZodSchemaName as xt, renderMediaUploadMutationBody as y, STRING_SCHEMA as yn, isUpdateEndpoint as yt, getInfiniteQueryOptionsName as z, decapitalize as zn, NATIVE_PACKAGE_IMPORT_PATH as zt };
|
|
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 };
|