@tanstack/react-query 5.103.2 → 5.104.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/README.md +2 -2
- package/build/legacy/HydrationBoundary.d.cts +2 -3
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +2 -3
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +2 -3
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +2 -3
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +4 -5
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +4 -5
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +8 -9
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +8 -9
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.cts +3 -4
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.ts +3 -4
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +7 -8
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +7 -8
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.d.cts +2 -3
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +2 -3
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +9 -9
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +9 -9
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/suspense.cjs.map +1 -1
- package/build/legacy/suspense.d.cts +4 -5
- package/build/legacy/suspense.d.cts.map +1 -1
- package/build/legacy/suspense.d.ts +4 -5
- package/build/legacy/suspense.d.ts.map +1 -1
- package/build/legacy/suspense.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +30 -30
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +30 -30
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -2
- package/build/legacy/useBaseQuery.d.cts.map +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -2
- package/build/legacy/useBaseQuery.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +3 -4
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +3 -4
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -2
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -2
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useMutation.d.cts +1 -2
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +1 -2
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutationState.d.cts +2 -3
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +2 -3
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +1 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +1 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +9 -6
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +9 -6
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +10 -6
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +10 -6
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +11 -8
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +11 -8
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +1 -2
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +1 -2
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +2 -3
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +2 -3
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +2 -3
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +2 -3
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +4 -5
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +4 -5
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +8 -9
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +8 -9
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.cts +3 -4
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.ts +3 -4
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +7 -8
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +7 -8
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.d.cts +2 -3
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +2 -3
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +9 -9
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +9 -9
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/suspense.cjs.map +1 -1
- package/build/modern/suspense.d.cts +4 -5
- package/build/modern/suspense.d.cts.map +1 -1
- package/build/modern/suspense.d.ts +4 -5
- package/build/modern/suspense.d.ts.map +1 -1
- package/build/modern/suspense.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +30 -30
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +30 -30
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -2
- package/build/modern/useBaseQuery.d.cts.map +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -2
- package/build/modern/useBaseQuery.d.ts.map +1 -1
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +3 -4
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +3 -4
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -2
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +1 -2
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useMutation.d.cts +1 -2
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +1 -2
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutationState.d.cts +2 -3
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +2 -3
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +1 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +1 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +9 -6
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +9 -6
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +10 -6
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +10 -6
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +11 -8
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +11 -8
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +1 -2
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +1 -2
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/package.json +8 -9
- package/src/infiniteQueryOptions.ts +1 -1
- package/src/queryOptions.ts +4 -4
- package/src/suspense.ts +1 -2
- package/src/types.ts +5 -4
- package/src/useBaseQuery.ts +3 -6
- package/src/useQueries.ts +6 -2
- package/src/useQuery.ts +7 -2
- package/src/useSuspenseQueries.ts +7 -3
- package/build/query-codemods/eslint.config.js +0 -25
- package/build/query-codemods/package.json +0 -38
- package/build/query-codemods/root.eslint.config.js +0 -113
- package/build/query-codemods/tsconfig.json +0 -8
- package/build/query-codemods/vite.config.ts +0 -30
- /package/build/codemods/{src/utils → utils}/index.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/query-cache-transformer.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/query-client-transformer.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/use-query-like-transformer.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/key-transformation.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/replace-import-specifier.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/utils/replacers/key-replacer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/is-loading/is-loading.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/README.md +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/keep-previous-data.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/utils/already-has-placeholder-data-property.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/remove-overloads.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/transformers/filter-aware-usage-transformer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/utils/index.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/utils/unknown-usage-error.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/rename-hydrate/rename-hydrate.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/rename-properties/rename-properties.cjs +0 -0
|
@@ -41,9 +41,13 @@ type GetUseSuspenseQueryResult<T> = T extends {
|
|
|
41
41
|
} ? UseSuspenseQueryResult<TQueryFnData, unknown extends TError ? DefaultError : TError> : UseSuspenseQueryResult;
|
|
42
42
|
/**
|
|
43
43
|
* The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every
|
|
44
|
-
* entry's `queryFn`/`select` are inferred individually, up to 20 elements
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* entry's `queryFn`/`select` are inferred individually, up to 20 elements — past that, a tuple falls back to
|
|
45
|
+
* a single homogeneous {@link UseSuspenseQueryOptions} type.
|
|
46
|
+
*
|
|
47
|
+
* An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally
|
|
48
|
+
* matches a query options object is mapped per-element instead, still inferring each entry individually; any
|
|
49
|
+
* other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
|
|
50
|
+
* that same homogeneous options type too.
|
|
47
51
|
*
|
|
48
52
|
* @template T - The type of the `queries` array as written at the call site.
|
|
49
53
|
* @template TResults - The internal accumulator that this type builds during recursion. It is not meant
|
|
@@ -51,7 +55,7 @@ type GetUseSuspenseQueryResult<T> = T extends {
|
|
|
51
55
|
* @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not
|
|
52
56
|
* meant to be set explicitly.
|
|
53
57
|
*/
|
|
54
|
-
type SuspenseQueriesOptions<T extends Array<any>, TResults extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryOptions> : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryOptions<Head>] : T extends [infer Head, ...infer Tails] ? SuspenseQueriesOptions<[...Tails], [...TResults, GetUseSuspenseQueryOptions<Head>], [...TDepth, 1]> : Array<unknown> extends T ? T : T extends Array<UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>> : Array<UseSuspenseQueryOptions>;
|
|
58
|
+
export type SuspenseQueriesOptions<T extends Array<any>, TResults extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryOptions> : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryOptions<Head>] : T extends [infer Head, ...infer Tails] ? SuspenseQueriesOptions<[...Tails], [...TResults, GetUseSuspenseQueryOptions<Head>], [...TDepth, 1]> : Array<unknown> extends T ? T : T extends Array<UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>> : Array<UseSuspenseQueryOptions>;
|
|
55
59
|
/**
|
|
56
60
|
* The result type returned by `useSuspenseQueries`, when no `combine` is provided. Mirrors
|
|
57
61
|
* {@link SuspenseQueriesOptions}: each tuple element's result type is inferred individually, up to 20 elements.
|
|
@@ -64,7 +68,7 @@ type SuspenseQueriesOptions<T extends Array<any>, TResults extends Array<any> =
|
|
|
64
68
|
* @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not
|
|
65
69
|
* meant to be set explicitly.
|
|
66
70
|
*/
|
|
67
|
-
type SuspenseQueriesResults<T extends Array<any>, TResults extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryResult<Head>] : T extends [infer Head, ...infer Tails] ? SuspenseQueriesResults<[...Tails], [...TResults, GetUseSuspenseQueryResult<Head>], [...TDepth, 1]> : { [K in keyof T]: GetUseSuspenseQueryResult<T[K]>; };
|
|
71
|
+
export type SuspenseQueriesResults<T extends Array<any>, TResults extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryResult<Head>] : T extends [infer Head, ...infer Tails] ? SuspenseQueriesResults<[...Tails], [...TResults, GetUseSuspenseQueryResult<Head>], [...TDepth, 1]> : { [K in keyof T]: GetUseSuspenseQueryResult<T[K]>; };
|
|
68
72
|
/**
|
|
69
73
|
* The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`
|
|
70
74
|
* option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
|
|
@@ -231,7 +235,7 @@ type SuspenseQueriesResults<T extends Array<any>, TResults extends Array<any> =
|
|
|
231
235
|
* }
|
|
232
236
|
* ```
|
|
233
237
|
*/
|
|
234
|
-
declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = SuspenseQueriesResults<T>>(options: {
|
|
238
|
+
export declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = SuspenseQueriesResults<T>>(options: {
|
|
235
239
|
/**
|
|
236
240
|
* An array with query option objects identical to `useSuspenseQuery`.
|
|
237
241
|
*/
|
|
@@ -362,7 +366,7 @@ declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = Susp
|
|
|
362
366
|
* }
|
|
363
367
|
* ```
|
|
364
368
|
*/
|
|
365
|
-
declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = SuspenseQueriesResults<T>>(options: {
|
|
369
|
+
export declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = SuspenseQueriesResults<T>>(options: {
|
|
366
370
|
/**
|
|
367
371
|
* An array with query option objects identical to `useSuspenseQuery`.
|
|
368
372
|
*/
|
|
@@ -374,5 +378,4 @@ declare function useSuspenseQueries<T extends Array<any>, TCombinedResult = Susp
|
|
|
374
378
|
combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult;
|
|
375
379
|
}, queryClient?: QueryClient): TCombinedResult;
|
|
376
380
|
//#endregion
|
|
377
|
-
export { SuspenseQueriesOptions, SuspenseQueriesResults, useSuspenseQueries };
|
|
378
381
|
//# sourceMappingURL=useSuspenseQueries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQueries.d.ts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":";;;KAaK;KAGA;KAEA,2BAA2B,KAE9B;EACE,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEV,wBAAwB,cAAc,QAAQ,SAC9C;EAAY,mBAAmB;EAAc,cAAc;IACzD,wBAAwB,cAAc,UACtC;EAAY,YAAY;EAAO,cAAc;IAC3C,iCAAiC,QAAQ,SAEzC,iBAAiB,oBAAoB,cAAc,SACjD,wBAAwB,cAAc,QAAQ,SAC9C,iBAAiB,oBAAoB,UACnC,wBAAwB,cAAc,UACtC,iBAAiB,gBACf,wBAAwB,gBAExB;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,OACA,aAEF;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,cACA,aAGF;KAEf,0BAA0B,KAE7B;EAAY;EAAkB,cAAc;EAAQ,YAAY;IAC5D,uBAAuB,OAAO,UAC9B;EAAY,mBAAmB;EAAc,cAAc;IACzD,uBAAuB,cAAc,UACrC;EAAY,YAAY;EAAO,cAAc;IAC3C,uBAAuB,OAAO,UAE9B,sBAAsB,cAAc,SAClC,uBAAuB,OAAO,UAC9B,iBAAiB,oBAAoB,UACnC,uBAAuB,cAAc,UACrC,iBAAiB,gBACf,uBAAuB,gBAEvB;EACI,UACI,oBAAoB,qBACpB;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,uCACkB,QAAQ,eAAe,uBACvB,SAAS,eAAe,UAE1C;EACI,UACI,oBAAoB,qBACpB;EACJ,eAAe,wBAAwB;IAEzC,uBACE,8BACgB,SAAS,eAAe,UAG1C
|
|
1
|
+
{"version":3,"file":"useSuspenseQueries.d.ts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":";;;KAaK;KAGA;KAEA,2BAA2B,KAE9B;EACE,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEV,wBAAwB,cAAc,QAAQ,SAC9C;EAAY,mBAAmB;EAAc,cAAc;IACzD,wBAAwB,cAAc,UACtC;EAAY,YAAY;EAAO,cAAc;IAC3C,iCAAiC,QAAQ,SAEzC,iBAAiB,oBAAoB,cAAc,SACjD,wBAAwB,cAAc,QAAQ,SAC9C,iBAAiB,oBAAoB,UACnC,wBAAwB,cAAc,UACtC,iBAAiB,gBACf,wBAAwB,gBAExB;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,OACA,aAEF;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,cACA,aAGF;KAEf,0BAA0B,KAE7B;EAAY;EAAkB,cAAc;EAAQ,YAAY;IAC5D,uBAAuB,OAAO,UAC9B;EAAY,mBAAmB;EAAc,cAAc;IACzD,uBAAuB,cAAc,UACrC;EAAY,YAAY;EAAO,cAAc;IAC3C,uBAAuB,OAAO,UAE9B,sBAAsB,cAAc,SAClC,uBAAuB,OAAO,UAC9B,iBAAiB,oBAAoB,UACnC,uBAAuB,cAAc,UACrC,iBAAiB,gBACf,uBAAuB,gBAEvB;EACI,UACI,oBAAoB,qBACpB;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,uCACkB,QAAQ,eAAe,uBACvB,SAAS,eAAe,UAE1C;EACI,UACI,oBAAoB,qBACpB;EACJ,eAAe,wBAAwB;IAEzC,uBACE,8BACgB,SAAS,eAAe,UAG1C;;;;;;;;;;;;;;;;;YAkBR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,2BACN,oBAEE,iBAAiB,YACX,UAAU,2BAA2B,SACzC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,2BAA2B,YACrC,cAEN,uBAAuB,IACrB,IAGA,UAAU,MACN,8BACQ,oBACA,cACA,aACA,cAGV,MACE,wBAAwB,cAAc,QAAQ,OAAO,cAGvD,MAAM;;;;;;;;;;;;;YAcR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,0BACN,oBAEE,iBAAiB,YACX,UAAU,0BAA0B,SACxC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,0BAA0B,YACpC,iBAEH,WAAW,IAAI,0BAA0B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwKxC,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBACiB,uBAAuB,sBACpB,WAAW,IAAI,2BAA2B,EAAE;;;;;EAKhE,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Ha,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBAAsB,uBAAuB;;;;;EAK7C,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQueries.js","names":[],"sources":["../../src/useSuspenseQueries.ts"],"sourcesContent":["'use client'\nimport { skipToken } from '@tanstack/query-core'\nimport { useQueries } from './useQueries'\nimport { defaultThrowOnError } from './suspense'\nimport type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'\nimport type {\n DefaultError,\n QueryClient,\n QueryFunction,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseSuspenseQueryOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseSuspenseQueryOptions<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryOptions<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryOptions<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseSuspenseQueryOptions<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryOptions<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryOptions<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseSuspenseQueryOptions\n\ntype GetUseSuspenseQueryResult<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseSuspenseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseSuspenseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryResult<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseSuspenseQueryResult\n\n/**\n * The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every\n * entry's `queryFn`/`select` are inferred individually, up to 20 elements. An opaque array (e.g. `unknown[]`)\n * is returned as-is; a non-tuple array of a known element type, or a tuple past 20 elements, falls back to a\n * single homogeneous {@link UseSuspenseQueryOptions} type.\n *\n * @template T - The type of the `queries` array as written at the call site.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type SuspenseQueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseSuspenseQueryOptions>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryOptions<Head>]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesOptions<\n [...Tails],\n [...TResults, GetUseSuspenseQueryOptions<Head>],\n [...TDepth, 1]\n >\n : Array<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseSuspenseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n >\n : // Fallback\n Array<UseSuspenseQueryOptions>\n\n/**\n * The result type returned by `useSuspenseQueries`, when no `combine` is provided. Mirrors\n * {@link SuspenseQueriesOptions}: each tuple element's result type is inferred individually, up to 20 elements.\n * A non-tuple array is mapped per-element instead, still inferring each entry individually; only past 20\n * elements does this fall back to a single homogeneous {@link UseSuspenseQueryResult} type.\n *\n * @template T - The type of the `queries` array, as inferred by {@link SuspenseQueriesOptions}.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type SuspenseQueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseSuspenseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesResults<\n [...Tails],\n [...TResults, GetUseSuspenseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseSuspenseQueryResult<T[K]> }\n\n/**\n * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`\n * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.\n *\n * @param options - The `queries` array to run in Suspense, and an optional `combine` function.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be\n * defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived\n * flags set accordingly).\n *\n * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone\n * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid\n * this, make sure to set a high enough `staleTime`. Cancellation does not work.\n *\n * @example\n * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is\n * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.\n * Use {@link QueryErrorResetBoundary} to let the user retry after such an error:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * // Every result is guaranteed to be defined — no per-query `isPending` check needed.\n * const postQueries = useSuspenseQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query) => (\n * <li key={query.data.id}>{query.data.title}</li>\n * ))}\n * </ul>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts ids={[1, 2, 3]} />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so\n * they fetch in parallel rather than suspending one after another:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Dashboard() {\n * const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * { queryKey: ['projects'], queryFn: fetchProjects },\n * ],\n * })\n *\n * return (\n * <div>\n * <UserList users={usersQuery.data} />\n * <TeamList teams={teamsQuery.data} />\n * <ProjectList projects={projectsQuery.data} />\n * </div>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Dashboard />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * `combine`s the results into a single boolean, so `Refresh` only re-renders when that boolean changes,\n * not on every individual query update. This overload is the only one that accepts `combine`:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Refresh() {\n * const anyFetching = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * ],\n * combine: (results) => results.some((result) => result.isFetching),\n * })\n *\n * return anyFetching ? <span>Refreshing…</span> : null\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Refresh />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport function useSuspenseQueries<\n T extends Array<any>,\n TCombinedResult = SuspenseQueriesResults<T>,\n>(\n options: {\n /**\n * An array with query option objects identical to `useSuspenseQuery`.\n */\n queries:\n | readonly [...SuspenseQueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetUseSuspenseQueryOptions<T[K]> }]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): TCombinedResult\n\n/**\n * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`\n * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.\n *\n * @param options - The `queries` array to run in Suspense, and an optional `combine` function.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be\n * defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived\n * flags set accordingly).\n *\n * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone\n * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid\n * this, make sure to set a high enough `staleTime`. Cancellation does not work.\n *\n * @example\n * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is\n * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.\n * Use {@link QueryErrorResetBoundary} to let the user retry after such an error:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * // Every result is guaranteed to be defined — no per-query `isPending` check needed.\n * const postQueries = useSuspenseQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query) => (\n * <li key={query.data.id}>{query.data.title}</li>\n * ))}\n * </ul>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts ids={[1, 2, 3]} />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so\n * they fetch in parallel rather than suspending one after another:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Dashboard() {\n * const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * { queryKey: ['projects'], queryFn: fetchProjects },\n * ],\n * })\n *\n * return (\n * <div>\n * <UserList users={usersQuery.data} />\n * <TeamList teams={teamsQuery.data} />\n * <ProjectList projects={projectsQuery.data} />\n * </div>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Dashboard />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport function useSuspenseQueries<\n T extends Array<any>,\n TCombinedResult = SuspenseQueriesResults<T>,\n>(\n options: {\n /**\n * An array with query option objects identical to `useSuspenseQuery`.\n */\n queries: readonly [...SuspenseQueriesOptions<T>]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): TCombinedResult\n\nexport function useSuspenseQueries(options: any, queryClient?: QueryClient) {\n return useQueries(\n {\n ...options,\n queries: options.queries.map((query: any) => {\n if (process.env.NODE_ENV !== 'production') {\n if (query.queryFn === skipToken) {\n console.error('skipToken is not allowed for useSuspenseQueries')\n }\n }\n\n return {\n ...query,\n suspense: true,\n throwOnError: defaultThrowOnError,\n enabled: true,\n placeholderData: undefined,\n }\n }),\n },\n queryClient,\n )\n}\n"],"mappings":";;;;;AA0fA,SAAgB,mBAAmB,SAAc,aAA2B;CAC1E,OAAO,WACL;EACE,GAAG;EACH,SAAS,QAAQ,QAAQ,KAAK,UAAe;GAC3C,IAAI,QAAQ,IAAI,aAAa,cACvB;QAAA,MAAM,YAAY,WACpB,QAAQ,MAAM,iDAAiD;GAAA;GAInE,OAAO;IACL,GAAG;IACH,UAAU;IACV,cAAc;IACd,SAAS;IACT,iBAAiB,KAAA;GACnB;EACF,CAAC;CACH,GACA,WACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useSuspenseQueries.js","names":[],"sources":["../../src/useSuspenseQueries.ts"],"sourcesContent":["'use client'\nimport { skipToken } from '@tanstack/query-core'\nimport { useQueries } from './useQueries'\nimport { defaultThrowOnError } from './suspense'\nimport type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'\nimport type {\n DefaultError,\n QueryClient,\n QueryFunction,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseSuspenseQueryOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseSuspenseQueryOptions<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryOptions<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryOptions<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseSuspenseQueryOptions<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryOptions<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryOptions<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseSuspenseQueryOptions\n\ntype GetUseSuspenseQueryResult<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseSuspenseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseSuspenseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseSuspenseQueryResult<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseSuspenseQueryResult\n\n/**\n * The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every\n * entry's `queryFn`/`select` are inferred individually, up to 20 elements — past that, a tuple falls back to\n * a single homogeneous {@link UseSuspenseQueryOptions} type.\n *\n * An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally\n * matches a query options object is mapped per-element instead, still inferring each entry individually; any\n * other non-tuple array — one whose element type doesn't match the expected options shape — falls back to\n * that same homogeneous options type too.\n *\n * @template T - The type of the `queries` array as written at the call site.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type SuspenseQueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseSuspenseQueryOptions>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryOptions<Head>]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesOptions<\n [...Tails],\n [...TResults, GetUseSuspenseQueryOptions<Head>],\n [...TDepth, 1]\n >\n : Array<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseSuspenseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n >\n : // Fallback\n Array<UseSuspenseQueryOptions>\n\n/**\n * The result type returned by `useSuspenseQueries`, when no `combine` is provided. Mirrors\n * {@link SuspenseQueriesOptions}: each tuple element's result type is inferred individually, up to 20 elements.\n * A non-tuple array is mapped per-element instead, still inferring each entry individually; only past 20\n * elements does this fall back to a single homogeneous {@link UseSuspenseQueryResult} type.\n *\n * @template T - The type of the `queries` array, as inferred by {@link SuspenseQueriesOptions}.\n * @template TResults - The internal accumulator that this type builds during recursion. It is not meant\n * to be set explicitly.\n * @template TDepth - The internal recursion-depth counter, checked against the 20-element limit. It is not\n * meant to be set explicitly.\n */\nexport type SuspenseQueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseSuspenseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesResults<\n [...Tails],\n [...TResults, GetUseSuspenseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseSuspenseQueryResult<T[K]> }\n\n/**\n * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`\n * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.\n *\n * @param options - The `queries` array to run in Suspense, and an optional `combine` function.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be\n * defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived\n * flags set accordingly).\n *\n * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone\n * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid\n * this, make sure to set a high enough `staleTime`. Cancellation does not work.\n *\n * @example\n * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is\n * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.\n * Use {@link QueryErrorResetBoundary} to let the user retry after such an error:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * // Every result is guaranteed to be defined — no per-query `isPending` check needed.\n * const postQueries = useSuspenseQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query) => (\n * <li key={query.data.id}>{query.data.title}</li>\n * ))}\n * </ul>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts ids={[1, 2, 3]} />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so\n * they fetch in parallel rather than suspending one after another:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Dashboard() {\n * const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * { queryKey: ['projects'], queryFn: fetchProjects },\n * ],\n * })\n *\n * return (\n * <div>\n * <UserList users={usersQuery.data} />\n * <TeamList teams={teamsQuery.data} />\n * <ProjectList projects={projectsQuery.data} />\n * </div>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Dashboard />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * `combine`s the results into a single boolean, so `Refresh` only re-renders when that boolean changes,\n * not on every individual query update. This overload is the only one that accepts `combine`:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Refresh() {\n * const anyFetching = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * ],\n * combine: (results) => results.some((result) => result.isFetching),\n * })\n *\n * return anyFetching ? <span>Refreshing…</span> : null\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Refresh />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport function useSuspenseQueries<\n T extends Array<any>,\n TCombinedResult = SuspenseQueriesResults<T>,\n>(\n options: {\n /**\n * An array with query option objects identical to `useSuspenseQuery`.\n */\n queries:\n | readonly [...SuspenseQueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetUseSuspenseQueryOptions<T[K]> }]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): TCombinedResult\n\n/**\n * The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`\n * option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.\n *\n * @param options - The `queries` array to run in Suspense, and an optional `combine` function.\n * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be\n * defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived\n * flags set accordingly).\n *\n * Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone\n * stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid\n * this, make sure to set a high enough `staleTime`. Cancellation does not work.\n *\n * @example\n * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is\n * required around `<Suspense>`. A failed background refetch instead continues to render the cached data.\n * Use {@link QueryErrorResetBoundary} to let the user retry after such an error:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Posts({ ids }: { ids: Array<number> }) {\n * // Every result is guaranteed to be defined — no per-query `isPending` check needed.\n * const postQueries = useSuspenseQueries({\n * queries: ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * })\n *\n * return (\n * <ul>\n * {postQueries.map((query) => (\n * <li key={query.data.id}>{query.data.title}</li>\n * ))}\n * </ul>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading posts...</h1>}>\n * <Posts ids={[1, 2, 3]} />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n *\n * @example\n * Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so\n * they fetch in parallel rather than suspending one after another:\n * ```tsx\n * import { Suspense } from 'react'\n * import { ErrorBoundary } from 'react-error-boundary'\n * import {\n * QueryErrorResetBoundary,\n * useSuspenseQueries,\n * } from '@tanstack/react-query'\n *\n * function Dashboard() {\n * const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({\n * queries: [\n * { queryKey: ['users'], queryFn: fetchUsers },\n * { queryKey: ['teams'], queryFn: fetchTeams },\n * { queryKey: ['projects'], queryFn: fetchProjects },\n * ],\n * })\n *\n * return (\n * <div>\n * <UserList users={usersQuery.data} />\n * <TeamList teams={teamsQuery.data} />\n * <ProjectList projects={projectsQuery.data} />\n * </div>\n * )\n * }\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Suspense fallback={<h1>Loading dashboard...</h1>}>\n * <Dashboard />\n * </Suspense>\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport function useSuspenseQueries<\n T extends Array<any>,\n TCombinedResult = SuspenseQueriesResults<T>,\n>(\n options: {\n /**\n * An array with query option objects identical to `useSuspenseQuery`.\n */\n queries: readonly [...SuspenseQueriesOptions<T>]\n /**\n * Use this to combine the results of the queries into a single value. The result will be structurally\n * shared to be as referentially stable as possible.\n */\n combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): TCombinedResult\n\nexport function useSuspenseQueries(options: any, queryClient?: QueryClient) {\n return useQueries(\n {\n ...options,\n queries: options.queries.map((query: any) => {\n if (process.env.NODE_ENV !== 'production') {\n if (query.queryFn === skipToken) {\n console.error('skipToken is not allowed for useSuspenseQueries')\n }\n }\n\n return {\n ...query,\n suspense: true,\n throwOnError: defaultThrowOnError,\n enabled: true,\n placeholderData: undefined,\n }\n }),\n },\n queryClient,\n )\n}\n"],"mappings":";;;;;AA8fA,SAAgB,mBAAmB,SAAc,aAA2B;CAC1E,OAAO,WACL;EACE,GAAG;EACH,SAAS,QAAQ,QAAQ,KAAK,UAAe;GAC3C,IAAI,QAAQ,IAAI,aAAa,cACvB;QAAA,MAAM,YAAY,WACpB,QAAQ,MAAM,iDAAiD;GAAA;GAInE,OAAO;IACL,GAAG;IACH,UAAU;IACV,cAAc;IACd,SAAS;IACT,iBAAiB,KAAA;GACnB;EACF,CAAC;CACH,GACA,WACF;AACF"}
|
|
@@ -68,7 +68,6 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
|
68
68
|
* }
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
|
-
declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
71
|
+
export declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
72
72
|
//#endregion
|
|
73
|
-
export { useSuspenseQuery };
|
|
74
73
|
//# sourceMappingURL=useSuspenseQuery.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.d.cts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.cts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0EgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,wBAAwB,cAAc,QAAQ,OAAO,YAC9D,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -68,7 +68,6 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
|
68
68
|
* }
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
|
-
declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
71
|
+
export declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
72
72
|
//#endregion
|
|
73
|
-
export { useSuspenseQuery };
|
|
74
73
|
//# sourceMappingURL=useSuspenseQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.d.ts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.ts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0EgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,wBAAwB,cAAc,QAAQ,OAAO,YAC9D,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -4,7 +4,7 @@ import { DehydratedState, HydrateOptions, OmitKeyof, QueryClient } from "@tansta
|
|
|
4
4
|
/**
|
|
5
5
|
* The props accepted by `HydrationBoundary`.
|
|
6
6
|
*/
|
|
7
|
-
interface HydrationBoundaryProps {
|
|
7
|
+
export interface HydrationBoundaryProps {
|
|
8
8
|
/**
|
|
9
9
|
* The state to hydrate.
|
|
10
10
|
*/
|
|
@@ -70,7 +70,6 @@ interface HydrationBoundaryProps {
|
|
|
70
70
|
* }
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
|
-
declare const HydrationBoundary: ({ children, options, state, queryClient }: HydrationBoundaryProps) => React.ReactElement;
|
|
73
|
+
export declare const HydrationBoundary: ({ children, options, state, queryClient }: HydrationBoundaryProps) => React.ReactElement;
|
|
74
74
|
//#endregion
|
|
75
|
-
export { HydrationBoundary, HydrationBoundaryProps };
|
|
76
75
|
//# sourceMappingURL=HydrationBoundary.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.d.cts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.d.cts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8CH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BA+EkB,MAAM"}
|
|
@@ -4,7 +4,7 @@ import { DehydratedState, HydrateOptions, OmitKeyof, QueryClient } from "@tansta
|
|
|
4
4
|
/**
|
|
5
5
|
* The props accepted by `HydrationBoundary`.
|
|
6
6
|
*/
|
|
7
|
-
interface HydrationBoundaryProps {
|
|
7
|
+
export interface HydrationBoundaryProps {
|
|
8
8
|
/**
|
|
9
9
|
* The state to hydrate.
|
|
10
10
|
*/
|
|
@@ -70,7 +70,6 @@ interface HydrationBoundaryProps {
|
|
|
70
70
|
* }
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
|
-
declare const HydrationBoundary: ({ children, options, state, queryClient }: HydrationBoundaryProps) => React.ReactElement;
|
|
73
|
+
export declare const HydrationBoundary: ({ children, options, state, queryClient }: HydrationBoundaryProps) => React.ReactElement;
|
|
74
74
|
//#endregion
|
|
75
|
-
export { HydrationBoundary, HydrationBoundaryProps };
|
|
76
75
|
//# sourceMappingURL=HydrationBoundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8CH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BA+EkB,MAAM"}
|
|
@@ -7,12 +7,11 @@ import * as React from "react";
|
|
|
7
7
|
*
|
|
8
8
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
9
9
|
*/
|
|
10
|
-
declare const useIsRestoring: () => boolean;
|
|
10
|
+
export declare const useIsRestoring: () => boolean;
|
|
11
11
|
/**
|
|
12
12
|
* The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
|
|
13
13
|
* being restored, read by `useIsRestoring`.
|
|
14
14
|
*/
|
|
15
|
-
declare const IsRestoringProvider: React.Provider<boolean>;
|
|
15
|
+
export declare const IsRestoringProvider: React.Provider<boolean>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { IsRestoringProvider, useIsRestoring };
|
|
18
17
|
//# sourceMappingURL=IsRestoringProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;qBAYa;;;;;qBAMA,qBAAmB,MAAA"}
|
|
@@ -7,12 +7,11 @@ import * as React from "react";
|
|
|
7
7
|
*
|
|
8
8
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
9
9
|
*/
|
|
10
|
-
declare const useIsRestoring: () => boolean;
|
|
10
|
+
export declare const useIsRestoring: () => boolean;
|
|
11
11
|
/**
|
|
12
12
|
* The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
|
|
13
13
|
* being restored, read by `useIsRestoring`.
|
|
14
14
|
*/
|
|
15
|
-
declare const IsRestoringProvider: React.Provider<boolean>;
|
|
15
|
+
export declare const IsRestoringProvider: React.Provider<boolean>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { IsRestoringProvider, useIsRestoring };
|
|
18
17
|
//# sourceMappingURL=IsRestoringProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;qBAYa;;;;;qBAMA,qBAAmB,MAAA"}
|
|
@@ -4,7 +4,7 @@ import { QueryClient } from "@tanstack/query-core";
|
|
|
4
4
|
/**
|
|
5
5
|
* The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
|
|
6
6
|
*/
|
|
7
|
-
declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
7
|
+
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
8
8
|
/**
|
|
9
9
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
10
10
|
*
|
|
@@ -13,11 +13,11 @@ declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
|
13
13
|
* @returns The current `QueryClient` instance.
|
|
14
14
|
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
|
|
15
15
|
*/
|
|
16
|
-
declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
16
|
+
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
17
17
|
/**
|
|
18
18
|
* The props accepted by `QueryClientProvider`.
|
|
19
19
|
*/
|
|
20
|
-
type QueryClientProviderProps = {
|
|
20
|
+
export type QueryClientProviderProps = {
|
|
21
21
|
/**
|
|
22
22
|
* **Required**
|
|
23
23
|
*
|
|
@@ -48,7 +48,6 @@ type QueryClientProviderProps = {
|
|
|
48
48
|
* }
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
|
|
51
|
+
export declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { QueryClientContext, QueryClientProvider, QueryClientProviderProps, useQueryClient };
|
|
54
53
|
//# sourceMappingURL=QueryClientProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;qBAsBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
|
|
@@ -4,7 +4,7 @@ import { QueryClient } from "@tanstack/query-core";
|
|
|
4
4
|
/**
|
|
5
5
|
* The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
|
|
6
6
|
*/
|
|
7
|
-
declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
7
|
+
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
8
8
|
/**
|
|
9
9
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
10
10
|
*
|
|
@@ -13,11 +13,11 @@ declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
|
13
13
|
* @returns The current `QueryClient` instance.
|
|
14
14
|
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
|
|
15
15
|
*/
|
|
16
|
-
declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
16
|
+
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
17
17
|
/**
|
|
18
18
|
* The props accepted by `QueryClientProvider`.
|
|
19
19
|
*/
|
|
20
|
-
type QueryClientProviderProps = {
|
|
20
|
+
export type QueryClientProviderProps = {
|
|
21
21
|
/**
|
|
22
22
|
* **Required**
|
|
23
23
|
*
|
|
@@ -48,7 +48,6 @@ type QueryClientProviderProps = {
|
|
|
48
48
|
* }
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
|
|
51
|
+
export declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { QueryClientContext, QueryClientProvider, QueryClientProviderProps, useQueryClient };
|
|
54
53
|
//# sourceMappingURL=QueryClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;qBAsBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/QueryErrorResetBoundary.d.ts
|
|
3
|
-
type QueryErrorResetFunction = () => void;
|
|
4
|
-
type QueryErrorIsResetFunction = () => boolean;
|
|
5
|
-
type QueryErrorClearResetFunction = () => void;
|
|
6
|
-
interface QueryErrorResetBoundaryValue {
|
|
3
|
+
export type QueryErrorResetFunction = () => void;
|
|
4
|
+
export type QueryErrorIsResetFunction = () => boolean;
|
|
5
|
+
export type QueryErrorClearResetFunction = () => void;
|
|
6
|
+
export interface QueryErrorResetBoundaryValue {
|
|
7
7
|
clearReset: QueryErrorClearResetFunction;
|
|
8
8
|
isReset: QueryErrorIsResetFunction;
|
|
9
9
|
reset: QueryErrorResetFunction;
|
|
@@ -38,18 +38,18 @@ interface QueryErrorResetBoundaryValue {
|
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
41
|
+
export declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
42
42
|
/**
|
|
43
43
|
* A render-prop function usable as `children` on `QueryErrorResetBoundary`.
|
|
44
44
|
*
|
|
45
45
|
* @param value - The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
46
46
|
* @returns The children to render.
|
|
47
47
|
*/
|
|
48
|
-
type QueryErrorResetBoundaryFunction = (value: QueryErrorResetBoundaryValue) => React.ReactNode;
|
|
48
|
+
export type QueryErrorResetBoundaryFunction = (value: QueryErrorResetBoundaryValue) => React.ReactNode;
|
|
49
49
|
/**
|
|
50
50
|
* The props accepted by `QueryErrorResetBoundary`.
|
|
51
51
|
*/
|
|
52
|
-
interface QueryErrorResetBoundaryProps {
|
|
52
|
+
export interface QueryErrorResetBoundaryProps {
|
|
53
53
|
/**
|
|
54
54
|
* Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and
|
|
55
55
|
* returns a node.
|
|
@@ -90,7 +90,6 @@ interface QueryErrorResetBoundaryProps {
|
|
|
90
90
|
* }
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
export declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
94
94
|
//#endregion
|
|
95
|
-
export { QueryErrorClearResetFunction, QueryErrorIsResetFunction, QueryErrorResetBoundary, QueryErrorResetBoundaryFunction, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, QueryErrorResetFunction, useQueryErrorResetBoundary };
|
|
96
95
|
//# sourceMappingURL=QueryErrorResetBoundary.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;YAIY;YACA;YACA;iBAEK;EACf,YAAY;EACZ,SAAS;EACT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgEI,kCAA0B;;;;;;;YAW3B,mCACV,OAAO,iCACJ,MAAM;;;;iBAKM;;;;;EAKf,UAAU,kCAAkC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCvC,4BAA2B,YAErC,6DAA4B,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/QueryErrorResetBoundary.d.ts
|
|
3
|
-
type QueryErrorResetFunction = () => void;
|
|
4
|
-
type QueryErrorIsResetFunction = () => boolean;
|
|
5
|
-
type QueryErrorClearResetFunction = () => void;
|
|
6
|
-
interface QueryErrorResetBoundaryValue {
|
|
3
|
+
export type QueryErrorResetFunction = () => void;
|
|
4
|
+
export type QueryErrorIsResetFunction = () => boolean;
|
|
5
|
+
export type QueryErrorClearResetFunction = () => void;
|
|
6
|
+
export interface QueryErrorResetBoundaryValue {
|
|
7
7
|
clearReset: QueryErrorClearResetFunction;
|
|
8
8
|
isReset: QueryErrorIsResetFunction;
|
|
9
9
|
reset: QueryErrorResetFunction;
|
|
@@ -38,18 +38,18 @@ interface QueryErrorResetBoundaryValue {
|
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
41
|
+
export declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
42
42
|
/**
|
|
43
43
|
* A render-prop function usable as `children` on `QueryErrorResetBoundary`.
|
|
44
44
|
*
|
|
45
45
|
* @param value - The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
46
46
|
* @returns The children to render.
|
|
47
47
|
*/
|
|
48
|
-
type QueryErrorResetBoundaryFunction = (value: QueryErrorResetBoundaryValue) => React.ReactNode;
|
|
48
|
+
export type QueryErrorResetBoundaryFunction = (value: QueryErrorResetBoundaryValue) => React.ReactNode;
|
|
49
49
|
/**
|
|
50
50
|
* The props accepted by `QueryErrorResetBoundary`.
|
|
51
51
|
*/
|
|
52
|
-
interface QueryErrorResetBoundaryProps {
|
|
52
|
+
export interface QueryErrorResetBoundaryProps {
|
|
53
53
|
/**
|
|
54
54
|
* Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and
|
|
55
55
|
* returns a node.
|
|
@@ -90,7 +90,6 @@ interface QueryErrorResetBoundaryProps {
|
|
|
90
90
|
* }
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
export declare const QueryErrorResetBoundary: ({ children }: QueryErrorResetBoundaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
94
94
|
//#endregion
|
|
95
|
-
export { QueryErrorClearResetFunction, QueryErrorIsResetFunction, QueryErrorResetBoundary, QueryErrorResetBoundaryFunction, QueryErrorResetBoundaryProps, QueryErrorResetBoundaryValue, QueryErrorResetFunction, useQueryErrorResetBoundary };
|
|
96
95
|
//# sourceMappingURL=QueryErrorResetBoundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;YAIY;YACA;YACA;iBAEK;EACf,YAAY;EACZ,SAAS;EACT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgEI,kCAA0B;;;;;;;YAW3B,mCACV,OAAO,iCACJ,MAAM;;;;iBAKM;;;;;EAKf,UAAU,kCAAkC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCvC,4BAA2B,YAErC,6DAA4B,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.cjs";
|
|
2
2
|
import { DefaultedQueryObserverOptions, Query, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
|
|
3
3
|
//#region src/errorBoundaryUtils.d.ts
|
|
4
|
-
declare const ensurePreventErrorBoundaryRetry: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue, query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => void;
|
|
5
|
-
declare const useClearResetErrorBoundary: (errorResetBoundary: QueryErrorResetBoundaryValue) => void;
|
|
6
|
-
declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey extends QueryKey>({ result, errorResetBoundary, throwOnError, query, suspense }: {
|
|
4
|
+
export declare const ensurePreventErrorBoundaryRetry: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue, query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => void;
|
|
5
|
+
export declare const useClearResetErrorBoundary: (errorResetBoundary: QueryErrorResetBoundaryValue) => void;
|
|
6
|
+
export declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey extends QueryKey>({ result, errorResetBoundary, throwOnError, query, suspense }: {
|
|
7
7
|
result: QueryObserverResult<TData, TError>;
|
|
8
8
|
errorResetBoundary: QueryErrorResetBoundaryValue;
|
|
9
9
|
throwOnError: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
@@ -11,5 +11,4 @@ declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey e
|
|
|
11
11
|
suspense: boolean | undefined;
|
|
12
12
|
}) => boolean | undefined;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary };
|
|
15
14
|
//# sourceMappingURL=errorBoundaryUtils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorBoundaryUtils.d.cts","names":[],"sources":["../../src/errorBoundaryUtils.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errorBoundaryUtils.d.cts","names":[],"sources":["../../src/errorBoundaryUtils.ts"],"mappings":";;;qBAYa,kCACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,SAAS,8BACP,cACA,QACA,OACA,YACA,YAEF,oBAAoB,8BACpB,OAAO,MAAM,cAAc,QAAQ,YAAY;qBAepC,6BACX,oBAAoB;qBAOT,cACX,OACA,QACA,cACA,YACA,kBAAkB,YAClB,QAAA,oBAAA,cAAA,OAAA;EAOA,QAAQ,oBAAoB,OAAO;EACnC,oBAAoB;EACpB,cAAc,aAAa,cAAc,QAAQ,YAAY;EAC7D,OAAO,MAAM,cAAc,QAAQ,YAAY;EAC/C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.js";
|
|
2
2
|
import { DefaultedQueryObserverOptions, Query, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
|
|
3
3
|
//#region src/errorBoundaryUtils.d.ts
|
|
4
|
-
declare const ensurePreventErrorBoundaryRetry: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue, query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => void;
|
|
5
|
-
declare const useClearResetErrorBoundary: (errorResetBoundary: QueryErrorResetBoundaryValue) => void;
|
|
6
|
-
declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey extends QueryKey>({ result, errorResetBoundary, throwOnError, query, suspense }: {
|
|
4
|
+
export declare const ensurePreventErrorBoundaryRetry: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue, query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => void;
|
|
5
|
+
export declare const useClearResetErrorBoundary: (errorResetBoundary: QueryErrorResetBoundaryValue) => void;
|
|
6
|
+
export declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey extends QueryKey>({ result, errorResetBoundary, throwOnError, query, suspense }: {
|
|
7
7
|
result: QueryObserverResult<TData, TError>;
|
|
8
8
|
errorResetBoundary: QueryErrorResetBoundaryValue;
|
|
9
9
|
throwOnError: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
@@ -11,5 +11,4 @@ declare const getHasError: <TData, TError, TQueryFnData, TQueryData, TQueryKey e
|
|
|
11
11
|
suspense: boolean | undefined;
|
|
12
12
|
}) => boolean | undefined;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary };
|
|
15
14
|
//# sourceMappingURL=errorBoundaryUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorBoundaryUtils.d.ts","names":[],"sources":["../../src/errorBoundaryUtils.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errorBoundaryUtils.d.ts","names":[],"sources":["../../src/errorBoundaryUtils.ts"],"mappings":";;;qBAYa,kCACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,SAAS,8BACP,cACA,QACA,OACA,YACA,YAEF,oBAAoB,8BACpB,OAAO,MAAM,cAAc,QAAQ,YAAY;qBAepC,6BACX,oBAAoB;qBAOT,cACX,OACA,QACA,cACA,YACA,kBAAkB,YAClB,QAAA,oBAAA,cAAA,OAAA;EAOA,QAAQ,oBAAoB,OAAO;EACnC,oBAAoB;EACpB,cAAc,aAAa,cAAc,QAAQ,YAAY;EAC7D,OAAO,MAAM,cAAc,QAAQ,YAAY;EAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryOptions.cjs","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and\n * `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be\n * `skipToken`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n *\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AA4TA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions.cjs","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and\n * `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be\n * `skipToken`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n *\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AA4TA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
|