@tanstack/query-broadcast-client-experimental 4.0.0 → 4.0.5

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.
Files changed (43) hide show
  1. package/build/cjs/node_modules/broadcast-channel/dist/es/broadcast-channel.js +260 -0
  2. package/build/cjs/node_modules/broadcast-channel/dist/es/broadcast-channel.js.map +1 -0
  3. package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js +83 -0
  4. package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js.map +1 -0
  5. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js +325 -0
  6. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js.map +1 -0
  7. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js +193 -0
  8. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js.map +1 -0
  9. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js +88 -0
  10. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js.map +1 -0
  11. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js +77 -0
  12. package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js.map +1 -0
  13. package/build/cjs/node_modules/broadcast-channel/dist/es/options.js +41 -0
  14. package/build/cjs/node_modules/broadcast-channel/dist/es/options.js.map +1 -0
  15. package/build/cjs/node_modules/broadcast-channel/dist/es/util.js +77 -0
  16. package/build/cjs/node_modules/broadcast-channel/dist/es/util.js.map +1 -0
  17. package/build/cjs/node_modules/oblivious-set/dist/es/index.js +83 -0
  18. package/build/cjs/node_modules/oblivious-set/dist/es/index.js.map +1 -0
  19. package/build/stats-html.html +1 -1
  20. package/build/stats.json +427 -0
  21. package/build/types/query-broadcast-client-experimental/src/index.d.ts +7 -0
  22. package/build/types/query-core/src/focusManager.d.ts +16 -0
  23. package/build/types/query-core/src/hydration.d.ts +34 -0
  24. package/build/types/query-core/src/index.d.ts +20 -0
  25. package/build/types/query-core/src/infiniteQueryBehavior.d.ts +15 -0
  26. package/build/types/query-core/src/infiniteQueryObserver.d.ts +18 -0
  27. package/build/types/query-core/src/logger.d.ts +8 -0
  28. package/build/types/query-core/src/mutation.d.ts +70 -0
  29. package/build/types/query-core/src/mutationCache.d.ts +52 -0
  30. package/build/types/query-core/src/mutationObserver.d.ts +23 -0
  31. package/build/types/query-core/src/notifyManager.d.ts +18 -0
  32. package/build/types/query-core/src/onlineManager.d.ts +16 -0
  33. package/build/types/query-core/src/queriesObserver.d.ts +23 -0
  34. package/build/types/query-core/src/query.d.ts +119 -0
  35. package/build/types/query-core/src/queryCache.d.ts +59 -0
  36. package/build/types/query-core/src/queryClient.d.ts +65 -0
  37. package/build/types/query-core/src/queryObserver.d.ts +61 -0
  38. package/build/types/query-core/src/removable.d.ts +9 -0
  39. package/build/types/query-core/src/retryer.d.ts +33 -0
  40. package/build/types/query-core/src/subscribable.d.ts +10 -0
  41. package/build/types/query-core/src/types.d.ts +417 -0
  42. package/build/types/query-core/src/utils.d.ts +99 -0
  43. package/package.json +2 -2
