@warp-drive/core 5.6.0-alpha.15 → 5.6.0-alpha.18
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/build-config/babel-macros.d.ts +1 -2
- package/declarations/build-config/canary-features.d.ts +1 -2
- package/declarations/build-config/debugging.d.ts +1 -2
- package/declarations/build-config/deprecations.d.ts +1 -2
- package/declarations/build-config/env.d.ts +1 -2
- package/declarations/build-config/macros.d.ts +1 -2
- package/declarations/build-config.d.ts +1 -2
- package/declarations/configure.d.ts +6 -7
- package/declarations/graph/-private/-diff.d.ts +21 -22
- package/declarations/graph/-private/-edge-definition.d.ts +134 -135
- package/declarations/graph/-private/-state.d.ts +93 -7
- package/declarations/graph/-private/-utils.d.ts +18 -13
- package/declarations/graph/-private/coerce-id.d.ts +6 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/graph/-private/edges/collection.d.ts +35 -36
- package/declarations/graph/-private/edges/implicit.d.ts +28 -29
- package/declarations/graph/-private/edges/resource.d.ts +19 -20
- package/declarations/graph/-private/graph.d.ts +83 -48
- package/declarations/graph/-private/normalize-link.d.ts +7 -2
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/merge-identifier.d.ts +2 -3
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/replace-related-record.d.ts +2 -3
- package/declarations/graph/-private/operations/replace-related-records.d.ts +58 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +11 -9
- package/declarations/graph/-private.d.ts +9 -10
- package/declarations/index.d.ts +11 -12
- package/declarations/reactive/-private/document.d.ts +143 -144
- package/declarations/reactive/-private/fields/compute.d.ts +31 -28
- package/declarations/reactive/-private/fields/extension.d.ts +2 -3
- package/declarations/reactive/-private/fields/managed-array.d.ts +19 -20
- package/declarations/reactive/-private/fields/managed-object.d.ts +16 -16
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +15 -16
- package/declarations/reactive/-private/hooks.d.ts +3 -4
- package/declarations/reactive/-private/record.d.ts +61 -59
- package/declarations/reactive/-private/schema.d.ts +242 -224
- package/declarations/reactive/-private/symbols.d.ts +26 -1
- package/declarations/reactive/-private.d.ts +1 -2
- package/declarations/reactive.d.ts +4 -5
- package/declarations/request/-private/context.d.ts +34 -35
- package/declarations/request/-private/debug.d.ts +2 -3
- package/declarations/request/-private/fetch.d.ts +23 -24
- package/declarations/request/-private/future.d.ts +3 -4
- package/declarations/request/-private/manager.d.ts +159 -157
- package/declarations/request/-private/promise-cache.d.ts +21 -13
- package/declarations/request/-private/types.d.ts +124 -124
- package/declarations/request/-private/utils.d.ts +8 -9
- package/declarations/request.d.ts +5 -6
- package/declarations/store/-private/cache-handler/handler.d.ts +57 -52
- package/declarations/store/-private/cache-handler/types.d.ts +95 -96
- package/declarations/store/-private/cache-handler/utils.d.ts +16 -16
- package/declarations/store/-private/caches/cache-utils.d.ts +7 -4
- package/declarations/store/-private/caches/identifier-cache.d.ts +234 -246
- package/declarations/store/-private/caches/instance-cache.d.ts +47 -47
- package/declarations/store/-private/caches/resource-utils.d.ts +3 -4
- package/declarations/store/-private/debug/utils.d.ts +6 -7
- package/declarations/store/-private/default-cache-policy.d.ts +362 -361
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +154 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +14 -14
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +21 -22
- package/declarations/store/-private/managers/cache-manager.d.ts +440 -425
- package/declarations/store/-private/managers/notification-manager.d.ts +88 -83
- package/declarations/store/-private/managers/record-array-manager.d.ts +89 -90
- package/declarations/store/-private/network/request-cache.d.ts +86 -83
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +252 -244
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +154 -155
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +148 -149
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +28 -23
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +263 -241
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +253 -223
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -121
- package/declarations/store/-private/record-arrays/many-array.d.ts +180 -184
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +120 -110
- package/declarations/store/-private/store-service.d.ts +1594 -1586
- package/declarations/store/-private/utils/coerce-id.d.ts +6 -1
- package/declarations/store/-private/utils/construct-resource.d.ts +1 -2
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/declarations/store/-private.d.ts +31 -28
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +96 -97
- package/declarations/store/-types/q/ds-model.d.ts +17 -18
- package/declarations/store/-types/q/identifier.d.ts +11 -12
- package/declarations/store/-types/q/record-instance.d.ts +16 -17
- package/declarations/store/-types/q/schema-service.d.ts +346 -343
- package/declarations/store/-types/q/store.d.ts +25 -28
- package/declarations/store.d.ts +1 -2
- package/declarations/types/-private.d.ts +16 -8
- package/declarations/types/cache/aliases.d.ts +11 -1
- package/declarations/types/cache/change.d.ts +4 -5
- package/declarations/types/cache/mutations.d.ts +51 -28
- package/declarations/types/cache/operations.d.ts +60 -47
- package/declarations/types/cache/relationship.d.ts +11 -9
- package/declarations/types/cache.d.ts +495 -484
- package/declarations/types/graph.d.ts +31 -32
- package/declarations/types/identifier.d.ts +83 -82
- package/declarations/types/json/raw.d.ts +1 -2
- package/declarations/types/params.d.ts +4 -5
- package/declarations/types/record.d.ts +117 -76
- package/declarations/types/request.d.ts +289 -266
- package/declarations/types/runtime.d.ts +8 -9
- package/declarations/types/schema/concepts.d.ts +19 -13
- package/declarations/types/schema/fields.d.ts +1712 -1713
- package/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/declarations/types/spec/document.d.ts +28 -22
- package/declarations/types/spec/error.d.ts +16 -17
- package/declarations/types/spec/json-api-raw.d.ts +102 -102
- package/declarations/types/symbols.d.ts +74 -75
- package/declarations/types/utils.d.ts +5 -5
- package/declarations/types.d.ts +10 -11
- package/declarations/utils/string.d.ts +43 -40
- package/dist/graph/-private.js +1 -1
- package/dist/{handler-D1C3Innj.js → handler-C2T-IyJK.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +42 -73
- package/dist/{request-state-CCOJIj5i.js → request-state-CjLph1LP.js} +275 -261
- package/dist/store/-private.js +2 -2
- package/dist/{symbols-epHW0Vm9.js → symbols-SIstXMLI.js} +1 -1
- package/dist/types/-private.js +1 -1
- package/package.json +4 -4
- package/declarations/build-config/babel-macros.d.ts.map +0 -1
- package/declarations/build-config/canary-features.d.ts.map +0 -1
- package/declarations/build-config/debugging.d.ts.map +0 -1
- package/declarations/build-config/deprecations.d.ts.map +0 -1
- package/declarations/build-config/env.d.ts.map +0 -1
- package/declarations/build-config/macros.d.ts.map +0 -1
- package/declarations/build-config.d.ts.map +0 -1
- package/declarations/configure.d.ts.map +0 -1
- package/declarations/graph/-private/-diff.d.ts.map +0 -1
- package/declarations/graph/-private/-edge-definition.d.ts.map +0 -1
- package/declarations/graph/-private/-state.d.ts.map +0 -1
- package/declarations/graph/-private/-utils.d.ts.map +0 -1
- package/declarations/graph/-private/coerce-id.d.ts.map +0 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/graph/-private/edges/collection.d.ts.map +0 -1
- package/declarations/graph/-private/edges/implicit.d.ts.map +0 -1
- package/declarations/graph/-private/edges/resource.d.ts.map +0 -1
- package/declarations/graph/-private/graph.d.ts.map +0 -1
- package/declarations/graph/-private/normalize-link.d.ts.map +0 -1
- package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/merge-identifier.d.ts.map +0 -1
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-record.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/update-relationship.d.ts.map +0 -1
- package/declarations/graph/-private.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/reactive/-private/document.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/compute.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/extension.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-object.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +0 -1
- package/declarations/reactive/-private/hooks.d.ts.map +0 -1
- package/declarations/reactive/-private/record.d.ts.map +0 -1
- package/declarations/reactive/-private/schema.d.ts.map +0 -1
- package/declarations/reactive/-private/symbols.d.ts.map +0 -1
- package/declarations/reactive/-private.d.ts.map +0 -1
- package/declarations/reactive.d.ts.map +0 -1
- package/declarations/request/-private/context.d.ts.map +0 -1
- package/declarations/request/-private/debug.d.ts.map +0 -1
- package/declarations/request/-private/fetch.d.ts.map +0 -1
- package/declarations/request/-private/future.d.ts.map +0 -1
- package/declarations/request/-private/manager.d.ts.map +0 -1
- package/declarations/request/-private/promise-cache.d.ts.map +0 -1
- package/declarations/request/-private/types.d.ts.map +0 -1
- package/declarations/request/-private/utils.d.ts.map +0 -1
- package/declarations/request.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/handler.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/types.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/cache-utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/identifier-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/instance-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/resource-utils.d.ts.map +0 -1
- package/declarations/store/-private/debug/utils.d.ts.map +0 -1
- package/declarations/store/-private/default-cache-policy.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/notification-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/record-array-manager.d.ts.map +0 -1
- package/declarations/store/-private/network/request-cache.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/many-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +0 -1
- package/declarations/store/-private/store-service.d.ts.map +0 -1
- package/declarations/store/-private/store-service.type-test.d.ts +0 -2
- package/declarations/store/-private/store-service.type-test.d.ts.map +0 -1
- package/declarations/store/-private/utils/coerce-id.d.ts.map +0 -1
- package/declarations/store/-private/utils/construct-resource.d.ts.map +0 -1
- package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts.map +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +0 -1
- package/declarations/store/-private.d.ts.map +0 -1
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-types/q/ds-model.d.ts.map +0 -1
- package/declarations/store/-types/q/identifier.d.ts.map +0 -1
- package/declarations/store/-types/q/promise-proxies.d.ts +0 -2
- package/declarations/store/-types/q/promise-proxies.d.ts.map +0 -1
- package/declarations/store/-types/q/record-data-json-api.d.ts +0 -31
- package/declarations/store/-types/q/record-data-json-api.d.ts.map +0 -1
- package/declarations/store/-types/q/record-instance.d.ts.map +0 -1
- package/declarations/store/-types/q/schema-service.d.ts.map +0 -1
- package/declarations/store/-types/q/store.d.ts.map +0 -1
- package/declarations/store.d.ts.map +0 -1
- package/declarations/types/-private.d.ts.map +0 -1
- package/declarations/types/cache/aliases.d.ts.map +0 -1
- package/declarations/types/cache/change.d.ts.map +0 -1
- package/declarations/types/cache/mutations.d.ts.map +0 -1
- package/declarations/types/cache/operations.d.ts.map +0 -1
- package/declarations/types/cache/relationship.d.ts.map +0 -1
- package/declarations/types/cache.d.ts.map +0 -1
- package/declarations/types/graph.d.ts.map +0 -1
- package/declarations/types/identifier.d.ts.map +0 -1
- package/declarations/types/json/raw.d.ts.map +0 -1
- package/declarations/types/params.d.ts.map +0 -1
- package/declarations/types/record.d.ts.map +0 -1
- package/declarations/types/record.type-test.d.ts +0 -2
- package/declarations/types/record.type-test.d.ts.map +0 -1
- package/declarations/types/request.d.ts.map +0 -1
- package/declarations/types/request.type-test.d.ts +0 -2
- package/declarations/types/request.type-test.d.ts.map +0 -1
- package/declarations/types/runtime.d.ts.map +0 -1
- package/declarations/types/schema/concepts.d.ts.map +0 -1
- package/declarations/types/schema/fields.d.ts.map +0 -1
- package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
- package/declarations/types/spec/document.d.ts.map +0 -1
- package/declarations/types/spec/error.d.ts.map +0 -1
- package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
- package/declarations/types/symbols.d.ts.map +0 -1
- package/declarations/types/utils.d.ts.map +0 -1
- package/declarations/types.d.ts.map +0 -1
- package/declarations/utils/string.d.ts.map +0 -1
- package/dist/build-config/babel-macros.js.map +0 -1
- package/dist/build-config/canary-features.js.map +0 -1
- package/dist/build-config/debugging.js.map +0 -1
- package/dist/build-config/deprecations.js.map +0 -1
- package/dist/build-config/env.js.map +0 -1
- package/dist/build-config/macros.js.map +0 -1
- package/dist/build-config.js.map +0 -1
- package/dist/configure-B48bFHOl.js.map +0 -1
- package/dist/configure.js.map +0 -1
- package/dist/context-COmAnXUQ.js.map +0 -1
- package/dist/graph/-private.js.map +0 -1
- package/dist/handler-D1C3Innj.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactive/-private.js.map +0 -1
- package/dist/reactive.js.map +0 -1
- package/dist/request-state-CCOJIj5i.js.map +0 -1
- package/dist/request.js.map +0 -1
- package/dist/store/-private.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/symbols-epHW0Vm9.js.map +0 -1
- package/dist/types/-private.js.map +0 -1
- package/dist/types/cache/aliases.js.map +0 -1
- package/dist/types/cache/change.js.map +0 -1
- package/dist/types/cache/mutations.js.map +0 -1
- package/dist/types/cache/operations.js.map +0 -1
- package/dist/types/cache/relationship.js.map +0 -1
- package/dist/types/cache.js.map +0 -1
- package/dist/types/graph.js.map +0 -1
- package/dist/types/identifier.js.map +0 -1
- package/dist/types/json/raw.js.map +0 -1
- package/dist/types/params.js.map +0 -1
- package/dist/types/record.js.map +0 -1
- package/dist/types/request.js.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- package/dist/types/schema/concepts.js.map +0 -1
- package/dist/types/schema/fields.js.map +0 -1
- package/dist/types/schema/fields.type-test.js.map +0 -1
- package/dist/types/spec/document.js.map +0 -1
- package/dist/types/spec/error.js.map +0 -1
- package/dist/types/spec/json-api-raw.js.map +0 -1
- package/dist/types/symbols.js.map +0 -1
- package/dist/types/utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/string.js.map +0 -1
|
@@ -393,7 +393,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
/**
|
|
396
|
-
* Each instance of {Store} receives a unique instance of a IdentifierCache.
|
|
396
|
+
* Each instance of {@link Store} receives a unique instance of a IdentifierCache.
|
|
397
397
|
*
|
|
398
398
|
* This cache is responsible for assigning or retrieving the unique identify
|
|
399
399
|
* for arbitrary resource data encountered by the store. Data representing
|
|
@@ -402,10 +402,12 @@ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
|
402
402
|
*
|
|
403
403
|
* It can be configured by consuming applications.
|
|
404
404
|
*
|
|
405
|
-
* @
|
|
406
|
-
|
|
405
|
+
* @hideconstructor
|
|
406
|
+
* @public
|
|
407
407
|
*/
|
|
408
408
|
class IdentifierCache {
|
|
409
|
+
/** @internal */
|
|
410
|
+
|
|
409
411
|
constructor() {
|
|
410
412
|
// we cache the user configuredGenerationMethod at init because it must
|
|
411
413
|
// be configured prior and is not allowed to be changed
|
|
@@ -435,6 +437,8 @@ class IdentifierCache {
|
|
|
435
437
|
__configureMerge(method) {
|
|
436
438
|
this._merge = method || defaultMergeMethod;
|
|
437
439
|
}
|
|
440
|
+
|
|
441
|
+
/** @internal */
|
|
438
442
|
upgradeIdentifier(resource) {
|
|
439
443
|
return this._getRecordIdentifier(resource, 2);
|
|
440
444
|
}
|
|
@@ -524,8 +528,6 @@ class IdentifierCache {
|
|
|
524
528
|
* useful for the "create" case when we need to see if
|
|
525
529
|
* we are accidentally overwritting something
|
|
526
530
|
*
|
|
527
|
-
* @param resource
|
|
528
|
-
* @return {StableRecordIdentifier | undefined}
|
|
529
531
|
* @private
|
|
530
532
|
*/
|
|
531
533
|
peekRecordIdentifier(resource) {
|
|
@@ -535,9 +537,7 @@ class IdentifierCache {
|
|
|
535
537
|
/**
|
|
536
538
|
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
537
539
|
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
538
|
-
@
|
|
539
|
-
@return {StableDocumentIdentifier | null}
|
|
540
|
-
@public
|
|
540
|
+
@public
|
|
541
541
|
*/
|
|
542
542
|
getOrCreateDocumentIdentifier(request) {
|
|
543
543
|
let cacheKey = request.cacheOptions?.key;
|
|
@@ -568,9 +568,7 @@ class IdentifierCache {
|
|
|
568
568
|
- return an object with an `lid` that is stable (repeated calls with the same
|
|
569
569
|
`id` + `type` or `lid` will return the same `lid` value)
|
|
570
570
|
- this referential stability of the object itself is guaranteed
|
|
571
|
-
@
|
|
572
|
-
@return {StableRecordIdentifier}
|
|
573
|
-
@public
|
|
571
|
+
@public
|
|
574
572
|
*/
|
|
575
573
|
getOrCreateRecordIdentifier(resource) {
|
|
576
574
|
return this._getRecordIdentifier(resource, 1);
|
|
@@ -582,9 +580,7 @@ class IdentifierCache {
|
|
|
582
580
|
potentially does not have an `id`.
|
|
583
581
|
Delegates generation to the user supplied `GenerateMethod` if one has been provided
|
|
584
582
|
with the signature `generateMethod({ type }, 'record')`.
|
|
585
|
-
@
|
|
586
|
-
@return {StableRecordIdentifier}
|
|
587
|
-
@public
|
|
583
|
+
@public
|
|
588
584
|
*/
|
|
589
585
|
createIdentifierForNewRecord(data) {
|
|
590
586
|
const newLid = this._generate(data, 'record');
|
|
@@ -625,10 +621,7 @@ class IdentifierCache {
|
|
|
625
621
|
If a merge occurs, it is possible the returned identifier does not match the originally
|
|
626
622
|
provided identifier. In this case the abandoned identifier will go through the usual
|
|
627
623
|
`forgetRecordIdentifier` codepaths.
|
|
628
|
-
@
|
|
629
|
-
@param data
|
|
630
|
-
@return {StableRecordIdentifier}
|
|
631
|
-
@public
|
|
624
|
+
@public
|
|
632
625
|
*/
|
|
633
626
|
updateRecordIdentifier(identifierObject, data) {
|
|
634
627
|
let identifier = this.getOrCreateRecordIdentifier(identifierObject);
|
|
@@ -741,8 +734,7 @@ class IdentifierCache {
|
|
|
741
734
|
Useful when a record has been deleted and the deletion has been persisted and
|
|
742
735
|
we do not care about the record anymore. Especially useful when an `id` of a
|
|
743
736
|
deleted record might be reused later for a new record.
|
|
744
|
-
@
|
|
745
|
-
@public
|
|
737
|
+
@public
|
|
746
738
|
*/
|
|
747
739
|
forgetRecordIdentifier(identifierObject) {
|
|
748
740
|
const identifier = this.getOrCreateRecordIdentifier(identifierObject);
|
|
@@ -776,6 +768,8 @@ class IdentifierCache {
|
|
|
776
768
|
}
|
|
777
769
|
}
|
|
778
770
|
}
|
|
771
|
+
|
|
772
|
+
/** @internal */
|
|
779
773
|
destroy() {
|
|
780
774
|
NEW_IDENTIFIERS.clear();
|
|
781
775
|
this._cache.documents.forEach(identifier => {
|
|
@@ -1568,13 +1562,12 @@ function _log(scope, prefix, subScop1, subScop2, subScop3, subScop4) {
|
|
|
1568
1562
|
A `RecordReference` is a low-level API that allows users and
|
|
1569
1563
|
addon authors to perform meta-operations on a record.
|
|
1570
1564
|
|
|
1571
|
-
@
|
|
1565
|
+
@hideconstructor
|
|
1572
1566
|
@public
|
|
1573
1567
|
*/
|
|
1574
1568
|
class RecordReference {
|
|
1575
1569
|
// unsubscribe token given to us by the notification manager
|
|
1576
|
-
|
|
1577
|
-
___identifier;
|
|
1570
|
+
|
|
1578
1571
|
constructor(store, identifier) {
|
|
1579
1572
|
this.store = store;
|
|
1580
1573
|
this.___identifier = identifier;
|
|
@@ -1584,6 +1577,8 @@ class RecordReference {
|
|
|
1584
1577
|
}
|
|
1585
1578
|
});
|
|
1586
1579
|
}
|
|
1580
|
+
|
|
1581
|
+
/** @internal */
|
|
1587
1582
|
destroy() {
|
|
1588
1583
|
this.store.notifications.unsubscribe(this.___token);
|
|
1589
1584
|
}
|
|
@@ -1601,7 +1596,6 @@ class RecordReference {
|
|
|
1601
1596
|
userRef.id(); // '1'
|
|
1602
1597
|
```
|
|
1603
1598
|
@public
|
|
1604
|
-
@return {String} The id of the record.
|
|
1605
1599
|
*/
|
|
1606
1600
|
id() {
|
|
1607
1601
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
@@ -1619,7 +1613,6 @@ class RecordReference {
|
|
|
1619
1613
|
userRef.identifier(); // '1'
|
|
1620
1614
|
```
|
|
1621
1615
|
@public
|
|
1622
|
-
@return {String} The identifier of the record.
|
|
1623
1616
|
*/
|
|
1624
1617
|
identifier() {
|
|
1625
1618
|
return this.___identifier;
|
|
@@ -1635,7 +1628,6 @@ class RecordReference {
|
|
|
1635
1628
|
userRef.remoteType(); // 'identity'
|
|
1636
1629
|
```
|
|
1637
1630
|
@public
|
|
1638
|
-
@return {String} 'identity'
|
|
1639
1631
|
*/
|
|
1640
1632
|
remoteType() {
|
|
1641
1633
|
return 'identity';
|
|
@@ -1690,7 +1682,6 @@ class RecordReference {
|
|
|
1690
1682
|
userRef.value(); // user
|
|
1691
1683
|
```
|
|
1692
1684
|
@public
|
|
1693
|
-
@return {Model} the record for this RecordReference
|
|
1694
1685
|
*/
|
|
1695
1686
|
value() {
|
|
1696
1687
|
return this.store.peekRecord(this.___identifier);
|
|
@@ -1706,7 +1697,6 @@ class RecordReference {
|
|
|
1706
1697
|
userRef.load().then(...)
|
|
1707
1698
|
```
|
|
1708
1699
|
@public
|
|
1709
|
-
@return {Promise<record>} the record for this RecordReference
|
|
1710
1700
|
*/
|
|
1711
1701
|
load() {
|
|
1712
1702
|
const id = this.id();
|
|
@@ -1730,7 +1720,6 @@ class RecordReference {
|
|
|
1730
1720
|
userRef.reload().then(...)
|
|
1731
1721
|
```
|
|
1732
1722
|
@public
|
|
1733
|
-
@return {Promise<record>} the record for this RecordReference
|
|
1734
1723
|
*/
|
|
1735
1724
|
reload() {
|
|
1736
1725
|
const id = this.id();
|
|
@@ -2977,10 +2966,22 @@ function _unsubscribe(token, cache) {
|
|
|
2977
2966
|
* This Feature is what allows WarpDrive to create subscriptions that
|
|
2978
2967
|
* work with any framework or change-notification system.
|
|
2979
2968
|
*
|
|
2980
|
-
* @
|
|
2969
|
+
* @hideconstructor
|
|
2981
2970
|
* @public
|
|
2982
2971
|
*/
|
|
2983
2972
|
class NotificationManager {
|
|
2973
|
+
/** @internal */
|
|
2974
|
+
|
|
2975
|
+
/** @internal */
|
|
2976
|
+
|
|
2977
|
+
/** @internal */
|
|
2978
|
+
|
|
2979
|
+
/** @internal */
|
|
2980
|
+
|
|
2981
|
+
/** @internal */
|
|
2982
|
+
|
|
2983
|
+
/** @internal */
|
|
2984
|
+
|
|
2984
2985
|
constructor(store) {
|
|
2985
2986
|
this.store = store;
|
|
2986
2987
|
this.isDestroyed = false;
|
|
@@ -3048,7 +3049,6 @@ class NotificationManager {
|
|
|
3048
3049
|
* remove a previous subscription
|
|
3049
3050
|
*
|
|
3050
3051
|
* @public
|
|
3051
|
-
* @param {UnsubscribeToken} token
|
|
3052
3052
|
*/
|
|
3053
3053
|
unsubscribe(token) {
|
|
3054
3054
|
if (!this.isDestroyed) {
|
|
@@ -3059,10 +3059,6 @@ class NotificationManager {
|
|
|
3059
3059
|
/**
|
|
3060
3060
|
* Custom Caches and Application Code should not call this method directly.
|
|
3061
3061
|
*
|
|
3062
|
-
* @param identifier
|
|
3063
|
-
* @param value
|
|
3064
|
-
* @param key
|
|
3065
|
-
* @return {Boolean} whether a notification was delivered to any subscribers
|
|
3066
3062
|
* @private
|
|
3067
3063
|
*/
|
|
3068
3064
|
|
|
@@ -3115,6 +3111,8 @@ class NotificationManager {
|
|
|
3115
3111
|
}
|
|
3116
3112
|
return hasSubscribers;
|
|
3117
3113
|
}
|
|
3114
|
+
|
|
3115
|
+
/** @internal */
|
|
3118
3116
|
_onNextFlush(cb) {
|
|
3119
3117
|
this._onFlushCB = cb;
|
|
3120
3118
|
}
|
|
@@ -3132,6 +3130,8 @@ class NotificationManager {
|
|
|
3132
3130
|
this._flush();
|
|
3133
3131
|
return true;
|
|
3134
3132
|
}
|
|
3133
|
+
|
|
3134
|
+
/** @internal */
|
|
3135
3135
|
_flush() {
|
|
3136
3136
|
const buffered = this._buffered;
|
|
3137
3137
|
if (buffered.size) {
|
|
@@ -3173,6 +3173,8 @@ class NotificationManager {
|
|
|
3173
3173
|
});
|
|
3174
3174
|
return true;
|
|
3175
3175
|
}
|
|
3176
|
+
|
|
3177
|
+
/** @internal */
|
|
3176
3178
|
destroy() {
|
|
3177
3179
|
this.isDestroyed = true;
|
|
3178
3180
|
this._cache.clear();
|
|
@@ -3520,7 +3522,7 @@ class IdentifierArray {
|
|
|
3520
3522
|
}
|
|
3521
3523
|
})(!transaction) : {};
|
|
3522
3524
|
transaction = true;
|
|
3523
|
-
const result =
|
|
3525
|
+
const result = options[MUTATE](target, receiver, prop, args, _SIGNAL);
|
|
3524
3526
|
transaction = false;
|
|
3525
3527
|
return result;
|
|
3526
3528
|
};
|
|
@@ -3565,7 +3567,7 @@ class IdentifierArray {
|
|
|
3565
3567
|
if (prop === 'length') {
|
|
3566
3568
|
if (!transaction && value === 0) {
|
|
3567
3569
|
transaction = true;
|
|
3568
|
-
|
|
3570
|
+
options[MUTATE](target, receiver, 'length 0', [], _SIGNAL);
|
|
3569
3571
|
transaction = false;
|
|
3570
3572
|
return true;
|
|
3571
3573
|
} else if (transaction) {
|
|
@@ -3639,7 +3641,7 @@ class IdentifierArray {
|
|
|
3639
3641
|
// a transaction.
|
|
3640
3642
|
// while "arr[arr.length] = newVal;" is handled by this replace cell code path.
|
|
3641
3643
|
if (!transaction) {
|
|
3642
|
-
|
|
3644
|
+
options[MUTATE](target, receiver, 'replace cell', [index, original, newIdentifier], _SIGNAL);
|
|
3643
3645
|
} else {
|
|
3644
3646
|
target[index] = newIdentifier;
|
|
3645
3647
|
}
|
|
@@ -4237,10 +4239,11 @@ function hasRecordIdentifier(op) {
|
|
|
4237
4239
|
* The RequestStateService is used to track the state of requests
|
|
4238
4240
|
* for fetching or updating known resource identifies that are inflight.
|
|
4239
4241
|
*
|
|
4240
|
-
* @
|
|
4242
|
+
* @hideconstructor
|
|
4241
4243
|
* @public
|
|
4242
4244
|
*/
|
|
4243
4245
|
class RequestStateService {
|
|
4246
|
+
/** @internal */
|
|
4244
4247
|
_pending = new Map();
|
|
4245
4248
|
_done = new Map();
|
|
4246
4249
|
_subscriptions = new Map();
|
|
@@ -4249,9 +4252,11 @@ class RequestStateService {
|
|
|
4249
4252
|
constructor(store) {
|
|
4250
4253
|
this._store = store;
|
|
4251
4254
|
}
|
|
4255
|
+
/** @internal */
|
|
4252
4256
|
_clearEntries(identifier) {
|
|
4253
4257
|
this._done.delete(identifier);
|
|
4254
4258
|
}
|
|
4259
|
+
/** @internal */
|
|
4255
4260
|
_enqueue(promise, queryRequest) {
|
|
4256
4261
|
const query = queryRequest.data[0];
|
|
4257
4262
|
if (hasRecordIdentifier(query)) {
|
|
@@ -4605,6 +4610,8 @@ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS))
|
|
|
4605
4610
|
*
|
|
4606
4611
|
*/
|
|
4607
4612
|
|
|
4613
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4614
|
+
|
|
4608
4615
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
4609
4616
|
const EmptyClass = class {
|
|
4610
4617
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
@@ -6480,7 +6487,202 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
6480
6487
|
const extract = recordIdentifierFor;
|
|
6481
6488
|
return extract(recordOrPromiseRecord);
|
|
6482
6489
|
}
|
|
6490
|
+
function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
6491
|
+
const collection = receiver;
|
|
6492
|
+
switch (prop) {
|
|
6493
|
+
case 'length 0':
|
|
6494
|
+
{
|
|
6495
|
+
Reflect.set(target, 'length', 0);
|
|
6496
|
+
mutateReplaceRelatedRecords(collection, [], _SIGNAL);
|
|
6497
|
+
return true;
|
|
6498
|
+
}
|
|
6499
|
+
case 'replace cell':
|
|
6500
|
+
{
|
|
6501
|
+
const [index, prior, value] = args;
|
|
6502
|
+
target[index] = value;
|
|
6503
|
+
mutateReplaceRelatedRecord(collection, {
|
|
6504
|
+
value,
|
|
6505
|
+
prior,
|
|
6506
|
+
index
|
|
6507
|
+
}, _SIGNAL);
|
|
6508
|
+
return true;
|
|
6509
|
+
}
|
|
6510
|
+
case 'push':
|
|
6511
|
+
{
|
|
6512
|
+
const newValues = extractIdentifiersFromRecords(args);
|
|
6513
|
+
assertNoDuplicates(collection, target, currentState => currentState.push(...newValues), `Cannot push duplicates to a hasMany's state.`);
|
|
6514
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6515
|
+
// dedupe
|
|
6516
|
+
const seen = new Set(target);
|
|
6517
|
+
const unique = new Set();
|
|
6518
|
+
args.forEach(item => {
|
|
6519
|
+
const identifier = recordIdentifierFor(item);
|
|
6520
|
+
if (!seen.has(identifier)) {
|
|
6521
|
+
seen.add(identifier);
|
|
6522
|
+
unique.add(item);
|
|
6523
|
+
}
|
|
6524
|
+
});
|
|
6525
|
+
const newArgs = Array.from(unique);
|
|
6526
|
+
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6527
|
+
if (newArgs.length) {
|
|
6528
|
+
mutateAddToRelatedRecords(collection, {
|
|
6529
|
+
value: extractIdentifiersFromRecords(newArgs)
|
|
6530
|
+
}, _SIGNAL);
|
|
6531
|
+
}
|
|
6532
|
+
return result;
|
|
6533
|
+
}
|
|
6483
6534
|
|
|
6535
|
+
// else, no dedupe, error on duplicates
|
|
6536
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6537
|
+
if (newValues.length) {
|
|
6538
|
+
mutateAddToRelatedRecords(collection, {
|
|
6539
|
+
value: newValues
|
|
6540
|
+
}, _SIGNAL);
|
|
6541
|
+
}
|
|
6542
|
+
return result;
|
|
6543
|
+
}
|
|
6544
|
+
case 'pop':
|
|
6545
|
+
{
|
|
6546
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6547
|
+
if (result) {
|
|
6548
|
+
mutateRemoveFromRelatedRecords(collection, {
|
|
6549
|
+
value: recordIdentifierFor(result)
|
|
6550
|
+
}, _SIGNAL);
|
|
6551
|
+
}
|
|
6552
|
+
return result;
|
|
6553
|
+
}
|
|
6554
|
+
case 'unshift':
|
|
6555
|
+
{
|
|
6556
|
+
const newValues = extractIdentifiersFromRecords(args);
|
|
6557
|
+
assertNoDuplicates(collection, target, currentState => currentState.unshift(...newValues), `Cannot unshift duplicates to a hasMany's state.`);
|
|
6558
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6559
|
+
// dedupe
|
|
6560
|
+
const seen = new Set(target);
|
|
6561
|
+
const unique = new Set();
|
|
6562
|
+
args.forEach(item => {
|
|
6563
|
+
const identifier = recordIdentifierFor(item);
|
|
6564
|
+
if (!seen.has(identifier)) {
|
|
6565
|
+
seen.add(identifier);
|
|
6566
|
+
unique.add(item);
|
|
6567
|
+
}
|
|
6568
|
+
});
|
|
6569
|
+
const newArgs = Array.from(unique);
|
|
6570
|
+
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6571
|
+
if (newArgs.length) {
|
|
6572
|
+
mutateAddToRelatedRecords(collection, {
|
|
6573
|
+
value: extractIdentifiersFromRecords(newArgs),
|
|
6574
|
+
index: 0
|
|
6575
|
+
}, _SIGNAL);
|
|
6576
|
+
}
|
|
6577
|
+
return result;
|
|
6578
|
+
}
|
|
6579
|
+
|
|
6580
|
+
// else, no dedupe, error on duplicates
|
|
6581
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6582
|
+
if (newValues.length) {
|
|
6583
|
+
mutateAddToRelatedRecords(collection, {
|
|
6584
|
+
value: newValues,
|
|
6585
|
+
index: 0
|
|
6586
|
+
}, _SIGNAL);
|
|
6587
|
+
}
|
|
6588
|
+
return result;
|
|
6589
|
+
}
|
|
6590
|
+
case 'shift':
|
|
6591
|
+
{
|
|
6592
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6593
|
+
if (result) {
|
|
6594
|
+
mutateRemoveFromRelatedRecords(collection, {
|
|
6595
|
+
value: recordIdentifierFor(result),
|
|
6596
|
+
index: 0
|
|
6597
|
+
}, _SIGNAL);
|
|
6598
|
+
}
|
|
6599
|
+
return result;
|
|
6600
|
+
}
|
|
6601
|
+
case 'sort':
|
|
6602
|
+
{
|
|
6603
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6604
|
+
mutateSortRelatedRecords(collection, result.map(recordIdentifierFor), _SIGNAL);
|
|
6605
|
+
return result;
|
|
6606
|
+
}
|
|
6607
|
+
case 'splice':
|
|
6608
|
+
{
|
|
6609
|
+
const [start, deleteCount, ...adds] = args;
|
|
6610
|
+
|
|
6611
|
+
// detect a full replace
|
|
6612
|
+
if (start === 0 && deleteCount === collection[SOURCE].length) {
|
|
6613
|
+
const newValues = extractIdentifiersFromRecords(adds);
|
|
6614
|
+
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot replace a hasMany's state with a new state that contains duplicates.`);
|
|
6615
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6616
|
+
// dedupe
|
|
6617
|
+
const current = new Set(adds);
|
|
6618
|
+
const unique = Array.from(current);
|
|
6619
|
+
const newArgs = [start, deleteCount].concat(unique);
|
|
6620
|
+
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6621
|
+
mutateReplaceRelatedRecords(collection, extractIdentifiersFromRecords(unique), _SIGNAL);
|
|
6622
|
+
return result;
|
|
6623
|
+
}
|
|
6624
|
+
|
|
6625
|
+
// else, no dedupe, error on duplicates
|
|
6626
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6627
|
+
mutateReplaceRelatedRecords(collection, newValues, _SIGNAL);
|
|
6628
|
+
return result;
|
|
6629
|
+
}
|
|
6630
|
+
const newValues = extractIdentifiersFromRecords(adds);
|
|
6631
|
+
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot splice a hasMany's state with a new state that contains duplicates.`);
|
|
6632
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6633
|
+
// dedupe
|
|
6634
|
+
const currentState = target.slice();
|
|
6635
|
+
currentState.splice(start, deleteCount);
|
|
6636
|
+
const seen = new Set(currentState);
|
|
6637
|
+
const unique = [];
|
|
6638
|
+
adds.forEach(item => {
|
|
6639
|
+
const identifier = recordIdentifierFor(item);
|
|
6640
|
+
if (!seen.has(identifier)) {
|
|
6641
|
+
seen.add(identifier);
|
|
6642
|
+
unique.push(item);
|
|
6643
|
+
}
|
|
6644
|
+
});
|
|
6645
|
+
const newArgs = [start, deleteCount, ...unique];
|
|
6646
|
+
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6647
|
+
if (deleteCount > 0) {
|
|
6648
|
+
mutateRemoveFromRelatedRecords(collection, {
|
|
6649
|
+
value: result.map(recordIdentifierFor),
|
|
6650
|
+
index: start
|
|
6651
|
+
}, _SIGNAL);
|
|
6652
|
+
}
|
|
6653
|
+
if (unique.length > 0) {
|
|
6654
|
+
mutateAddToRelatedRecords(collection, {
|
|
6655
|
+
value: extractIdentifiersFromRecords(unique),
|
|
6656
|
+
index: start
|
|
6657
|
+
}, _SIGNAL);
|
|
6658
|
+
}
|
|
6659
|
+
return result;
|
|
6660
|
+
}
|
|
6661
|
+
|
|
6662
|
+
// else, no dedupe, error on duplicates
|
|
6663
|
+
const result = Reflect.apply(target[prop], receiver, args);
|
|
6664
|
+
if (deleteCount > 0) {
|
|
6665
|
+
mutateRemoveFromRelatedRecords(collection, {
|
|
6666
|
+
value: result.map(recordIdentifierFor),
|
|
6667
|
+
index: start
|
|
6668
|
+
}, _SIGNAL);
|
|
6669
|
+
}
|
|
6670
|
+
if (newValues.length > 0) {
|
|
6671
|
+
mutateAddToRelatedRecords(collection, {
|
|
6672
|
+
value: newValues,
|
|
6673
|
+
index: start
|
|
6674
|
+
}, _SIGNAL);
|
|
6675
|
+
}
|
|
6676
|
+
return result;
|
|
6677
|
+
}
|
|
6678
|
+
default:
|
|
6679
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6680
|
+
{
|
|
6681
|
+
throw new Error(`unable to convert ${prop} into a transaction that updates the cache state for this record array`);
|
|
6682
|
+
}
|
|
6683
|
+
})() : {};
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6484
6686
|
/**
|
|
6485
6687
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
6486
6688
|
relationship.
|
|
@@ -6579,6 +6781,7 @@ class RelatedCollection extends IdentifierArray {
|
|
|
6579
6781
|
*/
|
|
6580
6782
|
|
|
6581
6783
|
constructor(options) {
|
|
6784
|
+
options[MUTATE] = _MUTATE;
|
|
6582
6785
|
super(options);
|
|
6583
6786
|
this.isLoaded = options.isLoaded || false;
|
|
6584
6787
|
this.isAsync = options.isAsync || false;
|
|
@@ -6586,201 +6789,6 @@ class RelatedCollection extends IdentifierArray {
|
|
|
6586
6789
|
this.identifier = options.identifier;
|
|
6587
6790
|
this.key = options.key;
|
|
6588
6791
|
}
|
|
6589
|
-
[MUTATE](target, receiver, prop, args, _SIGNAL) {
|
|
6590
|
-
switch (prop) {
|
|
6591
|
-
case 'length 0':
|
|
6592
|
-
{
|
|
6593
|
-
Reflect.set(target, 'length', 0);
|
|
6594
|
-
mutateReplaceRelatedRecords(this, [], _SIGNAL);
|
|
6595
|
-
return true;
|
|
6596
|
-
}
|
|
6597
|
-
case 'replace cell':
|
|
6598
|
-
{
|
|
6599
|
-
const [index, prior, value] = args;
|
|
6600
|
-
target[index] = value;
|
|
6601
|
-
mutateReplaceRelatedRecord(this, {
|
|
6602
|
-
value,
|
|
6603
|
-
prior,
|
|
6604
|
-
index
|
|
6605
|
-
}, _SIGNAL);
|
|
6606
|
-
return true;
|
|
6607
|
-
}
|
|
6608
|
-
case 'push':
|
|
6609
|
-
{
|
|
6610
|
-
const newValues = extractIdentifiersFromRecords(args);
|
|
6611
|
-
assertNoDuplicates(this, target, currentState => currentState.push(...newValues), `Cannot push duplicates to a hasMany's state.`);
|
|
6612
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6613
|
-
// dedupe
|
|
6614
|
-
const seen = new Set(target);
|
|
6615
|
-
const unique = new Set();
|
|
6616
|
-
args.forEach(item => {
|
|
6617
|
-
const identifier = recordIdentifierFor(item);
|
|
6618
|
-
if (!seen.has(identifier)) {
|
|
6619
|
-
seen.add(identifier);
|
|
6620
|
-
unique.add(item);
|
|
6621
|
-
}
|
|
6622
|
-
});
|
|
6623
|
-
const newArgs = Array.from(unique);
|
|
6624
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6625
|
-
if (newArgs.length) {
|
|
6626
|
-
mutateAddToRelatedRecords(this, {
|
|
6627
|
-
value: extractIdentifiersFromRecords(newArgs)
|
|
6628
|
-
}, _SIGNAL);
|
|
6629
|
-
}
|
|
6630
|
-
return result;
|
|
6631
|
-
}
|
|
6632
|
-
|
|
6633
|
-
// else, no dedupe, error on duplicates
|
|
6634
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6635
|
-
if (newValues.length) {
|
|
6636
|
-
mutateAddToRelatedRecords(this, {
|
|
6637
|
-
value: newValues
|
|
6638
|
-
}, _SIGNAL);
|
|
6639
|
-
}
|
|
6640
|
-
return result;
|
|
6641
|
-
}
|
|
6642
|
-
case 'pop':
|
|
6643
|
-
{
|
|
6644
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6645
|
-
if (result) {
|
|
6646
|
-
mutateRemoveFromRelatedRecords(this, {
|
|
6647
|
-
value: recordIdentifierFor(result)
|
|
6648
|
-
}, _SIGNAL);
|
|
6649
|
-
}
|
|
6650
|
-
return result;
|
|
6651
|
-
}
|
|
6652
|
-
case 'unshift':
|
|
6653
|
-
{
|
|
6654
|
-
const newValues = extractIdentifiersFromRecords(args);
|
|
6655
|
-
assertNoDuplicates(this, target, currentState => currentState.unshift(...newValues), `Cannot unshift duplicates to a hasMany's state.`);
|
|
6656
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6657
|
-
// dedupe
|
|
6658
|
-
const seen = new Set(target);
|
|
6659
|
-
const unique = new Set();
|
|
6660
|
-
args.forEach(item => {
|
|
6661
|
-
const identifier = recordIdentifierFor(item);
|
|
6662
|
-
if (!seen.has(identifier)) {
|
|
6663
|
-
seen.add(identifier);
|
|
6664
|
-
unique.add(item);
|
|
6665
|
-
}
|
|
6666
|
-
});
|
|
6667
|
-
const newArgs = Array.from(unique);
|
|
6668
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6669
|
-
if (newArgs.length) {
|
|
6670
|
-
mutateAddToRelatedRecords(this, {
|
|
6671
|
-
value: extractIdentifiersFromRecords(newArgs),
|
|
6672
|
-
index: 0
|
|
6673
|
-
}, _SIGNAL);
|
|
6674
|
-
}
|
|
6675
|
-
return result;
|
|
6676
|
-
}
|
|
6677
|
-
|
|
6678
|
-
// else, no dedupe, error on duplicates
|
|
6679
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6680
|
-
if (newValues.length) {
|
|
6681
|
-
mutateAddToRelatedRecords(this, {
|
|
6682
|
-
value: newValues,
|
|
6683
|
-
index: 0
|
|
6684
|
-
}, _SIGNAL);
|
|
6685
|
-
}
|
|
6686
|
-
return result;
|
|
6687
|
-
}
|
|
6688
|
-
case 'shift':
|
|
6689
|
-
{
|
|
6690
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6691
|
-
if (result) {
|
|
6692
|
-
mutateRemoveFromRelatedRecords(this, {
|
|
6693
|
-
value: recordIdentifierFor(result),
|
|
6694
|
-
index: 0
|
|
6695
|
-
}, _SIGNAL);
|
|
6696
|
-
}
|
|
6697
|
-
return result;
|
|
6698
|
-
}
|
|
6699
|
-
case 'sort':
|
|
6700
|
-
{
|
|
6701
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6702
|
-
mutateSortRelatedRecords(this, result.map(recordIdentifierFor), _SIGNAL);
|
|
6703
|
-
return result;
|
|
6704
|
-
}
|
|
6705
|
-
case 'splice':
|
|
6706
|
-
{
|
|
6707
|
-
const [start, deleteCount, ...adds] = args;
|
|
6708
|
-
|
|
6709
|
-
// detect a full replace
|
|
6710
|
-
if (start === 0 && deleteCount === this[SOURCE].length) {
|
|
6711
|
-
const newValues = extractIdentifiersFromRecords(adds);
|
|
6712
|
-
assertNoDuplicates(this, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot replace a hasMany's state with a new state that contains duplicates.`);
|
|
6713
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6714
|
-
// dedupe
|
|
6715
|
-
const current = new Set(adds);
|
|
6716
|
-
const unique = Array.from(current);
|
|
6717
|
-
const newArgs = [start, deleteCount].concat(unique);
|
|
6718
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6719
|
-
mutateReplaceRelatedRecords(this, extractIdentifiersFromRecords(unique), _SIGNAL);
|
|
6720
|
-
return result;
|
|
6721
|
-
}
|
|
6722
|
-
|
|
6723
|
-
// else, no dedupe, error on duplicates
|
|
6724
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6725
|
-
mutateReplaceRelatedRecords(this, newValues, _SIGNAL);
|
|
6726
|
-
return result;
|
|
6727
|
-
}
|
|
6728
|
-
const newValues = extractIdentifiersFromRecords(adds);
|
|
6729
|
-
assertNoDuplicates(this, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot splice a hasMany's state with a new state that contains duplicates.`);
|
|
6730
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6731
|
-
// dedupe
|
|
6732
|
-
const currentState = target.slice();
|
|
6733
|
-
currentState.splice(start, deleteCount);
|
|
6734
|
-
const seen = new Set(currentState);
|
|
6735
|
-
const unique = [];
|
|
6736
|
-
adds.forEach(item => {
|
|
6737
|
-
const identifier = recordIdentifierFor(item);
|
|
6738
|
-
if (!seen.has(identifier)) {
|
|
6739
|
-
seen.add(identifier);
|
|
6740
|
-
unique.push(item);
|
|
6741
|
-
}
|
|
6742
|
-
});
|
|
6743
|
-
const newArgs = [start, deleteCount, ...unique];
|
|
6744
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6745
|
-
if (deleteCount > 0) {
|
|
6746
|
-
mutateRemoveFromRelatedRecords(this, {
|
|
6747
|
-
value: result.map(recordIdentifierFor),
|
|
6748
|
-
index: start
|
|
6749
|
-
}, _SIGNAL);
|
|
6750
|
-
}
|
|
6751
|
-
if (unique.length > 0) {
|
|
6752
|
-
mutateAddToRelatedRecords(this, {
|
|
6753
|
-
value: extractIdentifiersFromRecords(unique),
|
|
6754
|
-
index: start
|
|
6755
|
-
}, _SIGNAL);
|
|
6756
|
-
}
|
|
6757
|
-
return result;
|
|
6758
|
-
}
|
|
6759
|
-
|
|
6760
|
-
// else, no dedupe, error on duplicates
|
|
6761
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6762
|
-
if (deleteCount > 0) {
|
|
6763
|
-
mutateRemoveFromRelatedRecords(this, {
|
|
6764
|
-
value: result.map(recordIdentifierFor),
|
|
6765
|
-
index: start
|
|
6766
|
-
}, _SIGNAL);
|
|
6767
|
-
}
|
|
6768
|
-
if (newValues.length > 0) {
|
|
6769
|
-
mutateAddToRelatedRecords(this, {
|
|
6770
|
-
value: newValues,
|
|
6771
|
-
index: start
|
|
6772
|
-
}, _SIGNAL);
|
|
6773
|
-
}
|
|
6774
|
-
return result;
|
|
6775
|
-
}
|
|
6776
|
-
default:
|
|
6777
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6778
|
-
{
|
|
6779
|
-
throw new Error(`unable to convert ${prop} into a transaction that updates the cache state for this record array`);
|
|
6780
|
-
}
|
|
6781
|
-
})() : {};
|
|
6782
|
-
}
|
|
6783
|
-
}
|
|
6784
6792
|
notify() {
|
|
6785
6793
|
notifyInternalSignal(this[ARRAY_SIGNAL]);
|
|
6786
6794
|
}
|
|
@@ -7137,6 +7145,8 @@ function isNeverString(val) {
|
|
|
7137
7145
|
|
|
7138
7146
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7139
7147
|
|
|
7148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7149
|
+
|
|
7140
7150
|
/**
|
|
7141
7151
|
* A reactive class
|
|
7142
7152
|
*
|
|
@@ -7236,6 +7246,7 @@ class RequestSubscription {
|
|
|
7236
7246
|
this._invalidated = false;
|
|
7237
7247
|
this._nextInterval = null;
|
|
7238
7248
|
this.isDestroyed = false;
|
|
7249
|
+
this[DISPOSE] = _DISPOSE;
|
|
7239
7250
|
this._installListeners();
|
|
7240
7251
|
void this._beginPolling();
|
|
7241
7252
|
}
|
|
@@ -7621,36 +7632,11 @@ class RequestSubscription {
|
|
|
7621
7632
|
}
|
|
7622
7633
|
|
|
7623
7634
|
/**
|
|
7624
|
-
*
|
|
7625
|
-
* unmounts.
|
|
7635
|
+
* @internal
|
|
7626
7636
|
*/
|
|
7627
7637
|
static {
|
|
7628
7638
|
decorateMethodV2(this.prototype, "contentFeatures", [memoized]);
|
|
7629
7639
|
}
|
|
7630
|
-
[DISPOSE]() {
|
|
7631
|
-
this.isDestroyed = true;
|
|
7632
|
-
this._removeSubscriptions();
|
|
7633
|
-
if (typeof window === 'undefined') {
|
|
7634
|
-
return;
|
|
7635
|
-
}
|
|
7636
|
-
this._clearInterval();
|
|
7637
|
-
window.removeEventListener('online', this._onlineChanged, {
|
|
7638
|
-
passive: true,
|
|
7639
|
-
capture: true
|
|
7640
|
-
});
|
|
7641
|
-
window.removeEventListener('offline', this._onlineChanged, {
|
|
7642
|
-
passive: true,
|
|
7643
|
-
capture: true
|
|
7644
|
-
});
|
|
7645
|
-
document.removeEventListener('visibilitychange', this._backgroundChanged, {
|
|
7646
|
-
passive: true,
|
|
7647
|
-
capture: true
|
|
7648
|
-
});
|
|
7649
|
-
}
|
|
7650
|
-
|
|
7651
|
-
/**
|
|
7652
|
-
* @internal
|
|
7653
|
-
*/
|
|
7654
7640
|
get _request() {
|
|
7655
7641
|
const {
|
|
7656
7642
|
request,
|
|
@@ -7728,11 +7714,39 @@ function isStore(store) {
|
|
|
7728
7714
|
function createRequestSubscription(store, args) {
|
|
7729
7715
|
return new RequestSubscription(store, args);
|
|
7730
7716
|
}
|
|
7717
|
+
function upgradeSubscription(sub) {
|
|
7718
|
+
return sub;
|
|
7719
|
+
}
|
|
7720
|
+
function _DISPOSE() {
|
|
7721
|
+
const self = upgradeSubscription(this);
|
|
7722
|
+
self.isDestroyed = true;
|
|
7723
|
+
self._removeSubscriptions();
|
|
7724
|
+
if (typeof window === 'undefined') {
|
|
7725
|
+
return;
|
|
7726
|
+
}
|
|
7727
|
+
self._clearInterval();
|
|
7728
|
+
window.removeEventListener('online', self._onlineChanged, {
|
|
7729
|
+
passive: true,
|
|
7730
|
+
capture: true
|
|
7731
|
+
});
|
|
7732
|
+
window.removeEventListener('offline', self._onlineChanged, {
|
|
7733
|
+
passive: true,
|
|
7734
|
+
capture: true
|
|
7735
|
+
});
|
|
7736
|
+
document.removeEventListener('visibilitychange', self._backgroundChanged, {
|
|
7737
|
+
passive: true,
|
|
7738
|
+
capture: true
|
|
7739
|
+
});
|
|
7740
|
+
}
|
|
7731
7741
|
const RequestCache = new WeakMap();
|
|
7732
7742
|
function isAbortError(error) {
|
|
7733
7743
|
return error instanceof DOMException && error.name === 'AbortError';
|
|
7734
7744
|
}
|
|
7735
|
-
|
|
7745
|
+
function upgradeLoadingState(state) {
|
|
7746
|
+
return state;
|
|
7747
|
+
}
|
|
7748
|
+
async function watchStream(stream, loadingState) {
|
|
7749
|
+
const state = upgradeLoadingState(loadingState);
|
|
7736
7750
|
const reader = stream.getReader();
|
|
7737
7751
|
let bytesLoaded = 0;
|
|
7738
7752
|
let shouldForward = state._stream !== null && state._stream.readable.locked;
|