@tanstack/query-core 4.0.11-beta.0 → 4.1.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/cjs/focusManager.js +101 -0
- package/build/cjs/focusManager.js.map +1 -0
- package/build/cjs/hydration.js +112 -0
- package/build/cjs/hydration.js.map +1 -0
- package/build/cjs/index.js +51 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/infiniteQueryBehavior.js +160 -0
- package/build/cjs/infiniteQueryBehavior.js.map +1 -0
- package/build/cjs/infiniteQueryObserver.js +92 -0
- package/build/cjs/infiniteQueryObserver.js.map +1 -0
- package/build/cjs/logger.js +18 -0
- package/build/cjs/logger.js.map +1 -0
- package/build/cjs/mutation.js +258 -0
- package/build/cjs/mutation.js.map +1 -0
- package/build/cjs/mutationCache.js +99 -0
- package/build/cjs/mutationCache.js.map +1 -0
- package/build/cjs/mutationObserver.js +140 -0
- package/build/cjs/mutationObserver.js.map +1 -0
- package/build/cjs/notifyManager.js +114 -0
- package/build/cjs/notifyManager.js.map +1 -0
- package/build/cjs/onlineManager.js +100 -0
- package/build/cjs/onlineManager.js.map +1 -0
- package/build/cjs/queriesObserver.js +170 -0
- package/build/cjs/queriesObserver.js.map +1 -0
- package/build/cjs/query.js +474 -0
- package/build/cjs/query.js.map +1 -0
- package/build/cjs/queryCache.js +140 -0
- package/build/cjs/queryCache.js.map +1 -0
- package/build/cjs/queryClient.js +353 -0
- package/build/cjs/queryClient.js.map +1 -0
- package/build/cjs/queryObserver.js +529 -0
- package/build/cjs/queryObserver.js.map +1 -0
- package/build/cjs/removable.js +47 -0
- package/build/cjs/removable.js.map +1 -0
- package/build/cjs/retryer.js +177 -0
- package/build/cjs/retryer.js.map +1 -0
- package/build/cjs/subscribable.js +43 -0
- package/build/cjs/subscribable.js.map +1 -0
- package/build/cjs/utils.js +356 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/{lib/index.mjs → esm/index.js} +18 -1
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/stats.json +811 -0
- package/build/{lib → types/packages/query-core/src}/focusManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/hydration.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/index.d.ts +2 -2
- package/build/{lib → types/packages/query-core/src}/infiniteQueryBehavior.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/infiniteQueryObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/logger.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/logger.native.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/mutation.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/mutationCache.d.ts +6 -1
- package/build/{lib → types/packages/query-core/src}/mutationObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/notifyManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/onlineManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queriesObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/query.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queryCache.d.ts +6 -1
- package/build/{lib → types/packages/query-core/src}/queryClient.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queryObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/removable.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/retryer.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/subscribable.d.ts +0 -0
- package/build/types/packages/query-core/src/tests/focusManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/hydration.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/infiniteQueryBehavior.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/infiniteQueryObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutationCache.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutationObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutations.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/notifyManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/onlineManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queriesObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/query.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryCache.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryClient.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/utils.test.d.ts +1 -0
- package/build/{lib → types/packages/query-core/src}/types.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/utils.d.ts +0 -0
- package/build/types/tests/utils.d.ts +24 -0
- package/build/umd/index.development.js +17 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +7 -16
- package/src/index.ts +2 -2
- package/src/mutationCache.ts +7 -0
- package/src/mutationObserver.ts +9 -0
- package/src/queryCache.ts +7 -0
- package/src/queryObserver.ts +8 -0
- package/src/tests/queryObserver.test.tsx +19 -0
- package/build/lib/index.js +0 -3096
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs.map +0 -1
|
File without changes
|
|
File without changes
|
|
@@ -10,11 +10,11 @@ export { notifyManager } from './notifyManager';
|
|
|
10
10
|
export { focusManager } from './focusManager';
|
|
11
11
|
export { onlineManager } from './onlineManager';
|
|
12
12
|
export { hashQueryKey, isError, parseQueryArgs, parseFilterArgs, parseMutationFilterArgs, parseMutationArgs, } from './utils';
|
|
13
|
-
export type { MutationFilters, QueryFilters
|
|
13
|
+
export type { MutationFilters, QueryFilters } from './utils';
|
|
14
14
|
export { isCancelledError } from './retryer';
|
|
15
15
|
export { dehydrate, hydrate } from './hydration';
|
|
16
16
|
export * from './types';
|
|
17
|
-
export type { Query
|
|
17
|
+
export type { Query } from './query';
|
|
18
18
|
export type { Mutation } from './mutation';
|
|
19
19
|
export type { Logger } from './logger';
|
|
20
20
|
export type { DehydrateOptions, DehydratedState, HydrateOptions, ShouldDehydrateMutationFunction, ShouldDehydrateQueryFunction, } from './hydration';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -27,12 +27,17 @@ interface NotifyEventMutationObserverRemoved {
|
|
|
27
27
|
mutation: Mutation<any, any, any, any>;
|
|
28
28
|
observer: MutationObserver<any, any, any>;
|
|
29
29
|
}
|
|
30
|
+
interface NotifyEventMutationObserverOptionsUpdated {
|
|
31
|
+
type: 'observerOptionsUpdated';
|
|
32
|
+
mutation?: Mutation<any, any, any, any>;
|
|
33
|
+
observer: MutationObserver<any, any, any, any>;
|
|
34
|
+
}
|
|
30
35
|
interface NotifyEventMutationUpdated {
|
|
31
36
|
type: 'updated';
|
|
32
37
|
mutation: Mutation<any, any, any, any>;
|
|
33
38
|
action: Action<any, any, any, any>;
|
|
34
39
|
}
|
|
35
|
-
declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationUpdated;
|
|
40
|
+
declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated;
|
|
36
41
|
declare type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
|
|
37
42
|
export declare class MutationCache extends Subscribable<MutationCacheListener> {
|
|
38
43
|
config: MutationCacheConfig;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -35,7 +35,12 @@ interface NotifyEventQueryObserverResultsUpdated {
|
|
|
35
35
|
type: 'observerResultsUpdated';
|
|
36
36
|
query: Query<any, any, any, any>;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
interface NotifyEventQueryObserverOptionsUpdated {
|
|
39
|
+
type: 'observerOptionsUpdated';
|
|
40
|
+
query: Query<any, any, any, any>;
|
|
41
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
42
|
+
}
|
|
43
|
+
declare type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated | NotifyEventQueryObserverAdded | NotifyEventQueryObserverRemoved | NotifyEventQueryObserverResultsUpdated | NotifyEventQueryObserverOptionsUpdated;
|
|
39
44
|
declare type QueryCacheListener = (event: QueryCacheNotifyEvent) => void;
|
|
40
45
|
export declare class QueryCache extends Subscribable<QueryCacheListener> {
|
|
41
46
|
config: QueryCacheConfig;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { MutationOptions, QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
4
|
+
export declare function createQueryClient(config?: QueryClientConfig): QueryClient;
|
|
5
|
+
export declare function mockVisibilityState(value: DocumentVisibilityState): jest.SpyInstance<DocumentVisibilityState, []>;
|
|
6
|
+
export declare function mockNavigatorOnLine(value: boolean): jest.SpyInstance<boolean, []>;
|
|
7
|
+
export declare const mockLogger: {
|
|
8
|
+
log: jest.Mock<any, any>;
|
|
9
|
+
warn: jest.Mock<any, any>;
|
|
10
|
+
error: jest.Mock<any, any>;
|
|
11
|
+
};
|
|
12
|
+
export declare function queryKey(): Array<string>;
|
|
13
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
14
|
+
export declare function setActTimeout(fn: () => void, ms?: number): NodeJS.Timeout;
|
|
15
|
+
/**
|
|
16
|
+
* Assert the parameter is of a specific type.
|
|
17
|
+
*/
|
|
18
|
+
export declare const expectType: <T>(_: T) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Assert the parameter is not typed as `any`
|
|
21
|
+
*/
|
|
22
|
+
export declare const expectTypeNotAny: <T>(_: 0 extends 1 & T ? never : T) => void;
|
|
23
|
+
export declare const executeMutation: (queryClient: QueryClient, options: MutationOptions<any, any, any, any>) => Promise<unknown>;
|
|
24
|
+
export declare function setIsServer(isServer: boolean): () => void;
|
|
@@ -2203,6 +2203,14 @@
|
|
|
2203
2203
|
const prevQuery = this.currentQuery;
|
|
2204
2204
|
this.options = this.client.defaultQueryOptions(options);
|
|
2205
2205
|
|
|
2206
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2207
|
+
this.client.getQueryCache().notify({
|
|
2208
|
+
type: 'observerOptionsUpdated',
|
|
2209
|
+
query: this.currentQuery,
|
|
2210
|
+
observer: this
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2206
2214
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2207
2215
|
throw new Error('Expected enabled to be a boolean');
|
|
2208
2216
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2886,7 +2894,16 @@
|
|
|
2886
2894
|
}
|
|
2887
2895
|
|
|
2888
2896
|
setOptions(options) {
|
|
2897
|
+
const prevOptions = this.options;
|
|
2889
2898
|
this.options = this.client.defaultMutationOptions(options);
|
|
2899
|
+
|
|
2900
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2901
|
+
this.client.getMutationCache().notify({
|
|
2902
|
+
type: 'observerOptionsUpdated',
|
|
2903
|
+
mutation: this.currentMutation,
|
|
2904
|
+
observer: this
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2890
2907
|
}
|
|
2891
2908
|
|
|
2892
2909
|
onUnsubscribe() {
|