@warp-drive/core 5.7.0-alpha.14 → 5.7.0-alpha.15

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 (69) hide show
  1. package/declarations/graph/-private/-diff.d.ts +8 -8
  2. package/declarations/graph/-private/-edge-definition.d.ts +2 -2
  3. package/declarations/graph/-private/-state.d.ts +2 -2
  4. package/declarations/graph/-private/-utils.d.ts +5 -5
  5. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
  6. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  7. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  8. package/declarations/graph/-private/edges/resource.d.ts +5 -5
  9. package/declarations/graph/-private/graph.d.ts +15 -15
  10. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
  11. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
  12. package/declarations/index.d.ts +1 -1
  13. package/declarations/reactive/-private/default-mode.d.ts +2 -2
  14. package/declarations/reactive/-private/document.d.ts +6 -16
  15. package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
  16. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  17. package/declarations/reactive/-private/hooks.d.ts +2 -2
  18. package/declarations/reactive/-private/record.d.ts +44 -5
  19. package/declarations/reactive/-private/schema.d.ts +12 -12
  20. package/declarations/reactive/-private/symbols.d.ts +1 -0
  21. package/declarations/reactive.d.ts +277 -1
  22. package/declarations/request/-private/context.d.ts +2 -2
  23. package/declarations/request/-private/manager.d.ts +2 -2
  24. package/declarations/request/-private/types.d.ts +4 -4
  25. package/declarations/store/-private/cache-handler/types.d.ts +9 -9
  26. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  27. package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
  28. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  29. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
  30. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
  31. package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
  32. package/declarations/store/-private/managers/notification-manager.d.ts +21 -22
  33. package/declarations/store/-private/managers/record-array-manager.d.ts +15 -15
  34. package/declarations/store/-private/network/request-cache.d.ts +11 -11
  35. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  36. package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
  37. package/declarations/store/-private/record-arrays/-utils.d.ts +3 -3
  38. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +2 -2
  39. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +2 -2
  40. package/declarations/store/-private/record-arrays/resource-array.d.ts +9 -9
  41. package/declarations/store/-private/store-service.d.ts +19 -16
  42. package/declarations/store/-private.d.ts +1 -1
  43. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  44. package/declarations/store/-types/q/identifier.d.ts +9 -6
  45. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  46. package/declarations/store/deprecated/-private.d.ts +5 -5
  47. package/declarations/types/-private.d.ts +1 -1
  48. package/declarations/types/cache/aliases.d.ts +2 -2
  49. package/declarations/types/cache/change.d.ts +2 -2
  50. package/declarations/types/cache/mutations.d.ts +13 -13
  51. package/declarations/types/cache/operations.d.ts +20 -20
  52. package/declarations/types/cache/relationship.d.ts +4 -4
  53. package/declarations/types/cache.d.ts +51 -113
  54. package/declarations/types/graph.d.ts +12 -12
  55. package/declarations/types/identifier.d.ts +60 -76
  56. package/declarations/types/request.d.ts +6 -6
  57. package/declarations/types/schema/concepts.d.ts +2 -2
  58. package/declarations/types/spec/document.d.ts +6 -6
  59. package/dist/graph/-private.js +125 -125
  60. package/dist/index.js +2 -2
  61. package/dist/reactive/-private.js +1 -1
  62. package/dist/reactive.js +126 -4
  63. package/dist/{request-state-CCrTjb0Z.js → request-state-CQ0Q6d1V.js} +3493 -3483
  64. package/dist/store/-private.js +1 -1
  65. package/dist/store.js +30 -43
  66. package/dist/{symbols-C5p2hcy9.js → symbols-sql1_mdx.js} +2 -1
  67. package/dist/types/-private.js +1 -1
  68. package/dist/types/identifier.js +19 -45
  69. package/package.json +3 -3
@@ -1,25 +1,27 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import type { ResourceKey, RequestKey } from "../../../types/identifier.js";
2
2
  import type { CacheCapabilitiesManager as StoreWrapper } from "../../-types/q/cache-capabilities-manager.js";
3
3
  import type { SchemaService } from "../../-types/q/schema-service.js";
4
- import type { IdentifierCache } from "../caches/identifier-cache.js";
5
4
  import type { Store } from "../store-service.js";
