@ember-data/store 5.4.0-alpha.32 → 5.4.0-alpha.34

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.
Files changed (45) hide show
  1. package/addon/-private.js +1 -1
  2. package/addon/{cache-handler-oB00-31L.js → cache-handler-k7I5KvcC.js} +11 -1
  3. package/addon/cache-handler-k7I5KvcC.js.map +1 -0
  4. package/addon/index.js +1 -1
  5. package/package.json +9 -9
  6. package/unstable-preview-types/-private/cache-handler.d.ts +99 -97
  7. package/unstable-preview-types/-private/caches/cache-utils.d.ts +10 -8
  8. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +179 -177
  9. package/unstable-preview-types/-private/caches/instance-cache.d.ts +61 -59
  10. package/unstable-preview-types/-private/caches/resource-utils.d.ts +11 -9
  11. package/unstable-preview-types/-private/document.d.ts +144 -142
  12. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +176 -174
  13. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +17 -15
  14. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +27 -25
  15. package/unstable-preview-types/-private/managers/cache-manager.d.ts +440 -438
  16. package/unstable-preview-types/-private/managers/notification-manager.d.ts +96 -94
  17. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +95 -93
  18. package/unstable-preview-types/-private/network/request-cache.d.ts +107 -105
  19. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +128 -130
  20. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -1
  21. package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts +118 -0
  22. package/unstable-preview-types/-private/record-arrays/native-proxy-type-fix.d.ts.map +1 -0
  23. package/unstable-preview-types/-private/store-service.d.ts +1501 -1499
  24. package/unstable-preview-types/-private/utils/coerce-id.d.ts +9 -7
  25. package/unstable-preview-types/-private/utils/construct-resource.d.ts +9 -7
  26. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +6 -4
  27. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +3 -1
  28. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +3 -1
  29. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +3 -1
  30. package/unstable-preview-types/-private.d.ts +18 -1
  31. package/unstable-preview-types/-private.d.ts.map +1 -1
  32. package/unstable-preview-types/-types/overview.d.ts +20 -18
  33. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +105 -103
  34. package/unstable-preview-types/-types/q/cache.d.ts +45 -43
  35. package/unstable-preview-types/-types/q/ds-model.d.ts +13 -11
  36. package/unstable-preview-types/-types/q/identifier.d.ts +167 -165
  37. package/unstable-preview-types/-types/q/promise-proxies.d.ts +3 -1
  38. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +34 -32
  39. package/unstable-preview-types/-types/q/record-instance.d.ts +28 -26
  40. package/unstable-preview-types/-types/q/schema-service.d.ts +212 -210
  41. package/unstable-preview-types/-types/q/store.d.ts +15 -13
  42. package/unstable-preview-types/index.d.ts +219 -184
  43. package/addon/cache-handler-oB00-31L.js.map +0 -1
  44. package/unstable-preview-types/-private/index.d.ts +0 -16
  45. package/unstable-preview-types/-private/index.d.ts.map +0 -1
