@contember/binding 1.1.0-alpha.0 → 1.1.0-alpha.11
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 +19 -40
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +11 -11
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +6 -6
- package/dist/development/accessors/FieldAccessor.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 +27 -40
- 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 +13 -8
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/development/core/MarkerMerger.js +2 -2
- 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.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 +27 -3
- 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.map +1 -1
- package/dist/development/coreComponents/HasOne.js +1 -1
- package/dist/development/dao/Environment.js +35 -3
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/dao/TreeNodeEnvironmentFactory.js +6 -13
- package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -1
- 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 +2 -2
- 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 +19 -40
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +11 -11
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +6 -6
- package/dist/production/accessors/FieldAccessor.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 +27 -40
- 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 +12 -7
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/production/core/MarkerMerger.js +2 -2
- 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.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 +27 -3
- 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.map +1 -1
- package/dist/production/coreComponents/HasOne.js +1 -1
- package/dist/production/dao/Environment.js +35 -3
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/dao/TreeNodeEnvironmentFactory.js +6 -13
- package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -1
- 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 +2 -2
- 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 +5 -5
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
- package/dist/types/accessors/EntityListAccessor.d.ts +4 -4
- package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
- package/dist/types/accessors/FieldAccessor.d.ts +2 -2
- package/dist/types/accessors/FieldAccessor.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/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 +13 -3
- 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/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.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/ParentEntity.d.ts +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
- package/dist/types/dao/Environment.d.ts +14 -5
- package/dist/types/dao/Environment.d.ts.map +1 -1
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -1
- 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/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 +7 -5
- 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 +9 -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 +22 -58
- package/src/accessors/EntityListAccessor.ts +12 -12
- package/src/accessors/FieldAccessor.ts +5 -5
- package/src/core/AccessorErrorManager.ts +6 -2
- package/src/core/Config.ts +0 -1
- package/src/core/DataBinding.ts +28 -44
- package/src/core/DirtinessTracker.ts +4 -16
- package/src/core/ErrorsPreprocessor.ts +16 -18
- package/src/core/EventManager.ts +14 -8
- 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 +2 -2
- 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 +38 -4
- 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/state/FieldState.ts +2 -2
- package/src/coreComponents/Component.tsx +20 -7
- package/src/coreComponents/DataBindingProvider.tsx +0 -2
- package/src/coreComponents/EntityListSubTree.tsx +2 -3
- package/src/dao/Environment.ts +48 -7
- package/src/dao/TreeNodeEnvironmentFactory.ts +8 -13
- 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/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/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/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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeId,
|
|
1
|
+
import { RuntimeId, SingleEntityPersistedData } from '../accessorTree'
|
|
2
2
|
import { BindingError } from '../BindingError'
|
|
3
3
|
import type { EntityOperations } from '../core/operations'
|
|
4
4
|
import type { Environment } from '../dao'
|
|
@@ -26,10 +26,11 @@ import type { FieldAccessor } from './FieldAccessor'
|
|
|
26
26
|
import type { PersistErrorOptions } from './PersistErrorOptions'
|
|
27
27
|
import type { PersistSuccessOptions } from './PersistSuccessOptions'
|
|
28
28
|
import type { EntityRealmState } from '../core/state'
|
|
29
|
+
import { getEntityMarker } from '../core/state'
|
|
29
30
|
|
|
30
31
|
class EntityAccessor implements Errorable {
|
|
31
32
|
public constructor(
|
|
32
|
-
private readonly
|
|
33
|
+
private readonly state: EntityRealmState,
|
|
33
34
|
private readonly operations: EntityOperations,
|
|
34
35
|
private readonly runtimeId: RuntimeId,
|
|
35
36
|
public readonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️
|
|
@@ -42,7 +43,7 @@ class EntityAccessor implements Errorable {
|
|
|
42
43
|
public readonly getAccessor: EntityAccessor.GetEntityAccessor,
|
|
43
44
|
) {}
|
|
44
45
|
|
|
45
|
-
public get idOnServer():
|
|
46
|
+
public get idOnServer(): EntityId | undefined {
|
|
46
47
|
return this.runtimeId.existsOnServer ? this.runtimeId.value : undefined
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -60,30 +61,30 @@ class EntityAccessor implements Errorable {
|
|
|
60
61
|
//
|
|
61
62
|
|
|
62
63
|
public addError(error: ErrorAccessor.Error | string): () => void {
|
|
63
|
-
return this.operations.addError(this.
|
|
64
|
+
return this.operations.addError(this.state, ErrorAccessor.normalizeError(error))
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
public addEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(
|
|
67
68
|
event: { type: Type; key?: string },
|
|
68
69
|
listener: EntityAccessor.EntityEventListenerMap[Type],
|
|
69
70
|
): () => void {
|
|
70
|
-
return this.operations.addEventListener(this.
|
|
71
|
+
return this.operations.addEventListener(this.state, event, listener)
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
public batchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {
|
|
74
|
-
this.operations.batchUpdates(this.
|
|
75
|
+
this.operations.batchUpdates(this.state, performUpdates)
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
public connectEntityAtField(field: FieldName, entityToConnect: EntityAccessor): void {
|
|
78
|
-
this.operations.connectEntityAtField(this.
|
|
79
|
+
this.operations.connectEntityAtField(this.state, field, entityToConnect)
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
public disconnectEntityAtField(field: FieldName, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {
|
|
82
|
-
this.operations.disconnectEntityAtField(this.
|
|
83
|
+
this.operations.disconnectEntityAtField(this.state, field, initializeReplacement)
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
public deleteEntity(): void {
|
|
86
|
-
this.operations.deleteEntity(this.
|
|
87
|
+
this.operations.deleteEntity(this.state)
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
//
|
|
@@ -116,21 +117,6 @@ class EntityAccessor implements Errorable {
|
|
|
116
117
|
return this.getRelativeEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
public getKeyConnectedOnServer(entity: SugaredRelativeSingleEntity | string): string | null {
|
|
120
|
-
const desugared = QueryLanguage.desugarRelativeSingleEntity(entity, this.environment)
|
|
121
|
-
const lastHasOne = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1]
|
|
122
|
-
const lastHasOnePlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(lastHasOne)
|
|
123
|
-
|
|
124
|
-
let containingAccessor: EntityAccessor = this
|
|
125
|
-
|
|
126
|
-
if (desugared.hasOneRelationPath.length > 1) {
|
|
127
|
-
containingAccessor = this.getRelativeSingleEntity({
|
|
128
|
-
hasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
return containingAccessor.getPersistedKeyByPlaceholder(lastHasOnePlaceholder)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
120
|
//
|
|
135
121
|
|
|
136
122
|
/**
|
|
@@ -159,6 +145,18 @@ class EntityAccessor implements Errorable {
|
|
|
159
145
|
) as EntityListAccessor
|
|
160
146
|
}
|
|
161
147
|
|
|
148
|
+
public getParent(): EntityAccessor | EntityListAccessor | undefined {
|
|
149
|
+
const blueprint = this.state.blueprint
|
|
150
|
+
if (blueprint.type === 'subTree') {
|
|
151
|
+
return undefined
|
|
152
|
+
}
|
|
153
|
+
return blueprint.parent.getAccessor()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public getMarker() {
|
|
157
|
+
return getEntityMarker(this.state)
|
|
158
|
+
}
|
|
159
|
+
|
|
162
160
|
private getAccessorByPlaceholder(placeholderName: FieldName): EntityAccessor.NestedAccessor {
|
|
163
161
|
const record = this.fieldData.get(placeholderName)
|
|
164
162
|
if (record === undefined) {
|
|
@@ -173,40 +171,6 @@ class EntityAccessor implements Errorable {
|
|
|
173
171
|
}
|
|
174
172
|
return record.getAccessor()
|
|
175
173
|
}
|
|
176
|
-
|
|
177
|
-
private getPersistedKeyByPlaceholder(placeholderName: string): string | null {
|
|
178
|
-
if (this.dataFromServer === undefined) {
|
|
179
|
-
return null
|
|
180
|
-
}
|
|
181
|
-
const key = this.dataFromServer.get(placeholderName)
|
|
182
|
-
|
|
183
|
-
if (key instanceof ServerGeneratedUuid) {
|
|
184
|
-
return key.value
|
|
185
|
-
}
|
|
186
|
-
if (key === null) {
|
|
187
|
-
// TODO this also returns null and fails to throw when placeholderName points to a regular scalar field that
|
|
188
|
-
// happens to be also null.
|
|
189
|
-
return null
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// From now on, we're past the happy path, way into error land.
|
|
193
|
-
if (key === undefined) {
|
|
194
|
-
throw new BindingError(
|
|
195
|
-
`EntityAccessor.getKeyConnectedOnServer: unknown placeholder '${placeholderName}'. Unless this is just ` +
|
|
196
|
-
`a typo, this typically happens when a has-one relation hasn't been registered during static render.`,
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
if (key instanceof Set) {
|
|
200
|
-
throw new BindingError(
|
|
201
|
-
`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a has-many relation, ` +
|
|
202
|
-
`not a has-one. This method is meant exclusively for has-one relations.`,
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
throw new BindingError(
|
|
206
|
-
`EntityAccessor.getKeyConnectedOnServer: the placeholder '${placeholderName}' refers to a scalar field, not a` +
|
|
207
|
-
`has-one relation. This method is meant exclusively for has-one relations.`,
|
|
208
|
-
)
|
|
209
|
-
}
|
|
210
174
|
}
|
|
211
175
|
|
|
212
176
|
namespace EntityAccessor {
|
|
@@ -13,10 +13,10 @@ import { RuntimeId } from '../accessorTree'
|
|
|
13
13
|
|
|
14
14
|
class EntityListAccessor implements Errorable {
|
|
15
15
|
public constructor(
|
|
16
|
-
private readonly
|
|
16
|
+
private readonly state: EntityListState,
|
|
17
17
|
private readonly operations: ListOperations,
|
|
18
18
|
private readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,
|
|
19
|
-
private readonly _idsPersistedOnServer: ReadonlySet<
|
|
19
|
+
private readonly _idsPersistedOnServer: ReadonlySet<EntityId>,
|
|
20
20
|
public readonly hasUnpersistedChanges: boolean,
|
|
21
21
|
public readonly errors: ErrorAccessor | undefined,
|
|
22
22
|
public readonly environment: Environment,
|
|
@@ -42,7 +42,7 @@ class EntityListAccessor implements Errorable {
|
|
|
42
42
|
* This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
|
|
43
43
|
* the list since the last server query.
|
|
44
44
|
*/
|
|
45
|
-
public get idsPersistedOnServer(): Set<
|
|
45
|
+
public get idsPersistedOnServer(): Set<EntityId> {
|
|
46
46
|
return new Set(this._idsPersistedOnServer)
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -65,7 +65,7 @@ class EntityListAccessor implements Errorable {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
public hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {
|
|
68
|
-
if (typeof entityOrItsId === 'string') {
|
|
68
|
+
if (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {
|
|
69
69
|
return this.idsPersistedOnServer.has(entityOrItsId)
|
|
70
70
|
}
|
|
71
71
|
const idOnServer = entityOrItsId.idOnServer
|
|
@@ -94,14 +94,14 @@ class EntityListAccessor implements Errorable {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
public addError(error: ErrorAccessor.Error | string): () => void {
|
|
97
|
-
return this.operations.addError(this.
|
|
97
|
+
return this.operations.addError(this.state, ErrorAccessor.normalizeError(error))
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
public addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(
|
|
101
101
|
event: { type: Type; key?: string },
|
|
102
102
|
listener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],
|
|
103
103
|
) {
|
|
104
|
-
return this.operations.addEventListener(this.
|
|
104
|
+
return this.operations.addEventListener(this.state, event, listener)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
public addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(
|
|
@@ -109,25 +109,25 @@ class EntityListAccessor implements Errorable {
|
|
|
109
109
|
event: { type: Type; key?: string },
|
|
110
110
|
listener: EntityAccessor.EntityEventListenerMap[Type],
|
|
111
111
|
) {
|
|
112
|
-
return this.operations.addChildEventListener(this.
|
|
112
|
+
return this.operations.addChildEventListener(this.state, event, listener)
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
public batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {
|
|
116
|
-
this.operations.batchUpdates(this.
|
|
116
|
+
this.operations.batchUpdates(this.state, performUpdates)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
public connectEntity(entityToConnect: EntityAccessor): void {
|
|
120
|
-
this.operations.connectEntity(this.
|
|
120
|
+
this.operations.connectEntity(this.state, entityToConnect)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
public createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {
|
|
124
|
-
return this.operations.createNewEntity(this.
|
|
124
|
+
return this.operations.createNewEntity(this.state, initialize)
|
|
125
125
|
}
|
|
126
126
|
public disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {
|
|
127
|
-
this.operations.disconnectEntity(this.
|
|
127
|
+
this.operations.disconnectEntity(this.state, childEntity, options)
|
|
128
128
|
}
|
|
129
129
|
public getChildEntityById(id: EntityId): EntityAccessor {
|
|
130
|
-
return this.operations.getChildEntityById(this.
|
|
130
|
+
return this.operations.getChildEntityById(this.state, id)
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -9,7 +9,7 @@ import type { SchemaColumn } from '../core/schema/SchemaColumn'
|
|
|
9
9
|
|
|
10
10
|
class FieldAccessor<Value extends FieldValue = FieldValue> implements Errorable {
|
|
11
11
|
constructor(
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly state: FieldState<Value>,
|
|
13
13
|
private readonly operations: FieldOperations,
|
|
14
14
|
public readonly fieldName: FieldName,
|
|
15
15
|
public readonly value: Value | null,
|
|
@@ -23,22 +23,22 @@ class FieldAccessor<Value extends FieldValue = FieldValue> implements Errorable
|
|
|
23
23
|
) {}
|
|
24
24
|
|
|
25
25
|
public addError(error: ErrorAccessor.Error | string): () => void {
|
|
26
|
-
return this.operations.addError(this.
|
|
26
|
+
return this.operations.addError(this.state, ErrorAccessor.normalizeError(error))
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public clearErrors(): void {
|
|
30
|
-
this.operations.clearErrors(this.
|
|
30
|
+
this.operations.clearErrors(this.state)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
public addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(
|
|
34
34
|
event: { type: Type; key?: string },
|
|
35
35
|
listener: FieldAccessor.FieldEventListenerMap<Value>[Type],
|
|
36
36
|
): () => void {
|
|
37
|
-
return this.operations.addEventListener(this.
|
|
37
|
+
return this.operations.addEventListener(this.state, event, listener)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {
|
|
41
|
-
this.operations.updateValue(this.
|
|
41
|
+
this.operations.updateValue(this.state, newValue, options)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
public hasValue(candidate: this['value']): boolean {
|
|
@@ -4,6 +4,7 @@ import { ErrorsPreprocessor } from './ErrorsPreprocessor'
|
|
|
4
4
|
import { EventManager } from './EventManager'
|
|
5
5
|
import { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'
|
|
6
6
|
import type { TreeStore } from './TreeStore'
|
|
7
|
+
import { SubMutationOperation } from './MutationGenerator'
|
|
7
8
|
|
|
8
9
|
export class AccessorErrorManager {
|
|
9
10
|
private errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()
|
|
@@ -45,11 +46,11 @@ export class AccessorErrorManager {
|
|
|
45
46
|
})
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
public replaceErrors(data: MutationDataResponse) {
|
|
49
|
+
public replaceErrors(data: MutationDataResponse, operations: SubMutationOperation[]) {
|
|
49
50
|
this.eventManager.syncOperation(() => {
|
|
50
51
|
this.clearErrors()
|
|
51
52
|
|
|
52
|
-
const preprocessor = new ErrorsPreprocessor(data)
|
|
53
|
+
const preprocessor = new ErrorsPreprocessor(data, operations)
|
|
53
54
|
const errorTreeRoot = preprocessor.preprocess()
|
|
54
55
|
|
|
55
56
|
this.setRootStateErrors(errorTreeRoot)
|
|
@@ -134,6 +135,9 @@ export class AccessorErrorManager {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
for (const [childKey, child] of errors.children) {
|
|
138
|
+
if (typeof childKey !== 'string') {
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
137
141
|
if (child.nodeType === 'leaf') {
|
|
138
142
|
const fieldState = state.children.get(childKey)
|
|
139
143
|
|
package/src/core/Config.ts
CHANGED
package/src/core/DataBinding.ts
CHANGED
|
@@ -29,7 +29,6 @@ import { MarkerMerger } from './MarkerMerger'
|
|
|
29
29
|
import { MarkerTreeGenerator } from './MarkerTreeGenerator'
|
|
30
30
|
import { MutationGenerator } from './MutationGenerator'
|
|
31
31
|
import { QueryGenerator } from './QueryGenerator'
|
|
32
|
-
import { Schema, SchemaLoader } from './schema'
|
|
33
32
|
import { StateIterator } from './state'
|
|
34
33
|
import { StateInitializer } from './StateInitializer'
|
|
35
34
|
import { TreeAugmenter } from './TreeAugmenter'
|
|
@@ -39,8 +38,6 @@ import type { UpdateMetadata } from './UpdateMetadata'
|
|
|
39
38
|
import { getCombinedSignal } from './utils'
|
|
40
39
|
|
|
41
40
|
export class DataBinding {
|
|
42
|
-
private static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()
|
|
43
|
-
|
|
44
41
|
private readonly accessorErrorManager: AccessorErrorManager
|
|
45
42
|
private readonly batchUpdatesOptions: BatchUpdatesOptions
|
|
46
43
|
private readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions
|
|
@@ -50,7 +47,6 @@ export class DataBinding {
|
|
|
50
47
|
private readonly eventManager: EventManager
|
|
51
48
|
private readonly stateInitializer: StateInitializer
|
|
52
49
|
private readonly treeAugmenter: TreeAugmenter
|
|
53
|
-
private readonly treeStore: TreeStore
|
|
54
50
|
|
|
55
51
|
// private treeRootListeners: {
|
|
56
52
|
// eventListeners: {}
|
|
@@ -62,13 +58,13 @@ export class DataBinding {
|
|
|
62
58
|
private readonly contentApiClient: GraphQlClient,
|
|
63
59
|
private readonly systemApiClient: GraphQlClient,
|
|
64
60
|
private readonly tenantApiClient: GraphQlClient,
|
|
61
|
+
private readonly treeStore: TreeStore,
|
|
65
62
|
private readonly environment: Environment,
|
|
66
|
-
private readonly onUpdate: (newData: TreeRootAccessor) => void,
|
|
67
|
-
private readonly onError: (error: RequestError) => void,
|
|
68
|
-
private readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,
|
|
63
|
+
private readonly onUpdate: (newData: TreeRootAccessor, binding: DataBinding) => void,
|
|
64
|
+
private readonly onError: (error: RequestError, binding: DataBinding) => void,
|
|
65
|
+
private readonly onPersistSuccess: (result: SuccessfulPersistResult, binding: DataBinding) => void,
|
|
69
66
|
) {
|
|
70
67
|
this.config = new Config()
|
|
71
|
-
this.treeStore = new TreeStore()
|
|
72
68
|
this.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)
|
|
73
69
|
this.asyncBatchUpdatesOptions = {
|
|
74
70
|
...this.batchUpdatesOptions,
|
|
@@ -89,7 +85,6 @@ export class DataBinding {
|
|
|
89
85
|
this.stateInitializer = new StateInitializer(
|
|
90
86
|
this.accessorErrorManager,
|
|
91
87
|
this.batchUpdatesOptions,
|
|
92
|
-
this.config,
|
|
93
88
|
this.eventManager,
|
|
94
89
|
this.treeStore,
|
|
95
90
|
)
|
|
@@ -144,9 +139,9 @@ export class DataBinding {
|
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
const generator = new MutationGenerator(this.treeStore)
|
|
147
|
-
const
|
|
142
|
+
const mutationResult = generator.getPersistMutation()
|
|
148
143
|
|
|
149
|
-
if (
|
|
144
|
+
if (mutationResult === undefined) {
|
|
150
145
|
this.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.
|
|
151
146
|
const persistSuccessOptions: PersistSuccessOptions = {
|
|
152
147
|
...this.bindingOperations,
|
|
@@ -159,27 +154,28 @@ export class DataBinding {
|
|
|
159
154
|
type: 'nothingToPersist',
|
|
160
155
|
}
|
|
161
156
|
}
|
|
157
|
+
const { query, operations } = mutationResult
|
|
162
158
|
|
|
163
|
-
const mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(
|
|
159
|
+
const mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(query, {
|
|
164
160
|
signal,
|
|
165
161
|
})
|
|
166
162
|
|
|
167
163
|
if (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {
|
|
168
164
|
this.onError({
|
|
169
165
|
type: 'gqlError',
|
|
170
|
-
query
|
|
166
|
+
query,
|
|
171
167
|
errors: mutationResponse.errors,
|
|
172
|
-
})
|
|
168
|
+
}, this)
|
|
173
169
|
}
|
|
174
|
-
|
|
175
|
-
const mutationData = mutationResponse.data?.transaction ?? {}
|
|
176
|
-
const aliases = Object.keys(mutationData)
|
|
177
|
-
if (!mutationResponse.data) {
|
|
170
|
+
if (!mutationResponse.data?.transaction) {
|
|
178
171
|
throw {
|
|
179
|
-
errors:
|
|
172
|
+
errors: [],
|
|
180
173
|
type: 'invalidResponse',
|
|
181
174
|
}
|
|
182
|
-
}
|
|
175
|
+
}
|
|
176
|
+
const { __typename, ok, errorMessage, ...mutationData } = mutationResponse.data.transaction
|
|
177
|
+
const aliases = Object.keys(mutationData)
|
|
178
|
+
if (aliases.every(item => mutationData[item].ok)) {
|
|
183
179
|
const persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)
|
|
184
180
|
const result: SuccessfulPersistResult = {
|
|
185
181
|
type: 'justSuccess',
|
|
@@ -196,6 +192,7 @@ export class DataBinding {
|
|
|
196
192
|
subTreeResponse.node,
|
|
197
193
|
]),
|
|
198
194
|
),
|
|
195
|
+
operations,
|
|
199
196
|
)
|
|
200
197
|
const persistSuccessOptions: PersistSuccessOptions = {
|
|
201
198
|
...this.bindingOperations,
|
|
@@ -212,13 +209,16 @@ export class DataBinding {
|
|
|
212
209
|
...result,
|
|
213
210
|
afterPersistError: e,
|
|
214
211
|
}
|
|
215
|
-
this.onPersistSuccess(resultWithError)
|
|
212
|
+
this.onPersistSuccess(resultWithError, this)
|
|
216
213
|
return resultWithError
|
|
217
214
|
}
|
|
218
|
-
this.onPersistSuccess(result)
|
|
215
|
+
this.onPersistSuccess(result, this)
|
|
219
216
|
return result
|
|
220
217
|
} else {
|
|
221
|
-
|
|
218
|
+
if (errorMessage) {
|
|
219
|
+
console.error(errorMessage)
|
|
220
|
+
}
|
|
221
|
+
this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData, operations))
|
|
222
222
|
await this.eventManager.triggerOnPersistError(persistErrorOptions)
|
|
223
223
|
await onPersistError?.(persistErrorOptions)
|
|
224
224
|
if (shouldTryAgain) {
|
|
@@ -249,7 +249,7 @@ export class DataBinding {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
private resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {
|
|
252
|
-
this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))
|
|
252
|
+
this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations), this)
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
// This is currently useless but potentially future-compatible
|
|
@@ -270,9 +270,7 @@ export class DataBinding {
|
|
|
270
270
|
if (options.signal?.aborted) {
|
|
271
271
|
return Promise.reject(DataBindingExtendAborted)
|
|
272
272
|
}
|
|
273
|
-
const
|
|
274
|
-
this.treeStore.setSchema(schema)
|
|
275
|
-
const markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).generate()
|
|
273
|
+
const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()
|
|
276
274
|
|
|
277
275
|
if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
|
|
278
276
|
// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this
|
|
@@ -340,7 +338,7 @@ export class DataBinding {
|
|
|
340
338
|
}
|
|
341
339
|
|
|
342
340
|
this.eventManager.syncOperation(() => {
|
|
343
|
-
this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})
|
|
341
|
+
this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {}, aggregateMarkerTreeRoot)
|
|
344
342
|
|
|
345
343
|
for (const extension of pendingExtensions) {
|
|
346
344
|
this.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)
|
|
@@ -369,7 +367,7 @@ export class DataBinding {
|
|
|
369
367
|
if (metadata.name === 'AbortError') {
|
|
370
368
|
return
|
|
371
369
|
}
|
|
372
|
-
this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))
|
|
370
|
+
this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata), this)
|
|
373
371
|
}
|
|
374
372
|
|
|
375
373
|
if (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {
|
|
@@ -377,7 +375,7 @@ export class DataBinding {
|
|
|
377
375
|
type: 'gqlError',
|
|
378
376
|
query: query ?? 'unknown query',
|
|
379
377
|
errors: queryResponse.errors,
|
|
380
|
-
})
|
|
378
|
+
}, this)
|
|
381
379
|
}
|
|
382
380
|
|
|
383
381
|
return queryResponse
|
|
@@ -422,20 +420,6 @@ export class DataBinding {
|
|
|
422
420
|
})
|
|
423
421
|
}
|
|
424
422
|
|
|
425
|
-
private getOrLoadSchema(): Schema | Promise<Schema> {
|
|
426
|
-
const existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)
|
|
427
|
-
if (existing !== undefined) {
|
|
428
|
-
return existing
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))
|
|
432
|
-
schemaPromise.then(schema => {
|
|
433
|
-
DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)
|
|
434
|
-
})
|
|
435
|
-
DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)
|
|
436
|
-
return schemaPromise
|
|
437
|
-
}
|
|
438
|
-
|
|
439
423
|
private static getNextTreeRootIdSeed = (() => {
|
|
440
424
|
let seed = 1
|
|
441
425
|
return () => seed++
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export class DirtinessTracker {
|
|
2
2
|
private changesCount = 0
|
|
3
|
-
private
|
|
3
|
+
private touchedCount = 0
|
|
4
4
|
|
|
5
|
-
public
|
|
6
|
-
return this.
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
public getTotalChangesCount() {
|
|
10
|
-
return this.totalChangesCount
|
|
5
|
+
public getTotalTouchCount() {
|
|
6
|
+
return this.touchedCount
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
public hasChanges() {
|
|
@@ -18,16 +14,8 @@ export class DirtinessTracker {
|
|
|
18
14
|
this.changesCount = 0
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
public increment() {
|
|
22
|
-
this.totalChangesCount++
|
|
23
|
-
this.changesCount++
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public decrement() {
|
|
27
|
-
this.changesCount--
|
|
28
|
-
}
|
|
29
|
-
|
|
30
17
|
public increaseBy(delta: number) {
|
|
31
18
|
this.changesCount += delta
|
|
19
|
+
this.touchedCount++
|
|
32
20
|
}
|
|
33
21
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { ErrorAccessor } from '../accessors'
|
|
2
2
|
import type { ExecutionError, MutationDataResponse, MutationResponse, ValidationError } from '../accessorTree'
|
|
3
|
-
import type { PlaceholderName } from '../treeParameters'
|
|
3
|
+
import type { EntityId, FieldName, PlaceholderName } from '../treeParameters'
|
|
4
4
|
import { assertNever } from '../utils'
|
|
5
|
-
import { MutationAlias
|
|
5
|
+
import { MutationAlias } from './requestAliases'
|
|
6
|
+
import { SubMutationOperation } from './MutationGenerator'
|
|
6
7
|
|
|
7
8
|
class ErrorsPreprocessor {
|
|
8
|
-
public constructor(
|
|
9
|
+
public constructor(
|
|
10
|
+
private readonly requestResponse: MutationDataResponse,
|
|
11
|
+
private readonly operations: SubMutationOperation[],
|
|
12
|
+
) {}
|
|
9
13
|
|
|
10
14
|
public preprocess(): ErrorsPreprocessor.ErrorTreeRoot {
|
|
11
15
|
const treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()
|
|
@@ -14,43 +18,37 @@ class ErrorsPreprocessor {
|
|
|
14
18
|
return treeRoot
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
for (const
|
|
18
|
-
const mutationResponse = this.requestResponse[
|
|
21
|
+
for (const operation of this.operations) {
|
|
22
|
+
const mutationResponse = this.requestResponse[operation.alias]
|
|
19
23
|
const processedResponse = this.processMutationResponse(mutationResponse)
|
|
20
24
|
|
|
21
25
|
if (processedResponse === undefined) {
|
|
22
26
|
continue
|
|
23
27
|
}
|
|
28
|
+
const { subTreeType, subTreePlaceholder, id } = operation
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (operation === undefined) {
|
|
28
|
-
continue
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { subTreeType, subTreePlaceholder, entityId } = operation
|
|
32
|
-
|
|
33
|
-
if (subTreeType === mutationOperationSubTreeType.singleEntity) {
|
|
30
|
+
if (subTreeType === 'single') {
|
|
34
31
|
if (treeRoot.has(subTreePlaceholder)) {
|
|
35
32
|
return this.rejectCorruptData()
|
|
36
33
|
}
|
|
37
34
|
treeRoot.set(subTreePlaceholder, processedResponse)
|
|
38
|
-
} else if (subTreeType ===
|
|
35
|
+
} else if (subTreeType === 'list') {
|
|
39
36
|
const child = treeRoot.get(subTreePlaceholder)
|
|
40
37
|
|
|
41
38
|
if (child === undefined) {
|
|
42
39
|
treeRoot.set(subTreePlaceholder, {
|
|
43
40
|
nodeType: 'iNode',
|
|
44
|
-
children: new Map([[
|
|
41
|
+
children: new Map([[id, processedResponse]]),
|
|
45
42
|
validation: [],
|
|
46
43
|
execution: [],
|
|
47
44
|
})
|
|
48
45
|
} else if (child.nodeType === 'iNode') {
|
|
49
|
-
child.children.set(
|
|
46
|
+
child.children.set(id, processedResponse)
|
|
50
47
|
}
|
|
51
48
|
} else {
|
|
52
49
|
return assertNever(subTreeType)
|
|
53
50
|
}
|
|
51
|
+
|
|
54
52
|
}
|
|
55
53
|
return treeRoot
|
|
56
54
|
}
|
|
@@ -227,7 +225,7 @@ namespace ErrorsPreprocessor {
|
|
|
227
225
|
|
|
228
226
|
export interface ErrorINode extends BaseErrorNode {
|
|
229
227
|
nodeType: 'iNode'
|
|
230
|
-
children: Map<
|
|
228
|
+
children: Map<FieldName | EntityId, ErrorNode>
|
|
231
229
|
}
|
|
232
230
|
|
|
233
231
|
export type ErrorNode = ErrorINode | LeafErrorNode
|
package/src/core/EventManager.ts
CHANGED
|
@@ -346,9 +346,12 @@ export class EventManager {
|
|
|
346
346
|
|
|
347
347
|
for (const [state, callback] of callbackQueue) {
|
|
348
348
|
correspondingStates.push(state)
|
|
349
|
+
const changesCountBefore = this.dirtinessTracker.getTotalTouchCount()
|
|
350
|
+
let validateChanges = false
|
|
349
351
|
try {
|
|
350
352
|
const result = callback(state.getAccessor as any, options as any) // TS can't quite handle this but this is sound.
|
|
351
353
|
if (result instanceof Promise) {
|
|
354
|
+
validateChanges = true
|
|
352
355
|
promiseReturns.push(result)
|
|
353
356
|
} else {
|
|
354
357
|
promiseReturns.push(Promise.resolve(result))
|
|
@@ -356,10 +359,15 @@ export class EventManager {
|
|
|
356
359
|
} catch (e) {
|
|
357
360
|
promiseReturns.push(Promise.reject(e))
|
|
358
361
|
}
|
|
362
|
+
if (validateChanges) {
|
|
363
|
+
this.validateWithoutChanges(changesCountBefore, eventType)
|
|
364
|
+
}
|
|
359
365
|
}
|
|
360
366
|
// TODO timeout
|
|
361
367
|
|
|
362
|
-
const
|
|
368
|
+
const changesCountBefore = this.dirtinessTracker.getTotalTouchCount()
|
|
369
|
+
const newCallbacks = await Promise.allSettled(promiseReturns)
|
|
370
|
+
this.validateWithoutChanges(changesCountBefore, eventType)
|
|
363
371
|
|
|
364
372
|
callbackQueue.length = 0 // Empties the queue
|
|
365
373
|
|
|
@@ -561,20 +569,18 @@ export class EventManager {
|
|
|
561
569
|
}
|
|
562
570
|
}
|
|
563
571
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
const changesCountAfter = this.dirtinessTracker.getTotalChangesCount()
|
|
572
|
+
|
|
573
|
+
private validateWithoutChanges(initialCount: number, eventType: string): void {
|
|
574
|
+
const changesCountAfter = this.dirtinessTracker.getTotalTouchCount()
|
|
568
575
|
if (import.meta.env.DEV) {
|
|
569
|
-
if (
|
|
576
|
+
if (initialCount !== changesCountAfter) {
|
|
570
577
|
// This isn't bulletproof. They could e.g. undo a change and make another one which would
|
|
571
578
|
// slip through this detection. But for most cases, it should be good enough and not too expensive.
|
|
572
579
|
throw new BindingError(
|
|
573
580
|
`A ${eventType} event handler cannot be asynchronous and alter the accessor tree at the same time. ` +
|
|
574
|
-
|
|
581
|
+
`To achieve this, prepare your data asynchronously but only touch the tree from a returned callback.`,
|
|
575
582
|
)
|
|
576
583
|
}
|
|
577
584
|
}
|
|
578
|
-
return result
|
|
579
585
|
}
|
|
580
586
|
}
|