5
+ import type { CacheKeyManager } from "./cache-key-manager.js";
6
6
  import type { NotificationType } from "./notification-manager.js";
7
7
  export interface CacheCapabilitiesManager {
8
8
  getSchemaDefinitionService(): SchemaService;
9
9
  }
10
10
  export declare class CacheCapabilitiesManager implements StoreWrapper {
11
11
  _willNotify: boolean;
12
- _pendingNotifies: Map<StableRecordIdentifier, Set<string>>;
12
+ _pendingNotifies: Map<ResourceKey, Set<string>>;
13
13
  _store: Store;
14
14
  constructor(_store: Store);
15
- get identifierCache(): IdentifierCache;
16
- _scheduleNotification(identifier: StableRecordIdentifier, key: string): void;
15
+ get cacheKeyManager(): CacheKeyManager;
16
+ /** @deprecated use {@link CacheCapabilitiesManager.cacheKeyManager} */
17
+ get identifierCache(): CacheKeyManager;
18
+ _scheduleNotification(identifier: ResourceKey, key: string): void;
17
19
  _flushNotifications(): void;
18
- notifyChange(identifier: StableRecordIdentifier, namespace: "added" | "removed", key: null): void;
19
- notifyChange(identifier: StableDocumentIdentifier, namespace: "added" | "updated" | "removed", key: null): void;
20
- notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key: string | null): void;
20
+ notifyChange(identifier: ResourceKey, namespace: "added" | "removed", key: null): void;
21
+ notifyChange(identifier: RequestKey, namespace: "added" | "updated" | "removed", key: null): void;
22
+ notifyChange(identifier: ResourceKey, namespace: NotificationType, key: string | null): void;
21
23
  get schema(): SchemaService;
22
- setRecordId(identifier: StableRecordIdentifier, id: string): void;
23
- hasRecord(identifier: StableRecordIdentifier): boolean;
24
- disconnectRecord(identifier: StableRecordIdentifier): void;
24
+ setRecordId(identifier: ResourceKey, id: string): void;
25
+ hasRecord(identifier: ResourceKey): boolean;
26
+ disconnectRecord(identifier: ResourceKey): void;
25
27
  }
@@ -1,13 +1,13 @@
1
- import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableExistingRecordIdentifier, type StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import { type PersistedResourceKey, type ResourceKey, type RequestKey } from "../../../types/identifier.js";
2
2
  import type { ImmutableRequestInfo } from "../../../types/request.js";
3
3
  import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
4
4
  import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from "../../-types/q/identifier.js";
5
5
  type TypeFromIdentifier<T> = T extends {
6
6
  type: infer U;
7
7
  } ? U : string;
