@kubb/plugin-vue-query 3.16.1 → 3.16.3

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 (39) hide show
  1. package/dist/components-ClNrCCre.cjs +873 -0
  2. package/dist/components-ClNrCCre.cjs.map +1 -0
  3. package/dist/components-D8lYnxao.js +803 -0
  4. package/dist/components-D8lYnxao.js.map +1 -0
  5. package/dist/components.cjs +9 -36
  6. package/dist/components.d.cts +266 -124
  7. package/dist/components.d.ts +266 -124
  8. package/dist/components.js +3 -3
  9. package/dist/generators-DIB6YtRr.js +556 -0
  10. package/dist/generators-DIB6YtRr.js.map +1 -0
  11. package/dist/generators-DIZQUvkg.cjs +573 -0
  12. package/dist/generators-DIZQUvkg.cjs.map +1 -0
  13. package/dist/generators.cjs +5 -20
  14. package/dist/generators.d.cts +12 -12
  15. package/dist/generators.d.ts +12 -12
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +118 -143
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -8
  20. package/dist/index.d.ts +6 -8
  21. package/dist/index.js +118 -137
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-DPDni0p-.d.ts +1385 -0
  24. package/dist/types-UcJcIqHK.d.cts +1385 -0
  25. package/package.json +25 -30
  26. package/dist/chunk-5RO5VZAJ.js +0 -444
  27. package/dist/chunk-5RO5VZAJ.js.map +0 -1
  28. package/dist/chunk-BBSHBY5N.cjs +0 -448
  29. package/dist/chunk-BBSHBY5N.cjs.map +0 -1
  30. package/dist/chunk-KHEXOVSW.js +0 -726
  31. package/dist/chunk-KHEXOVSW.js.map +0 -1
  32. package/dist/chunk-ZR7DRLPY.cjs +0 -734
  33. package/dist/chunk-ZR7DRLPY.cjs.map +0 -1
  34. package/dist/components.cjs.map +0 -1
  35. package/dist/components.js.map +0 -1
  36. package/dist/generators.cjs.map +0 -1
  37. package/dist/generators.js.map +0 -1
  38. package/dist/types-CDzVWC17.d.cts +0 -164
  39. package/dist/types-CDzVWC17.d.ts +0 -164
