@kubb/plugin-vue-query 4.4.0 → 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-B1jcCl0j.d.cts → types-BfKwA3Gv.d.cts} +188 -310
  24. package/dist/{types-DDtBZP0d.d.ts → types-I09wleY8.d.ts} +188 -310
  25. package/package.json +18 -14
  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
@@ -1,180 +1,12 @@
1
+ import { URLPath } from "@kubb/core/utils";
1
2
  import { isOptional } from "@kubb/oas";
2
- import { Client } from "@kubb/plugin-client/components";
3
3
  import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
4
4
  import { File, Function, FunctionParams, Type } from "@kubb/react-fabric";
5
- import { URLPath } from "@kubb/core/utils";
6
5
  import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
6
+ import { Client } from "@kubb/plugin-client/components";
7
7
 
8
- //#region src/components/MutationKey.tsx
9
- function getParams$6({}) {
10
- return FunctionParams.factory({});
11
- }
12
- const getTransformer$1 = ({ operation, casing }) => {
13
- return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`];
14
- };
15
- function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
16
- const params = getParams$6({
17
- pathParamsType,
18
- typeSchemas
19
- });
20
- const keys = transformer({
21
- operation,
22
- schemas: typeSchemas,
23
- casing: paramsCasing
24
- });
25
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
26
- name,
27
- isExportable: true,
28
- isIndexable: true,
29
- children: /* @__PURE__ */ jsx(Function.Arrow, {
30
- name,
31
- export: true,
32
- params: params.toConstructor(),
33
- singleLine: true,
34
- children: `[${keys.join(", ")}] as const`
35
- })
36
- }), /* @__PURE__ */ jsx(File.Source, {
37
- name: typeName,
38
- isExportable: true,
39
- isIndexable: true,
40
- isTypeOnly: true,
41
- children: /* @__PURE__ */ jsx(Type, {
42
- name: typeName,
43
- export: true,
44
- children: `ReturnType<typeof ${name}>`
45
- })
46
- })] });
47
- }
48
- MutationKey.getParams = getParams$6;
49
- MutationKey.getTransformer = getTransformer$1;
50
-
51
- //#endregion
52
- //#region src/components/Mutation.tsx
53
- function getParams$5({ paramsCasing, dataReturnType, typeSchemas }) {
54
- const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
55
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
56
- const TRequest = FunctionParams.factory({
57
- ...getPathParams(typeSchemas.pathParams, {
58
- typed: true,
59
- casing: paramsCasing,
60
- override(item) {
61
- return {
62
- ...item,
63
- type: `MaybeRefOrGetter<${item.type}>`
64
- };
65
- }
66
- }),
67
- data: typeSchemas.request?.name ? {
68
- type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
69
- optional: isOptional(typeSchemas.request?.schema)
70
- } : void 0,
71
- params: typeSchemas.queryParams?.name ? {
72
- type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
73
- optional: isOptional(typeSchemas.queryParams?.schema)
74
- } : void 0,
75
- headers: typeSchemas.headerParams?.name ? {
76
- type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
77
- optional: isOptional(typeSchemas.headerParams?.schema)
78
- } : void 0
79
- }).toConstructor();
80
- return FunctionParams.factory({ options: {
81
- type: `
82
- {
83
- mutation?: MutationObserverOptions<${[
84
- TData,
85
- TError,
86
- TRequest ? `{${TRequest}}` : "void",
87
- "TContext"
88
- ].join(", ")}> & { client?: QueryClient },
89
- client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
90
- }
91
- `,
92
- default: "{}"
93
- } });
94
- }
95
- function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
96
- const mutationKeyParams = MutationKey.getParams({
97
- pathParamsType,
98
- typeSchemas
99
- });
100
- const params = getParams$5({
101
- paramsCasing,
102
- pathParamsType,
103
- dataReturnType,
104
- typeSchemas
105
- });
106
- const clientParams = Client.getParams({
107
- paramsCasing,
108
- paramsType,
109
- typeSchemas,
110
- pathParamsType,
111
- isConfigurable: true
112
- });
113
- const mutationParams = FunctionParams.factory({
114
- ...getPathParams(typeSchemas.pathParams, {
115
- typed: true,
116
- casing: paramsCasing
117
- }),
118
- data: typeSchemas.request?.name ? {
119
- type: typeSchemas.request?.name,
120
- optional: isOptional(typeSchemas.request?.schema)
121
- } : void 0,
122
- params: typeSchemas.queryParams?.name ? {
123
- type: typeSchemas.queryParams?.name,
124
- optional: isOptional(typeSchemas.queryParams?.schema)
125
- } : void 0,
126
- headers: typeSchemas.headerParams?.name ? {
127
- type: typeSchemas.headerParams?.name,
128
- optional: isOptional(typeSchemas.headerParams?.schema)
129
- } : void 0
130
- });
131
- const dataParams = FunctionParams.factory({ data: {
132
- mode: "object",
133
- children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
134
- if (value) acc[key] = {
135
- ...value,
136
- type: void 0
137
- };
138
- return acc;
139
- }, {})
140
- } });
141
- const TRequest = mutationParams.toConstructor();
142
- const generics = [
143
- dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
144
- `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
145
- TRequest ? `{${TRequest}}` : "void",
146
- "TContext"
147
- ].join(", ");
148
- return /* @__PURE__ */ jsx(File.Source, {
149
- name,
150
- isExportable: true,
151
- isIndexable: true,
152
- children: /* @__PURE__ */ jsx(Function, {
153
- name,
154
- export: true,
155
- params: params.toConstructor(),
156
- JSDoc: { comments: getComments(operation) },
157
- generics: ["TContext"],
158
- children: `
159
- const { mutation = {}, client: config = {} } = options ?? {}
160
- const { client: queryClient, ...mutationOptions } = mutation;
161
- const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
162
-
163
- return useMutation<${generics}>({
164
- mutationFn: async(${dataParams.toConstructor()}) => {
165
- return ${clientName}(${clientParams.toCall()})
166
- },
167
- mutationKey,
168
- ...mutationOptions
169
- }, queryClient)
170
- `
171
- })
172
- });
173
- }
174
-
175
- //#endregion
176
8
  //#region src/components/QueryKey.tsx
