@contember/engine-content-api 1.1.2 → 1.2.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acl/EvaluatedPredicateReplacer.d.ts +9 -0
- package/dist/src/acl/EvaluatedPredicateReplacer.d.ts.map +1 -0
- package/dist/src/acl/EvaluatedPredicateReplacer.js +31 -0
- package/dist/src/acl/EvaluatedPredicateReplacer.js.map +1 -0
- package/dist/src/acl/PermissionFactory.d.ts.map +1 -1
- package/dist/src/acl/PermissionFactory.js +15 -11
- package/dist/src/acl/PermissionFactory.js.map +1 -1
- package/dist/src/acl/PredicateFactory.d.ts +4 -2
- package/dist/src/acl/PredicateFactory.d.ts.map +1 -1
- package/dist/src/acl/PredicateFactory.js +17 -6
- package/dist/src/acl/PredicateFactory.js.map +1 -1
- package/dist/src/acl/PredicatesInjector.d.ts +1 -1
- package/dist/src/acl/PredicatesInjector.d.ts.map +1 -1
- package/dist/src/acl/PredicatesInjector.js +16 -19
- package/dist/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/src/acl/VariableInjector.d.ts +0 -1
- package/dist/src/acl/VariableInjector.d.ts.map +1 -1
- package/dist/src/acl/VariableInjector.js +4 -14
- package/dist/src/acl/VariableInjector.js.map +1 -1
- package/dist/src/acl/VariableUtils.d.ts +2 -13
- package/dist/src/acl/VariableUtils.d.ts.map +1 -1
- package/dist/src/acl/VariableUtils.js +5 -16
- package/dist/src/acl/VariableUtils.js.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +0 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +14 -15
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts +5 -4
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js +29 -20
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -2
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts +3 -3
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +3 -3
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts +5 -4
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js +29 -20
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js.map +1 -1
- package/dist/src/input-validation/ColumnValueResolver.d.ts +4 -3
- package/dist/src/input-validation/ColumnValueResolver.d.ts.map +1 -1
- package/dist/src/input-validation/ColumnValueResolver.js.map +1 -1
- package/dist/src/input-validation/EntityRulesResolver.js +4 -4
- package/dist/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/src/input-validation/QueryAstFactory.js +1 -1
- package/dist/src/input-validation/QueryAstFactory.js.map +1 -1
- package/dist/src/input-validation/ValidationContext.d.ts +2 -2
- package/dist/src/input-validation/ValidationContext.d.ts.map +1 -1
- package/dist/src/input-validation/ValidationContext.js.map +1 -1
- package/dist/src/input-validation/ValidationDataSelector.d.ts.map +1 -1
- package/dist/src/input-validation/ValidationDataSelector.js +1 -1
- package/dist/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +7 -8
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/src/input-validation/preValidation/InputPreValidator.js +4 -4
- package/dist/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +7 -8
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/src/inputProcessing/CreateInputProcessor.d.ts +8 -9
- package/dist/src/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
- package/dist/src/inputProcessing/CreateInputVisitor.d.ts +7 -7
- package/dist/src/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
- package/dist/src/inputProcessing/CreateInputVisitor.js +15 -46
- package/dist/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/src/inputProcessing/UpdateInputProcessor.d.ts +8 -9
- package/dist/src/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
- package/dist/src/inputProcessing/UpdateInputVisitor.d.ts +7 -7
- package/dist/src/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
- package/dist/src/inputProcessing/UpdateInputVisitor.js +13 -28
- package/dist/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/src/inputProcessing/index.d.ts +0 -1
- package/dist/src/inputProcessing/index.d.ts.map +1 -1
- package/dist/src/inputProcessing/index.js +0 -1
- package/dist/src/inputProcessing/index.js.map +1 -1
- package/dist/src/introspection/IntrospectionSchemaFactory.js +7 -7
- package/dist/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/src/introspection/content-schema.types.d.ts +19 -223
- package/dist/src/introspection/content-schema.types.d.ts.map +1 -1
- package/dist/src/introspection/content-schema.types.js +2 -2
- package/dist/src/introspection/content-schema.types.js.map +1 -1
- package/dist/src/mapper/Mapper.d.ts +6 -6
- package/dist/src/mapper/Mapper.d.ts.map +1 -1
- package/dist/src/mapper/Mapper.js +28 -23
- package/dist/src/mapper/Mapper.js.map +1 -1
- package/dist/src/mapper/MapperContainer.d.ts.map +1 -1
- package/dist/src/mapper/MapperContainer.js +7 -4
- package/dist/src/mapper/MapperContainer.js.map +1 -1
- package/dist/src/mapper/delete/DeleteExecutor.js +3 -3
- package/dist/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts +4 -2
- package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
- package/dist/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/src/mapper/select/JoinVisitor.d.ts +6 -6
- package/dist/src/mapper/select/JoinVisitor.d.ts.map +1 -1
- package/dist/src/mapper/select/JoinVisitor.js +6 -6
- package/dist/src/mapper/select/JoinVisitor.js.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.d.ts +32 -5
- package/dist/src/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.js +37 -15
- package/dist/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/src/mapper/select/SelectBuilder.d.ts +2 -1
- package/dist/src/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectBuilder.js +4 -2
- package/dist/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/src/mapper/select/SelectBuilderFactory.d.ts +2 -1
- package/dist/src/mapper/select/SelectBuilderFactory.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectExecutionHandler.d.ts +1 -0
- package/dist/src/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
- package/dist/src/mapper/select/WhereBuilder.d.ts +6 -3
- package/dist/src/mapper/select/WhereBuilder.d.ts.map +1 -1
- package/dist/src/mapper/select/WhereBuilder.js +31 -24
- package/dist/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts +9 -8
- package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitor.js +45 -24
- package/dist/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.d.ts.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js.map +1 -1
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.d.ts +5 -0
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.d.ts.map +1 -0
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js +39 -0
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -0
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts +15 -0
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -0
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js +118 -0
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts +6 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.js +28 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.js.map +1 -0
- package/dist/src/mapper/select/optimizer/helpers.d.ts +10 -0
- package/dist/src/mapper/select/optimizer/helpers.d.ts.map +1 -0
- package/dist/src/mapper/select/optimizer/helpers.js +72 -0
- package/dist/src/mapper/select/optimizer/helpers.js.map +1 -0
- package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts +2 -3
- package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/src/mapper/update/UpdateBuilder.js +3 -3
- package/dist/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/src/resolvers/GraphQlQueryAstFactory.js +2 -2
- package/dist/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/src/resolvers/MutationResolver.js +15 -15
- package/dist/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/src/resolvers/ReadHelpers.js +10 -10
- package/dist/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/src/resolvers/ReadResolver.js +2 -2
- package/dist/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/src/schema/FieldAccessVisitor.d.ts +2 -2
- package/dist/src/schema/FieldAccessVisitor.d.ts.map +1 -1
- package/dist/src/schema/FieldAccessVisitor.js +2 -2
- package/dist/src/schema/FieldAccessVisitor.js.map +1 -1
- package/dist/src/schema/MutationProvider.js +4 -4
- package/dist/src/schema/MutationProvider.js.map +1 -1
- package/dist/src/schema/OrderByTypeProvider.js +1 -1
- package/dist/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/src/schema/QueryProvider.js +3 -3
- package/dist/src/schema/QueryProvider.js.map +1 -1
- package/dist/src/schema/ResultSchemaTypeProvider.d.ts +2 -2
- package/dist/src/schema/ResultSchemaTypeProvider.d.ts.map +1 -1
- package/dist/src/schema/WhereTypeProvider.js +4 -4
- package/dist/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts +7 -7
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
- package/dist/src/schema/entities/FieldArgsVisitor.js +3 -3
- package/dist/src/schema/entities/FieldArgsVisitor.js.map +1 -1
- package/dist/src/schema/entities/FieldTypeVisitor.d.ts +3 -3
- package/dist/src/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
- package/dist/src/schema/entities/FieldTypeVisitor.js +3 -3
- package/dist/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts +3 -3
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js +3 -3
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js +6 -6
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts +3 -3
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js +5 -5
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +10 -4
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js +3 -3
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js +6 -6
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +2 -2
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +2 -2
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/object.d.ts.map +1 -1
- package/dist/src/utils/object.js +3 -4
- package/dist/src/utils/object.js.map +1 -1
- package/dist/src/utils/uniqueWhereFields.js +3 -3
- package/dist/src/utils/uniqueWhereFields.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js +2 -2
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js +7 -6
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.js +137 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.js.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/complexCondition.test.js +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.js +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.js +73 -0
- package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.js +73 -0
- package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js +6 -6
- package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js +6 -3
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/model.js.map +1 -1
- package/dist/tests/cases/unit/aclVariablesFactory.test.js +7 -33
- package/dist/tests/cases/unit/aclVariablesFactory.test.js.map +1 -1
- package/dist/tests/cases/unit/conditionOptimizer.test.d.ts +2 -0
- package/dist/tests/cases/unit/conditionOptimizer.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/conditionOptimizer.test.js +118 -0
- package/dist/tests/cases/unit/conditionOptimizer.test.js.map +1 -0
- package/dist/tests/cases/unit/orderbyHelper.test.js +1 -0
- package/dist/tests/cases/unit/orderbyHelper.test.js.map +1 -1
- package/dist/tests/cases/unit/permissionMerger.test.js +2 -0
- package/dist/tests/cases/unit/permissionMerger.test.js.map +1 -1
- package/dist/tests/cases/unit/predicatesFactory.test.d.ts +2 -0
- package/dist/tests/cases/unit/predicatesFactory.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/predicatesFactory.test.js +109 -0
- package/dist/tests/cases/unit/predicatesFactory.test.js.map +1 -0
- package/dist/tests/cases/unit/predicatesInjector.test.js +88 -14
- package/dist/tests/cases/unit/predicatesInjector.test.js.map +1 -1
- package/dist/tests/cases/unit/variableInjector.test.js +4 -3
- package/dist/tests/cases/unit/variableInjector.test.js.map +1 -1
- package/dist/tests/cases/unit/whereOptimizer.test.d.ts +2 -0
- package/dist/tests/cases/unit/whereOptimizer.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/whereOptimizer.test.js +265 -0
- package/dist/tests/cases/unit/whereOptimizer.test.js.map +1 -0
- package/dist/tests/src/testGraphql.d.ts.map +1 -1
- package/dist/tests/src/testGraphql.js +10 -2
- package/dist/tests/src/testGraphql.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/graphql.codegen.yml +0 -3
- package/package.json +16 -16
- package/src/acl/EvaluatedPredicateReplacer.ts +32 -0
- package/src/acl/PermissionFactory.ts +18 -13
- package/src/acl/PredicateFactory.ts +32 -8
- package/src/acl/PredicatesInjector.ts +25 -17
- package/src/acl/VariableInjector.ts +2 -15
- package/src/acl/VariableUtils.ts +7 -23
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +17 -24
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +1 -6
- package/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts +26 -46
- package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +6 -3
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +4 -22
- package/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.ts +26 -49
- package/src/input-validation/ColumnValueResolver.ts +2 -3
- package/src/input-validation/EntityRulesResolver.ts +4 -4
- package/src/input-validation/QueryAstFactory.ts +1 -1
- package/src/input-validation/ValidationContext.ts +2 -2
- package/src/input-validation/ValidationDataSelector.ts +2 -2
- package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +7 -8
- package/src/input-validation/preValidation/InputPreValidator.ts +4 -4
- package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +7 -8
- package/src/inputProcessing/CreateInputProcessor.ts +8 -9
- package/src/inputProcessing/CreateInputVisitor.ts +27 -89
- package/src/inputProcessing/UpdateInputProcessor.ts +8 -9
- package/src/inputProcessing/UpdateInputVisitor.ts +25 -71
- package/src/inputProcessing/index.ts +0 -1
- package/src/introspection/IntrospectionSchemaFactory.ts +7 -7
- package/src/introspection/content-schema.types.ts +19 -286
- package/src/mapper/Mapper.ts +37 -30
- package/src/mapper/MapperContainer.ts +10 -5
- package/src/mapper/delete/DeleteExecutor.ts +3 -3
- package/src/mapper/insert/SqlCreateInputProcessor.ts +3 -3
- package/src/mapper/select/JoinVisitor.ts +6 -33
- package/src/mapper/select/RelationFetcher.ts +101 -41
- package/src/mapper/select/SelectBuilder.ts +3 -1
- package/src/mapper/select/SelectBuilderFactory.ts +2 -1
- package/src/mapper/select/SelectExecutionHandler.ts +1 -0
- package/src/mapper/select/WhereBuilder.ts +46 -32
- package/src/mapper/select/handlers/FieldsVisitor.ts +47 -57
- package/src/mapper/select/handlers/FieldsVisitorFactory.ts +1 -0
- package/src/mapper/select/optimizer/ConditionOptimizer.ts +41 -0
- package/src/mapper/select/optimizer/WhereOptimizer.ts +138 -0
- package/src/mapper/select/optimizer/WhereReplacer.ts +27 -0
- package/src/mapper/select/optimizer/helpers.ts +58 -0
- package/src/mapper/update/SqlUpdateInputProcessor.ts +1 -1
- package/src/mapper/update/UpdateBuilder.ts +3 -3
- package/src/resolvers/GraphQlQueryAstFactory.ts +3 -3
- package/src/resolvers/MutationResolver.ts +1 -1
- package/src/resolvers/ReadHelpers.ts +3 -3
- package/src/resolvers/ReadResolver.ts +2 -2
- package/src/schema/FieldAccessVisitor.ts +2 -2
- package/src/schema/OrderByTypeProvider.ts +1 -1
- package/src/schema/WhereTypeProvider.ts +4 -4
- package/src/schema/entities/FieldArgsVisitor.ts +3 -3
- package/src/schema/entities/FieldTypeVisitor.ts +3 -3
- package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +3 -6
- package/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.ts +6 -20
- package/src/schema/mutations/CreateEntityRelationInputFieldVisitor.ts +5 -18
- package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +3 -6
- package/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.ts +6 -20
- package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +2 -12
- package/src/utils/object.ts +6 -6
- package/src/utils/uniqueWhereFields.ts +3 -3
- package/tests/cases/integration/graphQlRequests/delete/aclDelete.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/insert/acl/setField.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/insert/aclInsert.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +7 -6
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +130 -0
- package/tests/cases/integration/graphQlRequests/query/filter/complexCondition.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.ts +1 -1
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +74 -0
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +77 -0
- package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +7 -7
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +5 -5
- package/tests/cases/unit/aclVariablesFactory.test.ts +8 -35
- package/tests/cases/unit/conditionOptimizer.test.ts +135 -0
- package/tests/cases/unit/orderbyHelper.test.ts +1 -0
- package/tests/cases/unit/permissionMerger.test.ts +2 -0
- package/tests/cases/unit/predicatesFactory.test.ts +103 -0
- package/tests/cases/unit/predicatesInjector.test.ts +78 -16
- package/tests/cases/unit/variableInjector.test.ts +6 -5
- package/tests/cases/unit/whereOptimizer.test.ts +289 -0
- package/tests/src/testGraphql.ts +9 -2
- package/dist/src/inputProcessing/InputContext.d.ts +0 -43
- package/dist/src/inputProcessing/InputContext.d.ts.map +0 -1
- package/dist/src/inputProcessing/InputContext.js +0 -3
- package/dist/src/inputProcessing/InputContext.js.map +0 -1
- package/jasmine.json +0 -7
- package/src/inputProcessing/InputContext.ts +0 -49
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { SchemaDefinition as def } from '@contember/schema-definition'
|
|
2
|
+
import { Acl } from '@contember/schema'
|
|
3
|
+
import { test } from 'vitest'
|
|
4
|
+
import { execute } from '../../../../../src/test'
|
|
5
|
+
import { GQL, SQL } from '../../../../../src/tags'
|
|
6
|
+
import { testUuid } from '../../../../../src/testUuid'
|
|
7
|
+
|
|
8
|
+
namespace TestModel {
|
|
9
|
+
export class Author {
|
|
10
|
+
name = def.stringColumn()
|
|
11
|
+
isPublic = def.boolColumn().notNull()
|
|
12
|
+
image = def.manyHasOne(Image, 'authors')
|
|
13
|
+
}
|
|
14
|
+
export class Article {
|
|
15
|
+
title = def.stringColumn()
|
|
16
|
+
isPublic = def.boolColumn().notNull()
|
|
17
|
+
image = def.manyHasOne(Image, 'articles')
|
|
18
|
+
}
|
|
19
|
+
export class Image {
|
|
20
|
+
url = def.stringColumn().notNull()
|
|
21
|
+
|
|
22
|
+
articles = def.oneHasMany(Article, 'image')
|
|
23
|
+
authors = def.oneHasMany(Author, 'image')
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const permissions: Acl.Permissions = {
|
|
27
|
+
Author: {
|
|
28
|
+
predicates: {
|
|
29
|
+
authorPredicate: {
|
|
30
|
+
isPublic: { eq: true },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
operations: {
|
|
34
|
+
read: {
|
|
35
|
+
id: 'authorPredicate',
|
|
36
|
+
name: 'authorPredicate',
|
|
37
|
+
image: 'authorPredicate',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
Article: {
|
|
42
|
+
predicates: {
|
|
43
|
+
articlePredicate: {
|
|
44
|
+
isPublic: { eq: true },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
operations: {
|
|
48
|
+
read: {
|
|
49
|
+
id: 'articlePredicate',
|
|
50
|
+
title: 'articlePredicate',
|
|
51
|
+
image: 'articlePredicate',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
Image: {
|
|
56
|
+
predicates: {
|
|
57
|
+
imagePredicate: {
|
|
58
|
+
or: [
|
|
59
|
+
{ authors: { isPublic: { eq: true } } },
|
|
60
|
+
{ articles: { isPublic: { eq: true } } },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
operations: {
|
|
65
|
+
read: {
|
|
66
|
+
id: 'imagePredicate',
|
|
67
|
+
url: 'imagePredicate',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
test('predicate with OR', async () => {
|
|
74
|
+
await execute({
|
|
75
|
+
schema: def.createModel(TestModel),
|
|
76
|
+
permissions: permissions,
|
|
77
|
+
variables: {},
|
|
78
|
+
query: GQL`
|
|
79
|
+
query {
|
|
80
|
+
listAuthor {
|
|
81
|
+
id
|
|
82
|
+
image {
|
|
83
|
+
url
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}`,
|
|
87
|
+
executes: [
|
|
88
|
+
{
|
|
89
|
+
sql: SQL`SELECT "root_"."id" AS "root_id", "root_"."image_id" AS "root_image"
|
|
90
|
+
FROM "public"."author" AS "root_"
|
|
91
|
+
WHERE "root_"."is_public" = ?`,
|
|
92
|
+
parameters: [true],
|
|
93
|
+
response: {
|
|
94
|
+
rows: [
|
|
95
|
+
{
|
|
96
|
+
root_id: testUuid(1),
|
|
97
|
+
root_image: testUuid(2),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
sql: `select "root_"."id" as "root_id", "root_"."url" as "root_url", "root_"."id" as "root_id" from "public"."image" as "root_" where "root_"."id" in (?)`,
|
|
104
|
+
parameters: [testUuid(2)],
|
|
105
|
+
response: {
|
|
106
|
+
rows: [
|
|
107
|
+
{
|
|
108
|
+
root_id: testUuid(2),
|
|
109
|
+
root_url: 'abcd',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
return: {
|
|
116
|
+
data: {
|
|
117
|
+
listAuthor: [
|
|
118
|
+
{
|
|
119
|
+
id: testUuid(1),
|
|
120
|
+
image: {
|
|
121
|
+
url: 'abcd',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
|
|
@@ -25,7 +25,7 @@ test('Complex condition', async () => {
|
|
|
25
25
|
{
|
|
26
26
|
sql: SQL`select "root_"."id" as "root_id"
|
|
27
27
|
from "public"."post" as "root_"
|
|
28
|
-
where (
|
|
28
|
+
where ("root_"."title" = ? or "root_"."title" = ?
|
|
29
29
|
or not("root_"."title" < ?)
|
|
30
30
|
or "root_"."title" is null and not("root_"."title" is null))`,
|
|
31
31
|
parameters: ['A', 'B', 'X'],
|
|
@@ -19,7 +19,7 @@ test('Composed filter with nulls', async () => {
|
|
|
19
19
|
`,
|
|
20
20
|
executes: [
|
|
21
21
|
{
|
|
22
|
-
sql: SQL`select "root_"."id" as "root_id" from "public"."post" as "root_" where
|
|
22
|
+
sql: SQL`select "root_"."id" as "root_id" from "public"."post" as "root_" where "root_"."title" = ?`,
|
|
23
23
|
parameters: ['John'],
|
|
24
24
|
response: { rows: [{ root_id: testUuid(1) }] },
|
|
25
25
|
},
|
|
@@ -171,3 +171,77 @@ test('empty many-has-many inverse relation', async () => {
|
|
|
171
171
|
})
|
|
172
172
|
|
|
173
173
|
|
|
174
|
+
test('Posts with filtered tags', async () => {
|
|
175
|
+
await execute({
|
|
176
|
+
schema: new SchemaBuilder()
|
|
177
|
+
.entity('Post', entity => entity)
|
|
178
|
+
.entity('Tag', entity => entity.column('name').manyHasMany('posts', relation => relation.target('Post').inversedBy('tags')))
|
|
179
|
+
.buildSchema(),
|
|
180
|
+
query: GQL`
|
|
181
|
+
query {
|
|
182
|
+
listPost {
|
|
183
|
+
id
|
|
184
|
+
tags(filter: {name: {eq: "Foo"}}) {
|
|
185
|
+
name
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
`,
|
|
190
|
+
executes: [
|
|
191
|
+
{
|
|
192
|
+
sql: SQL`select "root_"."id" as "root_id",
|
|
193
|
+
"root_"."id" as "root_id"
|
|
194
|
+
from "public"."post" as "root_"`,
|
|
195
|
+
response: {
|
|
196
|
+
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
sql: SQL`select "junction_"."post_id", "junction_"."tag_id" from "public"."tag_posts" as "junction_" inner join "public"."tag" as "root_" on "junction_"."tag_id" = "root_"."id" where "junction_"."post_id" in (?, ?) and "root_"."name" = ?`,
|
|
201
|
+
parameters: [testUuid(1), testUuid(2), 'Foo'],
|
|
202
|
+
response: {
|
|
203
|
+
rows: [
|
|
204
|
+
{ post_id: testUuid(1), tag_id: testUuid(3) },
|
|
205
|
+
{ post_id: testUuid(2), tag_id: testUuid(3) },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
sql: SQL`
|
|
211
|
+
select "root_"."name" as "root_name",
|
|
212
|
+
"root_"."id" as "root_id"
|
|
213
|
+
from "public"."tag" as "root_"
|
|
214
|
+
where "root_"."id" in (?)`,
|
|
215
|
+
parameters: [testUuid(3)],
|
|
216
|
+
response: {
|
|
217
|
+
rows: [
|
|
218
|
+
{ root_id: testUuid(3), root_name: 'foo' },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
return: {
|
|
224
|
+
data: {
|
|
225
|
+
listPost: [
|
|
226
|
+
{
|
|
227
|
+
id: testUuid(1),
|
|
228
|
+
tags: [
|
|
229
|
+
{
|
|
230
|
+
name: 'foo',
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: testUuid(2),
|
|
236
|
+
tags: [
|
|
237
|
+
{
|
|
238
|
+
name: 'foo',
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
|
|
@@ -4,6 +4,83 @@ import { SchemaBuilder } from '@contember/schema-definition'
|
|
|
4
4
|
import { GQL, SQL } from '../../../../../src/tags'
|
|
5
5
|
import { testUuid } from '../../../../../src/testUuid'
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
test('Posts with filtered tags', async () => {
|
|
9
|
+
await execute({
|
|
10
|
+
schema: new SchemaBuilder()
|
|
11
|
+
.entity('Post', entity => entity.manyHasMany('tags', relation => relation.target('Tag')))
|
|
12
|
+
.entity('Tag', entity => entity.column('name'))
|
|
13
|
+
.buildSchema(),
|
|
14
|
+
query: GQL`
|
|
15
|
+
query {
|
|
16
|
+
listPost {
|
|
17
|
+
id
|
|
18
|
+
tags(filter: {name: {eq: "Foo"}}) {
|
|
19
|
+
name
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
executes: [
|
|
25
|
+
{
|
|
26
|
+
sql: SQL`select "root_"."id" as "root_id",
|
|
27
|
+
"root_"."id" as "root_id"
|
|
28
|
+
from "public"."post" as "root_"`,
|
|
29
|
+
response: {
|
|
30
|
+
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
sql: SQL`select "junction_"."tag_id", "junction_"."post_id" from "public"."post_tags" as "junction_" inner join "public"."tag" as "root_" on "junction_"."tag_id" = "root_"."id" where "junction_"."post_id" in (?, ?) and "root_"."name" = ?`,
|
|
35
|
+
parameters: [testUuid(1), testUuid(2), 'Foo'],
|
|
36
|
+
response: {
|
|
37
|
+
rows: [
|
|
38
|
+
{ post_id: testUuid(1), tag_id: testUuid(3) },
|
|
39
|
+
{ post_id: testUuid(2), tag_id: testUuid(3) },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
sql: SQL`
|
|
45
|
+
select "root_"."name" as "root_name",
|
|
46
|
+
"root_"."id" as "root_id"
|
|
47
|
+
from "public"."tag" as "root_"
|
|
48
|
+
where "root_"."id" in (?)`,
|
|
49
|
+
parameters: [testUuid(3)],
|
|
50
|
+
response: {
|
|
51
|
+
rows: [
|
|
52
|
+
{ root_id: testUuid(3), root_name: 'foo' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
return: {
|
|
58
|
+
data: {
|
|
59
|
+
listPost: [
|
|
60
|
+
{
|
|
61
|
+
id: testUuid(1),
|
|
62
|
+
tags: [
|
|
63
|
+
{
|
|
64
|
+
name: 'foo',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: testUuid(2),
|
|
70
|
+
tags: [
|
|
71
|
+
{
|
|
72
|
+
name: 'foo',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
7
84
|
test('Posts with paginated tags (many has many owning)', async () => {
|
|
8
85
|
await execute({
|
|
9
86
|
schema: new SchemaBuilder()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from 'vitest'
|
|
2
2
|
import { execute, failedTransaction, sqlTransaction } from '../../../../../src/test'
|
|
3
3
|
import { SchemaBuilder } from '@contember/schema-definition'
|
|
4
|
-
import {
|
|
4
|
+
import { Model } from '@contember/schema'
|
|
5
5
|
import { GQL, SQL } from '../../../../../src/tags'
|
|
6
6
|
import { testUuid } from '../../../../../src/testUuid'
|
|
7
7
|
|
|
@@ -35,7 +35,7 @@ test('update name', async () => {
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
variables: {
|
|
38
|
-
name_variable: ['John', 'Jack'],
|
|
38
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
39
39
|
},
|
|
40
40
|
executes: [
|
|
41
41
|
...sqlTransaction([
|
|
@@ -98,7 +98,7 @@ test('update name - denied', async () => {
|
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
100
|
variables: {
|
|
101
|
-
name_variable: ['John', 'Jack'],
|
|
101
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
102
102
|
},
|
|
103
103
|
executes: [
|
|
104
104
|
...failedTransaction([
|
|
@@ -113,10 +113,10 @@ test('update name - denied', async () => {
|
|
|
113
113
|
? :: text as "name",
|
|
114
114
|
"root_"."id"
|
|
115
115
|
from "public"."author" as "root_"
|
|
116
|
-
where
|
|
116
|
+
where false) update "public"."author"
|
|
117
117
|
set "name" = "newData_"."name" from "newData_"
|
|
118
118
|
where "author"."id" = "newData_"."id" and false`,
|
|
119
|
-
parameters: ['John'
|
|
119
|
+
parameters: ['John'],
|
|
120
120
|
response: 0,
|
|
121
121
|
},
|
|
122
122
|
]),
|
|
@@ -176,8 +176,8 @@ test('update m:n', async () => {
|
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
variables: {
|
|
179
|
-
post_name_variable: ['Lorem ipsum', 'Dolor sit'],
|
|
180
|
-
category_name_variable: ['foo', 'bar'],
|
|
179
|
+
post_name_variable: { in: ['Lorem ipsum', 'Dolor sit'] },
|
|
180
|
+
category_name_variable: { in: ['foo', 'bar'] },
|
|
181
181
|
},
|
|
182
182
|
query: GQL`mutation {
|
|
183
183
|
updatePost(by: {id: "${testUuid(1)}"}, data: {categories: [
|
|
@@ -30,20 +30,20 @@ const testSchema = async (test: Test) => {
|
|
|
30
30
|
const graphQlSchemaBuilder = schemaFactory.create(schemaWithAcl, authorizator)
|
|
31
31
|
const graphQlSchema = graphQlSchemaBuilder.build()
|
|
32
32
|
|
|
33
|
-
const result = await graphql(
|
|
34
|
-
graphQlSchema,
|
|
35
|
-
`
|
|
33
|
+
const result = await graphql({
|
|
34
|
+
schema: graphQlSchema,
|
|
35
|
+
source: `
|
|
36
36
|
{
|
|
37
37
|
_info {
|
|
38
38
|
description
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
`,
|
|
42
|
-
)
|
|
42
|
+
})
|
|
43
43
|
const errors = (result.errors || []).map(it => it.message)
|
|
44
44
|
assert.deepEqual(errors, [])
|
|
45
45
|
|
|
46
|
-
const textSchema = printSchema(graphQlSchema)
|
|
46
|
+
const textSchema = printSchema(graphQlSchema) + '\n'
|
|
47
47
|
|
|
48
48
|
const filename = path.join(__dirname, test.graphQlSchemaFile)
|
|
49
49
|
let expectedSchema: string
|
|
@@ -5,24 +5,21 @@ import { testUuid } from '@contember/engine-api-tester'
|
|
|
5
5
|
|
|
6
6
|
describe('create acl variables', () => {
|
|
7
7
|
|
|
8
|
+
const definition: Acl.EntityVariable = { type: Acl.VariableType.entity, entityName: 'Author' }
|
|
8
9
|
it('prefix from memberships', () => {
|
|
9
10
|
assert.deepStrictEqual(createAclVariables({
|
|
10
11
|
roles: {
|
|
11
12
|
author: {
|
|
12
13
|
stages: '*',
|
|
13
14
|
variables: {
|
|
14
|
-
authorID:
|
|
15
|
+
authorID: definition,
|
|
15
16
|
},
|
|
16
17
|
entities: {
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
|
-
}, {
|
|
21
|
-
|
|
22
|
-
personId: null,
|
|
23
|
-
memberships: [{ role: 'author', variables: [{ name: 'authorID', values: [testUuid(2)] }] }],
|
|
24
|
-
}), {
|
|
25
|
-
author__authorID: [testUuid(2)],
|
|
21
|
+
}, [{ role: 'author', variables: [{ name: 'authorID', condition: { in: [testUuid(2)] } }] }]), {
|
|
22
|
+
author__authorID: { in: [testUuid(2)] },
|
|
26
23
|
})
|
|
27
24
|
})
|
|
28
25
|
|
|
@@ -33,38 +30,14 @@ describe('create acl variables', () => {
|
|
|
33
30
|
author: {
|
|
34
31
|
stages: '*',
|
|
35
32
|
variables: {
|
|
36
|
-
authorID:
|
|
33
|
+
authorID: definition,
|
|
37
34
|
},
|
|
38
35
|
entities: {},
|
|
39
36
|
},
|
|
40
37
|
},
|
|
41
|
-
}, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
memberships: [{ role: 'author', variables: [] }],
|
|
45
|
-
}), {
|
|
46
|
-
author__authorID: [],
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
it('predefined', () => {
|
|
52
|
-
assert.deepStrictEqual(createAclVariables({
|
|
53
|
-
roles: {
|
|
54
|
-
author: {
|
|
55
|
-
stages: '*',
|
|
56
|
-
variables: {
|
|
57
|
-
authorIdentity: { type: Acl.VariableType.predefined, value: 'identityID' },
|
|
58
|
-
},
|
|
59
|
-
entities: {},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}, {
|
|
63
|
-
identityId: testUuid(1),
|
|
64
|
-
personId: null,
|
|
65
|
-
memberships: [{ role: 'author', variables: [] }],
|
|
66
|
-
}), {
|
|
67
|
-
author__authorIdentity: [testUuid(1)],
|
|
38
|
+
}, [{ role: 'author', variables: [] }],
|
|
39
|
+
), {
|
|
40
|
+
author__authorID: { never: true },
|
|
68
41
|
})
|
|
69
42
|
})
|
|
70
43
|
})
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { describe, it, assert } from 'vitest'
|
|
2
|
+
import { ConditionOptimizer } from '../../../src/mapper/select/optimizer/ConditionOptimizer'
|
|
3
|
+
|
|
4
|
+
describe('condition optimizer', () => {
|
|
5
|
+
const optimizer = new ConditionOptimizer()
|
|
6
|
+
|
|
7
|
+
it('remove OR when only 1', () => {
|
|
8
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
9
|
+
or: [{ eq: 1 }],
|
|
10
|
+
}), { eq: 1 })
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('keep OR when > 1', () => {
|
|
14
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
15
|
+
or: [{ eq: 1 }, { eq: 2 }],
|
|
16
|
+
}), {
|
|
17
|
+
or: [{ eq: 1 }, { eq: 2 }],
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('keep never in OR', () => {
|
|
22
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
23
|
+
or: [{ never: true }],
|
|
24
|
+
}), false)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('optimizes OR with never', () => {
|
|
28
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
29
|
+
or: [{ eq: 1 }, { never: true }],
|
|
30
|
+
}), { eq: 1 })
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('optimizes OR with always', () => {
|
|
34
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
35
|
+
or: [{ eq: 1 }, { always: true }],
|
|
36
|
+
}), true)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('optimizes AND with never', () => {
|
|
40
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
41
|
+
and: [{ eq: 1 }, { never: true }],
|
|
42
|
+
}), false)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('optimizes AND with always', () => {
|
|
46
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
47
|
+
and: [{ eq: 1 }, { always: true }],
|
|
48
|
+
}), { eq: 1 })
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('optimizes NOT with never', () => {
|
|
52
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
53
|
+
not: { never: true },
|
|
54
|
+
}), true)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('optimizes NOT with always', () => {
|
|
58
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
59
|
+
not: { always: true },
|
|
60
|
+
}), false)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('optimizes empty AND', () => {
|
|
64
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
65
|
+
and: [],
|
|
66
|
+
}), {})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('optimizes empty OR', () => {
|
|
70
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
71
|
+
or: [],
|
|
72
|
+
}), {})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
it('flattens AND', () => {
|
|
77
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
78
|
+
eq: 0,
|
|
79
|
+
and: [
|
|
80
|
+
{ eq: 1 },
|
|
81
|
+
{
|
|
82
|
+
eq: 2,
|
|
83
|
+
and: [
|
|
84
|
+
{ eq: 3 },
|
|
85
|
+
{
|
|
86
|
+
eq: 4,
|
|
87
|
+
and: [{ eq: 5 }, { eq: 6 }],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}), { and: [{ eq: 0 }, { eq: 1 }, { eq: 2 }, { eq: 3 }, { eq: 4 }, { eq: 5 }, { eq: 6 }] })
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('flattens OR', () => {
|
|
96
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
97
|
+
or: [
|
|
98
|
+
{ eq: 1 },
|
|
99
|
+
{
|
|
100
|
+
|
|
101
|
+
or: [
|
|
102
|
+
{ eq: 2 },
|
|
103
|
+
{ or: [{ eq: 3 }, { eq: 4 }] },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
}), { or: [{ eq: 1 }, { eq: 2 }, { eq: 3 }, { eq: 4 }] })
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('flattens NOT', () => {
|
|
111
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
112
|
+
not: { not: { not: { eq: 1 } } },
|
|
113
|
+
}), { not: { eq: 1 } })
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('combine AND and OR', () => {
|
|
117
|
+
assert.deepStrictEqual(optimizer.optimize({
|
|
118
|
+
or: [
|
|
119
|
+
{ and: [{ eq: 1 }, { eq: 2 }] },
|
|
120
|
+
{ and: [{ eq: 3 }, { eq: 4 }], eq: 5 },
|
|
121
|
+
],
|
|
122
|
+
}), { or: [
|
|
123
|
+
{ and: [{ eq: 1 }, { eq: 2 }] },
|
|
124
|
+
{ and: [{ eq: 3 }, { eq: 4 }, { eq: 5 }] },
|
|
125
|
+
] })
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('remove conditions with null value', () => {
|
|
129
|
+
assert.deepStrictEqual(optimizer.optimize({ eq: null }), {})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('remove conditions with undefined value', () => {
|
|
133
|
+
assert.deepStrictEqual(optimizer.optimize({ eq: undefined }), {})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
@@ -15,8 +15,10 @@ const execute = (test: Test) => {
|
|
|
15
15
|
.entity('Entity2', e => e.oneHasOne('xyz', r => r.target('Entity1')))
|
|
16
16
|
.buildSchema()
|
|
17
17
|
const merger = new PermissionFactory(schema)
|
|
18
|
+
const initialAcl = JSON.parse(JSON.stringify(test.acl))
|
|
18
19
|
const result = merger.create(test.acl, test.roles)
|
|
19
20
|
assert.deepStrictEqual(result, test.result)
|
|
21
|
+
assert.deepStrictEqual(test.acl, initialAcl)
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
describe('Permission merger', () => {
|