@tanstack/query-core 5.61.4 → 5.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/{hydration-mN0SLMKB.d.cts → hydration-BOBMySlm.d.cts} +14 -10
- package/build/legacy/{hydration-D-INNavI.d.ts → hydration-OMuWWX9N.d.ts} +14 -10
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.cjs +3 -1
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js +3 -1
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/{hydration-mN0SLMKB.d.cts → hydration-BOBMySlm.d.cts} +14 -10
- package/build/modern/{hydration-D-INNavI.d.ts → hydration-OMuWWX9N.d.ts} +14 -10
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.cjs +3 -1
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js +3 -1
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/build/modern/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/queryClient.ts +20 -6
- package/src/types.ts +17 -3
- package/src/utils.ts +11 -3
package/src/queryClient.ts
CHANGED
|
@@ -39,6 +39,7 @@ import type {
|
|
|
39
39
|
RefetchQueryFilters,
|
|
40
40
|
ResetOptions,
|
|
41
41
|
SetDataOptions,
|
|
42
|
+
UnsetMarker,
|
|
42
43
|
} from './types'
|
|
43
44
|
import type { QueryState } from './query'
|
|
44
45
|
import type { MutationFilters, QueryFilters, Updater } from './utils'
|
|
@@ -119,7 +120,8 @@ export class QueryClient {
|
|
|
119
120
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
120
121
|
TInferredQueryFnData = TTaggedQueryKey extends DataTag<
|
|
121
122
|
unknown,
|
|
122
|
-
infer TaggedValue
|
|
123
|
+
infer TaggedValue,
|
|
124
|
+
unknown
|
|
123
125
|
>
|
|
124
126
|
? TaggedValue
|
|
125
127
|
: TQueryFnData,
|
|
@@ -169,7 +171,8 @@ export class QueryClient {
|
|
|
169
171
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
170
172
|
TInferredQueryFnData = TTaggedQueryKey extends DataTag<
|
|
171
173
|
unknown,
|
|
172
|
-
infer TaggedValue
|
|
174
|
+
infer TaggedValue,
|
|
175
|
+
unknown
|
|
173
176
|
>
|
|
174
177
|
? TaggedValue
|
|
175
178
|
: TQueryFnData,
|
|
@@ -225,16 +228,27 @@ export class QueryClient {
|
|
|
225
228
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
226
229
|
TInferredQueryFnData = TTaggedQueryKey extends DataTag<
|
|
227
230
|
unknown,
|
|
228
|
-
infer TaggedValue
|
|
231
|
+
infer TaggedValue,
|
|
232
|
+
unknown
|
|
229
233
|
>
|
|
230
234
|
? TaggedValue
|
|
231
235
|
: TQueryFnData,
|
|
236
|
+
TInferredError = TTaggedQueryKey extends DataTag<
|
|
237
|
+
unknown,
|
|
238
|
+
unknown,
|
|
239
|
+
infer TaggedError
|
|
240
|
+
>
|
|
241
|
+
? TaggedError extends UnsetMarker
|
|
242
|
+
? TError
|
|
243
|
+
: TaggedError
|
|
244
|
+
: TError,
|
|
232
245
|
>(
|
|
233
246
|
queryKey: TTaggedQueryKey,
|
|
234
|
-
): QueryState<TInferredQueryFnData,
|
|
247
|
+
): QueryState<TInferredQueryFnData, TInferredError> | undefined {
|
|
235
248
|
const options = this.defaultQueryOptions({ queryKey })
|
|
236
|
-
return this.#queryCache.get<TInferredQueryFnData,
|
|
237
|
-
|
|
249
|
+
return this.#queryCache.get<TInferredQueryFnData, TInferredError>(
|
|
250
|
+
options.queryHash,
|
|
251
|
+
)?.state
|
|
238
252
|
}
|
|
239
253
|
|
|
240
254
|
removeQueries(filters?: QueryFilters): void {
|
package/src/types.ts
CHANGED
|
@@ -43,8 +43,12 @@ export type DefaultError = Register extends {
|
|
|
43
43
|
export type QueryKey = ReadonlyArray<unknown>
|
|
44
44
|
|
|
45
45
|
export declare const dataTagSymbol: unique symbol
|
|
46
|
-
export
|
|
46
|
+
export declare const dataTagErrorSymbol: unique symbol
|
|
47
|
+
export declare const unsetMarker: unique symbol
|
|
48
|
+
export type UnsetMarker = typeof unsetMarker
|
|
49
|
+
export type DataTag<TType, TValue, TError = UnsetMarker> = TType & {
|
|
47
50
|
[dataTagSymbol]: TValue
|
|
51
|
+
[dataTagErrorSymbol]: TError
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export type QueryFunction<
|
|
@@ -534,11 +538,21 @@ export interface RefetchOptions extends ResultOptions {
|
|
|
534
538
|
cancelRefetch?: boolean
|
|
535
539
|
}
|
|
536
540
|
|
|
537
|
-
export interface InvalidateQueryFilters
|
|
541
|
+
export interface InvalidateQueryFilters<
|
|
542
|
+
TQueryFnData = unknown,
|
|
543
|
+
TError = DefaultError,
|
|
544
|
+
TData = TQueryFnData,
|
|
545
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
546
|
+
> extends QueryFilters<TQueryFnData, TError, TData, TQueryKey> {
|
|
538
547
|
refetchType?: QueryTypeFilter | 'none'
|
|
539
548
|
}
|
|
540
549
|
|
|
541
|
-
export interface RefetchQueryFilters
|
|
550
|
+
export interface RefetchQueryFilters<
|
|
551
|
+
TQueryFnData = unknown,
|
|
552
|
+
TError = DefaultError,
|
|
553
|
+
TData = TQueryFnData,
|
|
554
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
555
|
+
> extends QueryFilters<TQueryFnData, TError, TData, TQueryKey> {}
|
|
542
556
|
|
|
543
557
|
export interface InvalidateOptions extends RefetchOptions {}
|
|
544
558
|
export interface ResetOptions extends RefetchOptions {}
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
DataTag,
|
|
2
3
|
DefaultError,
|
|
3
4
|
Enabled,
|
|
4
5
|
FetchStatus,
|
|
@@ -14,7 +15,12 @@ import type { FetchOptions, Query } from './query'
|
|
|
14
15
|
|
|
15
16
|
// TYPES
|
|
16
17
|
|
|
17
|
-
export interface QueryFilters
|
|
18
|
+
export interface QueryFilters<
|
|
19
|
+
TQueryFnData = unknown,
|
|
20
|
+
TError = DefaultError,
|
|
21
|
+
TData = TQueryFnData,
|
|
22
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
23
|
+
> {
|
|
18
24
|
/**
|
|
19
25
|
* Filter to active queries, inactive queries or all queries
|
|
20
26
|
*/
|
|
@@ -26,11 +32,13 @@ export interface QueryFilters {
|
|
|
26
32
|
/**
|
|
27
33
|
* Include queries matching this predicate function
|
|
28
34
|
*/
|
|
29
|
-
predicate?: (query: Query) => boolean
|
|
35
|
+
predicate?: (query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean
|
|
30
36
|
/**
|
|
31
37
|
* Include queries matching this query key
|
|
32
38
|
*/
|
|
33
|
-
queryKey?:
|
|
39
|
+
queryKey?: unknown extends TQueryFnData
|
|
40
|
+
? QueryKey
|
|
41
|
+
: QueryKey & DataTag<unknown, TQueryFnData, TError>
|
|
34
42
|
/**
|
|
35
43
|
* Include or exclude stale queries
|
|
36
44
|
*/
|