@tanstack/query-core 5.28.6 → 5.28.9
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.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.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.js.map +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.cjs.map +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/{queryClient-6vLRMq5C.d.ts → queryClient-Iu1tSaKE.d.ts} +7 -6
- package/build/legacy/{queryClient-C_S9rQE6.d.cts → queryClient-nKFaeeO2.d.cts} +7 -6
- package/build/legacy/queryClient.cjs +2 -2
- 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 +2 -2
- 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.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- 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.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.js.map +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.cjs.map +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/{queryClient-6vLRMq5C.d.ts → queryClient-Iu1tSaKE.d.ts} +7 -6
- package/build/modern/{queryClient-C_S9rQE6.d.cts → queryClient-nKFaeeO2.d.cts} +7 -6
- package/build/modern/queryClient.cjs +2 -2
- 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 +2 -2
- 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.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/OmitKeyof.test-d.ts +59 -0
- package/src/infiniteQueryBehavior.ts +2 -1
- package/src/query.ts +6 -2
- package/src/queryClient.ts +14 -13
- package/src/types.ts +13 -2
package/build/modern/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aJ as CancelOptions, v as DataTag, D as DefaultError, aI as DefaultOptions, $ as DefaultedInfiniteQueryObserverOptions, Z as DefaultedQueryObserverOptions, ar as DefinedInfiniteQueryObserverResult, aj as DefinedQueryObserverResult, a1 as EnsureQueryDataOptions, a2 as FetchInfiniteQueryOptions, a9 as FetchNextPageOptions, aa as FetchPreviousPageOptions, a0 as FetchQueryOptions, ac as FetchStatus, B as GetNextPageParamFunction, G as GetPreviousPageParamFunction, E as InfiniteData, al as InfiniteQueryObserverBaseResult, ao as InfiniteQueryObserverLoadingErrorResult, an as InfiniteQueryObserverLoadingResult, _ as InfiniteQueryObserverOptions, am as InfiniteQueryObserverPendingResult, ap as InfiniteQueryObserverRefetchErrorResult, as as InfiniteQueryObserverResult, aq as InfiniteQueryObserverSuccessResult, T as InfiniteQueryPageParamsOptions, I as InitialDataFunction, L as InitialPageParam, a7 as InvalidateOptions, a5 as InvalidateQueryFilters, aA as MutateFunction, az as MutateOptions, aw as MutationFunction, at as MutationKey, av as MutationMeta, aB as MutationObserverBaseResult, aE as MutationObserverErrorResult, aC as MutationObserverIdleResult, aD as MutationObserverLoadingResult, ay as MutationObserverOptions, aG as MutationObserverResult, aF as MutationObserverSuccessResult, ax as MutationOptions, au as MutationStatus, H as NetworkMode, N as NoInfer, aM as NotifyEvent, aL as NotifyEventType, J as NotifyOnChangeProps, O as OmitKeyof, Y as Optional, P as PlaceholderDataFunction, z as QueriesPlaceholderDataFunction, aH as QueryClientConfig, w as QueryFunction, y as QueryFunctionContext, t as QueryKey, A as QueryKeyHashFunction, F as QueryMeta, ad as QueryObserverBaseResult, ag as QueryObserverLoadingErrorResult, af as QueryObserverLoadingResult, W as QueryObserverOptions, ae as QueryObserverPendingResult, ah as QueryObserverRefetchErrorResult, ak as QueryObserverResult, ai as QueryObserverSuccessResult, K as QueryOptions, x as QueryPersister, ab as QueryStatus, a4 as RefetchOptions, a6 as RefetchQueryFilters, R as Register, a8 as ResetOptions, a3 as ResultOptions, aK as SetDataOptions, V as ThrowOnError, X as WithRequired, u as dataTagSymbol } from './queryClient-Iu1tSaKE.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/build/modern/utils.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { g as MutationFilters, j as QueryFilters,
|
|
1
|
+
export { g as MutationFilters, j as QueryFilters, aQ as QueryTypeFilter, S as SkipToken, U as Updater, b0 as addToEnd, b1 as addToStart, aS as functionalUpdate, h as hashKey, aV as hashQueryKeyByOptions, aY as isPlainArray, aZ as isPlainObject, i as isServer, aT as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aR as noop, aW as partialMatchKey, a$ as replaceData, r as replaceEqualDeep, aX as shallowEqualObjects, s as skipToken, a_ as sleep, aU as timeUntilStale } from './queryClient-nKFaeeO2.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/modern/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { g as MutationFilters, j as QueryFilters,
|
|
1
|
+
export { g as MutationFilters, j as QueryFilters, aQ as QueryTypeFilter, S as SkipToken, U as Updater, b0 as addToEnd, b1 as addToStart, aS as functionalUpdate, h as hashKey, aV as hashQueryKeyByOptions, aY as isPlainArray, aZ as isPlainObject, i as isServer, aT as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aR as noop, aW as partialMatchKey, a$ as replaceData, r as replaceEqualDeep, aX as shallowEqualObjects, s as skipToken, a_ as sleep, aU as timeUntilStale } from './queryClient-Iu1tSaKE.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expectTypeOf, it } from 'vitest'
|
|
2
|
+
import type { OmitKeyof } from '..'
|
|
3
|
+
|
|
4
|
+
describe('OmitKeyof', () => {
|
|
5
|
+
it("'s type check", () => {
|
|
6
|
+
type A = {
|
|
7
|
+
x: string
|
|
8
|
+
y: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type ExpectedType = {
|
|
12
|
+
x: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Bad point
|
|
16
|
+
// 1. original Omit can use 'z' as type parameter with no type error
|
|
17
|
+
// 2. original Omit have no auto complete for 2nd type parameter
|
|
18
|
+
expectTypeOf<Omit<A, 'z' | 'y'>>().toEqualTypeOf<ExpectedType>()
|
|
19
|
+
|
|
20
|
+
// Solution
|
|
21
|
+
|
|
22
|
+
// 1. strictly
|
|
23
|
+
expectTypeOf<
|
|
24
|
+
OmitKeyof<
|
|
25
|
+
A,
|
|
26
|
+
// OmitKeyof can't use 'z' as type parameter with type error because A don't have key 'z'
|
|
27
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
28
|
+
'z' | 'y'
|
|
29
|
+
>
|
|
30
|
+
>().toEqualTypeOf<ExpectedType>
|
|
31
|
+
expectTypeOf<
|
|
32
|
+
OmitKeyof<
|
|
33
|
+
A,
|
|
34
|
+
// OmitKeyof can't use 'z' as type parameter with type error because A don't have key 'z'
|
|
35
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
36
|
+
'z' | 'y',
|
|
37
|
+
'strictly'
|
|
38
|
+
>
|
|
39
|
+
>().toEqualTypeOf<ExpectedType>
|
|
40
|
+
|
|
41
|
+
// 2. safely
|
|
42
|
+
expectTypeOf<
|
|
43
|
+
OmitKeyof<
|
|
44
|
+
A,
|
|
45
|
+
// OmitKeyof can't use 'z' as type parameter type error with strictly parameter or default parameter
|
|
46
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
47
|
+
'z' | 'y'
|
|
48
|
+
>
|
|
49
|
+
>().toEqualTypeOf<ExpectedType>
|
|
50
|
+
expectTypeOf<
|
|
51
|
+
OmitKeyof<
|
|
52
|
+
A,
|
|
53
|
+
// With 'safely', OmitKeyof can use 'z' as type parameter like original Omit but This support autocomplete too yet for DX.
|
|
54
|
+
'z' | 'y',
|
|
55
|
+
'safely'
|
|
56
|
+
>
|
|
57
|
+
>().toEqualTypeOf<ExpectedType>
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -3,6 +3,7 @@ import type { QueryBehavior } from './query'
|
|
|
3
3
|
import type {
|
|
4
4
|
InfiniteData,
|
|
5
5
|
InfiniteQueryPageParamsOptions,
|
|
6
|
+
OmitKeyof,
|
|
6
7
|
QueryFunctionContext,
|
|
7
8
|
QueryKey,
|
|
8
9
|
} from './types'
|
|
@@ -67,7 +68,7 @@ export function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(
|
|
|
67
68
|
return Promise.resolve(data)
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
const queryFnContext:
|
|
71
|
+
const queryFnContext: OmitKeyof<
|
|
71
72
|
QueryFunctionContext<QueryKey, unknown>,
|
|
72
73
|
'signal'
|
|
73
74
|
> = {
|
package/src/query.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
DefaultError,
|
|
8
8
|
FetchStatus,
|
|
9
9
|
InitialDataFunction,
|
|
10
|
+
OmitKeyof,
|
|
10
11
|
QueryFunctionContext,
|
|
11
12
|
QueryKey,
|
|
12
13
|
QueryMeta,
|
|
@@ -370,7 +371,10 @@ export class Query<
|
|
|
370
371
|
const abortController = new AbortController()
|
|
371
372
|
|
|
372
373
|
// Create query function context
|
|
373
|
-
const queryFnContext:
|
|
374
|
+
const queryFnContext: OmitKeyof<
|
|
375
|
+
QueryFunctionContext<TQueryKey>,
|
|
376
|
+
'signal'
|
|
377
|
+
> = {
|
|
374
378
|
queryKey: this.queryKey,
|
|
375
379
|
meta: this.meta,
|
|
376
380
|
}
|
|
@@ -421,7 +425,7 @@ export class Query<
|
|
|
421
425
|
}
|
|
422
426
|
|
|
423
427
|
// Trigger behavior hook
|
|
424
|
-
const context:
|
|
428
|
+
const context: OmitKeyof<
|
|
425
429
|
FetchContext<TQueryFnData, TError, TData, TQueryKey>,
|
|
426
430
|
'signal'
|
|
427
431
|
> = {
|
package/src/queryClient.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { focusManager } from './focusManager'
|
|
|
12
12
|
import { onlineManager } from './onlineManager'
|
|
13
13
|
import { notifyManager } from './notifyManager'
|
|
14
14
|
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
|
|
15
|
-
import type { DataTag, NoInfer } from './types'
|
|
15
|
+
import type { DataTag, NoInfer, OmitKeyof } from './types'
|
|
16
16
|
import type { QueryState } from './query'
|
|
17
17
|
import type {
|
|
18
18
|
CancelOptions,
|
|
@@ -43,7 +43,7 @@ import type { MutationFilters, QueryFilters, Updater } from './utils'
|
|
|
43
43
|
|
|
44
44
|
interface QueryDefaults {
|
|
45
45
|
queryKey: QueryKey
|
|
46
|
-
defaultOptions:
|
|
46
|
+
defaultOptions: OmitKeyof<QueryOptions<any, any, any>, 'queryKey'>
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
interface MutationDefaults {
|
|
@@ -154,12 +154,10 @@ export class QueryClient {
|
|
|
154
154
|
getQueriesData<TQueryFnData = unknown>(
|
|
155
155
|
filters: QueryFilters,
|
|
156
156
|
): Array<[QueryKey, TQueryFnData | undefined]> {
|
|
157
|
-
return this.
|
|
158
|
-
.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return [queryKey, data]
|
|
162
|
-
})
|
|
157
|
+
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
|
|
158
|
+
const data = state.data as TQueryFnData | undefined
|
|
159
|
+
return [queryKey, data]
|
|
160
|
+
})
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
setQueryData<
|
|
@@ -208,7 +206,7 @@ export class QueryClient {
|
|
|
208
206
|
options?: SetDataOptions,
|
|
209
207
|
): Array<[QueryKey, TQueryFnData | undefined]> {
|
|
210
208
|
return notifyManager.batch(() =>
|
|
211
|
-
this
|
|
209
|
+
this.#queryCache
|
|
212
210
|
.findAll(filters)
|
|
213
211
|
.map(({ queryKey }) => [
|
|
214
212
|
queryKey,
|
|
@@ -429,7 +427,7 @@ export class QueryClient {
|
|
|
429
427
|
setQueryDefaults(
|
|
430
428
|
queryKey: QueryKey,
|
|
431
429
|
options: Partial<
|
|
432
|
-
|
|
430
|
+
OmitKeyof<QueryObserverOptions<unknown, any, any, any>, 'queryKey'>
|
|
433
431
|
>,
|
|
434
432
|
): void {
|
|
435
433
|
this.#queryDefaults.set(hashKey(queryKey), {
|
|
@@ -440,10 +438,10 @@ export class QueryClient {
|
|
|
440
438
|
|
|
441
439
|
getQueryDefaults(
|
|
442
440
|
queryKey: QueryKey,
|
|
443
|
-
):
|
|
441
|
+
): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {
|
|
444
442
|
const defaults = [...this.#queryDefaults.values()]
|
|
445
443
|
|
|
446
|
-
let result:
|
|
444
|
+
let result: OmitKeyof<
|
|
447
445
|
QueryObserverOptions<any, any, any, any, any>,
|
|
448
446
|
'queryKey'
|
|
449
447
|
> = {}
|
|
@@ -458,7 +456,10 @@ export class QueryClient {
|
|
|
458
456
|
|
|
459
457
|
setMutationDefaults(
|
|
460
458
|
mutationKey: MutationKey,
|
|
461
|
-
options:
|
|
459
|
+
options: OmitKeyof<
|
|
460
|
+
MutationObserverOptions<any, any, any, any>,
|
|
461
|
+
'mutationKey'
|
|
462
|
+
>,
|
|
462
463
|
): void {
|
|
463
464
|
this.#mutationDefaults.set(hashKey(mutationKey), {
|
|
464
465
|
mutationKey,
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,14 @@ import type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'
|
|
|
7
7
|
import type { QueryCache } from './queryCache'
|
|
8
8
|
import type { MutationCache } from './mutationCache'
|
|
9
9
|
|
|
10
|
+
export type OmitKeyof<
|
|
11
|
+
TObject,
|
|
12
|
+
TKey extends TStrictly extends 'safely'
|
|
13
|
+
? keyof TObject | (string & Record<never, never>)
|
|
14
|
+
: keyof TObject,
|
|
15
|
+
TStrictly extends 'strictly' | 'safely' = 'strictly',
|
|
16
|
+
> = Omit<TObject, TKey>
|
|
17
|
+
|
|
10
18
|
export type NoInfer<T> = [T][T extends any ? 0 : never]
|
|
11
19
|
|
|
12
20
|
export interface Register {
|
|
@@ -341,7 +349,7 @@ export type Optional<TTarget, TKey extends keyof TTarget> = Pick<
|
|
|
341
349
|
Partial<TTarget>,
|
|
342
350
|
TKey
|
|
343
351
|
> &
|
|
344
|
-
|
|
352
|
+
OmitKeyof<TTarget, TKey>
|
|
345
353
|
|
|
346
354
|
export type DefaultedQueryObserverOptions<
|
|
347
355
|
TQueryFnData = unknown,
|
|
@@ -889,7 +897,10 @@ export interface QueryClientConfig {
|
|
|
889
897
|
}
|
|
890
898
|
|
|
891
899
|
export interface DefaultOptions<TError = DefaultError> {
|
|
892
|
-
queries?:
|
|
900
|
+
queries?: OmitKeyof<
|
|
901
|
+
QueryObserverOptions<unknown, TError>,
|
|
902
|
+
'suspense' | 'queryKey'
|
|
903
|
+
>
|
|
893
904
|
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>
|
|
894
905
|
}
|
|
895
906
|
|