@contember/engine-content-api 2.1.0-rc.3 → 2.2.0-alpha.10
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/CLAUDE.md +12 -0
- package/dist/development/src/ExecutionContainer.cjs +7 -4
- package/dist/development/src/ExecutionContainer.cjs.map +1 -1
- package/dist/development/src/ExecutionContainer.js +7 -4
- package/dist/development/src/ExecutionContainer.js.map +1 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
- package/dist/development/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/development/src/acl/PermissionFactory.js.map +1 -1
- package/dist/development/src/acl/PredicateFactory.cjs.map +1 -1
- package/dist/development/src/acl/PredicateFactory.js.map +1 -1
- package/dist/development/src/acl/PredicatesInjector.cjs.map +1 -1
- package/dist/development/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js.map +1 -1
- package/dist/development/src/input-validation/EntityRulesResolver.cjs.map +1 -1
- package/dist/development/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/development/src/input-validation/JsonSchemaValidator.cjs +208 -0
- package/dist/development/src/input-validation/JsonSchemaValidator.cjs.map +1 -0
- package/dist/development/src/input-validation/JsonSchemaValidator.js +208 -0
- package/dist/development/src/input-validation/JsonSchemaValidator.js.map +1 -0
- package/dist/development/src/input-validation/QueryAstFactory.cjs.map +1 -1
- package/dist/development/src/input-validation/QueryAstFactory.js.map +1 -1
- package/dist/development/src/input-validation/ValidationContext.cjs.map +1 -1
- package/dist/development/src/input-validation/ValidationContext.js.map +1 -1
- package/dist/development/src/input-validation/ValidationDataSelector.cjs.map +1 -1
- package/dist/development/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/development/src/input-validation/ValidationEvaluation.cjs.map +1 -1
- package/dist/development/src/input-validation/ValidationEvaluation.js.map +1 -1
- package/dist/development/src/input-validation/dependencies/DependencyCollector.cjs.map +1 -1
- package/dist/development/src/input-validation/dependencies/DependencyCollector.js.map +1 -1
- package/dist/development/src/input-validation/dependencies/DependencyMerger.cjs.map +1 -1
- package/dist/development/src/input-validation/dependencies/DependencyMerger.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs +38 -2
- package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/InputPreValidator.js +38 -2
- package/dist/development/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/development/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
- package/dist/development/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/development/src/inputProcessing/ObjectNode.cjs.map +1 -1
- package/dist/development/src/inputProcessing/ObjectNode.js.map +1 -1
- package/dist/development/src/inputProcessing/UniqueWhereExpander.cjs.map +1 -1
- package/dist/development/src/inputProcessing/UniqueWhereExpander.js.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaDefinitionFactory.cjs.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaDefinitionFactory.js.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/development/src/mapper/EventManager.cjs.map +1 -1
- package/dist/development/src/mapper/EventManager.js.map +1 -1
- package/dist/development/src/mapper/JunctionTableManager.cjs.map +1 -1
- package/dist/development/src/mapper/JunctionTableManager.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +8 -5
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +8 -5
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/MapperFactory.cjs +7 -4
- package/dist/development/src/mapper/MapperFactory.cjs.map +1 -1
- package/dist/development/src/mapper/MapperFactory.js +7 -4
- package/dist/development/src/mapper/MapperFactory.js.map +1 -1
- package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
- package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
- package/dist/development/src/mapper/Result.cjs.map +1 -1
- package/dist/development/src/mapper/Result.js.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/development/src/mapper/delete/DeleteState.cjs.map +1 -1
- package/dist/development/src/mapper/delete/DeleteState.js.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/select/ConditionBuilder.cjs +10 -1
- package/dist/development/src/mapper/select/ConditionBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/ConditionBuilder.js +10 -1
- package/dist/development/src/mapper/select/ConditionBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/JoinBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/JoinBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/JoinVisitor.cjs.map +1 -1
- package/dist/development/src/mapper/select/JoinVisitor.js.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/OrderByHelper.cjs.map +1 -1
- package/dist/development/src/mapper/select/OrderByHelper.js.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.cjs +2 -2
- package/dist/development/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.js +2 -2
- package/dist/development/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/SelectHydrator.cjs +39 -19
- package/dist/development/src/mapper/select/SelectHydrator.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectHydrator.js +39 -19
- package/dist/development/src/mapper/select/SelectHydrator.js.map +1 -1
- package/dist/development/src/mapper/select/WhereBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs +9 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js +9 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitorFactory.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitorFactory.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.js.map +1 -1
- package/dist/development/src/mapper/select/optimizer/ConditionOptimizer.cjs.map +1 -1
- package/dist/development/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
- package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/development/src/mapper/update/Updater.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.cjs +49 -35
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +50 -36
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/development/src/resolvers/RefreshViewResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/RefreshViewResolver.js.map +1 -1
- package/dist/development/src/resolvers/ValidationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/ValidationResolver.js.map +1 -1
- package/dist/development/src/schema/ColumnTypeResolver.cjs +2 -0
- package/dist/development/src/schema/ColumnTypeResolver.cjs.map +1 -1
- package/dist/development/src/schema/ColumnTypeResolver.js +2 -0
- package/dist/development/src/schema/ColumnTypeResolver.js.map +1 -1
- package/dist/development/src/schema/ConditionTypeProvider.cjs +2 -0
- package/dist/development/src/schema/ConditionTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/ConditionTypeProvider.js +2 -0
- package/dist/development/src/schema/ConditionTypeProvider.js.map +1 -1
- package/dist/development/src/schema/CustomTypesProvider.cjs +32 -0
- package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
- package/dist/development/src/schema/CustomTypesProvider.js +32 -0
- package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/development/src/schema/EnumsProvider.cjs.map +1 -1
- package/dist/development/src/schema/EnumsProvider.js.map +1 -1
- package/dist/development/src/schema/FieldAccessVisitor.cjs.map +1 -1
- package/dist/development/src/schema/FieldAccessVisitor.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilder.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/development/src/schema/MutationProvider.js.map +1 -1
- package/dist/development/src/schema/OperationExtension.cjs.map +1 -1
- package/dist/development/src/schema/OperationExtension.js.map +1 -1
- package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/development/src/schema/PaginatedFieldConfigFactory.cjs.map +1 -1
- package/dist/development/src/schema/PaginatedFieldConfigFactory.js.map +1 -1
- package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/development/src/schema/QueryProvider.js.map +1 -1
- package/dist/development/src/schema/RefreshViewMutationProvider.cjs.map +1 -1
- package/dist/development/src/schema/RefreshViewMutationProvider.js.map +1 -1
- package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
- package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
- package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/development/src/schema/entities/FieldArgsVisitor.cjs.map +1 -1
- package/dist/development/src/schema/entities/FieldArgsVisitor.js.map +1 -1
- package/dist/development/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
- package/dist/development/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/ConnectOrCreateRelationInputProvider.cjs.map +1 -1
- package/dist/development/src/schema/mutations/ConnectOrCreateRelationInputProvider.js.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationInputProvider.cjs.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityRelationInputProvider.js.map +1 -1
- package/dist/development/src/schema/mutations/EntityInputProvider.cjs.map +1 -1
- package/dist/development/src/schema/mutations/EntityInputProvider.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputProvider.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputProvider.js.map +1 -1
- package/dist/development/src/schema/utils.cjs.map +1 -1
- package/dist/development/src/schema/utils.js.map +1 -1
- package/dist/development/src/utils/accessor.cjs.map +1 -1
- package/dist/development/src/utils/accessor.js.map +1 -1
- package/dist/development/src/utils/paginationUtils.cjs.map +1 -1
- package/dist/development/src/utils/paginationUtils.js.map +1 -1
- package/dist/development/src/utils/singletonFactory.cjs.map +1 -1
- package/dist/development/src/utils/singletonFactory.js.map +1 -1
- package/dist/production/src/ExecutionContainer.cjs +7 -4
- package/dist/production/src/ExecutionContainer.cjs.map +1 -1
- package/dist/production/src/ExecutionContainer.js +7 -4
- package/dist/production/src/ExecutionContainer.js.map +1 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
- package/dist/production/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/production/src/acl/PermissionFactory.js.map +1 -1
- package/dist/production/src/acl/PredicateFactory.cjs.map +1 -1
- package/dist/production/src/acl/PredicateFactory.js.map +1 -1
- package/dist/production/src/acl/PredicatesInjector.cjs.map +1 -1
- package/dist/production/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js.map +1 -1
- package/dist/production/src/input-validation/EntityRulesResolver.cjs.map +1 -1
- package/dist/production/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/production/src/input-validation/JsonSchemaValidator.cjs +208 -0
- package/dist/production/src/input-validation/JsonSchemaValidator.cjs.map +1 -0
- package/dist/production/src/input-validation/JsonSchemaValidator.js +208 -0
- package/dist/production/src/input-validation/JsonSchemaValidator.js.map +1 -0
- package/dist/production/src/input-validation/QueryAstFactory.cjs.map +1 -1
- package/dist/production/src/input-validation/QueryAstFactory.js.map +1 -1
- package/dist/production/src/input-validation/ValidationContext.cjs.map +1 -1
- package/dist/production/src/input-validation/ValidationContext.js.map +1 -1
- package/dist/production/src/input-validation/ValidationDataSelector.cjs.map +1 -1
- package/dist/production/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/production/src/input-validation/ValidationEvaluation.cjs.map +1 -1
- package/dist/production/src/input-validation/ValidationEvaluation.js.map +1 -1
- package/dist/production/src/input-validation/dependencies/DependencyCollector.cjs.map +1 -1
- package/dist/production/src/input-validation/dependencies/DependencyCollector.js.map +1 -1
- package/dist/production/src/input-validation/dependencies/DependencyMerger.cjs.map +1 -1
- package/dist/production/src/input-validation/dependencies/DependencyMerger.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs +38 -2
- package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/InputPreValidator.js +38 -2
- package/dist/production/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/production/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
- package/dist/production/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/production/src/inputProcessing/ObjectNode.cjs.map +1 -1
- package/dist/production/src/inputProcessing/ObjectNode.js.map +1 -1
- package/dist/production/src/inputProcessing/UniqueWhereExpander.cjs.map +1 -1
- package/dist/production/src/inputProcessing/UniqueWhereExpander.js.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaDefinitionFactory.cjs.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaDefinitionFactory.js.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/production/src/mapper/EventManager.cjs.map +1 -1
- package/dist/production/src/mapper/EventManager.js.map +1 -1
- package/dist/production/src/mapper/JunctionTableManager.cjs.map +1 -1
- package/dist/production/src/mapper/JunctionTableManager.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +8 -5
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +8 -5
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/MapperFactory.cjs +7 -4
- package/dist/production/src/mapper/MapperFactory.cjs.map +1 -1
- package/dist/production/src/mapper/MapperFactory.js +7 -4
- package/dist/production/src/mapper/MapperFactory.js.map +1 -1
- package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
- package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
- package/dist/production/src/mapper/Result.cjs.map +1 -1
- package/dist/production/src/mapper/Result.js.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/production/src/mapper/delete/DeleteState.cjs.map +1 -1
- package/dist/production/src/mapper/delete/DeleteState.js.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/select/ConditionBuilder.cjs +10 -1
- package/dist/production/src/mapper/select/ConditionBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/ConditionBuilder.js +10 -1
- package/dist/production/src/mapper/select/ConditionBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/JoinBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/JoinBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/JoinVisitor.cjs.map +1 -1
- package/dist/production/src/mapper/select/JoinVisitor.js.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/OrderByHelper.cjs.map +1 -1
- package/dist/production/src/mapper/select/OrderByHelper.js.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.cjs +2 -2
- package/dist/production/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.js +2 -2
- package/dist/production/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/SelectHydrator.cjs +39 -19
- package/dist/production/src/mapper/select/SelectHydrator.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectHydrator.js +39 -19
- package/dist/production/src/mapper/select/SelectHydrator.js.map +1 -1
- package/dist/production/src/mapper/select/WhereBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs +9 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js +9 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitorFactory.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitorFactory.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.js.map +1 -1
- package/dist/production/src/mapper/select/optimizer/ConditionOptimizer.cjs.map +1 -1
- package/dist/production/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
- package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/production/src/mapper/update/Updater.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.cjs +49 -35
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +50 -36
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/production/src/resolvers/RefreshViewResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/RefreshViewResolver.js.map +1 -1
- package/dist/production/src/resolvers/ValidationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/ValidationResolver.js.map +1 -1
- package/dist/production/src/schema/ColumnTypeResolver.cjs +2 -0
- package/dist/production/src/schema/ColumnTypeResolver.cjs.map +1 -1
- package/dist/production/src/schema/ColumnTypeResolver.js +2 -0
- package/dist/production/src/schema/ColumnTypeResolver.js.map +1 -1
- package/dist/production/src/schema/ConditionTypeProvider.cjs +2 -0
- package/dist/production/src/schema/ConditionTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/ConditionTypeProvider.js +2 -0
- package/dist/production/src/schema/ConditionTypeProvider.js.map +1 -1
- package/dist/production/src/schema/CustomTypesProvider.cjs +32 -0
- package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
- package/dist/production/src/schema/CustomTypesProvider.js +32 -0
- package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/production/src/schema/EnumsProvider.cjs.map +1 -1
- package/dist/production/src/schema/EnumsProvider.js.map +1 -1
- package/dist/production/src/schema/FieldAccessVisitor.cjs.map +1 -1
- package/dist/production/src/schema/FieldAccessVisitor.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilder.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/production/src/schema/MutationProvider.js.map +1 -1
- package/dist/production/src/schema/OperationExtension.cjs.map +1 -1
- package/dist/production/src/schema/OperationExtension.js.map +1 -1
- package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/production/src/schema/PaginatedFieldConfigFactory.cjs.map +1 -1
- package/dist/production/src/schema/PaginatedFieldConfigFactory.js.map +1 -1
- package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/production/src/schema/QueryProvider.js.map +1 -1
- package/dist/production/src/schema/RefreshViewMutationProvider.cjs.map +1 -1
- package/dist/production/src/schema/RefreshViewMutationProvider.js.map +1 -1
- package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
- package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
- package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/production/src/schema/entities/FieldArgsVisitor.cjs.map +1 -1
- package/dist/production/src/schema/entities/FieldArgsVisitor.js.map +1 -1
- package/dist/production/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
- package/dist/production/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/ConnectOrCreateRelationInputProvider.cjs.map +1 -1
- package/dist/production/src/schema/mutations/ConnectOrCreateRelationInputProvider.js.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationInputProvider.cjs.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityRelationInputProvider.js.map +1 -1
- package/dist/production/src/schema/mutations/EntityInputProvider.cjs.map +1 -1
- package/dist/production/src/schema/mutations/EntityInputProvider.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputProvider.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputProvider.js.map +1 -1
- package/dist/production/src/schema/utils.cjs.map +1 -1
- package/dist/production/src/schema/utils.js.map +1 -1
- package/dist/production/src/utils/accessor.cjs.map +1 -1
- package/dist/production/src/utils/accessor.js.map +1 -1
- package/dist/production/src/utils/paginationUtils.cjs.map +1 -1
- package/dist/production/src/utils/paginationUtils.js.map +1 -1
- package/dist/production/src/utils/singletonFactory.cjs.map +1 -1
- package/dist/production/src/utils/singletonFactory.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/numericColumn.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/numericColumn.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/numericFilter.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/numericFilter.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/similarQuery.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/similarQuery.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/formatting/numericFormat.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/formatting/numericFormat.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/formatting/numericList.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/formatting/numericList.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/validation/utils.d.ts +1 -1
- package/dist/tests/cases/integration/graphQlRequests/validation/utils.d.ts.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/model.d.ts +1 -1
- package/dist/tests/cases/unit/decimalType.test.d.ts +2 -0
- package/dist/tests/cases/unit/decimalType.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/jsonSchemaValidator.test.d.ts +2 -0
- package/dist/tests/cases/unit/jsonSchemaValidator.test.d.ts.map +1 -0
- package/dist/tests/src/assert.d.ts.map +1 -1
- package/dist/tests/src/tags.d.ts.map +1 -1
- package/dist/tests/src/test.d.ts +4 -1
- package/dist/tests/src/test.d.ts.map +1 -1
- package/dist/tests/src/testGraphql.d.ts.map +1 -1
- package/dist/tests/src/testUuid.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ExecutionContainer.d.ts +14 -13
- package/dist/types/ExecutionContainer.d.ts.map +1 -1
- package/dist/types/acl/Authorizator.d.ts.map +1 -1
- package/dist/types/acl/EvaluatedPredicateReplacer.d.ts.map +1 -1
- package/dist/types/acl/PermissionFactory.d.ts.map +1 -1
- package/dist/types/acl/PredicateFactory.d.ts +1 -1
- package/dist/types/acl/PredicateFactory.d.ts.map +1 -1
- package/dist/types/acl/PredicatesInjector.d.ts +1 -1
- package/dist/types/acl/PredicatesInjector.d.ts.map +1 -1
- package/dist/types/acl/VariableInjector.d.ts.map +1 -1
- package/dist/types/acl/VariableUtils.d.ts.map +1 -1
- package/dist/types/acl/index.d.ts +6 -6
- package/dist/types/acl/index.d.ts.map +1 -1
- package/dist/types/exception.d.ts.map +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.d.ts +2 -2
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.d.ts.map +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +3 -3
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts +3 -3
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/index.d.ts +3 -3
- package/dist/types/extensions/hasManyToHasOneReducer/index.d.ts.map +1 -1
- package/dist/types/extensions/index.d.ts +2 -2
- package/dist/types/extensions/index.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts +2 -2
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts +2 -2
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.d.ts +2 -2
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts +2 -2
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts +2 -2
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/input-validation/ColumnValueResolver.d.ts.map +1 -1
- package/dist/types/input-validation/EntityRulesResolver.d.ts.map +1 -1
- package/dist/types/input-validation/InputValidator.d.ts +1 -1
- package/dist/types/input-validation/InputValidator.d.ts.map +1 -1
- package/dist/types/input-validation/JsonSchemaValidator.d.ts +25 -0
- package/dist/types/input-validation/JsonSchemaValidator.d.ts.map +1 -0
- package/dist/types/input-validation/QueryAstFactory.d.ts +2 -2
- package/dist/types/input-validation/QueryAstFactory.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationContext.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationDataSelector.d.ts +4 -4
- package/dist/types/input-validation/ValidationDataSelector.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationEvaluation.d.ts +1 -1
- package/dist/types/input-validation/ValidationEvaluation.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationPath.d.ts.map +1 -1
- package/dist/types/input-validation/dependencies/DependencyCollector.d.ts.map +1 -1
- package/dist/types/input-validation/dependencies/DependencyMerger.d.ts +1 -1
- package/dist/types/input-validation/dependencies/DependencyMerger.d.ts.map +1 -1
- package/dist/types/input-validation/dependencies/index.d.ts +2 -2
- package/dist/types/input-validation/dependencies/index.d.ts.map +1 -1
- package/dist/types/input-validation/index.d.ts +12 -11
- package/dist/types/input-validation/index.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +5 -5
- package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/InputPreValidator.d.ts +11 -6
- package/dist/types/input-validation/preValidation/InputPreValidator.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +7 -7
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/index.d.ts +3 -3
- package/dist/types/input-validation/preValidation/index.d.ts.map +1 -1
- package/dist/types/inputProcessing/CreateInputProcessor.d.ts +2 -2
- package/dist/types/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/CreateInputVisitor.d.ts +2 -2
- package/dist/types/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
- package/dist/types/inputProcessing/FieldNode.d.ts.map +1 -1
- package/dist/types/inputProcessing/ObjectNode.d.ts +1 -1
- package/dist/types/inputProcessing/ObjectNode.d.ts.map +1 -1
- package/dist/types/inputProcessing/UniqueWhereExpander.d.ts +2 -2
- package/dist/types/inputProcessing/UniqueWhereExpander.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +2 -2
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -2
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
- package/dist/types/inputProcessing/index.d.ts +7 -7
- package/dist/types/inputProcessing/index.d.ts.map +1 -1
- package/dist/types/introspection/IntrospectionSchemaDefinitionFactory.d.ts +1 -1
- package/dist/types/introspection/IntrospectionSchemaDefinitionFactory.d.ts.map +1 -1
- package/dist/types/introspection/IntrospectionSchemaFactory.d.ts +3 -3
- package/dist/types/introspection/IntrospectionSchemaFactory.d.ts.map +1 -1
- package/dist/types/introspection/index.d.ts +4 -4
- package/dist/types/introspection/index.d.ts.map +1 -1
- package/dist/types/introspection/introspection.schema.d.ts.map +1 -1
- package/dist/types/mapper/CheckedPrimary.d.ts.map +1 -1
- package/dist/types/mapper/ColumnValue.d.ts.map +1 -1
- package/dist/types/mapper/Constraints.d.ts.map +1 -1
- package/dist/types/mapper/ErrorUtils.d.ts +1 -1
- package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
- package/dist/types/mapper/EventManager.d.ts +11 -11
- package/dist/types/mapper/EventManager.d.ts.map +1 -1
- package/dist/types/mapper/JunctionTableManager.d.ts +4 -4
- package/dist/types/mapper/JunctionTableManager.d.ts.map +1 -1
- package/dist/types/mapper/Mapper.d.ts +17 -14
- package/dist/types/mapper/Mapper.d.ts.map +1 -1
- package/dist/types/mapper/MapperFactory.d.ts +11 -10
- package/dist/types/mapper/MapperFactory.d.ts.map +1 -1
- package/dist/types/mapper/MutationProcessorHelper.d.ts +1 -1
- package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
- package/dist/types/mapper/Result.d.ts +1 -1
- package/dist/types/mapper/Result.d.ts.map +1 -1
- package/dist/types/mapper/delete/DeleteExecutor.d.ts +6 -6
- package/dist/types/mapper/delete/DeleteExecutor.d.ts.map +1 -1
- package/dist/types/mapper/delete/DeleteState.d.ts +2 -2
- package/dist/types/mapper/delete/DeleteState.d.ts.map +1 -1
- package/dist/types/mapper/delete/DeletedEntitiesStorage.d.ts.map +1 -1
- package/dist/types/mapper/delete/helpers.d.ts +1 -1
- package/dist/types/mapper/delete/helpers.d.ts.map +1 -1
- package/dist/types/mapper/delete/index.d.ts +2 -2
- package/dist/types/mapper/delete/index.d.ts.map +1 -1
- package/dist/types/mapper/index.d.ts +15 -15
- package/dist/types/mapper/index.d.ts.map +1 -1
- package/dist/types/mapper/insert/InsertBuilder.d.ts +4 -4
- package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
- package/dist/types/mapper/insert/InsertBuilderFactory.d.ts +3 -3
- package/dist/types/mapper/insert/InsertBuilderFactory.d.ts.map +1 -1
- package/dist/types/mapper/insert/Inserter.d.ts +5 -5
- package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
- package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts +4 -4
- package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/index.d.ts +4 -4
- package/dist/types/mapper/insert/index.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +7 -7
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts +9 -9
- package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts +8 -8
- package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts +8 -8
- package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts +7 -7
- package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/select/ConditionBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/JoinBuilder.d.ts +1 -1
- package/dist/types/mapper/select/JoinBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/JoinVisitor.d.ts +1 -1
- package/dist/types/mapper/select/JoinVisitor.d.ts.map +1 -1
- package/dist/types/mapper/select/OrderByBuilder.d.ts +2 -2
- package/dist/types/mapper/select/OrderByBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/OrderByHelper.d.ts +1 -1
- package/dist/types/mapper/select/OrderByHelper.d.ts.map +1 -1
- package/dist/types/mapper/select/Path.d.ts.map +1 -1
- package/dist/types/mapper/select/RelationFetcher.d.ts +7 -7
- package/dist/types/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectBuilder.d.ts +10 -10
- package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectBuilderFactory.d.ts +2 -2
- package/dist/types/mapper/select/SelectBuilderFactory.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectExecutionHandler.d.ts +4 -4
- package/dist/types/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectHydrator.d.ts +7 -1
- package/dist/types/mapper/select/SelectHydrator.d.ts.map +1 -1
- package/dist/types/mapper/select/WhereBuilder.d.ts +4 -4
- package/dist/types/mapper/select/WhereBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts +4 -4
- package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
- package/dist/types/mapper/select/handlers/FieldsVisitorFactory.d.ts +5 -5
- package/dist/types/mapper/select/handlers/FieldsVisitorFactory.d.ts.map +1 -1
- package/dist/types/mapper/select/handlers/MetaHandler.d.ts +3 -3
- package/dist/types/mapper/select/handlers/MetaHandler.d.ts.map +1 -1
- package/dist/types/mapper/select/handlers/index.d.ts +3 -3
- package/dist/types/mapper/select/handlers/index.d.ts.map +1 -1
- package/dist/types/mapper/select/index.d.ts +13 -13
- package/dist/types/mapper/select/index.d.ts.map +1 -1
- package/dist/types/mapper/select/optimizer/ConditionOptimizer.d.ts.map +1 -1
- package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts +1 -1
- package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -1
- package/dist/types/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -1
- package/dist/types/mapper/select/optimizer/helpers.d.ts +1 -1
- package/dist/types/mapper/select/optimizer/helpers.d.ts.map +1 -1
- package/dist/types/mapper/types.d.ts +1 -1
- package/dist/types/mapper/types.d.ts.map +1 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +5 -5
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/UpdateBuilder.d.ts +4 -4
- package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
- package/dist/types/mapper/update/UpdateBuilderFactory.d.ts +3 -3
- package/dist/types/mapper/update/UpdateBuilderFactory.d.ts.map +1 -1
- package/dist/types/mapper/update/Updater.d.ts +5 -5
- package/dist/types/mapper/update/Updater.d.ts.map +1 -1
- package/dist/types/mapper/update/index.d.ts +4 -4
- package/dist/types/mapper/update/index.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +12 -12
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts +12 -12
- package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +12 -12
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts +6 -6
- package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts +10 -10
- package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts +1 -1
- package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
- package/dist/types/resolvers/MutationResolver.d.ts +3 -3
- package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/ReadHelpers.d.ts +2 -2
- package/dist/types/resolvers/ReadHelpers.d.ts.map +1 -1
- package/dist/types/resolvers/ReadResolver.d.ts +4 -4
- package/dist/types/resolvers/ReadResolver.d.ts.map +1 -1
- package/dist/types/resolvers/RefreshViewResolver.d.ts +1 -1
- package/dist/types/resolvers/RefreshViewResolver.d.ts.map +1 -1
- package/dist/types/resolvers/ValidationResolver.d.ts +2 -2
- package/dist/types/resolvers/ValidationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/index.d.ts +4 -4
- package/dist/types/resolvers/index.d.ts.map +1 -1
- package/dist/types/schema/ColumnTypeResolver.d.ts +2 -2
- package/dist/types/schema/ColumnTypeResolver.d.ts.map +1 -1
- package/dist/types/schema/ConditionTypeProvider.d.ts +1 -1
- package/dist/types/schema/ConditionTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/CustomTypesProvider.d.ts +1 -0
- package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
- package/dist/types/schema/EntityTypeProvider.d.ts +5 -5
- package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/EnumsProvider.d.ts.map +1 -1
- package/dist/types/schema/FieldAccessVisitor.d.ts +1 -1
- package/dist/types/schema/FieldAccessVisitor.d.ts.map +1 -1
- package/dist/types/schema/GraphQlSchemaBuilder.d.ts +6 -6
- package/dist/types/schema/GraphQlSchemaBuilder.d.ts.map +1 -1
- package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts +30 -30
- package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts.map +1 -1
- package/dist/types/schema/MutationProvider.d.ts +6 -6
- package/dist/types/schema/MutationProvider.d.ts.map +1 -1
- package/dist/types/schema/OperationExtension.d.ts.map +1 -1
- package/dist/types/schema/OrderByTypeProvider.d.ts +1 -1
- package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/PaginatedFieldConfigFactory.d.ts +3 -3
- package/dist/types/schema/PaginatedFieldConfigFactory.d.ts.map +1 -1
- package/dist/types/schema/QueryProvider.d.ts +6 -6
- package/dist/types/schema/QueryProvider.d.ts.map +1 -1
- package/dist/types/schema/RefreshViewMutationProvider.d.ts +2 -2
- package/dist/types/schema/RefreshViewMutationProvider.d.ts.map +1 -1
- package/dist/types/schema/ValidationQueriesProvider.d.ts +4 -4
- package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
- package/dist/types/schema/WhereTypeProvider.d.ts +3 -3
- package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/entities/FieldArgsVisitor.d.ts +2 -2
- package/dist/types/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
- package/dist/types/schema/entities/FieldTypeVisitor.d.ts +3 -3
- package/dist/types/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
- package/dist/types/schema/entities/index.d.ts +2 -2
- package/dist/types/schema/entities/index.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +18 -18
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/mutations/ConnectOrCreateRelationInputProvider.d.ts +3 -3
- package/dist/types/schema/mutations/ConnectOrCreateRelationInputProvider.d.ts.map +1 -1
- package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts +3 -3
- package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts +1 -1
- package/dist/types/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts +5 -5
- package/dist/types/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/CreateEntityRelationInputProvider.d.ts +1 -1
- package/dist/types/schema/mutations/CreateEntityRelationInputProvider.d.ts.map +1 -1
- package/dist/types/schema/mutations/EntityInputProvider.d.ts +1 -1
- package/dist/types/schema/mutations/EntityInputProvider.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +4 -4
- package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +6 -6
- package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationInputProvider.d.ts +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationInputProvider.d.ts.map +1 -1
- package/dist/types/schema/mutations/index.d.ts +9 -9
- package/dist/types/schema/mutations/index.d.ts.map +1 -1
- package/dist/types/schema/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Mutex.d.ts.map +1 -1
- package/dist/types/utils/ResolveInfoUtils.d.ts.map +1 -1
- package/dist/types/utils/accessor.d.ts +1 -1
- package/dist/types/utils/accessor.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +13 -13
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/isIt.d.ts.map +1 -1
- package/dist/types/utils/paginationUtils.d.ts +1 -1
- package/dist/types/utils/paginationUtils.d.ts.map +1 -1
- package/dist/types/utils/promises.d.ts.map +1 -1
- package/dist/types/utils/singletonFactory.d.ts.map +1 -1
- package/dist/types/utils/strings.d.ts.map +1 -1
- package/dist/types/utils/tuple.d.ts.map +1 -1
- package/dist/types/utils/uniqueWhereFields.d.ts.map +1 -1
- package/dist/types/utils/viewComputedId.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/ExecutionContainer.ts +27 -14
- package/src/acl/EvaluatedPredicateReplacer.ts +1 -1
- package/src/acl/PermissionFactory.ts +2 -2
- package/src/acl/PredicateFactory.ts +2 -2
- package/src/acl/PredicatesInjector.ts +1 -1
- package/src/acl/index.ts +6 -6
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.ts +2 -2
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +5 -5
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +4 -4
- package/src/extensions/hasManyToHasOneReducer/index.ts +3 -3
- package/src/extensions/index.ts +2 -2
- package/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts +2 -2
- package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +5 -5
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.ts +2 -2
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +4 -4
- package/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.ts +2 -2
- package/src/index.ts +11 -11
- package/src/input-validation/EntityRulesResolver.ts +3 -3
- package/src/input-validation/InputValidator.ts +1 -1
- package/src/input-validation/JsonSchemaValidator.ts +257 -0
- package/src/input-validation/QueryAstFactory.ts +2 -2
- package/src/input-validation/ValidationContext.ts +1 -1
- package/src/input-validation/ValidationDataSelector.ts +3 -3
- package/src/input-validation/ValidationEvaluation.ts +1 -1
- package/src/input-validation/dependencies/DependencyCollector.ts +1 -1
- package/src/input-validation/dependencies/DependencyMerger.ts +2 -2
- package/src/input-validation/dependencies/index.ts +2 -2
- package/src/input-validation/index.ts +12 -11
- package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +4 -4
- package/src/input-validation/preValidation/InputPreValidator.ts +60 -17
- package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +4 -4
- package/src/input-validation/preValidation/index.ts +3 -3
- package/src/inputProcessing/CreateInputProcessor.ts +2 -2
- package/src/inputProcessing/CreateInputVisitor.ts +4 -4
- package/src/inputProcessing/ObjectNode.ts +1 -1
- package/src/inputProcessing/UniqueWhereExpander.ts +3 -3
- package/src/inputProcessing/UpdateInputProcessor.ts +2 -2
- package/src/inputProcessing/UpdateInputVisitor.ts +4 -4
- package/src/inputProcessing/index.ts +7 -7
- package/src/introspection/IntrospectionSchemaDefinitionFactory.ts +3 -3
- package/src/introspection/IntrospectionSchemaFactory.ts +4 -4
- package/src/introspection/index.ts +4 -4
- package/src/mapper/ErrorUtils.ts +2 -2
- package/src/mapper/EventManager.ts +2 -2
- package/src/mapper/JunctionTableManager.ts +6 -6
- package/src/mapper/Mapper.ts +23 -19
- package/src/mapper/MapperFactory.ts +15 -11
- package/src/mapper/MutationProcessorHelper.ts +1 -1
- package/src/mapper/Result.ts +1 -1
- package/src/mapper/delete/DeleteExecutor.ts +11 -11
- package/src/mapper/delete/DeleteState.ts +3 -3
- package/src/mapper/delete/index.ts +2 -2
- package/src/mapper/index.ts +15 -15
- package/src/mapper/insert/InsertBuilder.ts +5 -5
- package/src/mapper/insert/InsertBuilderFactory.ts +3 -3
- package/src/mapper/insert/Inserter.ts +8 -8
- package/src/mapper/insert/SqlCreateInputProcessor.ts +10 -10
- package/src/mapper/insert/index.ts +4 -4
- package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +6 -6
- package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +7 -7
- package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +5 -5
- package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +6 -6
- package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +7 -7
- package/src/mapper/select/ConditionBuilder.ts +15 -2
- package/src/mapper/select/JoinBuilder.ts +2 -2
- package/src/mapper/select/JoinVisitor.ts +1 -1
- package/src/mapper/select/OrderByBuilder.ts +3 -3
- package/src/mapper/select/OrderByHelper.ts +1 -1
- package/src/mapper/select/RelationFetcher.ts +11 -13
- package/src/mapper/select/SelectBuilder.ts +11 -11
- package/src/mapper/select/SelectBuilderFactory.ts +2 -2
- package/src/mapper/select/SelectExecutionHandler.ts +4 -4
- package/src/mapper/select/SelectHydrator.ts +45 -18
- package/src/mapper/select/WhereBuilder.ts +5 -5
- package/src/mapper/select/handlers/FieldsVisitor.ts +22 -7
- package/src/mapper/select/handlers/FieldsVisitorFactory.ts +5 -5
- package/src/mapper/select/handlers/MetaHandler.ts +5 -5
- package/src/mapper/select/handlers/index.ts +3 -3
- package/src/mapper/select/index.ts +13 -13
- package/src/mapper/select/optimizer/ConditionOptimizer.ts +1 -1
- package/src/mapper/select/optimizer/WhereOptimizer.ts +3 -3
- package/src/mapper/types.ts +1 -1
- package/src/mapper/update/SqlUpdateInputProcessor.ts +11 -11
- package/src/mapper/update/UpdateBuilder.ts +6 -6
- package/src/mapper/update/UpdateBuilderFactory.ts +3 -3
- package/src/mapper/update/Updater.ts +8 -8
- package/src/mapper/update/index.ts +4 -4
- package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +6 -6
- package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +7 -7
- package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +6 -6
- package/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts +6 -6
- package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +7 -7
- package/src/resolvers/GraphQlQueryAstFactory.ts +2 -2
- package/src/resolvers/MutationResolver.ts +68 -45
- package/src/resolvers/ReadHelpers.ts +5 -5
- package/src/resolvers/ReadResolver.ts +4 -4
- package/src/resolvers/RefreshViewResolver.ts +1 -1
- package/src/resolvers/ValidationResolver.ts +3 -3
- package/src/resolvers/index.ts +4 -4
- package/src/schema/ColumnTypeResolver.ts +6 -4
- package/src/schema/ConditionTypeProvider.ts +7 -4
- package/src/schema/CustomTypesProvider.ts +37 -0
- package/src/schema/EntityTypeProvider.ts +10 -10
- package/src/schema/EnumsProvider.ts +1 -1
- package/src/schema/FieldAccessVisitor.ts +1 -1
- package/src/schema/GraphQlSchemaBuilder.ts +6 -6
- package/src/schema/GraphQlSchemaBuilderFactory.ts +30 -30
- package/src/schema/MutationProvider.ts +9 -9
- package/src/schema/OperationExtension.ts +1 -1
- package/src/schema/OrderByTypeProvider.ts +4 -4
- package/src/schema/PaginatedFieldConfigFactory.ts +3 -3
- package/src/schema/QueryProvider.ts +8 -8
- package/src/schema/RefreshViewMutationProvider.ts +2 -2
- package/src/schema/ValidationQueriesProvider.ts +5 -5
- package/src/schema/WhereTypeProvider.ts +7 -7
- package/src/schema/entities/FieldArgsVisitor.ts +2 -2
- package/src/schema/entities/FieldTypeVisitor.ts +4 -4
- package/src/schema/entities/index.ts +2 -2
- package/src/schema/index.ts +18 -18
- package/src/schema/mutations/ConnectOrCreateRelationInputProvider.ts +5 -5
- package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +3 -3
- package/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.ts +2 -2
- package/src/schema/mutations/CreateEntityRelationInputFieldVisitor.ts +7 -7
- package/src/schema/mutations/CreateEntityRelationInputProvider.ts +2 -2
- package/src/schema/mutations/EntityInputProvider.ts +4 -4
- package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +3 -3
- package/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.ts +1 -1
- package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +8 -8
- package/src/schema/mutations/UpdateEntityRelationInputProvider.ts +2 -2
- package/src/schema/mutations/index.ts +9 -9
- package/src/schema/utils.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/accessor.ts +2 -2
- package/src/utils/index.ts +13 -13
- package/src/utils/paginationUtils.ts +1 -1
- package/src/utils/singletonFactory.ts +1 -1
- package/tests/cases/bugs/bug-filter-or.test.ts +3 -3
- package/tests/cases/bugs/bug-update-by-nested-unique.test.ts +3 -3
- package/tests/cases/bugs/bug102.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/aclDelete.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/additionalDeleteFilter.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/cascadeDelete.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/orphanRemoval.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/restrictOnDelete.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/setNullOnDelete.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/acl/setField.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/aclInsert.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/basicInsert.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/insertCustomId.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/manyHasManyInverse/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/manyHasManyOwning/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/manyHasOne/connectOrCreate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/manyHasOne/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.ts +97 -0
- package/tests/cases/integration/graphQlRequests/insert/numericColumn.test.ts +110 -0
- package/tests/cases/integration/graphQlRequests/insert/oneHasMany/connect.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/oneHasMany/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/oneHasOneInverse/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/oneHasOneOwning/create.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/oneHasOneOwning/empty.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/subOperationFail.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/validation/toBeFixed.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/acl/orPredicate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/acl/sameRowAndFieldPredicate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/complexCondition.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/containsQuery.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/manyHasManyOwnerRelation.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/manyHasOneRelation.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/numericFilter.test.ts +92 -0
- package/tests/cases/integration/graphQlRequests/query/filter/oneHasManyRelation.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/filter/similarQuery.test.ts +72 -0
- package/tests/cases/integration/graphQlRequests/query/formatting/dateFormat.test.ts +135 -4
- package/tests/cases/integration/graphQlRequests/query/formatting/numericFormat.test.ts +68 -0
- package/tests/cases/integration/graphQlRequests/query/formatting/numericList.test.ts +41 -0
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/misc/aliasedType.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/misc/longAliasHash.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/misc/transaction.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +51 -5
- package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/pagination/simpleLimit.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/byRelations.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/sorting/sortNulls.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/unique/basicQueryById.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/unique/composedUnique.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/unique/oneHasManyUnique.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/unique/uniqueWithFilter.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/additionalFilter.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/basic/columnUpdate.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/connectOrCreate.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/combination.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/connectOrCreate.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connectOrCreate.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/create.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/delete.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/disconnect.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/update/queryPortal.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/transaction.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/update/validation/toBeFixed.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/validation/conditions.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/nestedValidation.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/validation/optionalAssert.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/validation/required.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/validation/requiredWhen.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/validation/rules/andRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/lengthRangeRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/maxLengthRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/minLength.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/notEmptyRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/notRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/orRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/patternRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/rules/rangeRule.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/validation/utils.ts +2 -2
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +2 -2
- package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-predicate.gql +2 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-predicate2.gql +2 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-acl.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-array.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-basic.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-column-types.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +3 -0
- package/tests/cases/integration/graphQlSchema/schema-read-only.gql +2 -0
- package/tests/cases/integration/graphQlSchema/schema-view-entity.gql +2 -0
- package/tests/cases/unit/aclVariablesFactory.test.ts +2 -2
- package/tests/cases/unit/conditionOptimizer.test.ts +1 -1
- package/tests/cases/unit/decimalType.test.ts +65 -0
- package/tests/cases/unit/inputPreValidator.test.ts +101 -6
- package/tests/cases/unit/inputValidation.test.ts +3 -3
- package/tests/cases/unit/jsonSchemaValidator.test.ts +115 -0
- package/tests/cases/unit/orderbyHelper.test.ts +3 -3
- package/tests/cases/unit/permissionMerger.test.ts +2 -2
- package/tests/cases/unit/predicatesFactory.test.ts +2 -2
- package/tests/cases/unit/predicatesInjector.test.ts +5 -5
- package/tests/cases/unit/uuidType.test.ts +1 -1
- package/tests/cases/unit/variableInjector.test.ts +2 -2
- package/tests/cases/unit/whereBuilder.test.ts +4 -4
- package/tests/cases/unit/whereOptimizer.test.ts +3 -3
- package/tests/src/test.ts +9 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionFactory.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PermissionFactory.ts"],"sourcesContent":["import { Acl, Model, Schema, Writable } from '@contember/schema'\nimport { getEntity, PredicateDefinitionProcessor } from '@contember/schema-utils'\nimport { mapObject } from '../utils'\nimport { prefixVariable } from './VariableUtils'\n\nexport interface Identity {\n\tprojectRoles: readonly string[]\n}\n\nexport interface ContextualPermissions {\n\troot: Acl.Permissions\n\tall: Acl.Permissions\n}\n\nexport class PermissionFactory {\n\tpublic create(schema: Schema, roles: readonly string[], prefix?: string): Acl.Permissions {\n\t\treturn this.createInternal(schema, roles, false, prefix)\n\t}\n\n\tpublic createContextual(schema: Schema, roles: readonly string[]): ContextualPermissions {\n\t\treturn {\n\t\t\troot: this.createInternal(schema, roles, false),\n\t\t\tall: this.createInternal(schema, roles, true),\n\t\t}\n\t}\n\n\tprivate createInternal(schema: Schema, roles: readonly string[], includeThrough: boolean, prefix?: string): Acl.Permissions {\n\t\tlet result: Acl.Permissions = {}\n\t\tfor (let role of roles) {\n\t\t\tconst roleDefinition = schema.acl.roles[role] || { entities: {} }\n\t\t\tlet rolePermissions: Acl.Permissions = this.prefixPredicatesWithRole(schema.model, roleDefinition.entities, prefix || role)\n\t\t\tif (roleDefinition.inherits) {\n\t\t\t\tconst inheritedPermissions = this.createInternal(schema, roleDefinition.inherits, includeThrough, prefix || role)\n\t\t\t\trolePermissions = this.mergePermissions(inheritedPermissions, rolePermissions, includeThrough)\n\t\t\t}\n\t\t\tresult = this.mergePermissions(result, rolePermissions, includeThrough)\n\t\t}\n\t\tresult = this.makePrimaryPredicatesUnionOfAllFields(schema.model, result)\n\n\t\treturn result\n\t}\n\n\tprivate prefixPredicatesWithRole(model: Model.Schema, permissions: Acl.Permissions, role: string): Acl.Permissions {\n\t\treturn mapObject(permissions, ({ operations, predicates }, entityName) => ({\n\t\t\toperations,\n\t\t\tpredicates: mapObject(predicates, predicate => {\n\t\t\t\tconst predicateDefinitionProcessor = new PredicateDefinitionProcessor(model)\n\t\t\t\treturn predicateDefinitionProcessor.process(getEntity(model, entityName), predicate, {\n\t\t\t\t\thandleColumn: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t\thandleRelation: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}),\n\t\t}))\n\t}\n\n\tprivate makePrimaryPredicatesUnionOfAllFields(model: Model.Schema, permissions: Acl.Permissions): Acl.Permissions {\n\t\treturn mapObject(permissions, (permission, entityName): Acl.EntityPermissions => {\n\t\t\tconst entity = getEntity(model, entityName)\n\t\t\tconst entityPredicates: Writable<Acl.PredicateMap> = { ...permission.predicates }\n\t\t\tconst entityOperations: Writable<Acl.EntityOperations> = { ...permission.operations }\n\n\t\t\tconst operationNames = ['read', 'create', 'update'] as const\n\t\t\tfor (let operation of operationNames) {\n\t\t\t\tif (!entityOperations[operation]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst fieldPermissions: Writable<Acl.FieldPermissions> = { ...entityOperations[operation] }\n\t\t\t\tentityOperations[operation] = fieldPermissions\n\n\t\t\t\tif (Object.values(fieldPermissions).some(it => it === true)) {\n\t\t\t\t\tfieldPermissions[entity.primary] = true\n\t\t\t\t}\n\t\t\t\tif (fieldPermissions[entity.primary] === true) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst predicateReferences: string[] = Object.entries(fieldPermissions)\n\t\t\t\t\t.filter(([key]) => key !== entity.primary)\n\t\t\t\t\t.map(([key, value]) => value)\n\t\t\t\t\t.filter(value => value !== false)\n\t\t\t\t\t.filter((value, index, array): value is string => array.indexOf(value) === index)\n\n\t\t\t\tlet idPermissions: Acl.Predicate = fieldPermissions[entity.primary] || false\n\n\t\t\t\tfor (let predicateReference of predicateReferences) {\n\t\t\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tidPermissions,\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tpredicateReference,\n\t\t\t\t\t)\n\t\t\t\t\tif (typeof predicate !== 'string' || predicateDefinition === undefined) {\n\t\t\t\t\t\tthrow new Error('should not happen')\n\t\t\t\t\t}\n\t\t\t\t\tidPermissions = predicate\n\t\t\t\t\tentityPredicates[predicate] = predicateDefinition\n\t\t\t\t}\n\t\t\t\tfieldPermissions[entity.primary] = idPermissions\n\t\t\t\tentityPredicates[idPermissions as Acl.PredicateReference] = entityPredicates[idPermissions as Acl.PredicateReference]\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toperations: entityOperations,\n\t\t\t\tpredicates: entityPredicates,\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate mergePermissions(left: Acl.Permissions, right: Acl.Permissions, includeThrough = false): Acl.Permissions {\n\t\tconst result = { ...left }\n\t\tfor (let entityName in right) {\n\t\t\tif (result[entityName] !== undefined) {\n\t\t\t\tresult[entityName] = this.mergeEntityPermissions(result[entityName], right[entityName], includeThrough)\n\t\t\t} else {\n\t\t\t\tresult[entityName] = right[entityName]\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate mergeEntityPermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): Acl.EntityPermissions {\n\t\tlet predicates: Writable<Acl.PredicateMap> = {}\n\t\tconst operations: Writable<Acl.EntityOperations> = {}\n\t\tif (left.operations.customPrimary || right.operations.customPrimary) {\n\t\t\toperations.customPrimary = true\n\t\t}\n\t\tconst noRoot: `${Acl.Operation}`[] = []\n\n\t\tfor (\n\t\t\tlet operation of [\n\t\t\t\t'create',\n\t\t\t\t'read',\n\t\t\t\t'update',\n\t\t\t] as const\n\t\t) {\n\t\t\tconst { predicates: opPredicates, permissions: fieldPermissions, noRoot: opNoRoot } = this.mergeOperationPermissions(\n\t\t\t\tleft,\n\t\t\t\tright,\n\t\t\t\toperation,\n\t\t\t\tincludeThrough,\n\t\t\t)\n\n\t\t\tif (opNoRoot) {\n\t\t\t\tnoRoot.push(operation)\n\t\t\t}\n\n\t\t\tpredicates = { ...predicates, ...opPredicates }\n\t\t\tif (Object.keys(fieldPermissions).length > 0) {\n\t\t\t\toperations[operation] = fieldPermissions\n\t\t\t}\n\t\t}\n\n\t\tconst { predicateDefinition, predicate, noRoot: opNoRoot } = this.mergeDeletePermissions(left, right, includeThrough)\n\t\tif (opNoRoot) {\n\t\t\tnoRoot.push('delete')\n\t\t}\n\t\tif (predicate === true) {\n\t\t\toperations.delete = true\n\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\toperations.delete = predicate\n\t\t}\n\n\t\tif (noRoot.length > 0) {\n\t\t\toperations.noRoot = noRoot\n\t\t}\n\n\t\treturn {\n\t\t\tpredicates: predicates,\n\t\t\toperations: operations,\n\t\t}\n\t}\n\n\tprivate mergeOperationPermissions(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: 'create' | 'read' | 'update',\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tpredicates: Acl.PredicateMap\n\t\tpermissions: Acl.FieldPermissions\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, operation, includeThrough)\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergeFieldPermissions(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate mergeDeletePermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): {\n\t\tnoRoot: boolean\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, 'delete', includeThrough)\n\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergePredicates(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate resolveNoRoot<const Op extends `${Acl.Operation}`>(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: Op,\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tleftPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t\trightPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t} {\n\t\tconst leftRootForbidden = left.operations.noRoot?.includes(operation) || false\n\t\tconst rightRootForbidden = right.operations.noRoot?.includes(operation) || false\n\t\tconst leftPermissions = left.operations[operation]\n\t\tconst rightPermissions = right.operations[operation]\n\n\t\tconst rootForbidden = (leftRootForbidden && rightRootForbidden)\n\t\t\t|| (leftRootForbidden && !rightPermissions)\n\t\t\t|| (rightRootForbidden && !leftPermissions)\n\n\t\t// When includeThrough is true, keep all permissions regardless of noRoot\n\t\t// (used for \"all\" permissions that apply when accessing through relations)\n\t\tconst resolvedLeftPermissions = !includeThrough && !rootForbidden && leftRootForbidden ? undefined : leftPermissions\n\t\tconst resolvedRightPermissions = !includeThrough && !rootForbidden && rightRootForbidden ? undefined : rightPermissions\n\n\t\treturn {\n\t\t\tnoRoot: rootForbidden,\n\t\t\tleftPermissions: resolvedLeftPermissions,\n\t\t\trightPermissions: resolvedRightPermissions,\n\t\t}\n\t}\n\n\tprivate mergeFieldPermissions(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t): { predicates: Acl.PredicateMap; permissions: Acl.FieldPermissions } {\n\t\tconst permissions: Writable<Acl.FieldPermissions> = {}\n\t\tconst predicates: Writable<Acl.PredicateMap> = {}\n\n\t\tfor (let field in { ...leftFieldPermissions, ...rightFieldPermissions }) {\n\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\tleftPredicates,\n\t\t\t\tleftFieldPermissions[field] || false,\n\t\t\t\trightPredicates,\n\t\t\t\trightFieldPermissions[field] || false,\n\t\t\t)\n\t\t\tif (predicate === true) {\n\t\t\t\tpermissions[field] = true\n\t\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\t\tpermissions[field] = predicate\n\t\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\t}\n\t\t}\n\n\t\treturn { predicates, permissions }\n\t}\n\n\tprivate mergePredicates(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftReference: Acl.Predicate | undefined = false,\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightReference: Acl.Predicate | undefined = false,\n\t): {\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tif (leftReference === true || rightReference === true) {\n\t\t\treturn {\n\t\t\t\tpredicate: true,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\n\t\tif (leftReference !== false && rightReference !== false) {\n\t\t\tconst leftPredicate: Acl.PredicateDefinition = leftPredicates[leftReference]\n\t\t\tconst rightPredicate: Acl.PredicateDefinition = rightPredicates[rightReference]\n\t\t\tif (leftPredicate === rightPredicate) {\n\t\t\t\treturn {\n\t\t\t\t\tpredicate: leftReference,\n\t\t\t\t\tpredicateDefinition: leftPredicate,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet predicateName = '__merge__' + leftReference + '__' + rightReference\n\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\tpredicateName += '_'\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: {\n\t\t\t\t\tor: [leftPredicate, rightPredicate],\n\t\t\t\t} as Acl.PredicateDefinition,\n\t\t\t}\n\t\t} else if (leftReference !== false) {\n\t\t\treturn {\n\t\t\t\tpredicate: leftReference,\n\t\t\t\tpredicateDefinition: leftPredicates[leftReference],\n\t\t\t}\n\t\t} else if (rightReference !== false) {\n\t\t\tlet predicateName = rightReference\n\t\t\tif (rightPredicates !== leftPredicates) {\n\t\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\t\tpredicateName += '_'\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: rightPredicates[rightReference],\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpredicate: false,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["mapObject","PredicateDefinitionProcessor","getEntity","prefixVariable","opNoRoot"],"mappings":";;;;;AAcO,MAAM,kBAAkB;AAAA,EACvB,OAAO,QAAgB,OAA0B,QAAkC;AACzF,WAAO,KAAK,eAAe,QAAQ,OAAO,OAAO,MAAM;AAAA,EACxD;AAAA,EAEO,iBAAiB,QAAgB,OAAiD;AACxF,WAAO;AAAA,MACN,MAAM,KAAK,eAAe,QAAQ,OAAO,KAAK;AAAA,MAC9C,KAAK,KAAK,eAAe,QAAQ,OAAO,IAAI;AAAA,IAAA;AAAA,EAE9C;AAAA,EAEQ,eAAe,QAAgB,OAA0B,gBAAyB,QAAkC;AAC3H,QAAI,SAA0B,CAAA;AAC9B,aAAS,QAAQ,OAAO;AACvB,YAAM,iBAAiB,OAAO,IAAI,MAAM,IAAI,KAAK,EAAE,UAAU,GAAC;AAC9D,UAAI,kBAAmC,KAAK,yBAAyB,OAAO,OAAO,eAAe,UAAU,UAAU,IAAI;AAC1H,UAAI,eAAe,UAAU;AAC5B,cAAM,uBAAuB,KAAK,eAAe,QAAQ,eAAe,UAAU,gBAAgB,UAAU,IAAI;AAChH,0BAAkB,KAAK,iBAAiB,sBAAsB,iBAAiB,cAAc;AAAA,MAC9F;AACA,eAAS,KAAK,iBAAiB,QAAQ,iBAAiB,cAAc;AAAA,IACvE;AACA,aAAS,KAAK,sCAAsC,OAAO,OAAO,MAAM;AAExE,WAAO;AAAA,EACR;AAAA,EAEQ,yBAAyB,OAAqB,aAA8B,MAA+B;AAClH,WAAOA,OAAAA,UAAU,aAAa,CAAC,EAAE,YAAY,WAAA,GAAc,gBAAgB;AAAA,MAC1E;AAAA,MACA,YAAYA,OAAAA,UAAU,YAAY,CAAA,cAAa;AAC9C,cA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AEA,QAAI,kBAAkB,SAAS,mBAAmB,OAAO;AACxD,YAAM,gBAAyC,eAAe,aAAa;AAC3E,YAAM,iBAA0C,gBAAgB,cAAc;AAC9E,UAAI,kBAAkB,gBAAgB;AACrC,eAAO;AAAA,UACN,WAAW;AAAA,UACX,qBAAqB;AAAA,QAAA;AAAA,MAEvB;AAEA,UAAI,gBAAgB,cAAc,gBAAgB,OAAO;AACzD,aAAO,eAAe,aAAa,GAAG;AACrC,yBAAiB;AAAA,MAClB;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,UACpB,IAAI,CAAC,eAAe,cAAc;AAAA,QAAA;AAAA,MACnC;AAAA,IAEF,WAAW,kBAAkB,OAAO;AACnC,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,eAAe,aAAa;AAAA,MAAA;AAAA,IAEnD,WAAW,mBAAmB,OAAO;AACpC,UAAI,gBAAgB;AACpB,UAAI,oBAAoB,gBAAgB;AACvC,eAAO,eAAe,aAAa,GAAG;AACrC,2BAAiB;AAAA,QAClB;AAAA,MACD;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,gBAAgB,cAAc;AAAA,MAAA;AAAA,IAErD,OAAO;AACN,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAAA,EACD;AACD;;"}
|
|
1
|
+
{"version":3,"file":"PermissionFactory.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PermissionFactory.ts"],"sourcesContent":["import { Acl, Model, Schema, Writable } from '@contember/schema'\nimport { getEntity, PredicateDefinitionProcessor } from '@contember/schema-utils'\nimport { mapObject } from '../utils/index.js'\nimport { prefixVariable } from './VariableUtils.js'\n\nexport interface Identity {\n\tprojectRoles: readonly string[]\n}\n\nexport interface ContextualPermissions {\n\troot: Acl.Permissions\n\tall: Acl.Permissions\n}\n\nexport class PermissionFactory {\n\tpublic create(schema: Schema, roles: readonly string[], prefix?: string): Acl.Permissions {\n\t\treturn this.createInternal(schema, roles, false, prefix)\n\t}\n\n\tpublic createContextual(schema: Schema, roles: readonly string[]): ContextualPermissions {\n\t\treturn {\n\t\t\troot: this.createInternal(schema, roles, false),\n\t\t\tall: this.createInternal(schema, roles, true),\n\t\t}\n\t}\n\n\tprivate createInternal(schema: Schema, roles: readonly string[], includeThrough: boolean, prefix?: string): Acl.Permissions {\n\t\tlet result: Acl.Permissions = {}\n\t\tfor (let role of roles) {\n\t\t\tconst roleDefinition = schema.acl.roles[role] || { entities: {} }\n\t\t\tlet rolePermissions: Acl.Permissions = this.prefixPredicatesWithRole(schema.model, roleDefinition.entities, prefix || role)\n\t\t\tif (roleDefinition.inherits) {\n\t\t\t\tconst inheritedPermissions = this.createInternal(schema, roleDefinition.inherits, includeThrough, prefix || role)\n\t\t\t\trolePermissions = this.mergePermissions(inheritedPermissions, rolePermissions, includeThrough)\n\t\t\t}\n\t\t\tresult = this.mergePermissions(result, rolePermissions, includeThrough)\n\t\t}\n\t\tresult = this.makePrimaryPredicatesUnionOfAllFields(schema.model, result)\n\n\t\treturn result\n\t}\n\n\tprivate prefixPredicatesWithRole(model: Model.Schema, permissions: Acl.Permissions, role: string): Acl.Permissions {\n\t\treturn mapObject(permissions, ({ operations, predicates }, entityName) => ({\n\t\t\toperations,\n\t\t\tpredicates: mapObject(predicates, predicate => {\n\t\t\t\tconst predicateDefinitionProcessor = new PredicateDefinitionProcessor(model)\n\t\t\t\treturn predicateDefinitionProcessor.process(getEntity(model, entityName), predicate, {\n\t\t\t\t\thandleColumn: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t\thandleRelation: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}),\n\t\t}))\n\t}\n\n\tprivate makePrimaryPredicatesUnionOfAllFields(model: Model.Schema, permissions: Acl.Permissions): Acl.Permissions {\n\t\treturn mapObject(permissions, (permission, entityName): Acl.EntityPermissions => {\n\t\t\tconst entity = getEntity(model, entityName)\n\t\t\tconst entityPredicates: Writable<Acl.PredicateMap> = { ...permission.predicates }\n\t\t\tconst entityOperations: Writable<Acl.EntityOperations> = { ...permission.operations }\n\n\t\t\tconst operationNames = ['read', 'create', 'update'] as const\n\t\t\tfor (let operation of operationNames) {\n\t\t\t\tif (!entityOperations[operation]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst fieldPermissions: Writable<Acl.FieldPermissions> = { ...entityOperations[operation] }\n\t\t\t\tentityOperations[operation] = fieldPermissions\n\n\t\t\t\tif (Object.values(fieldPermissions).some(it => it === true)) {\n\t\t\t\t\tfieldPermissions[entity.primary] = true\n\t\t\t\t}\n\t\t\t\tif (fieldPermissions[entity.primary] === true) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst predicateReferences: string[] = Object.entries(fieldPermissions)\n\t\t\t\t\t.filter(([key]) => key !== entity.primary)\n\t\t\t\t\t.map(([key, value]) => value)\n\t\t\t\t\t.filter(value => value !== false)\n\t\t\t\t\t.filter((value, index, array): value is string => array.indexOf(value) === index)\n\n\t\t\t\tlet idPermissions: Acl.Predicate = fieldPermissions[entity.primary] || false\n\n\t\t\t\tfor (let predicateReference of predicateReferences) {\n\t\t\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tidPermissions,\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tpredicateReference,\n\t\t\t\t\t)\n\t\t\t\t\tif (typeof predicate !== 'string' || predicateDefinition === undefined) {\n\t\t\t\t\t\tthrow new Error('should not happen')\n\t\t\t\t\t}\n\t\t\t\t\tidPermissions = predicate\n\t\t\t\t\tentityPredicates[predicate] = predicateDefinition\n\t\t\t\t}\n\t\t\t\tfieldPermissions[entity.primary] = idPermissions\n\t\t\t\tentityPredicates[idPermissions as Acl.PredicateReference] = entityPredicates[idPermissions as Acl.PredicateReference]\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toperations: entityOperations,\n\t\t\t\tpredicates: entityPredicates,\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate mergePermissions(left: Acl.Permissions, right: Acl.Permissions, includeThrough = false): Acl.Permissions {\n\t\tconst result = { ...left }\n\t\tfor (let entityName in right) {\n\t\t\tif (result[entityName] !== undefined) {\n\t\t\t\tresult[entityName] = this.mergeEntityPermissions(result[entityName], right[entityName], includeThrough)\n\t\t\t} else {\n\t\t\t\tresult[entityName] = right[entityName]\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate mergeEntityPermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): Acl.EntityPermissions {\n\t\tlet predicates: Writable<Acl.PredicateMap> = {}\n\t\tconst operations: Writable<Acl.EntityOperations> = {}\n\t\tif (left.operations.customPrimary || right.operations.customPrimary) {\n\t\t\toperations.customPrimary = true\n\t\t}\n\t\tconst noRoot: `${Acl.Operation}`[] = []\n\n\t\tfor (\n\t\t\tlet operation of [\n\t\t\t\t'create',\n\t\t\t\t'read',\n\t\t\t\t'update',\n\t\t\t] as const\n\t\t) {\n\t\t\tconst { predicates: opPredicates, permissions: fieldPermissions, noRoot: opNoRoot } = this.mergeOperationPermissions(\n\t\t\t\tleft,\n\t\t\t\tright,\n\t\t\t\toperation,\n\t\t\t\tincludeThrough,\n\t\t\t)\n\n\t\t\tif (opNoRoot) {\n\t\t\t\tnoRoot.push(operation)\n\t\t\t}\n\n\t\t\tpredicates = { ...predicates, ...opPredicates }\n\t\t\tif (Object.keys(fieldPermissions).length > 0) {\n\t\t\t\toperations[operation] = fieldPermissions\n\t\t\t}\n\t\t}\n\n\t\tconst { predicateDefinition, predicate, noRoot: opNoRoot } = this.mergeDeletePermissions(left, right, includeThrough)\n\t\tif (opNoRoot) {\n\t\t\tnoRoot.push('delete')\n\t\t}\n\t\tif (predicate === true) {\n\t\t\toperations.delete = true\n\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\toperations.delete = predicate\n\t\t}\n\n\t\tif (noRoot.length > 0) {\n\t\t\toperations.noRoot = noRoot\n\t\t}\n\n\t\treturn {\n\t\t\tpredicates: predicates,\n\t\t\toperations: operations,\n\t\t}\n\t}\n\n\tprivate mergeOperationPermissions(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: 'create' | 'read' | 'update',\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tpredicates: Acl.PredicateMap\n\t\tpermissions: Acl.FieldPermissions\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, operation, includeThrough)\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergeFieldPermissions(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate mergeDeletePermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): {\n\t\tnoRoot: boolean\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, 'delete', includeThrough)\n\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergePredicates(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate resolveNoRoot<const Op extends `${Acl.Operation}`>(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: Op,\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tleftPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t\trightPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t} {\n\t\tconst leftRootForbidden = left.operations.noRoot?.includes(operation) || false\n\t\tconst rightRootForbidden = right.operations.noRoot?.includes(operation) || false\n\t\tconst leftPermissions = left.operations[operation]\n\t\tconst rightPermissions = right.operations[operation]\n\n\t\tconst rootForbidden = (leftRootForbidden && rightRootForbidden)\n\t\t\t|| (leftRootForbidden && !rightPermissions)\n\t\t\t|| (rightRootForbidden && !leftPermissions)\n\n\t\t// When includeThrough is true, keep all permissions regardless of noRoot\n\t\t// (used for \"all\" permissions that apply when accessing through relations)\n\t\tconst resolvedLeftPermissions = !includeThrough && !rootForbidden && leftRootForbidden ? undefined : leftPermissions\n\t\tconst resolvedRightPermissions = !includeThrough && !rootForbidden && rightRootForbidden ? undefined : rightPermissions\n\n\t\treturn {\n\t\t\tnoRoot: rootForbidden,\n\t\t\tleftPermissions: resolvedLeftPermissions,\n\t\t\trightPermissions: resolvedRightPermissions,\n\t\t}\n\t}\n\n\tprivate mergeFieldPermissions(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t): { predicates: Acl.PredicateMap; permissions: Acl.FieldPermissions } {\n\t\tconst permissions: Writable<Acl.FieldPermissions> = {}\n\t\tconst predicates: Writable<Acl.PredicateMap> = {}\n\n\t\tfor (let field in { ...leftFieldPermissions, ...rightFieldPermissions }) {\n\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\tleftPredicates,\n\t\t\t\tleftFieldPermissions[field] || false,\n\t\t\t\trightPredicates,\n\t\t\t\trightFieldPermissions[field] || false,\n\t\t\t)\n\t\t\tif (predicate === true) {\n\t\t\t\tpermissions[field] = true\n\t\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\t\tpermissions[field] = predicate\n\t\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\t}\n\t\t}\n\n\t\treturn { predicates, permissions }\n\t}\n\n\tprivate mergePredicates(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftReference: Acl.Predicate | undefined = false,\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightReference: Acl.Predicate | undefined = false,\n\t): {\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tif (leftReference === true || rightReference === true) {\n\t\t\treturn {\n\t\t\t\tpredicate: true,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\n\t\tif (leftReference !== false && rightReference !== false) {\n\t\t\tconst leftPredicate: Acl.PredicateDefinition = leftPredicates[leftReference]\n\t\t\tconst rightPredicate: Acl.PredicateDefinition = rightPredicates[rightReference]\n\t\t\tif (leftPredicate === rightPredicate) {\n\t\t\t\treturn {\n\t\t\t\t\tpredicate: leftReference,\n\t\t\t\t\tpredicateDefinition: leftPredicate,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet predicateName = '__merge__' + leftReference + '__' + rightReference\n\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\tpredicateName += '_'\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: {\n\t\t\t\t\tor: [leftPredicate, rightPredicate],\n\t\t\t\t} as Acl.PredicateDefinition,\n\t\t\t}\n\t\t} else if (leftReference !== false) {\n\t\t\treturn {\n\t\t\t\tpredicate: leftReference,\n\t\t\t\tpredicateDefinition: leftPredicates[leftReference],\n\t\t\t}\n\t\t} else if (rightReference !== false) {\n\t\t\tlet predicateName = rightReference\n\t\t\tif (rightPredicates !== leftPredicates) {\n\t\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\t\tpredicateName += '_'\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: rightPredicates[rightReference],\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpredicate: false,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["mapObject","PredicateDefinitionProcessor","getEntity","prefixVariable","opNoRoot"],"mappings":";;;;;AAcO,MAAM,kBAAkB;AAAA,EACvB,OAAO,QAAgB,OAA0B,QAAkC;AACzF,WAAO,KAAK,eAAe,QAAQ,OAAO,OAAO,MAAM;AAAA,EACxD;AAAA,EAEO,iBAAiB,QAAgB,OAAiD;AACxF,WAAO;AAAA,MACN,MAAM,KAAK,eAAe,QAAQ,OAAO,KAAK;AAAA,MAC9C,KAAK,KAAK,eAAe,QAAQ,OAAO,IAAI;AAAA,IAAA;AAAA,EAE9C;AAAA,EAEQ,eAAe,QAAgB,OAA0B,gBAAyB,QAAkC;AAC3H,QAAI,SAA0B,CAAA;AAC9B,aAAS,QAAQ,OAAO;AACvB,YAAM,iBAAiB,OAAO,IAAI,MAAM,IAAI,KAAK,EAAE,UAAU,GAAC;AAC9D,UAAI,kBAAmC,KAAK,yBAAyB,OAAO,OAAO,eAAe,UAAU,UAAU,IAAI;AAC1H,UAAI,eAAe,UAAU;AAC5B,cAAM,uBAAuB,KAAK,eAAe,QAAQ,eAAe,UAAU,gBAAgB,UAAU,IAAI;AAChH,0BAAkB,KAAK,iBAAiB,sBAAsB,iBAAiB,cAAc;AAAA,MAC9F;AACA,eAAS,KAAK,iBAAiB,QAAQ,iBAAiB,cAAc;AAAA,IACvE;AACA,aAAS,KAAK,sCAAsC,OAAO,OAAO,MAAM;AAExE,WAAO;AAAA,EACR;AAAA,EAEQ,yBAAyB,OAAqB,aAA8B,MAA+B;AAClH,WAAOA,OAAAA,UAAU,aAAa,CAAC,EAAE,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B,QAAQ,mBAAmB,MAAM;AACtD,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAEA,QAAI,kBAAkB,SAAS,mBAAmB,OAAO;AACxD,YAAM,gBAAyC,eAAe,aAAa;AAC3E,YAAM,iBAA0C,gBAAgB,cAAc;AAC9E,UAAI,kBAAkB,gBAAgB;AACrC,eAAO;AAAA,UACN,WAAW;AAAA,UACX,qBAAqB;AAAA,QAAA;AAAA,MAEvB;AAEA,UAAI,gBAAgB,cAAc,gBAAgB,OAAO;AACzD,aAAO,eAAe,aAAa,GAAG;AACrC,yBAAiB;AAAA,MAClB;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,UACpB,IAAI,CAAC,eAAe,cAAc;AAAA,QAAA;AAAA,MACnC;AAAA,IAEF,WAAW,kBAAkB,OAAO;AACnC,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,eAAe,aAAa;AAAA,MAAA;AAAA,IAEnD,WAAW,mBAAmB,OAAO;AACpC,UAAI,gBAAgB;AACpB,UAAI,oBAAoB,gBAAgB;AACvC,eAAO,eAAe,aAAa,GAAG;AACrC,2BAAiB;AAAA,QAClB;AAAA,MACD;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,gBAAgB,cAAc;AAAA,MAAA;AAAA,IAErD,OAAO;AACN,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAAA,EACD;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionFactory.js","sources":["../../../../../packages/engine-content-api/src/acl/PermissionFactory.ts"],"sourcesContent":["import { Acl, Model, Schema, Writable } from '@contember/schema'\nimport { getEntity, PredicateDefinitionProcessor } from '@contember/schema-utils'\nimport { mapObject } from '../utils'\nimport { prefixVariable } from './VariableUtils'\n\nexport interface Identity {\n\tprojectRoles: readonly string[]\n}\n\nexport interface ContextualPermissions {\n\troot: Acl.Permissions\n\tall: Acl.Permissions\n}\n\nexport class PermissionFactory {\n\tpublic create(schema: Schema, roles: readonly string[], prefix?: string): Acl.Permissions {\n\t\treturn this.createInternal(schema, roles, false, prefix)\n\t}\n\n\tpublic createContextual(schema: Schema, roles: readonly string[]): ContextualPermissions {\n\t\treturn {\n\t\t\troot: this.createInternal(schema, roles, false),\n\t\t\tall: this.createInternal(schema, roles, true),\n\t\t}\n\t}\n\n\tprivate createInternal(schema: Schema, roles: readonly string[], includeThrough: boolean, prefix?: string): Acl.Permissions {\n\t\tlet result: Acl.Permissions = {}\n\t\tfor (let role of roles) {\n\t\t\tconst roleDefinition = schema.acl.roles[role] || { entities: {} }\n\t\t\tlet rolePermissions: Acl.Permissions = this.prefixPredicatesWithRole(schema.model, roleDefinition.entities, prefix || role)\n\t\t\tif (roleDefinition.inherits) {\n\t\t\t\tconst inheritedPermissions = this.createInternal(schema, roleDefinition.inherits, includeThrough, prefix || role)\n\t\t\t\trolePermissions = this.mergePermissions(inheritedPermissions, rolePermissions, includeThrough)\n\t\t\t}\n\t\t\tresult = this.mergePermissions(result, rolePermissions, includeThrough)\n\t\t}\n\t\tresult = this.makePrimaryPredicatesUnionOfAllFields(schema.model, result)\n\n\t\treturn result\n\t}\n\n\tprivate prefixPredicatesWithRole(model: Model.Schema, permissions: Acl.Permissions, role: string): Acl.Permissions {\n\t\treturn mapObject(permissions, ({ operations, predicates }, entityName) => ({\n\t\t\toperations,\n\t\t\tpredicates: mapObject(predicates, predicate => {\n\t\t\t\tconst predicateDefinitionProcessor = new PredicateDefinitionProcessor(model)\n\t\t\t\treturn predicateDefinitionProcessor.process(getEntity(model, entityName), predicate, {\n\t\t\t\t\thandleColumn: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t\thandleRelation: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}),\n\t\t}))\n\t}\n\n\tprivate makePrimaryPredicatesUnionOfAllFields(model: Model.Schema, permissions: Acl.Permissions): Acl.Permissions {\n\t\treturn mapObject(permissions, (permission, entityName): Acl.EntityPermissions => {\n\t\t\tconst entity = getEntity(model, entityName)\n\t\t\tconst entityPredicates: Writable<Acl.PredicateMap> = { ...permission.predicates }\n\t\t\tconst entityOperations: Writable<Acl.EntityOperations> = { ...permission.operations }\n\n\t\t\tconst operationNames = ['read', 'create', 'update'] as const\n\t\t\tfor (let operation of operationNames) {\n\t\t\t\tif (!entityOperations[operation]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst fieldPermissions: Writable<Acl.FieldPermissions> = { ...entityOperations[operation] }\n\t\t\t\tentityOperations[operation] = fieldPermissions\n\n\t\t\t\tif (Object.values(fieldPermissions).some(it => it === true)) {\n\t\t\t\t\tfieldPermissions[entity.primary] = true\n\t\t\t\t}\n\t\t\t\tif (fieldPermissions[entity.primary] === true) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst predicateReferences: string[] = Object.entries(fieldPermissions)\n\t\t\t\t\t.filter(([key]) => key !== entity.primary)\n\t\t\t\t\t.map(([key, value]) => value)\n\t\t\t\t\t.filter(value => value !== false)\n\t\t\t\t\t.filter((value, index, array): value is string => array.indexOf(value) === index)\n\n\t\t\t\tlet idPermissions: Acl.Predicate = fieldPermissions[entity.primary] || false\n\n\t\t\t\tfor (let predicateReference of predicateReferences) {\n\t\t\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tidPermissions,\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tpredicateReference,\n\t\t\t\t\t)\n\t\t\t\t\tif (typeof predicate !== 'string' || predicateDefinition === undefined) {\n\t\t\t\t\t\tthrow new Error('should not happen')\n\t\t\t\t\t}\n\t\t\t\t\tidPermissions = predicate\n\t\t\t\t\tentityPredicates[predicate] = predicateDefinition\n\t\t\t\t}\n\t\t\t\tfieldPermissions[entity.primary] = idPermissions\n\t\t\t\tentityPredicates[idPermissions as Acl.PredicateReference] = entityPredicates[idPermissions as Acl.PredicateReference]\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toperations: entityOperations,\n\t\t\t\tpredicates: entityPredicates,\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate mergePermissions(left: Acl.Permissions, right: Acl.Permissions, includeThrough = false): Acl.Permissions {\n\t\tconst result = { ...left }\n\t\tfor (let entityName in right) {\n\t\t\tif (result[entityName] !== undefined) {\n\t\t\t\tresult[entityName] = this.mergeEntityPermissions(result[entityName], right[entityName], includeThrough)\n\t\t\t} else {\n\t\t\t\tresult[entityName] = right[entityName]\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate mergeEntityPermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): Acl.EntityPermissions {\n\t\tlet predicates: Writable<Acl.PredicateMap> = {}\n\t\tconst operations: Writable<Acl.EntityOperations> = {}\n\t\tif (left.operations.customPrimary || right.operations.customPrimary) {\n\t\t\toperations.customPrimary = true\n\t\t}\n\t\tconst noRoot: `${Acl.Operation}`[] = []\n\n\t\tfor (\n\t\t\tlet operation of [\n\t\t\t\t'create',\n\t\t\t\t'read',\n\t\t\t\t'update',\n\t\t\t] as const\n\t\t) {\n\t\t\tconst { predicates: opPredicates, permissions: fieldPermissions, noRoot: opNoRoot } = this.mergeOperationPermissions(\n\t\t\t\tleft,\n\t\t\t\tright,\n\t\t\t\toperation,\n\t\t\t\tincludeThrough,\n\t\t\t)\n\n\t\t\tif (opNoRoot) {\n\t\t\t\tnoRoot.push(operation)\n\t\t\t}\n\n\t\t\tpredicates = { ...predicates, ...opPredicates }\n\t\t\tif (Object.keys(fieldPermissions).length > 0) {\n\t\t\t\toperations[operation] = fieldPermissions\n\t\t\t}\n\t\t}\n\n\t\tconst { predicateDefinition, predicate, noRoot: opNoRoot } = this.mergeDeletePermissions(left, right, includeThrough)\n\t\tif (opNoRoot) {\n\t\t\tnoRoot.push('delete')\n\t\t}\n\t\tif (predicate === true) {\n\t\t\toperations.delete = true\n\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\toperations.delete = predicate\n\t\t}\n\n\t\tif (noRoot.length > 0) {\n\t\t\toperations.noRoot = noRoot\n\t\t}\n\n\t\treturn {\n\t\t\tpredicates: predicates,\n\t\t\toperations: operations,\n\t\t}\n\t}\n\n\tprivate mergeOperationPermissions(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: 'create' | 'read' | 'update',\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tpredicates: Acl.PredicateMap\n\t\tpermissions: Acl.FieldPermissions\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, operation, includeThrough)\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergeFieldPermissions(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate mergeDeletePermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): {\n\t\tnoRoot: boolean\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, 'delete', includeThrough)\n\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergePredicates(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate resolveNoRoot<const Op extends `${Acl.Operation}`>(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: Op,\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tleftPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t\trightPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t} {\n\t\tconst leftRootForbidden = left.operations.noRoot?.includes(operation) || false\n\t\tconst rightRootForbidden = right.operations.noRoot?.includes(operation) || false\n\t\tconst leftPermissions = left.operations[operation]\n\t\tconst rightPermissions = right.operations[operation]\n\n\t\tconst rootForbidden = (leftRootForbidden && rightRootForbidden)\n\t\t\t|| (leftRootForbidden && !rightPermissions)\n\t\t\t|| (rightRootForbidden && !leftPermissions)\n\n\t\t// When includeThrough is true, keep all permissions regardless of noRoot\n\t\t// (used for \"all\" permissions that apply when accessing through relations)\n\t\tconst resolvedLeftPermissions = !includeThrough && !rootForbidden && leftRootForbidden ? undefined : leftPermissions\n\t\tconst resolvedRightPermissions = !includeThrough && !rootForbidden && rightRootForbidden ? undefined : rightPermissions\n\n\t\treturn {\n\t\t\tnoRoot: rootForbidden,\n\t\t\tleftPermissions: resolvedLeftPermissions,\n\t\t\trightPermissions: resolvedRightPermissions,\n\t\t}\n\t}\n\n\tprivate mergeFieldPermissions(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t): { predicates: Acl.PredicateMap; permissions: Acl.FieldPermissions } {\n\t\tconst permissions: Writable<Acl.FieldPermissions> = {}\n\t\tconst predicates: Writable<Acl.PredicateMap> = {}\n\n\t\tfor (let field in { ...leftFieldPermissions, ...rightFieldPermissions }) {\n\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\tleftPredicates,\n\t\t\t\tleftFieldPermissions[field] || false,\n\t\t\t\trightPredicates,\n\t\t\t\trightFieldPermissions[field] || false,\n\t\t\t)\n\t\t\tif (predicate === true) {\n\t\t\t\tpermissions[field] = true\n\t\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\t\tpermissions[field] = predicate\n\t\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\t}\n\t\t}\n\n\t\treturn { predicates, permissions }\n\t}\n\n\tprivate mergePredicates(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftReference: Acl.Predicate | undefined = false,\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightReference: Acl.Predicate | undefined = false,\n\t): {\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tif (leftReference === true || rightReference === true) {\n\t\t\treturn {\n\t\t\t\tpredicate: true,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\n\t\tif (leftReference !== false && rightReference !== false) {\n\t\t\tconst leftPredicate: Acl.PredicateDefinition = leftPredicates[leftReference]\n\t\t\tconst rightPredicate: Acl.PredicateDefinition = rightPredicates[rightReference]\n\t\t\tif (leftPredicate === rightPredicate) {\n\t\t\t\treturn {\n\t\t\t\t\tpredicate: leftReference,\n\t\t\t\t\tpredicateDefinition: leftPredicate,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet predicateName = '__merge__' + leftReference + '__' + rightReference\n\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\tpredicateName += '_'\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: {\n\t\t\t\t\tor: [leftPredicate, rightPredicate],\n\t\t\t\t} as Acl.PredicateDefinition,\n\t\t\t}\n\t\t} else if (leftReference !== false) {\n\t\t\treturn {\n\t\t\t\tpredicate: leftReference,\n\t\t\t\tpredicateDefinition: leftPredicates[leftReference],\n\t\t\t}\n\t\t} else if (rightReference !== false) {\n\t\t\tlet predicateName = rightReference\n\t\t\tif (rightPredicates !== leftPredicates) {\n\t\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\t\tpredicateName += '_'\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: rightPredicates[rightReference],\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpredicate: false,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["opNoRoot"],"mappings":";;;AAcO,MAAM,kBAAkB;AAAA,EACvB,OAAO,QAAgB,OAA0B,QAAkC;AACzF,WAAO,KAAK,eAAe,QAAQ,OAAO,OAAO,MAAM;AAAA,EACxD;AAAA,EAEO,iBAAiB,QAAgB,OAAiD;AACxF,WAAO;AAAA,MACN,MAAM,KAAK,eAAe,QAAQ,OAAO,KAAK;AAAA,MAC9C,KAAK,KAAK,eAAe,QAAQ,OAAO,IAAI;AAAA,IAAA;AAAA,EAE9C;AAAA,EAEQ,eAAe,QAAgB,OAA0B,gBAAyB,QAAkC;AAC3H,QAAI,SAA0B,CAAA;AAC9B,aAAS,QAAQ,OAAO;AACvB,YAAM,iBAAiB,OAAO,IAAI,MAAM,IAAI,KAAK,EAAE,UAAU,GAAC;AAC9D,UAAI,kBAAmC,KAAK,yBAAyB,OAAO,OAAO,eAAe,UAAU,UAAU,IAAI;AAC1H,UAAI,eAAe,UAAU;AAC5B,cAAM,uBAAuB,KAAK,eAAe,QAAQ,eAAe,UAAU,gBAAgB,UAAU,IAAI;AAChH,0BAAkB,KAAK,iBAAiB,sBAAsB,iBAAiB,cAAc;AAAA,MAC9F;AACA,eAAS,KAAK,iBAAiB,QAAQ,iBAAiB,cAAc;AAAA,IACvE;AACA,aAAS,KAAK,sCAAsC,OAAO,OAAO,MAAM;AAExE,WAAO;AAAA,EACR;AAAA,EAEQ,yBA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QAAI,kBAAkB,QAAQ,mBAAmB,MAAM;AACtD,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAEA,QAAI,kBAAkB,SAAS,mBAAmB,OAAO;AACxD,YAAM,gBAAyC,eAAe,aAAa;AAC3E,YAAM,iBAA0C,gBAAgB,cAAc;AAC9E,UAAI,kBAAkB,gBAAgB;AACrC,eAAO;AAAA,UACN,WAAW;AAAA,UACX,qBAAqB;AAAA,QAAA;AAAA,MAEvB;AAEA,UAAI,gBAAgB,cAAc,gBAAgB,OAAO;AACzD,aAAO,eAAe,aAAa,GAAG;AACrC,yBAAiB;AAAA,MAClB;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,UACpB,IAAI,CAAC,eAAe,cAAc;AAAA,QAAA;AAAA,MACnC;AAAA,IAEF,WAAW,kBAAkB,OAAO;AACnC,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,eAAe,aAAa;AAAA,MAAA;AAAA,IAEnD,WAAW,mBAAmB,OAAO;AACpC,UAAI,gBAAgB;AACpB,UAAI,oBAAoB,gBAAgB;AACvC,eAAO,eAAe,aAAa,GAAG;AACrC,2BAAiB;AAAA,QAClB;AAAA,MACD;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,gBAAgB,cAAc;AAAA,MAAA;AAAA,IAErD,OAAO;AACN,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAAA,EACD;AACD;"}
|
|
1
|
+
{"version":3,"file":"PermissionFactory.js","sources":["../../../../../packages/engine-content-api/src/acl/PermissionFactory.ts"],"sourcesContent":["import { Acl, Model, Schema, Writable } from '@contember/schema'\nimport { getEntity, PredicateDefinitionProcessor } from '@contember/schema-utils'\nimport { mapObject } from '../utils/index.js'\nimport { prefixVariable } from './VariableUtils.js'\n\nexport interface Identity {\n\tprojectRoles: readonly string[]\n}\n\nexport interface ContextualPermissions {\n\troot: Acl.Permissions\n\tall: Acl.Permissions\n}\n\nexport class PermissionFactory {\n\tpublic create(schema: Schema, roles: readonly string[], prefix?: string): Acl.Permissions {\n\t\treturn this.createInternal(schema, roles, false, prefix)\n\t}\n\n\tpublic createContextual(schema: Schema, roles: readonly string[]): ContextualPermissions {\n\t\treturn {\n\t\t\troot: this.createInternal(schema, roles, false),\n\t\t\tall: this.createInternal(schema, roles, true),\n\t\t}\n\t}\n\n\tprivate createInternal(schema: Schema, roles: readonly string[], includeThrough: boolean, prefix?: string): Acl.Permissions {\n\t\tlet result: Acl.Permissions = {}\n\t\tfor (let role of roles) {\n\t\t\tconst roleDefinition = schema.acl.roles[role] || { entities: {} }\n\t\t\tlet rolePermissions: Acl.Permissions = this.prefixPredicatesWithRole(schema.model, roleDefinition.entities, prefix || role)\n\t\t\tif (roleDefinition.inherits) {\n\t\t\t\tconst inheritedPermissions = this.createInternal(schema, roleDefinition.inherits, includeThrough, prefix || role)\n\t\t\t\trolePermissions = this.mergePermissions(inheritedPermissions, rolePermissions, includeThrough)\n\t\t\t}\n\t\t\tresult = this.mergePermissions(result, rolePermissions, includeThrough)\n\t\t}\n\t\tresult = this.makePrimaryPredicatesUnionOfAllFields(schema.model, result)\n\n\t\treturn result\n\t}\n\n\tprivate prefixPredicatesWithRole(model: Model.Schema, permissions: Acl.Permissions, role: string): Acl.Permissions {\n\t\treturn mapObject(permissions, ({ operations, predicates }, entityName) => ({\n\t\t\toperations,\n\t\t\tpredicates: mapObject(predicates, predicate => {\n\t\t\t\tconst predicateDefinitionProcessor = new PredicateDefinitionProcessor(model)\n\t\t\t\treturn predicateDefinitionProcessor.process(getEntity(model, entityName), predicate, {\n\t\t\t\t\thandleColumn: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t\thandleRelation: ({ value }) => {\n\t\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\t\treturn prefixVariable(role, value)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn value\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}),\n\t\t}))\n\t}\n\n\tprivate makePrimaryPredicatesUnionOfAllFields(model: Model.Schema, permissions: Acl.Permissions): Acl.Permissions {\n\t\treturn mapObject(permissions, (permission, entityName): Acl.EntityPermissions => {\n\t\t\tconst entity = getEntity(model, entityName)\n\t\t\tconst entityPredicates: Writable<Acl.PredicateMap> = { ...permission.predicates }\n\t\t\tconst entityOperations: Writable<Acl.EntityOperations> = { ...permission.operations }\n\n\t\t\tconst operationNames = ['read', 'create', 'update'] as const\n\t\t\tfor (let operation of operationNames) {\n\t\t\t\tif (!entityOperations[operation]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst fieldPermissions: Writable<Acl.FieldPermissions> = { ...entityOperations[operation] }\n\t\t\t\tentityOperations[operation] = fieldPermissions\n\n\t\t\t\tif (Object.values(fieldPermissions).some(it => it === true)) {\n\t\t\t\t\tfieldPermissions[entity.primary] = true\n\t\t\t\t}\n\t\t\t\tif (fieldPermissions[entity.primary] === true) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst predicateReferences: string[] = Object.entries(fieldPermissions)\n\t\t\t\t\t.filter(([key]) => key !== entity.primary)\n\t\t\t\t\t.map(([key, value]) => value)\n\t\t\t\t\t.filter(value => value !== false)\n\t\t\t\t\t.filter((value, index, array): value is string => array.indexOf(value) === index)\n\n\t\t\t\tlet idPermissions: Acl.Predicate = fieldPermissions[entity.primary] || false\n\n\t\t\t\tfor (let predicateReference of predicateReferences) {\n\t\t\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tidPermissions,\n\t\t\t\t\t\tentityPredicates,\n\t\t\t\t\t\tpredicateReference,\n\t\t\t\t\t)\n\t\t\t\t\tif (typeof predicate !== 'string' || predicateDefinition === undefined) {\n\t\t\t\t\t\tthrow new Error('should not happen')\n\t\t\t\t\t}\n\t\t\t\t\tidPermissions = predicate\n\t\t\t\t\tentityPredicates[predicate] = predicateDefinition\n\t\t\t\t}\n\t\t\t\tfieldPermissions[entity.primary] = idPermissions\n\t\t\t\tentityPredicates[idPermissions as Acl.PredicateReference] = entityPredicates[idPermissions as Acl.PredicateReference]\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toperations: entityOperations,\n\t\t\t\tpredicates: entityPredicates,\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate mergePermissions(left: Acl.Permissions, right: Acl.Permissions, includeThrough = false): Acl.Permissions {\n\t\tconst result = { ...left }\n\t\tfor (let entityName in right) {\n\t\t\tif (result[entityName] !== undefined) {\n\t\t\t\tresult[entityName] = this.mergeEntityPermissions(result[entityName], right[entityName], includeThrough)\n\t\t\t} else {\n\t\t\t\tresult[entityName] = right[entityName]\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate mergeEntityPermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): Acl.EntityPermissions {\n\t\tlet predicates: Writable<Acl.PredicateMap> = {}\n\t\tconst operations: Writable<Acl.EntityOperations> = {}\n\t\tif (left.operations.customPrimary || right.operations.customPrimary) {\n\t\t\toperations.customPrimary = true\n\t\t}\n\t\tconst noRoot: `${Acl.Operation}`[] = []\n\n\t\tfor (\n\t\t\tlet operation of [\n\t\t\t\t'create',\n\t\t\t\t'read',\n\t\t\t\t'update',\n\t\t\t] as const\n\t\t) {\n\t\t\tconst { predicates: opPredicates, permissions: fieldPermissions, noRoot: opNoRoot } = this.mergeOperationPermissions(\n\t\t\t\tleft,\n\t\t\t\tright,\n\t\t\t\toperation,\n\t\t\t\tincludeThrough,\n\t\t\t)\n\n\t\t\tif (opNoRoot) {\n\t\t\t\tnoRoot.push(operation)\n\t\t\t}\n\n\t\t\tpredicates = { ...predicates, ...opPredicates }\n\t\t\tif (Object.keys(fieldPermissions).length > 0) {\n\t\t\t\toperations[operation] = fieldPermissions\n\t\t\t}\n\t\t}\n\n\t\tconst { predicateDefinition, predicate, noRoot: opNoRoot } = this.mergeDeletePermissions(left, right, includeThrough)\n\t\tif (opNoRoot) {\n\t\t\tnoRoot.push('delete')\n\t\t}\n\t\tif (predicate === true) {\n\t\t\toperations.delete = true\n\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\toperations.delete = predicate\n\t\t}\n\n\t\tif (noRoot.length > 0) {\n\t\t\toperations.noRoot = noRoot\n\t\t}\n\n\t\treturn {\n\t\t\tpredicates: predicates,\n\t\t\toperations: operations,\n\t\t}\n\t}\n\n\tprivate mergeOperationPermissions(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: 'create' | 'read' | 'update',\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tpredicates: Acl.PredicateMap\n\t\tpermissions: Acl.FieldPermissions\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, operation, includeThrough)\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergeFieldPermissions(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate mergeDeletePermissions(left: Acl.EntityPermissions, right: Acl.EntityPermissions, includeThrough = false): {\n\t\tnoRoot: boolean\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tconst { noRoot, leftPermissions, rightPermissions } = this.resolveNoRoot(left, right, 'delete', includeThrough)\n\n\t\treturn {\n\t\t\tnoRoot,\n\t\t\t...this.mergePredicates(\n\t\t\t\tleft.predicates,\n\t\t\t\tleftPermissions,\n\t\t\t\tright.predicates,\n\t\t\t\trightPermissions,\n\t\t\t),\n\t\t}\n\t}\n\n\tprivate resolveNoRoot<const Op extends `${Acl.Operation}`>(\n\t\tleft: Acl.EntityPermissions,\n\t\tright: Acl.EntityPermissions,\n\t\toperation: Op,\n\t\tincludeThrough = false,\n\t): {\n\t\tnoRoot: boolean\n\t\tleftPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t\trightPermissions: Acl.EntityPermissions['operations'][Op] | undefined\n\t} {\n\t\tconst leftRootForbidden = left.operations.noRoot?.includes(operation) || false\n\t\tconst rightRootForbidden = right.operations.noRoot?.includes(operation) || false\n\t\tconst leftPermissions = left.operations[operation]\n\t\tconst rightPermissions = right.operations[operation]\n\n\t\tconst rootForbidden = (leftRootForbidden && rightRootForbidden)\n\t\t\t|| (leftRootForbidden && !rightPermissions)\n\t\t\t|| (rightRootForbidden && !leftPermissions)\n\n\t\t// When includeThrough is true, keep all permissions regardless of noRoot\n\t\t// (used for \"all\" permissions that apply when accessing through relations)\n\t\tconst resolvedLeftPermissions = !includeThrough && !rootForbidden && leftRootForbidden ? undefined : leftPermissions\n\t\tconst resolvedRightPermissions = !includeThrough && !rootForbidden && rightRootForbidden ? undefined : rightPermissions\n\n\t\treturn {\n\t\t\tnoRoot: rootForbidden,\n\t\t\tleftPermissions: resolvedLeftPermissions,\n\t\t\trightPermissions: resolvedRightPermissions,\n\t\t}\n\t}\n\n\tprivate mergeFieldPermissions(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightFieldPermissions: Acl.FieldPermissions | undefined = {},\n\t): { predicates: Acl.PredicateMap; permissions: Acl.FieldPermissions } {\n\t\tconst permissions: Writable<Acl.FieldPermissions> = {}\n\t\tconst predicates: Writable<Acl.PredicateMap> = {}\n\n\t\tfor (let field in { ...leftFieldPermissions, ...rightFieldPermissions }) {\n\t\t\tconst { predicateDefinition, predicate } = this.mergePredicates(\n\t\t\t\tleftPredicates,\n\t\t\t\tleftFieldPermissions[field] || false,\n\t\t\t\trightPredicates,\n\t\t\t\trightFieldPermissions[field] || false,\n\t\t\t)\n\t\t\tif (predicate === true) {\n\t\t\t\tpermissions[field] = true\n\t\t\t} else if (predicateDefinition !== undefined && typeof predicate === 'string') {\n\t\t\t\tpermissions[field] = predicate\n\t\t\t\tpredicates[predicate] = predicateDefinition\n\t\t\t}\n\t\t}\n\n\t\treturn { predicates, permissions }\n\t}\n\n\tprivate mergePredicates(\n\t\tleftPredicates: Acl.PredicateMap,\n\t\tleftReference: Acl.Predicate | undefined = false,\n\t\trightPredicates: Acl.PredicateMap,\n\t\trightReference: Acl.Predicate | undefined = false,\n\t): {\n\t\tpredicate: Acl.PredicateReference | boolean\n\t\tpredicateDefinition: Acl.PredicateDefinition | undefined\n\t} {\n\t\tif (leftReference === true || rightReference === true) {\n\t\t\treturn {\n\t\t\t\tpredicate: true,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\n\t\tif (leftReference !== false && rightReference !== false) {\n\t\t\tconst leftPredicate: Acl.PredicateDefinition = leftPredicates[leftReference]\n\t\t\tconst rightPredicate: Acl.PredicateDefinition = rightPredicates[rightReference]\n\t\t\tif (leftPredicate === rightPredicate) {\n\t\t\t\treturn {\n\t\t\t\t\tpredicate: leftReference,\n\t\t\t\t\tpredicateDefinition: leftPredicate,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet predicateName = '__merge__' + leftReference + '__' + rightReference\n\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\tpredicateName += '_'\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: {\n\t\t\t\t\tor: [leftPredicate, rightPredicate],\n\t\t\t\t} as Acl.PredicateDefinition,\n\t\t\t}\n\t\t} else if (leftReference !== false) {\n\t\t\treturn {\n\t\t\t\tpredicate: leftReference,\n\t\t\t\tpredicateDefinition: leftPredicates[leftReference],\n\t\t\t}\n\t\t} else if (rightReference !== false) {\n\t\t\tlet predicateName = rightReference\n\t\t\tif (rightPredicates !== leftPredicates) {\n\t\t\t\twhile (leftPredicates[predicateName]) {\n\t\t\t\t\tpredicateName += '_'\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpredicate: predicateName,\n\t\t\t\tpredicateDefinition: rightPredicates[rightReference],\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpredicate: false,\n\t\t\t\tpredicateDefinition: undefined,\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["opNoRoot"],"mappings":";;;AAcO,MAAM,kBAAkB;AAAA,EACvB,OAAO,QAAgB,OAA0B,QAAkC;AACzF,WAAO,KAAK,eAAe,QAAQ,OAAO,OAAO,MAAM;AAAA,EACxD;AAAA,EAEO,iBAAiB,QAAgB,OAAiD;AACxF,WAAO;AAAA,MACN,MAAM,KAAK,eAAe,QAAQ,OAAO,KAAK;AAAA,MAC9C,KAAK,KAAK,eAAe,QAAQ,OAAO,IAAI;AAAA,IAAA;AAAA,EAE9C;AAAA,EAEQ,eAAe,QAAgB,OAA0B,gBAAyB,QAAkC;AAC3H,QAAI,SAA0B,CAAA;AAC9B,aAAS,QAAQ,OAAO;AACvB,YAAM,iBAAiB,OAAO,IAAI,MAAM,IAAI,KAAK,EAAE,UAAU,GAAC;AAC9D,UAAI,kBAAmC,KAAK,yBAAyB,OAAO,OAAO,eAAe,UAAU,UAAU,IAAI;AAC1H,UAAI,eAAe,UAAU;AAC5B,cAAM,uBAAuB,KAAK,eAAe,QAAQ,eAAe,UAAU,gBAAgB,UAAU,IAAI;AAChH,0BAAkB,KAAK,iBAAiB,sBAAsB,iBAAiB,cAAc;AAAA,MAC9F;AACA,eAAS,KAAK,iBAAiB,QAAQ,iBAAiB,cAAc;AAAA,IACvE;AACA,aAAS,KAAK,sCAAsC,OAAO,OAAO,MAAM;AAExE,WAAO;AAAA,EACR;AAAA,EAEQ,yBAAyB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I,kBAAkB,QAAQ,mBAAmB,MAAM;AACtD,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAEA,QAAI,kBAAkB,SAAS,mBAAmB,OAAO;AACxD,YAAM,gBAAyC,eAAe,aAAa;AAC3E,YAAM,iBAA0C,gBAAgB,cAAc;AAC9E,UAAI,kBAAkB,gBAAgB;AACrC,eAAO;AAAA,UACN,WAAW;AAAA,UACX,qBAAqB;AAAA,QAAA;AAAA,MAEvB;AAEA,UAAI,gBAAgB,cAAc,gBAAgB,OAAO;AACzD,aAAO,eAAe,aAAa,GAAG;AACrC,yBAAiB;AAAA,MAClB;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,UACpB,IAAI,CAAC,eAAe,cAAc;AAAA,QAAA;AAAA,MACnC;AAAA,IAEF,WAAW,kBAAkB,OAAO;AACnC,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,eAAe,aAAa;AAAA,MAAA;AAAA,IAEnD,WAAW,mBAAmB,OAAO;AACpC,UAAI,gBAAgB;AACpB,UAAI,oBAAoB,gBAAgB;AACvC,eAAO,eAAe,aAAa,GAAG;AACrC,2BAAiB;AAAA,QAClB;AAAA,MACD;AACA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB,gBAAgB,cAAc;AAAA,MAAA;AAAA,IAErD,OAAO;AACN,aAAO;AAAA,QACN,WAAW;AAAA,QACX,qBAAqB;AAAA,MAAA;AAAA,IAEvB;AAAA,EACD;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PredicateFactory.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicateFactory.ts"],"sourcesContent":["import { Acl, Input, Model } from '@contember/schema'\nimport { VariableInjector } from './VariableInjector'\nimport { EvaluatedPredicateReplacer } from './EvaluatedPredicateReplacer'\n\nconst getRowLevelPredicatePseudoField = (entity: Model.Entity) => entity.primary\n\nexport interface FieldRequiredPredicate {\n\tpredicate: Acl.Predicate\n\tisSameAsPrimary: boolean\n}\n\nexport class PredicateFactory {\n\tconstructor(\n\t\tprivate readonly permissions: Acl.Permissions,\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly variableInjector: VariableInjector,\n\t\tprivate readonly allPermissions?: Acl.Permissions,\n\t) {}\n\n\t/**\n\t * Selects the appropriate permission set based on query context:\n\t * - `isRoot === false` (nested/relation context): uses allPermissions (includes through-only permissions)\n\t * - `isRoot === true` or `isRoot === undefined` (root or unknown context): uses root-only permissions\n\t *\n\t * The `undefined` vs `true` distinction matters: `undefined` is the default for callers\n\t * that don't track root context, and must fall through to root permissions for safety.\n\t */\n\tprivate getPermissionsForContext(isRoot?: boolean): Acl.Permissions {\n\t\tif (isRoot === false && this.allPermissions) {\n\t\t\treturn this.allPermissions\n\t\t}\n\t\treturn this.permissions\n\t}\n\n\tpublic getFieldPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): FieldRequiredPredicate {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\tconst predicate = permissions?.[fieldName] ?? false\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\n\t\tconst primaryPredicate = permissions?.[rowLevelField] ?? false\n\t\tconst isSameAsPrimary = predicate === primaryPredicate\n\n\t\treturn {\n\t\t\tisSameAsPrimary,\n\t\t\tpredicate,\n\t\t}\n\t}\n\n\tpublic shouldApplyCellLevelPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.read,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): boolean {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\treturn permissions?.[fieldName] !== permissions?.[rowLevelField]\n\t}\n\n\t/** Delete predicates are not context-aware — through-permission support is scoped to read operations only. */\n\tpublic createDeletePredicate(entity: Model.Entity) {\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\t\tconst entityPermissions = this.permissions[entity.name]\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst deletePredicate = entityPermissions.operations.delete\n\t\tif (deletePredicate === undefined || deletePredicate === false) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tif (deletePredicate === true) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.buildPredicates(entity, [deletePredicate])\n\t}\n\n\tpublic create(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldNames: string[] = [getRowLevelPredicatePseudoField(entity)],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name]\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\tif (fieldNames === undefined) {\n\t\t\tfieldNames = [getRowLevelPredicatePseudoField(entity)]\n\t\t}\n\t\tconst fieldPermissions = entityPermissions.operations[operation]\n\t\tif (fieldPermissions === undefined) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst operationPredicates = this.getRequiredPredicates(fieldNames, fieldPermissions)\n\t\tif (operationPredicates === false) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\treturn this.buildPredicates(entity, operationPredicates, relationContext, isRoot)\n\t}\n\n\tpublic buildPredicates(\n\t\tentity: Model.Entity,\n\t\tpredicates: Acl.PredicateReference[],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name] ?? {}\n\n\t\tconst predicatesWhere: Input.Where[] = predicates.reduce(\n\t\t\t(result: Input.Where[], name: Acl.PredicateReference): Input.Where[] => {\n\t\t\t\tif (!entityPermissions.predicates[name]) {\n\t\t\t\t\tthrow new Error(`${entity.name}: Undefined predicate ${name}`)\n\t\t\t\t}\n\t\t\t\tconst predicateWhere: Input.Where = this.variableInjector.inject(entity, entityPermissions.predicates[name])\n\t\t\t\treturn [...result, predicateWhere]\n\t\t\t},\n\t\t\t[],\n\t\t)\n\t\tif (predicatesWhere.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tconst where: Input.Where = predicatesWhere.length === 1 ? predicatesWhere[0] : { and: predicatesWhere }\n\t\treturn this.optimizePredicates(where, relationContext, isRoot)\n\t}\n\n\tprivate getRequiredPredicates(\n\t\tfieldNames: string[],\n\t\tfieldPermissions: Acl.FieldPermissions,\n\t): Acl.PredicateReference[] | false {\n\t\tconst predicates: Acl.PredicateReference[] = []\n\t\tfor (let name of fieldNames) {\n\t\t\tconst fieldPredicate = fieldPermissions[name]\n\t\t\tif (fieldPredicate === undefined || fieldPredicate === false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (fieldPredicate === true) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!predicates.includes(fieldPredicate)) {\n\t\t\t\tpredicates.push(fieldPredicate)\n\t\t\t}\n\t\t}\n\t\treturn predicates\n\t}\n\n\tpublic optimizePredicates(where: Input.OptionalWhere, relationContext?: Model.AnyRelationContext, isRoot?: boolean) {\n\t\tif (!relationContext || !relationContext.targetRelation) {\n\t\t\treturn where\n\t\t}\n\t\tconst sourcePredicate = this.create(relationContext.entity, Acl.Operation.read, [relationContext.relation.name], undefined, isRoot)\n\t\tif (Object.keys(sourcePredicate).length === 0) {\n\t\t\treturn where\n\t\t}\n\n\t\tconst replacer = new EvaluatedPredicateReplacer(sourcePredicate, relationContext.entity, relationContext.targetRel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AAA,IAAC;AAEF,QAAI,gBAAgB,WAAW,GAAG;AACjC,aAAO,CAAA;AAAA,IACR;AACA,UAAM,QAAqB,gBAAgB,WAAW,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,gBAAA;AACtF,WAAO,KAAK,mBAAmB,OAAO,iBAAiB,MAAM;AAAA,EAC9D;AAAA,EAEQ,sBACP,YACA,kBACmC;AACnC,UAAM,aAAuC,CAAA;AAC7C,aAAS,QAAQ,YAAY;AAC5B,YAAM,iBAAiB,iBAAiB,IAAI;AAC5C,UAAI,mBAAmB,UAAa,mBAAmB,OAAO;AAC7D,eAAO;AAAA,MACR;AACA,UAAI,mBAAmB,MAAM;AAC5B;AAAA,MACD;AACA,UAAI,CAAC,WAAW,SAAS,cAAc,GAAG;AACzC,mBAAW,KAAK,cAAc;AAAA,MAC/B;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EAEO,mBAAmB,OAA4B,iBAA4C,QAAkB;AACnH,QAAI,CAAC,mBAAmB,CAAC,gBAAgB,gBAAgB;AACxD,aAAO;AAAA,IACR;AACA,UAAM,kBAAkB,KAAK,OAAO,gBAAgB,QAAQA,OAAAA,IAAI,UAAU,MAAM,CAAC,gBAAgB,SAAS,IAAI,GAAG,QAAW,MAAM;AAClI,QAAI,OAAO,KAAK,eAAe,EAAE,WAAW,GAAG;AAC9C,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,IAAIC,sDAA2B,iBAAiB,gBAAgB,QAAQ,gBAAgB,cAAc;AACvH,WAAO,SAAS,QAAQ,KAAK;AAAA,EAC9B;AACD;;"}
|
|
1
|
+
{"version":3,"file":"PredicateFactory.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicateFactory.ts"],"sourcesContent":["import { Acl, Input, Model } from '@contember/schema'\nimport { VariableInjector } from './VariableInjector.js'\nimport { EvaluatedPredicateReplacer } from './EvaluatedPredicateReplacer.js'\n\nconst getRowLevelPredicatePseudoField = (entity: Model.Entity) => entity.primary\n\nexport interface FieldRequiredPredicate {\n\tpredicate: Acl.Predicate\n\tisSameAsPrimary: boolean\n}\n\nexport class PredicateFactory {\n\tconstructor(\n\t\tprivate readonly permissions: Acl.Permissions,\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly variableInjector: VariableInjector,\n\t\tprivate readonly allPermissions?: Acl.Permissions,\n\t) {}\n\n\t/**\n\t * Selects the appropriate permission set based on query context:\n\t * - `isRoot === false` (nested/relation context): uses allPermissions (includes through-only permissions)\n\t * - `isRoot === true` or `isRoot === undefined` (root or unknown context): uses root-only permissions\n\t *\n\t * The `undefined` vs `true` distinction matters: `undefined` is the default for callers\n\t * that don't track root context, and must fall through to root permissions for safety.\n\t */\n\tprivate getPermissionsForContext(isRoot?: boolean): Acl.Permissions {\n\t\tif (isRoot === false && this.allPermissions) {\n\t\t\treturn this.allPermissions\n\t\t}\n\t\treturn this.permissions\n\t}\n\n\tpublic getFieldPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): FieldRequiredPredicate {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\tconst predicate = permissions?.[fieldName] ?? false\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\n\t\tconst primaryPredicate = permissions?.[rowLevelField] ?? false\n\t\tconst isSameAsPrimary = predicate === primaryPredicate\n\n\t\treturn {\n\t\t\tisSameAsPrimary,\n\t\t\tpredicate,\n\t\t}\n\t}\n\n\tpublic shouldApplyCellLevelPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.read,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): boolean {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\treturn permissions?.[fieldName] !== permissions?.[rowLevelField]\n\t}\n\n\t/** Delete predicates are not context-aware — through-permission support is scoped to read operations only. */\n\tpublic createDeletePredicate(entity: Model.Entity) {\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\t\tconst entityPermissions = this.permissions[entity.name]\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst deletePredicate = entityPermissions.operations.delete\n\t\tif (deletePredicate === undefined || deletePredicate === false) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tif (deletePredicate === true) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.buildPredicates(entity, [deletePredicate])\n\t}\n\n\tpublic create(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldNames: string[] = [getRowLevelPredicatePseudoField(entity)],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name]\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\tif (fieldNames === undefined) {\n\t\t\tfieldNames = [getRowLevelPredicatePseudoField(entity)]\n\t\t}\n\t\tconst fieldPermissions = entityPermissions.operations[operation]\n\t\tif (fieldPermissions === undefined) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst operationPredicates = this.getRequiredPredicates(fieldNames, fieldPermissions)\n\t\tif (operationPredicates === false) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\treturn this.buildPredicates(entity, operationPredicates, relationContext, isRoot)\n\t}\n\n\tpublic buildPredicates(\n\t\tentity: Model.Entity,\n\t\tpredicates: Acl.PredicateReference[],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name] ?? {}\n\n\t\tconst predicatesWhere: Input.Where[] = predicates.reduce(\n\t\t\t(result: Input.Where[], name: Acl.PredicateReference): Input.Where[] => {\n\t\t\t\tif (!entityPermissions.predicates[name]) {\n\t\t\t\t\tthrow new Error(`${entity.name}: Undefined predicate ${name}`)\n\t\t\t\t}\n\t\t\t\tconst predicateWhere: Input.Where = this.variableInjector.inject(entity, entityPermissions.predicates[name])\n\t\t\t\treturn [...result, predicateWhere]\n\t\t\t},\n\t\t\t[],\n\t\t)\n\t\tif (predicatesWhere.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tconst where: Input.Where = predicatesWhere.length === 1 ? predicatesWhere[0] : { and: predicatesWhere }\n\t\treturn this.optimizePredicates(where, relationContext, isRoot)\n\t}\n\n\tprivate getRequiredPredicates(\n\t\tfieldNames: string[],\n\t\tfieldPermissions: Acl.FieldPermissions,\n\t): Acl.PredicateReference[] | false {\n\t\tconst predicates: Acl.PredicateReference[] = []\n\t\tfor (let name of fieldNames) {\n\t\t\tconst fieldPredicate = fieldPermissions[name]\n\t\t\tif (fieldPredicate === undefined || fieldPredicate === false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (fieldPredicate === true) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!predicates.includes(fieldPredicate)) {\n\t\t\t\tpredicates.push(fieldPredicate)\n\t\t\t}\n\t\t}\n\t\treturn predicates\n\t}\n\n\tpublic optimizePredicates(where: Input.OptionalWhere, relationContext?: Model.AnyRelationContext, isRoot?: boolean) {\n\t\tif (!relationContext || !relationContext.targetRelation) {\n\t\t\treturn where\n\t\t}\n\t\tconst sourcePredicate = this.create(relationContext.entity, Acl.Operation.read, [relationContext.relation.name], undefined, isRoot)\n\t\tif (Object.keys(sourcePredicate).length === 0) {\n\t\t\treturn where\n\t\t}\n\n\t\tconst replacer = new EvaluatedPredicateReplacer(sourcePredicate, relationContext.entity, relationContext.targ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A;AAAA,IAAC;AAEF,QAAI,gBAAgB,WAAW,GAAG;AACjC,aAAO,CAAA;AAAA,IACR;AACA,UAAM,QAAqB,gBAAgB,WAAW,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,gBAAA;AACtF,WAAO,KAAK,mBAAmB,OAAO,iBAAiB,MAAM;AAAA,EAC9D;AAAA,EAEQ,sBACP,YACA,kBACmC;AACnC,UAAM,aAAuC,CAAA;AAC7C,aAAS,QAAQ,YAAY;AAC5B,YAAM,iBAAiB,iBAAiB,IAAI;AAC5C,UAAI,mBAAmB,UAAa,mBAAmB,OAAO;AAC7D,eAAO;AAAA,MACR;AACA,UAAI,mBAAmB,MAAM;AAC5B;AAAA,MACD;AACA,UAAI,CAAC,WAAW,SAAS,cAAc,GAAG;AACzC,mBAAW,KAAK,cAAc;AAAA,MAC/B;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EAEO,mBAAmB,OAA4B,iBAA4C,QAAkB;AACnH,QAAI,CAAC,mBAAmB,CAAC,gBAAgB,gBAAgB;AACxD,aAAO;AAAA,IACR;AACA,UAAM,kBAAkB,KAAK,OAAO,gBAAgB,QAAQA,OAAAA,IAAI,UAAU,MAAM,CAAC,gBAAgB,SAAS,IAAI,GAAG,QAAW,MAAM;AAClI,QAAI,OAAO,KAAK,eAAe,EAAE,WAAW,GAAG;AAC9C,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,IAAIC,sDAA2B,iBAAiB,gBAAgB,QAAQ,gBAAgB,cAAc;AACvH,WAAO,SAAS,QAAQ,KAAK;AAAA,EAC9B;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PredicateFactory.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicateFactory.ts"],"sourcesContent":["import { Acl, Input, Model } from '@contember/schema'\nimport { VariableInjector } from './VariableInjector'\nimport { EvaluatedPredicateReplacer } from './EvaluatedPredicateReplacer'\n\nconst getRowLevelPredicatePseudoField = (entity: Model.Entity) => entity.primary\n\nexport interface FieldRequiredPredicate {\n\tpredicate: Acl.Predicate\n\tisSameAsPrimary: boolean\n}\n\nexport class PredicateFactory {\n\tconstructor(\n\t\tprivate readonly permissions: Acl.Permissions,\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly variableInjector: VariableInjector,\n\t\tprivate readonly allPermissions?: Acl.Permissions,\n\t) {}\n\n\t/**\n\t * Selects the appropriate permission set based on query context:\n\t * - `isRoot === false` (nested/relation context): uses allPermissions (includes through-only permissions)\n\t * - `isRoot === true` or `isRoot === undefined` (root or unknown context): uses root-only permissions\n\t *\n\t * The `undefined` vs `true` distinction matters: `undefined` is the default for callers\n\t * that don't track root context, and must fall through to root permissions for safety.\n\t */\n\tprivate getPermissionsForContext(isRoot?: boolean): Acl.Permissions {\n\t\tif (isRoot === false && this.allPermissions) {\n\t\t\treturn this.allPermissions\n\t\t}\n\t\treturn this.permissions\n\t}\n\n\tpublic getFieldPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): FieldRequiredPredicate {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\tconst predicate = permissions?.[fieldName] ?? false\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\n\t\tconst primaryPredicate = permissions?.[rowLevelField] ?? false\n\t\tconst isSameAsPrimary = predicate === primaryPredicate\n\n\t\treturn {\n\t\t\tisSameAsPrimary,\n\t\t\tpredicate,\n\t\t}\n\t}\n\n\tpublic shouldApplyCellLevelPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.read,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): boolean {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\treturn permissions?.[fieldName] !== permissions?.[rowLevelField]\n\t}\n\n\t/** Delete predicates are not context-aware — through-permission support is scoped to read operations only. */\n\tpublic createDeletePredicate(entity: Model.Entity) {\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\t\tconst entityPermissions = this.permissions[entity.name]\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst deletePredicate = entityPermissions.operations.delete\n\t\tif (deletePredicate === undefined || deletePredicate === false) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tif (deletePredicate === true) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.buildPredicates(entity, [deletePredicate])\n\t}\n\n\tpublic create(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldNames: string[] = [getRowLevelPredicatePseudoField(entity)],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name]\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\tif (fieldNames === undefined) {\n\t\t\tfieldNames = [getRowLevelPredicatePseudoField(entity)]\n\t\t}\n\t\tconst fieldPermissions = entityPermissions.operations[operation]\n\t\tif (fieldPermissions === undefined) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst operationPredicates = this.getRequiredPredicates(fieldNames, fieldPermissions)\n\t\tif (operationPredicates === false) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\treturn this.buildPredicates(entity, operationPredicates, relationContext, isRoot)\n\t}\n\n\tpublic buildPredicates(\n\t\tentity: Model.Entity,\n\t\tpredicates: Acl.PredicateReference[],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name] ?? {}\n\n\t\tconst predicatesWhere: Input.Where[] = predicates.reduce(\n\t\t\t(result: Input.Where[], name: Acl.PredicateReference): Input.Where[] => {\n\t\t\t\tif (!entityPermissions.predicates[name]) {\n\t\t\t\t\tthrow new Error(`${entity.name}: Undefined predicate ${name}`)\n\t\t\t\t}\n\t\t\t\tconst predicateWhere: Input.Where = this.variableInjector.inject(entity, entityPermissions.predicates[name])\n\t\t\t\treturn [...result, predicateWhere]\n\t\t\t},\n\t\t\t[],\n\t\t)\n\t\tif (predicatesWhere.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tconst where: Input.Where = predicatesWhere.length === 1 ? predicatesWhere[0] : { and: predicatesWhere }\n\t\treturn this.optimizePredicates(where, relationContext, isRoot)\n\t}\n\n\tprivate getRequiredPredicates(\n\t\tfieldNames: string[],\n\t\tfieldPermissions: Acl.FieldPermissions,\n\t): Acl.PredicateReference[] | false {\n\t\tconst predicates: Acl.PredicateReference[] = []\n\t\tfor (let name of fieldNames) {\n\t\t\tconst fieldPredicate = fieldPermissions[name]\n\t\t\tif (fieldPredicate === undefined || fieldPredicate === false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (fieldPredicate === true) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!predicates.includes(fieldPredicate)) {\n\t\t\t\tpredicates.push(fieldPredicate)\n\t\t\t}\n\t\t}\n\t\treturn predicates\n\t}\n\n\tpublic optimizePredicates(where: Input.OptionalWhere, relationContext?: Model.AnyRelationContext, isRoot?: boolean) {\n\t\tif (!relationContext || !relationContext.targetRelation) {\n\t\t\treturn where\n\t\t}\n\t\tconst sourcePredicate = this.create(relationContext.entity, Acl.Operation.read, [relationContext.relation.name], undefined, isRoot)\n\t\tif (Object.keys(sourcePredicate).length === 0) {\n\t\t\treturn where\n\t\t}\n\n\t\tconst replacer = new EvaluatedPredicateReplacer(sourcePredicate, relationContext.entity, relationContext.targetRelation)\n\t\treturn replacer.replace(where)\n\t}\n}\n"],"names":[],"mappings":";;AAIA,MAAM,kCAAkC,CAAC,WAAyB,OAAO;AAOlE,MAAM,iBAAiB;AAAA,EAC7B,YACkB,aACA,OACA,kBACA,gBAChB;AAJgB,SAAA,cAAA;AACA,SAAA,QAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUK,yBAAyB,QAAmC;AACnE,QAAI,WAAW,SAAS,KAAK,gBAAgB;AAC5C,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,kBACN,QACA,WACA,WACA,QACyB;AACzB,UAAM,QAAQ,KAAK,yBAAyB,MAAM;AAClD,UAAM,cAAc,MAAM,OAAO,IAAI,GAAG,aAAa,SAAS;AAC9D,UAAM,YAAY,cAAc,SAAS,KAAK;AAC9C,UAAM,gBAAgB,gCAAgC,MAAM;AAE5D,UAAM,mBAAmB,cAAc,aAAa,KAAK;AACzD,UAAM,kBAAkB,cAAc;AAEtC,WAAO;AAAA,MACN;AAAA,MACA;AAAA,IAAA;AAAA,EAEF;AAAA,EAEO,8BACN,QACA,WACA,WACA,QACU;AACV,UAAM,QAAQ,KAAK,yBAAyB,MAAM;AAClD,UAAM,gBAAgB,gCAAgC,MAAM;AAC5D,UAAM,cAAc,MAAM,OAAO,IAAI,GAAG,aAAa,SAAS;AAC9D,WAAO,cAAc,SAAS,MAAM,cAAc,aAAa;AAAA,EAChE;AAAA;AAAA,EAGO,sBAAsB,QAAsB;AAClD,UAAM,iBAA8B,EAAE,CAAC,OAAO,OAAO,GAAG,EAAE,OAAO,OAAK;AACtE,UAAM,oBAAoB,KAAK,YAAY,OAAO,IAAI;AACtD,QAAI,CAAC,mBAAmB;AACvB,aAAO;AAAA,IACR;AACA,UAAM,kBAAkB,kBAAkB,WAAW;AACrD,QAAI,oBAAo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,IAAC;AAEF,QAAI,gBAAgB,WAAW,GAAG;AACjC,aAAO,CAAA;AAAA,IACR;AACA,UAAM,QAAqB,gBAAgB,WAAW,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,gBAAA;AACtF,WAAO,KAAK,mBAAmB,OAAO,iBAAiB,MAAM;AAAA,EAC9D;AAAA,EAEQ,sBACP,YACA,kBACmC;AACnC,UAAM,aAAuC,CAAA;AAC7C,aAAS,QAAQ,YAAY;AAC5B,YAAM,iBAAiB,iBAAiB,IAAI;AAC5C,UAAI,mBAAmB,UAAa,mBAAmB,OAAO;AAC7D,eAAO;AAAA,MACR;AACA,UAAI,mBAAmB,MAAM;AAC5B;AAAA,MACD;AACA,UAAI,CAAC,WAAW,SAAS,cAAc,GAAG;AACzC,mBAAW,KAAK,cAAc;AAAA,MAC/B;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EAEO,mBAAmB,OAA4B,iBAA4C,QAAkB;AACnH,QAAI,CAAC,mBAAmB,CAAC,gBAAgB,gBAAgB;AACxD,aAAO;AAAA,IACR;AACA,UAAM,kBAAkB,KAAK,OAAO,gBAAgB,QAAQ,IAAI,UAAU,MAAM,CAAC,gBAAgB,SAAS,IAAI,GAAG,QAAW,MAAM;AAClI,QAAI,OAAO,KAAK,eAAe,EAAE,WAAW,GAAG;AAC9C,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,IAAI,2BAA2B,iBAAiB,gBAAgB,QAAQ,gBAAgB,cAAc;AACvH,WAAO,SAAS,QAAQ,KAAK;AAAA,EAC9B;AACD;"}
|
|
1
|
+
{"version":3,"file":"PredicateFactory.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicateFactory.ts"],"sourcesContent":["import { Acl, Input, Model } from '@contember/schema'\nimport { VariableInjector } from './VariableInjector.js'\nimport { EvaluatedPredicateReplacer } from './EvaluatedPredicateReplacer.js'\n\nconst getRowLevelPredicatePseudoField = (entity: Model.Entity) => entity.primary\n\nexport interface FieldRequiredPredicate {\n\tpredicate: Acl.Predicate\n\tisSameAsPrimary: boolean\n}\n\nexport class PredicateFactory {\n\tconstructor(\n\t\tprivate readonly permissions: Acl.Permissions,\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly variableInjector: VariableInjector,\n\t\tprivate readonly allPermissions?: Acl.Permissions,\n\t) {}\n\n\t/**\n\t * Selects the appropriate permission set based on query context:\n\t * - `isRoot === false` (nested/relation context): uses allPermissions (includes through-only permissions)\n\t * - `isRoot === true` or `isRoot === undefined` (root or unknown context): uses root-only permissions\n\t *\n\t * The `undefined` vs `true` distinction matters: `undefined` is the default for callers\n\t * that don't track root context, and must fall through to root permissions for safety.\n\t */\n\tprivate getPermissionsForContext(isRoot?: boolean): Acl.Permissions {\n\t\tif (isRoot === false && this.allPermissions) {\n\t\t\treturn this.allPermissions\n\t\t}\n\t\treturn this.permissions\n\t}\n\n\tpublic getFieldPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): FieldRequiredPredicate {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\tconst predicate = permissions?.[fieldName] ?? false\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\n\t\tconst primaryPredicate = permissions?.[rowLevelField] ?? false\n\t\tconst isSameAsPrimary = predicate === primaryPredicate\n\n\t\treturn {\n\t\t\tisSameAsPrimary,\n\t\t\tpredicate,\n\t\t}\n\t}\n\n\tpublic shouldApplyCellLevelPredicate(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.read,\n\t\tfieldName: string,\n\t\tisRoot?: boolean,\n\t): boolean {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst rowLevelField = getRowLevelPredicatePseudoField(entity)\n\t\tconst permissions = perms[entity.name]?.operations?.[operation]\n\t\treturn permissions?.[fieldName] !== permissions?.[rowLevelField]\n\t}\n\n\t/** Delete predicates are not context-aware — through-permission support is scoped to read operations only. */\n\tpublic createDeletePredicate(entity: Model.Entity) {\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\t\tconst entityPermissions = this.permissions[entity.name]\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst deletePredicate = entityPermissions.operations.delete\n\t\tif (deletePredicate === undefined || deletePredicate === false) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tif (deletePredicate === true) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.buildPredicates(entity, [deletePredicate])\n\t}\n\n\tpublic create(\n\t\tentity: Model.Entity,\n\t\toperation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,\n\t\tfieldNames: string[] = [getRowLevelPredicatePseudoField(entity)],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name]\n\t\tconst neverCondition: Input.Where = { [entity.primary]: { never: true } }\n\n\t\tif (!entityPermissions) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\tif (fieldNames === undefined) {\n\t\t\tfieldNames = [getRowLevelPredicatePseudoField(entity)]\n\t\t}\n\t\tconst fieldPermissions = entityPermissions.operations[operation]\n\t\tif (fieldPermissions === undefined) {\n\t\t\treturn neverCondition\n\t\t}\n\t\tconst operationPredicates = this.getRequiredPredicates(fieldNames, fieldPermissions)\n\t\tif (operationPredicates === false) {\n\t\t\treturn neverCondition\n\t\t}\n\n\t\treturn this.buildPredicates(entity, operationPredicates, relationContext, isRoot)\n\t}\n\n\tpublic buildPredicates(\n\t\tentity: Model.Entity,\n\t\tpredicates: Acl.PredicateReference[],\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst perms = this.getPermissionsForContext(isRoot)\n\t\tconst entityPermissions: Acl.EntityPermissions = perms[entity.name] ?? {}\n\n\t\tconst predicatesWhere: Input.Where[] = predicates.reduce(\n\t\t\t(result: Input.Where[], name: Acl.PredicateReference): Input.Where[] => {\n\t\t\t\tif (!entityPermissions.predicates[name]) {\n\t\t\t\t\tthrow new Error(`${entity.name}: Undefined predicate ${name}`)\n\t\t\t\t}\n\t\t\t\tconst predicateWhere: Input.Where = this.variableInjector.inject(entity, entityPermissions.predicates[name])\n\t\t\t\treturn [...result, predicateWhere]\n\t\t\t},\n\t\t\t[],\n\t\t)\n\t\tif (predicatesWhere.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tconst where: Input.Where = predicatesWhere.length === 1 ? predicatesWhere[0] : { and: predicatesWhere }\n\t\treturn this.optimizePredicates(where, relationContext, isRoot)\n\t}\n\n\tprivate getRequiredPredicates(\n\t\tfieldNames: string[],\n\t\tfieldPermissions: Acl.FieldPermissions,\n\t): Acl.PredicateReference[] | false {\n\t\tconst predicates: Acl.PredicateReference[] = []\n\t\tfor (let name of fieldNames) {\n\t\t\tconst fieldPredicate = fieldPermissions[name]\n\t\t\tif (fieldPredicate === undefined || fieldPredicate === false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (fieldPredicate === true) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!predicates.includes(fieldPredicate)) {\n\t\t\t\tpredicates.push(fieldPredicate)\n\t\t\t}\n\t\t}\n\t\treturn predicates\n\t}\n\n\tpublic optimizePredicates(where: Input.OptionalWhere, relationContext?: Model.AnyRelationContext, isRoot?: boolean) {\n\t\tif (!relationContext || !relationContext.targetRelation) {\n\t\t\treturn where\n\t\t}\n\t\tconst sourcePredicate = this.create(relationContext.entity, Acl.Operation.read, [relationContext.relation.name], undefined, isRoot)\n\t\tif (Object.keys(sourcePredicate).length === 0) {\n\t\t\treturn where\n\t\t}\n\n\t\tconst replacer = new EvaluatedPredicateReplacer(sourcePredicate, relationContext.entity, relationContext.targetRelation)\n\t\treturn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GAAG;AACjC,aAAO,CAAA;AAAA,IACR;AACA,UAAM,QAAqB,gBAAgB,WAAW,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,gBAAA;AACtF,WAAO,KAAK,mBAAmB,OAAO,iBAAiB,MAAM;AAAA,EAC9D;AAAA,EAEQ,sBACP,YACA,kBACmC;AACnC,UAAM,aAAuC,CAAA;AAC7C,aAAS,QAAQ,YAAY;AAC5B,YAAM,iBAAiB,iBAAiB,IAAI;AAC5C,UAAI,mBAAmB,UAAa,mBAAmB,OAAO;AAC7D,eAAO;AAAA,MACR;AACA,UAAI,mBAAmB,MAAM;AAC5B;AAAA,MACD;AACA,UAAI,CAAC,WAAW,SAAS,cAAc,GAAG;AACzC,mBAAW,KAAK,cAAc;AAAA,MAC/B;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EAEO,mBAAmB,OAA4B,iBAA4C,QAAkB;AACnH,QAAI,CAAC,mBAAmB,CAAC,gBAAgB,gBAAgB;AACxD,aAAO;AAAA,IACR;AACA,UAAM,kBAAkB,KAAK,OAAO,gBAAgB,QAAQ,IAAI,UAAU,MAAM,CAAC,gBAAgB,SAAS,IAAI,GAAG,QAAW,MAAM;AAClI,QAAI,OAAO,KAAK,eAAe,EAAE,WAAW,GAAG;AAC9C,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,IAAI,2BAA2B,iBAAiB,gBAAgB,QAAQ,gBAAgB,cAAc;AACvH,WAAO,SAAS,QAAQ,KAAK;AAAA,EAC9B;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PredicatesInjector.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tpredicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t}\n}\n"],"names":["schema","Acl","acceptFieldVisitor"],"mappings":";;;;AAIO,MAAM,mBAAmB;AAAA,EAC/B,YAA6BA,SAAuC,kBAAoC;AAA3E,SAAA,SAAAA;AAAuC,SAAA,mBAAA;AAAA,EAAqC;AAAA,EAElG,OACN,QACA,OACA,iBACA,cACsB;AACtB,UAAM,cAAc,CAAC,oBAAoB,CAAC,gBAAgB,aAAa,WAAW;AAClF,UAAM,kBAAkB,KAAK,cAAc,OAAO,QAAQ,MAAM,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AACvH,WAAO,KAAK,YAAY,QAAQ,QAAW,iBAAiB,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AAAA,EACpH;AAAA;AAAA;AAAA;AAAA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IAAI,QAAQ,QAAQ,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,MAAA;AAAA,IAE3G;AACA,QAAI,MAAM,KAAK;AACd,kBAAY,MAAM,KAAK,cAAc,MAAM,KAAK,QAAQ,QAAQ,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,IACnI;AAEA,UAAM,SAAS,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,CAAC,CAAC,OAAO,MAAM,KAAK,EAAE,SAAS,EAAE,CAAC;AAEjF,QAAI,OAAO,WAAW,GAAG;AACxB,aAAO;AAAA,IACR;AACA,aAAS,SAAS,QAAQ;AACzB,kBAAY,KAAK,IAAIC,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,OAAO;AAAA,QACnE,aAAa,MAAM,MAAM,KAAK;AAAA,QAC9B,eAAe,CAAA,YAAW;AACzB,gBAAM,gBAAgB,MAAM,KAAK;AACjC,cAAI,kBAAkB,MAAM;AAC3B,mBAAO;AAAA,UACR;AAEA,gBAAM,kBAAkB,KAAK,2BAA2B,cAAc,QAAQ,SAAS,MAAM,QAAQ,OAAO,IAAI,MAAM;AAEtH,gBAAM,+BAA+B,mBAAmB;AAExD,gBAAM,qBAAiD,CAAC,GAAG,cAAc,OAAO;AAChF,iBAAO,KAAK,cAAc,eAAe,QAAQ,cAAc,OAAO,SAAS,8BAA8B,oBAAoB,WAAW;AAAA,QAC7I;AAAA,MAAA,CACA;AAAA,IACF;AACA,UAAM,qBAAqB,CAAC,SACzB,SACA,OAAO,OAAO,CAAA,OAAM,KAAK,iBAAiB,8BAA8B,QAAQD,OAAAA,IAAI,UAAU,MAAM,IAAI,WAAW,CAAC;AAEvH,WAAO,KAAK,YAAY,QAAQ,oBAAoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;;"}
|
|
1
|
+
{"version":3,"file":"PredicatesInjector.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tpredicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t}\n}\n"],"names":["schema","Acl","acceptFieldVisitor"],"mappings":";;;;AAIO,MAAM,mBAAmB;AAAA,EAC/B,YAA6BA,SAAuC,kBAAoC;AAA3E,SAAA,SAAAA;AAAuC,SAAA,mBAAA;AAAA,EAAqC;AAAA,EAElG,OACN,QACA,OACA,iBACA,cACsB;AACtB,UAAM,cAAc,CAAC,oBAAoB,CAAC,gBAAgB,aAAa,WAAW;AAClF,UAAM,kBAAkB,KAAK,cAAc,OAAO,QAAQ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AoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PredicatesInjector.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tpredicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,mBAAmB;AAAA,EAC/B,YAA6B,QAAuC,kBAAoC;AAA3E,SAAA,SAAA;AAAuC,SAAA,mB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,CAAC,SACzB,SACA,OAAO,OAAO,CAAA,OAAM,KAAK,iBAAiB,8BAA8B,QAAQ,IAAI,UAAU,MAAM,IAAI,WAAW,CAAC;AAEvH,WAAO,KAAK,YAAY,QAAQ,oBAAoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;"}
|
|
1
|
+
{"version":3,"file":"PredicatesInjector.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tpredicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryR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AAK,cAAc,eAAe,QAAQ,cAAc,OAAO,SAAS,8BAA8B,oBAAoB,WAAW;AAAA,QAC7I;AAAA,MAAA,CACA;AAAA,IACF;AACA,UAAM,qBAAqB,CAAC,SACzB,SACA,OAAO,OAAO,CAAA,OAAM,KAAK,iBAAiB,8BAA8B,QAAQ,IAAI,UAAU,MAAM,IAAI,WAAW,CAAC;AAEvH,WAAO,KAAK,YAAY,QAAQ,oBAAoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;"}
|
package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneReducer.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.ts"],"sourcesContent":["import { EntityFieldsProvider, FieldMap } from '../EntityFieldsProvider'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Model } from '@contember/schema'\nimport { HasManyToHasOneRelationReducerFieldVisitor } from './HasManyToHasOneRelationReducerVisitor'\n\nexport class HasManyToHasOneReducer implements EntityFieldsProvider<HasManyToHasOneReducerExtension> {\n\tstatic extensionName: string = 'HasManyToHasOneReducer'\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly visitor: HasManyToHasOneRelationReducerFieldVisitor,\n\t) {}\n\n\tgetFields(entity: Model.Entity, accessibleFields: Model.AnyField[]): FieldMap<HasManyToHasOneReducerExtension> {\n\t\tconst fieldMap: FieldMap<HasManyToHasOneReducerExtension> = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tif (field.type !== Model.RelationType.OneHasMany) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor (const [name, resultField] of acceptFieldVisitor(this.schema, entity, field, this.visitor)) {\n\t\t\t\tfieldMap[name] = resultField\n\t\t\t}\n\t\t}\n\t\treturn fieldMap\n\t}\n}\n\nexport interface HasManyToHasOneReducerExtension {\n\trelationName: string\n}\n"],"names":["schema","Model","acceptFieldVisitor"],"mappings":";;;;;;;AAKO,MAAM,uBAAwF;AAAA,EAGpG,YACkBA,SACA,SAChB;AAFgB,SAAA,SAAAA;AACA,SAAA,UAAA;AAAA,EACf;AAAA,EAEH,UAAU,QAAsB,kBAA+E;AAC9G,UAAM,WAAsD,CAAA;AAC5D,eAAW,SAAS,kBAAkB;AACrC,UAAI,MAAM,SAASC,aAAM,aAAa,YAAY;AACjD;AAAA,MACD;AAEA,iBAAW,CAAC,MAAM,WAAW,KAAKC,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,OAAO,KAAK,OAAO,GAAG;AAC/F,iBAAS,IAAI,IAAI;AAAA,MAClB;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AApBC,cADY,wBACL,iBAAwB,wBAAA;;"}
|
|
1
|
+
{"version":3,"file":"HasManyToHasOneReducer.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.ts"],"sourcesContent":["import { EntityFieldsProvider, FieldMap } from '../EntityFieldsProvider.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Model } from '@contember/schema'\nimport { HasManyToHasOneRelationReducerFieldVisitor } from './HasManyToHasOneRelationReducerVisitor.js'\n\nexport class HasManyToHasOneReducer implements EntityFieldsProvider<HasManyToHasOneReducerExtension> {\n\tstatic extensionName: string = 'HasManyToHasOneReducer'\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly visitor: HasManyToHasOneRelationReducerFieldVisitor,\n\t) {}\n\n\tgetFields(entity: Model.Entity, accessibleFields: Model.AnyField[]): FieldMap<HasManyToHasOneReducerExtension> {\n\t\tconst fieldMap: FieldMap<HasManyToHasOneReducerExtension> = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tif (field.type !== Model.RelationType.OneHasMany) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor (const [name, resultField] of acceptFieldVisitor(this.schema, entity, field, this.visitor)) {\n\t\t\t\tfieldMap[name] = resultField\n\t\t\t}\n\t\t}\n\t\treturn fieldMap\n\t}\n}\n\nexport interface HasManyToHasOneReducerExtension {\n\trelationName: string\n}\n"],"names":["schema","Model","acceptFieldVisitor"],"mappings":";;;;;;;AAKO,MAAM,uBAAwF;AAAA,EAGpG,YACkBA,SACA,SAChB;AAFgB,SAAA,SAAAA;AACA,SAAA,UAAA;AAAA,EACf;AAAA,EAEH,UAAU,QAAsB,kBAA+E;AAC9G,UAAM,WAAsD,CAAA;AAC5D,eAAW,SAAS,kBAAkB;AACrC,UAAI,MAAM,SAASC,aAAM,aAAa,YAAY;AACjD;AAAA,MACD;AAEA,iBAAW,CAAC,MAAM,WAAW,KAAKC,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,OAAO,KAAK,OAAO,GAAG;AAC/F,iBAAS,IAAI,IAAI;AAAA,MAClB;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AApBC,cADY,wBACL,iBAAwB,wBAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneReducer.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.ts"],"sourcesContent":["import { EntityFieldsProvider, FieldMap } from '../EntityFieldsProvider'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Model } from '@contember/schema'\nimport { HasManyToHasOneRelationReducerFieldVisitor } from './HasManyToHasOneRelationReducerVisitor'\n\nexport class HasManyToHasOneReducer implements EntityFieldsProvider<HasManyToHasOneReducerExtension> {\n\tstatic extensionName: string = 'HasManyToHasOneReducer'\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly visitor: HasManyToHasOneRelationReducerFieldVisitor,\n\t) {}\n\n\tgetFields(entity: Model.Entity, accessibleFields: Model.AnyField[]): FieldMap<HasManyToHasOneReducerExtension> {\n\t\tconst fieldMap: FieldMap<HasManyToHasOneReducerExtension> = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tif (field.type !== Model.RelationType.OneHasMany) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor (const [name, resultField] of acceptFieldVisitor(this.schema, entity, field, this.visitor)) {\n\t\t\t\tfieldMap[name] = resultField\n\t\t\t}\n\t\t}\n\t\treturn fieldMap\n\t}\n}\n\nexport interface HasManyToHasOneReducerExtension {\n\trelationName: string\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,uBAAwF;AAAA,EAGpG,YACkB,QACA,SAChB;AAFgB,SAAA,SAAA;AACA,SAAA,UAAA;AAAA,EACf;AAAA,EAEH,UAAU,QAAsB,kBAA+E;AAC9G,UAAM,WAAsD,CAAA;AAC5D,eAAW,SAAS,kBAAkB;AACrC,UAAI,MAAM,SAAS,MAAM,aAAa,YAAY;AACjD;AAAA,MACD;AAEA,iBAAW,CAAC,MAAM,WAAW,KAAK,mBAAmB,KAAK,QAAQ,QAAQ,OAAO,KAAK,OAAO,GAAG;AAC/F,iBAAS,IAAI,IAAI;AAAA,MAClB;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AApBC,cADY,wBACL,iBAAwB,wBAAA;"}
|
|
1
|
+
{"version":3,"file":"HasManyToHasOneReducer.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.ts"],"sourcesContent":["import { EntityFieldsProvider, FieldMap } from '../EntityFieldsProvider.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Model } from '@contember/schema'\nimport { HasManyToHasOneRelationReducerFieldVisitor } from './HasManyToHasOneRelationReducerVisitor.js'\n\nexport class HasManyToHasOneReducer implements EntityFieldsProvider<HasManyToHasOneReducerExtension> {\n\tstatic extensionName: string = 'HasManyToHasOneReducer'\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly visitor: HasManyToHasOneRelationReducerFieldVisitor,\n\t) {}\n\n\tgetFields(entity: Model.Entity, accessibleFields: Model.AnyField[]): FieldMap<HasManyToHasOneReducerExtension> {\n\t\tconst fieldMap: FieldMap<HasManyToHasOneReducerExtension> = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tif (field.type !== Model.RelationType.OneHasMany) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor (const [name, resultField] of acceptFieldVisitor(this.schema, entity, field, this.visitor)) {\n\t\t\t\tfieldMap[name] = resultField\n\t\t\t}\n\t\t}\n\t\treturn fieldMap\n\t}\n}\n\nexport interface HasManyToHasOneReducerExtension {\n\trelationName: string\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,uBAAwF;AAAA,EAGpG,YACkB,QACA,SAChB;AAFgB,SAAA,SAAA;AACA,SAAA,UAAA;AAAA,EACf;AAAA,EAEH,UAAU,QAAsB,kBAA+E;AAC9G,UAAM,WAAsD,CAAA;AAC5D,eAAW,SAAS,kBAAkB;AACrC,UAAI,MAAM,SAAS,MAAM,aAAa,YAAY;AACjD;AAAA,MACD;AAEA,iBAAW,CAAC,MAAM,WAAW,KAAK,mBAAmB,KAAK,QAAQ,QAAQ,OAAO,KAAK,OAAO,GAAG;AAC/F,iBAAS,IAAI,IAAI;AAAA,MAClB;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AApBC,cADY,wBACL,iBAAwB,wBAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneReducerExecutionHandler.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { isIt } from '../../utils'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper'\nimport { ImplementationException } from '../../exception'\nimport { UniqueWhereExpander } from '../../inputProcessing'\nimport { HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\n\nexport class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHandler<Input.UniqueQueryInput, HasManyToHasOneReducerExtension> {\n\tconstructor(private readonly schema: Model.Schema, private readonly uniqueWhereExpander: UniqueWhereExpander) {}\n\n\tprocess(context: SelectExecutionHandlerContext<Input.UniqueQueryInput, HasManyToHasOneReducerExtension>): void {\n\t\tconst { addData, entity, objectNode } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\taddData({\n\t\t\tfield: entity.primary,\n\t\t\tdataProvider: async (ids: Input.PrimaryValue[]) => {\n\t\t\t\tconst relationContext = acceptFieldVisitor(this.schema, entity, objectNode.extensions.relationName, {\n\t\t\t\t\tvisitRelation: context => context,\n\t\t\t\t\tvisitColumn: (): never => {\n\t\t\t\t\t\tthrow new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst { targetEntity, targetRelation } = relationContext\n\t\t\t\tif (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')\n\t\t\t\t}\n\n\t\t\t\tconst uniqueWhere = this.uniqueWhereExpander.expand(targetEntity, {\n\t\t\t\t\t...objectNode.args.by,\n\t\t\t\t\t[targetRelation.name]: { [entity.primary]: ids },\n\t\t\t\t})\n\t\t\t\tif (Object.keys(uniqueWhere).length !== 2) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only tuple unique keys are allowed')\n\t\t\t\t}\n\t\t\t\tconst whereWithParentId = {\n\t\t\t\t\tand: [objectNode.args.filter || {}, uniqueWhere],\n\t\t\t\t}\n\t\t\t\tconst newObjectNode = objectNode.withArgs<Input.ListQueryInput>({ filter: whereWithParentId })\n\n\t\t\t\treturn context.mapper.selectAssoc(targetEntity, newObjectNode, [\n\t\t\t\t\t...context.relationPath,\n\t\t\t\t\trelationContext,\n\t\t\t\t], targetRelation.name)\n\t\t\t},\n\t\t\tdefaultValue: null,\n\t\t})\n\t}\n}\n"],"names":["acceptFieldVisitor","context","ImplementationException","isIt"],"mappings":";;;;;AAQO,MAAM,uCAAkI;AAAA,EAC9I,YAA6B,QAAuC,qBAA0C;AAAjF,SAAA,SAAA;AAAuC,SAAA,sBAAA;AAAA,EAA2C;AAAA,EAE/G,QAAQ,SAAuG;AAC9G,UAAM,EAAE,SAAS,QAAQ,WAAA,IAAe;AACxC,QAAI,CAAC,YAAY;AAChB,YAAM,IAAI,MAAA;AAAA,IACX;AACA,YAAQ;AAAA,MACP,OAAO,OAAO;AAAA,MACd,cAAc,OAAO,QAA8B;AAClD,cAAM,kBAAkBA,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,WAAW,WAAW,cAAc;AAAA,UACnG,eAAe,CAAAC,aAAWA;AAAAA,UAC1B,aAAa,MAAa;AACzB,kBAAM,IAAIC,UAAAA,wBAAwB,qEAAqE;AAAA,UACxG;AAAA,QAAA,CACA;AAED,cAAM,EAAE,cAAc,eAAA,IAAmB;AACzC,YAAI,CAAC,kBAAkB,CAACC,KAAAA,KAAkC,gBAAgB,eAAe,GAAG;AAC3F,gBAAM,IAAI,MAAM,0FAA0F;AAAA,QAC3G;AAEA,cAAM,cAAc,KAAK,oBAAoB,OAAO,cAAc;AAAA,UACjE,GAAG,WAAW,KAAK;AAAA,UACnB,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,IAAA;AAAA,QAAI,CAC/C;AACD,YAAI,OAAO,KAAK,WAAW,EAAE,WAAW,GAAG;AAC1C,gBAAM,IAAI,MAAM,4EAA4E;AAAA,QAC7F;AACA,cAAM,oBAAoB;AAAA,UACzB,KAAK,CAAC,WAAW,KAAK,UAAU,CAAA,GAAI,WAAW;AAAA,QAAA;AAEhD,cAAM,gBAAgB,WAAW,SAA+B,EAAE,QAAQ,mBAAmB;AAE7F,eAAO,QAAQ,OAAO,YAAY,cAAc,eAAe;AAAA,UAC9D,GAAG,QAAQ;AAAA,UACX;AAAA,QAAA,GACE,eAAe,IAAI;AAAA,MACvB;AAAA,MACA,cAAc;AAAA,IAAA,CACd;AAAA,EACF;AACD;;"}
|
|
1
|
+
{"version":3,"file":"HasManyToHasOneReducerExecutionHandler.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { isIt } from '../../utils/index.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper/index.js'\nimport { ImplementationException } from '../../exception.js'\nimport { UniqueWhereExpander } from '../../inputProcessing/index.js'\nimport { HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer.js'\n\nexport class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHandler<Input.UniqueQueryInput, HasManyToHasOneReducerExtension> {\n\tconstructor(private readonly schema: Model.Schema, private readonly uniqueWhereExpander: UniqueWhereExpander) {}\n\n\tprocess(context: SelectExecutionHandlerContext<Input.UniqueQueryInput, HasManyToHasOneReducerExtension>): void {\n\t\tconst { addData, entity, objectNode } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\taddData({\n\t\t\tfield: entity.primary,\n\t\t\tdataProvider: async (ids: Input.PrimaryValue[]) => {\n\t\t\t\tconst relationContext = acceptFieldVisitor(this.schema, entity, objectNode.extensions.relationName, {\n\t\t\t\t\tvisitRelation: context => context,\n\t\t\t\t\tvisitColumn: (): never => {\n\t\t\t\t\t\tthrow new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst { targetEntity, targetRelation } = relationContext\n\t\t\t\tif (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')\n\t\t\t\t}\n\n\t\t\t\tconst uniqueWhere = this.uniqueWhereExpander.expand(targetEntity, {\n\t\t\t\t\t...objectNode.args.by,\n\t\t\t\t\t[targetRelation.name]: { [entity.primary]: ids },\n\t\t\t\t})\n\t\t\t\tif (Object.keys(uniqueWhere).length !== 2) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only tuple unique keys are allowed')\n\t\t\t\t}\n\t\t\t\tconst whereWithParentId = {\n\t\t\t\t\tand: [objectNode.args.filter || {}, uniqueWhere],\n\t\t\t\t}\n\t\t\t\tconst newObjectNode = objectNode.withArgs<Input.ListQueryInput>({ filter: whereWithParentId })\n\n\t\t\t\treturn context.mapper.selectAssoc(targetEntity, newObjectNode, [\n\t\t\t\t\t...context.relationPath,\n\t\t\t\t\trelationContext,\n\t\t\t\t], targetRelation.name)\n\t\t\t},\n\t\t\tdefaultValue: null,\n\t\t})\n\t}\n}\n"],"names":["acceptFieldVisitor","context","ImplementationException","isIt"],"mappings":";;;;;AAQO,MAAM,uCAAkI;AAAA,EAC9I,YAA6B,QAAuC,qBAA0C;AAAjF,SAAA,SAAA;AAAuC,SAAA,sBAAA;AAAA,EAA2C;AAAA,EAE/G,QAAQ,SAAuG;AAC9G,UAAM,EAAE,SAAS,QAAQ,WAAA,IAAe;AACxC,QAAI,CAAC,YAAY;AAChB,YAAM,IAAI,MAAA;AAAA,IACX;AACA,YAAQ;AAAA,MACP,OAAO,OAAO;AAAA,MACd,cAAc,OAAO,QAA8B;AAClD,cAAM,kBAAkBA,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,WAAW,WAAW,cAAc;AAAA,UACnG,eAAe,CAAAC,aAAWA;AAAAA,UAC1B,aAAa,MAAa;AACzB,kBAAM,IAAIC,UAAAA,wBAAwB,qEAAqE;AAAA,UACxG;AAAA,QAAA,CACA;AAED,cAAM,EAAE,cAAc,eAAA,IAAmB;AACzC,YAAI,CAAC,kBAAkB,CAACC,KAAAA,KAAkC,gBAAgB,eAAe,GAAG;AAC3F,gBAAM,IAAI,MAAM,0FAA0F;AAAA,QAC3G;AAEA,cAAM,cAAc,KAAK,oBAAoB,OAAO,cAAc;AAAA,UACjE,GAAG,WAAW,KAAK;AAAA,UACnB,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,IAAA;AAAA,QAAI,CAC/C;AACD,YAAI,OAAO,KAAK,WAAW,EAAE,WAAW,GAAG;AAC1C,gBAAM,IAAI,MAAM,4EAA4E;AAAA,QAC7F;AACA,cAAM,oBAAoB;AAAA,UACzB,KAAK,CAAC,WAAW,KAAK,UAAU,CAAA,GAAI,WAAW;AAAA,QAAA;AAEhD,cAAM,gBAAgB,WAAW,SAA+B,EAAE,QAAQ,mBAAmB;AAE7F,eAAO,QAAQ,OAAO,YAAY,cAAc,eAAe;AAAA,UAC9D,GAAG,QAAQ;AAAA,UACX;AAAA,QAAA,GACE,eAAe,IAAI;AAAA,MACvB;AAAA,MACA,cAAc;AAAA,IAAA,CACd;AAAA,EACF;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneReducerExecutionHandler.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { isIt } from '../../utils'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper'\nimport { ImplementationException } from '../../exception'\nimport { UniqueWhereExpander } from '../../inputProcessing'\nimport { HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\n\nexport class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHandler<Input.UniqueQueryInput, HasManyToHasOneReducerExtension> {\n\tconstructor(private readonly schema: Model.Schema, private readonly uniqueWhereExpander: UniqueWhereExpander) {}\n\n\tprocess(context: SelectExecutionHandlerContext<Input.UniqueQueryInput, HasManyToHasOneReducerExtension>): void {\n\t\tconst { addData, entity, objectNode } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\taddData({\n\t\t\tfield: entity.primary,\n\t\t\tdataProvider: async (ids: Input.PrimaryValue[]) => {\n\t\t\t\tconst relationContext = acceptFieldVisitor(this.schema, entity, objectNode.extensions.relationName, {\n\t\t\t\t\tvisitRelation: context => context,\n\t\t\t\t\tvisitColumn: (): never => {\n\t\t\t\t\t\tthrow new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst { targetEntity, targetRelation } = relationContext\n\t\t\t\tif (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')\n\t\t\t\t}\n\n\t\t\t\tconst uniqueWhere = this.uniqueWhereExpander.expand(targetEntity, {\n\t\t\t\t\t...objectNode.args.by,\n\t\t\t\t\t[targetRelation.name]: { [entity.primary]: ids },\n\t\t\t\t})\n\t\t\t\tif (Object.keys(uniqueWhere).length !== 2) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only tuple unique keys are allowed')\n\t\t\t\t}\n\t\t\t\tconst whereWithParentId = {\n\t\t\t\t\tand: [objectNode.args.filter || {}, uniqueWhere],\n\t\t\t\t}\n\t\t\t\tconst newObjectNode = objectNode.withArgs<Input.ListQueryInput>({ filter: whereWithParentId })\n\n\t\t\t\treturn context.mapper.selectAssoc(targetEntity, newObjectNode, [\n\t\t\t\t\t...context.relationPath,\n\t\t\t\t\trelationContext,\n\t\t\t\t], targetRelation.name)\n\t\t\t},\n\t\t\tdefaultValue: null,\n\t\t})\n\t}\n}\n"],"names":["context"],"mappings":";;;AAQO,MAAM,uCAAkI;AAAA,EAC9I,YAA6B,QAAuC,qBAA0C;AAAjF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-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { isIt } from '../../utils/index.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper/index.js'\nimport { ImplementationException } from '../../exception.js'\nimport { UniqueWhereExpander } from '../../inputProcessing/index.js'\nimport { HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer.js'\n\nexport class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHandler<Input.UniqueQueryInput, HasManyToHasOneReducerExtension> {\n\tconstructor(private readonly schema: Model.Schema, private readonly uniqueWhereExpander: UniqueWhereExpander) {}\n\n\tprocess(context: SelectExecutionHandlerContext<Input.UniqueQueryInput, HasManyToHasOneReducerExtension>): void {\n\t\tconst { addData, entity, objectNode } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\taddData({\n\t\t\tfield: entity.primary,\n\t\t\tdataProvider: async (ids: Input.PrimaryValue[]) => {\n\t\t\t\tconst relationContext = acceptFieldVisitor(this.schema, entity, objectNode.extensions.relationName, {\n\t\t\t\t\tvisitRelation: context => context,\n\t\t\t\t\tvisitColumn: (): never => {\n\t\t\t\t\t\tthrow new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst { targetEntity, targetRelation } = relationContext\n\t\t\t\tif (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')\n\t\t\t\t}\n\n\t\t\t\tconst uniqueWhere = this.uniqueWhereExpander.expand(targetEntity, {\n\t\t\t\t\t...objectNode.args.by,\n\t\t\t\t\t[targetRelation.name]: { [entity.primary]: ids },\n\t\t\t\t})\n\t\t\t\tif (Object.keys(uniqueWhere).length !== 2) {\n\t\t\t\t\tthrow new Error('HasManyToHasOneReducerExecutionHandler: only tuple unique keys are allowed')\n\t\t\t\t}\n\t\t\t\tconst whereWithParentId = {\n\t\t\t\t\tand: [objectNode.args.filter || {}, uniqueWhere],\n\t\t\t\t}\n\t\t\t\tconst newObjectNode = objectNode.withArgs<Input.ListQueryInput>({ filter: whereWithParentId })\n\n\t\t\t\treturn context.mapper.selectAssoc(targetEntity, newObjectNode, [\n\t\t\t\t\t...context.relationPath,\n\t\t\t\t\trelationContext,\n\t\t\t\t], targetRelation.name)\n\t\t\t},\n\t\t\tdefaultValue: null,\n\t\t})\n\t}\n}\n"],"names":["context"],"mappings":";;;AAQO,MAAM,uCAAkI;AAAA,EAC9I,YAA6B,QAAuC,qBAA0C;AAAjF,SAAA,SAAA;AAAuC,SAAA,sBAAA;AAAA,EAA2C;AAAA,EAE/G,QAAQ,SAAuG;AAC9G,UAAM,EAAE,SAAS,QAAQ,WAAA,IAAe;AACxC,QAAI,CAAC,YAAY;AAChB,YAAM,IAAI,MAAA;AAAA,IACX;AACA,YAAQ;AAAA,MACP,OAAO,OAAO;AAAA,MACd,cAAc,OAAO,QAA8B;AAClD,cAAM,kBAAkB,mBAAmB,KAAK,QAAQ,QAAQ,WAAW,WAAW,cAAc;AAAA,UACnG,eAAe,CAAAA,aAAWA;AAAAA,UAC1B,aAAa,MAAa;AACzB,kBAAM,IAAI,wBAAwB,qEAAqE;AAAA,UACxG;AAAA,QAAA,CACA;AAED,cAAM,EAAE,cAAc,eAAA,IAAmB;AACzC,YAAI,CAAC,kBAAkB,CAAC,KAAkC,gBAAgB,eAAe,GAAG;AAC3F,gBAAM,IAAI,MAAM,0FAA0F;AAAA,QAC3G;AAEA,cAAM,cAAc,KAAK,oBAAoB,OAAO,cAAc;AAAA,UACjE,GAAG,WAAW,KAAK;AAAA,UACnB,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,IAAA;AAAA,QAAI,CAC/C;AACD,YAAI,OAAO,KAAK,WAAW,EAAE,WAAW,GAAG;AAC1C,gBAAM,IAAI,MAAM,4EAA4E;AAAA,QAC7F;AACA,cAAM,oBAAoB;AAAA,UACzB,KAAK,CAAC,WAAW,KAAK,UAAU,CAAA,GAAI,WAAW;AAAA,QAAA;AAEhD,cAAM,gBAAgB,WAAW,SAA+B,EAAE,QAAQ,mBAAmB;AAE7F,eAAO,QAAQ,OAAO,YAAY,cAAc,eAAe;AAAA,UAC9D,GAAG,QAAQ;AAAA,UACX;AAAA,QAAA,GACE,eAAe,IAAI;AAAA,MACvB;AAAA,MACA,cAAc;AAAA,IAAA,CACd;AAAA,EACF;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneRelationReducerVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t},\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements Model.ColumnVisitor<Result[]>, Model.RelationByTypeVisitor<Result[]> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey =>\n\t\t\t\tuniqueKey\n\t\t\t\t\t.every(it => acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t\t)\n\n\t\tconst graphQlName = relation.name + 'By'\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${relation.name}Of${entity.name}ByUniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) // todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t// todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.concat([universalUnique])\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["schema","getFieldsForUniqueWhere","it","acceptFieldVisitor","FieldAccessVisitor","Acl","GraphQLInputObjectType","GqlTypeName","HasManyToHasOneReducer","GraphQLNonNull","aliasAwareResolver","graphQlName","uniqueWhere"],"mappings":";;;;;;;;;;;;AAgBO,MAAM,2CAA2H;AAAA,EACvI,YACkBA,SACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEI,cAAc;AACpB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,uBAAuB;AAC7B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,wBAAwB;AAC9B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,kBAAkB;AACxB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,0BAA0B;AAChC,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,yBAAyB;AAC/B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB,YAAqC;AACnG,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAA;AAAA,IACR;AACA,UAAM,oBAAoBC,kBAAAA,wBAAwB,KAAK,QAAQ,YAAY;AAE3E,UAAM,aAAoC,kBACxC,IAAI,QAAM,GAAG,OAAO,CAAAC,QAAMA,QAAO,eAAe,IAAI,CAAC,EACrD,OAAO,QAAM,GAAG,SAAS,CAAC,EAC1B;AAAA,MAAO,eACP,UACE,MAAM,QAAMC,YAAAA,mBAAmB,KAAK,QAAQ,aAAa,MAAM,IAAI,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AAY,EACxC;AAAA,MAAO,CAAA,UACPP,YAAAA;AAAAA,QACC,KAAK;AAAA,QACL,aAAa;AAAA,QACb;AAAA,QACA,IAAIC,mBAAAA,mBAAmBC,OAAAA,IAAI,UAAU,MAAM,KAAK,YAAY;AAAA,MAAA;AAAA,IAC7D,EAEA,IAAmB,CAAA,cAAa;AAChC,UAAI,SAAS,IAAI,SAAS,GAAG;AAC5B,eAAO;AAAA,MACR;AACA,eAAS,IAAI,SAAS;AACtB,YAAMM,eAAc,SAAS,OAAOJ,MAAAA,gBAAgB,SAAS;AAC7D,YAAMK,eAAsC,IAAIN,+BAAuB;AAAA;AAAA,QAEtE,MAAMC,MAAAA,cAAc,OAAO,IAAI,GAAG,SAAS,IAAI,KAAK,SAAS;AAAA,QAC7D,QAAQ,MAAM;AACb,iBAAO,KAAK,kBAAkB,qBAAqB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC;AAAA,QAC/E;AAAA,MAAA,CACA;AAED,aAAO;AAAA,QACNI;AAAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,YAAY;AAAA,YACX,cAAc,SAAS;AAAA,YACvB,cAAcH,uBAAAA,uBAAuB;AAAA,UAAA;AAAA,UAEtC,MAAM;AAAA,YACL,IAAI,EAAE,MAAM,IAAIC,QAAAA,eAAeG,YAAW,EAAA;AAAA,YAC1C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAA;AAAA,UAAE;AAAA,UAE9E,SAASF,MAAAA;AAAAA,QAAA;AAAA,MACV;AAAA,IAEF,CAAC,EACA,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAC3C;AACD;;"}
|
|
1
|
+
{"version":3,"file":"HasManyToHasOneRelationReducerVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema/index.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl/index.js'\nimport { getFieldsForUniqueWhere } from '../../utils/index.js'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer.js'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t},\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements Model.ColumnVisitor<Result[]>, Model.RelationByTypeVisitor<Result[]> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey =>\n\t\t\t\tuniqueKey\n\t\t\t\t\t.every(it => acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t\t)\n\n\t\tconst graphQlName = relation.name + 'By'\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${relation.name}Of${entity.name}ByUniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) // todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t// todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.concat([universalUnique])\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["schema","getFieldsForUniqueWhere","it","acceptFieldVisitor","FieldAccessVisitor","Acl","GraphQLInputObjectType","GqlTypeName","HasManyToHasOneReducer","GraphQLNonNull","aliasAwareResolver","graphQlName","uniqueWhere"],"mappings":";;;;;;;;;;;;AAgBO,MAAM,2CAA2H;AAAA,EACvI,YACkBA,SACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEI,cAAc;AACpB,WAA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AAAA,MAAA,CACA;AAED,aAAO;AAAA,QACNI;AAAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,YAAY;AAAA,YACX,cAAc,SAAS;AAAA,YACvB,cAAcH,uBAAAA,uBAAuB;AAAA,UAAA;AAAA,UAEtC,MAAM;AAAA,YACL,IAAI,EAAE,MAAM,IAAIC,QAAAA,eAAeG,YAAW,EAAA;AAAA,YAC1C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAA;AAAA,UAAE;AAAA,UAE9E,SAASF,MAAAA;AAAAA,QAAA;AAAA,MACV;AAAA,IAEF,CAAC,EACA,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAC3C;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyToHasOneRelationReducerVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t},\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements Model.ColumnVisitor<Result[]>, Model.RelationByTypeVisitor<Result[]> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey =>\n\t\t\t\tuniqueKey\n\t\t\t\t\t.every(it => acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t\t)\n\n\t\tconst graphQlName = relation.name + 'By'\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${relation.name}Of${entity.name}ByUniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) // todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t// todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.concat([universalUnique])\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["it","graphQlName","uniqueWhere"],"mappings":";;;;;;;;;;AAgBO,MAAM,2CAA2H;AAAA,EACvI,YACkB,QACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEI,cAAc;AACpB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,uBAAuB;AAC7B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,wBAAwB;AAC9B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,kBAAkB;AACxB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,0BAA0B;AAChC,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,yBAAyB;AAC/B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB,YAAqC;AACnG,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAA;AAAA,IACR;AACA,UAAM,oBAAoB,wBAAwB,KAAK,QAAQ,YAAY;AAE3E,UAAM,aAAoC,kBACxC,IAAI,QAAM,GAAG,OAAO,CAAAA,QAAMA,QAAO,eAAe,IAAI,CAAC,EACrD,OAAO,QAAM,GAAG,SAAS,CAAC,EAC1B;AAAA,MAAO,eACP,UACE,MAAM,QAAM,mBAAmB,KAAK,QAAQ,aAAa,MAAM,IAAI,IAAI,mBAAmB,IAAI,UAAU,MAAM,KAAK,YAAY,CAAC,CAAC;AAAA,I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AM,KAAK,YAAY;AAAA,MAAA;AAAA,IAC7D,EAEA,IAAmB,CAAA,cAAa;AAChC,UAAI,SAAS,IAAI,SAAS,GAAG;AAC5B,eAAO;AAAA,MACR;AACA,eAAS,IAAI,SAAS;AACtB,YAAMC,eAAc,SAAS,OAAO,gBAAgB,SAAS;AAC7D,YAAMC,eAAsC,IAAI,uBAAuB;AAAA;AAAA,QAEtE,MAAM,cAAc,OAAO,IAAI,GAAG,SAAS,IAAI,KAAK,SAAS;AAAA,QAC7D,QAAQ,MAAM;AACb,iBAAO,KAAK,kBAAkB,qBAAqB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC;AAAA,QAC/E;AAAA,MAAA,CACA;AAED,aAAO;AAAA,QACND;AAAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,YAAY;AAAA,YACX,cAAc,SAAS;AAAA,YACvB,cAAc,uBAAuB;AAAA,UAAA;AAAA,UAEtC,MAAM;AAAA,YACL,IAAI,EAAE,MAAM,IAAI,eAAeC,YAAW,EAAA;AAAA,YAC1C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAA;AAAA,UAAE;AAAA,UAE9E,SAAS;AAAA,QAAA;AAAA,MACV;AAAA,IAEF,CAAC,EACA,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAC3C;AACD;"}
|
|
1
|
+
{"version":3,"file":"HasManyToHasOneRelationReducerVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema/index.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl/index.js'\nimport { getFieldsForUniqueWhere } from '../../utils/index.js'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer.js'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t},\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements Model.ColumnVisitor<Result[]>, Model.RelationByTypeVisitor<Result[]> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey =>\n\t\t\t\tuniqueKey\n\t\t\t\t\t.every(it => acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t\t)\n\n\t\tconst graphQlName = relation.name + 'By'\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${relation.name}Of${entity.name}ByUniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) // todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t// todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.concat([universalUnique])\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["it","graphQlName","uniqueWhere"],"mappings":";;;;;;;;;;AAgBO,MAAM,2CAA2H;AAAA,EACvI,YACkB,QACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEI,cAAc;AACpB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,uBAAuB;AAC7B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,wBAAwB;AAC9B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,kBAAkB;AACxB,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,0BAA0B;AAChC,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,yBAAyB;AAC/B,WAAO,CAAA;AAAA,EACR;AAAA,EAEO,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB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,EAC3C;AACD;"}
|
package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedHasManyCountVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { GroupedCounts, Mapper, RelationFetcher } from '../../mapper'\nimport { ObjectNode } from '../../inputProcessing'\n\nexport class PaginatedHasManyCountVisitor\n\timplements Model.ColumnVisitor<Promise<GroupedCounts>>, Model.RelationByTypeVisitor<Promise<GroupedCounts>>\n{\n\tconstructor(\n\t\tprivate readonly ids: Input.PrimaryValue[],\n\t\tprivate readonly objectNode: ObjectNode<Input.PaginationQueryInput>,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly relationPath: Model.AnyRelationContext[],\n\t) {}\n\n\tasync visitOneHasMany(relationContext: Model.OneHasManyContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countOneHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tvisitColumn(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitManyHasOne(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneInverse(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneOwning(): never {\n\t\tthrow new Error()\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,6BAEb;AAAA,EACC,YACkB,KACA,YACA,iBACA,QACA,cAChB;AALgB,SAAA,MAAA;AACA,SAAA,aAAA;AACA,SAAA,kBAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EACf;AAAA,EAEH,MAAM,gBAAgB,iBAAkE;AACvF,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,uBAAuB,iBAAyE;AACrG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,wBAAwB,iBAA0E;AACvG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,cAAqB;AACpB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,kBAAyB;AACxB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,wBAA+B;AAC9B,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,uBAA8B;AAC7B,UAAM,IAAI,MAAA;AAAA,EACX;AACD;;"}
|
|
1
|
+
{"version":3,"file":"PaginatedHasManyCountVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { GroupedCounts, Mapper, RelationFetcher } from '../../mapper/index.js'\nimport { ObjectNode } from '../../inputProcessing/index.js'\n\nexport class PaginatedHasManyCountVisitor\n\timplements Model.ColumnVisitor<Promise<GroupedCounts>>, Model.RelationByTypeVisitor<Promise<GroupedCounts>>\n{\n\tconstructor(\n\t\tprivate readonly ids: Input.PrimaryValue[],\n\t\tprivate readonly objectNode: ObjectNode<Input.PaginationQueryInput>,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly relationPath: Model.AnyRelationContext[],\n\t) {}\n\n\tasync visitOneHasMany(relationContext: Model.OneHasManyContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countOneHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tvisitColumn(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitManyHasOne(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneInverse(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneOwning(): never {\n\t\tthrow new Error()\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,6BAEb;AAAA,EACC,YACkB,KACA,YACA,iBACA,QACA,cAChB;AALgB,SAAA,MAAA;AACA,SAAA,aAAA;AACA,SAAA,kBAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EACf;AAAA,EAEH,MAAM,gBAAgB,iBAAkE;AACvF,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,uBAAuB,iBAAyE;AACrG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,wBAAwB,iBAA0E;AACvG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,cAAqB;AACpB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,kBAAyB;AACxB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,wBAA+B;AAC9B,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,uBAA8B;AAC7B,UAAM,IAAI,MAAA;AAAA,EACX;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedHasManyCountVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { GroupedCounts, Mapper, RelationFetcher } from '../../mapper'\nimport { ObjectNode } from '../../inputProcessing'\n\nexport class PaginatedHasManyCountVisitor\n\timplements Model.ColumnVisitor<Promise<GroupedCounts>>, Model.RelationByTypeVisitor<Promise<GroupedCounts>>\n{\n\tconstructor(\n\t\tprivate readonly ids: Input.PrimaryValue[],\n\t\tprivate readonly objectNode: ObjectNode<Input.PaginationQueryInput>,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly relationPath: Model.AnyRelationContext[],\n\t) {}\n\n\tasync visitOneHasMany(relationContext: Model.OneHasManyContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countOneHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tvisitColumn(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitManyHasOne(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneInverse(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneOwning(): never {\n\t\tthrow new Error()\n\t}\n}\n"],"names":[],"mappings":"AAIO,MAAM,6BAEb;AAAA,EACC,YACkB,KACA,YACA,iBACA,QACA,cAChB;AALgB,SAAA,MAAA;AACA,SAAA,aAAA;AACA,SAAA,kBAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EACf;AAAA,EAEH,MAAM,gBAAgB,iBAAkE;AACvF,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,uBAAuB,iBAAyE;AACrG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,wBAAwB,iBAA0E;AACvG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,cAAqB;AACpB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,kBAAyB;AACxB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,wBAA+B;AAC9B,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,uBAA8B;AAC7B,UAAM,IAAI,MAAA;AAAA,EACX;AACD;"}
|
|
1
|
+
{"version":3,"file":"PaginatedHasManyCountVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { GroupedCounts, Mapper, RelationFetcher } from '../../mapper/index.js'\nimport { ObjectNode } from '../../inputProcessing/index.js'\n\nexport class PaginatedHasManyCountVisitor\n\timplements Model.ColumnVisitor<Promise<GroupedCounts>>, Model.RelationByTypeVisitor<Promise<GroupedCounts>>\n{\n\tconstructor(\n\t\tprivate readonly ids: Input.PrimaryValue[],\n\t\tprivate readonly objectNode: ObjectNode<Input.PaginationQueryInput>,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly relationPath: Model.AnyRelationContext[],\n\t) {}\n\n\tasync visitOneHasMany(relationContext: Model.OneHasManyContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countOneHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tasync visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): Promise<GroupedCounts> {\n\t\treturn await this.relationFetcher.countManyHasManyGroups(\n\t\t\t{\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tfilter: this.objectNode.args.filter,\n\t\t\t\trelationContext,\n\t\t\t\trelationPath: this.relationPath,\n\t\t\t\tids: this.ids,\n\t\t\t},\n\t\t)\n\t}\n\n\tvisitColumn(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitManyHasOne(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneInverse(): never {\n\t\tthrow new Error()\n\t}\n\n\tvisitOneHasOneOwning(): never {\n\t\tthrow new Error()\n\t}\n}\n"],"names":[],"mappings":"AAIO,MAAM,6BAEb;AAAA,EACC,YACkB,KACA,YACA,iBACA,QACA,cAChB;AALgB,SAAA,MAAA;AACA,SAAA,aAAA;AACA,SAAA,kBAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EACf;AAAA,EAEH,MAAM,gBAAgB,iBAAkE;AACvF,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,uBAAuB,iBAAyE;AACrG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,MAAM,wBAAwB,iBAA0E;AACvG,WAAO,MAAM,KAAK,gBAAgB;AAAA,MACjC;AAAA,QACC,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK,WAAW,KAAK;AAAA,QAC7B;AAAA,QACA,cAAc,KAAK;AAAA,QACnB,KAAK,KAAK;AAAA,MAAA;AAAA,IACX;AAAA,EAEF;AAAA,EAEA,cAAqB;AACpB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,kBAAyB;AACxB,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,wBAA+B;AAC9B,UAAM,IAAI,MAAA;AAAA,EACX;AAAA,EAEA,uBAA8B;AAC7B,UAAM,IAAI,MAAA;AAAA,EACX;AACD;"}
|
package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedHasManyExecutionHandler.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { RelationFetcher, SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper'\nimport { PaginatedHasManyFieldProviderExtension } from './PaginatedHasManyFieldProvider'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { createPaginationHelper } from '../../utils'\nimport { PaginatedHasManyCountVisitor } from './PaginatedHasManyCountVisitor'\nimport { PaginatedHasManyNodesVisitor } from './PaginatedHasManyNodesVisitor'\n\nexport class PaginatedHasManyExecutionHandler implements SelectExecutionHandler<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t) {}\n\n\tprocess(\n\t\tcontext: SelectExecutionHandlerContext<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension>,\n\t): void {\n\t\tconst { addData, entity, objectNode, mapper } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\tconst pagination = createPaginationHelper(objectNode)\n\t\taddData({\n\t\t\tfield: context.entity.primary,\n\t\t\tdataProvider: async ids => {\n\t\t\t\tconst counts = pagination.requiresTotalCount\n\t\t\t\t\t? await acceptFieldVisitor(\n\t\t\t\t\t\tthis.schema,\n\t\t\t\t\t\tentity,\n\t\t\t\t\t\tobjectNode.extensions.relationName,\n\t\t\t\t\t\tnew PaginatedHasManyCountVisitor(ids, objectNode, this.relationFetcher, mapper, context.relationPath),\n\t\t\t\t\t)\n\t\t\t\t\t: {}\n\n\t\t\t\tconst nodes = pagination.nodeField\n\t\t\t\t\t? await acceptFieldVisitor(\n\t\t\t\t\t\tthis.schema,\n\t\t\t\t\t\tentity,\n\t\t\t\t\t\tobjectNode.extensions.relationName,\n\t\t\t\t\t\tnew PaginatedHasManyNodesVisitor(ids, pagination.nodeField, this.relationFetcher, mapper, context.relationPath),\n\t\t\t\t\t)\n\t\t\t\t\t: undefined\n\t\t\t\tconst result = new Map<Input.PrimaryValue, any>()\n\t\t\t\tfor (const id of ids) {\n\t\t\t\t\tresult.set(id, pagination.createResponse(counts?.[id] ?? 0, nodes?.[id] ?? []))\n\t\t\t\t}\n\t\t\t\treturn Object.fromEntries(result)\n\t\t\t},\n\t\t\tdefaultValue: pagination.createResponse(0, []),\n\t\t})\n\t}\n}\n"],"names":["createPaginationHelper","acceptFieldVisitor","PaginatedHasManyCountVisitor","PaginatedHasManyNodesVisitor"],"mappings":";;;;;;AAQO,MAAM,iCAAuI;AAAA,EACnJ,YACkB,QACA,iBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,kBAAA;AAAA,EACf;AAAA,EAEH,QACC,SACO;AACP,UAAM,EAAE,SAAS,QAAQ,YAAY,WAAW;AAChD,QAAI,CAAC,YAAY;AAChB,YAAM,IAAI,MAAA;AAAA,IACX;AACA,UAAM,aAAaA,gBAAAA,uBAAuB,UAAU;AACpD,YAAQ;AAAA,MACP,OAAO,QAAQ,OAAO;AAAA,MACtB,cAAc,OAAM,QAAO;AAC1B,cAAM,SAAS,WAAW,qBACvB,MAAMC,YAAAA;AAAAA,UACP,KAAK;AAAA,UACL;AAAA,UACA,WAAW,WAAW;AAAA,UACtB,IAAIC,6BAAAA,6BAA6B,KAAK,YAAY,KAAK,iBAAiB,QAAQ,QAAQ,YAAY;AAAA,QAAA,IAEnG,CAAA;AAEH,cAAM,QAAQ,WAAW,YACtB,MAAMD,YAAAA;AAAAA,UACP,KAAK;AAAA,UACL;AAAA,UACA,WAAW,WAAW;AAAA,UACtB,IAAIE,6BAAAA,6BAA6B,KAAK,WAAW,WAAW,KAAK,iBAAiB,QAAQ,QAAQ,YAAY;AAAA,QAAA,IAE7G;AACH,cAAM,6BAAa,IAAA;AACnB,mBAAW,MAAM,KAAK;AACrB,iBAAO,IAAI,IAAI,WAAW,eAAe,SAAS,EAAE,KAAK,GAAG,QAAQ,EAAE,KAAK,CAAA,CAAE,CAAC;AAAA,QAC/E;AACA,eAAO,OAAO,YAAY,MAAM;AAAA,MACjC;AAAA,MACA,cAAc,WAAW,eAAe,GAAG,CAAA,CAAE;AAAA,IAAA,CAC7C;AAAA,EACF;AACD;;"}
|
|
1
|
+
{"version":3,"file":"PaginatedHasManyExecutionHandler.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { RelationFetcher, SelectExecutionHandler, SelectExecutionHandlerContext } from '../../mapper/index.js'\nimport { PaginatedHasManyFieldProviderExtension } from './PaginatedHasManyFieldProvider.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { createPaginationHelper } from '../../utils/index.js'\nimport { PaginatedHasManyCountVisitor } from './PaginatedHasManyCountVisitor.js'\nimport { PaginatedHasManyNodesVisitor } from './PaginatedHasManyNodesVisitor.js'\n\nexport class PaginatedHasManyExecutionHandler implements SelectExecutionHandler<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension> {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly relationFetcher: RelationFetcher,\n\t) {}\n\n\tprocess(\n\t\tcontext: SelectExecutionHandlerContext<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension>,\n\t): void {\n\t\tconst { addData, entity, objectNode, mapper } = context\n\t\tif (!objectNode) {\n\t\t\tthrow new Error()\n\t\t}\n\t\tconst pagination = createPaginationHelper(objectNode)\n\t\taddData({\n\t\t\tfield: context.entity.primary,\n\t\t\tdataProvider: async ids => {\n\t\t\t\tconst counts = pagination.requiresTotalCount\n\t\t\t\t\t? await acceptFieldVisitor(\n\t\t\t\t\t\tthis.schema,\n\t\t\t\t\t\tentity,\n\t\t\t\t\t\tobjectNode.extensions.relationName,\n\t\t\t\t\t\tnew PaginatedHasManyCountVisitor(ids, objectNode, this.relationFetcher, mapper, context.relationPath),\n\t\t\t\t\t)\n\t\t\t\t\t: {}\n\n\t\t\t\tconst nodes = pagination.nodeField\n\t\t\t\t\t? await acceptFieldVisitor(\n\t\t\t\t\t\tthis.schema,\n\t\t\t\t\t\tentity,\n\t\t\t\t\t\tobjectNode.extensions.relationName,\n\t\t\t\t\t\tnew PaginatedHasManyNodesVisitor(ids, pagination.nodeField, this.relationFetcher, mapper, context.relationPath),\n\t\t\t\t\t)\n\t\t\t\t\t: undefined\n\t\t\t\tconst result = new Map<Input.PrimaryValue, any>()\n\t\t\t\tfor (const id of ids) {\n\t\t\t\t\tresult.set(id, pagination.createResponse(counts?.[id] ?? 0, nodes?.[id] ?? []))\n\t\t\t\t}\n\t\t\t\treturn Object.fromEntries(result)\n\t\t\t},\n\t\t\tdefaultValue: pagination.createResponse(0, []),\n\t\t})\n\t}\n}\n"],"names":["createPaginationHelper","acceptFieldVisitor","PaginatedHasManyCountVisitor","PaginatedHasManyNodesVisitor"],"mappings":";;;;;;AAQO,MAAM,iCAAuI;AAAA,EACnJ,YACkB,QACA,iBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,kBAAA;AAAA,EACf;AAAA,EAEH,QACC,SACO;AACP,UAAM,EAAE,SAAS,QAAQ,YAAY,WAAW;AAChD,QAAI,CAAC,YAAY;AAChB,YAAM,IAAI,MAAA;AAAA,IACX;AACA,UAAM,aAAaA,gBAAAA,uBAAuB,UAAU;AACpD,YAAQ;AAAA,MACP,OAAO,QAAQ,OAAO;AAAA,MACtB,cAAc,OAAM,QAAO;AAC1B,cAAM,SAAS,WAAW,qBACvB,MAAMC,YAAAA;AAAAA,UACP,KAAK;AAAA,UACL;AAAA,UACA,WAAW,WAAW;AAAA,UACtB,IAAIC,6BAAAA,6BAA6B,KAAK,YAAY,KAAK,iBAAiB,QAAQ,QAAQ,YAAY;AAAA,QAAA,IAEnG,CAAA;AAEH,cAAM,QAAQ,WAAW,YACtB,MAAMD,YAAAA;AAAAA,UACP,KAAK;AAAA,UACL;AAAA,UACA,WAAW,WAAW;AAAA,UACtB,IAAIE,6BAAAA,6BAA6B,KAAK,WAAW,WAAW,KAAK,iBAAiB,QAAQ,QAAQ,YAAY;AAAA,QAAA,IAE7G;AACH,cAAM,6BAAa,IAAA;AACnB,mBAAW,MAAM,KAAK;AACrB,iBAAO,IAAI,IAAI,WAAW,eAAe,SAAS,EAAE,KAAK,GAAG,QAAQ,EAAE,KAAK,CAAA,CAAE,CAAC;AAAA,QAC/E;AACA,eAAO,OAAO,YAAY,MAAM;AAAA,MACjC;AAAA,MACA,cAAc,WAAW,eAAe,GAAG,CAAA,CAAE;AAAA,IAAA,CAC7C;AAAA,EACF;AACD;;"}
|