1 | import { DocumentNode, FieldNode } from 'graphql';
|
2 | import { Transaction } from '../core/cache';
|
3 | import { StoreObject, StoreValue, Reference } from '../../utilities';
|
4 | import { FieldValueGetter } from './entityStore';
|
5 | import { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction } from './policies';
|
6 | import { Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
|
7 | import { FragmentRegistryAPI } from './fragmentRegistry';
|
8 | export { StoreObject, StoreValue, Reference };
|
9 | export interface IdGetterObj extends Object {
|
10 | __typename?: string;
|
11 | id?: string;
|
12 | _id?: string;
|
13 | }
|
14 | export declare type IdGetter = (value: IdGetterObj) => string | undefined;
|
15 | export interface NormalizedCache {
|
16 | has(dataId: string): boolean;
|
17 | get(dataId: string, fieldName: string): StoreValue;
|
18 | merge(olderId: string, newerObject: StoreObject): void;
|
19 | merge(olderObject: StoreObject, newerId: string): void;
|
20 | modify(dataId: string, fields: Modifiers | Modifier<any>): boolean;
|
21 | delete(dataId: string, fieldName?: string): boolean;
|
22 | clear(): void;
|
23 | toObject(): NormalizedCacheObject;
|
24 | replace(newData: NormalizedCacheObject): void;
|
25 | retain(rootId: string): number;
|
26 | release(rootId: string): number;
|
27 | getFieldValue: FieldValueGetter;
|
28 | toReference: ToReferenceFunction;
|
29 | canRead: CanReadFunction;
|
30 | getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
|
31 | }
|
32 | export interface NormalizedCacheObject {
|
33 | __META?: {
|
34 | extraRootIds: string[];
|
35 | };
|
36 | [dataId: string]: StoreObject | undefined;
|
37 | }
|
38 | export type OptimisticStoreItem = {
|
39 | id: string;
|
40 | data: NormalizedCacheObject;
|
41 | transaction: Transaction<NormalizedCacheObject>;
|
42 | };
|
43 | export type ReadQueryOptions = {
|
44 | store: NormalizedCache;
|
45 | query: DocumentNode;
|
46 | variables?: Object;
|
47 | previousResult?: any;
|
48 | canonizeResults?: boolean;
|
49 | rootId?: string;
|
50 | config?: ApolloReducerConfig;
|
51 | };
|
52 | export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
|
53 | returnPartialData?: boolean;
|
54 | };
|
55 | export type ApolloReducerConfig = {
|
56 | dataIdFromObject?: KeyFieldsFunction;
|
57 | addTypename?: boolean;
|
58 | };
|
59 | export interface InMemoryCacheConfig extends ApolloReducerConfig {
|
60 | resultCaching?: boolean;
|
61 | possibleTypes?: PossibleTypesMap;
|
62 | typePolicies?: TypePolicies;
|
63 | resultCacheMaxSize?: number;
|
64 | canonizeResults?: boolean;
|
65 | fragments?: FragmentRegistryAPI;
|
66 | }
|
67 | export interface MergeInfo {
|
68 | field: FieldNode;
|
69 | typename: string | undefined;
|
70 | merge: FieldMergeFunction;
|
71 | }
|
72 | export interface MergeTree {
|
73 | info?: MergeInfo;
|
74 | map: Map<string | number, MergeTree>;
|
75 | }
|
76 | export interface ReadMergeModifyContext {
|
77 | store: NormalizedCache;
|
78 | variables?: Record<string, any>;
|
79 | varString?: string;
|
80 | }
|
81 |
|
\ | No newline at end of file |