@povio/openapi-codegen-cli 3.2.0-rc.8 → 3.3.0-rc.1

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.
Files changed (44) hide show
  1. package/README.md +2 -51
  2. package/dist/acl.d.mts +19 -6
  3. package/dist/acl.mjs +7 -6
  4. package/dist/{auth.context-YFWzkwoN.mjs → auth.context-BAz8frX9.mjs} +1 -2
  5. package/dist/{config-DgrOddSC.d.mts → config-BQqze8rU.d.mts} +2 -1
  6. package/dist/{error-handling-BMXC5P08.mjs → error-handling-CsnufAil.mjs} +12 -22
  7. package/dist/{error-handling-CNOHs4Fc.d.mts → error-handling-D6ZYITQ3.d.mts} +4 -1
  8. package/dist/generate.runner-BeCGJ1ar.mjs +87 -0
  9. package/dist/{generateCodeFromOpenAPIDoc-CZT3sThI.cjs → generateCodeFromOpenAPIDoc-KQT4kYxY.mjs} +2375 -1403
  10. package/dist/generator.d.mts +10 -3
  11. package/dist/generator.mjs +4 -6
  12. package/dist/index.d.mts +47 -12
  13. package/dist/index.mjs +3 -6
  14. package/dist/metro.cjs +4861 -112
  15. package/dist/metro.d.mts +4 -3
  16. package/dist/metro.mjs +3 -3
  17. package/dist/{openapi-codegen.runner-C93V7SGj.mjs → openapi-codegen.runner-nPBssrBL.mjs} +2 -2
  18. package/dist/{openapi-source.runner-BZ6ZLgRO.mjs → openapi-source.runner-8kCe-g9S.mjs} +6 -18
  19. package/dist/{openapi-source.runner-ykstqlPC.d.mts → openapi-source.runner-B6KKrXw7.d.mts} +8 -2
  20. package/dist/{options-KPf-Fti5.d.mts → options-DdQJ9BSc.d.mts} +1 -6
  21. package/dist/sh.d.mts +1 -1
  22. package/dist/sh.mjs +53 -36
  23. package/dist/tiny.d.mts +1 -1
  24. package/dist/tiny.mjs +1 -1
  25. package/dist/vite.d.mts +4 -3
  26. package/dist/vite.mjs +4 -5
  27. package/dist/zod.d.mts +7 -2
  28. package/dist/zod.mjs +1 -1
  29. package/package.json +22 -32
  30. package/dist/generate.runner-BvSprH6D.mjs +0 -1683
  31. package/dist/generate.utils-CH2U2Dpr.cjs +0 -2314
  32. package/dist/generateCodeFromOpenAPIDoc-glAKBEGP.mjs +0 -2036
  33. package/dist/getDataFromOpenAPIDoc-7RxjULpB.mjs +0 -2011
  34. package/dist/native-rest-interceptor-CAWR8H5Y.mjs +0 -208
  35. package/dist/native-rest-interceptor-Cz6saoq5.d.mts +0 -46
  36. package/dist/native.d.mts +0 -3
  37. package/dist/native.mjs +0 -3
  38. package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
  39. package/dist/openapi-codegen-native-linux-x64.node +0 -0
  40. package/dist/openapi-codegen-native-win32-x64.node +0 -0
  41. package/dist/rest-transport.types-DM5-qyOJ.d.mts +0 -66
  42. package/dist/rest-transport.types-DxitRtsB.mjs +0 -11
  43. package/dist/rest.d.mts +0 -2
  44. package/dist/rest.mjs +0 -2
