@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.
- package/dist/{components-CX83mklO.js → components-DVc9iach.js} +261 -218
- package/dist/components-DVc9iach.js.map +1 -0
- package/dist/{components-7ul5AP_u.cjs → components-YtTYHVwV.cjs} +261 -218
- package/dist/components-YtTYHVwV.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CNv1RI1y.cjs → generators-C6VGGGTj.cjs} +2 -2
- package/dist/{generators-CNv1RI1y.cjs.map → generators-C6VGGGTj.cjs.map} +1 -1
- package/dist/{generators-CVc1Qlnh.js → generators-DzaRYGiz.js} +2 -2
- package/dist/{generators-CVc1Qlnh.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/MutationOptions.tsx +2 -2
- 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__/clientPostImportPath.ts +4 -2
- 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/src/generators/__snapshots__/updatePetById.ts +4 -2
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +4 -2
- package/src/generators/__snapshots__/updatePetByIdWithCustomOptions.ts +4 -2
- package/dist/components-7ul5AP_u.cjs.map +0 -1
- 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
|
-
|
|
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,
|
|
@@ -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"},
|
|
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
|
-
...
|
|
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")
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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")
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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")
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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]) =>
|
|
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")
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
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
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
1326
|
+
//# sourceMappingURL=components-DVc9iach.js.map
|