@contember/binding 1.0.0-rc.2 → 1.0.0-rc.20
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/accessorSorting/moveEntity.js +1 -1
- package/dist/development/accessorSorting/moveEntity.js.map +1 -1
- package/dist/development/accessors/ErrorAccessor.js +1 -1
- package/dist/development/accessors/ErrorAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +3 -2
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +3 -3
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/DataBinding.js +6 -5
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +6 -6
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +7 -7
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/development/core/MarkerMerger.js +2 -2
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MarkerTreeGenerator.js +2 -2
- package/dist/development/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +4 -4
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +5 -5
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +13 -6
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +2 -2
- 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 +6 -6
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +2 -2
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +1 -1
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +1 -1
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/schema/SchemaPreprocessor.js +3 -3
- package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/development/dao/Environment.js +3 -3
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js +1 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/UuidFieldHelper.js +1 -1
- package/dist/development/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
- package/dist/development/index.js +1 -1
- package/dist/development/queryLanguage/CacheStore.js +1 -1
- package/dist/development/queryLanguage/CacheStore.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js +5 -5
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +9 -1
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +2 -2
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/queryLanguage/tokenList.js +6 -1
- package/dist/development/queryLanguage/tokenList.js.map +1 -1
- package/dist/development/structures/BijectiveIndexedMap.js +2 -2
- package/dist/development/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/development/structures/LRUCache.js +1 -1
- package/dist/development/structures/LRUCache.js.map +1 -1
- package/dist/development/structures/WeakIdCache.js +1 -1
- package/dist/development/structures/WeakIdCache.js.map +1 -1
- package/dist/development/treeParameters/EventListenersStore.js +3 -3
- package/dist/development/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/development/utils/assertNever.js +1 -1
- package/dist/development/utils/assertNever.js.map +1 -1
- package/dist/production/accessorSorting/moveEntity.js +1 -1
- package/dist/production/accessorSorting/moveEntity.js.map +1 -1
- package/dist/production/accessors/ErrorAccessor.js +1 -1
- package/dist/production/accessors/ErrorAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +3 -2
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +3 -3
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/DataBinding.js +6 -5
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js +6 -6
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js +7 -7
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/production/core/MarkerMerger.js +2 -2
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MarkerTreeGenerator.js +2 -2
- package/dist/production/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +4 -4
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js +5 -5
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +13 -6
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +2 -2
- 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 +6 -6
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +2 -2
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/FieldOperations.js +1 -1
- package/dist/production/core/operations/FieldOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.js +1 -1
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/core/schema/SchemaPreprocessor.js +3 -3
- package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
- package/dist/production/dao/Environment.js +3 -3
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js +1 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/UuidFieldHelper.js +1 -1
- package/dist/production/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
- package/dist/production/index.js +1 -1
- package/dist/production/queryLanguage/CacheStore.js +1 -1
- package/dist/production/queryLanguage/CacheStore.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js +5 -5
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +9 -1
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +2 -2
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/queryLanguage/tokenList.js +6 -1
- package/dist/production/queryLanguage/tokenList.js.map +1 -1
- package/dist/production/structures/BijectiveIndexedMap.js +2 -2
- package/dist/production/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/production/structures/LRUCache.js +1 -1
- package/dist/production/structures/LRUCache.js.map +1 -1
- package/dist/production/structures/WeakIdCache.js +1 -1
- package/dist/production/structures/WeakIdCache.js.map +1 -1
- package/dist/production/treeParameters/EventListenersStore.js +3 -3
- package/dist/production/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/production/utils/assertNever.js +1 -1
- package/dist/production/utils/assertNever.js.map +1 -1
- package/dist/types/BindingError.d.ts +4 -0
- package/dist/types/BindingError.d.ts.map +1 -0
- package/dist/types/accessorPropagation/AccessorProvider.d.ts +8 -0
- package/dist/types/accessorPropagation/AccessorProvider.d.ts.map +1 -0
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +5 -0
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -0
- package/dist/types/accessorPropagation/BindingOperationsProvider.d.ts +8 -0
- package/dist/types/accessorPropagation/BindingOperationsProvider.d.ts.map +1 -0
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +3 -0
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -0
- package/dist/types/accessorPropagation/EntityKeyProvider.d.ts +7 -0
- package/dist/types/accessorPropagation/EntityKeyProvider.d.ts.map +1 -0
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts +4 -0
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -0
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +3 -0
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -0
- package/dist/types/accessorPropagation/TreeRootIdProvider.d.ts +8 -0
- package/dist/types/accessorPropagation/TreeRootIdProvider.d.ts.map +1 -0
- package/dist/types/accessorPropagation/index.d.ts +27 -0
- package/dist/types/accessorPropagation/index.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +16 -0
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useBindingOperations.d.ts +3 -0
- package/dist/types/accessorPropagation/useBindingOperations.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeEntityList.d.ts +11 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeEntityList.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeSingleEntity.d.ts +11 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeSingleEntity.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeSingleField.d.ts +11 -0
- package/dist/types/accessorPropagation/useDesugaredRelativeSingleField.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntity.d.ts +7 -0
- package/dist/types/accessorPropagation/useEntity.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntityKey.d.ts +2 -0
- package/dist/types/accessorPropagation/useEntityKey.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntityList.d.ts +6 -0
- package/dist/types/accessorPropagation/useEntityList.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +4 -0
- package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntityListSubTreeParameters.d.ts +5 -0
- package/dist/types/accessorPropagation/useEntityListSubTreeParameters.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts +4 -0
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEntitySubTreeParameters.d.ts +5 -0
- package/dist/types/accessorPropagation/useEntitySubTreeParameters.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useEnvironment.d.ts +3 -0
- package/dist/types/accessorPropagation/useEnvironment.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useField.d.ts +6 -0
- package/dist/types/accessorPropagation/useField.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useGetEntityByKey.d.ts +3 -0
- package/dist/types/accessorPropagation/useGetEntityByKey.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts +4 -0
- package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts +4 -0
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useGetTreeFilters.d.ts +3 -0
- package/dist/types/accessorPropagation/useGetTreeFilters.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useHasEntity.d.ts +2 -0
- package/dist/types/accessorPropagation/useHasEntity.d.ts.map +1 -0
- package/dist/types/accessorPropagation/usePersist.d.ts +3 -0
- package/dist/types/accessorPropagation/usePersist.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useTreeRootId.d.ts +3 -0
- package/dist/types/accessorPropagation/useTreeRootId.d.ts.map +1 -0
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +10 -0
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -0
- package/dist/types/accessorSorting/SortedEntities.d.ts +9 -0
- package/dist/types/accessorSorting/SortedEntities.d.ts.map +1 -0
- package/dist/types/accessorSorting/addEntityAtIndex.d.ts +4 -0
- package/dist/types/accessorSorting/addEntityAtIndex.d.ts.map +1 -0
- package/dist/types/accessorSorting/errors.d.ts +6 -0
- package/dist/types/accessorSorting/errors.d.ts.map +1 -0
- package/dist/types/accessorSorting/index.d.ts +8 -0
- package/dist/types/accessorSorting/index.d.ts.map +1 -0
- package/dist/types/accessorSorting/moveEntity.d.ts +5 -0
- package/dist/types/accessorSorting/moveEntity.d.ts.map +1 -0
- package/dist/types/accessorSorting/repairEntitiesOrder.d.ts +4 -0
- package/dist/types/accessorSorting/repairEntitiesOrder.d.ts.map +1 -0
- package/dist/types/accessorSorting/sortEntities.d.ts +4 -0
- package/dist/types/accessorSorting/sortEntities.d.ts.map +1 -0
- package/dist/types/accessorSorting/useSortedEntities.d.ts +5 -0
- package/dist/types/accessorSorting/useSortedEntities.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTree.d.ts +11 -0
- package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeState.d.ts +15 -0
- package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +12 -0
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeStateMetadata.d.ts +4 -0
- package/dist/types/accessorTree/AccessorTreeStateMetadata.d.ts.map +1 -0
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +7 -0
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -0
- package/dist/types/accessorTree/DirtinessContext.d.ts +3 -0
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -0
- package/dist/types/accessorTree/MutationRequestResponse.d.ts +44 -0
- package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -0
- package/dist/types/accessorTree/MutationStateContext.d.ts +3 -0
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -0
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +13 -0
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -0
- package/dist/types/accessorTree/PersistResult.d.ts +24 -0
- package/dist/types/accessorTree/PersistResult.d.ts.map +1 -0
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +15 -0
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -0
- package/dist/types/accessorTree/RequestError.d.ts +13 -0
- package/dist/types/accessorTree/RequestError.d.ts.map +1 -0
- package/dist/types/accessorTree/RuntimeId.d.ts +25 -0
- package/dist/types/accessorTree/RuntimeId.d.ts.map +1 -0
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts +4 -0
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -0
- package/dist/types/accessorTree/index.d.ts +19 -0
- package/dist/types/accessorTree/index.d.ts.map +1 -0
- package/dist/types/accessorTree/metadataToRequestError.d.ts +4 -0
- package/dist/types/accessorTree/metadataToRequestError.d.ts.map +1 -0
- package/dist/types/accessorTree/useDataBinding.d.ts +4 -0
- package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -0
- package/dist/types/accessorTree/useDirtinessState.d.ts +2 -0
- package/dist/types/accessorTree/useDirtinessState.d.ts.map +1 -0
- package/dist/types/accessorTree/useMutationState.d.ts +2 -0
- package/dist/types/accessorTree/useMutationState.d.ts.map +1 -0
- package/dist/types/accessors/AsyncBatchUpdatesOptions.d.ts +8 -0
- package/dist/types/accessors/AsyncBatchUpdatesOptions.d.ts.map +1 -0
- package/dist/types/accessors/BatchUpdatesOptions.d.ts +9 -0
- package/dist/types/accessors/BatchUpdatesOptions.d.ts.map +1 -0
- package/dist/types/accessors/BindingConfig.d.ts +8 -0
- package/dist/types/accessors/BindingConfig.d.ts.map +1 -0
- package/dist/types/accessors/BindingOperations.d.ts +12 -0
- package/dist/types/accessors/BindingOperations.d.ts.map +1 -0
- package/dist/types/accessors/EntityAccessor.d.ts +90 -0
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -0
- package/dist/types/accessors/EntityListAccessor.d.ts +84 -0
- package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -0
- package/dist/types/accessors/ErrorAccessor.d.ts +26 -0
- package/dist/types/accessors/ErrorAccessor.d.ts.map +1 -0
- package/dist/types/accessors/Errorable.d.ts +5 -0
- package/dist/types/accessors/Errorable.d.ts.map +1 -0
- package/dist/types/accessors/ExtendTree.d.ts +9 -0
- package/dist/types/accessors/ExtendTree.d.ts.map +1 -0
- package/dist/types/accessors/FieldAccessor.d.ts +55 -0
- package/dist/types/accessors/FieldAccessor.d.ts.map +1 -0
- package/dist/types/accessors/GetEntityByKey.d.ts +3 -0
- package/dist/types/accessors/GetEntityByKey.d.ts.map +1 -0
- package/dist/types/accessors/GetEntityListSubTree.d.ts +5 -0
- package/dist/types/accessors/GetEntityListSubTree.d.ts.map +1 -0
- package/dist/types/accessors/GetEntitySubTree.d.ts +5 -0
- package/dist/types/accessors/GetEntitySubTree.d.ts.map +1 -0
- package/dist/types/accessors/Persist.d.ts +10 -0
- package/dist/types/accessors/Persist.d.ts.map +1 -0
- package/dist/types/accessors/PersistErrorOptions.d.ts +10 -0
- package/dist/types/accessors/PersistErrorOptions.d.ts.map +1 -0
- package/dist/types/accessors/PersistSuccessOptions.d.ts +5 -0
- package/dist/types/accessors/PersistSuccessOptions.d.ts.map +1 -0
- package/dist/types/accessors/TreeRootAccessor.d.ts +11 -0
- package/dist/types/accessors/TreeRootAccessor.d.ts.map +1 -0
- package/dist/types/accessors/index.d.ts +18 -0
- package/dist/types/accessors/index.d.ts.map +1 -0
- package/dist/types/bindingTypes.d.ts +4 -0
- package/dist/types/bindingTypes.d.ts.map +1 -0
- package/dist/types/core/AccessorErrorManager.d.ts +24 -0
- package/dist/types/core/AccessorErrorManager.d.ts.map +1 -0
- package/dist/types/core/Config.d.ts +9 -0
- package/dist/types/core/Config.d.ts.map +1 -0
- package/dist/types/core/DataBinding.d.ts +38 -0
- package/dist/types/core/DataBinding.d.ts.map +1 -0
- package/dist/types/core/DirtinessTracker.d.ts +12 -0
- package/dist/types/core/DirtinessTracker.d.ts.map +1 -0
- package/dist/types/core/ErrorsPreprocessor.d.ts +33 -0
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -0
- package/dist/types/core/EventManager.d.ts +56 -0
- package/dist/types/core/EventManager.d.ts.map +1 -0
- package/dist/types/core/IncrementalMarkerBuilder.d.ts +7 -0
- package/dist/types/core/IncrementalMarkerBuilder.d.ts.map +1 -0
- package/dist/types/core/MarkerComparator.d.ts +8 -0
- package/dist/types/core/MarkerComparator.d.ts.map +1 -0
- package/dist/types/core/MarkerMerger.d.ts +22 -0
- package/dist/types/core/MarkerMerger.d.ts.map +1 -0
- package/dist/types/core/MarkerTreeGenerator.d.ts +14 -0
- package/dist/types/core/MarkerTreeGenerator.d.ts.map +1 -0
- package/dist/types/core/MutationGenerator.d.ts +18 -0
- package/dist/types/core/MutationGenerator.d.ts.map +1 -0
- package/dist/types/core/QueryGenerator.d.ts +14 -0
- package/dist/types/core/QueryGenerator.d.ts.map +1 -0
- package/dist/types/core/RealmKeyGenerator.d.ts +11 -0
- package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -0
- package/dist/types/core/RequestResponseNormalizer.d.ts +11 -0
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -0
- package/dist/types/core/StateInitializer.d.ts +38 -0
- package/dist/types/core/StateInitializer.d.ts.map +1 -0
- package/dist/types/core/TreeAugmenter.d.ts +20 -0
- package/dist/types/core/TreeAugmenter.d.ts.map +1 -0
- package/dist/types/core/TreeFilterGenerator.d.ts +13 -0
- package/dist/types/core/TreeFilterGenerator.d.ts.map +1 -0
- package/dist/types/core/TreeParameterMerger.d.ts +20 -0
- package/dist/types/core/TreeParameterMerger.d.ts.map +1 -0
- package/dist/types/core/TreeStore.d.ts +32 -0
- package/dist/types/core/TreeStore.d.ts.map +1 -0
- package/dist/types/core/UpdateMetadata.d.ts +4 -0
- package/dist/types/core/UpdateMetadata.d.ts.map +1 -0
- package/dist/types/core/VariableInputTransformer.d.ts +7 -0
- package/dist/types/core/VariableInputTransformer.d.ts.map +1 -0
- package/dist/types/core/exceptions/ErrorLocator.d.ts +8 -0
- package/dist/types/core/exceptions/ErrorLocator.d.ts.map +1 -0
- package/dist/types/core/exceptions/LocalizedBindingError.d.ts +9 -0
- package/dist/types/core/exceptions/LocalizedBindingError.d.ts.map +1 -0
- package/dist/types/core/exceptions/MarkerSugarer.d.ts +10 -0
- package/dist/types/core/exceptions/MarkerSugarer.d.ts.map +1 -0
- package/dist/types/core/exceptions/RawMarkerPath.d.ts +3 -0
- package/dist/types/core/exceptions/RawMarkerPath.d.ts.map +1 -0
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts +11 -0
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts.map +1 -0
- package/dist/types/core/exceptions/index.d.ts +6 -0
- package/dist/types/core/exceptions/index.d.ts.map +1 -0
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +5 -0
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +1 -0
- package/dist/types/core/factories/index.d.ts +2 -0
- package/dist/types/core/factories/index.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/operations/EntityOperations.d.ts +26 -0
- package/dist/types/core/operations/EntityOperations.d.ts.map +1 -0
- package/dist/types/core/operations/FieldOperations.d.ts +22 -0
- package/dist/types/core/operations/FieldOperations.d.ts.map +1 -0
- package/dist/types/core/operations/ListOperations.d.ts +32 -0
- package/dist/types/core/operations/ListOperations.d.ts.map +1 -0
- package/dist/types/core/operations/OperationsHelpers.d.ts +14 -0
- package/dist/types/core/operations/OperationsHelpers.d.ts.map +1 -0
- package/dist/types/core/operations/index.d.ts +4 -0
- package/dist/types/core/operations/index.d.ts.map +1 -0
- package/dist/types/core/requestAliases/MutationAlias.d.ts +9 -0
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -0
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +11 -0
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +1 -0
- package/dist/types/core/requestAliases/index.d.ts +5 -0
- package/dist/types/core/requestAliases/index.d.ts.map +1 -0
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +5 -0
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +1 -0
- package/dist/types/core/requestAliases/mutationOperationType.d.ts +6 -0
- package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +1 -0
- package/dist/types/core/schema/RawSchema.d.ts +7 -0
- package/dist/types/core/schema/RawSchema.d.ts.map +1 -0
- package/dist/types/core/schema/RawSchemaEntity.d.ts +12 -0
- package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -0
- package/dist/types/core/schema/RawSchemaEnum.d.ts +6 -0
- package/dist/types/core/schema/RawSchemaEnum.d.ts.map +1 -0
- package/dist/types/core/schema/Schema.d.ts +9 -0
- package/dist/types/core/schema/Schema.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaColumn.d.ts +12 -0
- package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaColumnType.d.ts +3 -0
- package/dist/types/core/schema/SchemaColumnType.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaEntities.d.ts +4 -0
- package/dist/types/core/schema/SchemaEntities.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaEntity.d.ts +10 -0
- package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaEnums.d.ts +4 -0
- package/dist/types/core/schema/SchemaEnums.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaField.d.ts +4 -0
- package/dist/types/core/schema/SchemaField.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaFields.d.ts +4 -0
- package/dist/types/core/schema/SchemaFields.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaLoader.d.ts +7 -0
- package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaPreprocessor.d.ts +9 -0
- package/dist/types/core/schema/SchemaPreprocessor.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaRelation.d.ts +24 -0
- package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaRelationOrderBy.d.ts +5 -0
- package/dist/types/core/schema/SchemaRelationOrderBy.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaStore.d.ts +7 -0
- package/dist/types/core/schema/SchemaStore.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaUniqueConstraint.d.ts +5 -0
- package/dist/types/core/schema/SchemaUniqueConstraint.d.ts.map +1 -0
- package/dist/types/core/schema/SchemaValidator.d.ts +14 -0
- package/dist/types/core/schema/SchemaValidator.d.ts.map +1 -0
- package/dist/types/core/schema/index.d.ts +15 -0
- package/dist/types/core/schema/index.d.ts.map +1 -0
- package/dist/types/core/state/EntityListState.d.ts +27 -0
- package/dist/types/core/state/EntityListState.d.ts.map +1 -0
- package/dist/types/core/state/EntityRealmState.d.ts +44 -0
- package/dist/types/core/state/EntityRealmState.d.ts.map +1 -0
- package/dist/types/core/state/EntityState.d.ts +12 -0
- package/dist/types/core/state/EntityState.d.ts.map +1 -0
- package/dist/types/core/state/FieldState.d.ts +19 -0
- package/dist/types/core/state/FieldState.d.ts.map +1 -0
- package/dist/types/core/state/StateIterator.d.ts +14 -0
- package/dist/types/core/state/StateIterator.d.ts.map +1 -0
- package/dist/types/core/state/StateNode.d.ts +8 -0
- package/dist/types/core/state/StateNode.d.ts.map +1 -0
- package/dist/types/core/state/getEntityMarker.d.ts +3 -0
- package/dist/types/core/state/getEntityMarker.d.ts.map +1 -0
- package/dist/types/core/state/index.d.ts +8 -0
- package/dist/types/core/state/index.d.ts.map +1 -0
- package/dist/types/core/utils/getCombinedSignal.d.ts +2 -0
- package/dist/types/core/utils/getCombinedSignal.d.ts.map +1 -0
- package/dist/types/core/utils/index.d.ts +2 -0
- package/dist/types/core/utils/index.d.ts.map +1 -0
- package/dist/types/coreComponents/Component.d.ts +8 -0
- package/dist/types/coreComponents/Component.d.ts.map +1 -0
- package/dist/types/coreComponents/DataBindingProvider.d.ts +17 -0
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -0
- package/dist/types/coreComponents/Entity.d.ts +9 -0
- package/dist/types/coreComponents/Entity.d.ts.map +1 -0
- package/dist/types/coreComponents/EntityList.d.ts +12 -0
- package/dist/types/coreComponents/EntityList.d.ts.map +1 -0
- package/dist/types/coreComponents/EntityListSubTree.d.ts +16 -0
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -0
- package/dist/types/coreComponents/EntitySubTree.d.ts +14 -0
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -0
- package/dist/types/coreComponents/Field.d.ts +11 -0
- package/dist/types/coreComponents/Field.d.ts.map +1 -0
- package/dist/types/coreComponents/HasMany.d.ts +13 -0
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -0
- package/dist/types/coreComponents/HasOne.d.ts +9 -0
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -0
- package/dist/types/coreComponents/MarkerProvider.d.ts +21 -0
- package/dist/types/coreComponents/MarkerProvider.d.ts.map +1 -0
- package/dist/types/coreComponents/ParentEntity.d.ts +7 -0
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -0
- package/dist/types/coreComponents/index.d.ts +12 -0
- package/dist/types/coreComponents/index.d.ts.map +1 -0
- package/dist/types/dao/Environment.d.ts +55 -0
- package/dist/types/dao/Environment.d.ts.map +1 -0
- package/dist/types/dao/VariableFieldValue.d.ts +5 -0
- package/dist/types/dao/VariableFieldValue.d.ts.map +1 -0
- package/dist/types/dao/index.d.ts +3 -0
- package/dist/types/dao/index.d.ts.map +1 -0
- package/dist/types/entityEvents/index.d.ts +8 -0
- package/dist/types/entityEvents/index.d.ts.map +1 -0
- package/dist/types/entityEvents/useDerivedField.d.ts +9 -0
- package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -0
- package/dist/types/entityEvents/useEntityBeforePersist.d.ts +3 -0
- package/dist/types/entityEvents/useEntityBeforePersist.d.ts.map +1 -0
- package/dist/types/entityEvents/useEntityBeforeUpdate.d.ts +3 -0
- package/dist/types/entityEvents/useEntityBeforeUpdate.d.ts.map +1 -0
- package/dist/types/entityEvents/useEntityEvent.d.ts +9 -0
- package/dist/types/entityEvents/useEntityEvent.d.ts.map +1 -0
- package/dist/types/entityEvents/useEntityPersistError.d.ts +3 -0
- package/dist/types/entityEvents/useEntityPersistError.d.ts.map +1 -0
- package/dist/types/entityEvents/useEntityPersistSuccess.d.ts +3 -0
- package/dist/types/entityEvents/useEntityPersistSuccess.d.ts.map +1 -0
- package/dist/types/entityEvents/useOnConnectionUpdate.d.ts +4 -0
- package/dist/types/entityEvents/useOnConnectionUpdate.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts +7 -0
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +10 -0
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +10 -0
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +1 -0
- package/dist/types/fieldHelpers/helpers/index.d.ts +3 -0
- package/dist/types/fieldHelpers/helpers/index.d.ts.map +1 -0
- package/dist/types/fieldHelpers/index.d.ts +2 -0
- package/dist/types/fieldHelpers/index.d.ts.map +1 -0
- package/dist/types/helperComponents/DeferredSubTrees.d.ts +7 -0
- package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -0
- package/dist/types/helperComponents/EntityView.d.ts +9 -0
- package/dist/types/helperComponents/EntityView.d.ts.map +1 -0
- package/dist/types/helperComponents/FieldView.d.ts +46 -0
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -0
- package/dist/types/helperComponents/StaticRender.d.ts +6 -0
- package/dist/types/helperComponents/StaticRender.d.ts.map +1 -0
- package/dist/types/helperComponents/SugaredField.d.ts +9 -0
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -0
- package/dist/types/helperComponents/index.d.ts +6 -0
- package/dist/types/helperComponents/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/markers/EntityFieldMarkers.d.ts +7 -0
- package/dist/types/markers/EntityFieldMarkers.d.ts.map +1 -0
- package/dist/types/markers/EntityFieldMarkersContainer.d.ts +13 -0
- package/dist/types/markers/EntityFieldMarkersContainer.d.ts.map +1 -0
- package/dist/types/markers/EntityFieldPlaceholders.d.ts +3 -0
- package/dist/types/markers/EntityFieldPlaceholders.d.ts.map +1 -0
- package/dist/types/markers/EntityFieldsWithHoistablesMarker.d.ts +10 -0
- package/dist/types/markers/EntityFieldsWithHoistablesMarker.d.ts.map +1 -0
- package/dist/types/markers/EntityListSubTreeMarker.d.ts +12 -0
- package/dist/types/markers/EntityListSubTreeMarker.d.ts.map +1 -0
- package/dist/types/markers/EntitySubTreeMarker.d.ts +12 -0
- package/dist/types/markers/EntitySubTreeMarker.d.ts.map +1 -0
- package/dist/types/markers/FieldMarker.d.ts +14 -0
- package/dist/types/markers/FieldMarker.d.ts.map +1 -0
- package/dist/types/markers/HasManyRelationMarker.d.ts +12 -0
- package/dist/types/markers/HasManyRelationMarker.d.ts.map +1 -0
- package/dist/types/markers/HasOneRelationMarker.d.ts +12 -0
- package/dist/types/markers/HasOneRelationMarker.d.ts.map +1 -0
- package/dist/types/markers/MarkerTreeRoot.d.ts +8 -0
- package/dist/types/markers/MarkerTreeRoot.d.ts.map +1 -0
- package/dist/types/markers/MeaningfulMarker.d.ts +7 -0
- package/dist/types/markers/MeaningfulMarker.d.ts.map +1 -0
- package/dist/types/markers/ParentEntityMarker.d.ts +8 -0
- package/dist/types/markers/ParentEntityMarker.d.ts.map +1 -0
- package/dist/types/markers/PlaceholderGenerator.d.ts +9 -0
- package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -0
- package/dist/types/markers/SubTreeMarkers.d.ts +5 -0
- package/dist/types/markers/SubTreeMarkers.d.ts.map +1 -0
- package/dist/types/markers/index.d.ts +15 -0
- package/dist/types/markers/index.d.ts.map +1 -0
- package/dist/types/queryLanguage/CacheStore.d.ts +9 -0
- package/dist/types/queryLanguage/CacheStore.d.ts.map +1 -0
- package/dist/types/queryLanguage/MarkerFactory.d.ts +21 -0
- package/dist/types/queryLanguage/MarkerFactory.d.ts.map +1 -0
- package/dist/types/queryLanguage/Parser.d.ts +82 -0
- package/dist/types/queryLanguage/Parser.d.ts.map +1 -0
- package/dist/types/queryLanguage/ParserResults.d.ts +63 -0
- package/dist/types/queryLanguage/ParserResults.d.ts.map +1 -0
- package/dist/types/queryLanguage/QueryLanguage.d.ts +44 -0
- package/dist/types/queryLanguage/QueryLanguage.d.ts.map +1 -0
- package/dist/types/queryLanguage/QueryLanguageError.d.ts +3 -0
- package/dist/types/queryLanguage/QueryLanguageError.d.ts.map +1 -0
- package/dist/types/queryLanguage/index.d.ts +6 -0
- package/dist/types/queryLanguage/index.d.ts.map +1 -0
- package/dist/types/queryLanguage/tokenList.d.ts +35 -0
- package/dist/types/queryLanguage/tokenList.d.ts.map +1 -0
- package/dist/types/structures/BijectiveIndexedMap.d.ts +24 -0
- package/dist/types/structures/BijectiveIndexedMap.d.ts.map +1 -0
- package/dist/types/structures/LRUCache.d.ts +9 -0
- package/dist/types/structures/LRUCache.d.ts.map +1 -0
- package/dist/types/structures/WeakIdCache.d.ts +9 -0
- package/dist/types/structures/WeakIdCache.d.ts.map +1 -0
- package/dist/types/structures/index.d.ts +4 -0
- package/dist/types/structures/index.d.ts.map +1 -0
- package/dist/types/treeParameterHelpers/index.d.ts +2 -0
- package/dist/types/treeParameterHelpers/index.d.ts.map +1 -0
- package/dist/types/treeParameterHelpers/wrapFilterInHasOnes.d.ts +3 -0
- package/dist/types/treeParameterHelpers/wrapFilterInHasOnes.d.ts.map +1 -0
- package/dist/types/treeParameters/AnyField.d.ts +8 -0
- package/dist/types/treeParameters/AnyField.d.ts.map +1 -0
- package/dist/types/treeParameters/EntityCreationParameters.d.ts +13 -0
- package/dist/types/treeParameters/EntityCreationParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/EntityListEventListeners.d.ts +15 -0
- package/dist/types/treeParameters/EntityListEventListeners.d.ts.map +1 -0
- package/dist/types/treeParameters/EntityListParameters.d.ts +17 -0
- package/dist/types/treeParameters/EntityListParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/EntityListPreferences.d.ts +8 -0
- package/dist/types/treeParameters/EntityListPreferences.d.ts.map +1 -0
- package/dist/types/treeParameters/EventListenersStore.d.ts +32 -0
- package/dist/types/treeParameters/EventListenersStore.d.ts.map +1 -0
- package/dist/types/treeParameters/FieldEventListeners.d.ts +13 -0
- package/dist/types/treeParameters/FieldEventListeners.d.ts.map +1 -0
- package/dist/types/treeParameters/HasManyRelation.d.ts +10 -0
- package/dist/types/treeParameters/HasManyRelation.d.ts.map +1 -0
- package/dist/types/treeParameters/HasOneRelation.d.ts +13 -0
- package/dist/types/treeParameters/HasOneRelation.d.ts.map +1 -0
- package/dist/types/treeParameters/LeafField.d.ts +14 -0
- package/dist/types/treeParameters/LeafField.d.ts.map +1 -0
- package/dist/types/treeParameters/ParentEntityParameters.d.ts +8 -0
- package/dist/types/treeParameters/ParentEntityParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/QualifiedEntityList.d.ts +19 -0
- package/dist/types/treeParameters/QualifiedEntityList.d.ts.map +1 -0
- package/dist/types/treeParameters/QualifiedEntityParameters.d.ts +17 -0
- package/dist/types/treeParameters/QualifiedEntityParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/QualifiedFieldList.d.ts +17 -0
- package/dist/types/treeParameters/QualifiedFieldList.d.ts.map +1 -0
- package/dist/types/treeParameters/QualifiedSingleEntity.d.ts +20 -0
- package/dist/types/treeParameters/QualifiedSingleEntity.d.ts.map +1 -0
- package/dist/types/treeParameters/QualifiedSingleEntityParameters.d.ts +8 -0
- package/dist/types/treeParameters/QualifiedSingleEntityParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/Relation.d.ts +15 -0
- package/dist/types/treeParameters/Relation.d.ts.map +1 -0
- package/dist/types/treeParameters/RelativeEntityList.d.ts +19 -0
- package/dist/types/treeParameters/RelativeEntityList.d.ts.map +1 -0
- package/dist/types/treeParameters/RelativeSingleEntity.d.ts +13 -0
- package/dist/types/treeParameters/RelativeSingleEntity.d.ts.map +1 -0
- package/dist/types/treeParameters/RelativeSingleField.d.ts +15 -0
- package/dist/types/treeParameters/RelativeSingleField.d.ts.map +1 -0
- package/dist/types/treeParameters/SetOnCreate.d.ts +4 -0
- package/dist/types/treeParameters/SetOnCreate.d.ts.map +1 -0
- package/dist/types/treeParameters/SingleEntityEventListeners.d.ts +16 -0
- package/dist/types/treeParameters/SingleEntityEventListeners.d.ts.map +1 -0
- package/dist/types/treeParameters/SingleEntityParameters.d.ts +8 -0
- package/dist/types/treeParameters/SingleEntityParameters.d.ts.map +1 -0
- package/dist/types/treeParameters/UnconstrainedQualifiedEntityList.d.ts +19 -0
- package/dist/types/treeParameters/UnconstrainedQualifiedEntityList.d.ts.map +1 -0
- package/dist/types/treeParameters/UnconstrainedQualifiedSingleEntity.d.ts +18 -0
- package/dist/types/treeParameters/UnconstrainedQualifiedSingleEntity.d.ts.map +1 -0
- package/dist/types/treeParameters/index.d.ts +27 -0
- package/dist/types/treeParameters/index.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/Alias.d.ts +2 -0
- package/dist/types/treeParameters/primitives/Alias.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/EntityId.d.ts +2 -0
- package/dist/types/treeParameters/primitives/EntityId.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/EntityName.d.ts +2 -0
- package/dist/types/treeParameters/primitives/EntityName.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/EntityRealmKey.d.ts +2 -0
- package/dist/types/treeParameters/primitives/EntityRealmKey.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/ExpectedEntityCount.d.ts +2 -0
- package/dist/types/treeParameters/primitives/ExpectedEntityCount.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/ExpectedQualifiedEntityMutation.d.ts +2 -0
- package/dist/types/treeParameters/primitives/ExpectedQualifiedEntityMutation.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/ExpectedRelationMutation.d.ts +2 -0
- package/dist/types/treeParameters/primitives/ExpectedRelationMutation.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/FieldName.d.ts +2 -0
- package/dist/types/treeParameters/primitives/FieldName.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/FieldValue.d.ts +5 -0
- package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/Filter.d.ts +4 -0
- package/dist/types/treeParameters/primitives/Filter.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/Limit.d.ts +2 -0
- package/dist/types/treeParameters/primitives/Limit.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/Offset.d.ts +2 -0
- package/dist/types/treeParameters/primitives/Offset.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/OrderBy.d.ts +4 -0
- package/dist/types/treeParameters/primitives/OrderBy.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/PlaceholderName.d.ts +2 -0
- package/dist/types/treeParameters/primitives/PlaceholderName.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/RemovalType.d.ts +2 -0
- package/dist/types/treeParameters/primitives/RemovalType.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/Scalar.d.ts +2 -0
- package/dist/types/treeParameters/primitives/Scalar.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/TreeRootId.d.ts +2 -0
- package/dist/types/treeParameters/primitives/TreeRootId.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/UniqueWhere.d.ts +4 -0
- package/dist/types/treeParameters/primitives/UniqueWhere.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts +19 -0
- package/dist/types/treeParameters/primitives/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/utils/Hashing.d.ts +10 -0
- package/dist/types/utils/Hashing.d.ts.map +1 -0
- package/dist/types/utils/assert.d.ts +2 -0
- package/dist/types/utils/assert.d.ts.map +1 -0
- package/dist/types/utils/assertNever.d.ts +2 -0
- package/dist/types/utils/assertNever.d.ts.map +1 -0
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts +2 -0
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/isEmptyObject.d.ts +2 -0
- package/dist/types/utils/isEmptyObject.d.ts.map +1 -0
- package/dist/types/utils/ucfirst.d.ts +2 -0
- package/dist/types/utils/ucfirst.d.ts.map +1 -0
- package/package.json +9 -12
- package/src/BindingError.ts +5 -0
- package/src/accessorPropagation/AccessorProvider.tsx +17 -0
- package/src/accessorPropagation/BindingOperationsContext.ts +32 -0
- package/src/accessorPropagation/BindingOperationsProvider.tsx +16 -0
- package/src/accessorPropagation/EntityKeyContext.ts +4 -0
- package/src/accessorPropagation/EntityKeyProvider.tsx +11 -0
- package/src/accessorPropagation/EnvironmentContext.ts +5 -0
- package/src/accessorPropagation/TreeRootIdContext.ts +5 -0
- package/src/accessorPropagation/TreeRootIdProvider.tsx +12 -0
- package/src/accessorPropagation/index.ts +29 -0
- package/src/accessorPropagation/useAccessorUpdateSubscription.ts +107 -0
- package/src/accessorPropagation/useBindingOperations.ts +5 -0
- package/src/accessorPropagation/useDesugaredRelativeEntityList.ts +70 -0
- package/src/accessorPropagation/useDesugaredRelativeSingleEntity.ts +58 -0
- package/src/accessorPropagation/useDesugaredRelativeSingleField.ts +58 -0
- package/src/accessorPropagation/useEntity.ts +56 -0
- package/src/accessorPropagation/useEntityKey.ts +15 -0
- package/src/accessorPropagation/useEntityList.ts +49 -0
- package/src/accessorPropagation/useEntityListSubTree.ts +20 -0
- package/src/accessorPropagation/useEntityListSubTreeParameters.ts +88 -0
- package/src/accessorPropagation/useEntitySubTree.ts +19 -0
- package/src/accessorPropagation/useEntitySubTreeParameters.ts +66 -0
- package/src/accessorPropagation/useEnvironment.ts +7 -0
- package/src/accessorPropagation/useField.ts +51 -0
- package/src/accessorPropagation/useGetEntityByKey.ts +4 -0
- package/src/accessorPropagation/useGetEntityListSubTree.ts +28 -0
- package/src/accessorPropagation/useGetEntitySubTree.ts +28 -0
- package/src/accessorPropagation/useGetTreeFilters.ts +4 -0
- package/src/accessorPropagation/useHasEntity.ts +6 -0
- package/src/accessorPropagation/usePersist.ts +4 -0
- package/src/accessorPropagation/useTreeRootId.ts +5 -0
- package/src/accessorSorting/SetOrderFieldOnCreate.tsx +92 -0
- package/src/accessorSorting/SortedEntities.ts +9 -0
- package/src/accessorSorting/addEntityAtIndex.ts +27 -0
- package/src/accessorSorting/errors.ts +18 -0
- package/src/accessorSorting/index.ts +9 -0
- package/src/accessorSorting/moveEntity.ts +66 -0
- package/src/accessorSorting/repairEntitiesOrder.ts +15 -0
- package/src/accessorSorting/sortEntities.ts +20 -0
- package/src/accessorSorting/useSortedEntities.ts +105 -0
- package/src/accessorTree/AccessorTree.tsx +34 -0
- package/src/accessorTree/AccessorTreeState.ts +18 -0
- package/src/accessorTree/AccessorTreeStateAction.ts +15 -0
- package/src/accessorTree/AccessorTreeStateMetadata.ts +3 -0
- package/src/accessorTree/AccessorTreeStateOptions.ts +7 -0
- package/src/accessorTree/DirtinessContext.ts +4 -0
- package/src/accessorTree/MutationRequestResponse.ts +55 -0
- package/src/accessorTree/MutationStateContext.ts +4 -0
- package/src/accessorTree/NormalizedPersistedData.ts +23 -0
- package/src/accessorTree/PersistResult.ts +30 -0
- package/src/accessorTree/QueryRequestResponse.ts +19 -0
- package/src/accessorTree/RequestError.ts +16 -0
- package/src/accessorTree/RuntimeId.ts +49 -0
- package/src/accessorTree/accessorTreeStateReducer.ts +27 -0
- package/src/accessorTree/index.ts +18 -0
- package/src/accessorTree/metadataToRequestError.ts +14 -0
- package/src/accessorTree/useDataBinding.ts +98 -0
- package/src/accessorTree/useDirtinessState.ts +4 -0
- package/src/accessorTree/useMutationState.ts +4 -0
- package/src/accessors/AsyncBatchUpdatesOptions.ts +8 -0
- package/src/accessors/BatchUpdatesOptions.ts +9 -0
- package/src/accessors/BindingConfig.ts +7 -0
- package/src/accessors/BindingOperations.ts +15 -0
- package/src/accessors/EntityAccessor.ts +259 -0
- package/src/accessors/EntityListAccessor.ts +173 -0
- package/src/accessors/ErrorAccessor.ts +39 -0
- package/src/accessors/Errorable.ts +5 -0
- package/src/accessors/ExtendTree.ts +10 -0
- package/src/accessors/FieldAccessor.ts +102 -0
- package/src/accessors/GetEntityByKey.ts +3 -0
- package/src/accessors/GetEntityListSubTree.ts +14 -0
- package/src/accessors/GetEntitySubTree.ts +14 -0
- package/src/accessors/Persist.ts +11 -0
- package/src/accessors/PersistErrorOptions.ts +12 -0
- package/src/accessors/PersistSuccessOptions.ts +5 -0
- package/src/accessors/TreeRootAccessor.ts +14 -0
- package/src/accessors/index.ts +17 -0
- package/src/ambient.d.ts +1 -0
- package/src/bindingTypes.ts +3 -0
- package/src/core/AccessorErrorManager.ts +231 -0
- package/src/core/Config.ts +29 -0
- package/src/core/DataBinding.ts +456 -0
- package/src/core/DirtinessTracker.ts +33 -0
- package/src/core/ErrorsPreprocessor.ts +240 -0
- package/src/core/EventManager.ts +580 -0
- package/src/core/IncrementalMarkerBuilder.ts +60 -0
- package/src/core/MarkerComparator.ts +102 -0
- package/src/core/MarkerMerger.ts +297 -0
- package/src/core/MarkerTreeGenerator.ts +121 -0
- package/src/core/MutationGenerator.ts +716 -0
- package/src/core/QueryGenerator.ts +173 -0
- package/src/core/RealmKeyGenerator.ts +54 -0
- package/src/core/RequestResponseNormalizer.ts +213 -0
- package/src/core/StateInitializer.ts +571 -0
- package/src/core/TreeAugmenter.ts +262 -0
- package/src/core/TreeFilterGenerator.ts +116 -0
- package/src/core/TreeParameterMerger.ts +374 -0
- package/src/core/TreeStore.ts +260 -0
- package/src/core/UpdateMetadata.ts +3 -0
- package/src/core/VariableInputTransformer.ts +23 -0
- package/src/core/exceptions/ErrorLocator.ts +58 -0
- package/src/core/exceptions/LocalizedBindingError.ts +20 -0
- package/src/core/exceptions/MarkerSugarer.ts +61 -0
- package/src/core/exceptions/RawMarkerPath.ts +3 -0
- package/src/core/exceptions/TreeParameterSugarer.ts +41 -0
- package/src/core/exceptions/index.ts +5 -0
- package/src/core/factories/createBatchUpdatesOptions.ts +38 -0
- package/src/core/factories/index.ts +1 -0
- package/src/core/index.ts +5 -0
- package/src/core/operations/EntityOperations.ts +310 -0
- package/src/core/operations/FieldOperations.ts +127 -0
- package/src/core/operations/ListOperations.ts +207 -0
- package/src/core/operations/OperationsHelpers.ts +150 -0
- package/src/core/operations/index.ts +3 -0
- package/src/core/requestAliases/MutationAlias.ts +66 -0
- package/src/core/requestAliases/TopLevelMutationOperation.ts +11 -0
- package/src/core/requestAliases/index.ts +4 -0
- package/src/core/requestAliases/mutationOperationSubTreeType.ts +4 -0
- package/src/core/requestAliases/mutationOperationType.ts +5 -0
- package/src/core/schema/RawSchema.ts +7 -0
- package/src/core/schema/RawSchemaEntity.ts +13 -0
- package/src/core/schema/RawSchemaEnum.ts +6 -0
- package/src/core/schema/Schema.ts +11 -0
- package/src/core/schema/SchemaColumn.ts +15 -0
- package/src/core/schema/SchemaColumnType.ts +3 -0
- package/src/core/schema/SchemaEntities.ts +4 -0
- package/src/core/schema/SchemaEntity.ts +10 -0
- package/src/core/schema/SchemaEnums.ts +3 -0
- package/src/core/schema/SchemaField.ts +4 -0
- package/src/core/schema/SchemaFields.ts +4 -0
- package/src/core/schema/SchemaLoader.ts +62 -0
- package/src/core/schema/SchemaPreprocessor.ts +51 -0
- package/src/core/schema/SchemaRelation.ts +29 -0
- package/src/core/schema/SchemaRelationOrderBy.ts +4 -0
- package/src/core/schema/SchemaStore.ts +8 -0
- package/src/core/schema/SchemaUniqueConstraint.ts +5 -0
- package/src/core/schema/SchemaValidator.ts +238 -0
- package/src/core/schema/index.ts +14 -0
- package/src/core/state/EntityListState.ts +37 -0
- package/src/core/state/EntityRealmState.ts +63 -0
- package/src/core/state/EntityState.ts +12 -0
- package/src/core/state/FieldState.ts +20 -0
- package/src/core/state/StateIterator.ts +122 -0
- package/src/core/state/StateNode.ts +8 -0
- package/src/core/state/getEntityMarker.ts +4 -0
- package/src/core/state/index.ts +7 -0
- package/src/core/utils/getCombinedSignal.ts +36 -0
- package/src/core/utils/index.ts +1 -0
- package/src/coreComponents/Component.tsx +61 -0
- package/src/coreComponents/DataBindingProvider.tsx +45 -0
- package/src/coreComponents/Entity.tsx +23 -0
- package/src/coreComponents/EntityList.tsx +52 -0
- package/src/coreComponents/EntityListSubTree.tsx +85 -0
- package/src/coreComponents/EntitySubTree.tsx +98 -0
- package/src/coreComponents/Field.tsx +39 -0
- package/src/coreComponents/HasMany.tsx +46 -0
- package/src/coreComponents/HasOne.tsx +39 -0
- package/src/coreComponents/MarkerProvider.ts +59 -0
- package/src/coreComponents/ParentEntity.tsx +17 -0
- package/src/coreComponents/index.ts +11 -0
- package/src/dao/Environment.ts +201 -0
- package/src/dao/VariableFieldValue.ts +3 -0
- package/src/dao/index.ts +2 -0
- package/src/entityEvents/index.ts +7 -0
- package/src/entityEvents/useDerivedField.ts +64 -0
- package/src/entityEvents/useEntityBeforePersist.ts +6 -0
- package/src/entityEvents/useEntityBeforeUpdate.ts +6 -0
- package/src/entityEvents/useEntityEvent.ts +57 -0
- package/src/entityEvents/useEntityPersistError.ts +6 -0
- package/src/entityEvents/useEntityPersistSuccess.ts +6 -0
- package/src/entityEvents/useOnConnectionUpdate.ts +10 -0
- package/src/fieldHelpers/helpers/FieldHelper.ts +10 -0
- package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +21 -0
- package/src/fieldHelpers/helpers/UuidFieldHelper.ts +18 -0
- package/src/fieldHelpers/helpers/index.ts +2 -0
- package/src/fieldHelpers/index.ts +1 -0
- package/src/helperComponents/DeferredSubTrees.tsx +116 -0
- package/src/helperComponents/EntityView.tsx +16 -0
- package/src/helperComponents/FieldView.tsx +129 -0
- package/src/helperComponents/StaticRender.tsx +12 -0
- package/src/helperComponents/SugaredField.tsx +15 -0
- package/src/helperComponents/index.ts +5 -0
- package/src/index.ts +19 -0
- package/src/markers/EntityFieldMarkers.ts +7 -0
- package/src/markers/EntityFieldMarkersContainer.ts +45 -0
- package/src/markers/EntityFieldPlaceholders.ts +3 -0
- package/src/markers/EntityFieldsWithHoistablesMarker.ts +11 -0
- package/src/markers/EntityListSubTreeMarker.ts +20 -0
- package/src/markers/EntitySubTreeMarker.ts +20 -0
- package/src/markers/FieldMarker.ts +19 -0
- package/src/markers/HasManyRelationMarker.ts +27 -0
- package/src/markers/HasOneRelationMarker.ts +21 -0
- package/src/markers/MarkerTreeRoot.ts +9 -0
- package/src/markers/MeaningfulMarker.ts +12 -0
- package/src/markers/ParentEntityMarker.ts +9 -0
- package/src/markers/PlaceholderGenerator.ts +36 -0
- package/src/markers/SubTreeMarkers.ts +5 -0
- package/src/markers/index.ts +14 -0
- package/src/queryLanguage/CacheStore.ts +56 -0
- package/src/queryLanguage/MarkerFactory.ts +300 -0
- package/src/queryLanguage/Parser.ts +859 -0
- package/src/queryLanguage/ParserResults.ts +81 -0
- package/src/queryLanguage/QueryLanguage.ts +730 -0
- package/src/queryLanguage/QueryLanguageError.ts +1 -0
- package/src/queryLanguage/index.ts +5 -0
- package/src/queryLanguage/tokenList.ts +175 -0
- package/src/structures/BijectiveIndexedMap.ts +139 -0
- package/src/structures/LRUCache.ts +29 -0
- package/src/structures/WeakIdCache.ts +25 -0
- package/src/structures/index.ts +3 -0
- package/src/treeParameterHelpers/index.ts +1 -0
- package/src/treeParameterHelpers/wrapFilterInHasOnes.ts +21 -0
- package/src/treeParameters/AnyField.ts +9 -0
- package/src/treeParameters/EntityCreationParameters.ts +34 -0
- package/src/treeParameters/EntityListEventListeners.ts +20 -0
- package/src/treeParameters/EntityListParameters.ts +19 -0
- package/src/treeParameters/EntityListPreferences.ts +11 -0
- package/src/treeParameters/EventListenersStore.ts +81 -0
- package/src/treeParameters/FieldEventListeners.ts +22 -0
- package/src/treeParameters/HasManyRelation.ts +18 -0
- package/src/treeParameters/HasOneRelation.ts +21 -0
- package/src/treeParameters/LeafField.ts +18 -0
- package/src/treeParameters/ParentEntityParameters.ts +10 -0
- package/src/treeParameters/QualifiedEntityList.ts +43 -0
- package/src/treeParameters/QualifiedEntityParameters.ts +20 -0
- package/src/treeParameters/QualifiedFieldList.ts +36 -0
- package/src/treeParameters/QualifiedSingleEntity.ts +46 -0
- package/src/treeParameters/QualifiedSingleEntityParameters.ts +9 -0
- package/src/treeParameters/Relation.ts +17 -0
- package/src/treeParameters/RelativeEntityList.ts +25 -0
- package/src/treeParameters/RelativeSingleEntity.ts +16 -0
- package/src/treeParameters/RelativeSingleField.ts +20 -0
- package/src/treeParameters/SetOnCreate.ts +6 -0
- package/src/treeParameters/SingleEntityEventListeners.ts +24 -0
- package/src/treeParameters/SingleEntityParameters.ts +9 -0
- package/src/treeParameters/UnconstrainedQualifiedEntityList.ts +37 -0
- package/src/treeParameters/UnconstrainedQualifiedSingleEntity.ts +37 -0
- package/src/treeParameters/index.ts +27 -0
- package/src/treeParameters/primitives/Alias.ts +1 -0
- package/src/treeParameters/primitives/EntityId.ts +2 -0
- package/src/treeParameters/primitives/EntityName.ts +4 -0
- package/src/treeParameters/primitives/EntityRealmKey.ts +2 -0
- package/src/treeParameters/primitives/ExpectedEntityCount.ts +1 -0
- package/src/treeParameters/primitives/ExpectedQualifiedEntityMutation.ts +1 -0
- package/src/treeParameters/primitives/ExpectedRelationMutation.ts +1 -0
- package/src/treeParameters/primitives/FieldName.ts +7 -0
- package/src/treeParameters/primitives/FieldValue.ts +6 -0
- package/src/treeParameters/primitives/Filter.ts +7 -0
- package/src/treeParameters/primitives/Limit.ts +1 -0
- package/src/treeParameters/primitives/Offset.ts +1 -0
- package/src/treeParameters/primitives/OrderBy.ts +6 -0
- package/src/treeParameters/primitives/PlaceholderName.ts +4 -0
- package/src/treeParameters/primitives/RemovalType.ts +1 -0
- package/src/treeParameters/primitives/Scalar.ts +1 -0
- package/src/treeParameters/primitives/TreeRootId.ts +1 -0
- package/src/treeParameters/primitives/UniqueWhere.ts +7 -0
- package/src/treeParameters/primitives/index.ts +18 -0
- package/src/tsconfig.json +12 -0
- package/src/utils/Hashing.ts +81 -0
- package/src/utils/assert.ts +7 -0
- package/src/utils/assertNever.ts +10 -0
- package/src/utils/generateEnumerabilityPreventingEntropy.ts +3 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/isEmptyObject.ts +9 -0
- package/src/utils/ucfirst.ts +1 -0
- package/dist/binding.d.ts +0 -2247
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAugmenter.js","sources":["../../../src/core/TreeAugmenter.ts"],"sourcesContent":["import {\n\tClientGeneratedUuid,\n\tEntityListPersistedData,\n\tReceivedDataTree,\n\tRuntimeId,\n\tServerGeneratedUuid,\n\tUnpersistedEntityDummyId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { EntityId, PlaceholderName, TreeRootId } from '../treeParameters'\nimport { assert, assertNever } from '../utils'\nimport { EventManager } from './EventManager'\nimport { OperationsHelpers } from './operations/OperationsHelpers'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, RootStateNode } from './state'\nimport type { StateInitializer } from './StateInitializer'\nimport type { TreeStore } from './TreeStore'\n\nexport class TreeAugmenter {\n\tpublic constructor(\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic extendPersistedData(newPersistedData: ReceivedDataTree) {\n\t\t// TODO this doesn't yet handle updates for entities whose persisted data just gets magically changed without notice.\n\t\tthis.treeStore.mergeInQueryResponse(newPersistedData)\n\t}\n\n\tpublic extendTreeStates(newTreeId: TreeRootId | undefined, newMarkerTree: MarkerTreeRoot): void {\n\t\tconst subTreeStates: Map<PlaceholderName, RootStateNode> = new Map()\n\n\t\tthis.treeStore.markerTrees.set(newTreeId, newMarkerTree)\n\t\tthis.treeStore.subTreeStatesByRoot.set(newTreeId, subTreeStates)\n\n\t\tfor (const [placeholderName, newSubTreeMarker] of newMarkerTree.subTrees) {\n\t\t\tconst newState = this.stateInitializer.initializeSubTree(newSubTreeMarker)\n\t\t\tsubTreeStates.set(placeholderName, newState)\n\t\t}\n\t}\n\n\tpublic updatePersistedData(response: ReceivedDataTree) {\n\t\tthis.treeStore.mergeInMutationResponse(response)\n\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\t\t// for (const rootPlaceholder in response) {\n\t\t\t\t// \tconst rootState = rootStates.get(rootPlaceholder)\n\t\t\t\t//\n\t\t\t\t// \tif (rootState === undefined) {\n\t\t\t\t// \t\tcontinue\n\t\t\t\t// \t}\n\t\t\t\t// TODO the above would be better, only refreshing roots which participated in the mutation. However, due to\n\t\t\t\t// \thow mutations are currently generated, we cannot assume that only roots present in the response need\n\t\t\t\t// \trefreshed. So we just refresh all.\n\t\t\t\tfor (const [rootPlaceholder, rootState] of rootStates) {\n\t\t\t\t\tconst rootData = this.treeStore.subTreePersistedData.get(rootPlaceholder)\n\n\t\t\t\t\tif (rootState.type === 'entityList') {\n\t\t\t\t\t\tif (!(rootData instanceof Set)) {\n\t\t\t\t\t\t\tcontinue // This should never happen.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.updateEntityListPersistedData(rootState, rootData)\n\t\t\t\t\t} else if (rootState.type === 'entityRealm') {\n\t\t\t\t\t\tif (rootData !== undefined && !(rootData instanceof ServerGeneratedUuid)) {\n\t\t\t\t\t\t\tcontinue // This should never happen.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.updateRealmIdIfNecessary(rootState, rootData)\n\t\t\t\t\t\tthis.updateEntityRealmPersistedData(rootState)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(rootState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic resetCreatingSubTrees() {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [rootPlaceholder, rootState] of rootStates) {\n\t\t\t\tif (rootState.type === 'entityList') {\n\t\t\t\t\tassert(rootState.blueprint.parent === undefined)\n\t\t\t\t\tif (!rootState.blueprint.marker.parameters.isCreating) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.treeStore.subTreePersistedData.delete(rootPlaceholder)\n\t\t\t\t\tconst changesCount = rootState.unpersistedChangesCount\n\n\t\t\t\t\t// Just emptying the list. But the list itself can stay.\n\t\t\t\t\tfor (const childState of rootState.children.values()) {\n\t\t\t\t\t\tthis.treeStore.disposeOfRealm(childState)\n\t\t\t\t\t}\n\t\t\t\t\trootState.accessor = undefined\n\t\t\t\t\trootState.children.clear()\n\t\t\t\t\trootState.childrenWithPendingUpdates?.clear()\n\t\t\t\t\trootState.errors = undefined\n\t\t\t\t\trootState.plannedRemovals?.clear()\n\n\t\t\t\t\tthis.eventManager.registerJustUpdated(\n\t\t\t\t\t\trootState,\n\t\t\t\t\t\tchangesCount ? -1 * changesCount : EventManager.NO_CHANGES_DIFFERENCE,\n\t\t\t\t\t)\n\t\t\t\t} else if (rootState.type === 'entityRealm') {\n\t\t\t\t\tassert(rootState.blueprint.parent === undefined)\n\t\t\t\t\tif (!rootState.blueprint.marker.parameters.isCreating) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst presentListeners = rootState.eventListeners\n\t\t\t\t\tthis.treeStore.disposeOfRealm(rootState)\n\n\t\t\t\t\t// It's crucial to delete the persisted data before we re-initialize so that we get a fresh, new entity.\n\t\t\t\t\tthis.treeStore.subTreePersistedData.delete(rootPlaceholder)\n\t\t\t\t\tconst newRootState = this.stateInitializer.initializeSubTree(rootState.blueprint.marker)\n\n\t\t\t\t\t// We preserve the previous listeners but purge some of them.\n\t\t\t\t\tnewRootState.eventListeners = presentListeners\n\t\t\t\t\tOperationsHelpers.purgeStaleListenersAfterIdChange(newRootState as EntityRealmState)\n\n\t\t\t\t\trootStates.set(rootPlaceholder, newRootState)\n\n\t\t\t\t\tthis.eventManager.registerJustUpdated(newRootState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(rootState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate updateRealmIdIfNecessary(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: ServerGeneratedUuid | undefined | null,\n\t) {\n\t\tconst currentId = realm.entity.id\n\t\tlet idToChangeTo: RuntimeId | undefined = undefined\n\n\t\tif (currentId instanceof ServerGeneratedUuid) {\n\t\t\tif (newId === undefined || newId === null) {\n\t\t\t\tidToChangeTo = new UnpersistedEntityDummyId()\n\t\t\t} else if (currentId.value !== newId.value) {\n\t\t\t\tidToChangeTo = newId\n\t\t\t}\n\t\t} else if (currentId instanceof ClientGeneratedUuid) {\n\t\t\tidToChangeTo = newId ?? new UnpersistedEntityDummyId()\n\t\t} else if (currentId instanceof UnpersistedEntityDummyId) {\n\t\t\tif (newId) {\n\t\t\t\tidToChangeTo = newId\n\t\t\t}\n\t\t} else {\n\t\t\treturn assertNever(currentId)\n\t\t}\n\t\tif (idToChangeTo) {\n\t\t\tOperationsHelpers.changeRealmId(this.treeStore, this.eventManager, this.stateInitializer, realm, idToChangeTo)\n\t\t}\n\t}\n\n\tprivate updateEntityRealmPersistedData(realm: EntityRealmState) {\n\t\tconst realmId = realm.entity.id\n\t\tconst persistedData = realmId.existsOnServer ? this.treeStore.persistedEntityData.get(realmId.value) : undefined\n\n\t\tfor (const [placeholderName, child] of realm.children) {\n\t\t\tconst childData = persistedData?.get(placeholderName)\n\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (childData instanceof ServerGeneratedUuid || childData instanceof Set) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.persistedValue !== childData) {\n\t\t\t\t\t\tconst shouldChangeBothValues = child.persistedValue === child.value\n\n\t\t\t\t\t\tchild.persistedValue = childData\n\t\t\t\t\t\tif (shouldChangeBothValues) {\n\t\t\t\t\t\t\tchild.value = childData ?? null\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.eventManager.registerJustUpdated(child, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealm':\n\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\tif (!(childData instanceof ServerGeneratedUuid) && childData !== undefined && childData !== null) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tthis.updateRealmIdIfNecessary(child, childData)\n\t\t\t\t\tif (child.type === 'entityRealm') {\n\t\t\t\t\t\tthis.updateEntityRealmPersistedData(child)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tif (childData !== undefined && !(childData instanceof Set)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tthis.updateEntityListPersistedData(child, childData ?? new Set()) // TODO!!\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn assertNever(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate updateEntityListPersistedData(state: EntityListState, newPersistedIds: EntityListPersistedData) {\n\t\tconst persistedWithoutState: EntityId[] = []\n\n\t\t// TODO This isn't particularly efficient. We should probably use something like diff-sequence here.\n\n\t\tfor (const persistedId of newPersistedIds) {\n\t\t\tif (!state.children.has(persistedId)) {\n\t\t\t\tpersistedWithoutState.push(persistedId)\n\t\t\t}\n\t\t}\n\t\tfor (const [stateId, child] of state.children) {\n\t\t\tconst childRuntimeId = child.entity.id\n\t\t\tif (!newPersistedIds.has(stateId)) {\n\t\t\t\tif (\n\t\t\t\t\t// It's a uuid but it's not among the persisted so either it got deleted/disconnected or the client-side\n\t\t\t\t\t// id generation didn't quite pan out.\n\t\t\t\t\tchildRuntimeId instanceof ServerGeneratedUuid ||\n\t\t\t\t\tchildRuntimeId instanceof ClientGeneratedUuid ||\n\t\t\t\t\t// No persisted entity id to allocate to this so that's a goodbye.\n\t\t\t\t\tpersistedWithoutState.length === 0\n\t\t\t\t) {\n\t\t\t\t\tstate.getAccessor().disconnectEntity(child.getAccessor())\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tconst drawnId = persistedWithoutState.shift()!\n\t\t\t\t\tOperationsHelpers.changeRealmId(\n\t\t\t\t\t\tthis.treeStore,\n\t\t\t\t\t\tthis.eventManager,\n\t\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tnew ServerGeneratedUuid(drawnId),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (childRuntimeId instanceof ClientGeneratedUuid) {\n\t\t\t\tOperationsHelpers.changeRealmId(\n\t\t\t\t\tthis.treeStore,\n\t\t\t\t\tthis.eventManager,\n\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\tchild,\n\t\t\t\t\tnew ServerGeneratedUuid(childRuntimeId.value),\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (child.type === 'entityRealm') {\n\t\t\t\tthis.updateEntityRealmPersistedData(child)\n\t\t\t}\n\t\t}\n\t\tfor (const unclaimedPersistedId of persistedWithoutState) {\n\t\t\tthis.stateInitializer.initializeEntityRealm(new ServerGeneratedUuid(unclaimedPersistedId), state.entityName, {\n\t\t\t\ttype: 'listEntity',\n\t\t\t\tparent: state,\n\t\t\t})\n\t\t}\n\t\t// All that remains now is the order.\n\t\tstate.children.changeKeyOrder(newPersistedIds)\n\t}\n}\n"],"names":[],"mappings":";;;;;;oBAkB2B;AAAA,EACnB,YACW,cACA,kBACA,WAChB;;;;;EAEK,oBAAoB,kBAAoC;SAEzD,UAAU,qBAAqB;AAAA;AAAA,EAG9B,iBAAiB,WAAmC,eAAqC;UACzF,gBAAqD,IAAI;SAE1D,UAAU,YAAY,IAAI,WAAW;SACrC,UAAU,oBAAoB,IAAI,WAAW;eAEvC,CAAC,iBAAiB,qBAAqB,cAAc,UAAU;YACnE,WAAW,KAAK,iBAAiB,kBAAkB;oBAC3C,IAAI,iBAAiB;AAAA;AAAA;AAAA,EAI9B,oBAAoB,UAA4B;SACjD,UAAU,wBAAwB;SAElC,aAAa,gBAAgB,MAAM;iBAC5B,cAAc,KAAK,UAAU,oBAAoB,UAAU;mBAU1D,CAAC,iBAAiB,cAAc,YAAY;gBAChD,WAAW,KAAK,UAAU,qBAAqB,IAAI;cAErD,UAAU,SAAS,cAAc;gBAChC,sBAAsB,MAAM;;;iBAG3B,8BAA8B,WAAW;AAAA,qBACpC,UAAU,SAAS,eAAe;gBACxC,aAAa,UAAa,sBAAsB,sBAAsB;;;iBAGrE,yBAAyB,WAAW;iBACpC,+BAA+B;AAAA,iBAC9B;mBACC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOL,wBAAwB;eACnB,cAAc,KAAK,UAAU,oBAAoB,UAAU;iBAC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C5G,MAAM;AAAA,QACN,QAAQ;AAAA;AAAA;UAIJ,SAAS,eAAe;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"TreeAugmenter.js","sources":["../../../src/core/TreeAugmenter.ts"],"sourcesContent":["import {\n\tClientGeneratedUuid,\n\tEntityListPersistedData,\n\tReceivedDataTree,\n\tRuntimeId,\n\tServerGeneratedUuid,\n\tUnpersistedEntityDummyId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { EntityId, PlaceholderName, TreeRootId } from '../treeParameters'\nimport { assert, assertNever } from '../utils'\nimport { EventManager } from './EventManager'\nimport { OperationsHelpers } from './operations/OperationsHelpers'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, RootStateNode } from './state'\nimport type { StateInitializer } from './StateInitializer'\nimport type { TreeStore } from './TreeStore'\n\nexport class TreeAugmenter {\n\tpublic constructor(\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic extendPersistedData(newPersistedData: ReceivedDataTree) {\n\t\t// TODO this doesn't yet handle updates for entities whose persisted data just gets magically changed without notice.\n\t\tthis.treeStore.mergeInQueryResponse(newPersistedData)\n\t}\n\n\tpublic extendTreeStates(newTreeId: TreeRootId | undefined, newMarkerTree: MarkerTreeRoot): void {\n\t\tconst subTreeStates: Map<PlaceholderName, RootStateNode> = new Map()\n\n\t\tthis.treeStore.markerTrees.set(newTreeId, newMarkerTree)\n\t\tthis.treeStore.subTreeStatesByRoot.set(newTreeId, subTreeStates)\n\n\t\tfor (const [placeholderName, newSubTreeMarker] of newMarkerTree.subTrees) {\n\t\t\tconst newState = this.stateInitializer.initializeSubTree(newSubTreeMarker)\n\t\t\tsubTreeStates.set(placeholderName, newState)\n\t\t}\n\t}\n\n\tpublic updatePersistedData(response: ReceivedDataTree) {\n\t\tthis.treeStore.mergeInMutationResponse(response)\n\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\t\t// for (const rootPlaceholder in response) {\n\t\t\t\t// \tconst rootState = rootStates.get(rootPlaceholder)\n\t\t\t\t//\n\t\t\t\t// \tif (rootState === undefined) {\n\t\t\t\t// \t\tcontinue\n\t\t\t\t// \t}\n\t\t\t\t// TODO the above would be better, only refreshing roots which participated in the mutation. However, due to\n\t\t\t\t// \thow mutations are currently generated, we cannot assume that only roots present in the response need\n\t\t\t\t// \trefreshed. So we just refresh all.\n\t\t\t\tfor (const [rootPlaceholder, rootState] of rootStates) {\n\t\t\t\t\tconst rootData = this.treeStore.subTreePersistedData.get(rootPlaceholder)\n\n\t\t\t\t\tif (rootState.type === 'entityList') {\n\t\t\t\t\t\tif (!(rootData instanceof Set)) {\n\t\t\t\t\t\t\tcontinue // This should never happen.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.updateEntityListPersistedData(rootState, rootData)\n\t\t\t\t\t} else if (rootState.type === 'entityRealm') {\n\t\t\t\t\t\tif (rootData !== undefined && !(rootData instanceof ServerGeneratedUuid)) {\n\t\t\t\t\t\t\tcontinue // This should never happen.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.updateRealmIdIfNecessary(rootState, rootData)\n\t\t\t\t\t\tthis.updateEntityRealmPersistedData(rootState)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(rootState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic resetCreatingSubTrees() {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [rootPlaceholder, rootState] of rootStates) {\n\t\t\t\tif (rootState.type === 'entityList') {\n\t\t\t\t\tassert(rootState.blueprint.parent === undefined)\n\t\t\t\t\tif (!rootState.blueprint.marker.parameters.isCreating) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.treeStore.subTreePersistedData.delete(rootPlaceholder)\n\t\t\t\t\tconst changesCount = rootState.unpersistedChangesCount\n\n\t\t\t\t\t// Just emptying the list. But the list itself can stay.\n\t\t\t\t\tfor (const childState of rootState.children.values()) {\n\t\t\t\t\t\tthis.treeStore.disposeOfRealm(childState)\n\t\t\t\t\t}\n\t\t\t\t\trootState.accessor = undefined\n\t\t\t\t\trootState.children.clear()\n\t\t\t\t\trootState.childrenWithPendingUpdates?.clear()\n\t\t\t\t\trootState.errors = undefined\n\t\t\t\t\trootState.plannedRemovals?.clear()\n\n\t\t\t\t\tthis.eventManager.registerJustUpdated(\n\t\t\t\t\t\trootState,\n\t\t\t\t\t\tchangesCount ? -1 * changesCount : EventManager.NO_CHANGES_DIFFERENCE,\n\t\t\t\t\t)\n\t\t\t\t} else if (rootState.type === 'entityRealm') {\n\t\t\t\t\tassert(rootState.blueprint.parent === undefined)\n\t\t\t\t\tif (!rootState.blueprint.marker.parameters.isCreating) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst presentListeners = rootState.eventListeners\n\t\t\t\t\tthis.treeStore.disposeOfRealm(rootState)\n\n\t\t\t\t\t// It's crucial to delete the persisted data before we re-initialize so that we get a fresh, new entity.\n\t\t\t\t\tthis.treeStore.subTreePersistedData.delete(rootPlaceholder)\n\t\t\t\t\tconst newRootState = this.stateInitializer.initializeSubTree(rootState.blueprint.marker)\n\n\t\t\t\t\t// We preserve the previous listeners but purge some of them.\n\t\t\t\t\tnewRootState.eventListeners = presentListeners\n\t\t\t\t\tOperationsHelpers.purgeStaleListenersAfterIdChange(newRootState as EntityRealmState)\n\n\t\t\t\t\trootStates.set(rootPlaceholder, newRootState)\n\n\t\t\t\t\tthis.eventManager.registerJustUpdated(newRootState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(rootState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate updateRealmIdIfNecessary(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: ServerGeneratedUuid | undefined | null,\n\t) {\n\t\tconst currentId = realm.entity.id\n\t\tlet idToChangeTo: RuntimeId | undefined = undefined\n\n\t\tif (currentId instanceof ServerGeneratedUuid) {\n\t\t\tif (newId === undefined || newId === null) {\n\t\t\t\tidToChangeTo = new UnpersistedEntityDummyId()\n\t\t\t} else if (currentId.value !== newId.value) {\n\t\t\t\tidToChangeTo = newId\n\t\t\t}\n\t\t} else if (currentId instanceof ClientGeneratedUuid) {\n\t\t\tidToChangeTo = newId ?? new UnpersistedEntityDummyId()\n\t\t} else if (currentId instanceof UnpersistedEntityDummyId) {\n\t\t\tif (newId) {\n\t\t\t\tidToChangeTo = newId\n\t\t\t}\n\t\t} else {\n\t\t\treturn assertNever(currentId)\n\t\t}\n\t\tif (idToChangeTo) {\n\t\t\tOperationsHelpers.changeRealmId(this.treeStore, this.eventManager, this.stateInitializer, realm, idToChangeTo)\n\t\t}\n\t}\n\n\tprivate updateEntityRealmPersistedData(realm: EntityRealmState) {\n\t\tconst realmId = realm.entity.id\n\t\tconst persistedData = realmId.existsOnServer ? this.treeStore.persistedEntityData.get(realmId.value) : undefined\n\n\t\tfor (const [placeholderName, child] of realm.children) {\n\t\t\tconst childData = persistedData?.get(placeholderName)\n\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (childData instanceof ServerGeneratedUuid || childData instanceof Set) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.persistedValue !== childData) {\n\t\t\t\t\t\tconst shouldChangeBothValues = child.persistedValue === child.value\n\n\t\t\t\t\t\tchild.persistedValue = childData\n\t\t\t\t\t\tif (shouldChangeBothValues) {\n\t\t\t\t\t\t\tchild.value = childData ?? null\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.eventManager.registerJustUpdated(child, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealm':\n\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\tif (!(childData instanceof ServerGeneratedUuid) && childData !== undefined && childData !== null) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tthis.updateRealmIdIfNecessary(child, childData)\n\t\t\t\t\tif (child.type === 'entityRealm') {\n\t\t\t\t\t\tthis.updateEntityRealmPersistedData(child)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tif (childData !== undefined && !(childData instanceof Set)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tthis.updateEntityListPersistedData(child, childData ?? new Set()) // TODO!!\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn assertNever(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate updateEntityListPersistedData(state: EntityListState, newPersistedIds: EntityListPersistedData) {\n\t\tconst persistedWithoutState: EntityId[] = []\n\n\t\t// TODO This isn't particularly efficient. We should probably use something like diff-sequence here.\n\n\t\tfor (const persistedId of newPersistedIds) {\n\t\t\tif (!state.children.has(persistedId)) {\n\t\t\t\tpersistedWithoutState.push(persistedId)\n\t\t\t}\n\t\t}\n\t\tfor (const [stateId, child] of state.children) {\n\t\t\tconst childRuntimeId = child.entity.id\n\t\t\tif (!newPersistedIds.has(stateId)) {\n\t\t\t\tif (\n\t\t\t\t\t// It's a uuid but it's not among the persisted so either it got deleted/disconnected or the client-side\n\t\t\t\t\t// id generation didn't quite pan out.\n\t\t\t\t\tchildRuntimeId instanceof ServerGeneratedUuid ||\n\t\t\t\t\tchildRuntimeId instanceof ClientGeneratedUuid ||\n\t\t\t\t\t// No persisted entity id to allocate to this so that's a goodbye.\n\t\t\t\t\tpersistedWithoutState.length === 0\n\t\t\t\t) {\n\t\t\t\t\tstate.getAccessor().disconnectEntity(child.getAccessor())\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tconst drawnId = persistedWithoutState.shift()!\n\t\t\t\t\tOperationsHelpers.changeRealmId(\n\t\t\t\t\t\tthis.treeStore,\n\t\t\t\t\t\tthis.eventManager,\n\t\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tnew ServerGeneratedUuid(drawnId),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (childRuntimeId instanceof ClientGeneratedUuid) {\n\t\t\t\tOperationsHelpers.changeRealmId(\n\t\t\t\t\tthis.treeStore,\n\t\t\t\t\tthis.eventManager,\n\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\tchild,\n\t\t\t\t\tnew ServerGeneratedUuid(childRuntimeId.value),\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (child.type === 'entityRealm') {\n\t\t\t\tthis.updateEntityRealmPersistedData(child)\n\t\t\t}\n\t\t}\n\t\tfor (const unclaimedPersistedId of persistedWithoutState) {\n\t\t\tthis.stateInitializer.initializeEntityRealm(new ServerGeneratedUuid(unclaimedPersistedId), state.entityName, {\n\t\t\t\ttype: 'listEntity',\n\t\t\t\tparent: state,\n\t\t\t})\n\t\t}\n\t\t// All that remains now is the order.\n\t\tstate.children.changeKeyOrder(newPersistedIds)\n\t}\n}\n"],"names":[],"mappings":";;;;;;oBAkB2B;AAAA,EACnB,YACW,cACA,kBACA,WAChB;;;;;EAEK,oBAAoB,kBAAoC;SAEzD,UAAU,qBAAqB;AAAA;AAAA,EAG9B,iBAAiB,WAAmC,eAAqC;UACzF,oCAAyD;SAE1D,UAAU,YAAY,IAAI,WAAW;SACrC,UAAU,oBAAoB,IAAI,WAAW;eAEvC,CAAC,iBAAiB,qBAAqB,cAAc,UAAU;YACnE,WAAW,KAAK,iBAAiB,kBAAkB;oBAC3C,IAAI,iBAAiB;AAAA;AAAA;AAAA,EA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UAChC,CAAC,gBAAgB,IAAI,UAAU;YAIjC,0BAA0B,uBAC1B,0BAA0B,uBAE1B,sBAAsB,WAAW,GAChC;gBACK,cAAc,iBAAiB,MAAM;;eAErC;gBACA,UAAU,sBAAsB;4BACpB,cACjB,KAAK,WACL,KAAK,cACL,KAAK,kBACL,OACA,IAAI,oBAAoB;AAAA;AAAA,iBAGhB,0BAA0B,qBAAqB;0BACvC,cACjB,KAAK,WACL,KAAK,cACL,KAAK,kBACL,OACA,IAAI,oBAAoB,eAAe;AAAA;UAGrC,MAAM,SAAS,eAAe;aAC5B,+BAA+B;AAAA;AAAA;eAG3B,wBAAwB,uBAAuB;WACpD,iBAAiB,sBAAsB,IAAI,oBAAoB,uBAAuB,MAAM,YAAY;AAAA,QAC5G,MAAM;AAAA,QACN,QAAQ;AAAA;AAAA;UAIJ,SAAS,eAAe;AAAA;AAAA;;"}
|
|
@@ -52,7 +52,7 @@ class TreeFilterGenerator {
|
|
|
52
52
|
relations: this.normalizeRawRelationFilters(relations)
|
|
53
53
|
}));
|
|
54
54
|
}
|
|
55
|
-
populateRawRelationFilters(markers, relations = new Map()) {
|
|
55
|
+
populateRawRelationFilters(markers, relations = /* @__PURE__ */ new Map()) {
|
|
56
56
|
for (const [, marker] of markers.markers) {
|
|
57
57
|
if (!(marker instanceof HasOneRelationMarker) && !(marker instanceof HasManyRelationMarker)) {
|
|
58
58
|
continue;
|
|
@@ -66,7 +66,7 @@ class TreeFilterGenerator {
|
|
|
66
66
|
}
|
|
67
67
|
let existingRelation = relations.get(marker.parameters.field);
|
|
68
68
|
if (existingRelation === void 0) {
|
|
69
|
-
relations.set(marker.parameters.field, existingRelation = new Map());
|
|
69
|
+
relations.set(marker.parameters.field, existingRelation = /* @__PURE__ */ new Map());
|
|
70
70
|
}
|
|
71
71
|
this.populateRawRelationFilters(marker.fields, existingRelation);
|
|
72
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeFilterGenerator.js","sources":["../../../src/core/TreeFilterGenerator.ts"],"sourcesContent":["import type { RelationFilter, TreeFilter } from '@contember/client'\nimport { EntityListPersistedData, ServerGeneratedUuid } from '../accessorTree'\nimport {\n\tEntityFieldMarkersContainer,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport type { EntityName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { StateIterator } from './state'\nimport type { TreeStore } from './TreeStore'\n\ntype RawRelationFilters = Map<string, RawRelationFilters>\n\nexport class TreeFilterGenerator {\n\tpublic constructor(private readonly treeStore: TreeStore) {}\n\n\tpublic generateTreeFilter(): TreeFilter[] {\n\t\tconst filters: TreeFilter[][] = []\n\n\t\tfor (const [placeholderName, state] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\tconst blueprint = state.blueprint\n\n\t\t\tif (blueprint.parent || blueprint.marker.parameters.expectedMutation === 'none') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst marker = blueprint.marker\n\t\t\tfilters.push(this.generateSubTreeFilter(marker, this.treeStore.subTreePersistedData.get(placeholderName)))\n\t\t}\n\t\treturn filters.flat()\n\t}\n\n\tprivate generateSubTreeFilter(\n\t\tsubTree: EntitySubTreeMarker | EntityListSubTreeMarker,\n\t\tpersistedData: ServerGeneratedUuid | EntityListPersistedData | undefined,\n\t): TreeFilter[] {\n\t\tconst filters: TreeFilter[] = []\n\n\t\tif (persistedData === undefined) {\n\t\t\treturn filters // Do nothing\n\t\t}\n\n\t\tif (persistedData instanceof ServerGeneratedUuid) {\n\t\t\tconst filter = this.generateTopLevelEntityFilter(\n\t\t\t\tpersistedData.value,\n\t\t\t\tsubTree.parameters.entityName,\n\t\t\t\tsubTree.fields,\n\t\t\t)\n\t\t\tfilter && filters.push(filter)\n\t\t} else {\n\t\t\tfor (const id of persistedData) {\n\t\t\t\tconst filter = this.generateTopLevelEntityFilter(id, subTree.parameters.entityName, subTree.fields)\n\t\t\t\tfilter && filters.push(filter)\n\t\t\t}\n\t\t}\n\n\t\treturn filters\n\t}\n\n\tprivate generateTopLevelEntityFilter(\n\t\tid: string,\n\t\tentityName: EntityName,\n\t\tfields: EntityFieldMarkersContainer,\n\t): TreeFilter | undefined {\n\t\treturn {\n\t\t\tentity: entityName,\n\t\t\tid: id,\n\t\t\trelations: this.generateEntityRelations(fields),\n\t\t}\n\t}\n\n\tprivate generateEntityRelations(markers: EntityFieldMarkersContainer): RelationFilter[] {\n\t\tconst rawFilter = this.populateRawRelationFilters(markers)\n\t\treturn this.normalizeRawRelationFilters(rawFilter)\n\t}\n\n\tprivate normalizeRawRelationFilters(raw: RawRelationFilters): RelationFilter[] {\n\t\treturn Array.from(raw, ([fieldName, relations]) => ({\n\t\t\tname: fieldName,\n\t\t\trelations: this.normalizeRawRelationFilters(relations),\n\t\t}))\n\t}\n\n\tprivate populateRawRelationFilters(\n\t\tmarkers: EntityFieldMarkersContainer,\n\t\trelations: RawRelationFilters = new Map(),\n\t): RawRelationFilters {\n\t\tfor (const [, marker] of markers.markers) {\n\t\t\tif (!(marker instanceof HasOneRelationMarker) && !(marker instanceof HasManyRelationMarker)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmarker.parameters.expectedMutation === 'none' ||\n\t\t\t\tmarker.parameters.expectedMutation === 'connectOrDisconnect'\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t} else if (\n\t\t\t\tmarker.parameters.expectedMutation === 'anyMutation' ||\n\t\t\t\tmarker.parameters.expectedMutation === 'createOrDelete'\n\t\t\t) {\n\t\t\t} else {\n\t\t\t\treturn assertNever(marker.parameters.expectedMutation)\n\t\t\t}\n\t\t\tlet existingRelation = relations.get(marker.parameters.field)\n\n\t\t\tif (existingRelation === undefined) {\n\t\t\t\trelations.set(marker.parameters.field, (existingRelation = new Map()))\n\t\t\t}\n\t\t\tthis.populateRawRelationFilters(marker.fields, existingRelation)\n\t\t}\n\n\t\treturn relations\n\t}\n}\n"],"names":[],"mappings":";;;;;0BAgBiC;AAAA,EACzB,YAA6B,WAAsB;;;EAEnD,qBAAmC;UACnC,UAA0B;eAErB,CAAC,iBAAiB,UAAU,cAAc,cAAc,KAAK,YAAY;YAC7E,YAAY,MAAM;UAEpB,UAAU,UAAU,UAAU,OAAO,WAAW,qBAAqB,QAAQ;;;YAG3E,SAAS,UAAU;cACjB,KAAK,KAAK,sBAAsB,QAAQ,KAAK,UAAU,qBAAqB,IAAI;AAAA;WAElF,QAAQ;AAAA;AAAA,EAGR,sBACP,SACA,eACe;UACT,UAAwB;QAE1B,kBAAkB,QAAW;aACzB;AAAA;QAGJ,yBAAyB,qBAAqB;YAC3C,SAAS,KAAK,6BACnB,cAAc,OACd,QAAQ,WAAW,YACnB,QAAQ;gBAEC,QAAQ,KAAK;AAAA,WACjB;iBACK,MAAM,eAAe;cACzB,SAAS,KAAK,6BAA6B,IAAI,QAAQ,WAAW,YAAY,QAAQ;kBAClF,QAAQ,KAAK;AAAA;AAAA;WAIlB;AAAA;AAAA,EAGA,6BACP,IACA,YACA,QACyB;WAClB;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,MACA,WAAW,KAAK,wBAAwB;AAAA;AAAA;AAAA,EAIlC,wBAAwB,SAAwD;UACjF,YAAY,KAAK,2BAA2B;WAC3C,KAAK,4BAA4B;AAAA;AAAA,EAGjC,4BAA4B,KAA2C;WACvE,MAAM,KAAK,KAAK,CAAC,CAAC,WAAW;MACnC,MAAM;AAAA,MACN,WAAW,KAAK,4BAA4B;AAAA;AAAA;AAAA,EAItC,2BACP,SACA,
|
|
1
|
+
{"version":3,"file":"TreeFilterGenerator.js","sources":["../../../src/core/TreeFilterGenerator.ts"],"sourcesContent":["import type { RelationFilter, TreeFilter } from '@contember/client'\nimport { EntityListPersistedData, ServerGeneratedUuid } from '../accessorTree'\nimport {\n\tEntityFieldMarkersContainer,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport type { EntityName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { StateIterator } from './state'\nimport type { TreeStore } from './TreeStore'\n\ntype RawRelationFilters = Map<string, RawRelationFilters>\n\nexport class TreeFilterGenerator {\n\tpublic constructor(private readonly treeStore: TreeStore) {}\n\n\tpublic generateTreeFilter(): TreeFilter[] {\n\t\tconst filters: TreeFilter[][] = []\n\n\t\tfor (const [placeholderName, state] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\tconst blueprint = state.blueprint\n\n\t\t\tif (blueprint.parent || blueprint.marker.parameters.expectedMutation === 'none') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst marker = blueprint.marker\n\t\t\tfilters.push(this.generateSubTreeFilter(marker, this.treeStore.subTreePersistedData.get(placeholderName)))\n\t\t}\n\t\treturn filters.flat()\n\t}\n\n\tprivate generateSubTreeFilter(\n\t\tsubTree: EntitySubTreeMarker | EntityListSubTreeMarker,\n\t\tpersistedData: ServerGeneratedUuid | EntityListPersistedData | undefined,\n\t): TreeFilter[] {\n\t\tconst filters: TreeFilter[] = []\n\n\t\tif (persistedData === undefined) {\n\t\t\treturn filters // Do nothing\n\t\t}\n\n\t\tif (persistedData instanceof ServerGeneratedUuid) {\n\t\t\tconst filter = this.generateTopLevelEntityFilter(\n\t\t\t\tpersistedData.value,\n\t\t\t\tsubTree.parameters.entityName,\n\t\t\t\tsubTree.fields,\n\t\t\t)\n\t\t\tfilter && filters.push(filter)\n\t\t} else {\n\t\t\tfor (const id of persistedData) {\n\t\t\t\tconst filter = this.generateTopLevelEntityFilter(id, subTree.parameters.entityName, subTree.fields)\n\t\t\t\tfilter && filters.push(filter)\n\t\t\t}\n\t\t}\n\n\t\treturn filters\n\t}\n\n\tprivate generateTopLevelEntityFilter(\n\t\tid: string,\n\t\tentityName: EntityName,\n\t\tfields: EntityFieldMarkersContainer,\n\t): TreeFilter | undefined {\n\t\treturn {\n\t\t\tentity: entityName,\n\t\t\tid: id,\n\t\t\trelations: this.generateEntityRelations(fields),\n\t\t}\n\t}\n\n\tprivate generateEntityRelations(markers: EntityFieldMarkersContainer): RelationFilter[] {\n\t\tconst rawFilter = this.populateRawRelationFilters(markers)\n\t\treturn this.normalizeRawRelationFilters(rawFilter)\n\t}\n\n\tprivate normalizeRawRelationFilters(raw: RawRelationFilters): RelationFilter[] {\n\t\treturn Array.from(raw, ([fieldName, relations]) => ({\n\t\t\tname: fieldName,\n\t\t\trelations: this.normalizeRawRelationFilters(relations),\n\t\t}))\n\t}\n\n\tprivate populateRawRelationFilters(\n\t\tmarkers: EntityFieldMarkersContainer,\n\t\trelations: RawRelationFilters = new Map(),\n\t): RawRelationFilters {\n\t\tfor (const [, marker] of markers.markers) {\n\t\t\tif (!(marker instanceof HasOneRelationMarker) && !(marker instanceof HasManyRelationMarker)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmarker.parameters.expectedMutation === 'none' ||\n\t\t\t\tmarker.parameters.expectedMutation === 'connectOrDisconnect'\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t} else if (\n\t\t\t\tmarker.parameters.expectedMutation === 'anyMutation' ||\n\t\t\t\tmarker.parameters.expectedMutation === 'createOrDelete'\n\t\t\t) {\n\t\t\t} else {\n\t\t\t\treturn assertNever(marker.parameters.expectedMutation)\n\t\t\t}\n\t\t\tlet existingRelation = relations.get(marker.parameters.field)\n\n\t\t\tif (existingRelation === undefined) {\n\t\t\t\trelations.set(marker.parameters.field, (existingRelation = new Map()))\n\t\t\t}\n\t\t\tthis.populateRawRelationFilters(marker.fields, existingRelation)\n\t\t}\n\n\t\treturn relations\n\t}\n}\n"],"names":[],"mappings":";;;;;0BAgBiC;AAAA,EACzB,YAA6B,WAAsB;;;EAEnD,qBAAmC;UACnC,UAA0B;eAErB,CAAC,iBAAiB,UAAU,cAAc,cAAc,KAAK,YAAY;YAC7E,YAAY,MAAM;UAEpB,UAAU,UAAU,UAAU,OAAO,WAAW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PersistedData } from "../accessorTree/NormalizedPersistedData
|
|
|
11
11
|
import { assertNever } from "../utils/assertNever.js";
|
|
12
12
|
import { PlaceholderGenerator } from "../markers/PlaceholderGenerator.js";
|
|
13
13
|
import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
|
|
14
|
-
const emptyEntityIdSet = new Set();
|
|
14
|
+
const emptyEntityIdSet = /* @__PURE__ */ new Set();
|
|
15
15
|
class TreeStore {
|
|
16
16
|
constructor() {
|
|
17
|
-
__publicField(this, "entityStore", new Map());
|
|
18
|
-
__publicField(this, "entityRealmStore", new Map());
|
|
19
|
-
__publicField(this, "markerTrees", new Map());
|
|
20
|
-
__publicField(this, "subTreeStatesByRoot", new Map());
|
|
17
|
+
__publicField(this, "entityStore", /* @__PURE__ */ new Map());
|
|
18
|
+
__publicField(this, "entityRealmStore", /* @__PURE__ */ new Map());
|
|
19
|
+
__publicField(this, "markerTrees", /* @__PURE__ */ new Map());
|
|
20
|
+
__publicField(this, "subTreeStatesByRoot", /* @__PURE__ */ new Map());
|
|
21
21
|
__publicField(this, "_schema");
|
|
22
|
-
__publicField(this, "persistedData", new NormalizedPersistedData(new Map(), new Map()));
|
|
22
|
+
__publicField(this, "persistedData", new NormalizedPersistedData(/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()));
|
|
23
23
|
}
|
|
24
24
|
mergeInQueryResponse(response) {
|
|
25
25
|
RequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeStore.js","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import { NormalizedPersistedData, PersistedEntityDataStore, ReceivedDataTree, SubTreeDataStore } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<EntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tprivate _schema: Schema | undefined\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor() {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response)\n\t}\n\n\tpublic setSchema(newSchema: Schema): void {\n\t\t// TODO\n\t\tif (this._schema === undefined) {\n\t\t\tthis._schema = newSchema\n\t\t}\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\tif (this._schema === undefined) {\n\t\t\tthrow new BindingError(`Fatal error: failed to load api schema.`)\n\t\t}\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityField(parentEntityName, relationFromParent)\n\n\t\tif (relationSchema?.__typename !== '_Relation') {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<string> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.value)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.value)\n\t\tthis.persistedEntityData.delete(entity.id.value)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,mBAA0C,IAAI;gBAE7B;AAAA,EAYf,cAAc;AAXL,uCAA0C,IAAI;AAC9C,4CAAiF,IAAI;AAIrF,uCA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,OAAO,GAAG;SAC7B,oBAAoB,OAAO,OAAO,GAAG;AAAA;AAAA,EAGpC,uBAAuB,eAAwC;;iBAC1C,oBAAoB,cAAc,SAAS,UAAU;YAC3E,iBAAiB,WAAW,YAAY;;;mBAIjC,QAAQ,KAAK,YAAY,UAAU;qBAClC,yBAAyB,KAAK,SAAS,UAAU;kBACrD,WAAW,iBAAiB,kBAAkB,kBAAkB;gBAClE,UAAU;;;;;eAKT;AAAA;WAED;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"TreeStore.js","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import { NormalizedPersistedData, PersistedEntityDataStore, ReceivedDataTree, SubTreeDataStore } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<EntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tprivate _schema: Schema | undefined\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor() {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response)\n\t}\n\n\tpublic setSchema(newSchema: Schema): void {\n\t\t// TODO\n\t\tif (this._schema === undefined) {\n\t\t\tthis._schema = newSchema\n\t\t}\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\tif (this._schema === undefined) {\n\t\t\tthrow new BindingError(`Fatal error: failed to load api schema.`)\n\t\t}\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityField(parentEntityName, relationFromParent)\n\n\t\tif (relationSchema?.__typename !== '_Relation') {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<string> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.value)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.value)\n\t\tthis.persistedEntityData.delete(entity.id.value)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,uCAA8C;gBAE7B;AAAA,EAYf,cAAc;AAXL,2DAA8C;AAC9C,gEAAqF;AAIrF,2DAA+D;AAC/D,mEAA4F;AAEpG;AACQ,yCAAyC,IAAI,4CAA4B,2BAAW;AAAA;AAAA,EAI7F,qBAAqB,UAAkC;8BACnC,qBAAqB,KAAK,eAAe;AAAA;AAAA,EAG7D,wBAAwB,UAAkC;8BACtC,wBAAwB,KAAK,eAAe;AAAA;AAAA,EAGhE,UAAU,WAAyB;QAErC,KAAK,YAAY,QAAW;WAC1B,UAAU;AAAA;AAAA;AAAA,MAIN,sBAAgD;WACnD,KAAK,cAAc;AAAA;AAAA,MAGhB,uBAAyC;WAC5C,KAAK,cAAc;AAAA;AAAA,MAGhB,SAAiB;QACvB,KAAK,YAAY,QAAW;YACzB,IAAI,aAAa;AAAA;WAEjB,KAAK;AAAA;AAAA,EAGN,oBAAoB,aAKd;UACN,YAAY,YAAY;QAC1B,UAAU,WAAW,QAAW;aAC5B;AAAA;QAEJ;QACA;QACA;QAEA,UAAU,SAAS,UAAU;yBACb,UAAU,OAAO,OAAO;2BACtB,UAAU,OAAO,WAAW;eACxC,UAAU;A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,KAAK,qBAAqB,IAAI,UAAU,OAAO,oBAAoC;AAAA;AAAA;AAAA,EAItF,eAAe,kBAA2D;SAC3E,iBAAiB,OAAO,iBAAiB;qBAC7B,OAAO,OAAO,OAAO,iBAAiB;QAEnD,iBAAiB,SAAS,eAAe;uBAC3B,UAAU,QAAQ,4BAA4B,OAAO;iBAE3D,SAAS,iBAAiB,SAAS,UAAU;gBAC/C,MAAM;AAAA,eACR;;eAEA;AAAA,eACA,mBAAmB;iBAClB,eAAe;;;eAGhB,cAAc;uBACP,aAAa,MAAM,SAAS,UAAU;mBAC3C,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;UAOnB,SAAS,iBAAiB;QAC5B,OAAO,OAAO,SAAS,GAAG;WACxB,gBAAgB;AAAA;AAAA;AAAA,EAIhB,gBAAgB,QAAqB;eAChC,SAAS,OAAO,OAAO,UAAU;WACtC,eAAe;AAAA;SAEhB,YAAY,OAAO,OAAO,GAAG;SAC7B,oBAAoB,OAAO,OAAO,GAAG;AAAA;AAAA,EAGpC,uBAAuB,eAAwC;;iBAC1C,oBAAoB,cAAc,SAAS,UAAU;YAC3E,iBAAiB,WAAW,YAAY;;;mBAIjC,QAAQ,KAAK,YAAY,UAAU;qBAClC,yBAAyB,KAAK,SAAS,UAAU;kBACrD,WAAW,iBAAiB,kBAAkB,kBAAkB;gBAClE,UAAU;;;;;eAKT;AAAA;WAED;AAAA;AAAA;;"}
|
|
@@ -147,7 +147,7 @@ ${error.message}
|
|
|
147
147
|
parent.children.delete(entityId.value);
|
|
148
148
|
if (entityId.existsOnServer) {
|
|
149
149
|
if (parent.plannedRemovals === void 0) {
|
|
150
|
-
parent.plannedRemovals = new Map();
|
|
150
|
+
parent.plannedRemovals = /* @__PURE__ */ new Map();
|
|
151
151
|
}
|
|
152
152
|
changesDelta++;
|
|
153
153
|
parent.plannedRemovals.set(entityId.value, "delete");
|
|
@@ -157,7 +157,7 @@ ${error.message}
|
|
|
157
157
|
const placeholderName = realmToDelete.blueprint.marker.placeholderName;
|
|
158
158
|
if (entityId.existsOnServer) {
|
|
159
159
|
if (parent.plannedHasOneDeletions === void 0) {
|
|
160
|
-
parent.plannedHasOneDeletions = new Map();
|
|
160
|
+
parent.plannedHasOneDeletions = /* @__PURE__ */ new Map();
|
|
161
161
|
}
|
|
162
162
|
changesDelta++;
|
|
163
163
|
parent.plannedHasOneDeletions.set(placeholderName, realmToDelete);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityOperations.js","sources":["../../../../src/core/operations/EntityOperations.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, ErrorAccessor } from '../../accessors'\nimport { ServerGeneratedUuid, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport { EntityFieldMarkersContainer, HasOneRelationMarker } from '../../markers'\nimport type { FieldName } from '../../treeParameters'\nimport { assertNever } from '../../utils'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport type { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { EntityListState, EntityRealmState, EntityRealmStateStub, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class EntityOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(entityRealm: EntityRealmState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(entityRealm, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tstate: EntityRealmState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityRealmState, performUpdates: EntityAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntityAtField(outerState: EntityRealmState, fieldName: FieldName, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst fieldsToConnect = getEntityMarker(stateToConnect).fields\n\t\t\tconst persistedData = this.treeStore.persistedEntityData.get(outerState.entity.id.value)\n\n\t\t\tconst entityName = outerState.entity.entityName\n\t\t\tconst fieldSchema = this.treeStore.schema.getEntityField(entityName, fieldName)\n\n\t\t\tif (fieldSchema === undefined) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`EntityAccessor.connectEntityAtField: Unknown field ${entityName}.${fieldName}.\\n\\n` +\n\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t)\n\t\t\t} else if (fieldSchema.__typename === '_Column') {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`EntityAccessor.connectEntityAtField: Cannot connect at field ${entityName}.${fieldName} because ` +\n\t\t\t\t\t\t`it's not a has-one relation.\\n\\n` +\n\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealm(outerState)) {\n\t\t\t\tconst targetHasOneMarkers = this.resolveHasOneRelationMarkers(\n\t\t\t\t\tgetEntityMarker(state).fields,\n\t\t\t\t\tfieldName,\n\t\t\t\t\t`Cannot connect at field '${fieldName}' as it doesn't refer to a has one relation.`,\n\t\t\t\t)\n\t\t\t\tfor (const targetHasOneMarker of targetHasOneMarkers) {\n\t\t\t\t\tconst previouslyConnectedState = state.children.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tpreviouslyConnectedState === undefined ||\n\t\t\t\t\t\tpreviouslyConnectedState.type === 'field' ||\n\t\t\t\t\t\tpreviouslyConnectedState.type === 'entityList'\n\t\t\t\t\t) {\n\t\t\t\t\t\tOperationsHelpers.rejectInvalidAccessorTree()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (previouslyConnectedState.entity.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`EntityAccessor.connectEntityAtField: Attempting to connect at field ${entityName}.${fieldName} ` +\n\t\t\t\t\t\t\t\t`an entity of type '${stateToConnect.entity.entityName}' but ` +\n\t\t\t\t\t\t\t\t`'${previouslyConnectedState.entity.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(targetHasOneMarker.fields, fieldsToConnect)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t\t`EntityAccessor: cannot connect entity with key '${entityToConnect.key}' because its fields are` +\n\t\t\t\t\t\t\t\t\t`incompatible with entities found at field '${fieldName}'. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tpreviouslyConnectedState === stateToConnect ||\n\t\t\t\t\t\tpreviouslyConnectedState.entity.id.value === stateToConnect.entity.id.value\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue // Do nothing.\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO remove from planned deletions if appropriate\n\n\t\t\t\t\tthis.treeStore.disposeOfRealm(previouslyConnectedState)\n\n\t\t\t\t\tlet changesDelta = 0\n\n\t\t\t\t\tif (previouslyConnectedState.type === 'entityRealm') {\n\t\t\t\t\t\tchangesDelta -= previouslyConnectedState.unpersistedChangesCount\n\t\t\t\t\t}\n\n\t\t\t\t\tconst persistedId = persistedData?.get(targetHasOneMarker.placeholderName)\n\t\t\t\t\tif (persistedId instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\tif (persistedId.value === stateToConnect.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta-- // It was removed from the list but now we're adding it back.\n\t\t\t\t\t\t} else if (persistedId.value === previouslyConnectedState.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta++ // We're changing it from the persisted id.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!previouslyConnectedState.entity.id.existsOnServer) {\n\t\t\t\t\t\t// This assumes the invariant enforced above that we cannot connect unpersisted entities.\n\t\t\t\t\t\t// Hence the previouslyConnectedState still refers to the entity created initially.\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tpersistedId === null || // We're updating.\n\t\t\t\t\t\t\t(persistedId === undefined && // We're creating.\n\t\t\t\t\t\t\t\t(!fieldsToConnect.hasAtLeastOneBearingField || !targetHasOneMarker.parameters.isNonbearing))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO do something about the existing state…\n\n\t\t\t\t\tthis.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tstateToConnect.entity.id,\n\t\t\t\t\t\tstateToConnect.entity.entityName,\n\t\t\t\t\t\tpreviouslyConnectedState.blueprint,\n\t\t\t\t\t)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(state, targetHasOneMarker.placeholderName)\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntityAtField(\n\t\touterState: EntityRealmState,\n\t\tfieldName: FieldName,\n\t\tinitializeReplacement: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedData = this.treeStore.persistedEntityData.get(outerState.entity.id.value)\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealm(outerState)) {\n\t\t\t\tconst targetHasOneMarkers = this.resolveHasOneRelationMarkers(\n\t\t\t\t\tgetEntityMarker(state).fields,\n\t\t\t\t\tfieldName,\n\t\t\t\t\t`Cannot disconnect at field '${fieldName}' as it doesn't refer to a has one relation.`,\n\t\t\t\t)\n\t\t\t\tfor (const targetHasOneMarker of targetHasOneMarkers) {\n\t\t\t\t\tconst stateToDisconnect = state.children.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstateToDisconnect === undefined ||\n\t\t\t\t\t\t(stateToDisconnect.type !== 'entityRealm' && stateToDisconnect.type !== 'entityRealmStub')\n\t\t\t\t\t) {\n\t\t\t\t\t\tOperationsHelpers.rejectInvalidAccessorTree()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.treeStore.disposeOfRealm(stateToDisconnect)\n\n\t\t\t\t\tlet changesDelta = 0\n\n\t\t\t\t\tif (stateToDisconnect.type === 'entityRealm') {\n\t\t\t\t\t\tchangesDelta -= stateToDisconnect.unpersistedChangesCount\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedId = persistedData?.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (persistedId instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\tif (persistedId.value === stateToDisconnect.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta++ // Disconnecting the persisted entity.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Do nothing. The entity that is being disconnected is already different from the one that is persisted,\n\t\t\t\t\t\t\t// and so we must have already accounted for this change.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (persistedId === undefined || persistedId === null) {\n\t\t\t\t\t\tif (stateToDisconnect.entity.id.existsOnServer) {\n\t\t\t\t\t\t\t// We had connected a persisted entity, which increased the changes count,\n\t\t\t\t\t\t\t// but now are disconnecting it again.\n\t\t\t\t\t\t\tchangesDelta--\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Do nothing. Disconnecting unpersisted entities doesn't change the count.\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tnew UnpersistedEntityDummyId(),\n\t\t\t\t\t\tstateToDisconnect.entity.entityName,\n\t\t\t\t\t\tstateToDisconnect.blueprint,\n\t\t\t\t\t)\n\t\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initializeReplacement)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(state, targetHasOneMarker.placeholderName)\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic deleteEntity(realm: EntityRealmState) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst outerState = realm.entity\n\t\t\touterState.isScheduledForDeletion = true\n\n\t\t\tconst entityId = outerState.id\n\n\t\t\tfor (const realmToDelete of outerState.realms.values()) {\n\t\t\t\tlet parent: EntityRealmState | EntityRealmStateStub | EntityListState\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (realmToDelete.blueprint.type === 'listEntity') {\n\t\t\t\t\tparent = realmToDelete.blueprint.parent\n\t\t\t\t\tparent.children.delete(entityId.value)\n\n\t\t\t\t\tif (entityId.existsOnServer) {\n\t\t\t\t\t\tif (parent.plannedRemovals === undefined) {\n\t\t\t\t\t\t\tparent.plannedRemovals = new Map()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\tparent.plannedRemovals.set(entityId.value, 'delete')\n\t\t\t\t\t}\n\t\t\t\t} else if (realmToDelete.blueprint.type === 'hasOne') {\n\t\t\t\t\tparent = realmToDelete.blueprint.parent\n\t\t\t\t\tconst placeholderName = realmToDelete.blueprint.marker.placeholderName\n\n\t\t\t\t\tif (entityId.existsOnServer) {\n\t\t\t\t\t\tif (parent.plannedHasOneDeletions === undefined) {\n\t\t\t\t\t\t\tparent.plannedHasOneDeletions = new Map()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\tparent.plannedHasOneDeletions.set(placeholderName, realmToDelete)\n\t\t\t\t\t}\n\t\t\t\t\tthis.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tnew UnpersistedEntityDummyId(),\n\t\t\t\t\t\touterState.entityName,\n\t\t\t\t\t\trealmToDelete.blueprint,\n\t\t\t\t\t)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(parent, placeholderName)\n\t\t\t\t} else if (realmToDelete.blueprint.type === 'subTree') {\n\t\t\t\t\tthrow new BindingError('Deleting top-level entities is not yet implemented.')\n\t\t\t\t} else {\n\t\t\t\t\treturn assertNever(realmToDelete.blueprint)\n\t\t\t\t}\n\n\t\t\t\tif (realmToDelete.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever this had caused\n\t\t\t\t\tchangesDelta -= realmToDelete.unpersistedChangesCount\n\t\t\t\t}\n\t\t\t\tthis.eventManager.registerJustUpdated(parent, changesDelta)\n\n\t\t\t\tif (realmToDelete.type === 'entityRealm') {\n\t\t\t\t\tparent.childrenWithPendingUpdates?.delete(realmToDelete)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(realmToDelete)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate *resolveHasOneRelationMarkers(\n\t\tcontainer: EntityFieldMarkersContainer,\n\t\tfield: FieldName,\n\t\tmessage: string,\n\t): IterableIterator<HasOneRelationMarker> {\n\t\tconst placeholders = container.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst normalizedPlaceholders = placeholders instanceof Set ? placeholders : [placeholders]\n\n\t\tfor (const placeholderName of normalizedPlaceholders) {\n\t\t\tconst hasOneRelation = container.markers.get(placeholderName)\n\n\t\t\tif (!(hasOneRelation instanceof HasOneRelationMarker)) {\n\t\t\t\tthrow new BindingError(message)\n\t\t\t}\n\t\t\tyield hasOneRelation\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;uBAgB8B;AAAA,EACtB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;;;;;;;EAEK,SAAS,aAA+B,OAAwC;WAC/E,KAAK,qBAAqB,SAAS,aAAa;AAAA;AAAA,EAGjD,iBACN,OACA,OACA,UACC;QACG,MAAM,mBAAmB,QAAW;YACjC,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,aAAa,OAAyB,gBAAoD;SAC3F,aAAa,cAAc,MAAM;qBACtB,MAAM,aAAa,KAAK;AAAA;AAAA;AAAA,EAIlC,qBAAqB,YAA8B,WAAsB,iBAAiC;SAC3G,aAAa,cAAc,MAAM;YAC/B,iBAAiB,kBAAkB,iCAAiC,KAAK,WAAW;YACpF,kBAAkB,gBAAgB,gBAAgB;YAClD,gBAAgB,KAAK,UAAU,oBAAoB,IAAI,WAAW,OAAO,GAAG;YAE5E,aAAa,WAAW,OAAO;Y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ACA,eAAe;YAEf,cAAc,UAAU,SAAS,cAAc;mBACzC,cAAc,UAAU;iBAC1B,SAAS,OAAO,SAAS;cAE5B,SAAS,gBAAgB;gBACxB,OAAO,oBAAoB,QAAW;qBAClC,kBAAkB,IAAI;AAAA;;mBAGvB,gBAAgB,IAAI,SAAS,OAAO;AAAA;AAAA,mBAElC,cAAc,UAAU,SAAS,UAAU;mBAC5C,cAAc,UAAU;gBAC3B,kBAAkB,cAAc,UAAU,OAAO;cAEnD,SAAS,gBAAgB;gBACxB,OAAO,2BAA2B,QAAW;qBACzC,yBAAyB,IAAI;AAAA;;mBAG9B,uBAAuB,IAAI,iBAAiB;AAAA;eAE/C,iBAAiB,sBACrB,IAAI,4BACJ,WAAW,YACX,cAAc;eAGV,aAAa,0BAA0B,QAAQ;AAAA,mBAC1C,cAAc,UAAU,SAAS,WAAW;gBAChD,IAAI,aAAa;AAAA,eACjB;iBACC,YAAY,cAAc;AAAA;YAG9B,cAAc,SAAS,eAAe;0BAEzB,cAAc;AAAA;aAE1B,aAAa,oBAAoB,QAAQ;YAE1C,cAAc,SAAS,eAAe;iBAClC,4BAA4B,OAAO;AAAA;aAGtC,UAAU,eAAe;AAAA;AAAA;AAAA;AAAA,GAKxB,6BACR,WACA,OACA,SACyC;UACnC,eAAe,UAAU,aAAa,IAAI;QAE5C,iBAAiB,QAAW;;;UAG1B,yBAAyB,wBAAwB,MAAM,eAAe,CAAC;eAElE,mBAAmB,wBAAwB;YAC/C,iBAAiB,UAAU,QAAQ,IAAI;UAEzC,4BAA4B,uBAAuB;cAChD,IAAI,aAAa;AAAA;YAElB;AAAA;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"EntityOperations.js","sources":["../../../../src/core/operations/EntityOperations.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, ErrorAccessor } from '../../accessors'\nimport { ServerGeneratedUuid, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport { EntityFieldMarkersContainer, HasOneRelationMarker } from '../../markers'\nimport type { FieldName } from '../../treeParameters'\nimport { assertNever } from '../../utils'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport type { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { EntityListState, EntityRealmState, EntityRealmStateStub, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class EntityOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(entityRealm: EntityRealmState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(entityRealm, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tstate: EntityRealmState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityRealmState, performUpdates: EntityAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntityAtField(outerState: EntityRealmState, fieldName: FieldName, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst fieldsToConnect = getEntityMarker(stateToConnect).fields\n\t\t\tconst persistedData = this.treeStore.persistedEntityData.get(outerState.entity.id.value)\n\n\t\t\tconst entityName = outerState.entity.entityName\n\t\t\tconst fieldSchema = this.treeStore.schema.getEntityField(entityName, fieldName)\n\n\t\t\tif (fieldSchema === undefined) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`EntityAccessor.connectEntityAtField: Unknown field ${entityName}.${fieldName}.\\n\\n` +\n\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t)\n\t\t\t} else if (fieldSchema.__typename === '_Column') {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`EntityAccessor.connectEntityAtField: Cannot connect at field ${entityName}.${fieldName} because ` +\n\t\t\t\t\t\t`it's not a has-one relation.\\n\\n` +\n\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealm(outerState)) {\n\t\t\t\tconst targetHasOneMarkers = this.resolveHasOneRelationMarkers(\n\t\t\t\t\tgetEntityMarker(state).fields,\n\t\t\t\t\tfieldName,\n\t\t\t\t\t`Cannot connect at field '${fieldName}' as it doesn't refer to a has one relation.`,\n\t\t\t\t)\n\t\t\t\tfor (const targetHasOneMarker of targetHasOneMarkers) {\n\t\t\t\t\tconst previouslyConnectedState = state.children.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tpreviouslyConnectedState === undefined ||\n\t\t\t\t\t\tpreviouslyConnectedState.type === 'field' ||\n\t\t\t\t\t\tpreviouslyConnectedState.type === 'entityList'\n\t\t\t\t\t) {\n\t\t\t\t\t\tOperationsHelpers.rejectInvalidAccessorTree()\n\t\t\t\t\t}\n\n\t\t\t\t\tif (previouslyConnectedState.entity.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`EntityAccessor.connectEntityAtField: Attempting to connect at field ${entityName}.${fieldName} ` +\n\t\t\t\t\t\t\t\t`an entity of type '${stateToConnect.entity.entityName}' but ` +\n\t\t\t\t\t\t\t\t`'${previouslyConnectedState.entity.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(targetHasOneMarker.fields, fieldsToConnect)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t\t`EntityAccessor: cannot connect entity with key '${entityToConnect.key}' because its fields are` +\n\t\t\t\t\t\t\t\t\t`incompatible with entities found at field '${fieldName}'. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tpreviouslyConnectedState === stateToConnect ||\n\t\t\t\t\t\tpreviouslyConnectedState.entity.id.value === stateToConnect.entity.id.value\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue // Do nothing.\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO remove from planned deletions if appropriate\n\n\t\t\t\t\tthis.treeStore.disposeOfRealm(previouslyConnectedState)\n\n\t\t\t\t\tlet changesDelta = 0\n\n\t\t\t\t\tif (previouslyConnectedState.type === 'entityRealm') {\n\t\t\t\t\t\tchangesDelta -= previouslyConnectedState.unpersistedChangesCount\n\t\t\t\t\t}\n\n\t\t\t\t\tconst persistedId = persistedData?.get(targetHasOneMarker.placeholderName)\n\t\t\t\t\tif (persistedId instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\tif (persistedId.value === stateToConnect.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta-- // It was removed from the list but now we're adding it back.\n\t\t\t\t\t\t} else if (persistedId.value === previouslyConnectedState.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta++ // We're changing it from the persisted id.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!previouslyConnectedState.entity.id.existsOnServer) {\n\t\t\t\t\t\t// This assumes the invariant enforced above that we cannot connect unpersisted entities.\n\t\t\t\t\t\t// Hence the previouslyConnectedState still refers to the entity created initially.\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tpersistedId === null || // We're updating.\n\t\t\t\t\t\t\t(persistedId === undefined && // We're creating.\n\t\t\t\t\t\t\t\t(!fieldsToConnect.hasAtLeastOneBearingField || !targetHasOneMarker.parameters.isNonbearing))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO do something about the existing state…\n\n\t\t\t\t\tthis.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tstateToConnect.entity.id,\n\t\t\t\t\t\tstateToConnect.entity.entityName,\n\t\t\t\t\t\tpreviouslyConnectedState.blueprint,\n\t\t\t\t\t)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(state, targetHasOneMarker.placeholderName)\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntityAtField(\n\t\touterState: EntityRealmState,\n\t\tfieldName: FieldName,\n\t\tinitializeReplacement: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedData = this.treeStore.persistedEntityData.get(outerState.entity.id.value)\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealm(outerState)) {\n\t\t\t\tconst targetHasOneMarkers = this.resolveHasOneRelationMarkers(\n\t\t\t\t\tgetEntityMarker(state).fields,\n\t\t\t\t\tfieldName,\n\t\t\t\t\t`Cannot disconnect at field '${fieldName}' as it doesn't refer to a has one relation.`,\n\t\t\t\t)\n\t\t\t\tfor (const targetHasOneMarker of targetHasOneMarkers) {\n\t\t\t\t\tconst stateToDisconnect = state.children.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstateToDisconnect === undefined ||\n\t\t\t\t\t\t(stateToDisconnect.type !== 'entityRealm' && stateToDisconnect.type !== 'entityRealmStub')\n\t\t\t\t\t) {\n\t\t\t\t\t\tOperationsHelpers.rejectInvalidAccessorTree()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.treeStore.disposeOfRealm(stateToDisconnect)\n\n\t\t\t\t\tlet changesDelta = 0\n\n\t\t\t\t\tif (stateToDisconnect.type === 'entityRealm') {\n\t\t\t\t\t\tchangesDelta -= stateToDisconnect.unpersistedChangesCount\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedId = persistedData?.get(targetHasOneMarker.placeholderName)\n\n\t\t\t\t\tif (persistedId instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\tif (persistedId.value === stateToDisconnect.entity.id.value) {\n\t\t\t\t\t\t\tchangesDelta++ // Disconnecting the persisted entity.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Do nothing. The entity that is being disconnected is already different from the one that is persisted,\n\t\t\t\t\t\t\t// and so we must have already accounted for this change.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (persistedId === undefined || persistedId === null) {\n\t\t\t\t\t\tif (stateToDisconnect.entity.id.existsOnServer) {\n\t\t\t\t\t\t\t// We had connected a persisted entity, which increased the changes count,\n\t\t\t\t\t\t\t// but now are disconnecting it again.\n\t\t\t\t\t\t\tchangesDelta--\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Do nothing. Disconnecting unpersisted entities doesn't change the count.\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tnew UnpersistedEntityDummyId(),\n\t\t\t\t\t\tstateToDisconnect.entity.entityName,\n\t\t\t\t\t\tstateToDisconnect.blueprint,\n\t\t\t\t\t)\n\t\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initializeReplacement)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(state, targetHasOneMarker.placeholderName)\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic deleteEntity(realm: EntityRealmState) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst outerState = realm.entity\n\t\t\touterState.isScheduledForDeletion = true\n\n\t\t\tconst entityId = outerState.id\n\n\t\t\tfor (const realmToDelete of outerState.realms.values()) {\n\t\t\t\tlet parent: EntityRealmState | EntityRealmStateStub | EntityListState\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (realmToDelete.blueprint.type === 'listEntity') {\n\t\t\t\t\tparent = realmToDelete.blueprint.parent\n\t\t\t\t\tparent.children.delete(entityId.value)\n\n\t\t\t\t\tif (entityId.existsOnServer) {\n\t\t\t\t\t\tif (parent.plannedRemovals === undefined) {\n\t\t\t\t\t\t\tparent.plannedRemovals = new Map()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\tparent.plannedRemovals.set(entityId.value, 'delete')\n\t\t\t\t\t}\n\t\t\t\t} else if (realmToDelete.blueprint.type === 'hasOne') {\n\t\t\t\t\tparent = realmToDelete.blueprint.parent\n\t\t\t\t\tconst placeholderName = realmToDelete.blueprint.marker.placeholderName\n\n\t\t\t\t\tif (entityId.existsOnServer) {\n\t\t\t\t\t\tif (parent.plannedHasOneDeletions === undefined) {\n\t\t\t\t\t\t\tparent.plannedHasOneDeletions = new Map()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t\tparent.plannedHasOneDeletions.set(placeholderName, realmToDelete)\n\t\t\t\t\t}\n\t\t\t\t\tthis.stateInitializer.initializeEntityRealm(\n\t\t\t\t\t\tnew UnpersistedEntityDummyId(),\n\t\t\t\t\t\touterState.entityName,\n\t\t\t\t\t\trealmToDelete.blueprint,\n\t\t\t\t\t)\n\n\t\t\t\t\tthis.eventManager.registerUpdatedConnection(parent, placeholderName)\n\t\t\t\t} else if (realmToDelete.blueprint.type === 'subTree') {\n\t\t\t\t\tthrow new BindingError('Deleting top-level entities is not yet implemented.')\n\t\t\t\t} else {\n\t\t\t\t\treturn assertNever(realmToDelete.blueprint)\n\t\t\t\t}\n\n\t\t\t\tif (realmToDelete.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever this had caused\n\t\t\t\t\tchangesDelta -= realmToDelete.unpersistedChangesCount\n\t\t\t\t}\n\t\t\t\tthis.eventManager.registerJustUpdated(parent, changesDelta)\n\n\t\t\t\tif (realmToDelete.type === 'entityRealm') {\n\t\t\t\t\tparent.childrenWithPendingUpdates?.delete(realmToDelete)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(realmToDelete)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate *resolveHasOneRelationMarkers(\n\t\tcontainer: EntityFieldMarkersContainer,\n\t\tfield: FieldName,\n\t\tmessage: string,\n\t): IterableIterator<HasOneRelationMarker> {\n\t\tconst placeholders = container.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst normalizedPlaceholders = placeholders instanceof Set ? placeholders : [placeholders]\n\n\t\tfor (const placeholderName of normalizedPlaceholders) {\n\t\t\tconst hasOneRelation = container.markers.get(placeholderName)\n\n\t\t\tif (!(hasOneRelation instanceof HasOneRelationMarker)) {\n\t\t\t\tthrow new BindingError(message)\n\t\t\t}\n\t\t\tyield hasOneRelation\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;uBAgB8B;AAAA,EACtB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;;;;;;;EAEK,SAAS,aAA+B,OAAwC;WAC/E,KAAK,qBAAqB,SAAS,aAAa;AAAA;AAAA,EAGjD,iBACN,OACA,OACA,UACC;QACG,MAAM,mBAAmB,QAAW;YACjC,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,aAAa,OAAyB,gBAAoD;SAC3F,aAAa,cAAc,MAAM;qBACtB,MAAM,aAAa,KAAK;AAAA;AAAA;AAAA,EAIlC,qBAAqB,YAA8B,WAAsB,iBAAiC;SAC3G,aAAa,cAAc,MAAM;YAC/B,iBAAiB,kBAAkB,iCAAiC,KAAK,WAAW;YACpF,kBAAkB,gBAAgB,gBAAgB;YAClD,gBAAgB,KAAK,UAAU,oBAAoB,IAAI,WAAW,OAAO,GAAG;YAE5E,aAAa,WAAW,OAAO;YAC/B,cAAc,KAAK,UAAU,OAAO,eAAe,YAAY;UAEjE,gBAAgB,QAAW;cACxB,IAAI,aACT,sDAAsD,cAAc;AAAA;AAAA,qBAC7C,aAAa,oBAAoB;AAAA,iBAE/C,YAAY,eAAe,WAAW;cAC1C,IAAI,aACT,gEAAgE,cAAc;AAAA;AAAA,qBAEvD,aAAa,oBAAoB;AAAA;iBAI/C,SAAS,cAAc,iBAAiB,aAAa;cACzD,sBAAsB,KAAK,6BAChC,gBAAgB,OAAO,QACvB,WACA,4BAA4B;mBAElB,sBAAsB,qBAAqB;gBAC/C,2BAA2B,MAAM,SAAS,IAAI,mBAAmB;cAGtE,6BAA6B,UAC7B,yBAAyB,SAAS,WAClC,yBAAyB,SAAS,cACjC;8BACiB;AAAA;cAGf,yBAAy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BAC1C,cAAc,UAAU,SAAS,WAAW;gBAChD,IAAI,aAAa;AAAA,eACjB;iBACC,YAAY,cAAc;AAAA;YAG9B,cAAc,SAAS,eAAe;0BAEzB,cAAc;AAAA;aAE1B,aAAa,oBAAoB,QAAQ;YAE1C,cAAc,SAAS,eAAe;iBAClC,4BAA4B,OAAO;AAAA;aAGtC,UAAU,eAAe;AAAA;AAAA;AAAA;AAAA,GAKxB,6BACR,WACA,OACA,SACyC;UACnC,eAAe,UAAU,aAAa,IAAI;QAE5C,iBAAiB,QAAW;;;UAG1B,yBAAyB,wBAAwB,MAAM,eAAe,CAAC;eAElE,mBAAmB,wBAAwB;YAC/C,iBAAiB,UAAU,QAAQ,IAAI;UAEzC,4BAA4B,uBAAuB;cAChD,IAAI,aAAa;AAAA;YAElB;AAAA;AAAA;AAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldOperations.js","sources":["../../../../src/core/operations/FieldOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport { ErrorAccessor, FieldAccessor } from '../../accessors'\nimport { ClientGeneratedUuid } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport { PRIMARY_KEY_NAME } from '../../bindingTypes'\nimport type { FieldValue } from '../../treeParameters'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { FieldState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class FieldOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(fieldState: FieldState<any>, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(fieldState, error)\n\t}\n\n\tpublic clearErrors(fieldState: FieldState<any>): void {\n\t\treturn this.accessorErrorManager.clearErrorsByState(fieldState)\n\t}\n\n\tpublic addEventListener<\n\t\tType extends keyof FieldAccessor.FieldEventListenerMap,\n\t\tValue extends FieldValue = FieldValue,\n\t>(\n\t\tstate: FieldState<Value>,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\tif (!state.eventListeners) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic updateValue<Value extends FieldValue = FieldValue>(\n\t\tfieldState: FieldState<Value>,\n\t\tnewValue: Value | null,\n\t\t{ agent = FieldAccessor.userAgent }: FieldAccessor.UpdateOptions = {},\n\t) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst { placeholderName, parent } = fieldState\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME) {\n\t\t\t\tconst entity = fieldState.parent.entity\n\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tif (newValue !== fieldState.value && (fieldState.touchLog !== undefined || entity.hasIdSetInStone)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.\\n` +\n\t\t\t\t\t\t\t\t`Once set, it is immutable.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof newValue !== 'string' || !uuidValidate(newValue)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. ` +\n\t\t\t\t\t\t\t\t`Expecting a valid uuid but '${newValue}' was given.\\n` +\n\t\t\t\t\t\t\t\t`Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (this.treeStore.entityStore.has(newValue)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. ` +\n\t\t\t\t\t\t\t\t`It is already in use by an existing entity.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof newValue !== 'string') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tOperationsHelpers.changeEntityId(\n\t\t\t\t\tthis.treeStore,\n\t\t\t\t\tthis.eventManager,\n\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\tentity,\n\t\t\t\t\tnew ClientGeneratedUuid(newValue),\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const field of StateIterator.eachSiblingRealmChild(this.treeStore, fieldState)) {\n\t\t\t\tif (newValue === field.value) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.touchLog === undefined) {\n\t\t\t\t\tfield.touchLog = new Set()\n\t\t\t\t}\n\t\t\t\tfield.touchLog.add(agent)\n\t\t\t\tfield.value = newValue\n\n\t\t\t\tconst resolvedValue =\n\t\t\t\t\tfield.fieldMarker.defaultValue === undefined\n\t\t\t\t\t\t? newValue\n\t\t\t\t\t\t: newValue === null\n\t\t\t\t\t\t? field.fieldMarker.defaultValue\n\t\t\t\t\t\t: newValue\n\t\t\t\tconst normalizedPersistedValue = field.persistedValue === undefined ? null : field.persistedValue\n\t\t\t\tconst hadUnpersistedChangesBefore = field.hasUnpersistedChanges\n\t\t\t\tconst hasUnpersistedChangesNow = resolvedValue !== normalizedPersistedValue\n\t\t\t\tfield.hasUnpersistedChanges = hasUnpersistedChangesNow\n\n\t\t\t\tconst shouldInfluenceUpdateCount =\n\t\t\t\t\t!getEntityMarker(parent).fields.hasAtLeastOneBearingField ||\n\t\t\t\t\t!field.fieldMarker.isNonbearing ||\n\t\t\t\t\tfield.persistedValue !== undefined\n\n\t\t\t\tlet changesDelta = EventManager.NO_CHANGES_DIFFERENCE\n\n\t\t\t\tif (shouldInfluenceUpdateCount) {\n\t\t\t\t\tif (!hadUnpersistedChangesBefore && hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t} else if (hadUnpersistedChangesBefore && !hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta--\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(field, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;sBAc6B;AAAA,EACrB,YACW,sBACA,cACA,kBACA,WAChB;;;;;;EAEK,SAAS,YAA6B,OAAwC;WAC7E,KAAK,qBAAqB,SAAS,YAAY;AAAA;AAAA,EAGhD,YAAY,YAAmC;WAC9C,KAAK,qBAAqB,mBAAmB;AAAA;AAAA,EAG9C,iBAIN,OACA,OACA,UACa;QACT,CAAC,MAAM,gBAAgB;YACpB,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,YACN,YACA,UACA,EAAE,QAAQ,cAAc,cAA2C,IAClE;SACI,aAAa,cAAc,MAAM;YAC/B,EAAE,iBAAiB,WAAW;UAChC,oBAAoB,kBAAkB;cACnC,SAAS,WAAW,OAAO;YAuB7B,OAAO,aAAa,UAAU;gBAC3B,IAAI;AAAA;0BAEO,eACjB,KAAK,WACL,KAAK,cACL,KAAK,kBACL,QACA,IAAI,oBAAoB;AAAA;iBAGf,SAAS,cAAc,sBAAsB,KAAK,WAAW,aAAa;YAChF,aAAa,MAAM,OAAO;;;YAG1B,MAAM,aAAa,QAAW;gBAC3B
|
|
1
|
+
{"version":3,"file":"FieldOperations.js","sources":["../../../../src/core/operations/FieldOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport { ErrorAccessor, FieldAccessor } from '../../accessors'\nimport { ClientGeneratedUuid } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport { PRIMARY_KEY_NAME } from '../../bindingTypes'\nimport type { FieldValue } from '../../treeParameters'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { FieldState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class FieldOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(fieldState: FieldState<any>, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(fieldState, error)\n\t}\n\n\tpublic clearErrors(fieldState: FieldState<any>): void {\n\t\treturn this.accessorErrorManager.clearErrorsByState(fieldState)\n\t}\n\n\tpublic addEventListener<\n\t\tType extends keyof FieldAccessor.FieldEventListenerMap,\n\t\tValue extends FieldValue = FieldValue,\n\t>(\n\t\tstate: FieldState<Value>,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\tif (!state.eventListeners) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic updateValue<Value extends FieldValue = FieldValue>(\n\t\tfieldState: FieldState<Value>,\n\t\tnewValue: Value | null,\n\t\t{ agent = FieldAccessor.userAgent }: FieldAccessor.UpdateOptions = {},\n\t) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst { placeholderName, parent } = fieldState\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME) {\n\t\t\t\tconst entity = fieldState.parent.entity\n\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tif (newValue !== fieldState.value && (fieldState.touchLog !== undefined || entity.hasIdSetInStone)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.\\n` +\n\t\t\t\t\t\t\t\t`Once set, it is immutable.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof newValue !== 'string' || !uuidValidate(newValue)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. ` +\n\t\t\t\t\t\t\t\t`Expecting a valid uuid but '${newValue}' was given.\\n` +\n\t\t\t\t\t\t\t\t`Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (this.treeStore.entityStore.has(newValue)) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. ` +\n\t\t\t\t\t\t\t\t`It is already in use by an existing entity.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof newValue !== 'string') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tOperationsHelpers.changeEntityId(\n\t\t\t\t\tthis.treeStore,\n\t\t\t\t\tthis.eventManager,\n\t\t\t\t\tthis.stateInitializer,\n\t\t\t\t\tentity,\n\t\t\t\t\tnew ClientGeneratedUuid(newValue),\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const field of StateIterator.eachSiblingRealmChild(this.treeStore, fieldState)) {\n\t\t\t\tif (newValue === field.value) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.touchLog === undefined) {\n\t\t\t\t\tfield.touchLog = new Set()\n\t\t\t\t}\n\t\t\t\tfield.touchLog.add(agent)\n\t\t\t\tfield.value = newValue\n\n\t\t\t\tconst resolvedValue =\n\t\t\t\t\tfield.fieldMarker.defaultValue === undefined\n\t\t\t\t\t\t? newValue\n\t\t\t\t\t\t: newValue === null\n\t\t\t\t\t\t? field.fieldMarker.defaultValue\n\t\t\t\t\t\t: newValue\n\t\t\t\tconst normalizedPersistedValue = field.persistedValue === undefined ? null : field.persistedValue\n\t\t\t\tconst hadUnpersistedChangesBefore = field.hasUnpersistedChanges\n\t\t\t\tconst hasUnpersistedChangesNow = resolvedValue !== normalizedPersistedValue\n\t\t\t\tfield.hasUnpersistedChanges = hasUnpersistedChangesNow\n\n\t\t\t\tconst shouldInfluenceUpdateCount =\n\t\t\t\t\t!getEntityMarker(parent).fields.hasAtLeastOneBearingField ||\n\t\t\t\t\t!field.fieldMarker.isNonbearing ||\n\t\t\t\t\tfield.persistedValue !== undefined\n\n\t\t\t\tlet changesDelta = EventManager.NO_CHANGES_DIFFERENCE\n\n\t\t\t\tif (shouldInfluenceUpdateCount) {\n\t\t\t\t\tif (!hadUnpersistedChangesBefore && hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta++\n\t\t\t\t\t} else if (hadUnpersistedChangesBefore && !hasUnpersistedChangesNow) {\n\t\t\t\t\t\tchangesDelta--\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(field, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;sBAc6B;AAAA,EACrB,YACW,sBACA,cACA,kBACA,WAChB;;;;;;EAEK,SAAS,YAA6B,OAAwC;WAC7E,KAAK,qBAAqB,SAAS,YAAY;AAAA;AAAA,EAGhD,YAAY,YAAmC;WAC9C,KAAK,qBAAqB,mBAAmB;AAAA;AAAA,EAG9C,iBAIN,OACA,OACA,UACa;QACT,CAAC,MAAM,gBAAgB;YACpB,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,YACN,YACA,UACA,EAAE,QAAQ,cAAc,cAA2C,IAClE;SACI,aAAa,cAAc,MAAM;YAC/B,EAAE,iBAAiB,WAAW;UAChC,oBAAoB,kBAAkB;cACnC,SAAS,WAAW,OAAO;YAuB7B,OAAO,aAAa,UAAU;gBAC3B,IAAI;AAAA;0BAEO,eACjB,KAAK,WACL,KAAK,cACL,KAAK,kBACL,QACA,IAAI,oBAAoB;AAAA;iBAGf,SAAS,cAAc,sBAAsB,KAAK,WAAW,aAAa;YAChF,aAAa,MAAM,OAAO;;;YAG1B,MAAM,aAAa,QAAW;gBAC3B,+BAAe;AAAA;cAEhB,SAAS,IAAI;cACb,QAAQ;cAER,gBACL,MAAM,YAAY,iBAAiB,SAChC,WACA,aAAa,OACb,MAAM,YAAY,eAClB;cACE,2BAA2B,MAAM,mBAAmB,SAAY,OAAO,MAAM;cAC7E,8BAA8B,MAAM;cACpC,2BAA2B,kBAAkB;cAC7C,wBAAwB;cAExB,6BACL,CAAC,gBAAgB,QAAQ,OAAO,6BAChC,CAAC,MAAM,YAAY,gBACnB,MAAM,mBAAmB;YAEtB,eAAe,aAAa;YAE5B,4BAA4B;cAC3B,CAAC,+BAA+B,0BAA0B;;qBAEnD,+BAA+B,CAAC,0BAA0B;;;;aAKjE,aAAa,oBAAoB,OAAO;AAAA;AAAA;AAAA;AAAA;;"}
|
|
@@ -99,7 +99,7 @@ ${error.message}
|
|
|
99
99
|
if (persistedEntityIds.has(disconnectedChildIdValue)) {
|
|
100
100
|
changesDelta++;
|
|
101
101
|
if (state.plannedRemovals === void 0) {
|
|
102
|
-
state.plannedRemovals = new Map();
|
|
102
|
+
state.plannedRemovals = /* @__PURE__ */ new Map();
|
|
103
103
|
}
|
|
104
104
|
if (!options.noPersist) {
|
|
105
105
|
state.plannedRemovals.set(disconnectedChildIdValue, "disconnect");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListOperations.js","sources":["../../../../src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '../../accessors'\nimport { RuntimeId, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type ` +\n\t\t\t\t\t\t\t`'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are ` +\n\t\t\t\t\t\t\t\t`incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t`Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else {\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: {noPersist?: boolean}) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Entity list doesn't include an entity with id '${disconnectedChildIdValue}' and so it cannot remove it.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tlistState.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: string) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id)\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` +\n\t\t\t\t\t(looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids ` +\n\t\t\t\t\t\t `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and ` +\n\t\t\t\t\t\t `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;;;;;;;qBAe4B;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;;;;;;;EAEK,SAAS,WAA4B,OAAwC;WAC5E,KAAK,qBAAqB,SAAS,WAAW;AAAA;AAAA,EAG/C,iBACN,OACA,OACA,UACC;QACG,MAAM,mBAAmB,QAAW;YACjC,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,sBACN,OACA,OACA,UACC;QACG,MAAM,wBAAwB,QAAW;YACtC,sBAAsB,IAAI;AAAA;WAE1B,MAAM,oBAAoB,IAAI,OAAO;AAAA;AAAA,EAGtC,aAAa,OAAwB,gBAAwD;SAC9F,aAAa,cAAc,MAAM;qBACtB,MAAM,aAAa,KAAK;AAAA;AAAA;AAAA,EA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YAEf,mBAAmB,IAAI,2BAA2B;;cAGjD,MAAM,oBAAoB,QAAW;kBAClC,kBAAkB,IAAI;AAAA;cAEzB,CAAC,QAAQ,WAAW;kBACjB,gBAAgB,IAAI,0BAA0B;AAAA;AAAA,mBAE3C,uBAAuB,OAAO,GAAG,gBAAgB;;;YAOxD,uBAAuB,SAAS,eAAe;0BAElC,uBAAuB;AAAA;aAGnC,aAAa,oBAAoB,OAAO;AAAA;AAAA;AAAA;AAAA,EAKzC,gBAAgB,YAA6B,YAAuE;WACnH,KAAK,aAAa,cAAc,MAAiB;YAEjD,KAAK,IAAI;iBAEJ,SAAS,cAAc,sBAAsB,KAAK,WAAW,aAAa;cAC9E,YAAY,KAAK,iBAAiB,sBAAsB,IAAI,MAAM,YAAY;AAAA,UACnF,MAAM;AAAA,UACN,QAAQ;AAAA;aAGJ,iBAAiB,+BAA+B,WAAW;aAK3D,aAAa,oBAAoB,OAAO,aAAa;AAAA;aAEpD;AAAA;AAAA;AAAA,EAIF,mBAAmB,OAAwB,IAAY;UACvD,QAAQ,MAAM,SAAS,IAAI;QAC7B,UAAU,QAAW;YAClB,cAAcA,SAAa,OAAO,yBAAyB,eAAe;UAC5E,aAAa;cACV,IAAI,aAAa,kDAAkD;AAAA;YAEpE,eAAe,KAAK,UAAU,iBAAiB,IAAI,OAAO,kBAAkB,uBAAuB;YACnG,IAAI,aACT,kDAAkD,qDAE9C;AAAA,oQAGA;AAAA;WAGC,MAAM;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"ListOperations.js","sources":["../../../../src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '../../accessors'\nimport { RuntimeId, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type ` +\n\t\t\t\t\t\t\t`'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are ` +\n\t\t\t\t\t\t\t\t`incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t`Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else {\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: {noPersist?: boolean}) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Entity list doesn't include an entity with id '${disconnectedChildIdValue}' and so it cannot remove it.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tlistState.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: string) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id)\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` +\n\t\t\t\t\t(looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids ` +\n\t\t\t\t\t\t `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and ` +\n\t\t\t\t\t\t `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;;;;;;;qBAe4B;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;;;;;;;EAEK,SAAS,WAA4B,OAAwC;WAC5E,KAAK,qBAAqB,SAAS,WAAW;AAAA;AAAA,EAG/C,iBACN,OACA,OACA,UACC;QACG,MAAM,mBAAmB,QAAW;YACjC,iBAAiB,IAAI;AAAA;WAErB,MAAM,eAAe,IAAI,OAAO;AAAA;AAAA,EAGjC,sBACN,OACA,OACA,UACC;QACG,MAAM,wBAAwB,QAAW;YACtC,sBAAsB,IAAI;AAAA;WAE1B,MAAM,oBAAoB,IAAI,OAAO;AAAA;AAAA,EAGtC,aAAa,OAAwB,gBAAwD;SAC9F,aAAa,cAAc,MAAM;qBACtB,MAAM,aAAa,KAAK;AAAA;AAAA;AAAA,EAIlC,cAAc,YAA6B,iBAAiC;SAC7E,aAAa,cAAc,MAAM;YAC/B,qBAAqB,KAAK,UAAU,0BAA0B;YAC9D,iBAAiB,kBAAkB,iCAAiC,KAAK,WAAW;YACpF,cAAc,eAAe,OAAO;iBAG/B,SAAS,cAAc,sBAAsB,KAA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AOxD,uBAAuB,SAAS,eAAe;0BAElC,uBAAuB;AAAA;aAGnC,aAAa,oBAAoB,OAAO;AAAA;AAAA;AAAA;AAAA,EAKzC,gBAAgB,YAA6B,YAAuE;WACnH,KAAK,aAAa,cAAc,MAAiB;YAEjD,KAAK,IAAI;iBAEJ,SAAS,cAAc,sBAAsB,KAAK,WAAW,aAAa;cAC9E,YAAY,KAAK,iBAAiB,sBAAsB,IAAI,MAAM,YAAY;AAAA,UACnF,MAAM;AAAA,UACN,QAAQ;AAAA;aAGJ,iBAAiB,+BAA+B,WAAW;aAK3D,aAAa,oBAAoB,OAAO,aAAa;AAAA;aAEpD;AAAA;AAAA;AAAA,EAIF,mBAAmB,OAAwB,IAAY;UACvD,QAAQ,MAAM,SAAS,IAAI;QAC7B,UAAU,QAAW;YAClB,cAAcA,SAAa,OAAO,yBAAyB,eAAe;UAC5E,aAAa;cACV,IAAI,aAAa,kDAAkD;AAAA;YAEpE,eAAe,KAAK,UAAU,iBAAiB,IAAI,OAAO,kBAAkB,uBAAuB;YACnG,IAAI,aACT,kDAAkD,qDAE9C;AAAA,oQAGA;AAAA;WAGC,MAAM;AAAA;AAAA;;"}
|
|
@@ -6,14 +6,14 @@ class SchemaPreprocessor {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
static processRawEnums(rawEnums) {
|
|
9
|
-
const enums = new Map();
|
|
9
|
+
const enums = /* @__PURE__ */ new Map();
|
|
10
10
|
for (const { name, values } of rawEnums) {
|
|
11
11
|
enums.set(name, new Set(values));
|
|
12
12
|
}
|
|
13
13
|
return enums;
|
|
14
14
|
}
|
|
15
15
|
static processRawEntities(rawEntities) {
|
|
16
|
-
const entities = new Map();
|
|
16
|
+
const entities = /* @__PURE__ */ new Map();
|
|
17
17
|
for (const entity of rawEntities) {
|
|
18
18
|
entities.set(entity.name, {
|
|
19
19
|
customPrimaryAllowed: entity.customPrimaryAllowed,
|
|
@@ -25,7 +25,7 @@ class SchemaPreprocessor {
|
|
|
25
25
|
return entities;
|
|
26
26
|
}
|
|
27
27
|
static processRawFields(rawFields) {
|
|
28
|
-
const fields = new Map();
|
|
28
|
+
const fields = /* @__PURE__ */ new Map();
|
|
29
29
|
for (const field of rawFields) {
|
|
30
30
|
fields.set(field.name, field);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaPreprocessor.js","sources":["../../../../src/core/schema/SchemaPreprocessor.ts"],"sourcesContent":["import type { RawSchema } from './RawSchema'\nimport type { RawSchemaEntity, RawSchemaFields } from './RawSchemaEntity'\nimport type { RawSchemaEnum } from './RawSchemaEnum'\nimport type { SchemaEntities } from './SchemaEntities'\nimport type { SchemaEnums } from './SchemaEnums'\nimport type { SchemaFields } from './SchemaFields'\nimport type { SchemaStore } from './SchemaStore'\n\nexport class SchemaPreprocessor {\n\tpublic static processRawSchema(rawSchema: RawSchema): SchemaStore {\n\t\treturn {\n\t\t\tenums: this.processRawEnums(rawSchema.enums),\n\t\t\tentities: this.processRawEntities(rawSchema.entities),\n\t\t}\n\t}\n\n\tprivate static processRawEnums(rawEnums: RawSchemaEnum[]): SchemaEnums {\n\t\tconst enums: SchemaEnums = new Map()\n\n\t\tfor (const { name, values } of rawEnums) {\n\t\t\tenums.set(name, new Set(values))\n\t\t}\n\n\t\treturn enums\n\t}\n\n\tprivate static processRawEntities(rawEntities: RawSchemaEntity[]): SchemaEntities {\n\t\tconst entities: SchemaEntities = new Map()\n\n\t\tfor (const entity of rawEntities) {\n\t\t\tentities.set(entity.name, {\n\t\t\t\tcustomPrimaryAllowed: entity.customPrimaryAllowed,\n\t\t\t\tfields: this.processRawFields(entity.fields),\n\t\t\t\tname: entity.name,\n\t\t\t\tunique: entity.unique,\n\t\t\t})\n\t\t}\n\n\t\treturn entities\n\t}\n\n\tprivate static processRawFields(rawFields: RawSchemaFields): SchemaFields {\n\t\tconst fields: SchemaFields = new Map()\n\n\t\tfor (const field of rawFields) {\n\t\t\tfields.set(field.name, field)\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":"yBAQgC;AAAA,SACjB,iBAAiB,WAAmC;WAC1D;AAAA,MACN,OAAO,KAAK,gBAAgB,UAAU;AAAA,MACtC,UAAU,KAAK,mBAAmB,UAAU;AAAA;AAAA;AAAA,SAI/B,gBAAgB,UAAwC;UAChE,
|
|
1
|
+
{"version":3,"file":"SchemaPreprocessor.js","sources":["../../../../src/core/schema/SchemaPreprocessor.ts"],"sourcesContent":["import type { RawSchema } from './RawSchema'\nimport type { RawSchemaEntity, RawSchemaFields } from './RawSchemaEntity'\nimport type { RawSchemaEnum } from './RawSchemaEnum'\nimport type { SchemaEntities } from './SchemaEntities'\nimport type { SchemaEnums } from './SchemaEnums'\nimport type { SchemaFields } from './SchemaFields'\nimport type { SchemaStore } from './SchemaStore'\n\nexport class SchemaPreprocessor {\n\tpublic static processRawSchema(rawSchema: RawSchema): SchemaStore {\n\t\treturn {\n\t\t\tenums: this.processRawEnums(rawSchema.enums),\n\t\t\tentities: this.processRawEntities(rawSchema.entities),\n\t\t}\n\t}\n\n\tprivate static processRawEnums(rawEnums: RawSchemaEnum[]): SchemaEnums {\n\t\tconst enums: SchemaEnums = new Map()\n\n\t\tfor (const { name, values } of rawEnums) {\n\t\t\tenums.set(name, new Set(values))\n\t\t}\n\n\t\treturn enums\n\t}\n\n\tprivate static processRawEntities(rawEntities: RawSchemaEntity[]): SchemaEntities {\n\t\tconst entities: SchemaEntities = new Map()\n\n\t\tfor (const entity of rawEntities) {\n\t\t\tentities.set(entity.name, {\n\t\t\t\tcustomPrimaryAllowed: entity.customPrimaryAllowed,\n\t\t\t\tfields: this.processRawFields(entity.fields),\n\t\t\t\tname: entity.name,\n\t\t\t\tunique: entity.unique,\n\t\t\t})\n\t\t}\n\n\t\treturn entities\n\t}\n\n\tprivate static processRawFields(rawFields: RawSchemaFields): SchemaFields {\n\t\tconst fields: SchemaFields = new Map()\n\n\t\tfor (const field of rawFields) {\n\t\t\tfields.set(field.name, field)\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":"yBAQgC;AAAA,SACjB,iBAAiB,WAAmC;WAC1D;AAAA,MACN,OAAO,KAAK,gBAAgB,UAAU;AAAA,MACtC,UAAU,KAAK,mBAAmB,UAAU;AAAA;AAAA;AAAA,SAI/B,gBAAgB,UAAwC;UAChE,4BAAyB;eAEpB,EAAE,MAAM,YAAY,UAAU;YAClC,IAAI,MAAM,IAAI,IAAI;AAAA;WAGlB;AAAA;AAAA,SAGO,mBAAmB,aAAgD;UAC3E,+BAA+B;eAE1B,UAAU,aAAa;eACxB,IAAI,OAAO,MAAM;AAAA,QACzB,sBAAsB,OAAO;AAAA,QAC7B,QAAQ,KAAK,iBAAiB,OAAO;AAAA,QACrC,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA;AAAA;WAIV;AAAA;AAAA,SAGO,iBAAiB,WAA0C;UACnE,6BAA2B;eAEtB,SAAS,WAAW;aACvB,IAAI,MAAM,MAAM;AAAA;WAGjB;AAAA;AAAA;;"}
|
|
@@ -100,14 +100,14 @@ class Environment {
|
|
|
100
100
|
return args;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
(
|
|
104
|
-
Environment2.systemVariableNames = new Set([
|
|
103
|
+
((Environment2) => {
|
|
104
|
+
Environment2.systemVariableNames = /* @__PURE__ */ new Set([
|
|
105
105
|
"labelMiddleware",
|
|
106
106
|
"rootWhere",
|
|
107
107
|
"rootWhereAsFilter",
|
|
108
108
|
"rootShouldExists"
|
|
109
109
|
]);
|
|
110
|
-
Environment2.reservedVariableNames = new Set([
|
|
110
|
+
Environment2.reservedVariableNames = /* @__PURE__ */ new Set([
|
|
111
111
|
...Environment2.systemVariableNames,
|
|
112
112
|
"dimensions"
|
|
113
113
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Filter, UniqueWhere } from '../treeParameters'\n\nclass Environment {\n\tprivate readonly names: Environment.NameStore\n\n\tpublic constructor(names: Environment.NameStore = Environment.defaultNameStore) {\n\t\tthis.names = {\n\t\t\t...Environment.defaultNameStore,\n\t\t\t...names,\n\t\t}\n\t}\n\n\tpublic static create(delta: Partial<Environment.NameStore> = {}) {\n\t\treturn new Environment({\n\t\t\t...Environment.defaultSystemVariables,\n\t\t\tdimensions: {},\n\t\t}).putDelta(delta)\n\t}\n\n\tpublic hasName(name: keyof Environment.NameStore): boolean {\n\t\treturn name in this.names\n\t}\n\n\tpublic hasDimension(dimensionName: keyof Environment.SelectedDimensions): boolean {\n\t\treturn dimensionName in this.names.dimensions\n\t}\n\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(\n\t\tname: keyof Environment.NameStore,\n\t\tfallback: F,\n\t): V | F {\n\t\tif (!this.hasName(name)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: keyof Environment.SelectedDimensions, fallback: F): string[] | F {\n\t\tif (!this.hasDimension(dimensionName)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getValue<V extends Environment.Value = Environment.Value>(name: keyof Environment.NameStore): V {\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimension(dimensionName: keyof Environment.SelectedDimensions): string[] {\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getAllNames(): Environment.NameStore {\n\t\treturn { ...this.names }\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn { ...this.names.dimensions }\n\t}\n\n\tpublic getSystemVariable<N extends Environment.SystemVariableName>(name: N): Environment.SystemVariables[N] {\n\t\treturn this.names[name]\n\t}\n\n\tpublic putName(name: Environment.Name, value: Environment.Value): Environment {\n\t\treturn new Environment({\n\t\t\t...this.names,\n\t\t\tdimensions: { ...this.names.dimensions },\n\t\t\t[name]: value,\n\t\t})\n\t}\n\n\tpublic putSystemVariable<N extends Environment.SystemVariableName>(\n\t\tname: N,\n\t\tvalue: Environment.SystemVariables[N],\n\t): Environment {\n\t\treturn this.putName(name, value)\n\t}\n\n\tpublic putDelta(delta: Partial<Environment.NameStore>): Environment {\n\t\tconst currentNames = this.getAllNames()\n\n\t\tfor (const newName in delta) {\n\t\t\tconst deltaValue = delta[newName]\n\t\t\tif (deltaValue === undefined) {\n\t\t\t\tdelete currentNames[newName]\n\t\t\t} else {\n\t\t\t\tcurrentNames[newName] = deltaValue\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment(currentNames)\n\t}\n\n\tpublic updateDimensionsIfNecessary(\n\t\tdimensions: Environment.NameStore['dimensions'],\n\t\tdefaultDimensions: Environment.NameStore['dimensions'],\n\t): Environment {\n\t\tconst normalizedDimensions: Environment.NameStore['dimensions'] = {\n\t\t\t...defaultDimensions,\n\t\t\t...dimensions,\n\t\t}\n\n\t\tconst dimensionsEqual = JSON.stringify(this.names.dimensions) === JSON.stringify(normalizedDimensions)\n\t\treturn dimensionsEqual\n\t\t\t? this\n\t\t\t: new Environment({\n\t\t\t\t\t...this.names,\n\t\t\t\t\tdimensions: { ...normalizedDimensions },\n\t\t\t })\n\t}\n\n\tpublic static generateDelta(\n\t\tcurrentEnvironment: Environment,\n\t\tdelta: Environment.DeltaFactory,\n\t): Partial<Environment.NameStore> {\n\t\tconst newDelta: Partial<Environment.NameStore> = {}\n\n\t\tfor (const name in delta) {\n\t\t\tconst value = delta[name]\n\n\t\t\tnewDelta[name] =\n\t\t\t\tvalue &&\n\t\t\t\tvalue instanceof Function &&\n\t\t\t\t!Environment.systemVariableNames.has(name as Environment.SystemVariableName)\n\t\t\t\t\t? value(currentEnvironment)\n\t\t\t\t\t: delta[name]\n\t\t}\n\n\t\treturn newDelta\n\t}\n\n\tpublic applySystemMiddleware<\n\t\tN extends Environment.SystemMiddlewareName,\n\t\tA extends Parameters<Exclude<Environment.SystemMiddleware[N], undefined>>,\n\t>(name: N, ...args: A): ReturnType<Exclude<Environment.SystemMiddleware[N], undefined>> | A {\n\t\tconst middleware: Environment.SystemMiddleware[N] = this.names[name]\n\t\tif (typeof middleware === 'function') {\n\t\t\treturn (middleware as (...args: A) => any)(...args)\n\t\t}\n\t\treturn args\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string | number\n\n\texport type Value = ReactNode\n\n\texport interface SystemVariables {\n\t\tlabelMiddleware?: (label: ReactNode) => ReactNode\n\t\trootWhere?: UniqueWhere\n\t\trootWhereAsFilter?: Filter\n\t\trootShouldExists?: 'no' | 'maybe' | 'yes'\n\t}\n\n\texport const systemVariableNames: Set<SystemVariableName> = new Set([\n\t\t'labelMiddleware',\n\t\t'rootWhere',\n\t\t'rootWhereAsFilter',\n\t\t'rootShouldExists',\n\t])\n\n\texport const reservedVariableNames: Set<string> = new Set([\n\t\t...systemVariableNames,\n\t\t'dimensions',\n\t])\n\n\texport type SystemVariableName = keyof SystemVariables\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport interface NameStore extends SystemVariables {\n\t\tdimensions: SelectedDimensions\n\n\t\t[name: string]: Value\n\t}\n\n\texport type DeltaFactory = { [N in string]: ((environment: Environment) => Environment.Value) | Environment.Value } &\n\t\t{ [N in keyof SystemVariables]?: SystemVariables[N] }\n\n\texport type SystemMiddleware = {\n\t\t[N in SystemMiddlewareName]: SystemVariables[N]\n\t}\n\n\texport type SystemMiddlewareName = 'labelMiddleware'\n\n\texport const defaultSystemVariables: SystemVariables = {\n\t\tlabelMiddleware: label => label,\n\t}\n\n\texport const defaultNameStore: NameStore = {\n\t\t...defaultSystemVariables,\n\t\tdimensions: {},\n\t}\n}\n\nexport { Environment }\n"],"names":[],"mappings":";;;;;;AAGA,kBAAkB;AAAA,EAGV,YAAY,QAA+B,YAAY,kBAAkB;AAF/D;SAGX,QAAQ;AAAA,SACT,YAAY;AAAA,SACZ;AAAA;AAAA;AAAA,SAIS,OAAO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K;AAAA;AAAA;AAAA,SAIP,cACb,oBACA,OACiC;UAC3B,WAA2C;eAEtC,QAAQ,OAAO;YACnB,QAAQ,MAAM;eAEX,QACR,SACA,iBAAiB,YACjB,CAAC,YAAY,oBAAoB,IAAI,QAClC,MAAM,sBACN,MAAM;AAAA;WAGJ;AAAA;AAAA,EAGD,sBAGL,SAAY,MAA8E;UACrF,aAA8C,KAAK,MAAM;QAC3D,OAAO,eAAe,YAAY;aAC7B,WAAmC,GAAG;AAAA;WAExC;AAAA;AAAA;AAIT,
|
|
1
|
+
{"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Filter, UniqueWhere } from '../treeParameters'\n\nclass Environment {\n\tprivate readonly names: Environment.NameStore\n\n\tpublic constructor(names: Environment.NameStore = Environment.defaultNameStore) {\n\t\tthis.names = {\n\t\t\t...Environment.defaultNameStore,\n\t\t\t...names,\n\t\t}\n\t}\n\n\tpublic static create(delta: Partial<Environment.NameStore> = {}) {\n\t\treturn new Environment({\n\t\t\t...Environment.defaultSystemVariables,\n\t\t\tdimensions: {},\n\t\t}).putDelta(delta)\n\t}\n\n\tpublic hasName(name: keyof Environment.NameStore): boolean {\n\t\treturn name in this.names\n\t}\n\n\tpublic hasDimension(dimensionName: keyof Environment.SelectedDimensions): boolean {\n\t\treturn dimensionName in this.names.dimensions\n\t}\n\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(\n\t\tname: keyof Environment.NameStore,\n\t\tfallback: F,\n\t): V | F {\n\t\tif (!this.hasName(name)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: keyof Environment.SelectedDimensions, fallback: F): string[] | F {\n\t\tif (!this.hasDimension(dimensionName)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getValue<V extends Environment.Value = Environment.Value>(name: keyof Environment.NameStore): V {\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimension(dimensionName: keyof Environment.SelectedDimensions): string[] {\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getAllNames(): Environment.NameStore {\n\t\treturn { ...this.names }\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn { ...this.names.dimensions }\n\t}\n\n\tpublic getSystemVariable<N extends Environment.SystemVariableName>(name: N): Environment.SystemVariables[N] {\n\t\treturn this.names[name]\n\t}\n\n\tpublic putName(name: Environment.Name, value: Environment.Value): Environment {\n\t\treturn new Environment({\n\t\t\t...this.names,\n\t\t\tdimensions: { ...this.names.dimensions },\n\t\t\t[name]: value,\n\t\t})\n\t}\n\n\tpublic putSystemVariable<N extends Environment.SystemVariableName>(\n\t\tname: N,\n\t\tvalue: Environment.SystemVariables[N],\n\t): Environment {\n\t\treturn this.putName(name, value)\n\t}\n\n\tpublic putDelta(delta: Partial<Environment.NameStore>): Environment {\n\t\tconst currentNames = this.getAllNames()\n\n\t\tfor (const newName in delta) {\n\t\t\tconst deltaValue = delta[newName]\n\t\t\tif (deltaValue === undefined) {\n\t\t\t\tdelete currentNames[newName]\n\t\t\t} else {\n\t\t\t\tcurrentNames[newName] = deltaValue\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment(currentNames)\n\t}\n\n\tpublic updateDimensionsIfNecessary(\n\t\tdimensions: Environment.NameStore['dimensions'],\n\t\tdefaultDimensions: Environment.NameStore['dimensions'],\n\t): Environment {\n\t\tconst normalizedDimensions: Environment.NameStore['dimensions'] = {\n\t\t\t...defaultDimensions,\n\t\t\t...dimensions,\n\t\t}\n\n\t\tconst dimensionsEqual = JSON.stringify(this.names.dimensions) === JSON.stringify(normalizedDimensions)\n\t\treturn dimensionsEqual\n\t\t\t? this\n\t\t\t: new Environment({\n\t\t\t\t\t...this.names,\n\t\t\t\t\tdimensions: { ...normalizedDimensions },\n\t\t\t })\n\t}\n\n\tpublic static generateDelta(\n\t\tcurrentEnvironment: Environment,\n\t\tdelta: Environment.DeltaFactory,\n\t): Partial<Environment.NameStore> {\n\t\tconst newDelta: Partial<Environment.NameStore> = {}\n\n\t\tfor (const name in delta) {\n\t\t\tconst value = delta[name]\n\n\t\t\tnewDelta[name] =\n\t\t\t\tvalue &&\n\t\t\t\tvalue instanceof Function &&\n\t\t\t\t!Environment.systemVariableNames.has(name as Environment.SystemVariableName)\n\t\t\t\t\t? value(currentEnvironment)\n\t\t\t\t\t: delta[name]\n\t\t}\n\n\t\treturn newDelta\n\t}\n\n\tpublic applySystemMiddleware<\n\t\tN extends Environment.SystemMiddlewareName,\n\t\tA extends Parameters<Exclude<Environment.SystemMiddleware[N], undefined>>,\n\t>(name: N, ...args: A): ReturnType<Exclude<Environment.SystemMiddleware[N], undefined>> | A {\n\t\tconst middleware: Environment.SystemMiddleware[N] = this.names[name]\n\t\tif (typeof middleware === 'function') {\n\t\t\treturn (middleware as (...args: A) => any)(...args)\n\t\t}\n\t\treturn args\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string | number\n\n\texport type Value = ReactNode\n\n\texport interface SystemVariables {\n\t\tlabelMiddleware?: (label: ReactNode) => ReactNode\n\t\trootWhere?: UniqueWhere\n\t\trootWhereAsFilter?: Filter\n\t\trootShouldExists?: 'no' | 'maybe' | 'yes'\n\t}\n\n\texport const systemVariableNames: Set<SystemVariableName> = new Set([\n\t\t'labelMiddleware',\n\t\t'rootWhere',\n\t\t'rootWhereAsFilter',\n\t\t'rootShouldExists',\n\t])\n\n\texport const reservedVariableNames: Set<string> = new Set([\n\t\t...systemVariableNames,\n\t\t'dimensions',\n\t])\n\n\texport type SystemVariableName = keyof SystemVariables\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport interface NameStore extends SystemVariables {\n\t\tdimensions: SelectedDimensions\n\n\t\t[name: string]: Value\n\t}\n\n\texport type DeltaFactory = { [N in string]: ((environment: Environment) => Environment.Value) | Environment.Value } &\n\t\t{ [N in keyof SystemVariables]?: SystemVariables[N] }\n\n\texport type SystemMiddleware = {\n\t\t[N in SystemMiddlewareName]: SystemVariables[N]\n\t}\n\n\texport type SystemMiddlewareName = 'labelMiddleware'\n\n\texport const defaultSystemVariables: SystemVariables = {\n\t\tlabelMiddleware: label => label,\n\t}\n\n\texport const defaultNameStore: NameStore = {\n\t\t...defaultSystemVariables,\n\t\tdimensions: {},\n\t}\n}\n\nexport { Environment }\n"],"names":[],"mappings":";;;;;;AAGA,kBAAkB;AAAA,EAGV,YAAY,QAA+B,YAAY,kBAAkB;AAF/D;SAGX,QAAQ;AAAA,SACT,YAAY;AAAA,SACZ;AAAA;AAAA;AAAA,SAIS,OAAO,QAAwC,IAAI;WACzD,IAAI,YAAY;AAAA,SACnB,YAAY;AAAA,MACf,YAAY;AAAA,OACV,SAAS;AAAA;AAAA,EAGN,QAAQ,MAA4C;WACnD,QAAQ,KAAK;AAAA;AAAA,EAGd,aAAa,eAA8D;WAC1E,iBAAiB,KAAK,MAAM;AAAA;AAAA,EAG7B,eACN,MACA,UACQ;QACJ,CAAC,KAAK,QAAQ,OAAO;aACjB;AAAA;WAED,KAAK,MAAM;AAAA;AAAA,EAGZ,mBAAsB,eAAqD,UAA2B;QACxG,CAAC,KAAK,aAAa,gBAAgB;aAC/B;AAAA;WAED,KAAK,MAAM,WAAW;AAAA;AAAA,EAGvB,SAA0D,MAAsC;WAC/F,KAAK,MAAM;AAAA;AAAA,EAGZ,aAAa,eAA+D;WAC3E,KAAK,MAAM,WAAW;AAAA;AAAA,EAGvB,cAAqC;WACpC,KAAK,KAAK;AAAA;AAAA,EAGX,mBAAmD;WAClD,KAAK,KAAK,MAAM;AAAA;AAAA,EAGjB,kBAA4D,MAAyC;WACpG,KAAK,MAAM;AAAA;AAAA,EAGZ,QAAQ,MAAwB,OAAuC;WACtE,IAAI,YAAY;AAAA,SACnB,KAAK;AAAA,MACR,YAAY,KAAK,KAAK,MAAM;AAAA,OAC3B,OAAO;AAAA;AAAA;AAAA,EAIH,kBACN,MACA,OACc;WACP,KAAK,QAAQ,MAAM;AAAA;AAAA,EAGpB,SAAS,OAAoD;UAC7D,eAAe,KAAK;eAEf,WAAW,OAAO;YACtB,aAAa,MAAM;UACrB,eAAe,QAAW;eACtB,aAAa;AAAA,aACd;qBACO,WAAW;AAAA;AAAA;WAInB,IAAI,YAAY;AAAA;AAAA,EAGjB,4BACN,YACA,mBACc;UACR,uBAA4D;AAAA,SAC9D;AAAA,SACA;AAAA;UAGE,kBAAkB,KAAK,UAAU,KAAK,MAAM,gBAAgB,KAAK,UAAU;WAC1E,kBACJ,OACA,IAAI,YAAY;AAAA,SACb,KAAK;AAAA,MACR,YAAY,KAAK;AAAA;AAAA;AAAA,SAIP,cACb,oBACA,OACiC;UAC3B,WAA2C;eAEtC,QAAQ,OAAO;YACnB,QAAQ,MAAM;eAEX,QACR,SACA,iBAAiB,YACjB,CAAC,YAAY,oBAAoB,IAAI,QAClC,MAAM,sBACN,MAAM;AAAA;WAGJ;AAAA;AAAA,EAGD,sBAGL,SAAY,MAA8E;UACrF,aAA8C,KAAK,MAAM;QAC3D,OAAO,eAAe,YAAY;aAC7B,WAAmC,GAAG;AAAA;WAExC;AAAA;AAAA;AAIT,EAAU,iBAAV;AAYc,yDAAmD,IAAI;AAAA,IACnE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGY,2DAAyC,IAAI;AAAA,IACzD,GAAG;IACH;AAAA;AAwBY,wCAA0C;AAAA,IACtD,iBAAiB,WAAS;AAAA;AAGd,kCAA8B;AAAA,OACvC;IACH,YAAY;AAAA;AAAA,GAnDJ;;"}
|
|
@@ -4,7 +4,7 @@ class TemporalFieldHelper extends FieldHelper {
|
|
|
4
4
|
this.getAccessor().updateValue(new Date().toISOString(), options);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
(
|
|
7
|
+
((TemporalFieldHelper2) => {
|
|
8
8
|
TemporalFieldHelper2.setToNow = (field, options) => {
|
|
9
9
|
new TemporalFieldHelper2(field).setToNow(options);
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t//public setToDate() TODO\n\t//public setToTime() TODO\n\t//public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":[],"mappings":";AAGA,kCAAkC,YAAoB;AAAA,EAC9C,SAAS,SAAuC;SACjD,cAAc,YAAY,IAAI,OAAO,eAAe;AAAA;AAAA;AAO3D,
|
|
1
|
+
{"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t//public setToDate() TODO\n\t//public setToTime() TODO\n\t//public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":[],"mappings":";AAGA,kCAAkC,YAAoB;AAAA,EAC9C,SAAS,SAAuC;SACjD,cAAc,YAAY,IAAI,OAAO,eAAe;AAAA;AAAA;AAO3D,EAAU,yBAAV;AACc,kCAAW,CACvB,OACA,YACI;QACA,qBAAoB,OAAO,SAAS;AAAA;AAAA,GALhC;;"}
|
|
@@ -5,7 +5,7 @@ class UuidFieldHelper extends FieldHelper {
|
|
|
5
5
|
this.getAccessor().updateValue(v4(), options);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
(
|
|
8
|
+
((UuidFieldHelper2) => {
|
|
9
9
|
UuidFieldHelper2.setToUuid = (field, options) => {
|
|
10
10
|
new UuidFieldHelper2(field).setToUuid(options);
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UuidFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["uuidV4"],"mappings":";;AAIA,8BAA8B,YAAoB;AAAA,EAC1C,UAAU,SAAuC;SAClD,cAAc,YAAYA,MAAU;AAAA;AAAA;AAG3C,
|
|
1
|
+
{"version":3,"file":"UuidFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["uuidV4"],"mappings":";;AAIA,8BAA8B,YAAoB;AAAA,EAC1C,UAAU,SAAuC;SAClD,cAAc,YAAYA,MAAU;AAAA;AAAA;AAG3C,EAAU,qBAAV;AACc,+BAAY,CACxB,OACA,YACI;QACA,iBAAgB,OAAO,UAAU;AAAA;AAAA,GAL7B;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export { ClientGeneratedUuid, ServerGeneratedUuid, UnpersistedEntityDummyId } fr
|
|
|
48
48
|
export { useDataBinding } from "./accessorTree/useDataBinding.js";
|
|
49
49
|
export { useDirtinessState } from "./accessorTree/useDirtinessState.js";
|
|
50
50
|
export { useMutationState } from "./accessorTree/useMutationState.js";
|
|
51
|
-
export { DataBinding } from "./core/DataBinding.js";
|
|
51
|
+
export { DataBinding, DataBindingExtendAborted } from "./core/DataBinding.js";
|
|
52
52
|
export { MarkerMerger } from "./core/MarkerMerger.js";
|
|
53
53
|
export { MarkerTreeGenerator } from "./core/MarkerTreeGenerator.js";
|
|
54
54
|
export { TreeParameterMerger } from "./core/TreeParameterMerger.js";
|
|
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import { LRUCache } from "../structures/LRUCache.js";
|
|
8
8
|
class CacheStore {
|
|
9
9
|
constructor() {
|
|
10
|
-
__publicField(this, "cacheStore", new WeakMap());
|
|
10
|
+
__publicField(this, "cacheStore", /* @__PURE__ */ new WeakMap());
|
|
11
11
|
}
|
|
12
12
|
get(environment, entry, expression) {
|
|
13
13
|
let caches = this.cacheStore.get(environment);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheStore.js","sources":["../../../src/queryLanguage/CacheStore.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport { LRUCache } from '../structures'\nimport type { Parser } from './Parser'\n\ntype CacheByEntryPoint = {\n\t[Entry in Parser.EntryPoint]: LRUCache<string, Parser.ParserResult[Entry]>\n}\n\nexport class CacheStore {\n\tprivate cacheStore: WeakMap<Environment, CacheByEntryPoint> = new WeakMap()\n\n\tpublic get<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t): Parser.ParserResult[Entry] | undefined {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\treturn caches[entry].get(expression) as Parser.ParserResult[Entry] | undefined\n\t}\n\n\tpublic set<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t\tvalue: Parser.ParserResult[Entry],\n\t) {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\t(caches[entry] as LRUCache<string, Parser.ParserResult[Entry]>).set(expression, value)\n\t}\n\n\tprivate createEntryPointCache(): CacheByEntryPoint {\n\t\t// TODO configurable limits\n\t\treturn {\n\t\t\tqualifiedEntityList: new LRUCache(50),\n\t\t\tqualifiedFieldList: new LRUCache(50),\n\t\t\tqualifiedSingleEntity: new LRUCache(50),\n\t\t\tunconstrainedQualifiedEntityList: new LRUCache(10),\n\t\t\tunconstrainedQualifiedSingleEntity: new LRUCache(10),\n\t\t\trelativeSingleField: new LRUCache(1000),\n\t\t\trelativeSingleEntity: new LRUCache(500),\n\t\t\trelativeEntityList: new LRUCache(500),\n\t\t\tuniqueWhere: new LRUCache(100),\n\t\t\tfilter: new LRUCache(100),\n\t\t\torderBy: new LRUCache(50),\n\t\t\ttaggedMap: new LRUCache(50),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;iBAQwB;AAAA;AACf,
|
|
1
|
+
{"version":3,"file":"CacheStore.js","sources":["../../../src/queryLanguage/CacheStore.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport { LRUCache } from '../structures'\nimport type { Parser } from './Parser'\n\ntype CacheByEntryPoint = {\n\t[Entry in Parser.EntryPoint]: LRUCache<string, Parser.ParserResult[Entry]>\n}\n\nexport class CacheStore {\n\tprivate cacheStore: WeakMap<Environment, CacheByEntryPoint> = new WeakMap()\n\n\tpublic get<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t): Parser.ParserResult[Entry] | undefined {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\treturn caches[entry].get(expression) as Parser.ParserResult[Entry] | undefined\n\t}\n\n\tpublic set<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t\tvalue: Parser.ParserResult[Entry],\n\t) {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\t(caches[entry] as LRUCache<string, Parser.ParserResult[Entry]>).set(expression, value)\n\t}\n\n\tprivate createEntryPointCache(): CacheByEntryPoint {\n\t\t// TODO configurable limits\n\t\treturn {\n\t\t\tqualifiedEntityList: new LRUCache(50),\n\t\t\tqualifiedFieldList: new LRUCache(50),\n\t\t\tqualifiedSingleEntity: new LRUCache(50),\n\t\t\tunconstrainedQualifiedEntityList: new LRUCache(10),\n\t\t\tunconstrainedQualifiedSingleEntity: new LRUCache(10),\n\t\t\trelativeSingleField: new LRUCache(1000),\n\t\t\trelativeSingleEntity: new LRUCache(500),\n\t\t\trelativeEntityList: new LRUCache(500),\n\t\t\tuniqueWhere: new LRUCache(100),\n\t\t\tfilter: new LRUCache(100),\n\t\t\torderBy: new LRUCache(50),\n\t\t\ttaggedMap: new LRUCache(50),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;iBAQwB;AAAA;AACf,0DAA0D;AAAA;AAAA,EAE3D,IACN,aACA,OACA,YACyC;QACrC,SAAS,KAAK,WAAW,IAAI;QAE7B,WAAW,QAAW;WACpB,WAAW,IAAI,aAAc,SAAS,KAAK;AAAA;WAE1C,OAAO,OAAO,IAAI;AAAA;AAAA,EAGnB,IACN,aACA,OACA,YACA,OACC;QACG,SAAS,KAAK,WAAW,IAAI;QAE7B,WAAW,QAAW;WACpB,WAAW,IAAI,aAAc,SAAS,KAAK;AAAA;AAEhD,WAAO,OAAwD,IAAI,YAAY;AAAA;AAAA,EAGzE,wBAA2C;WAE3C;AAAA,MACN,qBAAqB,IAAI,SAAS;AAAA,MAClC,oBAAoB,IAAI,SAAS;AAAA,MACjC,uBAAuB,IAAI,SAAS;AAAA,MACpC,kCAAkC,IAAI,SAAS;AAAA,MAC/C,oCAAoC,IAAI,SAAS;AAAA,MACjD,qBAAqB,IAAI,SAAS;AAAA,MAClC,sBAAsB,IAAI,SAAS;AAAA,MACnC,oBAAoB,IAAI,SAAS;AAAA,MACjC,aAAa,IAAI,SAAS;AAAA,MAC1B,QAAQ,IAAI,SAAS;AAAA,MACrB,SAAS,IAAI,SAAS;AAAA,MACtB,WAAW,IAAI,SAAS;AAAA;AAAA;AAAA;;"}
|