1 | import { Trie } from "@wry/trie";
|
2 | import type { StoreValue, StoreObject, Reference } from "../../utilities/index.js";
|
3 | import type { NormalizedCache, NormalizedCacheObject } from "./types.js";
|
4 | import type { Policies, StorageType } from "./policies.js";
|
5 | import type { Cache } from "../core/types/Cache.js";
|
6 | import type { SafeReadonly, Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from "../core/types/common.js";
|
7 | import type { DocumentNode, FieldNode, SelectionSetNode } from "graphql";
|
8 | export declare abstract class EntityStore implements NormalizedCache {
|
9 | readonly policies: Policies;
|
10 | readonly group: CacheGroup;
|
11 | protected data: NormalizedCacheObject;
|
12 | constructor(policies: Policies, group: CacheGroup);
|
13 | abstract addLayer(layerId: string, replay: (layer: EntityStore) => any): Layer;
|
14 | abstract removeLayer(layerId: string): EntityStore;
|
15 | toObject(): NormalizedCacheObject;
|
16 | has(dataId: string): boolean;
|
17 | get(dataId: string, fieldName: string): StoreValue;
|
18 | protected lookup(dataId: string, dependOnExistence?: boolean): StoreObject | undefined;
|
19 | merge(older: string | StoreObject, newer: StoreObject | string): void;
|
20 | modify(dataId: string, fields: Modifier<any> | Modifiers<Record<string, any>>): boolean;
|
21 | delete(dataId: string, fieldName?: string, args?: Record<string, any>): boolean;
|
22 | evict(options: Cache.EvictOptions, limit: EntityStore): boolean;
|
23 | clear(): void;
|
24 | extract(): NormalizedCacheObject;
|
25 | replace(newData: NormalizedCacheObject | null): void;
|
26 | abstract getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
|
27 | private rootIds;
|
28 | retain(rootId: string): number;
|
29 | release(rootId: string): number;
|
30 | getRootIdSet(ids?: Set<string>): Set<string>;
|
31 | gc(): string[];
|
32 | private refs;
|
33 | findChildRefIds(dataId: string): Record<string, true>;
|
34 | /** overload for `InMemoryCache.maybeBroadcastWatch` */
|
35 | makeCacheKey(document: DocumentNode, callback: Cache.WatchCallback<any>, details: string): object;
|
36 | /** overload for `StoreReader.executeSelectionSet` */
|
37 | makeCacheKey(selectionSet: SelectionSetNode, parent: string | StoreObject, varString: string | undefined, canonizeResults: boolean): object;
|
38 | /** overload for `StoreReader.executeSubSelectedArray` */
|
39 | makeCacheKey(field: FieldNode, array: readonly any[], varString: string | undefined): object;
|
40 | /** @deprecated This is only meant for internal usage,
|
41 | * in your own code please use a `Trie` instance instead. */
|
42 | makeCacheKey(...args: any[]): object;
|
43 | getFieldValue: <T = StoreValue>(objectOrReference: StoreObject | Reference | undefined, storeFieldName: string) => SafeReadonly<T>;
|
44 | canRead: CanReadFunction;
|
45 | toReference: ToReferenceFunction;
|
46 | }
|
47 | export type FieldValueGetter = EntityStore["getFieldValue"];
|
48 | declare class CacheGroup {
|
49 | readonly caching: boolean;
|
50 | private parent;
|
51 | private d;
|
52 | keyMaker: Trie<object>;
|
53 | constructor(caching: boolean, parent?: CacheGroup | null);
|
54 | resetCaching(): void;
|
55 | depend(dataId: string, storeFieldName: string): void;
|
56 | dirty(dataId: string, storeFieldName: string): void;
|
57 | }
|
58 | export declare function maybeDependOnExistenceOfEntity(store: NormalizedCache, entityId: string): void;
|
59 | export declare namespace EntityStore {
|
60 | class Root extends EntityStore {
|
61 | constructor({ policies, resultCaching, seed, }: {
|
62 | policies: Policies;
|
63 | resultCaching?: boolean;
|
64 | seed?: NormalizedCacheObject;
|
65 | });
|
66 | readonly stump: Stump;
|
67 | addLayer(layerId: string, replay: (layer: EntityStore) => any): Layer;
|
68 | removeLayer(): Root;
|
69 | readonly storageTrie: Trie<StorageType>;
|
70 | getStorage(): StorageType;
|
71 | }
|
72 | }
|
73 | declare class Layer extends EntityStore {
|
74 | readonly id: string;
|
75 | readonly parent: EntityStore;
|
76 | readonly replay: (layer: EntityStore) => any;
|
77 | readonly group: CacheGroup;
|
78 | constructor(id: string, parent: EntityStore, replay: (layer: EntityStore) => any, group: CacheGroup);
|
79 | addLayer(layerId: string, replay: (layer: EntityStore) => any): Layer;
|
80 | removeLayer(layerId: string): EntityStore;
|
81 | toObject(): NormalizedCacheObject;
|
82 | findChildRefIds(dataId: string): Record<string, true>;
|
83 | getStorage(): StorageType;
|
84 | }
|
85 | declare class Stump extends Layer {
|
86 | constructor(root: EntityStore.Root);
|
87 | removeLayer(): this;
|
88 | merge(older: string | StoreObject, newer: string | StoreObject): void;
|
89 | }
|
90 | export declare function supportsResultCaching(store: any): store is EntityStore;
|
91 | export {};
|
92 |
|
\ | No newline at end of file |