@contember/engine-content-api 1.2.0-rc.1 → 1.2.0-rc.3
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/VariableInjector.d.ts +1 -0
- package/dist/src/acl/VariableInjector.d.ts.map +1 -1
- package/dist/src/acl/VariableInjector.js +8 -1
- package/dist/src/acl/VariableInjector.js.map +1 -1
- package/dist/src/mapper/Mapper.js +1 -1
- package/dist/src/mapper/Mapper.js.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.js +6 -3
- package/dist/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/acl/VariableInjector.ts +9 -1
- package/src/mapper/Mapper.ts +1 -1
- package/src/mapper/select/RelationFetcher.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -10,31 +10,31 @@
|
|
|
10
10
|
"test": "vitest --no-threads"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@contember/database": "^1.2.0-rc.
|
|
14
|
-
"@contember/dic": "^1.2.0-rc.
|
|
15
|
-
"@contember/logger": "^1.2.0-rc.
|
|
16
|
-
"@contember/graphql-utils": "^1.2.0-rc.
|
|
17
|
-
"@contember/schema": "^1.2.0-rc.
|
|
18
|
-
"@contember/schema-definition": "^1.2.0-rc.
|
|
19
|
-
"@contember/schema-utils": "^1.2.0-rc.
|
|
13
|
+
"@contember/database": "^1.2.0-rc.3",
|
|
14
|
+
"@contember/dic": "^1.2.0-rc.3",
|
|
15
|
+
"@contember/logger": "^1.2.0-rc.3",
|
|
16
|
+
"@contember/graphql-utils": "^1.2.0-rc.3",
|
|
17
|
+
"@contember/schema": "^1.2.0-rc.3",
|
|
18
|
+
"@contember/schema-definition": "^1.2.0-rc.3",
|
|
19
|
+
"@contember/schema-utils": "^1.2.0-rc.3",
|
|
20
20
|
"@graphql-tools/schema": "^8.3.5",
|
|
21
21
|
"fast-deep-equal": "^3.1.3",
|
|
22
22
|
"graphql-tag": "^2.12.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@contember/database-tester": "^1.2.0-rc.
|
|
26
|
-
"@contember/engine-api-tester": "^1.2.0-rc.
|
|
27
|
-
"@contember/schema-definition": "^1.2.0-rc.
|
|
25
|
+
"@contember/database-tester": "^1.2.0-rc.3",
|
|
26
|
+
"@contember/engine-api-tester": "^1.2.0-rc.3",
|
|
27
|
+
"@contember/schema-definition": "^1.2.0-rc.3",
|
|
28
28
|
"@graphql-codegen/cli": "^2.6.2",
|
|
29
29
|
"@graphql-codegen/typescript": "^2.5.1",
|
|
30
30
|
"@graphql-codegen/typescript-operations": "^2.4.2",
|
|
31
31
|
"@graphql-codegen/typescript-resolvers": "^2.6.6",
|
|
32
32
|
"@types/node": "^18",
|
|
33
33
|
"graphql": "^16.5.0",
|
|
34
|
-
"pg": "^8.
|
|
34
|
+
"pg": "^8.9.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"graphql": ">= 14.6.0",
|
|
38
|
-
"pg": "^8.
|
|
38
|
+
"pg": "^8.9.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -2,12 +2,18 @@ import { Acl, Input, Model } from '@contember/schema'
|
|
|
2
2
|
import { PredicateDefinitionProcessor } from '@contember/schema-utils'
|
|
3
3
|
|
|
4
4
|
export class VariableInjector {
|
|
5
|
+
private injectorCache = new WeakMap<Acl.PredicateDefinition, Input.Where>()
|
|
6
|
+
|
|
5
7
|
constructor(private readonly schema: Model.Schema, private readonly variables: Acl.VariablesMap) {}
|
|
6
8
|
|
|
7
9
|
public inject(entity: Model.Entity, where: Acl.PredicateDefinition): Input.Where {
|
|
10
|
+
const cacheEntry = this.injectorCache.get(where)
|
|
11
|
+
if (cacheEntry !== undefined) {
|
|
12
|
+
return cacheEntry
|
|
13
|
+
}
|
|
8
14
|
const predicateDefinitionProcessor = new PredicateDefinitionProcessor(this.schema)
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
const resultWhere = predicateDefinitionProcessor.process(entity, where, {
|
|
11
17
|
handleColumn: ({ value }) => {
|
|
12
18
|
if (typeof value === 'string') {
|
|
13
19
|
return this.variables[value] ?? { never: true }
|
|
@@ -21,5 +27,7 @@ export class VariableInjector {
|
|
|
21
27
|
return value
|
|
22
28
|
},
|
|
23
29
|
})
|
|
30
|
+
this.injectorCache.set(where, resultWhere)
|
|
31
|
+
return resultWhere
|
|
24
32
|
}
|
|
25
33
|
}
|
package/src/mapper/Mapper.ts
CHANGED
|
@@ -153,7 +153,7 @@ export class Mapper {
|
|
|
153
153
|
.select(expr => expr.raw('count(*)'), 'row_count')
|
|
154
154
|
.select([path.alias, relation.joiningColumn.columnName])
|
|
155
155
|
.groupBy([path.alias, relation.joiningColumn.columnName])
|
|
156
|
-
const withPredicates = this.predicatesInjector.inject(entity, filter)
|
|
156
|
+
const withPredicates = this.predicatesInjector.inject(entity, filter, relationPath[relationPath.length - 1])
|
|
157
157
|
const qbWithWhere = this.whereBuilder.build(qb, entity, path, withPredicates, { relationPath })
|
|
158
158
|
const rows = await qbWithWhere.getResult(this.db)
|
|
159
159
|
const result = new Map<string, number>()
|
|
@@ -118,7 +118,10 @@ export class RelationFetcher {
|
|
|
118
118
|
|
|
119
119
|
const joiningColumns = this.resolveJoiningColumns({ relationType: relationContext.type, joiningTable: owningRelation.joiningTable })
|
|
120
120
|
|
|
121
|
-
const qb = this.buildJunctionQb(owningRelation, ids, joiningColumns, relationContext.targetEntity, { filter },
|
|
121
|
+
const qb = this.buildJunctionQb(owningRelation, ids, joiningColumns, relationContext.targetEntity, { filter }, [
|
|
122
|
+
...relationPath,
|
|
123
|
+
relationContext,
|
|
124
|
+
])
|
|
122
125
|
.select(['junction_', joiningColumns.sourceColumn.columnName])
|
|
123
126
|
.select(expr => expr.raw('count(*)'), 'row_count')
|
|
124
127
|
.groupBy(['junction_', joiningColumns.sourceColumn.columnName])
|
|
@@ -151,7 +154,7 @@ export class RelationFetcher {
|
|
|
151
154
|
joiningColumns,
|
|
152
155
|
targetEntity,
|
|
153
156
|
objectNode,
|
|
154
|
-
relationPath,
|
|
157
|
+
[...relationPath, relationContext],
|
|
155
158
|
)
|
|
156
159
|
if (junctionValues.length === 0) {
|
|
157
160
|
return {}
|
|
@@ -259,7 +262,7 @@ export class RelationFetcher {
|
|
|
259
262
|
.from(joiningTable.tableName, 'junction_')
|
|
260
263
|
.where(clause => clause.in(['junction_', whereColumn], ids))
|
|
261
264
|
|
|
262
|
-
const where = this.predicateInjector.inject(targetEntity, objectArgs.filter || {})
|
|
265
|
+
const where = this.predicateInjector.inject(targetEntity, objectArgs.filter || {}, relationPath[relationPath.length - 1])
|
|
263
266
|
const hasWhere = where && Object.keys(where).length > 0
|
|
264
267
|
const hasFieldOrderBy =
|
|
265
268
|
objectArgs.orderBy &&
|