1 | import type { DocumentNode, FieldNode } from "graphql";
|
2 | import type { Transaction } from "../core/cache.js";
|
3 | import type { StoreObject, StoreValue, Reference } from "../../utilities/index.js";
|
4 | import type { FieldValueGetter } from "./entityStore.js";
|
5 | import type { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction } from "./policies.js";
|
6 | import type { Modifiers, ToReferenceFunction, CanReadFunction, AllFieldsModifier } from "../core/types/common.js";
|
7 | import type { FragmentRegistryAPI } from "./fragmentRegistry.js";
|
8 | export type { 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 |
|
16 |
|
17 |
|
18 |
|
19 | export interface NormalizedCache {
|
20 | has(dataId: string): boolean;
|
21 | get(dataId: string, fieldName: string): StoreValue;
|
22 | merge(olderId: string, newerObject: StoreObject): void;
|
23 | merge(olderObject: StoreObject, newerId: string): void;
|
24 | modify<Entity extends Record<string, any>>(dataId: string, fields: Modifiers<Entity> | AllFieldsModifier<Entity>): boolean;
|
25 | delete(dataId: string, fieldName?: string): boolean;
|
26 | clear(): void;
|
27 | |
28 |
|
29 |
|
30 | toObject(): NormalizedCacheObject;
|
31 | |
32 |
|
33 |
|
34 | replace(newData: NormalizedCacheObject): void;
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | retain(rootId: string): number;
|
44 | release(rootId: string): number;
|
45 | getFieldValue: FieldValueGetter;
|
46 | toReference: ToReferenceFunction;
|
47 | canRead: CanReadFunction;
|
48 | getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
|
49 | }
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export interface NormalizedCacheObject {
|
55 | __META?: {
|
56 | extraRootIds: string[];
|
57 | };
|
58 | [dataId: string]: StoreObject | undefined;
|
59 | }
|
60 | export type OptimisticStoreItem = {
|
61 | id: string;
|
62 | data: NormalizedCacheObject;
|
63 | transaction: Transaction<NormalizedCacheObject>;
|
64 | };
|
65 | export type ReadQueryOptions = {
|
66 | |
67 |
|
68 |
|
69 | store: NormalizedCache;
|
70 | |
71 |
|
72 |
|
73 | query: DocumentNode;
|
74 | variables?: Object;
|
75 | previousResult?: any;
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | canonizeResults?: boolean;
|
84 | rootId?: string;
|
85 | config?: ApolloReducerConfig;
|
86 | };
|
87 | export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
|
88 | returnPartialData?: boolean;
|
89 | };
|
90 | export type ApolloReducerConfig = {
|
91 | dataIdFromObject?: KeyFieldsFunction;
|
92 | addTypename?: boolean;
|
93 | };
|
94 | export interface InMemoryCacheConfig extends ApolloReducerConfig {
|
95 | resultCaching?: boolean;
|
96 | possibleTypes?: PossibleTypesMap;
|
97 | typePolicies?: TypePolicies;
|
98 | |
99 |
|
100 |
|
101 |
|
102 | resultCacheMaxSize?: number;
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | canonizeResults?: boolean;
|
110 | fragments?: FragmentRegistryAPI;
|
111 | }
|
112 | export interface MergeInfo {
|
113 | field: FieldNode;
|
114 | typename: string | undefined;
|
115 | merge: FieldMergeFunction;
|
116 | }
|
117 | export interface MergeTree {
|
118 | info?: MergeInfo;
|
119 | map: Map<string | number, MergeTree>;
|
120 | }
|
121 | export interface ReadMergeModifyContext {
|
122 | store: NormalizedCache;
|
123 | variables?: Record<string, any>;
|
124 | varString?: string;
|
125 | }
|
126 |
|
\ | No newline at end of file |