@kubb/plugin-react-query 4.5.14 → 4.6.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.
- package/dist/{components-0G5mZf1J.cjs → components-C0HQi0Tg.cjs} +319 -25
- package/dist/components-C0HQi0Tg.cjs.map +1 -0
- package/dist/{components-BWrDXrTl.js → components-K4qy3AIg.js} +307 -25
- package/dist/components-K4qy3AIg.js.map +1 -0
- package/dist/components.cjs +3 -1
- package/dist/components.d.cts +121 -30
- package/dist/components.d.ts +121 -30
- package/dist/components.js +2 -2
- package/dist/{generators-DTCyUuOe.cjs → generators-CKLkXi1h.cjs} +225 -2
- package/dist/generators-CKLkXi1h.cjs.map +1 -0
- package/dist/{generators-BAjiYTwQ.js → generators-Df7UUFaq.js} +220 -3
- package/dist/generators-Df7UUFaq.js.map +1 -0
- package/dist/generators.cjs +3 -2
- package/dist/generators.d.cts +4 -1
- package/dist/generators.d.ts +4 -1
- package/dist/generators.js +3 -3
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/SuspenseInfiniteQuery.tsx +212 -0
- package/src/components/SuspenseInfiniteQueryOptions.tsx +230 -0
- package/src/components/index.ts +2 -0
- package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +100 -0
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +100 -0
- package/src/generators/index.ts +1 -0
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +191 -0
- package/src/plugin.ts +2 -2
- package/dist/components-0G5mZf1J.cjs.map +0 -1
- package/dist/components-BWrDXrTl.js.map +0 -1
- package/dist/generators-BAjiYTwQ.js.map +0 -1
- package/dist/generators-DTCyUuOe.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_generators = require('./generators-CKLkXi1h.cjs');
|
|
2
2
|
let __kubb_core_utils = require("@kubb/core/utils");
|
|
3
3
|
let __kubb_oas = require("@kubb/oas");
|
|
4
4
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -7,7 +7,7 @@ let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
|
7
7
|
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
8
8
|
|
|
9
9
|
//#region src/components/QueryKey.tsx
|
|
10
|
-
function getParams$
|
|
10
|
+
function getParams$10({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
11
11
|
return __kubb_react_fabric.FunctionParams.factory({
|
|
12
12
|
pathParams: {
|
|
13
13
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -37,7 +37,7 @@ const getTransformer$1 = ({ operation, schemas, casing }) => {
|
|
|
37
37
|
].filter(Boolean);
|
|
38
38
|
};
|
|
39
39
|
function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
|
|
40
|
-
const params = getParams$
|
|
40
|
+
const params = getParams$10({
|
|
41
41
|
pathParamsType,
|
|
42
42
|
typeSchemas,
|
|
43
43
|
paramsCasing
|
|
@@ -70,12 +70,12 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
|
|
|
70
70
|
})
|
|
71
71
|
})] });
|
|
72
72
|
}
|
|
73
|
-
QueryKey.getParams = getParams$
|
|
73
|
+
QueryKey.getParams = getParams$10;
|
|
74
74
|
QueryKey.getTransformer = getTransformer$1;
|
|
75
75
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/components/QueryOptions.tsx
|
|
78
|
-
function getParams$
|
|
78
|
+
function getParams$9({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
79
79
|
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
80
80
|
data: {
|
|
81
81
|
mode: "object",
|
|
@@ -131,7 +131,7 @@ function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
|
|
134
|
-
const params = getParams$
|
|
134
|
+
const params = getParams$9({
|
|
135
135
|
paramsType,
|
|
136
136
|
paramsCasing,
|
|
137
137
|
pathParamsType,
|
|
@@ -175,11 +175,11 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
|
|
|
175
175
|
})
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
QueryOptions.getParams = getParams$
|
|
178
|
+
QueryOptions.getParams = getParams$9;
|
|
179
179
|
|
|
180
180
|
//#endregion
|
|
181
181
|
//#region src/components/InfiniteQuery.tsx
|
|
182
|
-
function getParams$
|
|
182
|
+
function getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
|
|
183
183
|
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
184
184
|
data: {
|
|
185
185
|
mode: "object",
|
|
@@ -273,7 +273,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
273
273
|
typeSchemas,
|
|
274
274
|
paramsCasing
|
|
275
275
|
});
|
|
276
|
-
const params = getParams$
|
|
276
|
+
const params = getParams$8({
|
|
277
277
|
paramsCasing,
|
|
278
278
|
paramsType,
|
|
279
279
|
pathParamsType,
|
|
@@ -309,11 +309,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
309
309
|
})
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
-
InfiniteQuery.getParams = getParams$
|
|
312
|
+
InfiniteQuery.getParams = getParams$8;
|
|
313
313
|
|
|
314
314
|
//#endregion
|
|
315
315
|
//#region src/components/InfiniteQueryOptions.tsx
|
|
316
|
-
function getParams$
|
|
316
|
+
function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
317
317
|
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
318
318
|
data: {
|
|
319
319
|
mode: "object",
|
|
@@ -378,7 +378,7 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
378
378
|
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
379
379
|
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
380
380
|
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
381
|
-
const params = getParams$
|
|
381
|
+
const params = getParams$7({
|
|
382
382
|
paramsType,
|
|
383
383
|
paramsCasing,
|
|
384
384
|
pathParamsType,
|
|
@@ -457,18 +457,18 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
457
457
|
})
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
|
-
InfiniteQueryOptions.getParams = getParams$
|
|
460
|
+
InfiniteQueryOptions.getParams = getParams$7;
|
|
461
461
|
|
|
462
462
|
//#endregion
|
|
463
463
|
//#region src/components/MutationKey.tsx
|
|
464
|
-
function getParams$
|
|
464
|
+
function getParams$6({}) {
|
|
465
465
|
return __kubb_react_fabric.FunctionParams.factory({});
|
|
466
466
|
}
|
|
467
467
|
const getTransformer = ({ operation, casing }) => {
|
|
468
468
|
return [`{ url: '${new __kubb_core_utils.URLPath(operation.path, { casing }).toURLPath()}' }`];
|
|
469
469
|
};
|
|
470
470
|
function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }) {
|
|
471
|
-
const params = getParams$
|
|
471
|
+
const params = getParams$6({
|
|
472
472
|
pathParamsType,
|
|
473
473
|
typeSchemas
|
|
474
474
|
});
|
|
@@ -500,19 +500,19 @@ function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operatio
|
|
|
500
500
|
})
|
|
501
501
|
})] });
|
|
502
502
|
}
|
|
503
|
-
MutationKey.getParams = getParams$
|
|
503
|
+
MutationKey.getParams = getParams$6;
|
|
504
504
|
MutationKey.getTransformer = getTransformer;
|
|
505
505
|
|
|
506
506
|
//#endregion
|
|
507
507
|
//#region src/components/MutationOptions.tsx
|
|
508
|
-
function getParams$
|
|
508
|
+
function getParams$5({ typeSchemas }) {
|
|
509
509
|
return __kubb_react_fabric.FunctionParams.factory({ config: {
|
|
510
510
|
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
511
511
|
default: "{}"
|
|
512
512
|
} });
|
|
513
513
|
}
|
|
514
514
|
function MutationOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
|
|
515
|
-
const params = getParams$
|
|
515
|
+
const params = getParams$5({ typeSchemas });
|
|
516
516
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
517
517
|
const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error";
|
|
518
518
|
const clientParams = __kubb_plugin_client_components.Client.getParams({
|
|
@@ -575,11 +575,11 @@ function MutationOptions({ name, clientName, dataReturnType, typeSchemas, params
|
|
|
575
575
|
})
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
|
-
MutationOptions.getParams = getParams$
|
|
578
|
+
MutationOptions.getParams = getParams$5;
|
|
579
579
|
|
|
580
580
|
//#endregion
|
|
581
581
|
//#region src/components/Mutation.tsx
|
|
582
|
-
function getParams$
|
|
582
|
+
function getParams$4({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
583
583
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
584
584
|
const TRequest = __kubb_react_fabric.FunctionParams.factory({
|
|
585
585
|
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
@@ -620,7 +620,7 @@ function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dat
|
|
|
620
620
|
pathParamsType,
|
|
621
621
|
typeSchemas
|
|
622
622
|
});
|
|
623
|
-
const params = getParams$
|
|
623
|
+
const params = getParams$4({
|
|
624
624
|
paramsCasing,
|
|
625
625
|
pathParamsType,
|
|
626
626
|
dataReturnType,
|
|
@@ -683,7 +683,7 @@ function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dat
|
|
|
683
683
|
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region src/components/Query.tsx
|
|
686
|
-
function getParams$
|
|
686
|
+
function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
687
687
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
688
688
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
689
689
|
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
@@ -781,7 +781,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
|
|
|
781
781
|
typeSchemas,
|
|
782
782
|
paramsCasing
|
|
783
783
|
});
|
|
784
|
-
const params = getParams$
|
|
784
|
+
const params = getParams$3({
|
|
785
785
|
paramsCasing,
|
|
786
786
|
paramsType,
|
|
787
787
|
pathParamsType,
|
|
@@ -817,7 +817,289 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
|
|
|
817
817
|
})
|
|
818
818
|
});
|
|
819
819
|
}
|
|
820
|
-
Query.getParams = getParams$
|
|
820
|
+
Query.getParams = getParams$3;
|
|
821
|
+
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region src/components/SuspenseInfiniteQuery.tsx
|
|
824
|
+
function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
|
|
825
|
+
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
826
|
+
data: {
|
|
827
|
+
mode: "object",
|
|
828
|
+
children: {
|
|
829
|
+
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
830
|
+
typed: true,
|
|
831
|
+
casing: paramsCasing
|
|
832
|
+
}),
|
|
833
|
+
data: typeSchemas.request?.name ? {
|
|
834
|
+
type: typeSchemas.request?.name,
|
|
835
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
836
|
+
} : void 0,
|
|
837
|
+
params: typeSchemas.queryParams?.name ? {
|
|
838
|
+
type: typeSchemas.queryParams?.name,
|
|
839
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
840
|
+
} : void 0,
|
|
841
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
842
|
+
type: typeSchemas.headerParams?.name,
|
|
843
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
844
|
+
} : void 0
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
options: {
|
|
848
|
+
type: `
|
|
849
|
+
{
|
|
850
|
+
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
851
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
852
|
+
}
|
|
853
|
+
`,
|
|
854
|
+
default: "{}"
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
return __kubb_react_fabric.FunctionParams.factory({
|
|
858
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
859
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
860
|
+
children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
861
|
+
typed: true,
|
|
862
|
+
casing: paramsCasing
|
|
863
|
+
}),
|
|
864
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema)
|
|
865
|
+
} : void 0,
|
|
866
|
+
data: typeSchemas.request?.name ? {
|
|
867
|
+
type: typeSchemas.request?.name,
|
|
868
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
869
|
+
} : void 0,
|
|
870
|
+
params: typeSchemas.queryParams?.name ? {
|
|
871
|
+
type: typeSchemas.queryParams?.name,
|
|
872
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
873
|
+
} : void 0,
|
|
874
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
875
|
+
type: typeSchemas.headerParams?.name,
|
|
876
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
877
|
+
} : void 0,
|
|
878
|
+
options: {
|
|
879
|
+
type: `
|
|
880
|
+
{
|
|
881
|
+
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
882
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
883
|
+
}
|
|
884
|
+
`,
|
|
885
|
+
default: "{}"
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, initialPageParam, queryParam }) {
|
|
890
|
+
const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
891
|
+
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
892
|
+
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
893
|
+
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
894
|
+
const parts = initialPageParam.split(" as ");
|
|
895
|
+
return parts[parts.length - 1] ?? "unknown";
|
|
896
|
+
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
897
|
+
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
898
|
+
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
899
|
+
const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
|
|
900
|
+
const generics = [
|
|
901
|
+
`TQueryFnData = ${responseType}`,
|
|
902
|
+
`TError = ${errorType}`,
|
|
903
|
+
"TData = InfiniteData<TQueryFnData>",
|
|
904
|
+
`TQueryKey extends QueryKey = ${queryKeyTypeName}`,
|
|
905
|
+
`TPageParam = ${pageParamType}`
|
|
906
|
+
];
|
|
907
|
+
const queryKeyParams = QueryKey.getParams({
|
|
908
|
+
pathParamsType,
|
|
909
|
+
typeSchemas,
|
|
910
|
+
paramsCasing
|
|
911
|
+
});
|
|
912
|
+
const queryOptionsParams = QueryOptions.getParams({
|
|
913
|
+
paramsType,
|
|
914
|
+
pathParamsType,
|
|
915
|
+
typeSchemas,
|
|
916
|
+
paramsCasing
|
|
917
|
+
});
|
|
918
|
+
const params = getParams$2({
|
|
919
|
+
paramsCasing,
|
|
920
|
+
paramsType,
|
|
921
|
+
pathParamsType,
|
|
922
|
+
typeSchemas,
|
|
923
|
+
pageParamGeneric: "TPageParam"
|
|
924
|
+
});
|
|
925
|
+
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
926
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
927
|
+
name,
|
|
928
|
+
isExportable: true,
|
|
929
|
+
isIndexable: true,
|
|
930
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
|
|
931
|
+
name,
|
|
932
|
+
export: true,
|
|
933
|
+
generics: generics.join(", "),
|
|
934
|
+
params: params.toConstructor(),
|
|
935
|
+
JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
|
|
936
|
+
children: `
|
|
937
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
938
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
939
|
+
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
940
|
+
|
|
941
|
+
const query = useSuspenseInfiniteQuery({
|
|
942
|
+
...${queryOptions},
|
|
943
|
+
queryKey,
|
|
944
|
+
...queryOptions
|
|
945
|
+
} as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
|
|
946
|
+
|
|
947
|
+
query.queryKey = queryKey as TQueryKey
|
|
948
|
+
|
|
949
|
+
return query
|
|
950
|
+
`
|
|
951
|
+
})
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
SuspenseInfiniteQuery.getParams = getParams$2;
|
|
955
|
+
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/components/SuspenseInfiniteQueryOptions.tsx
|
|
958
|
+
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
959
|
+
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
960
|
+
data: {
|
|
961
|
+
mode: "object",
|
|
962
|
+
children: {
|
|
963
|
+
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
964
|
+
typed: true,
|
|
965
|
+
casing: paramsCasing
|
|
966
|
+
}),
|
|
967
|
+
data: typeSchemas.request?.name ? {
|
|
968
|
+
type: typeSchemas.request?.name,
|
|
969
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
970
|
+
} : void 0,
|
|
971
|
+
params: typeSchemas.queryParams?.name ? {
|
|
972
|
+
type: typeSchemas.queryParams?.name,
|
|
973
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
974
|
+
} : void 0,
|
|
975
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
976
|
+
type: typeSchemas.headerParams?.name,
|
|
977
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
978
|
+
} : void 0
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
config: {
|
|
982
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
983
|
+
default: "{}"
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
return __kubb_react_fabric.FunctionParams.factory({
|
|
987
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
988
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
989
|
+
children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
990
|
+
typed: true,
|
|
991
|
+
casing: paramsCasing
|
|
992
|
+
}),
|
|
993
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.pathParams?.schema)
|
|
994
|
+
} : void 0,
|
|
995
|
+
data: typeSchemas.request?.name ? {
|
|
996
|
+
type: typeSchemas.request?.name,
|
|
997
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
998
|
+
} : void 0,
|
|
999
|
+
params: typeSchemas.queryParams?.name ? {
|
|
1000
|
+
type: typeSchemas.queryParams?.name,
|
|
1001
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
1002
|
+
} : void 0,
|
|
1003
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
1004
|
+
type: typeSchemas.headerParams?.name,
|
|
1005
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
1006
|
+
} : void 0,
|
|
1007
|
+
config: {
|
|
1008
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
1009
|
+
default: "{}"
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
|
|
1014
|
+
const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1015
|
+
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
1016
|
+
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
1017
|
+
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
1018
|
+
const parts = initialPageParam.split(" as ");
|
|
1019
|
+
return parts[parts.length - 1] ?? "unknown";
|
|
1020
|
+
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
1021
|
+
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
1022
|
+
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
1023
|
+
const params = getParams$1({
|
|
1024
|
+
paramsType,
|
|
1025
|
+
paramsCasing,
|
|
1026
|
+
pathParamsType,
|
|
1027
|
+
typeSchemas
|
|
1028
|
+
});
|
|
1029
|
+
const clientParams = __kubb_plugin_client_components.Client.getParams({
|
|
1030
|
+
paramsCasing,
|
|
1031
|
+
typeSchemas,
|
|
1032
|
+
paramsType,
|
|
1033
|
+
pathParamsType,
|
|
1034
|
+
isConfigurable: true
|
|
1035
|
+
});
|
|
1036
|
+
const queryKeyParams = QueryKey.getParams({
|
|
1037
|
+
pathParamsType,
|
|
1038
|
+
typeSchemas,
|
|
1039
|
+
paramsCasing
|
|
1040
|
+
});
|
|
1041
|
+
const queryOptions = [
|
|
1042
|
+
`initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
|
|
1043
|
+
cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` : void 0,
|
|
1044
|
+
cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` : void 0,
|
|
1045
|
+
!cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : void 0,
|
|
1046
|
+
!cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : void 0,
|
|
1047
|
+
!cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : void 0
|
|
1048
|
+
].filter(Boolean);
|
|
1049
|
+
const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
|
|
1050
|
+
params = {
|
|
1051
|
+
...(params ?? {}),
|
|
1052
|
+
['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
|
|
1053
|
+
} as ${typeSchemas.queryParams?.name}` : "";
|
|
1054
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
|
|
1055
|
+
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
1056
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
1057
|
+
name,
|
|
1058
|
+
isExportable: true,
|
|
1059
|
+
isIndexable: true,
|
|
1060
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
|
|
1061
|
+
name,
|
|
1062
|
+
export: true,
|
|
1063
|
+
params: params.toConstructor(),
|
|
1064
|
+
children: `
|
|
1065
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1066
|
+
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
1067
|
+
${enabledText}
|
|
1068
|
+
queryKey,
|
|
1069
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
1070
|
+
config.signal = signal
|
|
1071
|
+
${infiniteOverrideParams}
|
|
1072
|
+
return ${clientName}(${clientParams.toCall()})
|
|
1073
|
+
},
|
|
1074
|
+
${queryOptions.join(",\n")}
|
|
1075
|
+
})
|
|
1076
|
+
`
|
|
1077
|
+
})
|
|
1078
|
+
});
|
|
1079
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
1080
|
+
name,
|
|
1081
|
+
isExportable: true,
|
|
1082
|
+
isIndexable: true,
|
|
1083
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
|
|
1084
|
+
name,
|
|
1085
|
+
export: true,
|
|
1086
|
+
params: params.toConstructor(),
|
|
1087
|
+
children: `
|
|
1088
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1089
|
+
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
1090
|
+
${enabledText}
|
|
1091
|
+
queryKey,
|
|
1092
|
+
queryFn: async ({ signal }) => {
|
|
1093
|
+
config.signal = signal
|
|
1094
|
+
return ${clientName}(${clientParams.toCall()})
|
|
1095
|
+
},
|
|
1096
|
+
${queryOptions.join(",\n")}
|
|
1097
|
+
})
|
|
1098
|
+
`
|
|
1099
|
+
})
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
SuspenseInfiniteQueryOptions.getParams = getParams$1;
|
|
821
1103
|
|
|
822
1104
|
//#endregion
|
|
823
1105
|
//#region src/components/SuspenseQuery.tsx
|
|
@@ -1007,10 +1289,22 @@ Object.defineProperty(exports, 'QueryOptions', {
|
|
|
1007
1289
|
return QueryOptions;
|
|
1008
1290
|
}
|
|
1009
1291
|
});
|
|
1292
|
+
Object.defineProperty(exports, 'SuspenseInfiniteQuery', {
|
|
1293
|
+
enumerable: true,
|
|
1294
|
+
get: function () {
|
|
1295
|
+
return SuspenseInfiniteQuery;
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
Object.defineProperty(exports, 'SuspenseInfiniteQueryOptions', {
|
|
1299
|
+
enumerable: true,
|
|
1300
|
+
get: function () {
|
|
1301
|
+
return SuspenseInfiniteQueryOptions;
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1010
1304
|
Object.defineProperty(exports, 'SuspenseQuery', {
|
|
1011
1305
|
enumerable: true,
|
|
1012
1306
|
get: function () {
|
|
1013
1307
|
return SuspenseQuery;
|
|
1014
1308
|
}
|
|
1015
1309
|
});
|
|
1016
|
-
//# sourceMappingURL=components-
|
|
1310
|
+
//# sourceMappingURL=components-C0HQi0Tg.cjs.map
|