@contember/binding 1.1.0-beta.4 → 1.1.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/accessorPropagation/AccessorProvider.js +7 -14
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js +3 -7
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js +3 -7
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js +39 -56
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js +3 -7
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +104 -89
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorSorting/errors.js.map +1 -1
- package/dist/development/accessorSorting/useSortedEntities.js +15 -18
- package/dist/development/accessorSorting/useSortedEntities.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js +20 -39
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +1 -1
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +6 -6
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +16 -16
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/DirtinessTracker.js.map +1 -1
- package/dist/development/core/EventManager.js +11 -11
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +5 -5
- package/dist/development/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/development/core/MarkerTreeGenerator.js +6 -6
- package/dist/development/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +18 -12
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RealmKeyGenerator.js +2 -2
- package/dist/development/core/RealmKeyGenerator.js.map +1 -1
- package/dist/development/core/StateInitializer.js +8 -8
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeParameterMerger.js.map +1 -1
- package/dist/development/core/TreeStore.js +7 -7
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/exceptions/ErrorLocator.js +3 -3
- package/dist/development/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/development/core/schema/SchemaLoader.js +2 -2
- package/dist/development/core/schema/SchemaLoader.js.map +1 -1
- package/dist/development/core/state/StateIterator.js.map +1 -1
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +11 -11
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +11 -15
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +35 -31
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +41 -41
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +63 -51
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +28 -20
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +30 -33
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +30 -33
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js +12 -6
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/Environment.js +1 -1
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/FieldHelper.js +1 -1
- package/dist/development/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +83 -86
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js +5 -3
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js +50 -36
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/If.js +70 -63
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js +9 -5
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js +6 -13
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js +2 -2
- package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js +2 -2
- package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/development/markers/FieldMarker.js +2 -2
- package/dist/development/markers/FieldMarker.js.map +1 -1
- package/dist/development/markers/HasManyRelationMarker.js +3 -3
- package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/development/markers/HasOneRelationMarker.js +2 -2
- package/dist/development/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/development/queryLanguage/CacheStore.js +1 -1
- package/dist/development/queryLanguage/CacheStore.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +7 -7
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +6 -6
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/structures/BijectiveIndexedMap.js +1 -1
- 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.map +1 -1
- package/dist/production/accessorPropagation/AccessorProvider.js +2 -8
- package/dist/production/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/production/accessorPropagation/BindingOperationsProvider.js +2 -5
- package/dist/production/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EntityKeyProvider.js +2 -5
- package/dist/production/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EnvironmentContext.js +23 -43
- package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/production/accessorPropagation/TreeRootIdProvider.js +2 -5
- package/dist/production/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js +62 -62
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/accessorSorting/errors.js.map +1 -1
- package/dist/production/accessorSorting/useSortedEntities.js +15 -18
- package/dist/production/accessorSorting/useSortedEntities.js.map +1 -1
- package/dist/production/accessorTree/AccessorTree.js +3 -21
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js +1 -1
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +6 -6
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +16 -16
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/DirtinessTracker.js.map +1 -1
- package/dist/production/core/EventManager.js +11 -11
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +5 -5
- package/dist/production/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/production/core/MarkerTreeGenerator.js +6 -6
- package/dist/production/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +18 -12
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RealmKeyGenerator.js +2 -2
- package/dist/production/core/RealmKeyGenerator.js.map +1 -1
- package/dist/production/core/StateInitializer.js +8 -8
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeParameterMerger.js.map +1 -1
- package/dist/production/core/TreeStore.js +7 -7
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/exceptions/ErrorLocator.js +3 -3
- package/dist/production/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/production/core/schema/SchemaLoader.js +2 -2
- package/dist/production/core/schema/SchemaLoader.js.map +1 -1
- package/dist/production/core/state/StateIterator.js.map +1 -1
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js +10 -9
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/Entity.js +7 -10
- package/dist/production/coreComponents/Entity.js.map +1 -1
- package/dist/production/coreComponents/EntityList.js +25 -28
- package/dist/production/coreComponents/EntityList.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js +29 -28
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js +39 -34
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/Field.js +20 -20
- package/dist/production/coreComponents/Field.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js +18 -20
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js +18 -20
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/coreComponents/ParentEntity.js +8 -6
- package/dist/production/coreComponents/ParentEntity.js.map +1 -1
- package/dist/production/dao/Environment.js +1 -1
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/FieldHelper.js +1 -1
- package/dist/production/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.js +67 -77
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/EntityView.js +1 -3
- package/dist/production/helperComponents/EntityView.js.map +1 -1
- package/dist/production/helperComponents/FieldView.js +38 -31
- package/dist/production/helperComponents/FieldView.js.map +1 -1
- package/dist/production/helperComponents/If.js +40 -52
- package/dist/production/helperComponents/If.js.map +1 -1
- package/dist/production/helperComponents/StaticRender.js +5 -5
- package/dist/production/helperComponents/StaticRender.js.map +1 -1
- package/dist/production/helperComponents/SugaredField.js +2 -8
- package/dist/production/helperComponents/SugaredField.js.map +1 -1
- package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js +2 -2
- package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js +2 -2
- package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/production/markers/FieldMarker.js +2 -2
- package/dist/production/markers/FieldMarker.js.map +1 -1
- package/dist/production/markers/HasManyRelationMarker.js +2 -2
- package/dist/production/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/production/markers/HasOneRelationMarker.js +2 -2
- package/dist/production/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/production/queryLanguage/CacheStore.js +1 -1
- package/dist/production/queryLanguage/CacheStore.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +7 -7
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +6 -6
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/structures/BijectiveIndexedMap.js +1 -1
- 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.map +1 -1
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +1 -1
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -1
- package/dist/types/accessorSorting/SortedEntities.d.ts +1 -1
- package/dist/types/accessorSorting/SortedEntities.d.ts.map +1 -1
- package/dist/types/accessorSorting/errors.d.ts +0 -3
- package/dist/types/accessorSorting/errors.d.ts.map +1 -1
- package/dist/types/accessorSorting/useSortedEntities.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeState.d.ts +1 -1
- package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +1 -1
- package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationRequestResponse.d.ts +3 -3
- package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +5 -5
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
- package/dist/types/accessorTree/PersistResult.d.ts +2 -2
- package/dist/types/accessorTree/PersistResult.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +3 -3
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
- package/dist/types/accessorTree/RequestError.d.ts +1 -1
- package/dist/types/accessorTree/RequestError.d.ts.map +1 -1
- package/dist/types/accessorTree/RuntimeId.d.ts +2 -2
- package/dist/types/accessorTree/RuntimeId.d.ts.map +1 -1
- package/dist/types/accessors/ExtendTree.d.ts +1 -1
- package/dist/types/accessors/ExtendTree.d.ts.map +1 -1
- package/dist/types/accessors/GetEntityByKey.d.ts +1 -1
- package/dist/types/accessors/GetEntityByKey.d.ts.map +1 -1
- package/dist/types/accessors/GetEntityListSubTree.d.ts +1 -1
- package/dist/types/accessors/GetEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessors/GetEntitySubTree.d.ts +1 -1
- package/dist/types/accessors/GetEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessors/Persist.d.ts +1 -1
- package/dist/types/accessors/Persist.d.ts.map +1 -1
- package/dist/types/accessors/PersistErrorOptions.d.ts +1 -1
- package/dist/types/accessors/PersistErrorOptions.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts +3 -2
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/core/QueryGenerator.d.ts +1 -1
- package/dist/types/core/QueryGenerator.d.ts.map +1 -1
- package/dist/types/core/exceptions/RawMarkerPath.d.ts +1 -1
- package/dist/types/core/exceptions/RawMarkerPath.d.ts.map +1 -1
- package/dist/types/core/schema/RawSchemaEntity.d.ts +1 -1
- package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaColumnType.d.ts +2 -2
- package/dist/types/core/schema/SchemaColumnType.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaEntities.d.ts +1 -1
- package/dist/types/core/schema/SchemaEntities.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaEnums.d.ts +3 -3
- package/dist/types/core/schema/SchemaEnums.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaField.d.ts +1 -1
- package/dist/types/core/schema/SchemaField.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaFields.d.ts +1 -1
- package/dist/types/core/schema/SchemaFields.d.ts.map +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
- package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
- package/dist/types/core/state/EntityListState.d.ts +1 -1
- package/dist/types/core/state/EntityListState.d.ts.map +1 -1
- package/dist/types/core/state/EntityRealmState.d.ts +1 -1
- package/dist/types/core/state/EntityRealmState.d.ts.map +1 -1
- package/dist/types/core/state/StateNode.d.ts +3 -3
- package/dist/types/core/state/StateNode.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts +2 -2
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/Entity.d.ts +1 -1
- package/dist/types/coreComponents/Entity.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityList.d.ts +1 -1
- package/dist/types/coreComponents/EntityList.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts +2 -2
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/HasMany.d.ts +1 -1
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
- package/dist/types/coreComponents/HasOne.d.ts +1 -1
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
- package/dist/types/coreComponents/MarkerProvider.d.ts +3 -3
- package/dist/types/coreComponents/MarkerProvider.d.ts.map +1 -1
- package/dist/types/helperComponents/FieldView.d.ts +5 -5
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
- package/dist/types/helperComponents/If.d.ts +1 -1
- package/dist/types/helperComponents/If.d.ts.map +1 -1
- package/dist/types/markers/EntityFieldMarkers.d.ts +2 -2
- package/dist/types/markers/EntityFieldMarkers.d.ts.map +1 -1
- package/dist/types/markers/EntityFieldPlaceholders.d.ts +1 -1
- package/dist/types/markers/EntityFieldPlaceholders.d.ts.map +1 -1
- package/dist/types/markers/MeaningfulMarker.d.ts +1 -1
- package/dist/types/markers/MeaningfulMarker.d.ts.map +1 -1
- package/dist/types/markers/SubTreeMarkers.d.ts +1 -1
- package/dist/types/markers/SubTreeMarkers.d.ts.map +1 -1
- package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
- package/dist/types/queryLanguage/QueryLanguage.d.ts +2 -3
- package/dist/types/queryLanguage/QueryLanguage.d.ts.map +1 -1
- package/dist/types/treeParameters/EntityListEventListeners.d.ts +4 -4
- package/dist/types/treeParameters/EntityListEventListeners.d.ts.map +1 -1
- package/dist/types/treeParameters/EventListenersStore.d.ts +1 -1
- package/dist/types/treeParameters/EventListenersStore.d.ts.map +1 -1
- package/dist/types/treeParameters/FieldEventListeners.d.ts +3 -3
- package/dist/types/treeParameters/FieldEventListeners.d.ts.map +1 -1
- package/dist/types/treeParameters/SetOnCreate.d.ts +2 -2
- package/dist/types/treeParameters/SetOnCreate.d.ts.map +1 -1
- package/dist/types/treeParameters/SingleEntityEventListeners.d.ts +3 -3
- package/dist/types/treeParameters/SingleEntityEventListeners.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Alias.d.ts +1 -1
- package/dist/types/treeParameters/primitives/Alias.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts +1 -1
- package/dist/types/treeParameters/primitives/EntityId.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/EntityName.d.ts +1 -1
- package/dist/types/treeParameters/primitives/EntityName.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/EntityRealmKey.d.ts +1 -1
- package/dist/types/treeParameters/primitives/EntityRealmKey.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/ExpectedEntityCount.d.ts +1 -1
- package/dist/types/treeParameters/primitives/ExpectedEntityCount.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/ExpectedQualifiedEntityMutation.d.ts +1 -1
- package/dist/types/treeParameters/primitives/ExpectedQualifiedEntityMutation.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/ExpectedRelationMutation.d.ts +1 -1
- package/dist/types/treeParameters/primitives/ExpectedRelationMutation.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/FieldName.d.ts +1 -1
- package/dist/types/treeParameters/primitives/FieldName.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
- package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Filter.d.ts +2 -2
- package/dist/types/treeParameters/primitives/Filter.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Json.d.ts +1 -1
- package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Limit.d.ts +1 -1
- package/dist/types/treeParameters/primitives/Limit.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Offset.d.ts +1 -1
- package/dist/types/treeParameters/primitives/Offset.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/OrderBy.d.ts +2 -2
- package/dist/types/treeParameters/primitives/OrderBy.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/PlaceholderName.d.ts +1 -1
- package/dist/types/treeParameters/primitives/PlaceholderName.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/RemovalType.d.ts +1 -1
- package/dist/types/treeParameters/primitives/RemovalType.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Scalar.d.ts +1 -1
- package/dist/types/treeParameters/primitives/Scalar.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/TreeRootId.d.ts +1 -1
- package/dist/types/treeParameters/primitives/TreeRootId.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/UniqueWhere.d.ts +2 -2
- package/dist/types/treeParameters/primitives/UniqueWhere.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -14
- package/src/accessorSorting/SortedEntities.ts +1 -1
- package/src/accessorSorting/errors.ts +0 -7
- package/src/accessorSorting/useSortedEntities.ts +15 -18
- package/src/accessorTree/MutationRequestResponse.ts +1 -1
- package/src/core/MutationGenerator.ts +16 -5
- package/src/core/TreeParameterMerger.ts +2 -2
- package/src/dao/Environment.ts +1 -1
- package/src/queryLanguage/Parser.ts +3 -3
- package/LICENSE +0 -186
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[
|
|
1
|
+
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;;AAkCO,MAAM,gBAAgB;AAAA,EAC5B,CAAyB,UAA2C;AACzC,8BAAA,MAAM,YAAY,yCAAyC;AAErF,UAAM,aAAa;AACb,UAAA,aAAa,2BAA2B,KAAK;AACnD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAO,cAAc,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZ,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA,qBAAC,QAAQ,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
1
2
|
import { GraphQlBuilder } from "@contember/client";
|
|
2
3
|
import { Component } from "./Component.js";
|
|
3
4
|
import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
|
|
4
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useField } from "../accessorPropagation/useField.js";
|
|
6
6
|
import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
7
|
-
const Field = Component(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
children: props.format(field.value)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
const Field = Component(
|
|
8
|
+
(props) => {
|
|
9
|
+
const field = useField(props);
|
|
10
|
+
if (props.format !== void 0) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.format(field.value) });
|
|
12
|
+
}
|
|
13
|
+
if (field.value instanceof GraphQlBuilder.GraphQlLiteral || field.value === null || typeof field.value === "boolean") {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsx(Fragment, { children: field.value });
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
generateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),
|
|
20
|
+
generateEnvironment: (props, environment) => {
|
|
21
|
+
return TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"Field"
|
|
25
|
+
);
|
|
26
26
|
export {
|
|
27
27
|
Field
|
|
28
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":[
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;;;;AAkBO,MAAM,QAAQ;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQ,SAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAAE,CAAA;AAAA,IACrC;AAGC,QAAA,MAAM,iBAAiB,eAAe,kBACtC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAA,oBAAA,UAAA,EAAG,gBAAM,MAAM,CAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAA,2BAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
2
|
import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
|
|
2
3
|
import { Component } from "./Component.js";
|
|
3
4
|
import { EntityList } from "./EntityList.js";
|
|
4
5
|
import { Field } from "./Field.js";
|
|
5
6
|
import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
|
|
6
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
7
7
|
import { useEntityList } from "../accessorPropagation/useEntityList.js";
|
|
8
8
|
import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
9
|
-
const HasMany = Component(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...props,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const HasMany = Component(
|
|
10
|
+
(props) => {
|
|
11
|
+
const entityList = useEntityList(props);
|
|
12
|
+
return /* @__PURE__ */ jsx(EntityList, { ...props, accessor: entityList });
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
generateEnvironment: (props, oldEnvironment) => {
|
|
16
|
+
const environment = oldEnvironment.withVariables(props.variables);
|
|
17
|
+
return TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props);
|
|
18
|
+
},
|
|
19
|
+
staticRender: (props) => /* @__PURE__ */ jsxs(EntityList, { ...props, accessor: void 0, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(Field, { field: PRIMARY_KEY_NAME }),
|
|
21
|
+
props.children
|
|
22
|
+
] }),
|
|
23
|
+
generateBranchMarker: (props, fields, environment) => MarkerFactory.createRelativeEntityListFields(props, environment, fields)
|
|
19
24
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
accessor: void 0,
|
|
23
|
-
children: [/* @__PURE__ */ jsx(Field, {
|
|
24
|
-
field: PRIMARY_KEY_NAME
|
|
25
|
-
}), props.children]
|
|
26
|
-
}),
|
|
27
|
-
generateBranchMarker: (props, fields, environment) => MarkerFactory.createRelativeEntityListFields(props, environment, fields)
|
|
28
|
-
}, "HasMany");
|
|
25
|
+
"HasMany"
|
|
26
|
+
);
|
|
29
27
|
export {
|
|
30
28
|
HasMany
|
|
31
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":[
|
|
1
|
+
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAsBO,MAAM,UAAU;AAAA,EACtB,CAAyB,UAAgD;AAClE,UAAA,aAAa,cAAc,KAAK;AAEtC,WAAQ,oBAAA,YAAA,EAAY,GAAG,OAAO,UAAU,WAAY,CAAA;AAAA,EACrD;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,+BAA+B,aAAa,KAAK;AAAA,IACpF;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,cAAY,GAAG,OAAO,UAAU,QAChC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,+BAA+B,OAAO,aAAa,MAAM;AAAA,EACzE;AAAA,EACA;AACD;"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
2
|
import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
|
|
2
3
|
import { Component } from "./Component.js";
|
|
3
4
|
import { Entity } from "./Entity.js";
|
|
4
5
|
import { Field } from "./Field.js";
|
|
5
6
|
import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
|
|
6
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
7
7
|
import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
8
8
|
import { useEntity } from "../accessorPropagation/useEntity.js";
|
|
9
|
-
const HasOne = Component(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...props,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const HasOne = Component(
|
|
10
|
+
(props) => {
|
|
11
|
+
const entity = useEntity(props);
|
|
12
|
+
return /* @__PURE__ */ jsx(Entity, { ...props, accessor: entity });
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
generateEnvironment: (props, oldEnvironment) => {
|
|
16
|
+
const environment = oldEnvironment.withVariables(props.variables);
|
|
17
|
+
return TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props);
|
|
18
|
+
},
|
|
19
|
+
staticRender: (props) => /* @__PURE__ */ jsxs(Entity, { ...props, accessor: void 0, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(Field, { field: PRIMARY_KEY_NAME }),
|
|
21
|
+
props.children
|
|
22
|
+
] }),
|
|
23
|
+
generateBranchMarker: (props, fields, environment) => MarkerFactory.createRelativeSingleEntityFields(props, environment, fields)
|
|
19
24
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
accessor: void 0,
|
|
23
|
-
children: [/* @__PURE__ */ jsx(Field, {
|
|
24
|
-
field: PRIMARY_KEY_NAME
|
|
25
|
-
}), props.children]
|
|
26
|
-
}),
|
|
27
|
-
generateBranchMarker: (props, fields, environment) => MarkerFactory.createRelativeSingleEntityFields(props, environment, fields)
|
|
28
|
-
}, "HasOne");
|
|
25
|
+
"HasOne"
|
|
26
|
+
);
|
|
29
27
|
export {
|
|
30
28
|
HasOne
|
|
31
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[
|
|
1
|
+
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAgBO,MAAM,SAAS;AAAA,EACrB,CAAyB,UAAoC;AACtD,UAAA,SAAS,UAAU,KAAK;AAE9B,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,UAAU,OAAQ,CAAA;AAAA,EAC7C;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,2BAA2B,aAAa,KAAK;AAAA,IAChF;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,UAAQ,GAAG,OAAO,UAAU,QAC5B,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa,MAAM;AAAA,EAC3E;AAAA,EACA;AACD;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Component } from "./Component.js";
|
|
2
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "./Component.js";
|
|
3
3
|
import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
4
|
-
const ParentEntity = Component(
|
|
5
|
-
children: props.children
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
4
|
+
const ParentEntity = Component(
|
|
5
|
+
(props) => /* @__PURE__ */ jsx(Fragment, { children: props.children }),
|
|
6
|
+
{
|
|
7
|
+
generateBranchMarker: (props, fields, environment) => MarkerFactory.createParentEntityMarker(props, fields, environment)
|
|
8
|
+
},
|
|
9
|
+
"ParentEntity"
|
|
10
|
+
);
|
|
9
11
|
export {
|
|
10
12
|
ParentEntity
|
|
11
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":[
|
|
1
|
+
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":[],"mappings":";;;AASO,MAAM,eAAe;AAAA,EAC3B,CAAA,UAAY,oBAAA,UAAA,EAAA,UAAA,MAAM,UAAS;AAAA,EAC3B;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,yBAAyB,OAAO,QAAQ,WAAW;AAAA,EACnE;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport type { Filter } from '../treeParameters'\nimport equal from 'fast-deep-equal/es6'\nimport { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'\nimport { GraphQlLiteral } from '@contember/client'\n\nclass Environment {\n\tprivate constructor(\n\t\tprivate readonly options: Environment.Options,\n\t) {\n\t}\n\n\tpublic static create() {\n\t\treturn new Environment({\n\t\t\tdimensions: {},\n\t\t\tvariables: {},\n\t\t\tparameters: {},\n\t\t\textensions: new Map(),\n\t\t})\n\t}\n\n\tpublic getSubTree(): Environment.SubTreeNode {\n\t\tfor (let env: Environment = this; env.options.node; env = env.getParent()) {\n\t\t\tconst node = env.options.node\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t\tthrow new BindingError('Not in a SubTree')\n\t}\n\n\tpublic getSubTreeNode(): Environment.AnyNode {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn this.options.node\n\t}\n\n\tpublic withSubTree(SubTree: Environment.SubTreeNode) {\n\t\tconst { parent, ...options } = this.options\n\t\treturn new Environment({\n\t\t\t...options,\n\t\t\tnode: SubTree,\n\t\t})\n\t}\n\n\tpublic withSubTreeChild(node: Environment.InnerNode) {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`)\n\t\t}\n\t\tif (this.options.node.entity.fields.get(node.field.name) !== node.field) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tnode,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\n\tpublic hasVariable(key: string): boolean {\n\t\treturn key in this.options.variables\n\t}\n\n\tpublic getVariable<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tif (!(key in this.options.variables)) {\n\t\t\tthrow new BindingError(`Variable ${key} not found`)\n\t\t}\n\t\treturn this.options.variables[key] as V\n\t}\n\n\tpublic getVariableOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\treturn (this.options.variables[key] as V) ?? fallback\n\t}\n\n\t/** @deprecated use getVariable or getParameter */\n\tpublic getValue<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tconsole.warn('Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, undefined) as V\n\t}\n\n\t/** @deprecated use getVariableOrElse or getParameterOrElse */\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\tconsole.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as any\n\t}\n\n\t/** @deprecated */\n\tpublic hasName(key: string): boolean {\n\t\tconsole.warn('Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.')\n\t\treturn key in this.options.variables || key in this.options.parameters\n\t}\n\n\tpublic withVariables(variables: Environment.ValuesMapWithFactory | undefined): Environment {\n\t\tif (variables === undefined) {\n\t\t\treturn this\n\t\t}\n\t\tconst newVariables = { ...this.options.variables }\n\t\tfor (const [newName, newValue] of Object.entries(variables)) {\n\t\t\tif (newName === 'labelMiddleware') {\n\t\t\t\tthrow new BindingError('You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.')\n\t\t\t}\n\t\t\tconst resolvedValue = typeof newValue === 'function' ? newValue(this) : newValue\n\t\t\tif (resolvedValue === undefined) {\n\t\t\t\tdelete newVariables[newName]\n\t\t\t} else {\n\t\t\t\tnewVariables[newName] = resolvedValue\n\t\t\t}\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tvariables: newVariables,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\tpublic getAllVariables() {\n\t\treturn this.options.variables\n\t}\n\n\tpublic hasParameter(key: string): boolean {\n\t\treturn key in this.options.parameters\n\t}\n\n\tpublic getParameter<F>(key: string): string | number {\n\t\tif (!(key in this.options.parameters)) {\n\t\t\tthrow new BindingError(`Parameter ${key} not found`)\n\t\t}\n\t\treturn this.options.parameters[key] as string | number\n\t}\n\n\tpublic getParameterOrElse<F>(key: string, fallback: F): string | number | F {\n\t\treturn this.options.parameters[key] ?? fallback\n\t}\n\n\tpublic getAllParameters() {\n\t\treturn this.options.parameters\n\t}\n\n\tpublic withParameters(parameters: Environment.Parameters): Environment {\n\t\treturn new Environment({ ...this.options, parameters })\n\t}\n\n\tpublic hasDimension(dimensionName: string): boolean {\n\t\treturn dimensionName in this.options.dimensions\n\t}\n\n\tpublic getDimension<F>(dimensionName: string): string[] {\n\t\tif (!(dimensionName in this.options.dimensions)) {\n\t\t\tthrow new BindingError(`Dimension ${dimensionName} does not exist.`)\n\t\t}\n\t\treturn this.options.dimensions[dimensionName]\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: string, fallback: F): string[] | F {\n\t\treturn this.options.dimensions[dimensionName] ?? fallback\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn this.options.dimensions\n\t}\n\n\tpublic withDimensions(dimensions: Environment.SelectedDimensions): Environment {\n\t\tconst newDimensions = {\n\t\t\t...this.options.dimensions,\n\t\t\t...dimensions,\n\t\t}\n\t\tif (equal(newDimensions, this.options.dimensions)) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Environment({ ...this.options, dimensions: newDimensions })\n\t}\n\n\tpublic getSchema(): Schema {\n\t\tif (!this.options.schema) {\n\t\t\tthrow new BindingError('Schema is not set')\n\t\t}\n\t\treturn this.options.schema\n\t}\n\n\tpublic withSchema(schema: Schema): Environment {\n\t\treturn new Environment({ ...this.options, schema })\n\t}\n\n\tpublic getParent(): Environment {\n\t\tif (!this.options.parent) {\n\t\t\tthrow new BindingError('There is no parent environment')\n\t\t}\n\t\treturn this.options.parent\n\t}\n\n\tpublic withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\textensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),\n\t\t})\n\t}\n\n\tpublic getExtension<S, R>(extension: Environment.Extension<S, R>): R {\n\t\tconst state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)\n\t\treturn extension.create(state as S, this)\n\t}\n\n\tpublic merge(other: Environment): Environment {\n\t\tif (other === this) {\n\t\t\treturn this\n\t\t}\n\t\tif (!equal(this.options.node, other.options.node)) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different tree position.`)\n\t\t}\n\t\tif (this.options.parameters !== other.options.parameters) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different parameters.`)\n\t\t}\n\t\tif (this.options.dimensions !== other.options.dimensions) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different dimensions.`)\n\t\t}\n\t\tif (this.options.extensions !== other.options.extensions) {\n\t\t\t// todo: deep compare?\n\t\t\tthrow new BindingError(`Cannot merge two environments with different extensions.`)\n\t\t}\n\n\t\tif (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {\n\t\t\treturn this\n\t\t}\n\t\tfor (const key in other.options.variables) {\n\t\t\tif (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {\n\t\t\t\tthrow new BindingError(`Cannot merge two environments with different value of variable ${key}:\\n`\n\t\t\t\t\t+ JSON.stringify(this.options.variables[key]) + '\\n'\n\t\t\t\t\t+ JSON.stringify(other.options.variables[key]))\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tparent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : undefined,\n\t\t\tvariables: { ...this.options.variables, ...other.options.variables },\n\t\t})\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string\n\n\texport type Value = ReactNode | GraphQlLiteral | Filter\n\n\texport type ResolvedValue = Value\n\n\texport interface Options {\n\t\tnode?: AnyNode\n\t\tschema?: Schema\n\t\tdimensions: SelectedDimensions\n\t\tparameters: Parameters\n\t\tvariables: CustomVariables\n\t\tparent?: Environment\n\t\textensions: Map<Extension<unknown, unknown>, unknown>\n\t}\n\n\texport type SubTreeNode =\n\t\t| SubTreeEntityNode\n\t\t| SubTreeEntityListNode\n\n\texport type InnerNode =\n\t\t| EntityNode\n\t\t| EntityListNode\n\t\t| ColumnNode\n\n\texport type AnyNode =\n\t\t| SubTreeNode\n\t\t| InnerNode\n\n\texport interface SubTreeEntityNode {\n\t\ttype: 'subtree-entity'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero' | 'one' | 'zero-or-one'\n\t\tfilter: Filter\n\t}\n\n\texport interface SubTreeEntityListNode {\n\t\ttype: 'subtree-entity-list'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero-to-many' | 'zero'\n\t\tfilter: Filter\n\t}\n\n\texport interface EntityNode {\n\t\ttype: 'entity'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface EntityListNode {\n\t\ttype: 'entity-list'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface ColumnNode {\n\t\ttype: 'column'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaColumn\n\t}\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport type Parameters = {\n\t\t[K in string]?: string | number\n\t}\n\n\texport interface CustomVariables {\n\t\t[key: string]: Value\n\t}\n\n\texport interface ValuesMapWithFactory {\n\t\t[key: string]:\n\t\t\t| ((environment: Environment) => Value)\n\t\t\t| Value\n\t}\n\n\texport type Extension<State, Result> = {\n\t\tcreate: (state: State | undefined, environment: Environment) => Result\n\t}\n\n\texport const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {\n\t\treturn {\n\t\t\tcreate,\n\t\t\t...otherMethods,\n\t\t}\n\t}\n\n\t/** @deprecated */\n\texport type DeltaFactory = ValuesMapWithFactory\n}\n\nexport { Environment }\n"],"names":["Environment"],"mappings":";;AAOA,MAAM,YAAY;AAAA,EACT,YACU,SAChB;AADgB,SAAA,UAAA;AAAA,EAElB;AAAA,EAEA,OAAc,SAAS;AACtB,WAAO,IAAI,YAAY;AAAA,MACtB,YAAY,CAAC;AAAA,MACb,WAAW,CAAC;AAAA,MACZ,YAAY,CAAC;AAAA,MACb,gCAAgB,IAAI;AAAA,IAAA,CACpB;AAAA,EACF;AAAA,EAEO,aAAsC;AACnC,aAAA,MAAmB,MAAM,IAAI,QAAQ,MAAM,MAAM,IAAI,aAAa;AACpE,YAAA,OAAO,IAAI,QAAQ;AACzB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AACnE,eAAA;AAAA,MACR;AAAA,IACD;AACM,UAAA,IAAI,aAAa,kBAAkB;AAAA,EAC1C;AAAA,EAEO,iBAAsC;AACxC,QAAA,CAAC,KAAK,QAAQ,MAAM;AACvB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EAEO,YAAY,SAAkC;AACpD,UAAM,EAAE,WAAW,QAAQ,IAAI,KAAK;AACpC,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type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport type { Filter } from '../treeParameters'\nimport equal from 'fast-deep-equal/es6/index.js'\nimport { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'\nimport { GraphQlLiteral } from '@contember/client'\n\nclass Environment {\n\tprivate constructor(\n\t\tprivate readonly options: Environment.Options,\n\t) {\n\t}\n\n\tpublic static create() {\n\t\treturn new Environment({\n\t\t\tdimensions: {},\n\t\t\tvariables: {},\n\t\t\tparameters: {},\n\t\t\textensions: new Map(),\n\t\t})\n\t}\n\n\tpublic getSubTree(): Environment.SubTreeNode {\n\t\tfor (let env: Environment = this; env.options.node; env = env.getParent()) {\n\t\t\tconst node = env.options.node\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t\tthrow new BindingError('Not in a SubTree')\n\t}\n\n\tpublic getSubTreeNode(): Environment.AnyNode {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn this.options.node\n\t}\n\n\tpublic withSubTree(SubTree: Environment.SubTreeNode) {\n\t\tconst { parent, ...options } = this.options\n\t\treturn new Environment({\n\t\t\t...options,\n\t\t\tnode: SubTree,\n\t\t})\n\t}\n\n\tpublic withSubTreeChild(node: Environment.InnerNode) {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`)\n\t\t}\n\t\tif (this.options.node.entity.fields.get(node.field.name) !== node.field) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tnode,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\n\tpublic hasVariable(key: string): boolean {\n\t\treturn key in this.options.variables\n\t}\n\n\tpublic getVariable<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tif (!(key in this.options.variables)) {\n\t\t\tthrow new BindingError(`Variable ${key} not found`)\n\t\t}\n\t\treturn this.options.variables[key] as V\n\t}\n\n\tpublic getVariableOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\treturn (this.options.variables[key] as V) ?? fallback\n\t}\n\n\t/** @deprecated use getVariable or getParameter */\n\tpublic getValue<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tconsole.warn('Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, undefined) as V\n\t}\n\n\t/** @deprecated use getVariableOrElse or getParameterOrElse */\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\tconsole.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as any\n\t}\n\n\t/** @deprecated */\n\tpublic hasName(key: string): boolean {\n\t\tconsole.warn('Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.')\n\t\treturn key in this.options.variables || key in this.options.parameters\n\t}\n\n\tpublic withVariables(variables: Environment.ValuesMapWithFactory | undefined): Environment {\n\t\tif (variables === undefined) {\n\t\t\treturn this\n\t\t}\n\t\tconst newVariables = { ...this.options.variables }\n\t\tfor (const [newName, newValue] of Object.entries(variables)) {\n\t\t\tif (newName === 'labelMiddleware') {\n\t\t\t\tthrow new BindingError('You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.')\n\t\t\t}\n\t\t\tconst resolvedValue = typeof newValue === 'function' ? newValue(this) : newValue\n\t\t\tif (resolvedValue === undefined) {\n\t\t\t\tdelete newVariables[newName]\n\t\t\t} else {\n\t\t\t\tnewVariables[newName] = resolvedValue\n\t\t\t}\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tvariables: newVariables,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\tpublic getAllVariables() {\n\t\treturn this.options.variables\n\t}\n\n\tpublic hasParameter(key: string): boolean {\n\t\treturn key in this.options.parameters\n\t}\n\n\tpublic getParameter<F>(key: string): string | number {\n\t\tif (!(key in this.options.parameters)) {\n\t\t\tthrow new BindingError(`Parameter ${key} not found`)\n\t\t}\n\t\treturn this.options.parameters[key] as string | number\n\t}\n\n\tpublic getParameterOrElse<F>(key: string, fallback: F): string | number | F {\n\t\treturn this.options.parameters[key] ?? fallback\n\t}\n\n\tpublic getAllParameters() {\n\t\treturn this.options.parameters\n\t}\n\n\tpublic withParameters(parameters: Environment.Parameters): Environment {\n\t\treturn new Environment({ ...this.options, parameters })\n\t}\n\n\tpublic hasDimension(dimensionName: string): boolean {\n\t\treturn dimensionName in this.options.dimensions\n\t}\n\n\tpublic getDimension<F>(dimensionName: string): string[] {\n\t\tif (!(dimensionName in this.options.dimensions)) {\n\t\t\tthrow new BindingError(`Dimension ${dimensionName} does not exist.`)\n\t\t}\n\t\treturn this.options.dimensions[dimensionName]\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: string, fallback: F): string[] | F {\n\t\treturn this.options.dimensions[dimensionName] ?? fallback\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn this.options.dimensions\n\t}\n\n\tpublic withDimensions(dimensions: Environment.SelectedDimensions): Environment {\n\t\tconst newDimensions = {\n\t\t\t...this.options.dimensions,\n\t\t\t...dimensions,\n\t\t}\n\t\tif (equal(newDimensions, this.options.dimensions)) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Environment({ ...this.options, dimensions: newDimensions })\n\t}\n\n\tpublic getSchema(): Schema {\n\t\tif (!this.options.schema) {\n\t\t\tthrow new BindingError('Schema is not set')\n\t\t}\n\t\treturn this.options.schema\n\t}\n\n\tpublic withSchema(schema: Schema): Environment {\n\t\treturn new Environment({ ...this.options, schema })\n\t}\n\n\tpublic getParent(): Environment {\n\t\tif (!this.options.parent) {\n\t\t\tthrow new BindingError('There is no parent environment')\n\t\t}\n\t\treturn this.options.parent\n\t}\n\n\tpublic withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\textensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),\n\t\t})\n\t}\n\n\tpublic getExtension<S, R>(extension: Environment.Extension<S, R>): R {\n\t\tconst state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)\n\t\treturn extension.create(state as S, this)\n\t}\n\n\tpublic merge(other: Environment): Environment {\n\t\tif (other === this) {\n\t\t\treturn this\n\t\t}\n\t\tif (!equal(this.options.node, other.options.node)) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different tree position.`)\n\t\t}\n\t\tif (this.options.parameters !== other.options.parameters) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different parameters.`)\n\t\t}\n\t\tif (this.options.dimensions !== other.options.dimensions) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different dimensions.`)\n\t\t}\n\t\tif (this.options.extensions !== other.options.extensions) {\n\t\t\t// todo: deep compare?\n\t\t\tthrow new BindingError(`Cannot merge two environments with different extensions.`)\n\t\t}\n\n\t\tif (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {\n\t\t\treturn this\n\t\t}\n\t\tfor (const key in other.options.variables) {\n\t\t\tif (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {\n\t\t\t\tthrow new BindingError(`Cannot merge two environments with different value of variable ${key}:\\n`\n\t\t\t\t\t+ JSON.stringify(this.options.variables[key]) + '\\n'\n\t\t\t\t\t+ JSON.stringify(other.options.variables[key]))\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tparent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : undefined,\n\t\t\tvariables: { ...this.options.variables, ...other.options.variables },\n\t\t})\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string\n\n\texport type Value = ReactNode | GraphQlLiteral | Filter\n\n\texport type ResolvedValue = Value\n\n\texport interface Options {\n\t\tnode?: AnyNode\n\t\tschema?: Schema\n\t\tdimensions: SelectedDimensions\n\t\tparameters: Parameters\n\t\tvariables: CustomVariables\n\t\tparent?: Environment\n\t\textensions: Map<Extension<unknown, unknown>, unknown>\n\t}\n\n\texport type SubTreeNode =\n\t\t| SubTreeEntityNode\n\t\t| SubTreeEntityListNode\n\n\texport type InnerNode =\n\t\t| EntityNode\n\t\t| EntityListNode\n\t\t| ColumnNode\n\n\texport type AnyNode =\n\t\t| SubTreeNode\n\t\t| InnerNode\n\n\texport interface SubTreeEntityNode {\n\t\ttype: 'subtree-entity'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero' | 'one' | 'zero-or-one'\n\t\tfilter: Filter\n\t}\n\n\texport interface SubTreeEntityListNode {\n\t\ttype: 'subtree-entity-list'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero-to-many' | 'zero'\n\t\tfilter: Filter\n\t}\n\n\texport interface EntityNode {\n\t\ttype: 'entity'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface EntityListNode {\n\t\ttype: 'entity-list'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface ColumnNode {\n\t\ttype: 'column'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaColumn\n\t}\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport type Parameters = {\n\t\t[K in string]?: string | number\n\t}\n\n\texport interface CustomVariables {\n\t\t[key: string]: Value\n\t}\n\n\texport interface ValuesMapWithFactory {\n\t\t[key: string]:\n\t\t\t| ((environment: Environment) => Value)\n\t\t\t| Value\n\t}\n\n\texport type Extension<State, Result> = {\n\t\tcreate: (state: State | undefined, environment: Environment) => Result\n\t}\n\n\texport const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {\n\t\treturn {\n\t\t\tcreate,\n\t\t\t...otherMethods,\n\t\t}\n\t}\n\n\t/** @deprecated */\n\texport type DeltaFactory = ValuesMapWithFactory\n}\n\nexport { Environment }\n"],"names":["Environment"],"mappings":";;AAOA,MAAM,YAAY;AAAA,EACT,YACU,SAChB;AADgB,SAAA,UAAA;AAAA,EAElB;AAAA,EAEA,OAAc,SAAS;AACtB,WAAO,IAAI,YAAY;AAAA,MACtB,YAAY,CAAC;AAAA,MACb,WAAW,CAAC;AAAA,MACZ,YAAY,CAAC;AAAA,MACb,gCAAgB,IAAI;AAAA,IAAA,CACpB;AAAA,EACF;AAAA,EAEO,aAAsC;AACnC,aAAA,MAAmB,MAAM,IAAI,QAAQ,MAAM,MAAM,IAAI,aAAa;AACpE,YAAA,OAAO,IAAI,QAAQ;AACzB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AACnE,eAAA;AAAA,MACR;AAAA,IACD;AACM,UAAA,IAAI,aAAa,kBAAkB;AAAA,EAC1C;AAAA,EAEO,iBAAsC;AACxC,QAAA,CAAC,KAAK,QAAQ,MAAM;AACvB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EAEO,YAAY,SAAkC;AACpD,UAAM,EAAE,WAAW,QAAQ,IAAI,KAAK;AACpC,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG;AAAA,MACH,MAAM;AAAA,IAAA,CACN;AAAA,EACF;AAAA,EAEO,iBAAiB,MAA6B;AAChD,QAAA,CAAC,KAAK,QAAQ,MAAM;AACjB,YAAA,IAAI,aAAa,mEAAmE;AAAA,IAC3F;AACI,QAAA,KAAK,QAAQ,KAAK,OAAO,OAAO,IAAI,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO;AACxE,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG,KAAK;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AA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ACR;AACW,eAAA,OAAO,MAAM,QAAQ,WAAW;AAC1C,UAAI,OAAO,KAAK,QAAQ,aAAa,CAAC,MAAM,KAAK,QAAQ,UAAU,MAAM,MAAM,QAAQ,UAAU,IAAI,GAAG;AACjG,cAAA,IAAI,aAAa,kEAAkE;AAAA,IACtF,KAAK,UAAU,KAAK,QAAQ,UAAU,IAAI,IAAI,OAC9C,KAAK,UAAU,MAAM,QAAQ,UAAU,IAAI,CAAC;AAAA,MAChD;AAAA,IACD;AAEA,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,QAAQ,KAAK,QAAQ,UAAU,MAAM,QAAQ,SAAS,KAAK,QAAQ,OAAO,MAAM,MAAM,QAAQ,MAAM,IAAI;AAAA,MACxG,WAAW,EAAE,GAAG,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAQ,UAAU;AAAA,IAAA,CACnE;AAAA,EACF;AACD;AAAA,CAEA,CAAUA,iBAAV;AAoFcA,eAAA,kBAAkB,CAAO,QAAmC,iBAAoE;AACrI,WAAA;AAAA,MACN;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EACJ;AACD,GAzFS,gBAAA,cAAA,CAAA,EAAA;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { FieldAccessor } from "../../accessors/FieldAccessor.js";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
4
|
var __publicField = (obj, key, value) => {
|
|
4
5
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
6
|
return value;
|
|
6
7
|
};
|
|
7
|
-
import { FieldAccessor } from "../../accessors/FieldAccessor.js";
|
|
8
8
|
class FieldHelper {
|
|
9
9
|
constructor(field) {
|
|
10
10
|
__publicField(this, "getAccessor");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import { FieldAccessor } from '../../accessors'\nimport type { FieldValue } from '../../treeParameters'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = field instanceof FieldAccessor ? field.getAccessor : field\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE;AAGlB,SAAK,cAAc,iBAAiB,gBAAgB,MAAM,cAAc;AAAA,EACzE;AACD;"}
|
|
1
|
+
{"version":3,"file":"FieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import { FieldAccessor } from '../../accessors'\nimport type { FieldValue } from '../../treeParameters'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = field instanceof FieldAccessor ? field.getAccessor : field\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE,kBAAA,MAAA,aAAA;AAGlB,SAAK,cAAc,iBAAiB,gBAAgB,MAAM,cAAc;AAAA,EACzE;AACD;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useState, useCallback, useEffect } from "react";
|
|
2
3
|
import { useConstantValueInvariant } from "@contember/react-utils";
|
|
3
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Component } from "../coreComponents/Component.js";
|
|
5
5
|
import { useBindingOperations } from "../accessorPropagation/useBindingOperations.js";
|
|
6
6
|
import { useMutationState } from "../accessorTree/useMutationState.js";
|
|
@@ -11,88 +11,78 @@ import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
|
11
11
|
import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
|
|
12
12
|
import { EntityFieldMarkersContainer } from "../markers/EntityFieldMarkersContainer.js";
|
|
13
13
|
import { EntityFieldsWithHoistablesMarker } from "../markers/EntityFieldsWithHoistablesMarker.js";
|
|
14
|
-
const DeferredSubTrees = Component(
|
|
15
|
-
|
|
16
|
-
extendTree
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
const DeferredSubTrees = Component(
|
|
15
|
+
(props) => {
|
|
16
|
+
const { extendTree } = useBindingOperations();
|
|
17
|
+
const isMutating = useMutationState();
|
|
18
|
+
const [loadState, setLoadState] = useState({ name: "initial" });
|
|
19
|
+
const [abortController] = useState(() => new AbortController());
|
|
20
|
+
const signal = abortController.signal;
|
|
21
|
+
const hasEntity = useHasEntity();
|
|
22
|
+
useConstantValueInvariant(hasEntity);
|
|
23
|
+
if (hasEntity) {
|
|
24
|
+
useEntityBeforePersist(
|
|
25
|
+
useCallback((getAccessor) => {
|
|
26
|
+
if (getAccessor().existsOnServer) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setLoadState({ name: "initial" });
|
|
30
|
+
}, [])
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
return () => {
|
|
35
|
+
abortController.abort();
|
|
36
|
+
};
|
|
37
|
+
}, [abortController]);
|
|
38
|
+
const environment = useEnvironment();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isMutating || loadState.name !== "initial" || signal.aborted) {
|
|
29
41
|
return;
|
|
30
42
|
}
|
|
31
|
-
setLoadState({
|
|
32
|
-
|
|
43
|
+
setLoadState({ name: "loading" });
|
|
44
|
+
const newFragment = /* @__PURE__ */ jsx(OnlyKeepSubTrees, { children: props.children });
|
|
45
|
+
extendTree(newFragment, { signal, environment }).then((treeRootId) => !signal.aborted && setLoadState({ name: "success", treeRootId })).catch((error) => {
|
|
46
|
+
if (signal.aborted) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
33
50
|
});
|
|
34
|
-
}, [])
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const environment = useEnvironment();
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (isMutating || loadState.name !== "initial" || signal.aborted) {
|
|
44
|
-
return;
|
|
51
|
+
}, [environment, extendTree, isMutating, loadState.name, props.children, signal]);
|
|
52
|
+
switch (loadState.name) {
|
|
53
|
+
case "initial":
|
|
54
|
+
case "loading":
|
|
55
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.fallback });
|
|
56
|
+
case "success":
|
|
57
|
+
return /* @__PURE__ */ jsx(TreeRootIdProvider, { treeRootId: loadState.treeRootId, children: props.children });
|
|
45
58
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
staticRender: (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62
|
+
props.children,
|
|
63
|
+
props.fallback
|
|
64
|
+
] }),
|
|
65
|
+
generateBranchMarker: (props, fields, environment) => {
|
|
66
|
+
const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
|
|
67
|
+
fieldsWithHoistablesMarker.subTrees?.clear();
|
|
68
|
+
return fieldsWithHoistablesMarker;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"DeferredSubTree"
|
|
72
|
+
);
|
|
73
|
+
const OnlyKeepSubTrees = Component(
|
|
74
|
+
() => null,
|
|
75
|
+
{
|
|
76
|
+
generateBranchMarker: (props, fields) => {
|
|
77
|
+
const emptyFields = MarkerFactory.createEntityFieldMarkersContainer(void 0);
|
|
78
|
+
if (fields instanceof EntityFieldMarkersContainer) {
|
|
79
|
+
return emptyFields;
|
|
61
80
|
}
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
}, [environment, extendTree, isMutating, loadState.name, props.children, signal]);
|
|
65
|
-
switch (loadState.name) {
|
|
66
|
-
case "initial":
|
|
67
|
-
case "loading":
|
|
68
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
69
|
-
children: props.fallback
|
|
70
|
-
});
|
|
71
|
-
case "success":
|
|
72
|
-
return /* @__PURE__ */ jsx(TreeRootIdProvider, {
|
|
73
|
-
treeRootId: loadState.treeRootId,
|
|
74
|
-
children: props.children
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
staticRender: (props) => /* @__PURE__ */ jsxs(Fragment, {
|
|
79
|
-
children: [props.children, props.fallback]
|
|
80
|
-
}),
|
|
81
|
-
generateBranchMarker: (props, fields, environment) => {
|
|
82
|
-
const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
|
|
83
|
-
fieldsWithHoistablesMarker.subTrees?.clear();
|
|
84
|
-
return fieldsWithHoistablesMarker;
|
|
85
|
-
}
|
|
86
|
-
}, "DeferredSubTree");
|
|
87
|
-
const OnlyKeepSubTrees = Component(() => null, {
|
|
88
|
-
generateBranchMarker: (props, fields) => {
|
|
89
|
-
const emptyFields = MarkerFactory.createEntityFieldMarkersContainer(void 0);
|
|
90
|
-
if (fields instanceof EntityFieldMarkersContainer) {
|
|
91
|
-
return emptyFields;
|
|
81
|
+
return new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, void 0);
|
|
92
82
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
},
|
|
84
|
+
"OnlyKeepSubTrees"
|
|
85
|
+
);
|
|
96
86
|
export {
|
|
97
87
|
DeferredSubTrees
|
|
98
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[
|
|
1
|
+
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,g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D;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -2,9 +2,7 @@ import { jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEntity } from "../accessorPropagation/useEntity.js";
|
|
3
3
|
function EntityView(props) {
|
|
4
4
|
const entity = "field" in props ? useEntity(props.field) : useEntity();
|
|
5
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
6
|
-
children: props.render(entity)
|
|
7
|
-
});
|
|
5
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.render(entity) });
|
|
8
6
|
}
|
|
9
7
|
export {
|
|
10
8
|
EntityView
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;AAUO,SAAS,WAAW,OAAwB;AAElD,QAAM,SAAS,WAAW,QAAQ,UAAU,MAAM,KAAK,IAAK;AAE5D,SAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,EAAE,CAAA;AAChC;"}
|