@warp-drive/core 5.7.0-alpha.13 → 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 (80) 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 -1
  21. package/declarations/reactive.d.ts +277 -1
  22. package/declarations/request/-private/context.d.ts +2 -2
  23. package/declarations/request/-private/fetch.d.ts +2 -2
  24. package/declarations/request/-private/manager.d.ts +2 -2
  25. package/declarations/request/-private/types.d.ts +4 -4
  26. package/declarations/request/-private/utils.d.ts +44 -2
  27. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  28. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  29. package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
  30. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  31. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
  32. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
  33. package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
  34. package/declarations/store/-private/managers/notification-manager.d.ts +21 -25
  35. package/declarations/store/-private/managers/record-array-manager.d.ts +78 -27
  36. package/declarations/store/-private/network/request-cache.d.ts +11 -11
  37. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  38. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
  39. package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
  40. package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
  41. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
  42. package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
  43. package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
  44. package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
  45. package/declarations/store/-private/store-service.d.ts +22 -19
  46. package/declarations/store/-private.d.ts +5 -3
  47. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  48. package/declarations/store/-types/q/identifier.d.ts +9 -6
  49. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  50. package/declarations/store/deprecated/-private.d.ts +5 -5
  51. package/declarations/store/deprecated/store.d.ts +8 -9
  52. package/declarations/types/-private.d.ts +1 -1
  53. package/declarations/types/cache/aliases.d.ts +2 -2
  54. package/declarations/types/cache/change.d.ts +2 -2
  55. package/declarations/types/cache/mutations.d.ts +13 -13
  56. package/declarations/types/cache/operations.d.ts +115 -32
  57. package/declarations/types/cache/relationship.d.ts +4 -4
  58. package/declarations/types/cache.d.ts +51 -113
  59. package/declarations/types/graph.d.ts +12 -12
  60. package/declarations/types/identifier.d.ts +60 -76
  61. package/declarations/types/request.d.ts +27 -6
  62. package/declarations/types/schema/concepts.d.ts +2 -2
  63. package/declarations/types/schema/fields.d.ts +1 -1
  64. package/declarations/types/spec/document.d.ts +6 -6
  65. package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
  66. package/dist/graph/-private.js +129 -129
  67. package/dist/index.js +6 -2
  68. package/dist/reactive/-private.js +1 -1
  69. package/dist/reactive.js +126 -4
  70. package/dist/{request-state-BWYju5O9.js → request-state-CQ0Q6d1V.js} +4290 -4218
  71. package/dist/request.js +1 -1
  72. package/dist/store/-private.js +1 -1
  73. package/dist/store.js +32 -44
  74. package/dist/{symbols-BoONANuz.js → symbols-sql1_mdx.js} +2 -2
  75. package/dist/types/-private.js +1 -1
  76. package/dist/types/identifier.js +19 -45
  77. package/dist/types/request.js +27 -0
  78. package/dist/types/schema/fields.js +2 -0
  79. package/package.json +3 -3
  80. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
@@ -1,30 +1,30 @@
1
1
  import type { Cache } from "@warp-drive/core/types/cache";
2
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
2
+ import type { RequestKey, ResourceKey } from "@warp-drive/core/types/identifier";
3
3
  import type { ImmutableRequestInfo, ResponseInfo, StructuredDocument } from "@warp-drive/core/types/request";
4
4
  import type { ResourceDocument } from "@warp-drive/core/types/spec/document";
5
5
  type UnsubscribeToken = object;
6
6
  type CacheOperation = "added" | "removed" | "updated" | "state";
7
7
  type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
8
8
  export interface NotificationCallback {
9
- (identifier: StableRecordIdentifier, notificationType: "attributes" | "relationships", key?: string): void;
10
- (identifier: StableRecordIdentifier, notificationType: "errors" | "meta" | "identity" | "state"): void;
9
+ (resourceKey: ResourceKey, notificationType: "attributes" | "relationships", key?: string): void;
10
+ (resourceKey: ResourceKey, notificationType: "errors" | "meta" | "identity" | "state"): void;
11
11
  }
12
12
  interface ResourceOperationCallback {
13
13
  // resource updates
14
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
14
+ (resourceKey: ResourceKey, notificationType: CacheOperation): void;
15
15
  }
