@tanstack/query-core 5.0.0-alpha.3 → 5.0.0-alpha.32
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/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +13 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +16 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/focusManager.d.ts +1 -0
- package/build/lib/focusManager.d.ts.map +1 -0
- package/build/lib/focusManager.esm.js +31 -15
- package/build/lib/focusManager.esm.js.map +1 -1
- package/build/lib/focusManager.js +31 -15
- package/build/lib/focusManager.js.map +1 -1
- package/build/lib/hydration.d.ts +3 -6
- package/build/lib/hydration.d.ts.map +1 -0
- package/build/lib/hydration.esm.js +9 -20
- package/build/lib/hydration.esm.js.map +1 -1
- package/build/lib/hydration.js +9 -20
- package/build/lib/hydration.js.map +1 -1
- package/build/lib/hydration.mjs +4 -18
- package/build/lib/hydration.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -3
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.d.ts +3 -2
- package/build/lib/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.esm.js +52 -48
- package/build/lib/infiniteQueryBehavior.esm.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.js +52 -48
- package/build/lib/infiniteQueryBehavior.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.mjs +48 -45
- package/build/lib/infiniteQueryBehavior.mjs.map +1 -1
- package/build/lib/infiniteQueryObserver.d.ts +7 -6
- package/build/lib/infiniteQueryObserver.d.ts.map +1 -0
- package/build/lib/infiniteQueryObserver.esm.js +7 -8
- package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
- package/build/lib/infiniteQueryObserver.js +7 -8
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/infiniteQueryObserver.mjs +4 -6
- package/build/lib/infiniteQueryObserver.mjs.map +1 -1
- package/build/lib/mutation.d.ts +1 -0
- package/build/lib/mutation.d.ts.map +1 -0
- package/build/lib/mutation.esm.js +127 -102
- package/build/lib/mutation.esm.js.map +1 -1
- package/build/lib/mutation.js +127 -102
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/mutationCache.d.ts +1 -0
- package/build/lib/mutationCache.d.ts.map +1 -0
- package/build/lib/mutationCache.esm.js +34 -20
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +34 -20
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs +5 -4
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/mutationObserver.d.ts +1 -0
- package/build/lib/mutationObserver.d.ts.map +1 -0
- package/build/lib/mutationObserver.esm.js +82 -52
- package/build/lib/mutationObserver.esm.js.map +1 -1
- package/build/lib/mutationObserver.js +82 -52
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/mutationObserver.mjs +1 -1
- package/build/lib/mutationObserver.mjs.map +1 -1
- package/build/lib/notifyManager.d.ts +1 -0
- package/build/lib/notifyManager.d.ts.map +1 -0
- package/build/lib/onlineManager.d.ts +1 -0
- package/build/lib/onlineManager.d.ts.map +1 -0
- package/build/lib/onlineManager.esm.js +29 -14
- package/build/lib/onlineManager.esm.js.map +1 -1
- package/build/lib/onlineManager.js +29 -14
- package/build/lib/onlineManager.js.map +1 -1
- package/build/lib/queriesObserver.d.ts +1 -0
- package/build/lib/queriesObserver.d.ts.map +1 -0
- package/build/lib/queriesObserver.esm.js +98 -68
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js +98 -68
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/queriesObserver.mjs +7 -6
- package/build/lib/queriesObserver.mjs.map +1 -1
- package/build/lib/query.d.ts +5 -3
- package/build/lib/query.d.ts.map +1 -0
- package/build/lib/query.esm.js +211 -162
- package/build/lib/query.esm.js.map +1 -1
- package/build/lib/query.js +211 -162
- package/build/lib/query.js.map +1 -1
- package/build/lib/query.mjs +2 -2
- package/build/lib/query.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +1 -1
- package/build/lib/queryCache.d.ts.map +1 -0
- package/build/lib/queryCache.esm.js +20 -13
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +20 -13
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs +6 -5
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +1 -0
- package/build/lib/queryClient.d.ts.map +1 -0
- package/build/lib/queryClient.esm.js +113 -71
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +113 -71
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +17 -13
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/queryObserver.d.ts +3 -4
- package/build/lib/queryObserver.d.ts.map +1 -0
- package/build/lib/queryObserver.esm.js +303 -214
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +301 -212
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs +16 -28
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/lib/removable.d.ts +1 -0
- package/build/lib/removable.d.ts.map +1 -0
- package/build/lib/removable.esm.js +13 -6
- package/build/lib/removable.esm.js.map +1 -1
- package/build/lib/removable.js +13 -6
- package/build/lib/removable.js.map +1 -1
- package/build/lib/retryer.d.ts +1 -0
- package/build/lib/retryer.d.ts.map +1 -0
- package/build/lib/retryer.esm.js +15 -14
- package/build/lib/retryer.esm.js.map +1 -1
- package/build/lib/retryer.js +15 -14
- package/build/lib/retryer.js.map +1 -1
- package/build/lib/subscribable.d.ts +2 -1
- package/build/lib/subscribable.d.ts.map +1 -0
- package/build/lib/subscribable.esm.js +4 -4
- package/build/lib/subscribable.esm.js.map +1 -1
- package/build/lib/subscribable.js +4 -4
- package/build/lib/subscribable.js.map +1 -1
- package/build/lib/subscribable.mjs +4 -4
- package/build/lib/subscribable.mjs.map +1 -1
- package/build/lib/tests/focusManager.test.d.ts +1 -0
- package/build/lib/tests/focusManager.test.d.ts.map +1 -0
- package/build/lib/tests/hydration.test.d.ts +1 -0
- package/build/lib/tests/hydration.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutationCache.test.d.ts +1 -0
- package/build/lib/tests/mutationCache.test.d.ts.map +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutations.test.d.ts +1 -0
- package/build/lib/tests/mutations.test.d.ts.map +1 -0
- package/build/lib/tests/notifyManager.test.d.ts +1 -0
- package/build/lib/tests/notifyManager.test.d.ts.map +1 -0
- package/build/lib/tests/onlineManager.test.d.ts +1 -0
- package/build/lib/tests/onlineManager.test.d.ts.map +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts.map +1 -0
- package/build/lib/tests/query.test.d.ts +1 -0
- package/build/lib/tests/query.test.d.ts.map +1 -0
- package/build/lib/tests/queryCache.test.d.ts +1 -0
- package/build/lib/tests/queryCache.test.d.ts.map +1 -0
- package/build/lib/tests/queryClient.test.d.ts +1 -0
- package/build/lib/tests/queryClient.test.d.ts.map +1 -0
- package/build/lib/tests/queryObserver.test.d.ts +1 -0
- package/build/lib/tests/queryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/utils.d.ts +5 -5
- package/build/lib/tests/utils.d.ts.map +1 -0
- package/build/lib/tests/utils.test.d.ts +1 -0
- package/build/lib/tests/utils.test.d.ts.map +1 -0
- package/build/lib/types.d.ts +12 -21
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/utils.d.ts +1 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.esm.js +1 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +113 -131
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/hydration.ts +18 -37
- package/src/index.ts +2 -4
- package/src/infiniteQueryBehavior.ts +52 -60
- package/src/infiniteQueryObserver.ts +15 -10
- package/src/mutationCache.ts +4 -4
- package/src/mutationObserver.ts +1 -1
- package/src/queriesObserver.ts +11 -11
- package/src/query.ts +8 -6
- package/src/queryCache.ts +5 -8
- package/src/queryClient.ts +18 -19
- package/src/queryObserver.ts +32 -41
- package/src/subscribable.ts +5 -5
- package/src/tests/focusManager.test.tsx +12 -14
- package/src/tests/hydration.test.tsx +22 -17
- package/src/tests/infiniteQueryBehavior.test.tsx +16 -9
- package/src/tests/infiniteQueryObserver.test.tsx +62 -1
- package/src/tests/mutationCache.test.tsx +11 -10
- package/src/tests/mutationObserver.test.tsx +3 -2
- package/src/tests/mutations.test.tsx +11 -10
- package/src/tests/notifyManager.test.tsx +7 -6
- package/src/tests/onlineManager.test.tsx +12 -17
- package/src/tests/queriesObserver.test.tsx +18 -17
- package/src/tests/query.test.tsx +19 -18
- package/src/tests/queryCache.test.tsx +12 -28
- package/src/tests/queryClient.test.tsx +82 -49
- package/src/tests/queryObserver.test.tsx +131 -9
- package/src/tests/utils.test.tsx +2 -1
- package/src/tests/utils.ts +5 -4
- package/src/types.ts +22 -20
package/src/types.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { RetryValue, RetryDelayValue } from './retryer'
|
|
|
6
6
|
import type { QueryFilters, QueryTypeFilter } from './utils'
|
|
7
7
|
import type { QueryCache } from './queryCache'
|
|
8
8
|
import type { MutationCache } from './mutationCache'
|
|
9
|
+
import type { FetchDirection } from './query'
|
|
9
10
|
|
|
10
11
|
export interface Register {
|
|
11
12
|
// defaultError: Error
|
|
@@ -40,6 +41,7 @@ export type QueryFunctionContext<
|
|
|
40
41
|
queryKey: TQueryKey
|
|
41
42
|
signal: AbortSignal
|
|
42
43
|
pageParam: TPageParam
|
|
44
|
+
direction: FetchDirection
|
|
43
45
|
meta: QueryMeta | undefined
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -47,8 +49,14 @@ export type InitialDataFunction<T> = () => T | undefined
|
|
|
47
49
|
|
|
48
50
|
type NonFunctionGuard<T> = T extends Function ? never : T
|
|
49
51
|
|
|
50
|
-
export type PlaceholderDataFunction<
|
|
52
|
+
export type PlaceholderDataFunction<
|
|
53
|
+
TQueryFnData = unknown,
|
|
54
|
+
TError = DefaultError,
|
|
55
|
+
TQueryData = TQueryFnData,
|
|
56
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
57
|
+
> = (
|
|
51
58
|
previousData: TQueryData | undefined,
|
|
59
|
+
previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined,
|
|
52
60
|
) => TQueryData | undefined
|
|
53
61
|
|
|
54
62
|
export type QueriesPlaceholderDataFunction<TQueryData> = () =>
|
|
@@ -62,11 +70,15 @@ export type QueryKeyHashFunction<TQueryKey extends QueryKey> = (
|
|
|
62
70
|
export type GetPreviousPageParamFunction<TPageParam, TQueryFnData = unknown> = (
|
|
63
71
|
firstPage: TQueryFnData,
|
|
64
72
|
allPages: TQueryFnData[],
|
|
73
|
+
firstPageParam: TPageParam,
|
|
74
|
+
allPageParams: TPageParam[],
|
|
65
75
|
) => TPageParam | undefined
|
|
66
76
|
|
|
67
77
|
export type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (
|
|
68
78
|
lastPage: TQueryFnData,
|
|
69
79
|
allPages: TQueryFnData[],
|
|
80
|
+
lastPageParam: TPageParam,
|
|
81
|
+
allPageParams: TPageParam[],
|
|
70
82
|
) => TPageParam | undefined
|
|
71
83
|
|
|
72
84
|
export interface InfiniteData<TData> {
|
|
@@ -148,7 +160,7 @@ export interface InfiniteQueryPageParamsOptions<
|
|
|
148
160
|
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>
|
|
149
161
|
}
|
|
150
162
|
|
|
151
|
-
export type
|
|
163
|
+
export type ThrowOnError<
|
|
152
164
|
TQueryFnData,
|
|
153
165
|
TError,
|
|
154
166
|
TQueryData,
|
|
@@ -196,7 +208,7 @@ export interface QueryObserverOptions<
|
|
|
196
208
|
| ((
|
|
197
209
|
data: TData | undefined,
|
|
198
210
|
query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,
|
|
199
|
-
) => number | false)
|
|
211
|
+
) => number | false | undefined)
|
|
200
212
|
/**
|
|
201
213
|
* If set to `true`, the query will continue to refetch while their tab/window is in the background.
|
|
202
214
|
* Defaults to `false`.
|
|
@@ -253,18 +265,6 @@ export interface QueryObserverOptions<
|
|
|
253
265
|
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
|
|
254
266
|
*/
|
|
255
267
|
notifyOnChangeProps?: Array<keyof InfiniteQueryObserverResult> | 'all'
|
|
256
|
-
/**
|
|
257
|
-
* This callback will fire any time the query successfully fetches new data.
|
|
258
|
-
*/
|
|
259
|
-
onSuccess?: (data: TData) => void
|
|
260
|
-
/**
|
|
261
|
-
* This callback will fire if the query encounters an error and will be passed the error.
|
|
262
|
-
*/
|
|
263
|
-
onError?: (err: TError) => void
|
|
264
|
-
/**
|
|
265
|
-
* This callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
|
|
266
|
-
*/
|
|
267
|
-
onSettled?: (data: TData | undefined, error: TError | null) => void
|
|
268
268
|
/**
|
|
269
269
|
* Whether errors should be thrown instead of setting the `error` property.
|
|
270
270
|
* If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.
|
|
@@ -272,7 +272,7 @@ export interface QueryObserverOptions<
|
|
|
272
272
|
* If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).
|
|
273
273
|
* Defaults to `false`.
|
|
274
274
|
*/
|
|
275
|
-
|
|
275
|
+
throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>
|
|
276
276
|
/**
|
|
277
277
|
* This option can be used to transform or select a part of the data returned by the query function.
|
|
278
278
|
*/
|
|
@@ -303,7 +303,7 @@ export type DefaultedQueryObserverOptions<
|
|
|
303
303
|
TQueryKey extends QueryKey = QueryKey,
|
|
304
304
|
> = WithRequired<
|
|
305
305
|
QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,
|
|
306
|
-
'
|
|
306
|
+
'throwOnError' | 'refetchOnReconnect'
|
|
307
307
|
>
|
|
308
308
|
|
|
309
309
|
export interface InfiniteQueryObserverOptions<
|
|
@@ -329,15 +329,17 @@ export type DefaultedInfiniteQueryObserverOptions<
|
|
|
329
329
|
TData = TQueryFnData,
|
|
330
330
|
TQueryData = TQueryFnData,
|
|
331
331
|
TQueryKey extends QueryKey = QueryKey,
|
|
332
|
+
TPageParam = unknown,
|
|
332
333
|
> = WithRequired<
|
|
333
334
|
InfiniteQueryObserverOptions<
|
|
334
335
|
TQueryFnData,
|
|
335
336
|
TError,
|
|
336
337
|
TData,
|
|
337
338
|
TQueryData,
|
|
338
|
-
TQueryKey
|
|
339
|
+
TQueryKey,
|
|
340
|
+
TPageParam
|
|
339
341
|
>,
|
|
340
|
-
'
|
|
342
|
+
'throwOnError' | 'refetchOnReconnect'
|
|
341
343
|
>
|
|
342
344
|
|
|
343
345
|
export interface FetchQueryOptions<
|
|
@@ -640,7 +642,7 @@ export interface MutationObserverOptions<
|
|
|
640
642
|
TVariables = void,
|
|
641
643
|
TContext = unknown,
|
|
642
644
|
> extends MutationOptions<TData, TError, TVariables, TContext> {
|
|
643
|
-
|
|
645
|
+
throwOnError?: boolean | ((error: TError) => boolean)
|
|
644
646
|
}
|
|
645
647
|
|
|
646
648
|
export interface MutateOptions<
|