@@ -0,0 +1,427 @@
1
+ {
2
+ "version": 2,
3
+ "tree": {
4
+ "name": "root",
5
+ "children": [
6
+ {
7
+ "name": "index.production.js",
8
+ "children": [
9
+ {
10
+ "name": "node_modules",
11
+ "children": [
12
+ {
13
+ "name": "broadcast-channel/dist/es",
14
+ "children": [
15
+ {
16
+ "uid": "f3f3-117",
17
+ "name": "util.js"
18
+ },
19
+ {
20
+ "name": "methods",
21
+ "children": [
22
+ {
23
+ "uid": "f3f3-119",
24
+ "name": "native.js"
25
+ },
26
+ {
27
+ "uid": "f3f3-125",
28
+ "name": "indexed-db.js"
29
+ },
30
+ {
31
+ "uid": "f3f3-127",
32
+ "name": "localstorage.js"
33
+ },
34
+ {
35
+ "uid": "f3f3-129",
36
+ "name": "simulate.js"
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ "uid": "f3f3-123",
42
+ "name": "options.js"
43
+ },
44
+ {
45
+ "uid": "f3f3-131",
46
+ "name": "method-chooser.js"
47
+ },
48
+ {
49
+ "uid": "f3f3-133",
50
+ "name": "broadcast-channel.js"
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "name": "oblivious-set/dist/es/index.js",
56
+ "uid": "f3f3-121"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "name": "packages/query-broadcast-client-experimental/src/index.ts",
62
+ "uid": "f3f3-135"
63
+ }
64
+ ]
65
+ }
66
+ ],
67
+ "isRoot": true
68
+ },
69
+ "nodeParts": {
70
+ "f3f3-117": {
71
+ "renderedLength": 1601,
72
+ "gzipLength": 792,
73
+ "brotliLength": 0,
74
+ "mainUid": "f3f3-116"
75
+ },
76
+ "f3f3-119": {
77
+ "renderedLength": 1626,
78
+ "gzipLength": 657,
79
+ "brotliLength": 0,
80
+ "mainUid": "f3f3-118"
81
+ },
82
+ "f3f3-121": {
83
+ "renderedLength": 1973,
84
+ "gzipLength": 727,
85
+ "brotliLength": 0,
86
+ "mainUid": "f3f3-120"
87
+ },
88
+ "f3f3-123": {
89
+ "renderedLength": 1205,
90
+ "gzipLength": 474,
91
+ "brotliLength": 0,
92
+ "mainUid": "f3f3-122"
93
+ },
94
+ "f3f3-125": {
95
+ "renderedLength": 8613,
96
+ "gzipLength": 2551,
97
+ "brotliLength": 0,
98
+ "mainUid": "f3f3-124"
99
+ },
100
+ "f3f3-127": {
101
+ "renderedLength": 4823,
102
+ "gzipLength": 1838,
103
+ "brotliLength": 0,
104
+ "mainUid": "f3f3-126"
105
+ },
106
+ "f3f3-129": {
107
+ "renderedLength": 1381,
108
+ "gzipLength": 477,
109
+ "brotliLength": 0,
110
+ "mainUid": "f3f3-128"
111
+ },
112
+ "f3f3-131": {
113
+ "renderedLength": 1738,
114
+ "gzipLength": 755,
115
+ "brotliLength": 0,
116
+ "mainUid": "f3f3-130"
117
+ },
118
+ "f3f3-133": {
119
+ "renderedLength": 6028,
120
+ "gzipLength": 1726,
121
+ "brotliLength": 0,
122
+ "mainUid": "f3f3-132"
123
+ },
124
+ "f3f3-135": {
125
+ "renderedLength": 1707,
126
+ "gzipLength": 503,
127
+ "brotliLength": 0,
128
+ "mainUid": "f3f3-134"
129
+ }
130
+ },
131
+ "nodeMetas": {
132
+ "f3f3-116": {
133
+ "id": "/node_modules/broadcast-channel/dist/es/util.js",
134
+ "moduleParts": {
135
+ "index.production.js": "f3f3-117"
136
+ },
137
+ "imported": [],
138
+ "importedBy": [
139
+ {
140
+ "uid": "f3f3-132"
141
+ },
142
+ {
143
+ "uid": "f3f3-137"
144
+ },
145
+ {
146
+ "uid": "f3f3-130"
147
+ },
148
+ {
149
+ "uid": "f3f3-118"
150
+ },
151
+ {
152
+ "uid": "f3f3-124"
153
+ },
154
+ {
155
+ "uid": "f3f3-126"
156
+ },
157
+ {
158
+ "uid": "f3f3-128"
159
+ }
160
+ ]
161
+ },
162
+ "f3f3-118": {
163
+ "id": "/node_modules/broadcast-channel/dist/es/methods/native.js",
164
+ "moduleParts": {
165
+ "index.production.js": "f3f3-119"
166
+ },
167
+ "imported": [
168
+ {
169
+ "uid": "f3f3-116"
170
+ }
171
+ ],
172
+ "importedBy": [
173
+ {
174
+ "uid": "f3f3-130"
175
+ }
176
+ ]
177
+ },
178
+ "f3f3-120": {
179
+ "id": "/node_modules/oblivious-set/dist/es/index.js",
180
+ "moduleParts": {
181
+ "index.production.js": "f3f3-121"
182
+ },
183
+ "imported": [],
184
+ "importedBy": [
185
+ {
186
+ "uid": "f3f3-124"
187
+ },
188
+ {
189
+ "uid": "f3f3-126"
190
+ }
191
+ ]
192
+ },
193
+ "f3f3-122": {
194
+ "id": "/node_modules/broadcast-channel/dist/es/options.js",
195
+ "moduleParts": {
196
+ "index.production.js": "f3f3-123"
197
+ },
198
+ "imported": [],
199
+ "importedBy": [
200
+ {
201
+ "uid": "f3f3-132"
202
+ },
203
+ {
204
+ "uid": "f3f3-124"
205
+ },
206
+ {
207
+ "uid": "f3f3-126"
208
+ }
209
+ ]
210
+ },
211
+ "f3f3-124": {
212
+ "id": "/node_modules/broadcast-channel/dist/es/methods/indexed-db.js",
213
+ "moduleParts": {
214
+ "index.production.js": "f3f3-125"
215
+ },
216
+ "imported": [
217
+ {
218
+ "uid": "f3f3-116"
219
+ },
220
+ {
221
+ "uid": "f3f3-120"
222
+ },
223
+ {
224
+ "uid": "f3f3-122"
225
+ }
226
+ ],
227
+ "importedBy": [
228
+ {
229
+ "uid": "f3f3-130"
230
+ }
231
+ ]
232
+ },
233
+ "f3f3-126": {
234
+ "id": "/node_modules/broadcast-channel/dist/es/methods/localstorage.js",
235
+ "moduleParts": {
236
+ "index.production.js": "f3f3-127"
237
+ },
238
+ "imported": [
239
+ {
240
+ "uid": "f3f3-120"
241
+ },
242
+ {
243
+ "uid": "f3f3-122"
244
+ },
245
+ {
246
+ "uid": "f3f3-116"
247
+ }
248
+ ],
249
+ "importedBy": [
250
+ {
251
+ "uid": "f3f3-130"
252
+ }
253
+ ]
254
+ },
255
+ "f3f3-128": {
256
+ "id": "/node_modules/broadcast-channel/dist/es/methods/simulate.js",
257
+ "moduleParts": {
258
+ "index.production.js": "f3f3-129"
259
+ },
260
+ "imported": [
261
+ {
262
+ "uid": "f3f3-116"
263
+ }
264
+ ],
265
+ "importedBy": [
266
+ {
267
+ "uid": "f3f3-130"
268
+ }
269
+ ]
270
+ },
271
+ "f3f3-130": {
272
+ "id": "/node_modules/broadcast-channel/dist/es/method-chooser.js",
273
+ "moduleParts": {
274
+ "index.production.js": "f3f3-131"
275
+ },
276
+ "imported": [
277
+ {
278
+ "uid": "f3f3-118"
279
+ },
280
+ {
281
+ "uid": "f3f3-124"
282
+ },
283
+ {
284
+ "uid": "f3f3-126"
285
+ },
286
+ {
287
+ "uid": "f3f3-128"
288
+ },
289
+ {
290
+ "uid": "f3f3-116"
291
+ }
292
+ ],
293
+ "importedBy": [
294
+ {
295
+ "uid": "f3f3-132"
296
+ }
297
+ ]
298
+ },
299
+ "f3f3-132": {
300
+ "id": "/node_modules/broadcast-channel/dist/es/broadcast-channel.js",
301
+ "moduleParts": {
302
+ "index.production.js": "f3f3-133"
303
+ },
304
+ "imported": [
305
+ {
306
+ "uid": "f3f3-116"
307
+ },
308
+ {
309
+ "uid": "f3f3-130"
310
+ },
311
+ {
312
+ "uid": "f3f3-122"
313
+ }
314
+ ],
315
+ "importedBy": [
316
+ {
317
+ "uid": "f3f3-136"
318
+ }
319
+ ]
320
+ },
321
+ "f3f3-134": {
322
+ "id": "/packages/query-broadcast-client-experimental/src/index.ts",
323
+ "moduleParts": {
324
+ "index.production.js": "f3f3-135"
325
+ },
326
+ "imported": [
327
+ {
328
+ "uid": "f3f3-136"
329
+ }
330
+ ],
331
+ "importedBy": [],
332
+ "isEntry": true
333
+ },
334
+ "f3f3-136": {
335
+ "id": "/node_modules/broadcast-channel/dist/es/index.js",
336
+ "moduleParts": {},
337
+ "imported": [
338
+ {
339
+ "uid": "f3f3-132"
340
+ },
341
+ {
342
+ "uid": "f3f3-137"
343
+ }
344
+ ],
345
+ "importedBy": [
346
+ {
347
+ "uid": "f3f3-134"
348
+ }
349
+ ]
350
+ },
351
+ "f3f3-137": {
352
+ "id": "/node_modules/broadcast-channel/dist/es/leader-election.js",
353
+ "moduleParts": {},
354
+ "imported": [
355
+ {
356
+ "uid": "f3f3-116"
357
+ },
358
+ {
359
+ "uid": "f3f3-138"
360
+ }
361
+ ],
362
+ "importedBy": [
363
+ {
364
+ "uid": "f3f3-136"
365
+ }
366
+ ]
367
+ },
368
+ "f3f3-138": {
369
+ "id": "/node_modules/unload/dist/es/index.js",
370
+ "moduleParts": {},
371
+ "imported": [
372
+ {
373
+ "uid": "f3f3-139"
374
+ },
375
+ {
376
+ "uid": "f3f3-140"
377
+ },
378
+ {
379
+ "uid": "f3f3-141"
380
+ }
381
+ ],
382
+ "importedBy": [
383
+ {
384
+ "uid": "f3f3-137"
385
+ }
386
+ ]
387
+ },
388
+ "f3f3-139": {
389
+ "id": "/node_modules/detect-node/index.esm.js",
390
+ "moduleParts": {},
391
+ "imported": [],
392
+ "importedBy": [
393
+ {
394
+ "uid": "f3f3-138"
395
+ }
396
+ ]
397
+ },
398
+ "f3f3-140": {
399
+ "id": "/node_modules/unload/dist/es/browser.js",
400
+ "moduleParts": {},
401
+ "imported": [],
402
+ "importedBy": [
403
+ {
404
+ "uid": "f3f3-138"
405
+ }
406
+ ]
407
+ },
408
+ "f3f3-141": {
409
+ "id": "/node_modules/unload/dist/es/node.js",
410
+ "moduleParts": {},
411
+ "imported": [],
412
+ "importedBy": [
413
+ {
414
+ "uid": "f3f3-138"
415
+ }
416
+ ]
417
+ }
418
+ },
419
+ "env": {
420
+ "rollup": "2.76.0"
421
+ },
422
+ "options": {
423
+ "gzip": true,
424
+ "brotli": false,
425
+ "sourcemap": false
426
+ }
427
+ }
@@ -0,0 +1,7 @@
1
+ import type { QueryClient } from '@tanstack/query-core';
2
+ interface BroadcastQueryClientOptions {
3
+ queryClient: QueryClient;
4
+ broadcastChannel?: string;
5
+ }
6
+ export declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
7
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Subscribable } from './subscribable';
2
+ declare type SetupFn = (setFocused: (focused?: boolean) => void) => (() => void) | undefined;
3
+ export declare class FocusManager extends Subscribable {
4
+ private focused?;
5
+ private cleanup?;
6
+ private setup;
7
+ constructor();
8
+ protected onSubscribe(): void;
9
+ protected onUnsubscribe(): void;
10
+ setEventListener(setup: SetupFn): void;
11
+ setFocused(focused?: boolean): void;
12
+ onFocus(): void;
13
+ isFocused(): boolean;
14
+ }
15
+ export declare const focusManager: FocusManager;
16
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { QueryClient } from './queryClient';
2
+ import type { Query, QueryState } from './query';
3
+ import type { MutationKey, MutationOptions, QueryKey, QueryOptions } from './types';
4
+ import type { Mutation, MutationState } from './mutation';
5
+ export interface DehydrateOptions {
6
+ dehydrateMutations?: boolean;
7
+ dehydrateQueries?: boolean;
8
+ shouldDehydrateMutation?: ShouldDehydrateMutationFunction;
9
+ shouldDehydrateQuery?: ShouldDehydrateQueryFunction;
10
+ }
11
+ export interface HydrateOptions {
12
+ defaultOptions?: {
13
+ queries?: QueryOptions;
14
+ mutations?: MutationOptions;
15
+ };
16
+ }
17
+ interface DehydratedMutation {
18
+ mutationKey?: MutationKey;
19
+ state: MutationState;
20
+ }
21
+ interface DehydratedQuery {
22
+ queryHash: string;
23
+ queryKey: QueryKey;
24
+ state: QueryState;
25
+ }
26
+ export interface DehydratedState {
27
+ mutations: DehydratedMutation[];
28
+ queries: DehydratedQuery[];
29
+ }
30
+ export declare type ShouldDehydrateQueryFunction = (query: Query) => boolean;
31
+ export declare type ShouldDehydrateMutationFunction = (mutation: Mutation) => boolean;
32
+ export declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
33
+ export declare function hydrate(client: QueryClient, dehydratedState: unknown, options?: HydrateOptions): void;
34
+ export {};
@@ -0,0 +1,20 @@
1
+ export { CancelledError } from './retryer';
2
+ export { QueryCache } from './queryCache';
3
+ export { QueryClient } from './queryClient';
4
+ export { QueryObserver } from './queryObserver';
5
+ export { QueriesObserver } from './queriesObserver';
6
+ export { InfiniteQueryObserver } from './infiniteQueryObserver';
7
+ export { MutationCache } from './mutationCache';
8
+ export { MutationObserver } from './mutationObserver';
9
+ export { notifyManager } from './notifyManager';
10
+ export { focusManager } from './focusManager';
11
+ export { onlineManager } from './onlineManager';
12
+ export { hashQueryKey, isError, parseQueryArgs, parseFilterArgs, parseMutationFilterArgs, parseMutationArgs, } from './utils';
13
+ export type { MutationFilters, QueryFilters } from './utils';
14
+ export { isCancelledError } from './retryer';
15
+ export { dehydrate, hydrate } from './hydration';
16
+ export * from './types';
17
+ export type { Query } from './query';
18
+ export type { Mutation } from './mutation';
19
+ export type { Logger } from './logger';
20
+ export type { DehydrateOptions, DehydratedState, HydrateOptions, ShouldDehydrateMutationFunction, ShouldDehydrateQueryFunction, } from './hydration';
@@ -0,0 +1,15 @@
1
+ import type { QueryBehavior } from './query';
2
+ import type { InfiniteData, QueryOptions } from './types';
3
+ export declare function infiniteQueryBehavior<TQueryFnData, TError, TData>(): QueryBehavior<TQueryFnData, TError, InfiniteData<TData>>;
4
+ export declare function getNextPageParam(options: QueryOptions<any, any>, pages: unknown[]): unknown | undefined;
5
+ export declare function getPreviousPageParam(options: QueryOptions<any, any>, pages: unknown[]): unknown | undefined;
6
+ /**
7
+ * Checks if there is a next page.
8
+ * Returns `undefined` if it cannot be determined.
9
+ */
10
+ export declare function hasNextPage(options: QueryOptions<any, any, any, any>, pages?: unknown): boolean | undefined;
11
+ /**
12
+ * Checks if there is a previous page.
13
+ * Returns `undefined` if it cannot be determined.
14
+ */
15
+ export declare function hasPreviousPage(options: QueryOptions<any, any, any, any>, pages?: unknown): boolean | undefined;
@@ -0,0 +1,18 @@
1
+ import type { DefaultedInfiniteQueryObserverOptions, FetchNextPageOptions, FetchPreviousPageOptions, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, QueryKey } from './types';
2
+ import type { QueryClient } from './queryClient';
3
+ import { NotifyOptions, ObserverFetchOptions, QueryObserver } from './queryObserver';
4
+ import { Query } from './query';
5
+ declare type InfiniteQueryObserverListener<TData, TError> = (result: InfiniteQueryObserverResult<TData, TError>) => void;
6
+ export declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends QueryObserver<TQueryFnData, TError, InfiniteData<TData>, InfiniteData<TQueryData>, TQueryKey> {
7
+ subscribe: (listener?: InfiniteQueryObserverListener<TData, TError>) => () => void;
8
+ getCurrentResult: () => InfiniteQueryObserverResult<TData, TError>;
9
+ protected fetch: (fetchOptions: ObserverFetchOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
10
+ constructor(client: QueryClient, options: InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>);
11
+ protected bindMethods(): void;
12
+ setOptions(options?: InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, notifyOptions?: NotifyOptions): void;
13
+ getOptimisticResult(options: DefaultedInfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): InfiniteQueryObserverResult<TData, TError>;
14
+ fetchNextPage({ pageParam, ...options }?: FetchNextPageOptions): Promise<InfiniteQueryObserverResult<TData, TError>>;
15
+ fetchPreviousPage({ pageParam, ...options }?: FetchPreviousPageOptions): Promise<InfiniteQueryObserverResult<TData, TError>>;
16
+ protected createResult(query: Query<TQueryFnData, TError, InfiniteData<TQueryData>, TQueryKey>, options: InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): InfiniteQueryObserverResult<TData, TError>;
17
+ }
18
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface Logger {
2
+ log: LogFunction;
3
+ warn: LogFunction;
4
+ error: LogFunction;
5
+ }
6
+ declare type LogFunction = (...args: any[]) => void;
7
+ export declare const defaultLogger: Logger;
8
+ export {};
@@ -0,0 +1,70 @@
1
+ import type { MutationOptions, MutationStatus, MutationMeta } from './types';
2
+ import type { MutationCache } from './mutationCache';
3
+ import type { MutationObserver } from './mutationObserver';
4
+ import { Logger } from './logger';
5
+ import { Removable } from './removable';
6
+ interface MutationConfig<TData, TError, TVariables, TContext> {
7
+ mutationId: number;
8
+ mutationCache: MutationCache;
9
+ options: MutationOptions<TData, TError, TVariables, TContext>;
10
+ logger?: Logger;
11
+ defaultOptions?: MutationOptions<TData, TError, TVariables, TContext>;
12
+ state?: MutationState<TData, TError, TVariables, TContext>;
13
+ meta?: MutationMeta;
14
+ }
15
+ export interface MutationState<TData = unknown, TError = unknown, TVariables = void, TContext = unknown> {
16
+ context: TContext | undefined;
17
+ data: TData | undefined;
18
+ error: TError | null;
19
+ failureCount: number;
20
+ isPaused: boolean;
21
+ status: MutationStatus;
22
+ variables: TVariables | undefined;
23
+ }
24
+ interface FailedAction {
25
+ type: 'failed';
26
+ }
27
+ interface LoadingAction<TVariables, TContext> {
28
+ type: 'loading';
29
+ variables?: TVariables;
30
+ context?: TContext;
31
+ }
32
+ interface SuccessAction<TData> {
33
+ type: 'success';
34
+ data: TData;
35
+ }
36
+ interface ErrorAction<TError> {
37
+ type: 'error';
38
+ error: TError;
39
+ }
40
+ interface PauseAction {
41
+ type: 'pause';
42
+ }
43
+ interface ContinueAction {
44
+ type: 'continue';
45
+ }
46
+ interface SetStateAction<TData, TError, TVariables, TContext> {
47
+ type: 'setState';
48
+ state: MutationState<TData, TError, TVariables, TContext>;
49
+ }
50
+ export declare type Action<TData, TError, TVariables, TContext> = ContinueAction | ErrorAction<TError> | FailedAction | LoadingAction<TVariables, TContext> | PauseAction | SetStateAction<TData, TError, TVariables, TContext> | SuccessAction<TData>;
51
+ export declare class Mutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown> extends Removable {
52
+ state: MutationState<TData, TError, TVariables, TContext>;
53
+ options: MutationOptions<TData, TError, TVariables, TContext>;
54
+ mutationId: number;
55
+ meta: MutationMeta | undefined;
56
+ private observers;
57
+ private mutationCache;
58
+ private logger;
59
+ private retryer?;
60
+ constructor(config: MutationConfig<TData, TError, TVariables, TContext>);
61
+ setState(state: MutationState<TData, TError, TVariables, TContext>): void;
62
+ addObserver(observer: MutationObserver<any, any, any, any>): void;
63
+ removeObserver(observer: MutationObserver<any, any, any, any>): void;
64
+ protected optionalRemove(): void;
65
+ continue(): Promise<TData>;
66
+ execute(): Promise<TData>;
67
+ private dispatch;
68
+ }
69
+ export declare function getDefaultState<TData, TError, TVariables, TContext>(): MutationState<TData, TError, TVariables, TContext>;
70
+ export {};
@@ -0,0 +1,52 @@
1
+ import { MutationObserver } from './mutationObserver';
2
+ import type { MutationOptions } from './types';
3
+ import type { QueryClient } from './queryClient';
4
+ import { Action, Mutation, MutationState } from './mutation';
5
+ import { MutationFilters } from './utils';
6
+ import { Subscribable } from './subscribable';
7
+ interface MutationCacheConfig {
8
+ onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation<unknown, unknown, unknown>) => void;
9
+ onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation<unknown, unknown, unknown>) => void;
10
+ onMutate?: (variables: unknown, mutation: Mutation<unknown, unknown, unknown, unknown>) => void;
11
+ }
12
+ interface NotifyEventMutationAdded {
13
+ type: 'added';
14
+ mutation: Mutation<any, any, any, any>;
15
+ }
16
+ interface NotifyEventMutationRemoved {
17
+ type: 'removed';
18
+ mutation: Mutation<any, any, any, any>;
19
+ }
20
+ interface NotifyEventMutationObserverAdded {
21
+ type: 'observerAdded';
22
+ mutation: Mutation<any, any, any, any>;
23
+ observer: MutationObserver<any, any, any>;
24
+ }
25
+ interface NotifyEventMutationObserverRemoved {
26
+ type: 'observerRemoved';
27
+ mutation: Mutation<any, any, any, any>;
28
+ observer: MutationObserver<any, any, any>;
29
+ }
30
+ interface NotifyEventMutationUpdated {
31
+ type: 'updated';
32
+ mutation: Mutation<any, any, any, any>;
33
+ action: Action<any, any, any, any>;
34
+ }
35
+ declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationUpdated;
36
+ declare type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
37
+ export declare class MutationCache extends Subscribable<MutationCacheListener> {
38
+ config: MutationCacheConfig;
39
+ private mutations;
40
+ private mutationId;
41
+ constructor(config?: MutationCacheConfig);
42
+ build<TData, TError, TVariables, TContext>(client: QueryClient, options: MutationOptions<TData, TError, TVariables, TContext>, state?: MutationState<TData, TError, TVariables, TContext>): Mutation<TData, TError, TVariables, TContext>;
43
+ add(mutation: Mutation<any, any, any, any>): void;
44
+ remove(mutation: Mutation<any, any, any, any>): void;
45
+ clear(): void;
46
+ getAll(): Mutation[];
47
+ find<TData = unknown, TError = unknown, TVariables = any, TContext = unknown>(filters: MutationFilters): Mutation<TData, TError, TVariables, TContext> | undefined;
48
+ findAll(filters: MutationFilters): Mutation[];
49
+ notify(event: MutationCacheNotifyEvent): void;
50
+ resumePausedMutations(): Promise<void>;
51
+ }
52
+ export {};