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