houdini 1.0.0-next.3 → 1.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +1254 -1062
- package/build/cmd-esm/index.js +1254 -1062
- package/build/codegen/generators/artifacts/selection.d.ts +3 -3
- package/build/codegen/generators/artifacts/utils.d.ts +0 -1
- package/build/codegen-cjs/index.js +847 -717
- package/build/codegen-esm/index.js +847 -717
- package/build/lib/config.d.ts +10 -90
- package/build/lib/deepMerge.d.ts +1 -0
- package/build/lib/graphql.d.ts +5 -2
- package/build/lib/index.d.ts +2 -0
- package/build/lib/pipeline.d.ts +1 -1
- package/build/lib/plugin.d.ts +2 -0
- package/build/lib/types.d.ts +250 -2
- package/build/lib-cjs/index.js +351 -162
- package/build/lib-esm/index.js +349 -162
- package/build/runtime/cache/cache.d.ts +23 -6
- package/build/runtime/cache/staleManager.d.ts +30 -0
- package/build/runtime/cache/subscription.d.ts +2 -1
- package/build/runtime/client/documentStore.d.ts +1 -1
- package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime/client/plugins/subscription.d.ts +1 -2
- package/build/runtime/lib/config.d.ts +4 -0
- package/build/runtime/lib/index.d.ts +1 -0
- package/build/runtime/lib/key.d.ts +6 -0
- package/build/runtime/lib/types.d.ts +4 -5
- package/build/runtime/public/cache.d.ts +8 -1
- package/build/runtime/public/record.d.ts +11 -1
- package/build/runtime/public/tests/test.d.ts +9 -10
- package/build/runtime-cjs/cache/cache.d.ts +23 -6
- package/build/runtime-cjs/cache/cache.js +95 -21
- package/build/runtime-cjs/cache/gc.js +9 -0
- package/build/runtime-cjs/cache/lists.js +3 -3
- package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
- package/build/runtime-cjs/cache/staleManager.js +95 -0
- package/build/runtime-cjs/cache/subscription.d.ts +2 -1
- package/build/runtime-cjs/cache/subscription.js +6 -3
- package/build/runtime-cjs/client/documentStore.d.ts +1 -1
- package/build/runtime-cjs/client/documentStore.js +1 -0
- package/build/runtime-cjs/client/plugins/cache.js +5 -3
- package/build/runtime-cjs/client/plugins/fetch.js +1 -0
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetchParams.js +6 -1
- package/build/runtime-cjs/client/plugins/query.js +1 -1
- package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -2
- package/build/runtime-cjs/client/plugins/subscription.js +2 -0
- package/build/runtime-cjs/lib/config.d.ts +4 -0
- package/build/runtime-cjs/lib/index.d.ts +1 -0
- package/build/runtime-cjs/lib/index.js +1 -0
- package/build/runtime-cjs/lib/key.d.ts +6 -0
- package/build/runtime-cjs/lib/key.js +41 -0
- package/build/runtime-cjs/lib/types.d.ts +4 -5
- package/build/runtime-cjs/public/cache.d.ts +8 -1
- package/build/runtime-cjs/public/cache.js +3 -0
- package/build/runtime-cjs/public/record.d.ts +11 -1
- package/build/runtime-cjs/public/record.js +8 -1
- package/build/runtime-cjs/public/tests/test.d.ts +9 -10
- package/build/runtime-esm/cache/cache.d.ts +23 -6
- package/build/runtime-esm/cache/cache.js +96 -22
- package/build/runtime-esm/cache/gc.js +9 -0
- package/build/runtime-esm/cache/lists.js +3 -3
- package/build/runtime-esm/cache/staleManager.d.ts +30 -0
- package/build/runtime-esm/cache/staleManager.js +71 -0
- package/build/runtime-esm/cache/subscription.d.ts +2 -1
- package/build/runtime-esm/cache/subscription.js +6 -3
- package/build/runtime-esm/client/documentStore.d.ts +1 -1
- package/build/runtime-esm/client/documentStore.js +1 -0
- package/build/runtime-esm/client/plugins/cache.js +5 -3
- package/build/runtime-esm/client/plugins/fetch.js +1 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetchParams.js +6 -1
- package/build/runtime-esm/client/plugins/query.js +1 -1
- package/build/runtime-esm/client/plugins/subscription.d.ts +1 -2
- package/build/runtime-esm/client/plugins/subscription.js +2 -0
- package/build/runtime-esm/lib/config.d.ts +4 -0
- package/build/runtime-esm/lib/index.d.ts +1 -0
- package/build/runtime-esm/lib/index.js +1 -0
- package/build/runtime-esm/lib/key.d.ts +6 -0
- package/build/runtime-esm/lib/key.js +17 -0
- package/build/runtime-esm/lib/types.d.ts +4 -5
- package/build/runtime-esm/public/cache.d.ts +8 -1
- package/build/runtime-esm/public/cache.js +3 -0
- package/build/runtime-esm/public/record.d.ts +11 -1
- package/build/runtime-esm/public/record.js +8 -1
- package/build/runtime-esm/public/tests/test.d.ts +9 -10
- package/build/test-cjs/index.js +930 -788
- package/build/test-esm/index.js +930 -788
- package/build/vite-cjs/index.js +1232 -1039
- package/build/vite-esm/index.js +1232 -1039
- package/package.json +3 -2
|
@@ -4,9 +4,10 @@ import { GarbageCollector } from './gc';
|
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
6
6
|
import { SchemaManager } from './schema';
|
|
7
|
+
import { StaleManager } from './staleManager';
|
|
7
8
|
import type { Layer, LayerID } from './storage';
|
|
8
9
|
import { InMemoryStorage } from './storage';
|
|
9
|
-
import { type FieldSelection
|
|
10
|
+
import { InMemorySubscriptions, type FieldSelection } from './subscription';
|
|
10
11
|
export declare class Cache {
|
|
11
12
|
_internal_unstable: CacheInternal;
|
|
12
13
|
constructor(config?: ConfigFile);
|
|
@@ -18,19 +19,30 @@ export declare class Cache {
|
|
|
18
19
|
variables?: {};
|
|
19
20
|
parent?: string;
|
|
20
21
|
layer?: LayerID | null;
|
|
21
|
-
applyUpdates?:
|
|
22
|
+
applyUpdates?: string[];
|
|
22
23
|
notifySubscribers?: SubscriptionSpec[];
|
|
23
24
|
forceNotify?: boolean;
|
|
25
|
+
forceStale?: boolean;
|
|
24
26
|
}): SubscriptionSpec[];
|
|
25
27
|
read(...args: Parameters<CacheInternal['getSelection']>): {
|
|
26
28
|
data: GraphQLObject | null;
|
|
27
29
|
partial: boolean;
|
|
30
|
+
stale: boolean;
|
|
28
31
|
};
|
|
29
32
|
subscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
30
33
|
unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
31
34
|
list(name: string, parentID?: string, allLists?: boolean): ListCollection;
|
|
32
35
|
delete(id: string): void;
|
|
33
36
|
setConfig(config: ConfigFile): void;
|
|
37
|
+
markTypeStale(type?: string, options?: {
|
|
38
|
+
field?: string;
|
|
39
|
+
when?: {};
|
|
40
|
+
}): void;
|
|
41
|
+
markRecordStale(id: string, options: {
|
|
42
|
+
field?: string;
|
|
43
|
+
when?: {};
|
|
44
|
+
}): void;
|
|
45
|
+
getFieldTime(id: string, field: string): number | null | undefined;
|
|
34
46
|
}
|
|
35
47
|
declare class CacheInternal {
|
|
36
48
|
private _disabled;
|
|
@@ -40,17 +52,19 @@ declare class CacheInternal {
|
|
|
40
52
|
lists: ListManager;
|
|
41
53
|
cache: Cache;
|
|
42
54
|
lifetimes: GarbageCollector;
|
|
55
|
+
staleManager: StaleManager;
|
|
43
56
|
schema: SchemaManager;
|
|
44
|
-
constructor({ storage, subscriptions, lists, cache, lifetimes, schema, }: {
|
|
57
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, }: {
|
|
45
58
|
storage: InMemoryStorage;
|
|
46
59
|
subscriptions: InMemorySubscriptions;
|
|
47
60
|
lists: ListManager;
|
|
48
61
|
cache: Cache;
|
|
49
62
|
lifetimes: GarbageCollector;
|
|
63
|
+
staleManager: StaleManager;
|
|
50
64
|
schema: SchemaManager;
|
|
51
65
|
});
|
|
52
66
|
setConfig(config: ConfigFile): void;
|
|
53
|
-
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, }: {
|
|
67
|
+
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, forceStale, }: {
|
|
54
68
|
data: {
|
|
55
69
|
[key: string]: GraphQLValue;
|
|
56
70
|
};
|
|
@@ -62,8 +76,9 @@ declare class CacheInternal {
|
|
|
62
76
|
root?: string;
|
|
63
77
|
layer: Layer;
|
|
64
78
|
toNotify?: FieldSelection[];
|
|
65
|
-
applyUpdates?:
|
|
79
|
+
applyUpdates?: string[];
|
|
66
80
|
forceNotify?: boolean;
|
|
81
|
+
forceStale?: boolean;
|
|
67
82
|
}): FieldSelection[];
|
|
68
83
|
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
69
84
|
selection: SubscriptionSelection;
|
|
@@ -73,6 +88,7 @@ declare class CacheInternal {
|
|
|
73
88
|
}): {
|
|
74
89
|
data: GraphQLObject | null;
|
|
75
90
|
partial: boolean;
|
|
91
|
+
stale: boolean;
|
|
76
92
|
hasData: boolean;
|
|
77
93
|
};
|
|
78
94
|
id(type: string, data: {} | null): string | null;
|
|
@@ -87,6 +103,7 @@ declare class CacheInternal {
|
|
|
87
103
|
}): {
|
|
88
104
|
data: LinkedList<GraphQLValue>;
|
|
89
105
|
partial: boolean;
|
|
106
|
+
stale: boolean;
|
|
90
107
|
hasData: boolean;
|
|
91
108
|
};
|
|
92
109
|
extractNestedListIDs({ value, abstract, recordID, key, linkedType, fields, variables, applyUpdates, specs, layer, forceNotify, }: {
|
|
@@ -97,7 +114,7 @@ declare class CacheInternal {
|
|
|
97
114
|
abstract: boolean;
|
|
98
115
|
variables: {};
|
|
99
116
|
specs: FieldSelection[];
|
|
100
|
-
applyUpdates
|
|
117
|
+
applyUpdates?: string[];
|
|
101
118
|
fields: SubscriptionSelection;
|
|
102
119
|
layer: Layer;
|
|
103
120
|
forceNotify?: boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Cache } from './cache';
|
|
2
|
+
export declare class StaleManager {
|
|
3
|
+
#private;
|
|
4
|
+
cache: Cache;
|
|
5
|
+
private fieldsTime;
|
|
6
|
+
constructor(cache: Cache);
|
|
7
|
+
/**
|
|
8
|
+
* get the FieldTime info
|
|
9
|
+
* @param id User:1
|
|
10
|
+
* @param field firstName
|
|
11
|
+
*/
|
|
12
|
+
getFieldTime(id: string, field: string): number | undefined | null;
|
|
13
|
+
/**
|
|
14
|
+
* set the date to a field
|
|
15
|
+
* @param id User:1
|
|
16
|
+
* @param field firstName
|
|
17
|
+
*/
|
|
18
|
+
setFieldTimeToNow(id: string, field: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* set null to a field (stale)
|
|
21
|
+
* @param id User:1
|
|
22
|
+
* @param field firstName
|
|
23
|
+
*/
|
|
24
|
+
markFieldStale(id: string, field: string): void;
|
|
25
|
+
markAllStale(): void;
|
|
26
|
+
markRecordStale(id: string): void;
|
|
27
|
+
markTypeStale(type: string): void;
|
|
28
|
+
markTypeFieldStale(type: string, field: string, when?: {}): void;
|
|
29
|
+
delete(id: string, field: string): void;
|
|
30
|
+
}
|
|
@@ -19,10 +19,11 @@ export declare class InMemorySubscriptions {
|
|
|
19
19
|
[key: string]: GraphQLValue;
|
|
20
20
|
};
|
|
21
21
|
}): void;
|
|
22
|
-
addFieldSubscription({ id, key, selection, }: {
|
|
22
|
+
addFieldSubscription({ id, key, selection, type, }: {
|
|
23
23
|
id: string;
|
|
24
24
|
key: string;
|
|
25
25
|
selection: FieldSelection;
|
|
26
|
+
type: string;
|
|
26
27
|
}): void;
|
|
27
28
|
registerList({ list, id, key, parentType, selection, filters, variables, }: {
|
|
28
29
|
list: Required<Required<SubscriptionSelection>['fields'][string]>['list'];
|
|
@@ -5,5 +5,5 @@ export declare const fetchParamsPlugin: (fn?: FetchParamFn) => ClientPlugin;
|
|
|
5
5
|
export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
|
|
6
6
|
text: string;
|
|
7
7
|
hash: string;
|
|
8
|
-
|
|
8
|
+
document: DocumentArtifact;
|
|
9
9
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { GraphQLObject } from '../../lib/types';
|
|
2
1
|
import type { ClientPluginContext } from '../documentStore';
|
|
3
2
|
export declare function subscriptionPlugin(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
|
|
4
3
|
export type SubscriptionHandler = (ctx: ClientPluginContext) => {
|
|
@@ -7,7 +6,7 @@ export type SubscriptionHandler = (ctx: ClientPluginContext) => {
|
|
|
7
6
|
variables?: {};
|
|
8
7
|
}, handlers: {
|
|
9
8
|
next: (payload: {
|
|
10
|
-
data?:
|
|
9
|
+
data?: {} | null;
|
|
11
10
|
errors?: readonly {
|
|
12
11
|
message: string;
|
|
13
12
|
}[];
|
|
@@ -55,6 +55,10 @@ export type ConfigFile = {
|
|
|
55
55
|
* Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
|
|
56
56
|
*/
|
|
57
57
|
defaultPartial?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Specifies after how long a data goes stale in miliseconds. (default: `undefined`)
|
|
60
|
+
*/
|
|
61
|
+
defaultLifetime?: number;
|
|
58
62
|
/**
|
|
59
63
|
* Specifies whether mutations should append or prepend list. For more information: https://www.houdinigraphql.com/api/graphql (default: `append`)
|
|
60
64
|
*/
|
|
@@ -71,7 +71,6 @@ export type BaseCompiledDocument = {
|
|
|
71
71
|
rootType: string;
|
|
72
72
|
input?: InputObject;
|
|
73
73
|
refetch?: {
|
|
74
|
-
update: RefetchUpdateMode;
|
|
75
74
|
path: string[];
|
|
76
75
|
method: 'cursor' | 'offset';
|
|
77
76
|
pageSize: number;
|
|
@@ -79,9 +78,9 @@ export type BaseCompiledDocument = {
|
|
|
79
78
|
embedded: boolean;
|
|
80
79
|
targetType: string;
|
|
81
80
|
paginated: boolean;
|
|
82
|
-
direction
|
|
81
|
+
direction: 'forward' | 'backward' | 'both';
|
|
83
82
|
};
|
|
84
|
-
|
|
83
|
+
plugin_data?: Record<string, any>;
|
|
85
84
|
};
|
|
86
85
|
export type HoudiniFetchContext = {
|
|
87
86
|
variables: () => {};
|
|
@@ -135,7 +134,7 @@ export type SubscriptionSelection = {
|
|
|
135
134
|
connection: boolean;
|
|
136
135
|
type: string;
|
|
137
136
|
};
|
|
138
|
-
|
|
137
|
+
updates?: string[];
|
|
139
138
|
filters?: {
|
|
140
139
|
[key: string]: {
|
|
141
140
|
kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
|
|
@@ -165,7 +164,6 @@ export type SubscriptionSpec = {
|
|
|
165
164
|
export type FetchQueryResult<_Data> = {
|
|
166
165
|
result: RequestPayload<_Data | null>;
|
|
167
166
|
source: DataSource | null;
|
|
168
|
-
partial: boolean;
|
|
169
167
|
};
|
|
170
168
|
export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
|
|
171
169
|
data: _Data | null;
|
|
@@ -174,6 +172,7 @@ export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
|
|
|
174
172
|
}[] | null;
|
|
175
173
|
fetching: boolean;
|
|
176
174
|
partial: boolean;
|
|
175
|
+
stale: boolean;
|
|
177
176
|
source: DataSource | null;
|
|
178
177
|
variables: _Input | null;
|
|
179
178
|
};
|
|
@@ -2,7 +2,7 @@ import type { Cache as _Cache } from '../cache/cache';
|
|
|
2
2
|
import { type QueryArtifact } from '../lib';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
|
-
import type { CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeNames, ValidLists } from './types';
|
|
5
|
+
import type { ArgType, CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeFieldNames, TypeNames, ValidLists } from './types';
|
|
6
6
|
export declare class Cache<Def extends CacheTypeDef> {
|
|
7
7
|
_internal_unstable: _Cache;
|
|
8
8
|
constructor(cache: _Cache);
|
|
@@ -29,4 +29,11 @@ export declare class Cache<Def extends CacheTypeDef> {
|
|
|
29
29
|
data: QueryValue<QueryList<Def>, _Query>;
|
|
30
30
|
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
31
31
|
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Mark some elements of the cache stale.
|
|
34
|
+
*/
|
|
35
|
+
markStale<_Type extends TypeNames<Def>, _Field extends TypeFieldNames<Def, _Type>>(type?: _Type, options?: {
|
|
36
|
+
field?: _Field;
|
|
37
|
+
when?: ArgType<Def, _Type, _Field>;
|
|
38
|
+
}): void;
|
|
32
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FragmentArtifact } from '../lib/types';
|
|
2
2
|
import type { Cache } from './cache';
|
|
3
|
-
import type { CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, ValidTypes } from './types';
|
|
3
|
+
import type { ArgType, CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, TypeFieldNames, ValidTypes } from './types';
|
|
4
4
|
export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
|
|
5
5
|
#private;
|
|
6
6
|
type: string;
|
|
@@ -26,6 +26,16 @@ export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<De
|
|
|
26
26
|
fragment: _Fragment;
|
|
27
27
|
data: FragmentValue<FragmentList<Def, Type>, _Fragment>;
|
|
28
28
|
variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
|
|
29
|
+
forceStale?: boolean;
|
|
29
30
|
}): void;
|
|
30
31
|
delete(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Mark some elements of the record stale in the cache.
|
|
34
|
+
* @param field
|
|
35
|
+
* @param when
|
|
36
|
+
*/
|
|
37
|
+
markStale<Field extends TypeFieldNames<Def, Type>>({ field, when, }?: {
|
|
38
|
+
field?: Field;
|
|
39
|
+
when?: ArgType<Def, Type, Field>;
|
|
40
|
+
}): void;
|
|
31
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SubscriptionSelection, type FragmentArtifact, type QueryArtifact } from '../../lib';
|
|
2
2
|
import { Cache } from '../cache';
|
|
3
3
|
import type { Record } from '../record';
|
|
4
|
-
type
|
|
4
|
+
export type CacheTypeDefTest = {
|
|
5
5
|
types: {
|
|
6
6
|
__ROOT__: {
|
|
7
7
|
idFields: {};
|
|
@@ -16,23 +16,23 @@ type CacheTypeDef = {
|
|
|
16
16
|
args: never;
|
|
17
17
|
};
|
|
18
18
|
viewer: {
|
|
19
|
-
type: Record<
|
|
19
|
+
type: Record<CacheTypeDefTest, 'User'> | null;
|
|
20
20
|
args: never;
|
|
21
21
|
};
|
|
22
22
|
pets: {
|
|
23
|
-
type: (Record<
|
|
23
|
+
type: (Record<CacheTypeDefTest, 'Cat'> | Record<CacheTypeDefTest, 'User'>)[];
|
|
24
24
|
args: never;
|
|
25
25
|
};
|
|
26
26
|
listOfLists: {
|
|
27
|
-
type: ((Record<
|
|
27
|
+
type: ((Record<CacheTypeDefTest, 'Cat'> | Record<CacheTypeDefTest, 'User'> | null | (null | Record<CacheTypeDefTest, 'User'>)[])[] | Record<CacheTypeDefTest, 'Cat'> | Record<CacheTypeDefTest, 'User'> | null)[];
|
|
28
28
|
args: never;
|
|
29
29
|
};
|
|
30
30
|
users: {
|
|
31
|
-
type: Record<
|
|
31
|
+
type: Record<CacheTypeDefTest, 'User'>[] | null;
|
|
32
32
|
args: never;
|
|
33
33
|
};
|
|
34
34
|
pet: {
|
|
35
|
-
type: Record<
|
|
35
|
+
type: Record<CacheTypeDefTest, 'Cat'> | Record<CacheTypeDefTest, 'User'>;
|
|
36
36
|
args: never;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
@@ -60,7 +60,7 @@ type CacheTypeDef = {
|
|
|
60
60
|
args: never;
|
|
61
61
|
};
|
|
62
62
|
parent: {
|
|
63
|
-
type: Record<
|
|
63
|
+
type: Record<CacheTypeDefTest, 'User'>;
|
|
64
64
|
args: never;
|
|
65
65
|
};
|
|
66
66
|
id: {
|
|
@@ -84,7 +84,7 @@ type CacheTypeDef = {
|
|
|
84
84
|
args: never;
|
|
85
85
|
};
|
|
86
86
|
parent: {
|
|
87
|
-
type: Record<
|
|
87
|
+
type: Record<CacheTypeDefTest, 'User'> | null;
|
|
88
88
|
args: never;
|
|
89
89
|
};
|
|
90
90
|
id: {
|
|
@@ -147,11 +147,10 @@ type CacheTypeDef = {
|
|
|
147
147
|
};
|
|
148
148
|
};
|
|
149
149
|
};
|
|
150
|
-
export declare const testCache: () => Cache<
|
|
150
|
+
export declare const testCache: () => Cache<CacheTypeDefTest>;
|
|
151
151
|
export declare const testFragment: (selection: SubscriptionSelection) => {
|
|
152
152
|
artifact: FragmentArtifact;
|
|
153
153
|
};
|
|
154
154
|
export declare const testQuery: (selection: SubscriptionSelection) => {
|
|
155
155
|
artifact: QueryArtifact;
|
|
156
156
|
};
|
|
157
|
-
export {};
|
|
@@ -4,9 +4,10 @@ import { GarbageCollector } from './gc';
|
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
6
6
|
import { SchemaManager } from './schema';
|
|
7
|
+
import { StaleManager } from './staleManager';
|
|
7
8
|
import type { Layer, LayerID } from './storage';
|
|
8
9
|
import { InMemoryStorage } from './storage';
|
|
9
|
-
import { type FieldSelection
|
|
10
|
+
import { InMemorySubscriptions, type FieldSelection } from './subscription';
|
|
10
11
|
export declare class Cache {
|
|
11
12
|
_internal_unstable: CacheInternal;
|
|
12
13
|
constructor(config?: ConfigFile);
|
|
@@ -18,19 +19,30 @@ export declare class Cache {
|
|
|
18
19
|
variables?: {};
|
|
19
20
|
parent?: string;
|
|
20
21
|
layer?: LayerID | null;
|
|
21
|
-
applyUpdates?:
|
|
22
|
+
applyUpdates?: string[];
|
|
22
23
|
notifySubscribers?: SubscriptionSpec[];
|
|
23
24
|
forceNotify?: boolean;
|
|
25
|
+
forceStale?: boolean;
|
|
24
26
|
}): SubscriptionSpec[];
|
|
25
27
|
read(...args: Parameters<CacheInternal['getSelection']>): {
|
|
26
28
|
data: GraphQLObject | null;
|
|
27
29
|
partial: boolean;
|
|
30
|
+
stale: boolean;
|
|
28
31
|
};
|
|
29
32
|
subscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
30
33
|
unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
31
34
|
list(name: string, parentID?: string, allLists?: boolean): ListCollection;
|
|
32
35
|
delete(id: string): void;
|
|
33
36
|
setConfig(config: ConfigFile): void;
|
|
37
|
+
markTypeStale(type?: string, options?: {
|
|
38
|
+
field?: string;
|
|
39
|
+
when?: {};
|
|
40
|
+
}): void;
|
|
41
|
+
markRecordStale(id: string, options: {
|
|
42
|
+
field?: string;
|
|
43
|
+
when?: {};
|
|
44
|
+
}): void;
|
|
45
|
+
getFieldTime(id: string, field: string): number | null | undefined;
|
|
34
46
|
}
|
|
35
47
|
declare class CacheInternal {
|
|
36
48
|
private _disabled;
|
|
@@ -40,17 +52,19 @@ declare class CacheInternal {
|
|
|
40
52
|
lists: ListManager;
|
|
41
53
|
cache: Cache;
|
|
42
54
|
lifetimes: GarbageCollector;
|
|
55
|
+
staleManager: StaleManager;
|
|
43
56
|
schema: SchemaManager;
|
|
44
|
-
constructor({ storage, subscriptions, lists, cache, lifetimes, schema, }: {
|
|
57
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, }: {
|
|
45
58
|
storage: InMemoryStorage;
|
|
46
59
|
subscriptions: InMemorySubscriptions;
|
|
47
60
|
lists: ListManager;
|
|
48
61
|
cache: Cache;
|
|
49
62
|
lifetimes: GarbageCollector;
|
|
63
|
+
staleManager: StaleManager;
|
|
50
64
|
schema: SchemaManager;
|
|
51
65
|
});
|
|
52
66
|
setConfig(config: ConfigFile): void;
|
|
53
|
-
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, }: {
|
|
67
|
+
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, forceStale, }: {
|
|
54
68
|
data: {
|
|
55
69
|
[key: string]: GraphQLValue;
|
|
56
70
|
};
|
|
@@ -62,8 +76,9 @@ declare class CacheInternal {
|
|
|
62
76
|
root?: string;
|
|
63
77
|
layer: Layer;
|
|
64
78
|
toNotify?: FieldSelection[];
|
|
65
|
-
applyUpdates?:
|
|
79
|
+
applyUpdates?: string[];
|
|
66
80
|
forceNotify?: boolean;
|
|
81
|
+
forceStale?: boolean;
|
|
67
82
|
}): FieldSelection[];
|
|
68
83
|
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
69
84
|
selection: SubscriptionSelection;
|
|
@@ -73,6 +88,7 @@ declare class CacheInternal {
|
|
|
73
88
|
}): {
|
|
74
89
|
data: GraphQLObject | null;
|
|
75
90
|
partial: boolean;
|
|
91
|
+
stale: boolean;
|
|
76
92
|
hasData: boolean;
|
|
77
93
|
};
|
|
78
94
|
id(type: string, data: {} | null): string | null;
|
|
@@ -87,6 +103,7 @@ declare class CacheInternal {
|
|
|
87
103
|
}): {
|
|
88
104
|
data: LinkedList<GraphQLValue>;
|
|
89
105
|
partial: boolean;
|
|
106
|
+
stale: boolean;
|
|
90
107
|
hasData: boolean;
|
|
91
108
|
};
|
|
92
109
|
extractNestedListIDs({ value, abstract, recordID, key, linkedType, fields, variables, applyUpdates, specs, layer, forceNotify, }: {
|
|
@@ -97,7 +114,7 @@ declare class CacheInternal {
|
|
|
97
114
|
abstract: boolean;
|
|
98
115
|
variables: {};
|
|
99
116
|
specs: FieldSelection[];
|
|
100
|
-
applyUpdates
|
|
117
|
+
applyUpdates?: string[];
|
|
101
118
|
fields: SubscriptionSelection;
|
|
102
119
|
layer: Layer;
|
|
103
120
|
forceNotify?: boolean;
|