8
- type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ? StableExistingRecordIdentifier<TypeFromIdentifier<T>> : StableRecordIdentifier;
9
- export declare function isStableIdentifier(identifier: unknown): identifier is StableRecordIdentifier;
10
- export declare function isDocumentIdentifier(identifier: unknown): identifier is StableDocumentIdentifier;
8
+ type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ? PersistedResourceKey<TypeFromIdentifier<T>> : ResourceKey;
9
+ export declare function isResourceKey(identifier: unknown): identifier is ResourceKey;
10
+ export declare function isRequestKey(identifier: unknown): identifier is RequestKey;
11
11
  interface KeyOptions {
12
12
  lid: IdentifierMap;
13
13
  id: IdentifierMap;
@@ -15,16 +15,16 @@ interface KeyOptions {
15
15
  type TypeMap = {
16
16
  [key: string]: KeyOptions;
17
17
  };
18
- // type IdentifierTypeLookup = { all: Set<StableRecordIdentifier>; id: Map<string, StableRecordIdentifier> };
18
+ // type IdentifierTypeLookup = { all: Set<ResourceKey>; id: Map<string, ResourceKey> };
19
19
  // type IdentifiersByType = Map<string, IdentifierTypeLookup>;
20
- type IdentifierMap = Map<string, StableRecordIdentifier>;
20
+ type IdentifierMap = Map<string, ResourceKey>;
21
21
  type StableCache = {
22
22
  resources: IdentifierMap;
23
- documents: Map<string, StableDocumentIdentifier>;
23
+ documents: Map<string, RequestKey>;
24
24
  resourcesByType: TypeMap;
25
25
  polymorphicLidBackMap: Map<string, string[]>;
26
26
  };
27
- export type MergeMethod = (targetIdentifier: StableRecordIdentifier, matchedIdentifier: StableRecordIdentifier, resourceData: unknown) => StableRecordIdentifier;
27
+ export type MergeMethod = (targetIdentifier: ResourceKey, matchedIdentifier: ResourceKey, resourceData: unknown) => ResourceKey;
28
28
  /**
29
29
  Configures how unique identifier lid strings are generated by @ember-data/store.
30
30
 
@@ -163,10 +163,10 @@ to the application instance, you may not need to implement the `resetMethod`.
163
163
  export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
164
164
  /**
165
165
  Configure a callback for when the identifier cache is generating a new
166
- StableRecordIdentifier for a resource.
166
+ ResourceKey for a resource.
167
167
 
168
168
  This method controls the `type` and `id` that will be assigned to the
169
- `StableRecordIdentifier` that is created.
169
+ `ResourceKey` that is created.
170
170
 
171
171
  This configuration MUST occur prior to the store instance being created.
172
172
 
@@ -178,7 +178,7 @@ import { setKeyInfoForResource } from '@warp-drive/core';
178
178
  */
179
179
  export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
180
180
  /**
181
- * Each instance of {@link Store} receives a unique instance of a IdentifierCache.
181
+ * Each instance of {@link Store} receives a unique instance of a CacheKeyManager.
182
182
  *
183
183
  * This cache is responsible for assigning or retrieving the unique identify
184
184
  * for arbitrary resource data encountered by the store. Data representing
@@ -190,7 +190,7 @@ export declare function setKeyInfoForResource(method: KeyInfoMethod | null): voi
190
190
  * @hideconstructor
191
191
  * @public
192
192
  */
193
- export declare class IdentifierCache {
193
+ export declare class CacheKeyManager {
194
194
  /** @internal */
195
195
  _cache: StableCache;
196
196
  private _generate;
@@ -215,7 +215,7 @@ export declare class IdentifierCache {
215
215
  type: string;
216
216
  id: string | null;
217
217
  lid?: string;
218
- }): StableRecordIdentifier;
218
+ }): ResourceKey;
219
219
  /**
220
220
  * @private
221
221
  */
@@ -229,14 +229,14 @@ export declare class IdentifierCache {
229
229
  *
230
230
  * @private
231
231
  */
232
- peekRecordIdentifier(resource: ResourceIdentifierObject | Identifier): StableRecordIdentifier | undefined;
232
+ peekRecordIdentifier(resource: ResourceIdentifierObject): ResourceKey | undefined;
233
233
  /**
234
234
  Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
235
235
  Returns `null` if the request does not have a `cacheKey` or `url`.
236
236
 
237
237
  @public
238
238
  */
239
- getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): StableDocumentIdentifier | null;
239
+ getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): RequestKey | null;
240
240
  /**
241
241
  Returns the Identifier for the given Resource, creates one if it does not yet exist.
242
242
 
@@ -264,7 +264,7 @@ export declare class IdentifierCache {
264
264
  type: string;
265
265
  id?: string | null;
266
266
  lid?: string;
267
- }): StableRecordIdentifier;
267
+ }): ResourceKey;
268
268
  /**
269
269
  Provides the opportunity to update secondary lookup tables for existing identifiers
270
270
  Called after an identifier created with `createIdentifierForNewRecord` has been
@@ -283,11 +283,12 @@ export declare class IdentifierCache {
283
283
 
284
284
  @public
285
285
  */
286
- updateRecordIdentifier(identifierObject: RecordIdentifier, data: unknown): StableRecordIdentifier;
286
+ // FIXME audit usage
287
+ updateRecordIdentifier(identifierObject: ResourceKey, data: unknown): ResourceKey;
287
288
  /**
288
289
  * @private
289
290
  */
290
- _mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
291
+ _mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: ResourceKey, existingIdentifier: ResourceKey, data: unknown): ResourceKey;
291
292
  /**
292
293
  Provides the opportunity to eliminate an identifier from secondary lookup tables
293
294
  as well as eliminates it from ember-data's own lookup tables and book keeping.
@@ -298,7 +299,8 @@ export declare class IdentifierCache {
298
299
 
299
300
  @public
300
301
  */