@@ -1,2314 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- let fs = require("fs");
24
- fs = __toESM(fs, 1);
25
- let path = require("path");
26
- path = __toESM(path, 1);
27
- require("url");
28
- let node_module = require("node:module");
29
- let node_fs = require("node:fs");
30
- let node_url = require("node:url");
31
- let node_path = require("node:path");
32
- node_path = __toESM(node_path, 1);
33
- let openapi_types = require("openapi-types");
34
- //#region src/generators/const/package.const.ts
35
- const PACKAGE_IMPORT_PATH = "@povio/openapi-codegen-cli";
36
- const NATIVE_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/native`;
37
- const REST_PACKAGE_IMPORT_PATH = `${PACKAGE_IMPORT_PATH}/rest`;
38
- //#endregion
39
- //#region src/generators/const/zod.const.ts
40
- const SCHEMA_SUFFIX = "Schema";
41
- const ENUM_SUFFIX = "Enum";
42
- const BODY_SCHEMA_SUFFIX = "Body";
43
- const PARAM_SCHEMA_SUFFIX = "Param";
44
- const RESPONSE_SCHEMA_SUFFIX = "Response";
45
- const ERROR_RESPONSE_SCHEMA_SUFFIX = "ErrorResponse";
46
- const VOID_SCHEMA = "z.void()";
47
- const ANY_SCHEMA = "z.any()";
48
- const BLOB_SCHEMA = "z.instanceof(Blob)";
49
- const ENUM_SCHEMA = "z.enum";
50
- const INT_SCHEMA = "z.int()";
51
- const NUMBER_SCHEMA = "z.number()";
52
- const STRING_SCHEMA = "z.string()";
53
- const EMAIL_SCHEMA = "z.email()";
54
- const URL_SCHEMA = "z.url()";
55
- const UUID_SCHEMA = "z.uuid()";
56
- const DATETIME_SCHEMA = "z.iso.datetime({ offset: true })";
57
- const ZOD_IMPORT = {
58
- bindings: ["z"],
59
- from: "zod"
60
- };
61
- //#endregion
62
- //#region src/generators/const/options.const.ts
63
- const DEFAULT_GENERATE_OPTIONS = {
64
- input: "http://localhost:4000/docs-json/",
65
- output: "output",
66
- clearOutput: false,
67
- incremental: true,
68
- splitByTags: true,
69
- defaultTag: "Common",
70
- includeTags: [],
71
- excludeTags: [],
72
- excludePathRegex: "",
73
- excludeRedundantZodSchemas: true,
74
- tsNamespaces: true,
75
- treeShakeableNamespaces: false,
76
- tsPath: "@/data",
77
- importPath: "ts",
78
- configs: {
79
- ["models"]: {
80
- outputFileNameSuffix: "models",
81
- namespaceSuffix: "Models"
82
- },
83
- ["endpoints"]: {
84
- outputFileNameSuffix: "api",
85
- namespaceSuffix: "Api"
86
- },
87
- ["queries"]: {
88
- outputFileNameSuffix: "queries",
89
- namespaceSuffix: "Queries"
90
- },
91
- ["acl"]: {
92
- outputFileNameSuffix: "acl",
93
- namespaceSuffix: "Acl"
94
- },
95
- ["configs"]: {
96
- outputFileNameSuffix: "configs",
97
- namespaceSuffix: "Configs"
98
- }
99
- },
100
- baseUrl: "",
101
- modelsOnly: false,
102
- standalone: false,
103
- schemaSuffix: SCHEMA_SUFFIX,
104
- enumSuffix: ENUM_SUFFIX,
105
- modelsInCommon: false,
106
- modelsInModules: false,
107
- withDefaultValues: true,
108
- extractEnums: true,
109
- replaceOptionalWithNullish: false,
110
- restClient: "axios",
111
- restClientImportPath: "",
112
- zodImportPath: "@povio/openapi-codegen-cli/zod",
113
- errorHandlingImportPath: "",
114
- removeOperationPrefixEndingWith: "Controller_",
115
- parseRequestParams: true,
116
- inlineEndpoints: false,
117
- inlineEndpointsExcludeModules: [],
118
- queryTypesImportPath: PACKAGE_IMPORT_PATH,
119
- mutationEffectsImportPath: PACKAGE_IMPORT_PATH,
120
- axiosRequestConfig: false,
121
- mutationEffects: true,
122
- mutationDefaultOnError: false,
123
- workspaceContext: [],
124
- prefetchQueries: true,
125
- mutationScope: false,
126
- infiniteQueries: false,
127
- infiniteQueryParamNames: { page: "page" },
128
- infiniteQueryResponseParamNames: {
129
- page: "page",
130
- totalItems: "totalItems",
131
- limit: "limit"
132
- },
133
- acl: true,
134
- checkAcl: true,
135
- abilityContextGenericAppAbilities: false,
136
- abilityContextImportPath: "",
137
- aclCheckImportPath: "@povio/openapi-codegen-cli/acl",
138
- builderConfigs: false,
139
- filterParamName: "filter",
140
- dataResponseParamNames: ["data", "items"],
141
- dynamicInputsImportPath: "@povio/ui",
142
- dynamicColumnsImportPath: "@povio/ui"
143
- };
144
- //#endregion
145
- //#region src/generators/utils/object.utils.ts
146
- /** Pick given properties in object */
147
- function pick(obj, paths) {
148
- const result = {};
149
- Object.keys(obj).forEach((key) => {
150
- if (!paths.includes(key)) return;
151
- result[key] = obj[key];
152
- });
153
- return result;
154
- }
155
- /**
156
- * Deep merge two or more objects/arrays recursively.
157
- * Arrays are concatenated, objects are merged recursively.
158
- * Later arguments take precedence over earlier ones.
159
- * Returns a new object/array without mutating the originals.
160
- */
161
- function deepMerge(source, ...sources) {
162
- if (sources.length === 0) return source;
163
- let result = source;
164
- for (const source of sources) result = mergeTwoValues(result, source);
165
- return result;
166
- }
167
- /**
168
- * Merge two values recursively
169
- */
170
- function mergeTwoValues(target, source) {
171
- if (source === null || source === void 0) return target;
172
- if (target === null || target === void 0) return deepClone(source);
173
- if (Array.isArray(target) && Array.isArray(source)) return [...target, ...source];
174
- if (isPlainObject(target) && isPlainObject(source)) {
175
- const result = {};
176
- for (const [key, targetValue] of Object.entries(target)) result[key] = deepClone(targetValue);
177
- for (const [key, sourceValue] of Object.entries(source)) {
178
- const targetValue = result[key];
179
- if (sourceValue === void 0) continue;
180
- else if (sourceValue === null) result[key] = sourceValue;
181
- else if (isPlainObject(targetValue) && isPlainObject(sourceValue)) result[key] = mergeTwoValues(targetValue, sourceValue);
182
- else if (Array.isArray(targetValue) && Array.isArray(sourceValue)) result[key] = [...targetValue, ...sourceValue];
183
- else result[key] = deepClone(sourceValue);
184
- }
185
- return result;
186
- }
187
- return deepClone(source);
188
- }
189
- /**
190
- * Deep clone an object or array to avoid reference sharing.
191
- * Helper function for deepMerge.
192
- */
193
- function deepClone(obj) {
194
- if (obj === null || obj === void 0 || typeof obj !== "object") return obj;
195
- if (Array.isArray(obj)) return obj.map((item) => deepClone(item));
196
- if (isPlainObject(obj)) {
197
- const result = {};
198
- for (const [key, value] of Object.entries(obj)) result[key] = deepClone(value);
199
- return result;
200
- }
201
- return obj;
202
- }
203
- /**
204
- * Check if a value is a plain object (not an array, Date, etc.)
205
- */
206
- function isPlainObject(obj) {
207
- return obj !== null && typeof obj === "object" && !Array.isArray(obj) && Object.prototype.toString.call(obj) === "[object Object]";
208
- }
209
- //#endregion
210
- //#region src/generators/utils/file.utils.ts
211
- function getOutputFileName({ output, fileName }) {
212
- return `${output}/${fileName}`;
213
- }
214
- async function writeFileIfChanged(file, data, skipExistingCheck = false) {
215
- if (skipExistingCheck) {
216
- await fs.default.promises.writeFile(file, data, "utf-8");
217
- return;
218
- }
219
- try {
220
- if (await fs.default.promises.readFile(file, "utf-8") === data) return;
221
- } catch (error) {
222
- if (error.code !== "ENOENT") throw error;
223
- }
224
- await fs.default.promises.writeFile(file, data, "utf-8");
225
- }
226
- async function writeFile({ fileName, content }, options) {
227
- const formattedContent = options?.formatGeneratedFile ? await options.formatGeneratedFile({
228
- fileName,
229
- content
230
- }) : content;
231
- await fs.default.promises.mkdir(path.default.dirname(fileName), { recursive: true });
232
- await writeFileIfChanged(fileName, formattedContent, options?.skipExistingCheck);
233
- }
234
- async function writeGenerateFileData(filesData, options) {
235
- if (!options?.formatGeneratedFile) {
236
- const directories = new Set(filesData.map(({ fileName }) => path.default.dirname(fileName)));
237
- for (const directory of directories) fs.default.mkdirSync(directory, { recursive: true });
238
- await Promise.all(filesData.map(({ fileName, content }) => writeFileIfChanged(fileName, content, options?.skipExistingCheck)));
239
- return;
240
- }
241
- for (const file of filesData) await writeFile(file, options);
242
- }
243
- function removeStaleGeneratedFiles({ output, filesData, options }) {
244
- if (!fs.default.existsSync(output)) return;
245
- const expectedFiles = new Set(filesData.map((file) => path.default.resolve(file.fileName)));
246
- const generatedSuffixes = new Set(Object.values(options.configs).map((config) => config.outputFileNameSuffix));
247
- const staleFiles = [];
248
- const visit = (dirPath) => {
249
- for (const dirent of fs.default.readdirSync(dirPath, { withFileTypes: true })) {
250
- const entryPath = path.default.join(dirPath, dirent.name);
251
- if (dirent.isDirectory()) {
252
- visit(entryPath);
253
- continue;
254
- }
255
- if (isGeneratedFile(entryPath, output, generatedSuffixes) && !expectedFiles.has(path.default.resolve(entryPath))) staleFiles.push(entryPath);
256
- }
257
- };
258
- visit(output);
259
- staleFiles.forEach((filePath) => fs.default.rmSync(filePath, { force: true }));
260
- removeEmptyDirectories(output);
261
- }
262
- function isGeneratedFile(filePath, output, generatedSuffixes) {
263
- const relativePath = path.default.relative(output, filePath);
264
- if (relativePath === ".openapi-codegen-cache.json") return true;
265
- const normalizedRelativePath = relativePath.split(path.default.sep).join("/");
266
- if ([
267
- "app-rest-client.ts",
268
- "queryModules.ts",
269
- "acl/app.ability.ts"
270
- ].includes(normalizedRelativePath)) return true;
271
- if (path.default.parse(filePath).ext !== ".ts") return false;
272
- const segments = relativePath.split(path.default.sep).filter(Boolean);
273
- if (segments.length < 2) return false;
274
- const moduleName = segments[0];
275
- const fileName = segments[segments.length - 1];
276
- if (!fileName.startsWith(`${moduleName}.`)) return false;
277
- const suffix = fileName.slice(moduleName.length + 1).replace(/\.tsx?$/, "");
278
- return generatedSuffixes.has(suffix);
279
- }
280
- function removeEmptyDirectories(root) {
281
- if (!fs.default.existsSync(root)) return;
282
- const removeIfEmpty = (dirPath) => {
283
- for (const dirent of fs.default.readdirSync(dirPath, { withFileTypes: true })) if (dirent.isDirectory()) removeIfEmpty(path.default.join(dirPath, dirent.name));
284
- if (dirPath !== root && fs.default.readdirSync(dirPath).length === 0) fs.default.rmdirSync(dirPath);
285
- };
286
- removeIfEmpty(root);
287
- }
288
- //#endregion
289
- //#region src/helpers/profile.helper.ts
290
- function nowMs() {
291
- return Number(process.hrtime.bigint()) / 1e6;
292
- }
293
- var Profiler = class {
294
- enabled;
295
- entries = /* @__PURE__ */ new Map();
296
- constructor(enabled) {
297
- this.enabled = enabled;
298
- }
299
- add(label, elapsedMs) {
300
- if (!this.enabled) return;
301
- const prev = this.entries.get(label);
302
- if (prev) {
303
- prev.totalMs += elapsedMs;
304
- prev.count += 1;
305
- return;
306
- }
307
- this.entries.set(label, {
308
- totalMs: elapsedMs,
309
- count: 1
310
- });
311
- }
312
- runSync(label, fn) {
313
- if (!this.enabled) return fn();
314
- const startMs = nowMs();
315
- try {
316
- return fn();
317
- } finally {
318
- this.add(label, nowMs() - startMs);
319
- }
320
- }
321
- async runAsync(label, fn) {
322
- if (!this.enabled) return await fn();
323
- const startMs = nowMs();
324
- try {
325
- return await fn();
326
- } finally {
327
- this.add(label, nowMs() - startMs);
328
- }
329
- }
330
- formatLines() {
331
- if (!this.enabled) return [];
332
- return Array.from(this.entries.entries()).sort((a, b) => b[1].totalMs - a[1].totalMs).map(([label, entry]) => {
333
- const avgMs = entry.totalMs / entry.count;
334
- return `${label}: ${entry.totalMs.toFixed(1)}ms (count: ${entry.count}, avg: ${avgMs.toFixed(2)}ms)`;
335
- });
336
- }
337
- };
338
- //#endregion
339
- //#region src/native/native-bindings.ts
340
- let bindings;
341
- let nativePath;
342
- function getNativePath() {
343
- if (nativePath) return nativePath;
344
- const moduleDir = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
345
- const binaryName = `openapi-codegen-native-${process.platform}-${process.arch}.node`;
346
- nativePath = [node_path.default.join(moduleDir, binaryName), node_path.default.resolve(moduleDir, "../../dist", binaryName)].find(node_fs.existsSync);
347
- if (!nativePath) throw new Error("Native OpenAPI codegen module is not built. Run `bun run build:native`.");
348
- return nativePath;
349
- }
350
- function hasNativeBindings() {
351
- try {
352
- getNativeBindings();
353
- return true;
354
- } catch {
355
- return false;
356
- }
357
- }
358
- function shouldUseNativeCodegen() {
359
- if (process.env.OPENAPI_CODEGEN_NATIVE === "0") return false;
360
- if (process.env.OPENAPI_CODEGEN_NATIVE === "1") return true;
361
- return hasNativeBindings();
362
- }
363
- function getNativeBindings() {
364
- if (!bindings) {
365
- const require = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
366
- const resolvedNativePath = getNativePath();
367
- if (typeof process.dlopen === "function") {
368
- const nativeModule = { exports: {} };
369
- process.dlopen(nativeModule, resolvedNativePath);
370
- bindings = nativeModule.exports;
371
- } else bindings = require(resolvedNativePath);
372
- }
373
- return bindings;
374
- }
375
- function compileNativeData(source, yaml, optionsJson) {
376
- return getNativeBindings().compileData(source, yaml, optionsJson);
377
- }
378
- //#endregion
379
- //#region src/generators/const/acl.const.ts
380
- const ACL_APP_ABILITY_FILE = {
381
- fileName: "acl/app.ability",
382
- extension: "ts"
383
- };
384
- const ACL_APP_ABILITIES = "AppAbilities";
385
- const ACL_CHECK_HOOK = "useAclCheck";
386
- const CASL_ABILITY_BINDING = {
387
- abilityTuple: "AbilityTuple",
388
- pureAbility: "PureAbility",
389
- forcedSubject: "ForcedSubject",
390
- subjectType: "Subject",
391
- subject: "subject"
392
- };
393
- const CASL_ABILITY_IMPORT = {
394
- bindings: [
395
- CASL_ABILITY_BINDING.abilityTuple,
396
- CASL_ABILITY_BINDING.pureAbility,
397
- CASL_ABILITY_BINDING.forcedSubject,
398
- CASL_ABILITY_BINDING.subjectType,
399
- CASL_ABILITY_BINDING.subject
400
- ],
401
- from: "@casl/ability"
402
- };
403
- //#endregion
404
- //#region src/generators/const/deps.const.ts
405
- const APP_REST_CLIENT_NAME = "AppRestClient";
406
- const APP_REST_CLIENT_FILE = {
407
- fileName: "app-rest-client",
408
- extension: "ts"
409
- };
410
- const DOMAIN_ERRORS_FILE = {
411
- fileName: "domain-errors",
412
- extension: "ts"
413
- };
414
- const QUERY_OPTIONS_TYPES = {
415
- query: "AppQueryOptions",
416
- infiniteQuery: "AppInfiniteQueryOptions",
417
- mutation: "AppMutationOptions"
418
- };
419
- const TEMPLATE_DATA_FILE_PATH = "src/data";
420
- const ERROR_HANDLERS = {
421
- ErrorHandler: "ErrorHandler",
422
- SharedErrorHandler: "SharedErrorHandler"
423
- };
424
- ERROR_HANDLERS.ErrorHandler, ERROR_HANDLERS.SharedErrorHandler;
425
- const BUILDERS_UTILS = {
426
- dynamicInputs: "dynamicInputs",
427
- dynamicColumns: "dynamicColumns"
428
- };
429
- const QUERY_MODULE_ENUM = "QueryModule";
430
- const QUERY_MODULES_FILE = {
431
- fileName: "queryModules",
432
- extension: "ts"
433
- };
434
- const MUTATION_EFFECTS = {
435
- optionsType: "MutationEffectsOptions",
436
- hookName: "useMutationEffects",
437
- runFunctionName: "runMutationEffects"
438
- };
439
- const ZOD_EXTENDED = {
440
- namespace: "ZodExtended",
441
- exports: {
442
- parse: "parse",
443
- sortExp: "sortExp"
444
- }
445
- };
446
- //#endregion
447
- //#region src/generators/utils/string.utils.ts
448
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
449
- const decapitalize = (str) => str.charAt(0).toLowerCase() + str.slice(1);
450
- const kebabToCamel = (str) => str.replace(/(-\w)/g, (group) => group[1].toUpperCase());
451
- const snakeToCamel = (str) => str.replace(/(_\w)/g, (group) => group[1].toUpperCase());
452
- const nonWordCharactersToCamel = (str) => str.replace(/[\W_]+(\w)?/g, (_, char) => char?.toUpperCase() ?? "");
453
- const suffixIfNeeded = (text, suffix = "") => text.endsWith(suffix) ? text : `${text}${suffix}`;
454
- const removeSuffix = (text, suffix) => text.replace(new RegExp(`${suffix}$`), "");
455
- const getLongestMostCommon = (strs) => {
456
- const counter = strs.reduce((acc, str) => ({
457
- ...acc,
458
- [str]: (acc[str] ?? 0) + 1
459
- }), {});
460
- return Object.entries(counter).toSorted((a, b) => {
461
- if (a[1] === b[1]) return b[0].length - a[0].length;
462
- return b[1] - a[1];
463
- })[0]?.[0];
464
- };
465
- const getMostCommonAdjacentCombinationSplit = (strs) => {
466
- const splits = strs.flatMap((str) => getAdjacentStringCombinations(splitByUppercase(capitalize(str))));
467
- return getLongestMostCommon(splits);
468
- };
469
- const splitByUppercase = (str) => {
470
- return str.split(/(?<![A-Z])(?=[A-Z])/).filter(Boolean);
471
- };
472
- const camelToSpaceSeparated = (text) => splitByUppercase(text).join(" ");
473
- const getAdjacentStringCombinations = (strs, ignoreStrs = [
474
- "dto",
475
- "by",
476
- "for",
477
- "of",
478
- "in",
479
- "to",
480
- "and",
481
- "with"
482
- ]) => {
483
- const combinations = [];
484
- for (let i = 0; i < strs.length; i++) {
485
- if (ignoreStrs.includes(strs[i].toLowerCase())) continue;
486
- for (let j = i + 1; j <= strs.length; j++) {
487
- if (ignoreStrs.includes(strs[j - 1]?.toLowerCase())) continue;
488
- combinations.push(strs.slice(i, j).join(""));
489
- }
490
- }
491
- return combinations;
492
- };
493
- const removeWord = (source, wordToRemove) => {
494
- const singularWordToRemove = wordToRemove.replace(/es$|s$/g, "");
495
- const pattern = new RegExp(`(${decapitalize(singularWordToRemove)}|${capitalize(singularWordToRemove)})[a-z]*(?=$|[A-Z])`, "g");
496
- return source.replace(pattern, "");
497
- };
498
- //#endregion
499
- //#region src/generators/utils/array.utils.ts
500
- const getUniqueArray = (...arrs) => [...new Set(arrs.flat())];
501
- //#endregion
502
- //#region src/generators/utils/namespace.utils.ts
503
- const getNamespaceName = ({ type, tag, options }) => `${capitalize(tag)}${options.configs[type].namespaceSuffix}`;
504
- //#endregion
505
- //#region src/generators/utils/tag.utils.ts
506
- const formattedTagCache = /* @__PURE__ */ new Map();
507
- const tagFilterCache = /* @__PURE__ */ new WeakMap();
508
- function formatTag(tag) {
509
- let formattedTag = formattedTagCache.get(tag);
510
- if (formattedTag === void 0) {
511
- formattedTag = nonWordCharactersToCamel(tag);
512
- formattedTagCache.set(tag, formattedTag);
513
- }
514
- return formattedTag;
515
- }
516
- function getOperationTag(operation, options) {
517
- const tag = operation.tags?.[0];
518
- return formatTag(tag ?? options.defaultTag);
519
- }
520
- function getEndpointTag(endpoint, options) {
521
- return formatTag((options.splitByTags ? endpoint.tags?.[0] : options.defaultTag) ?? options.defaultTag);
522
- }
523
- function isTagIncluded(tag, options) {
524
- const normalizedTag = formatTag(tag).toLowerCase();
525
- let filters = tagFilterCache.get(options);
526
- if (!filters) {
527
- filters = {
528
- include: new Set(options.includeTags.map((includeTag) => formatTag(includeTag).toLowerCase())),
529
- exclude: new Set(options.excludeTags.map((excludeTag) => formatTag(excludeTag).toLowerCase()))
530
- };
531
- tagFilterCache.set(options, filters);
532
- }
533
- if (filters.include.has(normalizedTag)) return true;
534
- if (filters.exclude.has(normalizedTag)) return false;
535
- return options.includeTags.length === 0;
536
- }
537
- function shouldInlineEndpointsForTag(tag, options) {
538
- if (!options.inlineEndpoints) return false;
539
- return !(options.inlineEndpointsExcludeModules ?? []).some((moduleName) => formatTag(moduleName).toLowerCase() === tag.toLowerCase());
540
- }
541
- //#endregion
542
- //#region src/generators/utils/js.utils.ts
543
- const isValidPropertyName = (str) => /^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(str);
544
- const invalidVariableNameCharactersToCamel = (str) => str.replace(/^[^a-zA-Z_$]*/g, "").replace(/[^a-zA-Z0-9_$]+(\w)?/g, (_, char) => char?.toUpperCase() ?? "");
545
- //#endregion
546
- //#region src/generators/const/openapi.const.ts
547
- const ALLOWED_PARAM_MEDIA_TYPES = [
548
- "application/octet-stream",
549
- "multipart/form-data",
550
- "application/x-www-form-urlencoded",
551
- "*/*"
552
- ];
553
- const ALLOWED_PATH_IN = [
554
- "query",
555
- "header",
556
- "path"
557
- ];
558
- const ALLOWED_METHODS = [
559
- openapi_types.OpenAPIV3.HttpMethods.GET,
560
- openapi_types.OpenAPIV3.HttpMethods.PUT,
561
- openapi_types.OpenAPIV3.HttpMethods.POST,
562
- openapi_types.OpenAPIV3.HttpMethods.DELETE,
563
- openapi_types.OpenAPIV3.HttpMethods.OPTIONS,
564
- openapi_types.OpenAPIV3.HttpMethods.HEAD,
565
- openapi_types.OpenAPIV3.HttpMethods.PATCH,
566
- openapi_types.OpenAPIV3.HttpMethods.TRACE
567
- ];
568
- const PRIMITIVE_TYPE_LIST = [
569
- "string",
570
- "number",
571
- "integer",
572
- "boolean"
573
- ];
574
- const COMPOSITE_KEYWORDS = [
575
- "allOf",
576
- "anyOf",
577
- "oneOf"
578
- ];
579
- //#endregion
580
- //#region src/generators/utils/openapi-schema.utils.ts
581
- function isReferenceObject(obj) {
582
- return obj != null && Object.prototype.hasOwnProperty.call(obj, "$ref");
583
- }
584
- function isSchemaObject(schema) {
585
- return !isReferenceObject(schema);
586
- }
587
- function isArraySchemaObject(schema) {
588
- return schema.type === "array";
589
- }
590
- function inferRequiredSchema(schema) {
591
- if (!schema.allOf) throw new Error("Function inferRequiredSchema is specialized to handle item with required only in an allOf array.");
592
- const [standaloneRequisites, noRequiredOnlyAllof] = schema.allOf.reduce((acc, cur) => {
593
- if (isBrokenAllOfItem(cur)) {
594
- const required = cur.required;
595
- acc[0].push(...required ?? []);
596
- } else acc[1].push(cur);
597
- return acc;
598
- }, [[], []]);
599
- const composedRequiredSchema = {
600
- properties: standaloneRequisites.reduce((acc, cur) => {
601
- acc[cur] = {};
602
- return acc;
603
- }, {}),
604
- type: "object",
605
- required: standaloneRequisites
606
- };
607
- return {
608
- noRequiredOnlyAllof,
609
- composedRequiredSchema,
610
- patchRequiredSchemaInLoop: (prop, getSchemaByRef) => {
611
- if (isReferenceObject(prop)) {
612
- const refType = getSchemaByRef(prop.$ref);
613
- if (refType) composedRequiredSchema.required.forEach((required) => {
614
- composedRequiredSchema.properties[required] = refType?.properties?.[required] ?? {};
615
- });
616
- } else {
617
- const properties = prop["properties"] ?? {};
618
- composedRequiredSchema.required.forEach((required) => {
619
- if (properties[required]) composedRequiredSchema.properties[required] = properties[required] ?? {};
620
- });
621
- }
622
- }
623
- };
624
- }
625
- const isBrokenAllOfItem = (item) => {
626
- return !isReferenceObject(item) && !!item.required && !item.type && !item.properties && !item?.allOf && !item?.anyOf && !item.oneOf;
627
- };
628
- //#endregion
629
- //#region src/generators/core/openapi/iterateSchema.ts
630
- function iterateSchema(schema, options) {
631
- if (!schema) return;
632
- const { data, onSchema } = options;
633
- if (isReferenceObject(schema) && onSchema({
634
- type: "reference",
635
- schema,
636
- data
637
- }) === true) return;
638
- const schemaObj = schema;
639
- if (COMPOSITE_KEYWORDS.some((prop) => prop in schemaObj && schemaObj[prop])) {
640
- const schemaObjs = schemaObj.allOf ?? schemaObj.anyOf ?? schemaObj.oneOf ?? [];
641
- for (const compositeObj of schemaObjs) {
642
- if (onSchema?.({
643
- type: "composite",
644
- parentSchema: schema,
645
- schema: compositeObj,
646
- data
647
- }) === true) continue;
648
- iterateSchema(compositeObj, {
649
- data,
650
- onSchema
651
- });
652
- }
653
- }
654
- if (schemaObj.properties) for (const [propertyName, propertyObj] of Object.entries(schemaObj.properties)) {
655
- if (onSchema({
656
- type: "property",
657
- parentSchema: schema,
658
- schema: propertyObj,
659
- data,
660
- propertyName
661
- }) === true) continue;
662
- iterateSchema(propertyObj, options);
663
- }
664
- if (schemaObj.additionalProperties && typeof schemaObj.additionalProperties === "object") {
665
- if (onSchema({
666
- type: "additionalProperties",
667
- parentSchema: schema,
668
- schema: schemaObj.additionalProperties,
669
- data
670
- }) === true) return;
671
- iterateSchema(schemaObj.additionalProperties, options);
672
- }
673
- if (schemaObj.type === "array") {
674
- const arrayObj = schema.items;
675
- if (onSchema({
676
- type: "array",
677
- parentSchema: schema,
678
- schema: arrayObj,
679
- data
680
- }) === true) return;
681
- iterateSchema(arrayObj, options);
682
- }
683
- }
684
- //#endregion
685
- //#region src/generators/utils/openapi.utils.ts
686
- const getSchemaRef = (schemaName) => `#/components/schemas/${schemaName}`;
687
- const autocorrectRef = (ref) => ref[1] === "/" ? ref : "#/" + ref.slice(1);
688
- const getSchemaNameByRef = (ref) => autocorrectRef(ref).split("/").at(-1);
689
- function normalizeString(text) {
690
- const formatted = prefixStringStartingWithNumberIfNeeded(text).normalize("NFKD").trim().replace(/\s+/g, "_").replace(/--+/g, "-").replace(/-+/g, "_").replace(/[^\w-]+/g, "_");
691
- return snakeToCamel(formatted);
692
- }
693
- function wrapWithQuotesIfNeeded(str) {
694
- if (/^[a-zA-Z]\w*$/.test(str)) return str;
695
- return `"${str}"`;
696
- }
697
- function unwrapQuotesIfNeeded(value) {
698
- if (typeof value === "string" && value.startsWith("\"") && value.endsWith("\"")) return value.slice(1, -1);
699
- return value;
700
- }
701
- function prefixStringStartingWithNumberIfNeeded(str) {
702
- const firstAsNumber = Number(str[0]);
703
- if (typeof firstAsNumber === "number" && !Number.isNaN(firstAsNumber)) return "_" + str;
704
- return str;
705
- }
706
- function pathParamToVariableName(name) {
707
- const preserveUnderscore = name.replaceAll("_", "#");
708
- return snakeToCamel(preserveUnderscore.replaceAll("-", "_")).replaceAll("#", "_");
709
- }
710
- const isPrimitiveType = (type) => PRIMITIVE_TYPE_LIST.includes(type);
711
- function escapeControlCharacters(str) {
712
- return str.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g, (_m, p1) => {
713
- const dec = p1.codePointAt();
714
- const hex = dec.toString(16);
715
- if (dec <= 255) return `\\x${`00${hex}`.slice(-2)}`;
716
- return `\\u${`0000${hex}`.slice(-4)}`;
717
- }).replace(/\//g, "\\/");
718
- }
719
- function isParamMediaTypeAllowed(mediaType) {
720
- return mediaType.includes("application/") && mediaType.includes("json") || ALLOWED_PARAM_MEDIA_TYPES.includes(mediaType) || mediaType.includes("text/");
721
- }
722
- function isMainResponseStatus(status) {
723
- return status >= 200 && status < 300;
724
- }
725
- function isErrorStatus(status) {
726
- return !(status >= 200 && status < 300);
727
- }
728
- function isMediaTypeAllowed(mediaType) {
729
- return mediaType.startsWith("application/");
730
- }
731
- const PATH_PARAM_WITH_BRACKETS_REGEX = /({\w+})/g;
732
- const WORD_PRECEDED_BY_NON_WORD_CHARACTER = /[^\w\-]+/g;
733
- /** @example turns `/media-objects/{id}` into `MediaObjectsById` */
734
- function pathToVariableName(path) {
735
- path = capitalize(kebabToCamel(path.replaceAll("/", "-")).replaceAll("-", ""));
736
- const pathParams = [...path.matchAll(PATH_PARAM_WITH_BRACKETS_REGEX)];
737
- if (pathParams.length > 0) {
738
- const lastPathParam = pathParams.toSorted((a, b) => a.index - b.index)[pathParams.length - 1][0];
739
- path = `${path.replace(PATH_PARAM_WITH_BRACKETS_REGEX, "")}By${capitalize(lastPathParam.slice(1, -1))}`;
740
- }
741
- return path.replace(WORD_PRECEDED_BY_NON_WORD_CHARACTER, "_");
742
- }
743
- const MATCHER_REGEX = /{(\b\w+(?:-\w+)*\b)}/g;
744
- function replaceHyphenatedPath(path) {
745
- const matches = path.match(MATCHER_REGEX);
746
- if (matches === null) return path.replaceAll(MATCHER_REGEX, ":$1");
747
- matches.forEach((match) => {
748
- const replacement = pathParamToVariableName(match.replaceAll(MATCHER_REGEX, ":$1"));
749
- path = path.replaceAll(match, replacement);
750
- });
751
- return path;
752
- }
753
- const isSortingParameterObject = (param, schema = param.schema, resolver) => {
754
- const enumNames = getParameterEnumNames(param, schema);
755
- return Array.isArray(enumNames) && enumNames.length > 0 && isStringLikeParameterSchema(schema, resolver);
756
- };
757
- function getParameterEnumNames(param, schema = param.schema) {
758
- return param["x-enumNames"] ?? (schema && isSchemaObject(schema) ? schema["x-enumNames"] : void 0);
759
- }
760
- function isStringLikeParameterSchema(schema, resolver) {
761
- if (!schema) return false;
762
- if (isReferenceObject(schema)) return resolver ? isStringLikeParameterSchema(resolver.resolveObject(schema), resolver) : true;
763
- if (schema.type === "string" || Array.isArray(schema.type) && schema.type.includes("string")) return true;
764
- return [
765
- ...schema.allOf ?? [],
766
- ...schema.oneOf ?? [],
767
- ...schema.anyOf ?? []
768
- ].some((compositeSchema) => isStringLikeParameterSchema(compositeSchema, resolver));
769
- }
770
- const isPathExcluded = (path, options) => {
771
- if (!options.excludePathRegex) return false;
772
- return new RegExp(options.excludePathRegex).test(path);
773
- };
774
- //#endregion
775
- //#region src/generators/utils/zod-schema.utils.ts
776
- const getZodSchemaName = (name, schemaSuffix) => suffixIfNeeded(capitalize(normalizeString(name)), schemaSuffix);
777
- const getEnumZodSchemaName = (name, enumSuffix, schemaSuffix) => suffixIfNeeded(capitalize(normalizeString(name)), `${enumSuffix}${schemaSuffix}`);
778
- const isNamedZodSchema = (schema) => ["z.", `${ZOD_EXTENDED.namespace}.`].every((searchString) => !schema.startsWith(searchString));
779
- const isEnumZodSchema = (schema) => schema.startsWith(ENUM_SCHEMA);
780
- const getZodSchemaOperationName = (operationName, isUniqueOperationName, tag) => isUniqueOperationName ? operationName : `${tag}_${operationName}`;
781
- const getBodyZodSchemaName = (operationName) => snakeToCamel(`${operationName}_${BODY_SCHEMA_SUFFIX}`);
782
- const getParamZodSchemaName = (operationName, paramName) => snakeToCamel(`${operationName}_${paramName}${PARAM_SCHEMA_SUFFIX}`);
783
- const getMainResponseZodSchemaName = (operationName) => snakeToCamel(`${operationName}${RESPONSE_SCHEMA_SUFFIX}`);
784
- const getErrorResponseZodSchemaName = (operationName, statusCode) => snakeToCamel(`${operationName}_${statusCode}_${ERROR_RESPONSE_SCHEMA_SUFFIX}`);
785
- function getResponseZodSchemaName({ statusCode, operationName, isUniqueOperationName, tag }) {
786
- const status = Number(statusCode);
787
- const zodSchemaOperationName = getZodSchemaOperationName(operationName, isUniqueOperationName, tag);
788
- if (!isMainResponseStatus(status) && statusCode !== "default" && isErrorStatus(status)) return getErrorResponseZodSchemaName(zodSchemaOperationName, statusCode);
789
- return getMainResponseZodSchemaName(zodSchemaOperationName);
790
- }
791
- //#endregion
792
- //#region src/generators/utils/generate/generate.openapi.utils.ts
793
- const schemaDescriptionsCache = /* @__PURE__ */ new WeakMap();
794
- function getSchemaDescriptions(schemaObj) {
795
- const cachedSchemaDescriptions = schemaDescriptionsCache.get(schemaObj);
796
- if (cachedSchemaDescriptions) return cachedSchemaDescriptions;
797
- const schemaDescriptions = [
798
- "minimum",
799
- "exclusiveMinimum",
800
- "maximum",
801
- "exclusiveMaximum",
802
- "minItems",
803
- "minLength",
804
- "minProperties",
805
- "maxItems",
806
- "maxLength",
807
- "maxProperties",
808
- "default",
809
- "example"
810
- ].filter((key) => schemaObj[key] !== void 0).reduce((acc, key) => [...acc, `${capitalize(camelToSpaceSeparated(key))}: \`${schemaObj[key]}\``], []);
811
- schemaDescriptionsCache.set(schemaObj, schemaDescriptions);
812
- return schemaDescriptions;
813
- }
814
- //#endregion
815
- //#region src/generators/utils/generate/generate.zod.utils.ts
816
- const getZodSchemaInferedTypeName = (zodSchemaName, options) => removeSuffix(zodSchemaName, options.schemaSuffix);
817
- const getImportedZodSchemaName = (resolver, zodSchemaName, namespaceTag) => {
818
- if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName;
819
- const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
820
- return `${resolver.options.tsNamespaces ? `${getNamespaceName({
821
- type: "models",
822
- tag,
823
- options: resolver.options
824
- })}.` : ""}${zodSchemaName}`;
825
- };
826
- function getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag) {
827
- if (namespaceTag && (resolver.options.modelsInCommon || resolver.options.modelsInModules) && resolver.options.splitByTags) return namespaceTag;
828
- return resolver.getTagByZodSchemaName(zodSchemaName) ?? namespaceTag;
829
- }
830
- const getImportedZodSchemaInferedTypeName = (resolver, zodSchemaName, currentTag, namespaceTag) => {
831
- if (!isNamedZodSchema(zodSchemaName)) return zodSchemaName === "z.void()" ? "void" : zodSchemaName;
832
- const tag = getOwningOrLocalProxyTag(resolver, zodSchemaName, namespaceTag);
833
- return `${resolver.options.tsNamespaces && (Boolean(namespaceTag) || tag !== currentTag) ? `${getNamespaceName({
834
- type: "models",
835
- tag,
836
- options: resolver.options
837
- })}.` : ""}${getZodSchemaInferedTypeName(zodSchemaName, resolver.options)}`;
838
- };
839
- function getZodSchemaType(data) {
840
- return data.isEnum ? "enum" : data.schemaObj?.type ?? "object";
841
- }
842
- function getZodSchemaDescription(data) {
843
- if (!data.schemaObj) return;
844
- return [data.schemaObj.description, ...getSchemaDescriptions(data.schemaObj)].filter(Boolean).join(". ");
845
- }
846
- function getType(resolver, schemaObj, tag) {
847
- if (isReferenceObject(schemaObj)) {
848
- const zodSchemaName = resolver.getZodSchemaNameByRef(schemaObj.$ref);
849
- return zodSchemaName ? getImportedZodSchemaInferedTypeName(resolver, zodSchemaName, tag) : void 0;
850
- }
851
- if (isArraySchemaObject(schemaObj)) {
852
- if (!isReferenceObject(schemaObj.items)) return `${schemaObj.items?.type ?? "unknown"}[]`;
853
- const zodSchemaName = resolver.getZodSchemaNameByRef(schemaObj.items.$ref);
854
- return zodSchemaName ? `${getImportedZodSchemaInferedTypeName(resolver, zodSchemaName, tag)}[]` : void 0;
855
- }
856
- if (COMPOSITE_KEYWORDS.some((prop) => prop in schemaObj && schemaObj[prop])) {
857
- const schemaObjs = schemaObj.allOf ?? schemaObj.anyOf ?? schemaObj.oneOf ?? [];
858
- if (schemaObjs.length > 0) return getType(resolver, schemaObjs[0], tag);
859
- }
860
- return schemaObj.type;
861
- }
862
- function getZodSchemaPropertyDescriptions(resolver, data, tag) {
863
- if (!data.schemaObj) return [];
864
- const ARRAY_INDEX = "[0]";
865
- const ADDITIONAL_PROPERTIES_KEY = "[key]";
866
- const properties = {};
867
- const onSchema = (schemaData) => {
868
- if (schemaData.type === "reference") return true;
869
- if (schemaData.type === "composite") return;
870
- const segments = [...schemaData.data?.pathSegments ?? []];
871
- if (schemaData.type === "array") segments.push(ARRAY_INDEX);
872
- else if (schemaData.type === "property") segments.push(schemaData.propertyName);
873
- else if (schemaData.type === "additionalProperties") segments.push(ADDITIONAL_PROPERTIES_KEY);
874
- if (schemaData.schema && segments[segments.length - 1] !== ARRAY_INDEX) {
875
- const resolvedSchema = resolver.resolveObject(schemaData.schema);
876
- const schemaDescriptions = [resolvedSchema?.description, ...getSchemaDescriptions(resolvedSchema)].filter(Boolean);
877
- const propertyKey = segments.join(".");
878
- if (!(properties[propertyKey] && "type" in schemaData.schema && schemaData.schema.type === "object")) {
879
- delete properties[propertyKey];
880
- properties[propertyKey] = {
881
- type: getType(resolver, schemaData.schema, tag) ?? "unknown",
882
- description: schemaDescriptions.join(". ")
883
- };
884
- }
885
- }
886
- iterateSchema(schemaData.schema, {
887
- data: { pathSegments: [...segments] },
888
- onSchema
889
- });
890
- return true;
891
- };
892
- if ("allOf" in data.schemaObj && data.schemaObj.allOf) data.schemaObj.allOf.forEach((schemaObj) => {
893
- if (isReferenceObject(schemaObj)) iterateSchema(resolver.resolveObject(schemaObj), {
894
- data: { pathSegments: [] },
895
- onSchema
896
- });
897
- });
898
- iterateSchema(data.schemaObj, {
899
- data: { pathSegments: [] },
900
- onSchema
901
- });
902
- return properties;
903
- }
904
- //#endregion
905
- //#region src/generators/utils/generate/generate.acl.utils.ts
906
- const getAbilityFunctionName = (endpoint) => `canUse${capitalize(snakeToCamel(endpoint.operationName))}`;
907
- const getImportedAbilityFunctionName = (endpoint, options) => {
908
- return `${options.tsNamespaces ? `${getNamespaceName({
909
- type: "acl",
910
- tag: getEndpointTag(endpoint, options),
911
- options
912
- })}.` : ""}${getAbilityFunctionName(endpoint)}`;
913
- };
914
- const getAbilityAction = (endpoint) => endpoint.acl?.[0].action;
915
- const getAbilitySubject = (endpoint) => endpoint.acl?.[0].subject;
916
- const hasAbilityConditions = (endpoint) => !!getAbilityConditionsTypes(endpoint)?.length;
917
- const getAbilityConditionsTypes = (endpoint) => endpoint.acl?.[0].conditionsTypes?.sort((a, b) => a.name.localeCompare(b.name));
918
- const getAbilityDescription = (endpoint) => endpoint.acl?.[0]?.description;
919
- const getAbilitySubjectTypes = (endpoint, resolver, tag) => {
920
- const abilitySubject = getAbilitySubject(endpoint);
921
- const types = [`"${abilitySubject ?? ""}"`];
922
- if (hasAbilityConditions(endpoint)) types.push(`ForcedSubject<"${abilitySubject}"> & { ${getAbilityConditionsTypes(endpoint)?.map((conditionType) => `${conditionType.name}${conditionType.required ? "" : "?"}: ${getAbilityConditionType(conditionType, resolver, tag)},`).join(" ")} }`);
923
- return types;
924
- };
925
- function getAbilityConditionType(conditionType, resolver, tag) {
926
- if (!conditionType.zodSchemaName) return conditionType.type ?? "";
927
- if (!resolver) return `${conditionType.type ?? ""}${conditionType.zodSchemaName}`;
928
- return getImportedZodSchemaInferedTypeName(resolver, conditionType.zodSchemaName, tag, tag);
929
- }
930
- function getAclData({ resolver, data, tag }) {
931
- const endpoints = data.get(tag)?.endpoints.filter(({ acl }) => acl && acl.length > 0);
932
- if (!endpoints || endpoints.length === 0) return;
933
- const hasAdditionalAbilityImports = endpoints.some(({ acl }) => acl?.[0].conditions && Object.keys(acl[0].conditions).length > 0);
934
- const aclZodSchemas = endpoints.reduce((acc, endpoint) => {
935
- const zodSchemas = endpoint.acl?.[0].conditionsTypes?.reduce((acc, propertyType) => [...acc, ...propertyType?.zodSchemaName ? [propertyType.zodSchemaName] : []], []);
936
- return [...acc, ...zodSchemas ?? []];
937
- }, []);
938
- return {
939
- endpoints,
940
- hasAdditionalAbilityImports,
941
- modelsImports: getModelsImports({
942
- resolver,
943
- tag,
944
- zodSchemasAsTypes: getUniqueArray(aclZodSchemas)
945
- })
946
- };
947
- }
948
- const getAppAbilitiesType = ({ resolver, data }) => {
949
- const appAbilitiesTypeMap = /* @__PURE__ */ new Map();
950
- const modelsImportsArr = [];
951
- let hasAdditionalAbilityImports = false;
952
- data.forEach((_, tag) => {
953
- const aclData = getAclData({
954
- resolver,
955
- data,
956
- tag
957
- });
958
- if (!aclData) return;
959
- const { modelsImports: tagModelsImports, hasAdditionalAbilityImports: tagHasAdditionalAbilityImports, endpoints } = aclData;
960
- modelsImportsArr.push(tagModelsImports);
961
- hasAdditionalAbilityImports = hasAdditionalAbilityImports || tagHasAdditionalAbilityImports;
962
- endpoints.forEach((endpoint) => {
963
- const abilityAction = getAbilityAction(endpoint);
964
- if (abilityAction) appAbilitiesTypeMap.set(abilityAction, /* @__PURE__ */ new Set([...appAbilitiesTypeMap.get(abilityAction) ?? [], ...getAbilitySubjectTypes(endpoint, resolver, tag)]));
965
- });
966
- });
967
- const modelsImports = mergeImports(resolver.options, ...modelsImportsArr);
968
- return {
969
- appAbilitiesType: appAbilitiesTypeMap.size > 0 ? Object.fromEntries(Array.from(appAbilitiesTypeMap.entries()).map(([key, valueSet]) => [key, Array.from(valueSet)])) : void 0,
970
- modelsImports,
971
- hasAdditionalAbilityImports
972
- };
973
- };
974
- /** Renders a `checkAcl(...)` call, passing the ability's conditions object only when the
975
- * ability function actually expects one (i.e. the endpoint declares matching conditions). */
976
- function renderAclCheckCall(resolver, endpoint, replacements, indent = "") {
977
- const checkParams = getAbilityConditionsTypes(endpoint)?.map((condition) => invalidVariableNameCharactersToCamel(condition.name));
978
- const paramNames = new Set(endpoint.parameters.map((param) => invalidVariableNameCharactersToCamel(param.name)));
979
- const hasAllCheckParams = checkParams?.every((param) => paramNames.has(param));
980
- const args = hasAbilityConditions(endpoint) && hasAllCheckParams ? `{ ${(checkParams ?? []).map((param) => {
981
- const resolvedParam = replacements?.[param] ?? param;
982
- return resolvedParam === param ? param : `${param}: ${resolvedParam}`;
983
- }).join(", ")} } ` : "";
984
- return `${indent}checkAcl(${getImportedAbilityFunctionName(endpoint, resolver.options)}(${args}));`;
985
- }
986
- //#endregion
987
- //#region src/generators/const/endpoints.const.ts
988
- const JSON_APPLICATION_FORMAT = "application/json";
989
- const DEFAULT_HEADERS = {
990
- "Content-Type": JSON_APPLICATION_FORMAT,
991
- Accept: JSON_APPLICATION_FORMAT
992
- };
993
- const BODY_PARAMETER_NAME = "data";
994
- const AXIOS_DEFAULT_IMPORT_NAME = "axios";
995
- const AXIOS_REQUEST_CONFIG_NAME = "config";
996
- const AXIOS_REQUEST_CONFIG_TYPE = "AxiosRequestConfig";
997
- const NATIVE_REQUEST_CONFIG_TYPE = "TransportRequestConfig";
998
- const NATIVE_RESPONSE_TYPE = "TransportResponse";
999
- const AXIOS_IMPORT = {
1000
- defaultImport: AXIOS_DEFAULT_IMPORT_NAME,
1001
- bindings: [],
1002
- typeBindings: [AXIOS_REQUEST_CONFIG_TYPE],
1003
- from: "axios"
1004
- };
1005
- function getRequestConfigTypeName(restClient) {
1006
- return restClient === "native" ? NATIVE_REQUEST_CONFIG_TYPE : AXIOS_REQUEST_CONFIG_TYPE;
1007
- }
1008
- //#endregion
1009
- //#region src/generators/utils/endpoint.utils.ts
1010
- const isGetEndpoint = (endpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET;
1011
- const isPaginatedGetEndpoint = (endpoint, options) => isGetEndpoint(endpoint) && Object.values(options.infiniteQueryParamNames).every((infiniteQueryParam) => endpoint.parameters.some((param) => param.name === infiniteQueryParam && param.type === "Query"));
1012
- const isReadAllEndpoint = (endpoint, options) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET && !isPathSegmentParam(endpoint.pathSegments.at(-1)) && isPaginatedGetEndpoint(endpoint, options);
1013
- const isReadEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
1014
- const isCreateEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.POST && hasMatchingPathWithoutTrailingParam(endpoint, readAllEndpoint);
1015
- const isUpdateEndpoint = (endpoint, readAllEndpoint) => [openapi_types.OpenAPIV3.HttpMethods.PUT, openapi_types.OpenAPIV3.HttpMethods.PATCH].includes(endpoint.method) && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
1016
- const isDeleteEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.DELETE && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
1017
- const isBulkDeleteEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.DELETE && hasMatchingPathWithoutTrailingParam(endpoint, readAllEndpoint);
1018
- const getPathSegments = (path) => path.split("/").filter(Boolean);
1019
- const isPathSegmentParam = (pathSegment) => pathSegment?.startsWith(":");
1020
- const hasMatchingPath = (endpoint, readAllEndpoint) => readAllEndpoint.pathSegments.every((segment, index) => isPathSegmentParam(segment) && isPathSegmentParam(endpoint.pathSegments[index]) || segment === endpoint.pathSegments[index]);
1021
- const hasMatchingPathWithoutTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length === readAllEndpoint.pathSegments.length && hasMatchingPath(endpoint, readAllEndpoint);
1022
- const hasMatchingPathWithTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length - 1 === readAllEndpoint.pathSegments.length && isPathSegmentParam(endpoint.pathSegments.at(-1)) && hasMatchingPath(endpoint, readAllEndpoint);
1023
- //#endregion
1024
- //#region src/generators/utils/query.utils.ts
1025
- const isQuery = (endpoint) => isGetEndpoint(endpoint);
1026
- const isMutation = (endpoint) => !isGetEndpoint(endpoint) || !!endpoint.mediaDownload;
1027
- const isInfiniteQuery = (endpoint, options) => isPaginatedGetEndpoint(endpoint, options);
1028
- const getDestructuredVariables = (resolver, endpoint, updateQueryEndpoints) => {
1029
- const requiredUpdateQueryParams = updateQueryEndpoints.reduce((acc, updateEndpoint) => [...acc, ...mapEndpointParamsToFunctionParams(resolver, updateEndpoint, { includeOnlyRequiredParams: true }).map((param) => param.name)], []);
1030
- return mapEndpointParamsToFunctionParams(resolver, endpoint, {
1031
- includeOnlyRequiredParams: true,
1032
- excludeBodyParam: true
1033
- }).filter((param) => requiredUpdateQueryParams.includes(param.name)).map((param) => param.name);
1034
- };
1035
- //#endregion
1036
- //#region src/generators/utils/ts.utils.ts
1037
- function primitiveTypeToTsType(type) {
1038
- switch (type) {
1039
- case "string": return "string";
1040
- case "number":
1041
- case "integer": return "number";
1042
- case "boolean": return "boolean";
1043
- }
1044
- }
1045
- //#endregion
1046
- //#region src/generators/utils/generate/generate.endpoints.utils.ts
1047
- const endpointNameCache = /* @__PURE__ */ new WeakMap();
1048
- const endpointPathCache = /* @__PURE__ */ new WeakMap();
1049
- const endpointBodyCache = /* @__PURE__ */ new WeakMap();
1050
- const endpointConfigCache = /* @__PURE__ */ new WeakMap();
1051
- const getEndpointName = (endpoint) => {
1052
- let name = endpointNameCache.get(endpoint);
1053
- if (name === void 0) {
1054
- name = decapitalize(snakeToCamel(endpoint.operationName));
1055
- endpointNameCache.set(endpoint, name);
1056
- }
1057
- return name;
1058
- };
1059
- function getImportedEndpointName(endpoint, options) {
1060
- return `${options.tsNamespaces ? `${getNamespaceName({
1061
- type: "endpoints",
1062
- tag: getEndpointTag(endpoint, options),
1063
- options
1064
- })}.` : ""}${getEndpointName(endpoint)}`;
1065
- }
1066
- const requiresBody = (endpoint) => endpoint.method !== openapi_types.OpenAPIV3.HttpMethods.GET;
1067
- const findEndpointBody = (endpoint) => endpoint.parameters.find((param) => param.type === "Body");
1068
- const getEndpointBody = (endpoint) => {
1069
- if (!endpointBodyCache.has(endpoint)) endpointBodyCache.set(endpoint, findEndpointBody(endpoint));
1070
- return endpointBodyCache.get(endpoint);
1071
- };
1072
- const hasEndpointConfig = (endpoint, resolver) => {
1073
- const endpointConfig = getEndpointConfig(endpoint);
1074
- const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
1075
- const needsBlobConfig = endpoint.mediaDownload || endpoint.response === "z.instanceof(Blob)";
1076
- return Object.keys(endpointConfig).length > 0 || hasAxiosRequestConfig || needsBlobConfig;
1077
- };
1078
- const getEndpointPath = (endpoint) => {
1079
- let endpointPath = endpointPathCache.get(endpoint);
1080
- if (endpointPath === void 0) {
1081
- endpointPath = endpoint.path.replace(/:([a-zA-Z0-9_]+)/g, "${$1}");
1082
- endpointPathCache.set(endpoint, endpointPath);
1083
- }
1084
- return endpointPath;
1085
- };
1086
- function mapEndpointParamsToFunctionParams(resolver, endpoint, options) {
1087
- const optionalPathParams = options?.optionalPathParams ? new Set(options.optionalPathParams) : void 0;
1088
- const params = endpoint.parameters.map((param) => {
1089
- let type = "string";
1090
- if (isNamedZodSchema(param.zodSchema)) type = getImportedZodSchemaInferedTypeName(resolver, param.zodSchema, void 0, options?.modelNamespaceTag);
1091
- else if (param.parameterObject?.schema && isSchemaObject(param.parameterObject.schema)) {
1092
- const openApiSchemaType = (param.parameterObject?.schema)?.type;
1093
- if (openApiSchemaType && isPrimitiveType(openApiSchemaType)) type = primitiveTypeToTsType(openApiSchemaType);
1094
- }
1095
- return {
1096
- name: invalidVariableNameCharactersToCamel(param.name),
1097
- type,
1098
- paramType: param.type,
1099
- required: param.parameterObject?.required ?? true,
1100
- parameterObject: param.parameterObject,
1101
- bodyObject: param.bodyObject
1102
- };
1103
- });
1104
- if (options?.includeFileParam && endpoint.mediaUpload) params.push({
1105
- name: "file",
1106
- type: "File",
1107
- paramType: "Body",
1108
- required: false,
1109
- parameterObject: void 0,
1110
- bodyObject: void 0
1111
- });
1112
- return params.toSorted((a, b) => {
1113
- if (a.required === b.required) {
1114
- const sortedParamTypes = [
1115
- "Path",
1116
- "Body",
1117
- "Query",
1118
- "Header"
1119
- ];
1120
- return sortedParamTypes.indexOf(a.paramType) - sortedParamTypes.indexOf(b.paramType);
1121
- }
1122
- return a.required ? -1 : 1;
1123
- }).filter((param) => (!options?.excludeBodyParam || param.name !== "data") && (!options?.excludePageParam || param.name !== resolver.options.infiniteQueryParamNames.page) && (!options?.includeOnlyRequiredParams || param.required) && (!options?.excludePathParams || param.paramType !== "Path")).map((param) => ({
1124
- ...param,
1125
- name: options?.replacePageParam && param.name === resolver.options.infiniteQueryParamNames.page ? "pageParam" : param.name,
1126
- required: param.paramType === "Path" && optionalPathParams?.has(param.name) ? false : param.required && (param.paramType === "Path" || !options?.pathParamsRequiredOnly)
1127
- }));
1128
- }
1129
- function getEndpointConfig(endpoint) {
1130
- let config = endpointConfigCache.get(endpoint);
1131
- if (!config) {
1132
- config = createEndpointConfig(endpoint);
1133
- endpointConfigCache.set(endpoint, config);
1134
- }
1135
- return config;
1136
- }
1137
- function createEndpointConfig(endpoint) {
1138
- const params = endpoint.parameters.filter((param) => param.type === "Query").map((param) => {
1139
- const paramPropertyName = isValidPropertyName(param.name) ? param.name : `"${param.name}"`;
1140
- const paramVariableName = invalidVariableNameCharactersToCamel(param.name);
1141
- return {
1142
- ...param,
1143
- name: paramPropertyName,
1144
- value: paramVariableName
1145
- };
1146
- });
1147
- const headers = {};
1148
- if (endpoint.requestFormat !== DEFAULT_HEADERS["Content-Type"]) headers["Content-Type"] = `'${endpoint.requestFormat}'`;
1149
- if (endpoint.responseFormat && endpoint.responseFormat !== DEFAULT_HEADERS.Accept) headers.Accept = `'${endpoint.responseFormat}'`;
1150
- endpoint.parameters.filter((param) => param.type === "Header").forEach((param) => {
1151
- headers[param.name] = invalidVariableNameCharactersToCamel(param.name);
1152
- });
1153
- return {
1154
- ...params.length > 0 ? { params } : {},
1155
- ...Object.keys(headers).length ? { headers } : {}
1156
- };
1157
- }
1158
- /** Renders the body of a media-upload mutationFn: call the endpoint (without the file arg) to
1159
- * get upload instructions, then upload the file itself to the returned URL. Shared between
1160
- * renderMutation (*.queries.ts) and renderMutationContent (*.configs.ts / builderConfigs) so
1161
- * both mutation paths stay in sync. Lines are relative to the caller's own indent. */
1162
- function renderMediaUploadMutationBody({ resolver, endpointFunction, resolvedEndpointArgs }) {
1163
- return [
1164
- `const uploadInstructions = await ${endpointFunction}(${resolvedEndpointArgs}${resolver.options.axiosRequestConfig ? `${resolvedEndpointArgs ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""});`,
1165
- "",
1166
- "if (file && uploadInstructions.url) {",
1167
- ` const method = (uploadInstructions.method?.toLowerCase() ?? "put") as "put" | "post";`,
1168
- " let dataToSend: File | FormData = file;",
1169
- " if (method === \"post\") {",
1170
- " dataToSend = new FormData();",
1171
- " if (uploadInstructions.fields) {",
1172
- " for (const [key, value] of uploadInstructions.fields) {",
1173
- " dataToSend.append(key, value);",
1174
- " }",
1175
- " }",
1176
- " dataToSend.append(\"file\", file);",
1177
- " }",
1178
- resolver.options.restClient === "native" ? " await AppRestClient.upload(uploadInstructions.url, dataToSend, {" : " await axios[method](uploadInstructions.url, dataToSend, {",
1179
- resolver.options.restClient === "native" ? " headers: method === \"put\" ? { \"Content-Type\": file.type } : undefined," : " headers: {",
1180
- ...resolver.options.restClient === "native" ? [] : [" \"Content-Type\": file.type,", " },"],
1181
- " signal: abortController?.signal,",
1182
- " onUploadProgress: onUploadProgress",
1183
- " ? (progressEvent) => onUploadProgress({ loaded: progressEvent.loaded, total: progressEvent.total ?? 0 })",
1184
- " : undefined,",
1185
- resolver.options.restClient === "native" ? " }, method);" : " });",
1186
- "}",
1187
- "",
1188
- "return uploadInstructions;"
1189
- ];
1190
- }
1191
- //#endregion
1192
- //#region src/generators/utils/generate/generate.query.utils.ts
1193
- const operationNameByEndpoint = /* @__PURE__ */ new WeakMap();
1194
- const capitalizedOperationNameByEndpoint = /* @__PURE__ */ new WeakMap();
1195
- function getOperationName(endpoint) {
1196
- let name = operationNameByEndpoint.get(endpoint);
1197
- if (name === void 0) {
1198
- name = snakeToCamel(endpoint.operationName);
1199
- operationNameByEndpoint.set(endpoint, name);
1200
- }
1201
- return name;
1202
- }
1203
- function getCapitalizedOperationName(endpoint) {
1204
- let name = capitalizedOperationNameByEndpoint.get(endpoint);
1205
- if (name === void 0) {
1206
- name = capitalize(getOperationName(endpoint));
1207
- capitalizedOperationNameByEndpoint.set(endpoint, name);
1208
- }
1209
- return name;
1210
- }
1211
- const getQueryName = (endpoint, mutation) => {
1212
- const addMutationSuffix = isQuery(endpoint) && isMutation(endpoint) && mutation;
1213
- return `use${getCapitalizedOperationName(endpoint)}${addMutationSuffix ? "Mutation" : ""}`;
1214
- };
1215
- const getInfiniteQueryName = (endpoint) => `use${getCapitalizedOperationName(endpoint)}Infinite`;
1216
- const getQueryOptionsName = (endpoint) => `${getOperationName(endpoint)}QueryOptions`;
1217
- const getInfiniteQueryOptionsName = (endpoint) => `${getOperationName(endpoint)}InfiniteQueryOptions`;
1218
- const getPrefetchQueryName = (endpoint) => `prefetch${getCapitalizedOperationName(endpoint)}`;
1219
- const getPrefetchInfiniteQueryName = (endpoint) => `prefetch${getCapitalizedOperationName(endpoint)}Infinite`;
1220
- const getImportedQueryName = (endpoint, options) => {
1221
- return `${options.tsNamespaces ? `${getNamespaceName({
1222
- type: "queries",
1223
- tag: getEndpointTag(endpoint, options),
1224
- options
1225
- })}.` : ""}${getQueryName(endpoint)}`;
1226
- };
1227
- const getImportedInfiniteQueryName = (endpoint, options) => {
1228
- return `${options.tsNamespaces ? `${getNamespaceName({
1229
- type: "queries",
1230
- tag: getEndpointTag(endpoint, options),
1231
- options
1232
- })}.` : ""}${getInfiniteQueryName(endpoint)}`;
1233
- };
1234
- //#endregion
1235
- //#region src/generators/utils/generate/generate.imports.utils.ts
1236
- function getModelsImports({ resolver, tag, zodSchemas = [], zodSchemasAsTypes = [] }) {
1237
- const type = "models";
1238
- const getTag = (zodSchemaName) => resolver.getTagByZodSchemaName(zodSchemaName);
1239
- const zodSchemaImports = getImports({
1240
- type,
1241
- tag,
1242
- entities: zodSchemas,
1243
- getTag,
1244
- getEntityName: (zodSchema) => zodSchema,
1245
- options: resolver.options
1246
- });
1247
- const zodSchemaTypeImports = getImports({
1248
- type,
1249
- tag,
1250
- entities: zodSchemasAsTypes,
1251
- getTag,
1252
- getEntityName: (zodSchema) => getZodSchemaInferedTypeName(zodSchema, resolver.options),
1253
- options: resolver.options
1254
- }).map((importData) => ({
1255
- ...importData,
1256
- ...resolver.options.tsNamespaces ? {} : { typeOnly: true }
1257
- }));
1258
- return mergeImports(resolver.options, zodSchemaImports, zodSchemaTypeImports);
1259
- }
1260
- function getEndpointsImports({ tag, endpoints, options }) {
1261
- return getImports({
1262
- type: "endpoints",
1263
- tag,
1264
- entities: endpoints,
1265
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1266
- getEntityName: getEndpointName,
1267
- options
1268
- });
1269
- }
1270
- function getQueriesImports({ tag, endpoints, options }) {
1271
- return getImports({
1272
- type: "queries",
1273
- tag,
1274
- entities: endpoints,
1275
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1276
- getEntityName: getQueryName,
1277
- options
1278
- });
1279
- }
1280
- function getInfiniteQueriesImports({ tag, endpoints, options }) {
1281
- return getImports({
1282
- type: "queries",
1283
- tag,
1284
- entities: endpoints,
1285
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1286
- getEntityName: getInfiniteQueryName,
1287
- options
1288
- });
1289
- }
1290
- function getAclImports({ tag, endpoints, options }) {
1291
- return getImports({
1292
- type: "acl",
1293
- tag,
1294
- entities: endpoints,
1295
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1296
- getEntityName: getAbilityFunctionName,
1297
- options
1298
- });
1299
- }
1300
- function getImportPath(options, fromRoot = false) {
1301
- let importPath = options.tsPath;
1302
- if (options.importPath === "relative") importPath = fromRoot ? "./" : "../";
1303
- else if (options.importPath === "absolute") importPath = options.output;
1304
- else if (new RegExp(`src/data`, "g").test(options.output)) importPath = options.output.replace(new RegExp(`.*${TEMPLATE_DATA_FILE_PATH}`, "g"), options.tsPath);
1305
- return `${importPath}/`.replace(/\/\//g, "/");
1306
- }
1307
- function getImports({ type = "models", tag: currentTag, entities, getTag, getEntityName, options }) {
1308
- const imports = /* @__PURE__ */ new Map();
1309
- entities.forEach((entity) => {
1310
- const tag = type === "models" && (options.modelsInCommon || options.modelsInModules) && options.splitByTags ? currentTag : getTag(entity);
1311
- if (!imports.has(tag)) {
1312
- const sameTagDir = currentTag === tag;
1313
- imports.set(tag, {
1314
- bindings: [options.tsNamespaces ? getNamespaceName({
1315
- type,
1316
- tag,
1317
- options
1318
- }) : getEntityName(entity)],
1319
- from: `${sameTagDir ? "./" : getImportPath(options)}${getTagImportPath({
1320
- type,
1321
- tag,
1322
- includeTagDir: !sameTagDir,
1323
- options
1324
- })}`
1325
- });
1326
- } else if (!options.tsNamespaces) imports.get(tag).bindings.push(getEntityName(entity));
1327
- });
1328
- return Array.from(imports.values());
1329
- }
1330
- function mergeImports(options, ...importArrs) {
1331
- const merged = /* @__PURE__ */ new Map();
1332
- importArrs.forEach((imports) => {
1333
- imports.forEach((importItem) => {
1334
- if (!merged.has(importItem.from)) merged.set(importItem.from, {
1335
- ...importItem,
1336
- bindings: importItem.typeOnly ? [] : [...importItem.bindings],
1337
- typeBindings: [...importItem.typeBindings ?? [], ...importItem.typeOnly ? importItem.bindings : []]
1338
- });
1339
- else {
1340
- const existing = merged.get(importItem.from);
1341
- if (!options.tsNamespaces && !importItem.typeOnly) existing.bindings.push(...importItem.bindings);
1342
- existing.typeBindings = [
1343
- ...existing.typeBindings ?? [],
1344
- ...importItem.typeBindings ?? [],
1345
- ...importItem.typeOnly ? importItem.bindings : []
1346
- ];
1347
- existing.typeOnly = false;
1348
- }
1349
- });
1350
- });
1351
- return Array.from(merged.values()).map((importItem) => ({
1352
- ...importItem,
1353
- bindings: getUniqueArray(importItem.bindings),
1354
- typeBindings: getUniqueArray(importItem.typeBindings ?? []).filter((binding) => !importItem.bindings.includes(binding)),
1355
- typeOnly: Boolean(importItem.typeOnly && importItem.bindings.length === 0 && (importItem.typeBindings?.length ?? 0) > 0)
1356
- }));
1357
- }
1358
- //#endregion
1359
- //#region src/generators/utils/generate/generate.utils.ts
1360
- function getFileNameWithExtension({ fileName, extension }) {
1361
- return `${fileName}.${extension}`;
1362
- }
1363
- function getTagFileNameWithoutExtension({ type, tag, options, includeTagDir = true }) {
1364
- const outputFileNameSuffix = options.configs[type].outputFileNameSuffix;
1365
- if (!tag) return outputFileNameSuffix;
1366
- return `${includeTagDir ? `${decapitalize(tag)}/` : ""}${decapitalize(tag)}.${outputFileNameSuffix}`;
1367
- }
1368
- function getTagImportPath(...args) {
1369
- return getTagFileNameWithoutExtension(...args);
1370
- }
1371
- function getTagFileName(...args) {
1372
- return `${getTagFileNameWithoutExtension(...args)}.ts`;
1373
- }
1374
- function getAppRestClientImportPath(options) {
1375
- if (options.restClientImportPath === DEFAULT_GENERATE_OPTIONS.restClientImportPath) return `${getImportPath(options)}${APP_REST_CLIENT_FILE.fileName}`;
1376
- return options.restClientImportPath;
1377
- }
1378
- function getQueryModulesImportPath(options) {
1379
- return `${getImportPath(options)}${QUERY_MODULES_FILE.fileName}`;
1380
- }
1381
- function getQueryTypesImportPath(options) {
1382
- return options.queryTypesImportPath;
1383
- }
1384
- //#endregion
1385
- Object.defineProperty(exports, "ACL_APP_ABILITIES", {
1386
- enumerable: true,
1387
- get: function() {
1388
- return ACL_APP_ABILITIES;
1389
- }
1390
- });
1391
- Object.defineProperty(exports, "ACL_APP_ABILITY_FILE", {
1392
- enumerable: true,
1393
- get: function() {
1394
- return ACL_APP_ABILITY_FILE;
1395
- }
1396
- });
1397
- Object.defineProperty(exports, "ACL_CHECK_HOOK", {
1398
- enumerable: true,
1399
- get: function() {
1400
- return ACL_CHECK_HOOK;
1401
- }
1402
- });
1403
- Object.defineProperty(exports, "ALLOWED_METHODS", {
1404
- enumerable: true,
1405
- get: function() {
1406
- return ALLOWED_METHODS;
1407
- }
1408
- });
1409
- Object.defineProperty(exports, "ALLOWED_PATH_IN", {
1410
- enumerable: true,
1411
- get: function() {
1412
- return ALLOWED_PATH_IN;
1413
- }
1414
- });
1415
- Object.defineProperty(exports, "ANY_SCHEMA", {
1416
- enumerable: true,
1417
- get: function() {
1418
- return ANY_SCHEMA;
1419
- }
1420
- });
1421
- Object.defineProperty(exports, "APP_REST_CLIENT_FILE", {
1422
- enumerable: true,
1423
- get: function() {
1424
- return APP_REST_CLIENT_FILE;
1425
- }
1426
- });
1427
- Object.defineProperty(exports, "APP_REST_CLIENT_NAME", {
1428
- enumerable: true,
1429
- get: function() {
1430
- return APP_REST_CLIENT_NAME;
1431
- }
1432
- });
1433
- Object.defineProperty(exports, "AXIOS_DEFAULT_IMPORT_NAME", {
1434
- enumerable: true,
1435
- get: function() {
1436
- return AXIOS_DEFAULT_IMPORT_NAME;
1437
- }
1438
- });
1439
- Object.defineProperty(exports, "AXIOS_IMPORT", {
1440
- enumerable: true,
1441
- get: function() {
1442
- return AXIOS_IMPORT;
1443
- }
1444
- });
1445
- Object.defineProperty(exports, "AXIOS_REQUEST_CONFIG_NAME", {
1446
- enumerable: true,
1447
- get: function() {
1448
- return AXIOS_REQUEST_CONFIG_NAME;
1449
- }
1450
- });
1451
- Object.defineProperty(exports, "AXIOS_REQUEST_CONFIG_TYPE", {
1452
- enumerable: true,
1453
- get: function() {
1454
- return AXIOS_REQUEST_CONFIG_TYPE;
1455
- }
1456
- });
1457
- Object.defineProperty(exports, "BLOB_SCHEMA", {
1458
- enumerable: true,
1459
- get: function() {
1460
- return BLOB_SCHEMA;
1461
- }
1462
- });
1463
- Object.defineProperty(exports, "BODY_PARAMETER_NAME", {
1464
- enumerable: true,
1465
- get: function() {
1466
- return BODY_PARAMETER_NAME;
1467
- }
1468
- });
1469
- Object.defineProperty(exports, "BUILDERS_UTILS", {
1470
- enumerable: true,
1471
- get: function() {
1472
- return BUILDERS_UTILS;
1473
- }
1474
- });
1475
- Object.defineProperty(exports, "CASL_ABILITY_BINDING", {
1476
- enumerable: true,
1477
- get: function() {
1478
- return CASL_ABILITY_BINDING;
1479
- }
1480
- });
1481
- Object.defineProperty(exports, "CASL_ABILITY_IMPORT", {
1482
- enumerable: true,
1483
- get: function() {
1484
- return CASL_ABILITY_IMPORT;
1485
- }
1486
- });
1487
- Object.defineProperty(exports, "DATETIME_SCHEMA", {
1488
- enumerable: true,
1489
- get: function() {
1490
- return DATETIME_SCHEMA;
1491
- }
1492
- });
1493
- Object.defineProperty(exports, "DEFAULT_GENERATE_OPTIONS", {
1494
- enumerable: true,
1495
- get: function() {
1496
- return DEFAULT_GENERATE_OPTIONS;
1497
- }
1498
- });
1499
- Object.defineProperty(exports, "DOMAIN_ERRORS_FILE", {
1500
- enumerable: true,
1501
- get: function() {
1502
- return DOMAIN_ERRORS_FILE;
1503
- }
1504
- });
1505
- Object.defineProperty(exports, "EMAIL_SCHEMA", {
1506
- enumerable: true,
1507
- get: function() {
1508
- return EMAIL_SCHEMA;
1509
- }
1510
- });
1511
- Object.defineProperty(exports, "ENUM_SCHEMA", {
1512
- enumerable: true,
1513
- get: function() {
1514
- return ENUM_SCHEMA;
1515
- }
1516
- });
1517
- Object.defineProperty(exports, "INT_SCHEMA", {
1518
- enumerable: true,
1519
- get: function() {
1520
- return INT_SCHEMA;
1521
- }
1522
- });
1523
- Object.defineProperty(exports, "JSON_APPLICATION_FORMAT", {
1524
- enumerable: true,
1525
- get: function() {
1526
- return JSON_APPLICATION_FORMAT;
1527
- }
1528
- });
1529
- Object.defineProperty(exports, "MUTATION_EFFECTS", {
1530
- enumerable: true,
1531
- get: function() {
1532
- return MUTATION_EFFECTS;
1533
- }
1534
- });
1535
- Object.defineProperty(exports, "NATIVE_PACKAGE_IMPORT_PATH", {
1536
- enumerable: true,
1537
- get: function() {
1538
- return NATIVE_PACKAGE_IMPORT_PATH;
1539
- }
1540
- });
1541
- Object.defineProperty(exports, "NATIVE_RESPONSE_TYPE", {
1542
- enumerable: true,
1543
- get: function() {
1544
- return NATIVE_RESPONSE_TYPE;
1545
- }
1546
- });
1547
- Object.defineProperty(exports, "NUMBER_SCHEMA", {
1548
- enumerable: true,
1549
- get: function() {
1550
- return NUMBER_SCHEMA;
1551
- }
1552
- });
1553
- Object.defineProperty(exports, "PACKAGE_IMPORT_PATH", {
1554
- enumerable: true,
1555
- get: function() {
1556
- return PACKAGE_IMPORT_PATH;
1557
- }
1558
- });
1559
- Object.defineProperty(exports, "Profiler", {
1560
- enumerable: true,
1561
- get: function() {
1562
- return Profiler;
1563
- }
1564
- });
1565
- Object.defineProperty(exports, "QUERY_MODULES_FILE", {
1566
- enumerable: true,
1567
- get: function() {
1568
- return QUERY_MODULES_FILE;
1569
- }
1570
- });
1571
- Object.defineProperty(exports, "QUERY_MODULE_ENUM", {
1572
- enumerable: true,
1573
- get: function() {
1574
- return QUERY_MODULE_ENUM;
1575
- }
1576
- });
1577
- Object.defineProperty(exports, "QUERY_OPTIONS_TYPES", {
1578
- enumerable: true,
1579
- get: function() {
1580
- return QUERY_OPTIONS_TYPES;
1581
- }
1582
- });
1583
- Object.defineProperty(exports, "REST_PACKAGE_IMPORT_PATH", {
1584
- enumerable: true,
1585
- get: function() {
1586
- return REST_PACKAGE_IMPORT_PATH;
1587
- }
1588
- });
1589
- Object.defineProperty(exports, "STRING_SCHEMA", {
1590
- enumerable: true,
1591
- get: function() {
1592
- return STRING_SCHEMA;
1593
- }
1594
- });
1595
- Object.defineProperty(exports, "URL_SCHEMA", {
1596
- enumerable: true,
1597
- get: function() {
1598
- return URL_SCHEMA;
1599
- }
1600
- });
1601
- Object.defineProperty(exports, "UUID_SCHEMA", {
1602
- enumerable: true,
1603
- get: function() {
1604
- return UUID_SCHEMA;
1605
- }
1606
- });
1607
- Object.defineProperty(exports, "VOID_SCHEMA", {
1608
- enumerable: true,
1609
- get: function() {
1610
- return VOID_SCHEMA;
1611
- }
1612
- });
1613
- Object.defineProperty(exports, "ZOD_EXTENDED", {
1614
- enumerable: true,
1615
- get: function() {
1616
- return ZOD_EXTENDED;
1617
- }
1618
- });
1619
- Object.defineProperty(exports, "ZOD_IMPORT", {
1620
- enumerable: true,
1621
- get: function() {
1622
- return ZOD_IMPORT;
1623
- }
1624
- });
1625
- Object.defineProperty(exports, "__toESM", {
1626
- enumerable: true,
1627
- get: function() {
1628
- return __toESM;
1629
- }
1630
- });
1631
- Object.defineProperty(exports, "autocorrectRef", {
1632
- enumerable: true,
1633
- get: function() {
1634
- return autocorrectRef;
1635
- }
1636
- });
1637
- Object.defineProperty(exports, "camelToSpaceSeparated", {
1638
- enumerable: true,
1639
- get: function() {
1640
- return camelToSpaceSeparated;
1641
- }
1642
- });
1643
- Object.defineProperty(exports, "capitalize", {
1644
- enumerable: true,
1645
- get: function() {
1646
- return capitalize;
1647
- }
1648
- });
1649
- Object.defineProperty(exports, "compileNativeData", {
1650
- enumerable: true,
1651
- get: function() {
1652
- return compileNativeData;
1653
- }
1654
- });
1655
- Object.defineProperty(exports, "decapitalize", {
1656
- enumerable: true,
1657
- get: function() {
1658
- return decapitalize;
1659
- }
1660
- });
1661
- Object.defineProperty(exports, "deepMerge", {
1662
- enumerable: true,
1663
- get: function() {
1664
- return deepMerge;
1665
- }
1666
- });
1667
- Object.defineProperty(exports, "escapeControlCharacters", {
1668
- enumerable: true,
1669
- get: function() {
1670
- return escapeControlCharacters;
1671
- }
1672
- });
1673
- Object.defineProperty(exports, "formatTag", {
1674
- enumerable: true,
1675
- get: function() {
1676
- return formatTag;
1677
- }
1678
- });
1679
- Object.defineProperty(exports, "getAbilityAction", {
1680
- enumerable: true,
1681
- get: function() {
1682
- return getAbilityAction;
1683
- }
1684
- });
1685
- Object.defineProperty(exports, "getAbilityConditionType", {
1686
- enumerable: true,
1687
- get: function() {
1688
- return getAbilityConditionType;
1689
- }
1690
- });
1691
- Object.defineProperty(exports, "getAbilityConditionsTypes", {
1692
- enumerable: true,
1693
- get: function() {
1694
- return getAbilityConditionsTypes;
1695
- }
1696
- });
1697
- Object.defineProperty(exports, "getAbilityDescription", {
1698
- enumerable: true,
1699
- get: function() {
1700
- return getAbilityDescription;
1701
- }
1702
- });
1703
- Object.defineProperty(exports, "getAbilityFunctionName", {
1704
- enumerable: true,
1705
- get: function() {
1706
- return getAbilityFunctionName;
1707
- }
1708
- });
1709
- Object.defineProperty(exports, "getAbilitySubject", {
1710
- enumerable: true,
1711
- get: function() {
1712
- return getAbilitySubject;
1713
- }
1714
- });
1715
- Object.defineProperty(exports, "getAbilitySubjectTypes", {
1716
- enumerable: true,
1717
- get: function() {
1718
- return getAbilitySubjectTypes;
1719
- }
1720
- });
1721
- Object.defineProperty(exports, "getAclData", {
1722
- enumerable: true,
1723
- get: function() {
1724
- return getAclData;
1725
- }
1726
- });
1727
- Object.defineProperty(exports, "getAclImports", {
1728
- enumerable: true,
1729
- get: function() {
1730
- return getAclImports;
1731
- }
1732
- });
1733
- Object.defineProperty(exports, "getAppAbilitiesType", {
1734
- enumerable: true,
1735
- get: function() {
1736
- return getAppAbilitiesType;
1737
- }
1738
- });
1739
- Object.defineProperty(exports, "getAppRestClientImportPath", {
1740
- enumerable: true,
1741
- get: function() {
1742
- return getAppRestClientImportPath;
1743
- }
1744
- });
1745
- Object.defineProperty(exports, "getBodyZodSchemaName", {
1746
- enumerable: true,
1747
- get: function() {
1748
- return getBodyZodSchemaName;
1749
- }
1750
- });
1751
- Object.defineProperty(exports, "getDestructuredVariables", {
1752
- enumerable: true,
1753
- get: function() {
1754
- return getDestructuredVariables;
1755
- }
1756
- });
1757
- Object.defineProperty(exports, "getEndpointBody", {
1758
- enumerable: true,
1759
- get: function() {
1760
- return getEndpointBody;
1761
- }
1762
- });
1763
- Object.defineProperty(exports, "getEndpointConfig", {
1764
- enumerable: true,
1765
- get: function() {
1766
- return getEndpointConfig;
1767
- }
1768
- });
1769
- Object.defineProperty(exports, "getEndpointName", {
1770
- enumerable: true,
1771
- get: function() {
1772
- return getEndpointName;
1773
- }
1774
- });
1775
- Object.defineProperty(exports, "getEndpointPath", {
1776
- enumerable: true,
1777
- get: function() {
1778
- return getEndpointPath;
1779
- }
1780
- });
1781
- Object.defineProperty(exports, "getEndpointTag", {
1782
- enumerable: true,
1783
- get: function() {
1784
- return getEndpointTag;
1785
- }
1786
- });
1787
- Object.defineProperty(exports, "getEndpointsImports", {
1788
- enumerable: true,
1789
- get: function() {
1790
- return getEndpointsImports;
1791
- }
1792
- });
1793
- Object.defineProperty(exports, "getEnumZodSchemaName", {
1794
- enumerable: true,
1795
- get: function() {
1796
- return getEnumZodSchemaName;
1797
- }
1798
- });
1799
- Object.defineProperty(exports, "getFileNameWithExtension", {
1800
- enumerable: true,
1801
- get: function() {
1802
- return getFileNameWithExtension;
1803
- }
1804
- });
1805
- Object.defineProperty(exports, "getImportPath", {
1806
- enumerable: true,
1807
- get: function() {
1808
- return getImportPath;
1809
- }
1810
- });
1811
- Object.defineProperty(exports, "getImportedAbilityFunctionName", {
1812
- enumerable: true,
1813
- get: function() {
1814
- return getImportedAbilityFunctionName;
1815
- }
1816
- });
1817
- Object.defineProperty(exports, "getImportedEndpointName", {
1818
- enumerable: true,
1819
- get: function() {
1820
- return getImportedEndpointName;
1821
- }
1822
- });
1823
- Object.defineProperty(exports, "getImportedInfiniteQueryName", {
1824
- enumerable: true,
1825
- get: function() {
1826
- return getImportedInfiniteQueryName;
1827
- }
1828
- });
1829
- Object.defineProperty(exports, "getImportedQueryName", {
1830
- enumerable: true,
1831
- get: function() {
1832
- return getImportedQueryName;
1833
- }
1834
- });
1835
- Object.defineProperty(exports, "getImportedZodSchemaInferedTypeName", {
1836
- enumerable: true,
1837
- get: function() {
1838
- return getImportedZodSchemaInferedTypeName;
1839
- }
1840
- });
1841
- Object.defineProperty(exports, "getImportedZodSchemaName", {
1842
- enumerable: true,
1843
- get: function() {
1844
- return getImportedZodSchemaName;
1845
- }
1846
- });
1847
- Object.defineProperty(exports, "getInfiniteQueriesImports", {
1848
- enumerable: true,
1849
- get: function() {
1850
- return getInfiniteQueriesImports;
1851
- }
1852
- });
1853
- Object.defineProperty(exports, "getInfiniteQueryName", {
1854
- enumerable: true,
1855
- get: function() {
1856
- return getInfiniteQueryName;
1857
- }
1858
- });
1859
- Object.defineProperty(exports, "getInfiniteQueryOptionsName", {
1860
- enumerable: true,
1861
- get: function() {
1862
- return getInfiniteQueryOptionsName;
1863
- }
1864
- });
1865
- Object.defineProperty(exports, "getModelsImports", {
1866
- enumerable: true,
1867
- get: function() {
1868
- return getModelsImports;
1869
- }
1870
- });
1871
- Object.defineProperty(exports, "getMostCommonAdjacentCombinationSplit", {
1872
- enumerable: true,
1873
- get: function() {
1874
- return getMostCommonAdjacentCombinationSplit;
1875
- }
1876
- });
1877
- Object.defineProperty(exports, "getNamespaceName", {
1878
- enumerable: true,
1879
- get: function() {
1880
- return getNamespaceName;
1881
- }
1882
- });
1883
- Object.defineProperty(exports, "getOperationTag", {
1884
- enumerable: true,
1885
- get: function() {
1886
- return getOperationTag;
1887
- }
1888
- });
1889
- Object.defineProperty(exports, "getOutputFileName", {
1890
- enumerable: true,
1891
- get: function() {
1892
- return getOutputFileName;
1893
- }
1894
- });
1895
- Object.defineProperty(exports, "getParamZodSchemaName", {
1896
- enumerable: true,
1897
- get: function() {
1898
- return getParamZodSchemaName;
1899
- }
1900
- });
1901
- Object.defineProperty(exports, "getParameterEnumNames", {
1902
- enumerable: true,
1903
- get: function() {
1904
- return getParameterEnumNames;
1905
- }
1906
- });
1907
- Object.defineProperty(exports, "getPathSegments", {
1908
- enumerable: true,
1909
- get: function() {
1910
- return getPathSegments;
1911
- }
1912
- });
1913
- Object.defineProperty(exports, "getPrefetchInfiniteQueryName", {
1914
- enumerable: true,
1915
- get: function() {
1916
- return getPrefetchInfiniteQueryName;
1917
- }
1918
- });
1919
- Object.defineProperty(exports, "getPrefetchQueryName", {
1920
- enumerable: true,
1921
- get: function() {
1922
- return getPrefetchQueryName;
1923
- }
1924
- });
1925
- Object.defineProperty(exports, "getQueriesImports", {
1926
- enumerable: true,
1927
- get: function() {
1928
- return getQueriesImports;
1929
- }
1930
- });
1931
- Object.defineProperty(exports, "getQueryModulesImportPath", {
1932
- enumerable: true,
1933
- get: function() {
1934
- return getQueryModulesImportPath;
1935
- }
1936
- });
1937
- Object.defineProperty(exports, "getQueryName", {
1938
- enumerable: true,
1939
- get: function() {
1940
- return getQueryName;
1941
- }
1942
- });
1943
- Object.defineProperty(exports, "getQueryOptionsName", {
1944
- enumerable: true,
1945
- get: function() {
1946
- return getQueryOptionsName;
1947
- }
1948
- });
1949
- Object.defineProperty(exports, "getQueryTypesImportPath", {
1950
- enumerable: true,
1951
- get: function() {
1952
- return getQueryTypesImportPath;
1953
- }
1954
- });
1955
- Object.defineProperty(exports, "getRequestConfigTypeName", {
1956
- enumerable: true,
1957
- get: function() {
1958
- return getRequestConfigTypeName;
1959
- }
1960
- });
1961
- Object.defineProperty(exports, "getResponseZodSchemaName", {
1962
- enumerable: true,
1963
- get: function() {
1964
- return getResponseZodSchemaName;
1965
- }
1966
- });
1967
- Object.defineProperty(exports, "getSchemaDescriptions", {
1968
- enumerable: true,
1969
- get: function() {
1970
- return getSchemaDescriptions;
1971
- }
1972
- });
1973
- Object.defineProperty(exports, "getSchemaNameByRef", {
1974
- enumerable: true,
1975
- get: function() {
1976
- return getSchemaNameByRef;
1977
- }
1978
- });
1979
- Object.defineProperty(exports, "getSchemaRef", {
1980
- enumerable: true,
1981
- get: function() {
1982
- return getSchemaRef;
1983
- }
1984
- });
1985
- Object.defineProperty(exports, "getTagFileName", {
1986
- enumerable: true,
1987
- get: function() {
1988
- return getTagFileName;
1989
- }
1990
- });
1991
- Object.defineProperty(exports, "getTagImportPath", {
1992
- enumerable: true,
1993
- get: function() {
1994
- return getTagImportPath;
1995
- }
1996
- });
1997
- Object.defineProperty(exports, "getUniqueArray", {
1998
- enumerable: true,
1999
- get: function() {
2000
- return getUniqueArray;
2001
- }
2002
- });
2003
- Object.defineProperty(exports, "getZodSchemaDescription", {
2004
- enumerable: true,
2005
- get: function() {
2006
- return getZodSchemaDescription;
2007
- }
2008
- });
2009
- Object.defineProperty(exports, "getZodSchemaInferedTypeName", {
2010
- enumerable: true,
2011
- get: function() {
2012
- return getZodSchemaInferedTypeName;
2013
- }
2014
- });
2015
- Object.defineProperty(exports, "getZodSchemaName", {
2016
- enumerable: true,
2017
- get: function() {
2018
- return getZodSchemaName;
2019
- }
2020
- });
2021
- Object.defineProperty(exports, "getZodSchemaOperationName", {
2022
- enumerable: true,
2023
- get: function() {
2024
- return getZodSchemaOperationName;
2025
- }
2026
- });
2027
- Object.defineProperty(exports, "getZodSchemaPropertyDescriptions", {
2028
- enumerable: true,
2029
- get: function() {
2030
- return getZodSchemaPropertyDescriptions;
2031
- }
2032
- });
2033
- Object.defineProperty(exports, "getZodSchemaType", {
2034
- enumerable: true,
2035
- get: function() {
2036
- return getZodSchemaType;
2037
- }
2038
- });
2039
- Object.defineProperty(exports, "hasAbilityConditions", {
2040
- enumerable: true,
2041
- get: function() {
2042
- return hasAbilityConditions;
2043
- }
2044
- });
2045
- Object.defineProperty(exports, "hasEndpointConfig", {
2046
- enumerable: true,
2047
- get: function() {
2048
- return hasEndpointConfig;
2049
- }
2050
- });
2051
- Object.defineProperty(exports, "inferRequiredSchema", {
2052
- enumerable: true,
2053
- get: function() {
2054
- return inferRequiredSchema;
2055
- }
2056
- });
2057
- Object.defineProperty(exports, "invalidVariableNameCharactersToCamel", {
2058
- enumerable: true,
2059
- get: function() {
2060
- return invalidVariableNameCharactersToCamel;
2061
- }
2062
- });
2063
- Object.defineProperty(exports, "isArraySchemaObject", {
2064
- enumerable: true,
2065
- get: function() {
2066
- return isArraySchemaObject;
2067
- }
2068
- });
2069
- Object.defineProperty(exports, "isBulkDeleteEndpoint", {
2070
- enumerable: true,
2071
- get: function() {
2072
- return isBulkDeleteEndpoint;
2073
- }
2074
- });
2075
- Object.defineProperty(exports, "isCreateEndpoint", {
2076
- enumerable: true,
2077
- get: function() {
2078
- return isCreateEndpoint;
2079
- }
2080
- });
2081
- Object.defineProperty(exports, "isDeleteEndpoint", {
2082
- enumerable: true,
2083
- get: function() {
2084
- return isDeleteEndpoint;
2085
- }
2086
- });
2087
- Object.defineProperty(exports, "isEnumZodSchema", {
2088
- enumerable: true,
2089
- get: function() {
2090
- return isEnumZodSchema;
2091
- }
2092
- });
2093
- Object.defineProperty(exports, "isErrorStatus", {
2094
- enumerable: true,
2095
- get: function() {
2096
- return isErrorStatus;
2097
- }
2098
- });
2099
- Object.defineProperty(exports, "isInfiniteQuery", {
2100
- enumerable: true,
2101
- get: function() {
2102
- return isInfiniteQuery;
2103
- }
2104
- });
2105
- Object.defineProperty(exports, "isMainResponseStatus", {
2106
- enumerable: true,
2107
- get: function() {
2108
- return isMainResponseStatus;
2109
- }
2110
- });
2111
- Object.defineProperty(exports, "isMediaTypeAllowed", {
2112
- enumerable: true,
2113
- get: function() {
2114
- return isMediaTypeAllowed;
2115
- }
2116
- });
2117
- Object.defineProperty(exports, "isMutation", {
2118
- enumerable: true,
2119
- get: function() {
2120
- return isMutation;
2121
- }
2122
- });
2123
- Object.defineProperty(exports, "isNamedZodSchema", {
2124
- enumerable: true,
2125
- get: function() {
2126
- return isNamedZodSchema;
2127
- }
2128
- });
2129
- Object.defineProperty(exports, "isParamMediaTypeAllowed", {
2130
- enumerable: true,
2131
- get: function() {
2132
- return isParamMediaTypeAllowed;
2133
- }
2134
- });
2135
- Object.defineProperty(exports, "isPathExcluded", {
2136
- enumerable: true,
2137
- get: function() {
2138
- return isPathExcluded;
2139
- }
2140
- });
2141
- Object.defineProperty(exports, "isPathSegmentParam", {
2142
- enumerable: true,
2143
- get: function() {
2144
- return isPathSegmentParam;
2145
- }
2146
- });
2147
- Object.defineProperty(exports, "isPrimitiveType", {
2148
- enumerable: true,
2149
- get: function() {
2150
- return isPrimitiveType;
2151
- }
2152
- });
2153
- Object.defineProperty(exports, "isQuery", {
2154
- enumerable: true,
2155
- get: function() {
2156
- return isQuery;
2157
- }
2158
- });
2159
- Object.defineProperty(exports, "isReadAllEndpoint", {
2160
- enumerable: true,
2161
- get: function() {
2162
- return isReadAllEndpoint;
2163
- }
2164
- });
2165
- Object.defineProperty(exports, "isReadEndpoint", {
2166
- enumerable: true,
2167
- get: function() {
2168
- return isReadEndpoint;
2169
- }
2170
- });
2171
- Object.defineProperty(exports, "isReferenceObject", {
2172
- enumerable: true,
2173
- get: function() {
2174
- return isReferenceObject;
2175
- }
2176
- });
2177
- Object.defineProperty(exports, "isSchemaObject", {
2178
- enumerable: true,
2179
- get: function() {
2180
- return isSchemaObject;
2181
- }
2182
- });
2183
- Object.defineProperty(exports, "isSortingParameterObject", {
2184
- enumerable: true,
2185
- get: function() {
2186
- return isSortingParameterObject;
2187
- }
2188
- });
2189
- Object.defineProperty(exports, "isTagIncluded", {
2190
- enumerable: true,
2191
- get: function() {
2192
- return isTagIncluded;
2193
- }
2194
- });
2195
- Object.defineProperty(exports, "isUpdateEndpoint", {
2196
- enumerable: true,
2197
- get: function() {
2198
- return isUpdateEndpoint;
2199
- }
2200
- });
2201
- Object.defineProperty(exports, "iterateSchema", {
2202
- enumerable: true,
2203
- get: function() {
2204
- return iterateSchema;
2205
- }
2206
- });
2207
- Object.defineProperty(exports, "kebabToCamel", {
2208
- enumerable: true,
2209
- get: function() {
2210
- return kebabToCamel;
2211
- }
2212
- });
2213
- Object.defineProperty(exports, "mapEndpointParamsToFunctionParams", {
2214
- enumerable: true,
2215
- get: function() {
2216
- return mapEndpointParamsToFunctionParams;
2217
- }
2218
- });
2219
- Object.defineProperty(exports, "mergeImports", {
2220
- enumerable: true,
2221
- get: function() {
2222
- return mergeImports;
2223
- }
2224
- });
2225
- Object.defineProperty(exports, "pathParamToVariableName", {
2226
- enumerable: true,
2227
- get: function() {
2228
- return pathParamToVariableName;
2229
- }
2230
- });
2231
- Object.defineProperty(exports, "pathToVariableName", {
2232
- enumerable: true,
2233
- get: function() {
2234
- return pathToVariableName;
2235
- }
2236
- });
2237
- Object.defineProperty(exports, "pick", {
2238
- enumerable: true,
2239
- get: function() {
2240
- return pick;
2241
- }
2242
- });
2243
- Object.defineProperty(exports, "removeStaleGeneratedFiles", {
2244
- enumerable: true,
2245
- get: function() {
2246
- return removeStaleGeneratedFiles;
2247
- }
2248
- });
2249
- Object.defineProperty(exports, "removeWord", {
2250
- enumerable: true,
2251
- get: function() {
2252
- return removeWord;
2253
- }
2254
- });
2255
- Object.defineProperty(exports, "renderAclCheckCall", {
2256
- enumerable: true,
2257
- get: function() {
2258
- return renderAclCheckCall;
2259
- }
2260
- });
2261
- Object.defineProperty(exports, "renderMediaUploadMutationBody", {
2262
- enumerable: true,
2263
- get: function() {
2264
- return renderMediaUploadMutationBody;
2265
- }
2266
- });
2267
- Object.defineProperty(exports, "replaceHyphenatedPath", {
2268
- enumerable: true,
2269
- get: function() {
2270
- return replaceHyphenatedPath;
2271
- }
2272
- });
2273
- Object.defineProperty(exports, "requiresBody", {
2274
- enumerable: true,
2275
- get: function() {
2276
- return requiresBody;
2277
- }
2278
- });
2279
- Object.defineProperty(exports, "shouldInlineEndpointsForTag", {
2280
- enumerable: true,
2281
- get: function() {
2282
- return shouldInlineEndpointsForTag;
2283
- }
2284
- });
2285
- Object.defineProperty(exports, "shouldUseNativeCodegen", {
2286
- enumerable: true,
2287
- get: function() {
2288
- return shouldUseNativeCodegen;
2289
- }
2290
- });
2291
- Object.defineProperty(exports, "snakeToCamel", {
2292
- enumerable: true,
2293
- get: function() {
2294
- return snakeToCamel;
2295
- }
2296
- });
2297
- Object.defineProperty(exports, "unwrapQuotesIfNeeded", {
2298
- enumerable: true,
2299
- get: function() {
2300
- return unwrapQuotesIfNeeded;
2301
- }
2302
- });
2303
- Object.defineProperty(exports, "wrapWithQuotesIfNeeded", {
2304
- enumerable: true,
2305
- get: function() {
2306
- return wrapWithQuotesIfNeeded;
2307
- }
2308
- });
2309
- Object.defineProperty(exports, "writeGenerateFileData", {
2310
- enumerable: true,
2311
- get: function() {
2312
- return writeGenerateFileData;
2313
- }
2314
- });