@kubb/plugin-react-query 4.0.2 → 4.1.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.
@@ -21,186 +21,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- let __kubb_react = require("@kubb/react");
25
- __kubb_react = __toESM(__kubb_react);
26
24
  let __kubb_oas = require("@kubb/oas");
27
25
  __kubb_oas = __toESM(__kubb_oas);
28
- let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
29
- __kubb_plugin_client_components = __toESM(__kubb_plugin_client_components);
30
26
  let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
31
27
  __kubb_plugin_oas_utils = __toESM(__kubb_plugin_oas_utils);
28
+ let __kubb_react = require("@kubb/react");
29
+ __kubb_react = __toESM(__kubb_react);
32
30
  let __kubb_core_utils = require("@kubb/core/utils");
33
31
  __kubb_core_utils = __toESM(__kubb_core_utils);
34
32
  let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
35
33
  __kubb_react_jsx_runtime = __toESM(__kubb_react_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$7({}) {
39
- return __kubb_react.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, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer$1 }) {
45
- const params = getParams$7({
46
- pathParamsType,
47
- typeSchemas
48
- });
49
- const keys = transformer({
50
- operation,
51
- schemas: typeSchemas,
52
- casing: paramsCasing
53
- });
54
- 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, {
55
- name,
56
- isExportable: true,
57
- isIndexable: true,
58
- children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.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_jsx_runtime.jsx)(__kubb_react.File.Source, {
66
- name: typeName,
67
- isExportable: true,
68
- isIndexable: true,
69
- isTypeOnly: true,
70
- children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
71
- name: typeName,
72
- export: true,
73
- children: `ReturnType<typeof ${name}>`
74
- })
75
- })] });
76
- }
77
- MutationKey.getParams = getParams$7;
78
- MutationKey.getTransformer = getTransformer$1;
79
-
80
- //#endregion
81
- //#region src/components/Mutation.tsx
82
- function getParams$6({ paramsCasing, dataReturnType, typeSchemas }) {
83
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
84
- const TRequest = __kubb_react.FunctionParams.factory({
85
- ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
86
- typed: true,
87
- casing: paramsCasing
88
- }),
89
- data: typeSchemas.request?.name ? {
90
- type: typeSchemas.request?.name,
91
- optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
92
- } : void 0,
93
- params: typeSchemas.queryParams?.name ? {
94
- type: typeSchemas.queryParams?.name,
95
- optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
96
- } : void 0,
97
- headers: typeSchemas.headerParams?.name ? {
98
- type: typeSchemas.headerParams?.name,
99
- optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
100
- } : void 0
101
- }).toConstructor();
102
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
103
- const generics = [
104
- TData,
105
- TError,
106
- TRequest ? `{${TRequest}}` : "void",
107
- "TContext"
108
- ].join(", ");
109
- return __kubb_react.FunctionParams.factory({ options: {
110
- type: `
111
- {
112
- mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
113
- client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
114
- }
115
- `,
116
- default: "{}"
117
- } });
118
- }
119
- function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
120
- const mutationKeyParams = MutationKey.getParams({
121
- pathParamsType,
122
- typeSchemas
123
- });
124
- const params = getParams$6({
125
- paramsCasing,
126
- pathParamsType,
127
- dataReturnType,
128
- typeSchemas
129
- });
130
- const clientParams = __kubb_plugin_client_components.Client.getParams({
131
- paramsCasing,
132
- paramsType,
133
- typeSchemas,
134
- pathParamsType,
135
- isConfigurable: true
136
- });
137
- const mutationParams = __kubb_react.FunctionParams.factory({
138
- ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
139
- typed: true,
140
- casing: paramsCasing
141
- }),
142
- data: typeSchemas.request?.name ? {
143
- type: typeSchemas.request?.name,
144
- optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
145
- } : void 0,
146
- params: typeSchemas.queryParams?.name ? {
147
- type: typeSchemas.queryParams?.name,
148
- optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
149
- } : void 0,
150
- headers: typeSchemas.headerParams?.name ? {
151
- type: typeSchemas.headerParams?.name,
152
- optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
153
- } : void 0
154
- });
155
- const dataParams = __kubb_react.FunctionParams.factory({ data: {
156
- mode: "object",
157
- children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
158
- if (value) acc[key] = {
159
- ...value,
160
- type: void 0
161
- };
162
- return acc;
163
- }, {})
164
- } });
165
- const TRequest = mutationParams.toConstructor();
166
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
167
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
168
- const generics = [
169
- TData,
170
- TError,
171
- TRequest ? `{${TRequest}}` : "void",
172
- "TContext"
173
- ].join(", ");
174
- return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
175
- name,
176
- isExportable: true,
177
- isIndexable: true,
178
- children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
179
- name,
180
- export: true,
181
- params: params.toConstructor(),
182
- JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
183
- generics: ["TContext"],
184
- children: `
185
- const { mutation = {}, client: config = {} } = options ?? {}
186
- const { client: queryClient, ...mutationOptions } = mutation;
187
- const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
188
-
189
- return useMutation<${generics}>({
190
- mutationFn: async(${dataParams.toConstructor()}) => {
191
- return ${clientName}(${clientParams.toCall()})
192
- },
193
- mutationKey,
194
- ...mutationOptions
195
- }, queryClient)
196
- `
197
- })
198
- });
199
- }
200
-
201
- //#endregion
202
37
  //#region src/components/QueryKey.tsx
