@contember/binding 1.0.0-rc.8 → 1.1.0-alpha.0
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/BindingError.js +0 -1
- package/dist/development/BindingError.js.map +1 -1
- package/dist/development/accessorPropagation/AccessorProvider.js +3 -5
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsContext.js +2 -4
- package/dist/development/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js +2 -4
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyContext.js +1 -3
- package/dist/development/accessorPropagation/EntityKeyContext.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js +2 -4
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js +2 -4
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdContext.js +1 -3
- package/dist/development/accessorPropagation/TreeRootIdContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js +2 -4
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorPropagation/useAccessorUpdateSubscription.js +2 -4
- package/dist/development/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
- package/dist/development/accessorPropagation/useBindingOperations.js +2 -4
- package/dist/development/accessorPropagation/useBindingOperations.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js +3 -5
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js +3 -5
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js +3 -5
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/development/accessorPropagation/useEntity.js +7 -9
- package/dist/development/accessorPropagation/useEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityKey.js +3 -5
- package/dist/development/accessorPropagation/useEntityKey.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityList.js +7 -9
- package/dist/development/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTree.js +4 -6
- package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTreeParameters.js +2 -4
- package/dist/development/accessorPropagation/useEntityListSubTreeParameters.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTree.js +4 -6
- package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTreeParameters.js +2 -4
- package/dist/development/accessorPropagation/useEntitySubTreeParameters.js.map +1 -1
- package/dist/development/accessorPropagation/useEnvironment.js +2 -4
- package/dist/development/accessorPropagation/useEnvironment.js.map +1 -1
- package/dist/development/accessorPropagation/useField.js +7 -9
- package/dist/development/accessorPropagation/useField.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntityByKey.js +1 -3
- package/dist/development/accessorPropagation/useGetEntityByKey.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntityListSubTree.js +4 -6
- package/dist/development/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntitySubTree.js +4 -6
- package/dist/development/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useGetTreeFilters.js +1 -3
- package/dist/development/accessorPropagation/useGetTreeFilters.js.map +1 -1
- package/dist/development/accessorPropagation/useHasEntity.js +2 -4
- package/dist/development/accessorPropagation/useHasEntity.js.map +1 -1
- package/dist/development/accessorPropagation/usePersist.js +1 -3
- package/dist/development/accessorPropagation/usePersist.js.map +1 -1
- package/dist/development/accessorPropagation/useTreeRootId.js +2 -4
- package/dist/development/accessorPropagation/useTreeRootId.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +9 -11
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorSorting/addEntityAtIndex.js +2 -4
- package/dist/development/accessorSorting/addEntityAtIndex.js.map +1 -1
- package/dist/development/accessorSorting/errors.js +1 -3
- package/dist/development/accessorSorting/errors.js.map +1 -1
- package/dist/development/accessorSorting/moveEntity.js +1 -3
- package/dist/development/accessorSorting/moveEntity.js.map +1 -1
- package/dist/development/accessorSorting/repairEntitiesOrder.js +0 -1
- package/dist/development/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/development/accessorSorting/sortEntities.js +0 -1
- package/dist/development/accessorSorting/sortEntities.js.map +1 -1
- package/dist/development/accessorSorting/useSortedEntities.js +6 -8
- package/dist/development/accessorSorting/useSortedEntities.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js +4 -6
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/DirtinessContext.js +1 -3
- package/dist/development/accessorTree/DirtinessContext.js.map +1 -1
- package/dist/development/accessorTree/MutationStateContext.js +1 -3
- package/dist/development/accessorTree/MutationStateContext.js.map +1 -1
- package/dist/development/accessorTree/NormalizedPersistedData.js +0 -1
- package/dist/development/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +22 -17
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js +0 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/development/accessorTree/metadataToRequestError.js +0 -1
- package/dist/development/accessorTree/metadataToRequestError.js.map +1 -1
- package/dist/development/accessorTree/useDataBinding.js +5 -7
- package/dist/development/accessorTree/useDataBinding.js.map +1 -1
- package/dist/development/accessorTree/useDirtinessState.js +2 -4
- package/dist/development/accessorTree/useDirtinessState.js.map +1 -1
- package/dist/development/accessorTree/useMutationState.js +2 -4
- package/dist/development/accessorTree/useMutationState.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +5 -7
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +1 -3
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/ErrorAccessor.js +0 -1
- package/dist/development/accessors/ErrorAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +3 -5
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/accessors/TreeRootAccessor.js +0 -1
- package/dist/development/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/development/bindingTypes.js +0 -1
- package/dist/development/bindingTypes.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +15 -11
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js +18 -12
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +74 -67
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/DirtinessTracker.js +10 -3
- package/dist/development/core/DirtinessTracker.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +3 -5
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +20 -16
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +14 -8
- package/dist/development/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/development/core/MarkerComparator.js +6 -8
- package/dist/development/core/MarkerComparator.js.map +1 -1
- package/dist/development/core/MarkerMerger.js +18 -19
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MarkerTreeGenerator.js +18 -13
- package/dist/development/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +13 -15
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/QueryGenerator.js +9 -11
- package/dist/development/core/QueryGenerator.js.map +1 -1
- package/dist/development/core/RealmKeyGenerator.js +10 -6
- package/dist/development/core/RealmKeyGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +7 -9
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +28 -26
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +6 -8
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeFilterGenerator.js +8 -8
- package/dist/development/core/TreeFilterGenerator.js.map +1 -1
- package/dist/development/core/TreeParameterMerger.js +2 -4
- package/dist/development/core/TreeParameterMerger.js.map +1 -1
- package/dist/development/core/TreeStore.js +19 -15
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.js +6 -5
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/exceptions/ErrorLocator.js +10 -6
- package/dist/development/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/development/core/exceptions/LocalizedBindingError.js +1 -3
- package/dist/development/core/exceptions/LocalizedBindingError.js.map +1 -1
- package/dist/development/core/exceptions/MarkerSugarer.js +7 -9
- package/dist/development/core/exceptions/MarkerSugarer.js.map +1 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.js +0 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.js.map +1 -1
- package/dist/development/core/factories/createBatchUpdatesOptions.js +1 -3
- package/dist/development/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +13 -14
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +10 -12
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +12 -14
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/operations/OperationsHelpers.js +4 -6
- package/dist/development/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js +2 -4
- package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -1
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +1 -1
- package/dist/development/core/requestAliases/mutationOperationType.js +0 -1
- package/dist/development/core/requestAliases/mutationOperationType.js.map +1 -1
- package/dist/development/core/schema/Schema.js +3 -1
- package/dist/development/core/schema/Schema.js.map +1 -1
- package/dist/development/core/schema/SchemaLoader.js +9 -5
- package/dist/development/core/schema/SchemaLoader.js.map +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js +0 -1
- package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/development/core/state/StateIterator.js +2 -4
- package/dist/development/core/state/StateIterator.js.map +1 -1
- package/dist/development/core/state/getEntityMarker.js +0 -1
- package/dist/development/core/state/getEntityMarker.js.map +1 -1
- package/dist/development/core/utils/getCombinedSignal.js +0 -1
- package/dist/development/core/utils/getCombinedSignal.js.map +1 -1
- package/dist/development/coreComponents/Component.js +2 -4
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +3 -5
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +3 -5
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +3 -5
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +13 -23
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +14 -34
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +10 -8
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +10 -14
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +10 -14
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js +3 -5
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/Environment.js +147 -89
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/dao/TreeNodeEnvironmentFactory.js +159 -0
- package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/development/dao/VariableFieldValue.js +0 -1
- package/dist/development/dao/VariableFieldValue.js.map +1 -1
- package/dist/development/entityEvents/useDerivedField.js +4 -6
- package/dist/development/entityEvents/useDerivedField.js.map +1 -1
- package/dist/development/entityEvents/useEntityBeforePersist.js +1 -3
- package/dist/development/entityEvents/useEntityBeforePersist.js.map +1 -1
- package/dist/development/entityEvents/useEntityBeforeUpdate.js +1 -3
- package/dist/development/entityEvents/useEntityBeforeUpdate.js.map +1 -1
- package/dist/development/entityEvents/useEntityEvent.js +3 -5
- package/dist/development/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/development/entityEvents/useEntityPersistError.js +1 -3
- package/dist/development/entityEvents/useEntityPersistError.js.map +1 -1
- package/dist/development/entityEvents/useEntityPersistSuccess.js +1 -3
- package/dist/development/entityEvents/useEntityPersistSuccess.js.map +1 -1
- package/dist/development/entityEvents/useOnConnectionUpdate.js +1 -3
- package/dist/development/entityEvents/useOnConnectionUpdate.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/FieldHelper.js +8 -4
- package/dist/development/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js +1 -3
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/UuidFieldHelper.js +2 -4
- package/dist/development/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +9 -11
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js +2 -4
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js +7 -9
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js +2 -4
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js +3 -5
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/development/index.js +101 -101
- package/dist/development/index.js.map +1 -1
- package/dist/development/markers/EntityFieldMarkersContainer.js +5 -7
- package/dist/development/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/development/markers/EntityFieldsWithHoistablesMarker.js +0 -1
- package/dist/development/markers/EntityFieldsWithHoistablesMarker.js.map +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js +8 -4
- package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js +8 -4
- package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/development/markers/FieldMarker.js +8 -4
- package/dist/development/markers/FieldMarker.js.map +1 -1
- package/dist/development/markers/HasManyRelationMarker.js +9 -5
- package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/development/markers/HasOneRelationMarker.js +8 -4
- package/dist/development/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/development/markers/MarkerTreeRoot.js +0 -1
- package/dist/development/markers/MarkerTreeRoot.js.map +1 -1
- package/dist/development/markers/ParentEntityMarker.js +0 -1
- package/dist/development/markers/ParentEntityMarker.js.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.js +1 -3
- package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/development/queryLanguage/CacheStore.js +10 -4
- package/dist/development/queryLanguage/CacheStore.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js +15 -16
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +572 -547
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +32 -27
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguageError.js +0 -1
- package/dist/development/queryLanguage/QueryLanguageError.js.map +1 -1
- package/dist/development/queryLanguage/tokenList.js +6 -3
- package/dist/development/queryLanguage/tokenList.js.map +1 -1
- package/dist/development/structures/BijectiveIndexedMap.js +14 -9
- package/dist/development/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/development/structures/LRUCache.js +7 -2
- package/dist/development/structures/LRUCache.js.map +1 -1
- package/dist/development/structures/WeakIdCache.js +11 -4
- package/dist/development/structures/WeakIdCache.js.map +1 -1
- package/dist/development/treeParameterHelpers/wrapFilterInHasOnes.js +1 -3
- package/dist/development/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/development/treeParameters/EntityCreationParameters.js +0 -1
- package/dist/development/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/development/treeParameters/EntityListPreferences.js +0 -1
- package/dist/development/treeParameters/EntityListPreferences.js.map +1 -1
- package/dist/development/treeParameters/EventListenersStore.js +0 -1
- package/dist/development/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/development/treeParameters/LeafField.js +0 -1
- package/dist/development/treeParameters/LeafField.js.map +1 -1
- package/dist/development/treeParameters/QualifiedEntityParameters.js +0 -1
- package/dist/development/treeParameters/QualifiedEntityParameters.js.map +1 -1
- package/dist/development/treeParameters/Relation.js +0 -1
- package/dist/development/treeParameters/Relation.js.map +1 -1
- package/dist/development/utils/Hashing.js +0 -1
- package/dist/development/utils/Hashing.js.map +1 -1
- package/dist/development/utils/assert.js +1 -3
- package/dist/development/utils/assert.js.map +1 -1
- package/dist/development/utils/assertNever.js +2 -4
- package/dist/development/utils/assertNever.js.map +1 -1
- package/dist/development/utils/generateEnumerabilityPreventingEntropy.js +0 -1
- package/dist/development/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
- package/dist/development/utils/isEmptyObject.js +0 -1
- package/dist/development/utils/isEmptyObject.js.map +1 -1
- package/dist/development/utils/ucfirst.js +0 -1
- package/dist/development/utils/ucfirst.js.map +1 -1
- package/dist/production/BindingError.js.map +1 -1
- package/dist/production/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/production/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/production/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EntityKeyContext.js.map +1 -1
- package/dist/production/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/production/accessorPropagation/TreeRootIdContext.js.map +1 -1
- package/dist/production/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/production/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
- package/dist/production/accessorPropagation/useBindingOperations.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/production/accessorPropagation/useEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityKey.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTreeParameters.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTreeParameters.js.map +1 -1
- package/dist/production/accessorPropagation/useEnvironment.js.map +1 -1
- package/dist/production/accessorPropagation/useField.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntityByKey.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useGetTreeFilters.js.map +1 -1
- package/dist/production/accessorPropagation/useHasEntity.js.map +1 -1
- package/dist/production/accessorPropagation/usePersist.js.map +1 -1
- package/dist/production/accessorPropagation/useTreeRootId.js.map +1 -1
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/accessorSorting/addEntityAtIndex.js.map +1 -1
- package/dist/production/accessorSorting/errors.js.map +1 -1
- package/dist/production/accessorSorting/moveEntity.js.map +1 -1
- package/dist/production/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/production/accessorSorting/sortEntities.js.map +1 -1
- package/dist/production/accessorSorting/useSortedEntities.js.map +1 -1
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/DirtinessContext.js.map +1 -1
- package/dist/production/accessorTree/MutationStateContext.js.map +1 -1
- package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/production/accessorTree/metadataToRequestError.js.map +1 -1
- package/dist/production/accessorTree/useDataBinding.js.map +1 -1
- package/dist/production/accessorTree/useDirtinessState.js.map +1 -1
- package/dist/production/accessorTree/useMutationState.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/ErrorAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/production/bindingTypes.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +22 -11
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/DirtinessTracker.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/production/core/MarkerComparator.js +1 -1
- package/dist/production/core/MarkerComparator.js.map +1 -1
- package/dist/production/core/MarkerMerger.js +1 -4
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/QueryGenerator.js.map +1 -1
- package/dist/production/core/RealmKeyGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +1 -3
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeFilterGenerator.js.map +1 -1
- package/dist/production/core/TreeParameterMerger.js.map +1 -1
- 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/exceptions/ErrorLocator.js.map +1 -1
- package/dist/production/core/exceptions/LocalizedBindingError.js.map +1 -1
- package/dist/production/core/exceptions/MarkerSugarer.js.map +1 -1
- package/dist/production/core/exceptions/TreeParameterSugarer.js.map +1 -1
- package/dist/production/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +1 -1
- 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.map +1 -1
- package/dist/production/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +1 -1
- package/dist/production/core/requestAliases/mutationOperationType.js.map +1 -1
- package/dist/production/core/schema/Schema.js +3 -0
- package/dist/production/core/schema/Schema.js.map +1 -1
- package/dist/production/core/schema/SchemaLoader.js.map +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/production/core/state/StateIterator.js.map +1 -1
- package/dist/production/core/state/getEntityMarker.js.map +1 -1
- package/dist/production/core/utils/getCombinedSignal.js.map +1 -1
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/Entity.js.map +1 -1
- package/dist/production/coreComponents/EntityList.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 +3 -5
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/coreComponents/ParentEntity.js.map +1 -1
- package/dist/production/dao/Environment.js +147 -94
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/dao/TreeNodeEnvironmentFactory.js +159 -0
- package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -0
- package/dist/production/dao/VariableFieldValue.js.map +1 -1
- package/dist/production/entityEvents/useDerivedField.js.map +1 -1
- package/dist/production/entityEvents/useEntityBeforePersist.js.map +1 -1
- package/dist/production/entityEvents/useEntityBeforeUpdate.js.map +1 -1
- package/dist/production/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/production/entityEvents/useEntityPersistError.js.map +1 -1
- package/dist/production/entityEvents/useEntityPersistSuccess.js.map +1 -1
- package/dist/production/entityEvents/useOnConnectionUpdate.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/EntityView.js.map +1 -1
- package/dist/production/helperComponents/FieldView.js.map +1 -1
- package/dist/production/helperComponents/StaticRender.js.map +1 -1
- package/dist/production/helperComponents/SugaredField.js.map +1 -1
- package/dist/production/index.js +1 -1
- package/dist/production/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/production/markers/EntityFieldsWithHoistablesMarker.js.map +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/production/markers/FieldMarker.js.map +1 -1
- package/dist/production/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/production/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/production/markers/MarkerTreeRoot.js.map +1 -1
- package/dist/production/markers/ParentEntityMarker.js.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/production/queryLanguage/CacheStore.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js +4 -3
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +24 -7
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguageError.js.map +1 -1
- package/dist/production/queryLanguage/tokenList.js +5 -0
- package/dist/production/queryLanguage/tokenList.js.map +1 -1
- package/dist/production/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/production/structures/LRUCache.js.map +1 -1
- package/dist/production/structures/WeakIdCache.js.map +1 -1
- package/dist/production/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/production/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/production/treeParameters/EntityListPreferences.js.map +1 -1
- package/dist/production/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/production/treeParameters/LeafField.js.map +1 -1
- package/dist/production/treeParameters/QualifiedEntityParameters.js.map +1 -1
- package/dist/production/treeParameters/Relation.js.map +1 -1
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/production/utils/assert.js.map +1 -1
- package/dist/production/utils/assertNever.js +1 -1
- package/dist/production/utils/assertNever.js.map +1 -1
- package/dist/production/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
- package/dist/production/utils/isEmptyObject.js.map +1 -1
- package/dist/production/utils/ucfirst.js.map +1 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts +4 -0
- package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +4 -0
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/RequestError.d.ts +9 -1
- package/dist/types/accessorTree/RequestError.d.ts.map +1 -1
- package/dist/types/core/DataBinding.d.ts +1 -0
- package/dist/types/core/DataBinding.d.ts.map +1 -1
- package/dist/types/core/MarkerMerger.d.ts.map +1 -1
- package/dist/types/core/StateInitializer.d.ts.map +1 -1
- package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
- package/dist/types/core/schema/Schema.d.ts +2 -0
- package/dist/types/core/schema/Schema.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/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.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/dao/Environment.d.ts +82 -43
- 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/queryLanguage/MarkerFactory.d.ts.map +1 -1
- package/dist/types/queryLanguage/Parser.d.ts +1 -0
- package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
- package/dist/types/queryLanguage/tokenList.d.ts +1 -0
- package/dist/types/queryLanguage/tokenList.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/src/accessorTree/MutationRequestResponse.ts +1 -0
- package/src/accessorTree/QueryRequestResponse.ts +1 -0
- package/src/accessorTree/RequestError.ts +7 -1
- package/src/core/DataBinding.ts +27 -28
- package/src/core/MarkerMerger.ts +1 -4
- package/src/core/StateInitializer.ts +1 -3
- package/src/core/VariableInputTransformer.ts +7 -4
- package/src/core/schema/Schema.ts +5 -0
- package/src/core/schema/index.ts +0 -1
- 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 +221 -126
- package/src/dao/TreeNodeEnvironmentFactory.ts +228 -0
- package/src/queryLanguage/MarkerFactory.ts +5 -3
- package/src/queryLanguage/Parser.ts +36 -12
- package/src/queryLanguage/tokenList.ts +6 -0
- package/src/tsconfig.json +1 -1
- package/src/utils/assertNever.ts +1 -1
- package/dist/development/core/schema/SchemaValidator.js +0 -118
- package/dist/development/core/schema/SchemaValidator.js.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/core/schema/SchemaValidator.ts +0 -238
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
import { assertNever } from '../utils'
|
|
29
29
|
import { QueryLanguage } from './QueryLanguage'
|
|
30
30
|
import { GraphQlLiteral } from '@contember/client'
|
|
31
|
+
import { BindingError } from '../BindingError'
|
|
31
32
|
|
|
32
33
|
export class MarkerFactory {
|
|
33
34
|
private static createSubTreeMarker<
|
|
@@ -191,7 +192,7 @@ export class MarkerFactory {
|
|
|
191
192
|
)
|
|
192
193
|
return this.wrapRelativeEntityFieldMarkers(
|
|
193
194
|
relativeEntityList.hasOneRelationPath,
|
|
194
|
-
environment,
|
|
195
|
+
environment.getParent(),
|
|
195
196
|
this.createEntityFieldMarkersContainer(hasManyRelationMarker),
|
|
196
197
|
)
|
|
197
198
|
}
|
|
@@ -210,7 +211,7 @@ export class MarkerFactory {
|
|
|
210
211
|
return new EntityFieldsWithHoistablesMarker(
|
|
211
212
|
this.wrapRelativeEntityFieldMarkers(
|
|
212
213
|
relativeEntityList.hasOneRelationPath,
|
|
213
|
-
environment,
|
|
214
|
+
environment.getParent(),
|
|
214
215
|
this.createEntityFieldMarkersContainer(hasManyRelationMarker),
|
|
215
216
|
),
|
|
216
217
|
fields.subTrees,
|
|
@@ -236,7 +237,7 @@ export class MarkerFactory {
|
|
|
236
237
|
|
|
237
238
|
return this.wrapRelativeEntityFieldMarkers(
|
|
238
239
|
relativeSingleField.hasOneRelationPath,
|
|
239
|
-
environment,
|
|
240
|
+
environment.getParent(),
|
|
240
241
|
this.createEntityFieldMarkersContainer(getMarker(relativeSingleField)),
|
|
241
242
|
)
|
|
242
243
|
}
|
|
@@ -248,6 +249,7 @@ export class MarkerFactory {
|
|
|
248
249
|
): EntityFieldMarkersContainer {
|
|
249
250
|
for (let i = hasOneRelationPath.length - 1; i >= 0; i--) {
|
|
250
251
|
const marker = this.createHasOneRelationMarker(hasOneRelationPath[i], environment, fields)
|
|
252
|
+
environment = environment.getParent()
|
|
251
253
|
fields = this.createEntityFieldMarkersContainer(marker)
|
|
252
254
|
}
|
|
253
255
|
return fields
|
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
import { CacheStore } from './CacheStore'
|
|
22
22
|
import { QueryLanguageError } from './QueryLanguageError'
|
|
23
23
|
import { tokenList, TokenRegExps, tokens } from './tokenList'
|
|
24
|
+
import { BindingError } from '../BindingError'
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* TODO:
|
|
@@ -33,7 +34,7 @@ class Parser extends EmbeddedActionsParser {
|
|
|
33
34
|
private static rawInput: string = ''
|
|
34
35
|
private static lexer = new Lexer(tokenList)
|
|
35
36
|
private static parser = new Parser()
|
|
36
|
-
private static environment: Environment =
|
|
37
|
+
private static environment: Environment = Environment.create()
|
|
37
38
|
private static cacheStore: CacheStore = new CacheStore()
|
|
38
39
|
|
|
39
40
|
private qualifiedEntityList = this.RULE<ParsedQualifiedEntityList>('qualifiedEntityList', () => {
|
|
@@ -532,7 +533,7 @@ class Parser extends EmbeddedActionsParser {
|
|
|
532
533
|
})
|
|
533
534
|
|
|
534
535
|
private taggedMap: () => ParsedTaggedMap = this.RULE<ParsedTaggedMap>('taggedMap', () => {
|
|
535
|
-
const name = this.SUBRULE(this.
|
|
536
|
+
const name = this.SUBRULE(this.pageName)
|
|
536
537
|
return {
|
|
537
538
|
name,
|
|
538
539
|
entries: this.OPTION(() => this.SUBRULE(this.taggedMapEntries)) ?? [],
|
|
@@ -669,6 +670,17 @@ class Parser extends EmbeddedActionsParser {
|
|
|
669
670
|
])
|
|
670
671
|
})
|
|
671
672
|
|
|
673
|
+
private pageName: () => string = this.RULE('pageName', () => {
|
|
674
|
+
const parts: string[] = []
|
|
675
|
+
|
|
676
|
+
this.AT_LEAST_ONE_SEP({
|
|
677
|
+
SEP: tokens.Slash,
|
|
678
|
+
DEF: () => parts.push(this.CONSUME(tokens.Identifier).image),
|
|
679
|
+
})
|
|
680
|
+
|
|
681
|
+
return parts.join('/')
|
|
682
|
+
})
|
|
683
|
+
|
|
672
684
|
private entityIdentifier: () => EntityName = this.RULE('entityIdentifier', () => {
|
|
673
685
|
return this.OR([
|
|
674
686
|
{
|
|
@@ -711,25 +723,37 @@ class Parser extends EmbeddedActionsParser {
|
|
|
711
723
|
return new GraphQlBuilder.GraphQlLiteral(image)
|
|
712
724
|
})
|
|
713
725
|
|
|
714
|
-
private variable = this.RULE<
|
|
726
|
+
private variable = this.RULE<Environment.ResolvedValue>('variable', () => {
|
|
715
727
|
this.CONSUME(tokens.DollarSign)
|
|
716
728
|
const variableName = this.CONSUME(tokens.Identifier).image
|
|
717
729
|
|
|
718
730
|
return this.ACTION(() => {
|
|
719
|
-
if (
|
|
720
|
-
|
|
731
|
+
if (import.meta.env.DEV && variableName === 'rootWhereAsFilter') {
|
|
732
|
+
console.warn('$rootWhereAsFilter is deprecated, use $rootFilter')
|
|
733
|
+
}
|
|
734
|
+
switch (variableName) {
|
|
735
|
+
case 'rootWhereAsFilter':
|
|
736
|
+
case 'rootFilter':
|
|
737
|
+
return Parser.environment.getSubTree().filter
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (Parser.environment.hasVariable(variableName)) {
|
|
741
|
+
return Parser.environment.getVariable(variableName)
|
|
742
|
+
}
|
|
743
|
+
if (Parser.environment.hasParameter(variableName)) {
|
|
744
|
+
return Parser.environment.getParameter(variableName)
|
|
721
745
|
}
|
|
722
746
|
if (Parser.environment.hasDimension(variableName)) {
|
|
723
747
|
const dimensionValue = Parser.environment.getDimension(variableName)
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
throw new QueryLanguageError(
|
|
729
|
-
`The variable \$${variableName} resolved to a dimension which exists but contains ${dimensionValue.length} values. It has to contain exactly one. ` +
|
|
748
|
+
if (dimensionValue.length > 1) {
|
|
749
|
+
throw new BindingError(
|
|
750
|
+
`The variable \$${variableName} resolved to a dimension which exists but contains ${dimensionValue.length} values. It has to contain exactly one. ` +
|
|
730
751
|
`Perhaps you forgot to set the 'maxItems' prop of your DimensionsSwitcher?`,
|
|
731
|
-
|
|
752
|
+
)
|
|
753
|
+
}
|
|
754
|
+
return dimensionValue[0]
|
|
732
755
|
}
|
|
756
|
+
|
|
733
757
|
throw new QueryLanguageError(`Undefined variable \$${variableName}.`)
|
|
734
758
|
})
|
|
735
759
|
})
|
|
@@ -44,6 +44,11 @@ export const tokens = {
|
|
|
44
44
|
pattern: /:/,
|
|
45
45
|
}),
|
|
46
46
|
|
|
47
|
+
Slash: createToken({
|
|
48
|
+
name: 'Slash',
|
|
49
|
+
pattern: /\//,
|
|
50
|
+
}),
|
|
51
|
+
|
|
47
52
|
NumberLiteral: createToken({
|
|
48
53
|
name: 'NumberLiteral',
|
|
49
54
|
pattern: /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/,
|
|
@@ -149,6 +154,7 @@ const tokenList = [
|
|
|
149
154
|
tokens.Dot,
|
|
150
155
|
tokens.Comma,
|
|
151
156
|
tokens.Colon,
|
|
157
|
+
tokens.Slash,
|
|
152
158
|
tokens.StringLiteral,
|
|
153
159
|
tokens.NumberLiteral,
|
|
154
160
|
tokens.LeftParenthesis,
|
package/src/tsconfig.json
CHANGED
package/src/utils/assertNever.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BindingError } from '../BindingError'
|
|
|
2
2
|
|
|
3
3
|
export function assertNever(_: never): never {
|
|
4
4
|
throw new BindingError(
|
|
5
|
-
`FATAL ERROR. This should absolutely never have happened. Yet, despite all efforts, here we are
|
|
5
|
+
`FATAL ERROR. This should absolutely never have happened. Yet, despite all efforts, here we are. ` +
|
|
6
6
|
`Please find solace in having a good laugh about the whole situation. ` +
|
|
7
7
|
`You have just witnessed true harshness of software development. ` +
|
|
8
8
|
`Please report this bug.`,
|
|
@@ -1,118 +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
|
-
|
|
11
|
-
class SchemaValidator {
|
|
12
|
-
static assertTreeValid(schema, tree) {
|
|
13
|
-
const errors = Array.from(tree.subTrees.values(), (subTree) => Array.from(this.getSubTreeErrors(schema, subTree))).flat();
|
|
14
|
-
if (errors.length) {
|
|
15
|
-
throw new BindingError(`Invalid data tree:
|
|
16
|
-
` + errors.map((error) => ` \u2022 ${error.message} (Error at ${ErrorLocator.locateMarkerPath(error.markerPath)})`).join(`
|
|
17
|
-
`));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
static *getSubTreeErrors(schema, subTree) {
|
|
21
|
-
const entityName = subTree.entityName;
|
|
22
|
-
const entity = schema.store.entities.get(entityName);
|
|
23
|
-
if (entity === void 0) {
|
|
24
|
-
const type = subTree instanceof EntitySubTreeMarker ? "entity list" : "entity";
|
|
25
|
-
const alternative = this.recommendAlternative(entityName, schema.store.entities.keys());
|
|
26
|
-
yield new LocalizedBindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${alternative ? `Did you mean '${alternative}'?` : ""}`, [subTree]);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
yield* this.nestErrorsIn(subTree, this.getMarkersContainerErrors(schema, entity, subTree.fields));
|
|
30
|
-
}
|
|
31
|
-
static *getMarkersContainerErrors(schema, containingEntity, markers) {
|
|
32
|
-
for (const marker of markers.markers.values()) {
|
|
33
|
-
if (marker instanceof FieldMarker) {
|
|
34
|
-
yield* this.getFieldErrors(schema, containingEntity, marker);
|
|
35
|
-
} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {
|
|
36
|
-
yield* this.getRelationErrors(schema, containingEntity, marker);
|
|
37
|
-
} else {
|
|
38
|
-
return assertNever();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static *getRelationErrors(schema, containingEntity, marker) {
|
|
43
|
-
const relationName = marker.parameters.field;
|
|
44
|
-
const relation = containingEntity.fields.get(relationName);
|
|
45
|
-
const type = marker instanceof HasOneRelationMarker ? "one" : "many";
|
|
46
|
-
if (relation === void 0) {
|
|
47
|
-
const alternative = this.recommendAlternative(relationName, Array.from(containingEntity.fields).filter(([, field]) => {
|
|
48
|
-
if (field.__typename !== "_Relation") {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (marker instanceof HasOneRelationMarker) {
|
|
52
|
-
return field.type === "OneHasOne" || field.type === "ManyHasOne";
|
|
53
|
-
}
|
|
54
|
-
if (marker instanceof HasManyRelationMarker) {
|
|
55
|
-
return field.type === "OneHasMany" || field.type === "ManyHasMany";
|
|
56
|
-
}
|
|
57
|
-
return assertNever();
|
|
58
|
-
}).map(([fieldName]) => fieldName));
|
|
59
|
-
yield new LocalizedBindingError(`Invalid has-${type} relation '${relationName}' doesn't exist on entity '${containingEntity.name}'. ` + (alternative ? `Did you mean '${alternative}'?` : ""), [marker]);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (relation.__typename === "_Column") {
|
|
63
|
-
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]);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (marker instanceof HasOneRelationMarker && marker.parameters.reducedBy === void 0 && (relation.type === "OneHasMany" || relation.type === "ManyHasMany")) {
|
|
67
|
-
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]);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if ((marker instanceof HasManyRelationMarker || marker instanceof HasOneRelationMarker && marker.parameters.reducedBy !== void 0) && (relation.type === "OneHasOne" || relation.type === "ManyHasOne")) {
|
|
71
|
-
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]);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const targetEntityName = relation.targetEntity;
|
|
75
|
-
const targetEntity = schema.store.entities.get(targetEntityName);
|
|
76
|
-
if (targetEntity === void 0) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
yield* this.nestErrorsIn(marker, this.getMarkersContainerErrors(schema, targetEntity, marker.fields));
|
|
80
|
-
}
|
|
81
|
-
static *getFieldErrors(schema, containingEntity, marker) {
|
|
82
|
-
const fieldName = marker.fieldName;
|
|
83
|
-
const field = containingEntity.fields.get(fieldName);
|
|
84
|
-
if (field === void 0) {
|
|
85
|
-
const alternative = this.recommendAlternative(fieldName, Array.from(containingEntity.fields).filter(([, field2]) => field2.__typename === "_Column").map(([fieldName2]) => fieldName2));
|
|
86
|
-
yield new LocalizedBindingError(`Field '${fieldName}' doesn't exist on entity '${containingEntity.name}'. ` + (alternative ? `Did you mean '${alternative}'?` : ""), [marker]);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (field.__typename === "_Relation") {
|
|
90
|
-
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]);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
static *getUniqueWhereErrors(schema, containingEntity, where) {
|
|
95
|
-
}
|
|
96
|
-
static *getFilterErrors(schema, containingEntity, filter) {
|
|
97
|
-
}
|
|
98
|
-
static *nestErrorsIn(source, to) {
|
|
99
|
-
for (const error of to) {
|
|
100
|
-
yield error.nestedIn(source);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
static recommendAlternative(original, possibleAlternatives) {
|
|
104
|
-
let bestAlternative = void 0;
|
|
105
|
-
let bestAlternativeDistance = Number.MAX_SAFE_INTEGER;
|
|
106
|
-
for (const alternative of possibleAlternatives) {
|
|
107
|
-
const distance = levenshtein(original, alternative);
|
|
108
|
-
if (distance < bestAlternativeDistance) {
|
|
109
|
-
bestAlternative = alternative;
|
|
110
|
-
bestAlternativeDistance = distance;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return bestAlternative;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export { SchemaValidator };
|
|
118
|
-
//# 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":";;;;;;;;;;sBAiB6B;AAAA,SACd,gBAAgB,QAAgB,MAAsB;AACnE,UAAM,SAAS,MAAM,KAAK,KAAK,SAAS,UAAU,aACjD,MAAM,KAAK,KAAK,iBAAiB,QAAQ,WACxC;AAEF,QAAI,OAAO,QAAQ;AAClB,YAAM,IAAI,aACT;AAAA,IACC,OACE,IAAI,WAAS,WAAO,MAAM,qBAAqB,aAAa,iBAAiB,MAAM,gBACnF,KAAK;AAAA;AAAA;AAAA;AAAA,UAKK,iBACf,QACA,SACyC;AACzC,UAAM,aAAa,QAAQ;AAC3B,UAAM,SAAS,OAAO,MAAM,SAAS,IAAI;AAEzC,QAAI,WAAW,QAAW;AACzB,YAAM,OAAO,mBAAmB,sBAAsB,gBAAgB;AACtE,YAAM,cAAc,KAAK,qBAAqB,YAAY,OAAO,MAAM,SAAS;AAEhF,YAAM,IAAI,sBACT,WAAW,0BAA0B,8BACpC,cAAc,iBAAiB,kBAAkB,MAElD,CAAC;AAGF;AAAA;AAOD,WAAO,KAAK,aAAa,SAAS,KAAK,0BAA0B,QAAQ,QAAQ,QAAQ;AAAA;AAAA,UAG1E,0BACf,QACA,kBACA,SACyC;AACzC,eAAW,UAAU,QAAQ,QAAQ,UAAU;AAC9C,UAAI,kBAAkB,aAAa;AAClC,eAAO,KAAK,eAAe,QAAQ,kBAAkB;AAAA,iBAC3C,kBAAkB,wBAAwB,kBAAkB,uBAAuB;AAC7F,eAAO,KAAK,kBAAkB,QAAQ,kBAAkB;AAAA,aAClD;AACN,eAAO;AAAY;AAAA;AAAA;AAAA,UAKN,kBACf,QACA,kBACA,QACyC;AACzC,UAAM,eAAe,OAAO,WAAW;AACvC,UAAM,WAAW,iBAAiB,OAAO,IAAI;AAC7C,UAAM,OAAO,kBAAkB,uBAAuB,QAAQ;AAE9D,QAAI,aAAa,QAAW;AAC3B,YAAM,cAAc,KAAK,qBACxB,cACA,MAAM,KAAK,iBAAiB,QAC1B,OAAO,CAAC,GAAG,WAAW;AACtB,YAAI,MAAM,eAAe,aAAa;AACrC,iBAAO;AAAA;AAER,YAAI,kBAAkB,sBAAsB;AAC3C,iBAAO,MAAM,SAAS,eAAe,MAAM,SAAS;AAAA;AAErD,YAAI,kBAAkB,uBAAuB;AAC5C,iBAAO,MAAM,SAAS,gBAAgB,MAAM,SAAS;AAAA;AAEtD,eAAO;AAAY,SAEnB,IAAI,CAAC,CAAC,eAAe;AAGxB,YAAM,IAAI,sBACT,eAAe,kBAAkB,0CAA0C,iBAAiB,2BAC5E,iBAAiB,kBAAkB,KACnD,CAAC;AAEF;AAAA;AAED,QAAI,SAAS,eAAe,WAAW;AACtC,YAAM,IAAI,sBACT,eAAe,4BAA4B,4BAA4B,iBAAiB,uEACtB,kBAClE,CAAC;AAEF;AAAA;AAED,QACC,kBAAkB,wBAClB,OAAO,WAAW,cAAc,oBACtB,SAAS,gBAAgB,SAAS,SAAS,gBACpD;AACD,YAAM,IAAI,sBACT,uCAAuC,4BAA4B,iBAAiB,yEAEpF,CAAC;AAEF;AAAA;AAED,QACE,mBAAkB,yBACjB,kBAAkB,wBAAwB,OAAO,WAAW,cAAc,qBAClE,SAAS,eAAe,SAAS,SAAS,eACnD;AACD,YAAM,IAAI,sBACT,wCAAwC,4BAA4B,iBAAiB,yEAErF,CAAC;AAEF;AAAA;AAQD,UAAM,mBAAmB,SAAS;AAClC,UAAM,eAAe,OAAO,MAAM,SAAS,IAAI;AAE/C,QAAI,iBAAiB,QAAW;AAC/B;AAAA;AAGD,WAAO,KAAK,aAAa,QAAQ,KAAK,0BAA0B,QAAQ,cAAc,OAAO;AAAA;AAAA,UAG9E,eACf,QACA,kBACA,QACyC;AACzC,UAAM,YAAY,OAAO;AACzB,UAAM,QAAQ,iBAAiB,OAAO,IAAI;AAE1C,QAAI,UAAU,QAAW;AACxB,YAAM,cAAc,KAAK,qBACxB,WACA,MAAM,KAAK,iBAAiB,QAC1B,OAAO,CAAC,GAAG,YAAW,OAAM,eAAe,WAC3C,IAAI,CAAC,CAAC,gBAAe;AAGxB,YAAM,IAAI,sBACT,UAAU,uCAAuC,iBAAiB,2BAClD,iBAAiB,kBAAkB,KACnD,CAAC;AAEF;AAAA;AAED,QAAI,MAAM,eAAe,aAAa;AACrC,YAAM,IAAI,sBACT,4BAA4B,yBAAyB,iBAAiB,yBAEpE,MAAM,SAAS,eAAe,MAAM,SAAS,eAAe,QAAQ,iDAEtE,CAAC;AAEF;AAAA;AAAA;AAAA,UAOc,qBACf,QACA,kBACA,OACyC;AAAA;AAAA,UAI1B,gBACf,QACA,kBACA,QACyC;AAAA;AAAA,UAI1B,aACf,QACA,IACyC;AACzC,eAAW,SAAS,IAAI;AACvB,YAAM,MAAM,SAAS;AAAA;AAAA;AAAA,SAIR,qBAAqB,UAAkB,sBAA4D;AACjH,QAAI,kBAAsC;AAC1C,QAAI,0BAA0B,OAAO;AAErC,eAAW,eAAe,sBAAsB;AAC/C,YAAM,WAAW,YAAY,UAAU;AAEvC,UAAI,WAAW,yBAAyB;AACvC,0BAAkB;AAClB,kCAA0B;AAAA;AAAA;AAG5B,WAAO;AAAA;AAAA;;;;"}
|
|
@@ -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,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
|
-
}
|