@kubb/plugin-vue-query 4.4.1 → 4.5.0

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 (37) hide show
  1. package/dist/{components-DoPUxAFs.cjs → components-CvorLYVT.cjs} +214 -214
  2. package/dist/components-CvorLYVT.cjs.map +1 -0
  3. package/dist/{components-B8p5782n.js → components-kADKAHgd.js} +213 -213
  4. package/dist/components-kADKAHgd.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.cts +114 -114
  7. package/dist/components.d.ts +114 -114
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-a7s1tUe0.cjs → generators-B7BEw8ZB.cjs} +206 -143
  10. package/dist/generators-B7BEw8ZB.cjs.map +1 -0
  11. package/dist/{generators-CxbnV3X_.js → generators-DHkXUh19.js} +203 -141
  12. package/dist/generators-DHkXUh19.js.map +1 -0
  13. package/dist/generators.cjs +2 -2
  14. package/dist/generators.d.cts +5 -5
  15. package/dist/generators.d.ts +5 -5
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +18 -3
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +16 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-CGRXTDFW.d.ts → types-BfKwA3Gv.d.cts} +175 -183
  24. package/dist/{types-PVIn4n6Z.d.cts → types-I09wleY8.d.ts} +175 -183
  25. package/package.json +9 -9
  26. package/src/components/QueryOptions.tsx +1 -1
  27. package/src/components/index.ts +3 -3
  28. package/src/generators/index.ts +2 -2
  29. package/src/generators/infiniteQueryGenerator.tsx +35 -11
  30. package/src/generators/mutationGenerator.tsx +34 -9
  31. package/src/generators/queryGenerator.tsx +35 -11
  32. package/src/plugin.ts +24 -1
  33. package/src/types.ts +4 -3
  34. package/dist/components-B8p5782n.js.map +0 -1
  35. package/dist/components-DoPUxAFs.cjs.map +0 -1
  36. package/dist/generators-CxbnV3X_.js.map +0 -1
  37. package/dist/generators-a7s1tUe0.cjs.map +0 -1
@@ -21,189 +21,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
+ let __kubb_core_utils = require("@kubb/core/utils");
25
+ __kubb_core_utils = __toESM(__kubb_core_utils);
24
26
  let __kubb_oas = require("@kubb/oas");
25
27
  __kubb_oas = __toESM(__kubb_oas);
26
- let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
27
- __kubb_plugin_client_components = __toESM(__kubb_plugin_client_components);
28
28
  let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
29
29
  __kubb_plugin_oas_utils = __toESM(__kubb_plugin_oas_utils);
30
30
  let __kubb_react_fabric = require("@kubb/react-fabric");
31
31
  __kubb_react_fabric = __toESM(__kubb_react_fabric);
32
- let __kubb_core_utils = require("@kubb/core/utils");
33
- __kubb_core_utils = __toESM(__kubb_core_utils);
34
32
  let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
35
33
  __kubb_react_fabric_jsx_runtime = __toESM(__kubb_react_fabric_jsx_runtime);
34
+ let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
35
+ __kubb_plugin_client_components = __toESM(__kubb_plugin_client_components);
36
36
 
