@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,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const bindingCommon = require("@contember/binding-common");
|
|
4
|
+
const Config = require("./src/core/Config.cjs");
|
|
5
|
+
const DataBinding = require("./src/core/DataBinding.cjs");
|
|
6
|
+
const DirtinessTracker = require("./src/core/DirtinessTracker.cjs");
|
|
7
|
+
const EntityAccessorImpl = require("./src/accessors/EntityAccessorImpl.cjs");
|
|
8
|
+
const EntityListAccessorImpl = require("./src/accessors/EntityListAccessorImpl.cjs");
|
|
9
|
+
const EventManager = require("./src/core/EventManager.cjs");
|
|
10
|
+
const FieldAccessorImpl = require("./src/accessors/FieldAccessorImpl.cjs");
|
|
11
|
+
const NormalizedPersistedData = require("./src/accessorTree/NormalizedPersistedData.cjs");
|
|
12
|
+
const QueryGenerator = require("./src/core/QueryGenerator.cjs");
|
|
13
|
+
const StateInitializer = require("./src/core/StateInitializer.cjs");
|
|
14
|
+
const TreeAugmenter = require("./src/core/TreeAugmenter.cjs");
|
|
15
|
+
const TreeStore = require("./src/core/TreeStore.cjs");
|
|
16
|
+
exports.Config = Config.Config;
|
|
17
|
+
exports.DataBinding = DataBinding.DataBinding;
|
|
18
|
+
exports.DirtinessTracker = DirtinessTracker.DirtinessTracker;
|
|
19
|
+
exports.EntityAccessorImpl = EntityAccessorImpl.EntityAccessorImpl;
|
|
20
|
+
exports.EntityListAccessorImpl = EntityListAccessorImpl.EntityListAccessorImpl;
|
|
21
|
+
exports.EventManager = EventManager.EventManager;
|
|
22
|
+
exports.FieldAccessorImpl = FieldAccessorImpl.FieldAccessorImpl;
|
|
23
|
+
exports.NormalizedPersistedData = NormalizedPersistedData.NormalizedPersistedData;
|
|
24
|
+
exports.QueryGenerator = QueryGenerator.QueryGenerator;
|
|
25
|
+
exports.StateInitializer = StateInitializer.StateInitializer;
|
|
26
|
+
exports.TreeAugmenter = TreeAugmenter.TreeAugmenter;
|
|
27
|
+
exports.TreeStore = TreeStore.TreeStore;
|
|
28
|
+
Object.keys(bindingCommon).forEach((k) => {
|
|
29
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: () => bindingCommon[k]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "@contember/binding-common";
|
|
2
|
+
import { Config } from "./src/core/Config.js";
|
|
3
|
+
import { DataBinding } from "./src/core/DataBinding.js";
|
|
4
|
+
import { DirtinessTracker } from "./src/core/DirtinessTracker.js";
|
|
5
|
+
import { EntityAccessorImpl } from "./src/accessors/EntityAccessorImpl.js";
|
|
6
|
+
import { EntityListAccessorImpl } from "./src/accessors/EntityListAccessorImpl.js";
|
|
7
|
+
import { EventManager } from "./src/core/EventManager.js";
|
|
8
|
+
import { FieldAccessorImpl } from "./src/accessors/FieldAccessorImpl.js";
|
|
9
|
+
import { NormalizedPersistedData } from "./src/accessorTree/NormalizedPersistedData.js";
|
|
10
|
+
import { QueryGenerator } from "./src/core/QueryGenerator.js";
|
|
11
|
+
import { StateInitializer } from "./src/core/StateInitializer.js";
|
|
12
|
+
import { TreeAugmenter } from "./src/core/TreeAugmenter.js";
|
|
13
|
+
import { TreeStore } from "./src/core/TreeStore.js";
|
|
14
|
+
export {
|
|
15
|
+
Config,
|
|
16
|
+
DataBinding,
|
|
17
|
+
DirtinessTracker,
|
|
18
|
+
EntityAccessorImpl,
|
|
19
|
+
EntityListAccessorImpl,
|
|
20
|
+
EventManager,
|
|
21
|
+
FieldAccessorImpl,
|
|
22
|
+
NormalizedPersistedData,
|
|
23
|
+
QueryGenerator,
|
|
24
|
+
StateInitializer,
|
|
25
|
+
TreeAugmenter,
|
|
26
|
+
TreeStore
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
class NormalizedPersistedData {
|
|
4
|
+
constructor(subTreeDataStore, persistedEntityDataStore) {
|
|
5
|
+
this.subTreeDataStore = subTreeDataStore;
|
|
6
|
+
this.persistedEntityDataStore = persistedEntityDataStore;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.NormalizedPersistedData = NormalizedPersistedData;
|
|
10
|
+
//# sourceMappingURL=NormalizedPersistedData.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NormalizedPersistedData.cjs","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class NormalizedPersistedData {
|
|
2
|
+
constructor(subTreeDataStore, persistedEntityDataStore) {
|
|
3
|
+
this.subTreeDataStore = subTreeDataStore;
|
|
4
|
+
this.persistedEntityDataStore = persistedEntityDataStore;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
NormalizedPersistedData
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=NormalizedPersistedData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NormalizedPersistedData.js","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const bindingCommon = require("@contember/binding-common");
|
|
4
|
+
const getEntityMarker = require("../core/state/getEntityMarker.cjs");
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
8
|
+
class EntityAccessorImpl {
|
|
9
|
+
constructor(state, operations, runtimeId, key, name, fieldData, dataFromServer, hasUnpersistedChanges, errors, environment, getAccessor) {
|
|
10
|
+
this.state = state;
|
|
11
|
+
this.operations = operations;
|
|
12
|
+
this.runtimeId = runtimeId;
|
|
13
|
+
this.key = key;
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.fieldData = fieldData;
|
|
16
|
+
this.dataFromServer = dataFromServer;
|
|
17
|
+
this.hasUnpersistedChanges = hasUnpersistedChanges;
|
|
18
|
+
this.errors = errors;
|
|
19
|
+
this.environment = environment;
|
|
20
|
+
this.getAccessor = getAccessor;
|
|
21
|
+
__publicField(this, "__type", "EntityAccessor");
|
|
22
|
+
}
|
|
23
|
+
get idOnServer() {
|
|
24
|
+
return this.runtimeId.existsOnServer ? this.runtimeId.value : void 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Note that for entities that don't yet exist on server this will return a dummy id.
|
|
28
|
+
*/
|
|
29
|
+
get id() {
|
|
30
|
+
return this.runtimeId.value;
|
|
31
|
+
}
|
|
32
|
+
get existsOnServer() {
|
|
33
|
+
return this.runtimeId.existsOnServer;
|
|
34
|
+
}
|
|
35
|
+
//
|
|
36
|
+
addError(error) {
|
|
37
|
+
return this.operations.addError(this.state, bindingCommon.ErrorAccessor.normalizeError(error));
|
|
38
|
+
}
|
|
39
|
+
addEventListener(event, listener) {
|
|
40
|
+
return this.operations.addEventListener(this.state, event, listener);
|
|
41
|
+
}
|
|
42
|
+
batchUpdates(performUpdates) {
|
|
43
|
+
this.operations.batchUpdates(this.state, performUpdates);
|
|
44
|
+
}
|
|
45
|
+
connectEntityAtField(field, entityToConnect) {
|
|
46
|
+
const desugared = bindingCommon.QueryLanguage.desugarRelativeSingleEntity(field, this.environment);
|
|
47
|
+
const relativeTo = this.getEntity({
|
|
48
|
+
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1)
|
|
49
|
+
});
|
|
50
|
+
const fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field;
|
|
51
|
+
this.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect);
|
|
52
|
+
}
|
|
53
|
+
disconnectEntityAtField(field, initializeReplacement) {
|
|
54
|
+
const desugared = bindingCommon.QueryLanguage.desugarRelativeSingleEntity(field, this.environment);
|
|
55
|
+
const relativeTo = this.getEntity({
|
|
56
|
+
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1)
|
|
57
|
+
});
|
|
58
|
+
const fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field;
|
|
59
|
+
this.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement);
|
|
60
|
+
}
|
|
61
|
+
deleteEntity() {
|
|
62
|
+
this.operations.deleteEntity(this.state);
|
|
63
|
+
}
|
|
64
|
+
//
|
|
65
|
+
updateValues(fieldValuePairs) {
|
|
66
|
+
this.batchUpdates((getAccessor) => {
|
|
67
|
+
const entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs);
|
|
68
|
+
for (const [field, value] of entries) {
|
|
69
|
+
getAccessor().getField(field).updateValue(value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter
|
|
75
|
+
* is really just a way to succinctly write a type cast. Nothing more, really.
|
|
76
|
+
*/
|
|
77
|
+
getField(field) {
|
|
78
|
+
if (typeof field === "string" || !("hasOneRelationPath" in field)) {
|
|
79
|
+
return this.getField(bindingCommon.QueryLanguage.desugarRelativeSingleField(field, this.environment));
|
|
80
|
+
}
|
|
81
|
+
const entity = this.getEntity(field);
|
|
82
|
+
const fieldPlaceholder = bindingCommon.PlaceholderGenerator.getFieldPlaceholder(field.field);
|
|
83
|
+
const accessor = entity.fieldData.get(fieldPlaceholder);
|
|
84
|
+
if (accessor) {
|
|
85
|
+
return accessor.getAccessor();
|
|
86
|
+
}
|
|
87
|
+
bindingCommon.TreeNodeUtils.resolveColumn(entity.environment, field.field);
|
|
88
|
+
throw new bindingCommon.BindingError(
|
|
89
|
+
`EntityAccessor: cannot access field '${field.field}' on ${bindingCommon.TreeNodeUtils.describeLocation(entity.environment)}.
|
|
90
|
+
The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
getEntity(entity) {
|
|
94
|
+
if (typeof entity === "string" || !("hasOneRelationPath" in entity)) {
|
|
95
|
+
return this.getEntity(bindingCommon.QueryLanguage.desugarRelativeSingleEntity(entity, this.environment));
|
|
96
|
+
}
|
|
97
|
+
let relativeTo = this;
|
|
98
|
+
for (const hasOneRelation of entity.hasOneRelationPath) {
|
|
99
|
+
const fieldPlaceholder = bindingCommon.PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation);
|
|
100
|
+
const accessor = relativeTo.fieldData.get(fieldPlaceholder);
|
|
101
|
+
if (!accessor) {
|
|
102
|
+
return this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation);
|
|
103
|
+
}
|
|
104
|
+
relativeTo = accessor.getAccessor();
|
|
105
|
+
}
|
|
106
|
+
return relativeTo;
|
|
107
|
+
}
|
|
108
|
+
getEntityList(entityList) {
|
|
109
|
+
if (typeof entityList === "string" || !("hasOneRelationPath" in entityList)) {
|
|
110
|
+
return this.getEntityList(bindingCommon.QueryLanguage.desugarRelativeEntityList(entityList, this.environment));
|
|
111
|
+
}
|
|
112
|
+
const entity = this.getEntity(entityList);
|
|
113
|
+
const fieldPlaceholder = bindingCommon.PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation);
|
|
114
|
+
const accessor = entity.fieldData.get(fieldPlaceholder);
|
|
115
|
+
if (!accessor) {
|
|
116
|
+
return this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation);
|
|
117
|
+
}
|
|
118
|
+
return accessor.getAccessor();
|
|
119
|
+
}
|
|
120
|
+
raiseInvalidHasOneRelationError(relativeTo, hasOneRelation) {
|
|
121
|
+
bindingCommon.TreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy);
|
|
122
|
+
const entityMarker = relativeTo.getMarker();
|
|
123
|
+
const possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, bindingCommon.HasOneRelationMarker, hasOneRelation.field);
|
|
124
|
+
const markerParams = possibleMarkers.map((it) => bindingCommon.PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters));
|
|
125
|
+
const relationParams = bindingCommon.PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation);
|
|
126
|
+
this.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams);
|
|
127
|
+
}
|
|
128
|
+
raiseInvalidHasManyRelationError(entity, hasManyRelation) {
|
|
129
|
+
bindingCommon.TreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field);
|
|
130
|
+
const entityMarker = entity.getMarker();
|
|
131
|
+
const possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, bindingCommon.HasManyRelationMarker, hasManyRelation.field);
|
|
132
|
+
const markerParams = possibleMarkers.map((it) => bindingCommon.PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters));
|
|
133
|
+
const relationParams = bindingCommon.PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation);
|
|
134
|
+
this.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams);
|
|
135
|
+
}
|
|
136
|
+
raiseUndefinedRelationError(field, environment, relationParams, otherMarkersParams) {
|
|
137
|
+
const hint = this.createHintMessage(otherMarkersParams);
|
|
138
|
+
throw new bindingCommon.BindingError(
|
|
139
|
+
`EntityAccessor: cannot access relation '${field}' on ${bindingCommon.TreeNodeUtils.describeLocation(environment)}.
|
|
140
|
+
The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.
|
|
141
|
+
|
|
142
|
+
Provided parameters:
|
|
143
|
+
` + JSON.stringify(relationParams) + hint
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
createHintMessage(params) {
|
|
147
|
+
if (params.length === 0) {
|
|
148
|
+
return "";
|
|
149
|
+
}
|
|
150
|
+
const serializedParams = params.map((it) => JSON.stringify(it)).join("\n");
|
|
151
|
+
const message = params.length === 1 ? "However, there is existing marker for the same field, but it have different parameters:" : "However, there are existing markers for the same field, but they have different parameters:";
|
|
152
|
+
return `
|
|
153
|
+
|
|
154
|
+
${message}
|
|
155
|
+
${serializedParams}`;
|
|
156
|
+
}
|
|
157
|
+
getMarkersOfType(markers, markerConstructor, fieldName) {
|
|
158
|
+
return Array.from(markers.values()).filter((it) => it instanceof markerConstructor && it.parameters.field === fieldName);
|
|
159
|
+
}
|
|
160
|
+
getParent() {
|
|
161
|
+
const blueprint = this.state.blueprint;
|
|
162
|
+
if (blueprint.type === "subTree") {
|
|
163
|
+
return void 0;
|
|
164
|
+
}
|
|
165
|
+
return blueprint.parent.getAccessor();
|
|
166
|
+
}
|
|
167
|
+
getMarker() {
|
|
168
|
+
return getEntityMarker.getEntityMarker(this.state);
|
|
169
|
+
}
|
|
170
|
+
getFieldMeta(field) {
|
|
171
|
+
const fieldData = this.dataFromServer?.get(field);
|
|
172
|
+
return {
|
|
173
|
+
readable: fieldData?.readable,
|
|
174
|
+
updatable: fieldData?.updatable
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.EntityAccessorImpl = EntityAccessorImpl;
|
|
179
|
+
//# sourceMappingURL=EntityAccessorImpl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":["ErrorAccessor","QueryLanguage","PlaceholderGenerator","TreeNodeUtils","BindingError","HasOneRelationMarker","PlaceholderParametersGenerator","HasManyRelationMarker","getEntityMarker"],"mappings":";;;;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAezB;AAAA,EAEA,IAAI,aAAmC;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derGenerator, TreeNodeUtils, BindingError, HasOneRelationMarker, PlaceholderParametersGenerator, HasManyRelationMarker } from "@contember/binding-common";
|
|
2
|
+
import { getEntityMarker } from "../core/state/getEntityMarker.js";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
6
|
+
class EntityAccessorImpl {
|
|
7
|
+
constructor(state, operations, runtimeId, key, name, fieldData, dataFromServer, hasUnpersistedChanges, errors, environment, getAccessor) {
|
|
8
|
+
this.state = state;
|
|
9
|
+
this.operations = operations;
|
|
10
|
+
this.runtimeId = runtimeId;
|
|
11
|
+
this.key = key;
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.fieldData = fieldData;
|
|
14
|
+
this.dataFromServer = dataFromServer;
|
|
15
|
+
this.hasUnpersistedChanges = hasUnpersistedChanges;
|
|
16
|
+
this.errors = errors;
|
|
17
|
+
this.environment = environment;
|
|
18
|
+
this.getAccessor = getAccessor;
|
|
19
|
+
__publicField(this, "__type", "EntityAccessor");
|
|
20
|
+
}
|
|
21
|
+
get idOnServer() {
|
|
22
|
+
return this.runtimeId.existsOnServer ? this.runtimeId.value : void 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Note that for entities that don't yet exist on server this will return a dummy id.
|
|
26
|
+
*/
|
|
27
|
+
get id() {
|
|
28
|
+
return this.runtimeId.value;
|
|
29
|
+
}
|
|
30
|
+
get existsOnServer() {
|
|
31
|
+
return this.runtimeId.existsOnServer;
|
|
32
|
+
}
|
|
33
|
+
//
|
|
34
|
+
addError(error) {
|
|
35
|
+
return this.operations.addError(this.state, ErrorAccessor.normalizeError(error));
|
|
36
|
+
}
|
|
37
|
+
addEventListener(event, listener) {
|
|
38
|
+
return this.operations.addEventListener(this.state, event, listener);
|
|
39
|
+
}
|
|
40
|
+
batchUpdates(performUpdates) {
|
|
41
|
+
this.operations.batchUpdates(this.state, performUpdates);
|
|
42
|
+
}
|
|
43
|
+
connectEntityAtField(field, entityToConnect) {
|
|
44
|
+
const desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment);
|
|
45
|
+
const relativeTo = this.getEntity({
|
|
46
|
+
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1)
|
|
47
|
+
});
|
|
48
|
+
const fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field;
|
|
49
|
+
this.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect);
|
|
50
|
+
}
|
|
51
|
+
disconnectEntityAtField(field, initializeReplacement) {
|
|
52
|
+
const desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment);
|
|
53
|
+
const relativeTo = this.getEntity({
|
|
54
|
+
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1)
|
|
55
|
+
});
|
|
56
|
+
const fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field;
|
|
57
|
+
this.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement);
|
|
58
|
+
}
|
|
59
|
+
deleteEntity() {
|
|
60
|
+
this.operations.deleteEntity(this.state);
|
|
61
|
+
}
|
|
62
|
+
//
|
|
63
|
+
updateValues(fieldValuePairs) {
|
|
64
|
+
this.batchUpdates((getAccessor) => {
|
|
65
|
+
const entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs);
|
|
66
|
+
for (const [field, value] of entries) {
|
|
67
|
+
getAccessor().getField(field).updateValue(value);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter
|
|
73
|
+
* is really just a way to succinctly write a type cast. Nothing more, really.
|
|
74
|
+
*/
|
|
75
|
+
getField(field) {
|
|
76
|
+
if (typeof field === "string" || !("hasOneRelationPath" in field)) {
|
|
77
|
+
return this.getField(QueryLanguage.desugarRelativeSingleField(field, this.environment));
|
|
78
|
+
}
|
|
79
|
+
const entity = this.getEntity(field);
|
|
80
|
+
const fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field);
|
|
81
|
+
const accessor = entity.fieldData.get(fieldPlaceholder);
|
|
82
|
+
if (accessor) {
|
|
83
|
+
return accessor.getAccessor();
|
|
84
|
+
}
|
|
85
|
+
TreeNodeUtils.resolveColumn(entity.environment, field.field);
|
|
86
|
+
throw new BindingError(
|
|
87
|
+
`EntityAccessor: cannot access field '${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.
|
|
88
|
+
The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
getEntity(entity) {
|
|
92
|
+
if (typeof entity === "string" || !("hasOneRelationPath" in entity)) {
|
|
93
|
+
return this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment));
|
|
94
|
+
}
|
|
95
|
+
let relativeTo = this;
|
|
96
|
+
for (const hasOneRelation of entity.hasOneRelationPath) {
|
|
97
|
+
const fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation);
|
|
98
|
+
const accessor = relativeTo.fieldData.get(fieldPlaceholder);
|
|
99
|
+
if (!accessor) {
|
|
100
|
+
return this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation);
|
|
101
|
+
}
|
|
102
|
+
relativeTo = accessor.getAccessor();
|
|
103
|
+
}
|
|
104
|
+
return relativeTo;
|
|
105
|
+
}
|
|
106
|
+
getEntityList(entityList) {
|
|
107
|
+
if (typeof entityList === "string" || !("hasOneRelationPath" in entityList)) {
|
|
108
|
+
return this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment));
|
|
109
|
+
}
|
|
110
|
+
const entity = this.getEntity(entityList);
|
|
111
|
+
const fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation);
|
|
112
|
+
const accessor = entity.fieldData.get(fieldPlaceholder);
|
|
113
|
+
if (!accessor) {
|
|
114
|
+
return this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation);
|
|
115
|
+
}
|
|
116
|
+
return accessor.getAccessor();
|
|
117
|
+
}
|
|
118
|
+
raiseInvalidHasOneRelationError(relativeTo, hasOneRelation) {
|
|
119
|
+
TreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy);
|
|
120
|
+
const entityMarker = relativeTo.getMarker();
|
|
121
|
+
const possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field);
|
|
122
|
+
const markerParams = possibleMarkers.map((it) => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters));
|
|
123
|
+
const relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation);
|
|
124
|
+
this.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams);
|
|
125
|
+
}
|
|
126
|
+
raiseInvalidHasManyRelationError(entity, hasManyRelation) {
|
|
127
|
+
TreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field);
|
|
128
|
+
const entityMarker = entity.getMarker();
|
|
129
|
+
const possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field);
|
|
130
|
+
const markerParams = possibleMarkers.map((it) => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters));
|
|
131
|
+
const relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation);
|
|
132
|
+
this.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams);
|
|
133
|
+
}
|
|
134
|
+
raiseUndefinedRelationError(field, environment, relationParams, otherMarkersParams) {
|
|
135
|
+
const hint = this.createHintMessage(otherMarkersParams);
|
|
136
|
+
throw new BindingError(
|
|
137
|
+
`EntityAccessor: cannot access relation '${field}' on ${TreeNodeUtils.describeLocation(environment)}.
|
|
138
|
+
The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.
|
|
139
|
+
|
|
140
|
+
Provided parameters:
|
|
141
|
+
` + JSON.stringify(relationParams) + hint
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
createHintMessage(params) {
|
|
145
|
+
if (params.length === 0) {
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
const serializedParams = params.map((it) => JSON.stringify(it)).join("\n");
|
|
149
|
+
const message = params.length === 1 ? "However, there is existing marker for the same field, but it have different parameters:" : "However, there are existing markers for the same field, but they have different parameters:";
|
|
150
|
+
return `
|
|
151
|
+
|
|
152
|
+
${message}
|
|
153
|
+
${serializedParams}`;
|
|
154
|
+
}
|
|
155
|
+
getMarkersOfType(markers, markerConstructor, fieldName) {
|
|
156
|
+
return Array.from(markers.values()).filter((it) => it instanceof markerConstructor && it.parameters.field === fieldName);
|
|
157
|
+
}
|
|
158
|
+
getParent() {
|
|
159
|
+
const blueprint = this.state.blueprint;
|
|
160
|
+
if (blueprint.type === "subTree") {
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
return blueprint.parent.getAccessor();
|
|
164
|
+
}
|
|
165
|
+
getMarker() {
|
|
166
|
+
return getEntityMarker(this.state);
|
|
167
|
+
}
|
|
168
|
+
getFieldMeta(field) {
|
|
169
|
+
const fieldData = this.dataFromServer?.get(field);
|
|
170
|
+
return {
|
|
171
|
+
readable: fieldData?.readable,
|
|
172
|
+
updatable: fieldData?.updatable
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
EntityAccessorImpl
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=EntityAccessorImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable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KAAK,KAAK;AAAA,EAClC;AAAA,EAEA,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AAChD,WAAO;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IAAA;AAAA,EAExB;AACD;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const bindingCommon = require("@contember/binding-common");
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
7
|
+
class EntityListAccessorImpl {
|
|
8
|
+
constructor(state, operations, name, _children, _idsPersistedOnServer, hasUnpersistedChanges, errors, environment, getAccessor) {
|
|
9
|
+
this.state = state;
|
|
10
|
+
this.operations = operations;
|
|
11
|
+
this.name = name;
|
|
12
|
+
this._children = _children;
|
|
13
|
+
this._idsPersistedOnServer = _idsPersistedOnServer;
|
|
14
|
+
this.hasUnpersistedChanges = hasUnpersistedChanges;
|
|
15
|
+
this.errors = errors;
|
|
16
|
+
this.environment = environment;
|
|
17
|
+
this.getAccessor = getAccessor;
|
|
18
|
+
__publicField(this, "__type", "EntityListAccessor");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns all entity keys that are on the list.
|
|
22
|
+
* **KEYS ARE NOT IDS!**
|
|
23
|
+
* @see EntityAccessor.key
|
|
24
|
+
*/
|
|
25
|
+
*keys() {
|
|
26
|
+
for (const accessor of this) {
|
|
27
|
+
yield accessor.key;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
*ids() {
|
|
31
|
+
yield* this._children.keys();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
|
|
35
|
+
* the list since the last server query.
|
|
36
|
+
*/
|
|
37
|
+
get idsPersistedOnServer() {
|
|
38
|
+
return new Set(this._idsPersistedOnServer);
|
|
39
|
+
}
|
|
40
|
+
*[Symbol.iterator]() {
|
|
41
|
+
for (const { getAccessor } of this._children.values()) {
|
|
42
|
+
yield getAccessor();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
hasEntityId(id) {
|
|
46
|
+
return this._children.has(id);
|
|
47
|
+
}
|
|
48
|
+
isEmpty() {
|
|
49
|
+
return this.length === 0;
|
|
50
|
+
}
|
|
51
|
+
get length() {
|
|
52
|
+
return this._children.size;
|
|
53
|
+
}
|
|
54
|
+
hasEntityOnServer(entityOrItsId) {
|
|
55
|
+
if (typeof entityOrItsId === "string" || typeof entityOrItsId === "number") {
|
|
56
|
+
return this.idsPersistedOnServer.has(entityOrItsId);
|
|
57
|
+
}
|
|
58
|
+
const idOnServer = entityOrItsId.idOnServer;
|
|
59
|
+
if (idOnServer === void 0) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return this.idsPersistedOnServer.has(idOnServer);
|
|
63
|
+
}
|
|
64
|
+
deleteAll() {
|
|
65
|
+
this.batchUpdates((getAccessor) => {
|
|
66
|
+
const list = getAccessor();
|
|
67
|
+
for (const entity of list) {
|
|
68
|
+
entity.deleteEntity();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
disconnectAll() {
|
|
73
|
+
this.batchUpdates((getAccessor) => {
|
|
74
|
+
const list = getAccessor();
|
|
75
|
+
for (const entity of list) {
|
|
76
|
+
list.disconnectEntity(entity);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
addError(error) {
|
|
81
|
+
return this.operations.addError(this.state, bindingCommon.ErrorAccessor.normalizeError(error));
|
|
82
|
+
}
|
|
83
|
+
addEventListener(event, listener) {
|
|
84
|
+
return this.operations.addEventListener(this.state, event, listener);
|
|
85
|
+
}
|
|
86
|
+
addChildEventListener(event, listener) {
|
|
87
|
+
return this.operations.addChildEventListener(this.state, event, listener);
|
|
88
|
+
}
|
|
89
|
+
batchUpdates(performUpdates) {
|
|
90
|
+
this.operations.batchUpdates(this.state, performUpdates);
|
|
91
|
+
}
|
|
92
|
+
connectEntity(entityToConnect) {
|
|
93
|
+
this.operations.connectEntity(this.state, entityToConnect);
|
|
94
|
+
}
|
|
95
|
+
createNewEntity(initialize) {
|
|
96
|
+
return this.operations.createNewEntity(this.state, initialize);
|
|
97
|
+
}
|
|
98
|
+
disconnectEntity(childEntity, options = {}) {
|
|
99
|
+
this.operations.disconnectEntity(this.state, childEntity, options);
|
|
100
|
+
}
|
|
101
|
+
getChildEntityById(id) {
|
|
102
|
+
return this.operations.getChildEntityById(this.state, id);
|
|
103
|
+
}
|
|
104
|
+
getParent() {
|
|
105
|
+
return this.state.blueprint.parent?.getAccessor();
|
|
106
|
+
}
|
|
107
|
+
getMarker() {
|
|
108
|
+
return this.state.blueprint.marker;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.EntityListAccessorImpl = EntityListAccessorImpl;
|
|
112
|
+
//# sourceMappingURL=EntityListAccessorImpl.cjs.map
|