@warp-drive/core 5.6.0-beta.1 → 5.6.0-beta.3
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 +0 -87
- package/declarations/graph/-private/-utils.d.ts +5 -11
- package/declarations/graph/-private/coerce-id.d.ts +0 -6
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
- 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 -51
- package/declarations/graph/-private/normalize-link.d.ts +0 -6
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
- 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 -11
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -11
- 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 -34
- package/declarations/reactive/-private/schema.d.ts +50 -68
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- 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 -24
- 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 -5
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -28
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -40
- 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} +35 -53
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -25
- 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 +132 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
- 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 +67 -0
- package/declarations/store/-private/store-service.d.ts +167 -877
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +13 -14
- 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 +223 -0
- package/declarations/store/deprecated/store.d.ts +783 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +0 -11
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -37
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -7
- package/declarations/types/cache.d.ts +51 -127
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -78
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +66 -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 -10
- package/declarations/types/spec/json-api-raw.d.ts +6 -9
- package/declarations/types.d.ts +1 -1
- package/declarations/utils/string.d.ts +2 -3
- 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 +11 -11
- 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,11 +28,8 @@ 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
|
-
// Cache Management
|
|
35
|
-
// ================
|
|
36
33
|
/**
|
|
37
34
|
* Cache the response to a request
|
|
38
35
|
*
|
|
@@ -61,14 +58,11 @@ export declare class CacheManager implements Cache {
|
|
|
61
58
|
/**
|
|
62
59
|
* Perform an operation on the cache to update the remote state.
|
|
63
60
|
*
|
|
64
|
-
* Note: currently the only valid operation is a MergeOperation
|
|
65
|
-
* which occurs when a collision of identifiers is detected.
|
|
66
|
-
*
|
|
67
61
|
* @public
|
|
68
62
|
* @param op the operation to perform
|
|
69
63
|
* @return {void}
|
|
70
64
|
*/
|
|
71
|
-
patch(op:
|
|
65
|
+
patch(op: Operation | Operation[]): void;
|
|
72
66
|
/**
|
|
73
67
|
* Update resource data with a local mutation. Currently supports operations
|
|
74
68
|
* on relationships only.
|
|
@@ -105,34 +99,29 @@ export declare class CacheManager implements Cache {
|
|
|
105
99
|
* notifications for relational data.
|
|
106
100
|
*
|
|
107
101
|
* @public
|
|
108
|
-
* @param {
|
|
102
|
+
* @param {ResourceKey | RequestKey} cacheKey
|
|
109
103
|
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
110
104
|
*/
|
|
111
|
-
peek(
|
|
112
|
-
peek(
|
|
113
|
-
peekRemoteState(
|
|
114
|
-
peekRemoteState(
|
|
105
|
+
peek(cacheKey: ResourceKey): unknown;
|
|
106
|
+
peek(cacheKey: RequestKey): ResourceDocument | null;
|
|
107
|
+
peekRemoteState(cacheKey: ResourceKey): unknown;
|
|
108
|
+
peekRemoteState(cacheKey: RequestKey): ResourceDocument | null;
|
|
115
109
|
/**
|
|
116
110
|
* Peek the Cache for the existing request data associated with
|
|
117
111
|
* a cacheable request
|
|
118
112
|
*
|
|
119
|
-
* @param {
|
|
120
|
-
* @return {
|
|
113
|
+
* @param {RequestKey}
|
|
114
|
+
* @return {RequestKey | null}
|
|
121
115
|
* @public
|
|
122
116
|
*/
|
|
123
|
-
peekRequest(
|
|
117
|
+
peekRequest(key: RequestKey): StructuredDocument<ResourceDocument> | null;
|
|
124
118
|
/**
|
|
125
|
-
* Push resource data from a remote source into the cache for this
|
|
119
|
+
* Push resource data from a remote source into the cache for this ResourceKey
|
|
126
120
|
*
|
|
127
121
|
* @public
|
|
128
|
-
* @
|
|
129
|
-
* @param data
|
|
130
|
-
* @param hasRecord
|
|
131
|
-
* @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
|
|
122
|
+
* @return if `hasRecord` is true then calculated key changes should be returned
|
|
132
123
|
*/
|
|
133
|
-
upsert(
|
|
134
|
-
// Cache Forking Support
|
|
135
|
-
// =====================
|
|
124
|
+
upsert(key: ResourceKey, data: unknown, hasRecord: boolean): void | string[];
|
|
136
125
|
/**
|
|
137
126
|
* Create a fork of the cache from the current state.
|
|
138
127
|
*
|
|
@@ -165,7 +154,7 @@ export declare class CacheManager implements Cache {
|
|
|
165
154
|
* `Change` entry in the returned array.
|
|
166
155
|
*
|
|
167
156
|
* A `Change` is described by an object containing up to
|
|
168
|
-
* three properties: (1) the `
|
|
157
|
+
* three properties: (1) the `ResourceKey` of the entity that
|
|
169
158
|
* changed; (2) the `op` code of that change being one of
|
|
170
159
|
* `upsert` or `remove`, and if the op is `upsert` a `patch`
|
|
171
160
|
* containing the data to merge into the cache for the given
|
|
@@ -180,7 +169,7 @@ export declare class CacheManager implements Cache {
|
|
|
180
169
|
*
|
|
181
170
|
* ```ts
|
|
182
171
|
* interface Change {
|
|
183
|
-
*
|
|
172
|
+
* key: ResourceKey | RequestKey;
|
|
184
173
|
* op: 'upsert' | 'remove';
|
|
185
174
|
* patch?: unknown;
|
|
186
175
|
* }
|
|
@@ -189,8 +178,6 @@ export declare class CacheManager implements Cache {
|
|
|
189
178
|
* @public
|
|
190
179
|
*/
|
|
191
180
|
diff(): Promise<Change[]>;
|
|
192
|
-
// SSR Support
|
|
193
|
-
// ===========
|
|
194
181
|
/**
|
|
195
182
|
* Serialize the entire contents of the Cache into a Stream
|
|
196
183
|
* which may be fed back into a new instance of the same Cache
|
|
@@ -217,10 +204,6 @@ export declare class CacheManager implements Cache {
|
|
|
217
204
|
* @public
|
|
218
205
|
*/
|
|
219
206
|
hydrate(stream: ReadableStream<unknown>): Promise<void>;
|
|
220
|
-
// Cache
|
|
221
|
-
// =====
|
|
222
|
-
// Resource Support
|
|
223
|
-
// ================
|
|
224
207
|
/**
|
|
225
208
|
* [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
|
|
226
209
|
*
|
|
@@ -228,99 +211,74 @@ export declare class CacheManager implements Cache {
|
|
|
228
211
|
* process. This return value behavior is deprecated.
|
|
229
212
|
*
|
|
230
213
|
* @public
|
|
231
|
-
* @param identifier
|
|
232
|
-
* @param options
|
|
233
214
|
*/
|
|
234
|
-
clientDidCreate(
|
|
215
|
+
clientDidCreate(key: ResourceKey, options?: Record<string, unknown>): Record<string, unknown>;
|
|
235
216
|
/**
|
|
236
217
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
237
218
|
* will be part of a save transaction.
|
|
238
219
|
*
|
|
239
220
|
* @public
|
|
240
|
-
* @param
|
|
221
|
+
* @param key
|
|
241
222
|
*/
|
|
242
|
-
willCommit(
|
|
223
|
+
willCommit(key: ResourceKey, context: StoreRequestContext): void;
|
|
243
224
|
/**
|
|
244
225
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
245
226
|
* was successfully updated as part of a save transaction.
|
|
246
227
|
*
|
|
247
228
|
* @public
|
|
248
|
-
* @param identifier
|
|
249
|
-
* @param data
|
|
250
229
|
*/
|
|
251
|
-
didCommit(
|
|
230
|
+
didCommit(key: ResourceKey, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
|
|
252
231
|
/**
|
|
253
232
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
254
233
|
* was update via a save transaction failed.
|
|
255
234
|
*
|
|
256
235
|
* @public
|
|
257
|
-
* @param identifier
|
|
258
|
-
* @param errors
|
|
259
236
|
*/
|
|
260
|
-
commitWasRejected(
|
|
237
|
+
commitWasRejected(key: ResourceKey, errors?: ApiError[]): void;
|
|
261
238
|
/**
|
|
262
239
|
* [LIFECYCLE] Signals to the cache that all data for a resource
|
|
263
240
|
* should be cleared.
|
|
264
241
|
*
|
|
265
242
|
* @public
|
|
266
|
-
* @param identifier
|
|
267
243
|
*/
|
|
268
|
-
unloadRecord(
|
|
269
|
-
// Granular Resource Data APIs
|
|
270
|
-
// ===========================
|
|
244
|
+
unloadRecord(key: ResourceKey): void;
|
|
271
245
|
/**
|
|
272
246
|
* Retrieve the data for an attribute from the cache
|
|
273
247
|
*
|
|
274
248
|
* @public
|
|
275
|
-
* @param identifier
|
|
276
|
-
* @param propertyName
|
|
277
|
-
* @return {unknown}
|
|
278
249
|
*/
|
|
279
|
-
getAttr(
|
|
250
|
+
getAttr(key: ResourceKey, propertyName: string): Value | undefined;
|
|
280
251
|
/**
|
|
281
252
|
* Retrieve the remote state for an attribute from the cache
|
|
282
253
|
*
|
|
283
254
|
* @public
|
|
284
|
-
* @param identifier
|
|
285
|
-
* @param propertyName
|
|
286
|
-
* @return {unknown}
|
|
287
255
|
*/
|
|
288
|
-
getRemoteAttr(
|
|
256
|
+
getRemoteAttr(key: ResourceKey, propertyName: string): Value | undefined;
|
|
289
257
|
/**
|
|
290
258
|
* Mutate the data for an attribute in the cache
|
|
291
259
|
*
|
|
292
260
|
* @public
|
|
293
|
-
* @param identifier
|
|
294
|
-
* @param propertyName
|
|
295
|
-
* @param value
|
|
296
261
|
*/
|
|
297
|
-
setAttr(
|
|
262
|
+
setAttr(key: ResourceKey, propertyName: string, value: Value): void;
|
|
298
263
|
/**
|
|
299
264
|
* Query the cache for the changed attributes of a resource.
|
|
300
265
|
*
|
|
301
266
|
* @public
|
|
302
|
-
* @param identifier
|
|
303
|
-
* @return
|
|
304
267
|
*/
|
|
305
|
-
changedAttrs(
|
|
268
|
+
changedAttrs(key: ResourceKey): ChangedAttributesHash;
|
|
306
269
|
/**
|
|
307
270
|
* Query the cache for whether any mutated attributes exist
|
|
308
271
|
*
|
|
309
272
|
* @public
|
|
310
|
-
* @param identifier
|
|
311
|
-
* @return {Boolean}
|
|
312
273
|
*/
|
|
313
|
-
hasChangedAttrs(
|
|
274
|
+
hasChangedAttrs(key: ResourceKey): boolean;
|
|
314
275
|
/**
|
|
315
276
|
* Tell the cache to discard any uncommitted mutations to attributes
|
|
316
277
|
*
|
|
317
278
|
* @public
|
|
318
|
-
* @param identifier
|
|
319
279
|
* @return the names of attributes that were restored
|
|
320
280
|
*/
|
|
321
|
-
rollbackAttrs(
|
|
322
|
-
// Relationships
|
|
323
|
-
// =============
|
|
281
|
+
rollbackAttrs(key: ResourceKey): string[];
|
|
324
282
|
/**
|
|
325
283
|
* Query the cache for the changes to relationships of a resource.
|
|
326
284
|
*
|
|
@@ -330,32 +288,28 @@ export declare class CacheManager implements Cache {
|
|
|
330
288
|
* type RelationshipDiff =
|
|
331
289
|
| {
|
|
332
290
|
kind: 'collection';
|
|
333
|
-
remoteState:
|
|
334
|
-
additions: Set<
|
|
335
|
-
removals: Set<
|
|
336
|
-
localState:
|
|
291
|
+
remoteState: ResourceKey[];
|
|
292
|
+
additions: Set<ResourceKey>;
|
|
293
|
+
removals: Set<ResourceKey>;
|
|
294
|
+
localState: ResourceKey[];
|
|
337
295
|
reordered: boolean;
|
|
338
296
|
}
|
|
339
297
|
| {
|
|
340
298
|
kind: 'resource';
|
|
341
|
-
remoteState:
|
|
342
|
-
localState:
|
|
299
|
+
remoteState: ResourceKey | null;
|
|
300
|
+
localState: ResourceKey | null;
|
|
343
301
|
};
|
|
344
302
|
```
|
|
345
303
|
*
|
|
346
304
|
* @public
|
|
347
|
-
* @param {StableRecordIdentifier} identifier
|
|
348
|
-
* @return {Map<string, RelationshipDiff>}
|
|
349
305
|
*/
|
|
350
|
-
changedRelationships(
|
|
306
|
+
changedRelationships(key: ResourceKey): Map<string, RelationshipDiff>;
|
|
351
307
|
/**
|
|
352
308
|
* Query the cache for whether any mutated attributes exist
|
|
353
309
|
*
|
|
354
310
|
* @public
|
|
355
|
-
* @param {StableRecordIdentifier} identifier
|
|
356
|
-
* @return {Boolean}
|
|
357
311
|
*/
|
|
358
|
-
hasChangedRelationships(
|
|
312
|
+
hasChangedRelationships(key: ResourceKey): boolean;
|
|
359
313
|
/**
|
|
360
314
|
* Tell the cache to discard any uncommitted mutations to relationships.
|
|
361
315
|
*
|
|
@@ -364,80 +318,61 @@ export declare class CacheManager implements Cache {
|
|
|
364
318
|
* This method is a candidate to become a mutation
|
|
365
319
|
*
|
|
366
320
|
* @public
|
|
367
|
-
* @
|
|
368
|
-
* @return {String[]} the names of relationships that were restored
|
|
321
|
+
* @return the names of relationships that were restored
|
|
369
322
|
*/
|
|
370
|
-
rollbackRelationships(
|
|
323
|
+
rollbackRelationships(key: ResourceKey): string[];
|
|
371
324
|
/**
|
|
372
325
|
* Query the cache for the current state of a relationship property
|
|
373
326
|
*
|
|
374
327
|
* @public
|
|
375
|
-
* @param identifier
|
|
376
|
-
* @param propertyName
|
|
377
328
|
* @return resource relationship object
|
|
378
329
|
*/
|
|
379
|
-
getRelationship(
|
|
330
|
+
getRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
380
331
|
/**
|
|
381
332
|
* Query the cache for the remote state of a relationship property
|
|
382
333
|
*
|
|
383
334
|
* @public
|
|
384
|
-
* @param identifier
|
|
385
|
-
* @param propertyName
|
|
386
335
|
* @return resource relationship object
|
|
387
336
|
*/
|
|
388
|
-
getRemoteRelationship(
|
|
389
|
-
// Resource State
|
|
390
|
-
// ===============
|
|
337
|
+
getRemoteRelationship(key: ResourceKey, propertyName: string): ResourceRelationship | CollectionRelationship;
|
|
391
338
|
/**
|
|
392
339
|
* Update the cache state for the given resource to be marked as locally deleted,
|
|
393
340
|
* or remove such a mark.
|
|
394
341
|
*
|
|
395
342
|
* @public
|
|
396
|
-
* @param identifier
|
|
397
|
-
* @param isDeleted
|
|
398
343
|
*/
|
|
399
|
-
setIsDeleted(
|
|
344
|
+
setIsDeleted(key: ResourceKey, isDeleted: boolean): void;
|
|
400
345
|
/**
|
|
401
346
|
* Query the cache for any validation errors applicable to the given resource.
|
|
402
347
|
*
|
|
403
348
|
* @public
|
|
404
|
-
* @param identifier
|
|
405
|
-
* @return
|
|
406
349
|
*/
|
|
407
|
-
getErrors(
|
|
350
|
+
getErrors(key: ResourceKey): ApiError[];
|
|
408
351
|
/**
|
|
409
352
|
* Query the cache for whether a given resource has any available data
|
|
410
353
|
*
|
|
411
354
|
* @public
|
|
412
|
-
* @param identifier
|
|
413
|
-
* @return {Boolean}
|
|
414
355
|
*/
|
|
415
|
-
isEmpty(
|
|
356
|
+
isEmpty(key: ResourceKey): boolean;
|
|
416
357
|
/**
|
|
417
358
|
* Query the cache for whether a given resource was created locally and not
|
|
418
359
|
* yet persisted.
|
|
419
360
|
*
|
|
420
361
|
* @public
|
|
421
|
-
* @param identifier
|
|
422
|
-
* @return {Boolean}
|
|
423
362
|
*/
|
|
424
|
-
isNew(
|
|
363
|
+
isNew(key: ResourceKey): boolean;
|
|
425
364
|
/**
|
|
426
365
|
* Query the cache for whether a given resource is marked as deleted (but not
|
|
427
366
|
* necessarily persisted yet).
|
|
428
367
|
*
|
|
429
368
|
* @public
|
|
430
|
-
* @param identifier
|
|
431
|
-
* @return {Boolean}
|
|
432
369
|
*/
|
|
433
|
-
isDeleted(
|
|
370
|
+
isDeleted(key: ResourceKey): boolean;
|
|
434
371
|
/**
|
|
435
372
|
* Query the cache for whether a given resource has been deleted and that deletion
|
|
436
373
|
* has also been persisted.
|
|
437
374
|
*
|
|
438
375
|
* @public
|
|
439
|
-
* @param identifier
|
|
440
|
-
* @return {Boolean}
|
|
441
376
|
*/
|
|
442
|
-
isDeletionCommitted(
|
|
377
|
+
isDeletionCommitted(key: ResourceKey): boolean;
|
|
443
378
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
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
|
-
|
|
14
|
-
(identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
13
|
+
(cacheKey: ResourceKey, notificationType: CacheOperation): void;
|
|
15
14
|
}
|
|
16
15
|
export interface DocumentOperationCallback {
|
|
17
|
-
|
|
18
|
-
(identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
|
|
16
|
+
(cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* The NotificationManager provides the ability to subscribe to
|
|
@@ -28,48 +26,35 @@ export interface DocumentOperationCallback {
|
|
|
28
26
|
* @public
|
|
29
27
|
*/
|
|
30
28
|
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
29
|
constructor(store: Store);
|
|
44
30
|
/**
|
|
45
|
-
* Subscribe to changes for a given
|
|
31
|
+
* Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource
|
|
32
|
+
* or document.
|
|
46
33
|
*
|
|
47
34
|
* ```ts
|
|
48
35
|
* export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
|
|
49
36
|
*
|
|
50
37
|
* export interface NotificationCallback {
|
|
51
|
-
* (
|
|
52
|
-
* (
|
|
53
|
-
* (
|
|
38
|
+
* (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
|
|
39
|
+
* (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
|
|
40
|
+
* (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
|
|
54
41
|
* }
|
|
55
42
|
* export interface ResourceOperationCallback {
|
|
56
43
|
* // resource updates
|
|
57
|
-
* (
|
|
44
|
+
* (cacheKey: ResourceKey, notificationType: CacheOperation): void;
|
|
58
45
|
* }
|
|
59
46
|
* export interface DocumentOperationCallback {
|
|
60
47
|
* // document updates
|
|
61
|
-
* (
|
|
48
|
+
* (cacheKey: RequestKey, notificationType: CacheOperation): void;
|
|
62
49
|
* }
|
|
63
50
|
* ```
|
|
64
51
|
*
|
|
65
52
|
* @public
|
|
66
|
-
* @
|
|
67
|
-
* @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
|
|
68
|
-
* @return {UnsubscribeToken} an opaque token to be used with unsubscribe
|
|
53
|
+
* @return an opaque token to be used with unsubscribe
|
|
69
54
|
*/
|
|
70
|
-
subscribe(
|
|
71
|
-
subscribe(
|
|
72
|
-
subscribe(
|
|
55
|
+
subscribe(cacheKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
|
|
56
|
+
subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
|
|
57
|
+
subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
|
|
73
58
|
/**
|
|
74
59
|
* remove a previous subscription
|
|
75
60
|
*
|
|
@@ -81,18 +66,18 @@ export default class NotificationManager {
|
|
|
81
66
|
*
|
|
82
67
|
* @private
|
|
83
68
|
*/
|
|
84
|
-
notify(
|
|
85
|
-
notify(
|
|
86
|
-
notify(
|
|
87
|
-
notify(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string | null): boolean;
|
|
70
|
+
notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state", key?: null): boolean;
|
|
71
|
+
notify(cacheKey: ResourceKey, value: CacheOperation, key?: null): boolean;
|
|
72
|
+
notify(cacheKey: RequestKey, value: DocumentCacheOperation, key?: null): boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* This type exists for internal use only for
|
|
76
|
+
* where intimate contracts still exist either for
|
|
77
|
+
* the Test Suite or for Legacy code.
|
|
78
|
+
*
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
export interface PrivateNotificationManager extends NotificationManager {
|
|
92
82
|
_flush(): void;
|
|
93
|
-
private _flushNotification;
|
|
94
|
-
private _flushNotification;
|
|
95
|
-
private _flushNotification;
|
|
96
|
-
/** @internal */
|
|
97
|
-
destroy(): void;
|
|
98
83
|
}
|
|
@@ -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 {};
|