@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
|
@@ -11,88 +11,70 @@ import type { AccessorTreeState } from './AccessorTreeState'
|
|
|
11
11
|
import type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'
|
|
12
12
|
import { accessorTreeStateReducer } from './accessorTreeStateReducer'
|
|
13
13
|
import type { RequestError } from './RequestError'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
import { Environment } from '../dao'
|
|
15
|
+
import { Schema, SchemaLoader } from '../core/schema'
|
|
16
|
+
import { TreeStore } from '../core/TreeStore'
|
|
17
|
+
import { useIsMounted } from '@contember/react-utils'
|
|
18
18
|
|
|
19
19
|
export const useDataBinding = ({
|
|
20
20
|
nodeTree,
|
|
21
|
-
refreshOnEnvironmentChange = true,
|
|
22
21
|
refreshOnPersist = false,
|
|
23
22
|
}: AccessorTreeStateOptions): AccessorTreeState => {
|
|
24
23
|
const contentClient = useCurrentContentGraphQlClient()
|
|
25
24
|
const systemClient = useCurrentSystemGraphQlClient()
|
|
26
25
|
const tenantClient = useTenantGraphQlClient()
|
|
27
26
|
const environment = useEnvironment()
|
|
27
|
+
const currentTreeStore = useRef<TreeStore>()
|
|
28
|
+
const isMountedRef = useIsMounted()
|
|
29
|
+
const [schema, setSchema] = useState<Schema>()
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const resetDataBinding = useCallback((environment: Environment, newStore: boolean) => {
|
|
32
|
+
const onUpdate = (data: TreeRootAccessor, binding: DataBinding) => {
|
|
33
|
+
if (isMountedRef.current) {
|
|
34
|
+
dispatch({ type: 'setData', data, binding })
|
|
35
|
+
}
|
|
36
|
+
}
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
const onError = (error: RequestError, binding: DataBinding) => {
|
|
39
|
+
if (isMountedRef.current) {
|
|
40
|
+
dispatch({ type: 'failWithError', error, binding })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
const onPersistSuccess = () => {
|
|
45
|
+
if (isMountedRef.current && refreshOnPersist) {
|
|
46
|
+
resetDataBinding(environment, true)
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
}, [])
|
|
43
|
-
const onError = useCallback((error: RequestError) => {
|
|
44
|
-
if (!isMountedRef.current) {
|
|
45
|
-
return
|
|
49
|
+
|
|
50
|
+
if (currentTreeStore.current === undefined || newStore) {
|
|
51
|
+
currentTreeStore.current = new TreeStore(environment.getSchema())
|
|
46
52
|
}
|
|
47
|
-
dispatch({
|
|
48
|
-
type: 'failWithError',
|
|
49
|
-
error,
|
|
50
|
-
})
|
|
51
|
-
}, [])
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
if (!isMountedRef.current || !refreshOnPersist) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
dispatch({ type: 'reset' })
|
|
60
|
-
setDataBinding(create())
|
|
61
|
-
})
|
|
62
|
-
return create()
|
|
63
|
-
},
|
|
64
|
-
[contentClient, systemClient, tenantClient, environment, onUpdate, onError, refreshOnPersist],
|
|
65
|
-
)
|
|
54
|
+
const binding = new DataBinding(contentClient, systemClient, tenantClient, currentTreeStore.current, environment, onUpdate, onError, onPersistSuccess)
|
|
55
|
+
dispatch({ type: 'reset', binding, environment })
|
|
56
|
+
}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist])
|
|
66
57
|
|
|
67
|
-
const [
|
|
58
|
+
const [state, dispatch] = useReducer(accessorTreeStateReducer, {
|
|
59
|
+
name: 'initializing',
|
|
60
|
+
environment,
|
|
61
|
+
})
|
|
68
62
|
|
|
69
63
|
useEffect(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// To make their lives a bit easier, we do this.
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
dataBinding.extendTree(nodeTree)
|
|
78
|
-
}, [nodeTree, dataBinding, state.name])
|
|
64
|
+
(async () => {
|
|
65
|
+
setSchema(await SchemaLoader.loadSchema(contentClient))
|
|
66
|
+
})()
|
|
67
|
+
}, [contentClient])
|
|
79
68
|
|
|
80
69
|
useEffect(() => {
|
|
81
|
-
if (
|
|
82
|
-
|
|
70
|
+
if (schema) {
|
|
71
|
+
resetDataBinding(environment.withSchema(schema), false)
|
|
83
72
|
}
|
|
84
|
-
|
|
85
|
-
// This essentially just reacts to new environments.
|
|
86
|
-
setDataBinding(createDataBinding())
|
|
87
|
-
}, [createDataBinding, refreshOnEnvironmentChange])
|
|
73
|
+
}, [resetDataBinding, schema, environment])
|
|
88
74
|
|
|
89
75
|
useEffect(() => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return () => {
|
|
93
|
-
isMountedRef.current = false
|
|
94
|
-
}
|
|
95
|
-
}, [])
|
|
76
|
+
state.binding?.extendTree(nodeTree)
|
|
77
|
+
}, [nodeTree, state.binding])
|
|
96
78
|
|
|
97
79
|
return state
|
|
98
80
|
}
|
|
@@ -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'
|
|
@@ -42,7 +42,7 @@ class EntityAccessor implements Errorable {
|
|
|
42
42
|
public readonly getAccessor: EntityAccessor.GetEntityAccessor,
|
|
43
43
|
) {}
|
|
44
44
|
|
|
45
|
-
public get idOnServer():
|
|
45
|
+
public get idOnServer(): EntityId | undefined {
|
|
46
46
|
return this.runtimeId.existsOnServer ? this.runtimeId.value : undefined
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -116,21 +116,6 @@ class EntityAccessor implements Errorable {
|
|
|
116
116
|
return this.getRelativeEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))
|
|
117
117
|
}
|
|
118
118
|
|
|
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
119
|
//
|
|
135
120
|
|
|
136
121
|
/**
|
|
@@ -173,40 +158,6 @@ class EntityAccessor implements Errorable {
|
|
|
173
158
|
}
|
|
174
159
|
return record.getAccessor()
|
|
175
160
|
}
|
|
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
161
|
}
|
|
211
162
|
|
|
212
163
|
namespace EntityAccessor {
|
|
@@ -16,7 +16,7 @@ class EntityListAccessor implements Errorable {
|
|
|
16
16
|
private readonly stateKey: 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
|
|
@@ -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, SchemaValidator } 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, ...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,13 @@ 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
|
-
this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))
|
|
218
|
+
this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData, operations))
|
|
222
219
|
await this.eventManager.triggerOnPersistError(persistErrorOptions)
|
|
223
220
|
await onPersistError?.(persistErrorOptions)
|
|
224
221
|
if (shouldTryAgain) {
|
|
@@ -249,7 +246,7 @@ export class DataBinding {
|
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
private resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {
|
|
252
|
-
this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))
|
|
249
|
+
this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations), this)
|
|
253
250
|
}
|
|
254
251
|
|
|
255
252
|
// This is currently useless but potentially future-compatible
|
|
@@ -276,16 +273,6 @@ export class DataBinding {
|
|
|
276
273
|
// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this
|
|
277
274
|
// could still be false.
|
|
278
275
|
|
|
279
|
-
const schema = await this.getOrLoadSchema()
|
|
280
|
-
this.treeStore.setSchema(schema)
|
|
281
|
-
if (import.meta.env.DEV) {
|
|
282
|
-
// For most trees, checking this against the schema should be unnecessary since if we already effectively
|
|
283
|
-
// have this tree root, then assuming everything we already have is valid, this should match the schema as well.
|
|
284
|
-
// However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean
|
|
285
|
-
// towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.
|
|
286
|
-
SchemaValidator.assertTreeValid(schema, markerTreeRoot)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
276
|
return this.eventManager.syncOperation(() => {
|
|
290
277
|
const newTreeRootId = this.getNewTreeRootId()
|
|
291
278
|
this.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)
|
|
@@ -341,27 +328,14 @@ export class DataBinding {
|
|
|
341
328
|
|
|
342
329
|
const aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))
|
|
343
330
|
|
|
344
|
-
|
|
345
|
-
// in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we
|
|
346
|
-
// just get a "400 Bad Request" but that's not enough to make us delay the happy path.
|
|
347
|
-
const [aggregatePersistedData, schema] = await Promise.all([
|
|
348
|
-
this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),
|
|
349
|
-
this.getOrLoadSchema(),
|
|
350
|
-
])
|
|
351
|
-
this.treeStore.setSchema(schema)
|
|
352
|
-
|
|
353
|
-
if (import.meta.env.DEV) {
|
|
354
|
-
for (const extension of pendingExtensions) {
|
|
355
|
-
SchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)
|
|
356
|
-
}
|
|
357
|
-
}
|
|
331
|
+
const aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)
|
|
358
332
|
|
|
359
333
|
if (aggregateSignal?.aborted) {
|
|
360
334
|
return
|
|
361
335
|
}
|
|
362
336
|
|
|
363
337
|
this.eventManager.syncOperation(() => {
|
|
364
|
-
this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})
|
|
338
|
+
this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {}, aggregateMarkerTreeRoot)
|
|
365
339
|
|
|
366
340
|
for (const extension of pendingExtensions) {
|
|
367
341
|
this.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)
|
|
@@ -390,7 +364,7 @@ export class DataBinding {
|
|
|
390
364
|
if (metadata.name === 'AbortError') {
|
|
391
365
|
return
|
|
392
366
|
}
|
|
393
|
-
this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))
|
|
367
|
+
this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata), this)
|
|
394
368
|
}
|
|
395
369
|
|
|
396
370
|
if (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {
|
|
@@ -398,7 +372,7 @@ export class DataBinding {
|
|
|
398
372
|
type: 'gqlError',
|
|
399
373
|
query: query ?? 'unknown query',
|
|
400
374
|
errors: queryResponse.errors,
|
|
401
|
-
})
|
|
375
|
+
}, this)
|
|
402
376
|
}
|
|
403
377
|
|
|
404
378
|
return queryResponse
|
|
@@ -443,20 +417,6 @@ export class DataBinding {
|
|
|
443
417
|
})
|
|
444
418
|
}
|
|
445
419
|
|
|
446
|
-
private getOrLoadSchema(): Schema | Promise<Schema> {
|
|
447
|
-
const existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)
|
|
448
|
-
if (existing !== undefined) {
|
|
449
|
-
return existing
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))
|
|
453
|
-
schemaPromise.then(schema => {
|
|
454
|
-
DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)
|
|
455
|
-
})
|
|
456
|
-
DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)
|
|
457
|
-
return schemaPromise
|
|
458
|
-
}
|
|
459
|
-
|
|
460
420
|
private static getNextTreeRootIdSeed = (() => {
|
|
461
421
|
let seed = 1
|
|
462
422
|
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
|
}
|