177
- function getParams$4({ pathParamsType, paramsCasing, typeSchemas }) {
9
+ function getParams$6({ pathParamsType, paramsCasing, typeSchemas }) {
178
10
  return FunctionParams.factory({
179
11
  pathParams: {
180
12
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -199,7 +31,7 @@ function getParams$4({ pathParamsType, paramsCasing, typeSchemas }) {
199
31
  } : void 0
200
32
  });
201
33
  }
202
- const getTransformer = ({ operation, schemas, casing }) => {
34
+ const getTransformer$1 = ({ operation, schemas, casing }) => {
203
35
  return [
204
36
  new URLPath(operation.path, { casing }).toObject({
205
37
  type: "path",
@@ -209,8 +41,8 @@ const getTransformer = ({ operation, schemas, casing }) => {
209
41
  schemas.request?.name ? "...(data ? [data] : [])" : void 0
210
42
  ].filter(Boolean);
211
43
  };
212
- function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
213
- const params = getParams$4({
44
+ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
45
+ const params = getParams$6({
214
46
  pathParamsType,
215
47
  typeSchemas,
216
48
  paramsCasing
@@ -243,12 +75,12 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
243
75
  })
244
76
  })] });
245
77
  }
246
- QueryKey.getParams = getParams$4;
247
- QueryKey.getTransformer = getTransformer;
78
+ QueryKey.getParams = getParams$6;
79
+ QueryKey.getTransformer = getTransformer$1;
248
80
 
249
81
  //#endregion
250
82
  //#region src/components/QueryOptions.tsx
251
- function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
83
+ function getParams$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
252
84
  if (paramsType === "object") return FunctionParams.factory({
253
85
  data: {
254
86
  mode: "object",
@@ -318,7 +150,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas })
318
150
  function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
319
151
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
320
152
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
321
- const params = getParams$3({
153
+ const params = getParams$5({
322
154
  paramsType,
323
155
  paramsCasing,
324
156
  pathParamsType,
@@ -362,11 +194,11 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
362
194
  })
363
195
  });
364
196
  }
365
- QueryOptions.getParams = getParams$3;
197
+ QueryOptions.getParams = getParams$5;
366
198
 
367
199
  //#endregion
368
- //#region src/components/Query.tsx
369
- function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
200
+ //#region src/components/InfiniteQuery.tsx
201
+ function getParams$4({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
370
202
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
371
203
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
372
204
  if (paramsType === "object") return FunctionParams.factory({
@@ -400,12 +232,12 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
400
232
  options: {
401
233
  type: `
402
234
  {
403
- query?: Partial<QueryObserverOptions<${[
235
+ query?: Partial<InfiniteQueryObserverOptions<${[
404
236
  TData,
405
237
  TError,
406
- "TData",
407
238
  "TQueryData",
408
- "TQueryKey"
239
+ "TQueryKey",
240
+ "TQueryData"
409
241
  ].join(", ")}>> & { client?: QueryClient },
410
242
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
411
243
  }
@@ -443,12 +275,12 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
443
275
  options: {
444
276
  type: `
445
277
  {
446
- query?: Partial<QueryObserverOptions<${[
278
+ query?: Partial<InfiniteQueryObserverOptions<${[
447
279
  TData,
448
280
  TError,
449
- "TData",
450
281
  "TQueryData",
451
- "TQueryKey"
282
+ "TQueryKey",
283
+ "TQueryData"
452
284
  ].join(", ")}>> & { client?: QueryClient },
453
285
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
454
286
  }
@@ -457,11 +289,11 @@ function getParams$2({ paramsCasing, paramsType, pathParamsType, dataReturnType,
457
289
  }
458
290
  });
459
291
  }
460
- function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
292
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
461
293
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
462
- const returnType = `UseQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
294
+ const returnType = `UseInfiniteQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
463
295
  const generics = [
464
- `TData = ${TData}`,
296
+ `TData = InfiniteData<${TData}>`,
465
297
  `TQueryData = ${TData}`,
466
298
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
467
299
  ];
@@ -476,7 +308,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
476
308
  typeSchemas,
477
309
  paramsCasing
478
310
  });
479
- const params = getParams$2({
311
+ const params = getParams$4({
480
312
  paramsCasing,
481
313
  paramsType,
482
314
  pathParamsType,
@@ -499,11 +331,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
499
331
  const { client: queryClient, ...queryOptions } = queryConfig
500
332
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
501
333
 
502
- const query = useQuery({
334
+ const query = useInfiniteQuery({
503
335
  ...${queryOptions},
504
336
  queryKey,
505
337
  ...queryOptions
506
- } as unknown as QueryObserverOptions, queryClient) as ${returnType}
338
+ } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
507
339
 
508
340
  query.queryKey = queryKey as TQueryKey
509
341
 
@@ -512,11 +344,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
512
344
  })
513
345
  });
514
346
  }
515
- Query.getParams = getParams$2;
347
+ InfiniteQuery.getParams = getParams$4;
516
348
 
517
349
  //#endregion
518
350
  //#region src/components/InfiniteQueryOptions.tsx
519
- function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
351
+ function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
520
352
  if (paramsType === "object") return FunctionParams.factory({
521
353
  data: {
522
354
  mode: "object",
@@ -586,7 +418,7 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas })
586
418
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, paramsType, paramsCasing, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
587
419
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
588
420
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
589
- const params = getParams$1({
421
+ const params = getParams$3({
590
422
  paramsType,
591
423
  paramsCasing,
592
424
  pathParamsType,
@@ -645,11 +477,179 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
645
477
  })
646
478
  });
647
479
  }
648
- InfiniteQueryOptions.getParams = getParams$1;
480
+ InfiniteQueryOptions.getParams = getParams$3;
649
481
 
650
482
  //#endregion
651
- //#region src/components/InfiniteQuery.tsx
652
- function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
483
+ //#region src/components/MutationKey.tsx
484
+ function getParams$2({}) {
485
+ return FunctionParams.factory({});
486
+ }
487
+ const getTransformer = ({ operation, casing }) => {
488
+ return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`];
489
+ };
490
+ function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
491
+ const params = getParams$2({
492
+ pathParamsType,
493
+ typeSchemas
494
+ });
495
+ const keys = transformer({
496
+ operation,
497
+ schemas: typeSchemas,
498
+ casing: paramsCasing
499
+ });
500
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
501
+ name,
502
+ isExportable: true,
503
+ isIndexable: true,
504
+ children: /* @__PURE__ */ jsx(Function.Arrow, {
505
+ name,
506
+ export: true,
507
+ params: params.toConstructor(),
508
+ singleLine: true,
509
+ children: `[${keys.join(", ")}] as const`
510
+ })
511
+ }), /* @__PURE__ */ jsx(File.Source, {
512
+ name: typeName,
513
+ isExportable: true,
514
+ isIndexable: true,
515
+ isTypeOnly: true,
516
+ children: /* @__PURE__ */ jsx(Type, {
517
+ name: typeName,
518
+ export: true,
519
+ children: `ReturnType<typeof ${name}>`
520
+ })
521
+ })] });
522
+ }
523
+ MutationKey.getParams = getParams$2;
524
+ MutationKey.getTransformer = getTransformer;
525
+
526
+ //#endregion
527
+ //#region src/components/Mutation.tsx
528
+ function getParams$1({ paramsCasing, dataReturnType, typeSchemas }) {
529
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
530
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
531
+ const TRequest = FunctionParams.factory({
532
+ ...getPathParams(typeSchemas.pathParams, {
533
+ typed: true,
534
+ casing: paramsCasing,
535
+ override(item) {
536
+ return {
537
+ ...item,
538
+ type: `MaybeRefOrGetter<${item.type}>`
539
+ };
540
+ }
541
+ }),
542
+ data: typeSchemas.request?.name ? {
543
+ type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
544
+ optional: isOptional(typeSchemas.request?.schema)
545
+ } : void 0,
546
+ params: typeSchemas.queryParams?.name ? {
547
+ type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
548
+ optional: isOptional(typeSchemas.queryParams?.schema)
549
+ } : void 0,
550
+ headers: typeSchemas.headerParams?.name ? {
551
+ type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
552
+ optional: isOptional(typeSchemas.headerParams?.schema)
553
+ } : void 0
554
+ }).toConstructor();
555
+ return FunctionParams.factory({ options: {
556
+ type: `
557
+ {
558
+ mutation?: MutationObserverOptions<${[
559
+ TData,
560
+ TError,
561
+ TRequest ? `{${TRequest}}` : "void",
562
+ "TContext"
563
+ ].join(", ")}> & { client?: QueryClient },
564
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
565
+ }
566
+ `,
567
+ default: "{}"
568
+ } });
569
+ }
570
+ function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
571
+ const mutationKeyParams = MutationKey.getParams({
572
+ pathParamsType,
573
+ typeSchemas
574
+ });
575
+ const params = getParams$1({
576
+ paramsCasing,
577
+ pathParamsType,
578
+ dataReturnType,
579
+ typeSchemas
580
+ });
581
+ const clientParams = Client.getParams({
582
+ paramsCasing,
583
+ paramsType,
584
+ typeSchemas,
585
+ pathParamsType,
586
+ isConfigurable: true
587
+ });
588
+ const mutationParams = FunctionParams.factory({
589
+ ...getPathParams(typeSchemas.pathParams, {
590
+ typed: true,
591
+ casing: paramsCasing
592
+ }),
593
+ data: typeSchemas.request?.name ? {
594
+ type: typeSchemas.request?.name,
595
+ optional: isOptional(typeSchemas.request?.schema)
596
+ } : void 0,
597
+ params: typeSchemas.queryParams?.name ? {
598
+ type: typeSchemas.queryParams?.name,
599
+ optional: isOptional(typeSchemas.queryParams?.schema)
600
+ } : void 0,
601
+ headers: typeSchemas.headerParams?.name ? {
602
+ type: typeSchemas.headerParams?.name,
603
+ optional: isOptional(typeSchemas.headerParams?.schema)
604
+ } : void 0
605
+ });
606
+ const dataParams = FunctionParams.factory({ data: {
607
+ mode: "object",
608
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
609
+ if (value) acc[key] = {
610
+ ...value,
611
+ type: void 0
612
+ };
613
+ return acc;
614
+ }, {})
615
+ } });
616
+ const TRequest = mutationParams.toConstructor();
617
+ const generics = [
618
+ dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
619
+ `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
620
+ TRequest ? `{${TRequest}}` : "void",
621
+ "TContext"
622
+ ].join(", ");
623
+ return /* @__PURE__ */ jsx(File.Source, {
624
+ name,
625
+ isExportable: true,
626
+ isIndexable: true,
627
+ children: /* @__PURE__ */ jsx(Function, {
628
+ name,
629
+ export: true,
630
+ params: params.toConstructor(),
631
+ JSDoc: { comments: getComments(operation) },
632
+ generics: ["TContext"],
633
+ children: `
634
+ const { mutation = {}, client: config = {} } = options ?? {}
635
+ const { client: queryClient, ...mutationOptions } = mutation;
636
+ const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
637
+
638
+ return useMutation<${generics}>({
639
+ mutationFn: async(${dataParams.toConstructor()}) => {
640
+ return ${clientName}(${clientParams.toCall()})
641
+ },
642
+ mutationKey,
643
+ ...mutationOptions
644
+ }, queryClient)
645
+ `
646
+ })
647
+ });
648
+ }
649
+
650
+ //#endregion
651
+ //#region src/components/Query.tsx
652
+ function getParams({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
653
653
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
654
654
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
655
655
  if (paramsType === "object") return FunctionParams.factory({
@@ -683,12 +683,12 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
683
683
  options: {
684
684
  type: `
685
685
  {
686
- query?: Partial<InfiniteQueryObserverOptions<${[
686
+ query?: Partial<QueryObserverOptions<${[
687
687
  TData,
688
688
  TError,
689
+ "TData",
689
690
  "TQueryData",
690
- "TQueryKey",
691
- "TQueryData"
691
+ "TQueryKey"
692
692
  ].join(", ")}>> & { client?: QueryClient },
693
693
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
694
694
  }
@@ -726,12 +726,12 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
726
726
  options: {
727
727
  type: `
728
728
  {
729
- query?: Partial<InfiniteQueryObserverOptions<${[
729
+ query?: Partial<QueryObserverOptions<${[
730
730
  TData,
731
731
  TError,
732
+ "TData",
732
733
  "TQueryData",
733
- "TQueryKey",
734
- "TQueryData"
734
+ "TQueryKey"
735
735
  ].join(", ")}>> & { client?: QueryClient },
736
736
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
737
737
  }
@@ -740,11 +740,11 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
740
740
  }
741
741
  });
742
742
  }
743
- function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
743
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
744
744
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
745
- const returnType = `UseInfiniteQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
745
+ const returnType = `UseQueryReturnType<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
746
746
  const generics = [
747
- `TData = InfiniteData<${TData}>`,
747
+ `TData = ${TData}`,
748
748
  `TQueryData = ${TData}`,
749
749
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
750
750
  ];
@@ -782,11 +782,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
782
782
  const { client: queryClient, ...queryOptions } = queryConfig
783
783
  const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
784
784
 
785
- const query = useInfiniteQuery({
785
+ const query = useQuery({
786
786
  ...${queryOptions},
787
787
  queryKey,
788
788
  ...queryOptions
789
- } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
789
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
790
790
 
791
791
  query.queryKey = queryKey as TQueryKey
792
792
 
@@ -795,8 +795,8 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
795
795
  })
796
796
  });
797
797
  }
798
- InfiniteQuery.getParams = getParams;
798
+ Query.getParams = getParams;
799
799
 
800
800
  //#endregion
801
- export { QueryKey as a, QueryOptions as i, InfiniteQueryOptions as n, Mutation as o, Query as r, MutationKey as s, InfiniteQuery as t };
802
- //# sourceMappingURL=components-B8p5782n.js.map
801
+ export { InfiniteQuery as a, InfiniteQueryOptions as i, Mutation as n, QueryOptions as o, MutationKey as r, QueryKey as s, Query as t };
802
+ //# sourceMappingURL=components-kADKAHgd.js.map