@contember/binding-legacy 2.1.0-alpha.36 → 2.1.0-alpha.39
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/dist/development/index.cjs +34 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +28 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/accessorTree/NormalizedPersistedData.cjs +10 -0
- package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +1 -0
- package/dist/development/src/accessorTree/NormalizedPersistedData.js +10 -0
- package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +1 -0
- package/dist/development/src/accessors/EntityAccessorImpl.cjs +179 -0
- package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +1 -0
- package/dist/development/src/accessors/EntityAccessorImpl.js +179 -0
- package/dist/development/src/accessors/EntityAccessorImpl.js.map +1 -0
- package/dist/development/src/accessors/EntityListAccessorImpl.cjs +112 -0
- package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +1 -0
- package/dist/development/src/accessors/EntityListAccessorImpl.js +112 -0
- package/dist/development/src/accessors/EntityListAccessorImpl.js.map +1 -0
- package/dist/development/src/accessors/FieldAccessorImpl.cjs +54 -0
- package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +1 -0
- package/dist/development/src/accessors/FieldAccessorImpl.js +54 -0
- package/dist/development/src/accessors/FieldAccessorImpl.js.map +1 -0
- package/dist/development/src/core/AccessorErrorManager.cjs +200 -0
- package/dist/development/src/core/AccessorErrorManager.cjs.map +1 -0
- package/dist/development/src/core/AccessorErrorManager.js +200 -0
- package/dist/development/src/core/AccessorErrorManager.js.map +1 -0
- package/dist/development/src/core/Config.cjs +29 -0
- package/dist/development/src/core/Config.cjs.map +1 -0
- package/dist/development/src/core/Config.js +29 -0
- package/dist/development/src/core/Config.js.map +1 -0
- package/dist/development/src/core/DataBinding.cjs +357 -0
- package/dist/development/src/core/DataBinding.cjs.map +1 -0
- package/dist/development/src/core/DataBinding.js +357 -0
- package/dist/development/src/core/DataBinding.js.map +1 -0
- package/dist/development/src/core/DirtinessTracker.cjs +26 -0
- package/dist/development/src/core/DirtinessTracker.cjs.map +1 -0
- package/dist/development/src/core/DirtinessTracker.js +26 -0
- package/dist/development/src/core/DirtinessTracker.js.map +1 -0
- package/dist/development/src/core/ErrorsPreprocessor.cjs +180 -0
- package/dist/development/src/core/ErrorsPreprocessor.cjs.map +1 -0
- package/dist/development/src/core/ErrorsPreprocessor.js +180 -0
- package/dist/development/src/core/ErrorsPreprocessor.js.map +1 -0
- package/dist/development/src/core/EventManager.cjs +439 -0
- package/dist/development/src/core/EventManager.cjs.map +1 -0
- package/dist/development/src/core/EventManager.js +439 -0
- package/dist/development/src/core/EventManager.js.map +1 -0
- package/dist/development/src/core/MutationGenerator.cjs +670 -0
- package/dist/development/src/core/MutationGenerator.cjs.map +1 -0
- package/dist/development/src/core/MutationGenerator.js +670 -0
- package/dist/development/src/core/MutationGenerator.js.map +1 -0
- package/dist/development/src/core/QueryGenerator.cjs +110 -0
- package/dist/development/src/core/QueryGenerator.cjs.map +1 -0
- package/dist/development/src/core/QueryGenerator.js +110 -0
- package/dist/development/src/core/QueryGenerator.js.map +1 -0
- package/dist/development/src/core/RealmKeyGenerator.cjs +42 -0
- package/dist/development/src/core/RealmKeyGenerator.cjs.map +1 -0
- package/dist/development/src/core/RealmKeyGenerator.js +42 -0
- package/dist/development/src/core/RealmKeyGenerator.js.map +1 -0
- package/dist/development/src/core/RequestResponseNormalizer.cjs +136 -0
- package/dist/development/src/core/RequestResponseNormalizer.cjs.map +1 -0
- package/dist/development/src/core/RequestResponseNormalizer.js +136 -0
- package/dist/development/src/core/RequestResponseNormalizer.js.map +1 -0
- package/dist/development/src/core/StateInitializer.cjs +379 -0
- package/dist/development/src/core/StateInitializer.cjs.map +1 -0
- package/dist/development/src/core/StateInitializer.js +379 -0
- package/dist/development/src/core/StateInitializer.js.map +1 -0
- package/dist/development/src/core/TreeAugmenter.cjs +351 -0
- package/dist/development/src/core/TreeAugmenter.cjs.map +1 -0
- package/dist/development/src/core/TreeAugmenter.js +351 -0
- package/dist/development/src/core/TreeAugmenter.js.map +1 -0
- package/dist/development/src/core/TreeStore.cjs +172 -0
- package/dist/development/src/core/TreeStore.cjs.map +1 -0
- package/dist/development/src/core/TreeStore.js +172 -0
- package/dist/development/src/core/TreeStore.js.map +1 -0
- package/dist/development/src/core/exceptions/ErrorLocator.cjs +59 -0
- package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +1 -0
- package/dist/development/src/core/exceptions/ErrorLocator.js +59 -0
- package/dist/development/src/core/exceptions/ErrorLocator.js.map +1 -0
- package/dist/development/src/core/exceptions/MarkerSugarer.cjs +51 -0
- package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +1 -0
- package/dist/development/src/core/exceptions/MarkerSugarer.js +51 -0
- package/dist/development/src/core/exceptions/MarkerSugarer.js.map +1 -0
- package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs +33 -0
- package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -0
- package/dist/development/src/core/exceptions/TreeParameterSugarer.js +33 -0
- package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +1 -0
- package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs +23 -0
- package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -0
- package/dist/development/src/core/factories/createBatchUpdatesOptions.js +23 -0
- package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +1 -0
- package/dist/development/src/core/operations/EntityOperations.cjs +224 -0
- package/dist/development/src/core/operations/EntityOperations.cjs.map +1 -0
- package/dist/development/src/core/operations/EntityOperations.js +224 -0
- package/dist/development/src/core/operations/EntityOperations.js.map +1 -0
- package/dist/development/src/core/operations/FieldOperations.cjs +92 -0
- package/dist/development/src/core/operations/FieldOperations.cjs.map +1 -0
- package/dist/development/src/core/operations/FieldOperations.js +92 -0
- package/dist/development/src/core/operations/FieldOperations.js.map +1 -0
- package/dist/development/src/core/operations/ListOperations.cjs +158 -0
- package/dist/development/src/core/operations/ListOperations.cjs.map +1 -0
- package/dist/development/src/core/operations/ListOperations.js +158 -0
- package/dist/development/src/core/operations/ListOperations.js.map +1 -0
- package/dist/development/src/core/operations/OperationsHelpers.cjs +87 -0
- package/dist/development/src/core/operations/OperationsHelpers.cjs.map +1 -0
- package/dist/development/src/core/operations/OperationsHelpers.js +87 -0
- package/dist/development/src/core/operations/OperationsHelpers.js.map +1 -0
- package/dist/development/src/core/requestAliases/MutationAlias.cjs +14 -0
- package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +1 -0
- package/dist/development/src/core/requestAliases/MutationAlias.js +14 -0
- package/dist/development/src/core/requestAliases/MutationAlias.js.map +1 -0
- package/dist/development/src/core/state/StateIterator.cjs +100 -0
- package/dist/development/src/core/state/StateIterator.cjs.map +1 -0
- package/dist/development/src/core/state/StateIterator.js +100 -0
- package/dist/development/src/core/state/StateIterator.js.map +1 -0
- package/dist/development/src/core/state/getEntityMarker.cjs +5 -0
- package/dist/development/src/core/state/getEntityMarker.cjs.map +1 -0
- package/dist/development/src/core/state/getEntityMarker.js +5 -0
- package/dist/development/src/core/state/getEntityMarker.js.map +1 -0
- package/dist/development/src/core/utils/getCombinedSignal.cjs +33 -0
- package/dist/development/src/core/utils/getCombinedSignal.cjs.map +1 -0
- package/dist/development/src/core/utils/getCombinedSignal.js +33 -0
- package/dist/development/src/core/utils/getCombinedSignal.js.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs +13 -0
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.js +13 -0
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +18 -0
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +18 -0
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs +16 -0
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -0
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js +16 -0
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -0
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs +7 -0
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -0
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js +7 -0
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -0
- package/dist/development/src/utils/isEmptyObject.cjs +12 -0
- package/dist/development/src/utils/isEmptyObject.cjs.map +1 -0
- package/dist/development/src/utils/isEmptyObject.js +12 -0
- package/dist/development/src/utils/isEmptyObject.js.map +1 -0
- package/dist/production/index.cjs +34 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +28 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/accessorTree/NormalizedPersistedData.cjs +10 -0
- package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +1 -0
- package/dist/production/src/accessorTree/NormalizedPersistedData.js +10 -0
- package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +1 -0
- package/dist/production/src/accessors/EntityAccessorImpl.cjs +179 -0
- package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +1 -0
- package/dist/production/src/accessors/EntityAccessorImpl.js +179 -0
- package/dist/production/src/accessors/EntityAccessorImpl.js.map +1 -0
- package/dist/production/src/accessors/EntityListAccessorImpl.cjs +112 -0
- package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +1 -0
- package/dist/production/src/accessors/EntityListAccessorImpl.js +112 -0
- package/dist/production/src/accessors/EntityListAccessorImpl.js.map +1 -0
- package/dist/production/src/accessors/FieldAccessorImpl.cjs +54 -0
- package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +1 -0
- package/dist/production/src/accessors/FieldAccessorImpl.js +54 -0
- package/dist/production/src/accessors/FieldAccessorImpl.js.map +1 -0
- package/dist/production/src/core/AccessorErrorManager.cjs +200 -0
- package/dist/production/src/core/AccessorErrorManager.cjs.map +1 -0
- package/dist/production/src/core/AccessorErrorManager.js +200 -0
- package/dist/production/src/core/AccessorErrorManager.js.map +1 -0
- package/dist/production/src/core/Config.cjs +29 -0
- package/dist/production/src/core/Config.cjs.map +1 -0
- package/dist/production/src/core/Config.js +29 -0
- package/dist/production/src/core/Config.js.map +1 -0
- package/dist/production/src/core/DataBinding.cjs +357 -0
- package/dist/production/src/core/DataBinding.cjs.map +1 -0
- package/dist/production/src/core/DataBinding.js +357 -0
- package/dist/production/src/core/DataBinding.js.map +1 -0
- package/dist/production/src/core/DirtinessTracker.cjs +26 -0
- package/dist/production/src/core/DirtinessTracker.cjs.map +1 -0
- package/dist/production/src/core/DirtinessTracker.js +26 -0
- package/dist/production/src/core/DirtinessTracker.js.map +1 -0
- package/dist/production/src/core/ErrorsPreprocessor.cjs +180 -0
- package/dist/production/src/core/ErrorsPreprocessor.cjs.map +1 -0
- package/dist/production/src/core/ErrorsPreprocessor.js +180 -0
- package/dist/production/src/core/ErrorsPreprocessor.js.map +1 -0
- package/dist/production/src/core/EventManager.cjs +413 -0
- package/dist/production/src/core/EventManager.cjs.map +1 -0
- package/dist/production/src/core/EventManager.js +413 -0
- package/dist/production/src/core/EventManager.js.map +1 -0
- package/dist/production/src/core/MutationGenerator.cjs +670 -0
- package/dist/production/src/core/MutationGenerator.cjs.map +1 -0
- package/dist/production/src/core/MutationGenerator.js +670 -0
- package/dist/production/src/core/MutationGenerator.js.map +1 -0
- package/dist/production/src/core/QueryGenerator.cjs +110 -0
- package/dist/production/src/core/QueryGenerator.cjs.map +1 -0
- package/dist/production/src/core/QueryGenerator.js +110 -0
- package/dist/production/src/core/QueryGenerator.js.map +1 -0
- package/dist/production/src/core/RealmKeyGenerator.cjs +42 -0
- package/dist/production/src/core/RealmKeyGenerator.cjs.map +1 -0
- package/dist/production/src/core/RealmKeyGenerator.js +42 -0
- package/dist/production/src/core/RealmKeyGenerator.js.map +1 -0
- package/dist/production/src/core/RequestResponseNormalizer.cjs +136 -0
- package/dist/production/src/core/RequestResponseNormalizer.cjs.map +1 -0
- package/dist/production/src/core/RequestResponseNormalizer.js +136 -0
- package/dist/production/src/core/RequestResponseNormalizer.js.map +1 -0
- package/dist/production/src/core/StateInitializer.cjs +379 -0
- package/dist/production/src/core/StateInitializer.cjs.map +1 -0
- package/dist/production/src/core/StateInitializer.js +379 -0
- package/dist/production/src/core/StateInitializer.js.map +1 -0
- package/dist/production/src/core/TreeAugmenter.cjs +351 -0
- package/dist/production/src/core/TreeAugmenter.cjs.map +1 -0
- package/dist/production/src/core/TreeAugmenter.js +351 -0
- package/dist/production/src/core/TreeAugmenter.js.map +1 -0
- package/dist/production/src/core/TreeStore.cjs +172 -0
- package/dist/production/src/core/TreeStore.cjs.map +1 -0
- package/dist/production/src/core/TreeStore.js +172 -0
- package/dist/production/src/core/TreeStore.js.map +1 -0
- package/dist/production/src/core/exceptions/ErrorLocator.cjs +59 -0
- package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +1 -0
- package/dist/production/src/core/exceptions/ErrorLocator.js +59 -0
- package/dist/production/src/core/exceptions/ErrorLocator.js.map +1 -0
- package/dist/production/src/core/exceptions/MarkerSugarer.cjs +51 -0
- package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +1 -0
- package/dist/production/src/core/exceptions/MarkerSugarer.js +51 -0
- package/dist/production/src/core/exceptions/MarkerSugarer.js.map +1 -0
- package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs +33 -0
- package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -0
- package/dist/production/src/core/exceptions/TreeParameterSugarer.js +33 -0
- package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +1 -0
- package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs +23 -0
- package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -0
- package/dist/production/src/core/factories/createBatchUpdatesOptions.js +23 -0
- package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +1 -0
- package/dist/production/src/core/operations/EntityOperations.cjs +224 -0
- package/dist/production/src/core/operations/EntityOperations.cjs.map +1 -0
- package/dist/production/src/core/operations/EntityOperations.js +224 -0
- package/dist/production/src/core/operations/EntityOperations.js.map +1 -0
- package/dist/production/src/core/operations/FieldOperations.cjs +73 -0
- package/dist/production/src/core/operations/FieldOperations.cjs.map +1 -0
- package/dist/production/src/core/operations/FieldOperations.js +73 -0
- package/dist/production/src/core/operations/FieldOperations.js.map +1 -0
- package/dist/production/src/core/operations/ListOperations.cjs +158 -0
- package/dist/production/src/core/operations/ListOperations.cjs.map +1 -0
- package/dist/production/src/core/operations/ListOperations.js +158 -0
- package/dist/production/src/core/operations/ListOperations.js.map +1 -0
- package/dist/production/src/core/operations/OperationsHelpers.cjs +87 -0
- package/dist/production/src/core/operations/OperationsHelpers.cjs.map +1 -0
- package/dist/production/src/core/operations/OperationsHelpers.js +87 -0
- package/dist/production/src/core/operations/OperationsHelpers.js.map +1 -0
- package/dist/production/src/core/requestAliases/MutationAlias.cjs +14 -0
- package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +1 -0
- package/dist/production/src/core/requestAliases/MutationAlias.js +14 -0
- package/dist/production/src/core/requestAliases/MutationAlias.js.map +1 -0
- package/dist/production/src/core/state/StateIterator.cjs +100 -0
- package/dist/production/src/core/state/StateIterator.cjs.map +1 -0
- package/dist/production/src/core/state/StateIterator.js +100 -0
- package/dist/production/src/core/state/StateIterator.js.map +1 -0
- package/dist/production/src/core/state/getEntityMarker.cjs +5 -0
- package/dist/production/src/core/state/getEntityMarker.cjs.map +1 -0
- package/dist/production/src/core/state/getEntityMarker.js +5 -0
- package/dist/production/src/core/state/getEntityMarker.js.map +1 -0
- package/dist/production/src/core/utils/getCombinedSignal.cjs +33 -0
- package/dist/production/src/core/utils/getCombinedSignal.cjs.map +1 -0
- package/dist/production/src/core/utils/getCombinedSignal.js +33 -0
- package/dist/production/src/core/utils/getCombinedSignal.js.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs +13 -0
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.js +13 -0
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +18 -0
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +18 -0
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs +16 -0
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -0
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js +16 -0
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -0
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs +7 -0
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -0
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js +7 -0
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -0
- package/dist/production/src/utils/isEmptyObject.cjs +12 -0
- package/dist/production/src/utils/isEmptyObject.cjs.map +1 -0
- package/dist/production/src/utils/isEmptyObject.js +12 -0
- package/dist/production/src/utils/isEmptyObject.js.map +1 -0
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +18 -0
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -0
- package/dist/types/accessorTree/index.d.ts +2 -0
- package/dist/types/accessorTree/index.d.ts.map +1 -0
- package/dist/types/accessors/BindingConfig.d.ts +6 -0
- package/dist/types/accessors/BindingConfig.d.ts.map +1 -0
- package/dist/types/accessors/EntityAccessorImpl.d.ts +56 -0
- package/dist/types/accessors/EntityAccessorImpl.d.ts.map +1 -0
- package/dist/types/accessors/EntityListAccessorImpl.d.ts +57 -0
- package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +1 -0
- package/dist/types/accessors/FieldAccessorImpl.d.ts +32 -0
- package/dist/types/accessors/FieldAccessorImpl.d.ts.map +1 -0
- package/dist/types/accessors/index.d.ts +5 -0
- package/dist/types/accessors/index.d.ts.map +1 -0
- package/dist/types/core/AccessorErrorManager.d.ts +25 -0
- package/dist/types/core/AccessorErrorManager.d.ts.map +1 -0
- package/dist/types/core/Config.d.ts +9 -0
- package/dist/types/core/Config.d.ts.map +1 -0
- package/dist/types/core/DataBinding.d.ts +54 -0
- package/dist/types/core/DataBinding.d.ts.map +1 -0
- package/dist/types/core/DirtinessTracker.d.ts +9 -0
- package/dist/types/core/DirtinessTracker.d.ts.map +1 -0
- package/dist/types/core/ErrorsPreprocessor.d.ts +34 -0
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -0
- package/dist/types/core/EventManager.d.ts +57 -0
- package/dist/types/core/EventManager.d.ts.map +1 -0
- package/dist/types/core/MutationGenerator.d.ts +49 -0
- package/dist/types/core/MutationGenerator.d.ts.map +1 -0
- package/dist/types/core/QueryGenerator.d.ts +13 -0
- package/dist/types/core/QueryGenerator.d.ts.map +1 -0
- package/dist/types/core/RealmKeyGenerator.d.ts +10 -0
- package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -0
- package/dist/types/core/RequestResponseNormalizer.d.ts +11 -0
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -0
- package/dist/types/core/StateInitializer.d.ts +34 -0
- package/dist/types/core/StateInitializer.d.ts.map +1 -0
- package/dist/types/core/TreeAugmenter.d.ts +25 -0
- package/dist/types/core/TreeAugmenter.d.ts.map +1 -0
- package/dist/types/core/TreeStore.d.ts +30 -0
- package/dist/types/core/TreeStore.d.ts.map +1 -0
- package/dist/types/core/UpdateMetadata.d.ts +4 -0
- package/dist/types/core/UpdateMetadata.d.ts.map +1 -0
- package/dist/types/core/exceptions/ErrorLocator.d.ts +8 -0
- package/dist/types/core/exceptions/ErrorLocator.d.ts.map +1 -0
- package/dist/types/core/exceptions/MarkerSugarer.d.ts +10 -0
- package/dist/types/core/exceptions/MarkerSugarer.d.ts.map +1 -0
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts +11 -0
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts.map +1 -0
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +5 -0
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +1 -0
- package/dist/types/core/factories/index.d.ts +2 -0
- package/dist/types/core/factories/index.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +9 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/operations/EntityOperations.d.ts +26 -0
- package/dist/types/core/operations/EntityOperations.d.ts.map +1 -0
- package/dist/types/core/operations/FieldOperations.d.ts +22 -0
- package/dist/types/core/operations/FieldOperations.d.ts.map +1 -0
- package/dist/types/core/operations/ListOperations.d.ts +32 -0
- package/dist/types/core/operations/ListOperations.d.ts.map +1 -0
- package/dist/types/core/operations/OperationsHelpers.d.ts +14 -0
- package/dist/types/core/operations/OperationsHelpers.d.ts.map +1 -0
- package/dist/types/core/operations/index.d.ts +4 -0
- package/dist/types/core/operations/index.d.ts.map +1 -0
- package/dist/types/core/requestAliases/MutationAlias.d.ts +6 -0
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -0
- package/dist/types/core/requestAliases/index.d.ts +2 -0
- package/dist/types/core/requestAliases/index.d.ts.map +1 -0
- package/dist/types/core/state/EntityListState.d.ts +29 -0
- package/dist/types/core/state/EntityListState.d.ts.map +1 -0
- package/dist/types/core/state/EntityRealmState.d.ts +44 -0
- package/dist/types/core/state/EntityRealmState.d.ts.map +1 -0
- package/dist/types/core/state/EntityState.d.ts +11 -0
- package/dist/types/core/state/EntityState.d.ts.map +1 -0
- package/dist/types/core/state/FieldState.d.ts +19 -0
- package/dist/types/core/state/FieldState.d.ts.map +1 -0
- package/dist/types/core/state/StateIterator.d.ts +14 -0
- package/dist/types/core/state/StateIterator.d.ts.map +1 -0
- package/dist/types/core/state/StateNode.d.ts +8 -0
- package/dist/types/core/state/StateNode.d.ts.map +1 -0
- package/dist/types/core/state/getEntityMarker.d.ts +3 -0
- package/dist/types/core/state/getEntityMarker.d.ts.map +1 -0
- package/dist/types/core/state/index.d.ts +8 -0
- package/dist/types/core/state/index.d.ts.map +1 -0
- package/dist/types/core/utils/getCombinedSignal.d.ts +2 -0
- package/dist/types/core/utils/getCombinedSignal.d.ts.map +1 -0
- package/dist/types/core/utils/index.d.ts +2 -0
- package/dist/types/core/utils/index.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts +7 -0
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +10 -0
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +10 -0
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/index.d.ts +3 -0
- package/dist/types/fieldHelpers/helpers/index.d.ts.map +1 -0
- package/dist/types/fieldHelpers/index.d.ts +2 -0
- package/dist/types/fieldHelpers/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/utils/assertNever.d.ts +2 -0
- package/dist/types/utils/assertNever.d.ts.map +1 -0
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts +2 -0
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/isEmptyObject.d.ts +2 -0
- package/dist/types/utils/isEmptyObject.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { validate } from "uuid";
|
|
2
|
+
import { EventListenersStore, PRIMARY_KEY_NAME, BindingError, ServerId, ClientGeneratedUuid } from "@contember/binding-common";
|
|
3
|
+
import { EventManager } from "../EventManager.js";
|
|
4
|
+
import { OperationsHelpers } from "./OperationsHelpers.js";
|
|
5
|
+
import { StateIterator } from "../state/StateIterator.js";
|
|
6
|
+
import { getEntityMarker } from "../state/getEntityMarker.js";
|
|
7
|
+
class FieldOperations {
|
|
8
|
+
constructor(accessorErrorManager, eventManager, stateInitializer, treeStore) {
|
|
9
|
+
this.accessorErrorManager = accessorErrorManager;
|
|
10
|
+
this.eventManager = eventManager;
|
|
11
|
+
this.stateInitializer = stateInitializer;
|
|
12
|
+
this.treeStore = treeStore;
|
|
13
|
+
}
|
|
14
|
+
addError(fieldState, error) {
|
|
15
|
+
return this.accessorErrorManager.addError(fieldState, error);
|
|
16
|
+
}
|
|
17
|
+
clearErrors(fieldState) {
|
|
18
|
+
return this.accessorErrorManager.clearErrorsByState(fieldState);
|
|
19
|
+
}
|
|
20
|
+
addEventListener(state, event, listener) {
|
|
21
|
+
if (!state.eventListeners) {
|
|
22
|
+
state.eventListeners = new EventListenersStore();
|
|
23
|
+
}
|
|
24
|
+
return state.eventListeners.add(event, listener);
|
|
25
|
+
}
|
|
26
|
+
updateValue(fieldState, newValue, { agent = "user" } = {}) {
|
|
27
|
+
this.eventManager.syncOperation(() => {
|
|
28
|
+
const { placeholderName, parent } = fieldState;
|
|
29
|
+
if (placeholderName === PRIMARY_KEY_NAME) {
|
|
30
|
+
const entity = fieldState.parent.entity;
|
|
31
|
+
{
|
|
32
|
+
if (newValue !== fieldState.value && (fieldState.touchLog !== void 0 || entity.hasIdSetInStone)) {
|
|
33
|
+
throw new BindingError(
|
|
34
|
+
`Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.
|
|
35
|
+
Once set, it is immutable.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (typeof newValue !== "string" || !validate(newValue)) {
|
|
39
|
+
throw new BindingError(
|
|
40
|
+
`Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. Expecting a valid uuid but '${newValue}' was given.
|
|
41
|
+
Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (this.treeStore.entityStore.has(ServerId.formatUniqueValue(newValue, entity.entityName))) {
|
|
45
|
+
throw new BindingError(
|
|
46
|
+
`Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. It is already in use by an existing entity.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (typeof newValue !== "string") {
|
|
51
|
+
throw new BindingError();
|
|
52
|
+
}
|
|
53
|
+
OperationsHelpers.changeEntityId(
|
|
54
|
+
this.treeStore,
|
|
55
|
+
this.eventManager,
|
|
56
|
+
this.stateInitializer,
|
|
57
|
+
entity,
|
|
58
|
+
new ClientGeneratedUuid(newValue)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
for (const field of StateIterator.eachSiblingRealmChild(this.treeStore, fieldState)) {
|
|
62
|
+
if (newValue === field.value) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (field.touchLog === void 0) {
|
|
66
|
+
field.touchLog = /* @__PURE__ */ new Set();
|
|
67
|
+
}
|
|
68
|
+
field.touchLog.add(agent);
|
|
69
|
+
field.value = newValue;
|
|
70
|
+
const resolvedValue = field.fieldMarker.defaultValue === void 0 ? newValue : newValue === null ? field.fieldMarker.defaultValue : newValue;
|
|
71
|
+
const normalizedPersistedValue = field.persistedValue === void 0 ? null : field.persistedValue;
|
|
72
|
+
const hadUnpersistedChangesBefore = field.hasUnpersistedChanges;
|
|
73
|
+
const hasUnpersistedChangesNow = resolvedValue !== normalizedPersistedValue;
|
|
74
|
+
field.hasUnpersistedChanges = hasUnpersistedChangesNow;
|
|
75
|
+
const shouldInfluenceUpdateCount = !getEntityMarker(parent).fields.hasAtLeastOneBearingField || !field.fieldMarker.isNonbearing || field.persistedValue !== void 0;
|
|
76
|
+
let changesDelta = EventManager.NO_CHANGES_DIFFERENCE;
|
|
77
|
+
if (shouldInfluenceUpdateCount) {
|
|
78
|
+
if (!hadUnpersistedChangesBefore && hasUnpersistedChangesNow) {
|
|
79
|
+
changesDelta++;
|
|
80
|
+
} else if (hadUnpersistedChangesBefore && !hasUnpersistedChangesNow) {
|
|
81
|
+
changesDelta--;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.eventManager.registerJustUpdated(field, changesDelta);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
FieldOperations
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=FieldOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldOperations.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/FieldOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { FieldValue } from '@contember/binding-common'\nimport {\n\tBindingError,\n\tClientGeneratedUuid,\n\tErrorAccessor,\n\tEventListenersStore,\n\tFieldAccessor,\n\tPRIMARY_KEY_NAME,\n\tServerId,\n} from '@contember/binding-common'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { FieldState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\n\nexport class FieldOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(fieldState: FieldState<any>, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(fieldState, error)\n\t}\n\n\tpublic clearErrors(fieldState: FieldState<any>): void {\n\t\treturn this.accessorErrorManager.clearErrorsByState(fieldState)\n\t}\n\n\tpublic addEventListener<\n\t\tType extends keyof FieldAccessor.FieldEventListenerMap,\n\t\tValue extends FieldValue = FieldValue,\n\t>(\n\t\tstate: FieldState<Value>,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\tif (!state.eventListeners) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic updateValue<Value extends FieldValue = FieldValue>(\n\t\tfieldState: FieldState<Value>,\n\t\tnewValue: Value | null,\n\t\t{ agent = 'user' }: FieldAccessor.UpdateOptions = {},\n\t) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst { placeholderName, parent } = fieldState\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME) {\n\t\t\t\tconst entity = fieldState.parent.entity\n\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tif (newValue !== fieldState.value && (fieldState.touchLog !== undefined || entity.hasIdSetInStone)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.\\n`\n\t\t\t\t\t\t\t\t+ `Once set, it is immutable.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof newValue !== 'string' || !uuidValidate(newValue)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. `\n\t\t\t\t\t\t\t\t+ `Expecting a valid uuid but '${newValue}' was given.\\n`\n\t\t\t\t\t\t\t\t+ `Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (this.treeStore.entityStore.has(ServerId.formatUniqueValue(newValue, entity.entityName))) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. `\n\t\t\t\t\t\t\t\t+ `It is already in use by an existing entity.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof newValue !== 'string') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tOperationsHelpers.changeEntityId(\n\t\t\t\t\tthis.treeStore,\n\t\t\t\t\tthis.eventManager,\n\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\tentity,\n\t\t\t\t\tnew ClientGeneratedUuid(newValue),\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const field of StateIterator.eachSiblingRealmChild(this.treeStore, fieldState)) {\n\t\t\t\tif (newValue === field.value) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.touchLog === undefined) {\n\t\t\t\t\tfield.touchLog = new Set()\n\t\t\t\t}\n\t\t\t\tfield.touchLog.add(agent)\n\t\t\t\tfield.value = newValue\n\n\t\t\t\tconst resolvedValue = field.fieldMarker.defaultValue === undefined\n\t\t\t\t\t? newValue\n\t\t\t\t\t: newValue === null\n\t\t\t\t\t? field.fieldMarker.defaultValue\n\t\t\t\t\t: newValue\n\t\t\t\tconst normalizedPersistedValue = field.persistedValue === undefined ? null : field.persistedValue\n\t\t\t\tconst hadUnpersistedChangesBefore = field.hasUnpersistedChanges\n\t\t\t\tconst hasUnpersistedChangesNow = resolvedValue !== normalizedPersistedValue\n\t\t\t\tfield.hasUnpersistedChanges = hasUnpersistedChangesNow\n\n\t\t\t\tconst shouldInfluenceUpdateCount = !getEntityMarker(parent).fields.hasAtLeastOneBearingField\n\t\t\t\t\t|| !field.fieldMarker.isNonbearing\n\t\t\t\t\t|| field.persistedValue !== undefined\n\n\t\t\t\tlet changesDelta = EventManager.NO_CHANGES_DIFFERENCE\n\n\t\t\t\tif (shouldInfluenceUpdateCount) {\n\t\t\t\t\tif (!hadUnpersistedChangesBefore && hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t} else if (hadUnpersistedChangesBefore && !hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta--\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(field, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;AAkBO,MAAM,gBAAgB;AAAA,EACrB,YACW,sBACA,cACA,kBACA,WAChB;AAJgB,SAAA,uBAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEI,SAAS,YAA6B,OAAwC;AACpF,WAAO,KAAK,qBAAqB,SAAS,YAAY,KAAK;AAAA,EAC5D;AAAA,EAEO,YAAY,YAAmC;AACrD,WAAO,KAAK,qBAAqB,mBAAmB,UAAU;AAAA,EAC/D;AAAA,EAEO,iBAIN,OACA,OACA,UACa;AACb,QAAI,CAAC,MAAM,gBAAgB;AAC1B,YAAM,iBAAiB,IAAI,oBAAA;AAAA,IAC5B;AACA,WAAO,MAAM,eAAe,IAAI,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,YACN,YACA,UACA,EAAE,QAAQ,OAAA,IAAwC,IACjD;AACD,SAAK,aAAa,cAAc,MAAM;AACrC,YAAM,EAAE,iBAAiB,OAAA,IAAW;AACpC,UAAI,oBAAoB,kBAAkB;AACzC,cAAM,SAAS,WAAW,OAAO;AAER;AACxB,cAAI,aAAa,WAAW,UAAU,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BAA+B,0BAA0B;AAC7D;AAAA,UACD,WAAW,+BAA+B,CAAC,0BAA0B;AACpE;AAAA,UACD;AAAA,QACD;AAEA,aAAK,aAAa,oBAAoB,OAAO,YAAY;AAAA,MAC1D;AAAA,IACD,CAAC;AAAA,EACF;AACD;"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uuid = require("uuid");
|
|
4
|
+
const bindingCommon = require("@contember/binding-common");
|
|
5
|
+
const EventManager = require("../EventManager.cjs");
|
|
6
|
+
const RealmKeyGenerator = require("../RealmKeyGenerator.cjs");
|
|
7
|
+
const OperationsHelpers = require("./OperationsHelpers.cjs");
|
|
8
|
+
const ErrorLocator = require("../exceptions/ErrorLocator.cjs");
|
|
9
|
+
const StateIterator = require("../state/StateIterator.cjs");
|
|
10
|
+
const getEntityMarker = require("../state/getEntityMarker.cjs");
|
|
11
|
+
class ListOperations {
|
|
12
|
+
constructor(accessorErrorManager, batchUpdatesOptions, eventManager, stateInitializer, treeStore) {
|
|
13
|
+
this.accessorErrorManager = accessorErrorManager;
|
|
14
|
+
this.batchUpdatesOptions = batchUpdatesOptions;
|
|
15
|
+
this.eventManager = eventManager;
|
|
16
|
+
this.stateInitializer = stateInitializer;
|
|
17
|
+
this.treeStore = treeStore;
|
|
18
|
+
}
|
|
19
|
+
addError(listState, error) {
|
|
20
|
+
return this.accessorErrorManager.addError(listState, error);
|
|
21
|
+
}
|
|
22
|
+
addEventListener(state, event, listener) {
|
|
23
|
+
if (state.eventListeners === void 0) {
|
|
24
|
+
state.eventListeners = new bindingCommon.EventListenersStore();
|
|
25
|
+
}
|
|
26
|
+
return state.eventListeners.add(event, listener);
|
|
27
|
+
}
|
|
28
|
+
addChildEventListener(state, event, listener) {
|
|
29
|
+
if (state.childEventListeners === void 0) {
|
|
30
|
+
state.childEventListeners = new bindingCommon.EventListenersStore();
|
|
31
|
+
}
|
|
32
|
+
return state.childEventListeners.add(event, listener);
|
|
33
|
+
}
|
|
34
|
+
batchUpdates(state, performUpdates) {
|
|
35
|
+
this.eventManager.syncOperation(() => {
|
|
36
|
+
performUpdates(state.getAccessor, this.batchUpdatesOptions);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
connectEntity(outerState, entityToConnect) {
|
|
40
|
+
this.eventManager.syncOperation(() => {
|
|
41
|
+
const persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState);
|
|
42
|
+
const stateToConnect = OperationsHelpers.OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect);
|
|
43
|
+
const idToConnect = stateToConnect.entity.id;
|
|
44
|
+
for (const state of StateIterator.StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {
|
|
45
|
+
if (state.entityName !== stateToConnect.entity.entityName) {
|
|
46
|
+
throw new bindingCommon.BindingError(
|
|
47
|
+
`EntityListAccessor.connectEntity: Attempting to connect at an entity of type '${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.
|
|
48
|
+
|
|
49
|
+
Entity located at: ${ErrorLocator.ErrorLocator.locateInternalState(outerState)}.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
bindingCommon.MarkerComparator.assertEntityMarkersSubsetOf(
|
|
54
|
+
state.blueprint.marker.fields,
|
|
55
|
+
getEntityMarker.getEntityMarker(stateToConnect).fields
|
|
56
|
+
);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error instanceof bindingCommon.LocalizedBindingError) {
|
|
59
|
+
throw new bindingCommon.BindingError(
|
|
60
|
+
`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are incompatible with entities found on this list. Make sure both trees are equivalent.
|
|
61
|
+
|
|
62
|
+
${error.message}
|
|
63
|
+
|
|
64
|
+
` + (error.markerPath.length > 1 ? `Incompatibility found at: ${ErrorLocator.ErrorLocator.locateMarkerPath(error.markerPath)}.
|
|
65
|
+
|
|
66
|
+
` : "") + `Entity list located at: ${ErrorLocator.ErrorLocator.locateInternalState(state)}.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
if (state.children.has(idToConnect.value)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
this.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {
|
|
75
|
+
type: "listEntity",
|
|
76
|
+
parent: state
|
|
77
|
+
}, stateToConnect);
|
|
78
|
+
state.plannedRemovals?.delete(idToConnect.value);
|
|
79
|
+
let changesDelta = 0;
|
|
80
|
+
if (persistedEntityIds.has(idToConnect.value)) {
|
|
81
|
+
changesDelta--;
|
|
82
|
+
} else if (idToConnect.existsOnServer) {
|
|
83
|
+
changesDelta++;
|
|
84
|
+
}
|
|
85
|
+
if (stateToConnect.type === "entityRealm") {
|
|
86
|
+
changesDelta += stateToConnect.unpersistedChangesCount;
|
|
87
|
+
}
|
|
88
|
+
this.eventManager.registerJustUpdated(state, changesDelta);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
disconnectEntity(listState, childEntity, options) {
|
|
93
|
+
this.eventManager.syncOperation(() => {
|
|
94
|
+
const persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState);
|
|
95
|
+
if (!listState.children.has(childEntity.id)) {
|
|
96
|
+
throw new bindingCommon.BindingError(
|
|
97
|
+
`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
for (const state of StateIterator.StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {
|
|
101
|
+
const disconnectedChildIdValue = childEntity.id;
|
|
102
|
+
const disconnectedChildRealm = state.children.get(disconnectedChildIdValue);
|
|
103
|
+
if (disconnectedChildRealm === void 0) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
this.treeStore.disposeOfRealm(disconnectedChildRealm);
|
|
107
|
+
state.children.delete(disconnectedChildIdValue);
|
|
108
|
+
let changesDelta = 0;
|
|
109
|
+
if (persistedEntityIds.has(disconnectedChildIdValue)) {
|
|
110
|
+
changesDelta++;
|
|
111
|
+
if (state.plannedRemovals === void 0) {
|
|
112
|
+
state.plannedRemovals = /* @__PURE__ */ new Map();
|
|
113
|
+
}
|
|
114
|
+
if (!options.noPersist) {
|
|
115
|
+
state.plannedRemovals.set(disconnectedChildIdValue, "disconnect");
|
|
116
|
+
}
|
|
117
|
+
} else if (disconnectedChildRealm.entity.id.existsOnServer) {
|
|
118
|
+
changesDelta--;
|
|
119
|
+
}
|
|
120
|
+
if (disconnectedChildRealm.type === "entityRealm") {
|
|
121
|
+
changesDelta -= disconnectedChildRealm.unpersistedChangesCount;
|
|
122
|
+
}
|
|
123
|
+
this.eventManager.registerJustUpdated(state, changesDelta);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
createNewEntity(outerState, initialize) {
|
|
128
|
+
return this.eventManager.syncOperation(() => {
|
|
129
|
+
const id = new bindingCommon.UnpersistedEntityDummyId();
|
|
130
|
+
for (const state of StateIterator.StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {
|
|
131
|
+
const newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {
|
|
132
|
+
type: "listEntity",
|
|
133
|
+
parent: state
|
|
134
|
+
});
|
|
135
|
+
this.stateInitializer.runImmediateUserInitialization(newEntity, initialize);
|
|
136
|
+
this.eventManager.registerJustUpdated(state, EventManager.EventManager.NO_CHANGES_DIFFERENCE);
|
|
137
|
+
}
|
|
138
|
+
return id;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
getChildEntityById(state, id) {
|
|
142
|
+
const realm = state.children.get(id);
|
|
143
|
+
if (realm === void 0) {
|
|
144
|
+
const isRuntimeId = typeof id === "number" || uuid.validate(id) || bindingCommon.UnpersistedEntityDummyId.matchesDummyId(id);
|
|
145
|
+
if (isRuntimeId) {
|
|
146
|
+
throw new bindingCommon.BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`);
|
|
147
|
+
}
|
|
148
|
+
const looksLikeKey = typeof id === "string" && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.RealmKeyGenerator.vaguelyAppearsToBeAKey(id));
|
|
149
|
+
throw new bindingCommon.BindingError(
|
|
150
|
+
`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` + (looksLikeKey ? `
|
|
151
|
+
The supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids and you can use \`EntityAccessor.id\` to obtain one. Keys, on the other hand, are globally unique and you can use \`getEntityByKey\` to get its EntityAccessor.` : "")
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return realm.getAccessor();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.ListOperations = ListOperations;
|
|
158
|
+
//# sourceMappingURL=ListOperations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListOperations.cjs","sources":["../../../../../../packages/binding-legacy/src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityId,\n\tEventListenersStore,\n\tLocalizedBindingError,\n\tMarkerComparator,\n\tRuntimeId,\n\tUnpersistedEntityDummyId,\n} from '@contember/binding-common'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { ErrorLocator } from '../exceptions/ErrorLocator'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type `\n\t\t\t\t\t\t\t+ `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n`\n\t\t\t\t\t\t\t+ `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are `\n\t\t\t\t\t\t\t\t+ `incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n`\n\t\t\t\t\t\t\t\t+ `${error.message}\\n\\n`\n\t\t\t\t\t\t\t\t+ (error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t\t\t+ `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else if (idToConnect.existsOnServer) {\n\t\t\t\t\t// ignoring unpersisted entities\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: { noPersist?: boolean }) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\n\t\t\tif (!listState.children.has(childEntity.id)) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tstate.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: EntityId) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = typeof id === 'number' || uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = typeof id === 'string' && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id))\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.`\n\t\t\t\t\t+ (looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids `\n\t\t\t\t\t\t\t+ `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and `\n\t\t\t\t\t\t\t+ `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["EventListenersStore","OperationsHelpers","StateIterator","BindingError","ErrorLocator","MarkerComparator","getEntityMarker","LocalizedBindingError","UnpersistedEntityDummyId","EventManager","uuidValidate","RealmKeyGenerator"],"mappings":";;;;;;;;;;AAoBO,MAAM,eAAe;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;AALgB,SAAA,uBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEI,SAAS,WAA4B,OAAwC;AACnF,WAAO,KAAK,qBAAqB,SAAS,WAAW,KAAK;AAAA,EAC3D;AAAA,EAEO,iBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,mBAAmB,QAAW;AACvC,YAAM,iBAAiB,IAAIA,kCAAA;AAAA,IAC5B;AACA,WAAO,MAAM,eAAe,IAAI,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,sBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,wBAAwB,QAAW;AAC5C,YAAM,sBAAsB,IAAIA,kCAAA;AAAA,IACjC;AACA,WAAO,MAAM,oBAAoB,IAAI,OAAO,QAAQ;AAAA,EACrD;AAAA,EAEO,aAAa,OAAwB,gBAAwD;AACnG,SAAK,aAAa,cAAc,MAAM;AACrC,qBAAe,MAAM,aAAa,KAAK,mBAAmB;AAAA,IAC3D,CAAC;AAAA,EACF;AAAA,EAEO,cAAc,Y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ASN,4BAAc,sBAAsB,KAAK,WAAW,UAAU,GAAG;AACpF,cAAM,YAAY,KAAK,iBAAiB,sBAAsB,IAAI,MAAM,YAAY;AAAA,UACnF,MAAM;AAAA,UACN,QAAQ;AAAA,QAAA,CACR;AAED,aAAK,iBAAiB,+BAA+B,WAAW,UAAU;AAK1E,aAAK,aAAa,oBAAoB,OAAOO,aAAAA,aAAa,qBAAqB;AAAA,MAChF;AACA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAwB,IAAc;AAC/D,UAAM,QAAQ,MAAM,SAAS,IAAI,EAAE;AACnC,QAAI,UAAU,QAAW;AACxB,YAAM,cAAc,OAAO,OAAO,YAAYC,KAAAA,SAAa,EAAE,KAAKF,cAAAA,yBAAyB,eAAe,EAAE;AAC5G,UAAI,aAAa;AAChB,cAAM,IAAIL,cAAAA,aAAa,kDAAkD,EAAE,6BAA6B;AAAA,MACzG;AACA,YAAM,eAAe,OAAO,OAAO,aAAa,KAAK,UAAU,iBAAiB,IAAI,EAAE,KAAKQ,kBAAAA,kBAAkB,uBAAuB,EAAE;AACtI,YAAM,IAAIR,cAAAA;AAAAA,QACT,kDAAkD,EAAE,oCAChD,eACA;AAAA,oQAGA;AAAA,MAAA;AAAA,IAEN;AACA,WAAO,MAAM,YAAA;AAAA,EACd;AACD;;"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { validate } from "uuid";
|
|
2
|
+
import { EventListenersStore, BindingError, MarkerComparator, LocalizedBindingError, UnpersistedEntityDummyId } from "@contember/binding-common";
|
|
3
|
+
import { EventManager } from "../EventManager.js";
|
|
4
|
+
import { RealmKeyGenerator } from "../RealmKeyGenerator.js";
|
|
5
|
+
import { OperationsHelpers } from "./OperationsHelpers.js";
|
|
6
|
+
import { ErrorLocator } from "../exceptions/ErrorLocator.js";
|
|
7
|
+
import { StateIterator } from "../state/StateIterator.js";
|
|
8
|
+
import { getEntityMarker } from "../state/getEntityMarker.js";
|
|
9
|
+
class ListOperations {
|
|
10
|
+
constructor(accessorErrorManager, batchUpdatesOptions, eventManager, stateInitializer, treeStore) {
|
|
11
|
+
this.accessorErrorManager = accessorErrorManager;
|
|
12
|
+
this.batchUpdatesOptions = batchUpdatesOptions;
|
|
13
|
+
this.eventManager = eventManager;
|
|
14
|
+
this.stateInitializer = stateInitializer;
|
|
15
|
+
this.treeStore = treeStore;
|
|
16
|
+
}
|
|
17
|
+
addError(listState, error) {
|
|
18
|
+
return this.accessorErrorManager.addError(listState, error);
|
|
19
|
+
}
|
|
20
|
+
addEventListener(state, event, listener) {
|
|
21
|
+
if (state.eventListeners === void 0) {
|
|
22
|
+
state.eventListeners = new EventListenersStore();
|
|
23
|
+
}
|
|
24
|
+
return state.eventListeners.add(event, listener);
|
|
25
|
+
}
|
|
26
|
+
addChildEventListener(state, event, listener) {
|
|
27
|
+
if (state.childEventListeners === void 0) {
|
|
28
|
+
state.childEventListeners = new EventListenersStore();
|
|
29
|
+
}
|
|
30
|
+
return state.childEventListeners.add(event, listener);
|
|
31
|
+
}
|
|
32
|
+
batchUpdates(state, performUpdates) {
|
|
33
|
+
this.eventManager.syncOperation(() => {
|
|
34
|
+
performUpdates(state.getAccessor, this.batchUpdatesOptions);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
connectEntity(outerState, entityToConnect) {
|
|
38
|
+
this.eventManager.syncOperation(() => {
|
|
39
|
+
const persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState);
|
|
40
|
+
const stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect);
|
|
41
|
+
const idToConnect = stateToConnect.entity.id;
|
|
42
|
+
for (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {
|
|
43
|
+
if (state.entityName !== stateToConnect.entity.entityName) {
|
|
44
|
+
throw new BindingError(
|
|
45
|
+
`EntityListAccessor.connectEntity: Attempting to connect at an entity of type '${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.
|
|
46
|
+
|
|
47
|
+
Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
MarkerComparator.assertEntityMarkersSubsetOf(
|
|
52
|
+
state.blueprint.marker.fields,
|
|
53
|
+
getEntityMarker(stateToConnect).fields
|
|
54
|
+
);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof LocalizedBindingError) {
|
|
57
|
+
throw new BindingError(
|
|
58
|
+
`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are incompatible with entities found on this list. Make sure both trees are equivalent.
|
|
59
|
+
|
|
60
|
+
${error.message}
|
|
61
|
+
|
|
62
|
+
` + (error.markerPath.length > 1 ? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.
|
|
63
|
+
|
|
64
|
+
` : "") + `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
if (state.children.has(idToConnect.value)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
this.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {
|
|
73
|
+
type: "listEntity",
|
|
74
|
+
parent: state
|
|
75
|
+
}, stateToConnect);
|
|
76
|
+
state.plannedRemovals?.delete(idToConnect.value);
|
|
77
|
+
let changesDelta = 0;
|
|
78
|
+
if (persistedEntityIds.has(idToConnect.value)) {
|
|
79
|
+
changesDelta--;
|
|
80
|
+
} else if (idToConnect.existsOnServer) {
|
|
81
|
+
changesDelta++;
|
|
82
|
+
}
|
|
83
|
+
if (stateToConnect.type === "entityRealm") {
|
|
84
|
+
changesDelta += stateToConnect.unpersistedChangesCount;
|
|
85
|
+
}
|
|
86
|
+
this.eventManager.registerJustUpdated(state, changesDelta);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
disconnectEntity(listState, childEntity, options) {
|
|
91
|
+
this.eventManager.syncOperation(() => {
|
|
92
|
+
const persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState);
|
|
93
|
+
if (!listState.children.has(childEntity.id)) {
|
|
94
|
+
throw new BindingError(
|
|
95
|
+
`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
for (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {
|
|
99
|
+
const disconnectedChildIdValue = childEntity.id;
|
|
100
|
+
const disconnectedChildRealm = state.children.get(disconnectedChildIdValue);
|
|
101
|
+
if (disconnectedChildRealm === void 0) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
this.treeStore.disposeOfRealm(disconnectedChildRealm);
|
|
105
|
+
state.children.delete(disconnectedChildIdValue);
|
|
106
|
+
let changesDelta = 0;
|
|
107
|
+
if (persistedEntityIds.has(disconnectedChildIdValue)) {
|
|
108
|
+
changesDelta++;
|
|
109
|
+
if (state.plannedRemovals === void 0) {
|
|
110
|
+
state.plannedRemovals = /* @__PURE__ */ new Map();
|
|
111
|
+
}
|
|
112
|
+
if (!options.noPersist) {
|
|
113
|
+
state.plannedRemovals.set(disconnectedChildIdValue, "disconnect");
|
|
114
|
+
}
|
|
115
|
+
} else if (disconnectedChildRealm.entity.id.existsOnServer) {
|
|
116
|
+
changesDelta--;
|
|
117
|
+
}
|
|
118
|
+
if (disconnectedChildRealm.type === "entityRealm") {
|
|
119
|
+
changesDelta -= disconnectedChildRealm.unpersistedChangesCount;
|
|
120
|
+
}
|
|
121
|
+
this.eventManager.registerJustUpdated(state, changesDelta);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
createNewEntity(outerState, initialize) {
|
|
126
|
+
return this.eventManager.syncOperation(() => {
|
|
127
|
+
const id = new UnpersistedEntityDummyId();
|
|
128
|
+
for (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {
|
|
129
|
+
const newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {
|
|
130
|
+
type: "listEntity",
|
|
131
|
+
parent: state
|
|
132
|
+
});
|
|
133
|
+
this.stateInitializer.runImmediateUserInitialization(newEntity, initialize);
|
|
134
|
+
this.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE);
|
|
135
|
+
}
|
|
136
|
+
return id;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getChildEntityById(state, id) {
|
|
140
|
+
const realm = state.children.get(id);
|
|
141
|
+
if (realm === void 0) {
|
|
142
|
+
const isRuntimeId = typeof id === "number" || validate(id) || UnpersistedEntityDummyId.matchesDummyId(id);
|
|
143
|
+
if (isRuntimeId) {
|
|
144
|
+
throw new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`);
|
|
145
|
+
}
|
|
146
|
+
const looksLikeKey = typeof id === "string" && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id));
|
|
147
|
+
throw new BindingError(
|
|
148
|
+
`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` + (looksLikeKey ? `
|
|
149
|
+
The supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids and you can use \`EntityAccessor.id\` to obtain one. Keys, on the other hand, are globally unique and you can use \`getEntityByKey\` to get its EntityAccessor.` : "")
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return realm.getAccessor();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
ListOperations
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=ListOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListOperations.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityId,\n\tEventListenersStore,\n\tLocalizedBindingError,\n\tMarkerComparator,\n\tRuntimeId,\n\tUnpersistedEntityDummyId,\n} from '@contember/binding-common'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { ErrorLocator } from '../exceptions/ErrorLocator'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type `\n\t\t\t\t\t\t\t+ `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n`\n\t\t\t\t\t\t\t+ `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are `\n\t\t\t\t\t\t\t\t+ `incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n`\n\t\t\t\t\t\t\t\t+ `${error.message}\\n\\n`\n\t\t\t\t\t\t\t\t+ (error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t\t\t+ `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else if (idToConnect.existsOnServer) {\n\t\t\t\t\t// ignoring unpersisted entities\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: { noPersist?: boolean }) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\n\t\t\tif (!listState.children.has(childEntity.id)) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tstate.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: EntityId) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = typeof id === 'number' || uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = typeof id === 'string' && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id))\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.`\n\t\t\t\t\t+ (looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids `\n\t\t\t\t\t\t\t+ `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and `\n\t\t\t\t\t\t\t+ `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;;;AAoBO,MAAM,eAAe;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;AALgB,SAAA,uBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEI,SAAS,WAA4B,OAAwC;AACnF,WAAO,KAAK,qBAAqB,SAAS,WAAW,KAAK;AAAA,EAC3D;AAAA,EAEO,iBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,mBAAmB,QAAW;AACvC,YAAM,iBAAiB,IAAI,oBAAA;AAAA,IAC5B;AACA,WAAO,MAAM,eAAe,IAAI,OAAO,QA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SAAS,eAAe;AAElD,0BAAgB,uBAAuB;AAAA,QACxC;AAEA,aAAK,aAAa,oBAAoB,OAAO,YAAY;AAAA,MAC1D;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EAEO,gBAAgB,YAA6B,YAAuE;AAC1H,WAAO,KAAK,aAAa,cAAc,MAAiB;AAEvD,YAAM,KAAK,IAAI,yBAAA;AAEf,iBAAW,SAAS,cAAc,sBAAsB,KAAK,WAAW,UAAU,GAAG;AACpF,cAAM,YAAY,KAAK,iBAAiB,sBAAsB,IAAI,MAAM,YAAY;AAAA,UACnF,MAAM;AAAA,UACN,QAAQ;AAAA,QAAA,CACR;AAED,aAAK,iBAAiB,+BAA+B,WAAW,UAAU;AAK1E,aAAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,MAChF;AACA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAwB,IAAc;AAC/D,UAAM,QAAQ,MAAM,SAAS,IAAI,EAAE;AACnC,QAAI,UAAU,QAAW;AACxB,YAAM,cAAc,OAAO,OAAO,YAAYA,SAAa,EAAE,KAAK,yBAAyB,eAAe,EAAE;AAC5G,UAAI,aAAa;AAChB,cAAM,IAAI,aAAa,kDAAkD,EAAE,6BAA6B;AAAA,MACzG;AACA,YAAM,eAAe,OAAO,OAAO,aAAa,KAAK,UAAU,iBAAiB,IAAI,EAAE,KAAK,kBAAkB,uBAAuB,EAAE;AACtI,YAAM,IAAI;AAAA,QACT,kDAAkD,EAAE,oCAChD,eACA;AAAA,oQAGA;AAAA,MAAA;AAAA,IAEN;AACA,WAAO,MAAM,YAAA;AAAA,EACd;AACD;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const bindingCommon = require("@contember/binding-common");
|
|
4
|
+
const EventManager = require("../EventManager.cjs");
|
|
5
|
+
const RealmKeyGenerator = require("../RealmKeyGenerator.cjs");
|
|
6
|
+
class OperationsHelpers {
|
|
7
|
+
static rejectInvalidAccessorTree() {
|
|
8
|
+
throw new bindingCommon.BindingError(
|
|
9
|
+
`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
static resolveAndPrepareEntityToConnect(treeStore, entityToConnect) {
|
|
13
|
+
const entityToConnectKey = entityToConnect.key;
|
|
14
|
+
if (!entityToConnectKey) {
|
|
15
|
+
throw new bindingCommon.BindingError(`Attempting to connect an entity without a key.`);
|
|
16
|
+
}
|
|
17
|
+
const stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey);
|
|
18
|
+
if (stateToConnect === void 0) {
|
|
19
|
+
throw new bindingCommon.BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`);
|
|
20
|
+
}
|
|
21
|
+
return stateToConnect;
|
|
22
|
+
}
|
|
23
|
+
static changeEntityId(treeStore, eventManager, stateInitializer, entity, newId) {
|
|
24
|
+
const previousId = entity.id;
|
|
25
|
+
treeStore.entityStore.delete(previousId.uniqueValue);
|
|
26
|
+
treeStore.entityStore.set(newId.uniqueValue, entity);
|
|
27
|
+
let counter = 0;
|
|
28
|
+
for (const realm of entity.realms.values()) {
|
|
29
|
+
this.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId);
|
|
30
|
+
if (++counter === entity.realms.size) {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
entity.hasIdSetInStone = true;
|
|
35
|
+
entity.id = newId;
|
|
36
|
+
}
|
|
37
|
+
static changeRealmId(treeStore, eventManager, stateInitializer, realm, newId) {
|
|
38
|
+
const oldEntity = realm.entity;
|
|
39
|
+
const oldRealmKey = realm.realmKey;
|
|
40
|
+
const oldId = oldEntity.id;
|
|
41
|
+
const realmBlueprint = realm.blueprint;
|
|
42
|
+
const newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName);
|
|
43
|
+
const newRealmKey = RealmKeyGenerator.RealmKeyGenerator.getRealmKey(newId, realmBlueprint);
|
|
44
|
+
realm.realmKey = newRealmKey;
|
|
45
|
+
realm.entity = newEntity;
|
|
46
|
+
newEntity.id = newId;
|
|
47
|
+
oldEntity.realms.delete(oldRealmKey);
|
|
48
|
+
newEntity.realms.set(newRealmKey, realm);
|
|
49
|
+
if (realm.type === "entityRealm") {
|
|
50
|
+
const childIdState = realm.children.get(bindingCommon.PRIMARY_KEY_NAME);
|
|
51
|
+
if (childIdState?.type === "field") {
|
|
52
|
+
childIdState.value = newId.value;
|
|
53
|
+
eventManager.registerJustUpdated(childIdState, EventManager.EventManager.NO_CHANGES_DIFFERENCE);
|
|
54
|
+
}
|
|
55
|
+
this.purgeStaleListenersAfterIdChange(realm);
|
|
56
|
+
}
|
|
57
|
+
if (oldEntity.realms.size === 0) {
|
|
58
|
+
treeStore.disposeOfEntity(oldEntity);
|
|
59
|
+
}
|
|
60
|
+
treeStore.entityRealmStore.delete(oldRealmKey);
|
|
61
|
+
treeStore.entityRealmStore.set(newRealmKey, realm);
|
|
62
|
+
if (realmBlueprint.type === "listEntity") {
|
|
63
|
+
const list = realmBlueprint.parent;
|
|
64
|
+
list.children.changeKey(oldId.value, newId.value);
|
|
65
|
+
} else if (realmBlueprint.type === "hasOne") {
|
|
66
|
+
eventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName);
|
|
67
|
+
}
|
|
68
|
+
const parent = realmBlueprint.parent;
|
|
69
|
+
if (parent) {
|
|
70
|
+
eventManager.registerJustUpdated(parent, EventManager.EventManager.NO_CHANGES_DIFFERENCE);
|
|
71
|
+
}
|
|
72
|
+
if (realm.type === "entityRealm") {
|
|
73
|
+
eventManager.registerJustUpdated(realm, EventManager.EventManager.NO_CHANGES_DIFFERENCE);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
static purgeStaleListenersAfterIdChange(realm) {
|
|
77
|
+
const listeners = realm.eventListeners;
|
|
78
|
+
if (listeners) {
|
|
79
|
+
if (realm.blueprint.parent) {
|
|
80
|
+
listeners.delete({ type: "update" });
|
|
81
|
+
}
|
|
82
|
+
listeners.deleteByType("connectionUpdate");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.OperationsHelpers = OperationsHelpers;
|
|
87
|
+
//# sourceMappingURL=OperationsHelpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationsHelpers.cjs","sources":["../../../../../../packages/binding-legacy/src/core/operations/OperationsHelpers.ts"],"sourcesContent":["import type { EntityAccessor } from '@contember/binding-common'\nimport type { RuntimeId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { PRIMARY_KEY_NAME } from '@contember/binding-common'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport type { EntityRealmState, EntityRealmStateStub, EntityState } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\n\nexport class OperationsHelpers {\n\tpublic static rejectInvalidAccessorTree(): never {\n\t\tthrow new BindingError(\n\t\t\t`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`,\n\t\t)\n\t}\n\n\tpublic static resolveAndPrepareEntityToConnect(\n\t\ttreeStore: TreeStore,\n\t\tentityToConnect: EntityAccessor,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\tconst entityToConnectKey = entityToConnect.key\n\t\tif (!entityToConnectKey) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity without a key.`)\n\t\t}\n\t\tconst stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey)\n\n\t\tif (stateToConnect === undefined) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)\n\t\t}\n\t\t// TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with\n\t\t// \t\tinverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.\n\t\t// if (!stateToConnect.entity.id.existsOnServer) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +\n\t\t// \t\t\t`doesn't exist on server. That is currently impossible.`, // At least for now.\n\t\t// \t)\n\t\t// }\n\n\t\t// TODO\n\t\t// if (stateToConnect.entity.isScheduledForDeletion) {\n\t\t// \t// As far as the other realms are concerned, this entity is deleted. We don't want to just make it re-appear\n\t\t// \t// for them just because some other random relation decided to connect it.\n\t\t// \tstateToConnect.entity.realms.clear()\n\t\t// \tstateToConnect.entity.isScheduledForDeletion = false\n\t\t// }\n\n\t\treturn stateToConnect\n\t}\n\n\tpublic static changeEntityId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\tentity: EntityState,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst previousId = entity.id\n\n\t\ttreeStore.entityStore.delete(previousId.uniqueValue)\n\t\ttreeStore.entityStore.set(newId.uniqueValue, entity)\n\n\t\tlet counter = 0\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId)\n\n\t\t\tif (++counter === entity.realms.size) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tentity.hasIdSetInStone = true\n\t\tentity.id = newId\n\t}\n\n\tpublic static changeRealmId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst oldEntity = realm.entity\n\t\tconst oldRealmKey = realm.realmKey\n\t\tconst oldId = oldEntity.id\n\n\t\tconst realmBlueprint = realm.blueprint\n\n\t\tconst newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName)\n\t\tconst newRealmKey = RealmKeyGenerator.getRealmKey(newId, realmBlueprint)\n\n\t\trealm.realmKey = newRealmKey\n\t\trealm.entity = newEntity\n\n\t\t// This may still actually be necessary if we're going from a client to server generated uuid.\n\t\t// They both may have the same value but still be different.\n\t\tnewEntity.id = newId\n\t\toldEntity.realms.delete(oldRealmKey)\n\t\tnewEntity.realms.set(newRealmKey, realm)\n\n\t\tif (realm.type === 'entityRealm') {\n\t\t\tconst childIdState = realm.children.get(PRIMARY_KEY_NAME)\n\t\t\tif (childIdState?.type === 'field') {\n\t\t\t\tchildIdState.value = newId.value\n\t\t\t\teventManager.registerJustUpdated(childIdState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\n\t\t\tthis.purgeStaleListenersAfterIdChange(realm)\n\t\t}\n\n\t\tif (oldEntity.realms.size === 0) {\n\t\t\ttreeStore.disposeOfEntity(oldEntity)\n\t\t}\n\n\t\ttreeStore.entityRealmStore.delete(oldRealmKey)\n\t\ttreeStore.entityRealmStore.set(newRealmKey, realm)\n\n\t\tif (realmBlueprint.type === 'listEntity') {\n\t\t\tconst list = realmBlueprint.parent\n\t\t\tlist.children.changeKey(oldId.value, newId.value) // 😎\n\t\t} else if (realmBlueprint.type === 'hasOne') {\n\t\t\teventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName)\n\t\t}\n\t\tconst parent = realmBlueprint.parent\n\t\tif (parent) {\n\t\t\teventManager.registerJustUpdated(parent, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t\tif (realm.type === 'entityRealm') {\n\t\t\teventManager.registerJustUpdated(realm, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t}\n\n\tpublic static purgeStaleListenersAfterIdChange(realm: EntityRealmState) {\n\t\t// Version 1.\n\t\t// The listeners subscribed to a particular entity key so we no longer want to call these.\n\t\t// The only positionally associated listeners are in the blueprint so we re-initialize those.\n\t\t// realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)\n\n\t\t// Version 2.\n\t\t// This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.\n\n\t\t// Version 3.\n\t\t// The saga continues. We add a condition to exempt top-level realms. That way they can start\n\t\t// propagating changes from the top.\n\t\tconst listeners = realm.eventListeners\n\t\tif (listeners) {\n\t\t\tif (realm.blueprint.parent) {\n\t\t\t\tlisteners.delete({ type: 'update' })\n\t\t\t}\n\t\t\tlisteners.deleteByType('connectionUpdate')\n\t\t}\n\t}\n}\n"],"names":["BindingError","RealmKeyGenerator","PRIMARY_KEY_NAME","EventManager"],"mappings":";;;;;AAUO,MAAM,kBAAkB;AAAA,EAC9B,OAAc,4BAAmC;AAChD,UAAM,IAAIA,cAAAA;AAAAA,MACT;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,iCACb,WACA,iBAC0C;AAC1C,UAAM,qBAAqB,gBAAgB;AAC3C,QAAI,CAAC,oBAAoB;AACxB,YAAM,IAAIA,cAAAA,aAAa,gDAAgD;AAAA,IACxE;AACA,UAAM,iBAAiB,UAAU,iBAAiB,IAAI,kBAAkB;AAExE,QAAI,mBAAmB,QAAW;AACjC,YAAM,IAAIA,cAAAA,aAAa,6CAA6C,kBAAkB,yBAAyB;AAAA,IAChH;AAkBA,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,eACb,WACA,cACA,kBACA,QACA,OACC;AACD,UAAM,aAAa,OAAO;AAE1B,cAAU,YAAY,OAAO,WAAW,WAAW;AACnD,cAAU,YAAY,IAAI,MAAM,aAAa,MAAM;AAEnD,QAAI,UAAU;AACd,eAAW,SAAS,OAAO,OAAO,OAAA,GAAU;AAC3C,WAAK,cAAc,WAAW,cAAc,kBAAkB,OAAO,KAAK;AAE1E,UAAI,EAAE,YAAY,OAAO,OAAO,MAAM;AACrC;AAAA,MACD;AAAA,IACD;AAEA,WAAO,kBAAkB;AACzB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,OAAc,cACb,WACA,cACA,kBACA,OACA,OACC;AACD,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,MAAM;AAC1B,UAAM,QAAQ,UAAU;AAExB,UAAM,iBAAiB,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