@contember/binding 1.1.0-rc.5 → 1.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/accessorPropagation/AccessorProvider.js +2 -17
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js +2 -10
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js +2 -10
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js +23 -56
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js +2 -10
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/development/accessorPropagation/useEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useField.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +62 -91
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorSorting/moveEntity.js.map +1 -1
- package/dist/development/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js +3 -42
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +15 -2
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +9 -0
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +1 -0
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/accessors/TreeRootAccessor.js +3 -0
- package/dist/development/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +9 -0
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +3 -27
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/MarkerComparator.js +1 -0
- package/dist/development/core/MarkerComparator.js.map +1 -1
- package/dist/development/core/MarkerMerger.js +1 -0
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/QueryGenerator.js +1 -0
- package/dist/development/core/QueryGenerator.js.map +1 -1
- package/dist/development/core/RealmKeyGenerator.js +2 -0
- package/dist/development/core/RealmKeyGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +3 -0
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +6 -1
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeParameterMerger.js +26 -0
- package/dist/development/core/TreeParameterMerger.js.map +1 -1
- package/dist/development/core/TreeStore.js +2 -0
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.js +2 -2
- package/dist/development/core/operations/EntityOperations.js +3 -1
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +1 -21
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/state/StateIterator.js +1 -0
- 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 +10 -14
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +10 -15
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +25 -33
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +29 -41
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +39 -51
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +20 -20
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +18 -33
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +18 -33
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js +8 -6
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/Environment.js +3 -0
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js +4 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +67 -86
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js +2 -4
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js +38 -36
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/If.js +40 -65
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js +6 -6
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js +3 -18
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -1
- package/dist/development/helperComponents/helpers/evaluateCondition.js +1 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/development/markers/EntityFieldMarkersContainer.js +1 -0
- package/dist/development/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/development/markers/HasManyRelationMarker.js +0 -6
- package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/development/queryLanguage/CacheStore.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +2 -3
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +13 -5
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/structures/BijectiveIndexedMap.js +2 -0
- package/dist/development/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/development/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/development/treeParameters/EntityCreationParameters.js +1 -0
- package/dist/development/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/development/utils/Hashing.js +1 -0
- package/dist/development/utils/Hashing.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/accessorPropagation/useDesugaredRelativeEntityList.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleEntity.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleField.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/production/accessorPropagation/useEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useField.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js +62 -62
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/accessorSorting/moveEntity.js.map +1 -1
- package/dist/production/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/production/accessorTree/AccessorTree.js +3 -21
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +15 -2
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +9 -0
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +1 -0
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/accessors/TreeRootAccessor.js +3 -0
- package/dist/production/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +9 -0
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js +2 -0
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/MarkerComparator.js +1 -0
- package/dist/production/core/MarkerComparator.js.map +1 -1
- package/dist/production/core/MarkerMerger.js +1 -0
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/QueryGenerator.js +1 -0
- package/dist/production/core/QueryGenerator.js.map +1 -1
- package/dist/production/core/RealmKeyGenerator.js +2 -0
- package/dist/production/core/RealmKeyGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +3 -0
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +6 -1
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeParameterMerger.js +26 -0
- package/dist/production/core/TreeParameterMerger.js.map +1 -1
- package/dist/production/core/TreeStore.js +2 -0
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/production/core/exceptions/TreeParameterSugarer.js +2 -2
- package/dist/production/core/operations/EntityOperations.js +3 -1
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/state/StateIterator.js +1 -0
- 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 +10 -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 +3 -0
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js +4 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.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/helperComponents/helpers/evaluateCondition.js +1 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/production/markers/EntityFieldMarkersContainer.js +1 -0
- package/dist/production/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/production/queryLanguage/CacheStore.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +2 -0
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +13 -2
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/structures/BijectiveIndexedMap.js +2 -0
- package/dist/production/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/production/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/production/treeParameters/EntityCreationParameters.js +1 -0
- package/dist/production/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/production/utils/Hashing.js +1 -0
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +0 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +0 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +0 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +0 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +0 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts +0 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts +0 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/LICENSE +0 -186
- package/src/ambient.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV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AC,OAAO,MAClB,oBAAA,cAAA,EAAqB,SAAH,CAAiB,CACpC;AAAA,IACF,EAAA,CAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
|
|
@@ -1,76 +1,51 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
3
|
import { FilterFieldsCollector } from "./helpers/FilterFieldsCollector.js";
|
|
3
4
|
import { FilterEvaluator } from "./helpers/FilterEvaluator.js";
|
|
4
|
-
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
5
5
|
import { Field } from "../coreComponents/Field.js";
|
|
6
6
|
import { Component } from "../coreComponents/Component.js";
|
|
7
7
|
import { useEntity } from "../accessorPropagation/useEntity.js";
|
|
8
8
|
import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
|
|
9
9
|
import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
children
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
children
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const entity = useEntity();
|
|
50
|
-
const schema = env.getSchema();
|
|
51
|
-
const evaluated = useMemo(() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)), [condition, entity, env, schema]);
|
|
52
|
-
return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, {
|
|
53
|
-
children
|
|
54
|
-
}, void 0, false) : null;
|
|
55
|
-
}, ({
|
|
56
|
-
children,
|
|
57
|
-
condition
|
|
58
|
-
}, env) => {
|
|
59
|
-
const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
|
|
60
|
-
const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
|
|
61
|
-
const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, {
|
|
62
|
-
children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, {
|
|
63
|
-
field: it
|
|
64
|
-
}, it, false, {
|
|
65
|
-
fileName: _jsxFileName,
|
|
66
|
-
lineNumber: 62,
|
|
67
|
-
columnNumber: 69
|
|
68
|
-
}, void 0))
|
|
69
|
-
}, void 0, false);
|
|
70
|
-
return /* @__PURE__ */ jsxDEV(Fragment, {
|
|
71
|
-
children: [additionalFields, children]
|
|
72
|
-
}, void 0, true);
|
|
73
|
-
}, "IfFilter");
|
|
10
|
+
const If = Component(
|
|
11
|
+
(props) => {
|
|
12
|
+
return typeof props.condition !== "function" ? /* @__PURE__ */ jsx(IfFilter, { condition: props.condition, children: props.children }) : /* @__PURE__ */ jsx(IfCallback, { condition: props.condition, children: props.children });
|
|
13
|
+
},
|
|
14
|
+
"If"
|
|
15
|
+
);
|
|
16
|
+
const IfCallback = Component(
|
|
17
|
+
({ children, condition }) => {
|
|
18
|
+
const entity = useEntity();
|
|
19
|
+
const evaluated = useMemo(() => condition(entity), [condition, entity]);
|
|
20
|
+
return evaluated ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
|
|
21
|
+
},
|
|
22
|
+
({ children }) => {
|
|
23
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
24
|
+
},
|
|
25
|
+
"IfCallback"
|
|
26
|
+
);
|
|
27
|
+
const IfFilter = Component(
|
|
28
|
+
({ children, condition }) => {
|
|
29
|
+
const env = useEnvironment();
|
|
30
|
+
const entity = useEntity();
|
|
31
|
+
const schema = env.getSchema();
|
|
32
|
+
const evaluated = useMemo(
|
|
33
|
+
() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),
|
|
34
|
+
[condition, entity, env, schema]
|
|
35
|
+
);
|
|
36
|
+
return evaluated ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
|
|
37
|
+
},
|
|
38
|
+
({ children, condition }, env) => {
|
|
39
|
+
const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
|
|
40
|
+
const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
|
|
41
|
+
const additionalFields = /* @__PURE__ */ jsx(Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsx(Field, { field: it }, it)) });
|
|
42
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
+
additionalFields,
|
|
44
|
+
children
|
|
45
|
+
] });
|
|
46
|
+
},
|
|
47
|
+
"IfFilter"
|
|
48
|
+
);
|
|
74
49
|
export {
|
|
75
50
|
If
|
|
76
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":[
|
|
1
|
+
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":[],"mappings":";;;;;;;;;AAwBO,MAAM,KAAK;AAAA,EAAmB,CAAS,UAAA;AAC5C,WAAO,OAAO,MAAM,cAAc,aAC9B,oBAAA,UAAA,EAAS,WAAW,MAAM,WAAY,UAAM,MAAA,SAAA,CAAS,IACrD,oBAAA,YAAA,EAAW,WAAW,MAAM,WAAY,gBAAM,SAAS,CA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ents/Component.js";
|
|
3
|
-
const StaticRender = Component(
|
|
4
|
-
|
|
5
|
-
}) => /* @__PURE__ */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const StaticRender = Component(
|
|
4
|
+
() => null,
|
|
5
|
+
({ children }) => /* @__PURE__ */ jsx(Fragment, { children }),
|
|
6
|
+
"StaticRender"
|
|
7
|
+
);
|
|
8
8
|
export {
|
|
9
9
|
StaticRender
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":[
|
|
1
|
+
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":[],"mappings":";;AAOO,MAAM,eAAe;AAAA,EAC3B,MAAM;AAAA,EACN,CAAC,EAAE,SAAS,sCAAS,SAAS,CAAA;AAAA,EAC9B;AACD;"}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from "../coreComponents/Component.js";
|
|
3
3
|
import { Field } from "../coreComponents/Field.js";
|
|
4
|
-
var _jsxFileName = "/__w/interface/interface/packages/binding/src/helperComponents/SugaredField.tsx";
|
|
5
4
|
const SugaredField = Component((props) => {
|
|
6
5
|
if (typeof props.field === "string") {
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
...props,
|
|
9
|
-
field: props.field
|
|
10
|
-
}, void 0, false, {
|
|
11
|
-
fileName: _jsxFileName,
|
|
12
|
-
lineNumber: 12,
|
|
13
|
-
columnNumber: 10
|
|
14
|
-
}, void 0);
|
|
6
|
+
return /* @__PURE__ */ jsx(Field, { ...props, field: props.field });
|
|
15
7
|
}
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
...props,
|
|
18
|
-
...props.field
|
|
19
|
-
}, void 0, false, {
|
|
20
|
-
fileName: _jsxFileName,
|
|
21
|
-
lineNumber: 14,
|
|
22
|
-
columnNumber: 9
|
|
23
|
-
}, void 0);
|
|
8
|
+
return /* @__PURE__ */ jsx(Field, { ...props, ...props.field });
|
|
24
9
|
}, "SugaredField");
|
|
25
10
|
export {
|
|
26
11
|
SugaredField
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":[
|
|
1
|
+
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;AASa,MAAA,eAAe,UAAU,CAA4C,UAAwC;AACrH,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,+BAAQ,OAAO,EAAA,GAAG,OAAO,OAAO,MAAM,MAAO,CAAA;AAAA,EAC9C;AACA,6BAAQ,OAAO,EAAA,GAAG,OAAQ,GAAG,MAAM,MAAO,CAAA;AAC3C,GAAG,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterEvaluator.js","sources":["../../../../src/helperComponents/helpers/FilterEvaluator.ts"],"sourcesContent":["import { Schema } from '../../core/schema'\nimport { Input } from '@contember/client'\nimport { EntityAccessor } from '../../accessors'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\nimport { evaluateCondition } from './evaluateCondition'\n\n\nexport class FilterEvaluator {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t) {\n\t}\n\n\tevaluateFilter(entity: EntityAccessor, filter: Filter): boolean {\n\t\tconst entitySchema = this.schema.getEntity(entity.name)\n\n\t\tlet acc = true\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tconst operation = key === 'and' ? 'every' : 'some' as const\n\t\t\t\t\tacc &&= value[operation](it => this.evaluateFilter(entity, it))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tacc &&= !this.evaluateFilter(entity, value as Filter)\n\n\t\t\t} else {\n\t\t\t\tconst field = entitySchema.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tacc &&= evaluateCondition(entity.getField(key).value, value as Input.Condition)\n\t\t\t\t} else {\n\t\t\t\t\tacc &&= this.evaluateFilter(entity.getEntity(key), value as Filter)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn acc\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,eAAe,QAAwB,QAAyB;AAC/D,UAAM,eAAe,KAAK,OAAO,UAAU,OAAO,IAAI;AAEtD,QAAI,MAAM;AACV,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEM,cAAA,YAAY,QAAQ,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"FilterEvaluator.js","sources":["../../../../src/helperComponents/helpers/FilterEvaluator.ts"],"sourcesContent":["import { Schema } from '../../core/schema'\nimport { Input } from '@contember/client'\nimport { EntityAccessor } from '../../accessors'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\nimport { evaluateCondition } from './evaluateCondition'\n\n\nexport class FilterEvaluator {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t) {\n\t}\n\n\tevaluateFilter(entity: EntityAccessor, filter: Filter): boolean {\n\t\tconst entitySchema = this.schema.getEntity(entity.name)\n\n\t\tlet acc = true\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tconst operation = key === 'and' ? 'every' : 'some' as const\n\t\t\t\t\tacc &&= value[operation](it => this.evaluateFilter(entity, it))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tacc &&= !this.evaluateFilter(entity, value as Filter)\n\n\t\t\t} else {\n\t\t\t\tconst field = entitySchema.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tacc &&= evaluateCondition(entity.getField(key).value, value as Input.Condition)\n\t\t\t\t} else {\n\t\t\t\t\tacc &&= this.evaluateFilter(entity.getEntity(key), value as Filter)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn acc\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,eAAe,QAAwB,QAAyB;AAC/D,UAAM,eAAe,KAAK,OAAO,UAAU,OAAO,IAAI;AAEtD,QAAI,MAAM;AACV,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEM,cAAA,YAAY,QAAQ,QAAQ,UAAU;AACpC,sBAAA,MAAM,SAAS,EAAE,CAAA,OAAM,KAAK,eAAe,QAAQ,EAAE,CAAC;AAAA,MAAA,WAErD,QAAQ,OAAO;AACxB,sBAAQ,CAAC,KAAK,eAAe,QAAQ,KAAe;AAAA,MAAA,OAE/C;AACN,cAAM,QAAQ,aAAa,OAAO,IAAI,GAAG;AACzC,YAAI,CAAC,OAAO;AACX,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEI,YAAA,MAAM,eAAe,WAAW;AACnC,wBAAQ,kBAAkB,OAAO,SAAS,GAAG,EAAE,OAAO,KAAwB;AAAA,QAAA,OACxE;AACN,wBAAQ,KAAK,eAAe,OAAO,UAAU,GAAG,GAAG,KAAe;AAAA,QACnE;AAAA,MACD;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -28,6 +28,7 @@ const evaluateCondition = (value, condition) => {
|
|
|
28
28
|
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),
|
|
29
29
|
never: () => false,
|
|
30
30
|
always: () => true,
|
|
31
|
+
// deprecated
|
|
31
32
|
null: (expr) => value === null === expr
|
|
32
33
|
};
|
|
33
34
|
return Object.entries(condition).every(([operator, argument]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateCondition.js","sources":["../../../../src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { GraphQlLiteral, Input } from '@contember/client'\nimport { FieldValue } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nconst unwrapGraphqlLiteral = (value: Input.ColumnValue<GraphQlLiteral>): any => {\n\tif (value instanceof GraphQlLiteral) {\n\t\treturn value.value\n\t}\n\treturn value\n}\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue<GraphQlLiteral>>) => {\n\t\tconst handlers: {\n\t\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t\t) => boolean\n\t\t} = {\n\t\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\t\tnot: expr => !evaluateCondition(value, expr),\n\t\t\teq: expr => value === unwrapGraphqlLiteral(expr),\n\t\t\tnotEq: expr => value !== unwrapGraphqlLiteral(expr),\n\t\t\tisNull: expr => (value === null) === expr,\n\t\t\tin: expr => expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tnotIn: expr => !expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tlt: expr => value !== null && value < unwrapGraphqlLiteral(expr),\n\t\t\tlte: expr => value !== null && value <= unwrapGraphqlLiteral(expr),\n\t\t\tgt: expr => value !== null && value > unwrapGraphqlLiteral(expr),\n\t\t\tgte: expr => value !== null && value >= unwrapGraphqlLiteral(expr),\n\t\t\tcontains: expr => typeof value === 'string' && value.includes(unwrapGraphqlLiteral(expr)),\n\t\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tendsWith: expr => typeof value === 'string' && value.endsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tnever: () => false,\n\t\t\talways: () => true,\n\t\t\t// deprecated\n\t\t\tnull: expr => (value === null) === expr,\n\t\t}\n\t\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\t\tif (value === undefined) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst handlerKey = operator as keyof typeof handlers\n\t\t\tconst handler = handlers[handlerKey]\n\t\t\tif (!handler) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn handler(argument)\n\t\t})\n\t}\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,CAAC,UAAkD;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACd;AACO,SAAA;AACR;AAEa,MAAA,oBAAoB,CAAC,OAA0B,cAAkE;AAC5H,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,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Q,MAAM;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"evaluateCondition.js","sources":["../../../../src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { GraphQlLiteral, Input } from '@contember/client'\nimport { FieldValue } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nconst unwrapGraphqlLiteral = (value: Input.ColumnValue<GraphQlLiteral>): any => {\n\tif (value instanceof GraphQlLiteral) {\n\t\treturn value.value\n\t}\n\treturn value\n}\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue<GraphQlLiteral>>) => {\n\t\tconst handlers: {\n\t\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t\t) => boolean\n\t\t} = {\n\t\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\t\tnot: expr => !evaluateCondition(value, expr),\n\t\t\teq: expr => value === unwrapGraphqlLiteral(expr),\n\t\t\tnotEq: expr => value !== unwrapGraphqlLiteral(expr),\n\t\t\tisNull: expr => (value === null) === expr,\n\t\t\tin: expr => expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tnotIn: expr => !expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tlt: expr => value !== null && value < unwrapGraphqlLiteral(expr),\n\t\t\tlte: expr => value !== null && value <= unwrapGraphqlLiteral(expr),\n\t\t\tgt: expr => value !== null && value > unwrapGraphqlLiteral(expr),\n\t\t\tgte: expr => value !== null && value >= unwrapGraphqlLiteral(expr),\n\t\t\tcontains: expr => typeof value === 'string' && value.includes(unwrapGraphqlLiteral(expr)),\n\t\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tendsWith: expr => typeof value === 'string' && value.endsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tnever: () => false,\n\t\t\talways: () => true,\n\t\t\t// deprecated\n\t\t\tnull: expr => (value === null) === expr,\n\t\t}\n\t\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\t\tif (value === undefined) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst handlerKey = operator as keyof typeof handlers\n\t\t\tconst handler = handlers[handlerKey]\n\t\t\tif (!handler) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn handler(argument)\n\t\t})\n\t}\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,CAAC,UAAkD;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACd;AACO,SAAA;AACR;AAEa,MAAA,oBAAoB,CAAC,OAA0B,cAAkE;AAC5H,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAC/C,OAAO,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAClD,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI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AI,aAAa;AAAA,IACxB;AACA,WAAO,QAAQ,QAAQ;AAAA,EAAA,CACvB;AACF;"}
|
|
@@ -9,6 +9,7 @@ class EntityFieldMarkersContainer {
|
|
|
9
9
|
this.markers = markers;
|
|
10
10
|
this.placeholders = placeholders;
|
|
11
11
|
}
|
|
12
|
+
// …asserting that it's present
|
|
12
13
|
getFieldByPlaceholder(placeholder) {
|
|
13
14
|
const marker = this.markers.get(placeholder);
|
|
14
15
|
if (marker instanceof FieldMarker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFieldMarkersContainer.js","sources":["../../../src/markers/EntityFieldMarkersContainer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityFieldMarkers } from './EntityFieldMarkers'\nimport type { EntityFieldPlaceholders } from './EntityFieldPlaceholders'\nimport { FieldMarker } from './FieldMarker'\nimport { HasManyRelationMarker } from './HasManyRelationMarker'\nimport { HasOneRelationMarker } from './HasOneRelationMarker'\n\nexport class EntityFieldMarkersContainer {\n\tpublic constructor(\n\t\tpublic readonly hasAtLeastOneBearingField: boolean,\n\t\tpublic readonly markers: EntityFieldMarkers, // Indexed by placeholder names\n\t\tpublic readonly placeholders: EntityFieldPlaceholders, // Indexed by field names\n\t) {}\n\n\t// …asserting that it's present\n\tpublic getFieldByPlaceholder(placeholder: PlaceholderName): FieldName {\n\t\tconst marker = this.markers.get(placeholder)\n\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn marker.fieldName\n\t\t}\n\t\tif (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn marker.parameters.field\n\t\t}\n\t\tif (marker === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn assertNever(marker)\n\t}\n\n\tpublic *getPlaceholdersByField(field: FieldName): IterableIterator<PlaceholderName> {\n\t\tconst placeholders = this.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof placeholders === 'string') {\n\t\t\tyield placeholders\n\t\t\treturn\n\t\t}\n\t\tyield* placeholders.values()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,4BAA4B;AAAA,EACjC,YACU,2BACA,SACA,cACf;AAHe,SAAA,4BAAA;AACA,SAAA,UAAA;AACA,SAAA,eAAA;AAAA,EACd;AAAA,EAGI,sBAAsB,aAAyC;AACrE,UAAM,SAAS,KAAK,QAAQ,IAAI,WAAW;AAE3C,QAAI,kBAAkB,aAAa;AAClC,aAAO,OAAO;AAAA,IACf;AACI,QAAA,kBAAkB,wBAAwB,kBAAkB,uBAAuB;AACtF,aAAO,OAAO,WAAW;AAAA,IAC1B;AACA,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,YAAkB;AAAA,EAC1B;AAAA,EAEA,CAAQ,uBAAuB,OAAqD;AACnF,UAAM,eAAe,KAAK,aAAa,IAAI,KAAK;AAEhD,QAAI,iBAAiB,QAAW;AAC/B;AAAA,IACD;AACI,QAAA,OAAO,iBAAiB,UAAU;AAC/B,YAAA;AACN;AAAA,IACD;AACA,WAAO,aAAa;EACrB;AACD;"}
|
|
1
|
+
{"version":3,"file":"EntityFieldMarkersContainer.js","sources":["../../../src/markers/EntityFieldMarkersContainer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityFieldMarkers } from './EntityFieldMarkers'\nimport type { EntityFieldPlaceholders } from './EntityFieldPlaceholders'\nimport { FieldMarker } from './FieldMarker'\nimport { HasManyRelationMarker } from './HasManyRelationMarker'\nimport { HasOneRelationMarker } from './HasOneRelationMarker'\n\nexport class EntityFieldMarkersContainer {\n\tpublic constructor(\n\t\tpublic readonly hasAtLeastOneBearingField: boolean,\n\t\tpublic readonly markers: EntityFieldMarkers, // Indexed by placeholder names\n\t\tpublic readonly placeholders: EntityFieldPlaceholders, // Indexed by field names\n\t) {}\n\n\t// …asserting that it's present\n\tpublic getFieldByPlaceholder(placeholder: PlaceholderName): FieldName {\n\t\tconst marker = this.markers.get(placeholder)\n\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn marker.fieldName\n\t\t}\n\t\tif (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn marker.parameters.field\n\t\t}\n\t\tif (marker === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn assertNever(marker)\n\t}\n\n\tpublic *getPlaceholdersByField(field: FieldName): IterableIterator<PlaceholderName> {\n\t\tconst placeholders = this.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof placeholders === 'string') {\n\t\t\tyield placeholders\n\t\t\treturn\n\t\t}\n\t\tyield* placeholders.values()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,4BAA4B;AAAA,EACjC,YACU,2BACA,SACA,cACf;AAHe,SAAA,4BAAA;AACA,SAAA,UAAA;AACA,SAAA,eAAA;AAAA,EACd;AAAA;AAAA,EAGI,sBAAsB,aAAyC;AACrE,UAAM,SAAS,KAAK,QAAQ,IAAI,WAAW;AAE3C,QAAI,kBAAkB,aAAa;AAClC,aAAO,OAAO;AAAA,IACf;AACI,QAAA,kBAAkB,wBAAwB,kBAAkB,uBAAuB;AACtF,aAAO,OAAO,WAAW;AAAA,IAC1B;AACA,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,YAAkB;AAAA,EAC1B;AAAA,EAEA,CAAQ,uBAAuB,OAAqD;AACnF,UAAM,eAAe,KAAK,aAAa,IAAI,KAAK;AAEhD,QAAI,iBAAiB,QAAW;AAC/B;AAAA,IACD;AACI,QAAA,OAAO,iBAAiB,UAAU;AAC/B,YAAA;AACN;AAAA,IACD;AACA,WAAO,aAAa;EACrB;AACD;"}
|
|
@@ -4,7 +4,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { BindingError } from "../BindingError.js";
|
|
8
7
|
import { PlaceholderGenerator } from "./PlaceholderGenerator.js";
|
|
9
8
|
class HasManyRelationMarker {
|
|
10
9
|
constructor(parameters, fields, environment) {
|
|
@@ -12,11 +11,6 @@ class HasManyRelationMarker {
|
|
|
12
11
|
this.parameters = parameters;
|
|
13
12
|
this.fields = fields;
|
|
14
13
|
this.environment = environment;
|
|
15
|
-
{
|
|
16
|
-
if (parameters.initialEntityCount < 0 || !Number.isInteger(parameters.initialEntityCount)) {
|
|
17
|
-
throw new BindingError(`The preferred 'initialEntityCount' for a relation must be a non-negative integer!`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
14
|
this.placeholderName = PlaceholderGenerator.getHasManyRelationPlaceholder(this.parameters);
|
|
21
15
|
}
|
|
22
16
|
get isNonbearing() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyRelationMarker.js","sources":["../../../src/markers/HasManyRelationMarker.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport type { HasManyRelation } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\n// This doesn't represent reduced has many relations.\nexport class HasManyRelationMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: HasManyRelation,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tif (parameters.initialEntityCount < 0 || !Number.isInteger(parameters.initialEntityCount)) {\n\t\t\t\tthrow new BindingError(`The preferred 'initialEntityCount' for a relation must be a non-negative integer!`)\n\t\t\t}\n\t\t}\n\t\tthis.placeholderName = PlaceholderGenerator.getHasManyRelationPlaceholder(this.parameters)\n\t}\n\n\tpublic get isNonbearing() {\n\t\treturn this.parameters.isNonbearing\n\t}\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HasManyRelationMarker.js","sources":["../../../src/markers/HasManyRelationMarker.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport type { HasManyRelation } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\n// This doesn't represent reduced has many relations.\nexport class HasManyRelationMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: HasManyRelation,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tif (parameters.initialEntityCount < 0 || !Number.isInteger(parameters.initialEntityCount)) {\n\t\t\t\tthrow new BindingError(`The preferred 'initialEntityCount' for a relation must be a non-negative integer!`)\n\t\t\t}\n\t\t}\n\t\tthis.placeholderName = PlaceholderGenerator.getHasManyRelationPlaceholder(this.parameters)\n\t}\n\n\tpublic get isNonbearing() {\n\t\treturn this.parameters.isNonbearing\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAOO,MAAM,sBAAsB;AAAA,EAG3B,YACU,YACA,QACA,aACf;AANc;AAGC,SAAA,aAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AAOhB,SAAK,kBAAkB,qBAAqB,8BAA8B,KAAK,UAAU;AAAA,EAC1F;AAAA,EAEA,IAAW,eAAe;AACzB,WAAO,KAAK,WAAW;AAAA,EACxB;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheStore.js","sources":["../../../src/queryLanguage/CacheStore.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport { LRUCache } from '../structures'\nimport type { Parser } from './Parser'\n\ntype CacheByEntryPoint = {\n\t[Entry in Parser.EntryPoint]: LRUCache<string, Parser.ParserResult[Entry]>\n}\n\nexport class CacheStore {\n\tprivate cacheStore: WeakMap<Environment, CacheByEntryPoint> = new WeakMap()\n\n\tpublic get<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t): Parser.ParserResult[Entry] | undefined {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\treturn caches[entry].get(expression) as Parser.ParserResult[Entry] | undefined\n\t}\n\n\tpublic set<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t\tvalue: Parser.ParserResult[Entry],\n\t) {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\t(caches[entry] as LRUCache<string, Parser.ParserResult[Entry]>).set(expression, value)\n\t}\n\n\tprivate createEntryPointCache(): CacheByEntryPoint {\n\t\t// TODO configurable limits\n\t\treturn {\n\t\t\tqualifiedEntityList: new LRUCache(50),\n\t\t\tqualifiedFieldList: new LRUCache(50),\n\t\t\tqualifiedSingleEntity: new LRUCache(50),\n\t\t\tunconstrainedQualifiedEntityList: new LRUCache(10),\n\t\t\tunconstrainedQualifiedSingleEntity: new LRUCache(10),\n\t\t\trelativeSingleField: new LRUCache(1000),\n\t\t\trelativeSingleEntity: new LRUCache(500),\n\t\t\trelativeEntityList: new LRUCache(500),\n\t\t\tuniqueWhere: new LRUCache(100),\n\t\t\tfilter: new LRUCache(100),\n\t\t\torderBy: new LRUCache(50),\n\t\t\ttaggedMap: new LRUCache(50),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAQO,MAAM,WAAW;AAAA,EAAjB;AACE,0DAA0D;;EAE3D,IACN,aACA,OACA,YACyC;AACzC,QAAI,SAAS,KAAK,WAAW,IAAI,WAAW;AAE5C,QAAI,WAAW,QAAW;AACzB,WAAK,WAAW,IAAI,aAAc,SAAS,KAAK,uBAAwB;AAAA,IACzE;
|
|
1
|
+
{"version":3,"file":"CacheStore.js","sources":["../../../src/queryLanguage/CacheStore.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport { LRUCache } from '../structures'\nimport type { Parser } from './Parser'\n\ntype CacheByEntryPoint = {\n\t[Entry in Parser.EntryPoint]: LRUCache<string, Parser.ParserResult[Entry]>\n}\n\nexport class CacheStore {\n\tprivate cacheStore: WeakMap<Environment, CacheByEntryPoint> = new WeakMap()\n\n\tpublic get<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t): Parser.ParserResult[Entry] | undefined {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\treturn caches[entry].get(expression) as Parser.ParserResult[Entry] | undefined\n\t}\n\n\tpublic set<Entry extends Parser.EntryPoint>(\n\t\tenvironment: Environment,\n\t\tentry: Entry,\n\t\texpression: string,\n\t\tvalue: Parser.ParserResult[Entry],\n\t) {\n\t\tlet caches = this.cacheStore.get(environment)\n\n\t\tif (caches === undefined) {\n\t\t\tthis.cacheStore.set(environment, (caches = this.createEntryPointCache()))\n\t\t}\n\t\t(caches[entry] as LRUCache<string, Parser.ParserResult[Entry]>).set(expression, value)\n\t}\n\n\tprivate createEntryPointCache(): CacheByEntryPoint {\n\t\t// TODO configurable limits\n\t\treturn {\n\t\t\tqualifiedEntityList: new LRUCache(50),\n\t\t\tqualifiedFieldList: new LRUCache(50),\n\t\t\tqualifiedSingleEntity: new LRUCache(50),\n\t\t\tunconstrainedQualifiedEntityList: new LRUCache(10),\n\t\t\tunconstrainedQualifiedSingleEntity: new LRUCache(10),\n\t\t\trelativeSingleField: new LRUCache(1000),\n\t\t\trelativeSingleEntity: new LRUCache(500),\n\t\t\trelativeEntityList: new LRUCache(500),\n\t\t\tuniqueWhere: new LRUCache(100),\n\t\t\tfilter: new LRUCache(100),\n\t\t\torderBy: new LRUCache(50),\n\t\t\ttaggedMap: new LRUCache(50),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAQO,MAAM,WAAW;AAAA,EAAjB;AACE,0DAA0D;;EAE3D,IACN,aACA,OACA,YACyC;AACzC,QAAI,SAAS,KAAK,WAAW,IAAI,WAAW;AAE5C,QAAI,WAAW,QAAW;AACzB,WAAK,WAAW,IAAI,aAAc,SAAS,KAAK,uBAAwB;AAAA,IACzE;AACA,WAAO,OAAO,KAAK,EAAE,IAAI,UAAU;AAAA,EACpC;AAAA,EAEO,IACN,aACA,OACA,YACA,OACC;AACD,QAAI,SAAS,KAAK,WAAW,IAAI,WAAW;AAE5C,QAAI,WAAW,QAAW;AACzB,WAAK,WAAW,IAAI,aAAc,SAAS,KAAK,uBAAwB;AAAA,IACzE;AACC,WAAO,KAAK,EAAmD,IAAI,YAAY,KAAK;AAAA,EACtF;AAAA,EAEQ,wBAA2C;AAE3C,WAAA;AAAA,MACN,qBAAqB,IAAI,SAAS,EAAE;AAAA,MACpC,oBAAoB,IAAI,SAAS,EAAE;AAAA,MACnC,uBAAuB,IAAI,SAAS,EAAE;AAAA,MACtC,kCAAkC,IAAI,SAAS,EAAE;AAAA,MACjD,oCAAoC,IAAI,SAAS,EAAE;AAAA,MACnD,qBAAqB,IAAI,SAAS,GAAI;AAAA,MACtC,sBAAsB,IAAI,SAAS,GAAG;AAAA,MACtC,oBAAoB,IAAI,SAAS,GAAG;AAAA,MACpC,aAAa,IAAI,SAAS,GAAG;AAAA,MAC7B,QAAQ,IAAI,SAAS,GAAG;AAAA,MACxB,SAAS,IAAI,SAAS,EAAE;AAAA,MACxB,WAAW,IAAI,SAAS,EAAE;AAAA,IAAA;AAAA,EAE5B;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkerFactory.js","sources":["../../../src/queryLanguage/MarkerFactory.ts"],"sourcesContent":["import { MarkerMerger, TreeParameterMerger } from '../core'\nimport type { Environment } from '../dao'\nimport {\n\tEntityFieldMarker,\n\tEntityFieldMarkersContainer,\n\tEntityFieldsWithHoistablesMarker,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport type {\n\tEntityEventListenerStore,\n\tHasManyRelation,\n\tHasOneRelation,\n\tQualifiedSingleEntity,\n\tRelativeSingleField,\n\tSugaredParentEntityParameters,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { QueryLanguage } from './QueryLanguage'\nimport { GraphQlLiteral } from '@contember/client'\nimport { BindingError } from '../BindingError'\n\nexport class MarkerFactory {\n\tprivate static createSubTreeMarker<\n\t\tParams extends Record<'hasOneRelationPath', HasOneRelation[]> & Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Params,\n\t>(\n\t\tqualifiedParams: Params,\n\t\tkey: Key,\n\t\tMarker: new (params: Params, fields: EntityFieldMarkersContainer, env: Environment) =>\n\t\t\t| EntitySubTreeMarker\n\t\t\t| EntityListSubTreeMarker,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tlet entityFields: EntityFieldMarkersContainer | undefined\n\n\t\tif (fields instanceof EntityFieldsWithHoistablesMarker) {\n\t\t\t// TODO this is wrong with respect to hasOneRelationPath\n\t\t\tqualifiedParams = TreeParameterMerger.mergeInParentEntity(qualifiedParams, key, fields.parentReference)\n\t\t\tentityFields = fields.fields\n\t\t} else {\n\t\t\tentityFields = fields\n\t\t}\n\n\t\tconst subTree = new Marker(\n\t\t\tqualifiedParams,\n\t\t\tthis.wrapRelativeEntityFieldMarkers(\n\t\t\t\tqualifiedParams.hasOneRelationPath,\n\t\t\t\tenvironment,\n\t\t\t\tMarkerMerger.mergeInSystemFields(entityFields),\n\t\t\t),\n\t\t\tenvironment,\n\t\t)\n\t\tif (fields instanceof EntityFieldsWithHoistablesMarker) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\tthis.createEntityFieldMarkersContainer(undefined),\n\t\t\t\tMarkerMerger.mergeSubTreeMarkers(fields.subTrees, new Map([[subTree.placeholderName, subTree]])),\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.createEntityFieldMarkersContainer(undefined),\n\t\t\tnew Map([[subTree.placeholderName, subTree]]),\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createEntitySubTreeMarker(\n\t\tentity: SugaredQualifiedSingleEntity,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tconst qualifiedSingleEntity: QualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(entity, environment, { missingSetOnCreate: 'fillAndWarn' })\n\n\t\treturn this.createSubTreeMarker(qualifiedSingleEntity, 'eventListeners', EntitySubTreeMarker, fields, environment)\n\t}\n\n\tpublic static createUnconstrainedEntitySubTreeMarker(\n\t\tentity: SugaredUnconstrainedQualifiedSingleEntity,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarUnconstrainedQualifiedSingleEntity(entity, environment),\n\t\t\t'eventListeners',\n\t\t\tEntitySubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createEntityListSubTreeMarker(\n\t\tentityList: SugaredQualifiedEntityList,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarQualifiedEntityList(entityList, environment),\n\t\t\t'childEventListeners',\n\t\t\tEntityListSubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createUnconstrainedEntityListSubTreeMarker(\n\t\tentityList: SugaredUnconstrainedQualifiedEntityList,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarUnconstrainedQualifiedEntityList(entityList, environment),\n\t\t\t'childEventListeners',\n\t\t\tEntityListSubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createParentEntityMarker(\n\t\tparentEntity: SugaredParentEntityParameters,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tconst desugared = QueryLanguage.desugarParentEntityParameters(parentEntity, environment)\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fields, undefined, desugared)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tfields.fields,\n\t\t\tfields.subTrees,\n\t\t\tTreeParameterMerger.mergeParentEntityParameters(fields.parentReference, desugared),\n\t\t)\n\t}\n\n\tpublic static createEntityFieldsWithHoistablesMarker(\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fields, undefined, undefined)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(fields.fields, fields.subTrees, undefined)\n\t}\n\n\tpublic static createRelativeSingleEntityFields(\n\t\tfield: SugaredRelativeSingleEntity,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(field, environment)\n\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn this.wrapRelativeEntityFieldMarkers(relativeSingleEntity.hasOneRelationPath, environment, fields)\n\t\t}\n\t\trelativeSingleEntity.hasOneRelationPath[relativeSingleEntity.hasOneRelationPath.length - 1] =\n\t\t\tTreeParameterMerger.mergeInParentEntity(\n\t\t\t\trelativeSingleEntity.hasOneRelationPath[relativeSingleEntity.hasOneRelationPath.length - 1],\n\t\t\t\t'eventListeners',\n\t\t\t\tfields.parentReference,\n\t\t\t)\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.wrapRelativeEntityFieldMarkers(relativeSingleEntity.hasOneRelationPath, environment, fields.fields),\n\t\t\tfields.subTrees,\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createRelativeEntityListFields(\n\t\tfield: SugaredRelativeEntityList,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer,\n\t) {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(field, environment)\n\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\tconst hasManyRelationMarker = this.createHasManyRelationMarker(\n\t\t\t\trelativeEntityList.hasManyRelation,\n\t\t\t\tenvironment,\n\t\t\t\tfields,\n\t\t\t)\n\t\t\treturn this.wrapRelativeEntityFieldMarkers(\n\t\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t\tenvironment.getParent(),\n\t\t\t\tthis.createEntityFieldMarkersContainer(hasManyRelationMarker),\n\t\t\t)\n\t\t}\n\n\t\trelativeEntityList.hasManyRelation = TreeParameterMerger.mergeInParentEntity(\n\t\t\trelativeEntityList.hasManyRelation,\n\t\t\t'childEventListeners',\n\t\t\tfields.parentReference,\n\t\t)\n\n\t\tconst hasManyRelationMarker = this.createHasManyRelationMarker(\n\t\t\trelativeEntityList.hasManyRelation,\n\t\t\tenvironment,\n\t\t\tfields.fields,\n\t\t)\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.wrapRelativeEntityFieldMarkers(\n\t\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t\tenvironment.getParent(),\n\t\t\t\tthis.createEntityFieldMarkersContainer(hasManyRelationMarker),\n\t\t\t),\n\t\t\tfields.subTrees,\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createFieldMarker(field: SugaredRelativeSingleField, environment: Environment) {\n\t\treturn this.wrapRelativeSingleField(\n\t\t\tfield,\n\t\t\tenvironment,\n\t\t\trelativeSingleField =>\n\t\t\t\tnew FieldMarker(relativeSingleField.field, relativeSingleField.defaultValue, relativeSingleField.isNonbearing),\n\t\t)\n\t}\n\n\tprivate static wrapRelativeSingleField(\n\t\tfield: SugaredRelativeSingleField,\n\t\tenvironment: Environment,\n\t\tgetMarker: (relativeSingleField: RelativeSingleField) => EntityFieldMarker,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(field, environment)\n\n\t\treturn this.wrapRelativeEntityFieldMarkers(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\tenvironment.getParent(),\n\t\t\tthis.createEntityFieldMarkersContainer(getMarker(relativeSingleField)),\n\t\t)\n\t}\n\n\tprivate static wrapRelativeEntityFieldMarkers(\n\t\thasOneRelationPath: HasOneRelation[],\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t): EntityFieldMarkersContainer {\n\t\tfor (let i = hasOneRelationPath.length - 1; i >= 0; i--) {\n\t\t\tconst marker = this.createHasOneRelationMarker(hasOneRelationPath[i], environment, fields)\n\t\t\tenvironment = environment.getParent()\n\t\t\tfields = this.createEntityFieldMarkersContainer(marker)\n\t\t}\n\t\treturn fields\n\t}\n\n\tpublic static createEntityFieldMarkersContainer(marker: EntityFieldMarker | undefined): EntityFieldMarkersContainer {\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn new EntityFieldMarkersContainer(\n\t\t\t\t!marker.isNonbearing,\n\t\t\t\tnew Map([[marker.placeholderName, marker]]),\n\t\t\t\tnew Map([[marker.fieldName, marker.placeholderName]]),\n\t\t\t)\n\t\t} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn new EntityFieldMarkersContainer(\n\t\t\t\t!marker.parameters.isNonbearing,\n\t\t\t\tnew Map([[marker.placeholderName, marker]]),\n\t\t\t\tnew Map([[marker.parameters.field, marker.placeholderName]]),\n\t\t\t)\n\t\t} else if (marker === undefined) {\n\t\t\treturn new EntityFieldMarkersContainer(false, new Map(), new Map())\n\t\t} else {\n\t\t\treturn assertNever(marker)\n\t\t}\n\t}\n\n\tprivate static createHasOneRelationMarker(\n\t\thasOneRelation: HasOneRelation,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t): HasOneRelationMarker {\n\t\treturn new HasOneRelationMarker(\n\t\t\t{\n\t\t\t\t...hasOneRelation,\n\t\t\t\tsetOnCreate: hasOneRelation.reducedBy\n\t\t\t\t\t? TreeParameterMerger.mergeSetOnCreate(hasOneRelation.setOnCreate || {}, hasOneRelation.reducedBy)\n\t\t\t\t\t: hasOneRelation.setOnCreate,\n\t\t\t},\n\t\t\tMarkerMerger.mergeInSystemFields(fields),\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tprivate static createHasManyRelationMarker(\n\t\thasManyRelation: HasManyRelation,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t) {\n\t\treturn new HasManyRelationMarker(hasManyRelation, MarkerMerger.mergeInSystemFields(fields), environment)\n\t}\n}\n"],"names":["hasManyRelationMarker"],"mappings":";;;;;;;;;;;AAgCO,MAAM,cAAc;AAAA,EAC1B,OAAe,oBAId,iBACA,KACA,QAGA,QACA,aACmC;AAC/B,QAAA;AAEJ,QAAI,kBAAkB,kCAAkC;AAEvD,wBAAkB,oBAAoB,oBAAoB,iBAAiB,KAAK,OAAO,eAAe;AACtG,qBAAe,OAAO;AAAA,IAAA,OAChB;AACS,qBAAA;AAAA,IAChB;AAEA,UAAM,UAAU,IAAI;AAAA,MACnB;AAAA,MACA,KAAK;AAAA,QACJ,gBAAgB;AAAA,QAChB;AAAA,QACA,aAAa,oBAAoB,YAAY;AAAA,MAC9C;AAAA,MACA;AAAA,IAAA;AAED,QAAI,kBAAkB,kCAAkC;AACvD,aAAO,IAAI;AAAA,QACV,KAAK,kCAAkC,MAAS;AAAA,QAChD,aAAa,oBAAoB,OAAO,UAAc,oBAAA,IAAI,CAAC,CAAC,QAAQ,iBAAiB,OAAO,CAAC,CAAC,CAAC;AAAA,QAC/F;AAAA,MAAA;AAAA,IAEF;AACA,WAAO,IAAI;AAAA,MACV,KAAK,kCAAkC,MAAS;AAAA,MAChD,oBAAI,IAAI,CAAC,CAAC,QAAQ,iBAAiB,OAAO,CAAC,CAAC;AAAA,MAC5C;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,0BACb,QACA,QACA,aACmC;AAC7B,UAAA,wBAA+C,cAAc,6BAA6B,QAAQ,aAAa,EAAE,oBAAoB,eAAe;AAE1J,WAAO,KAAK,oBAAoB,uBAAuB,kBAAkB,qBAAqB,QAAQ,WAAW;AAAA,EAClH;AAAA,EAEA,OAAc,uCACb,QACA,QACA,aACmC;AACnC,WAAO,KAAK;AAAA,MACX,cAAc,0CAA0C,QAAQ,WAAW;AAAA,MAC3E;AAAA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EACxG;AACD;"}
|
|
1
|
+
{"version":3,"file":"MarkerFactory.js","sources":["../../../src/queryLanguage/MarkerFactory.ts"],"sourcesContent":["import { MarkerMerger, TreeParameterMerger } from '../core'\nimport type { Environment } from '../dao'\nimport {\n\tEntityFieldMarker,\n\tEntityFieldMarkersContainer,\n\tEntityFieldsWithHoistablesMarker,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport type {\n\tEntityEventListenerStore,\n\tHasManyRelation,\n\tHasOneRelation,\n\tQualifiedSingleEntity,\n\tRelativeSingleField,\n\tSugaredParentEntityParameters,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { QueryLanguage } from './QueryLanguage'\nimport { GraphQlLiteral } from '@contember/client'\nimport { BindingError } from '../BindingError'\n\nexport class MarkerFactory {\n\tprivate static createSubTreeMarker<\n\t\tParams extends Record<'hasOneRelationPath', HasOneRelation[]> & Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Params,\n\t>(\n\t\tqualifiedParams: Params,\n\t\tkey: Key,\n\t\tMarker: new (params: Params, fields: EntityFieldMarkersContainer, env: Environment) =>\n\t\t\t| EntitySubTreeMarker\n\t\t\t| EntityListSubTreeMarker,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tlet entityFields: EntityFieldMarkersContainer | undefined\n\n\t\tif (fields instanceof EntityFieldsWithHoistablesMarker) {\n\t\t\t// TODO this is wrong with respect to hasOneRelationPath\n\t\t\tqualifiedParams = TreeParameterMerger.mergeInParentEntity(qualifiedParams, key, fields.parentReference)\n\t\t\tentityFields = fields.fields\n\t\t} else {\n\t\t\tentityFields = fields\n\t\t}\n\n\t\tconst subTree = new Marker(\n\t\t\tqualifiedParams,\n\t\t\tthis.wrapRelativeEntityFieldMarkers(\n\t\t\t\tqualifiedParams.hasOneRelationPath,\n\t\t\t\tenvironment,\n\t\t\t\tMarkerMerger.mergeInSystemFields(entityFields),\n\t\t\t),\n\t\t\tenvironment,\n\t\t)\n\t\tif (fields instanceof EntityFieldsWithHoistablesMarker) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\tthis.createEntityFieldMarkersContainer(undefined),\n\t\t\t\tMarkerMerger.mergeSubTreeMarkers(fields.subTrees, new Map([[subTree.placeholderName, subTree]])),\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.createEntityFieldMarkersContainer(undefined),\n\t\t\tnew Map([[subTree.placeholderName, subTree]]),\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createEntitySubTreeMarker(\n\t\tentity: SugaredQualifiedSingleEntity,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tconst qualifiedSingleEntity: QualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(entity, environment, { missingSetOnCreate: 'fillAndWarn' })\n\n\t\treturn this.createSubTreeMarker(qualifiedSingleEntity, 'eventListeners', EntitySubTreeMarker, fields, environment)\n\t}\n\n\tpublic static createUnconstrainedEntitySubTreeMarker(\n\t\tentity: SugaredUnconstrainedQualifiedSingleEntity,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarUnconstrainedQualifiedSingleEntity(entity, environment),\n\t\t\t'eventListeners',\n\t\t\tEntitySubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createEntityListSubTreeMarker(\n\t\tentityList: SugaredQualifiedEntityList,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarQualifiedEntityList(entityList, environment),\n\t\t\t'childEventListeners',\n\t\t\tEntityListSubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createUnconstrainedEntityListSubTreeMarker(\n\t\tentityList: SugaredUnconstrainedQualifiedEntityList,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\treturn this.createSubTreeMarker(\n\t\t\tQueryLanguage.desugarUnconstrainedQualifiedEntityList(entityList, environment),\n\t\t\t'childEventListeners',\n\t\t\tEntityListSubTreeMarker,\n\t\t\tfields,\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tpublic static createParentEntityMarker(\n\t\tparentEntity: SugaredParentEntityParameters,\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tconst desugared = QueryLanguage.desugarParentEntityParameters(parentEntity, environment)\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fields, undefined, desugared)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tfields.fields,\n\t\t\tfields.subTrees,\n\t\t\tTreeParameterMerger.mergeParentEntityParameters(fields.parentReference, desugared),\n\t\t)\n\t}\n\n\tpublic static createEntityFieldsWithHoistablesMarker(\n\t\tfields: EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker,\n\t\tenvironment: Environment,\n\t): EntityFieldsWithHoistablesMarker {\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fields, undefined, undefined)\n\t\t}\n\t\treturn new EntityFieldsWithHoistablesMarker(fields.fields, fields.subTrees, undefined)\n\t}\n\n\tpublic static createRelativeSingleEntityFields(\n\t\tfield: SugaredRelativeSingleEntity,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(field, environment)\n\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\treturn this.wrapRelativeEntityFieldMarkers(relativeSingleEntity.hasOneRelationPath, environment, fields)\n\t\t}\n\t\trelativeSingleEntity.hasOneRelationPath[relativeSingleEntity.hasOneRelationPath.length - 1] =\n\t\t\tTreeParameterMerger.mergeInParentEntity(\n\t\t\t\trelativeSingleEntity.hasOneRelationPath[relativeSingleEntity.hasOneRelationPath.length - 1],\n\t\t\t\t'eventListeners',\n\t\t\t\tfields.parentReference,\n\t\t\t)\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.wrapRelativeEntityFieldMarkers(relativeSingleEntity.hasOneRelationPath, environment, fields.fields),\n\t\t\tfields.subTrees,\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createRelativeEntityListFields(\n\t\tfield: SugaredRelativeEntityList,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer,\n\t) {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(field, environment)\n\n\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\tconst hasManyRelationMarker = this.createHasManyRelationMarker(\n\t\t\t\trelativeEntityList.hasManyRelation,\n\t\t\t\tenvironment,\n\t\t\t\tfields,\n\t\t\t)\n\t\t\treturn this.wrapRelativeEntityFieldMarkers(\n\t\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t\tenvironment.getParent(),\n\t\t\t\tthis.createEntityFieldMarkersContainer(hasManyRelationMarker),\n\t\t\t)\n\t\t}\n\n\t\trelativeEntityList.hasManyRelation = TreeParameterMerger.mergeInParentEntity(\n\t\t\trelativeEntityList.hasManyRelation,\n\t\t\t'childEventListeners',\n\t\t\tfields.parentReference,\n\t\t)\n\n\t\tconst hasManyRelationMarker = this.createHasManyRelationMarker(\n\t\t\trelativeEntityList.hasManyRelation,\n\t\t\tenvironment,\n\t\t\tfields.fields,\n\t\t)\n\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\tthis.wrapRelativeEntityFieldMarkers(\n\t\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t\tenvironment.getParent(),\n\t\t\t\tthis.createEntityFieldMarkersContainer(hasManyRelationMarker),\n\t\t\t),\n\t\t\tfields.subTrees,\n\t\t\tundefined,\n\t\t)\n\t}\n\n\tpublic static createFieldMarker(field: SugaredRelativeSingleField, environment: Environment) {\n\t\treturn this.wrapRelativeSingleField(\n\t\t\tfield,\n\t\t\tenvironment,\n\t\t\trelativeSingleField =>\n\t\t\t\tnew FieldMarker(relativeSingleField.field, relativeSingleField.defaultValue, relativeSingleField.isNonbearing),\n\t\t)\n\t}\n\n\tprivate static wrapRelativeSingleField(\n\t\tfield: SugaredRelativeSingleField,\n\t\tenvironment: Environment,\n\t\tgetMarker: (relativeSingleField: RelativeSingleField) => EntityFieldMarker,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(field, environment)\n\n\t\treturn this.wrapRelativeEntityFieldMarkers(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\tenvironment.getParent(),\n\t\t\tthis.createEntityFieldMarkersContainer(getMarker(relativeSingleField)),\n\t\t)\n\t}\n\n\tprivate static wrapRelativeEntityFieldMarkers(\n\t\thasOneRelationPath: HasOneRelation[],\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t): EntityFieldMarkersContainer {\n\t\tfor (let i = hasOneRelationPath.length - 1; i >= 0; i--) {\n\t\t\tconst marker = this.createHasOneRelationMarker(hasOneRelationPath[i], environment, fields)\n\t\t\tenvironment = environment.getParent()\n\t\t\tfields = this.createEntityFieldMarkersContainer(marker)\n\t\t}\n\t\treturn fields\n\t}\n\n\tpublic static createEntityFieldMarkersContainer(marker: EntityFieldMarker | undefined): EntityFieldMarkersContainer {\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn new EntityFieldMarkersContainer(\n\t\t\t\t!marker.isNonbearing,\n\t\t\t\tnew Map([[marker.placeholderName, marker]]),\n\t\t\t\tnew Map([[marker.fieldName, marker.placeholderName]]),\n\t\t\t)\n\t\t} else if (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn new EntityFieldMarkersContainer(\n\t\t\t\t!marker.parameters.isNonbearing,\n\t\t\t\tnew Map([[marker.placeholderName, marker]]),\n\t\t\t\tnew Map([[marker.parameters.field, marker.placeholderName]]),\n\t\t\t)\n\t\t} else if (marker === undefined) {\n\t\t\treturn new EntityFieldMarkersContainer(false, new Map(), new Map())\n\t\t} else {\n\t\t\treturn assertNever(marker)\n\t\t}\n\t}\n\n\tprivate static createHasOneRelationMarker(\n\t\thasOneRelation: HasOneRelation,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t): HasOneRelationMarker {\n\t\treturn new HasOneRelationMarker(\n\t\t\t{\n\t\t\t\t...hasOneRelation,\n\t\t\t\tsetOnCreate: hasOneRelation.reducedBy\n\t\t\t\t\t? TreeParameterMerger.mergeSetOnCreate(hasOneRelation.setOnCreate || {}, hasOneRelation.reducedBy)\n\t\t\t\t\t: hasOneRelation.setOnCreate,\n\t\t\t},\n\t\t\tMarkerMerger.mergeInSystemFields(fields),\n\t\t\tenvironment,\n\t\t)\n\t}\n\n\tprivate static createHasManyRelationMarker(\n\t\thasManyRelation: HasManyRelation,\n\t\tenvironment: Environment,\n\t\tfields: EntityFieldMarkersContainer,\n\t) {\n\t\treturn new HasManyRelationMarker(hasManyRelation, MarkerMerger.mergeInSystemFields(fields), environment)\n\t}\n}\n"],"names":["hasManyRelationMarker"],"mappings":";;;;;;;;;;;AAgCO,MAAM,cAAc;AAAA,EAC1B,OAAe,oBAId,iBACA,KACA,QAGA,QACA,aACmC;AAC/B,QAAA;AAEJ,QAAI,kBAAkB,kCAAkC;AAEvD,wBAAkB,oBAAoB,oBAAoB,iBAAiB,KAAK,OAAO,eAAe;AACtG,qBAAe,OAAO;AAAA,IAAA,OAChB;AACS,qBAAA;AAAA,IAChB;AAEA,UAAM,UAAU,IAAI;AAAA,MACnB;AAAA,MACA,KAAK;AAAA,QACJ,gBAAgB;AAAA,QAChB;AAAA,QACA,aAAa,oBAAoB,YAAY;AAAA,MAC9C;AAAA,MACA;AAAA,IAAA;AAED,QAAI,kBAAkB,kCAAkC;AACvD,aAAO,IAAI;AAAA,QACV,KAAK,kCAAkC,MAAS;AAAA,QAChD,aAAa,oBAAoB,OAAO,UAAc,oBAAA,IAAI,CAAC,CAAC,QAAQ,iBAAiB,OAAO,CAAC,CAAC,CAAC;AAAA,QAC/F;AAAA,MAAA;AAAA,IAEF;AACA,WAAO,IAAI;AAAA,MACV,KAAK,kCAAkC,MAAS;AAAA,MAChD,oBAAI,IAAI,CAAC,CAAC,QAAQ,iBAAiB,OAAO,CAAC,CAAC;AAAA,MAC5C;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,0BACb,QACA,QACA,aACmC;AAC7B,UAAA,wBAA+C,cAAc,6BAA6B,QAAQ,aAAa,EAAE,oBAAoB,eAAe;AAE1J,WAAO,KAAK,oBAAoB,uBAAuB,kBAAkB,qBAAqB,QAAQ,WAAW;AAAA,EAClH;AAAA,EAEA,OAAc,uCACb,QACA,QACA,aACmC;AACnC,WAAO,KAAK;AAAA,MACX,cAAc,0CAA0C,QAAQ,WAAW;AAAA,MAC3E;AAAA,MACA;AAAA,MACA;AAA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ACxG;AACD;"}
|
|
@@ -198,6 +198,7 @@ const _Parser = class extends EmbeddedActionsParser {
|
|
|
198
198
|
and: negations
|
|
199
199
|
};
|
|
200
200
|
}));
|
|
201
|
+
// TODO this is to naïve and needs rewriting
|
|
201
202
|
__publicField(this, "negation", this.RULE("negation", () => {
|
|
202
203
|
return this.OR([
|
|
203
204
|
{
|
|
@@ -533,6 +534,7 @@ const _Parser = class extends EmbeddedActionsParser {
|
|
|
533
534
|
ALT: () => this.CONSUME(tokens.Identifier).image
|
|
534
535
|
},
|
|
535
536
|
{
|
|
537
|
+
// TODO this is a temporary hack to allow for literals that start with an uppercase letter… 🙈
|
|
536
538
|
ALT: () => this.CONSUME(tokens.EntityIdentifier).image
|
|
537
539
|
}
|
|
538
540
|
]);
|
|
@@ -578,9 +580,6 @@ const _Parser = class extends EmbeddedActionsParser {
|
|
|
578
580
|
this.CONSUME(tokens.DollarSign);
|
|
579
581
|
const variableName = this.CONSUME(tokens.Identifier).image;
|
|
580
582
|
return this.ACTION(() => {
|
|
581
|
-
if (variableName === "rootWhereAsFilter") {
|
|
582
|
-
console.warn("$rootWhereAsFilter is deprecated, use $rootFilter");
|
|
583
|
-
}
|
|
584
583
|
switch (variableName) {
|
|
585
584
|
case "rootWhereAsFilter":
|
|
586
585
|
case "rootFilter":
|