@contember/binding 1.0.3 → 1.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/accessorPropagation/EnvironmentContext.js +28 -2
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTree.js +4 -2
- package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTree.js +4 -2
- package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useExtendTree.js +27 -0
- package/dist/development/accessorPropagation/useExtendTree.js.map +1 -0
- package/dist/development/accessorTree/AccessorTree.js +16 -14
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/AccessorTreeStateContext.js +4 -0
- package/dist/development/accessorTree/AccessorTreeStateContext.js.map +1 -0
- package/dist/development/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +17 -4
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js +11 -2
- package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/development/accessorTree/useAccessorTreeState.js +12 -0
- package/dist/development/accessorTree/useAccessorTreeState.js.map +1 -0
- package/dist/development/accessorTree/useDataBinding.js +41 -51
- package/dist/development/accessorTree/useDataBinding.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +0 -32
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +1 -1
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +5 -2
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js +1 -2
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +24 -53
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/DirtinessTracker.js +4 -13
- package/dist/development/core/DirtinessTracker.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +9 -13
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +12 -7
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/development/core/MarkerComparator.js +1 -1
- package/dist/development/core/MarkerMerger.js +3 -6
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +180 -141
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +93 -134
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +30 -38
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +14 -14
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeFilterGenerator.js +2 -2
- package/dist/development/core/TreeFilterGenerator.js.map +1 -1
- package/dist/development/core/TreeStore.js +12 -23
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.js +4 -1
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +14 -13
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +2 -2
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +3 -3
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/operations/OperationsHelpers.js +2 -2
- package/dist/development/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js +4 -40
- package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/development/core/schema/Schema.js +29 -2
- package/dist/development/core/schema/Schema.js.map +1 -1
- package/dist/development/core/schema/SchemaLoader.js +12 -12
- package/dist/development/core/schema/SchemaLoader.js.map +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/development/coreComponents/Component.js +5 -2
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +0 -1
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +4 -12
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +4 -22
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +5 -1
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +3 -5
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +4 -6
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/dao/Environment.js +175 -90
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/dao/TreeNodeEnvironmentFactory.js +153 -0
- package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/If.js +39 -0
- package/dist/development/helperComponents/If.js.map +1 -0
- package/dist/development/helperComponents/SugaredField.js +1 -1
- package/dist/development/helperComponents/helpers/FilterEvaluator.js +35 -0
- package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
- package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +38 -0
- package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
- package/dist/development/index.js +7 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.js +4 -4
- package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js +6 -5
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +18 -6
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +1 -1
- package/dist/development/utils/Hashing.js +21 -6
- package/dist/development/utils/Hashing.js.map +1 -1
- package/dist/production/accessorPropagation/EnvironmentContext.js +28 -2
- package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
- package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
- package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useExtendTree.js +27 -0
- package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
- package/dist/production/accessorTree/AccessorTree.js +16 -14
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/AccessorTreeStateContext.js +4 -0
- package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
- package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js +17 -4
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessorTree/accessorTreeStateReducer.js +11 -2
- package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/production/accessorTree/useAccessorTreeState.js +12 -0
- package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
- package/dist/production/accessorTree/useDataBinding.js +41 -51
- package/dist/production/accessorTree/useDataBinding.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +0 -32
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +1 -1
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +5 -2
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js +1 -2
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +24 -44
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/DirtinessTracker.js +4 -13
- package/dist/production/core/DirtinessTracker.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js +9 -13
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js +11 -6
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/production/core/MarkerComparator.js +1 -1
- package/dist/production/core/MarkerMerger.js +3 -6
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +180 -141
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js +93 -134
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +30 -38
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +14 -14
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeFilterGenerator.js +2 -2
- package/dist/production/core/TreeFilterGenerator.js.map +1 -1
- package/dist/production/core/TreeStore.js +12 -23
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/VariableInputTransformer.js +4 -1
- package/dist/production/core/VariableInputTransformer.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +14 -13
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/FieldOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.js +3 -3
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/core/operations/OperationsHelpers.js +2 -2
- package/dist/production/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js +4 -33
- package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/production/core/schema/Schema.js +29 -2
- package/dist/production/core/schema/Schema.js.map +1 -1
- package/dist/production/core/schema/SchemaLoader.js +12 -12
- package/dist/production/core/schema/SchemaLoader.js.map +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/production/coreComponents/Component.js +5 -2
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js +0 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js +4 -12
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js +4 -22
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/Field.js +5 -1
- package/dist/production/coreComponents/Field.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js +3 -5
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js +4 -6
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/dao/Environment.js +175 -90
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/dao/TreeNodeEnvironmentFactory.js +153 -0
- package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/If.js +39 -0
- package/dist/production/helperComponents/If.js.map +1 -0
- package/dist/production/helperComponents/SugaredField.js +1 -1
- package/dist/production/helperComponents/helpers/FilterEvaluator.js +35 -0
- package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
- package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +38 -0
- package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
- package/dist/production/index.js +7 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.js +4 -4
- package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js +6 -5
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +15 -6
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +1 -1
- package/dist/production/utils/Hashing.js +21 -6
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts +13 -2
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/index.d.ts +1 -0
- package/dist/types/accessorPropagation/index.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts +2 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
- package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeState.d.ts +8 -0
- package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +6 -0
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -1
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts +5 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +5 -5
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
- package/dist/types/accessorTree/PersistResult.d.ts +2 -1
- package/dist/types/accessorTree/PersistResult.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +11 -10
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/RuntimeId.d.ts +16 -6
- package/dist/types/accessorTree/RuntimeId.d.ts.map +1 -1
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -1
- package/dist/types/accessorTree/index.d.ts +1 -0
- package/dist/types/accessorTree/index.d.ts.map +1 -1
- package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
- package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
- package/dist/types/accessorTree/useDataBinding.d.ts +1 -1
- package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
- package/dist/types/accessors/BindingConfig.d.ts +0 -1
- package/dist/types/accessors/BindingConfig.d.ts.map +1 -1
- package/dist/types/accessors/EntityAccessor.d.ts +1 -3
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
- package/dist/types/accessors/EntityListAccessor.d.ts +2 -2
- package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
- package/dist/types/core/AccessorErrorManager.d.ts +2 -1
- package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
- package/dist/types/core/Config.d.ts.map +1 -1
- package/dist/types/core/DataBinding.d.ts +3 -4
- package/dist/types/core/DataBinding.d.ts.map +1 -1
- package/dist/types/core/DirtinessTracker.d.ts +2 -5
- package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
- package/dist/types/core/ErrorsPreprocessor.d.ts +5 -3
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
- package/dist/types/core/EventManager.d.ts +1 -1
- package/dist/types/core/EventManager.d.ts.map +1 -1
- package/dist/types/core/MarkerMerger.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts +25 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
- package/dist/types/core/StateInitializer.d.ts +1 -5
- package/dist/types/core/StateInitializer.d.ts.map +1 -1
- package/dist/types/core/TreeAugmenter.d.ts +3 -2
- package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
- package/dist/types/core/TreeStore.d.ts +8 -8
- package/dist/types/core/TreeStore.d.ts.map +1 -1
- package/dist/types/core/VariableInputTransformer.d.ts +2 -2
- package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
- package/dist/types/core/operations/ListOperations.d.ts +2 -1
- package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
- package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
- package/dist/types/core/requestAliases/index.d.ts +0 -3
- package/dist/types/core/requestAliases/index.d.ts.map +1 -1
- package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
- package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
- package/dist/types/core/schema/Schema.d.ts +14 -2
- package/dist/types/core/schema/Schema.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaColumn.d.ts +1 -1
- package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
- package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaLoader.d.ts +2 -1
- package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
- package/dist/types/core/schema/index.d.ts +0 -1
- package/dist/types/core/schema/index.d.ts.map +1 -1
- package/dist/types/core/state/FieldState.d.ts +2 -2
- package/dist/types/core/state/FieldState.d.ts.map +1 -1
- package/dist/types/coreComponents/Component.d.ts +9 -4
- package/dist/types/coreComponents/Component.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts +0 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/Entity.d.ts +1 -1
- package/dist/types/coreComponents/Entity.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts +1 -1
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/coreComponents/HasMany.d.ts +1 -1
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
- package/dist/types/coreComponents/HasOne.d.ts +1 -1
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
- package/dist/types/dao/Environment.d.ts +89 -41
- package/dist/types/dao/Environment.d.ts.map +1 -1
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +19 -0
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -0
- package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
- package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
- package/dist/types/helperComponents/FieldView.d.ts +7 -7
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
- package/dist/types/helperComponents/If.d.ts +14 -0
- package/dist/types/helperComponents/If.d.ts.map +1 -0
- package/dist/types/helperComponents/StaticRender.d.ts +1 -1
- package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
- package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
- package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
- package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
- package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
- package/dist/types/helperComponents/index.d.ts +1 -0
- package/dist/types/helperComponents/index.d.ts.map +1 -1
- package/dist/types/markers/FieldMarker.d.ts +3 -3
- package/dist/types/markers/FieldMarker.d.ts.map +1 -1
- package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
- package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
- package/dist/types/queryLanguage/MarkerFactory.d.ts.map +1 -1
- package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
- package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
- package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/Hashing.d.ts +3 -2
- package/dist/types/utils/Hashing.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/accessorPropagation/EnvironmentContext.tsx +44 -0
- package/src/accessorPropagation/index.ts +1 -0
- package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
- package/src/accessorPropagation/useEntitySubTree.ts +8 -1
- package/src/accessorPropagation/useExtendTree.ts +30 -0
- package/src/accessorTree/AccessorTree.tsx +18 -18
- package/src/accessorTree/AccessorTreeState.ts +12 -1
- package/src/accessorTree/AccessorTreeStateAction.ts +7 -1
- package/src/accessorTree/AccessorTreeStateContext.ts +4 -0
- package/src/accessorTree/AccessorTreeStateOptions.ts +0 -1
- package/src/accessorTree/MutationRequestResponse.ts +3 -1
- package/src/accessorTree/NormalizedPersistedData.ts +5 -5
- package/src/accessorTree/PersistResult.ts +2 -1
- package/src/accessorTree/QueryRequestResponse.ts +17 -14
- package/src/accessorTree/RuntimeId.ts +27 -6
- package/src/accessorTree/accessorTreeStateReducer.ts +10 -1
- package/src/accessorTree/index.ts +1 -0
- package/src/accessorTree/useAccessorTreeState.ts +11 -0
- package/src/accessorTree/useDataBinding.ts +41 -59
- package/src/accessors/BindingConfig.ts +0 -1
- package/src/accessors/EntityAccessor.ts +2 -51
- package/src/accessors/EntityListAccessor.ts +3 -3
- package/src/core/AccessorErrorManager.ts +6 -2
- package/src/core/Config.ts +0 -1
- package/src/core/DataBinding.ts +25 -65
- package/src/core/DirtinessTracker.ts +4 -16
- package/src/core/ErrorsPreprocessor.ts +16 -18
- package/src/core/EventManager.ts +14 -8
- package/src/core/MarkerMerger.ts +1 -4
- package/src/core/MutationGenerator.ts +249 -188
- package/src/core/RequestResponseNormalizer.ts +111 -163
- package/src/core/StateInitializer.ts +46 -58
- package/src/core/TreeAugmenter.ts +16 -15
- package/src/core/TreeFilterGenerator.ts +5 -5
- package/src/core/TreeStore.ts +23 -27
- package/src/core/VariableInputTransformer.ts +9 -6
- package/src/core/index.ts +1 -0
- package/src/core/operations/EntityOperations.ts +13 -14
- package/src/core/operations/FieldOperations.ts +2 -2
- package/src/core/operations/ListOperations.ts +6 -5
- package/src/core/operations/OperationsHelpers.ts +2 -2
- package/src/core/requestAliases/MutationAlias.ts +4 -57
- package/src/core/requestAliases/index.ts +0 -3
- package/src/core/schema/RawSchemaEntity.ts +1 -2
- package/src/core/schema/Schema.ts +42 -3
- package/src/core/schema/SchemaColumn.ts +1 -1
- package/src/core/schema/SchemaEntity.ts +1 -1
- package/src/core/schema/SchemaLoader.ts +13 -11
- package/src/core/schema/SchemaPreprocessor.ts +1 -1
- package/src/core/schema/SchemaRelation.ts +1 -1
- package/src/core/schema/index.ts +0 -1
- package/src/core/state/FieldState.ts +2 -2
- package/src/coreComponents/Component.tsx +20 -7
- package/src/coreComponents/DataBindingProvider.tsx +0 -2
- package/src/coreComponents/EntityListSubTree.tsx +5 -16
- package/src/coreComponents/EntitySubTree.tsx +17 -32
- package/src/coreComponents/Field.tsx +4 -0
- package/src/coreComponents/HasMany.tsx +4 -6
- package/src/coreComponents/HasOne.tsx +6 -7
- package/src/dao/Environment.ts +260 -124
- package/src/dao/TreeNodeEnvironmentFactory.ts +224 -0
- package/src/helperComponents/DeferredSubTrees.tsx +20 -13
- package/src/helperComponents/If.tsx +71 -0
- package/src/helperComponents/helpers/FilterEvaluator.ts +46 -0
- package/src/helperComponents/helpers/FilterFieldsCollector.ts +46 -0
- package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
- package/src/helperComponents/index.ts +1 -0
- package/src/markers/EntityListSubTreeMarker.ts +1 -1
- package/src/markers/EntitySubTreeMarker.ts +1 -1
- package/src/markers/PlaceholderGenerator.ts +5 -2
- package/src/queryLanguage/MarkerFactory.ts +5 -3
- package/src/queryLanguage/Parser.ts +24 -11
- package/src/treeParameters/primitives/EntityId.ts +1 -1
- package/src/treeParameters/primitives/FieldValue.ts +2 -2
- package/src/treeParameters/primitives/Json.ts +7 -0
- package/src/treeParameters/primitives/index.ts +1 -0
- package/src/typings/react-fix.d.ts +12 -0
- package/src/utils/Hashing.ts +23 -8
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/development/core/schema/SchemaValidator.js +0 -116
- package/dist/development/core/schema/SchemaValidator.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
- package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
- package/dist/types/core/schema/SchemaValidator.d.ts +0 -14
- package/dist/types/core/schema/SchemaValidator.d.ts.map +0 -1
- package/src/accessorPropagation/EnvironmentContext.ts +0 -5
- package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
- package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
- package/src/core/requestAliases/mutationOperationType.ts +0 -5
- package/src/core/schema/SchemaValidator.ts +0 -238
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import levenshtein from "js-levenshtein";
|
|
2
|
-
import { BindingError } from "../../BindingError.js";
|
|
3
|
-
import { ErrorLocator } from "../exceptions/ErrorLocator.js";
|
|
4
|
-
import { LocalizedBindingError } from "../exceptions/LocalizedBindingError.js";
|
|
5
|
-
import { FieldMarker } from "../../markers/FieldMarker.js";
|
|
6
|
-
import { HasOneRelationMarker } from "../../markers/HasOneRelationMarker.js";
|
|
7
|
-
import { HasManyRelationMarker } from "../../markers/HasManyRelationMarker.js";
|
|
8
|
-
import { assertNever } from "../../utils/assertNever.js";
|
|
9
|
-
import { EntitySubTreeMarker } from "../../markers/EntitySubTreeMarker.js";
|
|
10
|
-
class SchemaValidator {
|
|
11
|
-
static assertTreeValid(schema, tree) {
|
|
12
|
-
const errors = Array.from(tree.subTrees.values(), (subTree) => Array.from(this.getSubTreeErrors(schema, subTree))).flat();
|
|
13
|
-
if (errors.length) {
|
|
14
|
-
throw new BindingError(`Invalid data tree:
|
|
15
|
-
` + errors.map((error) => ` \u2022 ${error.message} (Error at ${ErrorLocator.locateMarkerPath(error.markerPath)})`).join(`
|
|
16
|
-
`));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static *getSubTreeErrors(schema, subTree) {
|
|
20
|
-
const entityName = subTree.entityName;
|
|
21
|
-
const entity = schema.store.entities.get(entityName);
|
|
22
|
-
if (entity === void 0) {
|
|
23
|
-
const type = subTree instanceof EntitySubTreeMarker ? "entity list" : "entity";
|
|
24
|
-
const alternative = this.recommendAlternative(entityName, schema.store.entities.keys());
|
|
25
|
-
yield new LocalizedBindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${alternative ? `Did you mean '${alternative}'?` : ""}`, [subTree]);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
yield* this.nestErrorsIn(subTree, this.getMarkersContainerErrors(schema, entity, subTree.fields));
|
|
29
|
-
}
|
|
30
|
-
static *getMarkersContainerErrors(schema, containingEntity, markers) {
|
|
31
|
-
for (const marker of markers.markers.values()) {
|
|
32
|
-
if (marker instanceof FieldMarker) {
|
|
33
|
-
yield* this.getFieldErrors(schema, containingEntity, marker);
|
|
34
|
-
} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {
|
|
35
|
-
yield* this.getRelationErrors(schema, containingEntity, marker);
|
|
36
|
-
} else {
|
|
37
|
-
return assertNever();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
static *getRelationErrors(schema, containingEntity, marker) {
|
|
42
|
-
const relationName = marker.parameters.field;
|
|
43
|
-
const relation = containingEntity.fields.get(relationName);
|
|
44
|
-
const type = marker instanceof HasOneRelationMarker ? "one" : "many";
|
|
45
|
-
if (relation === void 0) {
|
|
46
|
-
const alternative = this.recommendAlternative(relationName, Array.from(containingEntity.fields).filter(([, field]) => {
|
|
47
|
-
if (field.__typename !== "_Relation") {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
if (marker instanceof HasOneRelationMarker) {
|
|
51
|
-
return field.type === "OneHasOne" || field.type === "ManyHasOne";
|
|
52
|
-
}
|
|
53
|
-
if (marker instanceof HasManyRelationMarker) {
|
|
54
|
-
return field.type === "OneHasMany" || field.type === "ManyHasMany";
|
|
55
|
-
}
|
|
56
|
-
return assertNever();
|
|
57
|
-
}).map(([fieldName]) => fieldName));
|
|
58
|
-
yield new LocalizedBindingError(`Invalid has-${type} relation '${relationName}' doesn't exist on entity '${containingEntity.name}'. ` + (alternative ? `Did you mean '${alternative}'?` : ""), [marker]);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (relation.__typename === "_Column") {
|
|
62
|
-
yield new LocalizedBindingError(`Invalid has-${type} relation: the name '${relationName}' on entity '${containingEntity.name}' refers to an ordinary scalar field but is being used as a has-${type} relation.`, [marker]);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (marker instanceof HasOneRelationMarker && marker.parameters.reducedBy === void 0 && (relation.type === "OneHasMany" || relation.type === "ManyHasMany")) {
|
|
66
|
-
yield new LocalizedBindingError(`Invalid has-one relation: the name '${relationName}' on entity '${containingEntity.name}' refers to a *has-many* relation but is being used as a has-one.`, [marker]);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if ((marker instanceof HasManyRelationMarker || marker instanceof HasOneRelationMarker && marker.parameters.reducedBy !== void 0) && (relation.type === "OneHasOne" || relation.type === "ManyHasOne")) {
|
|
70
|
-
yield new LocalizedBindingError(`Invalid has-many relation: the name '${relationName}' on entity '${containingEntity.name}' refers to a *has-one* relation but is being used as a has-many.`, [marker]);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const targetEntityName = relation.targetEntity;
|
|
74
|
-
const targetEntity = schema.store.entities.get(targetEntityName);
|
|
75
|
-
if (targetEntity === void 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
yield* this.nestErrorsIn(marker, this.getMarkersContainerErrors(schema, targetEntity, marker.fields));
|
|
79
|
-
}
|
|
80
|
-
static *getFieldErrors(schema, containingEntity, marker) {
|
|
81
|
-
const fieldName = marker.fieldName;
|
|
82
|
-
const field = containingEntity.fields.get(fieldName);
|
|
83
|
-
if (field === void 0) {
|
|
84
|
-
const alternative = this.recommendAlternative(fieldName, Array.from(containingEntity.fields).filter(([, field2]) => field2.__typename === "_Column").map(([fieldName2]) => fieldName2));
|
|
85
|
-
yield new LocalizedBindingError(`Field '${fieldName}' doesn't exist on entity '${containingEntity.name}'. ` + (alternative ? `Did you mean '${alternative}'?` : ""), [marker]);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (field.__typename === "_Relation") {
|
|
89
|
-
yield new LocalizedBindingError(`Invalid field: the name '${fieldName}' on entity '${containingEntity.name}' refers to a has-${field.type === "OneHasOne" || field.type === "ManyHasOne" ? "one" : "many"} relation but is being used as a field.`, [marker]);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
static *getUniqueWhereErrors(schema, containingEntity, where) {
|
|
94
|
-
}
|
|
95
|
-
static *getFilterErrors(schema, containingEntity, filter) {
|
|
96
|
-
}
|
|
97
|
-
static *nestErrorsIn(source, to) {
|
|
98
|
-
for (const error of to) {
|
|
99
|
-
yield error.nestedIn(source);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
static recommendAlternative(original, possibleAlternatives) {
|
|
103
|
-
let bestAlternative = void 0;
|
|
104
|
-
let bestAlternativeDistance = Number.MAX_SAFE_INTEGER;
|
|
105
|
-
for (const alternative of possibleAlternatives) {
|
|
106
|
-
const distance = levenshtein(original, alternative);
|
|
107
|
-
if (distance < bestAlternativeDistance) {
|
|
108
|
-
bestAlternative = alternative;
|
|
109
|
-
bestAlternativeDistance = distance;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return bestAlternative;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export { SchemaValidator };
|
|
116
|
-
//# sourceMappingURL=SchemaValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidator.js","sources":["../../../../src/core/schema/SchemaValidator.ts"],"sourcesContent":["import levenshtein from 'js-levenshtein'\nimport { BindingError } from '../../BindingError'\nimport {\n\tEntityFieldMarkersContainer,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../../markers'\nimport type { Filter, UniqueWhere } from '../../treeParameters'\nimport { assertNever } from '../../utils'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport type { Schema } from './Schema'\nimport type { SchemaEntity } from './SchemaEntity'\n\nexport class SchemaValidator {\n\tpublic static assertTreeValid(schema: Schema, tree: MarkerTreeRoot) {\n\t\tconst errors = Array.from(tree.subTrees.values(), subTree =>\n\t\t\tArray.from(this.getSubTreeErrors(schema, subTree)),\n\t\t).flat()\n\n\t\tif (errors.length) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Invalid data tree:\\n` +\n\t\t\t\t\terrors\n\t\t\t\t\t\t.map(error => `\\t• ${error.message} (Error at ${ErrorLocator.locateMarkerPath(error.markerPath)})`)\n\t\t\t\t\t\t.join(`\\n`),\n\t\t\t)\n\t\t}\n\t}\n\n\tprivate static *getSubTreeErrors(\n\t\tschema: Schema,\n\t\tsubTree: EntitySubTreeMarker | EntityListSubTreeMarker,\n\t): Generator<LocalizedBindingError, void> {\n\t\tconst entityName = subTree.entityName\n\t\tconst entity = schema.store.entities.get(entityName)\n\n\t\tif (entity === undefined) {\n\t\t\tconst type = subTree instanceof EntitySubTreeMarker ? 'entity list' : 'entity'\n\t\t\tconst alternative = this.recommendAlternative(entityName, schema.store.entities.keys())\n\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${\n\t\t\t\t\talternative ? `Did you mean '${alternative}'?` : ''\n\t\t\t\t}`,\n\t\t\t\t[subTree],\n\t\t\t)\n\n\t\t\treturn\n\t\t}\n\n\t\t// TODO check filter\n\t\t// TODO check where\n\t\t// TODO run custom validators\n\n\t\tyield* this.nestErrorsIn(subTree, this.getMarkersContainerErrors(schema, entity, subTree.fields))\n\t}\n\n\tprivate static *getMarkersContainerErrors(\n\t\tschema: Schema,\n\t\tcontainingEntity: SchemaEntity,\n\t\tmarkers: EntityFieldMarkersContainer,\n\t): Generator<LocalizedBindingError, void> {\n\t\tfor (const marker of markers.markers.values()) {\n\t\t\tif (marker instanceof FieldMarker) {\n\t\t\t\tyield* this.getFieldErrors(schema, containingEntity, marker)\n\t\t\t} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\t\tyield* this.getRelationErrors(schema, containingEntity, marker)\n\t\t\t} else {\n\t\t\t\treturn assertNever(marker)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static *getRelationErrors(\n\t\tschema: Schema,\n\t\tcontainingEntity: SchemaEntity,\n\t\tmarker: HasOneRelationMarker | HasManyRelationMarker,\n\t): Generator<LocalizedBindingError, void> {\n\t\tconst relationName = marker.parameters.field\n\t\tconst relation = containingEntity.fields.get(relationName)\n\t\tconst type = marker instanceof HasOneRelationMarker ? 'one' : 'many'\n\n\t\tif (relation === undefined) {\n\t\t\tconst alternative = this.recommendAlternative(\n\t\t\t\trelationName,\n\t\t\t\tArray.from(containingEntity.fields)\n\t\t\t\t\t.filter(([, field]) => {\n\t\t\t\t\t\tif (field.__typename !== '_Relation') {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker instanceof HasOneRelationMarker) {\n\t\t\t\t\t\t\treturn field.type === 'OneHasOne' || field.type === 'ManyHasOne'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker instanceof HasManyRelationMarker) {\n\t\t\t\t\t\t\treturn field.type === 'OneHasMany' || field.type === 'ManyHasMany'\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn assertNever(marker)\n\t\t\t\t\t})\n\t\t\t\t\t.map(([fieldName]) => fieldName),\n\t\t\t)\n\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid has-${type} relation '${relationName}' doesn't exist on entity '${containingEntity.name}'. ` +\n\t\t\t\t\t(alternative ? `Did you mean '${alternative}'?` : ''),\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (relation.__typename === '_Column') {\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid has-${type} relation: the name '${relationName}' on entity '${containingEntity.name}' ` +\n\t\t\t\t\t`refers to an ordinary scalar field but is being used as a has-${type} relation.`,\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tmarker instanceof HasOneRelationMarker &&\n\t\t\tmarker.parameters.reducedBy === undefined &&\n\t\t\t(relation.type === 'OneHasMany' || relation.type === 'ManyHasMany')\n\t\t) {\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid has-one relation: the name '${relationName}' on entity '${containingEntity.name}' ` +\n\t\t\t\t\t`refers to a *has-many* relation but is being used as a has-one.`,\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\t(marker instanceof HasManyRelationMarker ||\n\t\t\t\t(marker instanceof HasOneRelationMarker && marker.parameters.reducedBy !== undefined)) &&\n\t\t\t(relation.type === 'OneHasOne' || relation.type === 'ManyHasOne')\n\t\t) {\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid has-many relation: the name '${relationName}' on entity '${containingEntity.name}' ` +\n\t\t\t\t\t`refers to a *has-one* relation but is being used as a has-many.`,\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\n\t\t// TODO check filter\n\t\t// TODO check reducedBy\n\t\t// TODO check expected mutations\n\t\t// TODO run custom validators\n\n\t\tconst targetEntityName = relation.targetEntity\n\t\tconst targetEntity = schema.store.entities.get(targetEntityName)\n\n\t\tif (targetEntity === undefined) {\n\t\t\treturn // ?!? This really shouldn't ever happen.\n\t\t}\n\n\t\tyield* this.nestErrorsIn(marker, this.getMarkersContainerErrors(schema, targetEntity, marker.fields))\n\t}\n\n\tprivate static *getFieldErrors(\n\t\tschema: Schema,\n\t\tcontainingEntity: SchemaEntity,\n\t\tmarker: FieldMarker,\n\t): Generator<LocalizedBindingError, void> {\n\t\tconst fieldName = marker.fieldName\n\t\tconst field = containingEntity.fields.get(fieldName)\n\n\t\tif (field === undefined) {\n\t\t\tconst alternative = this.recommendAlternative(\n\t\t\t\tfieldName,\n\t\t\t\tArray.from(containingEntity.fields)\n\t\t\t\t\t.filter(([, field]) => field.__typename === '_Column')\n\t\t\t\t\t.map(([fieldName]) => fieldName),\n\t\t\t)\n\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Field '${fieldName}' doesn't exist on entity '${containingEntity.name}'. ` +\n\t\t\t\t\t(alternative ? `Did you mean '${alternative}'?` : ''),\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (field.__typename === '_Relation') {\n\t\t\tyield new LocalizedBindingError(\n\t\t\t\t`Invalid field: the name '${fieldName}' on entity '${containingEntity.name}' ` +\n\t\t\t\t\t`refers to a has-${\n\t\t\t\t\t\tfield.type === 'OneHasOne' || field.type === 'ManyHasOne' ? 'one' : 'many'\n\t\t\t\t\t} relation but is being used as a field.`,\n\t\t\t\t[marker],\n\t\t\t)\n\t\t\treturn\n\t\t}\n\n\t\t// TODO check that defaultValue matches the type\n\t\t// TODO run custom validators\n\t}\n\n\tprivate static *getUniqueWhereErrors(\n\t\tschema: Schema,\n\t\tcontainingEntity: SchemaEntity,\n\t\twhere: UniqueWhere,\n\t): Generator<LocalizedBindingError, void> {\n\t\t//\n\t}\n\n\tprivate static *getFilterErrors(\n\t\tschema: Schema,\n\t\tcontainingEntity: SchemaEntity,\n\t\tfilter: Filter,\n\t): Generator<LocalizedBindingError, void> {\n\t\t//\n\t}\n\n\tprivate static *nestErrorsIn(\n\t\tsource: HasOneRelationMarker | HasManyRelationMarker | EntityListSubTreeMarker | EntitySubTreeMarker,\n\t\tto: Generator<LocalizedBindingError, void>,\n\t): Generator<LocalizedBindingError, void> {\n\t\tfor (const error of to) {\n\t\t\tyield error.nestedIn(source)\n\t\t}\n\t}\n\n\tprivate static recommendAlternative(original: string, possibleAlternatives: Iterable<string>): string | undefined {\n\t\tlet bestAlternative: string | undefined = undefined\n\t\tlet bestAlternativeDistance = Number.MAX_SAFE_INTEGER\n\n\t\tfor (const alternative of possibleAlternatives) {\n\t\t\tconst distance = levenshtein(original, alternative)\n\n\t\t\tif (distance < bestAlternativeDistance) {\n\t\t\t\tbestAlternative = alternative\n\t\t\t\tbestAlternativeDistance = distance\n\t\t\t}\n\t\t}\n\t\treturn bestAlternative\n\t}\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOperationSubTreeType.js","sources":["../../../../src/core/requestAliases/mutationOperationSubTreeType.ts"],"sourcesContent":["export const mutationOperationSubTreeType = {\n\tsingleEntity: 's',\n\tentityList: 'l',\n} as const\n"],"names":[],"mappings":"AAAO,MAAM,+BAA+B;AAAA,EAC3C,cAAc;AAAA,EACd,YAAY;AACb;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOperationType.js","sources":["../../../../src/core/requestAliases/mutationOperationType.ts"],"sourcesContent":["export const mutationOperationType = {\n\tcreate: 'c',\n\tupdate: 'u',\n\tdelete: 'd',\n} as const\n"],"names":[],"mappings":"AAAO,MAAM,wBAAwB;AAAA,EACpC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AACT;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EntityId, PlaceholderName, TreeRootId } from '../../treeParameters';
|
|
2
|
-
import type { mutationOperationSubTreeType } from './mutationOperationSubTreeType';
|
|
3
|
-
import type { mutationOperationType } from './mutationOperationType';
|
|
4
|
-
export interface TopLevelMutationOperation {
|
|
5
|
-
treeRootId: TreeRootId | undefined;
|
|
6
|
-
subTreePlaceholder: PlaceholderName;
|
|
7
|
-
type: typeof mutationOperationType[keyof typeof mutationOperationType];
|
|
8
|
-
subTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType];
|
|
9
|
-
entityId: EntityId;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=TopLevelMutationOperation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TopLevelMutationOperation.d.ts","sourceRoot":"","sources":["../../../../src/core/requestAliases/TopLevelMutationOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAEpE,MAAM,WAAW,yBAAyB;IACzC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAA;IAClC,kBAAkB,EAAE,eAAe,CAAA;IACnC,IAAI,EAAE,OAAO,qBAAqB,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAA;IACtE,WAAW,EAAE,OAAO,4BAA4B,CAAC,MAAM,OAAO,4BAA4B,CAAC,CAAA;IAC3F,QAAQ,EAAE,QAAQ,CAAA;CAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOperationSubTreeType.d.ts","sourceRoot":"","sources":["../../../../src/core/requestAliases/mutationOperationSubTreeType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B;;;CAG/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOperationType.d.ts","sourceRoot":"","sources":["../../../../src/core/requestAliases/mutationOperationType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MarkerTreeRoot } from '../../markers';
|
|
2
|
-
import type { Schema } from './Schema';
|
|
3
|
-
export declare class SchemaValidator {
|
|
4
|
-
static assertTreeValid(schema: Schema, tree: MarkerTreeRoot): void;
|
|
5
|
-
private static getSubTreeErrors;
|
|
6
|
-
private static getMarkersContainerErrors;
|
|
7
|
-
private static getRelationErrors;
|
|
8
|
-
private static getFieldErrors;
|
|
9
|
-
private static getUniqueWhereErrors;
|
|
10
|
-
private static getFilterErrors;
|
|
11
|
-
private static nestErrorsIn;
|
|
12
|
-
private static recommendAlternative;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=SchemaValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidator.d.ts","sourceRoot":"","sources":["../../../../src/core/schema/SchemaValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAON,cAAc,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGtC,qBAAa,eAAe;WACb,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc;IAelE,OAAO,CAAC,MAAM,CAAE,gBAAgB;IA4BhC,OAAO,CAAC,MAAM,CAAE,yBAAyB;IAgBzC,OAAO,CAAC,MAAM,CAAE,iBAAiB;IAmFjC,OAAO,CAAC,MAAM,CAAE,cAAc;IAsC9B,OAAO,CAAC,MAAM,CAAE,oBAAoB;IAQpC,OAAO,CAAC,MAAM,CAAE,eAAe;IAQ/B,OAAO,CAAC,MAAM,CAAE,YAAY;IAS5B,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAcnC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EntityId, PlaceholderName, TreeRootId } from '../../treeParameters'
|
|
2
|
-
import type { mutationOperationSubTreeType } from './mutationOperationSubTreeType'
|
|
3
|
-
import type { mutationOperationType } from './mutationOperationType'
|
|
4
|
-
|
|
5
|
-
export interface TopLevelMutationOperation {
|
|
6
|
-
treeRootId: TreeRootId | undefined
|
|
7
|
-
subTreePlaceholder: PlaceholderName
|
|
8
|
-
type: typeof mutationOperationType[keyof typeof mutationOperationType]
|
|
9
|
-
subTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType]
|
|
10
|
-
entityId: EntityId
|
|
11
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import levenshtein from 'js-levenshtein'
|
|
2
|
-
import { BindingError } from '../../BindingError'
|
|
3
|
-
import {
|
|
4
|
-
EntityFieldMarkersContainer,
|
|
5
|
-
EntityListSubTreeMarker,
|
|
6
|
-
EntitySubTreeMarker,
|
|
7
|
-
FieldMarker,
|
|
8
|
-
HasManyRelationMarker,
|
|
9
|
-
HasOneRelationMarker,
|
|
10
|
-
MarkerTreeRoot,
|
|
11
|
-
} from '../../markers'
|
|
12
|
-
import type { Filter, UniqueWhere } from '../../treeParameters'
|
|
13
|
-
import { assertNever } from '../../utils'
|
|
14
|
-
import { ErrorLocator, LocalizedBindingError } from '../exceptions'
|
|
15
|
-
import type { Schema } from './Schema'
|
|
16
|
-
import type { SchemaEntity } from './SchemaEntity'
|
|
17
|
-
|
|
18
|
-
export class SchemaValidator {
|
|
19
|
-
public static assertTreeValid(schema: Schema, tree: MarkerTreeRoot) {
|
|
20
|
-
const errors = Array.from(tree.subTrees.values(), subTree =>
|
|
21
|
-
Array.from(this.getSubTreeErrors(schema, subTree)),
|
|
22
|
-
).flat()
|
|
23
|
-
|
|
24
|
-
if (errors.length) {
|
|
25
|
-
throw new BindingError(
|
|
26
|
-
`Invalid data tree:\n` +
|
|
27
|
-
errors
|
|
28
|
-
.map(error => `\t• ${error.message} (Error at ${ErrorLocator.locateMarkerPath(error.markerPath)})`)
|
|
29
|
-
.join(`\n`),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private static *getSubTreeErrors(
|
|
35
|
-
schema: Schema,
|
|
36
|
-
subTree: EntitySubTreeMarker | EntityListSubTreeMarker,
|
|
37
|
-
): Generator<LocalizedBindingError, void> {
|
|
38
|
-
const entityName = subTree.entityName
|
|
39
|
-
const entity = schema.store.entities.get(entityName)
|
|
40
|
-
|
|
41
|
-
if (entity === undefined) {
|
|
42
|
-
const type = subTree instanceof EntitySubTreeMarker ? 'entity list' : 'entity'
|
|
43
|
-
const alternative = this.recommendAlternative(entityName, schema.store.entities.keys())
|
|
44
|
-
|
|
45
|
-
yield new LocalizedBindingError(
|
|
46
|
-
`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${
|
|
47
|
-
alternative ? `Did you mean '${alternative}'?` : ''
|
|
48
|
-
}`,
|
|
49
|
-
[subTree],
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// TODO check filter
|
|
56
|
-
// TODO check where
|
|
57
|
-
// TODO run custom validators
|
|
58
|
-
|
|
59
|
-
yield* this.nestErrorsIn(subTree, this.getMarkersContainerErrors(schema, entity, subTree.fields))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private static *getMarkersContainerErrors(
|
|
63
|
-
schema: Schema,
|
|
64
|
-
containingEntity: SchemaEntity,
|
|
65
|
-
markers: EntityFieldMarkersContainer,
|
|
66
|
-
): Generator<LocalizedBindingError, void> {
|
|
67
|
-
for (const marker of markers.markers.values()) {
|
|
68
|
-
if (marker instanceof FieldMarker) {
|
|
69
|
-
yield* this.getFieldErrors(schema, containingEntity, marker)
|
|
70
|
-
} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {
|
|
71
|
-
yield* this.getRelationErrors(schema, containingEntity, marker)
|
|
72
|
-
} else {
|
|
73
|
-
return assertNever(marker)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private static *getRelationErrors(
|
|
79
|
-
schema: Schema,
|
|
80
|
-
containingEntity: SchemaEntity,
|
|
81
|
-
marker: HasOneRelationMarker | HasManyRelationMarker,
|
|
82
|
-
): Generator<LocalizedBindingError, void> {
|
|
83
|
-
const relationName = marker.parameters.field
|
|
84
|
-
const relation = containingEntity.fields.get(relationName)
|
|
85
|
-
const type = marker instanceof HasOneRelationMarker ? 'one' : 'many'
|
|
86
|
-
|
|
87
|
-
if (relation === undefined) {
|
|
88
|
-
const alternative = this.recommendAlternative(
|
|
89
|
-
relationName,
|
|
90
|
-
Array.from(containingEntity.fields)
|
|
91
|
-
.filter(([, field]) => {
|
|
92
|
-
if (field.__typename !== '_Relation') {
|
|
93
|
-
return false
|
|
94
|
-
}
|
|
95
|
-
if (marker instanceof HasOneRelationMarker) {
|
|
96
|
-
return field.type === 'OneHasOne' || field.type === 'ManyHasOne'
|
|
97
|
-
}
|
|
98
|
-
if (marker instanceof HasManyRelationMarker) {
|
|
99
|
-
return field.type === 'OneHasMany' || field.type === 'ManyHasMany'
|
|
100
|
-
}
|
|
101
|
-
return assertNever(marker)
|
|
102
|
-
})
|
|
103
|
-
.map(([fieldName]) => fieldName),
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
yield new LocalizedBindingError(
|
|
107
|
-
`Invalid has-${type} relation '${relationName}' doesn't exist on entity '${containingEntity.name}'. ` +
|
|
108
|
-
(alternative ? `Did you mean '${alternative}'?` : ''),
|
|
109
|
-
[marker],
|
|
110
|
-
)
|
|
111
|
-
return
|
|
112
|
-
}
|
|
113
|
-
if (relation.__typename === '_Column') {
|
|
114
|
-
yield new LocalizedBindingError(
|
|
115
|
-
`Invalid has-${type} relation: the name '${relationName}' on entity '${containingEntity.name}' ` +
|
|
116
|
-
`refers to an ordinary scalar field but is being used as a has-${type} relation.`,
|
|
117
|
-
[marker],
|
|
118
|
-
)
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
if (
|
|
122
|
-
marker instanceof HasOneRelationMarker &&
|
|
123
|
-
marker.parameters.reducedBy === undefined &&
|
|
124
|
-
(relation.type === 'OneHasMany' || relation.type === 'ManyHasMany')
|
|
125
|
-
) {
|
|
126
|
-
yield new LocalizedBindingError(
|
|
127
|
-
`Invalid has-one relation: the name '${relationName}' on entity '${containingEntity.name}' ` +
|
|
128
|
-
`refers to a *has-many* relation but is being used as a has-one.`,
|
|
129
|
-
[marker],
|
|
130
|
-
)
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
if (
|
|
134
|
-
(marker instanceof HasManyRelationMarker ||
|
|
135
|
-
(marker instanceof HasOneRelationMarker && marker.parameters.reducedBy !== undefined)) &&
|
|
136
|
-
(relation.type === 'OneHasOne' || relation.type === 'ManyHasOne')
|
|
137
|
-
) {
|
|
138
|
-
yield new LocalizedBindingError(
|
|
139
|
-
`Invalid has-many relation: the name '${relationName}' on entity '${containingEntity.name}' ` +
|
|
140
|
-
`refers to a *has-one* relation but is being used as a has-many.`,
|
|
141
|
-
[marker],
|
|
142
|
-
)
|
|
143
|
-
return
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// TODO check filter
|
|
147
|
-
// TODO check reducedBy
|
|
148
|
-
// TODO check expected mutations
|
|
149
|
-
// TODO run custom validators
|
|
150
|
-
|
|
151
|
-
const targetEntityName = relation.targetEntity
|
|
152
|
-
const targetEntity = schema.store.entities.get(targetEntityName)
|
|
153
|
-
|
|
154
|
-
if (targetEntity === undefined) {
|
|
155
|
-
return // ?!? This really shouldn't ever happen.
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
yield* this.nestErrorsIn(marker, this.getMarkersContainerErrors(schema, targetEntity, marker.fields))
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
private static *getFieldErrors(
|
|
162
|
-
schema: Schema,
|
|
163
|
-
containingEntity: SchemaEntity,
|
|
164
|
-
marker: FieldMarker,
|
|
165
|
-
): Generator<LocalizedBindingError, void> {
|
|
166
|
-
const fieldName = marker.fieldName
|
|
167
|
-
const field = containingEntity.fields.get(fieldName)
|
|
168
|
-
|
|
169
|
-
if (field === undefined) {
|
|
170
|
-
const alternative = this.recommendAlternative(
|
|
171
|
-
fieldName,
|
|
172
|
-
Array.from(containingEntity.fields)
|
|
173
|
-
.filter(([, field]) => field.__typename === '_Column')
|
|
174
|
-
.map(([fieldName]) => fieldName),
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
yield new LocalizedBindingError(
|
|
178
|
-
`Field '${fieldName}' doesn't exist on entity '${containingEntity.name}'. ` +
|
|
179
|
-
(alternative ? `Did you mean '${alternative}'?` : ''),
|
|
180
|
-
[marker],
|
|
181
|
-
)
|
|
182
|
-
return
|
|
183
|
-
}
|
|
184
|
-
if (field.__typename === '_Relation') {
|
|
185
|
-
yield new LocalizedBindingError(
|
|
186
|
-
`Invalid field: the name '${fieldName}' on entity '${containingEntity.name}' ` +
|
|
187
|
-
`refers to a has-${
|
|
188
|
-
field.type === 'OneHasOne' || field.type === 'ManyHasOne' ? 'one' : 'many'
|
|
189
|
-
} relation but is being used as a field.`,
|
|
190
|
-
[marker],
|
|
191
|
-
)
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// TODO check that defaultValue matches the type
|
|
196
|
-
// TODO run custom validators
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private static *getUniqueWhereErrors(
|
|
200
|
-
schema: Schema,
|
|
201
|
-
containingEntity: SchemaEntity,
|
|
202
|
-
where: UniqueWhere,
|
|
203
|
-
): Generator<LocalizedBindingError, void> {
|
|
204
|
-
//
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private static *getFilterErrors(
|
|
208
|
-
schema: Schema,
|
|
209
|
-
containingEntity: SchemaEntity,
|
|
210
|
-
filter: Filter,
|
|
211
|
-
): Generator<LocalizedBindingError, void> {
|
|
212
|
-
//
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private static *nestErrorsIn(
|
|
216
|
-
source: HasOneRelationMarker | HasManyRelationMarker | EntityListSubTreeMarker | EntitySubTreeMarker,
|
|
217
|
-
to: Generator<LocalizedBindingError, void>,
|
|
218
|
-
): Generator<LocalizedBindingError, void> {
|
|
219
|
-
for (const error of to) {
|
|
220
|
-
yield error.nestedIn(source)
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private static recommendAlternative(original: string, possibleAlternatives: Iterable<string>): string | undefined {
|
|
225
|
-
let bestAlternative: string | undefined = undefined
|
|
226
|
-
let bestAlternativeDistance = Number.MAX_SAFE_INTEGER
|
|
227
|
-
|
|
228
|
-
for (const alternative of possibleAlternatives) {
|
|
229
|
-
const distance = levenshtein(original, alternative)
|
|
230
|
-
|
|
231
|
-
if (distance < bestAlternativeDistance) {
|
|
232
|
-
bestAlternative = alternative
|
|
233
|
-
bestAlternativeDistance = distance
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return bestAlternative
|
|
237
|
-
}
|
|
238
|
-
}
|