@contember/binding 1.1.0-alpha.1 → 1.1.0-alpha.12
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/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 -8
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +10 -10
- 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 +2 -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 +23 -37
- 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 +175 -136
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +93 -130
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +22 -30
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +4 -4
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeStore.js +9 -20
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +10 -9
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +1 -1
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js +2 -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 +34 -2
- 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 +6 -1
- 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/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 -8
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +10 -10
- 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 +2 -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 +23 -37
- 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 +175 -136
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js +93 -130
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +22 -30
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +4 -4
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeStore.js +9 -20
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/VariableInputTransformer.js.map +1 -1
- package/dist/production/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +10 -9
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.js +1 -1
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js +2 -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 +34 -2
- 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 +6 -1
- 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 +3 -1
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts +3 -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/accessorPropagation/useGetEntityListSubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorSorting/addEntityAtIndex.d.ts +1 -1
- package/dist/types/accessorSorting/addEntityAtIndex.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 -5
- 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 +2 -2
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +2 -2
- package/dist/types/accessorTree/QueryRequestResponse.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 +4 -2
- 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/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 +3 -1
- 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 +5 -5
- 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.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 +9 -0
- 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/fieldHelpers/helpers/TemporalFieldHelper.d.ts +1 -1
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -1
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +1 -1
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.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/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 -3
- package/src/accessorTree/NormalizedPersistedData.ts +2 -2
- package/src/accessorTree/QueryRequestResponse.ts +2 -2
- 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 +20 -7
- package/src/accessors/EntityListAccessor.ts +9 -9
- package/src/accessors/FieldAccessor.ts +5 -5
- package/src/core/AccessorErrorManager.ts +3 -2
- package/src/core/Config.ts +0 -1
- package/src/core/DataBinding.ts +24 -40
- package/src/core/DirtinessTracker.ts +4 -16
- package/src/core/ErrorsPreprocessor.ts +14 -16
- package/src/core/EventManager.ts +14 -8
- package/src/core/MutationGenerator.ts +244 -183
- package/src/core/RequestResponseNormalizer.ts +110 -161
- package/src/core/StateInitializer.ts +35 -47
- package/src/core/TreeAugmenter.ts +5 -4
- package/src/core/TreeStore.ts +11 -21
- package/src/core/VariableInputTransformer.ts +2 -2
- package/src/core/factories/createBatchUpdatesOptions.ts +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/operations/EntityOperations.ts +9 -10
- package/src/core/operations/ListOperations.ts +2 -1
- package/src/core/requestAliases/MutationAlias.ts +2 -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 +42 -1
- 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/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
|
@@ -51,7 +51,7 @@ export class EntityOperations {
|
|
|
51
51
|
const persistedData = this.treeStore.persistedEntityData.get(outerState.entity.id.uniqueValue)
|
|
52
52
|
|
|
53
53
|
const entityName = outerState.entity.entityName
|
|
54
|
-
const fieldSchema = this.treeStore.schema.
|
|
54
|
+
const fieldSchema = this.treeStore.schema.getEntityFieldOrUndefined(entityName, fieldName)
|
|
55
55
|
|
|
56
56
|
if (fieldSchema === undefined) {
|
|
57
57
|
throw new BindingError(
|
|
@@ -127,16 +127,11 @@ export class EntityOperations {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
const persistedId = persistedData?.get(targetHasOneMarker.placeholderName)
|
|
130
|
-
if (persistedId instanceof ServerId) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
changesDelta++ // We're changing it from the persisted id.
|
|
135
|
-
}
|
|
130
|
+
if (persistedId instanceof ServerId && persistedId.value === stateToConnect.entity.id.value) {
|
|
131
|
+
changesDelta-- // It was removed from the list but now we're adding it back.
|
|
132
|
+
} else if (persistedId instanceof ServerId && persistedId.value === previouslyConnectedState.entity.id.value) {
|
|
133
|
+
changesDelta++ // We're changing it from the persisted id.
|
|
136
134
|
} else if (!previouslyConnectedState.entity.id.existsOnServer) {
|
|
137
|
-
// This assumes the invariant enforced above that we cannot connect unpersisted entities.
|
|
138
|
-
// Hence the previouslyConnectedState still refers to the entity created initially.
|
|
139
|
-
|
|
140
135
|
if (
|
|
141
136
|
persistedId === null || // We're updating.
|
|
142
137
|
(persistedId === undefined && // We're creating.
|
|
@@ -145,6 +140,9 @@ export class EntityOperations {
|
|
|
145
140
|
changesDelta++
|
|
146
141
|
}
|
|
147
142
|
}
|
|
143
|
+
if (stateToConnect.type === 'entityRealm') {
|
|
144
|
+
changesDelta += stateToConnect.unpersistedChangesCount
|
|
145
|
+
}
|
|
148
146
|
|
|
149
147
|
// TODO do something about the existing state…
|
|
150
148
|
|
|
@@ -152,6 +150,7 @@ export class EntityOperations {
|
|
|
152
150
|
stateToConnect.entity.id,
|
|
153
151
|
stateToConnect.entity.entityName,
|
|
154
152
|
previouslyConnectedState.blueprint,
|
|
153
|
+
stateToConnect,
|
|
155
154
|
)
|
|
156
155
|
|
|
157
156
|
this.eventManager.registerUpdatedConnection(state, targetHasOneMarker.placeholderName)
|
|
@@ -106,7 +106,8 @@ export class ListOperations {
|
|
|
106
106
|
if (persistedEntityIds.has(idToConnect.value)) {
|
|
107
107
|
// It was removed from the list but now we're adding it back.
|
|
108
108
|
changesDelta--
|
|
109
|
-
} else {
|
|
109
|
+
} else if (idToConnect.existsOnServer) {
|
|
110
|
+
// ignoring unpersisted entities
|
|
110
111
|
changesDelta++
|
|
111
112
|
}
|
|
112
113
|
if (stateToConnect.type === 'entityRealm') {
|
|
@@ -1,67 +1,12 @@
|
|
|
1
1
|
import type { RuntimeId } from '../../accessorTree'
|
|
2
|
-
import { BindingError } from '../../BindingError'
|
|
3
|
-
import type { PlaceholderName, TreeRootId } from '../../treeParameters'
|
|
4
|
-
import { mutationOperationSubTreeType } from './mutationOperationSubTreeType'
|
|
5
|
-
import type { mutationOperationType } from './mutationOperationType'
|
|
6
|
-
import type { TopLevelMutationOperation } from './TopLevelMutationOperation'
|
|
7
|
-
|
|
8
|
-
const mutationAliasRegex = /^(?:(u)|(t)([^t]+)t)(.+)__([cud])([sl])(.+)$/
|
|
9
|
-
|
|
10
|
-
const uuidToAliasRegex = /-/g
|
|
11
|
-
const uuidToAliasReplacement = '_'
|
|
12
|
-
|
|
13
|
-
const aliasToUuidRegex = /_/g
|
|
14
|
-
const aliasToUuidReplacement = '-'
|
|
15
|
-
|
|
16
|
-
// This is just a random character we use to make sure the alias doesn't start with a number as UUIDs often do.
|
|
17
|
-
const standaloneUuidPrefix = uuidToAliasReplacement
|
|
18
2
|
|
|
19
3
|
export class MutationAlias {
|
|
20
|
-
public static encodeTopLevel(operation: TopLevelMutationOperation): string {
|
|
21
|
-
const treeRootId = operation.treeRootId === undefined ? 'u' : `t${operation.treeRootId.replace('-', '_')}t`
|
|
22
|
-
const entityId = String(operation.entityId).replace(uuidToAliasRegex, uuidToAliasReplacement)
|
|
23
|
-
|
|
24
|
-
const alias = `${treeRootId}${operation.subTreePlaceholder}__${operation.type}${operation.subTreeType}${entityId}`
|
|
25
|
-
|
|
26
|
-
if (import.meta.env.DEV) {
|
|
27
|
-
const matches = alias.match(mutationAliasRegex)
|
|
28
|
-
|
|
29
|
-
if (!matches) {
|
|
30
|
-
throw new BindingError()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return alias
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public static decodeTopLevel(alias: string): TopLevelMutationOperation | undefined {
|
|
38
|
-
const matches = alias.match(mutationAliasRegex)
|
|
39
|
-
|
|
40
|
-
if (!matches) {
|
|
41
|
-
return undefined
|
|
42
|
-
}
|
|
43
|
-
const treeRootId: TreeRootId | undefined = matches[1] === 'u' ? undefined : matches[3]
|
|
44
|
-
const subTreePlaceholder: PlaceholderName = matches[4]
|
|
45
|
-
const type = matches[5] as typeof mutationOperationType[keyof typeof mutationOperationType]
|
|
46
|
-
const subTreeType =
|
|
47
|
-
matches[6] === 's' ? mutationOperationSubTreeType.singleEntity : mutationOperationSubTreeType.entityList
|
|
48
|
-
const entityId = matches[7].replace(aliasToUuidRegex, aliasToUuidReplacement)
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
treeRootId,
|
|
52
|
-
subTreePlaceholder,
|
|
53
|
-
type,
|
|
54
|
-
subTreeType,
|
|
55
|
-
entityId,
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
4
|
public static encodeEntityId(entityId: RuntimeId): string {
|
|
60
|
-
return
|
|
5
|
+
return `_${String(entityId.value).replace(/-/g, '_')}`
|
|
61
6
|
}
|
|
62
7
|
|
|
63
8
|
public static decodeEntityId(alias: string): RuntimeId['value'] {
|
|
64
|
-
const stringId = `${alias.substring(
|
|
9
|
+
const stringId = `${alias.substring(1).replace(/_/g, '-')}`
|
|
65
10
|
const intId = parseInt(stringId)
|
|
66
11
|
return intId.toString() === stringId ? intId : stringId
|
|
67
12
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { EntityName } from '../../treeParameters'
|
|
2
2
|
import type { SchemaColumn } from './SchemaColumn'
|
|
3
3
|
import type { SchemaRelation } from './SchemaRelation'
|
|
4
|
-
import type { SchemaUniqueConstraint } from './SchemaUniqueConstraint'
|
|
5
4
|
|
|
6
5
|
export type RawSchemaFields = Array<SchemaRelation | SchemaColumn>
|
|
7
6
|
|
|
@@ -9,5 +8,5 @@ export interface RawSchemaEntity {
|
|
|
9
8
|
name: EntityName
|
|
10
9
|
customPrimaryAllowed: boolean
|
|
11
10
|
fields: RawSchemaFields
|
|
12
|
-
unique:
|
|
11
|
+
unique: { fields: string[] }[]
|
|
13
12
|
}
|
|
@@ -1,16 +1,50 @@
|
|
|
1
1
|
import type { EntityName, FieldName } from '../../treeParameters'
|
|
2
|
+
import { BindingError } from '../../BindingError'
|
|
2
3
|
import type { SchemaField } from './SchemaField'
|
|
3
4
|
import type { SchemaStore } from './SchemaStore'
|
|
4
5
|
import { SchemaEntity } from './SchemaEntity'
|
|
6
|
+
import { SchemaColumn } from './SchemaColumn'
|
|
7
|
+
import { SchemaRelation } from './SchemaRelation'
|
|
8
|
+
import { SchemaEnumName } from './SchemaEnums'
|
|
5
9
|
|
|
6
10
|
export class Schema {
|
|
7
|
-
public constructor(
|
|
11
|
+
public constructor(private readonly store: SchemaStore) {}
|
|
8
12
|
|
|
9
|
-
public
|
|
13
|
+
public getEnumValues(enumName: SchemaEnumName): string[] {
|
|
14
|
+
return Array.from(this.store.enums.get(enumName) ?? this.throwError(`Missing schema for enum ${enumName}`))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public getEntityOrUndefined(entityName: EntityName): SchemaEntity | undefined {
|
|
10
18
|
return this.store.entities.get(entityName)
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
public
|
|
14
|
-
return this.store.entities.
|
|
21
|
+
public getEntityNames(): string[] {
|
|
22
|
+
return Array.from(this.store.entities.keys())
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public getEntity(entityName: EntityName): SchemaEntity {
|
|
26
|
+
return this.getEntityOrUndefined(entityName) ?? this.throwError(`Missing schema for entity ${entityName}`)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getEntityFieldOrUndefined(entityName: EntityName, fieldName: FieldName): SchemaField | undefined {
|
|
30
|
+
return this.store.entities.get(entityName)?.fields.get(fieldName)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getEntityField(entityName: EntityName, fieldName: FieldName): SchemaField {
|
|
34
|
+
return this.getEntityFieldOrUndefined(entityName, fieldName) ?? this.throwError(`Missing schema for field ${entityName}.${fieldName}`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public getEntityColumn(entityName: EntityName, fieldName: FieldName): SchemaColumn {
|
|
38
|
+
const field = this.getEntityField(entityName, fieldName)
|
|
39
|
+
return field.__typename === '_Column' ? field : this.throwError(`Field ${entityName}.${fieldName} is not of type column`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public getEntityRelation(entityName: EntityName, fieldName: FieldName): SchemaRelation {
|
|
43
|
+
const field = this.getEntityField(entityName, fieldName)
|
|
44
|
+
return field.__typename === '_Relation' ? field : this.throwError(`Field ${entityName}.${fieldName} is not of type relation`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private throwError(message: string): never {
|
|
48
|
+
throw new BindingError(message)
|
|
15
49
|
}
|
|
16
50
|
}
|
|
@@ -4,7 +4,7 @@ import type { SchemaEnumName } from './SchemaEnums'
|
|
|
4
4
|
|
|
5
5
|
export interface SchemaColumn {
|
|
6
6
|
__typename: '_Column'
|
|
7
|
-
defaultValue: string | null // JSON
|
|
7
|
+
defaultValue: string | number | boolean | null // JSON
|
|
8
8
|
name: FieldName
|
|
9
9
|
nullable: boolean
|
|
10
10
|
type: SchemaColumnType
|
|
@@ -4,6 +4,8 @@ import { Schema } from './Schema'
|
|
|
4
4
|
import { SchemaPreprocessor } from './SchemaPreprocessor'
|
|
5
5
|
|
|
6
6
|
export class SchemaLoader {
|
|
7
|
+
private static readonly schemaLoadCache: Map<string, Promise<Schema>> = new Map()
|
|
8
|
+
|
|
7
9
|
private static readonly schemaQuery =
|
|
8
10
|
'query {\n' +
|
|
9
11
|
' schema {\n' +
|
|
@@ -45,18 +47,18 @@ export class SchemaLoader {
|
|
|
45
47
|
|
|
46
48
|
public static async loadSchema(
|
|
47
49
|
client: GraphQlClient,
|
|
48
|
-
maxAttempts: number,
|
|
49
50
|
options?: GraphQlClientRequestOptions,
|
|
50
51
|
): Promise<Schema> {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
|
|
53
|
+
const existing = this.schemaLoadCache.get(client.apiUrl)
|
|
54
|
+
if (existing !== undefined) {
|
|
55
|
+
return existing
|
|
56
|
+
}
|
|
57
|
+
const schemaPromise = (async () => {
|
|
58
|
+
const raw: { data: { schema: RawSchema } } = await client.sendRequest(this.schemaQuery, options)
|
|
59
|
+
return new Schema(SchemaPreprocessor.processRawSchema(raw.data.schema))
|
|
60
|
+
})()
|
|
61
|
+
this.schemaLoadCache.set(client.apiUrl, schemaPromise)
|
|
62
|
+
return await schemaPromise
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -32,7 +32,7 @@ export class SchemaPreprocessor {
|
|
|
32
32
|
customPrimaryAllowed: entity.customPrimaryAllowed,
|
|
33
33
|
fields: this.processRawFields(entity.fields),
|
|
34
34
|
name: entity.name,
|
|
35
|
-
unique: entity.unique,
|
|
35
|
+
unique: entity.unique.map(it => ({ fields: new Set(it.fields) })),
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -8,7 +8,7 @@ export interface BaseRelation {
|
|
|
8
8
|
// This *CAN* be null because the whole notion of nullability doesn't make sense for ManyHasMany
|
|
9
9
|
nullable: boolean | null
|
|
10
10
|
onDelete: 'restrict' | 'cascade' | 'setNull' | null
|
|
11
|
-
orderBy: SchemaRelationOrderBy | null
|
|
11
|
+
orderBy: SchemaRelationOrderBy[] | null
|
|
12
12
|
orphanRemoval: boolean | null
|
|
13
13
|
targetEntity: EntityName
|
|
14
14
|
type: 'OneHasOne' | 'OneHasMany' | 'ManyHasOne' | 'ManyHasMany'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ErrorAccessor, FieldAccessor } from '../../accessors'
|
|
2
2
|
import type { FieldMarker } from '../../markers'
|
|
3
|
-
import type { FieldEventListenerStore, FieldName, FieldValue
|
|
3
|
+
import type { FieldEventListenerStore, FieldName, FieldValue } from '../../treeParameters'
|
|
4
4
|
import type { EntityRealmState } from './EntityRealmState'
|
|
5
5
|
|
|
6
6
|
export interface FieldState<Value extends FieldValue = FieldValue> {
|
|
@@ -13,7 +13,7 @@ export interface FieldState<Value extends FieldValue = FieldValue> {
|
|
|
13
13
|
readonly getAccessor: () => FieldAccessor
|
|
14
14
|
hasUnpersistedChanges: boolean
|
|
15
15
|
parent: EntityRealmState
|
|
16
|
-
persistedValue:
|
|
16
|
+
persistedValue: Value | undefined // Undefined means that the parent entity doesn't exist on server
|
|
17
17
|
placeholderName: FieldName
|
|
18
18
|
touchLog: Set<string> | undefined
|
|
19
19
|
value: Value | null
|
|
@@ -1,36 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { memo, NamedExoticComponent, PropsWithChildren, ReactElement } from 'react'
|
|
2
|
+
import { useEnvironment } from '../accessorPropagation/useEnvironment'
|
|
2
3
|
import type { Environment } from '../dao'
|
|
3
4
|
import { assertNever } from '../utils'
|
|
4
5
|
import type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from './MarkerProvider'
|
|
5
6
|
|
|
7
|
+
interface EnvironmentAwareFunctionComponent<P> {
|
|
8
|
+
(props: PropsWithChildren<P>, environment: Environment): ReactElement<any, any> | null;
|
|
9
|
+
displayName?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
function Component<Props extends {}>(
|
|
7
|
-
statelessRender:
|
|
13
|
+
statelessRender: EnvironmentAwareFunctionComponent<Props>,
|
|
8
14
|
displayName?: string,
|
|
9
15
|
): NamedExoticComponent<Props>
|
|
16
|
+
|
|
10
17
|
function Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(
|
|
11
|
-
statefulRender:
|
|
18
|
+
statefulRender: EnvironmentAwareFunctionComponent<Props>,
|
|
12
19
|
staticRender: (
|
|
13
20
|
props: StaticRenderProviderProps<Props, NonStaticPropNames>,
|
|
14
21
|
environment: Environment,
|
|
15
22
|
) => ReactElement | null,
|
|
16
23
|
displayName?: string,
|
|
17
24
|
): NamedExoticComponent<Props>
|
|
25
|
+
|
|
18
26
|
function Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(
|
|
19
|
-
statefulRender:
|
|
27
|
+
statefulRender: EnvironmentAwareFunctionComponent<Props>,
|
|
20
28
|
markerProvisions: MarkerProvider<Props, NonStaticPropNames>,
|
|
21
29
|
displayName?: string,
|
|
22
30
|
): NamedExoticComponent<Props>
|
|
31
|
+
|
|
23
32
|
function Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(
|
|
24
|
-
render:
|
|
33
|
+
render: EnvironmentAwareFunctionComponent<Props>,
|
|
25
34
|
decider?:
|
|
26
35
|
| string
|
|
27
36
|
| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactElement | null)
|
|
28
37
|
| MarkerProvider<Props, NonStaticPropNames>,
|
|
29
38
|
displayName?: string,
|
|
30
39
|
) {
|
|
40
|
+
const RenderWithEnv = (props: Props) => render(props, useEnvironment())
|
|
41
|
+
const renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv
|
|
42
|
+
|
|
31
43
|
if (decider === undefined || typeof decider === 'string') {
|
|
32
44
|
render.displayName = decider
|
|
33
|
-
const augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(
|
|
45
|
+
const augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)
|
|
34
46
|
augmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']
|
|
35
47
|
augmentedRender.displayName = decider
|
|
36
48
|
|
|
@@ -38,7 +50,7 @@ function Component<Props extends {}, NonStaticPropNames extends keyof Props = ne
|
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
render.displayName = displayName
|
|
41
|
-
const augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(
|
|
53
|
+
const augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)
|
|
42
54
|
augmentedRender.displayName = displayName
|
|
43
55
|
|
|
44
56
|
if (typeof decider === 'function') {
|
|
@@ -58,4 +70,5 @@ function Component<Props extends {}, NonStaticPropNames extends keyof Props = ne
|
|
|
58
70
|
assertNever(decider)
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
export type { EnvironmentAwareFunctionComponent }
|
|
61
74
|
export { Component }
|
|
@@ -3,7 +3,6 @@ import { AccessorTree, AccessorTreeState, useDataBinding } from '../accessorTree
|
|
|
3
3
|
|
|
4
4
|
export interface DataBindingProviderBaseProps {
|
|
5
5
|
children?: ReactNode
|
|
6
|
-
refreshOnEnvironmentChange?: boolean
|
|
7
6
|
refreshOnPersist?: boolean
|
|
8
7
|
}
|
|
9
8
|
|
|
@@ -26,7 +25,6 @@ export const DataBindingProvider = memo(function DataBindingProvider<StateProps
|
|
|
26
25
|
) {
|
|
27
26
|
const accessorTreeState = useDataBinding({
|
|
28
27
|
nodeTree: props.children,
|
|
29
|
-
refreshOnEnvironmentChange: props.refreshOnEnvironmentChange,
|
|
30
28
|
refreshOnPersist: props.refreshOnPersist ?? false,
|
|
31
29
|
})
|
|
32
30
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { whereToFilter } from '@contember/client'
|
|
2
1
|
import { useConstantValueInvariant } from '@contember/react-utils'
|
|
3
2
|
import { ComponentType, ReactElement, ReactNode, useCallback } from 'react'
|
|
4
3
|
import {
|
|
@@ -6,9 +5,9 @@ import {
|
|
|
6
5
|
useEntityListSubTreeParameters,
|
|
7
6
|
useGetEntityListSubTree,
|
|
8
7
|
} from '../accessorPropagation'
|
|
9
|
-
import {
|
|
8
|
+
import { PRIMARY_KEY_NAME } from '../bindingTypes'
|
|
10
9
|
import { Environment } from '../dao'
|
|
11
|
-
import { MarkerFactory
|
|
10
|
+
import { MarkerFactory } from '../queryLanguage'
|
|
12
11
|
import type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'
|
|
13
12
|
import { Component } from './Component'
|
|
14
13
|
import { EntityList, EntityListBaseProps } from './EntityList'
|
package/src/dao/Environment.ts
CHANGED
|
@@ -15,6 +15,7 @@ class Environment {
|
|
|
15
15
|
dimensions: {},
|
|
16
16
|
variables: {},
|
|
17
17
|
parameters: {},
|
|
18
|
+
extensions: new Map(),
|
|
18
19
|
})
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -107,7 +108,15 @@ class Environment {
|
|
|
107
108
|
newVariables[newName] = resolvedValue
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
return new Environment({
|
|
111
|
+
return new Environment({
|
|
112
|
+
...this.options,
|
|
113
|
+
variables: newVariables,
|
|
114
|
+
parent: this,
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public getAllVariables() {
|
|
119
|
+
return this.options.variables
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
public hasParameter(key: string): boolean {
|
|
@@ -125,6 +134,9 @@ class Environment {
|
|
|
125
134
|
return this.options.parameters[key] ?? fallback
|
|
126
135
|
}
|
|
127
136
|
|
|
137
|
+
public getAllParameters() {
|
|
138
|
+
return this.options.parameters
|
|
139
|
+
}
|
|
128
140
|
|
|
129
141
|
public withParameters(parameters: Environment.Parameters): Environment {
|
|
130
142
|
return new Environment({ ...this.options, parameters })
|
|
@@ -178,6 +190,18 @@ class Environment {
|
|
|
178
190
|
return this.options.parent
|
|
179
191
|
}
|
|
180
192
|
|
|
193
|
+
public withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {
|
|
194
|
+
return new Environment({
|
|
195
|
+
...this.options,
|
|
196
|
+
extensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public getExtension<S, R>(extension: Environment.Extension<S, R>): R {
|
|
201
|
+
const state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)
|
|
202
|
+
return extension.create(state as S, this)
|
|
203
|
+
}
|
|
204
|
+
|
|
181
205
|
public merge(other: Environment): Environment {
|
|
182
206
|
if (other === this) {
|
|
183
207
|
return this
|
|
@@ -191,6 +215,11 @@ class Environment {
|
|
|
191
215
|
if (this.options.dimensions !== other.options.dimensions) {
|
|
192
216
|
throw new BindingError(`Cannot merge two environments with different dimensions.`)
|
|
193
217
|
}
|
|
218
|
+
if (this.options.extensions !== other.options.extensions) {
|
|
219
|
+
// todo: deep compare?
|
|
220
|
+
throw new BindingError(`Cannot merge two environments with different extensions.`)
|
|
221
|
+
}
|
|
222
|
+
|
|
194
223
|
if (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {
|
|
195
224
|
return this
|
|
196
225
|
}
|
|
@@ -224,6 +253,7 @@ namespace Environment {
|
|
|
224
253
|
parameters: Parameters
|
|
225
254
|
variables: CustomVariables
|
|
226
255
|
parent?: Environment
|
|
256
|
+
extensions: Map<Extension<unknown, unknown>, unknown>
|
|
227
257
|
}
|
|
228
258
|
|
|
229
259
|
export type SubTreeNode =
|
|
@@ -289,6 +319,17 @@ namespace Environment {
|
|
|
289
319
|
| Value
|
|
290
320
|
}
|
|
291
321
|
|
|
322
|
+
export type Extension<State, Result> = {
|
|
323
|
+
create: (state: State | undefined, environment: Environment) => Result
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {
|
|
327
|
+
return {
|
|
328
|
+
create,
|
|
329
|
+
...otherMethods,
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
292
333
|
/** @deprecated */
|
|
293
334
|
export type DeltaFactory = ValuesMapWithFactory
|
|
294
335
|
}
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from '../treeParameters'
|
|
12
12
|
import { QueryLanguage } from '../queryLanguage'
|
|
13
13
|
import { BindingError } from '../BindingError'
|
|
14
|
-
import { NIL_UUID } from '../bindingTypes'
|
|
15
14
|
import { whereToFilter } from '@contember/client'
|
|
16
15
|
import { BaseRelation, Schema, SchemaColumn, SchemaEntity, SchemaField, SchemaRelation } from '../core/schema'
|
|
17
16
|
import levenshtein from 'js-levenshtein'
|
|
@@ -28,7 +27,7 @@ export class TreeNodeEnvironmentFactory {
|
|
|
28
27
|
|
|
29
28
|
if (sugaredEntityList.isCreating) {
|
|
30
29
|
entityList = QueryLanguage.desugarUnconstrainedQualifiedEntityList(sugaredEntityList, environment)
|
|
31
|
-
rootWhere = {
|
|
30
|
+
rootWhere = {} as const
|
|
32
31
|
expectedCardinality = 'zero'
|
|
33
32
|
|
|
34
33
|
} else {
|
|
@@ -56,7 +55,7 @@ export class TreeNodeEnvironmentFactory {
|
|
|
56
55
|
let expectedCardinality: Environment.SubTreeNode['expectedCardinality']
|
|
57
56
|
|
|
58
57
|
if (sugaredEntityList.isCreating) {
|
|
59
|
-
rootWhere = {
|
|
58
|
+
rootWhere = { } as const
|
|
60
59
|
expectedCardinality = 'zero'
|
|
61
60
|
entity = QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(sugaredEntityList, environment)
|
|
62
61
|
|
|
@@ -87,9 +86,7 @@ export class TreeNodeEnvironmentFactory {
|
|
|
87
86
|
const field = this.assertHasManyRelation(hasOneEnvironment, hasManyField)
|
|
88
87
|
|
|
89
88
|
const targetEntity = environment.getSchema().getEntity(field.targetEntity)
|
|
90
|
-
|
|
91
|
-
throw new BindingError('should not happen')
|
|
92
|
-
}
|
|
89
|
+
|
|
93
90
|
return hasOneEnvironment.withSubTreeChild({
|
|
94
91
|
type: 'entity-list',
|
|
95
92
|
field,
|
|
@@ -129,9 +126,7 @@ export class TreeNodeEnvironmentFactory {
|
|
|
129
126
|
for (const pathItem of hasOneRelationPath) {
|
|
130
127
|
const field = this.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy)
|
|
131
128
|
const targetEntity = environment.getSchema().getEntity(field.targetEntity)
|
|
132
|
-
|
|
133
|
-
throw new BindingError('should not happen')
|
|
134
|
-
}
|
|
129
|
+
|
|
135
130
|
environment = environment.withSubTreeChild({
|
|
136
131
|
type: 'entity',
|
|
137
132
|
field,
|
|
@@ -160,9 +155,9 @@ export class TreeNodeEnvironmentFactory {
|
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
private static resolveEntity(schema: Schema, entityName: string, type: 'entity' | 'entity list'): SchemaEntity {
|
|
163
|
-
const entity = schema.
|
|
158
|
+
const entity = schema.getEntityOrUndefined(entityName)
|
|
164
159
|
if (!entity) {
|
|
165
|
-
const alternative = this.recommendAlternative(entityName, schema.
|
|
160
|
+
const alternative = this.recommendAlternative(entityName, schema.getEntityNames())
|
|
166
161
|
const didYouMean = alternative ? `Did you mean '${alternative}'?` : ''
|
|
167
162
|
throw new BindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${didYouMean}`)
|
|
168
163
|
}
|
|
@@ -201,11 +196,11 @@ export class TreeNodeEnvironmentFactory {
|
|
|
201
196
|
|
|
202
197
|
private static describeLocation(environment: Environment): string {
|
|
203
198
|
const path = []
|
|
199
|
+
const loc = environment.getSubTreeNode()
|
|
204
200
|
for (let env = environment;; env = env.getParent()) {
|
|
205
201
|
const node = env.getSubTreeNode()
|
|
206
202
|
if (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {
|
|
207
|
-
|
|
208
|
-
return `entity '${node.entity.name}'${pathText}`
|
|
203
|
+
return `entity '${loc.entity.name}' in path '${[node.entity.name, ...path.reverse()].join('.')}'`
|
|
209
204
|
}
|
|
210
205
|
path.push(node.field.name)
|
|
211
206
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ReactNode, useCallback, useEffect, useState } from 'react'
|
|
2
|
-
import { TreeRootIdProvider, useBindingOperations } from '../accessorPropagation'
|
|
2
|
+
import { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'
|
|
3
3
|
import { useMutationState } from '../accessorTree'
|
|
4
4
|
import { Component } from '../coreComponents'
|
|
5
5
|
import { useEntityBeforePersist } from '../entityEvents'
|
|
6
6
|
import { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'
|
|
7
7
|
import { MarkerFactory } from '../queryLanguage'
|
|
8
8
|
import type { TreeRootId } from '../treeParameters'
|
|
9
|
+
import { useConstantValueInvariant } from '@contember/react-utils'
|
|
10
|
+
import { EntityAccessor } from '../accessors'
|
|
9
11
|
|
|
10
12
|
export interface DeferredSubTreesProps {
|
|
11
13
|
fallback: ReactNode
|
|
@@ -30,16 +32,20 @@ export const DeferredSubTrees = Component<DeferredSubTreesProps>(
|
|
|
30
32
|
const [abortController] = useState(() => new AbortController())
|
|
31
33
|
const signal = abortController.signal
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const hasEntity = useHasEntity()
|
|
36
|
+
useConstantValueInvariant(hasEntity)
|
|
37
|
+
if (hasEntity) {
|
|
38
|
+
useEntityBeforePersist(
|
|
39
|
+
useCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {
|
|
40
|
+
// This is a hack. We're really just circumventing the change of ids after a creation so that nested
|
|
41
|
+
// components don't error.
|
|
42
|
+
if (getAccessor().existsOnServer) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
setLoadState({ name: 'initial' })
|
|
46
|
+
}, []),
|
|
47
|
+
)
|
|
48
|
+
}
|
|
43
49
|
|
|
44
50
|
useEffect(() => {
|
|
45
51
|
return () => {
|
|
@@ -47,6 +53,7 @@ export const DeferredSubTrees = Component<DeferredSubTreesProps>(
|
|
|
47
53
|
}
|
|
48
54
|
}, [abortController])
|
|
49
55
|
|
|
56
|
+
const environment = useEnvironment()
|
|
50
57
|
useEffect(() => {
|
|
51
58
|
if (isMutating || loadState.name !== 'initial' || signal.aborted) {
|
|
52
59
|
return
|
|
@@ -55,7 +62,7 @@ export const DeferredSubTrees = Component<DeferredSubTreesProps>(
|
|
|
55
62
|
|
|
56
63
|
const newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>
|
|
57
64
|
|
|
58
|
-
extendTree(newFragment, { signal })
|
|
65
|
+
extendTree(newFragment, { signal, environment })
|
|
59
66
|
.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))
|
|
60
67
|
.catch(error => {
|
|
61
68
|
if (signal.aborted) {
|
|
@@ -63,7 +70,7 @@ export const DeferredSubTrees = Component<DeferredSubTreesProps>(
|
|
|
63
70
|
}
|
|
64
71
|
throw error
|
|
65
72
|
})
|
|
66
|
-
}, [extendTree, isMutating, loadState.name, props.children, signal])
|
|
73
|
+
}, [environment, extendTree, isMutating, loadState.name, props.children, signal])
|
|
67
74
|
|
|
68
75
|
switch (loadState.name) {
|
|
69
76
|
case 'initial':
|