@@ -0,0 +1,873 @@
1
+ //#region rolldown:runtime
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 ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const __kubb_react = __toESM(require("@kubb/react"));
25
+ const __kubb_oas = __toESM(require("@kubb/oas"));
26
+ const __kubb_plugin_client_components = __toESM(require("@kubb/plugin-client/components"));
27
+ const __kubb_plugin_oas_utils = __toESM(require("@kubb/plugin-oas/utils"));
28
+ const __kubb_core_utils = __toESM(require("@kubb/core/utils"));
29
+ const __kubb_react_jsx_runtime = __toESM(require("@kubb/react/jsx-runtime"));
30
+
31
+ //#region src/components/MutationKey.tsx
32
+ function getParams$6({}) {
33
+ return __kubb_react.FunctionParams.factory({});
34
+ }
35
+ const getTransformer$1 = ({ operation, casing }) => {
36
+ const path = new __kubb_core_utils.URLPath(operation.path, { casing });
37
+ return [JSON.stringify({ url: path.path })].filter(Boolean);
38
+ };
39
+ function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
40
+ const params = getParams$6({
41
+ pathParamsType,
42
+ typeSchemas
43
+ });
44
+ const keys = transformer({
45
+ operation,
46
+ schemas: typeSchemas,
47
+ casing: paramsCasing
48
+ });
49
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
50
+ name,
51
+ isExportable: true,
52
+ isIndexable: true,
53
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function.Arrow, {
54
+ name,
55
+ export: true,
56
+ params: params.toConstructor(),
57
+ singleLine: true,
58
+ children: `[${keys.join(", ")}] as const`
59
+ })
60
+ }), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
61
+ name: typeName,
62
+ isExportable: true,
63
+ isIndexable: true,
64
+ isTypeOnly: true,
65
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
66
+ name: typeName,
67
+ export: true,
68
+ children: `ReturnType<typeof ${name}>`
69
+ })
70
+ })] });
71
+ }
72
+ MutationKey.getParams = getParams$6;
73
+ MutationKey.getTransformer = getTransformer$1;
74
+
75
+ //#endregion
76
+ //#region src/components/Mutation.tsx
77
+ function getParams$5({ paramsCasing, dataReturnType, typeSchemas }) {
78
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
79
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
80
+ const mutationParams = __kubb_react.FunctionParams.factory({
81
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
82
+ typed: true,
83
+ casing: paramsCasing,
84
+ override(item) {
85
+ return {
86
+ ...item,
87
+ type: `MaybeRefOrGetter<${item.type}>`
88
+ };
89
+ }
90
+ }),
91
+ data: typeSchemas.request?.name ? {
92
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
93
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
94
+ } : void 0,
95
+ params: typeSchemas.queryParams?.name ? {
96
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
97
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
98
+ } : void 0,
99
+ headers: typeSchemas.headerParams?.name ? {
100
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
101
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
102
+ } : void 0
103
+ });
104
+ const TRequest = mutationParams.toConstructor();
105
+ return __kubb_react.FunctionParams.factory({ options: {
106
+ type: `
107
+ {
108
+ mutation?: MutationObserverOptions<${[
109
+ TData,
110
+ TError,
111
+ TRequest ? `{${TRequest}}` : "void",
112
+ "TContext"
113
+ ].join(", ")}> & { client?: QueryClient },
114
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
115
+ }
116
+ `,
117
+ default: "{}"
118
+ } });
119
+ }
120
+ function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
121
+ const mutationKeyParams = MutationKey.getParams({
122
+ pathParamsType,
123
+ typeSchemas
124
+ });
125
+ const params = getParams$5({
126
+ paramsCasing,
127
+ pathParamsType,
128
+ dataReturnType,
129
+ typeSchemas
130
+ });
131
+ const clientParams = __kubb_plugin_client_components.Client.getParams({
132
+ paramsCasing,
133
+ paramsType,
134
+ typeSchemas,
135
+ pathParamsType,
136
+ isConfigurable: true
137
+ });
138
+ const mutationParams = __kubb_react.FunctionParams.factory({
139
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
140
+ typed: true,
141
+ casing: paramsCasing
142
+ }),
143
+ data: typeSchemas.request?.name ? {
144
+ type: typeSchemas.request?.name,
145
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
146
+ } : void 0,
147
+ params: typeSchemas.queryParams?.name ? {
148
+ type: typeSchemas.queryParams?.name,
149
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
150
+ } : void 0,
151
+ headers: typeSchemas.headerParams?.name ? {
152
+ type: typeSchemas.headerParams?.name,
153
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
154
+ } : void 0
155
+ });
156
+ const dataParams = __kubb_react.FunctionParams.factory({ data: {
157
+ mode: "object",
158
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
159
+ if (value) acc[key] = {
160
+ ...value,
161
+ type: void 0
162
+ };
163
+ return acc;
164
+ }, {})
165
+ } });
166
+ const TRequest = mutationParams.toConstructor();
167
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
168
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
169
+ const generics = [
170
+ TData,
171
+ TError,
172
+ TRequest ? `{${TRequest}}` : "void",
173
+ "TContext"
174
+ ].join(", ");
175
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
176
+ name,
177
+ isExportable: true,
178
+ isIndexable: true,
179
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
180
+ name,
181
+ export: true,
182
+ params: params.toConstructor(),
183
+ JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
184
+ generics: ["TContext"],
185
+ children: `
186
+ const { mutation = {}, client: config = {} } = options ?? {}
187
+ const { client: queryClient, ...mutationOptions } = mutation;
188
+ const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
189
+
190
+ return useMutation<${generics}>({
191
+ mutationFn: async(${dataParams.toConstructor()}) => {
192
+ return ${clientName}(${clientParams.toCall()})
193
+ },
194
+ mutationKey,
195
+ ...mutationOptions
196
+ }, queryClient)
197
+ `
198
+ })
199
+ });
200
+ }
201
+
202
+ //#endregion
203
+ //#region src/components/QueryKey.tsx
204
+ function getParams$4({ pathParamsType, paramsCasing, typeSchemas }) {
205
+ return __kubb_react.FunctionParams.factory({
206
+ pathParams: {
207
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
208
+ children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
209
+ typed: true,
210
+ casing: paramsCasing,
211
+ override(item) {
212
+ return {
213
+ ...item,
214
+ type: `MaybeRefOrGetter<${item.type}>`
215
+ };
216
+ }
217
+ })
218
+ },
219
+ data: typeSchemas.request?.name ? {
220
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
221
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
222
+ } : void 0,
223
+ params: typeSchemas.queryParams?.name ? {
224
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
225
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
226
+ } : void 0
227
+ });
228
+ }
229
+ const getTransformer = ({ operation, schemas, casing }) => {
230
+ const path = new __kubb_core_utils.URLPath(operation.path, { casing });
231
+ const keys = [
232
+ path.toObject({
233
+ type: "path",
234
+ stringify: true
235
+ }),
236
+ schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
237
+ schemas.request?.name ? "...(data ? [data] : [])" : void 0
238
+ ].filter(Boolean);
239
+ return keys;
240
+ };
241
+ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
242
+ const params = getParams$4({
243
+ pathParamsType,
244
+ typeSchemas,
245
+ paramsCasing
246
+ });
247
+ const keys = transformer({
248
+ operation,
249
+ schemas: typeSchemas,
250
+ casing: paramsCasing
251
+ });
252
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
253
+ name,
254
+ isExportable: true,
255
+ isIndexable: true,
256
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function.Arrow, {
257
+ name,
258
+ export: true,
259
+ params: params.toConstructor(),
260
+ singleLine: true,
261
+ children: `[${keys.join(", ")}] as const`
262
+ })
263
+ }), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
264
+ name: typeName,
265
+ isExportable: true,
266
+ isIndexable: true,
267
+ isTypeOnly: true,
268
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
269
+ name: typeName,
270
+ export: true,
271
+ children: `ReturnType<typeof ${name}>`
272
+ })
273
+ })] });
274
+ }
275
+ QueryKey.getParams = getParams$4;
276
+ QueryKey.getTransformer = getTransformer;
277
+
278
+ //#endregion
279
+ //#region src/components/QueryOptions.tsx
280
+ function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
281
+ if (paramsType === "object") return __kubb_react.FunctionParams.factory({
282
+ data: {
283
+ mode: "object",
284
+ children: {
285
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
286
+ typed: true,
287
+ casing: paramsCasing,
288
+ override(item) {
289
+ return {
290
+ ...item,
291
+ type: `MaybeRefOrGetter<${item.type}>`
292
+ };
293
+ }
294
+ }),
295
+ data: typeSchemas.request?.name ? {
296
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
297
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
298
+ } : void 0,
299
+ params: typeSchemas.queryParams?.name ? {
300
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
301
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
302
+ } : void 0,
303
+ headers: typeSchemas.headerParams?.name ? {
304
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
305
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
306
+ } : void 0
307
+ }
308
+ },
309
+ config: {
310
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
311
+ default: "{}"
312
+ }
313
+ });
314
+ return __kubb_react.FunctionParams.factory({
315
+ pathParams: {
316
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
317
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema),
318
+ children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
319
+ typed: true,
320
+ casing: paramsCasing,
321
+ override(item) {
322
+ return {
323
+ ...item,
324
+ type: `MaybeRefOrGetter<${item.type}>`
325
+ };
326
+ }
327
+ })
328
+ },
329
+ data: typeSchemas.request?.name ? {
330
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
331
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
332
+ } : void 0,
333
+ params: typeSchemas.queryParams?.name ? {
334
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
335
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
336
+ } : void 0,
337
+ headers: typeSchemas.headerParams?.name ? {
338
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
339
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
340
+ } : void 0,
341
+ config: {
342
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
343
+ default: "{}"
344
+ }
345
+ });
346
+ }
347
+ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
348
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
349
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
350
+ const params = getParams$3({
351
+ paramsType,
352
+ paramsCasing,
353
+ pathParamsType,
354
+ typeSchemas
355
+ });
356
+ const clientParams = __kubb_plugin_client_components.Client.getParams({
357
+ paramsType,
358
+ paramsCasing,
359
+ typeSchemas,
360
+ pathParamsType,
361
+ isConfigurable: true
362
+ });
363
+ const queryKeyParams = QueryKey.getParams({
364
+ pathParamsType,
365
+ typeSchemas,
366
+ paramsCasing
367
+ });
368
+ const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
369
+ const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
370
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
371
+ name,
372
+ isExportable: true,
373
+ isIndexable: true,
374
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
375
+ name,
376
+ export: true,
377
+ params: params.toConstructor(),
378
+ children: `
379
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
380
+ return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
381
+ ${enabledText}
382
+ queryKey,
383
+ queryFn: async ({ signal }) => {
384
+ config.signal = signal
385
+ return ${clientName}(${clientParams.toCall({ transformName(name$1) {
386
+ return `toValue(${name$1})`;
387
+ } })})
388
+ },
389
+ })
390
+ `
391
+ })
392
+ });
393
+ }
394
+ QueryOptions.getParams = getParams$3;
395
+
396
+ //#endregion
397
+ //#region src/components/Query.tsx
398
+ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
399
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
400
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
401
+ if (paramsType === "object") return __kubb_react.FunctionParams.factory({
402
+ data: {
403
+ mode: "object",
404
+ children: {
405
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
406
+ typed: true,
407
+ casing: paramsCasing,
408
+ override(item) {
409
+ return {
410
+ ...item,
411
+ type: `MaybeRefOrGetter<${item.type}>`
412
+ };
413
+ }
414
+ }),
415
+ data: typeSchemas.request?.name ? {
416
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
417
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
418
+ } : void 0,
419
+ params: typeSchemas.queryParams?.name ? {
420
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
421
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
422
+ } : void 0,
423
+ headers: typeSchemas.headerParams?.name ? {
424
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
425
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
426
+ } : void 0
427
+ }
428
+ },
429
+ options: {
430
+ type: `
431
+ {
432
+ query?: Partial<QueryObserverOptions<${[
433
+ TData,
434
+ TError,
435
+ "TData",
436
+ "TQueryData",
437
+ "TQueryKey"
438
+ ].join(", ")}>> & { client?: QueryClient },
439
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
440
+ }
441
+ `,
442
+ default: "{}"
443
+ }
444
+ });
445
+ return __kubb_react.FunctionParams.factory({
446
+ pathParams: {
447
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
448
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema),
449
+ children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
450
+ typed: true,
451
+ casing: paramsCasing,
452
+ override(item) {
453
+ return {
454
+ ...item,
455
+ type: `MaybeRefOrGetter<${item.type}>`
456
+ };
457
+ }
458
+ })
459
+ },
460
+ data: typeSchemas.request?.name ? {
461
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
462
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
463
+ } : void 0,
464
+ params: typeSchemas.queryParams?.name ? {
465
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
466
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
467
+ } : void 0,
468
+ headers: typeSchemas.headerParams?.name ? {
469
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
470
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
471
+ } : void 0,
472
+ options: {
473
+ type: `
474
+ {
475
+ query?: Partial<QueryObserverOptions<${[
476
+ TData,
477
+ TError,
478
+ "TData",
479
+ "TQueryData",
480
+ "TQueryKey"
481
+ ].join(", ")}>> & { client?: QueryClient },
482
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
483
+ }
484
+ `,
485
+ default: "{}"
486
+ }
487
+ });
488
+ }
489
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
490
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
491
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
492
+ const returnType = `UseQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
493
+ const generics = [
494
+ `TData = ${TData}`,
495
+ `TQueryData = ${TData}`,
496
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
497
+ ];
498
+ const queryKeyParams = QueryKey.getParams({
499
+ pathParamsType,
500
+ typeSchemas,
501
+ paramsCasing
502
+ });
503
+ const queryOptionsParams = QueryOptions.getParams({
504
+ paramsType,
505
+ pathParamsType,
506
+ typeSchemas,
507
+ paramsCasing
508
+ });
509
+ const params = getParams$2({
510
+ paramsCasing,
511
+ paramsType,
512
+ pathParamsType,
513
+ dataReturnType,
514
+ typeSchemas
515
+ });
516
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
517
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
518
+ name,
519
+ isExportable: true,
520
+ isIndexable: true,
521
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
522
+ name,
523
+ export: true,
524
+ generics: generics.join(", "),
525
+ params: params.toConstructor(),
526
+ JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
527
+ children: `
528
+ const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}
529
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
530
+
531
+ const query = useQuery({
532
+ ...${queryOptions},
533
+ queryKey,
534
+ ...queryOptions
535
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
536
+
537
+ query.queryKey = queryKey as TQueryKey
538
+
539
+ return query
540
+ `
541
+ })
542
+ });
543
+ }
544
+ Query.getParams = getParams$2;
545
+
546
+ //#endregion
547
+ //#region src/components/InfiniteQueryOptions.tsx
548
+ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
549
+ if (paramsType === "object") return __kubb_react.FunctionParams.factory({
550
+ data: {
551
+ mode: "object",
552
+ children: {
553
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
554
+ typed: true,
555
+ casing: paramsCasing,
556
+ override(item) {
557
+ return {
558
+ ...item,
559
+ type: `MaybeRefOrGetter<${item.type}>`
560
+ };
561
+ }
562
+ }),
563
+ data: typeSchemas.request?.name ? {
564
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
565
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
566
+ } : void 0,
567
+ params: typeSchemas.queryParams?.name ? {
568
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
569
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
570
+ } : void 0,
571
+ headers: typeSchemas.headerParams?.name ? {
572
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
573
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
574
+ } : void 0
575
+ }
576
+ },
577
+ config: {
578
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
579
+ default: "{}"
580
+ }
581
+ });
582
+ return __kubb_react.FunctionParams.factory({
583
+ pathParams: {
584
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
585
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema),
586
+ children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
587
+ typed: true,
588
+ casing: paramsCasing,
589
+ override(item) {
590
+ return {
591
+ ...item,
592
+ type: `MaybeRefOrGetter<${item.type}>`
593
+ };
594
+ }
595
+ })
596
+ },
597
+ data: typeSchemas.request?.name ? {
598
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
599
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
600
+ } : void 0,
601
+ params: typeSchemas.queryParams?.name ? {
602
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
603
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
604
+ } : void 0,
605
+ headers: typeSchemas.headerParams?.name ? {
606
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
607
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
608
+ } : void 0,
609
+ config: {
610
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
611
+ default: "{}"
612
+ }
613
+ });
614
+ }
615
+ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, paramsType, paramsCasing, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
616
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
617
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
618
+ const params = getParams$1({
619
+ paramsType,
620
+ paramsCasing,
621
+ pathParamsType,
622
+ typeSchemas
623
+ });
624
+ const clientParams = __kubb_plugin_client_components.Client.getParams({
625
+ paramsType,
626
+ paramsCasing,
627
+ typeSchemas,
628
+ pathParamsType,
629
+ isConfigurable: true
630
+ });
631
+ const queryKeyParams = QueryKey.getParams({
632
+ paramsCasing,
633
+ pathParamsType,
634
+ typeSchemas
635
+ });
636
+ const queryOptions = [
637
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
638
+ cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` : void 0,
639
+ cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` : void 0,
640
+ !cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : void 0,
641
+ !cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : void 0,
642
+ !cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : void 0
643
+ ].filter(Boolean);
644
+ const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
645
+ if(params) {
646
+ params['${queryParam}'] = pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}']
647
+ }` : "";
648
+ const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
649
+ const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
650
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
651
+ name,
652
+ isExportable: true,
653
+ isIndexable: true,
654
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
655
+ name,
656
+ export: true,
657
+ params: params.toConstructor(),
658
+ children: `
659
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
660
+ return infiniteQueryOptions<${TData}, ${TError}, ${TData}, typeof queryKey, number>({
661
+ ${enabledText}
662
+ queryKey,
663
+ queryFn: async ({ signal, pageParam }) => {
664
+ config.signal = signal
665
+ ${infiniteOverrideParams}
666
+ return ${clientName}(${clientParams.toCall()})
667
+ },
668
+ ${queryOptions.join(",\n")}
669
+ })
670
+ `
671
+ })
672
+ });
673
+ }
674
+ InfiniteQueryOptions.getParams = getParams$1;
675
+
676
+ //#endregion
677
+ //#region src/components/InfiniteQuery.tsx
678
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
679
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
680
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
681
+ if (paramsType === "object") return __kubb_react.FunctionParams.factory({
682
+ data: {
683
+ mode: "object",
684
+ children: {
685
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
686
+ typed: true,
687
+ casing: paramsCasing,
688
+ override(item) {
689
+ return {
690
+ ...item,
691
+ type: `MaybeRefOrGetter<${item.type}>`
692
+ };
693
+ }
694
+ }),
695
+ data: typeSchemas.request?.name ? {
696
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
697
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
698
+ } : void 0,
699
+ params: typeSchemas.queryParams?.name ? {
700
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
701
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
702
+ } : void 0,
703
+ headers: typeSchemas.headerParams?.name ? {
704
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
705
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
706
+ } : void 0
707
+ }
708
+ },
709
+ options: {
710
+ type: `
711
+ {
712
+ query?: Partial<InfiniteQueryObserverOptions<${[
713
+ TData,
714
+ TError,
715
+ "TData",
716
+ "TQueryKey"
717
+ ].join(", ")}>> & { client?: QueryClient },
718
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
719
+ }
720
+ `,
721
+ default: "{}"
722
+ }
723
+ });
724
+ return __kubb_react.FunctionParams.factory({
725
+ pathParams: {
726
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
727
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema),
728
+ children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
729
+ typed: true,
730
+ casing: paramsCasing,
731
+ override(item) {
732
+ return {
733
+ ...item,
734
+ type: `MaybeRefOrGetter<${item.type}>`
735
+ };
736
+ }
737
+ })
738
+ },
739
+ data: typeSchemas.request?.name ? {
740
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
741
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
742
+ } : void 0,
743
+ params: typeSchemas.queryParams?.name ? {
744
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
745
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
746
+ } : void 0,
747
+ headers: typeSchemas.headerParams?.name ? {
748
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
749
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
750
+ } : void 0,
751
+ options: {
752
+ type: `
753
+ {
754
+ query?: Partial<InfiniteQueryObserverOptions<${[
755
+ TData,
756
+ TError,
757
+ "TData",
758
+ "TQueryKey"
759
+ ].join(", ")}>> & { client?: QueryClient },
760
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
761
+ }
762
+ `,
763
+ default: "{}"
764
+ }
765
+ });
766
+ }
767
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
768
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
769
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
770
+ const returnType = `UseInfiniteQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
771
+ const generics = [
772
+ `TData = InfiniteData<${TData}>`,
773
+ `TQueryData = ${TData}`,
774
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
775
+ ];
776
+ const queryKeyParams = QueryKey.getParams({
777
+ pathParamsType,
778
+ typeSchemas,
779
+ paramsCasing
780
+ });
781
+ const queryOptionsParams = QueryOptions.getParams({
782
+ paramsType,
783
+ pathParamsType,
784
+ typeSchemas,
785
+ paramsCasing
786
+ });
787
+ const params = getParams({
788
+ paramsCasing,
789
+ paramsType,
790
+ pathParamsType,
791
+ dataReturnType,
792
+ typeSchemas
793
+ });
794
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
795
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
796
+ name,
797
+ isExportable: true,
798
+ isIndexable: true,
799
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
800
+ name,
801
+ export: true,
802
+ generics: generics.join(", "),
803
+ params: params.toConstructor(),
804
+ JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
805
+ children: `
806
+ const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}
807
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
808
+
809
+ const query = useInfiniteQuery({
810
+ ...${queryOptions},
811
+ queryKey,
812
+ ...queryOptions
813
+ } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
814
+
815
+ query.queryKey = queryKey as TQueryKey
816
+
817
+ return query
818
+ `
819
+ })
820
+ });
821
+ }
822
+ InfiniteQuery.getParams = getParams;
823
+
824
+ //#endregion
825
+ Object.defineProperty(exports, 'InfiniteQuery', {
826
+ enumerable: true,
827
+ get: function () {
828
+ return InfiniteQuery;
829
+ }
830
+ });
831
+ Object.defineProperty(exports, 'InfiniteQueryOptions', {
832
+ enumerable: true,
833
+ get: function () {
834
+ return InfiniteQueryOptions;
835
+ }
836
+ });
837
+ Object.defineProperty(exports, 'Mutation', {
838
+ enumerable: true,
839
+ get: function () {
840
+ return Mutation;
841
+ }
842
+ });
843
+ Object.defineProperty(exports, 'MutationKey', {
844
+ enumerable: true,
845
+ get: function () {
846
+ return MutationKey;
847
+ }
848
+ });
849
+ Object.defineProperty(exports, 'Query', {
850
+ enumerable: true,
851
+ get: function () {
852
+ return Query;
853
+ }
854
+ });
855
+ Object.defineProperty(exports, 'QueryKey', {
856
+ enumerable: true,
857
+ get: function () {
858
+ return QueryKey;
859
+ }
860
+ });
861
+ Object.defineProperty(exports, 'QueryOptions', {
862
+ enumerable: true,
863
+ get: function () {
864
+ return QueryOptions;
865
+ }
866
+ });
867
+ Object.defineProperty(exports, '__toESM', {
868
+ enumerable: true,
869
+ get: function () {
870
+ return __toESM;
871
+ }
872
+ });
873
+ //# sourceMappingURL=components-ClNrCCre.cjs.map