@tanstack/query-persist-client-core 5.92.1 → 5.92.4
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/_tsup-dts-rollup.d.cts +246 -0
- package/build/legacy/_tsup-dts-rollup.d.ts +246 -0
- package/build/legacy/createPersister.d.cts +6 -87
- package/build/legacy/createPersister.d.ts +6 -87
- package/build/legacy/index.d.cts +19 -4
- package/build/legacy/index.d.ts +19 -4
- package/build/legacy/persist.d.cts +11 -61
- package/build/legacy/persist.d.ts +11 -61
- package/build/legacy/retryStrategies.d.cts +2 -11
- package/build/legacy/retryStrategies.d.ts +2 -11
- package/build/modern/_tsup-dts-rollup.d.cts +246 -0
- package/build/modern/_tsup-dts-rollup.d.ts +246 -0
- package/build/modern/createPersister.d.cts +6 -87
- package/build/modern/createPersister.d.ts +6 -87
- package/build/modern/index.d.cts +19 -4
- package/build/modern/index.d.ts +19 -4
- package/build/modern/persist.d.cts +11 -61
- package/build/modern/persist.d.ts +11 -61
- package/build/modern/retryStrategies.d.cts +2 -11
- package/build/modern/retryStrategies.d.ts +2 -11
- package/package.json +5 -6
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { DehydratedState } from '@tanstack/query-core';
|
|
2
|
+
import type { DehydrateOptions } from '@tanstack/query-core';
|
|
3
|
+
import type { HydrateOptions } from '@tanstack/query-core';
|
|
4
|
+
import { Options } from 'tsup';
|
|
5
|
+
import type { Query } from '@tanstack/query-core';
|
|
6
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
7
|
+
import type { QueryFilters } from '@tanstack/query-core';
|
|
8
|
+
import type { QueryFunctionContext } from '@tanstack/query-core';
|
|
9
|
+
import type { QueryKey } from '@tanstack/query-core';
|
|
10
|
+
import type { QueryState } from '@tanstack/query-core';
|
|
11
|
+
import { UserConfig } from 'vite';
|
|
12
|
+
|
|
13
|
+
declare interface AsyncStorage<TStorageValue = string> {
|
|
14
|
+
getItem: (key: string) => MaybePromise<TStorageValue | undefined | null>;
|
|
15
|
+
setItem: (key: string, value: TStorageValue) => MaybePromise<unknown>;
|
|
16
|
+
removeItem: (key: string) => MaybePromise<void>;
|
|
17
|
+
entries?: () => MaybePromise<Array<[key: string, value: TStorageValue]>>;
|
|
18
|
+
}
|
|
19
|
+
export { AsyncStorage }
|
|
20
|
+
export { AsyncStorage as AsyncStorage_alias_1 }
|
|
21
|
+
|
|
22
|
+
export declare function createMockPersister(): Persister;
|
|
23
|
+
|
|
24
|
+
export declare function createSpyPersister(): Persister;
|
|
25
|
+
|
|
26
|
+
export declare const default_alias: any[];
|
|
27
|
+
|
|
28
|
+
export declare const default_alias_1: any[];
|
|
29
|
+
|
|
30
|
+
export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
|
31
|
+
|
|
32
|
+
export declare const default_alias_3: UserConfig;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Warning: experimental feature.
|
|
36
|
+
* This utility function enables fine-grained query persistence.
|
|
37
|
+
* Simple add it as a `persister` parameter to `useQuery` or `defaultOptions` on `queryClient`.
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* useQuery({
|
|
41
|
+
queryKey: ['myKey'],
|
|
42
|
+
queryFn: fetcher,
|
|
43
|
+
persister: createPersister({
|
|
44
|
+
storage: localStorage,
|
|
45
|
+
}),
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
*/
|
|
49
|
+
declare function experimental_createQueryPersister<TStorageValue = string>({ storage, buster, maxAge, serialize, deserialize, prefix, refetchOnRestore, filters, }: StoragePersisterOptions<TStorageValue>): {
|
|
50
|
+
persisterFn: <T, TQueryKey extends QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => T | Promise<T>, ctx: QueryFunctionContext<TQueryKey>, query: Query) => Promise<T>;
|
|
51
|
+
persistQuery: (query: Query) => Promise<void>;
|
|
52
|
+
persistQueryByKey: (queryKey: QueryKey, queryClient: QueryClient) => Promise<void>;
|
|
53
|
+
retrieveQuery: <T>(queryHash: string, afterRestoreMacroTask?: (persistedQuery: PersistedQuery) => void) => Promise<T | undefined>;
|
|
54
|
+
persisterGc: () => Promise<void>;
|
|
55
|
+
restoreQueries: (queryClient: QueryClient, filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
56
|
+
removeQueries: (filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
export { experimental_createQueryPersister }
|
|
59
|
+
export { experimental_createQueryPersister as experimental_createQueryPersister_alias_1 }
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {Object} opts - Options for building configurations.
|
|
63
|
+
* @param {string[]} opts.entry - The entry array.
|
|
64
|
+
* @returns {import('tsup').Options}
|
|
65
|
+
*/
|
|
66
|
+
export declare function legacyConfig(opts: {
|
|
67
|
+
entry: string[];
|
|
68
|
+
}): Options;
|
|
69
|
+
|
|
70
|
+
declare type MaybePromise<T> = T | Promise<T>;
|
|
71
|
+
export { MaybePromise }
|
|
72
|
+
export { MaybePromise as MaybePromise_alias_1 }
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {Object} opts - Options for building configurations.
|
|
76
|
+
* @param {string[]} opts.entry - The entry array.
|
|
77
|
+
* @returns {import('tsup').Options}
|
|
78
|
+
*/
|
|
79
|
+
export declare function modernConfig(opts: {
|
|
80
|
+
entry: string[];
|
|
81
|
+
}): Options;
|
|
82
|
+
|
|
83
|
+
declare interface PersistedClient {
|
|
84
|
+
timestamp: number;
|
|
85
|
+
buster: string;
|
|
86
|
+
clientState: DehydratedState;
|
|
87
|
+
}
|
|
88
|
+
export { PersistedClient }
|
|
89
|
+
export { PersistedClient as PersistedClient_alias_1 }
|
|
90
|
+
|
|
91
|
+
declare interface PersistedQuery {
|
|
92
|
+
buster: string;
|
|
93
|
+
queryHash: string;
|
|
94
|
+
queryKey: QueryKey;
|
|
95
|
+
state: QueryState;
|
|
96
|
+
}
|
|
97
|
+
export { PersistedQuery }
|
|
98
|
+
export { PersistedQuery as PersistedQuery_alias_1 }
|
|
99
|
+
|
|
100
|
+
declare interface PersistedQueryClientRestoreOptions extends PersistQueryClientRootOptions {
|
|
101
|
+
/** The max-allowed age of the cache in milliseconds.
|
|
102
|
+
* If a persisted cache is found that is older than this
|
|
103
|
+
* time, it will be discarded */
|
|
104
|
+
maxAge?: number;
|
|
105
|
+
/** The options passed to the hydrate function */
|
|
106
|
+
hydrateOptions?: HydrateOptions;
|
|
107
|
+
}
|
|
108
|
+
export { PersistedQueryClientRestoreOptions }
|
|
109
|
+
export { PersistedQueryClientRestoreOptions as PersistedQueryClientRestoreOptions_alias_1 }
|
|
110
|
+
|
|
111
|
+
declare interface PersistedQueryClientSaveOptions extends PersistQueryClientRootOptions {
|
|
112
|
+
/** The options passed to the dehydrate function */
|
|
113
|
+
dehydrateOptions?: DehydrateOptions;
|
|
114
|
+
}
|
|
115
|
+
export { PersistedQueryClientSaveOptions }
|
|
116
|
+
export { PersistedQueryClientSaveOptions as PersistedQueryClientSaveOptions_alias_1 }
|
|
117
|
+
|
|
118
|
+
declare interface Persister {
|
|
119
|
+
persistClient: (persistClient: PersistedClient) => Promisable<void>;
|
|
120
|
+
restoreClient: () => Promisable<PersistedClient | undefined>;
|
|
121
|
+
removeClient: () => Promisable<void>;
|
|
122
|
+
}
|
|
123
|
+
export { Persister }
|
|
124
|
+
export { Persister as Persister_alias_1 }
|
|
125
|
+
|
|
126
|
+
declare const PERSISTER_KEY_PREFIX = "tanstack-query";
|
|
127
|
+
export { PERSISTER_KEY_PREFIX }
|
|
128
|
+
export { PERSISTER_KEY_PREFIX as PERSISTER_KEY_PREFIX_alias_1 }
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Restores persisted data to QueryCache and persists further changes.
|
|
132
|
+
*/
|
|
133
|
+
declare function persistQueryClient(props: PersistQueryClientOptions): [() => void, Promise<void>];
|
|
134
|
+
export { persistQueryClient }
|
|
135
|
+
export { persistQueryClient as persistQueryClient_alias_1 }
|
|
136
|
+
|
|
137
|
+
declare interface PersistQueryClientOptions extends PersistedQueryClientRestoreOptions, PersistedQueryClientSaveOptions, PersistQueryClientRootOptions {
|
|
138
|
+
}
|
|
139
|
+
export { PersistQueryClientOptions }
|
|
140
|
+
export { PersistQueryClientOptions as PersistQueryClientOptions_alias_1 }
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Restores persisted data to the QueryCache
|
|
144
|
+
* - data obtained from persister.restoreClient
|
|
145
|
+
* - data is hydrated using hydrateOptions
|
|
146
|
+
* If data is expired, busted, empty, or throws, it runs persister.removeClient
|
|
147
|
+
*/
|
|
148
|
+
declare function persistQueryClientRestore({ queryClient, persister, maxAge, buster, hydrateOptions, }: PersistedQueryClientRestoreOptions): Promise<void>;
|
|
149
|
+
export { persistQueryClientRestore }
|
|
150
|
+
export { persistQueryClientRestore as persistQueryClientRestore_alias_1 }
|
|
151
|
+
|
|
152
|
+
declare interface PersistQueryClientRootOptions {
|
|
153
|
+
/** The QueryClient to persist */
|
|
154
|
+
queryClient: QueryClient;
|
|
155
|
+
/** The Persister interface for storing and restoring the cache
|
|
156
|
+
* to/from a persisted location */
|
|
157
|
+
persister: Persister;
|
|
158
|
+
/** A unique string that can be used to forcefully
|
|
159
|
+
* invalidate existing caches if they do not share the same buster string */
|
|
160
|
+
buster?: string;
|
|
161
|
+
}
|
|
162
|
+
export { PersistQueryClientRootOptions }
|
|
163
|
+
export { PersistQueryClientRootOptions as PersistQueryClientRootOptions_alias_1 }
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Persists data from the QueryCache
|
|
167
|
+
* - data dehydrated using dehydrateOptions
|
|
168
|
+
* - data is persisted using persister.persistClient
|
|
169
|
+
*/
|
|
170
|
+
declare function persistQueryClientSave({ queryClient, persister, buster, dehydrateOptions, }: PersistedQueryClientSaveOptions): Promise<void>;
|
|
171
|
+
export { persistQueryClientSave }
|
|
172
|
+
export { persistQueryClientSave as persistQueryClientSave_alias_1 }
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Subscribe to QueryCache and MutationCache updates (for persisting)
|
|
176
|
+
* @returns an unsubscribe function (to discontinue monitoring)
|
|
177
|
+
*/
|
|
178
|
+
declare function persistQueryClientSubscribe(props: PersistedQueryClientSaveOptions): () => void;
|
|
179
|
+
export { persistQueryClientSubscribe }
|
|
180
|
+
export { persistQueryClientSubscribe as persistQueryClientSubscribe_alias_1 }
|
|
181
|
+
|
|
182
|
+
declare type PersistRetryer = (props: {
|
|
183
|
+
persistedClient: PersistedClient;
|
|
184
|
+
error: Error;
|
|
185
|
+
errorCount: number;
|
|
186
|
+
}) => PersistedClient | undefined;
|
|
187
|
+
export { PersistRetryer }
|
|
188
|
+
export { PersistRetryer as PersistRetryer_alias_1 }
|
|
189
|
+
|
|
190
|
+
declare type Promisable<T> = T | PromiseLike<T>;
|
|
191
|
+
export { Promisable }
|
|
192
|
+
export { Promisable as Promisable_alias_1 }
|
|
193
|
+
|
|
194
|
+
declare const removeOldestQuery: PersistRetryer;
|
|
195
|
+
export { removeOldestQuery }
|
|
196
|
+
export { removeOldestQuery as removeOldestQuery_alias_1 }
|
|
197
|
+
|
|
198
|
+
declare interface StoragePersisterOptions<TStorageValue = string> {
|
|
199
|
+
/** The storage client used for setting and retrieving items from cache.
|
|
200
|
+
* For SSR pass in `undefined`.
|
|
201
|
+
*/
|
|
202
|
+
storage: AsyncStorage<TStorageValue> | undefined | null;
|
|
203
|
+
/**
|
|
204
|
+
* How to serialize the data to storage.
|
|
205
|
+
* @default `JSON.stringify`
|
|
206
|
+
*/
|
|
207
|
+
serialize?: (persistedQuery: PersistedQuery) => MaybePromise<TStorageValue>;
|
|
208
|
+
/**
|
|
209
|
+
* How to deserialize the data from storage.
|
|
210
|
+
* @default `JSON.parse`
|
|
211
|
+
*/
|
|
212
|
+
deserialize?: (cachedString: TStorageValue) => MaybePromise<PersistedQuery>;
|
|
213
|
+
/**
|
|
214
|
+
* A unique string that can be used to forcefully invalidate existing caches,
|
|
215
|
+
* if they do not share the same buster string
|
|
216
|
+
*/
|
|
217
|
+
buster?: string;
|
|
218
|
+
/**
|
|
219
|
+
* The max-allowed age of the cache in milliseconds.
|
|
220
|
+
* If a persisted cache is found that is older than this
|
|
221
|
+
* time, it will be discarded
|
|
222
|
+
* @default 24 hours
|
|
223
|
+
*/
|
|
224
|
+
maxAge?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Prefix to be used for storage key.
|
|
227
|
+
* Storage key is a combination of prefix and query hash in a form of `prefix-queryHash`.
|
|
228
|
+
* @default 'tanstack-query'
|
|
229
|
+
*/
|
|
230
|
+
prefix?: string;
|
|
231
|
+
/**
|
|
232
|
+
* If set to `true`, the query will refetch on successful query restoration if the data is stale.
|
|
233
|
+
* If set to `false`, the query will not refetch on successful query restoration.
|
|
234
|
+
* If set to `'always'`, the query will always refetch on successful query restoration.
|
|
235
|
+
* Defaults to `true`.
|
|
236
|
+
*/
|
|
237
|
+
refetchOnRestore?: boolean | 'always';
|
|
238
|
+
/**
|
|
239
|
+
* Filters to narrow down which Queries should be persisted.
|
|
240
|
+
*/
|
|
241
|
+
filters?: QueryFilters;
|
|
242
|
+
}
|
|
243
|
+
export { StoragePersisterOptions }
|
|
244
|
+
export { StoragePersisterOptions as StoragePersisterOptions_alias_1 }
|
|
245
|
+
|
|
246
|
+
export { }
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { DehydratedState } from '@tanstack/query-core';
|
|
2
|
+
import type { DehydrateOptions } from '@tanstack/query-core';
|
|
3
|
+
import type { HydrateOptions } from '@tanstack/query-core';
|
|
4
|
+
import { Options } from 'tsup';
|
|
5
|
+
import type { Query } from '@tanstack/query-core';
|
|
6
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
7
|
+
import type { QueryFilters } from '@tanstack/query-core';
|
|
8
|
+
import type { QueryFunctionContext } from '@tanstack/query-core';
|
|
9
|
+
import type { QueryKey } from '@tanstack/query-core';
|
|
10
|
+
import type { QueryState } from '@tanstack/query-core';
|
|
11
|
+
import { UserConfig } from 'vite';
|
|
12
|
+
|
|
13
|
+
declare interface AsyncStorage<TStorageValue = string> {
|
|
14
|
+
getItem: (key: string) => MaybePromise<TStorageValue | undefined | null>;
|
|
15
|
+
setItem: (key: string, value: TStorageValue) => MaybePromise<unknown>;
|
|
16
|
+
removeItem: (key: string) => MaybePromise<void>;
|
|
17
|
+
entries?: () => MaybePromise<Array<[key: string, value: TStorageValue]>>;
|
|
18
|
+
}
|
|
19
|
+
export { AsyncStorage }
|
|
20
|
+
export { AsyncStorage as AsyncStorage_alias_1 }
|
|
21
|
+
|
|
22
|
+
export declare function createMockPersister(): Persister;
|
|
23
|
+
|
|
24
|
+
export declare function createSpyPersister(): Persister;
|
|
25
|
+
|
|
26
|
+
export declare const default_alias: any[];
|
|
27
|
+
|
|
28
|
+
export declare const default_alias_1: any[];
|
|
29
|
+
|
|
30
|
+
export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
|
31
|
+
|
|
32
|
+
export declare const default_alias_3: UserConfig;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Warning: experimental feature.
|
|
36
|
+
* This utility function enables fine-grained query persistence.
|
|
37
|
+
* Simple add it as a `persister` parameter to `useQuery` or `defaultOptions` on `queryClient`.
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* useQuery({
|
|
41
|
+
queryKey: ['myKey'],
|
|
42
|
+
queryFn: fetcher,
|
|
43
|
+
persister: createPersister({
|
|
44
|
+
storage: localStorage,
|
|
45
|
+
}),
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
*/
|
|
49
|
+
declare function experimental_createQueryPersister<TStorageValue = string>({ storage, buster, maxAge, serialize, deserialize, prefix, refetchOnRestore, filters, }: StoragePersisterOptions<TStorageValue>): {
|
|
50
|
+
persisterFn: <T, TQueryKey extends QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => T | Promise<T>, ctx: QueryFunctionContext<TQueryKey>, query: Query) => Promise<T>;
|
|
51
|
+
persistQuery: (query: Query) => Promise<void>;
|
|
52
|
+
persistQueryByKey: (queryKey: QueryKey, queryClient: QueryClient) => Promise<void>;
|
|
53
|
+
retrieveQuery: <T>(queryHash: string, afterRestoreMacroTask?: (persistedQuery: PersistedQuery) => void) => Promise<T | undefined>;
|
|
54
|
+
persisterGc: () => Promise<void>;
|
|
55
|
+
restoreQueries: (queryClient: QueryClient, filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
56
|
+
removeQueries: (filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
export { experimental_createQueryPersister }
|
|
59
|
+
export { experimental_createQueryPersister as experimental_createQueryPersister_alias_1 }
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {Object} opts - Options for building configurations.
|
|
63
|
+
* @param {string[]} opts.entry - The entry array.
|
|
64
|
+
* @returns {import('tsup').Options}
|
|
65
|
+
*/
|
|
66
|
+
export declare function legacyConfig(opts: {
|
|
67
|
+
entry: string[];
|
|
68
|
+
}): Options;
|
|
69
|
+
|
|
70
|
+
declare type MaybePromise<T> = T | Promise<T>;
|
|
71
|
+
export { MaybePromise }
|
|
72
|
+
export { MaybePromise as MaybePromise_alias_1 }
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {Object} opts - Options for building configurations.
|
|
76
|
+
* @param {string[]} opts.entry - The entry array.
|
|
77
|
+
* @returns {import('tsup').Options}
|
|
78
|
+
*/
|
|
79
|
+
export declare function modernConfig(opts: {
|
|
80
|
+
entry: string[];
|
|
81
|
+
}): Options;
|
|
82
|
+
|
|
83
|
+
declare interface PersistedClient {
|
|
84
|
+
timestamp: number;
|
|
85
|
+
buster: string;
|
|
86
|
+
clientState: DehydratedState;
|
|
87
|
+
}
|
|
88
|
+
export { PersistedClient }
|
|
89
|
+
export { PersistedClient as PersistedClient_alias_1 }
|
|
90
|
+
|
|
91
|
+
declare interface PersistedQuery {
|
|
92
|
+
buster: string;
|
|
93
|
+
queryHash: string;
|
|
94
|
+
queryKey: QueryKey;
|
|
95
|
+
state: QueryState;
|
|
96
|
+
}
|
|
97
|
+
export { PersistedQuery }
|
|
98
|
+
export { PersistedQuery as PersistedQuery_alias_1 }
|
|
99
|
+
|
|
100
|
+
declare interface PersistedQueryClientRestoreOptions extends PersistQueryClientRootOptions {
|
|
101
|
+
/** The max-allowed age of the cache in milliseconds.
|
|
102
|
+
* If a persisted cache is found that is older than this
|
|
103
|
+
* time, it will be discarded */
|
|
104
|
+
maxAge?: number;
|
|
105
|
+
/** The options passed to the hydrate function */
|
|
106
|
+
hydrateOptions?: HydrateOptions;
|
|
107
|
+
}
|
|
108
|
+
export { PersistedQueryClientRestoreOptions }
|
|
109
|
+
export { PersistedQueryClientRestoreOptions as PersistedQueryClientRestoreOptions_alias_1 }
|
|
110
|
+
|
|
111
|
+
declare interface PersistedQueryClientSaveOptions extends PersistQueryClientRootOptions {
|
|
112
|
+
/** The options passed to the dehydrate function */
|
|
113
|
+
dehydrateOptions?: DehydrateOptions;
|
|
114
|
+
}
|
|
115
|
+
export { PersistedQueryClientSaveOptions }
|
|
116
|
+
export { PersistedQueryClientSaveOptions as PersistedQueryClientSaveOptions_alias_1 }
|
|
117
|
+
|
|
118
|
+
declare interface Persister {
|
|
119
|
+
persistClient: (persistClient: PersistedClient) => Promisable<void>;
|
|
120
|
+
restoreClient: () => Promisable<PersistedClient | undefined>;
|
|
121
|
+
removeClient: () => Promisable<void>;
|
|
122
|
+
}
|
|
123
|
+
export { Persister }
|
|
124
|
+
export { Persister as Persister_alias_1 }
|
|
125
|
+
|
|
126
|
+
declare const PERSISTER_KEY_PREFIX = "tanstack-query";
|
|
127
|
+
export { PERSISTER_KEY_PREFIX }
|
|
128
|
+
export { PERSISTER_KEY_PREFIX as PERSISTER_KEY_PREFIX_alias_1 }
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Restores persisted data to QueryCache and persists further changes.
|
|
132
|
+
*/
|
|
133
|
+
declare function persistQueryClient(props: PersistQueryClientOptions): [() => void, Promise<void>];
|
|
134
|
+
export { persistQueryClient }
|
|
135
|
+
export { persistQueryClient as persistQueryClient_alias_1 }
|
|
136
|
+
|
|
137
|
+
declare interface PersistQueryClientOptions extends PersistedQueryClientRestoreOptions, PersistedQueryClientSaveOptions, PersistQueryClientRootOptions {
|
|
138
|
+
}
|
|
139
|
+
export { PersistQueryClientOptions }
|
|
140
|
+
export { PersistQueryClientOptions as PersistQueryClientOptions_alias_1 }
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Restores persisted data to the QueryCache
|
|
144
|
+
* - data obtained from persister.restoreClient
|
|
145
|
+
* - data is hydrated using hydrateOptions
|
|
146
|
+
* If data is expired, busted, empty, or throws, it runs persister.removeClient
|
|
147
|
+
*/
|
|
148
|
+
declare function persistQueryClientRestore({ queryClient, persister, maxAge, buster, hydrateOptions, }: PersistedQueryClientRestoreOptions): Promise<void>;
|
|
149
|
+
export { persistQueryClientRestore }
|
|
150
|
+
export { persistQueryClientRestore as persistQueryClientRestore_alias_1 }
|
|
151
|
+
|
|
152
|
+
declare interface PersistQueryClientRootOptions {
|
|
153
|
+
/** The QueryClient to persist */
|
|
154
|
+
queryClient: QueryClient;
|
|
155
|
+
/** The Persister interface for storing and restoring the cache
|
|
156
|
+
* to/from a persisted location */
|
|
157
|
+
persister: Persister;
|
|
158
|
+
/** A unique string that can be used to forcefully
|
|
159
|
+
* invalidate existing caches if they do not share the same buster string */
|
|
160
|
+
buster?: string;
|
|
161
|
+
}
|
|
162
|
+
export { PersistQueryClientRootOptions }
|
|
163
|
+
export { PersistQueryClientRootOptions as PersistQueryClientRootOptions_alias_1 }
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Persists data from the QueryCache
|
|
167
|
+
* - data dehydrated using dehydrateOptions
|
|
168
|
+
* - data is persisted using persister.persistClient
|
|
169
|
+
*/
|
|
170
|
+
declare function persistQueryClientSave({ queryClient, persister, buster, dehydrateOptions, }: PersistedQueryClientSaveOptions): Promise<void>;
|
|
171
|
+
export { persistQueryClientSave }
|
|
172
|
+
export { persistQueryClientSave as persistQueryClientSave_alias_1 }
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Subscribe to QueryCache and MutationCache updates (for persisting)
|
|
176
|
+
* @returns an unsubscribe function (to discontinue monitoring)
|
|
177
|
+
*/
|
|
178
|
+
declare function persistQueryClientSubscribe(props: PersistedQueryClientSaveOptions): () => void;
|
|
179
|
+
export { persistQueryClientSubscribe }
|
|
180
|
+
export { persistQueryClientSubscribe as persistQueryClientSubscribe_alias_1 }
|
|
181
|
+
|
|
182
|
+
declare type PersistRetryer = (props: {
|
|
183
|
+
persistedClient: PersistedClient;
|
|
184
|
+
error: Error;
|
|
185
|
+
errorCount: number;
|
|
186
|
+
}) => PersistedClient | undefined;
|
|
187
|
+
export { PersistRetryer }
|
|
188
|
+
export { PersistRetryer as PersistRetryer_alias_1 }
|
|
189
|
+
|
|
190
|
+
declare type Promisable<T> = T | PromiseLike<T>;
|
|
191
|
+
export { Promisable }
|
|
192
|
+
export { Promisable as Promisable_alias_1 }
|
|
193
|
+
|
|
194
|
+
declare const removeOldestQuery: PersistRetryer;
|
|
195
|
+
export { removeOldestQuery }
|
|
196
|
+
export { removeOldestQuery as removeOldestQuery_alias_1 }
|
|
197
|
+
|
|
198
|
+
declare interface StoragePersisterOptions<TStorageValue = string> {
|
|
199
|
+
/** The storage client used for setting and retrieving items from cache.
|
|
200
|
+
* For SSR pass in `undefined`.
|
|
201
|
+
*/
|
|
202
|
+
storage: AsyncStorage<TStorageValue> | undefined | null;
|
|
203
|
+
/**
|
|
204
|
+
* How to serialize the data to storage.
|
|
205
|
+
* @default `JSON.stringify`
|
|
206
|
+
*/
|
|
207
|
+
serialize?: (persistedQuery: PersistedQuery) => MaybePromise<TStorageValue>;
|
|
208
|
+
/**
|
|
209
|
+
* How to deserialize the data from storage.
|
|
210
|
+
* @default `JSON.parse`
|
|
211
|
+
*/
|
|
212
|
+
deserialize?: (cachedString: TStorageValue) => MaybePromise<PersistedQuery>;
|
|
213
|
+
/**
|
|
214
|
+
* A unique string that can be used to forcefully invalidate existing caches,
|
|
215
|
+
* if they do not share the same buster string
|
|
216
|
+
*/
|
|
217
|
+
buster?: string;
|
|
218
|
+
/**
|
|
219
|
+
* The max-allowed age of the cache in milliseconds.
|
|
220
|
+
* If a persisted cache is found that is older than this
|
|
221
|
+
* time, it will be discarded
|
|
222
|
+
* @default 24 hours
|
|
223
|
+
*/
|
|
224
|
+
maxAge?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Prefix to be used for storage key.
|
|
227
|
+
* Storage key is a combination of prefix and query hash in a form of `prefix-queryHash`.
|
|
228
|
+
* @default 'tanstack-query'
|
|
229
|
+
*/
|
|
230
|
+
prefix?: string;
|
|
231
|
+
/**
|
|
232
|
+
* If set to `true`, the query will refetch on successful query restoration if the data is stale.
|
|
233
|
+
* If set to `false`, the query will not refetch on successful query restoration.
|
|
234
|
+
* If set to `'always'`, the query will always refetch on successful query restoration.
|
|
235
|
+
* Defaults to `true`.
|
|
236
|
+
*/
|
|
237
|
+
refetchOnRestore?: boolean | 'always';
|
|
238
|
+
/**
|
|
239
|
+
* Filters to narrow down which Queries should be persisted.
|
|
240
|
+
*/
|
|
241
|
+
filters?: QueryFilters;
|
|
242
|
+
}
|
|
243
|
+
export { StoragePersisterOptions }
|
|
244
|
+
export { StoragePersisterOptions as StoragePersisterOptions_alias_1 }
|
|
245
|
+
|
|
246
|
+
export { }
|
|
@@ -1,87 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
state: QueryState;
|
|
8
|
-
}
|
|
9
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
-
interface AsyncStorage<TStorageValue = string> {
|
|
11
|
-
getItem: (key: string) => MaybePromise<TStorageValue | undefined | null>;
|
|
12
|
-
setItem: (key: string, value: TStorageValue) => MaybePromise<unknown>;
|
|
13
|
-
removeItem: (key: string) => MaybePromise<void>;
|
|
14
|
-
entries?: () => MaybePromise<Array<[key: string, value: TStorageValue]>>;
|
|
15
|
-
}
|
|
16
|
-
interface StoragePersisterOptions<TStorageValue = string> {
|
|
17
|
-
/** The storage client used for setting and retrieving items from cache.
|
|
18
|
-
* For SSR pass in `undefined`.
|
|
19
|
-
*/
|
|
20
|
-
storage: AsyncStorage<TStorageValue> | undefined | null;
|
|
21
|
-
/**
|
|
22
|
-
* How to serialize the data to storage.
|
|
23
|
-
* @default `JSON.stringify`
|
|
24
|
-
*/
|
|
25
|
-
serialize?: (persistedQuery: PersistedQuery) => MaybePromise<TStorageValue>;
|
|
26
|
-
/**
|
|
27
|
-
* How to deserialize the data from storage.
|
|
28
|
-
* @default `JSON.parse`
|
|
29
|
-
*/
|
|
30
|
-
deserialize?: (cachedString: TStorageValue) => MaybePromise<PersistedQuery>;
|
|
31
|
-
/**
|
|
32
|
-
* A unique string that can be used to forcefully invalidate existing caches,
|
|
33
|
-
* if they do not share the same buster string
|
|
34
|
-
*/
|
|
35
|
-
buster?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The max-allowed age of the cache in milliseconds.
|
|
38
|
-
* If a persisted cache is found that is older than this
|
|
39
|
-
* time, it will be discarded
|
|
40
|
-
* @default 24 hours
|
|
41
|
-
*/
|
|
42
|
-
maxAge?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Prefix to be used for storage key.
|
|
45
|
-
* Storage key is a combination of prefix and query hash in a form of `prefix-queryHash`.
|
|
46
|
-
* @default 'tanstack-query'
|
|
47
|
-
*/
|
|
48
|
-
prefix?: string;
|
|
49
|
-
/**
|
|
50
|
-
* If set to `true`, the query will refetch on successful query restoration if the data is stale.
|
|
51
|
-
* If set to `false`, the query will not refetch on successful query restoration.
|
|
52
|
-
* If set to `'always'`, the query will always refetch on successful query restoration.
|
|
53
|
-
* Defaults to `true`.
|
|
54
|
-
*/
|
|
55
|
-
refetchOnRestore?: boolean | 'always';
|
|
56
|
-
/**
|
|
57
|
-
* Filters to narrow down which Queries should be persisted.
|
|
58
|
-
*/
|
|
59
|
-
filters?: QueryFilters;
|
|
60
|
-
}
|
|
61
|
-
declare const PERSISTER_KEY_PREFIX = "tanstack-query";
|
|
62
|
-
/**
|
|
63
|
-
* Warning: experimental feature.
|
|
64
|
-
* This utility function enables fine-grained query persistence.
|
|
65
|
-
* Simple add it as a `persister` parameter to `useQuery` or `defaultOptions` on `queryClient`.
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
68
|
-
* useQuery({
|
|
69
|
-
queryKey: ['myKey'],
|
|
70
|
-
queryFn: fetcher,
|
|
71
|
-
persister: createPersister({
|
|
72
|
-
storage: localStorage,
|
|
73
|
-
}),
|
|
74
|
-
})
|
|
75
|
-
```
|
|
76
|
-
*/
|
|
77
|
-
declare function experimental_createQueryPersister<TStorageValue = string>({ storage, buster, maxAge, serialize, deserialize, prefix, refetchOnRestore, filters, }: StoragePersisterOptions<TStorageValue>): {
|
|
78
|
-
persisterFn: <T, TQueryKey extends QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => T | Promise<T>, ctx: QueryFunctionContext<TQueryKey>, query: Query) => Promise<T>;
|
|
79
|
-
persistQuery: (query: Query) => Promise<void>;
|
|
80
|
-
persistQueryByKey: (queryKey: QueryKey, queryClient: QueryClient) => Promise<void>;
|
|
81
|
-
retrieveQuery: <T>(queryHash: string, afterRestoreMacroTask?: (persistedQuery: PersistedQuery) => void) => Promise<T | undefined>;
|
|
82
|
-
persisterGc: () => Promise<void>;
|
|
83
|
-
restoreQueries: (queryClient: QueryClient, filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
84
|
-
removeQueries: (filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { type AsyncStorage, type MaybePromise, PERSISTER_KEY_PREFIX, type PersistedQuery, type StoragePersisterOptions, experimental_createQueryPersister };
|
|
1
|
+
export { experimental_createQueryPersister } from './_tsup-dts-rollup.cjs';
|
|
2
|
+
export { PersistedQuery } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { MaybePromise } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { AsyncStorage } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { StoragePersisterOptions } from './_tsup-dts-rollup.cjs';
|
|
6
|
+
export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.cjs';
|
|
@@ -1,87 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
state: QueryState;
|
|
8
|
-
}
|
|
9
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
-
interface AsyncStorage<TStorageValue = string> {
|
|
11
|
-
getItem: (key: string) => MaybePromise<TStorageValue | undefined | null>;
|
|
12
|
-
setItem: (key: string, value: TStorageValue) => MaybePromise<unknown>;
|
|
13
|
-
removeItem: (key: string) => MaybePromise<void>;
|
|
14
|
-
entries?: () => MaybePromise<Array<[key: string, value: TStorageValue]>>;
|
|
15
|
-
}
|
|
16
|
-
interface StoragePersisterOptions<TStorageValue = string> {
|
|
17
|
-
/** The storage client used for setting and retrieving items from cache.
|
|
18
|
-
* For SSR pass in `undefined`.
|
|
19
|
-
*/
|
|
20
|
-
storage: AsyncStorage<TStorageValue> | undefined | null;
|
|
21
|
-
/**
|
|
22
|
-
* How to serialize the data to storage.
|
|
23
|
-
* @default `JSON.stringify`
|
|
24
|
-
*/
|
|
25
|
-
serialize?: (persistedQuery: PersistedQuery) => MaybePromise<TStorageValue>;
|
|
26
|
-
/**
|
|
27
|
-
* How to deserialize the data from storage.
|
|
28
|
-
* @default `JSON.parse`
|
|
29
|
-
*/
|
|
30
|
-
deserialize?: (cachedString: TStorageValue) => MaybePromise<PersistedQuery>;
|
|
31
|
-
/**
|
|
32
|
-
* A unique string that can be used to forcefully invalidate existing caches,
|
|
33
|
-
* if they do not share the same buster string
|
|
34
|
-
*/
|
|
35
|
-
buster?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The max-allowed age of the cache in milliseconds.
|
|
38
|
-
* If a persisted cache is found that is older than this
|
|
39
|
-
* time, it will be discarded
|
|
40
|
-
* @default 24 hours
|
|
41
|
-
*/
|
|
42
|
-
maxAge?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Prefix to be used for storage key.
|
|
45
|
-
* Storage key is a combination of prefix and query hash in a form of `prefix-queryHash`.
|
|
46
|
-
* @default 'tanstack-query'
|
|
47
|
-
*/
|
|
48
|
-
prefix?: string;
|
|
49
|
-
/**
|
|
50
|
-
* If set to `true`, the query will refetch on successful query restoration if the data is stale.
|
|
51
|
-
* If set to `false`, the query will not refetch on successful query restoration.
|
|
52
|
-
* If set to `'always'`, the query will always refetch on successful query restoration.
|
|
53
|
-
* Defaults to `true`.
|
|
54
|
-
*/
|
|
55
|
-
refetchOnRestore?: boolean | 'always';
|
|
56
|
-
/**
|
|
57
|
-
* Filters to narrow down which Queries should be persisted.
|
|
58
|
-
*/
|
|
59
|
-
filters?: QueryFilters;
|
|
60
|
-
}
|
|
61
|
-
declare const PERSISTER_KEY_PREFIX = "tanstack-query";
|
|
62
|
-
/**
|
|
63
|
-
* Warning: experimental feature.
|
|
64
|
-
* This utility function enables fine-grained query persistence.
|
|
65
|
-
* Simple add it as a `persister` parameter to `useQuery` or `defaultOptions` on `queryClient`.
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
68
|
-
* useQuery({
|
|
69
|
-
queryKey: ['myKey'],
|
|
70
|
-
queryFn: fetcher,
|
|
71
|
-
persister: createPersister({
|
|
72
|
-
storage: localStorage,
|
|
73
|
-
}),
|
|
74
|
-
})
|
|
75
|
-
```
|
|
76
|
-
*/
|
|
77
|
-
declare function experimental_createQueryPersister<TStorageValue = string>({ storage, buster, maxAge, serialize, deserialize, prefix, refetchOnRestore, filters, }: StoragePersisterOptions<TStorageValue>): {
|
|
78
|
-
persisterFn: <T, TQueryKey extends QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => T | Promise<T>, ctx: QueryFunctionContext<TQueryKey>, query: Query) => Promise<T>;
|
|
79
|
-
persistQuery: (query: Query) => Promise<void>;
|
|
80
|
-
persistQueryByKey: (queryKey: QueryKey, queryClient: QueryClient) => Promise<void>;
|
|
81
|
-
retrieveQuery: <T>(queryHash: string, afterRestoreMacroTask?: (persistedQuery: PersistedQuery) => void) => Promise<T | undefined>;
|
|
82
|
-
persisterGc: () => Promise<void>;
|
|
83
|
-
restoreQueries: (queryClient: QueryClient, filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
84
|
-
removeQueries: (filters?: Pick<QueryFilters, "queryKey" | "exact">) => Promise<void>;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { type AsyncStorage, type MaybePromise, PERSISTER_KEY_PREFIX, type PersistedQuery, type StoragePersisterOptions, experimental_createQueryPersister };
|
|
1
|
+
export { experimental_createQueryPersister } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { PersistedQuery } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { MaybePromise } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { AsyncStorage } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { StoragePersisterOptions } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.js';
|