203
- function getParams$5({ pathParamsType, paramsCasing, typeSchemas }) {
38
+ function getParams$8({ pathParamsType, paramsCasing, typeSchemas }) {
204
39
  return __kubb_react.FunctionParams.factory({
205
40
  pathParams: {
206
41
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -219,7 +54,7 @@ function getParams$5({ pathParamsType, paramsCasing, typeSchemas }) {
219
54
  } : void 0
220
55
  });
221
56
  }
222
- const getTransformer = ({ operation, schemas, casing }) => {
57
+ const getTransformer$1 = ({ operation, schemas, casing }) => {
223
58
  return [
224
59
  new __kubb_core_utils.URLPath(operation.path, { casing }).toObject({
225
60
  type: "path",
@@ -229,8 +64,8 @@ const getTransformer = ({ operation, schemas, casing }) => {
229
64
  schemas.request?.name ? "...(data ? [data] : [])" : void 0
230
65
  ].filter(Boolean);
231
66
  };
232
- function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
233
- const params = getParams$5({
67
+ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
68
+ const params = getParams$8({
234
69
  pathParamsType,
235
70
  typeSchemas,
236
71
  paramsCasing
@@ -263,12 +98,12 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
263
98
  })
264
99
  })] });
265
100
  }
266
- QueryKey.getParams = getParams$5;
267
- QueryKey.getTransformer = getTransformer;
101
+ QueryKey.getParams = getParams$8;
102
+ QueryKey.getTransformer = getTransformer$1;
268
103
 
269
104
  //#endregion
270
105
  //#region src/components/QueryOptions.tsx
271
- function getParams$4({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
106
+ function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
272
107
  if (paramsType === "object") return __kubb_react.FunctionParams.factory({
273
108
  data: {
274
109
  mode: "object",
@@ -324,7 +159,7 @@ function getParams$4({ paramsType, paramsCasing, pathParamsType, typeSchemas })
324
159
  });
325
160
  }
326
161
  function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
327
- const params = getParams$4({
162
+ const params = getParams$7({
328
163
  paramsType,
329
164
  paramsCasing,
330
165
  pathParamsType,
@@ -368,13 +203,11 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
368
203
  })
369
204
  });
370
205
  }
371
- QueryOptions.getParams = getParams$4;
206
+ QueryOptions.getParams = getParams$7;
372
207
 
373
208
  //#endregion
374
- //#region src/components/Query.tsx
375
- function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
376
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
377
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
209
+ //#region src/components/InfiniteQuery.tsx
210
+ function getParams$6({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
378
211
  if (paramsType === "object") return __kubb_react.FunctionParams.factory({
379
212
  data: {
380
213
  mode: "object",
@@ -400,13 +233,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType,
400
233
  options: {
401
234
  type: `
402
235
  {
403
- query?: Partial<QueryObserverOptions<${[
404
- TData,
405
- TError,
406
- "TData",
407
- "TQueryData",
408
- "TQueryKey"
409
- ].join(", ")}>> & { client?: QueryClient },
236
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
410
237
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
411
238
  }
412
239
  `,
@@ -437,13 +264,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType,
437
264
  options: {
438
265
  type: `
439
266
  {
440
- query?: Partial<QueryObserverOptions<${[
441
- TData,
442
- TError,
443
- "TData",
444
- "TQueryData",
445
- "TQueryKey"
446
- ].join(", ")}>> & { client?: QueryClient },
267
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
447
268
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
448
269
  }
449
270
  `,
@@ -451,13 +272,17 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType,
451
272
  }
452
273
  });
453
274
  }
454
- function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
455
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
456
- const returnType = `UseQueryResult<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
275
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, queryParam }) {
276
+ const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
277
+ const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
278
+ const pageParamType = (queryParam && typeSchemas.queryParams?.name ? `NonNullable<${typeSchemas.queryParams?.name}['${queryParam}']>` : void 0) ?? "number";
279
+ const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
457
280
  const generics = [
458
- `TData = ${TData}`,
459
- `TQueryData = ${TData}`,
460
- `TQueryKey extends QueryKey = ${queryKeyTypeName}`
281
+ `TQueryFnData = ${responseType}`,
282
+ `TError = ${errorType}`,
283
+ "TData = InfiniteData<TQueryFnData>",
284
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
285
+ `TPageParam = ${pageParamType}`
461
286
  ];
462
287
  const queryKeyParams = QueryKey.getParams({
463
288
  pathParamsType,
@@ -470,12 +295,12 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
470
295
  typeSchemas,
471
296
  paramsCasing
472
297
  });
473
- const params = getParams$3({
298
+ const params = getParams$6({
474
299
  paramsCasing,
475
300
  paramsType,
476
301
  pathParamsType,
477
- dataReturnType,
478
- typeSchemas
302
+ typeSchemas,
303
+ pageParamGeneric: "TPageParam"
479
304
  });
480
305
  const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
481
306
  return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
@@ -493,11 +318,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
493
318
  const { client: queryClient, ...queryOptions } = queryConfig
494
319
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
495
320
 
496
- const query = useQuery({
321
+ const query = useInfiniteQuery({
497
322
  ...${queryOptions},
498
323
  queryKey,
499
324
  ...queryOptions
500
- } as unknown as QueryObserverOptions, queryClient) as ${returnType}
325
+ } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
501
326
 
502
327
  query.queryKey = queryKey as TQueryKey
503
328
 
@@ -506,11 +331,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
506
331
  })
507
332
  });
508
333
  }
509
- Query.getParams = getParams$3;
334
+ InfiniteQuery.getParams = getParams$6;
510
335
 
511
336
  //#endregion
512
337
  //#region src/components/InfiniteQueryOptions.tsx
513
- function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
338
+ function getParams$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
514
339
  if (paramsType === "object") return __kubb_react.FunctionParams.factory({
515
340
  data: {
516
341
  mode: "object",
@@ -569,7 +394,7 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
569
394
  const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
570
395
  const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
571
396
  const pageParamType = queryParam && typeSchemas.queryParams?.name ? `NonNullable<${typeSchemas.queryParams?.name}['${queryParam}']>` : "number";
572
- const params = getParams$2({
397
+ const params = getParams$5({
573
398
  paramsType,
574
399
  paramsCasing,
575
400
  pathParamsType,
@@ -648,11 +473,235 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
648
473
  })
649
474
  });
650
475
  }
651
- InfiniteQueryOptions.getParams = getParams$2;
476
+ InfiniteQueryOptions.getParams = getParams$5;
652
477
 
653
478
  //#endregion
654
- //#region src/components/InfiniteQuery.tsx
655
- function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
479
+ //#region src/components/MutationKey.tsx
480
+ function getParams$4({}) {
481
+ return __kubb_react.FunctionParams.factory({});
482
+ }
483
+ const getTransformer = ({ operation, casing }) => {
484
+ return [`{ url: '${new __kubb_core_utils.URLPath(operation.path, { casing }).toURLPath()}' }`];
485
+ };
486
+ function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }) {
487
+ const params = getParams$4({
488
+ pathParamsType,
489
+ typeSchemas
490
+ });
491
+ const keys = transformer({
492
+ operation,
493
+ schemas: typeSchemas,
494
+ casing: paramsCasing
495
+ });
496
+ 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, {
497
+ name,
498
+ isExportable: true,
499
+ isIndexable: true,
500
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function.Arrow, {
501
+ name,
502
+ export: true,
503
+ params: params.toConstructor(),
504
+ singleLine: true,
505
+ children: `[${keys.join(", ")}] as const`
506
+ })
507
+ }), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
508
+ name: typeName,
509
+ isExportable: true,
510
+ isIndexable: true,
511
+ isTypeOnly: true,
512
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
513
+ name: typeName,
514
+ export: true,
515
+ children: `ReturnType<typeof ${name}>`
516
+ })
517
+ })] });
518
+ }
519
+ MutationKey.getParams = getParams$4;
520
+ MutationKey.getTransformer = getTransformer;
521
+
522
+ //#endregion
523
+ //#region src/components/MutationOptions.tsx
524
+ function getParams$3({ typeSchemas }) {
525
+ return __kubb_react.FunctionParams.factory({ config: {
526
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
527
+ default: "{}"
528
+ } });
529
+ }
530
+ function MutationOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
531
+ const params = getParams$3({ typeSchemas });
532
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
533
+ const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error";
534
+ const clientParams = __kubb_plugin_client_components.Client.getParams({
535
+ typeSchemas,
536
+ paramsCasing,
537
+ paramsType,
538
+ pathParamsType,
539
+ isConfigurable: true
540
+ });
541
+ const mutationKeyParams = MutationKey.getParams({
542
+ pathParamsType,
543
+ typeSchemas
544
+ });
545
+ const mutationParams = __kubb_react.FunctionParams.factory({
546
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
547
+ typed: true,
548
+ casing: paramsCasing
549
+ }),
550
+ data: typeSchemas.request?.name ? {
551
+ type: typeSchemas.request?.name,
552
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
553
+ } : void 0,
554
+ params: typeSchemas.queryParams?.name ? {
555
+ type: typeSchemas.queryParams?.name,
556
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
557
+ } : void 0,
558
+ headers: typeSchemas.headerParams?.name ? {
559
+ type: typeSchemas.headerParams?.name,
560
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
561
+ } : void 0
562
+ });
563
+ const dataParams = __kubb_react.FunctionParams.factory({ data: {
564
+ mode: "object",
565
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
566
+ if (value) acc[key] = {
567
+ ...value,
568
+ type: void 0
569
+ };
570
+ return acc;
571
+ }, {})
572
+ } });
573
+ const TRequest = mutationParams.toConstructor();
574
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
575
+ name,
576
+ isExportable: true,
577
+ isIndexable: true,
578
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
579
+ name,
580
+ export: true,
581
+ params: params.toConstructor(),
582
+ children: `
583
+ const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
584
+ return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : "void"}, typeof mutationKey>({
585
+ mutationKey,
586
+ mutationFn: async(${dataParams.toConstructor()}) => {
587
+ return ${clientName}(${clientParams.toCall()})
588
+ },
589
+ })
590
+ `
591
+ })
592
+ });
593
+ }
594
+ MutationOptions.getParams = getParams$3;
595
+
596
+ //#endregion
597
+ //#region src/components/Mutation.tsx
598
+ function getParams$2({ paramsCasing, dataReturnType, typeSchemas }) {
599
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
600
+ const TRequest = __kubb_react.FunctionParams.factory({
601
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
602
+ typed: true,
603
+ casing: paramsCasing
604
+ }),
605
+ data: typeSchemas.request?.name ? {
606
+ type: typeSchemas.request?.name,
607
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
608
+ } : void 0,
609
+ params: typeSchemas.queryParams?.name ? {
610
+ type: typeSchemas.queryParams?.name,
611
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
612
+ } : void 0,
613
+ headers: typeSchemas.headerParams?.name ? {
614
+ type: typeSchemas.headerParams?.name,
615
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
616
+ } : void 0
617
+ }).toConstructor();
618
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
619
+ const generics = [
620
+ TData,
621
+ TError,
622
+ TRequest ? `{${TRequest}}` : "void",
623
+ "TContext"
624
+ ].join(", ");
625
+ return __kubb_react.FunctionParams.factory({ options: {
626
+ type: `
627
+ {
628
+ mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
629
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
630
+ }
631
+ `,
632
+ default: "{}"
633
+ } });
634
+ }
635
+ function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
636
+ const mutationKeyParams = MutationKey.getParams({
637
+ pathParamsType,
638
+ typeSchemas
639
+ });
640
+ const params = getParams$2({
641
+ paramsCasing,
642
+ pathParamsType,
643
+ dataReturnType,
644
+ typeSchemas
645
+ });
646
+ const mutationParams = __kubb_react.FunctionParams.factory({
647
+ ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
648
+ typed: true,
649
+ casing: paramsCasing
650
+ }),
651
+ data: typeSchemas.request?.name ? {
652
+ type: typeSchemas.request?.name,
653
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
654
+ } : void 0,
655
+ params: typeSchemas.queryParams?.name ? {
656
+ type: typeSchemas.queryParams?.name,
657
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
658
+ } : void 0,
659
+ headers: typeSchemas.headerParams?.name ? {
660
+ type: typeSchemas.headerParams?.name,
661
+ optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
662
+ } : void 0
663
+ });
664
+ const mutationOptionsParams = MutationOptions.getParams({ typeSchemas });
665
+ const TRequest = mutationParams.toConstructor();
666
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
667
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
668
+ const returnType = `UseMutationOptions<${[
669
+ TData,
670
+ TError,
671
+ TRequest ? `{${TRequest}}` : "void",
672
+ "TContext"
673
+ ].join(", ")}>`;
674
+ const mutationOptions = `${mutationOptionsName}(${mutationOptionsParams.toCall()})`;
675
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
676
+ name,
677
+ isExportable: true,
678
+ isIndexable: true,
679
+ children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
680
+ name,
681
+ export: true,
682
+ params: params.toConstructor(),
683
+ JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
684
+ generics: ["TContext"],
685
+ children: `
686
+ const { mutation = {}, client: config = {} } = options ?? {}
687
+ const { client: queryClient, ...mutationOptions } = mutation;
688
+ const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
689
+
690
+ return useMutation({
691
+ ...${mutationOptions},
692
+ mutationKey,
693
+ ...mutationOptions
694
+ } as unknown as UseMutationOptions, queryClient) as ${returnType}
695
+ `
696
+ })
697
+ });
698
+ }
699
+
700
+ //#endregion
701
+ //#region src/components/Query.tsx
702
+ function getParams$1({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
703
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
704
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
656
705
  if (paramsType === "object") return __kubb_react.FunctionParams.factory({
657
706
  data: {
658
707
  mode: "object",
@@ -678,7 +727,13 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
678
727
  options: {
679
728
  type: `
680
729
  {
681
- query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
730
+ query?: Partial<QueryObserverOptions<${[
731
+ TData,
732
+ TError,
733
+ "TData",
734
+ "TQueryData",
735
+ "TQueryKey"
736
+ ].join(", ")}>> & { client?: QueryClient },
682
737
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
683
738
  }
684
739
  `,
@@ -709,7 +764,13 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
709
764
  options: {
710
765
  type: `
711
766
  {
712
- query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
767
+ query?: Partial<QueryObserverOptions<${[
768
+ TData,
769
+ TError,
770
+ "TData",
771
+ "TQueryData",
772
+ "TQueryKey"
773
+ ].join(", ")}>> & { client?: QueryClient },
713
774
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
714
775
  }
715
776
  `,
@@ -717,17 +778,13 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
717
778
  }
718
779
  });
719
780
  }
720
- function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, queryParam }) {
721
- const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
722
- const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
723
- const pageParamType = (queryParam && typeSchemas.queryParams?.name ? `NonNullable<${typeSchemas.queryParams?.name}['${queryParam}']>` : void 0) ?? "number";
724
- const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
781
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
782
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
783
+ const returnType = `UseQueryResult<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
725
784
  const generics = [
726
- `TQueryFnData = ${responseType}`,
727
- `TError = ${errorType}`,
728
- "TData = InfiniteData<TQueryFnData>",
729
- `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
730
- `TPageParam = ${pageParamType}`
785
+ `TData = ${TData}`,
786
+ `TQueryData = ${TData}`,
787
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
731
788
  ];
732
789
  const queryKeyParams = QueryKey.getParams({
733
790
  pathParamsType,
@@ -744,8 +801,8 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
744
801
  paramsCasing,
745
802
  paramsType,
746
803
  pathParamsType,
747
- typeSchemas,
748
- pageParamGeneric: "TPageParam"
804
+ dataReturnType,
805
+ typeSchemas
749
806
  });
750
807
  const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
751
808
  return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
@@ -763,11 +820,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
763
820
  const { client: queryClient, ...queryOptions } = queryConfig
764
821
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
765
822
 
766
- const query = useInfiniteQuery({
823
+ const query = useQuery({
767
824
  ...${queryOptions},
768
825
  queryKey,
769
826
  ...queryOptions
770
- } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
827
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
771
828
 
772
829
  query.queryKey = queryKey as TQueryKey
773
830
 
@@ -776,7 +833,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
776
833
  })
777
834
  });
778
835
  }
779
- InfiniteQuery.getParams = getParams$1;
836
+ Query.getParams = getParams$1;
780
837
 
781
838
  //#endregion
782
839
  //#region src/components/SuspenseQuery.tsx
@@ -942,6 +999,12 @@ Object.defineProperty(exports, 'MutationKey', {
942
999
  return MutationKey;
943
1000
  }
944
1001
  });
1002
+ Object.defineProperty(exports, 'MutationOptions', {
1003
+ enumerable: true,
1004
+ get: function () {
1005
+ return MutationOptions;
1006
+ }
1007
+ });
945
1008
  Object.defineProperty(exports, 'Query', {
946
1009
  enumerable: true,
947
1010
  get: function () {
@@ -972,4 +1035,4 @@ Object.defineProperty(exports, '__toESM', {
972
1035
  return __toESM;
973
1036
  }
974
1037
  });
975
- //# sourceMappingURL=components-CQAsEApg.cjs.map
1038
+ //# sourceMappingURL=components-DkiO4xNZ.cjs.map