@kubb/plugin-react-query 4.15.1 → 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.
- package/dist/{components-B6lqcqgn.js → components-DVc9iach.js} +259 -217
- package/dist/components-DVc9iach.js.map +1 -0
- package/dist/{components-6nRaAppd.cjs → components-YtTYHVwV.cjs} +259 -217
- package/dist/components-YtTYHVwV.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CYoqgYAV.cjs → generators-C6VGGGTj.cjs} +2 -2
- package/dist/{generators-CYoqgYAV.cjs.map → generators-C6VGGGTj.cjs.map} +1 -1
- package/dist/{generators-cZao868O.js → generators-DzaRYGiz.js} +2 -2
- package/dist/{generators-cZao868O.js.map → generators-DzaRYGiz.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +9 -9
- package/src/components/InfiniteQuery.tsx +35 -30
- package/src/components/InfiniteQueryOptions.tsx +38 -27
- package/src/components/Mutation.tsx +3 -1
- package/src/components/Query.tsx +31 -23
- package/src/components/QueryKey.tsx +8 -6
- package/src/components/QueryOptions.tsx +48 -26
- package/src/components/SuspenseInfiniteQuery.tsx +31 -26
- package/src/components/SuspenseInfiniteQueryOptions.tsx +38 -27
- package/src/components/SuspenseQuery.tsx +35 -24
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/findByStatusAllOptional.ts +82 -0
- package/src/generators/__snapshots__/findByStatusAllOptionalInline.ts +76 -0
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsTemplateString.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByStatusAllOptional.ts +97 -0
- package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextAndPreviousParam.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextParam.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseByStatusAllOptional.ts +79 -0
- package/src/generators/__snapshots__/findSuspenseByTags.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByStatusAllOptional.ts +97 -0
- package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +2 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +2 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsWithCustomOptions.ts +2 -1
- package/src/generators/__snapshots__/postAsQuery.ts +2 -2
- package/dist/components-6nRaAppd.cjs.map +0 -1
- package/dist/components-B6lqcqgn.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
|
-
|
|
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
|
-
|
|
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")
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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]) =>
|
|
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")
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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")
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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]) =>
|
|
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,
|
|
@@ -599,11 +618,12 @@ MutationOptions.getParams = getParams$5;
|
|
|
599
618
|
//#region src/components/Mutation.tsx
|
|
600
619
|
function getParams$4({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
601
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
|
+
});
|
|
602
625
|
const TRequest = FunctionParams.factory({
|
|
603
|
-
...
|
|
604
|
-
typed: true,
|
|
605
|
-
casing: paramsCasing
|
|
606
|
-
}),
|
|
626
|
+
...pathParams,
|
|
607
627
|
data: typeSchemas.request?.name ? {
|
|
608
628
|
type: typeSchemas.request?.name,
|
|
609
629
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -705,44 +725,49 @@ function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dat
|
|
|
705
725
|
function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
706
726
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
707
727
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
708
|
-
if (paramsType === "object")
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
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: `
|
|
732
756
|
{
|
|
733
757
|
query?: Partial<QueryObserverOptions<${[
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
758
|
+
TData,
|
|
759
|
+
TError,
|
|
760
|
+
"TData",
|
|
761
|
+
"TQueryData",
|
|
762
|
+
"TQueryKey"
|
|
763
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
740
764
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
741
765
|
}
|
|
742
766
|
`,
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
767
|
+
default: "{}"
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
746
771
|
return FunctionParams.factory({
|
|
747
772
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
748
773
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -750,7 +775,7 @@ function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
750
775
|
typed: true,
|
|
751
776
|
casing: paramsCasing
|
|
752
777
|
}),
|
|
753
|
-
|
|
778
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
754
779
|
} : void 0,
|
|
755
780
|
data: typeSchemas.request?.name ? {
|
|
756
781
|
type: typeSchemas.request?.name,
|
|
@@ -842,38 +867,43 @@ Query.getParams = getParams$3;
|
|
|
842
867
|
//#endregion
|
|
843
868
|
//#region src/components/SuspenseInfiniteQuery.tsx
|
|
844
869
|
function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
|
|
845
|
-
if (paramsType === "object")
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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: `
|
|
869
898
|
{
|
|
870
899
|
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
871
900
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
872
901
|
}
|
|
873
902
|
`,
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
903
|
+
default: "{}"
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}
|
|
877
907
|
return FunctionParams.factory({
|
|
878
908
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
879
909
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -881,7 +911,7 @@ function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pa
|
|
|
881
911
|
typed: true,
|
|
882
912
|
casing: paramsCasing
|
|
883
913
|
}),
|
|
884
|
-
|
|
914
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
885
915
|
} : void 0,
|
|
886
916
|
data: typeSchemas.request?.name ? {
|
|
887
917
|
type: typeSchemas.request?.name,
|
|
@@ -977,33 +1007,38 @@ SuspenseInfiniteQuery.getParams = getParams$2;
|
|
|
977
1007
|
//#endregion
|
|
978
1008
|
//#region src/components/SuspenseInfiniteQueryOptions.tsx
|
|
979
1009
|
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
980
|
-
if (paramsType === "object")
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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: "{}"
|
|
1000
1039
|
}
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
1004
|
-
default: "{}"
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1007
1042
|
return FunctionParams.factory({
|
|
1008
1043
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
1009
1044
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -1011,7 +1046,7 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
|
1011
1046
|
typed: true,
|
|
1012
1047
|
casing: paramsCasing
|
|
1013
1048
|
}),
|
|
1014
|
-
|
|
1049
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
1015
1050
|
} : void 0,
|
|
1016
1051
|
data: typeSchemas.request?.name ? {
|
|
1017
1052
|
type: typeSchemas.request?.name,
|
|
@@ -1089,7 +1124,9 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
1089
1124
|
...(params ?? {}),
|
|
1090
1125
|
['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
|
|
1091
1126
|
} as ${typeSchemas.queryParams?.name}` : "";
|
|
1092
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) =>
|
|
1127
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
1128
|
+
return item && !item.optional && !item.default ? key : void 0;
|
|
1129
|
+
}).filter(Boolean).join("&& ");
|
|
1093
1130
|
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
1094
1131
|
if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
|
|
1095
1132
|
name,
|
|
@@ -1144,43 +1181,48 @@ SuspenseInfiniteQueryOptions.getParams = getParams$1;
|
|
|
1144
1181
|
function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
1145
1182
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1146
1183
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
1147
|
-
if (paramsType === "object")
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
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: `
|
|
1171
1212
|
{
|
|
1172
1213
|
query?: Partial<UseSuspenseQueryOptions<${[
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1214
|
+
TData,
|
|
1215
|
+
TError,
|
|
1216
|
+
"TData",
|
|
1217
|
+
"TQueryKey"
|
|
1218
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
1178
1219
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
1179
1220
|
}
|
|
1180
1221
|
`,
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1222
|
+
default: "{}"
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1184
1226
|
return FunctionParams.factory({
|
|
1185
1227
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
1186
1228
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -1188,7 +1230,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
|
|
|
1188
1230
|
typed: true,
|
|
1189
1231
|
casing: paramsCasing
|
|
1190
1232
|
}),
|
|
1191
|
-
|
|
1233
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
1192
1234
|
} : void 0,
|
|
1193
1235
|
data: typeSchemas.request?.name ? {
|
|
1194
1236
|
type: typeSchemas.request?.name,
|
|
@@ -1281,4 +1323,4 @@ SuspenseQuery.getParams = getParams;
|
|
|
1281
1323
|
|
|
1282
1324
|
//#endregion
|
|
1283
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 };
|
|
1284
|
-
//# sourceMappingURL=components-
|
|
1326
|
+
//# sourceMappingURL=components-DVc9iach.js.map
|