@kubb/plugin-react-query 4.15.0 → 4.15.2

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 (55) hide show
  1. package/dist/{components-CX83mklO.js → components-DVc9iach.js} +261 -218
  2. package/dist/components-DVc9iach.js.map +1 -0
  3. package/dist/{components-7ul5AP_u.cjs → components-YtTYHVwV.cjs} +261 -218
  4. package/dist/components-YtTYHVwV.cjs.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.js +1 -1
  7. package/dist/{generators-CNv1RI1y.cjs → generators-C6VGGGTj.cjs} +2 -2
  8. package/dist/{generators-CNv1RI1y.cjs.map → generators-C6VGGGTj.cjs.map} +1 -1
  9. package/dist/{generators-CVc1Qlnh.js → generators-DzaRYGiz.js} +2 -2
  10. package/dist/{generators-CVc1Qlnh.js.map → generators-DzaRYGiz.js.map} +1 -1
  11. package/dist/generators.cjs +1 -1
  12. package/dist/generators.js +1 -1
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.js +2 -2
  15. package/package.json +9 -9
  16. package/src/components/InfiniteQuery.tsx +35 -30
  17. package/src/components/InfiniteQueryOptions.tsx +38 -27
  18. package/src/components/Mutation.tsx +3 -1
  19. package/src/components/MutationOptions.tsx +2 -2
  20. package/src/components/Query.tsx +31 -23
  21. package/src/components/QueryKey.tsx +8 -6
  22. package/src/components/QueryOptions.tsx +48 -26
  23. package/src/components/SuspenseInfiniteQuery.tsx +31 -26
  24. package/src/components/SuspenseInfiniteQueryOptions.tsx +38 -27
  25. package/src/components/SuspenseQuery.tsx +35 -24
  26. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
  27. package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
  28. package/src/generators/__snapshots__/clientPostImportPath.ts +4 -2
  29. package/src/generators/__snapshots__/findByStatusAllOptional.ts +82 -0
  30. package/src/generators/__snapshots__/findByStatusAllOptionalInline.ts +76 -0
  31. package/src/generators/__snapshots__/findByTags.ts +1 -1
  32. package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
  33. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
  34. package/src/generators/__snapshots__/findByTagsTemplateString.ts +1 -1
  35. package/src/generators/__snapshots__/findByTagsWithCustomOptions.ts +1 -1
  36. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +1 -1
  37. package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
  38. package/src/generators/__snapshots__/findInfiniteByStatusAllOptional.ts +97 -0
  39. package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
  40. package/src/generators/__snapshots__/findInfiniteByTagsNextAndPreviousParam.ts +1 -1
  41. package/src/generators/__snapshots__/findInfiniteByTagsNextParam.ts +1 -1
  42. package/src/generators/__snapshots__/findInfiniteByTagsWithCustomOptions.ts +1 -1
  43. package/src/generators/__snapshots__/findSuspenseByStatusAllOptional.ts +79 -0
  44. package/src/generators/__snapshots__/findSuspenseByTags.ts +1 -1
  45. package/src/generators/__snapshots__/findSuspenseByTagsWithCustomOptions.ts +1 -1
  46. package/src/generators/__snapshots__/findSuspenseInfiniteByStatusAllOptional.ts +97 -0
  47. package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +2 -1
  48. package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +2 -1
  49. package/src/generators/__snapshots__/findSuspenseInfiniteByTagsWithCustomOptions.ts +2 -1
  50. package/src/generators/__snapshots__/postAsQuery.ts +2 -2
  51. package/src/generators/__snapshots__/updatePetById.ts +4 -2
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +4 -2
  53. package/src/generators/__snapshots__/updatePetByIdWithCustomOptions.ts +4 -2
  54. package/dist/components-7ul5AP_u.cjs.map +0 -1
  55. package/dist/components-CX83mklO.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { URLPath, getNestedAccessor } from "@kubb/core/utils";
2
- import { isOptional } from "@kubb/oas";
2
+ import { isAllOptional, isOptional } from "@kubb/oas";
3
3
  import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
4
4
  import { File, Function, FunctionParams, Type } from "@kubb/react-fabric";
5
5
  import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
