@contember/binding 1.0.3 → 1.1.0-alpha.10
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/accessorPropagation/EnvironmentContext.js +28 -2
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTree.js +4 -2
- package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTree.js +4 -2
- package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useExtendTree.js +27 -0
- package/dist/development/accessorPropagation/useExtendTree.js.map +1 -0
- package/dist/development/accessorTree/AccessorTree.js +16 -14
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/AccessorTreeStateContext.js +4 -0
- package/dist/development/accessorTree/AccessorTreeStateContext.js.map +1 -0
- package/dist/development/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +17 -4
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js +11 -2
- package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/development/accessorTree/useAccessorTreeState.js +12 -0
- package/dist/development/accessorTree/useAccessorTreeState.js.map +1 -0
- package/dist/development/accessorTree/useDataBinding.js +41 -51
- package/dist/development/accessorTree/useDataBinding.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +0 -32
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +1 -1
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +5 -2
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js +1 -2
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +24 -53
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/DirtinessTracker.js +4 -13
- package/dist/development/core/DirtinessTracker.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +9 -13
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +12 -7
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/development/core/MarkerComparator.js +1 -1
- package/dist/development/core/MarkerMerger.js +3 -6
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +180 -141
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +93 -134
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +30 -38
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +14 -14
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeFilterGenerator.js +2 -2
- package/dist/development/core/TreeFilterGenerator.js.map +1 -1
- package/dist/development/core/TreeStore.js +12 -23
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.js +4 -1
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +14 -13
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +2 -2
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +3 -3
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/operations/OperationsHelpers.js +2 -2
- package/dist/development/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js +4 -40
- package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/development/core/schema/Schema.js +29 -2
- package/dist/development/core/schema/Schema.js.map +1 -1
- package/dist/development/core/schema/SchemaLoader.js +12 -12
- package/dist/development/core/schema/SchemaLoader.js.map +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/development/coreComponents/Component.js +5 -2
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +0 -1
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +4 -12
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +4 -22
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +5 -1
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +3 -5
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +4 -6
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/dao/Environment.js +175 -90
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/dao/TreeNodeEnvironmentFactory.js +153 -0
- package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/If.js +39 -0
- package/dist/development/helperComponents/If.js.map +1 -0
- package/dist/development/helperComponents/SugaredField.js +1 -1
- package/dist/development/helperComponents/helpers/FilterEvaluator.js +35 -0
- package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
- package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +38 -0
- package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
- package/dist/development/index.js +7 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.js +4 -4
- package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js +6 -5
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +18 -6
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +1 -1
- package/dist/development/utils/Hashing.js +21 -6
- package/dist/development/utils/Hashing.js.map +1 -1
- package/dist/production/accessorPropagation/EnvironmentContext.js +28 -2
- package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
- package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
- package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useExtendTree.js +27 -0
- package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
- package/dist/production/accessorTree/AccessorTree.js +16 -14
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/AccessorTreeStateContext.js +4 -0
- package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
- package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js +17 -4
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessorTree/accessorTreeStateReducer.js +11 -2
- package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/production/accessorTree/useAccessorTreeState.js +12 -0
- package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
- package/dist/production/accessorTree/useDataBinding.js +41 -51
- package/dist/production/accessorTree/useDataBinding.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +0 -32
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +1 -1
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +5 -2
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js +1 -2
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +24 -44
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/DirtinessTracker.js +4 -13
- package/dist/production/core/DirtinessTracker.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js +9 -13
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js +11 -6
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/production/core/MarkerComparator.js +1 -1
- package/dist/production/core/MarkerMerger.js +3 -6
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +180 -141
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js +93 -134
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +30 -38
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +14 -14
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeFilterGenerator.js +2 -2
- package/dist/production/core/TreeFilterGenerator.js.map +1 -1
- package/dist/production/core/TreeStore.js +12 -23
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/VariableInputTransformer.js +4 -1
- package/dist/production/core/VariableInputTransformer.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +14 -13
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/FieldOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.js +3 -3
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/core/operations/OperationsHelpers.js +2 -2
- package/dist/production/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js +4 -33
- package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/production/core/schema/Schema.js +29 -2
- package/dist/production/core/schema/Schema.js.map +1 -1
- package/dist/production/core/schema/SchemaLoader.js +12 -12
- package/dist/production/core/schema/SchemaLoader.js.map +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/production/coreComponents/Component.js +5 -2
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js +0 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js +4 -12
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js +4 -22
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/Field.js +5 -1
- package/dist/production/coreComponents/Field.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js +3 -5
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js +4 -6
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/dao/Environment.js +175 -90
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/dao/TreeNodeEnvironmentFactory.js +153 -0
- package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/If.js +39 -0
- package/dist/production/helperComponents/If.js.map +1 -0
- package/dist/production/helperComponents/SugaredField.js +1 -1
- package/dist/production/helperComponents/helpers/FilterEvaluator.js +35 -0
- package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
- package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +38 -0
- package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
- package/dist/production/index.js +7 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.js +4 -4
- package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js +6 -5
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +15 -6
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +1 -1
- package/dist/production/utils/Hashing.js +21 -6
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts +13 -2
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/index.d.ts +1 -0
- package/dist/types/accessorPropagation/index.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
- package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeState.d.ts +8 -0
- package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +6 -0
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -1
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts +5 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +5 -5
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
- package/dist/types/accessorTree/PersistResult.d.ts +2 -1
- package/dist/types/accessorTree/PersistResult.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +11 -10
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/RuntimeId.d.ts +16 -6
- package/dist/types/accessorTree/RuntimeId.d.ts.map +1 -1
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -1
- package/dist/types/accessorTree/index.d.ts +1 -0
- package/dist/types/accessorTree/index.d.ts.map +1 -1
- package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
- package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
- package/dist/types/accessorTree/useDataBinding.d.ts +1 -1
- package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
- package/dist/types/accessors/BindingConfig.d.ts +0 -1
- package/dist/types/accessors/BindingConfig.d.ts.map +1 -1
- package/dist/types/accessors/EntityAccessor.d.ts +1 -3
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
- package/dist/types/accessors/EntityListAccessor.d.ts +2 -2
- package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
- package/dist/types/core/AccessorErrorManager.d.ts +2 -1
- package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
- package/dist/types/core/Config.d.ts.map +1 -1
- package/dist/types/core/DataBinding.d.ts +3 -4
- package/dist/types/core/DataBinding.d.ts.map +1 -1
- package/dist/types/core/DirtinessTracker.d.ts +2 -5
- package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
- package/dist/types/core/ErrorsPreprocessor.d.ts +5 -3
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
- package/dist/types/core/EventManager.d.ts +1 -1
- package/dist/types/core/EventManager.d.ts.map +1 -1
- package/dist/types/core/MarkerMerger.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts +25 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
- package/dist/types/core/StateInitializer.d.ts +1 -5
- package/dist/types/core/StateInitializer.d.ts.map +1 -1
- package/dist/types/core/TreeAugmenter.d.ts +3 -2
- package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
- package/dist/types/core/TreeStore.d.ts +8 -8
- package/dist/types/core/TreeStore.d.ts.map +1 -1
- package/dist/types/core/VariableInputTransformer.d.ts +2 -2
- package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
- package/dist/types/core/operations/ListOperations.d.ts +2 -1
- package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
- package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
- package/dist/types/core/requestAliases/index.d.ts +0 -3
- package/dist/types/core/requestAliases/index.d.ts.map +1 -1
- package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
- package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
- package/dist/types/core/schema/Schema.d.ts +14 -2
- package/dist/types/core/schema/Schema.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaColumn.d.ts +1 -1
- package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
- package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaLoader.d.ts +2 -1
- package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
- package/dist/types/core/schema/index.d.ts +0 -1
- package/dist/types/core/schema/index.d.ts.map +1 -1
- package/dist/types/core/state/FieldState.d.ts +2 -2
- package/dist/types/core/state/FieldState.d.ts.map +1 -1
- package/dist/types/coreComponents/Component.d.ts +9 -4
- package/dist/types/coreComponents/Component.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts +0 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/Entity.d.ts +1 -1
- package/dist/types/coreComponents/Entity.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts +1 -1
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/coreComponents/HasMany.d.ts +1 -1
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
- package/dist/types/coreComponents/HasOne.d.ts +1 -1
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
- package/dist/types/dao/Environment.d.ts +89 -41
- package/dist/types/dao/Environment.d.ts.map +1 -1
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +19 -0
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -0
- package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
- package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
- package/dist/types/helperComponents/FieldView.d.ts +7 -7
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
- package/dist/types/helperComponents/If.d.ts +14 -0
- package/dist/types/helperComponents/If.d.ts.map +1 -0
- package/dist/types/helperComponents/StaticRender.d.ts +1 -1
- package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
- package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
- package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
- package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
- package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
- package/dist/types/helperComponents/index.d.ts +1 -0
- package/dist/types/helperComponents/index.d.ts.map +1 -1
- package/dist/types/markers/FieldMarker.d.ts +3 -3
- package/dist/types/markers/FieldMarker.d.ts.map +1 -1
- package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
- package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
- package/dist/types/queryLanguage/MarkerFactory.d.ts.map +1 -1
- package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
- package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
- package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/Hashing.d.ts +3 -2
- package/dist/types/utils/Hashing.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/accessorPropagation/EnvironmentContext.tsx +44 -0
- package/src/accessorPropagation/index.ts +1 -0
- package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
- package/src/accessorPropagation/useEntitySubTree.ts +8 -1
- package/src/accessorPropagation/useExtendTree.ts +30 -0
- package/src/accessorTree/AccessorTree.tsx +18 -18
- package/src/accessorTree/AccessorTreeState.ts +12 -1
- package/src/accessorTree/AccessorTreeStateAction.ts +7 -1
- package/src/accessorTree/AccessorTreeStateContext.ts +4 -0
- package/src/accessorTree/AccessorTreeStateOptions.ts +0 -1
- package/src/accessorTree/MutationRequestResponse.ts +3 -1
- package/src/accessorTree/NormalizedPersistedData.ts +5 -5
- package/src/accessorTree/PersistResult.ts +2 -1
- package/src/accessorTree/QueryRequestResponse.ts +17 -14
- package/src/accessorTree/RuntimeId.ts +27 -6
- package/src/accessorTree/accessorTreeStateReducer.ts +10 -1
- package/src/accessorTree/index.ts +1 -0
- package/src/accessorTree/useAccessorTreeState.ts +11 -0
- package/src/accessorTree/useDataBinding.ts +41 -59
- package/src/accessors/BindingConfig.ts +0 -1
- package/src/accessors/EntityAccessor.ts +2 -51
- package/src/accessors/EntityListAccessor.ts +3 -3
- package/src/core/AccessorErrorManager.ts +6 -2
- package/src/core/Config.ts +0 -1
- package/src/core/DataBinding.ts +25 -65
- package/src/core/DirtinessTracker.ts +4 -16
- package/src/core/ErrorsPreprocessor.ts +16 -18
- package/src/core/EventManager.ts +14 -8
- package/src/core/MarkerMerger.ts +1 -4
- package/src/core/MutationGenerator.ts +249 -188
- package/src/core/RequestResponseNormalizer.ts +111 -163
- package/src/core/StateInitializer.ts +46 -58
- package/src/core/TreeAugmenter.ts +16 -15
- package/src/core/TreeFilterGenerator.ts +5 -5
- package/src/core/TreeStore.ts +23 -27
- package/src/core/VariableInputTransformer.ts +9 -6
- package/src/core/index.ts +1 -0
- package/src/core/operations/EntityOperations.ts +13 -14
- package/src/core/operations/FieldOperations.ts +2 -2
- package/src/core/operations/ListOperations.ts +6 -5
- package/src/core/operations/OperationsHelpers.ts +2 -2
- package/src/core/requestAliases/MutationAlias.ts +4 -57
- package/src/core/requestAliases/index.ts +0 -3
- package/src/core/schema/RawSchemaEntity.ts +1 -2
- package/src/core/schema/Schema.ts +42 -3
- package/src/core/schema/SchemaColumn.ts +1 -1
- package/src/core/schema/SchemaEntity.ts +1 -1
- package/src/core/schema/SchemaLoader.ts +13 -11
- package/src/core/schema/SchemaPreprocessor.ts +1 -1
- package/src/core/schema/SchemaRelation.ts +1 -1
- package/src/core/schema/index.ts +0 -1
- package/src/core/state/FieldState.ts +2 -2
- package/src/coreComponents/Component.tsx +20 -7
- package/src/coreComponents/DataBindingProvider.tsx +0 -2
- package/src/coreComponents/EntityListSubTree.tsx +5 -16
- package/src/coreComponents/EntitySubTree.tsx +17 -32
- package/src/coreComponents/Field.tsx +4 -0
- package/src/coreComponents/HasMany.tsx +4 -6
- package/src/coreComponents/HasOne.tsx +6 -7
- package/src/dao/Environment.ts +260 -124
- package/src/dao/TreeNodeEnvironmentFactory.ts +224 -0
- package/src/helperComponents/DeferredSubTrees.tsx +20 -13
- package/src/helperComponents/If.tsx +71 -0
- package/src/helperComponents/helpers/FilterEvaluator.ts +46 -0
- package/src/helperComponents/helpers/FilterFieldsCollector.ts +46 -0
- package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
- package/src/helperComponents/index.ts +1 -0
- package/src/markers/EntityListSubTreeMarker.ts +1 -1
- package/src/markers/EntitySubTreeMarker.ts +1 -1
- package/src/markers/PlaceholderGenerator.ts +5 -2
- package/src/queryLanguage/MarkerFactory.ts +5 -3
- package/src/queryLanguage/Parser.ts +24 -11
- package/src/treeParameters/primitives/EntityId.ts +1 -1
- package/src/treeParameters/primitives/FieldValue.ts +2 -2
- package/src/treeParameters/primitives/Json.ts +7 -0
- package/src/treeParameters/primitives/index.ts +1 -0
- package/src/typings/react-fix.d.ts +12 -0
- package/src/utils/Hashing.ts +23 -8
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/development/core/schema/SchemaValidator.js +0 -116
- package/dist/development/core/schema/SchemaValidator.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
- package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
- package/dist/types/core/schema/SchemaValidator.d.ts +0 -14
- package/dist/types/core/schema/SchemaValidator.d.ts.map +0 -1
- package/src/accessorPropagation/EnvironmentContext.ts +0 -5
- package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
- package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
- package/src/core/requestAliases/mutationOperationType.ts +0 -5
- package/src/core/schema/SchemaValidator.ts +0 -238
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
1
|
+
import { createContext, createElement, Fragment, useCallback } from "react";
|
|
2
|
+
import { useEnvironment } from "./useEnvironment.js";
|
|
2
3
|
import { Environment } from "../dao/Environment.js";
|
|
4
|
+
import { Component } from "../coreComponents/Component.js";
|
|
3
5
|
const EnvironmentContext = createContext(Environment.create());
|
|
4
6
|
EnvironmentContext.displayName = "EnvironmentContext";
|
|
5
|
-
|
|
7
|
+
const EnvironmentMiddleware = Component(({ children, create }) => {
|
|
8
|
+
const env = useEnvironment();
|
|
9
|
+
return /* @__PURE__ */ createElement(EnvironmentContext.Provider, {
|
|
10
|
+
value: create(env)
|
|
11
|
+
}, children);
|
|
12
|
+
}, {
|
|
13
|
+
staticRender: ({ children }) => {
|
|
14
|
+
return /* @__PURE__ */ createElement(Fragment, null, children);
|
|
15
|
+
},
|
|
16
|
+
generateEnvironment: ({ create }, env) => {
|
|
17
|
+
return create(env);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const EnvironmentExtensionProvider = Component(({ children, extension, state }) => {
|
|
21
|
+
const create = useCallback((env) => env.withExtension(extension, state), [extension, state]);
|
|
22
|
+
return /* @__PURE__ */ createElement(EnvironmentMiddleware, {
|
|
23
|
+
create
|
|
24
|
+
}, children);
|
|
25
|
+
}, ({ children, extension, state }) => {
|
|
26
|
+
const create = (env) => env.withExtension(extension, state);
|
|
27
|
+
return /* @__PURE__ */ createElement(EnvironmentMiddleware, {
|
|
28
|
+
create
|
|
29
|
+
}, children);
|
|
30
|
+
});
|
|
31
|
+
export { EnvironmentContext, EnvironmentExtensionProvider, EnvironmentMiddleware };
|
|
6
32
|
//# sourceMappingURL=EnvironmentContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentContext.js","sources":["../../../src/accessorPropagation/EnvironmentContext.
|
|
1
|
+
{"version":3,"file":"EnvironmentContext.js","sources":["../../../src/accessorPropagation/EnvironmentContext.tsx"],"sourcesContent":["import { createContext, ReactElement, ReactNode, useCallback } from 'react'\nimport { Environment } from '../dao'\nimport { useEnvironment } from './useEnvironment'\nimport { Component } from '../coreComponents'\n\nexport const EnvironmentContext = createContext<Environment>(Environment.create())\nEnvironmentContext.displayName = 'EnvironmentContext'\n\nexport interface EnvironmentMiddlewareProps {\n\tchildren: ReactNode\n\tcreate: (env: Environment) => Environment\n}\n\nexport const EnvironmentMiddleware = Component(\n\t({ children, create }: EnvironmentMiddlewareProps) => {\n\t\tconst env = useEnvironment()\n\t\treturn <EnvironmentContext.Provider value={create(env)}>{children}</EnvironmentContext.Provider>\n\t},\n\t{\n\t\tstaticRender: ({ children }) => {\n\t\t\treturn <>{children}</>\n\t\t},\n\t\tgenerateEnvironment: ({ create }, env) => {\n\t\t\treturn create(env)\n\t\t},\n\t},\n)\n\nexport interface EnvironmentWithExtensionProps<S, R> {\n\tchildren: ReactNode\n\textension: Environment.Extension<S, R>\n\tstate: S\n}\n\nexport const EnvironmentExtensionProvider: <S, R>(props: EnvironmentWithExtensionProps<S, R>) => ReactElement | null = Component(\n\t({ children, extension, state }) => {\n\t\tconst create = useCallback((env: Environment) => env.withExtension(extension, state), [extension, state])\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n\t({ children, extension, state }) => {\n\t\tconst create = (env: Environment) => env.withExtension(extension, state)\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n)\n"],"names":["_jsx"],"mappings":";;;;AAKO,MAAM,qBAAqB,cAA2B,YAAY,QAAQ;AACjF,mBAAmB,cAAc;AAO1B,MAAM,wBAAwB,UACpC,CAAC,EAAE,UAAU,aAAyC;AACrD,QAAM,MAAM;AACL,SAAAA,8BAAC,mBAAmB,UAAnB;AAAA,IAA4B,OAAO,OAAO,GAAG;AAAA,EAAA,GAAI,QAAS;AACnE,GACA;AAAA,EACC,cAAc,CAAC,EAAE,eAAe;AAC/B,yDAAU,QAAS;AAAA,EACpB;AAAA,EACA,qBAAqB,CAAC,EAAE,UAAU,QAAQ;AACzC,WAAO,OAAO,GAAG;AAAA,EAClB;AACD,CACD;AAQO,MAAM,+BAA0G,UACtH,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,QAAM,SAAS,YAAY,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;AACxG,SAAQA,8BAAA,uBAAA;AAAA,IAAsB;AAAA,EAAA,GAAiB,QAAS;AACzD,GACA,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,QAAM,SAAS,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK;AACvE,SAAQA,8BAAA,uBAAA;AAAA,IAAsB;AAAA,EAAA,GAAiB,QAAS;AACzD,CACD;;"}
|
|
@@ -2,10 +2,12 @@ import { useCallback } from "react";
|
|
|
2
2
|
import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
|
|
3
3
|
import { useEntityListSubTreeParameters } from "./useEntityListSubTreeParameters.js";
|
|
4
4
|
import { useGetEntityListSubTree } from "./useGetEntityListSubTree.js";
|
|
5
|
-
const useEntityListSubTree = (qualifiedEntityList) => {
|
|
5
|
+
const useEntityListSubTree = (qualifiedEntityList, ...treeId) => {
|
|
6
6
|
const getSubTree = useGetEntityListSubTree();
|
|
7
7
|
const parameters = useEntityListSubTreeParameters(qualifiedEntityList);
|
|
8
|
-
const
|
|
8
|
+
const hasTreeId = treeId.length > 0;
|
|
9
|
+
const treeIdVal = treeId[0];
|
|
10
|
+
const getAccessor = useCallback(() => getSubTree(parameters, ...hasTreeId ? [treeIdVal] : []), [getSubTree, hasTreeId, parameters, treeIdVal]);
|
|
9
11
|
return useAccessorUpdateSubscription(getAccessor);
|
|
10
12
|
};
|
|
11
13
|
export { useEntityListSubTree };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityListSubTree.js","sources":["../../../src/accessorPropagation/useEntityListSubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntityListSubTreeParameters } from './useEntityListSubTreeParameters'\nimport { useGetEntityListSubTree } from './useGetEntityListSubTree'\n\nexport const useEntityListSubTree = (\n\tqualifiedEntityList: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n): EntityListAccessor => {\n\tconst getSubTree = useGetEntityListSubTree()\n\tconst parameters = useEntityListSubTreeParameters(qualifiedEntityList)\n\tconst getAccessor = useCallback(() => getSubTree(parameters
|
|
1
|
+
{"version":3,"file":"useEntityListSubTree.js","sources":["../../../src/accessorPropagation/useEntityListSubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntityListSubTreeParameters } from './useEntityListSubTreeParameters'\nimport { useGetEntityListSubTree } from './useGetEntityListSubTree'\nimport { TreeRootId } from '../treeParameters'\n\nexport const useEntityListSubTree = (\n\tqualifiedEntityList: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t...treeId: [TreeRootId | undefined] | []\n): EntityListAccessor => {\n\tconst getSubTree = useGetEntityListSubTree()\n\tconst parameters = useEntityListSubTreeParameters(qualifiedEntityList)\n\tconst hasTreeId = treeId.length > 0\n\tconst treeIdVal = treeId[0]\n\tconst getAccessor = useCallback(\n\t\t() => getSubTree(parameters, ...(hasTreeId ? [treeIdVal] : [])),\n\t\t[getSubTree, hasTreeId, parameters, treeIdVal],\n\t)\n\n\t// if (typeof parameters !== 'string' && parameters.value.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntityListSubTree: cannot use hasOneRelationPath!`)\n\t// }\n\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAQa,MAAA,uBAAuB,CACnC,wBACG,WACqB;AACxB,QAAM,aAAa;AACb,QAAA,aAAa,+BAA+B,mBAAmB;AAC/D,QAAA,YAAY,OAAO,SAAS;AAClC,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,GAAI,YAAY,CAAC,SAAS,IAAI,CAAG,CAAA,GAC9D,CAAC,YAAY,WAAW,YAAY,SAAS,CAC9C;AAMA,SAAO,8BAA8B,WAAW;AACjD;;"}
|
|
@@ -2,10 +2,12 @@ import { useCallback } from "react";
|
|
|
2
2
|
import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
|
|
3
3
|
import { useEntitySubTreeParameters } from "./useEntitySubTreeParameters.js";
|
|
4
4
|
import { useGetEntitySubTree } from "./useGetEntitySubTree.js";
|
|
5
|
-
const useEntitySubTree = (qualifiedSingleEntity) => {
|
|
5
|
+
const useEntitySubTree = (qualifiedSingleEntity, ...treeId) => {
|
|
6
6
|
const getSubTree = useGetEntitySubTree();
|
|
7
7
|
const parameters = useEntitySubTreeParameters(qualifiedSingleEntity);
|
|
8
|
-
const
|
|
8
|
+
const hasTreeId = treeId.length > 0;
|
|
9
|
+
const treeIdVal = treeId[0];
|
|
10
|
+
const getAccessor = useCallback(() => getSubTree(parameters, ...hasTreeId ? [treeIdVal] : []), [getSubTree, hasTreeId, parameters, treeIdVal]);
|
|
9
11
|
return useAccessorUpdateSubscription(getAccessor);
|
|
10
12
|
};
|
|
11
13
|
export { useEntitySubTree };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntitySubTree.js","sources":["../../../src/accessorPropagation/useEntitySubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntitySubTreeParameters } from './useEntitySubTreeParameters'\nimport { useGetEntitySubTree } from './useGetEntitySubTree'\n\nexport const useEntitySubTree = (\n\tqualifiedSingleEntity: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n): EntityAccessor => {\n\tconst getSubTree = useGetEntitySubTree()\n\tconst parameters = useEntitySubTreeParameters(qualifiedSingleEntity)\n\tconst getAccessor = useCallback(() => getSubTree(parameters
|
|
1
|
+
{"version":3,"file":"useEntitySubTree.js","sources":["../../../src/accessorPropagation/useEntitySubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntitySubTreeParameters } from './useEntitySubTreeParameters'\nimport { useGetEntitySubTree } from './useGetEntitySubTree'\nimport { TreeRootId } from '../treeParameters'\n\nexport const useEntitySubTree = (\n\tqualifiedSingleEntity: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t...treeId: [TreeRootId | undefined] | []\n): EntityAccessor => {\n\tconst getSubTree = useGetEntitySubTree()\n\tconst parameters = useEntitySubTreeParameters(qualifiedSingleEntity)\n\tconst hasTreeId = treeId.length > 0\n\tconst treeIdVal = treeId[0]\n\tconst getAccessor = useCallback(\n\t\t() => getSubTree(parameters, ...(hasTreeId ? [treeIdVal] : [])),\n\t\t[getSubTree, hasTreeId, parameters, treeIdVal],\n\t)\n\n\t// if (typeof parameters !== 'string' && parameters.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntitySubTree: cannot use hasOneRelationPath!`)\n\t// }\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAQa,MAAA,mBAAmB,CAC/B,0BACG,WACiB;AACpB,QAAM,aAAa;AACb,QAAA,aAAa,2BAA2B,qBAAqB;AAC7D,QAAA,YAAY,OAAO,SAAS;AAClC,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,GAAI,YAAY,CAAC,SAAS,IAAI,CAAG,CAAA,GAC9D,CAAC,YAAY,WAAW,YAAY,SAAS,CAC9C;AAKA,SAAO,8BAA8B,WAAW;AACjD;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useAbortController, useIsMounted } from "@contember/react-utils";
|
|
3
|
+
import { useBindingOperations } from "./useBindingOperations.js";
|
|
4
|
+
import { useEnvironment } from "./useEnvironment.js";
|
|
5
|
+
import { DataBindingExtendAborted } from "../core/DataBinding.js";
|
|
6
|
+
const useExtendTree = () => {
|
|
7
|
+
const abort = useAbortController();
|
|
8
|
+
const { extendTree } = useBindingOperations();
|
|
9
|
+
const isMountedRef = useIsMounted();
|
|
10
|
+
const environment = useEnvironment();
|
|
11
|
+
return useCallback(async (newFragment, options) => {
|
|
12
|
+
try {
|
|
13
|
+
const newTreeRootId = await extendTree(newFragment, { environment, ...options, signal: abort() });
|
|
14
|
+
if (!isMountedRef.current) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return newTreeRootId;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e === DataBindingExtendAborted) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
}, [abort, environment, extendTree, isMountedRef]);
|
|
25
|
+
};
|
|
26
|
+
export { useExtendTree };
|
|
27
|
+
//# sourceMappingURL=useExtendTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExtendTree.js","sources":["../../../src/accessorPropagation/useExtendTree.ts"],"sourcesContent":["import { ReactNode, useCallback } from 'react'\nimport { useAbortController, useIsMounted } from '@contember/react-utils'\nimport { useBindingOperations } from './useBindingOperations'\nimport { TreeRootId } from '../treeParameters'\nimport { ExtendTreeOptions } from '../accessors'\nimport { DataBindingExtendAborted } from '../core'\nimport { useEnvironment } from './useEnvironment'\n\nexport const useExtendTree = () => {\n\tconst abort = useAbortController()\n\tconst { extendTree } = useBindingOperations()\n\tconst isMountedRef = useIsMounted()\n\tconst environment = useEnvironment()\n\treturn useCallback(async (newFragment: ReactNode, options?: Omit<ExtendTreeOptions, 'signal'>): Promise<TreeRootId | undefined> => {\n\t\ttry {\n\t\t\tconst newTreeRootId = await extendTree(newFragment,\n\t\t\t\t{ environment, ...options, signal: abort() },\n\t\t\t)\n\t\t\tif (!isMountedRef.current) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn newTreeRootId\n\t\t} catch (e) {\n\t\t\tif (e === DataBindingExtendAborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}, [abort, environment, extendTree, isMountedRef])\n}\n"],"names":[],"mappings":";;;;;AAQO,MAAM,gBAAgB,MAAM;AAClC,QAAM,QAAQ;AACR,QAAA,EAAE,eAAe;AACvB,QAAM,eAAe;AACrB,QAAM,cAAc;AACb,SAAA,YAAY,OAAO,aAAwB,YAAiF;AAC9H,QAAA;AACG,YAAA,gBAAgB,MAAM,WAAW,aACtC,EAAE,gBAAgB,SAAS,QAAQ,MAAM,EAAA,CAC1C;AACI,UAAA,CAAC,aAAa,SAAS;AAC1B;AAAA,MACD;AACO,aAAA;AAAA,aACC;AACR,UAAI,MAAM,0BAA0B;AACnC;AAAA,MACD;AACM,YAAA;AAAA,IACP;AAAA,KACE,CAAC,OAAO,aAAa,YAAY,YAAY,CAAC;AAClD;;"}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
+
import { AccessorTreeStateContext } from "./AccessorTreeStateContext.js";
|
|
2
3
|
import { DirtinessContext } from "./DirtinessContext.js";
|
|
3
4
|
import { MutationStateContext } from "./MutationStateContext.js";
|
|
5
|
+
import { EnvironmentContext } from "../accessorPropagation/EnvironmentContext.js";
|
|
4
6
|
import { BindingOperationsProvider } from "../accessorPropagation/BindingOperationsProvider.js";
|
|
5
7
|
function AccessorTree({ state, children }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value:
|
|
8
|
+
const stateData = state.name === "initialized" ? state.data : {
|
|
9
|
+
hasUnpersistedChanges: false,
|
|
10
|
+
isMutating: false,
|
|
11
|
+
bindingOperations: void 0
|
|
12
|
+
};
|
|
13
|
+
return /* @__PURE__ */ createElement(EnvironmentContext.Provider, {
|
|
14
|
+
value: state.environment
|
|
15
|
+
}, /* @__PURE__ */ createElement(AccessorTreeStateContext.Provider, {
|
|
16
|
+
value: state
|
|
17
|
+
}, /* @__PURE__ */ createElement(DirtinessContext.Provider, {
|
|
18
|
+
value: stateData.hasUnpersistedChanges
|
|
17
19
|
}, /* @__PURE__ */ createElement(MutationStateContext.Provider, {
|
|
18
|
-
value:
|
|
20
|
+
value: stateData.isMutating
|
|
19
21
|
}, /* @__PURE__ */ createElement(BindingOperationsProvider, {
|
|
20
|
-
bindingOperations:
|
|
21
|
-
}, children)));
|
|
22
|
+
bindingOperations: stateData.bindingOperations
|
|
23
|
+
}, children)))));
|
|
22
24
|
}
|
|
23
25
|
AccessorTree.displayName = "AccessorTree";
|
|
24
26
|
export { AccessorTree };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessorTree.js","sources":["../../../src/accessorTree/AccessorTree.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingOperationsProvider } from '../accessorPropagation'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport { DirtinessContext } from './DirtinessContext'\nimport { MutationStateContext } from './MutationStateContext'\n\nexport interface AccessorTreeProps {\n\tstate: AccessorTreeState\n\tchildren: ReactNode\n}\n\nexport function AccessorTree({ state, children }: AccessorTreeProps) {\n\
|
|
1
|
+
{"version":3,"file":"AccessorTree.js","sources":["../../../src/accessorTree/AccessorTree.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingOperationsProvider, EnvironmentContext } from '../accessorPropagation'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport { AccessorTreeStateContext } from './AccessorTreeStateContext'\nimport { DirtinessContext } from './DirtinessContext'\nimport { MutationStateContext } from './MutationStateContext'\n\nexport interface AccessorTreeProps {\n\tstate: AccessorTreeState\n\tchildren: ReactNode\n}\n\nexport function AccessorTree({ state, children }: AccessorTreeProps) {\n\tconst stateData = state.name === 'initialized' ? state.data : {\n\t\thasUnpersistedChanges: false,\n\t\tisMutating: false,\n\t\tbindingOperations: undefined,\n\t}\n\treturn (\n\t\t<EnvironmentContext.Provider value={state.environment}>\n\t\t\t<AccessorTreeStateContext.Provider value={state}>\n\t\t\t\t<DirtinessContext.Provider value={stateData.hasUnpersistedChanges}>\n\t\t\t\t\t<MutationStateContext.Provider value={stateData.isMutating}>\n\t\t\t\t\t\t<BindingOperationsProvider bindingOperations={stateData.bindingOperations}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</BindingOperationsProvider>\n\t\t\t\t\t</MutationStateContext.Provider>\n\t\t\t\t</DirtinessContext.Provider>\n\t\t\t</AccessorTreeStateContext.Provider>\n\t\t</EnvironmentContext.Provider>\n\t)\n}\n\nAccessorTree.displayName = 'AccessorTree'\n"],"names":["_jsx"],"mappings":";;;;;;AAY6B,sBAAA,EAAE,OAAO,YAA+B;AACpE,QAAM,YAAY,MAAM,SAAS,gBAAgB,MAAM,OAAO;AAAA,IAC7D,uBAAuB;AAAA,IACvB,YAAY;AAAA,IACZ,mBAAmB;AAAA,EAAA;AAGnB,SAAAA,8BAAC,mBAAmB,UAAnB;AAAA,IAA4B,OAAO,MAAM;AAAA,EAAA,GACzCA,8BAAC,yBAAyB,UAAzB;AAAA,IAAkC,OAAO;AAAA,EAAA,GACzCA,8BAAC,iBAAiB,UAAjB;AAAA,IAA0B,OAAO,UAAU;AAAA,EAAA,GAC3CA,8BAAC,qBAAqB,UAArB;AAAA,IAA8B,OAAO,UAAU;AAAA,EAAA,GAC9CA,8BAAA,2BAAA;AAAA,IAA0B,mBAAmB,UAAU;AAAA,EAAA,GACtD,QACF,CACD,CACD,CACD,CACD;AAEF;AAEA,aAAa,cAAc;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessorTreeStateContext.js","sources":["../../../src/accessorTree/AccessorTreeStateContext.ts"],"sourcesContent":["import { createContext } from 'react'\nimport { AccessorTreeState } from './AccessorTreeState'\n\nexport const AccessorTreeStateContext = createContext<AccessorTreeState | undefined>(undefined)\n"],"names":[],"mappings":";AAGa,MAAA,2BAA2B,cAA6C,MAAS;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NormalizedPersistedData.js","sources":["../../../src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId,
|
|
1
|
+
{"version":3,"file":"NormalizedPersistedData.js","sources":["../../../src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '../treeParameters'\nimport type { ServerId, UniqueEntityId } from './RuntimeId'\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 EntityFieldPersistedData = FieldValue | ServerId | EntityListPersistedData\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":"AAiBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
|
|
@@ -5,13 +5,20 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import { generateEnumerabilityPreventingEntropy } from "../utils/generateEnumerabilityPreventingEntropy.js";
|
|
8
|
-
class
|
|
9
|
-
constructor(value) {
|
|
8
|
+
class ServerId {
|
|
9
|
+
constructor(value, entityName) {
|
|
10
10
|
this.value = value;
|
|
11
|
+
this.entityName = entityName;
|
|
11
12
|
}
|
|
12
13
|
get existsOnServer() {
|
|
13
14
|
return true;
|
|
14
15
|
}
|
|
16
|
+
get uniqueValue() {
|
|
17
|
+
return ServerId.formatUniqueValue(this.value, this.entityName);
|
|
18
|
+
}
|
|
19
|
+
static formatUniqueValue(id, entityName) {
|
|
20
|
+
return `${entityName}_${id}`;
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
class ClientGeneratedUuid {
|
|
17
24
|
constructor(value) {
|
|
@@ -20,6 +27,9 @@ class ClientGeneratedUuid {
|
|
|
20
27
|
get existsOnServer() {
|
|
21
28
|
return false;
|
|
22
29
|
}
|
|
30
|
+
get uniqueValue() {
|
|
31
|
+
return this.value;
|
|
32
|
+
}
|
|
23
33
|
}
|
|
24
34
|
const _UnpersistedEntityDummyId = class {
|
|
25
35
|
constructor() {
|
|
@@ -31,7 +41,10 @@ const _UnpersistedEntityDummyId = class {
|
|
|
31
41
|
return false;
|
|
32
42
|
}
|
|
33
43
|
static matchesDummyId(candidate) {
|
|
34
|
-
return _UnpersistedEntityDummyId.dummyIdRegex.test(candidate);
|
|
44
|
+
return typeof candidate === "string" && _UnpersistedEntityDummyId.dummyIdRegex.test(candidate);
|
|
45
|
+
}
|
|
46
|
+
get uniqueValue() {
|
|
47
|
+
return this.value;
|
|
35
48
|
}
|
|
36
49
|
};
|
|
37
50
|
let UnpersistedEntityDummyId = _UnpersistedEntityDummyId;
|
|
@@ -41,5 +54,5 @@ __publicField(UnpersistedEntityDummyId, "getNextSeed", (() => {
|
|
|
41
54
|
})());
|
|
42
55
|
__publicField(UnpersistedEntityDummyId, "entropyLength", 5);
|
|
43
56
|
__publicField(UnpersistedEntityDummyId, "dummyIdRegex", new RegExp(`^adminOnlyDummyId-\\d{${_UnpersistedEntityDummyId.entropyLength}}-\\d+$`));
|
|
44
|
-
export { ClientGeneratedUuid,
|
|
57
|
+
export { ClientGeneratedUuid, ServerId, UnpersistedEntityDummyId };
|
|
45
58
|
//# sourceMappingURL=RuntimeId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeId.js","sources":["../../../src/accessorTree/RuntimeId.ts"],"sourcesContent":["import { generateEnumerabilityPreventingEntropy } from '../utils'\n\nexport interface RuntimeIdSpec {\n\texistsOnServer: boolean\n\tvalue:
|
|
1
|
+
{"version":3,"file":"RuntimeId.js","sources":["../../../src/accessorTree/RuntimeId.ts"],"sourcesContent":["import { generateEnumerabilityPreventingEntropy } from '../utils'\nimport { EntityId } from '../treeParameters'\n\nexport type UniqueEntityId = string & { __type: 'UniqueEntityId' }\n\nexport interface RuntimeIdSpec {\n\texistsOnServer: boolean\n\tvalue: EntityId\n\tuniqueValue: UniqueEntityId\n}\n\nexport class ServerId implements RuntimeIdSpec {\n\tpublic get existsOnServer(): true {\n\t\treturn true\n\t}\n\tpublic constructor(public readonly value: EntityId, public readonly entityName: string) {\n\t}\n\n\tget uniqueValue() {\n\t\treturn ServerId.formatUniqueValue(this.value, this.entityName)\n\t}\n\n\tstatic formatUniqueValue(id: EntityId, entityName: string): UniqueEntityId {\n\t\treturn `${entityName}_${id}` as UniqueEntityId\n\t}\n}\n\nexport class ClientGeneratedUuid implements RuntimeIdSpec {\n\tpublic get existsOnServer(): false {\n\t\treturn false\n\t}\n\tpublic constructor(public readonly value: string) {}\n\n\tget uniqueValue() {\n\t\treturn this.value as UniqueEntityId\n\t}\n}\n\nexport class UnpersistedEntityDummyId implements RuntimeIdSpec {\n\tpublic get existsOnServer(): false {\n\t\treturn false\n\t}\n\tpublic readonly value: string\n\n\tprivate static getNextSeed = (() => {\n\t\tlet seed = 0\n\t\treturn () => seed++\n\t})()\n\n\tpublic constructor() {\n\t\tconst enumerabilityPreventingEntropy = generateEnumerabilityPreventingEntropy(\n\t\t\tUnpersistedEntityDummyId.entropyLength,\n\t\t)\n\n\t\t// KEEP THIS IN SYNC WITH THE REGEX BELOW!!!\n\t\tthis.value = `adminOnlyDummyId-${enumerabilityPreventingEntropy}-${UnpersistedEntityDummyId.getNextSeed()}`\n\t}\n\n\tprivate static entropyLength = 5\n\tprivate static dummyIdRegex = new RegExp(`^adminOnlyDummyId-\\\\d{${UnpersistedEntityDummyId.entropyLength}}-\\\\d+$`)\n\tpublic static matchesDummyId(candidate: EntityId): boolean {\n\t\treturn typeof candidate === 'string' && UnpersistedEntityDummyId.dummyIdRegex.test(candidate)\n\t}\n\n\tget uniqueValue() {\n\t\treturn this.value as UniqueEntityId\n\t}\n}\n\nexport type RuntimeId = ServerId | ClientGeneratedUuid | UnpersistedEntityDummyId\n"],"names":[],"mappings":";;;;;;;AAWO,MAAM,SAAkC;AAAA,EAIvC,YAA4B,OAAiC,YAAoB;AAArD,SAAA,QAAA;AAAiC,SAAA,aAAA;AAAA,EACpE;AAAA,MAJW,iBAAuB;AAC1B,WAAA;AAAA,EACR;AAAA,MAII,cAAc;AACjB,WAAO,SAAS,kBAAkB,KAAK,OAAO,KAAK,UAAU;AAAA,EAC9D;AAAA,SAEO,kBAAkB,IAAc,YAAoC;AAC1E,WAAO,GAAG,cAAc;AAAA,EACzB;AACD;AAEO,MAAM,oBAA6C;AAAA,EAIlD,YAA4B,OAAe;AAAf,SAAA,QAAA;AAAA,EAAgB;AAAA,MAHxC,iBAAwB;AAC3B,WAAA;AAAA,EACR;AAAA,MAGI,cAAc;AACjB,WAAO,KAAK;AAAA,EACb;AACD;AAEO,wCAAwD;AAAA,EAWvD,cAAc;AAPL;AAQT,UAAA,iCAAiC,uCACtC,0BAAyB,aAC1B;AAGA,SAAK,QAAQ,oBAAoB,kCAAkC,0BAAyB,YAAY;AAAA,EACzG;AAAA,MAjBW,iBAAwB;AAC3B,WAAA;AAAA,EACR;AAAA,SAmBc,eAAe,WAA8B;AAC1D,WAAO,OAAO,cAAc,YAAY,0BAAyB,aAAa,KAAK,SAAS;AAAA,EAC7F;AAAA,MAEI,cAAc;AACjB,WAAO,KAAK;AAAA,EACb;AACD;AA7BO;AAMS,cANT,0BAMS,eAAqB,OAAA;AACnC,MAAI,OAAO;AACX,SAAO,MAAM;AAAA;AAYC,cApBT,0BAoBS,iBAAgB;AAChB,cArBT,0BAqBS,gBAAe,IAAI,OAAO,yBAAyB,0BAAyB,sBAAsB;;"}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
const accessorTreeStateReducer = (previousState, action) => {
|
|
2
2
|
switch (action.type) {
|
|
3
3
|
case "setData":
|
|
4
|
-
if (previousState.name === "error") {
|
|
4
|
+
if (previousState.name === "error" || previousState.binding !== action.binding) {
|
|
5
5
|
return previousState;
|
|
6
6
|
}
|
|
7
7
|
return {
|
|
8
8
|
name: "initialized",
|
|
9
|
+
environment: previousState.environment,
|
|
10
|
+
binding: previousState.binding,
|
|
9
11
|
data: action.data
|
|
10
12
|
};
|
|
11
13
|
case "failWithError":
|
|
14
|
+
if (previousState.binding !== action.binding) {
|
|
15
|
+
return previousState;
|
|
16
|
+
}
|
|
12
17
|
return {
|
|
13
18
|
name: "error",
|
|
19
|
+
environment: previousState.environment,
|
|
20
|
+
binding: previousState.binding,
|
|
14
21
|
error: action.error
|
|
15
22
|
};
|
|
16
23
|
case "reset":
|
|
17
24
|
return {
|
|
18
|
-
name: "initializing"
|
|
25
|
+
name: "initializing",
|
|
26
|
+
environment: action.environment,
|
|
27
|
+
binding: action.binding
|
|
19
28
|
};
|
|
20
29
|
}
|
|
21
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessorTreeStateReducer.js","sources":["../../../src/accessorTree/accessorTreeStateReducer.ts"],"sourcesContent":["import type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateAction } from './AccessorTreeStateAction'\n\nexport const accessorTreeStateReducer = (\n\tpreviousState: AccessorTreeState,\n\taction: AccessorTreeStateAction,\n): AccessorTreeState => {\n\tswitch (action.type) {\n\t\tcase 'setData':\n\t\t\tif (previousState.name === 'error') {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'initialized',\n\t\t\t\tdata: action.data,\n\t\t\t}\n\t\tcase 'failWithError':\n\t\t\treturn {\n\t\t\t\tname: 'error',\n\t\t\t\terror: action.error,\n\t\t\t}\n\t\tcase 'reset':\n\t\t\treturn {\n\t\t\t\tname: 'initializing',\n\t\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGa,MAAA,2BAA2B,CACvC,eACA,WACuB;AACvB,UAAQ,OAAO;AAAA,SACT;
|
|
1
|
+
{"version":3,"file":"accessorTreeStateReducer.js","sources":["../../../src/accessorTree/accessorTreeStateReducer.ts"],"sourcesContent":["import type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateAction } from './AccessorTreeStateAction'\n\nexport const accessorTreeStateReducer = (\n\tpreviousState: AccessorTreeState,\n\taction: AccessorTreeStateAction,\n): AccessorTreeState => {\n\tswitch (action.type) {\n\t\tcase 'setData':\n\t\t\tif (previousState.name === 'error' || previousState.binding !== action.binding) {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'initialized',\n\t\t\t\tenvironment: previousState.environment,\n\t\t\t\tbinding: previousState.binding,\n\t\t\t\tdata: action.data,\n\t\t\t}\n\t\tcase 'failWithError':\n\t\t\tif (previousState.binding !== action.binding) {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'error',\n\t\t\t\tenvironment: previousState.environment,\n\t\t\t\tbinding: previousState.binding,\n\t\t\t\terror: action.error,\n\t\t\t}\n\t\tcase 'reset':\n\t\t\treturn {\n\t\t\t\tname: 'initializing',\n\t\t\t\tenvironment: action.environment,\n\t\t\t\tbinding: action.binding,\n\t\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGa,MAAA,2BAA2B,CACvC,eACA,WACuB;AACvB,UAAQ,OAAO;AAAA,SACT;AACJ,UAAI,cAAc,SAAS,WAAW,cAAc,YAAY,OAAO,SAAS;AACxE,eAAA;AAAA,MACR;AACO,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,cAAc;AAAA,QAC3B,SAAS,cAAc;AAAA,QACvB,MAAM,OAAO;AAAA,MAAA;AAAA,SAEV;AACA,UAAA,cAAc,YAAY,OAAO,SAAS;AACtC,eAAA;AAAA,MACR;AACO,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,cAAc;AAAA,QAC3B,SAAS,cAAc;AAAA,QACvB,OAAO,OAAO;AAAA,MAAA;AAAA,SAEX;AACG,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,OAAO;AAAA,QACpB,SAAS,OAAO;AAAA,MAAA;AAAA;AAGpB;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { AccessorTreeStateContext } from "./AccessorTreeStateContext.js";
|
|
3
|
+
import { BindingError } from "../BindingError.js";
|
|
4
|
+
const useAccessorTreeState = () => {
|
|
5
|
+
const state = useContext(AccessorTreeStateContext);
|
|
6
|
+
if (!state) {
|
|
7
|
+
throw new BindingError();
|
|
8
|
+
}
|
|
9
|
+
return state;
|
|
10
|
+
};
|
|
11
|
+
export { useAccessorTreeState };
|
|
12
|
+
//# sourceMappingURL=useAccessorTreeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccessorTreeState.js","sources":["../../../src/accessorTree/useAccessorTreeState.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { AccessorTreeStateContext } from './AccessorTreeStateContext'\nimport { BindingError } from '../BindingError'\n\nexport const useAccessorTreeState = () => {\n\tconst state = useContext(AccessorTreeStateContext)\n\tif (!state) {\n\t\tthrow new BindingError()\n\t}\n\treturn state\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,uBAAuB,MAAM;AACnC,QAAA,QAAQ,WAAW,wBAAwB;AACjD,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,aAAa;AAAA,EACxB;AACO,SAAA;AACR;;"}
|
|
@@ -1,71 +1,61 @@
|
|
|
1
1
|
import { useCurrentContentGraphQlClient, useCurrentSystemGraphQlClient, useTenantGraphQlClient } from "@contember/react-client";
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useState, useCallback, useReducer, useEffect } from "react";
|
|
3
3
|
import { accessorTreeStateReducer } from "./accessorTreeStateReducer.js";
|
|
4
|
+
import { TreeStore } from "../core/TreeStore.js";
|
|
5
|
+
import { useIsMounted } from "@contember/react-utils";
|
|
4
6
|
import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
|
|
5
7
|
import { DataBinding } from "../core/DataBinding.js";
|
|
6
|
-
|
|
7
|
-
name: "initializing"
|
|
8
|
-
};
|
|
8
|
+
import { SchemaLoader } from "../core/schema/SchemaLoader.js";
|
|
9
9
|
const useDataBinding = ({
|
|
10
10
|
nodeTree,
|
|
11
|
-
refreshOnEnvironmentChange = true,
|
|
12
11
|
refreshOnPersist = false
|
|
13
12
|
}) => {
|
|
14
13
|
const contentClient = useCurrentContentGraphQlClient();
|
|
15
14
|
const systemClient = useCurrentSystemGraphQlClient();
|
|
16
15
|
const tenantClient = useTenantGraphQlClient();
|
|
17
16
|
const environment = useEnvironment();
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
dispatch({
|
|
26
|
-
type: "setData",
|
|
27
|
-
data: accessor
|
|
28
|
-
});
|
|
29
|
-
}, []);
|
|
30
|
-
const onError = useCallback((error) => {
|
|
31
|
-
if (!isMountedRef.current) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
dispatch({
|
|
35
|
-
type: "failWithError",
|
|
36
|
-
error
|
|
37
|
-
});
|
|
38
|
-
}, []);
|
|
39
|
-
const createDataBinding = useCallback(() => {
|
|
40
|
-
const create = () => new DataBinding(contentClient, systemClient, tenantClient, environment, onUpdate, onError, () => {
|
|
41
|
-
if (!isMountedRef.current || !refreshOnPersist) {
|
|
42
|
-
return;
|
|
17
|
+
const currentTreeStore = useRef();
|
|
18
|
+
const isMountedRef = useIsMounted();
|
|
19
|
+
const [schema, setSchema] = useState();
|
|
20
|
+
const resetDataBinding = useCallback((environment2, newStore) => {
|
|
21
|
+
const onUpdate = (data, binding2) => {
|
|
22
|
+
if (isMountedRef.current) {
|
|
23
|
+
dispatch({ type: "setData", data, binding: binding2 });
|
|
43
24
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
};
|
|
26
|
+
const onError = (error, binding2) => {
|
|
27
|
+
if (isMountedRef.current) {
|
|
28
|
+
dispatch({ type: "failWithError", error, binding: binding2 });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const onPersistSuccess = () => {
|
|
32
|
+
if (isMountedRef.current && refreshOnPersist) {
|
|
33
|
+
resetDataBinding(environment2, true);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
if (currentTreeStore.current === void 0 || newStore) {
|
|
37
|
+
currentTreeStore.current = new TreeStore(environment2.getSchema());
|
|
53
38
|
}
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
const binding = new DataBinding(contentClient, systemClient, tenantClient, currentTreeStore.current, environment2, onUpdate, onError, onPersistSuccess);
|
|
40
|
+
dispatch({ type: "reset", binding, environment: environment2 });
|
|
41
|
+
}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist]);
|
|
42
|
+
const [state, dispatch] = useReducer(accessorTreeStateReducer, {
|
|
43
|
+
name: "initializing",
|
|
44
|
+
environment
|
|
45
|
+
});
|
|
56
46
|
useEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
(async () => {
|
|
48
|
+
setSchema(await SchemaLoader.loadSchema(contentClient));
|
|
49
|
+
})();
|
|
50
|
+
}, [contentClient]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (schema) {
|
|
53
|
+
resetDataBinding(environment.withSchema(schema), false);
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
setDataBinding(createDataBinding());
|
|
62
|
-
}, [createDataBinding, refreshOnEnvironmentChange]);
|
|
55
|
+
}, [resetDataBinding, schema, environment]);
|
|
63
56
|
useEffect(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
isMountedRef.current = false;
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
57
|
+
state.binding?.extendTree(nodeTree);
|
|
58
|
+
}, [nodeTree, state.binding]);
|
|
69
59
|
return state;
|
|
70
60
|
};
|
|
71
61
|
export { useDataBinding };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataBinding.js","sources":["../../../src/accessorTree/useDataBinding.ts"],"sourcesContent":["import {\n\tuseCurrentContentGraphQlClient,\n\tuseCurrentSystemGraphQlClient,\n\tuseTenantGraphQlClient,\n} from '@contember/react-client'\nimport { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { TreeRootAccessor } from '../accessors'\nimport { DataBinding } from '../core'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'\nimport { accessorTreeStateReducer } from './accessorTreeStateReducer'\nimport type { RequestError } from './RequestError'\
|
|
1
|
+
{"version":3,"file":"useDataBinding.js","sources":["../../../src/accessorTree/useDataBinding.ts"],"sourcesContent":["import {\n\tuseCurrentContentGraphQlClient,\n\tuseCurrentSystemGraphQlClient,\n\tuseTenantGraphQlClient,\n} from '@contember/react-client'\nimport { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { TreeRootAccessor } from '../accessors'\nimport { DataBinding } from '../core'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'\nimport { accessorTreeStateReducer } from './accessorTreeStateReducer'\nimport type { RequestError } from './RequestError'\nimport { Environment } from '../dao'\nimport { Schema, SchemaLoader } from '../core/schema'\nimport { TreeStore } from '../core/TreeStore'\nimport { useIsMounted } from '@contember/react-utils'\n\nexport const useDataBinding = ({\n\tnodeTree,\n\trefreshOnPersist = false,\n}: AccessorTreeStateOptions): AccessorTreeState => {\n\tconst contentClient = useCurrentContentGraphQlClient()\n\tconst systemClient = useCurrentSystemGraphQlClient()\n\tconst tenantClient = useTenantGraphQlClient()\n\tconst environment = useEnvironment()\n\tconst currentTreeStore = useRef<TreeStore>()\n\tconst isMountedRef = useIsMounted()\n\tconst [schema, setSchema] = useState<Schema>()\n\n\tconst resetDataBinding = useCallback((environment: Environment, newStore: boolean) => {\n\t\tconst onUpdate = (data: TreeRootAccessor, binding: DataBinding) => {\n\t\t\tif (isMountedRef.current) {\n\t\t\t\tdispatch({ type: 'setData', data, binding })\n\t\t\t}\n\t\t}\n\n\t\tconst onError = (error: RequestError, binding: DataBinding) => {\n\t\t\tif (isMountedRef.current) {\n\t\t\t\tdispatch({ type: 'failWithError', error, binding })\n\t\t\t}\n\t\t}\n\n\t\tconst onPersistSuccess = () => {\n\t\t\tif (isMountedRef.current && refreshOnPersist) {\n\t\t\t\tresetDataBinding(environment, true)\n\t\t\t}\n\t\t}\n\n\t\tif (currentTreeStore.current === undefined || newStore) {\n\t\t\tcurrentTreeStore.current = new TreeStore(environment.getSchema())\n\t\t}\n\n\t\tconst binding = new DataBinding(contentClient, systemClient, tenantClient, currentTreeStore.current, environment, onUpdate, onError, onPersistSuccess)\n\t\tdispatch({ type: 'reset', binding, environment })\n\t}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist])\n\n\tconst [state, dispatch] = useReducer(accessorTreeStateReducer, {\n\t\tname: 'initializing',\n\t\tenvironment,\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tsetSchema(await SchemaLoader.loadSchema(contentClient))\n\t\t})()\n\t}, [contentClient])\n\n\tuseEffect(() => {\n\t\tif (schema) {\n\t\t\tresetDataBinding(environment.withSchema(schema), false)\n\t\t}\n\t}, [resetDataBinding, schema, environment])\n\n\tuseEffect(() => {\n\t\tstate.binding?.extendTree(nodeTree)\n\t}, [nodeTree, state.binding])\n\n\treturn state\n}\n"],"names":[],"mappings":";;;;;;;;AAkBO,MAAM,iBAAiB,CAAC;AAAA,EAC9B;AAAA,EACA,mBAAmB;AAAA,MAC+B;AAClD,QAAM,gBAAgB;AACtB,QAAM,eAAe;AACrB,QAAM,eAAe;AACrB,QAAM,cAAc;AACpB,QAAM,mBAAmB;AACzB,QAAM,eAAe;AACf,QAAA,CAAC,QAAQ,aAAa,SAAiB;AAE7C,QAAM,mBAAmB,YAAY,CAAC,cAA0B,aAAsB;AAC/E,UAAA,WAAW,CAAC,MAAwB,aAAyB;AAClE,UAAI,aAAa,SAAS;AACzB,iBAAS,EAAE,MAAM,WAAW,MAAM,mBAAS;AAAA,MAC5C;AAAA,IAAA;AAGK,UAAA,UAAU,CAAC,OAAqB,aAAyB;AAC9D,UAAI,aAAa,SAAS;AACzB,iBAAS,EAAE,MAAM,iBAAiB,OAAO,mBAAS;AAAA,MACnD;AAAA,IAAA;AAGD,UAAM,mBAAmB,MAAM;AAC1B,UAAA,aAAa,WAAW,kBAAkB;AAC7C,yBAAiB,cAAa,IAAI;AAAA,MACnC;AAAA,IAAA;AAGG,QAAA,iBAAiB,YAAY,UAAa,UAAU;AACvD,uBAAiB,UAAU,IAAI,UAAU,aAAY,UAAW,CAAA;AAAA,IACjE;AAEM,UAAA,UAAU,IAAI,YAAY,eAAe,cAAc,cAAc,iBAAiB,SAAS,cAAa,UAAU,SAAS,gBAAgB;AACrJ,aAAS,EAAE,MAAM,SAAS,SAAS,2BAAa;AAAA,EAAA,GAC9C,CAAC,eAAe,cAAc,cAAc,cAAc,gBAAgB,CAAC;AAE9E,QAAM,CAAC,OAAO,YAAY,WAAW,0BAA0B;AAAA,IAC9D,MAAM;AAAA,IACN;AAAA,EAAA,CACA;AAED,YAAU,MAAM;AACd,IAAY,aAAA;AACZ,gBAAU,MAAM,aAAa,WAAW,aAAa,CAAC;AAAA,IAAA;EACpD,GACD,CAAC,aAAa,CAAC;AAElB,YAAU,MAAM;AACf,QAAI,QAAQ;AACX,uBAAiB,YAAY,WAAW,MAAM,GAAG,KAAK;AAAA,IACvD;AAAA,EACE,GAAA,CAAC,kBAAkB,QAAQ,WAAW,CAAC;AAE1C,YAAU,MAAM;AACT,UAAA,SAAS,WAAW,QAAQ;AAAA,EAChC,GAAA,CAAC,UAAU,MAAM,OAAO,CAAC;AAErB,SAAA;AACR;;"}
|
|
@@ -2,7 +2,6 @@ import { BindingError } from "../BindingError.js";
|
|
|
2
2
|
import { ErrorAccessor } from "./ErrorAccessor.js";
|
|
3
3
|
import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
|
|
4
4
|
import { PlaceholderGenerator } from "../markers/PlaceholderGenerator.js";
|
|
5
|
-
import { ServerGeneratedUuid } from "../accessorTree/RuntimeId.js";
|
|
6
5
|
class EntityAccessor {
|
|
7
6
|
constructor(stateKey, operations, runtimeId, key, name, fieldData, dataFromServer, hasUnpersistedChanges, errors, environment, getAccessor) {
|
|
8
7
|
this.stateKey = stateKey;
|
|
@@ -61,18 +60,6 @@ class EntityAccessor {
|
|
|
61
60
|
getEntityList(entityList) {
|
|
62
61
|
return this.getRelativeEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment));
|
|
63
62
|
}
|
|
64
|
-
getKeyConnectedOnServer(entity) {
|
|
65
|
-
const desugared = QueryLanguage.desugarRelativeSingleEntity(entity, this.environment);
|
|
66
|
-
const lastHasOne = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1];
|
|
67
|
-
const lastHasOnePlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(lastHasOne);
|
|
68
|
-
let containingAccessor = this;
|
|
69
|
-
if (desugared.hasOneRelationPath.length > 1) {
|
|
70
|
-
containingAccessor = this.getRelativeSingleEntity({
|
|
71
|
-
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1)
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return containingAccessor.getPersistedKeyByPlaceholder(lastHasOnePlaceholder);
|
|
75
|
-
}
|
|
76
63
|
getRelativeSingleField(field) {
|
|
77
64
|
return this.getRelativeSingleEntity(field).getAccessorByPlaceholder(PlaceholderGenerator.getFieldPlaceholder(field.field));
|
|
78
65
|
}
|
|
@@ -99,25 +86,6 @@ For more information, please consult the documentation.
|
|
|
99
86
|
}
|
|
100
87
|
return record.getAccessor();
|
|
101
88
|
}
|
|
102
|
-
getPersistedKeyByPlaceholder(placeholderName) {
|
|
103
|
-
if (this.dataFromServer === void 0) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const key = this.dataFromServer.get(placeholderName);
|
|
107
|
-
if (key instanceof ServerGeneratedUuid) {
|
|
108
|
-
return key.value;
|
|
109
|
-
}
|
|
110
|
-
if (key === null) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
if (key === void 0) {
|
|
114
|
-
throw new BindingError(`EntityAccessor.getKeyConnectedOnServer: unknown placeholder '${placeholderName}'. Unless this is just a typo, this typically happens when a has-one relation hasn't been registered during static render.`);
|
|
115
|
-
}
|
|
116
|
-
if (key instanceof Set) {
|
|
117
|
-
throw new BindingError(`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a has-many relation, not a has-one. This method is meant exclusively for has-one relations.`);
|
|
118
|
-
}
|
|
119
|
-
throw new BindingError(`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a scalar field, not ahas-one relation. This method is meant exclusively for has-one relations.`);
|
|
120
|
-
}
|
|
121
89
|
}
|
|
122
90
|
export { EntityAccessor };
|
|
123
91
|
//# sourceMappingURL=EntityAccessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityAccessor.js","sources":["../../../src/accessors/EntityAccessor.ts"],"sourcesContent":["import { RuntimeId, ServerGeneratedUuid, SingleEntityPersistedData } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { EntityOperations } from '../core/operations'\nimport type { Environment } from '../dao'\nimport { PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tFieldValue,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n} from '../treeParameters'\nimport type { AsyncBatchUpdatesOptions } from './AsyncBatchUpdatesOptions'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { EntityListAccessor } from './EntityListAccessor'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { FieldAccessor } from './FieldAccessor'\nimport type { PersistErrorOptions } from './PersistErrorOptions'\nimport type { PersistSuccessOptions } from './PersistSuccessOptions'\nimport type { EntityRealmState } from '../core/state'\n\nclass EntityAccessor implements Errorable {\n\tpublic constructor(\n\t\tprivate readonly stateKey: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\tpublic readonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {}\n\n\tpublic get idOnServer(): string | 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\tpublic get id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tpublic get existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.stateKey, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<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.stateKey, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.stateKey, performUpdates)\n\t}\n\n\tpublic connectEntityAtField(field: FieldName, entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntityAtField(this.stateKey, field, entityToConnect)\n\t}\n\n\tpublic disconnectEntityAtField(field: FieldName, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.disconnectEntityAtField(this.stateKey, field, initializeReplacement)\n\t}\n\n\tpublic deleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.stateKey)\n\t}\n\n\t//\n\n\tpublic updateValues(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\tpublic getField<Value extends FieldValue = FieldValue>(\n\t\tfield: SugaredRelativeSingleField | string,\n\t): FieldAccessor<Value> {\n\t\treturn this.getRelativeSingleField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t}\n\n\tpublic getEntity(entity: SugaredRelativeSingleEntity | string): EntityAccessor {\n\t\treturn this.getRelativeSingleEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t}\n\n\tpublic getEntityList(entityList: SugaredRelativeEntityList | string): EntityListAccessor {\n\t\treturn this.getRelativeEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t}\n\n\tpublic getKeyConnectedOnServer(entity: SugaredRelativeSingleEntity | string): string | null {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(entity, this.environment)\n\t\tconst lastHasOne = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1]\n\t\tconst lastHasOnePlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(lastHasOne)\n\n\t\tlet containingAccessor: EntityAccessor = this\n\n\t\tif (desugared.hasOneRelationPath.length > 1) {\n\t\t\tcontainingAccessor = this.getRelativeSingleEntity({\n\t\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t\t})\n\t\t}\n\t\treturn containingAccessor.getPersistedKeyByPlaceholder(lastHasOnePlaceholder)\n\t}\n\n\t//\n\n\t/**\n\t * @see EntityAccessor.getField\n\t */\n\tpublic getRelativeSingleField<Value extends FieldValue = FieldValue>(field: RelativeSingleField): FieldAccessor<Value> {\n\t\treturn this.getRelativeSingleEntity(field).getAccessorByPlaceholder(\n\t\t\tPlaceholderGenerator.getFieldPlaceholder(field.field),\n\t\t) as unknown as FieldAccessor<Value>\n\t}\n\n\tpublic getRelativeSingleEntity(relativeSingleEntity: RelativeSingleEntity): EntityAccessor {\n\t\tlet relativeTo: EntityAccessor = this\n\n\t\tfor (const hasOneRelation of relativeSingleEntity.hasOneRelationPath) {\n\t\t\trelativeTo = relativeTo.getAccessorByPlaceholder(\n\t\t\t\tPlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation),\n\t\t\t) as EntityAccessor\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tpublic getRelativeEntityList(entityList: RelativeEntityList): EntityListAccessor {\n\t\treturn this.getRelativeSingleEntity(entityList).getAccessorByPlaceholder(\n\t\t\tPlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation),\n\t\t) as EntityListAccessor\n\t}\n\n\tprivate getAccessorByPlaceholder(placeholderName: FieldName): EntityAccessor.NestedAccessor {\n\t\tconst record = this.fieldData.get(placeholderName)\n\t\tif (record === undefined) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityAccessor: unknown field placeholder '${placeholderName} on ${this.name}'. Unless this is just a typo, this is ` +\n\t\t\t\t\t`typically caused by one of the following:\\n` +\n\t\t\t\t\t`\\t• Trying to access a field that has not been registered during static render, and thus lacks a marker and an accessor.\\n` +\n\t\t\t\t\t`\\t• Misusing an EntityAccessor getter. If you used one of the getRelative[…] family, please make sure all ` +\n\t\t\t\t\t`parameters match the marker tree exactly.` +\n\t\t\t\t\t`\\n\\nFor more information, please consult the documentation.\\n\\n`,\n\t\t\t)\n\t\t}\n\t\treturn record.getAccessor()\n\t}\n\n\tprivate getPersistedKeyByPlaceholder(placeholderName: string): string | null {\n\t\tif (this.dataFromServer === undefined) {\n\t\t\treturn null\n\t\t}\n\t\tconst key = this.dataFromServer.get(placeholderName)\n\n\t\tif (key instanceof ServerGeneratedUuid) {\n\t\t\treturn key.value\n\t\t}\n\t\tif (key === null) {\n\t\t\t// TODO this also returns null and fails to throw when placeholderName points to a regular scalar field that\n\t\t\t// \thappens to be also null.\n\t\t\treturn null\n\t\t}\n\n\t\t// From now on, we're past the happy path, way into error land.\n\t\tif (key === undefined) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityAccessor.getKeyConnectedOnServer: unknown placeholder '${placeholderName}'. Unless this is just ` +\n\t\t\t\t\t`a typo, this typically happens when a has-one relation hasn't been registered during static render.`,\n\t\t\t)\n\t\t}\n\t\tif (key instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a has-many relation, ` +\n\t\t\t\t\t`not a has-one. This method is meant exclusively for has-one relations.`,\n\t\t\t)\n\t\t}\n\t\tthrow new BindingError(\n\t\t\t`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a scalar field, not a` +\n\t\t\t\t`has-one relation. This method is meant exclusively for has-one relations.`,\n\t\t)\n\t}\n}\n\nnamespace EntityAccessor {\n\texport interface FieldDatum {\n\t\tgetAccessor(): NestedAccessor\n\t}\n\texport type NestedAccessor = EntityAccessor | EntityListAccessor | FieldAccessor\n\n\texport type FieldValuePairs =\n\t\t| {\n\t\t\t\t[field: string]: FieldValue\n\t\t }\n\t\t| Iterable<[SugaredRelativeSingleField | string, FieldValue]>\n\n\texport type FieldData = Map<FieldName, FieldDatum>\n\n\texport type GetEntityAccessor = () => EntityAccessor\n\texport type BatchUpdatesHandler = (getAccessor: GetEntityAccessor, options: BatchUpdatesOptions) => void\n\texport type UpdateListener = (accessor: EntityAccessor) => void\n\n\texport type BeforePersistHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: AsyncBatchUpdatesOptions,\n\t) => void | Promise<void | BeforePersistHandler>\n\n\texport type PersistErrorHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: PersistErrorOptions,\n\t) => void | Promise<void>\n\n\texport type PersistSuccessHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: PersistSuccessOptions,\n\t) => void | Promise<void | PersistSuccessHandler>\n\n\texport interface RuntimeEntityEventListenerMap {\n\t\tbeforePersist: BeforePersistHandler\n\t\tbeforeUpdate: BatchUpdatesHandler\n\t\tconnectionUpdate: UpdateListener\n\t\tpersistError: PersistErrorHandler\n\t\tpersistSuccess: PersistSuccessHandler\n\t\tupdate: UpdateListener\n\t}\n\texport interface EntityEventListenerMap extends RuntimeEntityEventListenerMap {\n\t\tinitialize: BatchUpdatesHandler\n\t}\n\texport type EntityEventType = keyof EntityEventListenerMap\n}\n\nexport { EntityAccessor }\n"],"names":[],"mappings":";;;;;AA6BA,MAAM,eAAoC;AAAA,EAClC,YACW,UACA,YACA,WACD,KACA,MACC,WACA,gBACD,uBACA,QACA,aACA,aACf;AAXgB,SAAA,WAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACD,SAAA,MAAA;AACA,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,iBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAAA,EACd;AAAA,MAEQ,aAAiC;AAC3C,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAC/D;AAAA,MAKW,KAAe;AACzB,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,MAEW,iBAA0B;AACpC,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAIO,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,UAAU,cAAc,eAAe,KAAK,CAAC;AAAA,EACnF;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,UAAU,OAAO,QAAQ;AAAA,EACvE;AAAA,EAEO,aAAa,gBAA0D;AAC7E,SAAK,WAAW,aAAa,KAAK,UAAU,cAAc;AAAA,EAC3D;AAAA,EAEO,qBAAqB,OAAkB,iBAAuC;AACpF,SAAK,WAAW,qBAAqB,KAAK,UAAU,OAAO,eAAe;AAAA,EAC3E;AAAA,EAEO,wBAAwB,OAAkB,uBAAkE;AAClH,SAAK,WAAW,wBAAwB,KAAK,UAAU,OAAO,qBAAqB;AAAA,EACpF;AAAA,EAEO,eAAqB;AACtB,SAAA,WAAW,aAAa,KAAK,QAAQ;AAAA,EAC3C;AAAA,EAIO,aAAa,iBAAuD;AAC1E,SAAK,aAAa,CAAe,gBAAA;AAC1B,YAAA,UAAU,MAAM,QAAQ,eAAe,IAAI,kBAAkB,OAAO,QAAQ,eAAe;AAEtF,iBAAA,CAAC,OAAO,UAAU,SAAS;AACrC,oBAAA,EAAc,SAAS,KAAK,EAAE,YAAY,KAAK;AAAA,MAChD;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAMO,SACN,OACuB;AACvB,WAAO,KAAK,uBAA8B,cAAc,2BAA2B,OAAO,KAAK,WAAW,CAAC;AAAA,EAC5G;AAAA,EAEO,UAAU,QAA8D;AAC9E,WAAO,KAAK,wBAAwB,cAAc,4BAA4B,QAAQ,KAAK,WAAW,CAAC;AAAA,EACxG;AAAA,EAEO,cAAc,YAAoE;AACxF,WAAO,KAAK,sBAAsB,cAAc,0BAA0B,YAAY,KAAK,WAAW,CAAC;AAAA,EACxG;AAAA,EAEO,wBAAwB,QAA6D;AAC3F,UAAM,YAAY,cAAc,4BAA4B,QAAQ,KAAK,WAAW;AACpF,UAAM,aAAa,UAAU,mBAAmB,UAAU,mBAAmB,SAAS;AAChF,UAAA,wBAAwB,qBAAqB,6BAA6B,UAAU;AAE1F,QAAI,qBAAqC;AAErC,QAAA,UAAU,mBAAmB,SAAS,GAAG;AAC5C,2BAAqB,KAAK,wBAAwB;AAAA,QACjD,oBAAoB,UAAU,mBAAmB,MAAM,GAAG,EAAE;AAAA,MAAA,CAC5D;AAAA,IACF;AACO,WAAA,mBAAmB,6BAA6B,qBAAqB;AAAA,EAC7E;AAAA,EAOO,uBAA8D,OAAkD;AAC/G,WAAA,KAAK,wBAAwB,KAAK,EAAE,yBAC1C,qBAAqB,oBAAoB,MAAM,KAAK,CACrD;AAAA,EACD;AAAA,EAEO,wBAAwB,sBAA4D;AAC1F,QAAI,aAA6B;AAEtB,eAAA,kBAAkB,qBAAqB,oBAAoB;AACrE,mBAAa,WAAW,yBACvB,qBAAqB,6BAA6B,cAAc,CACjE;AAAA,IACD;AACO,WAAA;AAAA,EACR;AAAA,EAEO,sBAAsB,YAAoD;AACzE,WAAA,KAAK,wBAAwB,UAAU,EAAE,yBAC/C,qBAAqB,8BAA8B,WAAW,eAAe,CAC9E;AAAA,EACD;AAAA,EAEQ,yBAAyB,iBAA2D;AAC3F,UAAM,SAAS,KAAK,UAAU,IAAI,eAAe;AACjD,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aACT,8CAA8C,sBAAsB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAM1E;AAAA,IACD;AACA,WAAO,OAAO;EACf;AAAA,EAEQ,6BAA6B,iBAAwC;AACxE,QAAA,KAAK,mBAAmB,QAAW;AAC/B,aAAA;AAAA,IACR;AACA,UAAM,MAAM,KAAK,eAAe,IAAI,eAAe;AAEnD,QAAI,eAAe,qBAAqB;AACvC,aAAO,IAAI;AAAA,IACZ;AACA,QAAI,QAAQ,MAAM;AAGV,aAAA;AAAA,IACR;AAGA,QAAI,QAAQ,QAAW;AAChB,YAAA,IAAI,aACT,gEAAgE,2IAEjE;AAAA,IACD;AACA,QAAI,eAAe,KAAK;AACjB,YAAA,IAAI,aACT,4DAA4D,wHAE7D;AAAA,IACD;AACM,UAAA,IAAI,aACT,4DAA4D,2HAE7D;AAAA,EACD;AACD;;"}
|
|
1
|
+
{"version":3,"file":"EntityAccessor.js","sources":["../../../src/accessors/EntityAccessor.ts"],"sourcesContent":["import { RuntimeId, SingleEntityPersistedData } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { EntityOperations } from '../core/operations'\nimport type { Environment } from '../dao'\nimport { PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tFieldValue,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n} from '../treeParameters'\nimport type { AsyncBatchUpdatesOptions } from './AsyncBatchUpdatesOptions'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { EntityListAccessor } from './EntityListAccessor'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { FieldAccessor } from './FieldAccessor'\nimport type { PersistErrorOptions } from './PersistErrorOptions'\nimport type { PersistSuccessOptions } from './PersistSuccessOptions'\nimport type { EntityRealmState } from '../core/state'\n\nclass EntityAccessor implements Errorable {\n\tpublic constructor(\n\t\tprivate readonly stateKey: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\tpublic readonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {}\n\n\tpublic get 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\tpublic get id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tpublic get existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.stateKey, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<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.stateKey, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.stateKey, performUpdates)\n\t}\n\n\tpublic connectEntityAtField(field: FieldName, entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntityAtField(this.stateKey, field, entityToConnect)\n\t}\n\n\tpublic disconnectEntityAtField(field: FieldName, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.disconnectEntityAtField(this.stateKey, field, initializeReplacement)\n\t}\n\n\tpublic deleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.stateKey)\n\t}\n\n\t//\n\n\tpublic updateValues(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\tpublic getField<Value extends FieldValue = FieldValue>(\n\t\tfield: SugaredRelativeSingleField | string,\n\t): FieldAccessor<Value> {\n\t\treturn this.getRelativeSingleField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t}\n\n\tpublic getEntity(entity: SugaredRelativeSingleEntity | string): EntityAccessor {\n\t\treturn this.getRelativeSingleEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t}\n\n\tpublic getEntityList(entityList: SugaredRelativeEntityList | string): EntityListAccessor {\n\t\treturn this.getRelativeEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t}\n\n\t//\n\n\t/**\n\t * @see EntityAccessor.getField\n\t */\n\tpublic getRelativeSingleField<Value extends FieldValue = FieldValue>(field: RelativeSingleField): FieldAccessor<Value> {\n\t\treturn this.getRelativeSingleEntity(field).getAccessorByPlaceholder(\n\t\t\tPlaceholderGenerator.getFieldPlaceholder(field.field),\n\t\t) as unknown as FieldAccessor<Value>\n\t}\n\n\tpublic getRelativeSingleEntity(relativeSingleEntity: RelativeSingleEntity): EntityAccessor {\n\t\tlet relativeTo: EntityAccessor = this\n\n\t\tfor (const hasOneRelation of relativeSingleEntity.hasOneRelationPath) {\n\t\t\trelativeTo = relativeTo.getAccessorByPlaceholder(\n\t\t\t\tPlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation),\n\t\t\t) as EntityAccessor\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tpublic getRelativeEntityList(entityList: RelativeEntityList): EntityListAccessor {\n\t\treturn this.getRelativeSingleEntity(entityList).getAccessorByPlaceholder(\n\t\t\tPlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation),\n\t\t) as EntityListAccessor\n\t}\n\n\tprivate getAccessorByPlaceholder(placeholderName: FieldName): EntityAccessor.NestedAccessor {\n\t\tconst record = this.fieldData.get(placeholderName)\n\t\tif (record === undefined) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityAccessor: unknown field placeholder '${placeholderName} on ${this.name}'. Unless this is just a typo, this is ` +\n\t\t\t\t\t`typically caused by one of the following:\\n` +\n\t\t\t\t\t`\\t• Trying to access a field that has not been registered during static render, and thus lacks a marker and an accessor.\\n` +\n\t\t\t\t\t`\\t• Misusing an EntityAccessor getter. If you used one of the getRelative[…] family, please make sure all ` +\n\t\t\t\t\t`parameters match the marker tree exactly.` +\n\t\t\t\t\t`\\n\\nFor more information, please consult the documentation.\\n\\n`,\n\t\t\t)\n\t\t}\n\t\treturn record.getAccessor()\n\t}\n}\n\nnamespace EntityAccessor {\n\texport interface FieldDatum {\n\t\tgetAccessor(): NestedAccessor\n\t}\n\texport type NestedAccessor = EntityAccessor | EntityListAccessor | FieldAccessor\n\n\texport type FieldValuePairs =\n\t\t| {\n\t\t\t\t[field: string]: FieldValue\n\t\t }\n\t\t| Iterable<[SugaredRelativeSingleField | string, FieldValue]>\n\n\texport type FieldData = Map<FieldName, FieldDatum>\n\n\texport type GetEntityAccessor = () => EntityAccessor\n\texport type BatchUpdatesHandler = (getAccessor: GetEntityAccessor, options: BatchUpdatesOptions) => void\n\texport type UpdateListener = (accessor: EntityAccessor) => void\n\n\texport type BeforePersistHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: AsyncBatchUpdatesOptions,\n\t) => void | Promise<void | BeforePersistHandler>\n\n\texport type PersistErrorHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: PersistErrorOptions,\n\t) => void | Promise<void>\n\n\texport type PersistSuccessHandler = (\n\t\tgetAccessor: GetEntityAccessor,\n\t\toptions: PersistSuccessOptions,\n\t) => void | Promise<void | PersistSuccessHandler>\n\n\texport interface RuntimeEntityEventListenerMap {\n\t\tbeforePersist: BeforePersistHandler\n\t\tbeforeUpdate: BatchUpdatesHandler\n\t\tconnectionUpdate: UpdateListener\n\t\tpersistError: PersistErrorHandler\n\t\tpersistSuccess: PersistSuccessHandler\n\t\tupdate: UpdateListener\n\t}\n\texport interface EntityEventListenerMap extends RuntimeEntityEventListenerMap {\n\t\tinitialize: BatchUpdatesHandler\n\t}\n\texport type EntityEventType = keyof EntityEventListenerMap\n}\n\nexport { EntityAccessor }\n"],"names":[],"mappings":";;;;AA6BA,MAAM,eAAoC;AAAA,EAClC,YACW,UACA,YACA,WACD,KACA,MACC,WACA,gBACD,uBACA,QACA,aACA,aACf;AAXgB,SAAA,WAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACD,SAAA,MAAA;AACA,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,iBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAAA,EACd;AAAA,MAEQ,aAAmC;AAC7C,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAC/D;AAAA,MAKW,KAAe;AACzB,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,MAEW,iBAA0B;AACpC,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAIO,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,UAAU,cAAc,eAAe,KAAK,CAAC;AAAA,EACnF;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,UAAU,OAAO,QAAQ;AAAA,EACvE;AAAA,EAEO,aAAa,gBAA0D;AAC7E,SAAK,WAAW,aAAa,KAAK,UAAU,cAAc;AAAA,EAC3D;AAAA,EAEO,qBAAqB,OAAkB,iBAAuC;AACpF,SAAK,WAAW,qBAAqB,KAAK,UAAU,OAAO,eAAe;AAAA,EAC3E;AAAA,EAEO,wBAAwB,OAAkB,uBAAkE;AAClH,SAAK,WAAW,wBAAwB,KAAK,UAAU,OAAO,qBAAqB;AAAA,EACpF;AAAA,EAEO,eAAqB;AACtB,SAAA,WAAW,aAAa,KAAK,QAAQ;AAAA,EAC3C;AAAA,EAIO,aAAa,iBAAuD;AAC1E,SAAK,aAAa,CAAe,gBAAA;AAC1B,YAAA,UAAU,MAAM,QAAQ,eAAe,IAAI,kBAAkB,OAAO,QAAQ,eAAe;AAEtF,iBAAA,CAAC,OAAO,UAAU,SAAS;AACrC,oBAAA,EAAc,SAAS,KAAK,EAAE,YAAY,KAAK;AAAA,MAChD;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAMO,SACN,OACuB;AACvB,WAAO,KAAK,uBAA8B,cAAc,2BAA2B,OAAO,KAAK,WAAW,CAAC;AAAA,EAC5G;AAAA,EAEO,UAAU,QAA8D;AAC9E,WAAO,KAAK,wBAAwB,cAAc,4BAA4B,QAAQ,KAAK,WAAW,CAAC;AAAA,EACxG;AAAA,EAEO,cAAc,YAAoE;AACxF,WAAO,KAAK,sBAAsB,cAAc,0BAA0B,YAAY,KAAK,WAAW,CAAC;AAAA,EACxG;AAAA,EAOO,uBAA8D,OAAkD;AAC/G,WAAA,KAAK,wBAAwB,KAAK,EAAE,yBAC1C,qBAAqB,oBAAoB,MAAM,KAAK,CACrD;AAAA,EACD;AAAA,EAEO,wBAAwB,sBAA4D;AAC1F,QAAI,aAA6B;AAEtB,eAAA,kBAAkB,qBAAqB,oBAAoB;AACrE,mBAAa,WAAW,yBACvB,qBAAqB,6BAA6B,cAAc,CACjE;AAAA,IACD;AACO,WAAA;AAAA,EACR;AAAA,EAEO,sBAAsB,YAAoD;AACzE,WAAA,KAAK,wBAAwB,UAAU,EAAE,yBAC/C,qBAAqB,8BAA8B,WAAW,eAAe,CAC9E;AAAA,EACD;AAAA,EAEQ,yBAAyB,iBAA2D;AAC3F,UAAM,SAAS,KAAK,UAAU,IAAI,eAAe;AACjD,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aACT,8CAA8C,sBAAsB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAM1E;AAAA,IACD;AACA,WAAO,OAAO;EACf;AACD;;"}
|
|
@@ -36,7 +36,7 @@ class EntityListAccessor {
|
|
|
36
36
|
return this._children.size;
|
|
37
37
|
}
|
|
38
38
|
hasEntityOnServer(entityOrItsId) {
|
|
39
|
-
if (typeof entityOrItsId === "string") {
|
|
39
|
+
if (typeof entityOrItsId === "string" || typeof entityOrItsId === "number") {
|
|
40
40
|
return this.idsPersistedOnServer.has(entityOrItsId);
|
|
41
41
|
}
|
|
42
42
|
const idOnServer = entityOrItsId.idOnServer;
|