@warp-drive/core 5.6.0-beta.0 → 5.6.0-beta.2

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 (120) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  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 +6 -7
  9. package/declarations/graph/-private/graph.d.ts +17 -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 +73 -0
  14. package/declarations/reactive/-private/document.d.ts +11 -27
  15. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  16. package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
  17. package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
  18. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  19. package/declarations/reactive/-private/hooks.d.ts +2 -2
  20. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  21. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  22. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  23. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  24. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  25. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  26. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  27. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  28. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  29. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  30. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  31. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  32. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  33. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  34. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  35. package/declarations/reactive/-private/record.d.ts +44 -33
  36. package/declarations/reactive/-private/schema.d.ts +50 -66
  37. package/declarations/reactive/-private/symbols.d.ts +2 -7
  38. package/declarations/reactive/-private.d.ts +1 -1
  39. package/declarations/reactive.d.ts +278 -1
  40. package/declarations/request/-private/context.d.ts +3 -5
  41. package/declarations/request/-private/fetch.d.ts +2 -0
  42. package/declarations/request/-private/manager.d.ts +24 -28
  43. package/declarations/request/-private/types.d.ts +22 -23
  44. package/declarations/request/-private/utils.d.ts +44 -2
  45. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  46. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  47. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  48. package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
  49. package/declarations/store/-private/debug/utils.d.ts +1 -0
  50. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  51. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  52. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  53. package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
  54. package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
  55. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  56. package/declarations/store/-private/network/request-cache.d.ts +21 -24
  57. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  58. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  59. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  60. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  61. package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
  62. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
  63. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  64. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  65. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  66. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  67. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  68. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  69. package/declarations/store/-private/store-service.d.ts +167 -872
  70. package/declarations/store/-private.d.ts +14 -10
  71. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  72. package/declarations/store/-types/q/identifier.d.ts +9 -6
  73. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  74. package/declarations/store/-types/q/schema-service.d.ts +64 -40
  75. package/declarations/store/-types/q/store.d.ts +6 -7
  76. package/declarations/store/deprecated/-private.d.ts +224 -0
  77. package/declarations/store/deprecated/store.d.ts +787 -0
  78. package/declarations/types/-private.d.ts +1 -1
  79. package/declarations/types/cache/aliases.d.ts +2 -2
  80. package/declarations/types/cache/change.d.ts +2 -2
  81. package/declarations/types/cache/mutations.d.ts +13 -13
  82. package/declarations/types/cache/operations.d.ts +115 -32
  83. package/declarations/types/cache/relationship.d.ts +4 -4
  84. package/declarations/types/cache.d.ts +51 -115
  85. package/declarations/types/graph.d.ts +12 -12
  86. package/declarations/types/identifier.d.ts +52 -76
  87. package/declarations/types/params.d.ts +2 -3
  88. package/declarations/types/request.d.ts +69 -42
  89. package/declarations/types/schema/concepts.d.ts +2 -2
  90. package/declarations/types/schema/fields.d.ts +391 -14
  91. package/declarations/types/spec/document.d.ts +6 -6
  92. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  93. package/declarations/types.d.ts +2 -1
  94. package/declarations/utils/string.d.ts +2 -2
  95. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  96. package/dist/configure.js +1 -1
  97. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  98. package/dist/graph/-private.js +137 -144
  99. package/dist/index.js +25 -14
  100. package/dist/reactive/-private.js +1 -1
  101. package/dist/reactive.js +337 -1422
  102. package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
  103. package/dist/request.js +1 -1
  104. package/dist/store/-private.js +2 -3
  105. package/dist/store.js +32 -44
  106. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  107. package/dist/types/-private.js +1 -1
  108. package/dist/types/identifier.js +19 -45
  109. package/dist/types/request.js +45 -3
  110. package/dist/types/schema/fields.js +23 -2
  111. package/dist/utils/string.js +2 -2
  112. package/package.json +10 -10
  113. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  114. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  115. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  116. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  117. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  118. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  119. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  120. package/dist/handler-C2T-IyJK.js +0 -339
@@ -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";
@@ -28,7 +28,6 @@ import type { StoreRequestContext } from "../cache-handler/handler.js";
28
28
  * @public