@@ -8,20 +8,20 @@ import { Client } from "@kubb/plugin-client/components";
8
8
  //#region src/components/QueryKey.tsx
9
9
  function getParams$10({ pathParamsType, paramsCasing, typeSchemas }) {
10
10
  return FunctionParams.factory({
11
- pathParams: {
11
+ pathParams: typeSchemas.pathParams?.name ? {
12
12
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
13
13
  children: getPathParams(typeSchemas.pathParams, {
14
14
  typed: true,
15
15
  casing: paramsCasing
16
16
  })
17
- },
17
+ } : void 0,
18
18
  data: typeSchemas.request?.name ? {
19
19
  type: typeSchemas.request?.name,
20
- optional: isOptional(typeSchemas.request?.schema)
20
+ default: isOptional(typeSchemas.request?.schema) ? "{}" : void 0
21
21
  } : void 0,
22
22
  params: typeSchemas.queryParams?.name ? {
23
23
  type: typeSchemas.queryParams?.name,
24
- optional: isOptional(typeSchemas.queryParams?.schema)
24
+ default: isOptional(typeSchemas.queryParams?.schema) ? "{}" : void 0
25
25
  } : void 0
26
26
  });
27
27
  }
@@ -75,33 +75,38 @@ QueryKey.getTransformer = getTransformer$1;
75
75
  //#endregion
76
76
  //#region src/components/QueryOptions.tsx
77
77
  function getParams$9({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
78
- if (paramsType === "object") return FunctionParams.factory({
79
- data: {
80
- mode: "object",
81
- children: {
82
- ...getPathParams(typeSchemas.pathParams, {
83
- typed: true,
84
- casing: paramsCasing
85
- }),
86
- data: typeSchemas.request?.name ? {
87
- type: typeSchemas.request?.name,
88
- optional: isOptional(typeSchemas.request?.schema)
89
- } : void 0,
90
- params: typeSchemas.queryParams?.name ? {
91
- type: typeSchemas.queryParams?.name,
92
- optional: isOptional(typeSchemas.queryParams?.schema)
93
- } : void 0,
94
- headers: typeSchemas.headerParams?.name ? {
95
- type: typeSchemas.headerParams?.name,
96
- optional: isOptional(typeSchemas.headerParams?.schema)
97
- } : void 0
78
+ if (paramsType === "object") {
79
+ const children = {
80
+ ...getPathParams(typeSchemas.pathParams, {
81
+ typed: true,
82
+ casing: paramsCasing
83
+ }),
84
+ data: typeSchemas.request?.name ? {
85
+ type: typeSchemas.request?.name,
86
+ optional: isOptional(typeSchemas.request?.schema)
87
+ } : void 0,
88
+ params: typeSchemas.queryParams?.name ? {
89
+ type: typeSchemas.queryParams?.name,
90
+ optional: isOptional(typeSchemas.queryParams?.schema)
91
+ } : void 0,
92
+ headers: typeSchemas.headerParams?.name ? {
93
+ type: typeSchemas.headerParams?.name,
94
+ optional: isOptional(typeSchemas.headerParams?.schema)
95
+ } : void 0
96
+ };
97
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
98
+ return FunctionParams.factory({
99
+ data: {
100
+ mode: "object",
101
+ children,
102
+ default: allChildrenAreOptional ? "{}" : void 0
103
+ },
104
+ config: {
105
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
106
+ default: "{}"
98
107
  }
99
- },
100
- config: {
101
- type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
102
- default: "{}"
103
- }
104
- });
108
+ });
109
+ }
105
110
  return FunctionParams.factory({
106
111
  pathParams: typeSchemas.pathParams?.name ? {
107
112
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -109,7 +114,7 @@ function getParams$9({ paramsType, paramsCasing, pathParamsType, typeSchemas })
109
114
  typed: true,
110
115
  casing: paramsCasing
111
116
  }),
112
- optional: isOptional(typeSchemas.pathParams?.schema)
117
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
113
118
  } : void 0,
114
119
  data: typeSchemas.request?.name ? {
115
120
  type: typeSchemas.request?.name,
@@ -150,7 +155,9 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
150
155
  typeSchemas,
151
156
  paramsCasing
152
157
  });
153
- const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
158
+ const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
159
+ return item && !item.optional && !item.default ? key : void 0;
160
+ }).filter(Boolean).join("&& ");
154
161
  const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
