@tanstack/query-core 5.101.4 → 5.102.1
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/legacy/classPrivateFieldSet2-Bo0ZyOIv.cjs +56 -0
- package/build/legacy/classPrivateFieldSet2-CV7wyte-.js +27 -0
- package/build/legacy/classPrivateMethodInitSpec-CBwa_Y7C.js +7 -0
- package/build/legacy/classPrivateMethodInitSpec-DVhcLejn.cjs +12 -0
- package/build/legacy/environmentManager.cjs +25 -46
- package/build/legacy/environmentManager.cjs.map +1 -1
- package/build/legacy/environmentManager.d.cts +18 -2
- package/build/legacy/environmentManager.d.cts.map +1 -0
- package/build/legacy/environmentManager.d.ts +18 -2
- package/build/legacy/environmentManager.d.ts.map +1 -0
- package/build/legacy/environmentManager.js +23 -22
- package/build/legacy/environmentManager.js.map +1 -1
- package/build/legacy/focusManager.cjs +63 -104
- package/build/legacy/focusManager.cjs.map +1 -1
- package/build/legacy/focusManager.d.cts +18 -2
- package/build/legacy/focusManager.d.cts.map +1 -0
- package/build/legacy/focusManager.d.ts +18 -2
- package/build/legacy/focusManager.d.ts.map +1 -0
- package/build/legacy/focusManager.js +60 -76
- package/build/legacy/focusManager.js.map +1 -1
- package/build/legacy/hydration-BhSbkfZj.d.cts +1374 -0
- package/build/legacy/hydration-BhSbkfZj.d.cts.map +1 -0
- package/build/legacy/hydration-Hebl6yHM.d.ts +1374 -0
- package/build/legacy/hydration-Hebl6yHM.d.ts.map +1 -0
- package/build/legacy/hydration.cjs +111 -194
- package/build/legacy/hydration.cjs.map +1 -1
- package/build/legacy/hydration.d.cts +2 -7
- package/build/legacy/hydration.d.ts +2 -7
- package/build/legacy/hydration.js +105 -167
- package/build/legacy/hydration.js.map +1 -1
- package/build/legacy/index.cjs +59 -111
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +10 -141
- package/build/legacy/index.d.ts +10 -141
- package/build/legacy/index.js +16 -66
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/infiniteQueryBehavior.cjs +92 -135
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.d.ts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.js +89 -115
- package/build/legacy/infiniteQueryBehavior.js.map +1 -1
- package/build/legacy/infiniteQueryObserver.cjs +59 -88
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +20 -1
- package/build/legacy/infiniteQueryObserver.d.cts.map +1 -0
- package/build/legacy/infiniteQueryObserver.d.ts +20 -1
- package/build/legacy/infiniteQueryObserver.d.ts.map +1 -0
- package/build/legacy/infiniteQueryObserver.js +57 -64
- package/build/legacy/infiniteQueryObserver.js.map +1 -1
- package/build/legacy/mutation.cjs +236 -329
- package/build/legacy/mutation.cjs.map +1 -1
- package/build/legacy/mutation.d.cts +2 -4
- package/build/legacy/mutation.d.ts +2 -4
- package/build/legacy/mutation.js +231 -299
- package/build/legacy/mutation.js.map +1 -1
- package/build/legacy/mutationCache.cjs +121 -166
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +2 -2
- package/build/legacy/mutationCache.d.ts +2 -2
- package/build/legacy/mutationCache.js +117 -130
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationObserver.cjs +134 -187
- package/build/legacy/mutationObserver.cjs.map +1 -1
- package/build/legacy/mutationObserver.d.cts +2 -1
- package/build/legacy/mutationObserver.d.ts +2 -1
- package/build/legacy/mutationObserver.js +132 -160
- package/build/legacy/mutationObserver.js.map +1 -1
- package/build/legacy/notifyManager.cjs +76 -110
- package/build/legacy/notifyManager.cjs.map +1 -1
- package/build/legacy/notifyManager.d.cts +48 -3
- package/build/legacy/notifyManager.d.cts.map +1 -0
- package/build/legacy/notifyManager.d.ts +48 -3
- package/build/legacy/notifyManager.d.ts.map +1 -0
- package/build/legacy/notifyManager.js +73 -84
- package/build/legacy/notifyManager.js.map +1 -1
- package/build/legacy/onlineManager.cjs +57 -93
- package/build/legacy/onlineManager.cjs.map +1 -1
- package/build/legacy/onlineManager.d.cts +17 -2
- package/build/legacy/onlineManager.d.cts.map +1 -0
- package/build/legacy/onlineManager.d.ts +17 -2
- package/build/legacy/onlineManager.d.ts.map +1 -0
- package/build/legacy/onlineManager.js +54 -65
- package/build/legacy/onlineManager.js.map +1 -1
- package/build/legacy/queriesObserver.cjs +203 -262
- package/build/legacy/queriesObserver.cjs.map +1 -1
- package/build/legacy/queriesObserver.d.cts +23 -2
- package/build/legacy/queriesObserver.d.cts.map +1 -0
- package/build/legacy/queriesObserver.d.ts +23 -2
- package/build/legacy/queriesObserver.d.ts.map +1 -0
- package/build/legacy/queriesObserver.js +199 -233
- package/build/legacy/queriesObserver.js.map +1 -1
- package/build/legacy/query.cjs +409 -491
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +2 -9
- package/build/legacy/query.d.ts +2 -9
- package/build/legacy/query.js +402 -467
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.cjs +99 -128
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +2 -3
- package/build/legacy/queryCache.d.ts +2 -3
- package/build/legacy/queryCache.js +96 -100
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +295 -345
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +2 -1
- package/build/legacy/queryClient.d.ts +2 -1
- package/build/legacy/queryClient.js +292 -318
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.cjs +350 -502
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +2 -1
- package/build/legacy/queryObserver.d.ts +2 -1
- package/build/legacy/queryObserver.js +345 -480
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/removable-DeMjhW5M.d.cts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/legacy/removable-DeMjhW5M.d.ts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/legacy/removable.cjs +31 -67
- package/build/legacy/removable.cjs.map +1 -1
- package/build/legacy/removable.d.cts +2 -1
- package/build/legacy/removable.d.ts +2 -1
- package/build/legacy/removable.js +28 -39
- package/build/legacy/removable.js.map +1 -1
- package/build/legacy/retryer.cjs +127 -155
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +2 -7
- package/build/legacy/retryer.d.ts +2 -7
- package/build/legacy/retryer.js +121 -127
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.cjs +49 -78
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +33 -1
- package/build/legacy/streamedQuery.d.cts.map +1 -0
- package/build/legacy/streamedQuery.d.ts +33 -1
- package/build/legacy/streamedQuery.d.ts.map +1 -0
- package/build/legacy/streamedQuery.js +47 -54
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/subscribable-CbifVTKz.d.cts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/legacy/subscribable.cjs +22 -48
- package/build/legacy/subscribable.cjs.map +1 -1
- package/build/legacy/subscribable.d.cts +2 -1
- package/build/legacy/subscribable.d.ts +2 -1
- package/build/legacy/subscribable.js +21 -25
- package/build/legacy/subscribable.js.map +1 -1
- package/build/legacy/timeoutManager.cjs +64 -105
- package/build/legacy/timeoutManager.cjs.map +1 -1
- package/build/legacy/timeoutManager.d.cts +60 -7
- package/build/legacy/timeoutManager.d.cts.map +1 -0
- package/build/legacy/timeoutManager.d.ts +60 -7
- package/build/legacy/timeoutManager.d.ts.map +1 -0
- package/build/legacy/timeoutManager.js +60 -76
- package/build/legacy/timeoutManager.js.map +1 -1
- package/build/legacy/types.cjs +10 -35
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -94
- package/build/legacy/types.d.ts +2 -94
- package/build/legacy/types.js +7 -10
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.cjs +175 -300
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +2 -30
- package/build/legacy/utils.d.ts +2 -30
- package/build/legacy/utils.js +149 -252
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/environmentManager.cjs +25 -46
- package/build/modern/environmentManager.cjs.map +1 -1
- package/build/modern/environmentManager.d.cts +18 -2
- package/build/modern/environmentManager.d.cts.map +1 -0
- package/build/modern/environmentManager.d.ts +18 -2
- package/build/modern/environmentManager.d.ts.map +1 -0
- package/build/modern/environmentManager.js +23 -20
- package/build/modern/environmentManager.js.map +1 -1
- package/build/modern/focusManager.cjs +56 -90
- package/build/modern/focusManager.cjs.map +1 -1
- package/build/modern/focusManager.d.cts +18 -2
- package/build/modern/focusManager.d.cts.map +1 -0
- package/build/modern/focusManager.d.ts +18 -2
- package/build/modern/focusManager.d.ts.map +1 -0
- package/build/modern/focusManager.js +53 -63
- package/build/modern/focusManager.js.map +1 -1
- package/build/modern/hydration-BhSbkfZj.d.cts +1374 -0
- package/build/modern/hydration-BhSbkfZj.d.cts.map +1 -0
- package/build/modern/hydration-Hebl6yHM.d.ts +1374 -0
- package/build/modern/hydration-Hebl6yHM.d.ts.map +1 -0
- package/build/modern/hydration.cjs +102 -189
- package/build/modern/hydration.cjs.map +1 -1
- package/build/modern/hydration.d.cts +2 -7
- package/build/modern/hydration.d.ts +2 -7
- package/build/modern/hydration.js +96 -160
- package/build/modern/hydration.js.map +1 -1
- package/build/modern/index.cjs +59 -111
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +10 -141
- package/build/modern/index.d.ts +10 -141
- package/build/modern/index.js +16 -64
- package/build/modern/index.js.map +1 -1
- package/build/modern/infiniteQueryBehavior.cjs +89 -131
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +14 -3
- package/build/modern/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/modern/infiniteQueryBehavior.d.ts +14 -3
- package/build/modern/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/modern/infiniteQueryBehavior.js +86 -109
- package/build/modern/infiniteQueryBehavior.js.map +1 -1
- package/build/modern/infiniteQueryObserver.cjs +58 -87
- package/build/modern/infiniteQueryObserver.cjs.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +20 -1
- package/build/modern/infiniteQueryObserver.d.cts.map +1 -0
- package/build/modern/infiniteQueryObserver.d.ts +20 -1
- package/build/modern/infiniteQueryObserver.d.ts.map +1 -0
- package/build/modern/infiniteQueryObserver.js +56 -61
- package/build/modern/infiniteQueryObserver.js.map +1 -1
- package/build/modern/mutation.cjs +221 -303
- package/build/modern/mutation.cjs.map +1 -1
- package/build/modern/mutation.d.cts +2 -4
- package/build/modern/mutation.d.ts +2 -4
- package/build/modern/mutation.js +216 -274
- package/build/modern/mutation.js.map +1 -1
- package/build/modern/mutationCache.cjs +111 -145
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +2 -2
- package/build/modern/mutationCache.d.ts +2 -2
- package/build/modern/mutationCache.js +107 -117
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationObserver.cjs +115 -162
- package/build/modern/mutationObserver.cjs.map +1 -1
- package/build/modern/mutationObserver.d.cts +2 -1
- package/build/modern/mutationObserver.d.ts +2 -1
- package/build/modern/mutationObserver.js +113 -136
- package/build/modern/mutationObserver.js.map +1 -1
- package/build/modern/notifyManager.cjs +76 -110
- package/build/modern/notifyManager.cjs.map +1 -1
- package/build/modern/notifyManager.d.cts +48 -3
- package/build/modern/notifyManager.d.cts.map +1 -0
- package/build/modern/notifyManager.d.ts +48 -3
- package/build/modern/notifyManager.d.ts.map +1 -0
- package/build/modern/notifyManager.js +73 -82
- package/build/modern/notifyManager.js.map +1 -1
- package/build/modern/onlineManager.cjs +51 -80
- package/build/modern/onlineManager.cjs.map +1 -1
- package/build/modern/onlineManager.d.cts +17 -2
- package/build/modern/onlineManager.d.cts.map +1 -0
- package/build/modern/onlineManager.d.ts +17 -2
- package/build/modern/onlineManager.d.ts.map +1 -0
- package/build/modern/onlineManager.js +48 -53
- package/build/modern/onlineManager.js.map +1 -1
- package/build/modern/queriesObserver.cjs +185 -237
- package/build/modern/queriesObserver.cjs.map +1 -1
- package/build/modern/queriesObserver.d.cts +23 -2
- package/build/modern/queriesObserver.d.cts.map +1 -0
- package/build/modern/queriesObserver.d.ts +23 -2
- package/build/modern/queriesObserver.d.ts.map +1 -0
- package/build/modern/queriesObserver.js +181 -209
- package/build/modern/queriesObserver.js.map +1 -1
- package/build/modern/query.cjs +384 -464
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +2 -9
- package/build/modern/query.d.ts +2 -9
- package/build/modern/query.js +377 -441
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.cjs +97 -119
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +2 -3
- package/build/modern/queryCache.d.ts +2 -3
- package/build/modern/queryCache.js +94 -92
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +281 -318
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +2 -1
- package/build/modern/queryClient.d.ts +2 -1
- package/build/modern/queryClient.js +278 -299
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.cjs +329 -475
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +2 -1
- package/build/modern/queryObserver.d.ts +2 -1
- package/build/modern/queryObserver.js +324 -454
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/removable-DeMjhW5M.d.cts +13 -0
- package/build/modern/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/modern/removable-DeMjhW5M.d.ts +13 -0
- package/build/modern/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/modern/removable.cjs +27 -56
- package/build/modern/removable.cjs.map +1 -1
- package/build/modern/removable.d.cts +2 -1
- package/build/modern/removable.d.ts +2 -1
- package/build/modern/removable.js +24 -29
- package/build/modern/removable.js.map +1 -1
- package/build/modern/retryer.cjs +121 -151
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +2 -7
- package/build/modern/retryer.d.ts +2 -7
- package/build/modern/retryer.js +115 -121
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.cjs +49 -78
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +33 -1
- package/build/modern/streamedQuery.d.cts.map +1 -0
- package/build/modern/streamedQuery.d.ts +33 -1
- package/build/modern/streamedQuery.d.ts.map +1 -0
- package/build/modern/streamedQuery.js +47 -52
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/subscribable-CbifVTKz.d.cts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/modern/subscribable-CbifVTKz.d.ts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/modern/subscribable.cjs +22 -48
- package/build/modern/subscribable.cjs.map +1 -1
- package/build/modern/subscribable.d.cts +2 -1
- package/build/modern/subscribable.d.ts +2 -1
- package/build/modern/subscribable.js +21 -23
- package/build/modern/subscribable.js.map +1 -1
- package/build/modern/timeoutManager.cjs +59 -93
- package/build/modern/timeoutManager.cjs.map +1 -1
- package/build/modern/timeoutManager.d.cts +60 -7
- package/build/modern/timeoutManager.d.cts.map +1 -0
- package/build/modern/timeoutManager.d.ts +60 -7
- package/build/modern/timeoutManager.d.ts.map +1 -0
- package/build/modern/timeoutManager.js +55 -65
- package/build/modern/timeoutManager.js.map +1 -1
- package/build/modern/types.cjs +10 -35
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -94
- package/build/modern/types.d.ts +2 -94
- package/build/modern/types.js +8 -9
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.cjs +175 -300
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +2 -30
- package/build/modern/utils.d.ts +2 -30
- package/build/modern/utils.js +149 -250
- package/build/modern/utils.js.map +1 -1
- package/package.json +3 -5
- package/src/hydration.ts +65 -56
- package/src/index.ts +1 -0
- package/src/mutation.ts +14 -6
- package/src/mutationObserver.ts +8 -0
- package/src/queriesObserver.ts +14 -8
- package/src/query.ts +14 -6
- package/src/queryClient.ts +90 -2
- package/src/queryObserver.ts +41 -64
- package/src/retryer.ts +20 -12
- package/src/types.ts +70 -58
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -2188
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -2188
- package/build/legacy/chunk-PXG64RU4.js +0 -25
- package/build/legacy/chunk-PXG64RU4.js.map +0 -1
- package/build/legacy/thenable.cjs +0 -76
- package/build/legacy/thenable.cjs.map +0 -1
- package/build/legacy/thenable.d.cts +0 -6
- package/build/legacy/thenable.d.ts +0 -6
- package/build/legacy/thenable.js +0 -52
- package/build/legacy/thenable.js.map +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -2188
- package/build/modern/_tsup-dts-rollup.d.ts +0 -2188
- package/build/modern/thenable.cjs +0 -75
- package/build/modern/thenable.cjs.map +0 -1
- package/build/modern/thenable.d.cts +0 -6
- package/build/modern/thenable.d.ts +0 -6
- package/build/modern/thenable.js +0 -49
- package/build/modern/thenable.js.map +0 -1
- package/src/thenable.ts +0 -111
|
@@ -0,0 +1,1374 @@
|
|
|
1
|
+
import { t as Subscribable } from "./subscribable-CbifVTKz.js";
|
|
2
|
+
import { t as Removable } from "./removable-DeMjhW5M.js";
|
|
3
|
+
//#region src/queryObserver.d.ts
|
|
4
|
+
type QueryObserverListener<TData, TError> = (result: QueryObserverResult<TData, TError>) => void;
|
|
5
|
+
interface ObserverFetchOptions extends FetchOptions {
|
|
6
|
+
throwOnError?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare class QueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Subscribable<QueryObserverListener<TData, TError>> {
|
|
9
|
+
#private;
|
|
10
|
+
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
11
|
+
constructor(client: QueryClient, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>);
|
|
12
|
+
protected bindMethods(): void;
|
|
13
|
+
protected onSubscribe(): void;
|
|
14
|
+
protected onUnsubscribe(): void;
|
|
15
|
+
shouldFetchOnReconnect(): boolean;
|
|
16
|
+
shouldFetchOnWindowFocus(): boolean;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
setOptions(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): void;
|
|
19
|
+
getOptimisticResult(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
20
|
+
getCurrentResult(): QueryObserverResult<TData, TError>;
|
|
21
|
+
trackResult(result: QueryObserverResult<TData, TError>, onPropTracked?: (key: keyof QueryObserverResult) => void): QueryObserverResult<TData, TError>;
|
|
22
|
+
trackProp(key: keyof QueryObserverResult): void;
|
|
23
|
+
getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
24
|
+
refetch({ ...options }?: RefetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
25
|
+
fetchOptimistic(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): Promise<QueryObserverResult<TData, TError>>;
|
|
26
|
+
protected fetch(fetchOptions: ObserverFetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
27
|
+
protected createResult(query: Query<TQueryFnData, TError, TQueryData, TQueryKey>, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
28
|
+
updateResult(): void;
|
|
29
|
+
onQueryUpdate(): void;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/query.d.ts
|
|
33
|
+
interface QueryConfig<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
|
|
34
|
+
client: QueryClient;
|
|
35
|
+
queryKey: TQueryKey;
|
|
36
|
+
queryHash: string;
|
|
37
|
+
options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
38
|
+
defaultOptions?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
39
|
+
state?: QueryState<TData, TError>;
|
|
40
|
+
}
|
|
41
|
+
interface QueryState<TData = unknown, TError = DefaultError> {
|
|
42
|
+
data: TData | undefined;
|
|
43
|
+
dataUpdateCount: number;
|
|
44
|
+
dataUpdatedAt: number;
|
|
45
|
+
error: TError | null;
|
|
46
|
+
errorUpdateCount: number;
|
|
47
|
+
errorUpdatedAt: number;
|
|
48
|
+
fetchFailureCount: number;
|
|
49
|
+
fetchFailureReason: TError | null;
|
|
50
|
+
fetchMeta: FetchMeta | null;
|
|
51
|
+
isInvalidated: boolean;
|
|
52
|
+
status: QueryStatus;
|
|
53
|
+
fetchStatus: FetchStatus;
|
|
54
|
+
}
|
|
55
|
+
interface FetchContext<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
|
|
56
|
+
fetchFn: () => unknown | Promise<unknown>;
|
|
57
|
+
fetchOptions?: FetchOptions;
|
|
58
|
+
signal: AbortSignal;
|
|
59
|
+
options: QueryOptions<TQueryFnData, TError, TData, any>;
|
|
60
|
+
client: QueryClient;
|
|
61
|
+
queryKey: TQueryKey;
|
|
62
|
+
state: QueryState<TData, TError>;
|
|
63
|
+
}
|
|
64
|
+
interface QueryBehavior<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> {
|
|
65
|
+
onFetch: (context: FetchContext<TQueryFnData, TError, TData, TQueryKey>, query: Query) => void;
|
|
66
|
+
}
|
|
67
|
+
type FetchDirection = 'forward' | 'backward';
|
|
68
|
+
interface FetchMeta {
|
|
69
|
+
fetchMore?: {
|
|
70
|
+
direction: FetchDirection;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface FetchOptions<TData = unknown> {
|
|
74
|
+
cancelRefetch?: boolean;
|
|
75
|
+
meta?: FetchMeta;
|
|
76
|
+
initialPromise?: Promise<TData>;
|
|
77
|
+
}
|
|
78
|
+
interface FailedAction$1<TError> {
|
|
79
|
+
type: 'failed';
|
|
80
|
+
failureCount: number;
|
|
81
|
+
error: TError;
|
|
82
|
+
}
|
|
83
|
+
interface FetchAction {
|
|
84
|
+
type: 'fetch';
|
|
85
|
+
meta?: FetchMeta;
|
|
86
|
+
}
|
|
87
|
+
interface SuccessAction$1<TData> {
|
|
88
|
+
data: TData | undefined;
|
|
89
|
+
type: 'success';
|
|
90
|
+
dataUpdatedAt?: number;
|
|
91
|
+
manual?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface ErrorAction$1<TError> {
|
|
94
|
+
type: 'error';
|
|
95
|
+
error: TError;
|
|
96
|
+
}
|
|
97
|
+
interface InvalidateAction {
|
|
98
|
+
type: 'invalidate';
|
|
99
|
+
}
|
|
100
|
+
interface PauseAction$1 {
|
|
101
|
+
type: 'pause';
|
|
102
|
+
}
|
|
103
|
+
interface ContinueAction$1 {
|
|
104
|
+
type: 'continue';
|
|
105
|
+
}
|
|
106
|
+
interface SetStateAction<TData, TError> {
|
|
107
|
+
type: 'setState';
|
|
108
|
+
state: Partial<QueryState<TData, TError>>;
|
|
109
|
+
}
|
|
110
|
+
type Action$1<TData, TError> = ContinueAction$1 | ErrorAction$1<TError> | FailedAction$1<TError> | FetchAction | InvalidateAction | PauseAction$1 | SetStateAction<TData, TError> | SuccessAction$1<TData>;
|
|
111
|
+
declare class Query<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Removable {
|
|
112
|
+
#private;
|
|
113
|
+
queryKey: TQueryKey;
|
|
114
|
+
queryHash: string;
|
|
115
|
+
options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
116
|
+
state: QueryState<TData, TError>;
|
|
117
|
+
observers: Array<QueryObserver<any, any, any, any, any>>;
|
|
118
|
+
constructor(config: QueryConfig<TQueryFnData, TError, TData, TQueryKey>);
|
|
119
|
+
get meta(): QueryMeta | undefined;
|
|
120
|
+
get queryType(): "infinite" | undefined;
|
|
121
|
+
get promise(): Promise<TData> | undefined;
|
|
122
|
+
setOptions(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>): void;
|
|
123
|
+
protected optionalRemove(): void;
|
|
124
|
+
setData(newData: TData, options?: SetDataOptions & {
|
|
125
|
+
manual: boolean;
|
|
126
|
+
}): TData;
|
|
127
|
+
setState(state: Partial<QueryState<TData, TError>>): void;
|
|
128
|
+
cancel(options?: CancelOptions): Promise<void>;
|
|
129
|
+
destroy(): void;
|
|
130
|
+
get resetState(): QueryState<TData, TError>;
|
|
131
|
+
reset(): void;
|
|
132
|
+
isActive(): boolean;
|
|
133
|
+
isDisabled(): boolean;
|
|
134
|
+
isFetched(): boolean;
|
|
135
|
+
isStatic(): boolean;
|
|
136
|
+
isStale(): boolean;
|
|
137
|
+
isStaleByTime(staleTime?: StaleTime): boolean;
|
|
138
|
+
onFocus(): void;
|
|
139
|
+
onOnline(): void;
|
|
140
|
+
addObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
141
|
+
removeObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
142
|
+
getObserversCount(): number;
|
|
143
|
+
invalidate(): void;
|
|
144
|
+
fetch(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, fetchOptions?: FetchOptions<TQueryFnData>): Promise<TData>;
|
|
145
|
+
}
|
|
146
|
+
declare function fetchState<TQueryFnData, TError, TData, TQueryKey extends QueryKey>(data: TData | undefined, options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>): {
|
|
147
|
+
readonly error?: null | undefined;
|
|
148
|
+
readonly status?: "pending" | undefined;
|
|
149
|
+
readonly fetchFailureCount: 0;
|
|
150
|
+
readonly fetchFailureReason: null;
|
|
151
|
+
readonly fetchStatus: "fetching" | "paused";
|
|
152
|
+
};
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/mutationObserver.d.ts
|
|
155
|
+
type MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>) => void;
|
|
156
|
+
declare class MutationObserver<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends Subscribable<MutationObserverListener<TData, TError, TVariables, TOnMutateResult>> {
|
|
157
|
+
#private;
|
|
158
|
+
options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
159
|
+
constructor(client: QueryClient, options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>);
|
|
160
|
+
protected bindMethods(): void;
|
|
161
|
+
setOptions(options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>): void;
|
|
162
|
+
protected onSubscribe(): void;
|
|
163
|
+
protected onUnsubscribe(): void;
|
|
164
|
+
onMutationUpdate(action: Action<TData, TError, TVariables, TOnMutateResult>): void;
|
|
165
|
+
getCurrentResult(): MutationObserverResult<TData, TError, TVariables, TOnMutateResult>;
|
|
166
|
+
reset(): void;
|
|
167
|
+
mutate(variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>): Promise<TData>;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/mutationCache.d.ts
|
|
171
|
+
interface MutationCacheConfig {
|
|
172
|
+
onError?: (error: DefaultError, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
173
|
+
onSuccess?: (data: unknown, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
174
|
+
onMutate?: (variables: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
175
|
+
onSettled?: (data: unknown | undefined, error: DefaultError | null, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
176
|
+
}
|
|
177
|
+
interface NotifyEventMutationAdded extends NotifyEvent {
|
|
178
|
+
type: 'added';
|
|
179
|
+
mutation: Mutation<any, any, any, any>;
|
|
180
|
+
}
|
|
181
|
+
interface NotifyEventMutationRemoved extends NotifyEvent {
|
|
182
|
+
type: 'removed';
|
|
183
|
+
mutation: Mutation<any, any, any, any>;
|
|
184
|
+
}
|
|
185
|
+
interface NotifyEventMutationObserverAdded extends NotifyEvent {
|
|
186
|
+
type: 'observerAdded';
|
|
187
|
+
mutation: Mutation<any, any, any, any>;
|
|
188
|
+
observer: MutationObserver<any, any, any>;
|
|
189
|
+
}
|
|
190
|
+
interface NotifyEventMutationObserverRemoved extends NotifyEvent {
|
|
191
|
+
type: 'observerRemoved';
|
|
192
|
+
mutation: Mutation<any, any, any, any>;
|
|
193
|
+
observer: MutationObserver<any, any, any>;
|
|
194
|
+
}
|
|
195
|
+
interface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {
|
|
196
|
+
type: 'observerOptionsUpdated';
|
|
197
|
+
mutation?: Mutation<any, any, any, any>;
|
|
198
|
+
observer: MutationObserver<any, any, any, any>;
|
|
199
|
+
}
|
|
200
|
+
interface NotifyEventMutationUpdated extends NotifyEvent {
|
|
201
|
+
type: 'updated';
|
|
202
|
+
mutation: Mutation<any, any, any, any>;
|
|
203
|
+
action: Action<any, any, any, any>;
|
|
204
|
+
}
|
|
205
|
+
type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated;
|
|
206
|
+
type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
|
|
207
|
+
declare class MutationCache extends Subscribable<MutationCacheListener> {
|
|
208
|
+
#private;
|
|
209
|
+
config: MutationCacheConfig;
|
|
210
|
+
constructor(config?: MutationCacheConfig);
|
|
211
|
+
build<TData, TError, TVariables, TOnMutateResult>(client: QueryClient, options: MutationOptions<TData, TError, TVariables, TOnMutateResult>, state?: MutationState<TData, TError, TVariables, TOnMutateResult>): Mutation<TData, TError, TVariables, TOnMutateResult>;
|
|
212
|
+
add(mutation: Mutation<any, any, any, any>): void;
|
|
213
|
+
remove(mutation: Mutation<any, any, any, any>): void;
|
|
214
|
+
canRun(mutation: Mutation<any, any, any, any>): boolean;
|
|
215
|
+
runNext(mutation: Mutation<any, any, any, any>): Promise<unknown>;
|
|
216
|
+
clear(): void;
|
|
217
|
+
getAll(): Array<Mutation>;
|
|
218
|
+
find<TData = unknown, TError = DefaultError, TVariables = any, TOnMutateResult = unknown>(filters: MutationFilters): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined;
|
|
219
|
+
findAll(filters?: MutationFilters): Array<Mutation>;
|
|
220
|
+
notify(event: MutationCacheNotifyEvent): void;
|
|
221
|
+
resumePausedMutations(): Promise<unknown>;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/mutation.d.ts
|
|
225
|
+
interface MutationConfig<TData, TError, TVariables, TOnMutateResult> {
|
|
226
|
+
client: QueryClient;
|
|
227
|
+
mutationId: number;
|
|
228
|
+
mutationCache: MutationCache;
|
|
229
|
+
options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
230
|
+
state?: MutationState<TData, TError, TVariables, TOnMutateResult>;
|
|
231
|
+
}
|
|
232
|
+
interface MutationState<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
|
|
233
|
+
context: TOnMutateResult | undefined;
|
|
234
|
+
data: TData | undefined;
|
|
235
|
+
error: TError | null;
|
|
236
|
+
failureCount: number;
|
|
237
|
+
failureReason: TError | null;
|
|
238
|
+
isPaused: boolean;
|
|
239
|
+
status: MutationStatus;
|
|
240
|
+
variables: TVariables | undefined;
|
|
241
|
+
submittedAt: number;
|
|
242
|
+
}
|
|
243
|
+
interface FailedAction<TError> {
|
|
244
|
+
type: 'failed';
|
|
245
|
+
failureCount: number;
|
|
246
|
+
error: TError | null;
|
|
247
|
+
}
|
|
248
|
+
interface PendingAction<TVariables, TOnMutateResult> {
|
|
249
|
+
type: 'pending';
|
|
250
|
+
isPaused: boolean;
|
|
251
|
+
variables?: TVariables;
|
|
252
|
+
context?: TOnMutateResult;
|
|
253
|
+
}
|
|
254
|
+
interface SuccessAction<TData> {
|
|
255
|
+
type: 'success';
|
|
256
|
+
data: TData;
|
|
257
|
+
}
|
|
258
|
+
interface ErrorAction<TError> {
|
|
259
|
+
type: 'error';
|
|
260
|
+
error: TError;
|
|
261
|
+
}
|
|
262
|
+
interface PauseAction {
|
|
263
|
+
type: 'pause';
|
|
264
|
+
}
|
|
265
|
+
interface ContinueAction {
|
|
266
|
+
type: 'continue';
|
|
267
|
+
}
|
|
268
|
+
type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction | SuccessAction<TData>;
|
|
269
|
+
declare class Mutation<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> extends Removable {
|
|
270
|
+
#private;
|
|
271
|
+
state: MutationState<TData, TError, TVariables, TOnMutateResult>;
|
|
272
|
+
options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
273
|
+
readonly mutationId: number;
|
|
274
|
+
constructor(config: MutationConfig<TData, TError, TVariables, TOnMutateResult>);
|
|
275
|
+
setOptions(options: MutationOptions<TData, TError, TVariables, TOnMutateResult>): void;
|
|
276
|
+
get meta(): MutationMeta | undefined;
|
|
277
|
+
addObserver(observer: MutationObserver<any, any, any, any>): void;
|
|
278
|
+
removeObserver(observer: MutationObserver<any, any, any, any>): void;
|
|
279
|
+
protected optionalRemove(): void;
|
|
280
|
+
continue(): Promise<unknown>;
|
|
281
|
+
execute(variables: TVariables): Promise<TData>;
|
|
282
|
+
}
|
|
283
|
+
declare function getDefaultState<TData, TError, TVariables, TOnMutateResult>(): MutationState<TData, TError, TVariables, TOnMutateResult>;
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/utils.d.ts
|
|
286
|
+
type DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [...infer R, unknown] ? readonly [...R] : never;
|
|
287
|
+
type TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly [] ? readonly [] : TuplePrefixes<DropLast<T>> | T;
|
|
288
|
+
interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {
|
|
289
|
+
/**
|
|
290
|
+
* Filter to active queries, inactive queries or all queries
|
|
291
|
+
*/
|
|
292
|
+
type?: QueryTypeFilter;
|
|
293
|
+
/**
|
|
294
|
+
* Match query key exactly
|
|
295
|
+
*/
|
|
296
|
+
exact?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Include queries matching this predicate function
|
|
299
|
+
*/
|
|
300
|
+
predicate?: (query: Query) => boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Include queries matching this query key
|
|
303
|
+
*/
|
|
304
|
+
queryKey?: TQueryKey | TuplePrefixes<TQueryKey>;
|
|
305
|
+
/**
|
|
306
|
+
* Include or exclude stale queries
|
|
307
|
+
*/
|
|
308
|
+
stale?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Include queries matching their fetchStatus
|
|
311
|
+
*/
|
|
312
|
+
fetchStatus?: FetchStatus;
|
|
313
|
+
}
|
|
314
|
+
interface MutationFilters<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
|
|
315
|
+
/**
|
|
316
|
+
* Match mutation key exactly
|
|
317
|
+
*/
|
|
318
|
+
exact?: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Include mutations matching this predicate function
|
|
321
|
+
*/
|
|
322
|
+
predicate?: (mutation: Mutation<TData, TError, TVariables, TOnMutateResult>) => boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Include mutations matching this mutation key
|
|
325
|
+
*/
|
|
326
|
+
mutationKey?: TuplePrefixes<MutationKey>;
|
|
327
|
+
/**
|
|
328
|
+
* Filter by mutation status
|
|
329
|
+
*/
|
|
330
|
+
status?: MutationStatus;
|
|
331
|
+
}
|
|
332
|
+
type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
|
|
333
|
+
type QueryTypeFilter = 'all' | 'active' | 'inactive';
|
|
334
|
+
/** @deprecated
|
|
335
|
+
* use `environmentManager.isServer()` instead.
|
|
336
|
+
*/
|
|
337
|
+
declare const isServer: boolean;
|
|
338
|
+
declare function noop(): void;
|
|
339
|
+
declare function noop(): undefined;
|
|
340
|
+
declare function functionalUpdate<TInput, TOutput>(updater: Updater<TInput, TOutput>, input: TInput): TOutput;
|
|
341
|
+
declare function isValidTimeout(value: unknown): value is number;
|
|
342
|
+
declare function timeUntilStale(updatedAt: number, staleTime?: number): number;
|
|
343
|
+
declare function resolveStaleTime<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(staleTime: undefined | StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>, query: Query<TQueryFnData, TError, TData, TQueryKey>): StaleTime | undefined;
|
|
344
|
+
declare function resolveQueryBoolean<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(option: undefined | QueryBooleanOption<TQueryFnData, TError, TData, TQueryKey>, query: Query<TQueryFnData, TError, TData, TQueryKey>): boolean | undefined;
|
|
345
|
+
declare function matchQuery(filters: QueryFilters, query: Query<any, any, any, any>): boolean;
|
|
346
|
+
declare function matchMutation(filters: MutationFilters, mutation: Mutation<any, any>): boolean;
|
|
347
|
+
declare function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>): string;
|
|
348
|
+
/**
|
|
349
|
+
* Default query & mutation keys hash function.
|
|
350
|
+
* Hashes the value into a stable hash.
|
|
351
|
+
*/
|
|
352
|
+
declare function hashKey(queryKey: QueryKey | MutationKey): string;
|
|
353
|
+
/**
|
|
354
|
+
* Checks if key `b` partially matches with key `a`.
|
|
355
|
+
*/
|
|
356
|
+
declare function partialMatchKey(a: QueryKey, b: QueryKey): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* This function returns `a` if `b` is deeply equal.
|
|
359
|
+
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
360
|
+
* This can be used for structural sharing between JSON values for example.
|
|
361
|
+
*/
|
|
362
|
+
declare function replaceEqualDeep<T>(a: unknown, b: T, depth?: number): T;
|
|
363
|
+
/**
|
|
364
|
+
* Shallow compare objects.
|
|
365
|
+
*/
|
|
366
|
+
declare function shallowEqualObjects<T extends Record<string, any>>(a: T, b: T | undefined): boolean;
|
|
367
|
+
declare function isPlainArray(value: unknown): value is Array<unknown>;
|
|
368
|
+
declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
|
369
|
+
declare function sleep(timeout: number): Promise<void>;
|
|
370
|
+
declare function replaceData<TData, TOptions extends QueryOptions<any, any, any, any>>(prevData: TData | undefined, data: TData, options: TOptions): TData;
|
|
371
|
+
declare function keepPreviousData<T>(previousData: T | undefined): T | undefined;
|
|
372
|
+
declare function addToEnd<T>(items: Array<T>, item: T, max?: number): Array<T>;
|
|
373
|
+
declare function addToStart<T>(items: Array<T>, item: T, max?: number): Array<T>;
|
|
374
|
+
declare const skipToken: unique symbol;
|
|
375
|
+
type SkipToken = typeof skipToken;
|
|
376
|
+
declare function ensureQueryFn<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>(options: {
|
|
377
|
+
queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken;
|
|
378
|
+
queryHash?: string;
|
|
379
|
+
}, fetchOptions?: FetchOptions<TQueryFnData>): QueryFunction<TQueryFnData, TQueryKey>;
|
|
380
|
+
declare function shouldThrowError<T extends (...args: Array<any>) => boolean>(throwOnError: boolean | T | undefined, params: Parameters<T>): boolean;
|
|
381
|
+
declare function addConsumeAwareSignal<T>(object: T, getSignal: () => AbortSignal, onCancelled: VoidFunction): T & {
|
|
382
|
+
signal: AbortSignal;
|
|
383
|
+
};
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/queryCache.d.ts
|
|
386
|
+
interface QueryCacheConfig {
|
|
387
|
+
onError?: (error: DefaultError, query: Query<unknown, unknown, unknown>) => void;
|
|
388
|
+
onSuccess?: (data: unknown, query: Query<unknown, unknown, unknown>) => void;
|
|
389
|
+
onSettled?: (data: unknown | undefined, error: DefaultError | null, query: Query<unknown, unknown, unknown>) => void;
|
|
390
|
+
}
|
|
391
|
+
interface NotifyEventQueryAdded extends NotifyEvent {
|
|
392
|
+
type: 'added';
|
|
393
|
+
query: Query<any, any, any, any>;
|
|
394
|
+
}
|
|
395
|
+
interface NotifyEventQueryRemoved extends NotifyEvent {
|
|
396
|
+
type: 'removed';
|
|
397
|
+
query: Query<any, any, any, any>;
|
|
398
|
+
}
|
|
399
|
+
interface NotifyEventQueryUpdated extends NotifyEvent {
|
|
400
|
+
type: 'updated';
|
|
401
|
+
query: Query<any, any, any, any>;
|
|
402
|
+
action: Action$1<any, any>;
|
|
403
|
+
}
|
|
404
|
+
interface NotifyEventQueryObserverAdded extends NotifyEvent {
|
|
405
|
+
type: 'observerAdded';
|
|
406
|
+
query: Query<any, any, any, any>;
|
|
407
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
408
|
+
}
|
|
409
|
+
interface NotifyEventQueryObserverRemoved extends NotifyEvent {
|
|
410
|
+
type: 'observerRemoved';
|
|
411
|
+
query: Query<any, any, any, any>;
|
|
412
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
413
|
+
}
|
|
414
|
+
interface NotifyEventQueryObserverResultsUpdated extends NotifyEvent {
|
|
415
|
+
type: 'observerResultsUpdated';
|
|
416
|
+
query: Query<any, any, any, any>;
|
|
417
|
+
}
|
|
418
|
+
interface NotifyEventQueryObserverOptionsUpdated extends NotifyEvent {
|
|
419
|
+
type: 'observerOptionsUpdated';
|
|
420
|
+
query: Query<any, any, any, any>;
|
|
421
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
422
|
+
}
|
|
423
|
+
type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated | NotifyEventQueryObserverAdded | NotifyEventQueryObserverRemoved | NotifyEventQueryObserverResultsUpdated | NotifyEventQueryObserverOptionsUpdated;
|
|
424
|
+
type QueryCacheListener = (event: QueryCacheNotifyEvent) => void;
|
|
425
|
+
interface QueryStore {
|
|
426
|
+
has: (queryHash: string) => boolean;
|
|
427
|
+
set: (queryHash: string, query: Query) => void;
|
|
428
|
+
get: (queryHash: string) => Query | undefined;
|
|
429
|
+
delete: (queryHash: string) => void;
|
|
430
|
+
values: () => IterableIterator<Query>;
|
|
431
|
+
}
|
|
432
|
+
declare class QueryCache extends Subscribable<QueryCacheListener> {
|
|
433
|
+
#private;
|
|
434
|
+
config: QueryCacheConfig;
|
|
435
|
+
constructor(config?: QueryCacheConfig);
|
|
436
|
+
build<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(client: QueryClient, options: WithRequired<QueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'>, state?: QueryState<TData, TError>): Query<TQueryFnData, TError, TData, TQueryKey>;
|
|
437
|
+
add(query: Query<any, any, any, any>): void;
|
|
438
|
+
remove(query: Query<any, any, any, any>): void;
|
|
439
|
+
clear(): void;
|
|
440
|
+
get<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryHash: string): Query<TQueryFnData, TError, TData, TQueryKey> | undefined;
|
|
441
|
+
getAll(): Array<Query>;
|
|
442
|
+
find<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData>(filters: WithRequired<QueryFilters, 'queryKey'>): Query<TQueryFnData, TError, TData> | undefined;
|
|
443
|
+
findAll(filters?: QueryFilters<any>): Array<Query>;
|
|
444
|
+
notify(event: QueryCacheNotifyEvent): void;
|
|
445
|
+
onFocus(): void;
|
|
446
|
+
onOnline(): void;
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/queryClient.d.ts
|
|
450
|
+
declare class QueryClient {
|
|
451
|
+
#private;
|
|
452
|
+
constructor(config?: QueryClientConfig);
|
|
453
|
+
mount(): void;
|
|
454
|
+
unmount(): void;
|
|
455
|
+
isFetching<TQueryFilters extends QueryFilters<any> = QueryFilters>(filters?: TQueryFilters): number;
|
|
456
|
+
isMutating<TMutationFilters extends MutationFilters<any, any> = MutationFilters>(filters?: TMutationFilters): number;
|
|
457
|
+
/**
|
|
458
|
+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
459
|
+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
460
|
+
*
|
|
461
|
+
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
462
|
+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
463
|
+
*/
|
|
464
|
+
getQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
467
|
+
*/
|
|
468
|
+
ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<TData>;
|
|
469
|
+
getQueriesData<TQueryFnData = unknown, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters): Array<[QueryKey, TQueryFnData | undefined]>;
|
|
470
|
+
setQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey, updater: Updater<NoInfer<TInferredQueryFnData> | undefined, NoInfer<TInferredQueryFnData> | undefined>, options?: SetDataOptions): NoInfer<TInferredQueryFnData> | undefined;
|
|
471
|
+
setQueriesData<TQueryFnData, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters, updater: Updater<NoInfer<TQueryFnData> | undefined, NoInfer<TQueryFnData> | undefined>, options?: SetDataOptions): Array<[QueryKey, TQueryFnData | undefined]>;
|
|
472
|
+
getQueryState<TQueryFnData = unknown, TError = DefaultError, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>, TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): QueryState<TInferredQueryFnData, TInferredError> | undefined;
|
|
473
|
+
removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>): void;
|
|
474
|
+
resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, options?: ResetOptions): Promise<void>;
|
|
475
|
+
cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, cancelOptions?: CancelOptions): Promise<void>;
|
|
476
|
+
invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: InvalidateQueryFilters<TTaggedQueryKey>, options?: InvalidateOptions): Promise<void>;
|
|
477
|
+
refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: RefetchQueryFilters<TTaggedQueryKey>, options?: RefetchOptions): Promise<void>;
|
|
478
|
+
query<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>): Promise<TData>;
|
|
479
|
+
/**
|
|
480
|
+
* @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
|
|
481
|
+
*/
|
|
482
|
+
fetchQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<TData>;
|
|
483
|
+
/**
|
|
484
|
+
* @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
485
|
+
*/
|
|
486
|
+
prefetchQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<void>;
|
|
487
|
+
infiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<Array<TData> extends Array<InfiniteData<TQueryFnData>> ? InfiniteData<TQueryFnData, TPageParam> : TData>;
|
|
488
|
+
/**
|
|
489
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
|
|
490
|
+
*/
|
|
491
|
+
fetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
494
|
+
*/
|
|
495
|
+
prefetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<void>;
|
|
496
|
+
/**
|
|
497
|
+
* @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
498
|
+
*/
|
|
499
|
+
ensureInfiniteQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: EnsureInfiniteQueryDataOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
|
|
500
|
+
resumePausedMutations(): Promise<unknown>;
|
|
501
|
+
getQueryCache(): QueryCache;
|
|
502
|
+
getMutationCache(): MutationCache;
|
|
503
|
+
getDefaultOptions(): DefaultOptions;
|
|
504
|
+
setDefaultOptions(options: DefaultOptions): void;
|
|
505
|
+
setQueryDefaults<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData>(queryKey: QueryKey, options: Partial<OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>, 'queryKey'>>): void;
|
|
506
|
+
getQueryDefaults(queryKey: QueryKey): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'>;
|
|
507
|
+
setMutationDefaults<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(mutationKey: MutationKey, options: OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): void;
|
|
508
|
+
getMutationDefaults(mutationKey: MutationKey): OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'>;
|
|
509
|
+
defaultQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam> | DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
510
|
+
defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(options?: T): T;
|
|
511
|
+
clear(): void;
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/retryer.d.ts
|
|
515
|
+
interface RetryerConfig<TData = unknown, TError = DefaultError> {
|
|
516
|
+
fn: () => TData | Promise<TData>;
|
|
517
|
+
initialPromise?: Promise<TData>;
|
|
518
|
+
onCancel?: (error: TError) => void;
|
|
519
|
+
onFail?: (failureCount: number, error: TError) => void;
|
|
520
|
+
onPause?: () => void;
|
|
521
|
+
onContinue?: () => void;
|
|
522
|
+
retry?: RetryValue<TError>;
|
|
523
|
+
retryDelay?: RetryDelayValue<TError>;
|
|
524
|
+
networkMode: NetworkMode | undefined;
|
|
525
|
+
canRun: () => boolean;
|
|
526
|
+
}
|
|
527
|
+
interface Retryer<TData = unknown> {
|
|
528
|
+
promise: Promise<TData>;
|
|
529
|
+
cancel: (cancelOptions?: CancelOptions) => void;
|
|
530
|
+
continue: () => Promise<unknown>;
|
|
531
|
+
cancelRetry: () => void;
|
|
532
|
+
continueRetry: () => void;
|
|
533
|
+
canStart: () => boolean;
|
|
534
|
+
start: () => Promise<TData>;
|
|
535
|
+
status: () => 'pending' | 'resolved' | 'rejected';
|
|
536
|
+
}
|
|
537
|
+
type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>;
|
|
538
|
+
type ShouldRetryFunction<TError = DefaultError> = (failureCount: number, error: TError) => boolean;
|
|
539
|
+
type RetryDelayValue<TError> = number | RetryDelayFunction<TError>;
|
|
540
|
+
type RetryDelayFunction<TError = DefaultError> = (failureCount: number, error: TError) => number;
|
|
541
|
+
declare function canFetch(networkMode: NetworkMode | undefined): boolean;
|
|
542
|
+
declare class CancelledError extends Error {
|
|
543
|
+
revert?: boolean;
|
|
544
|
+
silent?: boolean;
|
|
545
|
+
constructor(options?: CancelOptions);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @deprecated Use instanceof `CancelledError` instead.
|
|
549
|
+
*/
|
|
550
|
+
declare function isCancelledError(value: any): value is CancelledError;
|
|
551
|
+
declare function createRetryer<TData = unknown, TError = DefaultError>(config: RetryerConfig<TData, TError>): Retryer<TData>;
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/types.d.ts
|
|
554
|
+
type NonUndefinedGuard<T> = T extends undefined ? never : T;
|
|
555
|
+
type DistributiveOmit<TObject, TKey extends keyof TObject> = TObject extends any ? Omit<TObject, TKey> : never;
|
|
556
|
+
type OmitKeyof<TObject, TKey extends TStrictly extends 'safely' ? keyof TObject | (string & Record<never, never>) | (number & Record<never, never>) | (symbol & Record<never, never>) : keyof TObject, TStrictly extends 'strictly' | 'safely' = 'strictly'> = Omit<TObject, TKey>;
|
|
557
|
+
type Override<TTargetA, TTargetB> = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey]; };
|
|
558
|
+
interface Register {}
|
|
559
|
+
type DefaultError = Register extends {
|
|
560
|
+
defaultError: infer TError;
|
|
561
|
+
} ? TError : Error;
|
|
562
|
+
type QueryKey = Register extends {
|
|
563
|
+
queryKey: infer TQueryKey;
|
|
564
|
+
} ? TQueryKey extends ReadonlyArray<unknown> ? TQueryKey : TQueryKey extends Array<unknown> ? TQueryKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
|
|
565
|
+
declare const dataTagSymbol: unique symbol;
|
|
566
|
+
type dataTagSymbol = typeof dataTagSymbol;
|
|
567
|
+
declare const dataTagErrorSymbol: unique symbol;
|
|
568
|
+
type dataTagErrorSymbol = typeof dataTagErrorSymbol;
|
|
569
|
+
declare const unsetMarker: unique symbol;
|
|
570
|
+
type UnsetMarker = typeof unsetMarker;
|
|
571
|
+
type AnyDataTag = {
|
|
572
|
+
[dataTagSymbol]: any;
|
|
573
|
+
[dataTagErrorSymbol]: any;
|
|
574
|
+
};
|
|
575
|
+
type DataTag<TType, TValue, TError = UnsetMarker> = TType extends AnyDataTag ? TType : TType & {
|
|
576
|
+
[dataTagSymbol]: TValue;
|
|
577
|
+
[dataTagErrorSymbol]: TError;
|
|
578
|
+
};
|
|
579
|
+
type QueryKeyWithDataTag<TQueryKey extends QueryKey = QueryKey, TQueryFnData = unknown, TError = DefaultError> = {
|
|
580
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>;
|
|
581
|
+
};
|
|
582
|
+
type InferDataFromTag<TQueryFnData, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, infer TaggedValue, unknown> ? TaggedValue : TQueryFnData;
|
|
583
|
+
type InferErrorFromTag<TError, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, unknown, infer TaggedError> ? TaggedError extends UnsetMarker ? TError : TaggedError : TError;
|
|
584
|
+
type QueryFunction<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>;
|
|
585
|
+
type StaleTime = number | 'static';
|
|
586
|
+
type StaleTimeFunction<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = StaleTime | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => StaleTime);
|
|
587
|
+
type QueryBooleanOption<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = boolean | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean);
|
|
588
|
+
type QueryPersister<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? (queryFn: QueryFunction<T, TQueryKey, never>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T> : (queryFn: QueryFunction<T, TQueryKey, TPageParam>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T>;
|
|
589
|
+
type QueryFunctionContext<TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? {
|
|
590
|
+
client: QueryClient;
|
|
591
|
+
queryKey: TQueryKey;
|
|
592
|
+
signal: AbortSignal;
|
|
593
|
+
meta: QueryMeta | undefined;
|
|
594
|
+
pageParam?: unknown;
|
|
595
|
+
/**
|
|
596
|
+
* @deprecated
|
|
597
|
+
* if you want access to the direction, you can add it to the pageParam
|
|
598
|
+
*/
|
|
599
|
+
direction?: unknown;
|
|
600
|
+
} : {
|
|
601
|
+
client: QueryClient;
|
|
602
|
+
queryKey: TQueryKey;
|
|
603
|
+
signal: AbortSignal;
|
|
604
|
+
pageParam: TPageParam;
|
|
605
|
+
/**
|
|
606
|
+
* @deprecated
|
|
607
|
+
* if you want access to the direction, you can add it to the pageParam
|
|
608
|
+
*/
|
|
609
|
+
direction: FetchDirection;
|
|
610
|
+
meta: QueryMeta | undefined;
|
|
611
|
+
};
|
|
612
|
+
type InitialDataFunction<T> = () => T | undefined;
|
|
613
|
+
type NonFunctionGuard<T> = T extends Function ? never : T;
|
|
614
|
+
type PlaceholderDataFunction<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = (previousData: TQueryData | undefined, previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => TQueryData | undefined;
|
|
615
|
+
type QueriesPlaceholderDataFunction<TQueryData> = (previousData: undefined, previousQuery: undefined) => TQueryData | undefined;
|
|
616
|
+
type QueryKeyHashFunction<TQueryKey extends QueryKey> = (queryKey: TQueryKey) => string;
|
|
617
|
+
type GetPreviousPageParamFunction<TPageParam, TQueryFnData = unknown> = (firstPage: TQueryFnData, allPages: Array<TQueryFnData>, firstPageParam: TPageParam, allPageParams: Array<TPageParam>) => TPageParam | undefined | null;
|
|
618
|
+
type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (lastPage: TQueryFnData, allPages: Array<TQueryFnData>, lastPageParam: TPageParam, allPageParams: Array<TPageParam>) => TPageParam | undefined | null;
|
|
619
|
+
interface InfiniteData<TData, TPageParam = unknown> {
|
|
620
|
+
pages: Array<TData>;
|
|
621
|
+
pageParams: Array<TPageParam>;
|
|
622
|
+
}
|
|
623
|
+
type QueryMeta = Register extends {
|
|
624
|
+
queryMeta: infer TQueryMeta;
|
|
625
|
+
} ? TQueryMeta extends Record<string, unknown> ? TQueryMeta : Record<string, unknown> : Record<string, unknown>;
|
|
626
|
+
type NetworkMode = 'online' | 'always' | 'offlineFirst';
|
|
627
|
+
type NotifyOnChangeProps = Array<keyof InfiniteQueryObserverResult> | 'all' | undefined | (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined);
|
|
628
|
+
interface QueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> {
|
|
629
|
+
/**
|
|
630
|
+
* If `false`, failed queries will not retry by default.
|
|
631
|
+
* If `true`, failed queries will retry infinitely.
|
|
632
|
+
* If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
|
|
633
|
+
* If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.
|
|
634
|
+
*/
|
|
635
|
+
retry?: RetryValue<TError>;
|
|
636
|
+
retryDelay?: RetryDelayValue<TError>;
|
|
637
|
+
networkMode?: NetworkMode;
|
|
638
|
+
/**
|
|
639
|
+
* The time in milliseconds that unused/inactive cache data remains in memory.
|
|
640
|
+
* When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.
|
|
641
|
+
* When different garbage collection times are specified, the longest one will be used.
|
|
642
|
+
* Setting it to `Infinity` will disable garbage collection.
|
|
643
|
+
*/
|
|
644
|
+
gcTime?: number;
|
|
645
|
+
queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken;
|
|
646
|
+
persister?: QueryPersister<TQueryFnData, NoInfer<TQueryKey>, TPageParam>;
|
|
647
|
+
queryHash?: string;
|
|
648
|
+
queryKey?: TQueryKey;
|
|
649
|
+
queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>;
|
|
650
|
+
initialData?: TData | InitialDataFunction<TData>;
|
|
651
|
+
initialDataUpdatedAt?: number | (() => number | undefined);
|
|
652
|
+
behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>;
|
|
653
|
+
/**
|
|
654
|
+
* Set this to `false` to disable structural sharing between query results.
|
|
655
|
+
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.
|
|
656
|
+
* Defaults to `true`.
|
|
657
|
+
*/
|
|
658
|
+
structuralSharing?: boolean | ((oldData: unknown | undefined, newData: unknown) => unknown);
|
|
659
|
+
_defaulted?: boolean;
|
|
660
|
+
_type?: 'infinite';
|
|
661
|
+
/**
|
|
662
|
+
* Additional payload to be stored on each query.
|
|
663
|
+
* Use this property to pass information that can be used in other places.
|
|
664
|
+
*/
|
|
665
|
+
meta?: QueryMeta;
|
|
666
|
+
/**
|
|
667
|
+
* Maximum number of pages to store in the data of an infinite query.
|
|
668
|
+
*/
|
|
669
|
+
maxPages?: number;
|
|
670
|
+
}
|
|
671
|
+
interface InitialPageParam<TPageParam = unknown> {
|
|
672
|
+
initialPageParam: TPageParam;
|
|
673
|
+
}
|
|
674
|
+
interface InfiniteQueryPageParamsOptions<TQueryFnData = unknown, TPageParam = unknown> extends InitialPageParam<TPageParam> {
|
|
675
|
+
/**
|
|
676
|
+
* This function can be set to automatically get the previous cursor for infinite queries.
|
|
677
|
+
* The result will also be used to determine the value of `hasPreviousPage`.
|
|
678
|
+
*/
|
|
679
|
+
getPreviousPageParam?: GetPreviousPageParamFunction<TPageParam, TQueryFnData>;
|
|
680
|
+
/**
|
|
681
|
+
* This function can be set to automatically get the next cursor for infinite queries.
|
|
682
|
+
* The result will also be used to determine the value of `hasNextPage`.
|
|
683
|
+
*/
|
|
684
|
+
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
|
|
685
|
+
}
|
|
686
|
+
type ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey extends QueryKey> = boolean | ((error: TError, query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean);
|
|
687
|
+
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
688
|
+
/**
|
|
689
|
+
* Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys.
|
|
690
|
+
* To refetch the query, use the `refetch` method returned from the `useQuery` instance.
|
|
691
|
+
* Accepts a boolean or function that returns a boolean.
|
|
692
|
+
* Defaults to `true`.
|
|
693
|
+
*/
|
|
694
|
+
enabled?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
695
|
+
/**
|
|
696
|
+
* The time in milliseconds after data is considered stale.
|
|
697
|
+
* If set to `Infinity`, the data will never be considered stale.
|
|
698
|
+
* If set to a function, the function will be executed with the query to compute a `staleTime`.
|
|
699
|
+
* Defaults to `0`.
|
|
700
|
+
*/
|
|
701
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
702
|
+
/**
|
|
703
|
+
* If set to a number, the query will continuously refetch at this frequency in milliseconds.
|
|
704
|
+
* If set to a function, the function will be executed with the latest data and query to compute a frequency
|
|
705
|
+
* Defaults to `false`.
|
|
706
|
+
*/
|
|
707
|
+
refetchInterval?: number | false | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => number | false | undefined);
|
|
708
|
+
/**
|
|
709
|
+
* If set to `true`, the query will continue to refetch while their tab/window is in the background.
|
|
710
|
+
* Defaults to `false`.
|
|
711
|
+
*/
|
|
712
|
+
refetchIntervalInBackground?: boolean;
|
|
713
|
+
/**
|
|
714
|
+
* If set to `true`, the query will refetch on window focus if the data is stale.
|
|
715
|
+
* If set to `false`, the query will not refetch on window focus.
|
|
716
|
+
* If set to `'always'`, the query will always refetch on window focus.
|
|
717
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
718
|
+
* Defaults to `true`.
|
|
719
|
+
*/
|
|
720
|
+
refetchOnWindowFocus?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
721
|
+
/**
|
|
722
|
+
* If set to `true`, the query will refetch on reconnect if the data is stale.
|
|
723
|
+
* If set to `false`, the query will not refetch on reconnect.
|
|
724
|
+
* If set to `'always'`, the query will always refetch on reconnect.
|
|
725
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
726
|
+
* Defaults to `true` unless `networkMode` is `'always'`.
|
|
727
|
+
*/
|
|
728
|
+
refetchOnReconnect?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
729
|
+
/**
|
|
730
|
+
* If set to `true`, the query will refetch on mount if the data is stale.
|
|
731
|
+
* If set to `false`, will disable additional instances of a query to trigger background refetch.
|
|
732
|
+
* If set to `'always'`, the query will always refetch on mount.
|
|
733
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value
|
|
734
|
+
* Defaults to `true`.
|
|
735
|
+
*/
|
|
736
|
+
refetchOnMount?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
737
|
+
/**
|
|
738
|
+
* If set to `false`, the query will not be retried on mount if it contains an error.
|
|
739
|
+
* If set to a function, the function will be executed with the query to compute the value.
|
|
740
|
+
* Defaults to `true`.
|
|
741
|
+
*/
|
|
742
|
+
retryOnMount?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
743
|
+
/**
|
|
744
|
+
* If set, the component will only re-render if any of the listed properties change.
|
|
745
|
+
* When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
|
|
746
|
+
* When set to `'all'`, the component will re-render whenever a query is updated.
|
|
747
|
+
* When set to a function, the function will be executed to compute the list of properties.
|
|
748
|
+
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
|
|
749
|
+
*/
|
|
750
|
+
notifyOnChangeProps?: NotifyOnChangeProps;
|
|
751
|
+
/**
|
|
752
|
+
* Whether errors should be thrown instead of setting the `error` property.
|
|
753
|
+
* If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.
|
|
754
|
+
* If set to `false` and `suspense` is `false`, errors are returned as state.
|
|
755
|
+
* 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`).
|
|
756
|
+
* Defaults to `false`.
|
|
757
|
+
*/
|
|
758
|
+
throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
759
|
+
/**
|
|
760
|
+
* This option can be used to transform or select a part of the data returned by the query function.
|
|
761
|
+
*/
|
|
762
|
+
select?: (data: TQueryData) => TData;
|
|
763
|
+
/**
|
|
764
|
+
* If set to `true`, the query will suspend when `status === 'pending'`
|
|
765
|
+
* and throw errors when `status === 'error'`.
|
|
766
|
+
* Defaults to `false`.
|
|
767
|
+
*/
|
|
768
|
+
suspense?: boolean;
|
|
769
|
+
/**
|
|
770
|
+
* If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.
|
|
771
|
+
*/
|
|
772
|
+
placeholderData?: NonFunctionGuard<TQueryData> | PlaceholderDataFunction<NonFunctionGuard<TQueryData>, TError, NonFunctionGuard<TQueryData>, TQueryKey>;
|
|
773
|
+
_optimisticResults?: 'optimistic' | 'isRestoring';
|
|
774
|
+
}
|
|
775
|
+
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & { [_ in TKey]: {}; };
|
|
776
|
+
type DefaultedQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = WithRequired<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
777
|
+
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserverOptions<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey, TPageParam>, InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {}
|
|
778
|
+
type DefaultedInfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = WithRequired<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
779
|
+
interface QueryExecuteOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
780
|
+
initialPageParam?: never;
|
|
781
|
+
select?: (data: TQueryData) => TData;
|
|
782
|
+
/**
|
|
783
|
+
* The time in milliseconds after data is considered stale.
|
|
784
|
+
* If the data is fresh it will be returned from the cache.
|
|
785
|
+
*/
|
|
786
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
787
|
+
}
|
|
788
|
+
/** @deprecated */
|
|
789
|
+
interface FetchQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
790
|
+
initialPageParam?: never;
|
|
791
|
+
/**
|
|
792
|
+
* The time in milliseconds after data is considered stale.
|
|
793
|
+
* If the data is fresh it will be returned from the cache.
|
|
794
|
+
*/
|
|
795
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>;
|
|
796
|
+
}
|
|
797
|
+
/** @deprecated */
|
|
798
|
+
interface EnsureQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> {
|
|
799
|
+
revalidateIfStale?: boolean;
|
|
800
|
+
}
|
|
801
|
+
/** @deprecated */
|
|
802
|
+
type EnsureInfiniteQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
803
|
+
revalidateIfStale?: boolean;
|
|
804
|
+
};
|
|
805
|
+
type InfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> = {
|
|
806
|
+
pages?: never;
|
|
807
|
+
} | {
|
|
808
|
+
pages: number;
|
|
809
|
+
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
|
|
810
|
+
};
|
|
811
|
+
type InfiniteQueryExecuteOptions<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Omit<QueryExecuteOptions<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey, TPageParam>, 'initialPageParam'> & InitialPageParam<TPageParam> & InfiniteQueryPages<TQueryFnData, TPageParam>;
|
|
812
|
+
/** @deprecated */
|
|
813
|
+
type FetchInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Omit<FetchQueryOptions<TQueryFnData, TError, InfiniteData<TData, TPageParam>, TQueryKey, TPageParam>, 'initialPageParam'> & InitialPageParam<TPageParam> & InfiniteQueryPages<TQueryFnData, TPageParam>;
|
|
814
|
+
interface ResultOptions {
|
|
815
|
+
throwOnError?: boolean;
|
|
816
|
+
}
|
|
817
|
+
interface RefetchOptions extends ResultOptions {
|
|
818
|
+
/**
|
|
819
|
+
* If set to `true`, a currently running request will be cancelled before a new request is made
|
|
820
|
+
*
|
|
821
|
+
* If set to `false`, no refetch will be made if there is already a request running.
|
|
822
|
+
*
|
|
823
|
+
* Defaults to `true`.
|
|
824
|
+
*/
|
|
825
|
+
cancelRefetch?: boolean;
|
|
826
|
+
}
|
|
827
|
+
interface InvalidateQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {
|
|
828
|
+
refetchType?: QueryTypeFilter | 'none';
|
|
829
|
+
}
|
|
830
|
+
interface RefetchQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {}
|
|
831
|
+
interface InvalidateOptions extends RefetchOptions {}
|
|
832
|
+
interface ResetOptions extends RefetchOptions {}
|
|
833
|
+
interface FetchNextPageOptions extends ResultOptions {
|
|
834
|
+
/**
|
|
835
|
+
* If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time,
|
|
836
|
+
* whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
|
|
837
|
+
*
|
|
838
|
+
* If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
839
|
+
*
|
|
840
|
+
* Defaults to `true`.
|
|
841
|
+
*/
|
|
842
|
+
cancelRefetch?: boolean;
|
|
843
|
+
}
|
|
844
|
+
interface FetchPreviousPageOptions extends ResultOptions {
|
|
845
|
+
/**
|
|
846
|
+
* If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time,
|
|
847
|
+
* whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
|
|
848
|
+
*
|
|
849
|
+
* If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
850
|
+
*
|
|
851
|
+
* Defaults to `true`.
|
|
852
|
+
*/
|
|
853
|
+
cancelRefetch?: boolean;
|
|
854
|
+
}
|
|
855
|
+
type QueryStatus = 'pending' | 'error' | 'success';
|
|
856
|
+
type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
857
|
+
interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
|
|
858
|
+
/**
|
|
859
|
+
* The last successfully resolved data for the query.
|
|
860
|
+
*/
|
|
861
|
+
data: TData | undefined;
|
|
862
|
+
/**
|
|
863
|
+
* The timestamp for when the query most recently returned the `status` as `"success"`.
|
|
864
|
+
*/
|
|
865
|
+
dataUpdatedAt: number;
|
|
866
|
+
/**
|
|
867
|
+
* The error object for the query, if an error was thrown.
|
|
868
|
+
* - Defaults to `null`.
|
|
869
|
+
*/
|
|
870
|
+
error: TError | null;
|
|
871
|
+
/**
|
|
872
|
+
* The timestamp for when the query most recently returned the `status` as `"error"`.
|
|
873
|
+
*/
|
|
874
|
+
errorUpdatedAt: number;
|
|
875
|
+
/**
|
|
876
|
+
* The failure count for the query.
|
|
877
|
+
* - Incremented every time the query fails.
|
|
878
|
+
* - Reset to `0` when the query succeeds.
|
|
879
|
+
*/
|
|
880
|
+
failureCount: number;
|
|
881
|
+
/**
|
|
882
|
+
* The failure reason for the query retry.
|
|
883
|
+
* - Reset to `null` when the query succeeds.
|
|
884
|
+
*/
|
|
885
|
+
failureReason: TError | null;
|
|
886
|
+
/**
|
|
887
|
+
* The sum of all errors.
|
|
888
|
+
*/
|
|
889
|
+
errorUpdateCount: number;
|
|
890
|
+
/**
|
|
891
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
892
|
+
* - `true` if the query attempt resulted in an error.
|
|
893
|
+
*/
|
|
894
|
+
isError: boolean;
|
|
895
|
+
/**
|
|
896
|
+
* Will be `true` if the query has been fetched.
|
|
897
|
+
*/
|
|
898
|
+
isFetched: boolean;
|
|
899
|
+
/**
|
|
900
|
+
* Will be `true` if the query has been fetched after the component mounted.
|
|
901
|
+
* - This property can be used to not show any previously cached data.
|
|
902
|
+
*/
|
|
903
|
+
isFetchedAfterMount: boolean;
|
|
904
|
+
/**
|
|
905
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
906
|
+
* - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.
|
|
907
|
+
*/
|
|
908
|
+
isFetching: boolean;
|
|
909
|
+
/**
|
|
910
|
+
* Is `true` whenever the first fetch for a query is in-flight.
|
|
911
|
+
* - Is the same as `isFetching && isPending`.
|
|
912
|
+
*/
|
|
913
|
+
isLoading: boolean;
|
|
914
|
+
/**
|
|
915
|
+
* Will be `pending` if there's no cached data and no query attempt was finished yet.
|
|
916
|
+
*/
|
|
917
|
+
isPending: boolean;
|
|
918
|
+
/**
|
|
919
|
+
* Will be `true` if the query failed while fetching for the first time.
|
|
920
|
+
*/
|
|
921
|
+
isLoadingError: boolean;
|
|
922
|
+
/**
|
|
923
|
+
* @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`
|
|
924
|
+
* and will be removed in the next major version.
|
|
925
|
+
*/
|
|
926
|
+
isInitialLoading: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
929
|
+
* - The query wanted to fetch, but has been `paused`.
|
|
930
|
+
*/
|
|
931
|
+
isPaused: boolean;
|
|
932
|
+
/**
|
|
933
|
+
* Will be `true` if the data shown is the placeholder data.
|
|
934
|
+
*/
|
|
935
|
+
isPlaceholderData: boolean;
|
|
936
|
+
/**
|
|
937
|
+
* Will be `true` if the query failed while refetching.
|
|
938
|
+
*/
|
|
939
|
+
isRefetchError: boolean;
|
|
940
|
+
/**
|
|
941
|
+
* Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.
|
|
942
|
+
* - Is the same as `isFetching && !isPending`.
|
|
943
|
+
*/
|
|
944
|
+
isRefetching: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.
|
|
947
|
+
*/
|
|
948
|
+
isStale: boolean;
|
|
949
|
+
/**
|
|
950
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
951
|
+
* - `true` if the query has received a response with no errors and is ready to display its data.
|
|
952
|
+
*/
|
|
953
|
+
isSuccess: boolean;
|
|
954
|
+
/**
|
|
955
|
+
* `true` if this observer is enabled, `false` otherwise.
|
|
956
|
+
*/
|
|
957
|
+
isEnabled: boolean;
|
|
958
|
+
/**
|
|
959
|
+
* A function to manually refetch the query.
|
|
960
|
+
*/
|
|
961
|
+
refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>;
|
|
962
|
+
/**
|
|
963
|
+
* The status of the query.
|
|
964
|
+
* - Will be:
|
|
965
|
+
* - `pending` if there's no cached data and no query attempt was finished yet.
|
|
966
|
+
* - `error` if the query attempt resulted in an error.
|
|
967
|
+
* - `success` if the query has received a response with no errors and is ready to display its data.
|
|
968
|
+
*/
|
|
969
|
+
status: QueryStatus;
|
|
970
|
+
/**
|
|
971
|
+
* The fetch status of the query.
|
|
972
|
+
* - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.
|
|
973
|
+
* - `paused`: The query wanted to fetch, but has been `paused`.
|
|
974
|
+
* - `idle`: The query is not fetching.
|
|
975
|
+
* - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.
|
|
976
|
+
*/
|
|
977
|
+
fetchStatus: FetchStatus;
|
|
978
|
+
}
|
|
979
|
+
interface QueryObserverPendingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
980
|
+
data: undefined;
|
|
981
|
+
error: null;
|
|
982
|
+
isError: false;
|
|
983
|
+
isPending: true;
|
|
984
|
+
isLoadingError: false;
|
|
985
|
+
isRefetchError: false;
|
|
986
|
+
isSuccess: false;
|
|
987
|
+
isPlaceholderData: false;
|
|
988
|
+
status: 'pending';
|
|
989
|
+
}
|
|
990
|
+
interface QueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
991
|
+
data: undefined;
|
|
992
|
+
error: null;
|
|
993
|
+
isError: false;
|
|
994
|
+
isPending: true;
|
|
995
|
+
isLoading: true;
|
|
996
|
+
isLoadingError: false;
|
|
997
|
+
isRefetchError: false;
|
|
998
|
+
isSuccess: false;
|
|
999
|
+
isPlaceholderData: false;
|
|
1000
|
+
status: 'pending';
|
|
1001
|
+
}
|
|
1002
|
+
interface QueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1003
|
+
data: undefined;
|
|
1004
|
+
error: TError;
|
|
1005
|
+
isError: true;
|
|
1006
|
+
isPending: false;
|
|
1007
|
+
isLoading: false;
|
|
1008
|
+
isLoadingError: true;
|
|
1009
|
+
isRefetchError: false;
|
|
1010
|
+
isSuccess: false;
|
|
1011
|
+
isPlaceholderData: false;
|
|
1012
|
+
status: 'error';
|
|
1013
|
+
}
|
|
1014
|
+
interface QueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1015
|
+
data: TData;
|
|
1016
|
+
error: TError;
|
|
1017
|
+
isError: true;
|
|
1018
|
+
isPending: false;
|
|
1019
|
+
isLoading: false;
|
|
1020
|
+
isLoadingError: false;
|
|
1021
|
+
isRefetchError: true;
|
|
1022
|
+
isSuccess: false;
|
|
1023
|
+
isPlaceholderData: false;
|
|
1024
|
+
status: 'error';
|
|
1025
|
+
}
|
|
1026
|
+
interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1027
|
+
data: TData;
|
|
1028
|
+
error: null;
|
|
1029
|
+
isError: false;
|
|
1030
|
+
isPending: false;
|
|
1031
|
+
isLoading: false;
|
|
1032
|
+
isLoadingError: false;
|
|
1033
|
+
isRefetchError: false;
|
|
1034
|
+
isSuccess: true;
|
|
1035
|
+
isPlaceholderData: false;
|
|
1036
|
+
status: 'success';
|
|
1037
|
+
}
|
|
1038
|
+
interface QueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1039
|
+
data: TData;
|
|
1040
|
+
isError: false;
|
|
1041
|
+
error: null;
|
|
1042
|
+
isPending: false;
|
|
1043
|
+
isLoading: false;
|
|
1044
|
+
isLoadingError: false;
|
|
1045
|
+
isRefetchError: false;
|
|
1046
|
+
isSuccess: true;
|
|
1047
|
+
isPlaceholderData: true;
|
|
1048
|
+
status: 'success';
|
|
1049
|
+
}
|
|
1050
|
+
type DefinedQueryObserverResult<TData = unknown, TError = DefaultError> = QueryObserverRefetchErrorResult<TData, TError> | QueryObserverSuccessResult<TData, TError>;
|
|
1051
|
+
type QueryObserverResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError> | QueryObserverLoadingErrorResult<TData, TError> | QueryObserverLoadingResult<TData, TError> | QueryObserverPendingResult<TData, TError> | QueryObserverPlaceholderResult<TData, TError>;
|
|
1052
|
+
interface InfiniteQueryObserverBaseResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1053
|
+
/**
|
|
1054
|
+
* This function allows you to fetch the next "page" of results.
|
|
1055
|
+
*/
|
|
1056
|
+
fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
|
|
1057
|
+
/**
|
|
1058
|
+
* This function allows you to fetch the previous "page" of results.
|
|
1059
|
+
*/
|
|
1060
|
+
fetchPreviousPage: (options?: FetchPreviousPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option).
|
|
1063
|
+
*/
|
|
1064
|
+
hasNextPage: boolean;
|
|
1065
|
+
/**
|
|
1066
|
+
* Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option).
|
|
1067
|
+
*/
|
|
1068
|
+
hasPreviousPage: boolean;
|
|
1069
|
+
/**
|
|
1070
|
+
* Will be `true` if the query failed while fetching the next page.
|
|
1071
|
+
*/
|
|
1072
|
+
isFetchNextPageError: boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Will be `true` while fetching the next page with `fetchNextPage`.
|
|
1075
|
+
*/
|
|
1076
|
+
isFetchingNextPage: boolean;
|
|
1077
|
+
/**
|
|
1078
|
+
* Will be `true` if the query failed while fetching the previous page.
|
|
1079
|
+
*/
|
|
1080
|
+
isFetchPreviousPageError: boolean;
|
|
1081
|
+
/**
|
|
1082
|
+
* Will be `true` while fetching the previous page with `fetchPreviousPage`.
|
|
1083
|
+
*/
|
|
1084
|
+
isFetchingPreviousPage: boolean;
|
|
1085
|
+
}
|
|
1086
|
+
interface InfiniteQueryObserverPendingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1087
|
+
data: undefined;
|
|
1088
|
+
error: null;
|
|
1089
|
+
isError: false;
|
|
1090
|
+
isPending: true;
|
|
1091
|
+
isLoadingError: false;
|
|
1092
|
+
isRefetchError: false;
|
|
1093
|
+
isFetchNextPageError: false;
|
|
1094
|
+
isFetchPreviousPageError: false;
|
|
1095
|
+
isSuccess: false;
|
|
1096
|
+
isPlaceholderData: false;
|
|
1097
|
+
status: 'pending';
|
|
1098
|
+
}
|
|
1099
|
+
interface InfiniteQueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1100
|
+
data: undefined;
|
|
1101
|
+
error: null;
|
|
1102
|
+
isError: false;
|
|
1103
|
+
isPending: true;
|
|
1104
|
+
isLoading: true;
|
|
1105
|
+
isLoadingError: false;
|
|
1106
|
+
isRefetchError: false;
|
|
1107
|
+
isFetchNextPageError: false;
|
|
1108
|
+
isFetchPreviousPageError: false;
|
|
1109
|
+
isSuccess: false;
|
|
1110
|
+
isPlaceholderData: false;
|
|
1111
|
+
status: 'pending';
|
|
1112
|
+
}
|
|
1113
|
+
interface InfiniteQueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1114
|
+
data: undefined;
|
|
1115
|
+
error: TError;
|
|
1116
|
+
isError: true;
|
|
1117
|
+
isPending: false;
|
|
1118
|
+
isLoading: false;
|
|
1119
|
+
isLoadingError: true;
|
|
1120
|
+
isRefetchError: false;
|
|
1121
|
+
isFetchNextPageError: false;
|
|
1122
|
+
isFetchPreviousPageError: false;
|
|
1123
|
+
isSuccess: false;
|
|
1124
|
+
isPlaceholderData: false;
|
|
1125
|
+
status: 'error';
|
|
1126
|
+
}
|
|
1127
|
+
interface InfiniteQueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1128
|
+
data: TData;
|
|
1129
|
+
error: TError;
|
|
1130
|
+
isError: true;
|
|
1131
|
+
isPending: false;
|
|
1132
|
+
isLoading: false;
|
|
1133
|
+
isLoadingError: false;
|
|
1134
|
+
isRefetchError: true;
|
|
1135
|
+
isSuccess: false;
|
|
1136
|
+
isPlaceholderData: false;
|
|
1137
|
+
status: 'error';
|
|
1138
|
+
}
|
|
1139
|
+
interface InfiniteQueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1140
|
+
data: TData;
|
|
1141
|
+
error: null;
|
|
1142
|
+
isError: false;
|
|
1143
|
+
isPending: false;
|
|
1144
|
+
isLoading: false;
|
|
1145
|
+
isLoadingError: false;
|
|
1146
|
+
isRefetchError: false;
|
|
1147
|
+
isFetchNextPageError: false;
|
|
1148
|
+
isFetchPreviousPageError: false;
|
|
1149
|
+
isSuccess: true;
|
|
1150
|
+
isPlaceholderData: false;
|
|
1151
|
+
status: 'success';
|
|
1152
|
+
}
|
|
1153
|
+
interface InfiniteQueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1154
|
+
data: TData;
|
|
1155
|
+
isError: false;
|
|
1156
|
+
error: null;
|
|
1157
|
+
isPending: false;
|
|
1158
|
+
isLoading: false;
|
|
1159
|
+
isLoadingError: false;
|
|
1160
|
+
isRefetchError: false;
|
|
1161
|
+
isSuccess: true;
|
|
1162
|
+
isPlaceholderData: true;
|
|
1163
|
+
isFetchNextPageError: false;
|
|
1164
|
+
isFetchPreviousPageError: false;
|
|
1165
|
+
status: 'success';
|
|
1166
|
+
}
|
|
1167
|
+
type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
|
|
1168
|
+
type InfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = DefinedInfiniteQueryObserverResult<TData, TError> | InfiniteQueryObserverLoadingErrorResult<TData, TError> | InfiniteQueryObserverLoadingResult<TData, TError> | InfiniteQueryObserverPendingResult<TData, TError> | InfiniteQueryObserverPlaceholderResult<TData, TError>;
|
|
1169
|
+
type MutationKey = Register extends {
|
|
1170
|
+
mutationKey: infer TMutationKey;
|
|
1171
|
+
} ? TMutationKey extends ReadonlyArray<unknown> ? TMutationKey : TMutationKey extends Array<unknown> ? TMutationKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
|
|
1172
|
+
type MutationStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
1173
|
+
type MutationScope = {
|
|
1174
|
+
id: string;
|
|
1175
|
+
};
|
|
1176
|
+
type MutationMeta = Register extends {
|
|
1177
|
+
mutationMeta: infer TMutationMeta;
|
|
1178
|
+
} ? TMutationMeta extends Record<string, unknown> ? TMutationMeta : Record<string, unknown> : Record<string, unknown>;
|
|
1179
|
+
type MutationFunctionContext = {
|
|
1180
|
+
client: QueryClient;
|
|
1181
|
+
meta: MutationMeta | undefined;
|
|
1182
|
+
mutationKey?: MutationKey;
|
|
1183
|
+
};
|
|
1184
|
+
type MutationFunction<TData = unknown, TVariables = unknown> = (variables: TVariables, context: MutationFunctionContext) => Promise<TData>;
|
|
1185
|
+
interface MutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
|
|
1186
|
+
mutationFn?: MutationFunction<TData, TVariables>;
|
|
1187
|
+
mutationKey?: MutationKey;
|
|
1188
|
+
onMutate?: (variables: TVariables, context: MutationFunctionContext) => Promise<TOnMutateResult> | TOnMutateResult;
|
|
1189
|
+
onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1190
|
+
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1191
|
+
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1192
|
+
retry?: RetryValue<TError>;
|
|
1193
|
+
retryDelay?: RetryDelayValue<TError>;
|
|
1194
|
+
networkMode?: NetworkMode;
|
|
1195
|
+
gcTime?: number;
|
|
1196
|
+
_defaulted?: boolean;
|
|
1197
|
+
meta?: MutationMeta;
|
|
1198
|
+
scope?: MutationScope;
|
|
1199
|
+
}
|
|
1200
|
+
interface MutationObserverOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
1201
|
+
throwOnError?: boolean | ((error: TError) => boolean);
|
|
1202
|
+
}
|
|
1203
|
+
interface MutateOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
|
|
1204
|
+
onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1205
|
+
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1206
|
+
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1207
|
+
}
|
|
1208
|
+
type MutateFunctionRest<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = undefined extends TVariables ? [variables?: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>] : [variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>];
|
|
1209
|
+
type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (...rest: MutateFunctionRest<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
|
|
1210
|
+
interface MutationObserverBaseResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationState<TData, TError, TVariables, TOnMutateResult> {
|
|
1211
|
+
/**
|
|
1212
|
+
* The last successfully resolved data for the mutation.
|
|
1213
|
+
*/
|
|
1214
|
+
data: TData | undefined;
|
|
1215
|
+
/**
|
|
1216
|
+
* The variables object passed to the `mutationFn`.
|
|
1217
|
+
*/
|
|
1218
|
+
variables: TVariables | undefined;
|
|
1219
|
+
/**
|
|
1220
|
+
* The error object for the mutation, if an error was encountered.
|
|
1221
|
+
* - Defaults to `null`.
|
|
1222
|
+
*/
|
|
1223
|
+
error: TError | null;
|
|
1224
|
+
/**
|
|
1225
|
+
* A boolean variable derived from `status`.
|
|
1226
|
+
* - `true` if the last mutation attempt resulted in an error.
|
|
1227
|
+
*/
|
|
1228
|
+
isError: boolean;
|
|
1229
|
+
/**
|
|
1230
|
+
* A boolean variable derived from `status`.
|
|
1231
|
+
* - `true` if the mutation is in its initial state prior to executing.
|
|
1232
|
+
*/
|
|
1233
|
+
isIdle: boolean;
|
|
1234
|
+
/**
|
|
1235
|
+
* A boolean variable derived from `status`.
|
|
1236
|
+
* - `true` if the mutation is currently executing.
|
|
1237
|
+
*/
|
|
1238
|
+
isPending: boolean;
|
|
1239
|
+
/**
|
|
1240
|
+
* A boolean variable derived from `status`.
|
|
1241
|
+
* - `true` if the last mutation attempt was successful.
|
|
1242
|
+
*/
|
|
1243
|
+
isSuccess: boolean;
|
|
1244
|
+
/**
|
|
1245
|
+
* The status of the mutation.
|
|
1246
|
+
* - Will be:
|
|
1247
|
+
* - `idle` initial status prior to the mutation function executing.
|
|
1248
|
+
* - `pending` if the mutation is currently executing.
|
|
1249
|
+
* - `error` if the last mutation attempt resulted in an error.
|
|
1250
|
+
* - `success` if the last mutation attempt was successful.
|
|
1251
|
+
*/
|
|
1252
|
+
status: MutationStatus;
|
|
1253
|
+
/**
|
|
1254
|
+
* The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
|
|
1255
|
+
* @param variables - The variables object to pass to the `mutationFn`.
|
|
1256
|
+
* @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.
|
|
1257
|
+
* @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.
|
|
1258
|
+
* @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.
|
|
1259
|
+
* @remarks
|
|
1260
|
+
* - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
|
|
1261
|
+
* - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.
|
|
1262
|
+
*/
|
|
1263
|
+
mutate: MutateFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
1264
|
+
/**
|
|
1265
|
+
* A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).
|
|
1266
|
+
*/
|
|
1267
|
+
reset: () => void;
|
|
1268
|
+
}
|
|
1269
|
+
interface MutationObserverIdleResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1270
|
+
data: undefined;
|
|
1271
|
+
variables: undefined;
|
|
1272
|
+
error: null;
|
|
1273
|
+
isError: false;
|
|
1274
|
+
isIdle: true;
|
|
1275
|
+
isPending: false;
|
|
1276
|
+
isSuccess: false;
|
|
1277
|
+
status: 'idle';
|
|
1278
|
+
}
|
|
1279
|
+
interface MutationObserverLoadingResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1280
|
+
data: undefined;
|
|
1281
|
+
variables: TVariables;
|
|
1282
|
+
error: null;
|
|
1283
|
+
isError: false;
|
|
1284
|
+
isIdle: false;
|
|
1285
|
+
isPending: true;
|
|
1286
|
+
isSuccess: false;
|
|
1287
|
+
status: 'pending';
|
|
1288
|
+
}
|
|
1289
|
+
interface MutationObserverErrorResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1290
|
+
data: undefined;
|
|
1291
|
+
error: TError;
|
|
1292
|
+
variables: TVariables;
|
|
1293
|
+
isError: true;
|
|
1294
|
+
isIdle: false;
|
|
1295
|
+
isPending: false;
|
|
1296
|
+
isSuccess: false;
|
|
1297
|
+
status: 'error';
|
|
1298
|
+
}
|
|
1299
|
+
interface MutationObserverSuccessResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1300
|
+
data: TData;
|
|
1301
|
+
error: null;
|
|
1302
|
+
variables: TVariables;
|
|
1303
|
+
isError: false;
|
|
1304
|
+
isIdle: false;
|
|
1305
|
+
isPending: false;
|
|
1306
|
+
isSuccess: true;
|
|
1307
|
+
status: 'success';
|
|
1308
|
+
}
|
|
1309
|
+
type MutationObserverResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = MutationObserverIdleResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverLoadingResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverErrorResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverSuccessResult<TData, TError, TVariables, TOnMutateResult>;
|
|
1310
|
+
interface QueryClientConfig {
|
|
1311
|
+
queryCache?: QueryCache;
|
|
1312
|
+
mutationCache?: MutationCache;
|
|
1313
|
+
defaultOptions?: DefaultOptions;
|
|
1314
|
+
}
|
|
1315
|
+
interface DefaultOptions<TError = DefaultError> {
|
|
1316
|
+
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'suspense' | 'queryKey'>;
|
|
1317
|
+
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>;
|
|
1318
|
+
hydrate?: HydrateOptions['defaultOptions'];
|
|
1319
|
+
dehydrate?: DehydrateOptions;
|
|
1320
|
+
}
|
|
1321
|
+
interface CancelOptions {
|
|
1322
|
+
revert?: boolean;
|
|
1323
|
+
silent?: boolean;
|
|
1324
|
+
}
|
|
1325
|
+
interface SetDataOptions {
|
|
1326
|
+
updatedAt?: number;
|
|
1327
|
+
}
|
|
1328
|
+
type NotifyEventType = 'added' | 'removed' | 'updated' | 'observerAdded' | 'observerRemoved' | 'observerResultsUpdated' | 'observerOptionsUpdated';
|
|
1329
|
+
interface NotifyEvent {
|
|
1330
|
+
type: NotifyEventType;
|
|
1331
|
+
}
|
|
1332
|
+
//#endregion
|
|
1333
|
+
//#region src/hydration.d.ts
|
|
1334
|
+
type TransformerFn = (data: any) => any;
|
|
1335
|
+
interface DehydrateOptions {
|
|
1336
|
+
serializeData?: TransformerFn;
|
|
1337
|
+
shouldDehydrateMutation?: (mutation: Mutation) => boolean;
|
|
1338
|
+
shouldDehydrateQuery?: (query: Query) => boolean;
|
|
1339
|
+
shouldRedactErrors?: (error: unknown) => boolean;
|
|
1340
|
+
}
|
|
1341
|
+
interface HydrateOptions {
|
|
1342
|
+
defaultOptions?: {
|
|
1343
|
+
deserializeData?: TransformerFn;
|
|
1344
|
+
queries?: QueryOptions;
|
|
1345
|
+
mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>;
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
interface DehydratedMutation {
|
|
1349
|
+
mutationKey?: MutationKey;
|
|
1350
|
+
state: MutationState;
|
|
1351
|
+
meta?: MutationMeta;
|
|
1352
|
+
scope?: MutationScope;
|
|
1353
|
+
}
|
|
1354
|
+
interface DehydratedQuery {
|
|
1355
|
+
queryHash: string;
|
|
1356
|
+
queryKey: QueryKey;
|
|
1357
|
+
state: QueryState;
|
|
1358
|
+
promise?: Promise<unknown>;
|
|
1359
|
+
meta?: QueryMeta;
|
|
1360
|
+
queryType?: 'infinite';
|
|
1361
|
+
dehydratedAt?: number;
|
|
1362
|
+
}
|
|
1363
|
+
interface DehydratedState {
|
|
1364
|
+
mutations: Array<DehydratedMutation>;
|
|
1365
|
+
queries: Array<DehydratedQuery>;
|
|
1366
|
+
}
|
|
1367
|
+
declare function dehydrateQuery(query: Query, serializeData?: TransformerFn, shouldRedactErrors?: (error: unknown) => boolean): DehydratedQuery;
|
|
1368
|
+
declare function defaultShouldDehydrateMutation(mutation: Mutation): boolean;
|
|
1369
|
+
declare function defaultShouldDehydrateQuery(query: Query): boolean;
|
|
1370
|
+
declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
|
|
1371
|
+
declare function hydrate(client: QueryClient, dehydratedState: Partial<DehydratedState>, options?: HydrateOptions): void;
|
|
1372
|
+
//#endregion
|
|
1373
|
+
export { MutationObserverBaseResult as $, QueryBehavior as $n, CancelledError as $t, InfiniteData as A, partialMatchKey as An, QueryObserverOptions as At, InfiniteQueryObserverSuccessResult as B, Action as Bn, RefetchQueryFilters as Bt, FetchPreviousPageOptions as C, isPlainObject as Cn, QueryKey as Ct, GetPreviousPageParamFunction as D, matchMutation as Dn, QueryObserverBaseResult as Dt, GetNextPageParamFunction as E, keepPreviousData as En, QueryMeta as Et, InfiniteQueryObserverOptions as F, shallowEqualObjects as Fn, QueryObserverSuccessResult as Ft, InvalidateQueryFilters as G, MutationCacheNotifyEvent as Gn, StaleTime as Gt, InitialDataFunction as H, MutationState as Hn, ResetOptions as Ht, InfiniteQueryObserverPendingResult as I, shouldThrowError as In, QueryOptions as It, MutateOptions as J, FetchContext as Jn, UnsetMarker as Jt, MutateFunction as K, MutationObserver as Kn, StaleTimeFunction as Kt, InfiniteQueryObserverPlaceholderResult as L, skipToken as Ln, QueryPersister as Lt, InfiniteQueryObserverBaseResult as M, replaceEqualDeep as Mn, QueryObserverPlaceholderResult as Mt, InfiniteQueryObserverLoadingErrorResult as N, resolveQueryBoolean as Nn, QueryObserverRefetchErrorResult as Nt, InferDataFromTag as O, matchQuery as On, QueryObserverLoadingErrorResult as Ot, InfiniteQueryObserverLoadingResult as P, resolveStaleTime as Pn, QueryObserverResult as Pt, MutationMeta as Q, Query as Qn, unsetMarker as Qt, InfiniteQueryObserverRefetchErrorResult as R, sleep as Rn, QueryStatus as Rt, FetchNextPageOptions as S, isPlainArray as Sn, QueryFunctionContext as St, FetchStatus as T, isValidTimeout as Tn, QueryKeyWithDataTag as Tt, InitialPageParam as U, getDefaultState as Un, ResultOptions as Ut, InfiniteQueryPageParamsOptions as V, Mutation as Vn, Register as Vt, InvalidateOptions as W, MutationCache as Wn, SetDataOptions as Wt, MutationFunctionContext as X, FetchMeta as Xn, dataTagErrorSymbol as Xt, MutationFunction as Y, FetchDirection as Yn, WithRequired as Yt, MutationKey as Z, FetchOptions as Zn, dataTagSymbol as Zt, DefinedQueryObserverResult as _, addToStart as _n, QueriesPlaceholderDataFunction as _t, defaultShouldDehydrateQuery as a, isCancelledError as an, MutationObserverSuccessResult as at, EnsureQueryDataOptions as b, hashKey as bn, QueryExecuteOptions as bt, hydrate as c, QueryCacheNotifyEvent as cn, MutationStatus as ct, DataTag as d, QueryFilters as dn, NotifyEvent as dt, RetryDelayValue as en, QueryState as er, MutationObserverErrorResult as et, DefaultError as f, QueryTypeFilter as fn, NotifyEventType as ft, DefinedInfiniteQueryObserverResult as g, addToEnd as gn, PlaceholderDataFunction as gt, DefaultedQueryObserverOptions as h, addConsumeAwareSignal as hn, Override as ht, defaultShouldDehydrateMutation as i, createRetryer as in, MutationObserverResult as it, InfiniteQueryExecuteOptions as j, replaceData as jn, QueryObserverPendingResult as jt, InferErrorFromTag as k, noop as kn, QueryObserverLoadingResult as kt, AnyDataTag as l, QueryStore as ln, NetworkMode as lt, DefaultedInfiniteQueryObserverOptions as m, Updater as mn, OmitKeyof as mt, DehydratedState as n, Retryer as nn, QueryObserver as nr, MutationObserverLoadingResult as nt, dehydrate as o, QueryClient as on, MutationOptions as ot, DefaultOptions as p, SkipToken as pn, NotifyOnChangeProps as pt, MutateFunctionRest as q, Action$1 as qn, ThrowOnError as qt, HydrateOptions as r, canFetch as rn, MutationObserverOptions as rt, dehydrateQuery as s, QueryCache as sn, MutationScope as st, DehydrateOptions as t, RetryValue as tn, fetchState as tr, MutationObserverIdleResult as tt, CancelOptions as u, MutationFilters as un, NonUndefinedGuard as ut, DistributiveOmit as v, ensureQueryFn as vn, QueryBooleanOption as vt, FetchQueryOptions as w, isServer as wn, QueryKeyHashFunction as wt, FetchInfiniteQueryOptions as x, hashQueryKeyByOptions as xn, QueryFunction as xt, EnsureInfiniteQueryDataOptions as y, functionalUpdate as yn, QueryClientConfig as yt, InfiniteQueryObserverResult as z, timeUntilStale as zn, RefetchOptions as zt };
|
|
1374
|
+
//# sourceMappingURL=hydration-Hebl6yHM.d.ts.map
|