16
16
  interface DocumentOperationCallback {
17
17
  // document updates
18
- (identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
18
+ (cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;
19
19
  }
20
20
  type NotificationManager = {
21
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
22
- subscribe(identifier: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
23
- subscribe(identifier: "document" | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
24
- notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string): boolean;
25
- notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state"): boolean;
26
- notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
27
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
21
+ subscribe(resourceKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
22
+ subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
23
+ subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
24
+ notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string): boolean;
25
+ notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state"): boolean;
26
+ notify(cacheKey: ResourceKey, value: CacheOperation): boolean;
27
+ notify(cacheKey: RequestKey, value: DocumentCacheOperation): boolean;
28
28
  };
29
29
  type Store = {
30
30
  cache: Cache;
@@ -236,7 +236,7 @@ export type PolicyConfig = {
236
236
  * request for that type is successful.
237
237
  *
238
238
  * For this to work, the `createRecord` request must include the `cacheOptions.types` array
239
- * with the types that should be invalidated, or its request should specify the identifiers
239
+ * with the types that should be invalidated, or its request should specify the ResourceKeys
240
240
  * of the records that are being created via `records`. Providing both is valid.
241
241
  *
242
242
  * > [!NOTE]
@@ -285,30 +285,28 @@ export type PolicyConfig = {
285
285
  export declare class DefaultCachePolicy {
286
286
  config: PolicyConfig;
287
287
  _stores: WeakMap<Store, {
288
- invalidated: Set<StableDocumentIdentifier>;
289
- types: Map<string, Set<StableDocumentIdentifier>>;
288
+ invalidated: Set<RequestKey>;
289
+ types: Map<string, Set<RequestKey>>;
290
290
  }>;
291
291
  _getStore(store: Store): {
292
- invalidated: Set<StableDocumentIdentifier>;
293
- types: Map<string, Set<StableDocumentIdentifier>>;
292
+ invalidated: Set<RequestKey>;
293
+ types: Map<string, Set<RequestKey>>;
294
294
  };
295
295
  constructor(config: PolicyConfig);
296
296
  /**
297
- * Invalidate a request by its identifier for a given store instance.
297
+ * Invalidate a request by its CacheKey for the given store instance.
298
298
  *
299
299
  * While the store argument may seem redundant, the CachePolicy
300
300
  * is designed to be shared across multiple stores / forks
301
301
  * of the store.
302
302
  *
303
303
  * ```ts
304
- * store.lifetimes.invalidateRequest(store, identifier);
304
+ * store.lifetimes.invalidateRequest(store, cacheKey);
305
305
  * ```
306
306
  *
307
307
  * @public
308
- * @param {StableDocumentIdentifier} identifier
309
- * @param {Store} store
310
308
  */
311
- invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
309
+ invalidateRequest(cacheKey: RequestKey, store: Store): void;
312
310
  /**
313
311
  * Invalidate all requests associated to a specific type
314
312
  * for a given store instance.
@@ -325,8 +323,6 @@ export declare class DefaultCachePolicy {
325
323
  * ```
326
324
  *
327
325
  * @public
328
- * @param {String} type
329
- * @param {Store} store
330
326
  */
331
327
  invalidateRequestsForType(type: string, store: Store): void;
332
328
  /**
@@ -340,13 +336,8 @@ export declare class DefaultCachePolicy {
340
336
  * This method should not be invoked directly by consumers.
341
337
  *
342
338
  * @public
343
- * @param {ImmutableRequestInfo} request
344
- * @param {ImmutableResponse} response
345
- * @param {Store} store
346
- * @param {StableDocumentIdentifier | null} identifier
347
- * @return {void}
348
339
  */
349
- didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
340
+ didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, cacheKey: RequestKey | null, store: Store): void;
350
341
  /**
351
342
  * Invoked to determine if the request may be fulfilled from cache
352
343
  * if possible.
@@ -359,11 +350,9 @@ export declare class DefaultCachePolicy {
359
350
  * and the cache will be updated before returning the response.
360
351
  *
361
352
  * @public
362
- * @param {StableDocumentIdentifier} identifier
363
- * @param {Store} store
364
- * @return {Boolean} true if the request is considered hard expired
353
+ * @return true if the request is considered hard expired
365
354
  */
366
- isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
355
+ isHardExpired(cacheKey: RequestKey, store: Store): boolean;
367
356
  /**
368
357
  * Invoked if `isHardExpired` is false to determine if the request
369
358
  * should be update behind the scenes if cache data is already available.
@@ -375,10 +364,8 @@ export declare class DefaultCachePolicy {
375
364
  * request is made to update the cache via the configured request handlers.
376
365
  *
377
366
  * @public
378
- * @param {StableDocumentIdentifier} identifier
379
- * @param {Store} store
380
- * @return {Boolean} true if the request is considered soft expired
367
+ * @return true if the request is considered soft expired
381
368
  */
382
- isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
369
+ isSoftExpired(cacheKey: RequestKey, store: Store): boolean;
383
370
  }
384
371
  export {};
@@ -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
  }