37
- //#region src/components/MutationKey.tsx
38
- function getParams$6({}) {
39
- return __kubb_react_fabric.FunctionParams.factory({});
40
- }
41
- const getTransformer$1 = ({ operation, casing }) => {
42
- return [`{ url: '${new __kubb_core_utils.URLPath(operation.path, { casing }).toURLPath()}' }`];
43
- };
44
- function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
45
- const params = getParams$6({
46
- pathParamsType,
47
- typeSchemas
48
- });
49
- const keys = transformer({
50
- operation,
51
- schemas: typeSchemas,
52
- casing: paramsCasing
53
- });
54
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
55
- name,
56
- isExportable: true,
57
- isIndexable: true,
58
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function.Arrow, {
59
- name,
60
- export: true,
61
- params: params.toConstructor(),
62
- singleLine: true,
63
- children: `[${keys.join(", ")}] as const`
64
- })
65
- }), /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
66
- name: typeName,
67
- isExportable: true,
68
- isIndexable: true,
69
- isTypeOnly: true,
70
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Type, {
71
- name: typeName,
72
- export: true,
73
- children: `ReturnType<typeof ${name}>`
74
- })
75
- })] });
76
- }
77
- MutationKey.getParams = getParams$6;
78
- MutationKey.getTransformer = getTransformer$1;
79
-
80
- //#endregion
81
- //#region src/components/Mutation.tsx
82
- function getParams$5({ paramsCasing, dataReturnType, typeSchemas }) {
83
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
84
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
85
- const TRequest = __kubb_react_fabric.FunctionParams.factory({
86
- ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
87
- typed: true,
88
- casing: paramsCasing,
89
- override(item) {
90
- return {
91
- ...item,
92
- type: `MaybeRefOrGetter<${item.type}>`
93
- };
94
- }
95
- }),
96
- data: typeSchemas.request?.name ? {
97
- type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
98
- optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
99
- } : void 0,
100
- params: typeSchemas.queryParams?.name ? {
101
- type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
102
- optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
103
- } : void 0,
104
- headers: typeSchemas.headerParams?.name ? {
105
- type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
106
- optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
107
- } : void 0
108
- }).toConstructor();
109
- return __kubb_react_fabric.FunctionParams.factory({ options: {
110
- type: `
111
- {
112
- mutation?: MutationObserverOptions<${[
113
- TData,
114
- TError,
115
- TRequest ? `{${TRequest}}` : "void",
116
- "TContext"
117
- ].join(", ")}> & { client?: QueryClient },
118
- client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
119
- }
120
- `,
121
- default: "{}"
122
- } });
123
- }
124
- function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
125
- const mutationKeyParams = MutationKey.getParams({
126
- pathParamsType,
127
- typeSchemas
128
- });
129
- const params = getParams$5({
130
- paramsCasing,
131
- pathParamsType,
132
- dataReturnType,
133
- typeSchemas
134
- });
135
- const clientParams = __kubb_plugin_client_components.Client.getParams({
136
- paramsCasing,
137
- paramsType,
138
- typeSchemas,
139
- pathParamsType,
140
- isConfigurable: true
141
- });
142
- const mutationParams = __kubb_react_fabric.FunctionParams.factory({
143
- ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
144
- typed: true,
145
- casing: paramsCasing
146
- }),
147
- data: typeSchemas.request?.name ? {
148
- type: typeSchemas.request?.name,
149
- optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
150
- } : void 0,
151
- params: typeSchemas.queryParams?.name ? {
152
- type: typeSchemas.queryParams?.name,
153
- optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
154
- } : void 0,
155
- headers: typeSchemas.headerParams?.name ? {
156
- type: typeSchemas.headerParams?.name,
157
- optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
158
- } : void 0
159
- });
160
- const dataParams = __kubb_react_fabric.FunctionParams.factory({ data: {
161
- mode: "object",
162
- children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
163
- if (value) acc[key] = {
164
- ...value,
165
- type: void 0
166
- };
167
- return acc;
168
- }, {})
169
- } });
170
- const TRequest = mutationParams.toConstructor();
171
- const generics = [
172
- dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
173
- `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
174
- TRequest ? `{${TRequest}}` : "void",
175
- "TContext"
176
- ].join(", ");
177
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
178
- name,
179
- isExportable: true,
180
- isIndexable: true,
181
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
182
- name,
183
- export: true,
184
- params: params.toConstructor(),
185
- JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
186
- generics: ["TContext"],
187
- children: `
188
- const { mutation = {}, client: config = {} } = options ?? {}
189
- const { client: queryClient, ...mutationOptions } = mutation;
190
- const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
191
-
192
- return useMutation<${generics}>({
193
- mutationFn: async(${dataParams.toConstructor()}) => {
194
- return ${clientName}(${clientParams.toCall()})
195
- },
196
- mutationKey,
197
- ...mutationOptions
198
- }, queryClient)
199
- `
200
- })
201
- });
202
- }
203
-
204
- //#endregion
205
37
  //#region src/components/QueryKey.tsx
206
- function getParams$4({ pathParamsType, paramsCasing, typeSchemas }) {
38
+ function getParams$6({ pathParamsType, paramsCasing, typeSchemas }) {
207
39
  return __kubb_react_fabric.FunctionParams.factory({
208
40
  pathParams: {
209
41
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -228,7 +60,7 @@ function getParams$4({ pathParamsType, paramsCasing, typeSchemas }) {
228
60
  } : void 0
229
61
  });
230
62
  }
231
- const getTransformer = ({ operation, schemas, casing }) => {
63
+ const getTransformer$1 = ({ operation, schemas, casing }) => {
232
64
  return [
233
65
  new __kubb_core_utils.URLPath(operation.path, { casing }).toObject({
234
66
  type: "path",
@@ -238,8 +70,8 @@ const getTransformer = ({ operation, schemas, casing }) => {
238
70
  schemas.request?.name ? "...(data ? [data] : [])" : void 0
239
71
  ].filter(Boolean);
240
72
  };
241
- function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
242
- const params = getParams$4({
73
+ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
74
+ const params = getParams$6({
243
75
  pathParamsType,
244
76
  typeSchemas,
245
77
  paramsCasing
@@ -272,12 +104,12 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
272
104
  })
273
105
  })] });
274
106
  }
275
- QueryKey.getParams = getParams$4;
276
- QueryKey.getTransformer = getTransformer;
107
+ QueryKey.getParams = getParams$6;
108
+ QueryKey.getTransformer = getTransformer$1;
277
109
 
278
110
  //#endregion
279
111
  //#region src/components/QueryOptions.tsx
280
- function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
112
+ function getParams$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
281
113
  if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
282
114
  data: {
283
115
  mode: "object",
@@ -347,7 +179,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas })
347
179
  function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
348
180
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
349
181
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
350
- const params = getParams$3({
182
+ const params = getParams$5({
351
183
  paramsType,
352
184
  paramsCasing,
353
185
  pathParamsType,
@@ -391,11 +223,11 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
391
223
  })
392
224
  });
393
225
  }
394
- QueryOptions.getParams = getParams$3;
226
+ QueryOptions.getParams = getParams$5;
395
227
 
396
228
  //#endregion
397
- //#region src/components/Query.tsx
398
- function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
229
+ //#region src/components/InfiniteQuery.tsx
230
+ function getParams$4({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
399
231
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
400
232
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
401
233
  if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
@@ -429,12 +261,12 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
429
261
  options: {
430
262
  type: `
431
263
  {
432
- query?: Partial<QueryObserverOptions<${[
264
+ query?: Partial<InfiniteQueryObserverOptions<${[
433
265
  TData,
434
266
  TError,
435
- "TData",
436
267
  "TQueryData",
437
- "TQueryKey"
268
+ "TQueryKey",
269
+ "TQueryData"
438
270
  ].join(", ")}>> & { client?: QueryClient },
439
271
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
440
272
  }
@@ -472,12 +304,12 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
472
304
  options: {
473
305
  type: `
474
306
  {
475
- query?: Partial<QueryObserverOptions<${[
307
+ query?: Partial<InfiniteQueryObserverOptions<${[
476
308
  TData,
477
309
  TError,
478
- "TData",
479
310
  "TQueryData",
480
- "TQueryKey"
311
+ "TQueryKey",
312
+ "TQueryData"
481
313
  ].join(", ")}>> & { client?: QueryClient },
482
314
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
483
315
  }
@@ -486,11 +318,11 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
486
318
  }
487
319
  });
488
320
  }
489
- function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
321
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
490
322
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
491
- const returnType = `UseQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
323
+ const returnType = `UseInfiniteQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
492
324
  const generics = [
493
- `TData = ${TData}`,
325
+ `TData = InfiniteData<${TData}>`,
494
326
  `TQueryData = ${TData}`,
495
327
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
496
328
  ];
@@ -505,7 +337,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
505
337
  typeSchemas,
506
338
  paramsCasing
507
339
  });
508
- const params = getParams$2({
340
+ const params = getParams$4({
509
341
  paramsCasing,
510
342
  paramsType,
511
343
  pathParamsType,
@@ -528,11 +360,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
528
360
  const { client: queryClient, ...queryOptions } = queryConfig
529
361
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
530
362
 
531
- const query = useQuery({
363
+ const query = useInfiniteQuery({
532
364
  ...${queryOptions},
533
365
  queryKey,
534
366
  ...queryOptions
535
- } as unknown as QueryObserverOptions, queryClient) as ${returnType}
367
+ } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
536
368
 
537
369
  query.queryKey = queryKey as TQueryKey
538
370
 
@@ -541,11 +373,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
541
373
  })
542
374
  });
543
375
  }
544
- Query.getParams = getParams$2;
376
+ InfiniteQuery.getParams = getParams$4;
545
377
 
546
378
  //#endregion
547
379
  //#region src/components/InfiniteQueryOptions.tsx
548
- function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
380
+ function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
549
381
  if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
550
382
  data: {
551
383
  mode: "object",
@@ -615,7 +447,7 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas })
615
447
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, paramsType, paramsCasing, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
616
448
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
617
449
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
618
- const params = getParams$1({
450
+ const params = getParams$3({
619
451
  paramsType,
620
452
  paramsCasing,
621
453
  pathParamsType,
@@ -674,11 +506,179 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
674
506
  })
675
507
  });
676
508
  }
677
- InfiniteQueryOptions.getParams = getParams$1;
509
+ InfiniteQueryOptions.getParams = getParams$3;
678
510
 
679
511
  //#endregion
680
- //#region src/components/InfiniteQuery.tsx
681
- function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
512
+ //#region src/components/MutationKey.tsx
513
+ function getParams$2({}) {
514
+ return __kubb_react_fabric.FunctionParams.factory({});
515
+ }
516
+ const getTransformer = ({ operation, casing }) => {
517
+ return [`{ url: '${new __kubb_core_utils.URLPath(operation.path, { casing }).toURLPath()}' }`];
518
+ };
519
+ function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
520
+ const params = getParams$2({
521
+ pathParamsType,
522
+ typeSchemas
523
+ });
524
+ const keys = transformer({
525
+ operation,
526
+ schemas: typeSchemas,
527
+ casing: paramsCasing
528
+ });
529
+ return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
530
+ name,
531
+ isExportable: true,
532
+ isIndexable: true,
533
+ children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function.Arrow, {
534
+ name,
535
+ export: true,
536
+ params: params.toConstructor(),
537
+ singleLine: true,
538
+ children: `[${keys.join(", ")}] as const`
539
+ })
540
+ }), /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
541
+ name: typeName,
542
+ isExportable: true,
543
+ isIndexable: true,
544
+ isTypeOnly: true,
545
+ children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Type, {
546
+ name: typeName,
547
+ export: true,
548
+ children: `ReturnType<typeof ${name}>`
549
+ })
550
+ })] });
551
+ }
552
+ MutationKey.getParams = getParams$2;
553
+ MutationKey.getTransformer = getTransformer;
554
+
555
+ //#endregion
556
+ //#region src/components/Mutation.tsx
557
+ function getParams$1({ paramsCasing, dataReturnType, typeSchemas }) {
558
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
559
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
560
+ const TRequest = __kubb_react_fabric.FunctionParams.factory({
561
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
562
+ typed: true,
563
+ casing: paramsCasing,
564
+ override(item) {
565
+ return {
566
+ ...item,
567
+ type: `MaybeRefOrGetter<${item.type}>`
568
+ };
569
+ }
570
+ }),
571
+ data: typeSchemas.request?.name ? {
572
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
573
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
574
+ } : void 0,
575
+ params: typeSchemas.queryParams?.name ? {
576
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
577
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
578
+ } : void 0,
579
+ headers: typeSchemas.headerParams?.name ? {
580
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
581
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
582
+ } : void 0
583
+ }).toConstructor();
584
+ return __kubb_react_fabric.FunctionParams.factory({ options: {
585
+ type: `
586
+ {
587
+ mutation?: MutationObserverOptions<${[
588
+ TData,
589
+ TError,
590
+ TRequest ? `{${TRequest}}` : "void",
591
+ "TContext"
592
+ ].join(", ")}> & { client?: QueryClient },
593
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
594
+ }
595
+ `,
596
+ default: "{}"
597
+ } });
598
+ }
599
+ function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
600
+ const mutationKeyParams = MutationKey.getParams({
601
+ pathParamsType,
602
+ typeSchemas
603
+ });
604
+ const params = getParams$1({
605
+ paramsCasing,
606
+ pathParamsType,
607
+ dataReturnType,
608
+ typeSchemas
609
+ });
610
+ const clientParams = __kubb_plugin_client_components.Client.getParams({
611
+ paramsCasing,
612
+ paramsType,
613
+ typeSchemas,
614
+ pathParamsType,
615
+ isConfigurable: true
616
+ });
617
+ const mutationParams = __kubb_react_fabric.FunctionParams.factory({
618
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
619
+ typed: true,
620
+ casing: paramsCasing
621
+ }),
622
+ data: typeSchemas.request?.name ? {
623
+ type: typeSchemas.request?.name,
624
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
625
+ } : void 0,
626
+ params: typeSchemas.queryParams?.name ? {
627
+ type: typeSchemas.queryParams?.name,
628
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
629
+ } : void 0,
630
+ headers: typeSchemas.headerParams?.name ? {
631
+ type: typeSchemas.headerParams?.name,
632
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
633
+ } : void 0
634
+ });
635
+ const dataParams = __kubb_react_fabric.FunctionParams.factory({ data: {
636
+ mode: "object",
637
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
638
+ if (value) acc[key] = {
639
+ ...value,
640
+ type: void 0
641
+ };
642
+ return acc;
643
+ }, {})
644
+ } });
645
+ const TRequest = mutationParams.toConstructor();
646
+ const generics = [
647
+ dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
648
+ `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
649
+ TRequest ? `{${TRequest}}` : "void",
650
+ "TContext"
651
+ ].join(", ");
652
+ return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
653
+ name,
654
+ isExportable: true,
655
+ isIndexable: true,
656
+ children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
657
+ name,
658
+ export: true,
659
+ params: params.toConstructor(),
660
+ JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
661
+ generics: ["TContext"],
662
+ children: `
663
+ const { mutation = {}, client: config = {} } = options ?? {}
664
+ const { client: queryClient, ...mutationOptions } = mutation;
665
+ const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
666
+
667
+ return useMutation<${generics}>({
668
+ mutationFn: async(${dataParams.toConstructor()}) => {
669
+ return ${clientName}(${clientParams.toCall()})
670
+ },
671
+ mutationKey,
672
+ ...mutationOptions
673
+ }, queryClient)
674
+ `
675
+ })
676
+ });
677
+ }
678
+
679
+ //#endregion
680
+ //#region src/components/Query.tsx
681
+ function getParams({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
682
682
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
683
683
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
684
684
  if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
@@ -712,12 +712,12 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
712
712
  options: {
713
713
  type: `
714
714
  {
715
- query?: Partial<InfiniteQueryObserverOptions<${[
715
+ query?: Partial<QueryObserverOptions<${[
716
716
  TData,
717
717
  TError,
718
+ "TData",
718
719
  "TQueryData",
719
- "TQueryKey",
720
- "TQueryData"
720
+ "TQueryKey"
721
721
  ].join(", ")}>> & { client?: QueryClient },
722
722
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
723
723
  }
@@ -755,12 +755,12 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
755
755
  options: {
756
756
  type: `
757
757
  {
758
- query?: Partial<InfiniteQueryObserverOptions<${[
758
+ query?: Partial<QueryObserverOptions<${[
759
759
  TData,
760
760
  TError,
761
+ "TData",
761
762
  "TQueryData",
762
- "TQueryKey",
763
- "TQueryData"
763
+ "TQueryKey"
764
764
  ].join(", ")}>> & { client?: QueryClient },
765
765
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
766
766
  }
@@ -769,11 +769,11 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
769
769
  }
770
770
  });
771
771
  }
772
- function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
772
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
773
773
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
774
- const returnType = `UseInfiniteQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
774
+ const returnType = `UseQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
775
775
  const generics = [
776
- `TData = InfiniteData<${TData}>`,
776
+ `TData = ${TData}`,
777
777
  `TQueryData = ${TData}`,
778
778
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
779
779
  ];
@@ -811,11 +811,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
811
811
  const { client: queryClient, ...queryOptions } = queryConfig
812
812
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
813
813
 
814
- const query = useInfiniteQuery({
814
+ const query = useQuery({
815
815
  ...${queryOptions},
816
816
  queryKey,
817
817
  ...queryOptions
818
- } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
818
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
819
819
 
820
820
  query.queryKey = queryKey as TQueryKey
821
821
 
@@ -824,7 +824,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
824
824
  })
825
825
  });
826
826
  }
827
- InfiniteQuery.getParams = getParams;
827
+ Query.getParams = getParams;
828
828
 
829
829
  //#endregion
830
830
  Object.defineProperty(exports, 'InfiniteQuery', {
@@ -875,4 +875,4 @@ Object.defineProperty(exports, '__toESM', {
875
875
  return __toESM;
876
876
  }
877
877
  });
878
- //# sourceMappingURL=components-DoPUxAFs.cjs.map
878
+ //# sourceMappingURL=components-CvorLYVT.cjs.map