@contember/binding 1.0.0-rc.2 → 1.0.0-rc.22
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":"MarkerTreeGenerator.js","sources":["../../../src/core/MarkerTreeGenerator.ts"],"sourcesContent":["import { BranchNode, ChildrenAnalyzer, Leaf, RawNodeRepresentation } from '@contember/react-multipass-rendering'\nimport type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport { Environment } from '../dao'\nimport {\n\tEntityFieldMarkersContainer,\n\tEntityFieldsWithHoistablesMarker,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport type { Alias } from '../treeParameters'\nimport { IncrementalMarkerBuilder } from './IncrementalMarkerBuilder'\n\ntype Fragment = EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker\ntype Terminals = FieldMarker | HasOneRelationMarker | Fragment\ntype Nonterminals = HasOneRelationMarker | HasManyRelationMarker | Fragment\n\nexport class MarkerTreeGenerator {\n\tprivate static childrenAnalyzer = MarkerTreeGenerator.initializeChildrenAnalyzer()\n\n\tpublic constructor(private sourceTree: ReactNode, private environment: Environment = Environment.create()) {}\n\n\tpublic generate(): MarkerTreeRoot {\n\t\tconst processed = MarkerTreeGenerator.childrenAnalyzer.processChildren(this.sourceTree, this.environment)\n\n\t\tif (processed.length === 0) {\n\t\t\treturn new MarkerTreeRoot(new Map(), new Map())\n\t\t}\n\n\t\tconst collectedMarkers = MarkerTreeGenerator.mapNodeResultToEntityFields(processed)\n\n\t\tif (collectedMarkers instanceof EntityFieldMarkersContainer) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.fields.markers.size) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.parentReference !== undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.subTrees === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\n\t\tconst subTrees = collectedMarkers.subTrees\n\n\t\treturn new MarkerTreeRoot(subTrees, this.generatePlaceholdersByAliases(subTrees))\n\t}\n\n\tprivate generatePlaceholdersByAliases(\n\t\thoistedSubTrees: Map<string, EntitySubTreeMarker | EntityListSubTreeMarker>,\n\t): Map<Alias, string> {\n\t\tconst placeholders = new Map<Alias, string>()\n\n\t\tfor (const [placeholderName, subTree] of hoistedSubTrees) {\n\t\t\tconst aliases = subTree.parameters.alias\n\t\t\tif (aliases === undefined || aliases.size === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tconst existingPlaceholder = placeholders.get(alias)\n\t\t\t\tif (existingPlaceholder !== undefined) {\n\t\t\t\t\tif (existingPlaceholder === placeholderName) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Detected the same sub-tree alias '${alias}' referring to sub-trees with different parameters!`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tplaceholders.set(alias, placeholderName)\n\t\t\t}\n\t\t}\n\n\t\treturn placeholders\n\t}\n\n\tprivate static mapNodeResultToEntityFields(\n\t\tresult: RawNodeRepresentation<Terminals, Nonterminals>,\n\t): EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer {\n\t\tconst builder = new IncrementalMarkerBuilder()\n\n\t\tif (!result) {\n\t\t\treturn builder.getFinalMarker()\n\t\t}\n\n\t\tif (!Array.isArray(result)) {\n\t\t\tbuilder.mutateIn(result)\n\t\t\treturn builder.getFinalMarker()\n\t\t}\n\n\t\tfor (const marker of result) {\n\t\t\tbuilder.mutateIn(marker)\n\t\t}\n\n\t\treturn builder.getFinalMarker()\n\t}\n\n\tprivate static initializeChildrenAnalyzer(): ChildrenAnalyzer<Terminals, Nonterminals, Environment> {\n\t\tconst fieldMarkerLeaf = new Leaf<any, Environment>('generateLeafMarker')\n\n\t\tconst branchMarkerBranchNode = new BranchNode<any, Environment>(\n\t\t\t'generateBranchMarker',\n\t\t\tthis.mapNodeResultToEntityFields,\n\t\t\t{ childrenAreOptional: true },\n\t\t)\n\n\t\treturn new ChildrenAnalyzer([fieldMarkerLeaf], [branchMarkerBranchNode], {\n\t\t\tstaticRenderFactoryName: 'staticRender',\n\t\t\trenderPropsErrorMessage:\n\t\t\t\t`Render props (functions as React component children) are not supported within the schema. ` +\n\t\t\t\t`You have likely used a bare custom component as opposed to wrapping in with \\`Component\\` ` +\n\t\t\t\t`from the \\`@contember/admin\\` package. Please refer to the documentation.`,\n\t\t\tignoreRenderProps: false,\n\t\t\tstaticContextFactoryName: 'generateEnvironment',\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;mCAqBiC;AAAA,EAGzB,YAAoB,YAA+B,cAA2B,YAAY,UAAU;;;;EAEpG,WAA2B;UAC3B,YAAY,qBAAoB,iBAAiB,gBAAgB,KAAK,YAAY,KAAK;QAEzF,UAAU,WAAW,GAAG;aACpB,IAAI,
|
|
1
|
+
{"version":3,"file":"MarkerTreeGenerator.js","sources":["../../../src/core/MarkerTreeGenerator.ts"],"sourcesContent":["import { BranchNode, ChildrenAnalyzer, Leaf, RawNodeRepresentation } from '@contember/react-multipass-rendering'\nimport type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport { Environment } from '../dao'\nimport {\n\tEntityFieldMarkersContainer,\n\tEntityFieldsWithHoistablesMarker,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport type { Alias } from '../treeParameters'\nimport { IncrementalMarkerBuilder } from './IncrementalMarkerBuilder'\n\ntype Fragment = EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker\ntype Terminals = FieldMarker | HasOneRelationMarker | Fragment\ntype Nonterminals = HasOneRelationMarker | HasManyRelationMarker | Fragment\n\nexport class MarkerTreeGenerator {\n\tprivate static childrenAnalyzer = MarkerTreeGenerator.initializeChildrenAnalyzer()\n\n\tpublic constructor(private sourceTree: ReactNode, private environment: Environment = Environment.create()) {}\n\n\tpublic generate(): MarkerTreeRoot {\n\t\tconst processed = MarkerTreeGenerator.childrenAnalyzer.processChildren(this.sourceTree, this.environment)\n\n\t\tif (processed.length === 0) {\n\t\t\treturn new MarkerTreeRoot(new Map(), new Map())\n\t\t}\n\n\t\tconst collectedMarkers = MarkerTreeGenerator.mapNodeResultToEntityFields(processed)\n\n\t\tif (collectedMarkers instanceof EntityFieldMarkersContainer) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.fields.markers.size) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.parentReference !== undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tif (collectedMarkers.subTrees === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\n\t\tconst subTrees = collectedMarkers.subTrees\n\n\t\treturn new MarkerTreeRoot(subTrees, this.generatePlaceholdersByAliases(subTrees))\n\t}\n\n\tprivate generatePlaceholdersByAliases(\n\t\thoistedSubTrees: Map<string, EntitySubTreeMarker | EntityListSubTreeMarker>,\n\t): Map<Alias, string> {\n\t\tconst placeholders = new Map<Alias, string>()\n\n\t\tfor (const [placeholderName, subTree] of hoistedSubTrees) {\n\t\t\tconst aliases = subTree.parameters.alias\n\t\t\tif (aliases === undefined || aliases.size === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tconst existingPlaceholder = placeholders.get(alias)\n\t\t\t\tif (existingPlaceholder !== undefined) {\n\t\t\t\t\tif (existingPlaceholder === placeholderName) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Detected the same sub-tree alias '${alias}' referring to sub-trees with different parameters!`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tplaceholders.set(alias, placeholderName)\n\t\t\t}\n\t\t}\n\n\t\treturn placeholders\n\t}\n\n\tprivate static mapNodeResultToEntityFields(\n\t\tresult: RawNodeRepresentation<Terminals, Nonterminals>,\n\t): EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer {\n\t\tconst builder = new IncrementalMarkerBuilder()\n\n\t\tif (!result) {\n\t\t\treturn builder.getFinalMarker()\n\t\t}\n\n\t\tif (!Array.isArray(result)) {\n\t\t\tbuilder.mutateIn(result)\n\t\t\treturn builder.getFinalMarker()\n\t\t}\n\n\t\tfor (const marker of result) {\n\t\t\tbuilder.mutateIn(marker)\n\t\t}\n\n\t\treturn builder.getFinalMarker()\n\t}\n\n\tprivate static initializeChildrenAnalyzer(): ChildrenAnalyzer<Terminals, Nonterminals, Environment> {\n\t\tconst fieldMarkerLeaf = new Leaf<any, Environment>('generateLeafMarker')\n\n\t\tconst branchMarkerBranchNode = new BranchNode<any, Environment>(\n\t\t\t'generateBranchMarker',\n\t\t\tthis.mapNodeResultToEntityFields,\n\t\t\t{ childrenAreOptional: true },\n\t\t)\n\n\t\treturn new ChildrenAnalyzer([fieldMarkerLeaf], [branchMarkerBranchNode], {\n\t\t\tstaticRenderFactoryName: 'staticRender',\n\t\t\trenderPropsErrorMessage:\n\t\t\t\t`Render props (functions as React component children) are not supported within the schema. ` +\n\t\t\t\t`You have likely used a bare custom component as opposed to wrapping in with \\`Component\\` ` +\n\t\t\t\t`from the \\`@contember/admin\\` package. Please refer to the documentation.`,\n\t\t\tignoreRenderProps: false,\n\t\t\tstaticContextFactoryName: 'generateEnvironment',\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;mCAqBiC;AAAA,EAGzB,YAAoB,YAA+B,cAA2B,YAAY,UAAU;;;;EAEpG,WAA2B;UAC3B,YAAY,qBAAoB,iBAAiB,gBAAgB,KAAK,YAAY,KAAK;QAEzF,UAAU,WAAW,GAAG;aACpB,IAAI,mCAAmB,2BAAW;AAAA;UAGpC,mBAAmB,qBAAoB,4BAA4B;QAErE,4BAA4B,6BAA6B;YACtD,IAAI;AAAA;QAEP,iBAAiB,OAAO,QAAQ,MAAM;YACnC,IAAI;AAAA;QAEP,iBAAiB,oBAAoB,QAAW;YAC7C,IAAI;AAAA;QAEP,iBAAiB,aAAa,QAAW;YACtC,IAAI;AAAA;UAGL,WAAW,iBAAiB;WAE3B,IAAI,eAAe,UAAU,KAAK,8BAA8B;AAAA;AAAA,EAGhE,8BACP,iBACqB;UACf,mCAAmB;eAEd,CAAC,iBAAiB,YAAY,iBAAiB;YACnD,UAAU,QAAQ,WAAW;UAC/B,YAAY,UAAa,QAAQ,SAAS,GAAG;;;iBAGtC,SAAS,SAAS;cACtB,sBAAsB,aAAa,IAAI;YACzC,wBAAwB,QAAW;cAClC,wBAAwB,iBAAiB;;;gBAGvC,IAAI,aACT,qCAAqC;AAAA;qBAG1B,IAAI,OAAO;AAAA;AAAA;WAInB;AAAA;AAAA,SAGO,4BACd,QACiE;UAC3D,UAAU,IAAI;QAEhB,CAAC,QAAQ;aACL,QAAQ;AAAA;QAGZ,CAAC,MAAM,QAAQ,SAAS;cACnB,SAAS;aACV,QAAQ;AAAA;eAGL,UAAU,QAAQ;cACpB,SAAS;AAAA;WAGX,QAAQ;AAAA;AAAA,SAGD,6BAAqF;UAC7F,kBAAkB,IAAI,KAAuB;UAE7C,yBAAyB,IAAI,WAClC,wBACA,KAAK,6BACL,EAAE,qBAAqB;WAGjB,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,yBAAyB;AAAA,MACxE,yBAAyB;AAAA,MACzB,yBACC;AAAA,MAGD,mBAAmB;AAAA,MACnB,0BAA0B;AAAA;AAAA;AAAA;;AA/Fb,mCAAA,oBAAmB,qBAAoB;;"}
|
|
@@ -18,7 +18,7 @@ class MutationGenerator {
|
|
|
18
18
|
getPersistMutation() {
|
|
19
19
|
try {
|
|
20
20
|
let builder = new CrudQueryBuilder.CrudQueryBuilder();
|
|
21
|
-
const processedPlaceholdersByEntity = new Map();
|
|
21
|
+
const processedPlaceholdersByEntity = /* @__PURE__ */ new Map();
|
|
22
22
|
for (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot) {
|
|
23
23
|
for (const [placeholderName, subTreeState] of rootStates) {
|
|
24
24
|
if (subTreeState.type === "entityRealm") {
|
|
@@ -127,7 +127,7 @@ class MutationGenerator {
|
|
|
127
127
|
registerCreateMutationPart(processedPlaceholdersByEntity, currentState, builder = new CrudQueryBuilder.WriteDataBuilder()) {
|
|
128
128
|
let processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity);
|
|
129
129
|
if (processedPlaceholders === void 0) {
|
|
130
|
-
processedPlaceholdersByEntity.set(currentState.entity, processedPlaceholders = new Set());
|
|
130
|
+
processedPlaceholdersByEntity.set(currentState.entity, processedPlaceholders = /* @__PURE__ */ new Set());
|
|
131
131
|
}
|
|
132
132
|
if (currentState.type === "entityRealmStub") {
|
|
133
133
|
return builder;
|
|
@@ -276,7 +276,7 @@ class MutationGenerator {
|
|
|
276
276
|
registerUpdateMutationPart(processedPlaceholdersByEntity, currentState, builder) {
|
|
277
277
|
let processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity);
|
|
278
278
|
if (processedPlaceholders === void 0) {
|
|
279
|
-
processedPlaceholdersByEntity.set(currentState.entity, processedPlaceholders = new Set());
|
|
279
|
+
processedPlaceholdersByEntity.set(currentState.entity, processedPlaceholders = /* @__PURE__ */ new Set());
|
|
280
280
|
}
|
|
281
281
|
const pathBack = this.treeStore.getPathBackToParent(currentState);
|
|
282
282
|
const entityData = this.treeStore.persistedEntityData.get(currentState.entity.id.value);
|
|
@@ -384,7 +384,7 @@ class MutationGenerator {
|
|
|
384
384
|
if (pathBack?.fieldBackToParent === marker.parameters.field) {
|
|
385
385
|
continue;
|
|
386
386
|
}
|
|
387
|
-
const persistedEntityIds = entityData?.get?.(placeholderName) ?? new Set();
|
|
387
|
+
const persistedEntityIds = entityData?.get?.(placeholderName) ?? /* @__PURE__ */ new Set();
|
|
388
388
|
if (!(persistedEntityIds instanceof Set)) {
|
|
389
389
|
continue;
|
|
390
390
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationGenerator.js","sources":["../../../src/core/MutationGenerator.ts"],"sourcesContent":["// noinspection JSVoidFunctionReturnValueUsed // IntelliJ seems to be super confused througouht this file.\n\nimport { CrudQueryBuilder, GraphQlBuilder } from '@contember/client'\nimport { ClientGeneratedUuid, ServerGeneratedUuid } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME, TYPENAME_KEY_NAME } from '../bindingTypes'\nimport { FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../markers'\nimport type { EntityId, EntityName, FieldValue, PlaceholderName, TreeRootId } from '../treeParameters'\nimport { assertNever, isEmptyObject } from '../utils'\nimport { QueryGenerator } from './QueryGenerator'\nimport { MutationAlias, mutationOperationSubTreeType, mutationOperationType } from './requestAliases'\nimport {\n\tEntityListState,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n} from './state'\nimport type { TreeStore } from './TreeStore'\n\ntype QueryBuilder = Omit<CrudQueryBuilder.CrudQueryBuilder, CrudQueryBuilder.Queries>\n\ntype ProcessedPlaceholdersByEntity = Map<EntityState, Set<PlaceholderName>>\n\n// TODO enforce correct expected mutations in dev mode.\nexport class MutationGenerator {\n\tpublic constructor(private readonly treeStore: TreeStore) {}\n\n\tpublic getPersistMutation(): string | undefined {\n\t\ttry {\n\t\t\tlet builder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder()\n\t\t\tconst processedPlaceholdersByEntity: ProcessedPlaceholdersByEntity = new Map()\n\n\t\t\tfor (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot) {\n\t\t\t\tfor (const [placeholderName, subTreeState] of rootStates) {\n\t\t\t\t\tif (subTreeState.type === 'entityRealm') {\n\t\t\t\t\t\tbuilder = this.addSubMutation(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\tmutationOperationSubTreeType.singleEntity,\n\t\t\t\t\t\t\tsubTreeState.entity.id.value,\n\t\t\t\t\t\t\tsubTreeState,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else if (subTreeState.type === 'entityList') {\n\t\t\t\t\t\tfor (const childState of subTreeState.children.values()) {\n\t\t\t\t\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t// TODO there can be a forceCreate somewhere in there that we're hereby ignoring.\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbuilder = this.addSubMutation(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\tmutationOperationSubTreeType.entityList,\n\t\t\t\t\t\t\t\tchildState.entity.id.value,\n\t\t\t\t\t\t\t\tchildState,\n\t\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\tfor (const [removedId, removalType] of subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\t\tif (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\t\tbuilder = this.addDeleteMutation(\n\t\t\t\t\t\t\t\t\t\tsubTreeState.entityName,\n\t\t\t\t\t\t\t\t\t\tremovedId,\n\t\t\t\t\t\t\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\t\t\t\t\tsubTreePlaceholder: placeholderName,\n\t\t\t\t\t\t\t\t\t\t\ttype: mutationOperationType.delete,\n\t\t\t\t\t\t\t\t\t\t\tsubTreeType: mutationOperationSubTreeType.entityList,\n\t\t\t\t\t\t\t\t\t\t\tentityId: removedId,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassertNever(subTreeState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn builder.inTransaction(undefined, { deferForeignKeyConstraints: true }).getGql()\n\t\t} catch (e) {\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\tprivate addSubMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\ttreeRootId: TreeRootId | undefined,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType],\n\t\tentityId: EntityId,\n\t\trealmState: EntityRealmState,\n\t\tqueryBuilder: QueryBuilder,\n\t): QueryBuilder {\n\t\tif (realmState.unpersistedChangesCount === 0) {\n\t\t\t// Bail out early\n\t\t\treturn queryBuilder\n\t\t}\n\t\tif (realmState.entity.isScheduledForDeletion) {\n\t\t\treturn this.addDeleteMutation(\n\t\t\t\trealmState.entity.entityName,\n\t\t\t\tentityId,\n\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\ttreeRootId,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\ttype: mutationOperationType.delete,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\tentityId,\n\t\t\t\t}),\n\t\t\t\tqueryBuilder,\n\t\t\t)\n\t\t} else if (!realmState.entity.id.existsOnServer) {\n\t\t\treturn this.addCreateMutation(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\trealmState,\n\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\ttreeRootId,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\ttype: mutationOperationType.create,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\tentityId,\n\t\t\t\t}),\n\t\t\t\tthis.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState),\n\t\t\t\tqueryBuilder,\n\t\t\t)\n\t\t}\n\t\treturn this.addUpdateMutation(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\trealmState,\n\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\ttreeRootId,\n\t\t\t\tsubTreePlaceholder,\n\t\t\t\ttype: mutationOperationType.update,\n\t\t\t\tsubTreeType,\n\t\t\t\tentityId,\n\t\t\t}),\n\t\t\tthis.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState),\n\t\t\tqueryBuilder,\n\t\t)\n\t}\n\n\tprivate getNodeFragmentName(\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType],\n\t\trealmState: EntityRealmState,\n\t): string | undefined {\n\t\tif (subTreeType !== mutationOperationSubTreeType.entityList) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn `${realmState.entity.entityName}_${subTreePlaceholder}`\n\t}\n\n\tprivate addDeleteMutation(\n\t\tentityName: EntityName,\n\t\tdeletedId: EntityId,\n\t\talias: string,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\treturn queryBuilder.delete(\n\t\t\tentityName,\n\t\t\tbuilder =>\n\t\t\t\tbuilder\n\t\t\t\t\t.ok()\n\t\t\t\t\t.node(builder => builder.column(PRIMARY_KEY_NAME))\n\t\t\t\t\t.by({ [PRIMARY_KEY_NAME]: deletedId })\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage(),\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate addUpdateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\talias: string,\n\t\tnodeFragmentName: string | undefined,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\tconst updateBuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update> =\n\t\t\tthis.registerUpdateMutationPart(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\tentityRealm,\n\t\t\t\tnew CrudQueryBuilder.WriteDataBuilder(),\n\t\t\t)\n\t\tif (updateBuilder.data === undefined || isEmptyObject(updateBuilder.data)) {\n\t\t\treturn queryBuilder\n\t\t}\n\n\t\tconst runtimeId = entityRealm.entity.id\n\n\t\tif (!runtimeId.existsOnServer) {\n\t\t\treturn queryBuilder\n\t\t}\n\n\t\tconst readBuilder = QueryGenerator.registerQueryPart(\n\t\t\tgetEntityMarker(entityRealm).fields.markers,\n\t\t\tCrudQueryBuilder.ReadBuilder.instantiate(),\n\t\t)\n\n\t\tif (nodeFragmentName) {\n\t\t\tqueryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder)\n\t\t}\n\n\t\treturn queryBuilder.update(\n\t\t\tentityRealm.entity.entityName,\n\t\t\tbuilder =>\n\t\t\t\tbuilder\n\t\t\t\t\t.node(nodeFragmentName ? builder => builder.applyFragment(nodeFragmentName) : readBuilder)\n\t\t\t\t\t.data(updateBuilder)\n\t\t\t\t\t.by({ [PRIMARY_KEY_NAME]: runtimeId.value })\n\t\t\t\t\t.ok()\n\t\t\t\t\t.validation()\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage(),\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate addCreateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\talias: string,\n\t\tnodeFragmentName: string | undefined,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\tconst createBuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> =\n\t\t\tthis.registerCreateMutationPart(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\tentityRealm,\n\t\t\t\tnew CrudQueryBuilder.WriteDataBuilder(),\n\t\t\t)\n\t\tif (createBuilder.data === undefined || isEmptyObject(createBuilder.data)) {\n\t\t\treturn queryBuilder\n\t\t}\n\t\tconst readBuilder = QueryGenerator.registerQueryPart(\n\t\t\tgetEntityMarker(entityRealm).fields.markers,\n\t\t\tCrudQueryBuilder.ReadBuilder.instantiate(),\n\t\t)\n\t\tif (nodeFragmentName) {\n\t\t\tqueryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder)\n\t\t}\n\n\t\treturn queryBuilder.create(\n\t\t\tentityRealm.entity.entityName,\n\t\t\tbuilder => {\n\t\t\t\t// if (where && writeBuilder.data !== undefined && !isEmptyObject(writeBuilder.data)) {\n\t\t\t\t// \t// Shallow cloning the parameters like this IS too naïve but it will likely last surprisingly long before we\n\t\t\t\t// \t// run into issues.\n\t\t\t\t// \twriteBuilder = new CrudQueryBuilder.WriteDataBuilder({ ...writeBuilder.data, ...where })\n\t\t\t\t// }\n\t\t\t\treturn builder\n\t\t\t\t\t.node(nodeFragmentName ? builder => builder.applyFragment(nodeFragmentName) : readBuilder)\n\t\t\t\t\t.data(createBuilder)\n\t\t\t\t\t.ok()\n\t\t\t\t\t.validation()\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage()\n\t\t\t},\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate registerCreateMutationPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> = new CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>(),\n\t): CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tif (currentState.type === 'entityRealmStub') {\n\t\t\t// TODO If there's a forceCreate, this is wrong.\n\t\t\treturn builder\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\n\t\tconst nonbearingFields: Array<\n\t\t\t| { type: 'field'; marker: FieldMarker; fieldState: FieldState }\n\t\t\t| { type: 'hasOne'; marker: HasOneRelationMarker; fieldState: EntityRealmState | EntityRealmStateStub }\n\t\t\t| { type: 'hasMany'; marker: HasManyRelationMarker; fieldState: EntityListState }\n\t\t> = []\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tconst marker = fieldState.fieldMarker\n\t\t\t\t\tconst placeholderName = marker.placeholderName\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tplaceholderName === TYPENAME_KEY_NAME ||\n\t\t\t\t\t\t(placeholderName === PRIMARY_KEY_NAME && !(currentState.entity.id instanceof ClientGeneratedUuid))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'field',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateFieldPart(fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'hasOne',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateEntityPart(processedPlaceholdersByEntity, fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'hasMany',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateEntityListPart(processedPlaceholdersByEntity, fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// if (\n\t\t// \tcurrentState.blueprint.creationParameters.forceCreation &&\n\t\t// \t(builder.data === undefined || isEmptyObject(builder.data))\n\t\t// ) {\n\t\t// \tbuilder = builder.set('_dummy_field_', true)\n\t\t// }\n\n\t\tif (\n\t\t\t(builder.data !== undefined && !isEmptyObject(builder.data)) ||\n\t\t\t!getEntityMarker(currentState).fields.hasAtLeastOneBearingField\n\t\t) {\n\t\t\tfor (const field of nonbearingFields) {\n\t\t\t\tswitch (field.type) {\n\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\tbuilder = this.registerCreateFieldPart(field.fieldState, field.marker, builder)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'hasOne': {\n\t\t\t\t\t\tbuilder = this.registerCreateEntityPart(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'hasMany': {\n\t\t\t\t\t\tbuilder = this.registerCreateEntityListPart(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tassertNever(field)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst setOnCreate = getEntityMarker(currentState).parameters.setOnCreate\n\t\tif (setOnCreate && builder.data !== undefined && !isEmptyObject(builder.data)) {\n\t\t\tfor (const key in setOnCreate) {\n\t\t\t\tconst field = setOnCreate[key]\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof field === 'string' ||\n\t\t\t\t\ttypeof field === 'number' ||\n\t\t\t\t\tfield === null ||\n\t\t\t\t\tfield instanceof GraphQlBuilder.GraphQlLiteral\n\t\t\t\t) {\n\t\t\t\t\tbuilder = builder.set(key, field)\n\t\t\t\t} else {\n\t\t\t\t\tbuilder = builder.one(key, builder => builder.connect(field))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn builder\n\t}\n\n\tprivate registerCreateFieldPart(\n\t\tfieldState: FieldState,\n\t\tmarker: FieldMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\n\t\tif (resolvedValue !== undefined && resolvedValue !== null) {\n\t\t\treturn builder.set(marker.fieldName, this.transformFieldValue(fieldState, resolvedValue))\n\t\t}\n\t\treturn builder\n\t}\n\n\tprivate registerCreateEntityPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tmarker: HasOneRelationMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\tconst reducedBy = marker.parameters.reducedBy\n\t\tconst runtimeId = fieldState.entity.id\n\n\t\tif (reducedBy === undefined) {\n\t\t\treturn builder.one(marker.parameters.field, builder => {\n\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value })\n\t\t\t\t}\n\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t})\n\t\t}\n\t\treturn builder.many(marker.parameters.field, builder => {\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t}\n\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState), alias)\n\t\t})\n\t}\n\n\tprivate registerCreateEntityListPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityListState,\n\t\tmarker: HasManyRelationMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\treturn builder.many(marker.parameters.field, builder => {\n\t\t\tfor (const entityRealm of fieldState.children.values()) {\n\t\t\t\tconst alias = MutationAlias.encodeEntityId(entityRealm.entity.id)\n\t\t\t\tif (entityRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\tbuilder = builder.connect({ [PRIMARY_KEY_NAME]: entityRealm.entity.id.value }, alias)\n\t\t\t\t} else {\n\t\t\t\t\tbuilder = builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, entityRealm), alias)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn builder\n\t\t})\n\t}\n\n\tprivate registerUpdateMutationPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update>,\n\t): CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update> {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\t\tconst entityData = this.treeStore.persistedEntityData.get(currentState.entity.id.value)\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME || placeholderName === TYPENAME_KEY_NAME) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (fieldState.persistedValue !== undefined) {\n\t\t\t\t\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (fieldState.persistedValue !== resolvedValue) {\n\t\t\t\t\t\t\tbuilder = builder.set(placeholderName, this.transformFieldValue(fieldState, resolvedValue))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst runtimeId = fieldState.entity.id\n\t\t\t\t\tconst reducedBy = marker.parameters.reducedBy\n\n\t\t\t\t\tif (reducedBy === undefined) {\n\t\t\t\t\t\tconst subBuilder = ((\n\t\t\t\t\t\t\tbuilder: CrudQueryBuilder.WriteOneRelationBuilder<CrudQueryBuilder.WriteOperation.Update>,\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\n\t\t\t\t\t\t\tif (persistedValue instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t\t\t\t\t\t// The persisted and currently referenced ids match, and so this is an update.\n\t\t\t\t\t\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\treturn builder // …unless we're dealing with a stub. There cannot be any updates there.\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn builder.update(builder =>\n\t\t\t\t\t\t\t\t\t\tthis.registerUpdateMutationPart(processedPlaceholdersByEntity, fieldState, builder),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// There was a referenced entity but currently, there is a different one. Let's investigate:\n\n\t\t\t\t\t\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\t\t\t\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t\t\t\t\t\t// It's planned for deletion.\n\t\t\t\t\t\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\t\t\t\t\t\treturn builder.delete()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t\t// This isn't the persisted entity but it does exist on the server. Thus this is a connect.\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\treturn builder.connect({\n\t\t\t\t\t\t\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// The currently present entity doesn't exist on the server. Try if creating yields anything…\n\t\t\t\t\t\t\t\tconst subBuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (isEmptyObject(subBuilder.data)) {\n\t\t\t\t\t\t\t\t\t// …and if it doesn't, we just disconnect.\n\t\t\t\t\t\t\t\t\treturn builder.disconnect()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// …but if it does, we return the create, disconnecting implicitly.\n\t\t\t\t\t\t\t\treturn subBuilder\n\t\t\t\t\t\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t// There isn't a linked entity on the server but we're seeing one that exists there.\n\t\t\t\t\t\t\t\t// Thus this is a connect.\n\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\treturn builder.connect({\n\t\t\t\t\t\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})(CrudQueryBuilder.WriteOneRelationBuilder.instantiate<CrudQueryBuilder.WriteOperation.Update>())\n\n\t\t\t\t\t\tif (subBuilder.data) {\n\t\t\t\t\t\t\tbuilder = builder.one(marker.parameters.field, subBuilder.data)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// This is a reduced has many relation.\n\t\t\t\t\t\tbuilder = builder.many(marker.parameters.field, builder => {\n\t\t\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\t\t\t\t\tif (persistedValue instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t\t\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\treturn builder\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn builder.update(\n\t\t\t\t\t\t\t\t\t\treducedBy,\n\t\t\t\t\t\t\t\t\t\tbuilder => this.registerUpdateMutationPart(processedPlaceholdersByEntity, fieldState, builder),\n\t\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\t\t\t\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t\t\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\t\t\t\t\t\treturn builder.delete(reducedBy, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t\t// TODO will re-using the alias like this work?\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\treturn builder.disconnect(reducedBy, alias).connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst subBuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (isEmptyObject(subBuilder.data)) {\n\t\t\t\t\t\t\t\t\treturn builder.disconnect(reducedBy, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn subBuilder\n\t\t\t\t\t\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\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\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedEntityIds = entityData?.get?.(placeholderName) ?? new Set()\n\n\t\t\t\t\tif (!(persistedEntityIds instanceof Set)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder = builder.many(marker.parameters.field, builder => {\n\t\t\t\t\t\tfor (const childState of fieldState.children.values()) {\n\t\t\t\t\t\t\tconst runtimeId = childState.entity.id\n\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\tif (persistedEntityIds.has(runtimeId.value)) {\n\t\t\t\t\t\t\t\t\tif (childState.type !== 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\t// A stub cannot have any pending changes.\n\t\t\t\t\t\t\t\t\t\tbuilder = builder.update(\n\t\t\t\t\t\t\t\t\t\t\t{ [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t\t\t\t\t\t\tbuilder => this.registerUpdateMutationPart(processedPlaceholdersByEntity, childState, builder),\n\t\t\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\tbuilder = builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tbuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, childState),\n\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fieldState.plannedRemovals) {\n\t\t\t\t\t\t\tfor (const [removedId, removalType] of fieldState.plannedRemovals) {\n\t\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(new ServerGeneratedUuid(removedId))\n\t\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\t\tbuilder = builder.delete({ [PRIMARY_KEY_NAME]: removedId }, alias)\n\t\t\t\t\t\t\t\t} else if (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\tbuilder = builder.disconnect({ [PRIMARY_KEY_NAME]: removedId }, alias)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn builder\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t}\n\t\t}\n\n\t\treturn builder\n\t}\n\n\tprivate transformFieldValue(fieldState: FieldState, value: FieldValue): FieldValue | GraphQlBuilder.GraphQlLiteral {\n\t\tif (typeof value !== 'string') {\n\t\t\treturn value\n\t\t}\n\t\tconst fieldSchema = this.treeStore.schema.getEntityField(\n\t\t\tfieldState.parent.entity.entityName,\n\t\t\tfieldState.fieldMarker.fieldName,\n\t\t)\n\t\tif (fieldSchema === undefined || fieldSchema.__typename !== '_Column') {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn fieldSchema.enumName === null ? value : new GraphQlBuilder.GraphQlLiteral(value)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;wBA0B+B;AAAA,EACvB,YAA6B,WAAsB;;;EAEnD,qBAAyC;QAC3C;UACC,UAAwB,IAAI,iBAAiB;YAC3C,gCAA+D,IAAI;iBAE9D,CAAC,YAAY,eAAe,KAAK,UAAU,qBAAqB;mBAC/D,CAAC,iBAAiB,iBAAiB,YAAY;cACrD,aAAa,SAAS,eAAe;sBAC9B,KAAK,eACd,+BACA,YACA,iBACA,6BAA6B,cAC7B,aAAa,OAAO,GAAG,OACvB,cACA;AAAA,qBAES,aAAa,SAAS,cAAc;uBACnC,cAAc,aAAa,SAAS,UAAU;kBACpD,WAAW,SAAS,mBAAmB;;;wBAIjC,KAAK,eACd,+BACA,YACA,iBACA,6BAA6B,YAC7B,WAAW,OAAO,GAAG,OACrB,YACA;AAAA;gBAGE,aAAa,iBAAiB;yBACtB,CAAC,WAAW,gBAAgB,aAAa,iBAAiB;oBAChE,gBAAgB,cAAc;;;oBAG9B,gBAAgB,UAAU;4BACnB,KAAK,kBACd,aAAa,YACb,WACA,cAAc,eAAe;AAAA,oBAC5B;AAAA,oBACA,oBAAoB;AAAA,oBACpB,MAAM,sBAAsB;AAAA,oBAC5B,aAAa,6BAA6B;AAAA,oBAC1C,UAAU;AAAA,sBAEX;AAAA,uBAEK;8BACM;AAAA;AAAA;AAAA;AAAA,iBAIT;wBACM;AAAA;AAAA;AAAA;aAIR,QAAQ,cAAc,QAAW,EAAE,4BAA4B,QAAQ;AAAA,aACtE;aACD;AAAA;AA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AAG,mBAAmB,UAAU,SAAS;AAAA;AAAA,qBAE9D;2BACI,SAAQ,OACjB,KAAK,2BAA2B,+BAA+B,aAC/D;AAAA;AAAA;gBAIC,WAAW,iBAAiB;yBACpB,CAAC,WAAW,gBAAgB,WAAW,iBAAiB;sBAC5D,QAAQ,cAAc,eAAe,IAAI,oBAAoB;oBAC/D,gBAAgB,UAAU;6BACnB,SAAQ,OAAO,GAAG,mBAAmB,aAAa;AAAA,2BAClD,gBAAgB,cAAc;6BAE9B,SAAQ,WAAW,GAAG,mBAAmB,aAAa;AAAA,uBAC1D;;;;;mBAKF;AAAA;;;;iBAKD;AAAA;AAAA;WAIH;AAAA;AAAA,EAGA,oBAAoB,YAAwB,OAA+D;QAC9G,OAAO,UAAU,UAAU;aACvB;AAAA;UAEF,cAAc,KAAK,UAAU,OAAO,eACzC,WAAW,OAAO,OAAO,YACzB,WAAW,YAAY;QAEpB,gBAAgB,UAAa,YAAY,eAAe,WAAW;YAChE,IAAI;AAAA;WAEJ,YAAY,aAAa,OAAO,QAAQ,IAAI,eAAe,eAAe;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"MutationGenerator.js","sources":["../../../src/core/MutationGenerator.ts"],"sourcesContent":["// noinspection JSVoidFunctionReturnValueUsed // IntelliJ seems to be super confused througouht this file.\n\nimport { CrudQueryBuilder, GraphQlBuilder } from '@contember/client'\nimport { ClientGeneratedUuid, ServerGeneratedUuid } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME, TYPENAME_KEY_NAME } from '../bindingTypes'\nimport { FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../markers'\nimport type { EntityId, EntityName, FieldValue, PlaceholderName, TreeRootId } from '../treeParameters'\nimport { assertNever, isEmptyObject } from '../utils'\nimport { QueryGenerator } from './QueryGenerator'\nimport { MutationAlias, mutationOperationSubTreeType, mutationOperationType } from './requestAliases'\nimport {\n\tEntityListState,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n} from './state'\nimport type { TreeStore } from './TreeStore'\n\ntype QueryBuilder = Omit<CrudQueryBuilder.CrudQueryBuilder, CrudQueryBuilder.Queries>\n\ntype ProcessedPlaceholdersByEntity = Map<EntityState, Set<PlaceholderName>>\n\n// TODO enforce correct expected mutations in dev mode.\nexport class MutationGenerator {\n\tpublic constructor(private readonly treeStore: TreeStore) {}\n\n\tpublic getPersistMutation(): string | undefined {\n\t\ttry {\n\t\t\tlet builder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder()\n\t\t\tconst processedPlaceholdersByEntity: ProcessedPlaceholdersByEntity = new Map()\n\n\t\t\tfor (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot) {\n\t\t\t\tfor (const [placeholderName, subTreeState] of rootStates) {\n\t\t\t\t\tif (subTreeState.type === 'entityRealm') {\n\t\t\t\t\t\tbuilder = this.addSubMutation(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\tmutationOperationSubTreeType.singleEntity,\n\t\t\t\t\t\t\tsubTreeState.entity.id.value,\n\t\t\t\t\t\t\tsubTreeState,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else if (subTreeState.type === 'entityList') {\n\t\t\t\t\t\tfor (const childState of subTreeState.children.values()) {\n\t\t\t\t\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t// TODO there can be a forceCreate somewhere in there that we're hereby ignoring.\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbuilder = this.addSubMutation(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\tmutationOperationSubTreeType.entityList,\n\t\t\t\t\t\t\t\tchildState.entity.id.value,\n\t\t\t\t\t\t\t\tchildState,\n\t\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\tfor (const [removedId, removalType] of subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\t\tif (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\t\tbuilder = this.addDeleteMutation(\n\t\t\t\t\t\t\t\t\t\tsubTreeState.entityName,\n\t\t\t\t\t\t\t\t\t\tremovedId,\n\t\t\t\t\t\t\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\t\t\t\t\t\t\ttreeRootId,\n\t\t\t\t\t\t\t\t\t\t\tsubTreePlaceholder: placeholderName,\n\t\t\t\t\t\t\t\t\t\t\ttype: mutationOperationType.delete,\n\t\t\t\t\t\t\t\t\t\t\tsubTreeType: mutationOperationSubTreeType.entityList,\n\t\t\t\t\t\t\t\t\t\t\tentityId: removedId,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassertNever(subTreeState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn builder.inTransaction(undefined, { deferForeignKeyConstraints: true }).getGql()\n\t\t} catch (e) {\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\tprivate addSubMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\ttreeRootId: TreeRootId | undefined,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType],\n\t\tentityId: EntityId,\n\t\trealmState: EntityRealmState,\n\t\tqueryBuilder: QueryBuilder,\n\t): QueryBuilder {\n\t\tif (realmState.unpersistedChangesCount === 0) {\n\t\t\t// Bail out early\n\t\t\treturn queryBuilder\n\t\t}\n\t\tif (realmState.entity.isScheduledForDeletion) {\n\t\t\treturn this.addDeleteMutation(\n\t\t\t\trealmState.entity.entityName,\n\t\t\t\tentityId,\n\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\ttreeRootId,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\ttype: mutationOperationType.delete,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\tentityId,\n\t\t\t\t}),\n\t\t\t\tqueryBuilder,\n\t\t\t)\n\t\t} else if (!realmState.entity.id.existsOnServer) {\n\t\t\treturn this.addCreateMutation(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\trealmState,\n\t\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\t\ttreeRootId,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\ttype: mutationOperationType.create,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\tentityId,\n\t\t\t\t}),\n\t\t\t\tthis.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState),\n\t\t\t\tqueryBuilder,\n\t\t\t)\n\t\t}\n\t\treturn this.addUpdateMutation(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\trealmState,\n\t\t\tMutationAlias.encodeTopLevel({\n\t\t\t\ttreeRootId,\n\t\t\t\tsubTreePlaceholder,\n\t\t\t\ttype: mutationOperationType.update,\n\t\t\t\tsubTreeType,\n\t\t\t\tentityId,\n\t\t\t}),\n\t\t\tthis.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState),\n\t\t\tqueryBuilder,\n\t\t)\n\t}\n\n\tprivate getNodeFragmentName(\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: typeof mutationOperationSubTreeType[keyof typeof mutationOperationSubTreeType],\n\t\trealmState: EntityRealmState,\n\t): string | undefined {\n\t\tif (subTreeType !== mutationOperationSubTreeType.entityList) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn `${realmState.entity.entityName}_${subTreePlaceholder}`\n\t}\n\n\tprivate addDeleteMutation(\n\t\tentityName: EntityName,\n\t\tdeletedId: EntityId,\n\t\talias: string,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\treturn queryBuilder.delete(\n\t\t\tentityName,\n\t\t\tbuilder =>\n\t\t\t\tbuilder\n\t\t\t\t\t.ok()\n\t\t\t\t\t.node(builder => builder.column(PRIMARY_KEY_NAME))\n\t\t\t\t\t.by({ [PRIMARY_KEY_NAME]: deletedId })\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage(),\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate addUpdateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\talias: string,\n\t\tnodeFragmentName: string | undefined,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\tconst updateBuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update> =\n\t\t\tthis.registerUpdateMutationPart(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\tentityRealm,\n\t\t\t\tnew CrudQueryBuilder.WriteDataBuilder(),\n\t\t\t)\n\t\tif (updateBuilder.data === undefined || isEmptyObject(updateBuilder.data)) {\n\t\t\treturn queryBuilder\n\t\t}\n\n\t\tconst runtimeId = entityRealm.entity.id\n\n\t\tif (!runtimeId.existsOnServer) {\n\t\t\treturn queryBuilder\n\t\t}\n\n\t\tconst readBuilder = QueryGenerator.registerQueryPart(\n\t\t\tgetEntityMarker(entityRealm).fields.markers,\n\t\t\tCrudQueryBuilder.ReadBuilder.instantiate(),\n\t\t)\n\n\t\tif (nodeFragmentName) {\n\t\t\tqueryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder)\n\t\t}\n\n\t\treturn queryBuilder.update(\n\t\t\tentityRealm.entity.entityName,\n\t\t\tbuilder =>\n\t\t\t\tbuilder\n\t\t\t\t\t.node(nodeFragmentName ? builder => builder.applyFragment(nodeFragmentName) : readBuilder)\n\t\t\t\t\t.data(updateBuilder)\n\t\t\t\t\t.by({ [PRIMARY_KEY_NAME]: runtimeId.value })\n\t\t\t\t\t.ok()\n\t\t\t\t\t.validation()\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage(),\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate addCreateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\talias: string,\n\t\tnodeFragmentName: string | undefined,\n\t\tqueryBuilder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder(),\n\t): QueryBuilder {\n\t\tconst createBuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> =\n\t\t\tthis.registerCreateMutationPart(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\tentityRealm,\n\t\t\t\tnew CrudQueryBuilder.WriteDataBuilder(),\n\t\t\t)\n\t\tif (createBuilder.data === undefined || isEmptyObject(createBuilder.data)) {\n\t\t\treturn queryBuilder\n\t\t}\n\t\tconst readBuilder = QueryGenerator.registerQueryPart(\n\t\t\tgetEntityMarker(entityRealm).fields.markers,\n\t\t\tCrudQueryBuilder.ReadBuilder.instantiate(),\n\t\t)\n\t\tif (nodeFragmentName) {\n\t\t\tqueryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder)\n\t\t}\n\n\t\treturn queryBuilder.create(\n\t\t\tentityRealm.entity.entityName,\n\t\t\tbuilder => {\n\t\t\t\t// if (where && writeBuilder.data !== undefined && !isEmptyObject(writeBuilder.data)) {\n\t\t\t\t// \t// Shallow cloning the parameters like this IS too naïve but it will likely last surprisingly long before we\n\t\t\t\t// \t// run into issues.\n\t\t\t\t// \twriteBuilder = new CrudQueryBuilder.WriteDataBuilder({ ...writeBuilder.data, ...where })\n\t\t\t\t// }\n\t\t\t\treturn builder\n\t\t\t\t\t.node(nodeFragmentName ? builder => builder.applyFragment(nodeFragmentName) : readBuilder)\n\t\t\t\t\t.data(createBuilder)\n\t\t\t\t\t.ok()\n\t\t\t\t\t.validation()\n\t\t\t\t\t.errors()\n\t\t\t\t\t.errorMessage()\n\t\t\t},\n\t\t\talias,\n\t\t)\n\t}\n\n\tprivate registerCreateMutationPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> = new CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>(),\n\t): CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create> {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tif (currentState.type === 'entityRealmStub') {\n\t\t\t// TODO If there's a forceCreate, this is wrong.\n\t\t\treturn builder\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\n\t\tconst nonbearingFields: Array<\n\t\t\t| { type: 'field'; marker: FieldMarker; fieldState: FieldState }\n\t\t\t| { type: 'hasOne'; marker: HasOneRelationMarker; fieldState: EntityRealmState | EntityRealmStateStub }\n\t\t\t| { type: 'hasMany'; marker: HasManyRelationMarker; fieldState: EntityListState }\n\t\t> = []\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tconst marker = fieldState.fieldMarker\n\t\t\t\t\tconst placeholderName = marker.placeholderName\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tplaceholderName === TYPENAME_KEY_NAME ||\n\t\t\t\t\t\t(placeholderName === PRIMARY_KEY_NAME && !(currentState.entity.id instanceof ClientGeneratedUuid))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'field',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateFieldPart(fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'hasOne',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateEntityPart(processedPlaceholdersByEntity, fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\ttype: 'hasMany',\n\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tbuilder = this.registerCreateEntityListPart(processedPlaceholdersByEntity, fieldState, marker, builder)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// if (\n\t\t// \tcurrentState.blueprint.creationParameters.forceCreation &&\n\t\t// \t(builder.data === undefined || isEmptyObject(builder.data))\n\t\t// ) {\n\t\t// \tbuilder = builder.set('_dummy_field_', true)\n\t\t// }\n\n\t\tif (\n\t\t\t(builder.data !== undefined && !isEmptyObject(builder.data)) ||\n\t\t\t!getEntityMarker(currentState).fields.hasAtLeastOneBearingField\n\t\t) {\n\t\t\tfor (const field of nonbearingFields) {\n\t\t\t\tswitch (field.type) {\n\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\tbuilder = this.registerCreateFieldPart(field.fieldState, field.marker, builder)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'hasOne': {\n\t\t\t\t\t\tbuilder = this.registerCreateEntityPart(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'hasMany': {\n\t\t\t\t\t\tbuilder = this.registerCreateEntityListPart(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tassertNever(field)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst setOnCreate = getEntityMarker(currentState).parameters.setOnCreate\n\t\tif (setOnCreate && builder.data !== undefined && !isEmptyObject(builder.data)) {\n\t\t\tfor (const key in setOnCreate) {\n\t\t\t\tconst field = setOnCreate[key]\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof field === 'string' ||\n\t\t\t\t\ttypeof field === 'number' ||\n\t\t\t\t\tfield === null ||\n\t\t\t\t\tfield instanceof GraphQlBuilder.GraphQlLiteral\n\t\t\t\t) {\n\t\t\t\t\tbuilder = builder.set(key, field)\n\t\t\t\t} else {\n\t\t\t\t\tbuilder = builder.one(key, builder => builder.connect(field))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn builder\n\t}\n\n\tprivate registerCreateFieldPart(\n\t\tfieldState: FieldState,\n\t\tmarker: FieldMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\n\t\tif (resolvedValue !== undefined && resolvedValue !== null) {\n\t\t\treturn builder.set(marker.fieldName, this.transformFieldValue(fieldState, resolvedValue))\n\t\t}\n\t\treturn builder\n\t}\n\n\tprivate registerCreateEntityPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tmarker: HasOneRelationMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\tconst reducedBy = marker.parameters.reducedBy\n\t\tconst runtimeId = fieldState.entity.id\n\n\t\tif (reducedBy === undefined) {\n\t\t\treturn builder.one(marker.parameters.field, builder => {\n\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value })\n\t\t\t\t}\n\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t})\n\t\t}\n\t\treturn builder.many(marker.parameters.field, builder => {\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t}\n\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState), alias)\n\t\t})\n\t}\n\n\tprivate registerCreateEntityListPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityListState,\n\t\tmarker: HasManyRelationMarker,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Create>,\n\t) {\n\t\treturn builder.many(marker.parameters.field, builder => {\n\t\t\tfor (const entityRealm of fieldState.children.values()) {\n\t\t\t\tconst alias = MutationAlias.encodeEntityId(entityRealm.entity.id)\n\t\t\t\tif (entityRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\tbuilder = builder.connect({ [PRIMARY_KEY_NAME]: entityRealm.entity.id.value }, alias)\n\t\t\t\t} else {\n\t\t\t\t\tbuilder = builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, entityRealm), alias)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn builder\n\t\t})\n\t}\n\n\tprivate registerUpdateMutationPart(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState,\n\t\tbuilder: CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update>,\n\t): CrudQueryBuilder.WriteDataBuilder<CrudQueryBuilder.WriteOperation.Update> {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\t\tconst entityData = this.treeStore.persistedEntityData.get(currentState.entity.id.value)\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME || placeholderName === TYPENAME_KEY_NAME) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (fieldState.persistedValue !== undefined) {\n\t\t\t\t\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (fieldState.persistedValue !== resolvedValue) {\n\t\t\t\t\t\t\tbuilder = builder.set(placeholderName, this.transformFieldValue(fieldState, resolvedValue))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst runtimeId = fieldState.entity.id\n\t\t\t\t\tconst reducedBy = marker.parameters.reducedBy\n\n\t\t\t\t\tif (reducedBy === undefined) {\n\t\t\t\t\t\tconst subBuilder = ((\n\t\t\t\t\t\t\tbuilder: CrudQueryBuilder.WriteOneRelationBuilder<CrudQueryBuilder.WriteOperation.Update>,\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\n\t\t\t\t\t\t\tif (persistedValue instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t\t\t\t\t\t// The persisted and currently referenced ids match, and so this is an update.\n\t\t\t\t\t\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\treturn builder // …unless we're dealing with a stub. There cannot be any updates there.\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn builder.update(builder =>\n\t\t\t\t\t\t\t\t\t\tthis.registerUpdateMutationPart(processedPlaceholdersByEntity, fieldState, builder),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// There was a referenced entity but currently, there is a different one. Let's investigate:\n\n\t\t\t\t\t\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\t\t\t\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t\t\t\t\t\t// It's planned for deletion.\n\t\t\t\t\t\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\t\t\t\t\t\treturn builder.delete()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t\t// This isn't the persisted entity but it does exist on the server. Thus this is a connect.\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\treturn builder.connect({\n\t\t\t\t\t\t\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// The currently present entity doesn't exist on the server. Try if creating yields anything…\n\t\t\t\t\t\t\t\tconst subBuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (isEmptyObject(subBuilder.data)) {\n\t\t\t\t\t\t\t\t\t// …and if it doesn't, we just disconnect.\n\t\t\t\t\t\t\t\t\treturn builder.disconnect()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// …but if it does, we return the create, disconnecting implicitly.\n\t\t\t\t\t\t\t\treturn subBuilder\n\t\t\t\t\t\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t// There isn't a linked entity on the server but we're seeing one that exists there.\n\t\t\t\t\t\t\t\t// Thus this is a connect.\n\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\treturn builder.connect({\n\t\t\t\t\t\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})(CrudQueryBuilder.WriteOneRelationBuilder.instantiate<CrudQueryBuilder.WriteOperation.Update>())\n\n\t\t\t\t\t\tif (subBuilder.data) {\n\t\t\t\t\t\t\tbuilder = builder.one(marker.parameters.field, subBuilder.data)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// This is a reduced has many relation.\n\t\t\t\t\t\tbuilder = builder.many(marker.parameters.field, builder => {\n\t\t\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\t\t\t\t\tif (persistedValue instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t\t\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\treturn builder\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn builder.update(\n\t\t\t\t\t\t\t\t\t\treducedBy,\n\t\t\t\t\t\t\t\t\t\tbuilder => this.registerUpdateMutationPart(processedPlaceholdersByEntity, fieldState, builder),\n\t\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\t\t\t\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t\t\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\t\t\t\t\t\treturn builder.delete(reducedBy, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\t\t// TODO will re-using the alias like this work?\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\treturn builder.disconnect(reducedBy, alias).connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst subBuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (isEmptyObject(subBuilder.data)) {\n\t\t\t\t\t\t\t\t\treturn builder.disconnect(reducedBy, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn subBuilder\n\t\t\t\t\t\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\treturn builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn builder.create(this.registerCreateMutationPart(processedPlaceholdersByEntity, fieldState))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\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\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedEntityIds = entityData?.get?.(placeholderName) ?? new Set()\n\n\t\t\t\t\tif (!(persistedEntityIds instanceof Set)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder = builder.many(marker.parameters.field, builder => {\n\t\t\t\t\t\tfor (const childState of fieldState.children.values()) {\n\t\t\t\t\t\t\tconst runtimeId = childState.entity.id\n\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\t\t\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t\t\t\t\tif (persistedEntityIds.has(runtimeId.value)) {\n\t\t\t\t\t\t\t\t\tif (childState.type !== 'entityRealmStub') {\n\t\t\t\t\t\t\t\t\t\t// A stub cannot have any pending changes.\n\t\t\t\t\t\t\t\t\t\tbuilder = builder.update(\n\t\t\t\t\t\t\t\t\t\t\t{ [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t\t\t\t\t\t\tbuilder => this.registerUpdateMutationPart(processedPlaceholdersByEntity, childState, builder),\n\t\t\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\tbuilder = builder.connect({ [PRIMARY_KEY_NAME]: runtimeId.value }, alias)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tbuilder = builder.create(\n\t\t\t\t\t\t\t\t\tthis.registerCreateMutationPart(processedPlaceholdersByEntity, childState),\n\t\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fieldState.plannedRemovals) {\n\t\t\t\t\t\t\tfor (const [removedId, removalType] of fieldState.plannedRemovals) {\n\t\t\t\t\t\t\t\tconst alias = MutationAlias.encodeEntityId(new ServerGeneratedUuid(removedId))\n\t\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\t\tbuilder = builder.delete({ [PRIMARY_KEY_NAME]: removedId }, alias)\n\t\t\t\t\t\t\t\t} else if (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\t\t// TODO also potentially update\n\t\t\t\t\t\t\t\t\tbuilder = builder.disconnect({ [PRIMARY_KEY_NAME]: removedId }, alias)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn builder\n\t\t\t\t\t})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t}\n\t\t}\n\n\t\treturn builder\n\t}\n\n\tprivate transformFieldValue(fieldState: FieldState, value: FieldValue): FieldValue | GraphQlBuilder.GraphQlLiteral {\n\t\tif (typeof value !== 'string') {\n\t\t\treturn value\n\t\t}\n\t\tconst fieldSchema = this.treeStore.schema.getEntityField(\n\t\t\tfieldState.parent.entity.entityName,\n\t\t\tfieldState.fieldMarker.fieldName,\n\t\t)\n\t\tif (fieldSchema === undefined || fieldSchema.__typename !== '_Column') {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn fieldSchema.enumName === null ? value : new GraphQlBuilder.GraphQlLiteral(value)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;wBA0B+B;AAAA,EACvB,YAA6B,WAAsB;;;EAEnD,qBAAyC;QAC3C;UACC,UAAwB,IAAI,iBAAiB;YAC3C,oDAAmE;iBAE9D,CAAC,YAAY,eAAe,KAAK,UAAU,qBAAqB;mBAC/D,CAAC,iBAAiB,iBAAiB,YAAY;cACrD,aAAa,SAAS,eAAe;sBAC9B,KAAK,eACd,+BACA,YACA,iBACA,6BAA6B,cAC7B,aAAa,OAAO,GAAG,OACvB,cACA;AAAA,qBAES,aAAa,SAAS,cAAc;uBACnC,cAAc,aAAa,SAAS,UAAU;kBACpD,WAAW,SAAS,mBAAmB;;;wBAIjC,KAAK,eACd,+BACA,YACA,iBACA,6BAA6B,YAC7B,WAAW,OAAO,GAAG,OACrB,YACA;AAAA;gBAGE,aAAa,iBAAiB;yBACtB,CAAC,WAAW,gBAAgB,aAAa,iBAAiB;oBAChE,gBAAgB,cAAc;;;oBAG9B,gBAAgB,UAAU;4BACnB,KAAK,kBACd,aAAa,YACb,WACA,cAAc,eAAe;AAAA,oBAC5B;AAAA,oBACA,oBAAoB;AAAA,oBACpB,MAAM,sBAAsB;AAAA,oBAC5B,aAAa,6BAA6B;AAAA,oBAC1C,UAAU;AAAA,sBAEX;AAAA,uBAEK;8BACM;AAAA;AAAA;AAAA;AAAA,iBAIT;wBACM;AAAA;AAAA;AAAA;aAIR,QAAQ,cAAc,QAAW,EAAE,4BAA4B,QAAQ;AAAA,aACtE;aACD;AAAA;AAAA;AAAA,EAID,eACP,+BACA,YACA,oBACA,aACA,UACA,YACA,cACe;QACX,WAAW,4BAA4B,GAAG;aAEtC;AAAA;QAEJ,WAAW,OAAO,wBAAwB;aACtC,KAAK,kBACX,WAAW,OAAO,YAClB,UACA,cAAc,eAAe;AAAA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,IAAI,oBAAoB;oBAC/D,gBAAgB,UAAU;6BACnB,SAAQ,OAAO,GAAG,mBAAmB,aAAa;AAAA,2BAClD,gBAAgB,cAAc;6BAE9B,SAAQ,WAAW,GAAG,mBAAmB,aAAa;AAAA,uBAC1D;;;;;mBAKF;AAAA;;;;iBAKD;AAAA;AAAA;WAIH;AAAA;AAAA,EAGA,oBAAoB,YAAwB,OAA+D;QAC9G,OAAO,UAAU,UAAU;aACvB;AAAA;UAEF,cAAc,KAAK,UAAU,OAAO,eACzC,WAAW,OAAO,OAAO,YACzB,WAAW,YAAY;QAEpB,gBAAgB,UAAa,YAAY,eAAe,WAAW;YAChE,IAAI;AAAA;WAEJ,YAAY,aAAa,OAAO,QAAQ,IAAI,eAAe,eAAe;AAAA;AAAA;;"}
|
|
@@ -8,7 +8,7 @@ import { ServerGeneratedUuid } from "../accessorTree/RuntimeId.js";
|
|
|
8
8
|
class RequestResponseNormalizer {
|
|
9
9
|
static mergeInQueryResponse(original, newPersistedData) {
|
|
10
10
|
const { subTreeDataStore, persistedEntityDataStore } = original;
|
|
11
|
-
const presentIds = new Set();
|
|
11
|
+
const presentIds = /* @__PURE__ */ new Set();
|
|
12
12
|
for (const placeholderName in newPersistedData) {
|
|
13
13
|
const treeDatum = newPersistedData[placeholderName];
|
|
14
14
|
const fieldData = this.createFieldData(persistedEntityDataStore, treeDatum);
|
|
@@ -24,7 +24,7 @@ class RequestResponseNormalizer {
|
|
|
24
24
|
}
|
|
25
25
|
static mergeInMutationResponse(original, newPersistedData) {
|
|
26
26
|
const { subTreeDataStore, persistedEntityDataStore } = original;
|
|
27
|
-
const presentIds = new Set();
|
|
27
|
+
const presentIds = /* @__PURE__ */ new Set();
|
|
28
28
|
for (const operationAlias in newPersistedData) {
|
|
29
29
|
const operation = MutationAlias.decodeTopLevel(operationAlias);
|
|
30
30
|
if (operation === void 0) {
|
|
@@ -49,7 +49,7 @@ class RequestResponseNormalizer {
|
|
|
49
49
|
if (list instanceof Set) {
|
|
50
50
|
list.add(fieldData.value);
|
|
51
51
|
} else if (list === void 0) {
|
|
52
|
-
subTreeDataStore.set(subTreePlaceholder, new Set([fieldData.value]));
|
|
52
|
+
subTreeDataStore.set(subTreePlaceholder, /* @__PURE__ */ new Set([fieldData.value]));
|
|
53
53
|
} else {
|
|
54
54
|
return this.rejectData();
|
|
55
55
|
}
|
|
@@ -85,7 +85,7 @@ class RequestResponseNormalizer {
|
|
|
85
85
|
}
|
|
86
86
|
static createFieldData(entityMap, fieldData) {
|
|
87
87
|
if (Array.isArray(fieldData)) {
|
|
88
|
-
const subTreeListIds = new Set();
|
|
88
|
+
const subTreeListIds = /* @__PURE__ */ new Set();
|
|
89
89
|
for (const entityDatum of fieldData) {
|
|
90
90
|
subTreeListIds.add(this.createEntityData(entityMap, entityDatum));
|
|
91
91
|
}
|
|
@@ -103,7 +103,7 @@ class RequestResponseNormalizer {
|
|
|
103
103
|
}
|
|
104
104
|
const presentEntityData = entityMap.get(primaryKey);
|
|
105
105
|
if (presentEntityData === void 0) {
|
|
106
|
-
const fieldsMap = new Map();
|
|
106
|
+
const fieldsMap = /* @__PURE__ */ new Map();
|
|
107
107
|
entityMap.set(primaryKey, fieldsMap);
|
|
108
108
|
for (const field in entityData) {
|
|
109
109
|
const fieldDatum = entityData[field];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestResponseNormalizer.js","sources":["../../../src/core/RequestResponseNormalizer.ts"],"sourcesContent":["import {\n\tEntityFieldPersistedData,\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tReceivedEntityData,\n\tReceivedFieldData,\n\tServerGeneratedUuid,\n\tSingleEntityPersistedData,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { assertNever } from '../utils'\nimport { MutationAlias, mutationOperationSubTreeType, mutationOperationType } from './requestAliases'\n\nexport class RequestResponseNormalizer {\n\tpublic static mergeInQueryResponse(\n\t\toriginal: NormalizedPersistedData,\n\t\tnewPersistedData: ReceivedDataTree,\n\t): Set<string> {\n\t\tconst { subTreeDataStore, persistedEntityDataStore } = original\n\t\tconst presentIds: Set<string> = new Set()\n\n\t\tfor (const placeholderName in newPersistedData) {\n\t\t\tconst treeDatum = newPersistedData[placeholderName]\n\n\t\t\tconst fieldData = this.createFieldData(persistedEntityDataStore, treeDatum)\n\n\t\t\tif (fieldData === null) {\n\t\t\t\tsubTreeDataStore.delete(placeholderName)\n\t\t\t} else if (fieldData instanceof Set || typeof fieldData === 'object') {\n\t\t\t\tsubTreeDataStore.set(placeholderName, fieldData)\n\t\t\t} else {\n\t\t\t\tthis.rejectData()\n\t\t\t}\n\t\t}\n\t\treturn presentIds\n\t}\n\n\tpublic static mergeInMutationResponse(\n\t\toriginal: NormalizedPersistedData,\n\t\tnewPersistedData: ReceivedDataTree,\n\t): Set<string> {\n\t\tconst { subTreeDataStore, persistedEntityDataStore } = original\n\t\tconst presentIds: Set<string> = new Set()\n\n\t\tfor (const operationAlias in newPersistedData) {\n\t\t\tconst operation = MutationAlias.decodeTopLevel(operationAlias)\n\n\t\t\tif (operation === undefined) {\n\t\t\t\treturn this.rejectData()\n\t\t\t}\n\t\t\tconst { type, entityId, subTreeType, subTreePlaceholder } = operation\n\n\t\t\tswitch (type) {\n\t\t\t\tcase mutationOperationType.update:\n\t\t\t\tcase mutationOperationType.create: {\n\t\t\t\t\tconst treeDatum = newPersistedData[operationAlias]\n\t\t\t\t\tconst fieldData = this.createFieldData(persistedEntityDataStore, treeDatum)\n\n\t\t\t\t\tif (subTreeType === mutationOperationSubTreeType.singleEntity) {\n\t\t\t\t\t\tif (fieldData instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\tsubTreeDataStore.set(subTreePlaceholder, fieldData)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (subTreeType === mutationOperationSubTreeType.entityList) {\n\t\t\t\t\t\tif (fieldData instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\tif (type === mutationOperationType.create) {\n\t\t\t\t\t\t\t\tconst list = subTreeDataStore.get(subTreePlaceholder)\n\n\t\t\t\t\t\t\t\tif (list instanceof Set) {\n\t\t\t\t\t\t\t\t\t// TODO this is somewhat dubious because we're essentially just guessing the order of the entities\n\t\t\t\t\t\t\t\t\t//\t\tand just carelessly put the new one at the end.\n\t\t\t\t\t\t\t\t\tlist.add(fieldData.value)\n\t\t\t\t\t\t\t\t} else if (list === undefined) {\n\t\t\t\t\t\t\t\t\t// That's fine. This is probably just an isCreating sub-tree.\n\t\t\t\t\t\t\t\t\tsubTreeDataStore.set(subTreePlaceholder, new Set([fieldData.value]))\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(subTreeType)\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase mutationOperationType.delete: {\n\t\t\t\t\t// TODO there are potentially some references to entityId that this whole process won't quite remove.\n\t\t\t\t\t//\t\tThat's a memory leak. Probably not particularly severe in most cases but still.\n\t\t\t\t\tpersistedEntityDataStore.delete(entityId)\n\t\t\t\t\tif (subTreeType === mutationOperationSubTreeType.singleEntity) {\n\t\t\t\t\t\tsubTreeDataStore.delete(subTreePlaceholder)\n\t\t\t\t\t} else if (subTreeType === mutationOperationSubTreeType.entityList) {\n\t\t\t\t\t\tconst list = subTreeDataStore.get(subTreePlaceholder)\n\n\t\t\t\t\t\tif (!(list instanceof Set)) {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlist.delete(entityId)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(subTreeType)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(type)\n\t\t\t}\n\t\t}\n\t\treturn presentIds\n\t}\n\n\tprivate static createFieldData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\tfieldData: ReceivedFieldData,\n\t): EntityFieldPersistedData {\n\t\tif (Array.isArray(fieldData)) {\n\t\t\tconst subTreeListIds = new Set<string>()\n\t\t\tfor (const entityDatum of fieldData) {\n\t\t\t\tsubTreeListIds.add(this.createEntityData(entityMap, entityDatum))\n\t\t\t}\n\t\t\treturn subTreeListIds\n\t\t} else if (fieldData !== null && typeof fieldData === 'object') {\n\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, fieldData))\n\t\t} else {\n\t\t\treturn fieldData\n\t\t}\n\t}\n\n\tprivate static createEntityData(entityMap: PersistedEntityDataStore, entityData: ReceivedEntityData): string {\n\t\tconst primaryKey: string | undefined = entityData[PRIMARY_KEY_NAME]\n\n\t\tif (primaryKey === undefined) {\n\t\t\tthrow new BindingError(`The server has responded with an entity that lacks a primary key.`)\n\t\t}\n\n\t\tconst presentEntityData = entityMap.get(primaryKey)\n\n\t\tif (presentEntityData === undefined) {\n\t\t\tconst fieldsMap: SingleEntityPersistedData = new Map()\n\t\t\tentityMap.set(primaryKey, fieldsMap)\n\t\t\tfor (const field in entityData) {\n\t\t\t\tconst fieldDatum = entityData[field]\n\n\t\t\t\tfieldsMap.set(field, this.createFieldData(entityMap, fieldDatum))\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeInEntityData(entityMap, presentEntityData, entityData)\n\t\t}\n\t\treturn primaryKey\n\t}\n\n\tprivate static mergeInFieldData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\tfromTarget: EntityFieldPersistedData | undefined,\n\t\tnewDatum: ReceivedFieldData,\n\t): EntityFieldPersistedData {\n\t\tif (fromTarget === undefined) {\n\t\t\treturn this.createFieldData(entityMap, newDatum)\n\t\t}\n\t\tif (fromTarget instanceof ServerGeneratedUuid || (fromTarget === null && typeof newDatum === 'object')) {\n\t\t\tif (newDatum === null) {\n\t\t\t\treturn null\n\t\t\t} else if (typeof newDatum === 'object' && !Array.isArray(newDatum)) {\n\t\t\t\tconst newId = newDatum[PRIMARY_KEY_NAME]\n\t\t\t\tconst target = entityMap.get(newId)\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, newDatum))\n\t\t\t\t}\n\n\t\t\t\tif (fromTarget?.value === newId) {\n\t\t\t\t\tthis.mergeInEntityData(entityMap, target, newDatum)\n\t\t\t\t\treturn fromTarget\n\t\t\t\t} else {\n\t\t\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, newDatum))\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (fromTarget instanceof Set) {\n\t\t\tif (Array.isArray(newDatum)) {\n\t\t\t\tfromTarget.clear()\n\t\t\t\tfor (const entityData of newDatum) {\n\t\t\t\t\tfromTarget.add(this.createEntityData(entityMap, entityData))\n\t\t\t\t}\n\t\t\t\treturn fromTarget\n\t\t\t}\n\t\t} else if (!Array.isArray(newDatum) && (newDatum === null || typeof newDatum !== 'object')) {\n\t\t\treturn newDatum\n\t\t}\n\t\treturn this.rejectData()\n\t}\n\n\tprivate static mergeInEntityData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\ttarget: SingleEntityPersistedData,\n\t\tnewData: ReceivedEntityData,\n\t): SingleEntityPersistedData {\n\t\tfor (const field in newData) {\n\t\t\tconst fromTarget = target.get(field)\n\t\t\tconst newDatum = newData[field]\n\n\t\t\ttarget.set(field, this.mergeInFieldData(entityMap, fromTarget, newDatum))\n\t\t}\n\t\treturn target\n\t}\n\n\tprivate static rejectData(extraMessage?: string): never {\n\t\tthrow new BindingError(`Failed to process data received from the API.${extraMessage ? `\\n${extraMessage}` : ''}`)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;gCAeuC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E1C;AAAA;AAAA,eAEE,CAAC,MAAM,QAAQ,2BAA2B,QAAQ,OAAO,aAAa,WAAW;aACpF;AAAA;WAED,KAAK;AAAA;AAAA,SAGE,kBACd,WACA,QACA,SAC4B;eACjB,SAAS,SAAS;YACtB,aAAa,OAAO,IAAI;YACxB,WAAW,QAAQ;aAElB,IAAI,OAAO,KAAK,iBAAiB,WAAW,YAAY;AAAA;WAEzD;AAAA;AAAA,SAGO,WAAW,cAA8B;UACjD,IAAI,aAAa,gDAAgD,eAAe;AAAA,EAAK,iBAAiB;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"RequestResponseNormalizer.js","sources":["../../../src/core/RequestResponseNormalizer.ts"],"sourcesContent":["import {\n\tEntityFieldPersistedData,\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tReceivedEntityData,\n\tReceivedFieldData,\n\tServerGeneratedUuid,\n\tSingleEntityPersistedData,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { assertNever } from '../utils'\nimport { MutationAlias, mutationOperationSubTreeType, mutationOperationType } from './requestAliases'\n\nexport class RequestResponseNormalizer {\n\tpublic static mergeInQueryResponse(\n\t\toriginal: NormalizedPersistedData,\n\t\tnewPersistedData: ReceivedDataTree,\n\t): Set<string> {\n\t\tconst { subTreeDataStore, persistedEntityDataStore } = original\n\t\tconst presentIds: Set<string> = new Set()\n\n\t\tfor (const placeholderName in newPersistedData) {\n\t\t\tconst treeDatum = newPersistedData[placeholderName]\n\n\t\t\tconst fieldData = this.createFieldData(persistedEntityDataStore, treeDatum)\n\n\t\t\tif (fieldData === null) {\n\t\t\t\tsubTreeDataStore.delete(placeholderName)\n\t\t\t} else if (fieldData instanceof Set || typeof fieldData === 'object') {\n\t\t\t\tsubTreeDataStore.set(placeholderName, fieldData)\n\t\t\t} else {\n\t\t\t\tthis.rejectData()\n\t\t\t}\n\t\t}\n\t\treturn presentIds\n\t}\n\n\tpublic static mergeInMutationResponse(\n\t\toriginal: NormalizedPersistedData,\n\t\tnewPersistedData: ReceivedDataTree,\n\t): Set<string> {\n\t\tconst { subTreeDataStore, persistedEntityDataStore } = original\n\t\tconst presentIds: Set<string> = new Set()\n\n\t\tfor (const operationAlias in newPersistedData) {\n\t\t\tconst operation = MutationAlias.decodeTopLevel(operationAlias)\n\n\t\t\tif (operation === undefined) {\n\t\t\t\treturn this.rejectData()\n\t\t\t}\n\t\t\tconst { type, entityId, subTreeType, subTreePlaceholder } = operation\n\n\t\t\tswitch (type) {\n\t\t\t\tcase mutationOperationType.update:\n\t\t\t\tcase mutationOperationType.create: {\n\t\t\t\t\tconst treeDatum = newPersistedData[operationAlias]\n\t\t\t\t\tconst fieldData = this.createFieldData(persistedEntityDataStore, treeDatum)\n\n\t\t\t\t\tif (subTreeType === mutationOperationSubTreeType.singleEntity) {\n\t\t\t\t\t\tif (fieldData instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\tsubTreeDataStore.set(subTreePlaceholder, fieldData)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (subTreeType === mutationOperationSubTreeType.entityList) {\n\t\t\t\t\t\tif (fieldData instanceof ServerGeneratedUuid) {\n\t\t\t\t\t\t\tif (type === mutationOperationType.create) {\n\t\t\t\t\t\t\t\tconst list = subTreeDataStore.get(subTreePlaceholder)\n\n\t\t\t\t\t\t\t\tif (list instanceof Set) {\n\t\t\t\t\t\t\t\t\t// TODO this is somewhat dubious because we're essentially just guessing the order of the entities\n\t\t\t\t\t\t\t\t\t//\t\tand just carelessly put the new one at the end.\n\t\t\t\t\t\t\t\t\tlist.add(fieldData.value)\n\t\t\t\t\t\t\t\t} else if (list === undefined) {\n\t\t\t\t\t\t\t\t\t// That's fine. This is probably just an isCreating sub-tree.\n\t\t\t\t\t\t\t\t\tsubTreeDataStore.set(subTreePlaceholder, new Set([fieldData.value]))\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(subTreeType)\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase mutationOperationType.delete: {\n\t\t\t\t\t// TODO there are potentially some references to entityId that this whole process won't quite remove.\n\t\t\t\t\t//\t\tThat's a memory leak. Probably not particularly severe in most cases but still.\n\t\t\t\t\tpersistedEntityDataStore.delete(entityId)\n\t\t\t\t\tif (subTreeType === mutationOperationSubTreeType.singleEntity) {\n\t\t\t\t\t\tsubTreeDataStore.delete(subTreePlaceholder)\n\t\t\t\t\t} else if (subTreeType === mutationOperationSubTreeType.entityList) {\n\t\t\t\t\t\tconst list = subTreeDataStore.get(subTreePlaceholder)\n\n\t\t\t\t\t\tif (!(list instanceof Set)) {\n\t\t\t\t\t\t\treturn this.rejectData()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlist.delete(entityId)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn assertNever(subTreeType)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(type)\n\t\t\t}\n\t\t}\n\t\treturn presentIds\n\t}\n\n\tprivate static createFieldData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\tfieldData: ReceivedFieldData,\n\t): EntityFieldPersistedData {\n\t\tif (Array.isArray(fieldData)) {\n\t\t\tconst subTreeListIds = new Set<string>()\n\t\t\tfor (const entityDatum of fieldData) {\n\t\t\t\tsubTreeListIds.add(this.createEntityData(entityMap, entityDatum))\n\t\t\t}\n\t\t\treturn subTreeListIds\n\t\t} else if (fieldData !== null && typeof fieldData === 'object') {\n\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, fieldData))\n\t\t} else {\n\t\t\treturn fieldData\n\t\t}\n\t}\n\n\tprivate static createEntityData(entityMap: PersistedEntityDataStore, entityData: ReceivedEntityData): string {\n\t\tconst primaryKey: string | undefined = entityData[PRIMARY_KEY_NAME]\n\n\t\tif (primaryKey === undefined) {\n\t\t\tthrow new BindingError(`The server has responded with an entity that lacks a primary key.`)\n\t\t}\n\n\t\tconst presentEntityData = entityMap.get(primaryKey)\n\n\t\tif (presentEntityData === undefined) {\n\t\t\tconst fieldsMap: SingleEntityPersistedData = new Map()\n\t\t\tentityMap.set(primaryKey, fieldsMap)\n\t\t\tfor (const field in entityData) {\n\t\t\t\tconst fieldDatum = entityData[field]\n\n\t\t\t\tfieldsMap.set(field, this.createFieldData(entityMap, fieldDatum))\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeInEntityData(entityMap, presentEntityData, entityData)\n\t\t}\n\t\treturn primaryKey\n\t}\n\n\tprivate static mergeInFieldData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\tfromTarget: EntityFieldPersistedData | undefined,\n\t\tnewDatum: ReceivedFieldData,\n\t): EntityFieldPersistedData {\n\t\tif (fromTarget === undefined) {\n\t\t\treturn this.createFieldData(entityMap, newDatum)\n\t\t}\n\t\tif (fromTarget instanceof ServerGeneratedUuid || (fromTarget === null && typeof newDatum === 'object')) {\n\t\t\tif (newDatum === null) {\n\t\t\t\treturn null\n\t\t\t} else if (typeof newDatum === 'object' && !Array.isArray(newDatum)) {\n\t\t\t\tconst newId = newDatum[PRIMARY_KEY_NAME]\n\t\t\t\tconst target = entityMap.get(newId)\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, newDatum))\n\t\t\t\t}\n\n\t\t\t\tif (fromTarget?.value === newId) {\n\t\t\t\t\tthis.mergeInEntityData(entityMap, target, newDatum)\n\t\t\t\t\treturn fromTarget\n\t\t\t\t} else {\n\t\t\t\t\treturn new ServerGeneratedUuid(this.createEntityData(entityMap, newDatum))\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (fromTarget instanceof Set) {\n\t\t\tif (Array.isArray(newDatum)) {\n\t\t\t\tfromTarget.clear()\n\t\t\t\tfor (const entityData of newDatum) {\n\t\t\t\t\tfromTarget.add(this.createEntityData(entityMap, entityData))\n\t\t\t\t}\n\t\t\t\treturn fromTarget\n\t\t\t}\n\t\t} else if (!Array.isArray(newDatum) && (newDatum === null || typeof newDatum !== 'object')) {\n\t\t\treturn newDatum\n\t\t}\n\t\treturn this.rejectData()\n\t}\n\n\tprivate static mergeInEntityData(\n\t\tentityMap: PersistedEntityDataStore,\n\t\ttarget: SingleEntityPersistedData,\n\t\tnewData: ReceivedEntityData,\n\t): SingleEntityPersistedData {\n\t\tfor (const field in newData) {\n\t\t\tconst fromTarget = target.get(field)\n\t\t\tconst newDatum = newData[field]\n\n\t\t\ttarget.set(field, this.mergeInFieldData(entityMap, fromTarget, newDatum))\n\t\t}\n\t\treturn target\n\t}\n\n\tprivate static rejectData(extraMessage?: string): never {\n\t\tthrow new BindingError(`Failed to process data received from the API.${extraMessage ? `\\n${extraMessage}` : ''}`)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;gCAeuC;AAAA,SACxB,qBACb,UACA,kBACc;UACR,EAAE,kBAAkB,6BAA6B;UACjD,iCAA8B;eAEzB,mBAAmB,kBAAkB;YACzC,YAAY,iBAAiB;YAE7B,YAAY,KAAK,gBAAgB,0BAA0B;UAE7D,cAAc,MAAM;yBACN,OAAO;AAAA,iBACd,qBAAqB,OAAO,OAAO,cAAc,UAAU;yBACpD,IAAI,iBAAiB;AAAA,aAChC;aACD;AAAA;AAAA;WAGA;AAAA;AAAA,SAGM,wBACb,UACA,kBACc;UACR,EAAE,kBAAkB,6BAA6B;UACjD,iCAA8B;eAEzB,kBAAkB,kBAAkB;YACxC,YAAY,cAAc,eAAe;UAE3C,cAAc,QAAW;eACrB,KAAK;AAAA;YAEP,EAAE,M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CAA2C;gBACvC,IAAI,YAAY;iBACf,SAAS,YAAY;cACzB,aAAa,WAAW;kBAEpB,IAAI,OAAO,KAAK,gBAAgB,WAAW;AAAA;AAAA,WAEhD;WACD,kBAAkB,WAAW,mBAAmB;AAAA;WAE/C;AAAA;AAAA,SAGO,iBACd,WACA,YACA,UAC2B;QACvB,eAAe,QAAW;aACtB,KAAK,gBAAgB,WAAW;AAAA;QAEpC,sBAAsB,uBAAwB,eAAe,QAAQ,OAAO,aAAa,UAAW;UACnG,aAAa,MAAM;eACf;AAAA,iBACG,OAAO,aAAa,YAAY,CAAC,MAAM,QAAQ,WAAW;cAC9D,QAAQ,SAAS;cACjB,SAAS,UAAU,IAAI;YACzB,WAAW,QAAW;iBAClB,IAAI,oBAAoB,KAAK,iBAAiB,WAAW;AAAA;YAG7D,YAAY,UAAU,OAAO;eAC3B,kBAAkB,WAAW,QAAQ;iBACnC;AAAA,eACD;iBACC,IAAI,oBAAoB,KAAK,iBAAiB,WAAW;AAAA;AAAA;AAAA,eAGxD,sBAAsB,KAAK;UACjC,MAAM,QAAQ,WAAW;mBACjB;mBACA,cAAc,UAAU;qBACvB,IAAI,KAAK,iBAAiB,WAAW;AAAA;eAE1C;AAAA;AAAA,eAEE,CAAC,MAAM,QAAQ,2BAA2B,QAAQ,OAAO,aAAa,WAAW;aACpF;AAAA;WAED,KAAK;AAAA;AAAA,SAGE,kBACd,WACA,QACA,SAC4B;eACjB,SAAS,SAAS;YACtB,aAAa,OAAO,IAAI;YACxB,WAAW,QAAQ;aAElB,IAAI,OAAO,KAAK,iBAAiB,WAAW,YAAY;AAAA;WAEzD;AAAA;AAAA,SAGO,WAAW,cAA8B;UACjD,IAAI,aAAa,gDAAgD,eAAe;AAAA,EAAK,iBAAiB;AAAA;AAAA;;"}
|
|
@@ -40,7 +40,7 @@ class StateInitializer {
|
|
|
40
40
|
let subTreeState;
|
|
41
41
|
const persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName);
|
|
42
42
|
if (tree instanceof EntityListSubTreeMarker) {
|
|
43
|
-
const persistedEntityIds = persistedRootData instanceof Set ? persistedRootData : new Set();
|
|
43
|
+
const persistedEntityIds = persistedRootData instanceof Set ? persistedRootData : /* @__PURE__ */ new Set();
|
|
44
44
|
subTreeState = this.initializeEntityListState({ marker: tree, parent: void 0 }, tree.entityName, persistedEntityIds);
|
|
45
45
|
} else {
|
|
46
46
|
subTreeState = this.materializeEntityRealm(this.initializeEntityRealm(persistedRootData instanceof ServerGeneratedUuid ? persistedRootData : new UnpersistedEntityDummyId(), tree.entityName, {
|
|
@@ -81,7 +81,7 @@ class StateInitializer {
|
|
|
81
81
|
}
|
|
82
82
|
this.initializeFromFieldMarker(realm, field, value.value);
|
|
83
83
|
} else if (field instanceof HasManyRelationMarker) {
|
|
84
|
-
this.initializeFromHasManyRelationMarker(realm, field, new Set());
|
|
84
|
+
this.initializeFromHasManyRelationMarker(realm, field, /* @__PURE__ */ new Set());
|
|
85
85
|
} else if (field instanceof HasOneRelationMarker) {
|
|
86
86
|
let runtimeId;
|
|
87
87
|
let subCopyFrom = void 0;
|
|
@@ -114,7 +114,7 @@ class StateInitializer {
|
|
|
114
114
|
realmKey,
|
|
115
115
|
entity,
|
|
116
116
|
accessor: void 0,
|
|
117
|
-
children: new Map(),
|
|
117
|
+
children: /* @__PURE__ */ new Map(),
|
|
118
118
|
childrenWithPendingUpdates: void 0,
|
|
119
119
|
errors: void 0,
|
|
120
120
|
eventListeners: this.initializeEntityEventListenerStore(blueprint),
|
|
@@ -150,7 +150,7 @@ class StateInitializer {
|
|
|
150
150
|
if (field instanceof FieldMarker) {
|
|
151
151
|
this.initializeFromFieldMarker(entityRealm, field, fieldDatum);
|
|
152
152
|
} else if (field instanceof HasManyRelationMarker) {
|
|
153
|
-
this.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set());
|
|
153
|
+
this.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : /* @__PURE__ */ new Set());
|
|
154
154
|
} else if (field instanceof HasOneRelationMarker) {
|
|
155
155
|
let runtimeId;
|
|
156
156
|
if (pathBack?.fieldBackToParent === field.parameters.field) {
|
|
@@ -188,7 +188,7 @@ class StateInitializer {
|
|
|
188
188
|
id,
|
|
189
189
|
isScheduledForDeletion: false,
|
|
190
190
|
maidenId: id instanceof UnpersistedEntityDummyId ? id : void 0,
|
|
191
|
-
realms: new Map()
|
|
191
|
+
realms: /* @__PURE__ */ new Map()
|
|
192
192
|
};
|
|
193
193
|
this.treeStore.entityStore.set(entityId, entityState);
|
|
194
194
|
return entityState;
|
|
@@ -240,7 +240,14 @@ class StateInitializer {
|
|
|
240
240
|
hasUnpersistedChanges: false,
|
|
241
241
|
getAccessor: () => {
|
|
242
242
|
if (fieldState.accessor === void 0) {
|
|
243
|
-
|
|
243
|
+
const fieldSchema = this.treeStore.schema.getEntityField(parent.entity.entityName, fieldMarker.fieldName);
|
|
244
|
+
if (!fieldSchema) {
|
|
245
|
+
throw new BindingError(`Unknown field ${parent.entity.entityName}.${fieldMarker.fieldName}.`);
|
|
246
|
+
}
|
|
247
|
+
if (fieldSchema.__typename !== "_Column") {
|
|
248
|
+
throw new BindingError(`Invalid type of field ${parent.entity.entityName}.${fieldMarker.fieldName}. Expected '_Column', '${fieldSchema.__typename}' found.`);
|
|
249
|
+
}
|
|
250
|
+
fieldState.accessor = new FieldAccessor(fieldState, this.fieldOperations, fieldState.placeholderName, fieldState.value, fieldState.persistedValue === void 0 ? null : fieldState.persistedValue, fieldState.fieldMarker.defaultValue, fieldState.errors, fieldState.hasUnpersistedChanges, fieldState.touchLog, fieldState.getAccessor, fieldSchema);
|
|
244
251
|
}
|
|
245
252
|
return fieldState.accessor;
|
|
246
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateInitializer.js","sources":["../../../src/core/StateInitializer.ts"],"sourcesContent":["import { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, FieldAccessor } from '../accessors'\nimport { EntityFieldPersistedData, RuntimeId, ServerGeneratedUuid, UnpersistedEntityDummyId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport {\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport { BijectiveIndexedMap } from '../structures'\nimport type {\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tEntityName,\n\tFieldEventListenerStore,\n\tFieldName,\n\tScalar,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { AccessorErrorManager } from './AccessorErrorManager'\nimport type { Config } from './Config'\nimport type { EventManager } from './EventManager'\nimport { EntityOperations, FieldOperations, ListOperations } from './operations'\nimport { RealmKeyGenerator } from './RealmKeyGenerator'\nimport {\n\tEntityListBlueprint,\n\tEntityListState,\n\tEntityRealmBlueprint,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n\tRootStateNode,\n} from './state'\nimport { TreeParameterMerger } from './TreeParameterMerger'\nimport type { TreeStore } from './TreeStore'\nimport { EventListenersStore } from '../treeParameters'\n\nexport class StateInitializer {\n\tprivate readonly fieldOperations: FieldOperations\n\tprivate readonly entityOperations: EntityOperations\n\tprivate readonly listOperations: ListOperations\n\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly config: Config,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {\n\t\tthis.fieldOperations = new FieldOperations(this.accessorErrorManager, this.eventManager, this, this.treeStore)\n\t\tthis.entityOperations = new EntityOperations(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.eventManager,\n\t\t\tthis,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.listOperations = new ListOperations(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.eventManager,\n\t\t\tthis,\n\t\t\tthis.treeStore,\n\t\t)\n\t}\n\n\tpublic initializeSubTree(tree: EntitySubTreeMarker | EntityListSubTreeMarker): RootStateNode {\n\t\tlet subTreeState: RootStateNode\n\t\tconst persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName)\n\n\t\tif (tree instanceof EntityListSubTreeMarker) {\n\t\t\tconst persistedEntityIds: Set<string> = persistedRootData instanceof Set ? persistedRootData : new Set()\n\t\t\tsubTreeState = this.initializeEntityListState(\n\t\t\t\t{ marker: tree, parent: undefined },\n\t\t\t\ttree.entityName,\n\t\t\t\tpersistedEntityIds,\n\t\t\t)\n\t\t} else {\n\t\t\tsubTreeState = this.materializeEntityRealm(\n\t\t\t\tthis.initializeEntityRealm(\n\t\t\t\t\tpersistedRootData instanceof ServerGeneratedUuid ? persistedRootData : new UnpersistedEntityDummyId(),\n\t\t\t\t\ttree.entityName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'subTree',\n\t\t\t\t\t\tmarker: tree,\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\treturn subTreeState\n\t}\n\n\tpublic initializeEntityRealm(\n\t\tid: RuntimeId,\n\t\tentityName: EntityName,\n\t\tblueprint: EntityRealmBlueprint,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\t// This is counter-intuitive a bit. The method can also return an EntityRealmState, not just a stub.\n\t\t// The reason is so that each call-site can just default to trying to initialize a stub without having to keep\n\t\t// in mind that the realm might have already been initialized.\n\n\t\tconst entity = this.initializeEntityState(id, entityName)\n\t\tconst realmKey = RealmKeyGenerator.getRealmKey(id, blueprint)\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tif (!copyFrom || copyFrom.type !== 'entityRealm') {\n\t\t\tconst stub: EntityRealmStateStub = {\n\t\t\t\ttype: 'entityRealmStub',\n\n\t\t\t\tblueprint,\n\t\t\t\tentity,\n\t\t\t\trealmKey,\n\t\t\t\tgetAccessor: () => this.materializeEntityRealm(stub).getAccessor(),\n\t\t\t}\n\t\t\tthis.registerEntityRealm(stub)\n\n\t\t\treturn stub\n\t\t}\n\t\tconst realm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(realm)\n\n\t\tconst marker = getEntityMarker(realm)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(realm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'field') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromFieldMarker(realm, field, value.value)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// todo: get from copyFrom\n\t\t\t\tthis.initializeFromHasManyRelationMarker(realm, field, new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tlet subCopyFrom: EntityRealmState | undefined = undefined\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\t\tif (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (value.type === 'entityRealm') {\n\t\t\t\t\t\tsubCopyFrom = value\n\t\t\t\t\t\truntimeId = value.entity.id\n\t\t\t\t\t} else {\n\t\t\t\t\t\truntimeId = new UnpersistedEntityDummyId()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(realm)\n\t\treturn realm\n\t}\n\n\tprivate createEntityRealm(blueprint: EntityRealmBlueprint, realmKey: string, entity: EntityState): EntityRealmState {\n\t\tconst entityRealm: EntityRealmState = {\n\t\t\ttype: 'entityRealm',\n\n\t\t\tblueprint,\n\t\t\trealmKey,\n\t\t\tentity,\n\n\t\t\taccessor: undefined,\n\t\t\tchildren: new Map(),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\terrors: undefined,\n\t\t\teventListeners: this.initializeEntityEventListenerStore(blueprint),\n\t\t\tfieldsWithPendingConnectionUpdates: undefined,\n\t\t\tplannedHasOneDeletions: undefined,\n\t\t\tunpersistedChangesCount: 0,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityRealm.accessor === undefined) {\n\t\t\t\t\tconst entity = entityRealm.entity\n\t\t\t\t\tentityRealm.accessor = new EntityAccessor(\n\t\t\t\t\t\tentityRealm,\n\t\t\t\t\t\tthis.entityOperations,\n\t\t\t\t\t\tentity.id,\n\t\t\t\t\t\tentityRealm.realmKey,\n\t\t\t\t\t\tentity.entityName,\n\n\t\t\t\t\t\t// We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and\n\t\t\t\t\t\t// keep in sync two copies of the same data. TS hides the extra info anyway.\n\t\t\t\t\t\tentityRealm.children,\n\t\t\t\t\t\tthis.treeStore.persistedEntityData.get(entity.id.value),\n\t\t\t\t\t\tentityRealm.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityRealm.errors,\n\t\t\t\t\t\tgetEntityMarker(entityRealm).environment,\n\t\t\t\t\t\tentityRealm.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityRealm.accessor\n\t\t\t},\n\t\t}\n\t\treturn entityRealm\n\t}\n\n\tprivate materializeEntityRealm(state: EntityRealmState | EntityRealmStateStub): EntityRealmState {\n\t\tif (state.type === 'entityRealm') {\n\t\t\treturn state\n\t\t}\n\t\tconst { realmKey, entity, blueprint } = state\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined && existing.type === 'entityRealm') {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityRealm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(entityRealm)\n\n\t\t// if (blueprint.creationParameters.forceCreation && !entity.id.existsOnServer) {\n\t\t// \tentityRealm.unpersistedChangesCount += 1\n\t\t// }\n\n\t\tconst persistedData = this.treeStore.persistedEntityData.get(entity.id.value)\n\n\t\tconst marker = getEntityMarker(state)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(entityRealm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tconst fieldDatum = persistedData?.get(placeholderName)\n\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tthis.initializeFromFieldMarker(entityRealm, field, fieldDatum)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// if (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t// \t// TODO this is probably wrong?\n\t\t\t\t// \tconst ids = pathBack.parent.children.get(field.placeholderName)\n\t\t\t\t// \tconst newData = this.treeStore.persistedEntityData.get(pathBack.parent.entity.id.value)\n\t\t\t\t// \tconsole.log('many?', pathBack, field, entityRealm, fieldDatum, ids)\n\t\t\t\t// }\n\t\t\t\tthis.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\truntimeId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityRealm)\n\n\t\treturn entityRealm\n\t}\n\n\tprivate registerEntityRealm(entityRealm: EntityRealmState | EntityRealmStateStub) {\n\t\tconst { realmKey, blueprint, entity } = entityRealm\n\n\t\tthis.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm)\n\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tblueprint.parent.children.set(entity.id.value, entityRealm)\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tblueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm)\n\t\t}\n\t\tentity.realms.set(realmKey, entityRealm)\n\t}\n\n\tpublic initializeEntityState(id: RuntimeId, entityName: EntityName): EntityState {\n\t\tconst entityId = id.value\n\n\t\tconst existing = this.treeStore.entityStore.get(entityId)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityState: EntityState = {\n\t\t\tentityName,\n\t\t\thasIdSetInStone: id instanceof ServerGeneratedUuid,\n\t\t\tid,\n\t\t\tisScheduledForDeletion: false,\n\t\t\tmaidenId: id instanceof UnpersistedEntityDummyId ? id : undefined,\n\t\t\trealms: new Map(),\n\t\t}\n\t\tthis.treeStore.entityStore.set(entityId, entityState)\n\n\t\treturn entityState\n\t}\n\n\tprivate initializeEntityListState(\n\t\tblueprint: EntityListBlueprint,\n\t\tentityName: EntityName,\n\t\tinitialEntityIds: Set<string>,\n\t): EntityListState {\n\t\tconst entityListState: EntityListState = {\n\t\t\ttype: 'entityList',\n\t\t\taccessor: undefined,\n\t\t\tblueprint,\n\t\t\tchildren: new BijectiveIndexedMap(realm => realm.entity.id.value),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\tentityName,\n\t\t\teventListeners: this.initializeEntityListEventListenerStore(blueprint),\n\t\t\tchildEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),\n\t\t\terrors: undefined,\n\t\t\tplannedRemovals: undefined,\n\t\t\tunpersistedChangesCount: 0, // TODO force creation?\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityListState.accessor === undefined) {\n\t\t\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState)\n\t\t\t\t\tentityListState.accessor = new EntityListAccessor(\n\t\t\t\t\t\tentityListState,\n\t\t\t\t\t\tthis.listOperations,\n\t\t\t\t\t\tentityListState.children,\n\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\tentityListState.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityListState.errors,\n\t\t\t\t\t\tentityListState.blueprint.marker.environment,\n\t\t\t\t\t\tentityListState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityListState.accessor\n\t\t\t},\n\t\t}\n\n\t\tconst initialData: Iterable<string | undefined> =\n\t\t\tinitialEntityIds.size === 0\n\t\t\t\t? Array.from({ length: blueprint.marker.parameters.initialEntityCount })\n\t\t\t\t: initialEntityIds\n\t\tfor (const entityId of initialData) {\n\t\t\tthis.initializeEntityRealm(\n\t\t\t\tentityId ? new ServerGeneratedUuid(entityId) : new UnpersistedEntityDummyId(),\n\t\t\t\tentityListState.entityName,\n\t\t\t\t{\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: entityListState,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityListState)\n\n\t\treturn entityListState\n\t}\n\n\tprivate initializeFieldState(\n\t\tparent: EntityRealmState,\n\t\tplaceholderName: FieldName,\n\t\tfieldMarker: FieldMarker,\n\t\tpersistedValue: Scalar | undefined,\n\t): FieldState {\n\t\tconst resolvedFieldValue = persistedValue ?? fieldMarker.defaultValue ?? null\n\n\t\tconst fieldState: FieldState = {\n\t\t\ttype: 'field',\n\t\t\taccessor: undefined,\n\t\t\tfieldMarker,\n\t\t\tplaceholderName,\n\t\t\tpersistedValue,\n\t\t\tparent,\n\t\t\tvalue: resolvedFieldValue,\n\t\t\teventListeners: this.initializeFieldEventListenerStore(fieldMarker),\n\t\t\terrors: undefined,\n\t\t\ttouchLog: undefined,\n\t\t\thasUnpersistedChanges: false,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (fieldState.accessor === undefined) {\n\t\t\t\t\tfieldState.accessor = new FieldAccessor(\n\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\tthis.fieldOperations,\n\t\t\t\t\t\tfieldState.placeholderName,\n\t\t\t\t\t\tfieldState.value,\n\t\t\t\t\t\tfieldState.persistedValue === undefined ? null : fieldState.persistedValue,\n\t\t\t\t\t\tfieldState.fieldMarker.defaultValue,\n\t\t\t\t\t\tfieldState.errors,\n\t\t\t\t\t\tfieldState.hasUnpersistedChanges,\n\t\t\t\t\t\tfieldState.touchLog,\n\t\t\t\t\t\tfieldState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn fieldState.accessor\n\t\t\t},\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(fieldState)\n\t\treturn fieldState\n\t}\n\n\tprivate initializeFromFieldMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: FieldMarker,\n\t\tfieldDatum: EntityFieldPersistedData | undefined,\n\t) {\n\t\tif (fieldDatum instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a collection of referenced entities where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t\t)\n\t\t}\n\t\tif (fieldDatum instanceof ServerGeneratedUuid) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a referenced entity where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use <HasOne />?`,\n\t\t\t)\n\t\t}\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeFieldState(parent, field.placeholderName, field, fieldDatum),\n\t\t)\n\t}\n\n\tprivate initializeFromHasOneRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasOneRelationMarker,\n\t\tentityId: RuntimeId,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {\n\t\t\t\ttype: 'hasOne',\n\t\t\t\tparent,\n\t\t\t\tmarker: field,\n\t\t\t}, copyFrom),\n\t\t)\n\t\t// if (fieldDatum instanceof ServerGeneratedUuid || fieldDatum === null || fieldDatum === undefined) {\n\t\t// \tconst entityId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t//\n\t\t//\n\t\t// } else if (fieldDatum instanceof Set) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a collection of entities for field '${relation.field}' where a single entity was expected. ` +\n\t\t// \t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a single entity was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate initializeFromHasManyRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasManyRelationMarker,\n\t\tpersistedEntityIds: Set<string>,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityListState(\n\t\t\t\t{ marker: field, parent },\n\t\t\t\tthis.getRelationTargetEntityName(parent, field),\n\t\t\t\tpersistedEntityIds,\n\t\t\t),\n\t\t)\n\t\t// const relation = field.parameters\n\t\t//\n\t\t// if (fieldDatum === undefined || fieldDatum instanceof Set) {\n\t\t//\n\t\t// } else if (typeof fieldDatum === 'object') {\n\t\t// \t// Intentionally allowing `fieldDatum === null` here as well since this should only happen when a *hasOne\n\t\t// \t// relation is unlinked, e.g. a Person does not have a linked Nationality.\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a referenced entity for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you wanted to use a <HasOne />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate getRelationTargetEntityName(\n\t\tentityRealm: EntityRealmState,\n\t\tfield: HasOneRelationMarker | HasManyRelationMarker,\n\t): EntityName {\n\t\tconst targetField = this.treeStore.schema.getEntityField(entityRealm.entity.entityName, field.parameters.field)\n\n\t\tif (targetField?.__typename !== '_Relation') {\n\t\t\tthrow new BindingError() // This should have been validated elsewhere.\n\t\t}\n\t\treturn targetField.targetEntity\n\t}\n\n\tpublic runImmediateUserInitialization(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tinitialize: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tif (initialize === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst entityRealm = this.materializeEntityRealm(realm)\n\n\t\trealm.getAccessor().batchUpdates(initialize)\n\n\t\tconst initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: 'initialize' })\n\t\tif (initializeListeners === undefined || initializeListeners.size === 0) {\n\t\t\trealm.entity.hasIdSetInStone = true\n\t\t}\n\t}\n\n\tpublic initializeEntityEventListenerStore(blueprint: EntityRealmBlueprint): EntityEventListenerStore | undefined {\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tconst blueprintListeners = blueprint.parent.blueprint.marker.parameters.childEventListeners\n\t\t\tconst childInitialize = blueprintListeners?.get({ type: 'initialize' })\n\t\t\tconst store: EntityEventListenerStore = new EventListenersStore(() => blueprint.parent.childEventListeners)\n\n\t\t\tif (childInitialize !== undefined) {\n\t\t\t\tstore.set({ type: 'initialize' }, childInitialize)\n\t\t\t}\n\t\t\treturn store\n\t\t}\n\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityListEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneEntityListEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListChildEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.childEventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeFieldEventListenerStore(marker: FieldMarker): FieldEventListenerStore | undefined {\n\t\t// TODO !!!\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;uBAwC8B;AAAA,EAKtB,YACW,sBACA,qBACA,QACA,cACA,WAChB;AAVe;AACA;AACA;;;;;;SASX,kBAAkB,IAAI,gBAAgB,KAAK,sBAAsB,KAAK,cAAc,MAAM,KAAK;SAC/F,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBACL,KAAK,cACL,MACA,KAAK;SAED,iBAAiB,IAAI,eACzB,KAAK,sBACL,KAAK,qBACL,KAAK,cACL,MACA,KAAK;AAAA;AAAA,EAIA,kBAAkB,MAAoE;QACxF;UACE,oBAAoB,KAAK,UAAU,qBAAqB,IAAI,KAAK;QAEnE,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4CACP,WACuC;UACjC,qBAAqB,UAAU,OAAO,WAAW;QAEnD,uBAAuB,QAAW;aAC9B;AAAA;WAED,oBAAoB,gCAAgC;AAAA;AAAA,EAGpD,kCAAkC,QAA0D;WAE5F;AAAA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"StateInitializer.js","sources":["../../../src/core/StateInitializer.ts"],"sourcesContent":["import { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, FieldAccessor } from '../accessors'\nimport { EntityFieldPersistedData, RuntimeId, ServerGeneratedUuid, UnpersistedEntityDummyId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport {\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport { BijectiveIndexedMap } from '../structures'\nimport type {\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tEntityName,\n\tFieldEventListenerStore,\n\tFieldName,\n\tScalar,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { AccessorErrorManager } from './AccessorErrorManager'\nimport type { Config } from './Config'\nimport type { EventManager } from './EventManager'\nimport { EntityOperations, FieldOperations, ListOperations } from './operations'\nimport { RealmKeyGenerator } from './RealmKeyGenerator'\nimport {\n\tEntityListBlueprint,\n\tEntityListState,\n\tEntityRealmBlueprint,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n\tRootStateNode,\n} from './state'\nimport { TreeParameterMerger } from './TreeParameterMerger'\nimport type { TreeStore } from './TreeStore'\nimport { EventListenersStore } from '../treeParameters'\n\nexport class StateInitializer {\n\tprivate readonly fieldOperations: FieldOperations\n\tprivate readonly entityOperations: EntityOperations\n\tprivate readonly listOperations: ListOperations\n\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly config: Config,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {\n\t\tthis.fieldOperations = new FieldOperations(this.accessorErrorManager, this.eventManager, this, this.treeStore)\n\t\tthis.entityOperations = new EntityOperations(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.eventManager,\n\t\t\tthis,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.listOperations = new ListOperations(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.eventManager,\n\t\t\tthis,\n\t\t\tthis.treeStore,\n\t\t)\n\t}\n\n\tpublic initializeSubTree(tree: EntitySubTreeMarker | EntityListSubTreeMarker): RootStateNode {\n\t\tlet subTreeState: RootStateNode\n\t\tconst persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName)\n\n\t\tif (tree instanceof EntityListSubTreeMarker) {\n\t\t\tconst persistedEntityIds: Set<string> = persistedRootData instanceof Set ? persistedRootData : new Set()\n\t\t\tsubTreeState = this.initializeEntityListState(\n\t\t\t\t{ marker: tree, parent: undefined },\n\t\t\t\ttree.entityName,\n\t\t\t\tpersistedEntityIds,\n\t\t\t)\n\t\t} else {\n\t\t\tsubTreeState = this.materializeEntityRealm(\n\t\t\t\tthis.initializeEntityRealm(\n\t\t\t\t\tpersistedRootData instanceof ServerGeneratedUuid ? persistedRootData : new UnpersistedEntityDummyId(),\n\t\t\t\t\ttree.entityName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'subTree',\n\t\t\t\t\t\tmarker: tree,\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\treturn subTreeState\n\t}\n\n\tpublic initializeEntityRealm(\n\t\tid: RuntimeId,\n\t\tentityName: EntityName,\n\t\tblueprint: EntityRealmBlueprint,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\t// This is counter-intuitive a bit. The method can also return an EntityRealmState, not just a stub.\n\t\t// The reason is so that each call-site can just default to trying to initialize a stub without having to keep\n\t\t// in mind that the realm might have already been initialized.\n\n\t\tconst entity = this.initializeEntityState(id, entityName)\n\t\tconst realmKey = RealmKeyGenerator.getRealmKey(id, blueprint)\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tif (!copyFrom || copyFrom.type !== 'entityRealm') {\n\t\t\tconst stub: EntityRealmStateStub = {\n\t\t\t\ttype: 'entityRealmStub',\n\n\t\t\t\tblueprint,\n\t\t\t\tentity,\n\t\t\t\trealmKey,\n\t\t\t\tgetAccessor: () => this.materializeEntityRealm(stub).getAccessor(),\n\t\t\t}\n\t\t\tthis.registerEntityRealm(stub)\n\n\t\t\treturn stub\n\t\t}\n\t\tconst realm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(realm)\n\n\t\tconst marker = getEntityMarker(realm)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(realm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'field') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromFieldMarker(realm, field, value.value)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// todo: get from copyFrom\n\t\t\t\tthis.initializeFromHasManyRelationMarker(realm, field, new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tlet subCopyFrom: EntityRealmState | undefined = undefined\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\t\tif (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (value.type === 'entityRealm') {\n\t\t\t\t\t\tsubCopyFrom = value\n\t\t\t\t\t\truntimeId = value.entity.id\n\t\t\t\t\t} else {\n\t\t\t\t\t\truntimeId = new UnpersistedEntityDummyId()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(realm)\n\t\treturn realm\n\t}\n\n\tprivate createEntityRealm(blueprint: EntityRealmBlueprint, realmKey: string, entity: EntityState): EntityRealmState {\n\t\tconst entityRealm: EntityRealmState = {\n\t\t\ttype: 'entityRealm',\n\n\t\t\tblueprint,\n\t\t\trealmKey,\n\t\t\tentity,\n\n\t\t\taccessor: undefined,\n\t\t\tchildren: new Map(),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\terrors: undefined,\n\t\t\teventListeners: this.initializeEntityEventListenerStore(blueprint),\n\t\t\tfieldsWithPendingConnectionUpdates: undefined,\n\t\t\tplannedHasOneDeletions: undefined,\n\t\t\tunpersistedChangesCount: 0,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityRealm.accessor === undefined) {\n\t\t\t\t\tconst entity = entityRealm.entity\n\t\t\t\t\tentityRealm.accessor = new EntityAccessor(\n\t\t\t\t\t\tentityRealm,\n\t\t\t\t\t\tthis.entityOperations,\n\t\t\t\t\t\tentity.id,\n\t\t\t\t\t\tentityRealm.realmKey,\n\t\t\t\t\t\tentity.entityName,\n\n\t\t\t\t\t\t// We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and\n\t\t\t\t\t\t// keep in sync two copies of the same data. TS hides the extra info anyway.\n\t\t\t\t\t\tentityRealm.children,\n\t\t\t\t\t\tthis.treeStore.persistedEntityData.get(entity.id.value),\n\t\t\t\t\t\tentityRealm.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityRealm.errors,\n\t\t\t\t\t\tgetEntityMarker(entityRealm).environment,\n\t\t\t\t\t\tentityRealm.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityRealm.accessor\n\t\t\t},\n\t\t}\n\t\treturn entityRealm\n\t}\n\n\tprivate materializeEntityRealm(state: EntityRealmState | EntityRealmStateStub): EntityRealmState {\n\t\tif (state.type === 'entityRealm') {\n\t\t\treturn state\n\t\t}\n\t\tconst { realmKey, entity, blueprint } = state\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined && existing.type === 'entityRealm') {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityRealm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(entityRealm)\n\n\t\t// if (blueprint.creationParameters.forceCreation && !entity.id.existsOnServer) {\n\t\t// \tentityRealm.unpersistedChangesCount += 1\n\t\t// }\n\n\t\tconst persistedData = this.treeStore.persistedEntityData.get(entity.id.value)\n\n\t\tconst marker = getEntityMarker(state)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(entityRealm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tconst fieldDatum = persistedData?.get(placeholderName)\n\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tthis.initializeFromFieldMarker(entityRealm, field, fieldDatum)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// if (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t// \t// TODO this is probably wrong?\n\t\t\t\t// \tconst ids = pathBack.parent.children.get(field.placeholderName)\n\t\t\t\t// \tconst newData = this.treeStore.persistedEntityData.get(pathBack.parent.entity.id.value)\n\t\t\t\t// \tconsole.log('many?', pathBack, field, entityRealm, fieldDatum, ids)\n\t\t\t\t// }\n\t\t\t\tthis.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\truntimeId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityRealm)\n\n\t\treturn entityRealm\n\t}\n\n\tprivate registerEntityRealm(entityRealm: EntityRealmState | EntityRealmStateStub) {\n\t\tconst { realmKey, blueprint, entity } = entityRealm\n\n\t\tthis.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm)\n\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tblueprint.parent.children.set(entity.id.value, entityRealm)\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tblueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm)\n\t\t}\n\t\tentity.realms.set(realmKey, entityRealm)\n\t}\n\n\tpublic initializeEntityState(id: RuntimeId, entityName: EntityName): EntityState {\n\t\tconst entityId = id.value\n\n\t\tconst existing = this.treeStore.entityStore.get(entityId)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityState: EntityState = {\n\t\t\tentityName,\n\t\t\thasIdSetInStone: id instanceof ServerGeneratedUuid,\n\t\t\tid,\n\t\t\tisScheduledForDeletion: false,\n\t\t\tmaidenId: id instanceof UnpersistedEntityDummyId ? id : undefined,\n\t\t\trealms: new Map(),\n\t\t}\n\t\tthis.treeStore.entityStore.set(entityId, entityState)\n\n\t\treturn entityState\n\t}\n\n\tprivate initializeEntityListState(\n\t\tblueprint: EntityListBlueprint,\n\t\tentityName: EntityName,\n\t\tinitialEntityIds: Set<string>,\n\t): EntityListState {\n\t\tconst entityListState: EntityListState = {\n\t\t\ttype: 'entityList',\n\t\t\taccessor: undefined,\n\t\t\tblueprint,\n\t\t\tchildren: new BijectiveIndexedMap(realm => realm.entity.id.value),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\tentityName,\n\t\t\teventListeners: this.initializeEntityListEventListenerStore(blueprint),\n\t\t\tchildEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),\n\t\t\terrors: undefined,\n\t\t\tplannedRemovals: undefined,\n\t\t\tunpersistedChangesCount: 0, // TODO force creation?\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityListState.accessor === undefined) {\n\t\t\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState)\n\t\t\t\t\tentityListState.accessor = new EntityListAccessor(\n\t\t\t\t\t\tentityListState,\n\t\t\t\t\t\tthis.listOperations,\n\t\t\t\t\t\tentityListState.children,\n\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\tentityListState.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityListState.errors,\n\t\t\t\t\t\tentityListState.blueprint.marker.environment,\n\t\t\t\t\t\tentityListState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityListState.accessor\n\t\t\t},\n\t\t}\n\n\t\tconst initialData: Iterable<string | undefined> =\n\t\t\tinitialEntityIds.size === 0\n\t\t\t\t? Array.from({ length: blueprint.marker.parameters.initialEntityCount })\n\t\t\t\t: initialEntityIds\n\t\tfor (const entityId of initialData) {\n\t\t\tthis.initializeEntityRealm(\n\t\t\t\tentityId ? new ServerGeneratedUuid(entityId) : new UnpersistedEntityDummyId(),\n\t\t\t\tentityListState.entityName,\n\t\t\t\t{\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: entityListState,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityListState)\n\n\t\treturn entityListState\n\t}\n\n\tprivate initializeFieldState(\n\t\tparent: EntityRealmState,\n\t\tplaceholderName: FieldName,\n\t\tfieldMarker: FieldMarker,\n\t\tpersistedValue: Scalar | undefined,\n\t): FieldState {\n\t\tconst resolvedFieldValue = persistedValue ?? fieldMarker.defaultValue ?? null\n\n\t\tconst fieldState: FieldState = {\n\t\t\ttype: 'field',\n\t\t\taccessor: undefined,\n\t\t\tfieldMarker,\n\t\t\tplaceholderName,\n\t\t\tpersistedValue,\n\t\t\tparent,\n\t\t\tvalue: resolvedFieldValue,\n\t\t\teventListeners: this.initializeFieldEventListenerStore(fieldMarker),\n\t\t\terrors: undefined,\n\t\t\ttouchLog: undefined,\n\t\t\thasUnpersistedChanges: false,\n\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (fieldState.accessor === undefined) {\n\t\t\t\t\tconst fieldSchema = this.treeStore.schema.getEntityField(parent.entity.entityName, fieldMarker.fieldName)\n\t\t\t\t\tif (!fieldSchema) {\n\t\t\t\t\t\tthrow new BindingError(`Unknown field ${parent.entity.entityName}.${fieldMarker.fieldName}.`)\n\t\t\t\t\t}\n\t\t\t\t\tif (fieldSchema.__typename !== '_Column') {\n\t\t\t\t\t\tthrow new BindingError(`Invalid type of field ${parent.entity.entityName}.${fieldMarker.fieldName}. Expected '_Column', '${fieldSchema.__typename}' found.`)\n\t\t\t\t\t}\n\t\t\t\t\tfieldState.accessor = new FieldAccessor(\n\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\tthis.fieldOperations,\n\t\t\t\t\t\tfieldState.placeholderName,\n\t\t\t\t\t\tfieldState.value,\n\t\t\t\t\t\tfieldState.persistedValue === undefined ? null : fieldState.persistedValue,\n\t\t\t\t\t\tfieldState.fieldMarker.defaultValue,\n\t\t\t\t\t\tfieldState.errors,\n\t\t\t\t\t\tfieldState.hasUnpersistedChanges,\n\t\t\t\t\t\tfieldState.touchLog,\n\t\t\t\t\t\tfieldState.getAccessor,\n\t\t\t\t\t\tfieldSchema,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn fieldState.accessor\n\t\t\t},\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(fieldState)\n\t\treturn fieldState\n\t}\n\n\tprivate initializeFromFieldMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: FieldMarker,\n\t\tfieldDatum: EntityFieldPersistedData | undefined,\n\t) {\n\t\tif (fieldDatum instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a collection of referenced entities where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t\t)\n\t\t}\n\t\tif (fieldDatum instanceof ServerGeneratedUuid) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a referenced entity where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use <HasOne />?`,\n\t\t\t)\n\t\t}\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeFieldState(parent, field.placeholderName, field, fieldDatum),\n\t\t)\n\t}\n\n\tprivate initializeFromHasOneRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasOneRelationMarker,\n\t\tentityId: RuntimeId,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {\n\t\t\t\ttype: 'hasOne',\n\t\t\t\tparent,\n\t\t\t\tmarker: field,\n\t\t\t}, copyFrom),\n\t\t)\n\t\t// if (fieldDatum instanceof ServerGeneratedUuid || fieldDatum === null || fieldDatum === undefined) {\n\t\t// \tconst entityId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t//\n\t\t//\n\t\t// } else if (fieldDatum instanceof Set) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a collection of entities for field '${relation.field}' where a single entity was expected. ` +\n\t\t// \t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a single entity was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate initializeFromHasManyRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasManyRelationMarker,\n\t\tpersistedEntityIds: Set<string>,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityListState(\n\t\t\t\t{ marker: field, parent },\n\t\t\t\tthis.getRelationTargetEntityName(parent, field),\n\t\t\t\tpersistedEntityIds,\n\t\t\t),\n\t\t)\n\t\t// const relation = field.parameters\n\t\t//\n\t\t// if (fieldDatum === undefined || fieldDatum instanceof Set) {\n\t\t//\n\t\t// } else if (typeof fieldDatum === 'object') {\n\t\t// \t// Intentionally allowing `fieldDatum === null` here as well since this should only happen when a *hasOne\n\t\t// \t// relation is unlinked, e.g. a Person does not have a linked Nationality.\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a referenced entity for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you wanted to use a <HasOne />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate getRelationTargetEntityName(\n\t\tentityRealm: EntityRealmState,\n\t\tfield: HasOneRelationMarker | HasManyRelationMarker,\n\t): EntityName {\n\t\tconst targetField = this.treeStore.schema.getEntityField(entityRealm.entity.entityName, field.parameters.field)\n\n\t\tif (targetField?.__typename !== '_Relation') {\n\t\t\tthrow new BindingError() // This should have been validated elsewhere.\n\t\t}\n\t\treturn targetField.targetEntity\n\t}\n\n\tpublic runImmediateUserInitialization(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tinitialize: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tif (initialize === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst entityRealm = this.materializeEntityRealm(realm)\n\n\t\trealm.getAccessor().batchUpdates(initialize)\n\n\t\tconst initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: 'initialize' })\n\t\tif (initializeListeners === undefined || initializeListeners.size === 0) {\n\t\t\trealm.entity.hasIdSetInStone = true\n\t\t}\n\t}\n\n\tpublic initializeEntityEventListenerStore(blueprint: EntityRealmBlueprint): EntityEventListenerStore | undefined {\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tconst blueprintListeners = blueprint.parent.blueprint.marker.parameters.childEventListeners\n\t\t\tconst childInitialize = blueprintListeners?.get({ type: 'initialize' })\n\t\t\tconst store: EntityEventListenerStore = new EventListenersStore(() => blueprint.parent.childEventListeners)\n\n\t\t\tif (childInitialize !== undefined) {\n\t\t\t\tstore.set({ type: 'initialize' }, childInitialize)\n\t\t\t}\n\t\t\treturn store\n\t\t}\n\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityListEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneEntityListEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListChildEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.childEventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeFieldEventListenerStore(marker: FieldMarker): FieldEventListenerStore | undefined {\n\t\t// TODO !!!\n\t\treturn undefined\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;uBAwC8B;AAAA,EAKtB,YACW,sBACA,qBACA,QACA,cACA,WAChB;AAVe;AACA;AACA;;;;;;SASX,kBAAkB,IAAI,gBAAgB,KAAK,sBAAsB,KAAK,cAAc,MAAM,KAAK;SAC/F,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBACL,KAAK,cACL,MACA,KAAK;SAED,iBAAiB,IAAI,eACzB,KAAK,sBACL,KAAK,qBACL,KAAK,cACL,MACA,KAAK;AAAA;AAAA,EAIA,kBAAkB,MAAoE;QACxF;UACE,oBAAoB,KAAK,UAAU,qBAAqB,IAAI,KAAK;QAEnE,gBAAgB,yBAAyB;YACtC,qBAAkC,6BAA6B,MAAM,wCAAwB;qBACpF,KAAK,0BACnB,EAAE,QAAQ,MAAM,QAAQ,UACxB,KAAK,YACL;AAAA,WAEK;qBACS,KAAK,uBACnB,KAAK,sBACJ,6BAA6B,sBAAsB,oBAAoB,IAAI,4BAC3E,KAAK,YACL;AAAA,QACC,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA;AAAA;WAML;AAAA;AAAA,EAGD,sBACN,IACA,YACA,WACA,UAC0C;UAKpC,SAAS,KAAK,sBAAsB,IAAI;UACxC,WAAW,kBAAkB,YAAY,IAAI;UAE7C,WAAW,KAAK,UAAU,iBAAiB,IAAI;QACjD,aAAa,QAAW;aACpB;AAAA;QAGJ,CAAC,YAAY,SAAS,SAAS,eAAe;YAC3C,OAA6B;AAAA,QAClC,MAAM;AAAA,QAEN;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAa,MA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EAsBK,4BACP,aACA,OACa;UACP,cAAc,KAAK,UAAU,OAAO,eAAe,YAAY,OAAO,YAAY,MAAM,WAAW;QAErG,aAAa,eAAe,aAAa;YACtC,IAAI;AAAA;WAEJ,YAAY;AAAA;AAAA,EAGb,+BACN,OACA,YACC;QACG,eAAe,QAAW;;;UAGxB,cAAc,KAAK,uBAAuB;UAE1C,cAAc,aAAa;UAE3B,sBAAsB,KAAK,aAAa,kBAAkB,aAAa,EAAE,MAAM;QACjF,wBAAwB,UAAa,oBAAoB,SAAS,GAAG;YAClE,OAAO,kBAAkB;AAAA;AAAA;AAAA,EAI1B,mCAAmC,WAAuE;QAC5G,UAAU,SAAS,cAAc;YAC9B,sBAAqB,UAAU,OAAO,UAAU,OAAO,WAAW;YAClE,kBAAkB,qBAAoB,IAAI,EAAE,MAAM;YAClD,QAAkC,IAAI,oBAAoB,MAAM,UAAU,OAAO;UAEnF,oBAAoB,QAAW;cAC5B,IAAI,EAAE,MAAM,gBAAgB;AAAA;aAE5B;AAAA;UAGF,qBAAqB,UAAU,OAAO,WAAW;QACnD,uBAAuB,QAAW;aAC9B;AAAA;WAED,oBAAoB,gCAAgC;AAAA;AAAA,EAGpD,uCACP,WAC2C;UACrC,qBAAqB,UAAU,OAAO,WAAW;QAEnD,uBAAuB,QAAW;aAC9B;AAAA;WAED,oBAAoB,8BAA8B;AAAA;AAAA,EAGlD,4CACP,WACuC;UACjC,qBAAqB,UAAU,OAAO,WAAW;QAEnD,uBAAuB,QAAW;aAC9B;AAAA;WAED,oBAAoB,gCAAgC;AAAA;AAAA,EAGpD,kCAAkC,QAA0D;WAE5F;AAAA;AAAA;;"}
|
|
@@ -14,7 +14,7 @@ class TreeAugmenter {
|
|
|
14
14
|
this.treeStore.mergeInQueryResponse(newPersistedData);
|
|
15
15
|
}
|
|
16
16
|
extendTreeStates(newTreeId, newMarkerTree) {
|
|
17
|
-
const subTreeStates = new Map();
|
|
17
|
+
const subTreeStates = /* @__PURE__ */ new Map();
|
|
18
18
|
this.treeStore.markerTrees.set(newTreeId, newMarkerTree);
|
|
19
19
|
this.treeStore.subTreeStatesByRoot.set(newTreeId, subTreeStates);
|
|
20
20
|
for (const [placeholderName, newSubTreeMarker] of newMarkerTree.subTrees) {
|
|
@@ -141,7 +141,7 @@ class TreeAugmenter {
|
|
|
141
141
|
if (childData !== void 0 && !(childData instanceof Set)) {
|
|
142
142
|
throw new BindingError();
|
|
143
143
|
}
|
|
144
|
-
this.updateEntityListPersistedData(child, childData ?? new Set());
|
|
144
|
+
this.updateEntityListPersistedData(child, childData ?? /* @__PURE__ */ new Set());
|
|
145
145
|
break;
|
|
146
146
|
}
|
|
147
147
|
default: {
|