@contember/engine-content-api 2.2.0-alpha.11 → 2.2.0-alpha.13
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 +1 -1
- package/dist/development/index.cjs +10 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +12 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/ExecutionContainer.cjs +6 -3
- package/dist/development/src/ExecutionContainer.cjs.map +1 -1
- package/dist/development/src/ExecutionContainer.js +6 -3
- package/dist/development/src/ExecutionContainer.js.map +1 -1
- package/dist/development/src/acl/AclScope.cjs +7 -0
- package/dist/development/src/acl/AclScope.cjs.map +1 -0
- package/dist/development/src/acl/AclScope.js +7 -0
- package/dist/development/src/acl/AclScope.js.map +1 -0
- package/dist/development/src/acl/Authorizator.cjs +0 -3
- package/dist/development/src/acl/Authorizator.cjs.map +1 -1
- package/dist/development/src/acl/Authorizator.js +0 -3
- package/dist/development/src/acl/Authorizator.js.map +1 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.cjs +4 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.js +4 -1
- package/dist/development/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
- package/dist/development/src/acl/PermissionFactory.cjs +50 -68
- package/dist/development/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/development/src/acl/PermissionFactory.js +51 -69
- package/dist/development/src/acl/PermissionFactory.js.map +1 -1
- package/dist/development/src/acl/PredicateFactory.cjs +95 -26
- package/dist/development/src/acl/PredicateFactory.cjs.map +1 -1
- package/dist/development/src/acl/PredicateFactory.js +95 -26
- package/dist/development/src/acl/PredicateFactory.js.map +1 -1
- package/dist/development/src/acl/PredicatesInjector.cjs +97 -32
- package/dist/development/src/acl/PredicatesInjector.cjs.map +1 -1
- package/dist/development/src/acl/PredicatesInjector.js +99 -34
- package/dist/development/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/development/src/acl/VariableInjector.cjs +7 -2
- package/dist/development/src/acl/VariableInjector.cjs.map +1 -1
- package/dist/development/src/acl/VariableInjector.js +7 -2
- package/dist/development/src/acl/VariableInjector.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +26 -2
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +27 -3
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +11 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +11 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +27 -3
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +27 -3
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +10 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +10 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/development/src/input-validation/ValidationDataSelector.cjs +2 -2
- package/dist/development/src/input-validation/ValidationDataSelector.cjs.map +1 -1
- package/dist/development/src/input-validation/ValidationDataSelector.js +2 -2
- package/dist/development/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/development/src/mapper/JunctionTableManager.cjs +18 -12
- package/dist/development/src/mapper/JunctionTableManager.cjs.map +1 -1
- package/dist/development/src/mapper/JunctionTableManager.js +19 -13
- package/dist/development/src/mapper/JunctionTableManager.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +65 -31
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +65 -31
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs +15 -8
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.js +15 -8
- package/dist/development/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.cjs +3 -2
- package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.js +3 -2
- package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilderFactory.cjs +2 -2
- package/dist/development/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilderFactory.js +2 -2
- package/dist/development/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.cjs +3 -3
- package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.js +3 -3
- package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs +3 -2
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js +3 -2
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +9 -8
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +9 -8
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +4 -4
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -4
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +3 -3
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +3 -3
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +7 -7
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +7 -7
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +6 -6
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +6 -6
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/select/JoinBuilder.cjs +26 -4
- package/dist/development/src/mapper/select/JoinBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/JoinBuilder.js +27 -5
- package/dist/development/src/mapper/select/JoinBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.cjs +81 -13
- package/dist/development/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.js +83 -15
- package/dist/development/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/Path.cjs +2 -0
- package/dist/development/src/mapper/select/Path.cjs.map +1 -1
- package/dist/development/src/mapper/select/Path.js +3 -1
- package/dist/development/src/mapper/select/Path.js.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.cjs +3 -2
- package/dist/development/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.js +3 -2
- package/dist/development/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.cjs +10 -16
- package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.js +8 -14
- package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/WhereBuilder.cjs +261 -47
- package/dist/development/src/mapper/select/WhereBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/WhereBuilder.js +262 -48
- package/dist/development/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/getFieldReadPredicate.cjs +8 -0
- package/dist/development/src/mapper/select/getFieldReadPredicate.cjs.map +1 -0
- package/dist/development/src/mapper/select/getFieldReadPredicate.js +8 -0
- package/dist/development/src/mapper/select/getFieldReadPredicate.js.map +1 -0
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs +8 -12
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js +9 -13
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +6 -2
- package/dist/development/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.js +6 -2
- package/dist/development/src/mapper/select/handlers/MetaHandler.js.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +229 -3
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +230 -4
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +3 -2
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +3 -2
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.cjs +35 -2
- package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.js +36 -3
- package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilderFactory.cjs +3 -2
- package/dist/development/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilderFactory.js +3 -2
- package/dist/development/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
- package/dist/development/src/mapper/update/Updater.cjs +12 -6
- package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/development/src/mapper/update/Updater.js +13 -7
- package/dist/development/src/mapper/update/Updater.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +27 -19
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +27 -19
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +13 -11
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +13 -11
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +11 -8
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +11 -8
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +19 -16
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +19 -16
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +19 -16
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +19 -16
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.cjs +6 -5
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +6 -5
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs +12 -2
- package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.js +12 -2
- package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.cjs +3 -2
- package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.js +3 -2
- package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +38 -11
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +38 -11
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/development/src/schema/MutationProvider.cjs +13 -8
- package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/development/src/schema/MutationProvider.js +13 -8
- package/dist/development/src/schema/MutationProvider.js.map +1 -1
- package/dist/development/src/schema/QueryProvider.cjs +3 -5
- package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/development/src/schema/QueryProvider.js +3 -5
- package/dist/development/src/schema/QueryProvider.js.map +1 -1
- package/dist/development/src/schema/entities/FieldTypeVisitor.cjs +15 -2
- package/dist/development/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
- package/dist/development/src/schema/entities/FieldTypeVisitor.js +15 -2
- package/dist/development/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/production/index.cjs +10 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +12 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/ExecutionContainer.cjs +6 -3
- package/dist/production/src/ExecutionContainer.cjs.map +1 -1
- package/dist/production/src/ExecutionContainer.js +6 -3
- package/dist/production/src/ExecutionContainer.js.map +1 -1
- package/dist/production/src/acl/AclScope.cjs +7 -0
- package/dist/production/src/acl/AclScope.cjs.map +1 -0
- package/dist/production/src/acl/AclScope.js +7 -0
- package/dist/production/src/acl/AclScope.js.map +1 -0
- package/dist/production/src/acl/Authorizator.cjs +0 -3
- package/dist/production/src/acl/Authorizator.cjs.map +1 -1
- package/dist/production/src/acl/Authorizator.js +0 -3
- package/dist/production/src/acl/Authorizator.js.map +1 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.cjs +4 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.js +4 -1
- package/dist/production/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
- package/dist/production/src/acl/PermissionFactory.cjs +50 -68
- package/dist/production/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/production/src/acl/PermissionFactory.js +51 -69
- package/dist/production/src/acl/PermissionFactory.js.map +1 -1
- package/dist/production/src/acl/PredicateFactory.cjs +95 -26
- package/dist/production/src/acl/PredicateFactory.cjs.map +1 -1
- package/dist/production/src/acl/PredicateFactory.js +95 -26
- package/dist/production/src/acl/PredicateFactory.js.map +1 -1
- package/dist/production/src/acl/PredicatesInjector.cjs +97 -32
- package/dist/production/src/acl/PredicatesInjector.cjs.map +1 -1
- package/dist/production/src/acl/PredicatesInjector.js +99 -34
- package/dist/production/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/production/src/acl/VariableInjector.cjs +7 -2
- package/dist/production/src/acl/VariableInjector.cjs.map +1 -1
- package/dist/production/src/acl/VariableInjector.js +7 -2
- package/dist/production/src/acl/VariableInjector.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +26 -2
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +27 -3
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +11 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +11 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +27 -3
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +27 -3
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +10 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +10 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/production/src/input-validation/ValidationDataSelector.cjs +2 -2
- package/dist/production/src/input-validation/ValidationDataSelector.cjs.map +1 -1
- package/dist/production/src/input-validation/ValidationDataSelector.js +2 -2
- package/dist/production/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/production/src/mapper/JunctionTableManager.cjs +18 -12
- package/dist/production/src/mapper/JunctionTableManager.cjs.map +1 -1
- package/dist/production/src/mapper/JunctionTableManager.js +19 -13
- package/dist/production/src/mapper/JunctionTableManager.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +65 -31
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +65 -31
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs +15 -8
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.js +15 -8
- package/dist/production/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.cjs +3 -2
- package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.js +3 -2
- package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilderFactory.cjs +2 -2
- package/dist/production/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilderFactory.js +2 -2
- package/dist/production/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.cjs +3 -3
- package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.js +3 -3
- package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs +3 -2
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js +3 -2
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +9 -8
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +9 -8
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +4 -4
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -4
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +3 -3
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +3 -3
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +7 -7
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +7 -7
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +6 -6
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +6 -6
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/select/JoinBuilder.cjs +26 -4
- package/dist/production/src/mapper/select/JoinBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/JoinBuilder.js +27 -5
- package/dist/production/src/mapper/select/JoinBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.cjs +81 -13
- package/dist/production/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.js +83 -15
- package/dist/production/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/Path.cjs +2 -0
- package/dist/production/src/mapper/select/Path.cjs.map +1 -1
- package/dist/production/src/mapper/select/Path.js +3 -1
- package/dist/production/src/mapper/select/Path.js.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.cjs +3 -2
- package/dist/production/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.js +3 -2
- package/dist/production/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.cjs +10 -16
- package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.js +8 -14
- package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/WhereBuilder.cjs +261 -47
- package/dist/production/src/mapper/select/WhereBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/WhereBuilder.js +262 -48
- package/dist/production/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/getFieldReadPredicate.cjs +8 -0
- package/dist/production/src/mapper/select/getFieldReadPredicate.cjs.map +1 -0
- package/dist/production/src/mapper/select/getFieldReadPredicate.js +8 -0
- package/dist/production/src/mapper/select/getFieldReadPredicate.js.map +1 -0
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs +8 -12
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js +9 -13
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +6 -2
- package/dist/production/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.js +6 -2
- package/dist/production/src/mapper/select/handlers/MetaHandler.js.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +229 -3
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +230 -4
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +3 -2
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +3 -2
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.cjs +35 -2
- package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.js +36 -3
- package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilderFactory.cjs +3 -2
- package/dist/production/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilderFactory.js +3 -2
- package/dist/production/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
- package/dist/production/src/mapper/update/Updater.cjs +12 -6
- package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/production/src/mapper/update/Updater.js +13 -7
- package/dist/production/src/mapper/update/Updater.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +27 -19
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +27 -19
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +13 -11
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +13 -11
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +11 -8
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +11 -8
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +19 -16
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +19 -16
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +19 -16
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +19 -16
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.cjs +6 -5
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +6 -5
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs +12 -2
- package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.js +12 -2
- package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.cjs +3 -2
- package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.js +3 -2
- package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +38 -11
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +38 -11
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/production/src/schema/MutationProvider.cjs +13 -8
- package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/production/src/schema/MutationProvider.js +13 -8
- package/dist/production/src/schema/MutationProvider.js.map +1 -1
- package/dist/production/src/schema/QueryProvider.cjs +3 -5
- package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/production/src/schema/QueryProvider.js +3 -5
- package/dist/production/src/schema/QueryProvider.js.map +1 -1
- package/dist/production/src/schema/entities/FieldTypeVisitor.cjs +15 -2
- package/dist/production/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
- package/dist/production/src/schema/entities/FieldTypeVisitor.js +15 -2
- package/dist/production/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.d.ts.map +1 -0
- package/dist/tests/src/test.d.ts +2 -0
- package/dist/tests/src/test.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ExecutionContainer.d.ts.map +1 -1
- package/dist/types/acl/AclScope.d.ts +26 -0
- package/dist/types/acl/AclScope.d.ts.map +1 -0
- package/dist/types/acl/Authorizator.d.ts +0 -1
- package/dist/types/acl/Authorizator.d.ts.map +1 -1
- package/dist/types/acl/EvaluatedPredicateReplacer.d.ts +1 -0
- package/dist/types/acl/EvaluatedPredicateReplacer.d.ts.map +1 -1
- package/dist/types/acl/PermissionFactory.d.ts +17 -4
- package/dist/types/acl/PermissionFactory.d.ts.map +1 -1
- package/dist/types/acl/PredicateFactory.d.ts +31 -15
- package/dist/types/acl/PredicateFactory.d.ts.map +1 -1
- package/dist/types/acl/PredicatesInjector.d.ts +67 -7
- package/dist/types/acl/PredicatesInjector.d.ts.map +1 -1
- package/dist/types/acl/VariableInjector.d.ts.map +1 -1
- package/dist/types/acl/index.d.ts +1 -0
- package/dist/types/acl/index.d.ts.map +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +3 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts +3 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationDataSelector.d.ts +2 -1
- package/dist/types/input-validation/ValidationDataSelector.d.ts.map +1 -1
- package/dist/types/mapper/JunctionTableManager.d.ts +17 -5
- package/dist/types/mapper/JunctionTableManager.d.ts.map +1 -1
- package/dist/types/mapper/Mapper.d.ts +16 -11
- package/dist/types/mapper/Mapper.d.ts.map +1 -1
- package/dist/types/mapper/delete/DeleteExecutor.d.ts +6 -2
- package/dist/types/mapper/delete/DeleteExecutor.d.ts.map +1 -1
- package/dist/types/mapper/insert/InsertBuilder.d.ts +3 -2
- package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
- package/dist/types/mapper/insert/InsertBuilderFactory.d.ts +2 -2
- package/dist/types/mapper/insert/InsertBuilderFactory.d.ts.map +1 -1
- package/dist/types/mapper/insert/Inserter.d.ts +2 -1
- package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
- package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts +6 -1
- package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +6 -1
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/select/JoinBuilder.d.ts +8 -2
- package/dist/types/mapper/select/JoinBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/OrderByBuilder.d.ts +18 -2
- package/dist/types/mapper/select/OrderByBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/Path.d.ts +11 -0
- package/dist/types/mapper/select/Path.d.ts.map +1 -1
- package/dist/types/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectExecutionHandler.d.ts +5 -0
- package/dist/types/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
- package/dist/types/mapper/select/WhereBuilder.d.ts +33 -1
- package/dist/types/mapper/select/WhereBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/getFieldReadPredicate.d.ts +4 -0
- package/dist/types/mapper/select/getFieldReadPredicate.d.ts.map +1 -0
- package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts +0 -1
- package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
- package/dist/types/mapper/select/handlers/MetaHandler.d.ts.map +1 -1
- package/dist/types/mapper/select/index.d.ts +1 -0
- package/dist/types/mapper/select/index.d.ts.map +1 -1
- package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts +36 -0
- package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +6 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/UpdateBuilder.d.ts +18 -2
- package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
- package/dist/types/mapper/update/UpdateBuilderFactory.d.ts +2 -2
- package/dist/types/mapper/update/UpdateBuilderFactory.d.ts.map +1 -1
- package/dist/types/mapper/update/Updater.d.ts +3 -2
- package/dist/types/mapper/update/Updater.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +8 -1
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/schema/EntityTypeProvider.d.ts +2 -1
- package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts +10 -2
- package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts.map +1 -1
- package/dist/types/schema/MutationProvider.d.ts +7 -1
- package/dist/types/schema/MutationProvider.d.ts.map +1 -1
- package/dist/types/schema/QueryProvider.d.ts +2 -1
- package/dist/types/schema/QueryProvider.d.ts.map +1 -1
- package/dist/types/schema/entities/FieldTypeVisitor.d.ts +4 -1
- package/dist/types/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/ExecutionContainer.ts +8 -3
- package/src/acl/AclScope.ts +29 -0
- package/src/acl/Authorizator.ts +0 -4
- package/src/acl/EvaluatedPredicateReplacer.ts +6 -2
- package/src/acl/PermissionFactory.ts +59 -104
- package/src/acl/PredicateFactory.ts +131 -28
- package/src/acl/PredicatesInjector.ts +135 -53
- package/src/acl/VariableInjector.ts +8 -3
- package/src/acl/index.ts +1 -0
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +14 -3
- package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +10 -2
- package/src/input-validation/ValidationDataSelector.ts +3 -2
- package/src/mapper/JunctionTableManager.ts +28 -6
- package/src/mapper/Mapper.ts +67 -23
- package/src/mapper/delete/DeleteExecutor.ts +13 -7
- package/src/mapper/insert/InsertBuilder.ts +3 -2
- package/src/mapper/insert/InsertBuilderFactory.ts +3 -3
- package/src/mapper/insert/Inserter.ts +4 -2
- package/src/mapper/insert/SqlCreateInputProcessor.ts +4 -1
- package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +10 -7
- package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +4 -4
- package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +3 -3
- package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +7 -7
- package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +6 -6
- package/src/mapper/select/JoinBuilder.ts +39 -6
- package/src/mapper/select/OrderByBuilder.ts +137 -17
- package/src/mapper/select/Path.ts +11 -0
- package/src/mapper/select/RelationFetcher.ts +4 -1
- package/src/mapper/select/SelectBuilder.ts +7 -16
- package/src/mapper/select/SelectExecutionHandler.ts +5 -0
- package/src/mapper/select/WhereBuilder.ts +322 -50
- package/src/mapper/select/getFieldReadPredicate.ts +12 -0
- package/src/mapper/select/handlers/FieldsVisitor.ts +9 -14
- package/src/mapper/select/handlers/MetaHandler.ts +5 -3
- package/src/mapper/select/index.ts +1 -0
- package/src/mapper/select/optimizer/WhereOptimizer.ts +279 -6
- package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -1
- package/src/mapper/update/UpdateBuilder.ts +41 -3
- package/src/mapper/update/UpdateBuilderFactory.ts +3 -2
- package/src/mapper/update/Updater.ts +11 -4
- package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +29 -18
- package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +11 -9
- package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +8 -5
- package/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts +16 -13
- package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +16 -13
- package/src/resolvers/MutationResolver.ts +4 -4
- package/src/resolvers/ReadHelpers.ts +1 -1
- package/src/schema/EntityTypeProvider.ts +2 -1
- package/src/schema/GraphQlSchemaBuilderFactory.ts +24 -8
- package/src/schema/MutationProvider.ts +16 -8
- package/src/schema/QueryProvider.ts +4 -4
- package/src/schema/entities/FieldTypeVisitor.ts +17 -1
- package/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.ts +320 -0
- package/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.ts +502 -0
- package/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.ts +54 -0
- package/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.ts +142 -0
- package/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts +7 -4
- package/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.ts +64 -0
- package/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.ts +124 -0
- package/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.ts +315 -0
- package/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.ts +55 -0
- package/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.ts +141 -0
- package/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.ts +320 -0
- package/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.ts +156 -0
- package/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.ts +513 -0
- package/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.ts +348 -0
- package/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.ts +203 -0
- package/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.ts +127 -0
- package/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.ts +79 -0
- package/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.ts +127 -0
- package/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.ts +89 -0
- package/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.ts +296 -0
- package/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.ts +265 -0
- package/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.ts +441 -0
- package/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.ts +415 -0
- package/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.ts +134 -0
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +129 -5
- package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +265 -0
- package/tests/cases/integration/graphQlSchema/schema-not-null-through.gql +201 -0
- package/tests/cases/unit/permissionMerger.test.ts +947 -13
- package/tests/cases/unit/predicatesFactory.test.ts +7 -16
- package/tests/cases/unit/predicatesInjector.test.ts +1031 -116
- package/tests/cases/unit/variableInjector.test.ts +12 -0
- package/tests/cases/unit/whereOptimizer.test.ts +62 -0
- package/tests/src/test.ts +8 -2
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const isIt = require("../../utils/isIt.cjs");
|
|
4
4
|
const schemaUtils = require("@contember/schema-utils");
|
|
5
|
+
const Path = require("./Path.cjs");
|
|
5
6
|
const Database = require("@contember/database");
|
|
7
|
+
const PredicatesInjector = require("../../acl/PredicatesInjector.cjs");
|
|
6
8
|
class WhereBuilder {
|
|
7
9
|
constructor(schema, joinBuilder, conditionBuilder, pathFactory, whereOptimizer, useExistsInHasManyFilter) {
|
|
8
10
|
this.schema = schema;
|
|
@@ -32,6 +34,47 @@ class WhereBuilder {
|
|
|
32
34
|
allowManyJoin: false
|
|
33
35
|
});
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Compiles a where into a single boolean SQL condition (a `Literal`), applying any relation joins it needs
|
|
39
|
+
* to `qb`. Shared by the read-predicate consumers that need the condition as an expression rather than a
|
|
40
|
+
* WHERE clause: the projection predicate column (selected as a boolean) and the order-by guard (wrapped in
|
|
41
|
+
* `CASE WHEN <condition> THEN <column> END`). An empty/trivially-true predicate compiles to `true`.
|
|
42
|
+
*/
|
|
43
|
+
buildConditionLiteral(qb, entity, path, where, optimizationHints = {}) {
|
|
44
|
+
let condition = new Database.Literal("true");
|
|
45
|
+
const resultQb = this.buildAdvanced(
|
|
46
|
+
entity,
|
|
47
|
+
path,
|
|
48
|
+
where,
|
|
49
|
+
(applyCondition) => {
|
|
50
|
+
condition = Database.ConditionBuilder.process((clause) => {
|
|
51
|
+
const applied = applyCondition(clause);
|
|
52
|
+
return applied.isEmpty() ? applied.raw("true") : applied;
|
|
53
|
+
}).getSql() ?? new Database.Literal("true");
|
|
54
|
+
return qb;
|
|
55
|
+
},
|
|
56
|
+
optimizationHints
|
|
57
|
+
);
|
|
58
|
+
return { qb: resultQb, condition };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The table source of a relation hop restricted to rows satisfying `guard` (the target's row-level read
|
|
62
|
+
* predicate): `(select <alias>.* from <table> as <alias> where <guard>)`. LEFT JOINing this source
|
|
63
|
+
* null-extends an unreadable row exactly like an absent one. The guard is compiled as-definer — its own
|
|
64
|
+
* relation hops are plain joins — and Postgres pulls the subquery up into the outer join tree.
|
|
65
|
+
*/
|
|
66
|
+
buildGuardedSource(entity, path, guard) {
|
|
67
|
+
const qb = Database.SelectBuilder.create().select((expr) => expr.raw(`${Database.wrapIdentifier(path.alias)}.*`)).from(entity.tableName, path.alias);
|
|
68
|
+
const guarded = this.buildInternal({
|
|
69
|
+
entity,
|
|
70
|
+
path,
|
|
71
|
+
where: this.whereOptimizer.optimize(guard, entity),
|
|
72
|
+
callback: (cb) => qb.where((clause) => cb(clause)),
|
|
73
|
+
allowManyJoin: false
|
|
74
|
+
});
|
|
75
|
+
const query = guarded.createQuery(new Database.Compiler.Context(Database.Compiler.SCHEMA_PLACEHOLDER, /* @__PURE__ */ new Set()));
|
|
76
|
+
return new Database.Literal(`(${query.sql})`, query.parameters);
|
|
77
|
+
}
|
|
35
78
|
buildInternal({
|
|
36
79
|
callback,
|
|
37
80
|
...args
|
|
@@ -41,11 +84,12 @@ class WhereBuilder {
|
|
|
41
84
|
(clause) => this.buildRecursive({
|
|
42
85
|
conditionBuilder: clause,
|
|
43
86
|
joinList,
|
|
44
|
-
...args
|
|
87
|
+
...args,
|
|
88
|
+
negated: false
|
|
45
89
|
})
|
|
46
90
|
);
|
|
47
91
|
return joinList.reduce(
|
|
48
|
-
(qb, { path, entity, relationName }) => this.joinBuilder.join(qb, path, entity, relationName),
|
|
92
|
+
(qb, { path, entity, relationName, targetSource, joinCondition }) => this.joinBuilder.join(qb, path, entity, relationName, targetSource, joinCondition),
|
|
49
93
|
qbWithWhere
|
|
50
94
|
);
|
|
51
95
|
}
|
|
@@ -55,7 +99,8 @@ class WhereBuilder {
|
|
|
55
99
|
path,
|
|
56
100
|
where,
|
|
57
101
|
joinList,
|
|
58
|
-
allowManyJoin
|
|
102
|
+
allowManyJoin,
|
|
103
|
+
negated
|
|
59
104
|
}) {
|
|
60
105
|
const tableName = path.alias;
|
|
61
106
|
if (where.and !== void 0 && where.and !== null && where.and.length > 0) {
|
|
@@ -68,7 +113,8 @@ class WhereBuilder {
|
|
|
68
113
|
path,
|
|
69
114
|
where: where2,
|
|
70
115
|
joinList,
|
|
71
|
-
allowManyJoin
|
|
116
|
+
allowManyJoin,
|
|
117
|
+
negated
|
|
72
118
|
}),
|
|
73
119
|
clause
|
|
74
120
|
)
|
|
@@ -85,7 +131,8 @@ class WhereBuilder {
|
|
|
85
131
|
path,
|
|
86
132
|
where: where2,
|
|
87
133
|
joinList,
|
|
88
|
-
allowManyJoin
|
|
134
|
+
allowManyJoin,
|
|
135
|
+
negated
|
|
89
136
|
})
|
|
90
137
|
),
|
|
91
138
|
clause
|
|
@@ -101,7 +148,8 @@ class WhereBuilder {
|
|
|
101
148
|
path,
|
|
102
149
|
where: expr,
|
|
103
150
|
joinList,
|
|
104
|
-
allowManyJoin
|
|
151
|
+
allowManyJoin,
|
|
152
|
+
negated: !negated
|
|
105
153
|
})
|
|
106
154
|
);
|
|
107
155
|
}
|
|
@@ -113,13 +161,42 @@ class WhereBuilder {
|
|
|
113
161
|
if (!fieldWhere) {
|
|
114
162
|
continue;
|
|
115
163
|
}
|
|
164
|
+
if (fieldName === PredicatesInjector.MASKED_CELL_KEY) {
|
|
165
|
+
conditionBuilder = PredicatesInjector.parseMaskedCells(fieldWhere).reduce(
|
|
166
|
+
(builder, cell) => this.buildMaskedCell(builder, entity, path, cell, joinList, allowManyJoin, negated),
|
|
167
|
+
conditionBuilder
|
|
168
|
+
);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
116
171
|
const targetPath = path.for(fieldName);
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
172
|
+
const hop = () => {
|
|
173
|
+
if (!this.isOptionalWhere(fieldWhere)) {
|
|
174
|
+
throw new Error(`WhereBuilder: ${entity.name}::${fieldName} expects a relation where`);
|
|
175
|
+
}
|
|
176
|
+
const { guard, fieldGuard, where: relationWhere } = PredicatesInjector.splitReadGuard(fieldWhere);
|
|
177
|
+
const guards = { row: Object.keys(guard).length > 0, field: Object.keys(fieldGuard).length > 0 };
|
|
178
|
+
return { guard, fieldGuard, where: relationWhere, path: guards.row || guards.field ? path.for(Path.hopPathSegment(fieldName, guards)) : targetPath };
|
|
179
|
+
};
|
|
180
|
+
const fieldGuardCondition = (fieldGuard) => {
|
|
181
|
+
if (Object.keys(fieldGuard).length === 0) {
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
const condition = Database.ConditionBuilder.process(
|
|
185
|
+
(clause) => this.buildRecursive({ conditionBuilder: clause, entity, path, where: fieldGuard, joinList, allowManyJoin, negated: false })
|
|
186
|
+
).getSql();
|
|
187
|
+
return condition === null ? void 0 : new Database.Literal(`coalesce(${condition.sql}, false)`, condition.parameters);
|
|
188
|
+
};
|
|
189
|
+
const existsIfReadable = (fieldGuard, subquery) => {
|
|
190
|
+
const readable = fieldGuardCondition(fieldGuard);
|
|
191
|
+
return readable === void 0 ? conditionBuilder.exists(subquery) : conditionBuilder.and((clause) => clause.with(readable).exists(subquery));
|
|
192
|
+
};
|
|
193
|
+
const joinedWhere = (context) => {
|
|
194
|
+
const { targetEntity, relation, entity: entity2 } = context;
|
|
195
|
+
const { guard, fieldGuard, where: relationWhere, path: targetPath2 } = hop();
|
|
196
|
+
if (Object.keys(relationWhere).length === 0) {
|
|
120
197
|
return conditionBuilder;
|
|
121
198
|
}
|
|
122
|
-
if (isIt.isIt(relation, "joiningColumn")) {
|
|
199
|
+
if (isIt.isIt(relation, "joiningColumn") && Object.keys(guard).length === 0 && Object.keys(fieldGuard).length === 0) {
|
|
123
200
|
const primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary);
|
|
124
201
|
if (primaryCondition !== null) {
|
|
125
202
|
return this.conditionBuilder.build(
|
|
@@ -131,14 +208,21 @@ class WhereBuilder {
|
|
|
131
208
|
);
|
|
132
209
|
}
|
|
133
210
|
}
|
|
134
|
-
joinList.push({
|
|
211
|
+
joinList.push({
|
|
212
|
+
path: targetPath2,
|
|
213
|
+
entity: entity2,
|
|
214
|
+
relationName: relation.name,
|
|
215
|
+
targetSource: this.createGuardedSource(targetEntity, targetPath2, guard),
|
|
216
|
+
joinCondition: fieldGuardCondition(fieldGuard)
|
|
217
|
+
});
|
|
135
218
|
return this.buildRecursive({
|
|
136
219
|
conditionBuilder,
|
|
137
220
|
entity: targetEntity,
|
|
138
|
-
path:
|
|
221
|
+
path: targetPath2,
|
|
139
222
|
where: relationWhere,
|
|
140
223
|
joinList,
|
|
141
|
-
allowManyJoin
|
|
224
|
+
allowManyJoin,
|
|
225
|
+
negated
|
|
142
226
|
});
|
|
143
227
|
};
|
|
144
228
|
conditionBuilder = schemaUtils.acceptFieldVisitor(this.schema, entity, fieldName, {
|
|
@@ -152,14 +236,17 @@ class WhereBuilder {
|
|
|
152
236
|
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
153
237
|
return joinedWhere(context);
|
|
154
238
|
}
|
|
155
|
-
|
|
239
|
+
const { guard, fieldGuard, where: relationWhere, path: targetPath2 } = hop();
|
|
240
|
+
return existsIfReadable(
|
|
241
|
+
fieldGuard,
|
|
156
242
|
this.createManyHasManySubquery(
|
|
157
243
|
[tableName, entity.primaryColumn],
|
|
158
|
-
|
|
244
|
+
relationWhere,
|
|
245
|
+
guard,
|
|
159
246
|
context.targetEntity,
|
|
160
247
|
context.targetRelation.joiningTable,
|
|
161
248
|
"inverse",
|
|
162
|
-
|
|
249
|
+
targetPath2
|
|
163
250
|
)
|
|
164
251
|
);
|
|
165
252
|
},
|
|
@@ -167,15 +254,17 @@ class WhereBuilder {
|
|
|
167
254
|
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
168
255
|
return joinedWhere(context);
|
|
169
256
|
}
|
|
170
|
-
where
|
|
171
|
-
return
|
|
257
|
+
const { guard, fieldGuard, where: relationWhere, path: targetPath2 } = hop();
|
|
258
|
+
return existsIfReadable(
|
|
259
|
+
fieldGuard,
|
|
172
260
|
this.createManyHasManySubquery(
|
|
173
261
|
[tableName, entity.primaryColumn],
|
|
174
|
-
|
|
262
|
+
relationWhere,
|
|
263
|
+
guard,
|
|
175
264
|
context.targetEntity,
|
|
176
265
|
context.relation.joiningTable,
|
|
177
266
|
"owning",
|
|
178
|
-
|
|
267
|
+
targetPath2
|
|
179
268
|
)
|
|
180
269
|
);
|
|
181
270
|
},
|
|
@@ -183,17 +272,43 @@ class WhereBuilder {
|
|
|
183
272
|
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
184
273
|
return joinedWhere(context);
|
|
185
274
|
}
|
|
186
|
-
const relationWhere =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
275
|
+
const { guard, fieldGuard, where: relationWhere, path: targetPath2 } = hop();
|
|
276
|
+
if (this.hasRootIsNull(relationWhere, context.targetEntity)) {
|
|
277
|
+
const subquery = (joinsChildren) => {
|
|
278
|
+
const qb2 = Database.SelectBuilder.create().select((it) => it.raw("1")).from(new Database.Literal(`(select ${Database.wrapIdentifier(tableName)}.${Database.wrapIdentifier(entity.primaryColumn)})`), targetPath2.for("tmp_").alias).leftJoin(
|
|
279
|
+
this.createGuardedSource(context.targetEntity, targetPath2, guard) ?? context.targetEntity.tableName,
|
|
280
|
+
targetPath2.alias,
|
|
281
|
+
(it) => joinsChildren ? it.columnsEq([targetPath2.for("tmp_").alias, entity.primaryColumn], [targetPath2.alias, context.targetRelation.joiningColumn.columnName]) : it.raw("false")
|
|
282
|
+
);
|
|
283
|
+
return this.buildInternal({
|
|
284
|
+
entity: context.targetEntity,
|
|
285
|
+
path: targetPath2,
|
|
286
|
+
where: relationWhere,
|
|
287
|
+
callback: (cb) => qb2.where((clause) => cb(clause)),
|
|
288
|
+
allowManyJoin: true
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
const readable = fieldGuardCondition(fieldGuard);
|
|
292
|
+
if (readable === void 0) {
|
|
293
|
+
return conditionBuilder.exists(subquery(true));
|
|
294
|
+
}
|
|
295
|
+
const withChildren = subquery(true).createQuery(new Database.Compiler.Context(Database.Compiler.SCHEMA_PLACEHOLDER, /* @__PURE__ */ new Set()));
|
|
296
|
+
const withoutChildren = subquery(false).createQuery(new Database.Compiler.Context(Database.Compiler.SCHEMA_PLACEHOLDER, /* @__PURE__ */ new Set()));
|
|
297
|
+
return conditionBuilder.with(
|
|
298
|
+
new Database.Literal(`case when ${readable.sql} then exists (${withChildren.sql}) else exists (${withoutChildren.sql}) end`, [
|
|
299
|
+
...readable.parameters,
|
|
300
|
+
...withChildren.parameters,
|
|
301
|
+
...withoutChildren.parameters
|
|
302
|
+
])
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const qb = Database.SelectBuilder.create().select((it) => it.raw("1")).from(context.targetEntity.tableName, targetPath2.alias).where((it) => it.columnsEq([tableName, entity.primaryColumn], [targetPath2.alias, context.targetRelation.joiningColumn.columnName]));
|
|
306
|
+
return existsIfReadable(
|
|
307
|
+
fieldGuard,
|
|
193
308
|
this.buildInternal({
|
|
194
309
|
entity: context.targetEntity,
|
|
195
|
-
path:
|
|
196
|
-
where: relationWhere,
|
|
310
|
+
path: targetPath2,
|
|
311
|
+
where: this.combineWhereAnd([relationWhere, guard]),
|
|
197
312
|
callback: (cb) => qb.where((clause) => cb(clause)),
|
|
198
313
|
allowManyJoin: true
|
|
199
314
|
})
|
|
@@ -203,12 +318,92 @@ class WhereBuilder {
|
|
|
203
318
|
}
|
|
204
319
|
return conditionBuilder;
|
|
205
320
|
}
|
|
206
|
-
|
|
321
|
+
/**
|
|
322
|
+
* A condition over a cell-level column holds on a masked cell iff it holds on NULL. Outside a negation FALSE and
|
|
323
|
+
* NULL drop the row alike, so only a condition that is TRUE on NULL needs more than `cond AND guard`; under a
|
|
324
|
+
* negation the masked cell must also keep NULL as NULL.
|
|
325
|
+
*/
|
|
326
|
+
buildMaskedCell(conditionBuilder, entity, path, { guard, where }, joinList, allowManyJoin, negated) {
|
|
327
|
+
const compile = (where2) => Database.ConditionBuilder.process((clause) => this.buildRecursive({ conditionBuilder: clause, entity, path, where: where2, joinList, allowManyJoin, negated })).getSql();
|
|
328
|
+
const condition = compile(where);
|
|
329
|
+
if (condition === null) {
|
|
330
|
+
return conditionBuilder;
|
|
331
|
+
}
|
|
332
|
+
const guardCondition = compile(guard);
|
|
333
|
+
if (guardCondition === null) {
|
|
334
|
+
return conditionBuilder.with(condition);
|
|
335
|
+
}
|
|
336
|
+
const onNull = this.evaluateWhereOnNull(where, entity);
|
|
337
|
+
const crispGuard = `coalesce(${guardCondition.sql}, false)`;
|
|
338
|
+
if (onNull === "true") {
|
|
339
|
+
return conditionBuilder.with(new Database.Literal(`(${condition.sql} or not ${crispGuard})`, [...condition.parameters, ...guardCondition.parameters]));
|
|
340
|
+
}
|
|
341
|
+
if (!negated) {
|
|
342
|
+
return conditionBuilder.with(condition).with(guardCondition);
|
|
343
|
+
}
|
|
344
|
+
if (onNull === "false") {
|
|
345
|
+
return conditionBuilder.with(new Database.Literal(`${condition.sql} and ${crispGuard}`, [...condition.parameters, ...guardCondition.parameters]));
|
|
346
|
+
}
|
|
347
|
+
return conditionBuilder.with(
|
|
348
|
+
new Database.Literal(`case when ${crispGuard} then ${condition.sql} end`, [...guardCondition.parameters, ...condition.parameters])
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
/** The three-valued result of a column where on a NULL cell, mirroring how `ConditionBuilder` compiles it. */
|
|
352
|
+
evaluateWhereOnNull(where, entity) {
|
|
353
|
+
const operands = [];
|
|
354
|
+
for (const [key, value] of Object.entries(where)) {
|
|
355
|
+
if (value === null || value === void 0) {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (!schemaUtils.isColumn(entity.fields[key]) || !this.isInputCondition(value)) {
|
|
359
|
+
throw new Error(`WhereBuilder: ${PredicatesInjector.MASKED_CELL_KEY} expects a column condition, got ${entity.name}::${key}`);
|
|
360
|
+
}
|
|
361
|
+
operands.push(this.evaluateConditionOnNull(value));
|
|
362
|
+
}
|
|
363
|
+
return combineNullCellValues(operands, "and");
|
|
364
|
+
}
|
|
365
|
+
evaluateConditionOnNull(condition) {
|
|
366
|
+
const isSet = (value) => value !== null && value !== void 0;
|
|
367
|
+
if (!Object.values(condition).some(isSet)) {
|
|
368
|
+
return "empty";
|
|
369
|
+
}
|
|
370
|
+
if (isSet(condition.and)) {
|
|
371
|
+
return combineNullCellValues(condition.and.map((it) => this.evaluateConditionOnNull(it)), "and");
|
|
372
|
+
}
|
|
373
|
+
if (isSet(condition.or)) {
|
|
374
|
+
return combineNullCellValues(condition.or.map((it) => this.evaluateConditionOnNull(it)), "or");
|
|
375
|
+
}
|
|
376
|
+
if (isSet(condition.not)) {
|
|
377
|
+
const operand = this.evaluateConditionOnNull(condition.not);
|
|
378
|
+
return operand === "true" ? "false" : operand === "false" ? "true" : operand;
|
|
379
|
+
}
|
|
380
|
+
const isNull = condition.isNull ?? condition.null;
|
|
381
|
+
if (isSet(isNull)) {
|
|
382
|
+
return isNull ? "true" : "false";
|
|
383
|
+
}
|
|
384
|
+
if (isSet(condition.always)) {
|
|
385
|
+
return "true";
|
|
386
|
+
}
|
|
387
|
+
if (isSet(condition.never)) {
|
|
388
|
+
return "false";
|
|
389
|
+
}
|
|
390
|
+
if (isSet(condition.in)) {
|
|
391
|
+
return condition.in.some((it) => it !== void 0) ? "unknown" : "false";
|
|
392
|
+
}
|
|
393
|
+
if (isSet(condition.notIn)) {
|
|
394
|
+
return condition.notIn.some((it) => it !== void 0) ? "unknown" : "true";
|
|
395
|
+
}
|
|
396
|
+
return "unknown";
|
|
397
|
+
}
|
|
398
|
+
createGuardedSource(entity, path, guard) {
|
|
399
|
+
return Object.keys(guard).length === 0 ? void 0 : this.buildGuardedSource(entity, path, guard);
|
|
400
|
+
}
|
|
401
|
+
createManyHasManySubquery(outerColumn, relationWhere, guard, targetEntity, joiningTable, fromSide, path) {
|
|
207
402
|
const fromColumn = fromSide === "owning" ? joiningTable.joiningColumn.columnName : joiningTable.inverseJoiningColumn.columnName;
|
|
208
403
|
const toColumn = fromSide === "owning" ? joiningTable.inverseJoiningColumn.columnName : joiningTable.joiningColumn.columnName;
|
|
209
404
|
const junctionPath = path.for("junction_");
|
|
210
405
|
const qb = Database.SelectBuilder.create().from(joiningTable.tableName, junctionPath.alias).select((it) => it.raw("1")).where((it) => it.columnsEq(outerColumn, [junctionPath.alias, fromColumn]));
|
|
211
|
-
const primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary);
|
|
406
|
+
const primaryCondition = Object.keys(guard).length === 0 ? this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary) : null;
|
|
212
407
|
if (primaryCondition !== null) {
|
|
213
408
|
const columnType = targetEntity.fields[targetEntity.primary];
|
|
214
409
|
return qb.where((condition) => this.conditionBuilder.build(condition, junctionPath.alias, toColumn, columnType, primaryCondition));
|
|
@@ -221,11 +416,24 @@ class WhereBuilder {
|
|
|
221
416
|
return this.buildInternal({
|
|
222
417
|
entity: targetEntity,
|
|
223
418
|
path: this.pathFactory.create([], path.fullAlias),
|
|
224
|
-
where: relationWhere,
|
|
419
|
+
where: this.combineWhereAnd([relationWhere, guard]),
|
|
225
420
|
callback: (cb) => qbJoined.where((clause) => cb(clause)),
|
|
226
421
|
allowManyJoin: true
|
|
227
422
|
});
|
|
228
423
|
}
|
|
424
|
+
combineWhereAnd(wheres) {
|
|
425
|
+
const nonEmpty = wheres.filter((it) => Object.keys(it).length > 0);
|
|
426
|
+
if (nonEmpty.length === 0) {
|
|
427
|
+
return {};
|
|
428
|
+
}
|
|
429
|
+
return nonEmpty.length === 1 ? nonEmpty[0] : { and: nonEmpty };
|
|
430
|
+
}
|
|
431
|
+
isInputCondition(value) {
|
|
432
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
433
|
+
}
|
|
434
|
+
isOptionalWhere(value) {
|
|
435
|
+
return value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value);
|
|
436
|
+
}
|
|
229
437
|
transformWhereToPrimaryCondition(where, primaryField) {
|
|
230
438
|
const keys = Object.keys(where);
|
|
231
439
|
if (keys.filter((it) => !["and", "or", "not", primaryField].includes(it)).length > 0) {
|
|
@@ -271,27 +479,33 @@ class WhereBuilder {
|
|
|
271
479
|
if (where.not && this.hasRootIsNull(where.not, entity)) {
|
|
272
480
|
return true;
|
|
273
481
|
}
|
|
274
|
-
} else if (
|
|
275
|
-
|
|
482
|
+
} else if (key === PredicatesInjector.MASKED_CELL_KEY) {
|
|
483
|
+
if (PredicatesInjector.parseMaskedCells(where[key]).some((cell) => this.hasRootIsNull(cell.where, entity) || this.hasRootIsNull(cell.guard, entity))) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
} else if (schemaUtils.isColumn(entity.fields[key])) {
|
|
487
|
+
const condition = where[key];
|
|
488
|
+
if (this.isInputCondition(condition) && this.conditionHasIsNull(condition)) {
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
276
491
|
}
|
|
277
492
|
}
|
|
278
493
|
return false;
|
|
279
494
|
}
|
|
280
495
|
conditionHasIsNull(cond) {
|
|
281
|
-
|
|
282
|
-
return true;
|
|
283
|
-
}
|
|
284
|
-
if (cond.and?.some((it) => this.conditionHasIsNull(it))) {
|
|
285
|
-
return true;
|
|
286
|
-
}
|
|
287
|
-
if (cond.or?.some((it) => this.conditionHasIsNull(it))) {
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
if (cond.not && this.conditionHasIsNull(cond.not)) {
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
496
|
+
return cond.isNull !== void 0 || cond.and?.some((item) => this.conditionHasIsNull(item)) === true || cond.or?.some((item) => this.conditionHasIsNull(item)) === true || cond.not !== void 0 && this.conditionHasIsNull(cond.not);
|
|
294
497
|
}
|
|
295
498
|
}
|
|
499
|
+
const combineNullCellValues = (operands, operator) => {
|
|
500
|
+
const present = operands.filter((it) => it !== "empty");
|
|
501
|
+
if (present.length === 0) {
|
|
502
|
+
return "empty";
|
|
503
|
+
}
|
|
504
|
+
const dominant = operator === "and" ? "false" : "true";
|
|
505
|
+
if (present.includes(dominant)) {
|
|
506
|
+
return dominant;
|
|
507
|
+
}
|
|
508
|
+
return present.includes("unknown") ? "unknown" : operator === "and" ? "true" : "false";
|
|
509
|
+
};
|
|
296
510
|
exports.WhereBuilder = WhereBuilder;
|
|
297
511
|
//# sourceMappingURL=WhereBuilder.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhereBuilder.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/select/WhereBuilder.ts"],"sourcesContent":["import { isIt } from '../../utils/index.js'\nimport { acceptFieldVisitor, isColumn } from '@contember/schema-utils'\nimport { Input, Model } from '@contember/schema'\nimport { Path, PathFactory } from './Path.js'\nimport { JoinBuilder } from './JoinBuilder.js'\nimport { ConditionBuilder } from './ConditionBuilder.js'\nimport { ConditionBuilder as SqlConditionBuilder, Literal, Operator, QueryBuilder, SelectBuilder, wrapIdentifier } from '@contember/database'\nimport { WhereOptimizationHints, WhereOptimizer } from './optimizer/WhereOptimizer.js'\n\nexport class WhereBuilder {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly joinBuilder: JoinBuilder,\n\t\tprivate readonly conditionBuilder: ConditionBuilder,\n\t\tprivate readonly pathFactory: PathFactory,\n\t\tprivate readonly whereOptimizer: WhereOptimizer,\n\t\tprivate readonly useExistsInHasManyFilter: boolean,\n\t) {}\n\n\tpublic build<R extends SelectBuilder.Result>(\n\t\tqb: SelectBuilder<R>,\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\twhere: Input.OptionalWhere,\n\t\toptimizationHints: WhereOptimizationHints = {},\n\t): SelectBuilder<R> {\n\t\tconst optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)\n\t\treturn this.buildInternal({\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere: optimizedWhere,\n\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\tallowManyJoin: false,\n\t\t})\n\t}\n\n\tpublic buildAdvanced<R extends SelectBuilder.Result>(\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\twhere: Input.OptionalWhere,\n\t\tcallback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<R>,\n\t\toptimizationHints: WhereOptimizationHints = {},\n\t): SelectBuilder<R> {\n\t\tconst optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)\n\t\treturn this.buildInternal({\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere: optimizedWhere,\n\t\t\tcallback,\n\t\t\tallowManyJoin: false,\n\t\t})\n\t}\n\n\tprivate buildInternal<R extends SelectBuilder.Result>({\n\t\tcallback,\n\t\t...args\n\t}: {\n\t\tentity: Model.Entity\n\t\tpath: Path\n\t\twhere: Input.OptionalWhere\n\t\tcallback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<R>\n\t\tallowManyJoin: boolean\n\t}): SelectBuilder<R> {\n\t\tconst joinList: WhereJoinDefinition[] = []\n\n\t\tconst qbWithWhere = callback(clause =>\n\t\t\tthis.buildRecursive({\n\t\t\t\tconditionBuilder: clause,\n\t\t\t\tjoinList: joinList,\n\t\t\t\t...args,\n\t\t\t})\n\t\t)\n\t\treturn joinList.reduce<SelectBuilder<R>>(\n\t\t\t(qb, { path, entity, relationName }) => this.joinBuilder.join<R>(qb, path, entity, relationName),\n\t\t\tqbWithWhere,\n\t\t)\n\t}\n\n\tprivate buildRecursive({\n\t\tconditionBuilder,\n\t\tentity,\n\t\tpath,\n\t\twhere,\n\t\tjoinList,\n\t\tallowManyJoin,\n\t}: {\n\t\tconditionBuilder: SqlConditionBuilder\n\t\tentity: Model.Entity\n\t\tpath: Path\n\t\twhere: Input.OptionalWhere\n\t\tjoinList: WhereJoinDefinition[]\n\t\tallowManyJoin: boolean\n\t}): SqlConditionBuilder {\n\t\tconst tableName = path.alias\n\n\t\tif (where.and !== undefined && where.and !== null && where.and.length > 0) {\n\t\t\tconst expr = where.and\n\t\t\tconditionBuilder = conditionBuilder.and(clause =>\n\t\t\t\texpr.reduce(\n\t\t\t\t\t(clause2, where) =>\n\t\t\t\t\t\t!where ? clause2 : this.buildRecursive({\n\t\t\t\t\t\t\tconditionBuilder: clause2,\n\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\tjoinList,\n\t\t\t\t\t\t\tallowManyJoin,\n\t\t\t\t\t\t}),\n\t\t\t\t\tclause,\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\tif (where.or !== undefined && where.or !== null && where.or.length > 0) {\n\t\t\tconst expr = where.or\n\t\t\tconditionBuilder = conditionBuilder.or(clause =>\n\t\t\t\texpr.reduce(\n\t\t\t\t\t(clause2, where) =>\n\t\t\t\t\t\t!where\n\t\t\t\t\t\t\t? clause2\n\t\t\t\t\t\t\t: clause2.and(clause3 =>\n\t\t\t\t\t\t\t\tthis.buildRecursive({\n\t\t\t\t\t\t\t\t\tconditionBuilder: clause3,\n\t\t\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\t\t\tjoinList,\n\t\t\t\t\t\t\t\t\tallowManyJoin,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\tclause,\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\tif (where.not !== undefined && where.not !== null) {\n\t\t\tconst expr = where.not\n\t\t\tconditionBuilder = conditionBuilder.not(clause =>\n\t\t\t\tthis.buildRecursive({\n\t\t\t\t\tconditionBuilder: clause,\n\t\t\t\t\tentity,\n\t\t\t\t\tpath,\n\t\t\t\t\twhere: expr,\n\t\t\t\t\tjoinList,\n\t\t\t\t\tallowManyJoin,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\n\t\tfor (const fieldName in where) {\n\t\t\tif (fieldName === 'and' || fieldName === 'or' || fieldName === 'not') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst fieldWhere = where[fieldName]\n\t\t\tif (!fieldWhere) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst targetPath = path.for(fieldName)\n\n\t\t\tconst joinedWhere = ({ targetEntity, relation, entity }: Model.AnyRelationContext): SqlConditionBuilder => {\n\t\t\t\tconst relationWhere = where[fieldName] as Input.OptionalWhere | null\n\t\t\t\tif (!relationWhere || Object.keys(relationWhere).length === 0) {\n\t\t\t\t\treturn conditionBuilder\n\t\t\t\t}\n\t\t\t\tif (isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\tconst primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary)\n\t\t\t\t\tif (primaryCondition !== null) {\n\t\t\t\t\t\treturn this.conditionBuilder.build(\n\t\t\t\t\t\t\tconditionBuilder,\n\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\trelation.joiningColumn.columnName,\n\t\t\t\t\t\t\ttargetEntity.fields[targetEntity.primary] as Model.AnyColumn,\n\t\t\t\t\t\t\tprimaryCondition,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tjoinList.push({ path: targetPath, entity, relationName: relation.name })\n\n\t\t\t\treturn this.buildRecursive({\n\t\t\t\t\tconditionBuilder,\n\t\t\t\t\tentity: targetEntity,\n\t\t\t\t\tpath: targetPath,\n\t\t\t\t\twhere: relationWhere,\n\t\t\t\t\tjoinList,\n\t\t\t\t\tallowManyJoin,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconditionBuilder = acceptFieldVisitor<SqlConditionBuilder>(this.schema, entity, fieldName, {\n\t\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\t\treturn this.conditionBuilder.build(conditionBuilder, tableName, column.columnName, column, fieldWhere as Input.Condition<Input.ColumnValue>)\n\t\t\t\t},\n\t\t\t\tvisitOneHasOneInverse: joinedWhere,\n\t\t\t\tvisitOneHasOneOwning: joinedWhere,\n\t\t\t\tvisitManyHasOne: joinedWhere,\n\t\t\t\tvisitManyHasManyInverse: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn conditionBuilder.exists(\n\t\t\t\t\t\tthis.createManyHasManySubquery(\n\t\t\t\t\t\t\t[tableName, entity.primaryColumn],\n\t\t\t\t\t\t\tfieldWhere as Input.OptionalWhere,\n\t\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\t\tcontext.targetRelation.joiningTable,\n\t\t\t\t\t\t\t'inverse',\n\t\t\t\t\t\t\ttargetPath,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\tvisitManyHasManyOwning: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relationWhere = where[fieldName] as Input.Where | null\n\n\t\t\t\t\treturn conditionBuilder.exists(\n\t\t\t\t\t\tthis.createManyHasManySubquery(\n\t\t\t\t\t\t\t[tableName, entity.primaryColumn],\n\t\t\t\t\t\t\tfieldWhere as Input.OptionalWhere,\n\t\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\t\tcontext.relation.joiningTable,\n\t\t\t\t\t\t\t'owning',\n\t\t\t\t\t\t\ttargetPath,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\tvisitOneHasMany: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relationWhere = fieldWhere as Input.OptionalWhere\n\n\t\t\t\t\tconst qb = this.hasRootIsNull(relationWhere, context.targetEntity)\n\t\t\t\t\t\t? SelectBuilder.create()\n\t\t\t\t\t\t\t.select(it => it.raw('1'))\n\t\t\t\t\t\t\t.from(new Literal(`(select ${wrapIdentifier(tableName)}.${wrapIdentifier(entity.primaryColumn)})`), targetPath.for('tmp_').alias)\n\t\t\t\t\t\t\t.leftJoin(\n\t\t\t\t\t\t\t\tcontext.targetEntity.tableName,\n\t\t\t\t\t\t\t\ttargetPath.alias,\n\t\t\t\t\t\t\t\tit => it.columnsEq([targetPath.for('tmp_').alias, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName]),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: SelectBuilder.create()\n\t\t\t\t\t\t\t.select(it => it.raw('1'))\n\t\t\t\t\t\t\t.from(context.targetEntity.tableName, targetPath.alias)\n\t\t\t\t\t\t\t.where(it => it.columnsEq([tableName, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName]))\n\n\t\t\t\t\treturn conditionBuilder.exists(\n\t\t\t\t\t\tthis.buildInternal({\n\t\t\t\t\t\t\tentity: context.targetEntity,\n\t\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\t\twhere: relationWhere,\n\t\t\t\t\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\t\t\t\t\tallowManyJoin: true,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn conditionBuilder\n\t}\n\n\tprivate createManyHasManySubquery(\n\t\touterColumn: QueryBuilder.ColumnIdentifier,\n\t\trelationWhere: Input.OptionalWhere,\n\t\ttargetEntity: Model.Entity,\n\t\tjoiningTable: Model.JoiningTable,\n\t\tfromSide: 'owning' | 'inverse',\n\t\tpath: Path,\n\t) {\n\t\tconst fromColumn = fromSide === 'owning' ? joiningTable.joiningColumn.columnName : joiningTable.inverseJoiningColumn.columnName\n\t\tconst toColumn = fromSide === 'owning' ? joiningTable.inverseJoiningColumn.columnName : joiningTable.joiningColumn.columnName\n\t\tconst junctionPath = path.for('junction_')\n\t\tconst qb = SelectBuilder.create<SelectBuilder.Result>()\n\t\t\t.from(joiningTable.tableName, junctionPath.alias)\n\t\t\t.select(it => it.raw('1'))\n\t\t\t.where(it => it.columnsEq(outerColumn, [junctionPath.alias, fromColumn]))\n\n\t\tconst primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary)\n\t\tif (primaryCondition !== null) {\n\t\t\tconst columnType = targetEntity.fields[targetEntity.primary] as Model.AnyColumn\n\n\t\t\treturn qb.where(condition => this.conditionBuilder.build(condition, junctionPath.alias, toColumn, columnType, primaryCondition))\n\t\t}\n\n\t\tconst qbJoined = qb.join(\n\t\t\ttargetEntity.tableName,\n\t\t\tpath.alias,\n\t\t\tclause => clause.compareColumns([junctionPath.alias, toColumn], Operator.eq, [path.alias, targetEntity.primary]),\n\t\t)\n\t\treturn this.buildInternal({\n\t\t\tentity: targetEntity,\n\t\t\tpath: this.pathFactory.create([], path.fullAlias),\n\t\t\twhere: relationWhere,\n\t\t\tcallback: cb => qbJoined.where(clause => cb(clause)),\n\t\t\tallowManyJoin: true,\n\t\t})\n\t}\n\n\tprivate transformWhereToPrimaryCondition(where: Input.OptionalWhere, primaryField: string): Input.Condition<never> | null {\n\t\tconst keys = Object.keys(where)\n\t\tif (keys.filter(it => !['and', 'or', 'not', primaryField].includes(it)).length > 0) {\n\t\t\treturn null\n\t\t}\n\t\tlet condition: {\n\t\t\tand?: Array<Input.Condition<never>>\n\t\t\tor?: Array<Input.Condition<never>>\n\t\t\tnot?: Input.Condition<never>\n\t\t} = {}\n\t\tif (where.and) {\n\t\t\tconst conditions = where.and\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.transformWhereToPrimaryCondition(it, primaryField))\n\t\t\tif (conditions.includes(null)) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.and = conditions as Input.Condition<never>[]\n\t\t}\n\t\tif (where.or) {\n\t\t\tconst conditions = where.or\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.transformWhereToPrimaryCondition(it, primaryField))\n\t\t\tif (conditions.includes(null)) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.or = conditions as Input.Condition<never>[]\n\t\t}\n\t\tif (where.not) {\n\t\t\tconst conditions = this.transformWhereToPrimaryCondition(where.not, primaryField)\n\t\t\tif (conditions === null) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.not = conditions as Input.Condition<never>\n\t\t}\n\t\tif (where[primaryField]) {\n\t\t\tif (Object.keys(condition).length > 0) {\n\t\t\t\treturn { and: [condition, where[primaryField] as Input.Condition<never>] }\n\t\t\t}\n\t\t\treturn where[primaryField] as Input.Condition<never>\n\t\t}\n\t\treturn condition\n\t}\n\n\tprivate hasRootIsNull(where: Input.OptionalWhere, entity: Model.Entity): boolean {\n\t\tfor (const key in where) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\tif (where[key]?.some(it => it && this.hasRootIsNull(it, entity))) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else if (key === 'not') {\n\t\t\t\tif (where.not && this.hasRootIsNull(where.not, entity)) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else if (isColumn(entity.fields[key]) && this.conditionHasIsNull(where[key] as Input.Condition)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\tprivate conditionHasIsNull(cond: Input.Condition): boolean {\n\t\tif (cond.isNull !== undefined) {\n\t\t\treturn true\n\t\t}\n\t\tif (cond.and?.some(it => this.conditionHasIsNull(it))) {\n\t\t\treturn true\n\t\t}\n\t\tif (cond.or?.some(it => this.conditionHasIsNull(it))) {\n\t\t\treturn true\n\t\t}\n\t\tif (cond.not && this.conditionHasIsNull(cond.not)) {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n}\n\nexport type WhereJoinDefinition = { path: Path; entity: Model.Entity; relationName: string }\n"],"names":["where","entity","isIt","acceptFieldVisitor","SelectBuilder","Literal","wrapIdentifier","Operator","isColumn"],"mappings":";;;;;AASO,MAAM,aAAa;AAAA,EACzB,YACkB,QACA,aACA,kBACA,aACA,gBACA,0BAChB;AANgB,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AACA,SAAA,cAAA;AACA,SAAA,iBAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,MACN,IACA,QACA,MACA,OACA,oBAA4C,IACzB;AACnB,UAAM,iBAAiB,KAAK,eAAe,SAAS,OAAO,QAAQ,iBAAiB;AACpF,WAAO,KAAK,cAAc;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,UAAU,CAAA,OAAM,GAAG,MAAM,CAAA,WAAU,GAAG,MAAM,CAAC;AAAA,MAC7C,eAAe;AAAA,IAAA,CACf;AAAA,EACF;AAAA,EAEO,cACN,QACA,MACA,OACA,UACA,oBAA4C,IACzB;AACnB,UAAM,iBAAiB,KAAK,eAAe,SAAS,OAAO,QAAQ,iBAAiB;AACpF,WAAO,KAAK,cAAc;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,eAAe;AAAA,IAAA,CACf;AAAA,EACF;AAAA,EAEQ,cAA8C;AAAA,IACrD;AAAA,IACA,GAAG;AAAA,EAAA,GAOiB;AACpB,U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ChF,UAAI,eAAe,MAAM;AACxB,eAAO;AAAA,MACR;AACA,gBAAU,MAAM;AAAA,IACjB;AACA,QAAI,MAAM,YAAY,GAAG;AACxB,UAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACtC,eAAO,EAAE,KAAK,CAAC,WAAW,MAAM,YAAY,CAA2B,EAAA;AAAA,MACxE;AACA,aAAO,MAAM,YAAY;AAAA,IAC1B;AACA,WAAO;AAAA,EACR;AAAA,EAEQ,cAAc,OAA4B,QAA+B;AAChF,eAAW,OAAO,OAAO;AACxB,UAAI,QAAQ,SAAS,QAAQ,MAAM;AAClC,YAAI,MAAM,GAAG,GAAG,KAAK,CAAA,OAAM,MAAM,KAAK,cAAc,IAAI,MAAM,CAAC,GAAG;AACjE,iBAAO;AAAA,QACR;AAAA,MACD,WAAW,QAAQ,OAAO;AACzB,YAAI,MAAM,OAAO,KAAK,cAAc,MAAM,KAAK,MAAM,GAAG;AACvD,iBAAO;AAAA,QACR;AAAA,MACD,WAAWC,YAAAA,SAAS,OAAO,OAAO,GAAG,CAAC,KAAK,KAAK,mBAAmB,MAAM,GAAG,CAAoB,GAAG;AAClG,eAAO;AAAA,MACR;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EAEQ,mBAAmB,MAAgC;AAC1D,QAAI,KAAK,WAAW,QAAW;AAC9B,aAAO;AAAA,IACR;AACA,QAAI,KAAK,KAAK,KAAK,CAAA,OAAM,KAAK,mBAAmB,EAAE,CAAC,GAAG;AACtD,aAAO;AAAA,IACR;AACA,QAAI,KAAK,IAAI,KAAK,CAAA,OAAM,KAAK,mBAAmB,EAAE,CAAC,GAAG;AACrD,aAAO;AAAA,IACR;AACA,QAAI,KAAK,OAAO,KAAK,mBAAmB,KAAK,GAAG,GAAG;AAClD,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AACD;;"}
|
|
1
|
+
{"version":3,"file":"WhereBuilder.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/select/WhereBuilder.ts"],"sourcesContent":["import { isIt } from '../../utils/index.js'\nimport { acceptFieldVisitor, isColumn } from '@contember/schema-utils'\nimport { Input, Model } from '@contember/schema'\nimport { hopPathSegment, Path, PathFactory } from './Path.js'\nimport { JoinBuilder } from './JoinBuilder.js'\nimport { ConditionBuilder } from './ConditionBuilder.js'\nimport {\n\tCompiler,\n\tConditionBuilder as SqlConditionBuilder,\n\tLiteral,\n\tOperator,\n\tQueryBuilder,\n\tSelectBuilder,\n\twrapIdentifier,\n} from '@contember/database'\nimport { WhereOptimizationHints, WhereOptimizer } from './optimizer/WhereOptimizer.js'\nimport { MASKED_CELL_KEY, MaskedCell, parseMaskedCells, splitReadGuard } from '../../acl/PredicatesInjector.js'\n\n/**\n * A user-authored relation hop: the remaining condition on the target rows and the target's row-level read\n * guard (see `READ_GUARD_KEY`). The guard is compiled into the hop's table source, never into its condition,\n * so an unreadable target row behaves exactly like an absent one under any boolean shape.\n */\ntype RelationHop = { where: Input.OptionalWhere; guard: Input.OptionalWhere; fieldGuard: Input.OptionalWhere; path: Path }\n\nexport class WhereBuilder {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly joinBuilder: JoinBuilder,\n\t\tprivate readonly conditionBuilder: ConditionBuilder,\n\t\tprivate readonly pathFactory: PathFactory,\n\t\tprivate readonly whereOptimizer: WhereOptimizer,\n\t\tprivate readonly useExistsInHasManyFilter: boolean,\n\t) {}\n\n\tpublic build<R extends SelectBuilder.Result>(\n\t\tqb: SelectBuilder<R>,\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\twhere: Input.OptionalWhere,\n\t\toptimizationHints: WhereOptimizationHints = {},\n\t): SelectBuilder<R> {\n\t\tconst optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)\n\t\treturn this.buildInternal({\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere: optimizedWhere,\n\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\tallowManyJoin: false,\n\t\t})\n\t}\n\n\tpublic buildAdvanced<R extends SelectBuilder.Result>(\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\twhere: Input.OptionalWhere,\n\t\tcallback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<R>,\n\t\toptimizationHints: WhereOptimizationHints = {},\n\t): SelectBuilder<R> {\n\t\tconst optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)\n\t\treturn this.buildInternal({\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere: optimizedWhere,\n\t\t\tcallback,\n\t\t\tallowManyJoin: false,\n\t\t})\n\t}\n\n\t/**\n\t * Compiles a where into a single boolean SQL condition (a `Literal`), applying any relation joins it needs\n\t * to `qb`. Shared by the read-predicate consumers that need the condition as an expression rather than a\n\t * WHERE clause: the projection predicate column (selected as a boolean) and the order-by guard (wrapped in\n\t * `CASE WHEN <condition> THEN <column> END`). An empty/trivially-true predicate compiles to `true`.\n\t */\n\tpublic buildConditionLiteral<R extends SelectBuilder.Result>(\n\t\tqb: SelectBuilder<R>,\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\twhere: Input.OptionalWhere,\n\t\toptimizationHints: WhereOptimizationHints = {},\n\t): { qb: SelectBuilder<R>; condition: Literal } {\n\t\tlet condition: Literal = new Literal('true')\n\t\tconst resultQb = this.buildAdvanced<R>(\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere,\n\t\t\tapplyCondition => {\n\t\t\t\tcondition = SqlConditionBuilder.process(clause => {\n\t\t\t\t\tconst applied = applyCondition(clause)\n\t\t\t\t\treturn applied.isEmpty() ? applied.raw('true') : applied\n\t\t\t\t}).getSql() ?? new Literal('true')\n\t\t\t\treturn qb\n\t\t\t},\n\t\t\toptimizationHints,\n\t\t)\n\t\treturn { qb: resultQb, condition }\n\t}\n\n\t/**\n\t * The table source of a relation hop restricted to rows satisfying `guard` (the target's row-level read\n\t * predicate): `(select <alias>.* from <table> as <alias> where <guard>)`. LEFT JOINing this source\n\t * null-extends an unreadable row exactly like an absent one. The guard is compiled as-definer — its own\n\t * relation hops are plain joins — and Postgres pulls the subquery up into the outer join tree.\n\t */\n\tpublic buildGuardedSource(entity: Model.Entity, path: Path, guard: Input.OptionalWhere): Literal {\n\t\tconst qb = SelectBuilder.create()\n\t\t\t.select(expr => expr.raw(`${wrapIdentifier(path.alias)}.*`))\n\t\t\t.from(entity.tableName, path.alias)\n\t\tconst guarded = this.buildInternal({\n\t\t\tentity,\n\t\t\tpath,\n\t\t\twhere: this.whereOptimizer.optimize(guard, entity),\n\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\tallowManyJoin: false,\n\t\t})\n\t\tconst query = guarded.createQuery(new Compiler.Context(Compiler.SCHEMA_PLACEHOLDER, new Set()))\n\t\treturn new Literal(`(${query.sql})`, query.parameters)\n\t}\n\n\tprivate buildInternal<R extends SelectBuilder.Result>({\n\t\tcallback,\n\t\t...args\n\t}: {\n\t\tentity: Model.Entity\n\t\tpath: Path\n\t\twhere: Input.OptionalWhere\n\t\tcallback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<R>\n\t\tallowManyJoin: boolean\n\t}): SelectBuilder<R> {\n\t\tconst joinList: WhereJoinDefinition[] = []\n\n\t\t// Every (sub)query starts unnegated: an EXISTS yields TRUE or FALSE, so a `not` around it does not reach in.\n\t\tconst qbWithWhere = callback(clause =>\n\t\t\tthis.buildRecursive({\n\t\t\t\tconditionBuilder: clause,\n\t\t\t\tjoinList: joinList,\n\t\t\t\t...args,\n\t\t\t\tnegated: false,\n\t\t\t})\n\t\t)\n\t\treturn joinList.reduce<SelectBuilder<R>>(\n\t\t\t(qb, { path, entity, relationName, targetSource, joinCondition }) =>\n\t\t\t\tthis.joinBuilder.join<R>(qb, path, entity, relationName, targetSource, joinCondition),\n\t\t\tqbWithWhere,\n\t\t)\n\t}\n\n\tprivate buildRecursive({\n\t\tconditionBuilder,\n\t\tentity,\n\t\tpath,\n\t\twhere,\n\t\tjoinList,\n\t\tallowManyJoin,\n\t\tnegated,\n\t}: {\n\t\tconditionBuilder: SqlConditionBuilder\n\t\tentity: Model.Entity\n\t\tpath: Path\n\t\twhere: Input.OptionalWhere\n\t\tjoinList: WhereJoinDefinition[]\n\t\tallowManyJoin: boolean\n\t\t/** Odd number of enclosing `not`s within the current (sub)query. */\n\t\tnegated: boolean\n\t}): SqlConditionBuilder {\n\t\tconst tableName = path.alias\n\n\t\tif (where.and !== undefined && where.and !== null && where.and.length > 0) {\n\t\t\tconst expr = where.and\n\t\t\tconditionBuilder = conditionBuilder.and(clause =>\n\t\t\t\texpr.reduce(\n\t\t\t\t\t(clause2, where) =>\n\t\t\t\t\t\t!where ? clause2 : this.buildRecursive({\n\t\t\t\t\t\t\tconditionBuilder: clause2,\n\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\tjoinList,\n\t\t\t\t\t\t\tallowManyJoin,\n\t\t\t\t\t\t\tnegated,\n\t\t\t\t\t\t}),\n\t\t\t\t\tclause,\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\tif (where.or !== undefined && where.or !== null && where.or.length > 0) {\n\t\t\tconst expr = where.or\n\t\t\tconditionBuilder = conditionBuilder.or(clause =>\n\t\t\t\texpr.reduce(\n\t\t\t\t\t(clause2, where) =>\n\t\t\t\t\t\t!where\n\t\t\t\t\t\t\t? clause2\n\t\t\t\t\t\t\t: clause2.and(clause3 =>\n\t\t\t\t\t\t\t\tthis.buildRecursive({\n\t\t\t\t\t\t\t\t\tconditionBuilder: clause3,\n\t\t\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\twhere,\n\t\t\t\t\t\t\t\t\tjoinList,\n\t\t\t\t\t\t\t\t\tallowManyJoin,\n\t\t\t\t\t\t\t\t\tnegated,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\tclause,\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\tif (where.not !== undefined && where.not !== null) {\n\t\t\tconst expr = where.not\n\t\t\tconditionBuilder = conditionBuilder.not(clause =>\n\t\t\t\tthis.buildRecursive({\n\t\t\t\t\tconditionBuilder: clause,\n\t\t\t\t\tentity,\n\t\t\t\t\tpath,\n\t\t\t\t\twhere: expr,\n\t\t\t\t\tjoinList,\n\t\t\t\t\tallowManyJoin,\n\t\t\t\t\tnegated: !negated,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\n\t\tfor (const fieldName in where) {\n\t\t\tif (fieldName === 'and' || fieldName === 'or' || fieldName === 'not') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst fieldWhere = where[fieldName]\n\t\t\tif (!fieldWhere) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (fieldName === MASKED_CELL_KEY) {\n\t\t\t\tconditionBuilder = parseMaskedCells(fieldWhere).reduce(\n\t\t\t\t\t(builder, cell) => this.buildMaskedCell(builder, entity, path, cell, joinList, allowManyJoin, negated),\n\t\t\t\t\tconditionBuilder,\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst targetPath = path.for(fieldName)\n\t\t\tconst hop = (): RelationHop => {\n\t\t\t\tif (!this.isOptionalWhere(fieldWhere)) {\n\t\t\t\t\tthrow new Error(`WhereBuilder: ${entity.name}::${fieldName} expects a relation where`)\n\t\t\t\t}\n\t\t\t\tconst { guard, fieldGuard, where: relationWhere } = splitReadGuard(fieldWhere)\n\t\t\t\tconst guards = { row: Object.keys(guard).length > 0, field: Object.keys(fieldGuard).length > 0 }\n\t\t\t\treturn { guard, fieldGuard, where: relationWhere, path: guards.row || guards.field ? path.for(hopPathSegment(fieldName, guards)) : targetPath }\n\t\t\t}\n\t\t\t// A masked relation field reads empty: the hop sees no related row where its field guard does not hold.\n\t\t\tconst fieldGuardCondition = (fieldGuard: Input.OptionalWhere): Literal | undefined => {\n\t\t\t\tif (Object.keys(fieldGuard).length === 0) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst condition = SqlConditionBuilder.process(clause =>\n\t\t\t\t\tthis.buildRecursive({ conditionBuilder: clause, entity, path, where: fieldGuard, joinList, allowManyJoin, negated: false })\n\t\t\t\t).getSql()\n\t\t\t\treturn condition === null ? undefined : new Literal(`coalesce(${condition.sql}, false)`, condition.parameters)\n\t\t\t}\n\t\t\tconst existsIfReadable = (fieldGuard: Input.OptionalWhere, subquery: SelectBuilder<SelectBuilder.Result>): SqlConditionBuilder => {\n\t\t\t\tconst readable = fieldGuardCondition(fieldGuard)\n\t\t\t\treturn readable === undefined ? conditionBuilder.exists(subquery) : conditionBuilder.and(clause => clause.with(readable).exists(subquery))\n\t\t\t}\n\n\t\t\tconst joinedWhere = (context: Model.AnyRelationContext): SqlConditionBuilder => {\n\t\t\t\tconst { targetEntity, relation, entity } = context\n\t\t\t\tconst { guard, fieldGuard, where: relationWhere, path: targetPath } = hop()\n\t\t\t\tif (Object.keys(relationWhere).length === 0) {\n\t\t\t\t\treturn conditionBuilder\n\t\t\t\t}\n\t\t\t\t// The FK shortcut skips the join, so it is only valid while every target row is readable.\n\t\t\t\tif (isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn') && Object.keys(guard).length === 0 && Object.keys(fieldGuard).length === 0) {\n\t\t\t\t\tconst primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary)\n\t\t\t\t\tif (primaryCondition !== null) {\n\t\t\t\t\t\treturn this.conditionBuilder.build(\n\t\t\t\t\t\t\tconditionBuilder,\n\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\trelation.joiningColumn.columnName,\n\t\t\t\t\t\t\ttargetEntity.fields[targetEntity.primary] as Model.AnyColumn,\n\t\t\t\t\t\t\tprimaryCondition,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tjoinList.push({\n\t\t\t\t\tpath: targetPath,\n\t\t\t\t\tentity,\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\ttargetSource: this.createGuardedSource(targetEntity, targetPath, guard),\n\t\t\t\t\tjoinCondition: fieldGuardCondition(fieldGuard),\n\t\t\t\t})\n\n\t\t\t\treturn this.buildRecursive({\n\t\t\t\t\tconditionBuilder,\n\t\t\t\t\tentity: targetEntity,\n\t\t\t\t\tpath: targetPath,\n\t\t\t\t\twhere: relationWhere,\n\t\t\t\t\tjoinList,\n\t\t\t\t\tallowManyJoin,\n\t\t\t\t\tnegated,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconditionBuilder = acceptFieldVisitor<SqlConditionBuilder>(this.schema, entity, fieldName, {\n\t\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\t\treturn this.conditionBuilder.build(conditionBuilder, tableName, column.columnName, column, fieldWhere as Input.Condition<Input.ColumnValue>)\n\t\t\t\t},\n\t\t\t\tvisitOneHasOneInverse: joinedWhere,\n\t\t\t\tvisitOneHasOneOwning: joinedWhere,\n\t\t\t\tvisitManyHasOne: joinedWhere,\n\t\t\t\tvisitManyHasManyInverse: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\t\t\t\t\tconst { guard, fieldGuard, where: relationWhere, path: targetPath } = hop()\n\n\t\t\t\t\treturn existsIfReadable(\n\t\t\t\t\t\tfieldGuard,\n\t\t\t\t\t\tthis.createManyHasManySubquery(\n\t\t\t\t\t\t\t[tableName, entity.primaryColumn],\n\t\t\t\t\t\t\trelationWhere,\n\t\t\t\t\t\t\tguard,\n\t\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\t\tcontext.targetRelation.joiningTable,\n\t\t\t\t\t\t\t'inverse',\n\t\t\t\t\t\t\ttargetPath,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\tvisitManyHasManyOwning: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\t\t\t\t\tconst { guard, fieldGuard, where: relationWhere, path: targetPath } = hop()\n\n\t\t\t\t\treturn existsIfReadable(\n\t\t\t\t\t\tfieldGuard,\n\t\t\t\t\t\tthis.createManyHasManySubquery(\n\t\t\t\t\t\t\t[tableName, entity.primaryColumn],\n\t\t\t\t\t\t\trelationWhere,\n\t\t\t\t\t\t\tguard,\n\t\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\t\tcontext.relation.joiningTable,\n\t\t\t\t\t\t\t'owning',\n\t\t\t\t\t\t\ttargetPath,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\tvisitOneHasMany: context => {\n\t\t\t\t\tif (allowManyJoin && !this.useExistsInHasManyFilter) {\n\t\t\t\t\t\treturn joinedWhere(context)\n\t\t\t\t\t}\n\t\t\t\t\tconst { guard, fieldGuard, where: relationWhere, path: targetPath } = hop()\n\n\t\t\t\t\tif (this.hasRootIsNull(relationWhere, context.targetEntity)) {\n\t\t\t\t\t\t// The null-extended row of the LEFT JOIN makes a parent without (readable) children match a\n\t\t\t\t\t\t// column `isNull`; the guarded source keeps unreadable children out of the join.\n\t\t\t\t\t\tconst subquery = (joinsChildren: boolean) => {\n\t\t\t\t\t\t\tconst qb = SelectBuilder.create()\n\t\t\t\t\t\t\t\t.select(it => it.raw('1'))\n\t\t\t\t\t\t\t\t.from(new Literal(`(select ${wrapIdentifier(tableName)}.${wrapIdentifier(entity.primaryColumn)})`), targetPath.for('tmp_').alias)\n\t\t\t\t\t\t\t\t.leftJoin(\n\t\t\t\t\t\t\t\t\tthis.createGuardedSource(context.targetEntity, targetPath, guard) ?? context.targetEntity.tableName,\n\t\t\t\t\t\t\t\t\ttargetPath.alias,\n\t\t\t\t\t\t\t\t\tit =>\n\t\t\t\t\t\t\t\t\t\tjoinsChildren\n\t\t\t\t\t\t\t\t\t\t\t? it.columnsEq([targetPath.for('tmp_').alias, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName])\n\t\t\t\t\t\t\t\t\t\t\t: it.raw('false'),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn this.buildInternal({\n\t\t\t\t\t\t\t\tentity: context.targetEntity,\n\t\t\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\t\t\twhere: relationWhere,\n\t\t\t\t\t\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\t\t\t\t\t\tallowManyJoin: true,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst readable = fieldGuardCondition(fieldGuard)\n\t\t\t\t\t\tif (readable === undefined) {\n\t\t\t\t\t\t\treturn conditionBuilder.exists(subquery(true))\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A masked relation is evaluated on the null-extended row alone, like a parent without children.\n\t\t\t\t\t\tconst withChildren = subquery(true).createQuery(new Compiler.Context(Compiler.SCHEMA_PLACEHOLDER, new Set()))\n\t\t\t\t\t\tconst withoutChildren = subquery(false).createQuery(new Compiler.Context(Compiler.SCHEMA_PLACEHOLDER, new Set()))\n\t\t\t\t\t\treturn conditionBuilder.with(\n\t\t\t\t\t\t\tnew Literal(`case when ${readable.sql} then exists (${withChildren.sql}) else exists (${withoutChildren.sql}) end`, [\n\t\t\t\t\t\t\t\t...readable.parameters,\n\t\t\t\t\t\t\t\t...withChildren.parameters,\n\t\t\t\t\t\t\t\t...withoutChildren.parameters,\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst qb = SelectBuilder.create()\n\t\t\t\t\t\t.select(it => it.raw('1'))\n\t\t\t\t\t\t.from(context.targetEntity.tableName, targetPath.alias)\n\t\t\t\t\t\t.where(it => it.columnsEq([tableName, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName]))\n\n\t\t\t\t\treturn existsIfReadable(\n\t\t\t\t\t\tfieldGuard,\n\t\t\t\t\t\tthis.buildInternal({\n\t\t\t\t\t\t\tentity: context.targetEntity,\n\t\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\t\twhere: this.combineWhereAnd([relationWhere, guard]),\n\t\t\t\t\t\t\tcallback: cb => qb.where(clause => cb(clause)),\n\t\t\t\t\t\t\tallowManyJoin: true,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn conditionBuilder\n\t}\n\n\t/**\n\t * A condition over a cell-level column holds on a masked cell iff it holds on NULL. Outside a negation FALSE and\n\t * NULL drop the row alike, so only a condition that is TRUE on NULL needs more than `cond AND guard`; under a\n\t * negation the masked cell must also keep NULL as NULL.\n\t */\n\tprivate buildMaskedCell(\n\t\tconditionBuilder: SqlConditionBuilder,\n\t\tentity: Model.Entity,\n\t\tpath: Path,\n\t\t{ guard, where }: MaskedCell,\n\t\tjoinList: WhereJoinDefinition[],\n\t\tallowManyJoin: boolean,\n\t\tnegated: boolean,\n\t): SqlConditionBuilder {\n\t\tconst compile = (where: Input.OptionalWhere) =>\n\t\t\tSqlConditionBuilder.process(clause => this.buildRecursive({ conditionBuilder: clause, entity, path, where, joinList, allowManyJoin, negated }))\n\t\t\t\t.getSql()\n\t\tconst condition = compile(where)\n\t\tif (condition === null) {\n\t\t\treturn conditionBuilder\n\t\t}\n\t\tconst guardCondition = compile(guard)\n\t\tif (guardCondition === null) {\n\t\t\treturn conditionBuilder.with(condition)\n\t\t}\n\t\tconst onNull = this.evaluateWhereOnNull(where, entity)\n\t\tconst crispGuard = `coalesce(${guardCondition.sql}, false)`\n\t\tif (onNull === 'true') {\n\t\t\treturn conditionBuilder.with(new Literal(`(${condition.sql} or not ${crispGuard})`, [...condition.parameters, ...guardCondition.parameters]))\n\t\t}\n\t\tif (!negated) {\n\t\t\treturn conditionBuilder.with(condition).with(guardCondition)\n\t\t}\n\t\tif (onNull === 'false') {\n\t\t\treturn conditionBuilder.with(new Literal(`${condition.sql} and ${crispGuard}`, [...condition.parameters, ...guardCondition.parameters]))\n\t\t}\n\t\treturn conditionBuilder.with(\n\t\t\tnew Literal(`case when ${crispGuard} then ${condition.sql} end`, [...guardCondition.parameters, ...condition.parameters]),\n\t\t)\n\t}\n\n\t/** The three-valued result of a column where on a NULL cell, mirroring how `ConditionBuilder` compiles it. */\n\tprivate evaluateWhereOnNull(where: Input.OptionalWhere, entity: Model.Entity): NullCellValue {\n\t\tconst operands: NullCellValue[] = []\n\t\tfor (const [key, value] of Object.entries(where)) {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!isColumn(entity.fields[key]) || !this.isInputCondition(value)) {\n\t\t\t\tthrow new Error(`WhereBuilder: ${MASKED_CELL_KEY} expects a column condition, got ${entity.name}::${key}`)\n\t\t\t}\n\t\t\toperands.push(this.evaluateConditionOnNull(value))\n\t\t}\n\t\treturn combineNullCellValues(operands, 'and')\n\t}\n\n\tprivate evaluateConditionOnNull(condition: Input.Condition): NullCellValue {\n\t\tconst isSet = <T>(value: T | null | undefined): value is T => value !== null && value !== undefined\n\t\tif (!Object.values(condition).some(isSet)) {\n\t\t\treturn 'empty'\n\t\t}\n\t\tif (isSet(condition.and)) {\n\t\t\treturn combineNullCellValues(condition.and.map(it => this.evaluateConditionOnNull(it)), 'and')\n\t\t}\n\t\tif (isSet(condition.or)) {\n\t\t\treturn combineNullCellValues(condition.or.map(it => this.evaluateConditionOnNull(it)), 'or')\n\t\t}\n\t\tif (isSet(condition.not)) {\n\t\t\tconst operand = this.evaluateConditionOnNull(condition.not)\n\t\t\treturn operand === 'true' ? 'false' : operand === 'false' ? 'true' : operand\n\t\t}\n\t\tconst isNull = condition.isNull ?? condition.null\n\t\tif (isSet(isNull)) {\n\t\t\treturn isNull ? 'true' : 'false'\n\t\t}\n\t\tif (isSet(condition.always)) {\n\t\t\treturn 'true'\n\t\t}\n\t\tif (isSet(condition.never)) {\n\t\t\treturn 'false'\n\t\t}\n\t\tif (isSet(condition.in)) {\n\t\t\treturn condition.in.some(it => it !== undefined) ? 'unknown' : 'false'\n\t\t}\n\t\tif (isSet(condition.notIn)) {\n\t\t\treturn condition.notIn.some(it => it !== undefined) ? 'unknown' : 'true'\n\t\t}\n\t\treturn 'unknown'\n\t}\n\n\tprivate createGuardedSource(entity: Model.Entity, path: Path, guard: Input.OptionalWhere): Literal | undefined {\n\t\treturn Object.keys(guard).length === 0 ? undefined : this.buildGuardedSource(entity, path, guard)\n\t}\n\n\tprivate createManyHasManySubquery(\n\t\touterColumn: QueryBuilder.ColumnIdentifier,\n\t\trelationWhere: Input.OptionalWhere,\n\t\tguard: Input.OptionalWhere,\n\t\ttargetEntity: Model.Entity,\n\t\tjoiningTable: Model.JoiningTable,\n\t\tfromSide: 'owning' | 'inverse',\n\t\tpath: Path,\n\t) {\n\t\tconst fromColumn = fromSide === 'owning' ? joiningTable.joiningColumn.columnName : joiningTable.inverseJoiningColumn.columnName\n\t\tconst toColumn = fromSide === 'owning' ? joiningTable.inverseJoiningColumn.columnName : joiningTable.joiningColumn.columnName\n\t\tconst junctionPath = path.for('junction_')\n\t\tconst qb = SelectBuilder.create<SelectBuilder.Result>()\n\t\t\t.from(joiningTable.tableName, junctionPath.alias)\n\t\t\t.select(it => it.raw('1'))\n\t\t\t.where(it => it.columnsEq(outerColumn, [junctionPath.alias, fromColumn]))\n\n\t\t// The junction-only shortcut skips the target table, so it is only valid while every target row is readable.\n\t\tconst primaryCondition = Object.keys(guard).length === 0 ? this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary) : null\n\t\tif (primaryCondition !== null) {\n\t\t\tconst columnType = targetEntity.fields[targetEntity.primary] as Model.AnyColumn\n\n\t\t\treturn qb.where(condition => this.conditionBuilder.build(condition, junctionPath.alias, toColumn, columnType, primaryCondition))\n\t\t}\n\n\t\tconst qbJoined = qb.join(\n\t\t\ttargetEntity.tableName,\n\t\t\tpath.alias,\n\t\t\tclause => clause.compareColumns([junctionPath.alias, toColumn], Operator.eq, [path.alias, targetEntity.primary]),\n\t\t)\n\t\treturn this.buildInternal({\n\t\t\tentity: targetEntity,\n\t\t\tpath: this.pathFactory.create([], path.fullAlias),\n\t\t\twhere: this.combineWhereAnd([relationWhere, guard]),\n\t\t\tcallback: cb => qbJoined.where(clause => cb(clause)),\n\t\t\tallowManyJoin: true,\n\t\t})\n\t}\n\n\tprivate combineWhereAnd(wheres: readonly Input.OptionalWhere[]): Input.OptionalWhere {\n\t\tconst nonEmpty = wheres.filter(it => Object.keys(it).length > 0)\n\t\tif (nonEmpty.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\treturn nonEmpty.length === 1 ? nonEmpty[0] : { and: nonEmpty }\n\t}\n\n\tprivate isInputCondition(value: unknown): value is Input.Condition {\n\t\treturn value !== null && typeof value === 'object' && !Array.isArray(value)\n\t}\n\n\tprivate isOptionalWhere(value: unknown): value is Input.OptionalWhere {\n\t\treturn value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value)\n\t}\n\n\tprivate transformWhereToPrimaryCondition(where: Input.OptionalWhere, primaryField: string): Input.Condition<never> | null {\n\t\tconst keys = Object.keys(where)\n\t\tif (keys.filter(it => !['and', 'or', 'not', primaryField].includes(it)).length > 0) {\n\t\t\treturn null\n\t\t}\n\t\tlet condition: {\n\t\t\tand?: Array<Input.Condition<never>>\n\t\t\tor?: Array<Input.Condition<never>>\n\t\t\tnot?: Input.Condition<never>\n\t\t} = {}\n\t\tif (where.and) {\n\t\t\tconst conditions = where.and\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.transformWhereToPrimaryCondition(it, primaryField))\n\t\t\tif (conditions.includes(null)) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.and = conditions as Input.Condition<never>[]\n\t\t}\n\t\tif (where.or) {\n\t\t\tconst conditions = where.or\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.transformWhereToPrimaryCondition(it, primaryField))\n\t\t\tif (conditions.includes(null)) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.or = conditions as Input.Condition<never>[]\n\t\t}\n\t\tif (where.not) {\n\t\t\tconst conditions = this.transformWhereToPrimaryCondition(where.not, primaryField)\n\t\t\tif (conditions === null) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tcondition.not = conditions as Input.Condition<never>\n\t\t}\n\t\tif (where[primaryField]) {\n\t\t\tif (Object.keys(condition).length > 0) {\n\t\t\t\treturn { and: [condition, where[primaryField] as Input.Condition<never>] }\n\t\t\t}\n\t\t\treturn where[primaryField] as Input.Condition<never>\n\t\t}\n\t\treturn condition\n\t}\n\n\tprivate hasRootIsNull(where: Input.OptionalWhere, entity: Model.Entity): boolean {\n\t\tfor (const key in where) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\tif (where[key]?.some(it => it && this.hasRootIsNull(it, entity))) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else if (key === 'not') {\n\t\t\t\tif (where.not && this.hasRootIsNull(where.not, entity)) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else if (key === MASKED_CELL_KEY) {\n\t\t\t\tif (parseMaskedCells(where[key]).some(cell => this.hasRootIsNull(cell.where, entity) || this.hasRootIsNull(cell.guard, entity))) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else if (isColumn(entity.fields[key])) {\n\t\t\t\tconst condition = where[key]\n\t\t\t\tif (this.isInputCondition(condition) && this.conditionHasIsNull(condition)) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\tprivate conditionHasIsNull(cond: Input.Condition): boolean {\n\t\treturn cond.isNull !== undefined\n\t\t\t|| cond.and?.some(item => this.conditionHasIsNull(item)) === true\n\t\t\t|| cond.or?.some(item => this.conditionHasIsNull(item)) === true\n\t\t\t|| (cond.not !== undefined && this.conditionHasIsNull(cond.not))\n\t}\n}\n\n/** `empty` is a condition that compiles to nothing, so it neither holds nor fails. */\ntype NullCellValue = 'true' | 'false' | 'unknown' | 'empty'\n\nconst combineNullCellValues = (operands: readonly NullCellValue[], operator: 'and' | 'or'): NullCellValue => {\n\tconst present = operands.filter(it => it !== 'empty')\n\tif (present.length === 0) {\n\t\treturn 'empty'\n\t}\n\tconst dominant = operator === 'and' ? 'false' : 'true'\n\tif (present.includes(dominant)) {\n\t\treturn dominant\n\t}\n\treturn present.includes('unknown') ? 'unknown' : operator === 'and' ? 'true' : 'false'\n}\n\nexport type WhereJoinDefinition = { path: Path; entity: Model.Entity; relationName: string; targetSource?: Literal; joinCondition?: Literal }\n"],"names":["Literal","SqlConditionBuilder","SelectBuilder","wrapIdentifier","Compiler","where","MASKED_CELL_KEY","parseMaskedCells","splitReadGuard","hopPathSegment","entity","targetPath","isIt","acceptFieldVisitor","qb","isColumn","Operator"],"mappings":";;;;;;;AAyBO,MAAM,aAAa;AAAA,EACzB,YACkB,QACA,aACA,kBACA,aACA,gBACA,0BAChB;AANgB,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AACA,SAAA,cAAA;AACA,SAAA,iBAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,MACN,IACA,QACA,MACA,OACA,oBAA4C,IACzB;AACnB,UAAM,iBAAiB,KAAK,eAAe,SAAS,OAAO,QAAQ,iBAAiB;AACpF,WAAO,KAAK,cAAc;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,UAAU,CAAA,OAAM,GAAG,MAAM,CAAA,WAAU,GAAG,MAAM,CAAC;AAAA,MAC7C,eAAe;AAAA,IAAA,CACf;AAAA,EACF;AAAA,EAEO,cACN,QACA,MACA,OACA,UACA,oBAA4C,IACzB;AACnB,UAAM,iBAAiB,KAAK,eAAe,SAAS,OAAO,QAAQ,iBAAiB;AACpF,WAAO,KAAK,cAAc;AAAA,MACzB;AAAA,MACA;AAA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