UNPKG

3 kBTypeScriptView Raw
1import "./fixPolyfills.js";
2import type { DocumentNode } from "graphql";
3import { ApolloCache } from "../core/cache.js";
4import type { Cache } from "../core/types/Cache.js";
5import type { StoreObject, Reference } from "../../utilities/index.js";
6import type { InMemoryCacheConfig, NormalizedCacheObject } from "./types.js";
7import { makeVar } from "./reactiveVars.js";
8import { Policies } from "./policies.js";
9import type { OperationVariables } from "../../core/index.js";
10import { getInMemoryCacheMemoryInternals } from "../../utilities/caching/getMemoryInternals.js";
11type BroadcastOptions = Pick<Cache.BatchOptions<InMemoryCache>, "optimistic" | "onWatchUpdated">;
12export declare class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
13 private data;
14 private optimisticData;
15 protected config: InMemoryCacheConfig;
16 private watches;
17 private addTypename;
18 private storeReader;
19 private storeWriter;
20 private addTypenameTransform;
21 private maybeBroadcastWatch;
22 readonly assumeImmutableResults = true;
23 readonly policies: Policies;
24 readonly makeVar: typeof makeVar;
25 constructor(config?: InMemoryCacheConfig);
26 private init;
27 private resetResultCache;
28 restore(data: NormalizedCacheObject): this;
29 extract(optimistic?: boolean): NormalizedCacheObject;
30 read<T>(options: Cache.ReadOptions): T | null;
31 write(options: Cache.WriteOptions): Reference | undefined;
32 modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache.ModifyOptions<Entity>): boolean;
33 diff<TData, TVariables extends OperationVariables = any>(options: Cache.DiffOptions<TData, TVariables>): Cache.DiffResult<TData>;
34 watch<TData = any, TVariables = any>(watch: Cache.WatchOptions<TData, TVariables>): () => void;
35 gc(options?: {
36 resetResultCache?: boolean;
37 resetResultIdentities?: boolean;
38 }): string[];
39 retain(rootId: string, optimistic?: boolean): number;
40 release(rootId: string, optimistic?: boolean): number;
41 identify(object: StoreObject | Reference): string | undefined;
42 evict(options: Cache.EvictOptions): boolean;
43 reset(options?: Cache.ResetOptions): Promise<void>;
44 removeOptimistic(idToRemove: string): void;
45 private txCount;
46 batch<TUpdateResult>(options: Cache.BatchOptions<InMemoryCache, TUpdateResult>): TUpdateResult;
47 performTransaction(update: (cache: InMemoryCache) => any, optimisticId?: string | null): any;
48 transformDocument(document: DocumentNode): DocumentNode;
49 protected broadcastWatches(options?: BroadcastOptions): void;
50 private addFragmentsToDocument;
51 private addTypenameToDocument;
52 private broadcastWatch;
53 /**
54 * @experimental
55 * @internal
56 * This is not a stable API - it is used in development builds to expose
57 * information to the DevTools.
58 * Use at your own risk!
59 */
60 getMemoryInternals?: typeof getInMemoryCacheMemoryInternals;
61}
62export {};
63//# sourceMappingURL=inMemoryCache.d.ts.map
\No newline at end of file