301
- forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
302
+ // FIXME audit usage
303
+ forgetRecordIdentifier(identifierObject: ResourceKey): void;
302
304
  /** @internal */
303
305
  destroy(): void;
304
306
  }
@@ -1,9 +1,9 @@
1
1
  import type { Cache, ChangedAttributesHash, RelationshipDiff } from "../../../types/cache.js";
2
2
  import type { Change } from "../../../types/cache/change.js";
3
- import type { MergeOperation } from "../../../types/cache/operations.js";
3
+ import type { Operation } from "../../../types/cache/operations.js";
4
4
  import type { CollectionRelationship, ResourceRelationship } from "../../../types/cache/relationship.js";
5
5
  import type { LocalRelationshipOperation } from "../../../types/graph.js";
6
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
6
+ import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
7
7
  import type { Value } from "../../../types/json/raw.js";
8
8
  import type { StructuredDataDocument, StructuredDocument } from "../../../types/request.js";
9
9
  import type { ResourceDocument, SingleResourceDataDocument } from "../../../types/spec/document.js";
@@ -61,14 +61,11 @@ export declare class CacheManager implements Cache {
61
61
  /**
62
62
  * Perform an operation on the cache to update the remote state.
63
63
  *
64
- * Note: currently the only valid operation is a MergeOperation
65
- * which occurs when a collision of identifiers is detected.
66
- *
67
64
  * @public
68
65
  * @param op the operation to perform
69
66
  * @return {void}
70
67
  */
71
- patch(op: MergeOperation): void;
68
+ patch(op: Operation | Operation[]): void;
72
69
  /**
73
70
  * Update resource data with a local mutation. Currently supports operations
74
71
  * on relationships only.
@@ -105,32 +102,29 @@ export declare class CacheManager implements Cache {
105
102
  * notifications for relational data.
106
103
  *
107
104
  * @public
108
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
105
+ * @param {ResourceKey | RequestKey} cacheKey
109
106
  * @return {ResourceDocument | ResourceBlob | null} the known resource data
110
107
  */
111
- peek(identifier: StableRecordIdentifier): unknown;
112
- peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
113
- peekRemoteState(identifier: StableRecordIdentifier): unknown;
114
- peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
108
+ peek(cacheKey: ResourceKey): unknown;
109
+ peek(cacheKey: RequestKey): ResourceDocument | null;
110
+ peekRemoteState(cacheKey: ResourceKey): unknown;
111
+ peekRemoteState(cacheKey: RequestKey): ResourceDocument | null;
115
112
  /**
116
113
  * Peek the Cache for the existing request data associated with
117
114
  * a cacheable request
118
115
  *
119
- * @param {StableDocumentIdentifier}
120
- * @return {StableDocumentIdentifier | null}
116
+ * @param {RequestKey}
117
+ * @return {RequestKey | null}
121
118
  * @public
122
119
  */
123
- peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
120
+ peekRequest(key: RequestKey): StructuredDocument<ResourceDocument> | null;
124
121
  /**
125
- * Push resource data from a remote source into the cache for this identifier
122
+ * Push resource data from a remote source into the cache for this ResourceKey
126
123
  *
127
124
  * @public
128
- * @param identifier
129
- * @param data
130
- * @param hasRecord
131
- * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
125
+ * @return if `hasRecord` is true then calculated key changes should be returned
132
126
  */
133
- upsert(identifier: StableRecordIdentifier, data: unknown, hasRecord: boolean): void | string[];
127
+ upsert(key: ResourceKey, data: unknown, hasRecord: boolean): void | string[];
134
128
  // Cache Forking Support
135
129
  // =====================
136
130
  /**
@@ -165,7 +159,7 @@ export declare class CacheManager implements Cache {
165
159
  * `Change` entry in the returned array.
166
160
  *
167
161
  * A `Change` is described by an object containing up to
168
- * three properties: (1) the `identifier` of the entity that
162
+ * three properties: (1) the `ResourceKey` of the entity that
169
163
  * changed; (2) the `op` code of that change being one of
170
164
  * `upsert` or `remove`, and if the op is `upsert` a `patch`
171
165
  * containing the data to merge into the cache for the given
@@ -180,7 +174,7 @@ export declare class CacheManager implements Cache {
180
174
  *
181
175
  * ```ts
182
176
  * interface Change {
183
- * identifier: StableRecordIdentifier | StableDocumentIdentifier;
177
+ * key: ResourceKey | RequestKey;
184
178
  * op: 'upsert' | 'remove';
185
179
  * patch?: unknown;
186
180
  * }
@@ -228,97 +222,76 @@ export declare class CacheManager implements Cache {
228
222
  * process. This return value behavior is deprecated.
229
223
  *
230
224
  * @public
231
- * @param identifier
232
- * @param options
233
225
  */
234
- clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown>;
226
+ clientDidCreate(key: ResourceKey, options?: Record<string, unknown>): Record<string, unknown>;
235
227
  /**
236
228
  * [LIFECYCLE] Signals to the cache that a resource
237
229
  * will be part of a save transaction.
238
230
  *
239
231
  * @public
240
- * @param identifier
232
+ * @param key
241
233
  */
242
- willCommit(identifier: StableRecordIdentifier, context: StoreRequestContext): void;
234
+ willCommit(key: ResourceKey, context: StoreRequestContext): void;
243
235
  /**
244
236
  * [LIFECYCLE] Signals to the cache that a resource
245
237
  * was successfully updated as part of a save transaction.
246
238
  *
247
239
  * @public
248
- * @param identifier
249
- * @param data
250
240
  */
251
- didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
241
+ didCommit(key: ResourceKey, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
252
242
  /**
253
243
  * [LIFECYCLE] Signals to the cache that a resource
254
244
  * was update via a save transaction failed.
255
245
  *
256
246
  * @public
257
- * @param identifier
258
- * @param errors
259
247
  */
260
- commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
248
+ commitWasRejected(key: ResourceKey, errors?: ApiError[]): void;
261
249
  /**
262
250
  * [LIFECYCLE] Signals to the cache that all data for a resource
263
251
  * should be cleared.
264
252
  *
265
253
  * @public
266
- * @param identifier
267
254
  */
268
- unloadRecord(identifier: StableRecordIdentifier): void;
255
+ unloadRecord(key: ResourceKey): void;
269
256
  // Granular Resource Data APIs
270
257
  // ===========================
271
258
  /**
272
259
  * Retrieve the data for an attribute from the cache
273
260
  *
274
261
  * @public
275
- * @param identifier
276
- * @param propertyName
277
- * @return {unknown}
278
262
  */
279
- getAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
263
+ getAttr(key: ResourceKey, propertyName: string): Value | undefined;
280
264
  /**
281
265
  * Retrieve the remote state for an attribute from the cache
282
266
  *
283
267
  * @public
284
- * @param identifier
285
- * @param propertyName
286
- * @return {unknown}
287
268
  */
288
- getRemoteAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
269
+ getRemoteAttr(key: ResourceKey, propertyName: string): Value | undefined;
289
270
  /**
290
271
  * Mutate the data for an attribute in the cache
291
272
  *
292
273
  * @public
293
- * @param identifier
294
- * @param propertyName
295
- * @param value
296
274
  */
297
- setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void;
275
+ setAttr(key: ResourceKey, propertyName: string, value: Value): void;
298
276
  /**
299
277
  * Query the cache for the changed attributes of a resource.
300
278
  *
301
279
  * @public
302
- * @param identifier
303
- * @return
304
280
  */
305
- changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
281
+ changedAttrs(key: ResourceKey): ChangedAttributesHash;
306
282
  /**
307
283
  * Query the cache for whether any mutated attributes exist
308
284
  *
309
285
  * @public
310
- * @param identifier
311
- * @return {Boolean}
312
286
  */
313
- hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
287
+ hasChangedAttrs(key: ResourceKey): boolean;
314
288
  /**
315
289
  * Tell the cache to discard any uncommitted mutations to attributes
316
290
  *
317
291
  * @public
318
- * @param identifier
319
292
  * @return the names of attributes that were restored
320
293
  */
321
- rollbackAttrs(identifier: StableRecordIdentifier): string[];
294
+ rollbackAttrs(key: ResourceKey): string[];
322
295
  // Relationships
323
296
  // =============
324
297
  /**
@@ -330,32 +303,28 @@ export declare class CacheManager implements Cache {
330
303
  * type RelationshipDiff =
331
304
  | {
332
305
  kind: 'collection';
333
- remoteState: StableRecordIdentifier[];
334
- additions: Set<StableRecordIdentifier>;
335
- removals: Set<StableRecordIdentifier>;
336
- localState: StableRecordIdentifier[];
306
+ remoteState: ResourceKey[];
307
+ additions: Set<ResourceKey>;
308
+ removals: Set<ResourceKey>;
309
+ localState: ResourceKey[];
337
310
  reordered: boolean;
338
311
  }
339
312
  | {
340
313
  kind: 'resource';
341
- remoteState: StableRecordIdentifier | null;
342
- localState: StableRecordIdentifier | null;
314
+ remoteState: ResourceKey | null;
315
+ localState: ResourceKey | null;
343
316
  };
344
317
  ```
345
318
  *
346
319
  * @public
347
- * @param {StableRecordIdentifier} identifier
348
- * @return {Map<string, RelationshipDiff>}
349
320
  */
350
- changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
321
+ changedRelationships(key: ResourceKey): Map<string, RelationshipDiff>;
351
322
  /**
352
323
  * Query the cache for whether any mutated attributes exist
353
324
  *
354
325
  * @public
355
- * @param {StableRecordIdentifier} identifier
356
- * @return {Boolean}
357
326
  */
358
- hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
327
+ hasChangedRelationships(key: ResourceKey): boolean;
359
328
  /**
360
329
  * Tell the cache to discard any uncommitted mutations to relationships.
361
330
  *
@@ -364,28 +333,23 @@ export declare class CacheManager implements Cache {
364
333
  * This method is a candidate to become a mutation
365
334
  *
366
335
  * @public
367
- * @param {StableRecordIdentifier} identifier
368
- * @return {String[]} the names of relationships that were restored
336
+ * @return the names of relationships that were restored
369
337
  */
370
- rollbackRelationships(identifier: StableRecordIdentifier): string[];
338
+ rollbackRelationships(key: ResourceKey): string[];
371
339
  /**
372
340
  * Query the cache for the current state of a relationship property
373
341
  *
374
342
  * @public
375
- * @param identifier
376
- * @param propertyName
377
343
  * @return resource relationship object
378
344
  */
379
- getRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
345
+ getRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
380
346
  /**
381
347
  * Query the cache for the remote state of a relationship property
382
348
  *
383
349
  * @public
384
- * @param identifier
385
- * @param propertyName
386
350
  * @return resource relationship object
387
351
  */
388
- getRemoteRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
352
+ getRemoteRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
389
353
  // Resource State
390
354
  // ===============
391
355
  /**
@@ -393,51 +357,39 @@ export declare class CacheManager implements Cache {
393
357
  * or remove such a mark.
394
358
  *
395
359
  * @public
396
- * @param identifier
397
- * @param isDeleted
398
360
  */
399
- setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
361
+ setIsDeleted(key: ResourceKey, isDeleted: boolean): void;
400
362
  /**
401
363
  * Query the cache for any validation errors applicable to the given resource.
402
364
  *
403
365
  * @public
404
- * @param identifier
405
- * @return
406
366
  */
407
- getErrors(identifier: StableRecordIdentifier): ApiError[];
367
+ getErrors(key: ResourceKey): ApiError[];
408
368
  /**
409
369
  * Query the cache for whether a given resource has any available data
410
370
  *
411
371
  * @public
412
- * @param identifier
413
- * @return {Boolean}
414
372
  */
415
- isEmpty(identifier: StableRecordIdentifier): boolean;
373
+ isEmpty(key: ResourceKey): boolean;
416
374
  /**
417
375
  * Query the cache for whether a given resource was created locally and not
418
376
  * yet persisted.
419
377
  *
420
378
  * @public
421
- * @param identifier
422
- * @return {Boolean}
423
379
  */
424
- isNew(identifier: StableRecordIdentifier): boolean;
380
+ isNew(key: ResourceKey): boolean;
425
381
  /**
426
382
  * Query the cache for whether a given resource is marked as deleted (but not
427
383
  * necessarily persisted yet).
428
384
  *
429
385
  * @public
430
- * @param identifier
431
- * @return {Boolean}
432
386
  */
433
- isDeleted(identifier: StableRecordIdentifier): boolean;
387
+ isDeleted(key: ResourceKey): boolean;
434
388
  /**
435
389
  * Query the cache for whether a given resource has been deleted and that deletion
436
390
  * has also been persisted.
437
391
  *
438
392
  * @public
439
- * @param identifier
440
- * @return {Boolean}
441
393
  */
442
- isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
394
+ isDeletionCommitted(key: ResourceKey): boolean;
443
395
  }
@@ -1,21 +1,21 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
2
2
  import type { Store } from "../store-service.js";
3
3
  export type UnsubscribeToken = object;
4
4
  export type CacheOperation = "added" | "removed" | "updated" | "state";
5
5
  export type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
6
6
  export type NotificationType = "attributes" | "relationships" | "identity" | "errors" | "meta" | CacheOperation;
7
7
  export interface NotificationCallback {
8
- (identifier: StableRecordIdentifier, notificationType: "attributes" | "relationships", key?: string): void;
9
- (identifier: StableRecordIdentifier, notificationType: "errors" | "meta" | "identity" | "state"): void;
10
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
8
+ (cacheKey: ResourceKey, notificationType: "attributes" | "relationships", key?: string): void;
9
+ (cacheKey: ResourceKey, notificationType: "errors" | "meta" | "identity" | "state"): void;
10
+ (cacheKey: ResourceKey, notificationType: CacheOperation): void;
11
11
  }
12
12
  export interface ResourceOperationCallback {
13
13
  // resource updates
14
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
14
+ (cacheKey: ResourceKey, notificationType: CacheOperation): void;
15
15
  }
16
16
  export interface DocumentOperationCallback {
17
17
  // document updates
18
- (identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
18
+ (cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;
19
19
  }
20
20
  /**
21
21
  * The NotificationManager provides the ability to subscribe to
@@ -42,34 +42,33 @@ export default class NotificationManager {
42
42
  private _onFlushCB?;
43
43
  constructor(store: Store);
44
44
  /**
45
- * Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.
45
+ * Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource
46
+ * or document.
46
47
  *
47
48
  * ```ts
48
49
  * export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
49
50
  *
50
51
  * export interface NotificationCallback {
51
- * (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
52
- * (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
53
- * (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
52
+ * (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
53
+ * (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
54
+ * (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
54
55
  * }
55
56
  * export interface ResourceOperationCallback {
56
57
  * // resource updates
57
- * (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
58
+ * (cacheKey: ResourceKey, notificationType: CacheOperation): void;
58
59
  * }
59
60
  * export interface DocumentOperationCallback {
60
61
  * // document updates
61
- * (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
62
+ * (cacheKey: RequestKey, notificationType: CacheOperation): void;
62
63
  * }
63
64
  * ```
64
65
  *
65
66
  * @public
66
- * @param {StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'} identifier
67
- * @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
68
- * @return {UnsubscribeToken} an opaque token to be used with unsubscribe
67
+ * @return an opaque token to be used with unsubscribe
69
68
  */
70
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
71
- subscribe(identifier: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
72
- subscribe(identifier: "document" | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
69
+ subscribe(cacheKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
70
+ subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
71
+ subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
73
72
  /**
74
73
  * remove a previous subscription
75
74
  *
@@ -81,10 +80,10 @@ export default class NotificationManager {
81
80
  *
82
81
  * @private
83
82
  */
84
- notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string | null): boolean;
85
- notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state", key?: null): boolean;
86
- notify(identifier: StableRecordIdentifier, value: CacheOperation, key?: null): boolean;
87
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation, key?: null): boolean;
83
+ notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string | null): boolean;
84
+ notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state", key?: null): boolean;
85
+ notify(cacheKey: ResourceKey, value: CacheOperation, key?: null): boolean;
86
+ notify(cacheKey: RequestKey, value: DocumentCacheOperation, key?: null): boolean;
88
87
  /** @internal */
89
88
  _onNextFlush(cb: () => void): void;
90
89
  private _scheduleNotify;