@contember/engine-content-api 1.2.0-alpha.10 → 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/PredicateFactory.d.ts +1 -1
- package/dist/src/acl/PredicateFactory.d.ts.map +1 -1
- package/dist/src/acl/PredicateFactory.js +6 -13
- 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 +13 -20
- package/dist/src/acl/PredicatesInjector.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 +11 -14
- 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 +11 -15
- 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/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/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 +2 -2
- 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 +11 -19
- package/dist/src/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.js +34 -25
- 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 +3 -2
- package/dist/src/mapper/select/WhereBuilder.d.ts.map +1 -1
- package/dist/src/mapper/select/WhereBuilder.js +29 -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 +33 -25
- 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.map +1 -1
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js +6 -0
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts +2 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js +52 -20
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts +4 -1
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereReplacer.js +4 -3
- package/dist/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
- 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/MutationResolver.js +1 -1
- package/dist/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/src/resolvers/ReadHelpers.js +3 -3
- 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/OrderByTypeProvider.js +1 -1
- package/dist/src/schema/OrderByTypeProvider.js.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 +3 -3
- 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/uniqueWhereFields.js +3 -3
- package/dist/src/utils/uniqueWhereFields.js.map +1 -1
- package/dist/tests/cases/unit/predicatesFactory.test.js +7 -1
- package/dist/tests/cases/unit/predicatesFactory.test.js.map +1 -1
- package/dist/tests/cases/unit/whereOptimizer.test.js +82 -0
- package/dist/tests/cases/unit/whereOptimizer.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/acl/PredicateFactory.ts +7 -14
- package/src/acl/PredicatesInjector.ts +13 -18
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +17 -24
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +1 -6
- package/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts +10 -28
- package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +6 -3
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +4 -22
- package/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.ts +10 -29
- 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/ValidationDataSelector.ts +1 -1
- 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/mapper/Mapper.ts +36 -33
- package/src/mapper/MapperContainer.ts +3 -2
- 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 +49 -50
- 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 +45 -34
- package/src/mapper/select/handlers/FieldsVisitor.ts +32 -49
- package/src/mapper/select/handlers/FieldsVisitorFactory.ts +1 -0
- package/src/mapper/select/optimizer/ConditionOptimizer.ts +6 -0
- package/src/mapper/select/optimizer/WhereOptimizer.ts +58 -20
- package/src/mapper/select/optimizer/WhereReplacer.ts +8 -3
- package/src/mapper/update/SqlUpdateInputProcessor.ts +1 -1
- package/src/mapper/update/UpdateBuilder.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/uniqueWhereFields.ts +3 -3
- package/tests/cases/unit/predicatesFactory.test.ts +8 -2
- package/tests/cases/unit/whereOptimizer.test.ts +94 -0
- 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/src/inputProcessing/InputContext.ts +0 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"test": "vitest --no-threads"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@contember/database": "^1.2.0-alpha.
|
|
14
|
-
"@contember/dic": "^1.2.0-alpha.
|
|
15
|
-
"@contember/engine-common": "^1.2.0-alpha.
|
|
16
|
-
"@contember/graphql-utils": "^1.2.0-alpha.
|
|
17
|
-
"@contember/schema": "^1.2.0-alpha.
|
|
18
|
-
"@contember/schema-utils": "^1.2.0-alpha.
|
|
13
|
+
"@contember/database": "^1.2.0-alpha.11",
|
|
14
|
+
"@contember/dic": "^1.2.0-alpha.11",
|
|
15
|
+
"@contember/engine-common": "^1.2.0-alpha.11",
|
|
16
|
+
"@contember/graphql-utils": "^1.2.0-alpha.11",
|
|
17
|
+
"@contember/schema": "^1.2.0-alpha.11",
|
|
18
|
+
"@contember/schema-utils": "^1.2.0-alpha.11",
|
|
19
19
|
"@graphql-tools/schema": "^8.3.5",
|
|
20
20
|
"graphql-tag": "^2.12.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@contember/database-tester": "^1.2.0-alpha.
|
|
24
|
-
"@contember/engine-api-tester": "^1.2.0-alpha.
|
|
25
|
-
"@contember/schema-definition": "^1.2.0-alpha.
|
|
23
|
+
"@contember/database-tester": "^1.2.0-alpha.11",
|
|
24
|
+
"@contember/engine-api-tester": "^1.2.0-alpha.11",
|
|
25
|
+
"@contember/schema-definition": "^1.2.0-alpha.11",
|
|
26
26
|
"@graphql-codegen/cli": "^2.6.2",
|
|
27
27
|
"@graphql-codegen/typescript": "^2.5.1",
|
|
28
28
|
"@graphql-codegen/typescript-operations": "^2.4.2",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Acl, Input, Model } from '@contember/schema'
|
|
2
2
|
import { VariableInjector } from './VariableInjector'
|
|
3
|
-
import { isOwningRelation } from '@contember/schema-utils'
|
|
4
|
-
import { ImplementationException } from '../exception'
|
|
5
3
|
import { EvaluatedPredicateReplacer } from './EvaluatedPredicateReplacer'
|
|
6
4
|
|
|
7
5
|
const getRowLevelPredicatePseudoField = (entity: Model.Entity) => entity.primary
|
|
@@ -31,13 +29,13 @@ export class PredicateFactory {
|
|
|
31
29
|
entity: Model.Entity,
|
|
32
30
|
operation: Acl.Operation.update | Acl.Operation.read | Acl.Operation.create,
|
|
33
31
|
fieldNames?: string[],
|
|
34
|
-
|
|
32
|
+
relationContext?: Model.AnyRelationContext,
|
|
35
33
|
): Input.Where
|
|
36
34
|
public create(
|
|
37
35
|
entity: Model.Entity,
|
|
38
36
|
operation: Acl.Operation,
|
|
39
37
|
fieldNames?: string[],
|
|
40
|
-
|
|
38
|
+
relationContext?: Model.AnyRelationContext,
|
|
41
39
|
): Input.Where {
|
|
42
40
|
const entityPermissions: Acl.EntityPermissions = this.permissions[entity.name]
|
|
43
41
|
const neverCondition: Input.Where = { [entity.primary]: { never: true } }
|
|
@@ -85,7 +83,7 @@ export class PredicateFactory {
|
|
|
85
83
|
return {}
|
|
86
84
|
}
|
|
87
85
|
const where: Input.Where = predicatesWhere.length === 1 ? predicatesWhere[0] : { and: predicatesWhere }
|
|
88
|
-
return this.optimizePredicates(where,
|
|
86
|
+
return this.optimizePredicates(where, relationContext)
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
private getRequiredPredicates(
|
|
@@ -108,21 +106,16 @@ export class PredicateFactory {
|
|
|
108
106
|
return predicates
|
|
109
107
|
}
|
|
110
108
|
|
|
111
|
-
private optimizePredicates(where: Input.Where,
|
|
112
|
-
if (!
|
|
109
|
+
private optimizePredicates(where: Input.Where, relationContext?: Model.AnyRelationContext) {
|
|
110
|
+
if (!relationContext || !relationContext.targetRelation) {
|
|
113
111
|
return where
|
|
114
112
|
}
|
|
115
|
-
const
|
|
116
|
-
if (!otherSide) {
|
|
117
|
-
throw new ImplementationException()
|
|
118
|
-
}
|
|
119
|
-
const sourceEntity = this.model.entities[overRelation.target]
|
|
120
|
-
const sourcePredicate = this.create(sourceEntity, Acl.Operation.read, [otherSide])
|
|
113
|
+
const sourcePredicate = this.create(relationContext.entity, Acl.Operation.read, [relationContext.relation.name])
|
|
121
114
|
if (Object.keys(sourcePredicate).length === 0) {
|
|
122
115
|
return where
|
|
123
116
|
}
|
|
124
117
|
|
|
125
|
-
const replacer = new EvaluatedPredicateReplacer(sourcePredicate,
|
|
118
|
+
const replacer = new EvaluatedPredicateReplacer(sourcePredicate, relationContext.entity, relationContext.targetRelation)
|
|
126
119
|
return replacer.replace(where)
|
|
127
120
|
}
|
|
128
121
|
}
|
|
@@ -5,18 +5,18 @@ import { PredicateFactory } from './PredicateFactory'
|
|
|
5
5
|
export class PredicatesInjector {
|
|
6
6
|
constructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}
|
|
7
7
|
|
|
8
|
-
public inject(entity: Model.Entity, where: Input.OptionalWhere,
|
|
8
|
+
public inject(entity: Model.Entity, where: Input.OptionalWhere, relationContext?: Model.AnyRelationContext): Input.OptionalWhere {
|
|
9
9
|
const restrictedWhere = this.injectToWhere(where, entity, true)
|
|
10
|
-
return this.createWhere(entity, undefined, restrictedWhere,
|
|
10
|
+
return this.createWhere(entity, undefined, restrictedWhere, relationContext)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
private createWhere(
|
|
14
14
|
entity: Model.Entity,
|
|
15
15
|
fieldNames: string[] | undefined,
|
|
16
16
|
where: Input.OptionalWhere,
|
|
17
|
-
|
|
17
|
+
relationContext?: Model.AnyRelationContext,
|
|
18
18
|
): Input.OptionalWhere {
|
|
19
|
-
const predicatesWhere: Input.Where = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames,
|
|
19
|
+
const predicatesWhere: Input.Where = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext)
|
|
20
20
|
|
|
21
21
|
const and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)
|
|
22
22
|
if (and.length === 0) {
|
|
@@ -32,17 +32,17 @@ export class PredicatesInjector {
|
|
|
32
32
|
where: Input.OptionalWhere,
|
|
33
33
|
entity: Model.Entity,
|
|
34
34
|
isRoot: boolean,
|
|
35
|
-
|
|
35
|
+
relationContext?: Model.AnyRelationContext,
|
|
36
36
|
): Input.OptionalWhere {
|
|
37
37
|
const resultWhere: Writable<Input.OptionalWhere> = {}
|
|
38
38
|
if (where.and) {
|
|
39
|
-
resultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it => this.injectToWhere(it, entity, isRoot,
|
|
39
|
+
resultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it => this.injectToWhere(it, entity, isRoot, relationContext))
|
|
40
40
|
}
|
|
41
41
|
if (where.or) {
|
|
42
|
-
resultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it => this.injectToWhere(it, entity, isRoot,
|
|
42
|
+
resultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it => this.injectToWhere(it, entity, isRoot, relationContext))
|
|
43
43
|
}
|
|
44
44
|
if (where.not) {
|
|
45
|
-
resultWhere.not = this.injectToWhere(where.not, entity, isRoot,
|
|
45
|
+
resultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))
|
|
@@ -51,21 +51,16 @@ export class PredicatesInjector {
|
|
|
51
51
|
return resultWhere
|
|
52
52
|
}
|
|
53
53
|
for (let field of fields) {
|
|
54
|
-
|
|
55
|
-
visitColumn: () =>
|
|
56
|
-
visitRelation: (
|
|
57
|
-
})
|
|
58
|
-
if (targetEntity) {
|
|
59
|
-
resultWhere[field] = this.injectToWhere(where[field] as Input.Where, targetEntity, false, targetRelation)
|
|
60
|
-
} else {
|
|
61
|
-
resultWhere[field] = where[field]
|
|
62
|
-
}
|
|
54
|
+
resultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {
|
|
55
|
+
visitColumn: () => where[field],
|
|
56
|
+
visitRelation: context => this.injectToWhere(where[field] as Input.Where, context.targetEntity, false, context),
|
|
57
|
+
})
|
|
63
58
|
}
|
|
64
59
|
const fieldsForPredicate = !isRoot
|
|
65
60
|
? fields
|
|
66
61
|
: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it))
|
|
67
62
|
|
|
68
|
-
return this.createWhere(entity, fieldsForPredicate, resultWhere,
|
|
63
|
+
return this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext)
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
}
|
|
@@ -18,7 +18,19 @@ export class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHa
|
|
|
18
18
|
addData(
|
|
19
19
|
entity.primary,
|
|
20
20
|
async (ids: Input.PrimaryValue[]) => {
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
const relationContext = acceptFieldVisitor(this.schema, entity, objectNode.extensions.relationName, {
|
|
23
|
+
visitRelation: context => context,
|
|
24
|
+
visitColumn: (): never => {
|
|
25
|
+
throw new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const { targetEntity, targetRelation } = relationContext
|
|
30
|
+
if (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {
|
|
31
|
+
throw new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
const uniqueWhere = this.uniqueWhereExpander.expand(targetEntity, {
|
|
23
35
|
...objectNode.args.by,
|
|
24
36
|
[targetRelation.name]: { [entity.primary]: ids },
|
|
@@ -31,31 +43,12 @@ export class HasManyToHasOneReducerExecutionHandler implements SelectExecutionHa
|
|
|
31
43
|
}
|
|
32
44
|
const newObjectNode = objectNode.withArgs<Input.ListQueryInput>({ filter: whereWithParentId })
|
|
33
45
|
|
|
34
|
-
return context.mapper.
|
|
46
|
+
return context.mapper.selectAssoc(targetEntity, newObjectNode, [
|
|
47
|
+
...context.relationPath,
|
|
48
|
+
relationContext,
|
|
49
|
+
], targetRelation.name)
|
|
35
50
|
},
|
|
36
51
|
null,
|
|
37
52
|
)
|
|
38
53
|
}
|
|
39
|
-
|
|
40
|
-
private getRelationTarget(
|
|
41
|
-
entity: Model.Entity,
|
|
42
|
-
relationName: string,
|
|
43
|
-
): [Model.Entity, Model.AnyRelation & Model.JoiningColumnRelation] {
|
|
44
|
-
return acceptFieldVisitor(this.schema, entity, relationName, {
|
|
45
|
-
visitColumn: (): never => {
|
|
46
|
-
throw new ImplementationException('HasManyToHasOneReducerExecutionHandler: Not applicable for a column')
|
|
47
|
-
},
|
|
48
|
-
visitRelation: (
|
|
49
|
-
entity,
|
|
50
|
-
relation,
|
|
51
|
-
targetEntity,
|
|
52
|
-
targetRelation,
|
|
53
|
-
): [Model.Entity, Model.AnyRelation & Model.JoiningColumnRelation] => {
|
|
54
|
-
if (!targetRelation || !isIt<Model.JoiningColumnRelation>(targetRelation, 'joiningColumn')) {
|
|
55
|
-
throw new Error('HasManyToHasOneReducerExecutionHandler: only applicable for relations with joiningColumn')
|
|
56
|
-
}
|
|
57
|
-
return [targetEntity, targetRelation]
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
54
|
}
|
|
@@ -48,12 +48,7 @@ export class HasManyToHasOneRelationReducerFieldVisitor implements
|
|
|
48
48
|
return {}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
public visitOneHasMany(
|
|
52
|
-
entity: Model.Entity,
|
|
53
|
-
relation: Model.AnyRelation,
|
|
54
|
-
targetEntity: Model.Entity,
|
|
55
|
-
targetRelation: Model.AnyRelation | null,
|
|
56
|
-
) {
|
|
51
|
+
public visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {
|
|
57
52
|
if (!targetRelation) {
|
|
58
53
|
return {}
|
|
59
54
|
}
|
|
@@ -11,58 +11,40 @@ export class PaginatedHasManyCountVisitor implements
|
|
|
11
11
|
private readonly objectNode: ObjectNode<Input.PaginationQueryInput>,
|
|
12
12
|
private readonly relationFetcher: RelationFetcher,
|
|
13
13
|
private readonly mapper: Mapper,
|
|
14
|
+
private readonly relationPath: Model.AnyRelationContext[],
|
|
14
15
|
) {}
|
|
15
16
|
|
|
16
|
-
async visitOneHasMany(
|
|
17
|
-
entity: Model.Entity,
|
|
18
|
-
relation: Model.OneHasManyRelation,
|
|
19
|
-
targetEntity: Model.Entity,
|
|
20
|
-
targetRelation: Model.ManyHasOneRelation,
|
|
21
|
-
): Promise<GroupedCounts> {
|
|
17
|
+
async visitOneHasMany(relationContext: Model.OneHasManyContext): Promise<GroupedCounts> {
|
|
22
18
|
return await this.relationFetcher.countOneHasManyGroups(
|
|
23
19
|
{
|
|
24
20
|
mapper: this.mapper,
|
|
25
21
|
filter: this.objectNode.args.filter,
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
relationContext,
|
|
23
|
+
relationPath: this.relationPath,
|
|
28
24
|
ids: this.ids,
|
|
29
25
|
},
|
|
30
26
|
)
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
async visitManyHasManyOwning(
|
|
34
|
-
entity: Model.Entity,
|
|
35
|
-
relation: Model.ManyHasManyOwningRelation,
|
|
36
|
-
targetEntity: Model.Entity,
|
|
37
|
-
targetRelation: Model.ManyHasManyInverseRelation | null,
|
|
38
|
-
): Promise<GroupedCounts> {
|
|
29
|
+
async visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): Promise<GroupedCounts> {
|
|
39
30
|
return await this.relationFetcher.countManyHasManyGroups(
|
|
40
31
|
{
|
|
41
32
|
mapper: this.mapper,
|
|
42
33
|
filter: this.objectNode.args.filter,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
targetRelation,
|
|
46
|
-
directionFrom: 'owning',
|
|
34
|
+
relationContext,
|
|
35
|
+
relationPath: this.relationPath,
|
|
47
36
|
ids: this.ids,
|
|
48
37
|
},
|
|
49
38
|
)
|
|
50
39
|
}
|
|
51
40
|
|
|
52
|
-
async visitManyHasManyInverse(
|
|
53
|
-
entity: Model.Entity,
|
|
54
|
-
relation: Model.ManyHasManyInverseRelation,
|
|
55
|
-
targetEntity: Model.Entity,
|
|
56
|
-
targetRelation: Model.ManyHasManyOwningRelation,
|
|
57
|
-
): Promise<GroupedCounts> {
|
|
41
|
+
async visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): Promise<GroupedCounts> {
|
|
58
42
|
return await this.relationFetcher.countManyHasManyGroups(
|
|
59
43
|
{
|
|
60
44
|
mapper: this.mapper,
|
|
61
45
|
filter: this.objectNode.args.filter,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
targetRelation,
|
|
65
|
-
directionFrom: 'inverse',
|
|
46
|
+
relationContext,
|
|
47
|
+
relationPath: this.relationPath,
|
|
66
48
|
ids: this.ids,
|
|
67
49
|
},
|
|
68
50
|
)
|
|
@@ -7,7 +7,10 @@ import { PaginatedHasManyCountVisitor } from './PaginatedHasManyCountVisitor'
|
|
|
7
7
|
import { PaginatedHasManyNodesVisitor } from './PaginatedHasManyNodesVisitor'
|
|
8
8
|
|
|
9
9
|
export class PaginatedHasManyExecutionHandler implements SelectExecutionHandler<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension> {
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly schema: Model.Schema,
|
|
12
|
+
private readonly relationFetcher: RelationFetcher,
|
|
13
|
+
) {}
|
|
11
14
|
|
|
12
15
|
process(
|
|
13
16
|
context: SelectExecutionHandlerContext<Input.PaginationQueryInput, PaginatedHasManyFieldProviderExtension>,
|
|
@@ -25,7 +28,7 @@ export class PaginatedHasManyExecutionHandler implements SelectExecutionHandler<
|
|
|
25
28
|
this.schema,
|
|
26
29
|
entity,
|
|
27
30
|
objectNode.extensions.relationName,
|
|
28
|
-
new PaginatedHasManyCountVisitor(ids, objectNode, this.relationFetcher, mapper),
|
|
31
|
+
new PaginatedHasManyCountVisitor(ids, objectNode, this.relationFetcher, mapper, context.relationPath),
|
|
29
32
|
)
|
|
30
33
|
: {}
|
|
31
34
|
|
|
@@ -34,7 +37,7 @@ export class PaginatedHasManyExecutionHandler implements SelectExecutionHandler<
|
|
|
34
37
|
this.schema,
|
|
35
38
|
entity,
|
|
36
39
|
objectNode.extensions.relationName,
|
|
37
|
-
new PaginatedHasManyNodesVisitor(ids, pagination.nodeField, this.relationFetcher, mapper),
|
|
40
|
+
new PaginatedHasManyNodesVisitor(ids, pagination.nodeField, this.relationFetcher, mapper, context.relationPath),
|
|
38
41
|
)
|
|
39
42
|
: undefined
|
|
40
43
|
const result = new Map<Input.PrimaryValue, any>()
|
|
@@ -11,37 +11,19 @@ export class PaginatedHasManyFieldProviderVisitor implements
|
|
|
11
11
|
|
|
12
12
|
constructor(private readonly paginatedFieldFactory: PaginatedFieldConfigFactory) {}
|
|
13
13
|
|
|
14
|
-
visitOneHasMany(
|
|
15
|
-
entity: Model.Entity,
|
|
16
|
-
relation: Model.OneHasManyRelation,
|
|
17
|
-
targetEntity: Model.Entity,
|
|
18
|
-
targetRelation: Model.ManyHasOneRelation,
|
|
19
|
-
): FieldMap<PaginatedHasManyFieldProviderExtension> {
|
|
14
|
+
visitOneHasMany({ targetEntity, relation }: Model.OneHasManyContext) {
|
|
20
15
|
return this.createField(targetEntity, relation)
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
visitManyHasManyOwning(
|
|
24
|
-
entity: Model.Entity,
|
|
25
|
-
relation: Model.ManyHasManyOwningRelation,
|
|
26
|
-
targetEntity: Model.Entity,
|
|
27
|
-
targetRelation: Model.ManyHasManyInverseRelation | null,
|
|
28
|
-
): FieldMap<PaginatedHasManyFieldProviderExtension> {
|
|
18
|
+
visitManyHasManyOwning({ targetEntity, relation }: Model.ManyHasManyOwningContext) {
|
|
29
19
|
return this.createField(targetEntity, relation)
|
|
30
20
|
}
|
|
31
21
|
|
|
32
|
-
visitManyHasManyInverse(
|
|
33
|
-
entity: Model.Entity,
|
|
34
|
-
relation: Model.ManyHasManyInverseRelation,
|
|
35
|
-
targetEntity: Model.Entity,
|
|
36
|
-
targetRelation: Model.ManyHasManyOwningRelation,
|
|
37
|
-
): FieldMap<PaginatedHasManyFieldProviderExtension> {
|
|
22
|
+
visitManyHasManyInverse({ targetEntity, relation }: Model.ManyHasManyInverseContext) {
|
|
38
23
|
return this.createField(targetEntity, relation)
|
|
39
24
|
}
|
|
40
25
|
|
|
41
|
-
private createField(
|
|
42
|
-
entity: Model.Entity,
|
|
43
|
-
relation: Model.Relation,
|
|
44
|
-
): FieldMap<PaginatedHasManyFieldProviderExtension> {
|
|
26
|
+
private createField(entity: Model.Entity, relation: Model.Relation): FieldMap<PaginatedHasManyFieldProviderExtension> {
|
|
45
27
|
return {
|
|
46
28
|
[`paginate${capitalizeFirstLetter(relation.name)}`]: {
|
|
47
29
|
...this.paginatedFieldFactory.createFieldConfig(entity),
|
|
@@ -11,59 +11,40 @@ export class PaginatedHasManyNodesVisitor implements
|
|
|
11
11
|
private readonly objectNode: ObjectNode<Input.PaginationQueryInput>,
|
|
12
12
|
private readonly relationFetcher: RelationFetcher,
|
|
13
13
|
private readonly mapper: Mapper,
|
|
14
|
+
private readonly relationPath: Model.AnyRelationContext[],
|
|
14
15
|
) {}
|
|
15
16
|
|
|
16
|
-
async visitOneHasMany(
|
|
17
|
-
entity: Model.Entity,
|
|
18
|
-
relation: Model.OneHasManyRelation,
|
|
19
|
-
targetEntity: Model.Entity,
|
|
20
|
-
targetRelation: Model.ManyHasOneRelation,
|
|
21
|
-
): Promise<SelectGroupedObjects> {
|
|
17
|
+
async visitOneHasMany(relationContext: Model.OneHasManyContext) {
|
|
22
18
|
return await this.relationFetcher.fetchOneHasManyGroups(
|
|
23
19
|
{
|
|
24
20
|
mapper: this.mapper,
|
|
25
21
|
objectNode: this.objectNode,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
targetRelation: targetRelation,
|
|
22
|
+
relationContext,
|
|
23
|
+
relationPath: this.relationPath,
|
|
29
24
|
ids: this.ids,
|
|
30
25
|
},
|
|
31
26
|
)
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
async visitManyHasManyOwning(
|
|
35
|
-
entity: Model.Entity,
|
|
36
|
-
relation: Model.ManyHasManyOwningRelation,
|
|
37
|
-
targetEntity: Model.Entity,
|
|
38
|
-
targetRelation: Model.ManyHasManyInverseRelation | null,
|
|
39
|
-
): Promise<SelectGroupedObjects> {
|
|
29
|
+
async visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext) {
|
|
40
30
|
return await this.relationFetcher.fetchManyHasManyGroups(
|
|
41
31
|
{
|
|
42
32
|
mapper: this.mapper,
|
|
43
33
|
field: this.objectNode,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
targetRelation,
|
|
47
|
-
directionFrom: 'owning',
|
|
34
|
+
relationContext,
|
|
35
|
+
relationPath: this.relationPath,
|
|
48
36
|
ids: this.ids,
|
|
49
37
|
},
|
|
50
38
|
)
|
|
51
39
|
}
|
|
52
40
|
|
|
53
|
-
async visitManyHasManyInverse(
|
|
54
|
-
entity: Model.Entity,
|
|
55
|
-
relation: Model.ManyHasManyInverseRelation,
|
|
56
|
-
targetEntity: Model.Entity,
|
|
57
|
-
targetRelation: Model.ManyHasManyOwningRelation,
|
|
58
|
-
): Promise<SelectGroupedObjects> {
|
|
41
|
+
async visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext) {
|
|
59
42
|
return await this.relationFetcher.fetchManyHasManyGroups(
|
|
60
43
|
{
|
|
61
44
|
mapper: this.mapper,
|
|
62
45
|
field: this.objectNode,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
targetRelation,
|
|
66
|
-
directionFrom: 'inverse',
|
|
46
|
+
relationContext,
|
|
47
|
+
relationPath: this.relationPath,
|
|
67
48
|
ids: this.ids,
|
|
68
49
|
},
|
|
69
50
|
)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NoDataError, Providers, resolveColumnValue } from '@contember/schema-utils'
|
|
2
|
-
import
|
|
3
|
-
import { Value } from '@contember/schema'
|
|
2
|
+
import { Model, Value } from '@contember/schema'
|
|
4
3
|
|
|
5
4
|
export class ColumnValueResolver {
|
|
6
5
|
constructor(private readonly providers: Providers) {}
|
|
7
6
|
|
|
8
|
-
getDefaultValidationValue(context:
|
|
7
|
+
getDefaultValidationValue(context: Model.ColumnContext & { input: Value.FieldValue | undefined }): Value.AtomicValue | undefined {
|
|
9
8
|
if (context.column.name === context.entity.primary) {
|
|
10
9
|
return '00000000-0000-0000-0000-000000000000'
|
|
11
10
|
}
|
|
@@ -51,7 +51,7 @@ export class EntityRulesResolver {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
class RequiredFieldsVisitor implements Model.RelationByTypeVisitor<boolean>, Model.ColumnVisitor<boolean> {
|
|
54
|
-
visitColumn(
|
|
54
|
+
visitColumn({ column }: Model.ColumnContext): boolean {
|
|
55
55
|
return !column.nullable && typeof column.default === 'undefined' && !column.sequence
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -63,7 +63,7 @@ class RequiredFieldsVisitor implements Model.RelationByTypeVisitor<boolean>, Mod
|
|
|
63
63
|
return false
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
visitManyHasOne(
|
|
66
|
+
visitManyHasOne({ relation }: Model.ManyHasOneContext): boolean {
|
|
67
67
|
return !relation.nullable
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -71,11 +71,11 @@ class RequiredFieldsVisitor implements Model.RelationByTypeVisitor<boolean>, Mod
|
|
|
71
71
|
return false
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
visitOneHasOneInverse(
|
|
74
|
+
visitOneHasOneInverse({ targetEntity, relation }: Model.OneHasOneInverseContext): boolean {
|
|
75
75
|
return !relation.nullable && !targetEntity.view
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
visitOneHasOneOwning(
|
|
78
|
+
visitOneHasOneOwning({ relation }: Model.OneHasOneOwningContext): boolean {
|
|
79
79
|
return !relation.nullable
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -22,7 +22,7 @@ export class QueryAstFactory {
|
|
|
22
22
|
fieldName,
|
|
23
23
|
{
|
|
24
24
|
visitColumn: () => [null, new FieldNode(fieldName, fieldName, {})],
|
|
25
|
-
visitRelation: ({
|
|
25
|
+
visitRelation: ({ targetEntity }) => [
|
|
26
26
|
targetEntity,
|
|
27
27
|
new ObjectNode(fieldName, fieldName, [], {}, {}, []).withField(
|
|
28
28
|
new FieldNode(targetEntity.primary, targetEntity.primary, {}),
|
|
@@ -20,7 +20,7 @@ export class ValidationDataSelector {
|
|
|
20
20
|
return {}
|
|
21
21
|
}
|
|
22
22
|
const queryAst = this.queryAstFactory.create(entity.name, dependencies).withArg('by', where)
|
|
23
|
-
const node = await mapper.selectUnique(entity, queryAst,
|
|
23
|
+
const node = await mapper.selectUnique(entity, queryAst, [])
|
|
24
24
|
if (!node) {
|
|
25
25
|
return null
|
|
26
26
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CreateInputProcessor } from '../../inputProcessing'
|
|
2
|
-
import * as Context from '../../inputProcessing'
|
|
3
2
|
import { Input, Model } from '@contember/schema'
|
|
4
3
|
import { appendRelationToPath, ValidationPath } from '../ValidationPath'
|
|
5
4
|
import { Mapper } from '../../mapper'
|
|
@@ -15,30 +14,30 @@ export class CreateInputPreValidationProcessor implements CreateInputProcessor<R
|
|
|
15
14
|
private readonly mapper: Mapper,
|
|
16
15
|
) {}
|
|
17
16
|
|
|
18
|
-
manyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<
|
|
17
|
+
manyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyInverseContext, Result> = {
|
|
19
18
|
connect: NoResult,
|
|
20
19
|
create: context => this.validateCreate(context),
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
manyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<
|
|
22
|
+
manyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyOwningContext, Result> = {
|
|
24
23
|
connect: NoResult,
|
|
25
24
|
create: context => this.validateCreate(context),
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
manyHasOne: CreateInputProcessor.HasOneRelationProcessor<
|
|
27
|
+
manyHasOne: CreateInputProcessor.HasOneRelationProcessor<Model.ManyHasOneContext, Result> = {
|
|
29
28
|
connect: NoResult,
|
|
30
29
|
create: context => this.validateCreate(context),
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
oneHasMany: CreateInputProcessor.HasManyRelationProcessor<
|
|
32
|
+
oneHasMany: CreateInputProcessor.HasManyRelationProcessor<Model.OneHasManyContext, Result> = {
|
|
34
33
|
connect: NoResult,
|
|
35
34
|
create: context => this.validateCreate(context),
|
|
36
35
|
}
|
|
37
|
-
oneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<
|
|
36
|
+
oneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneInverseContext, Result> = {
|
|
38
37
|
connect: NoResult,
|
|
39
38
|
create: context => this.validateCreate(context),
|
|
40
39
|
}
|
|
41
|
-
oneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<
|
|
40
|
+
oneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneOwningContext, Result> = {
|
|
42
41
|
connect: NoResult,
|
|
43
42
|
create: context => this.validateCreate(context),
|
|
44
43
|
}
|
|
@@ -61,7 +60,7 @@ export class CreateInputPreValidationProcessor implements CreateInputProcessor<R
|
|
|
61
60
|
})
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
async column(context:
|
|
63
|
+
async column(context: Model.ColumnContext): Promise<Result> {
|
|
65
64
|
return []
|
|
66
65
|
}
|
|
67
66
|
}
|
|
@@ -78,12 +78,12 @@ export class InputPreValidator {
|
|
|
78
78
|
|
|
79
79
|
private createContextForCreate(entity: Model.Entity, data: Input.CreateDataInput): ValidationContext.NodeContext {
|
|
80
80
|
const nodeData = acceptEveryFieldVisitor(this.model, entity, {
|
|
81
|
-
visitColumn: (entity, column) => {
|
|
81
|
+
visitColumn: ({ entity, column }) => {
|
|
82
82
|
const value = data[column.name] as Input.ColumnValue | undefined
|
|
83
83
|
const validationValue = this.columnValueResolver.getDefaultValidationValue({ entity, column, input: value })
|
|
84
84
|
return validationValue === undefined ? null : validationValue
|
|
85
85
|
},
|
|
86
|
-
visitHasOne: (
|
|
86
|
+
visitHasOne: ({ relation }) => {
|
|
87
87
|
const value = data[relation.name] as Input.CreateOneRelationInput | undefined
|
|
88
88
|
return value ? true : null
|
|
89
89
|
},
|
|
@@ -101,10 +101,10 @@ export class InputPreValidator {
|
|
|
101
101
|
dependencies: Dependencies,
|
|
102
102
|
): Promise<ValidationContext.NodeContext> {
|
|
103
103
|
const inputNodeData = acceptEveryFieldVisitor(this.model, entity, {
|
|
104
|
-
visitColumn: (
|
|
104
|
+
visitColumn: ({ column }) => {
|
|
105
105
|
return data[column.name] as Input.ColumnValue | undefined
|
|
106
106
|
},
|
|
107
|
-
visitHasOne: (
|
|
107
|
+
visitHasOne: ({ relation }) => {
|
|
108
108
|
const value = data[relation.name] as Input.CreateOneRelationInput | Input.UpdateOneRelationInput | undefined | null
|
|
109
109
|
if (value === undefined || value === null) {
|
|
110
110
|
return undefined
|