155
162
  return /* @__PURE__ */ jsx(File.Source, {
156
163
  name,
@@ -179,38 +186,43 @@ QueryOptions.getParams = getParams$9;
179
186
  //#endregion
180
187
  //#region src/components/InfiniteQuery.tsx
181
188
  function getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
182
- if (paramsType === "object") return FunctionParams.factory({
183
- data: {
184
- mode: "object",
185
- children: {
186
- ...getPathParams(typeSchemas.pathParams, {
187
- typed: true,
188
- casing: paramsCasing
189
- }),
190
- data: typeSchemas.request?.name ? {
191
- type: typeSchemas.request?.name,
192
- optional: isOptional(typeSchemas.request?.schema)
193
- } : void 0,
194
- params: typeSchemas.queryParams?.name ? {
195
- type: typeSchemas.queryParams?.name,
196
- optional: isOptional(typeSchemas.queryParams?.schema)
197
- } : void 0,
198
- headers: typeSchemas.headerParams?.name ? {
199
- type: typeSchemas.headerParams?.name,
200
- optional: isOptional(typeSchemas.headerParams?.schema)
201
- } : void 0
202
- }
203
- },
204
- options: {
205
- type: `
189
+ if (paramsType === "object") {
190
+ const children = {
191
+ ...getPathParams(typeSchemas.pathParams, {
192
+ typed: true,
193
+ casing: paramsCasing
194
+ }),
195
+ data: typeSchemas.request?.name ? {
196
+ type: typeSchemas.request?.name,
197
+ optional: isOptional(typeSchemas.request?.schema)
198
+ } : void 0,
199
+ params: typeSchemas.queryParams?.name ? {
200
+ type: typeSchemas.queryParams?.name,
201
+ optional: isOptional(typeSchemas.queryParams?.schema)
202
+ } : void 0,
203
+ headers: typeSchemas.headerParams?.name ? {
204
+ type: typeSchemas.headerParams?.name,
205
+ optional: isOptional(typeSchemas.headerParams?.schema)
206
+ } : void 0
207
+ };
208
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
209
+ return FunctionParams.factory({
210
+ data: {
211
+ mode: "object",
212
+ children,
213
+ default: allChildrenAreOptional ? "{}" : void 0
214
+ },
215
+ options: {
216
+ type: `
206
217
  {
207
218
  query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
208
219
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
209
220
  }
210
221
  `,
211
- default: "{}"
212
- }
213
- });
222
+ default: "{}"
223
+ }
224
+ });
225
+ }
214
226
  return FunctionParams.factory({
215
227
  pathParams: typeSchemas.pathParams?.name ? {
216
228
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -218,7 +230,7 @@ function getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
218
230
  typed: true,
219
231
  casing: paramsCasing
220
232
  }),
221
- optional: isOptional(typeSchemas.pathParams?.schema)
233
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
222
234
  } : void 0,
223
235
  data: typeSchemas.request?.name ? {
224
236
  type: typeSchemas.request?.name,
@@ -314,33 +326,38 @@ InfiniteQuery.getParams = getParams$8;
314
326
  //#endregion
315
327
  //#region src/components/InfiniteQueryOptions.tsx
316
328
  function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
317
- if (paramsType === "object") return FunctionParams.factory({
318
- data: {
319
- mode: "object",
320
- children: {
321
- ...getPathParams(typeSchemas.pathParams, {
322
- typed: true,
323
- casing: paramsCasing
324
- }),
325
- data: typeSchemas.request?.name ? {
326
- type: typeSchemas.request?.name,
327
- optional: isOptional(typeSchemas.request?.schema)
328
- } : void 0,
329
- params: typeSchemas.queryParams?.name ? {
330
- type: typeSchemas.queryParams?.name,
331
- optional: isOptional(typeSchemas.queryParams?.schema)
332
- } : void 0,
333
- headers: typeSchemas.headerParams?.name ? {
334
- type: typeSchemas.headerParams?.name,
335
- optional: isOptional(typeSchemas.headerParams?.schema)
336
- } : void 0
329
+ if (paramsType === "object") {
330
+ const children = {
331
+ ...getPathParams(typeSchemas.pathParams, {
332
+ typed: true,
333
+ casing: paramsCasing
334
+ }),
335
+ data: typeSchemas.request?.name ? {
336
+ type: typeSchemas.request?.name,
337
+ optional: isOptional(typeSchemas.request?.schema)
338
+ } : void 0,
339
+ params: typeSchemas.queryParams?.name ? {
340
+ type: typeSchemas.queryParams?.name,
341
+ optional: isOptional(typeSchemas.queryParams?.schema)
342
+ } : void 0,
343
+ headers: typeSchemas.headerParams?.name ? {
344
+ type: typeSchemas.headerParams?.name,
345
+ optional: isOptional(typeSchemas.headerParams?.schema)
346
+ } : void 0
347
+ };
348
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
349
+ return FunctionParams.factory({
350
+ data: {
351
+ mode: "object",
352
+ children,
353
+ default: allChildrenAreOptional ? "{}" : void 0
354
+ },
355
+ config: {
356
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
357
+ default: "{}"
337
358
  }
338
- },
339
- config: {
340
- type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
341
- default: "{}"
342
- }
343
- });
359
+ });
360
+ }
344
361
  return FunctionParams.factory({
345
362
  pathParams: typeSchemas.pathParams?.name ? {
346
363
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -348,7 +365,7 @@ function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas })
348
365
  typed: true,
349
366
  casing: paramsCasing
350
367
  }),
351
- optional: isOptional(typeSchemas.pathParams?.schema)
368
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
352
369
  } : void 0,
353
370
  data: typeSchemas.request?.name ? {
354
371
  type: typeSchemas.request?.name,
@@ -426,7 +443,9 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
426
443
  ...(params ?? {}),
427
444
  ['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
428
445
  } as ${typeSchemas.queryParams?.name}` : "";
429
- const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
446
+ const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
447
+ return item && !item.optional && !item.default ? key : void 0;
448
+ }).filter(Boolean).join("&& ");
430
449
  const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
431
450
  if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
432
451
  name,
@@ -580,9 +599,10 @@ function MutationOptions({ name, clientName, dataReturnType, typeSchemas, params
580
599
  name,
581
600
  export: true,
582
601
  params: params.toConstructor(),
602
+ generics: ["TContext = unknown"],
583
603
  children: `
584
604
  const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
585
- return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : "void"}, typeof mutationKey>({
605
+ return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
586
606
  mutationKey,
587
607
  mutationFn: async(${dataParams.toConstructor()}) => {
588
608
  return ${clientName}(${clientParams.toCall()})
@@ -598,11 +618,12 @@ MutationOptions.getParams = getParams$5;
598
618
  //#region src/components/Mutation.tsx
599
619
  function getParams$4({ paramsCasing, dataReturnType, typeSchemas }) {
600
620
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
621
+ const pathParams = getPathParams(typeSchemas.pathParams, {
622
+ typed: true,
623
+ casing: paramsCasing
624
+ });
601
625
  const TRequest = FunctionParams.factory({
602
- ...getPathParams(typeSchemas.pathParams, {
603
- typed: true,
604
- casing: paramsCasing
605
- }),
626
+ ...pathParams,
606
627
  data: typeSchemas.request?.name ? {
607
628
  type: typeSchemas.request?.name,
608
629
  optional: isOptional(typeSchemas.request?.schema)
@@ -704,44 +725,49 @@ function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dat
704
725
  function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
705
726
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
706
727
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
707
- if (paramsType === "object") return FunctionParams.factory({
708
- data: {
709
- mode: "object",
710
- children: {
711
- ...getPathParams(typeSchemas.pathParams, {
712
- typed: true,
713
- casing: paramsCasing
714
- }),
715
- data: typeSchemas.request?.name ? {
716
- type: typeSchemas.request?.name,
717
- optional: isOptional(typeSchemas.request?.schema)
718
- } : void 0,
719
- params: typeSchemas.queryParams?.name ? {
720
- type: typeSchemas.queryParams?.name,
721
- optional: isOptional(typeSchemas.queryParams?.schema)
722
- } : void 0,
723
- headers: typeSchemas.headerParams?.name ? {
724
- type: typeSchemas.headerParams?.name,
725
- optional: isOptional(typeSchemas.headerParams?.schema)
726
- } : void 0
727
- }
728
- },
729
- options: {
730
- type: `
728
+ if (paramsType === "object") {
729
+ const children = {
730
+ ...getPathParams(typeSchemas.pathParams, {
731
+ typed: true,
732
+ casing: paramsCasing
733
+ }),
734
+ data: typeSchemas.request?.name ? {
735
+ type: typeSchemas.request?.name,
736
+ optional: isOptional(typeSchemas.request?.schema)
737
+ } : void 0,
738
+ params: typeSchemas.queryParams?.name ? {
739
+ type: typeSchemas.queryParams?.name,
740
+ optional: isOptional(typeSchemas.queryParams?.schema)
741
+ } : void 0,
742
+ headers: typeSchemas.headerParams?.name ? {
743
+ type: typeSchemas.headerParams?.name,
744
+ optional: isOptional(typeSchemas.headerParams?.schema)
745
+ } : void 0
746
+ };
747
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
748
+ return FunctionParams.factory({
749
+ data: {
750
+ mode: "object",
751
+ children,
752
+ default: allChildrenAreOptional ? "{}" : void 0
753
+ },
754
+ options: {
755
+ type: `
731
756
  {
732
757
  query?: Partial<QueryObserverOptions<${[
733
- TData,
734
- TError,
735
- "TData",
736
- "TQueryData",
737
- "TQueryKey"
738
- ].join(", ")}>> & { client?: QueryClient },
758
+ TData,
759
+ TError,
760
+ "TData",
761
+ "TQueryData",
762
+ "TQueryKey"
763
+ ].join(", ")}>> & { client?: QueryClient },
739
764
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
740
765
  }
741
766
  `,
742
- default: "{}"
743
- }
744
- });
767
+ default: "{}"
768
+ }
769
+ });
770
+ }
745
771
  return FunctionParams.factory({
746
772
  pathParams: typeSchemas.pathParams?.name ? {
747
773
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -749,7 +775,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType,
749
775
  typed: true,
750
776
  casing: paramsCasing
751
777
  }),
752
- optional: isOptional(typeSchemas.pathParams?.schema)
778
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
753
779
  } : void 0,
754
780
  data: typeSchemas.request?.name ? {
755
781
  type: typeSchemas.request?.name,
@@ -841,38 +867,43 @@ Query.getParams = getParams$3;
841
867
  //#endregion
842
868
  //#region src/components/SuspenseInfiniteQuery.tsx
843
869
  function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
844
- if (paramsType === "object") return FunctionParams.factory({
845
- data: {
846
- mode: "object",
847
- children: {
848
- ...getPathParams(typeSchemas.pathParams, {
849
- typed: true,
850
- casing: paramsCasing
851
- }),
852
- data: typeSchemas.request?.name ? {
853
- type: typeSchemas.request?.name,
854
- optional: isOptional(typeSchemas.request?.schema)
855
- } : void 0,
856
- params: typeSchemas.queryParams?.name ? {
857
- type: typeSchemas.queryParams?.name,
858
- optional: isOptional(typeSchemas.queryParams?.schema)
859
- } : void 0,
860
- headers: typeSchemas.headerParams?.name ? {
861
- type: typeSchemas.headerParams?.name,
862
- optional: isOptional(typeSchemas.headerParams?.schema)
863
- } : void 0
864
- }
865
- },
866
- options: {
867
- type: `
870
+ if (paramsType === "object") {
871
+ const children = {
872
+ ...getPathParams(typeSchemas.pathParams, {
873
+ typed: true,
874
+ casing: paramsCasing
875
+ }),
876
+ data: typeSchemas.request?.name ? {
877
+ type: typeSchemas.request?.name,
878
+ optional: isOptional(typeSchemas.request?.schema)
879
+ } : void 0,
880
+ params: typeSchemas.queryParams?.name ? {
881
+ type: typeSchemas.queryParams?.name,
882
+ optional: isOptional(typeSchemas.queryParams?.schema)
883
+ } : void 0,
884
+ headers: typeSchemas.headerParams?.name ? {
885
+ type: typeSchemas.headerParams?.name,
886
+ optional: isOptional(typeSchemas.headerParams?.schema)
887
+ } : void 0
888
+ };
889
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
890
+ return FunctionParams.factory({
891
+ data: {
892
+ mode: "object",
893
+ children,
894
+ default: allChildrenAreOptional ? "{}" : void 0
895
+ },
896
+ options: {
897
+ type: `
868
898
  {
869
899
  query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
870
900
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
871
901
  }
872
902
  `,
873
- default: "{}"
874
- }
875
- });
903
+ default: "{}"
904
+ }
905
+ });
906
+ }
876
907
  return FunctionParams.factory({
877
908
  pathParams: typeSchemas.pathParams?.name ? {
878
909
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -880,7 +911,7 @@ function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
880
911
  typed: true,
881
912
  casing: paramsCasing
882
913
  }),
883
- optional: isOptional(typeSchemas.pathParams?.schema)
914
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
884
915
  } : void 0,
885
916
  data: typeSchemas.request?.name ? {
886
917
  type: typeSchemas.request?.name,
@@ -976,33 +1007,38 @@ SuspenseInfiniteQuery.getParams = getParams$2;
976
1007
  //#endregion
977
1008
  //#region src/components/SuspenseInfiniteQueryOptions.tsx
978
1009
  function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
979
- if (paramsType === "object") return FunctionParams.factory({
980
- data: {
981
- mode: "object",
982
- children: {
983
- ...getPathParams(typeSchemas.pathParams, {
984
- typed: true,
985
- casing: paramsCasing
986
- }),
987
- data: typeSchemas.request?.name ? {
988
- type: typeSchemas.request?.name,
989
- optional: isOptional(typeSchemas.request?.schema)
990
- } : void 0,
991
- params: typeSchemas.queryParams?.name ? {
992
- type: typeSchemas.queryParams?.name,
993
- optional: isOptional(typeSchemas.queryParams?.schema)
994
- } : void 0,
995
- headers: typeSchemas.headerParams?.name ? {
996
- type: typeSchemas.headerParams?.name,
997
- optional: isOptional(typeSchemas.headerParams?.schema)
998
- } : void 0
1010
+ if (paramsType === "object") {
1011
+ const children = {
1012
+ ...getPathParams(typeSchemas.pathParams, {
1013
+ typed: true,
1014
+ casing: paramsCasing
1015
+ }),
1016
+ data: typeSchemas.request?.name ? {
1017
+ type: typeSchemas.request?.name,
1018
+ optional: isOptional(typeSchemas.request?.schema)
1019
+ } : void 0,
1020
+ params: typeSchemas.queryParams?.name ? {
1021
+ type: typeSchemas.queryParams?.name,
1022
+ optional: isOptional(typeSchemas.queryParams?.schema)
1023
+ } : void 0,
1024
+ headers: typeSchemas.headerParams?.name ? {
1025
+ type: typeSchemas.headerParams?.name,
1026
+ optional: isOptional(typeSchemas.headerParams?.schema)
1027
+ } : void 0
1028
+ };
1029
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
1030
+ return FunctionParams.factory({
1031
+ data: {
1032
+ mode: "object",
1033
+ children,
1034
+ default: allChildrenAreOptional ? "{}" : void 0
1035
+ },
1036
+ config: {
1037
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
1038
+ default: "{}"
999
1039
  }
1000
- },
1001
- config: {
1002
- type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
1003
- default: "{}"
1004
- }
1005
- });
1040
+ });
1041
+ }
1006
1042
  return FunctionParams.factory({
1007
1043
  pathParams: typeSchemas.pathParams?.name ? {
1008
1044
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -1010,7 +1046,7 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas })
1010
1046
  typed: true,
1011
1047
  casing: paramsCasing
1012
1048
  }),
1013
- optional: isOptional(typeSchemas.pathParams?.schema)
1049
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
1014
1050
  } : void 0,
1015
1051
  data: typeSchemas.request?.name ? {
1016
1052
  type: typeSchemas.request?.name,
@@ -1088,7 +1124,9 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1088
1124
  ...(params ?? {}),
1089
1125
  ['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
1090
1126
  } as ${typeSchemas.queryParams?.name}` : "";
1091
- const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
1127
+ const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
1128
+ return item && !item.optional && !item.default ? key : void 0;
1129
+ }).filter(Boolean).join("&& ");
1092
1130
  const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
1093
1131
  if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
1094
1132
  name,
@@ -1143,43 +1181,48 @@ SuspenseInfiniteQueryOptions.getParams = getParams$1;
1143
1181
  function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
1144
1182
  const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
1145
1183
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
1146
- if (paramsType === "object") return FunctionParams.factory({
1147
- data: {
1148
- mode: "object",
1149
- children: {
1150
- ...getPathParams(typeSchemas.pathParams, {
1151
- typed: true,
1152
- casing: paramsCasing
1153
- }),
1154
- data: typeSchemas.request?.name ? {
1155
- type: typeSchemas.request?.name,
1156
- optional: isOptional(typeSchemas.request?.schema)
1157
- } : void 0,
1158
- params: typeSchemas.queryParams?.name ? {
1159
- type: typeSchemas.queryParams?.name,
1160
- optional: isOptional(typeSchemas.queryParams?.schema)
1161
- } : void 0,
1162
- headers: typeSchemas.headerParams?.name ? {
1163
- type: typeSchemas.headerParams?.name,
1164
- optional: isOptional(typeSchemas.headerParams?.schema)
1165
- } : void 0
1166
- }
1167
- },
1168
- options: {
1169
- type: `
1184
+ if (paramsType === "object") {
1185
+ const children = {
1186
+ ...getPathParams(typeSchemas.pathParams, {
1187
+ typed: true,
1188
+ casing: paramsCasing
1189
+ }),
1190
+ data: typeSchemas.request?.name ? {
1191
+ type: typeSchemas.request?.name,
1192
+ optional: isOptional(typeSchemas.request?.schema)
1193
+ } : void 0,
1194
+ params: typeSchemas.queryParams?.name ? {
1195
+ type: typeSchemas.queryParams?.name,
1196
+ optional: isOptional(typeSchemas.queryParams?.schema)
1197
+ } : void 0,
1198
+ headers: typeSchemas.headerParams?.name ? {
1199
+ type: typeSchemas.headerParams?.name,
1200
+ optional: isOptional(typeSchemas.headerParams?.schema)
1201
+ } : void 0
1202
+ };
1203
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
1204
+ return FunctionParams.factory({
1205
+ data: {
1206
+ mode: "object",
1207
+ children,
1208
+ default: allChildrenAreOptional ? "{}" : void 0
1209
+ },
1210
+ options: {
1211
+ type: `
1170
1212
  {
1171
1213
  query?: Partial<UseSuspenseQueryOptions<${[
1172
- TData,
1173
- TError,
1174
- "TData",
1175
- "TQueryKey"
1176
- ].join(", ")}>> & { client?: QueryClient },
1214
+ TData,
1215
+ TError,
1216
+ "TData",
1217
+ "TQueryKey"
1218
+ ].join(", ")}>> & { client?: QueryClient },
1177
1219
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
1178
1220
  }
1179
1221
  `,
1180
- default: "{}"
1181
- }
1182
- });
1222
+ default: "{}"
1223
+ }
1224
+ });
1225
+ }
1183
1226
  return FunctionParams.factory({
1184
1227
  pathParams: typeSchemas.pathParams?.name ? {
1185
1228
  mode: pathParamsType === "object" ? "object" : "inlineSpread",
@@ -1187,7 +1230,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
1187
1230
  typed: true,
1188
1231
  casing: paramsCasing
1189
1232
  }),
1190
- optional: isOptional(typeSchemas.pathParams?.schema)
1233
+ default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
1191
1234
  } : void 0,
1192
1235
  data: typeSchemas.request?.name ? {
1193
1236
  type: typeSchemas.request?.name,
@@ -1280,4 +1323,4 @@ SuspenseQuery.getParams = getParams;
1280
1323
 
1281
1324
  //#endregion
1282
1325
  export { Mutation as a, InfiniteQueryOptions as c, QueryKey as d, Query as i, InfiniteQuery as l, SuspenseInfiniteQueryOptions as n, MutationOptions as o, SuspenseInfiniteQuery as r, MutationKey as s, SuspenseQuery as t, QueryOptions as u };
1283
- //# sourceMappingURL=components-CX83mklO.js.map
1326
+ //# sourceMappingURL=components-DVc9iach.js.map