@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.
- package/declarations/graph/-private/-diff.d.ts +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -33
- package/declarations/reactive/-private/schema.d.ts +50 -66
- package/declarations/reactive/-private/symbols.d.ts +2 -7
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -23
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -24
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
- package/declarations/store/-private/store-service.d.ts +167 -872
- package/declarations/store/-private.d.ts +14 -10
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +64 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +224 -0
- package/declarations/store/deprecated/store.d.ts +787 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -115
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +69 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +391 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/types.d.ts +2 -1
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +337 -1422
- package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +10 -10
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- 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 {
|
|
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 {
|
|
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:
|
|
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 {
|
|
104
|
+
* @param {ResourceKey | RequestKey} cacheKey
|
|
109
105
|
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
110
106
|
*/
|
|
111
|
-
peek(
|
|
112
|
-
peek(
|
|
113
|
-
peekRemoteState(
|
|
114
|
-
peekRemoteState(
|
|
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 {
|
|
120
|
-
* @return {
|
|
115
|
+
* @param {RequestKey}
|
|
116
|
+
* @return {RequestKey | null}
|
|
121
117
|
* @public
|
|
122
118
|
*/
|
|
123
|
-
peekRequest(
|
|
119
|
+
peekRequest(key: RequestKey): StructuredDocument<ResourceDocument> | null;
|
|
124
120
|
/**
|
|
125
|
-
* Push resource data from a remote source into the cache for this
|
|
121
|
+
* Push resource data from a remote source into the cache for this ResourceKey
|
|
126
122
|
*
|
|
127
123
|
* @public
|
|
128
|
-
* @
|
|
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(
|
|
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 `
|
|
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
|
-
*
|
|
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(
|
|
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
|
|
231
|
+
* @param key
|
|
241
232
|
*/
|
|
242
|
-
willCommit(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
334
|
-
additions: Set<
|
|
335
|
-
removals: Set<
|
|
336
|
-
localState:
|
|
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:
|
|
342
|
-
localState:
|
|
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(
|
|
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(
|
|
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
|
-
* @
|
|
368
|
-
* @return {String[]} the names of relationships that were restored
|
|
335
|
+
* @return the names of relationships that were restored
|
|
369
336
|
*/
|
|
370
|
-
rollbackRelationships(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
393
|
+
isDeletionCommitted(key: ResourceKey): boolean;
|
|
443
394
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
(
|
|
9
|
-
(
|
|
10
|
-
(
|
|
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
|
-
(
|
|
14
|
+
(cacheKey: ResourceKey, notificationType: CacheOperation): void;
|
|
15
15
|
}
|
|
16
16
|
export interface DocumentOperationCallback {
|
|
17
17
|
// document updates
|
|
18
|
-
(
|
|
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
|
|
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
|
-
* (
|
|
52
|
-
* (
|
|
53
|
-
* (
|
|
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
|
-
* (
|
|
46
|
+
* (cacheKey: ResourceKey, notificationType: CacheOperation): void;
|
|
58
47
|
* }
|
|
59
48
|
* export interface DocumentOperationCallback {
|
|
60
49
|
* // document updates
|
|
61
|
-
* (
|
|
50
|
+
* (cacheKey: RequestKey, notificationType: CacheOperation): void;
|
|
62
51
|
* }
|
|
63
52
|
* ```
|
|
64
53
|
*
|
|
65
54
|
* @public
|
|
66
|
-
* @
|
|
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(
|
|
71
|
-
subscribe(
|
|
72
|
-
subscribe(
|
|
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(
|
|
85
|
-
notify(
|
|
86
|
-
notify(
|
|
87
|
-
notify(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
-
@
|
|
50
|
-
@
|
|
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
|
-
@
|
|
76
|
-
@param {String} modelName
|
|
77
|
-
@return {RecordArray}
|
|
72
|
+
@private
|
|
78
73
|
*/
|
|
79
|
-
liveArrayFor(type: string):
|
|
80
|
-
getCollection(config:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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 {
|
|
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:
|
|
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]:
|
|
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 {
|
|
71
|
+
* @param {ResourceKey} identifier
|
|
87
72
|
* @param {(state: RequestCacheRequestState) => void} callback
|
|
88
73
|
*/
|
|
89
|
-
subscribeForRecord(identifier:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {};
|