@warp-drive/core 5.7.0-alpha.14 → 5.7.0-alpha.16
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/declarations/graph/-private/-diff.d.ts +8 -8
- package/declarations/graph/-private/-edge-definition.d.ts +2 -2
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +5 -5
- package/declarations/graph/-private/graph.d.ts +15 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +2 -2
- package/declarations/reactive/-private/document.d.ts +6 -16
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/record.d.ts +44 -5
- package/declarations/reactive/-private/schema.d.ts +12 -12
- package/declarations/reactive/-private/symbols.d.ts +1 -0
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +2 -2
- package/declarations/request/-private/types.d.ts +4 -4
- package/declarations/store/-private/cache-handler/types.d.ts +9 -9
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
- package/declarations/store/-private/managers/notification-manager.d.ts +21 -22
- package/declarations/store/-private/managers/record-array-manager.d.ts +15 -15
- package/declarations/store/-private/network/request-cache.d.ts +11 -11
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
- package/declarations/store/-private/record-arrays/-utils.d.ts +3 -3
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +2 -2
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +2 -2
- package/declarations/store/-private/record-arrays/resource-array.d.ts +9 -9
- package/declarations/store/-private/store-service.d.ts +19 -16
- package/declarations/store/-private.d.ts +1 -1
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/schema-service.d.ts +9 -9
- package/declarations/store/deprecated/-private.d.ts +5 -5
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +20 -20
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -113
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +60 -76
- package/declarations/types/request.d.ts +6 -6
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/spec/document.d.ts +6 -6
- package/dist/graph/-private.js +125 -125
- package/dist/index.js +2 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +126 -4
- package/dist/{request-state-CCrTjb0Z.js → request-state-CQ0Q6d1V.js} +3493 -3483
- package/dist/store/-private.js +1 -1
- package/dist/store.js +30 -43
- package/dist/{symbols-C5p2hcy9.js → symbols-sql1_mdx.js} +2 -1
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@ import type { Change } from "./cache/change.js";
|
|
|
3
3
|
import type { Mutation } from "./cache/mutations.js";
|
|
4
4
|
import type { Operation } from "./cache/operations.js";
|
|
5
5
|
import type { CollectionRelationship, ResourceRelationship } from "./cache/relationship.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { RequestKey, ResourceKey } from "./identifier.js";
|
|
7
7
|
import type { Value } from "./json/raw.js";
|
|
8
8
|
import type { TypeFromInstanceOrString } from "./record.js";
|
|
9
9
|
import type { RequestContext, StructuredDataDocument, StructuredDocument } from "./request.js";
|
|
@@ -13,20 +13,19 @@ import type { ApiError } from "./spec/error.js";
|
|
|
13
13
|
* A hash of changed attributes with the key being the attribute name and the value being an
|
|
14
14
|
* array of `[oldValue, newValue]`.
|
|
15
15
|
*
|
|
16
|
-
* @internal
|
|
17
16
|
*/
|
|
18
17
|
export type ChangedAttributesHash = Record<string, [Value | undefined, Value]>;
|
|
19
18
|
export type RelationshipDiff = {
|
|
20
19
|
kind: "collection";
|
|
21
|
-
remoteState:
|
|
22
|
-
additions: Set<
|
|
23
|
-
removals: Set<
|
|
24
|
-
localState:
|
|
20
|
+
remoteState: ResourceKey[];
|
|
21
|
+
additions: Set<ResourceKey>;
|
|
22
|
+
removals: Set<ResourceKey>;
|
|
23
|
+
localState: ResourceKey[];
|
|
25
24
|
reordered: boolean;
|
|
26
25
|
} | {
|
|
27
26
|
kind: "resource";
|
|
28
|
-
remoteState:
|
|
29
|
-
localState:
|
|
27
|
+
remoteState: ResourceKey | null;
|
|
28
|
+
localState: ResourceKey | null;
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
32
31
|
* The interface for WarpDrive Caches.
|
|
@@ -34,16 +33,13 @@ export type RelationshipDiff = {
|
|
|
34
33
|
* A Cache handles in-memory storage of Document and Resource
|
|
35
34
|
* data.
|
|
36
35
|
*
|
|
37
|
-
* @class (Interface) Cache
|
|
38
36
|
* @public
|
|
39
37
|
*/
|
|
40
38
|
export interface Cache {
|
|
41
39
|
/**
|
|
42
40
|
* The Cache Version that this implementation implements.
|
|
43
41
|
*
|
|
44
|
-
* @type {'2'}
|
|
45
42
|
* @public
|
|
46
|
-
* @property version
|
|
47
43
|
*/
|
|
48
44
|
version: "2";
|
|
49
45
|
// Cache Management
|
|
@@ -65,8 +61,6 @@ export interface Cache {
|
|
|
65
61
|
* a `content` member and therefor must not assume the existence
|
|
66
62
|
* of `request` and `response` on the document.
|
|
67
63
|
*
|
|
68
|
-
* @param {StructuredDocument} doc
|
|
69
|
-
* @return {ResourceDocument}
|
|
70
64
|
* @public
|
|
71
65
|
*/
|
|
72
66
|
put<T>(doc: StructuredDocument<T> | {
|
|
@@ -77,15 +71,12 @@ export interface Cache {
|
|
|
77
71
|
* by merging new information into the existing state.
|
|
78
72
|
*
|
|
79
73
|
* @public
|
|
80
|
-
* @param
|
|
81
|
-
* @return {void}
|
|
74
|
+
* @param op the operation(s) to perform
|
|
82
75
|
*/
|
|
83
76
|
patch(op: Operation | Operation[]): void;
|
|
84
77
|
/**
|
|
85
78
|
* Update the "local" or "current" (unpersisted) state of the Cache
|
|
86
79
|
*
|
|
87
|
-
* @param {Mutation} mutation
|
|
88
|
-
* @return {void}
|
|
89
80
|
* @public
|
|
90
81
|
*/
|
|
91
82
|
mutate(mutation: Mutation): void;
|
|
@@ -117,11 +108,10 @@ export interface Cache {
|
|
|
117
108
|
* notifications for relational data.
|
|
118
109
|
*
|
|
119
110
|
* @public
|
|
120
|
-
* @
|
|
121
|
-
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
111
|
+
* @return the known resource data, if any
|
|
122
112
|
*/
|
|
123
|
-
peek<T = unknown>(
|
|
124
|
-
peek(
|
|
113
|
+
peek<T = unknown>(cacheKey: ResourceKey<TypeFromInstanceOrString<T>>): T | null;
|
|
114
|
+
peek(cacheKey: RequestKey): ResourceDocument | null;
|
|
125
115
|
/**
|
|
126
116
|
* Peek remote resource data from the Cache.
|
|
127
117
|
*
|
|
@@ -152,11 +142,10 @@ export interface Cache {
|
|
|
152
142
|
* notifications for relational data.
|
|
153
143
|
*
|
|
154
144
|
* @public
|
|
155
|
-
* @
|
|
156
|
-
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
145
|
+
* @return the known data, if any
|
|
157
146
|
*/
|
|
158
|
-
peekRemoteState<T = unknown>(
|
|
159
|
-
peekRemoteState(
|
|
147
|
+
peekRemoteState<T = unknown>(cacheKey: ResourceKey<TypeFromInstanceOrString<T>>): T | null;
|
|
148
|
+
peekRemoteState(cacheKey: RequestKey): ResourceDocument | null;
|
|
160
149
|
/**
|
|
161
150
|
* Peek the Cache for the existing request data associated with
|
|
162
151
|
* a cacheable request
|
|
@@ -165,21 +154,16 @@ export interface Cache {
|
|
|
165
154
|
* that it will return the the request, response, and content
|
|
166
155
|
* whereas `peek` will return just the `content`.
|
|
167
156
|
*
|
|
168
|
-
* @param {StableDocumentIdentifier}
|
|
169
|
-
* @return {StructuredDocument<ResourceDocument> | null}
|
|
170
157
|
* @public
|
|
171
158
|
*/
|
|
172
|
-
peekRequest(
|
|
159
|
+
peekRequest(cacheKey: RequestKey): StructuredDocument<ResourceDocument> | null;
|
|
173
160
|
/**
|
|
174
|
-
* Push resource data from a remote source into the cache for this
|
|
161
|
+
* Push resource data from a remote source into the cache for this ResourceKey
|
|
175
162
|
*
|
|
176
163
|
* @public
|
|
177
|
-
* @
|
|
178
|
-
* @param data
|
|
179
|
-
* @param hasRecord
|
|
180
|
-
* @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
|
|
164
|
+
* @return if `hasRecord` is true then calculated key changes should be returned
|
|
181
165
|
*/
|
|
182
|
-
upsert(
|
|
166
|
+
upsert(cacheKey: ResourceKey, data: ResourceBlob, hasRecord: boolean): void | string[];
|
|
183
167
|
// Cache Forking Support
|
|
184
168
|
// =====================
|
|
185
169
|
/**
|
|
@@ -190,7 +174,6 @@ export interface Cache {
|
|
|
190
174
|
* utilize this method to fork the cache.
|
|
191
175
|
*
|
|
192
176
|
* @public
|
|
193
|
-
* @return {Promise<Cache>}
|
|
194
177
|
*/
|
|
195
178
|
fork(): Promise<Cache>;
|
|
196
179
|
/**
|
|
@@ -200,9 +183,6 @@ export interface Cache {
|
|
|
200
183
|
* preferring instead to merge at the Store level, which will
|
|
201
184
|
* utilize this method to merge the caches.
|
|
202
185
|
*
|
|
203
|
-
* @param {Cache} cache
|
|
204
|
-
* @public
|
|
205
|
-
* @return {Promise<void>}
|
|
206
186
|
*/
|
|
207
187
|
merge(cache: Cache): Promise<void>;
|
|
208
188
|
/**
|
|
@@ -214,7 +194,7 @@ export interface Cache {
|
|
|
214
194
|
* `Change` entry in the returned array.
|
|
215
195
|
*
|
|
216
196
|
* A `Change` is described by an object containing up to
|
|
217
|
-
* three properties: (1) the `
|
|
197
|
+
* three properties: (1) the `CacheKey` of the entity that
|
|
218
198
|
* changed; (2) the `op` code of that change being one of
|
|
219
199
|
* `upsert` or `remove`, and if the op is `upsert` a `patch`
|
|
220
200
|
* containing the data to merge into the cache for the given
|
|
@@ -229,7 +209,7 @@ export interface Cache {
|
|
|
229
209
|
*
|
|
230
210
|
* ```ts
|
|
231
211
|
* interface Change {
|
|
232
|
-
*
|
|
212
|
+
* key: ResourceKey | RequestKey;
|
|
233
213
|
* op: 'upsert' | 'remove';
|
|
234
214
|
* patch?: unknown;
|
|
235
215
|
* }
|
|
@@ -261,8 +241,6 @@ export interface Cache {
|
|
|
261
241
|
* behavior supports optimizing pre/fetching of data for route transitions
|
|
262
242
|
* via data-only SSR modes.
|
|
263
243
|
*
|
|
264
|
-
* @param {ReadableStream} stream
|
|
265
|
-
* @return {Promise<void>}
|
|
266
244
|
* @public
|
|
267
245
|
*/
|
|
268
246
|
hydrate(stream: ReadableStream<unknown>): Promise<void>;
|
|
@@ -275,37 +253,31 @@ export interface Cache {
|
|
|
275
253
|
* process. This return value behavior is deprecated.
|
|
276
254
|
*
|
|
277
255
|
* @public
|
|
278
|
-
* @param identifier
|
|
279
|
-
* @param createArgs
|
|
280
256
|
*/
|
|
281
|
-
clientDidCreate(
|
|
257
|
+
clientDidCreate(cacheKey: ResourceKey, createArgs?: Record<string, unknown>): Record<string, unknown>;
|
|
282
258
|
/**
|
|
283
259
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
284
260
|
* will be part of a save transaction.
|
|
285
261
|
*
|
|
286
262
|
* @public
|
|
287
|
-
* @param identifier
|
|
288
263
|
*/
|
|
289
|
-
willCommit(
|
|
264
|
+
willCommit(cacheKey: ResourceKey, context: RequestContext | null): void;
|
|
290
265
|
/**
|
|
291
266
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
292
267
|
* was successfully updated as part of a save transaction.
|
|
293
268
|
*
|
|
294
269
|
* @public
|
|
295
|
-
* @param
|
|
270
|
+
* @param the primary ResourceKey that was operated on
|
|
296
271
|
* @param data - a document in the cache format containing any updated data
|
|
297
|
-
* @return {SingleResourceDataDocument}
|
|
298
272
|
*/
|
|
299
|
-
didCommit(
|
|
273
|
+
didCommit(cacheKey: ResourceKey, result: StructuredDataDocument<unknown> | null): SingleResourceDataDocument;
|
|
300
274
|
/**
|
|
301
275
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
302
276
|
* was update via a save transaction failed.
|
|
303
277
|
*
|
|
304
278
|
* @public
|
|
305
|
-
* @param identifier
|
|
306
|
-
* @param errors
|
|
307
279
|
*/
|
|
308
|
-
commitWasRejected(
|
|
280
|
+
commitWasRejected(cacheKey: ResourceKey, errors?: ApiError[]): void;
|
|
309
281
|
/**
|
|
310
282
|
* [LIFECYCLE] Signals to the cache that all data for a resource
|
|
311
283
|
* should be cleared.
|
|
@@ -313,40 +285,30 @@ export interface Cache {
|
|
|
313
285
|
* This method is a candidate to become a mutation
|
|
314
286
|
*
|
|
315
287
|
* @public
|
|
316
|
-
* @param identifier
|
|
317
288
|
*/
|
|
318
|
-
unloadRecord(
|
|
289
|
+
unloadRecord(cacheKey: ResourceKey): void;
|
|
319
290
|
// Granular Resource Data APIs
|
|
320
291
|
// ===========================
|
|
321
292
|
/**
|
|
322
293
|
* Retrieve the data for an attribute from the cache
|
|
323
294
|
*
|
|
324
295
|
* @public
|
|
325
|
-
* @param identifier
|
|
326
|
-
* @param field
|
|
327
|
-
* @return {unknown}
|
|
328
296
|
*/
|
|
329
|
-
getAttr(
|
|
297
|
+
getAttr(cacheKey: ResourceKey, field: string | string[]): Value | undefined;
|
|
330
298
|
/**
|
|
331
299
|
* Retrieve remote state without any local changes for a specific attribute
|
|
332
300
|
*
|
|
333
301
|
* @public
|
|
334
|
-
* @param identifier
|
|
335
|
-
* @param field
|
|
336
|
-
* @return {unknown}
|
|
337
302
|
*/
|
|
338
|
-
getRemoteAttr(
|
|
303
|
+
getRemoteAttr(cacheKey: ResourceKey, field: string | string[]): Value | undefined;
|
|
339
304
|
/**
|
|
340
305
|
* Mutate the data for an attribute in the cache
|
|
341
306
|
*
|
|
342
307
|
* This method is a candidate to become a mutation
|
|
343
308
|
*
|
|
344
309
|
* @public
|
|
345
|
-
* @param identifier
|
|
346
|
-
* @param field
|
|
347
|
-
* @param value
|
|
348
310
|
*/
|
|
349
|
-
setAttr(
|
|
311
|
+
setAttr(cacheKey: ResourceKey, field: string | string[], value: Value): void;
|
|
350
312
|
/**
|
|
351
313
|
* Query the cache for the changed attributes of a resource.
|
|
352
314
|
*
|
|
@@ -357,28 +319,23 @@ export interface Cache {
|
|
|
357
319
|
* ```
|
|
358
320
|
*
|
|
359
321
|
* @public
|
|
360
|
-
* @param identifier
|
|
361
|
-
* @return {Record<string, [unknown, unknown]>} `{ <field>: [<old>, <new>] }`
|
|
362
322
|
*/
|
|
363
|
-
changedAttrs(
|
|
323
|
+
changedAttrs(cacheKey: ResourceKey): ChangedAttributesHash;
|
|
364
324
|
/**
|
|
365
325
|
* Query the cache for whether any mutated attributes exist
|
|
366
326
|
*
|
|
367
327
|
* @public
|
|
368
|
-
* @param identifier
|
|
369
|
-
* @return {Boolean}
|
|
370
328
|
*/
|
|
371
|
-
hasChangedAttrs(
|
|
329
|
+
hasChangedAttrs(cacheKey: ResourceKey): boolean;
|
|
372
330
|
/**
|
|
373
331
|
* Tell the cache to discard any uncommitted mutations to attributes
|
|
374
332
|
*
|
|
375
333
|
* This method is a candidate to become a mutation
|
|
376
334
|
*
|
|
377
335
|
* @public
|
|
378
|
-
* @
|
|
379
|
-
* @return {String[]} the names of fields that were restored
|
|
336
|
+
* @return the names of fields that were restored
|
|
380
337
|
*/
|
|
381
|
-
rollbackAttrs(
|
|
338
|
+
rollbackAttrs(cacheKey: ResourceKey): string[];
|
|
382
339
|
/**
|
|
383
340
|
* Query the cache for the changes to relationships of a resource.
|
|
384
341
|
*
|
|
@@ -388,32 +345,28 @@ export interface Cache {
|
|
|
388
345
|
* type RelationshipDiff =
|
|
389
346
|
| {
|
|
390
347
|
kind: 'collection';
|
|
391
|
-
remoteState:
|
|
392
|
-
additions: Set<
|
|
393
|
-
removals: Set<
|
|
394
|
-
localState:
|
|
348
|
+
remoteState: ResourceKey[];
|
|
349
|
+
additions: Set<ResourceKey>;
|
|
350
|
+
removals: Set<ResourceKey>;
|
|
351
|
+
localState: ResourceKey[];
|
|
395
352
|
reordered: boolean;
|
|
396
353
|
}
|
|
397
354
|
| {
|
|
398
355
|
kind: 'resource';
|
|
399
|
-
remoteState:
|
|
400
|
-
localState:
|
|
356
|
+
remoteState: ResourceKey | null;
|
|
357
|
+
localState: ResourceKey | null;
|
|
401
358
|
};
|
|
402
359
|
```
|
|
403
360
|
*
|
|
404
361
|
* @public
|
|
405
|
-
* @param {StableRecordIdentifier} identifier
|
|
406
|
-
* @return {Map<string, RelationshipDiff>}
|
|
407
362
|
*/
|
|
408
|
-
changedRelationships(
|
|
363
|
+
changedRelationships(cacheKey: ResourceKey): Map<string, RelationshipDiff>;
|
|
409
364
|
/**
|
|
410
365
|
* Query the cache for whether any mutated attributes exist
|
|
411
366
|
*
|
|
412
367
|
* @public
|
|
413
|
-
* @param {StableRecordIdentifier} identifier
|
|
414
|
-
* @return {Boolean}
|
|
415
368
|
*/
|
|
416
|
-
hasChangedRelationships(
|
|
369
|
+
hasChangedRelationships(cacheKey: ResourceKey): boolean;
|
|
417
370
|
/**
|
|
418
371
|
* Tell the cache to discard any uncommitted mutations to relationships.
|
|
419
372
|
*
|
|
@@ -422,28 +375,23 @@ export interface Cache {
|
|
|
422
375
|
* This method is a candidate to become a mutation
|
|
423
376
|
*
|
|
424
377
|
* @public
|
|
425
|
-
* @
|
|
426
|
-
* @return {String[]} the names of relationships that were restored
|
|
378
|
+
* @return the names of relationships that were restored
|
|
427
379
|
*/
|
|
428
|
-
rollbackRelationships(
|
|
380
|
+
rollbackRelationships(cacheKey: ResourceKey): string[];
|
|
429
381
|
/**
|
|
430
382
|
* Query the cache for the current state of a relationship property
|
|
431
383
|
*
|
|
432
384
|
* @public
|
|
433
|
-
* @param {StableRecordIdentifier} identifier
|
|
434
|
-
* @param {String} field
|
|
435
385
|
* @return resource relationship object
|
|
436
386
|
*/
|
|
437
|
-
getRelationship(
|
|
387
|
+
getRelationship(cacheKey: ResourceKey, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
|
|
438
388
|
/**
|
|
439
389
|
* Query the cache for the server state of a relationship property without any local changes
|
|
440
390
|
*
|
|
441
391
|
* @public
|
|
442
|
-
* @param {StableRecordIdentifier} identifier
|
|
443
|
-
* @param {String} field
|
|
444
392
|
* @return resource relationship object
|
|
445
393
|
*/
|
|
446
|
-
getRemoteRelationship(
|
|
394
|
+
getRemoteRelationship(cacheKey: ResourceKey, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
|
|
447
395
|
// Resource State
|
|
448
396
|
// ===============
|
|
449
397
|
/**
|
|
@@ -453,49 +401,39 @@ export interface Cache {
|
|
|
453
401
|
* This method is a candidate to become a mutation
|
|
454
402
|
*
|
|
455
403
|
* @public
|
|
456
|
-
* @param identifier
|
|
457
|
-
* @param {Boolean} isDeleted
|
|
458
404
|
*/
|
|
459
|
-
setIsDeleted(
|
|
405
|
+
setIsDeleted(cacheKey: ResourceKey, isDeleted: boolean): void;
|
|
460
406
|
/**
|
|
461
407
|
* Query the cache for any validation errors applicable to the given resource.
|
|
462
408
|
*
|
|
463
409
|
* @public
|
|
464
410
|
*/
|
|
465
|
-
getErrors(
|
|
411
|
+
getErrors(cacheKey: ResourceKey): ApiError[];
|
|
466
412
|
/**
|
|
467
413
|
* Query the cache for whether a given resource has any available data
|
|
468
414
|
*
|
|
469
415
|
* @public
|
|
470
|
-
* @param identifier
|
|
471
|
-
* @return {Boolean}
|
|
472
416
|
*/
|
|
473
|
-
isEmpty(
|
|
417
|
+
isEmpty(cacheKey: ResourceKey): boolean;
|
|
474
418
|
/**
|
|
475
419
|
* Query the cache for whether a given resource was created locally and not
|
|
476
420
|
* yet persisted.
|
|
477
421
|
*
|
|
478
422
|
* @public
|
|
479
|
-
* @param identifier
|
|
480
|
-
* @return {Boolean}
|
|
481
423
|
*/
|
|
482
|
-
isNew(
|
|
424
|
+
isNew(cacheKey: ResourceKey): boolean;
|
|
483
425
|
/**
|
|
484
426
|
* Query the cache for whether a given resource is marked as deleted (but not
|
|
485
427
|
* necessarily persisted yet).
|
|
486
428
|
*
|
|
487
429
|
* @public
|
|
488
|
-
* @param identifier
|
|
489
|
-
* @return {Boolean}
|
|
490
430
|
*/
|
|
491
|
-
isDeleted(
|
|
431
|
+
isDeleted(cacheKey: ResourceKey): boolean;
|
|
492
432
|
/**
|
|
493
433
|
* Query the cache for whether a given resource has been deleted and that deletion
|
|
494
434
|
* has also been persisted.
|
|
495
435
|
*
|
|
496
436
|
* @public
|
|
497
|
-
* @param identifier
|
|
498
|
-
* @return {Boolean}
|
|
499
437
|
*/
|
|
500
|
-
isDeletionCommitted(
|
|
438
|
+
isDeletionCommitted(cacheKey: ResourceKey): boolean;
|
|
501
439
|
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import type { AddToResourceRelationshipMutation as AddResourceMutation, RemoveFromResourceRelationshipMutation as RemoveResourceMutation } from "./cache/mutations.js";
|
|
2
2
|
import type { AddToResourceRelationshipOperation as AddResourceOperation, RemoveFromResourceRelationshipOperation as RemoveResourceOperation, UpdateResourceRelationshipOperation } from "./cache/operations.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "./identifier.js";
|
|
4
4
|
import type { CollectionResourceRelationship, SingleResourceRelationship } from "./spec/json-api-raw.js";
|
|
5
5
|
export interface Operation {
|
|
6
6
|
op: string;
|
|
7
7
|
}
|
|
8
8
|
export interface UpdateRelationshipOperation {
|
|
9
9
|
op: "updateRelationship";
|
|
10
|
-
record:
|
|
10
|
+
record: ResourceKey;
|
|
11
11
|
field: string;
|
|
12
12
|
value: SingleResourceRelationship | CollectionResourceRelationship;
|
|
13
13
|
}
|
|
14
14
|
export interface DeleteRecordOperation {
|
|
15
15
|
op: "deleteRecord";
|
|
16
|
-
record:
|
|
16
|
+
record: ResourceKey;
|
|
17
17
|
isNew: boolean;
|
|
18
18
|
}
|
|
19
19
|
export interface UnknownOperation {
|
|
20
20
|
op: "never";
|
|
21
|
-
record:
|
|
21
|
+
record: ResourceKey;
|
|
22
22
|
field: string;
|
|
23
23
|
}
|
|
24
24
|
export interface ReplaceRelatedRecordOperation {
|
|
25
25
|
op: "replaceRelatedRecord";
|
|
26
|
-
record:
|
|
26
|
+
record: ResourceKey;
|
|
27
27
|
field: string;
|
|
28
|
-
value:
|
|
29
|
-
prior?:
|
|
28
|
+
value: ResourceKey | null;
|
|
29
|
+
prior?: ResourceKey;
|
|
30
30
|
index?: number;
|
|
31
31
|
}
|
|
32
32
|
export interface SortRelatedRecords {
|
|
33
33
|
op: "sortRelatedRecords";
|
|
34
|
-
record:
|
|
34
|
+
record: ResourceKey;
|
|
35
35
|
field: string;
|
|
36
|
-
value:
|
|
36
|
+
value: ResourceKey[];
|
|
37
37
|
}
|
|
38
38
|
export interface ReplaceRelatedRecordsOperation {
|
|
39
39
|
op: "replaceRelatedRecords";
|
|
40
|
-
record:
|
|
40
|
+
record: ResourceKey;
|
|
41
41
|
field: string;
|
|
42
|
-
value:
|
|
43
|
-
prior?:
|
|
42
|
+
value: ResourceKey[];
|
|
43
|
+
prior?: ResourceKey[];
|
|
44
44
|
index?: number;
|
|
45
45
|
}
|
|
46
46
|
export type RemoteRelationshipOperation = UpdateResourceRelationshipOperation | UpdateRelationshipOperation | ReplaceRelatedRecordOperation | ReplaceRelatedRecordsOperation | RemoveResourceOperation | AddResourceOperation | DeleteRecordOperation | SortRelatedRecords;
|
|
@@ -1,112 +1,96 @@
|
|
|
1
1
|
// provided for additional debuggability
|
|
2
2
|
export declare const DEBUG_CLIENT_ORIGINATED: unique symbol;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DEBUG_KEY_TYPE: unique symbol;
|
|
4
4
|
export declare const DEBUG_STALE_CACHE_OWNER: unique symbol;
|
|
5
5
|
// also present in production
|
|
6
6
|
export declare const CACHE_OWNER: "__$co";
|
|
7
|
-
export type
|
|
8
|
-
export interface Identifier {
|
|
9
|
-
lid: string;
|
|
10
|
-
clientId?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ExistingRecordIdentifier<T extends string = string> extends Identifier {
|
|
13
|
-
id: string;
|
|
14
|
-
type: T;
|
|
15
|
-
}
|
|
16
|
-
export interface NewRecordIdentifier<T extends string = string> extends Identifier {
|
|
17
|
-
id: string | null;
|
|
18
|
-
type: T;
|
|
19
|
-
}
|
|
20
|
-
export type StableDocumentIdentifier = {
|
|
21
|
-
lid: string;
|
|
22
|
-
};
|
|
23
|
-
export type RequestKey = StableDocumentIdentifier;
|
|
7
|
+
export type CacheKeyType = "record" | "document";
|
|
24
8
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
9
|
+
* A referentially stable object with a unique string (lid) that can be used
|
|
10
|
+
* as a reference to request data in the cache.
|
|
27
11
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* may also indicate that it was generated for a secondary
|
|
31
|
-
* index and the primary `id` index is not yet known.
|
|
12
|
+
* Only requests that are assigned a RequestKey are retrievable/replayable from
|
|
13
|
+
* the cache, though requests without RequestKeys may still update cache state.
|
|
32
14
|
*
|
|
33
|
-
* @
|
|
15
|
+
* @public
|
|
34
16
|
*/
|
|
35
|
-
export
|
|
17
|
+
export interface RequestKey {
|
|
18
|
+
lid: string;
|
|
19
|
+
type: "@document";
|
|
20
|
+
/** @internal */
|
|
21
|
+
[CACHE_OWNER]: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated use {@link RequestKey} */
|
|
24
|
+
export type StableDocumentIdentifier = RequestKey;
|
|
36
25
|
/**
|
|
37
|
-
* Used when an
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
26
|
+
* Used when an ResourceKey is known to be the stable version
|
|
40
27
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
interface ResourceKeyBase<T extends string = string> {
|
|
29
|
+
/**
|
|
30
|
+
* A string representing a unique identity.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
lid: string;
|
|
35
|
+
/**
|
|
36
|
+
* the primary `ResourceType` or "model name" this ResourceKey belongs to.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
type: T;
|
|
41
|
+
/** @internal */
|
|
42
|
+
[CACHE_OWNER]: number | undefined;
|
|
43
|
+
/** @internal */
|
|
44
|
+
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
45
|
+
/** @internal */
|
|
46
|
+
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
* Used when a
|
|
49
|
+
* Used when a ResourceKey was not created locally as part
|
|
46
50
|
* of a call to store.createRecord
|
|
47
51
|
*
|
|
48
|
-
* Distinguishing between this
|
|
49
|
-
*
|
|
52
|
+
* Distinguishing between this ResourceKey and one for a client created
|
|
53
|
+
* resource that was created with an ID is generally speaking not possible
|
|
50
54
|
* at runtime, so anything with an ID typically narrows to this.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
55
|
*/
|
|
54
|
-
export interface
|
|
56
|
+
export interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
57
|
+
/**
|
|
58
|
+
* the PrimaryKey for the resource this ResourceKey represents.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
55
62
|
id: string;
|
|
56
|
-
type: T;
|
|
57
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
58
|
-
[CACHE_OWNER]: number | undefined;
|
|
59
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
60
63
|
}
|
|
64
|
+
/** @deprecated use {@link PersistedResourceKey} */
|
|
65
|
+
export type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;
|
|
61
66
|
/**
|
|
62
|
-
* Used when a
|
|
67
|
+
* Used when a ResourceKey was created locally
|
|
63
68
|
* (by a call to store.createRecord).
|
|
64
69
|
*
|
|
65
|
-
* It is possible in rare circumstances to have a
|
|
70
|
+
* It is possible in rare circumstances to have a ResourceKey
|
|
66
71
|
* that is not for a new record but does not have an ID. This would
|
|
67
72
|
* happen if a user intentionally created one for use with a secondary-index
|
|
68
73
|
* prior to the record having been fully loaded.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
74
|
*/
|
|
72
|
-
export interface
|
|
75
|
+
export interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
76
|
+
/**
|
|
77
|
+
* the PrimaryKey for the resource this ResourceKey represents. `null`
|
|
78
|
+
* if not yet assigned a PrimaryKey value.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
73
82
|
id: string | null;
|
|
74
|
-
type: T;
|
|
75
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
76
|
-
[CACHE_OWNER]: number | undefined;
|
|
77
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* A referentially stable object with a unique string (lid) that can be used
|
|
81
86
|
* as a reference to data in the cache.
|
|
82
87
|
*
|
|
83
|
-
* Every
|
|
88
|
+
* Every resource has a unique ResourceKey, and ResourceKeys may refer
|
|
84
89
|
* to data that has never been loaded (for instance, in an async relationship).
|
|
85
90
|
*
|
|
86
|
-
* @class StableRecordIdentifier
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* A string representing a unique identity.
|
|
91
|
-
*
|
|
92
|
-
* @property lid
|
|
93
|
-
* @type {String}
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
/**
|
|
97
|
-
* the primary resource `type` or `modelName` this identity belongs to.
|
|
98
|
-
*
|
|
99
|
-
* @property type
|
|
100
|
-
* @type {String}
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
/**
|
|
104
|
-
* the primary id for the record this identity belongs to. `null`
|
|
105
|
-
* if not yet assigned an id.
|
|
106
|
-
*
|
|
107
|
-
* @property id
|
|
108
|
-
* @type {String | null}
|
|
109
91
|
* @public
|
|
110
92
|
*/
|
|
111
|
-
export type
|
|
112
|
-
|
|
93
|
+
export type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;
|
|
94
|
+
/** @deprecated use {@link ResourceKey} */
|
|
95
|
+
export type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;
|
|
96
|
+
export {};
|