@@ -1,440 +1,442 @@
1
- import type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive/core-types/cache';
2
- import type { Change } from '@warp-drive/core-types/cache/change';
3
- import type { CollectionRelationship, ResourceRelationship } from '@warp-drive/core-types/cache/relationship';
4
- import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph';
5
- import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
6
- import type { Value } from '@warp-drive/core-types/json/raw';
7
- import type { StructuredDataDocument, StructuredDocument } from '@warp-drive/core-types/request';
8
- import type { ResourceDocument, SingleResourceDataDocument } from '@warp-drive/core-types/spec/document';
9
- import type { ApiError } from '@warp-drive/core-types/spec/error';
10
- import type { MergeOperation } from '../../-types/q/cache';
11
- import type { JsonApiResource } from '../../-types/q/record-data-json-api';
12
- import type { StoreRequestContext } from '../cache-handler';
13
- /**
14
- * The CacheManager wraps a Cache enforcing that only
15
- * the public API surface area is exposed.
16
- *
17
- * Hence, it is the value of `Store.cache`, wrapping
18
- * the cache instance returned by `Store.createCache`.
19
- *
20
- * It handles translating between cache versions when
21
- * necessary, for instance when a Store is configured
22
- * to use both a v1 and a v2 cache depending on some
23
- * heuristic.
24
- *
25
- * Starting with the v2 spec, the cache is designed such
26
- * that it must be implemented as a singleton.
27
- *
28
- * @class CacheManager
29
- * @public
30
- */
31
- export declare class CacheManager implements Cache {
32
- #private;
33
- version: "2";
34
- constructor(cache: Cache);
35
- /**
36
- * Cache the response to a request
37
- *
38
- * Unlike `store.push` which has UPSERT
39
- * semantics, `put` has `replace` semantics similar to
40
- * the `http` method `PUT`
41
- *
42
- * the individually cacheable
43
- * e resource data it may contain
44
- * should upsert, but the document data surrounding it should
45
- * fully replace any existing information
46
- *
47
- * Note that in order to support inserting arbitrary data
48
- * to the cache that did not originate from a request `put`
49
- * should expect to sometimes encounter a document with only
50
- * a `content` member and therefor must not assume the existence
51
- * of `request` and `response` on the document.
52
- *
53
- * @method put
54
- * @param {StructuredDocument} doc
55
- * @return {ResourceDocument}
56
- * @public
57
- */
58
- put<T>(doc: StructuredDocument<T> | {
59
- content: T;
60
- }): ResourceDocument;
61
- /**
62
- * Perform an operation on the cache to update the remote state.
63
- *
64
- * Note: currently the only valid operation is a MergeOperation
65
- * which occurs when a collision of identifiers is detected.
66
- *
67
- * @method patch
68
- * @public
69
- * @param op the operation to perform
70
- * @return {void}
71
- */
72
- patch(op: MergeOperation): void;
73
- /**
74
- * Update resource data with a local mutation. Currently supports operations
75
- * on relationships only.
76
- *
77
- * @method mutate
78
- * @public
79
- * @param mutation
80
- */
81
- mutate(mutation: LocalRelationshipOperation): void;
82
- /**
83
- * Peek resource data from the Cache.
84
- *
85
- * In development, if the return value
86
- * is JSON the return value
87
- * will be deep-cloned and deep-frozen
88
- * to prevent mutation thereby enforcing cache
89
- * Immutability.
90
- *
91
- * This form of peek is useful for implementations
92
- * that want to feed raw-data from cache to the UI
93
- * or which want to interact with a blob of data
94
- * directly from the presentation cache.
95
- *
96
- * An implementation might want to do this because
97
- * de-referencing records which read from their own
98
- * blob is generally safer because the record does
99
- * not require retaining connections to the Store
100
- * and Cache to present data on a per-field basis.
101
- *
102
- * This generally takes the place of `getAttr` as
103
- * an API and may even take the place of `getRelationship`
104
- * depending on implementation specifics, though this
105
- * latter usage is less recommended due to the advantages
106
- * of the Graph handling necessary entanglements and
107
- * notifications for relational data.
108
- *
109
- * @method peek
110
- * @public
111
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
112
- * @return {ResourceDocument | ResourceBlob | null} the known resource data
113
- */
114
- peek(identifier: StableRecordIdentifier): unknown;
115
- peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
116
- /**
117
- * Peek the Cache for the existing request data associated with
118
- * a cacheable request
119
- *
120
- * @method peekRequest
121
- * @param {StableDocumentIdentifier}
122
- * @return {StableDocumentIdentifier | null}
123
- * @public
124
- */
125
- peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
126
- /**
127
- * Push resource data from a remote source into the cache for this identifier
128
- *
129
- * @method upsert
130
- * @public
131
- * @param identifier
132
- * @param data
133
- * @param hasRecord
134
- * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
135
- */
136
- upsert(identifier: StableRecordIdentifier, data: JsonApiResource, hasRecord: boolean): void | string[];
137
- /**
138
- * Create a fork of the cache from the current state.
139
- *
140
- * Applications should typically not call this method themselves,
141
- * preferring instead to fork at the Store level, which will
142
- * utilize this method to fork the cache.
143
- *
144
- * @method fork
145
- * @public
146
- * @return Promise<Cache>
147
- */
148
- fork(): Promise<Cache>;
149
- /**
150
- * Merge a fork back into a parent Cache.
151
- *
152
- * Applications should typically not call this method themselves,
153
- * preferring instead to merge at the Store level, which will
154
- * utilize this method to merge the caches.
155
- *
156
- * @method merge
157
- * @param {Cache} cache
158
- * @public
159
- * @return Promise<void>
160
- */
161
- merge(cache: Cache): Promise<void>;
162
- /**
163
- * Generate the list of changes applied to all
164
- * record in the store.
165
- *
166
- * Each individual resource or document that has
167
- * been mutated should be described as an individual
168
- * `Change` entry in the returned array.
169
- *
170
- * A `Change` is described by an object containing up to
171
- * three properties: (1) the `identifier` of the entity that
172
- * changed; (2) the `op` code of that change being one of
173
- * `upsert` or `remove`, and if the op is `upsert` a `patch`
174
- * containing the data to merge into the cache for the given
175
- * entity.
176
- *
177
- * This `patch` is opaque to the Store but should be understood
178
- * by the Cache and may expect to be utilized by an Adapter
179
- * when generating data during a `save` operation.
180
- *
181
- * It is generally recommended that the `patch` contain only
182
- * the updated state, ignoring fields that are unchanged
183
- *
184
- * ```ts
185
- * interface Change {
186
- * identifier: StableRecordIdentifier | StableDocumentIdentifier;
187
- * op: 'upsert' | 'remove';
188
- * patch?: unknown;
189
- * }
190
- * ```
191
- *
192
- * @method diff
193
- * @public
194
- */
195
- diff(): Promise<Change[]>;
196
- /**
197
- * Serialize the entire contents of the Cache into a Stream
198
- * which may be fed back into a new instance of the same Cache
199
- * via `cache.hydrate`.
200
- *
201
- * @method dump
202
- * @return {Promise<ReadableStream>}
203
- * @public
204
- */
205
- dump(): Promise<ReadableStream<unknown>>;
206
- /**
207
- * hydrate a Cache from a Stream with content previously serialized
208
- * from another instance of the same Cache, resolving when hydration
209
- * is complete.
210
- *
211
- * This method should expect to be called both in the context of restoring
212
- * the Cache during application rehydration after SSR **AND** at unknown
213
- * times during the lifetime of an already booted application when it is
214
- * desired to bulk-load additional information into the cache. This latter
215
- * behavior supports optimizing pre/fetching of data for route transitions
216
- * via data-only SSR modes.
217
- *
218
- * @method hydrate
219
- * @param {ReadableStream} stream
220
- * @return {Promise<void>}
221
- * @public
222
- */
223
- hydrate(stream: ReadableStream<unknown>): Promise<void>;
224
- /**
225
- * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
226
- *
227
- * It returns properties from options that should be set on the record during the create
228
- * process. This return value behavior is deprecated.
229
- *
230
- * @method clientDidCreate
231
- * @public
232
- * @param identifier
233
- * @param options
234
- */
235
- clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown>;
236
- /**
237
- * [LIFECYCLE] Signals to the cache that a resource
238
- * will be part of a save transaction.
239
- *
240
- * @method willCommit
241
- * @public
242
- * @param identifier
243
- */
244
- willCommit(identifier: StableRecordIdentifier, context: StoreRequestContext): void;
245
- /**
246
- * [LIFECYCLE] Signals to the cache that a resource
247
- * was successfully updated as part of a save transaction.
248
- *
249
- * @method didCommit
250
- * @public
251
- * @param identifier
252
- * @param data
253
- */
254
- didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
255
- /**
256
- * [LIFECYCLE] Signals to the cache that a resource
257
- * was update via a save transaction failed.
258
- *
259
- * @method commitWasRejected
260
- * @public
261
- * @param identifier
262
- * @param errors
263
- */
264
- commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
265
- /**
266
- * [LIFECYCLE] Signals to the cache that all data for a resource
267
- * should be cleared.
268
- *
269
- * @method unloadRecord
270
- * @public
271
- * @param identifier
272
- */
273
- unloadRecord(identifier: StableRecordIdentifier): void;
274
- /**
275
- * Retrieve the data for an attribute from the cache
276
- *
277
- * @method getAttr
278
- * @public
279
- * @param identifier
280
- * @param propertyName
281
- * @return {unknown}
282
- */
283
- getAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
284
- /**
285
- * Mutate the data for an attribute in the cache
286
- *
287
- * @method setAttr
288
- * @public
289
- * @param identifier
290
- * @param propertyName
291
- * @param value
292
- */
293
- setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void;
294
- /**
295
- * Query the cache for the changed attributes of a resource.
296
- *
297
- * @method changedAttrs
298
- * @public
299
- * @param identifier
300
- * @return
301
- */
302
- changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
303
- /**
304
- * Query the cache for whether any mutated attributes exist
305
- *
306
- * @method hasChangedAttrs
307
- * @public
308
- * @param identifier
309
- * @return {boolean}
310
- */
311
- hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
312
- /**
313
- * Tell the cache to discard any uncommitted mutations to attributes
314
- *
315
- * @method rollbackAttrs
316
- * @public
317
- * @param identifier
318
- * @return the names of attributes that were restored
319
- */
320
- rollbackAttrs(identifier: StableRecordIdentifier): string[];
321
- /**
322
- * Query the cache for the changes to relationships of a resource.
323
- *
324
- * Returns a map of relationship names to RelationshipDiff objects.
325
- *
326
- * ```ts
327
- * type RelationshipDiff =
328
- | {
329
- kind: 'collection';
330
- remoteState: StableRecordIdentifier[];
331
- additions: Set<StableRecordIdentifier>;
332
- removals: Set<StableRecordIdentifier>;
333
- localState: StableRecordIdentifier[];
334
- reordered: boolean;
335
- }
336
- | {
337
- kind: 'resource';
338
- remoteState: StableRecordIdentifier | null;
339
- localState: StableRecordIdentifier | null;
340
- };
341
- ```
342
- *
343
- * @method changedRelationships
344
- * @public
345
- * @param {StableRecordIdentifier} identifier
346
- * @return {Map<string, RelationshipDiff>}
347
- */
348
- changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
349
- /**
350
- * Query the cache for whether any mutated attributes exist
351
- *
352
- * @method hasChangedRelationships
353
- * @public
354
- * @param {StableRecordIdentifier} identifier
355
- * @return {boolean}
356
- */
357
- hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
358
- /**
359
- * Tell the cache to discard any uncommitted mutations to relationships.
360
- *
361
- * This will also discard the change on any appropriate inverses.
362
- *
363
- * This method is a candidate to become a mutation
364
- *
365
- * @method rollbackRelationships
366
- * @public
367
- * @param {StableRecordIdentifier} identifier
368
- * @return {string[]} the names of relationships that were restored
369
- */
370
- rollbackRelationships(identifier: StableRecordIdentifier): string[];
371
- /**
372
- * Query the cache for the current state of a relationship property
373
- *
374
- * @method getRelationship
375
- * @public
376
- * @param identifier
377
- * @param propertyName
378
- * @return resource relationship object
379
- */
380
- getRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
381
- /**
382
- * Update the cache state for the given resource to be marked as locally deleted,
383
- * or remove such a mark.
384
- *
385
- * @method setIsDeleted
386
- * @public
387
- * @param identifier
388
- * @param isDeleted
389
- */
390
- setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
391
- /**
392
- * Query the cache for any validation errors applicable to the given resource.
393
- *
394
- * @method getErrors
395
- * @public
396
- * @param identifier
397
- * @return
398
- */
399
- getErrors(identifier: StableRecordIdentifier): ApiError[];
400
- /**
401
- * Query the cache for whether a given resource has any available data
402
- *
403
- * @method isEmpty
404
- * @public
405
- * @param identifier
406
- * @return {boolean}
407
- */
408
- isEmpty(identifier: StableRecordIdentifier): boolean;
409
- /**
410
- * Query the cache for whether a given resource was created locally and not
411
- * yet persisted.
412
- *
413
- * @method isNew
414
- * @public
415
- * @param identifier
416
- * @return {boolean}
417
- */
418
- isNew(identifier: StableRecordIdentifier): boolean;
419
- /**
420
- * Query the cache for whether a given resource is marked as deleted (but not
421
- * necessarily persisted yet).
422
- *
423
- * @method isDeleted
424
- * @public
425
- * @param identifier
426
- * @return {boolean}
427
- */
428
- isDeleted(identifier: StableRecordIdentifier): boolean;
429
- /**
430
- * Query the cache for whether a given resource has been deleted and that deletion
431
- * has also been persisted.
432
- *
433
- * @method isDeletionCommitted
434
- * @public
435
- * @param identifier
436
- * @return {boolean}
437
- */
438
- isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
1
+ declare module '@ember-data/store/-private/managers/cache-manager' {
2
+ import type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive/core-types/cache';
3
+ import type { Change } from '@warp-drive/core-types/cache/change';
4
+ import type { CollectionRelationship, ResourceRelationship } from '@warp-drive/core-types/cache/relationship';
5
+ import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph';
6
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
7
+ import type { Value } from '@warp-drive/core-types/json/raw';
8
+ import type { StructuredDataDocument, StructuredDocument } from '@warp-drive/core-types/request';
9
+ import type { ResourceDocument, SingleResourceDataDocument } from '@warp-drive/core-types/spec/document';
10
+ import type { ApiError } from '@warp-drive/core-types/spec/error';
11
+ import type { MergeOperation } from '@ember-data/store/-types/q/cache';
12
+ import type { JsonApiResource } from '@ember-data/store/-types/q/record-data-json-api';
13
+ import type { StoreRequestContext } from '@ember-data/store/-private/cache-handler';
14
+ /**
15
+ * The CacheManager wraps a Cache enforcing that only
16
+ * the public API surface area is exposed.
17
+ *
18
+ * Hence, it is the value of `Store.cache`, wrapping
19
+ * the cache instance returned by `Store.createCache`.
20
+ *
21
+ * It handles translating between cache versions when
22
+ * necessary, for instance when a Store is configured
23
+ * to use both a v1 and a v2 cache depending on some
24
+ * heuristic.
25
+ *
26
+ * Starting with the v2 spec, the cache is designed such
27
+ * that it must be implemented as a singleton.
28
+ *
29
+ * @class CacheManager
30
+ * @public
31
+ */
32
+ export declare class CacheManager implements Cache {
33
+ #private;
34
+ version: "2";
35
+ constructor(cache: Cache);
36
+ /**
37
+ * Cache the response to a request
38
+ *
39
+ * Unlike `store.push` which has UPSERT
40
+ * semantics, `put` has `replace` semantics similar to
41
+ * the `http` method `PUT`
42
+ *
43
+ * the individually cacheable
44
+ * e resource data it may contain
45
+ * should upsert, but the document data surrounding it should
46
+ * fully replace any existing information
47
+ *
48
+ * Note that in order to support inserting arbitrary data
49
+ * to the cache that did not originate from a request `put`
50
+ * should expect to sometimes encounter a document with only
51
+ * a `content` member and therefor must not assume the existence
52
+ * of `request` and `response` on the document.
53
+ *
54
+ * @method put
55
+ * @param {StructuredDocument} doc
56
+ * @return {ResourceDocument}
57
+ * @public
58
+ */
59
+ put<T>(doc: StructuredDocument<T> | {
60
+ content: T;
61
+ }): ResourceDocument;
62
+ /**
63
+ * Perform an operation on the cache to update the remote state.
64
+ *
65
+ * Note: currently the only valid operation is a MergeOperation
66
+ * which occurs when a collision of identifiers is detected.
67
+ *
68
+ * @method patch
69
+ * @public
70
+ * @param op the operation to perform
71
+ * @return {void}
72
+ */
73
+ patch(op: MergeOperation): void;
74
+ /**
75
+ * Update resource data with a local mutation. Currently supports operations
76
+ * on relationships only.
77
+ *
78
+ * @method mutate
79
+ * @public
80
+ * @param mutation
81
+ */
82
+ mutate(mutation: LocalRelationshipOperation): void;
83
+ /**
84
+ * Peek resource data from the Cache.
85
+ *
86
+ * In development, if the return value
87
+ * is JSON the return value
88
+ * will be deep-cloned and deep-frozen
89
+ * to prevent mutation thereby enforcing cache
90
+ * Immutability.
91
+ *
92
+ * This form of peek is useful for implementations
93
+ * that want to feed raw-data from cache to the UI
94
+ * or which want to interact with a blob of data
95
+ * directly from the presentation cache.
96
+ *
97
+ * An implementation might want to do this because
98
+ * de-referencing records which read from their own
99
+ * blob is generally safer because the record does
100
+ * not require retaining connections to the Store
101
+ * and Cache to present data on a per-field basis.
102
+ *
103
+ * This generally takes the place of `getAttr` as
104
+ * an API and may even take the place of `getRelationship`
105
+ * depending on implementation specifics, though this
106
+ * latter usage is less recommended due to the advantages
107
+ * of the Graph handling necessary entanglements and
108
+ * notifications for relational data.
109
+ *
110
+ * @method peek
111
+ * @public
112
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
113
+ * @return {ResourceDocument | ResourceBlob | null} the known resource data
114
+ */
115
+ peek(identifier: StableRecordIdentifier): unknown;
116
+ peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
117
+ /**
118
+ * Peek the Cache for the existing request data associated with
119
+ * a cacheable request
120
+ *
121
+ * @method peekRequest
122
+ * @param {StableDocumentIdentifier}
123
+ * @return {StableDocumentIdentifier | null}
124
+ * @public
125
+ */
126
+ peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
127
+ /**
128
+ * Push resource data from a remote source into the cache for this identifier
129
+ *
130
+ * @method upsert
131
+ * @public
132
+ * @param identifier
133
+ * @param data
134
+ * @param hasRecord
135
+ * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
136
+ */
137
+ upsert(identifier: StableRecordIdentifier, data: JsonApiResource, hasRecord: boolean): void | string[];
138
+ /**
139
+ * Create a fork of the cache from the current state.
140
+ *
141
+ * Applications should typically not call this method themselves,
142
+ * preferring instead to fork at the Store level, which will
143
+ * utilize this method to fork the cache.
144
+ *
145
+ * @method fork
146
+ * @public
147
+ * @return Promise<Cache>
148
+ */
149
+ fork(): Promise<Cache>;
150
+ /**
151
+ * Merge a fork back into a parent Cache.
152
+ *
153
+ * Applications should typically not call this method themselves,
154
+ * preferring instead to merge at the Store level, which will
155
+ * utilize this method to merge the caches.
156
+ *
157
+ * @method merge
158
+ * @param {Cache} cache
159
+ * @public
160
+ * @return Promise<void>
161
+ */
162
+ merge(cache: Cache): Promise<void>;
163
+ /**
164
+ * Generate the list of changes applied to all
165
+ * record in the store.
166
+ *
167
+ * Each individual resource or document that has
168
+ * been mutated should be described as an individual
169
+ * `Change` entry in the returned array.
170
+ *
171
+ * A `Change` is described by an object containing up to
172
+ * three properties: (1) the `identifier` of the entity that
173
+ * changed; (2) the `op` code of that change being one of
174
+ * `upsert` or `remove`, and if the op is `upsert` a `patch`
175
+ * containing the data to merge into the cache for the given
176
+ * entity.
177
+ *
178
+ * This `patch` is opaque to the Store but should be understood
179
+ * by the Cache and may expect to be utilized by an Adapter
180
+ * when generating data during a `save` operation.
181
+ *
182
+ * It is generally recommended that the `patch` contain only
183
+ * the updated state, ignoring fields that are unchanged
184
+ *
185
+ * ```ts
186
+ * interface Change {
187
+ * identifier: StableRecordIdentifier | StableDocumentIdentifier;
188
+ * op: 'upsert' | 'remove';
189
+ * patch?: unknown;
190
+ * }
191
+ * ```
192
+ *
193
+ * @method diff
194
+ * @public
195
+ */
196
+ diff(): Promise<Change[]>;
197
+ /**
198
+ * Serialize the entire contents of the Cache into a Stream
199
+ * which may be fed back into a new instance of the same Cache
200
+ * via `cache.hydrate`.
201
+ *
202
+ * @method dump
203
+ * @return {Promise<ReadableStream>}
204
+ * @public
205
+ */
206
+ dump(): Promise<ReadableStream<unknown>>;
207
+ /**
208
+ * hydrate a Cache from a Stream with content previously serialized
209
+ * from another instance of the same Cache, resolving when hydration
210
+ * is complete.
211
+ *
212
+ * This method should expect to be called both in the context of restoring
213
+ * the Cache during application rehydration after SSR **AND** at unknown
214
+ * times during the lifetime of an already booted application when it is
215
+ * desired to bulk-load additional information into the cache. This latter
216
+ * behavior supports optimizing pre/fetching of data for route transitions
217
+ * via data-only SSR modes.
218
+ *
219
+ * @method hydrate
220
+ * @param {ReadableStream} stream
221
+ * @return {Promise<void>}
222
+ * @public
223
+ */
224
+ hydrate(stream: ReadableStream<unknown>): Promise<void>;
225
+ /**
226
+ * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
227
+ *
228
+ * It returns properties from options that should be set on the record during the create
229
+ * process. This return value behavior is deprecated.
230
+ *
231
+ * @method clientDidCreate
232
+ * @public
233
+ * @param identifier
234
+ * @param options
235
+ */
236
+ clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown>;
237
+ /**
238
+ * [LIFECYCLE] Signals to the cache that a resource
239
+ * will be part of a save transaction.
240
+ *
241
+ * @method willCommit
242
+ * @public
243
+ * @param identifier
244
+ */
245
+ willCommit(identifier: StableRecordIdentifier, context: StoreRequestContext): void;
246
+ /**
247
+ * [LIFECYCLE] Signals to the cache that a resource
248
+ * was successfully updated as part of a save transaction.
249
+ *
250
+ * @method didCommit
251
+ * @public
252
+ * @param identifier
253
+ * @param data
254
+ */
255
+ didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
256
+ /**
257
+ * [LIFECYCLE] Signals to the cache that a resource
258
+ * was update via a save transaction failed.
259
+ *
260
+ * @method commitWasRejected
261
+ * @public
262
+ * @param identifier
263
+ * @param errors
264
+ */
265
+ commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
266
+ /**
267
+ * [LIFECYCLE] Signals to the cache that all data for a resource
268
+ * should be cleared.
269
+ *
270
+ * @method unloadRecord
271
+ * @public
272
+ * @param identifier
273
+ */
274
+ unloadRecord(identifier: StableRecordIdentifier): void;
275
+ /**
276
+ * Retrieve the data for an attribute from the cache
277
+ *
278
+ * @method getAttr
279
+ * @public
280
+ * @param identifier
281
+ * @param propertyName
282
+ * @return {unknown}
283
+ */
284
+ getAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
285
+ /**
286
+ * Mutate the data for an attribute in the cache
287
+ *
288
+ * @method setAttr
289
+ * @public
290
+ * @param identifier
291
+ * @param propertyName
292
+ * @param value
293
+ */
294
+ setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void;
295
+ /**
296
+ * Query the cache for the changed attributes of a resource.
297
+ *
298
+ * @method changedAttrs
299
+ * @public
300
+ * @param identifier
301
+ * @return
302
+ */
303
+ changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
304
+ /**
305
+ * Query the cache for whether any mutated attributes exist
306
+ *
307
+ * @method hasChangedAttrs
308
+ * @public
309
+ * @param identifier
310
+ * @return {boolean}
311
+ */
312
+ hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
313
+ /**
314
+ * Tell the cache to discard any uncommitted mutations to attributes
315
+ *
316
+ * @method rollbackAttrs
317
+ * @public
318
+ * @param identifier
319
+ * @return the names of attributes that were restored
320
+ */
321
+ rollbackAttrs(identifier: StableRecordIdentifier): string[];
322
+ /**
323
+ * Query the cache for the changes to relationships of a resource.
324
+ *
325
+ * Returns a map of relationship names to RelationshipDiff objects.
326
+ *
327
+ * ```ts
328
+ * type RelationshipDiff =
329
+ | {
330
+ kind: 'collection';
331
+ remoteState: StableRecordIdentifier[];
332
+ additions: Set<StableRecordIdentifier>;
333
+ removals: Set<StableRecordIdentifier>;
334
+ localState: StableRecordIdentifier[];
335
+ reordered: boolean;
336
+ }
337
+ | {
338
+ kind: 'resource';
339
+ remoteState: StableRecordIdentifier | null;
340
+ localState: StableRecordIdentifier | null;
341
+ };
342
+ ```
343
+ *
344
+ * @method changedRelationships
345
+ * @public
346
+ * @param {StableRecordIdentifier} identifier
347
+ * @return {Map<string, RelationshipDiff>}
348
+ */
349
+ changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
350
+ /**
351
+ * Query the cache for whether any mutated attributes exist
352
+ *
353
+ * @method hasChangedRelationships
354
+ * @public
355
+ * @param {StableRecordIdentifier} identifier
356
+ * @return {boolean}
357
+ */
358
+ hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
359
+ /**
360
+ * Tell the cache to discard any uncommitted mutations to relationships.
361
+ *
362
+ * This will also discard the change on any appropriate inverses.
363
+ *
364
+ * This method is a candidate to become a mutation
365
+ *
366
+ * @method rollbackRelationships
367
+ * @public
368
+ * @param {StableRecordIdentifier} identifier
369
+ * @return {string[]} the names of relationships that were restored
370
+ */
371
+ rollbackRelationships(identifier: StableRecordIdentifier): string[];
372
+ /**
373
+ * Query the cache for the current state of a relationship property
374
+ *
375
+ * @method getRelationship
376
+ * @public
377
+ * @param identifier
378
+ * @param propertyName
379
+ * @return resource relationship object
380
+ */
381
+ getRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
382
+ /**
383
+ * Update the cache state for the given resource to be marked as locally deleted,
384
+ * or remove such a mark.
385
+ *
386
+ * @method setIsDeleted
387
+ * @public
388
+ * @param identifier
389
+ * @param isDeleted
390
+ */
391
+ setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
392
+ /**
393
+ * Query the cache for any validation errors applicable to the given resource.
394
+ *
395
+ * @method getErrors
396
+ * @public
397
+ * @param identifier
398
+ * @return
399
+ */
400
+ getErrors(identifier: StableRecordIdentifier): ApiError[];
401
+ /**
402
+ * Query the cache for whether a given resource has any available data
403
+ *
404
+ * @method isEmpty
405
+ * @public
406
+ * @param identifier
407
+ * @return {boolean}
408
+ */
409
+ isEmpty(identifier: StableRecordIdentifier): boolean;
410
+ /**
411
+ * Query the cache for whether a given resource was created locally and not
412
+ * yet persisted.
413
+ *
414
+ * @method isNew
415
+ * @public
416
+ * @param identifier
417
+ * @return {boolean}
418
+ */
419
+ isNew(identifier: StableRecordIdentifier): boolean;
420
+ /**
421
+ * Query the cache for whether a given resource is marked as deleted (but not
422
+ * necessarily persisted yet).
423
+ *
424
+ * @method isDeleted
425
+ * @public
426
+ * @param identifier
427
+ * @return {boolean}
428
+ */
429
+ isDeleted(identifier: StableRecordIdentifier): boolean;
430
+ /**
431
+ * Query the cache for whether a given resource has been deleted and that deletion
432
+ * has also been persisted.
433
+ *
434
+ * @method isDeletionCommitted
435
+ * @public
436
+ * @param identifier
437
+ * @return {boolean}
438
+ */
439
+ isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
440
+ }
439
441
  }
440
442
  //# sourceMappingURL=cache-manager.d.ts.map