29
29
  */
30
30
  export declare class CacheManager implements Cache {
31
- #private;
32
31
  version: "2";
33
32
  constructor(cache: Cache);
34
33
  // Cache Management
@@ -61,14 +60,11 @@ export declare class CacheManager implements Cache {
61
60
  /**
62
61
  * Perform an operation on the cache to update the remote state.
63
62
  *
64
- * Note: currently the only valid operation is a MergeOperation
65
- * which occurs when a collision of identifiers is detected.
66
- *
67
63
  * @public
68
64
  * @param op the operation to perform
69
65
  * @return {void}
70
66
  */
71
- patch(op: MergeOperation): void;
67
+ patch(op: Operation | Operation[]): void;
72
68
  /**
73
69
  * Update resource data with a local mutation. Currently supports operations
74
70
  * on relationships only.
@@ -105,32 +101,29 @@ export declare class CacheManager implements Cache {
105
101
  * notifications for relational data.
106
102
  *
107
103
  * @public
108
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
104
+ * @param {ResourceKey | RequestKey} cacheKey
109
105
  * @return {ResourceDocument | ResourceBlob | null} the known resource data
110
106
  */
111
- peek(identifier: StableRecordIdentifier): unknown;
112
- peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
113
- peekRemoteState(identifier: StableRecordIdentifier): unknown;
114
- peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
107
+ peek(cacheKey: ResourceKey): unknown;
108
+ peek(cacheKey: RequestKey): ResourceDocument | null;
109
+ peekRemoteState(cacheKey: ResourceKey): unknown;
110
+ peekRemoteState(cacheKey: RequestKey): ResourceDocument | null;
115
111
  /**
116
112
  * Peek the Cache for the existing request data associated with
117
113
  * a cacheable request
118
114
  *
119
- * @param {StableDocumentIdentifier}
120
- * @return {StableDocumentIdentifier | null}
115
+ * @param {RequestKey}
116
+ * @return {RequestKey | null}
121
117
  * @public
122
118
  */
123
- peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
119
+ peekRequest(key: RequestKey): StructuredDocument<ResourceDocument> | null;
124
120
  /**
125
- * Push resource data from a remote source into the cache for this identifier
121
+ * Push resource data from a remote source into the cache for this ResourceKey
126
122
  *
127
123
  * @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
124
+ * @return if `hasRecord` is true then calculated key changes should be returned
132
125
  */
133
- upsert(identifier: StableRecordIdentifier, data: unknown, hasRecord: boolean): void | string[];
126
+ upsert(key: ResourceKey, data: unknown, hasRecord: boolean): void | string[];
134
127
  // Cache Forking Support
135
128
  // =====================
136
129
  /**
@@ -165,7 +158,7 @@ export declare class CacheManager implements Cache {
165
158
  * `Change` entry in the returned array.
166
159
  *
167
160
  * A `Change` is described by an object containing up to
168
- * three properties: (1) the `identifier` of the entity that
161
+ * three properties: (1) the `ResourceKey` of the entity that
169
162
  * changed; (2) the `op` code of that change being one of
170
163
  * `upsert` or `remove`, and if the op is `upsert` a `patch`
171
164
  * containing the data to merge into the cache for the given
@@ -180,7 +173,7 @@ export declare class CacheManager implements Cache {
180
173
  *
181
174
  * ```ts
182
175
  * interface Change {
183
- * identifier: StableRecordIdentifier | StableDocumentIdentifier;
176
+ * key: ResourceKey | RequestKey;
184
177
  * op: 'upsert' | 'remove';
185
178
  * patch?: unknown;
186
179
  * }
@@ -228,97 +221,76 @@ export declare class CacheManager implements Cache {
228
221
  * process. This return value behavior is deprecated.
229
222
  *
230
223
  * @public
231
- * @param identifier
232
- * @param options
233
224
  */
234
- clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown>;
225
+ clientDidCreate(key: ResourceKey, options?: Record<string, unknown>): Record<string, unknown>;
235
226
  /**
236
227
  * [LIFECYCLE] Signals to the cache that a resource
237
228
  * will be part of a save transaction.
238
229
  *
239
230
  * @public
240
- * @param identifier
231
+ * @param key
241
232
  */
242
- willCommit(identifier: StableRecordIdentifier, context: StoreRequestContext): void;
233
+ willCommit(key: ResourceKey, context: StoreRequestContext): void;
243
234
  /**
244
235
  * [LIFECYCLE] Signals to the cache that a resource
245
236
  * was successfully updated as part of a save transaction.
246
237
  *
247
238
  * @public
248
- * @param identifier
249
- * @param data
250
239
  */
251
- didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
240
+ didCommit(key: ResourceKey, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
252
241
  /**
253
242
  * [LIFECYCLE] Signals to the cache that a resource
254
243
  * was update via a save transaction failed.
255
244
  *
256
245
  * @public
257
- * @param identifier
258
- * @param errors
259
246
  */
260
- commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
247
+ commitWasRejected(key: ResourceKey, errors?: ApiError[]): void;
261
248
  /**
262
249
  * [LIFECYCLE] Signals to the cache that all data for a resource
263
250
  * should be cleared.
264
251
  *
265
252
  * @public
266
- * @param identifier
267
253
  */
268
- unloadRecord(identifier: StableRecordIdentifier): void;
254
+ unloadRecord(key: ResourceKey): void;
269
255
  // Granular Resource Data APIs
270
256
  // ===========================
271
257
  /**
272
258
  * Retrieve the data for an attribute from the cache
273
259
  *
274
260
  * @public
275
- * @param identifier
276
- * @param propertyName
277
- * @return {unknown}
278
261
  */
279
- getAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
262
+ getAttr(key: ResourceKey, propertyName: string): Value | undefined;
280
263
  /**
281
264
  * Retrieve the remote state for an attribute from the cache
282
265
  *
283
266
  * @public
284
- * @param identifier
285
- * @param propertyName
286
- * @return {unknown}
287
267
  */
288
- getRemoteAttr(identifier: StableRecordIdentifier, propertyName: string): Value | undefined;
268
+ getRemoteAttr(key: ResourceKey, propertyName: string): Value | undefined;
289
269
  /**
290
270
  * Mutate the data for an attribute in the cache
291
271
  *
292
272
  * @public
293
- * @param identifier
294
- * @param propertyName
295
- * @param value
296
273
  */
297
- setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void;
274
+ setAttr(key: ResourceKey, propertyName: string, value: Value): void;
298
275
  /**
299
276
  * Query the cache for the changed attributes of a resource.
300
277
  *
301
278
  * @public
302
- * @param identifier
303
- * @return
304
279
  */
305
- changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
280
+ changedAttrs(key: ResourceKey): ChangedAttributesHash;
306
281
  /**
307
282
  * Query the cache for whether any mutated attributes exist
308
283
  *
309
284
  * @public
310
- * @param identifier
311
- * @return {Boolean}
312
285
  */
313
- hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
286
+ hasChangedAttrs(key: ResourceKey): boolean;
314
287
  /**
315
288
  * Tell the cache to discard any uncommitted mutations to attributes
316
289
  *
317
290
  * @public
318
- * @param identifier
319
291
  * @return the names of attributes that were restored
320
292
  */
321
- rollbackAttrs(identifier: StableRecordIdentifier): string[];
293
+ rollbackAttrs(key: ResourceKey): string[];
322
294
  // Relationships
323
295
  // =============
324
296
  /**
@@ -330,32 +302,28 @@ export declare class CacheManager implements Cache {
330
302
  * type RelationshipDiff =
331
303
  | {
332
304
  kind: 'collection';
333
- remoteState: StableRecordIdentifier[];
334
- additions: Set<StableRecordIdentifier>;
335
- removals: Set<StableRecordIdentifier>;
336
- localState: StableRecordIdentifier[];
305
+ remoteState: ResourceKey[];
306
+ additions: Set<ResourceKey>;
307
+ removals: Set<ResourceKey>;
308
+ localState: ResourceKey[];
337
309
  reordered: boolean;
338
310
  }
339
311
  | {
340
312
  kind: 'resource';
341
- remoteState: StableRecordIdentifier | null;
342
- localState: StableRecordIdentifier | null;
313
+ remoteState: ResourceKey | null;
314
+ localState: ResourceKey | null;
343
315
  };
344
316
  ```
345
317
  *
346
318
  * @public
347
- * @param {StableRecordIdentifier} identifier
348
- * @return {Map<string, RelationshipDiff>}
349
319
  */
350
- changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
320
+ changedRelationships(key: ResourceKey): Map<string, RelationshipDiff>;
351
321
  /**
352
322
  * Query the cache for whether any mutated attributes exist
353
323
  *
354
324
  * @public
355
- * @param {StableRecordIdentifier} identifier
356
- * @return {Boolean}
357
325
  */
358
- hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
326
+ hasChangedRelationships(key: ResourceKey): boolean;
359
327
  /**
360
328
  * Tell the cache to discard any uncommitted mutations to relationships.
361
329
  *
@@ -364,28 +332,23 @@ export declare class CacheManager implements Cache {
364
332
  * This method is a candidate to become a mutation
365
333
  *
366
334
  * @public
367
- * @param {StableRecordIdentifier} identifier
368
- * @return {String[]} the names of relationships that were restored
335
+ * @return the names of relationships that were restored
369
336
  */
370
- rollbackRelationships(identifier: StableRecordIdentifier): string[];
337
+ rollbackRelationships(key: ResourceKey): string[];
371
338
  /**
372
339
  * Query the cache for the current state of a relationship property
373
340
  *
374
341
  * @public
375
- * @param identifier
376
- * @param propertyName
377
342
  * @return resource relationship object
378
343
  */
379
- getRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
344
+ getRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
380
345
  /**
381
346
  * Query the cache for the remote state of a relationship property
382
347
  *
383
348
  * @public
384
- * @param identifier
385
- * @param propertyName
386
349
  * @return resource relationship object
387
350
  */
388
- getRemoteRelationship(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
351
+ getRemoteRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
389
352
  // Resource State
390
353
  // ===============
391
354
  /**
@@ -393,51 +356,39 @@ export declare class CacheManager implements Cache {
393
356
  * or remove such a mark.
394
357
  *
395
358
  * @public
396
- * @param identifier
397
- * @param isDeleted
398
359
  */
399
- setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
360
+ setIsDeleted(key: ResourceKey, isDeleted: boolean): void;
400
361
  /**
401
362
  * Query the cache for any validation errors applicable to the given resource.
402
363
  *
403
364
  * @public
404
- * @param identifier
405
- * @return
406
365
  */
407
- getErrors(identifier: StableRecordIdentifier): ApiError[];
366
+ getErrors(key: ResourceKey): ApiError[];
408
367
  /**
409
368
  * Query the cache for whether a given resource has any available data
410
369
  *
411
370
  * @public
412
- * @param identifier
413
- * @return {Boolean}
414
371
  */
415
- isEmpty(identifier: StableRecordIdentifier): boolean;
372
+ isEmpty(key: ResourceKey): boolean;
416
373
  /**
417
374
  * Query the cache for whether a given resource was created locally and not
418
375
  * yet persisted.
419
376
  *
420
377
  * @public
421
- * @param identifier
422
- * @return {Boolean}
423
378
  */
424
- isNew(identifier: StableRecordIdentifier): boolean;
379
+ isNew(key: ResourceKey): boolean;
425
380
  /**
426
381
  * Query the cache for whether a given resource is marked as deleted (but not
427
382
  * necessarily persisted yet).
428
383
  *
429
384
  * @public
430
- * @param identifier
431
- * @return {Boolean}
432
385
  */
433
- isDeleted(identifier: StableRecordIdentifier): boolean;
386
+ isDeleted(key: ResourceKey): boolean;
434
387
  /**
435
388
  * Query the cache for whether a given resource has been deleted and that deletion
436
389
  * has also been persisted.
437
390
  *
438
391
  * @public
439
- * @param identifier
440
- * @return {Boolean}
441
392
  */
442
- isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
393
+ isDeletionCommitted(key: ResourceKey): boolean;
443
394
  }
@@ -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
@@ -28,48 +28,35 @@ export interface DocumentOperationCallback {
28
28
  * @public
29
29
  */
30
30
  export default class NotificationManager {
31
- /** @internal */
32
- private store;
33
- /** @internal */
34
- private isDestroyed;
35
- /** @internal */
36
- private _buffered;
37
- /** @internal */
38
- private _cache;
39
- /** @internal */
40
- private _hasFlush;
41
- /** @internal */
42
- private _onFlushCB?;
43
31
  constructor(store: Store);
44
32
  /**
45
- * Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.
33
+ * Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource
34
+ * or document.
46
35
  *
47
36
  * ```ts
48
37
  * export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
49
38
  *
50
39
  * 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;
40
+ * (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
41
+ * (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
42
+ * (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
54
43
  * }
55
44
  * export interface ResourceOperationCallback {
56
45
  * // resource updates
57
- * (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
46
+ * (cacheKey: ResourceKey, notificationType: CacheOperation): void;
58
47
  * }
59
48
  * export interface DocumentOperationCallback {
60
49
  * // document updates
61
- * (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
50
+ * (cacheKey: RequestKey, notificationType: CacheOperation): void;
62
51
  * }
63
52
  * ```
64
53
  *
65
54
  * @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
55
+ * @return an opaque token to be used with unsubscribe
69
56
  */
70
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
71
- subscribe(identifier: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
72
- subscribe(identifier: "document" | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
57
+ subscribe(cacheKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
58
+ subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
59
+ subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
73
60
  /**
74
61
  * remove a previous subscription
75
62
  *
@@ -81,18 +68,18 @@ export default class NotificationManager {
81
68
  *
82
69
  * @private
83
70
  */
84
- notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string): boolean;
85
- notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state"): boolean;
86
- notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
87
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
88
- /** @internal */
89
- _onNextFlush(cb: () => void): void;
90
- private _scheduleNotify;
91
- /** @internal */
71
+ notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string | null): boolean;
72
+ notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state", key?: null): boolean;
73
+ notify(cacheKey: ResourceKey, value: CacheOperation, key?: null): boolean;
74
+ notify(cacheKey: RequestKey, value: DocumentCacheOperation, key?: null): boolean;
75
+ }
76
+ /**
77
+ * This type exists for internal use only for
78
+ * where intimate contracts still exist either for
79
+ * the Test Suite or for Legacy code.
80
+ *
81
+ * @private
82
+ */
83
+ export interface PrivateNotificationManager extends NotificationManager {
92
84
  _flush(): void;
93
- private _flushNotification;
94
- private _flushNotification;
95
- private _flushNotification;
96
- /** @internal */
97
- destroy(): void;
98
85
  }
@@ -1,10 +1,11 @@
1
1
  import type { LocalRelationshipOperation } from "../../../types/graph.js";
2
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
2
+ import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
3
3
  import type { ImmutableRequestInfo } from "../../../types/request.js";
4
4
  import type { CollectionResourceDocument } from "../../../types/spec/json-api-raw.js";
5
- import { Collection, IdentifierArray } from "../record-arrays/identifier-array.js";
5
+ import type { LegacyLiveArray } from "../record-arrays/legacy-live-array.js";
6
+ import { type LegacyQueryArray } from "../record-arrays/legacy-query.js";
7
+ import { type ReactiveResourceArray } from "../record-arrays/resource-array.js";
6
8
  import type { Store } from "../store-service.js";
7
- import type { UnsubscribeToken } from "./notification-manager.js";
8
9
  /**
9
10
  * This is a clever optimization.
10
11
  *
@@ -38,60 +39,62 @@ import type { UnsubscribeToken } from "./notification-manager.js";
38
39
  * Sincerely,
39
40
  * - runspired (Chris Thoburn) 08/21/2022
40
41
  *
41
- * @function fastPush
42
- * @internal
42
+ * @private
43
43
  * @param target the array to push into
44
44
  * @param source the items to push into target
45
45
  */
46
46
  export declare function fastPush<T>(target: T[], source: T[]): void;
47
- type ChangeSet = Map<StableRecordIdentifier, "add" | "del">;
47
+ interface LegacyQueryInit {
48
+ type: string;
49
+ query: ImmutableRequestInfo | Record<string, unknown>;
50
+ }
51
+ interface AnonymousRequestCollectionInit {
52
+ source: ResourceKey[];
53
+ }
54
+ interface RequestCollectionInit {
55
+ source: ResourceKey[];
56
+ requestKey: RequestKey;
57
+ }
58
+ type ChangeSet = Map<ResourceKey, "add" | "del">;
48
59
  /**
49
- @class RecordArrayManager
50
- @internal
60
+ @hideconstructor
61
+ @private
51
62
  */
52
63
  export declare class RecordArrayManager {
53
- store: Store;
54
- isDestroying: boolean;
55
- isDestroyed: boolean;
56
- _set: Map<IdentifierArray, Set<StableRecordIdentifier>>;
57
- _live: Map<string, IdentifierArray>;
58
- _managed: Set<IdentifierArray>;
59
- _pending: Map<IdentifierArray, ChangeSet>;
60
- _identifiers: Map<StableRecordIdentifier, Set<Collection>>;
61
- _staged: Map<string, ChangeSet>;
62
- _subscription: UnsubscribeToken;
63
- _documentSubscription: UnsubscribeToken;
64
- _keyedArrays: Map<string, Collection>;
65
- _visibilitySet: Map<StableRecordIdentifier, boolean>;
66
64
  constructor(options: {
67
65
  store: Store;
68
66
  });
69
- _syncArray(array: IdentifierArray | Collection): void;
70
67
  mutate(mutation: LocalRelationshipOperation): void;
71
68
  /**
72
69
  Get the `RecordArray` for a modelName, which contains all loaded records of
73
70
  given modelName.
74
71
 
75
- @internal
76
- @param {String} modelName
77
- @return {RecordArray}
72
+ @private
78
73
  */
79
- liveArrayFor(type: string): IdentifierArray;
80
- getCollection(config: {
81
- type?: string;
82
- query?: ImmutableRequestInfo | Record<string, unknown>;
83
- identifiers?: StableRecordIdentifier[];
84
- doc?: CollectionResourceDocument;
85
- identifier?: StableDocumentIdentifier | null;
86
- }): Collection;
87
- dirtyArray(array: IdentifierArray, delta: number, shouldSyncFromCache: boolean): void;
88
- _getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<IdentifierArray, ChangeSet> | void;
89
- populateManagedArray(array: Collection, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument | null): void;
90
- identifierAdded(identifier: StableRecordIdentifier): void;
91
- identifierRemoved(identifier: StableRecordIdentifier): void;
92
- identifierChanged(identifier: StableRecordIdentifier): void;
93
- clear(isClear?: boolean): void;
74
+ liveArrayFor(type: string): LegacyLiveArray;
75
+ getCollection(config: LegacyQueryInit): LegacyQueryArray;
76
+ getCollection(config: AnonymousRequestCollectionInit): ReactiveResourceArray;
77
+ getCollection(config: RequestCollectionInit): ReactiveResourceArray;
78
+ /**
79
+ * @private
80
+ */
81
+ populateManagedArray(array: ReactiveResourceArray, identifiers: ResourceKey[], payload: CollectionResourceDocument | null): void;
82
+ pause(): void;
83
+ resume(): void;
94
84
  destroy(): void;
95
85
  }
96
- export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<Collection>>, array: Collection, identifier: StableRecordIdentifier): void;
86
+ /**
87
+ * This type exists for internal use only for
88
+ * where intimate contracts still exist either for
89
+ * the Test Suite or for Legacy code.
90
+ *
91
+ * @private
92
+ */
93
+ export interface PrivateRecordArrayManager extends RecordArrayManager {
94
+ _live: Map<string, LegacyLiveArray>;
95
+ _pending: Map<ReactiveResourceArray, ChangeSet>;
96
+ _managed: Set<ReactiveResourceArray>;
97
+ clear(isClear?: boolean): void;
98
+ }
99
+ export declare function disassociateIdentifier(ArraysCache: Map<ResourceKey, Set<ReactiveResourceArray>>, array: ReactiveResourceArray, identifier: ResourceKey): void;
97
100
  export {};
@@ -1,4 +1,4 @@
1
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import type { ResourceKey } from "../../../types/identifier.js";
2
2
  import type { FindRecordOptions } from "../../-types/q/store.js";
3
3
  import type { Store } from "../store-service.js";
4
4
  declare const Touching: "___(unique) Symbol(Touching)";
@@ -6,7 +6,7 @@ export declare const RequestPromise: "___(unique) Symbol(RequestPromise)";
6
6
  export interface Operation {
7
7
  op: string;
8
8
  options: FindRecordOptions | undefined;
9
- recordIdentifier: StableRecordIdentifier;
9
+ recordIdentifier: ResourceKey;
10
10
  }
11
11
  export interface FindRecordQuery extends Operation {
12
12
  op: "findRecord";
@@ -30,7 +30,7 @@ export interface Response {
30
30
  data: unknown;
31
31
  }
32
32
  interface InternalRequest extends RequestCacheRequestState {
33
- [Touching]: StableRecordIdentifier[];
33
+ [Touching]: ResourceKey[];
34
34
  [RequestPromise]?: Promise<unknown>;
35
35
  }
36
36
  export type RequestSubscription = (requestState: RequestCacheRequestState) => void;
@@ -42,22 +42,7 @@ export type RequestSubscription = (requestState: RequestCacheRequestState) => vo
42
42
  * @public
43
43
  */
44
44
  export declare class RequestStateService {
45
- /** @internal */
46
- _pending: Map<StableRecordIdentifier, InternalRequest[]>;
47
- private _done;
48
- private _subscriptions;
49
- private _toFlush;
50
- private _store;
51
45
  constructor(store: Store);
52
- /** @internal */
53
- _clearEntries(identifier: StableRecordIdentifier): void;
54
- /** @internal */
55
- _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
56
- private _triggerSubscriptions;
57
- private _flush;
58
- private _flushRequest;
59
- private _dequeue;
60
- private _addDone;
61
46
  /**
62
47
  * Subscribe to requests for a given resource identity.
63
48
  *
@@ -83,25 +68,37 @@ export declare class RequestStateService {
83
68
  * design.
84
69
  *
85
70
  * @public
86
- * @param {StableRecordIdentifier} identifier
71
+ * @param {ResourceKey} identifier
87
72
  * @param {(state: RequestCacheRequestState) => void} callback
88
73
  */
89
- subscribeForRecord(identifier: StableRecordIdentifier, callback: RequestSubscription): void;
74
+ subscribeForRecord(identifier: ResourceKey, callback: RequestSubscription): void;
90
75
  /**
91
76
  * Retrieve all active requests for a given resource identity.
92
77
  *
93
78
  * @public
94
- * @param {StableRecordIdentifier} identifier
79
+ * @param {ResourceKey} identifier
95
80
  * @return {RequestCacheRequestState[]} an array of request states for any pending requests for the given identifier
96
81
  */
97
- getPendingRequestsForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState[];
82
+ getPendingRequestsForRecord(identifier: ResourceKey): RequestCacheRequestState[];
98
83
  /**
99
84
  * Retrieve the last completed request for a given resource identity.
100
85
  *
101
86
  * @public
102
- * @param {StableRecordIdentifier} identifier
87
+ * @param {ResourceKey} identifier
103
88
  * @return {RequestCacheRequestState | null} the state of the most recent request for the given identifier
104
89
  */
105
- getLastRequestForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState | null;
90
+ getLastRequestForRecord(identifier: ResourceKey): RequestCacheRequestState | null;
91
+ }
92
+ /**
93
+ * This type exists for internal use only for
94
+ * where intimate contracts still exist either for
95
+ * the Test Suite or for Legacy code.
96
+ *
97
+ * @private
98
+ */
99
+ export interface PrivateRequestStateService extends RequestStateService {
100
+ _pending: Map<ResourceKey, InternalRequest[]>;
101
+ _clearEntries(identifier: ResourceKey): void;
102
+ _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
106
103
  }
107
104
  export {};