@contember/engine-content-api 2.0.0-beta.1 → 2.0.0-beta.2
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/development/src/mapper/Mapper.cjs +2 -1
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +2 -1
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +2 -1
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +2 -1
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/mapper/Mapper.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/mapper/Mapper.ts +2 -1
- package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +68 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"generate": "gql-gen --config graphql.codegen.yml"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/database": "2.0.0-beta.
|
|
30
|
-
"@contember/dic": "2.0.0-beta.
|
|
31
|
-
"@contember/graphql-utils": "2.0.0-beta.
|
|
32
|
-
"@contember/logger": "2.0.0-beta.
|
|
33
|
-
"@contember/schema": "2.0.0-beta.
|
|
34
|
-
"@contember/schema-definition": "2.0.0-beta.
|
|
35
|
-
"@contember/schema-utils": "2.0.0-beta.
|
|
29
|
+
"@contember/database": "2.0.0-beta.2",
|
|
30
|
+
"@contember/dic": "2.0.0-beta.2",
|
|
31
|
+
"@contember/graphql-utils": "2.0.0-beta.2",
|
|
32
|
+
"@contember/logger": "2.0.0-beta.2",
|
|
33
|
+
"@contember/schema": "2.0.0-beta.2",
|
|
34
|
+
"@contember/schema-definition": "2.0.0-beta.2",
|
|
35
|
+
"@contember/schema-utils": "2.0.0-beta.2",
|
|
36
36
|
"fast-deep-equal": "^3.1.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@contember/database-tester": "2.0.0-beta.
|
|
40
|
-
"@contember/schema-definition": "2.0.0-beta.
|
|
39
|
+
"@contember/database-tester": "2.0.0-beta.2",
|
|
40
|
+
"@contember/schema-definition": "2.0.0-beta.2",
|
|
41
41
|
"@types/node": "^20.16.11",
|
|
42
42
|
"graphql": "^16.9.0",
|
|
43
43
|
"pg": "^8.12.0"
|
package/src/mapper/Mapper.ts
CHANGED
|
@@ -60,7 +60,8 @@ export class Mapper<ConnectionType extends Connection.ConnectionLike = Connectio
|
|
|
60
60
|
.from(entity.tableName, 'root_')
|
|
61
61
|
.select(['root_', columnName])
|
|
62
62
|
const expandedWhere = this.uniqueWhereExpander.expand(entity, where)
|
|
63
|
-
const
|
|
63
|
+
const withPredicates = this.predicatesInjector.inject(entity, expandedWhere)
|
|
64
|
+
const builtQb = this.whereBuilder.build(qb, entity, this.pathFactory.create([]), withPredicates)
|
|
64
65
|
const result = await builtQb.getResult(this.db)
|
|
65
66
|
|
|
66
67
|
return result[0] !== undefined ? result[0][columnName] : undefined
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test } from 'bun:test'
|
|
2
2
|
import { execute, failedTransaction, sqlTransaction } from '../../../../../src/test'
|
|
3
|
-
import { SchemaBuilder } from '@contember/schema-definition'
|
|
3
|
+
import { c, createSchema, SchemaBuilder } from '@contember/schema-definition'
|
|
4
4
|
import { Model } from '@contember/schema'
|
|
5
5
|
import { GQL, SQL } from '../../../../../src/tags'
|
|
6
6
|
import { testUuid } from '../../../../../src/testUuid'
|
|
@@ -255,3 +255,70 @@ test('update m:n', async () => {
|
|
|
255
255
|
})
|
|
256
256
|
})
|
|
257
257
|
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
namespace ConnectWithAclOnRead {
|
|
261
|
+
export const editor = c.createRole('editor')
|
|
262
|
+
|
|
263
|
+
@c.Allow(editor, {
|
|
264
|
+
read: ['id'],
|
|
265
|
+
update: ['id', 'category'],
|
|
266
|
+
})
|
|
267
|
+
export class Article {
|
|
268
|
+
category = c.manyHasOne(Category)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@c.Allow(editor, {
|
|
272
|
+
when: { isPublic: { eq: true } },
|
|
273
|
+
read: ['id', 'slug'],
|
|
274
|
+
})
|
|
275
|
+
export class Category {
|
|
276
|
+
isPublic = c.boolColumn().notNull()
|
|
277
|
+
slug = c.stringColumn().notNull().unique()
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
test('connect category', async () => {
|
|
283
|
+
const schema = createSchema(ConnectWithAclOnRead)
|
|
284
|
+
|
|
285
|
+
await execute({
|
|
286
|
+
schema: schema.model,
|
|
287
|
+
query: GQL`mutation {
|
|
288
|
+
updateArticle(
|
|
289
|
+
by: {id: "${testUuid(1)}"},
|
|
290
|
+
data: {category: {connect: {slug: "abcd"}}}
|
|
291
|
+
) {
|
|
292
|
+
ok
|
|
293
|
+
}
|
|
294
|
+
}`,
|
|
295
|
+
permissions: schema.acl.roles.editor.entities,
|
|
296
|
+
executes: [
|
|
297
|
+
...sqlTransaction([
|
|
298
|
+
{
|
|
299
|
+
sql: SQL`select "root_"."id" from "public"."article" as "root_" where "root_"."id" = ?`,
|
|
300
|
+
parameters: [testUuid(1)],
|
|
301
|
+
response: { rows: [{ id: testUuid(1) }] },
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."slug" = ? and "root_"."is_public" = ?`,
|
|
305
|
+
parameters: ['abcd', true],
|
|
306
|
+
response: { rows: [{ id: testUuid(2) }] },
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
sql: SQL`with "newData_" as (select ? :: uuid as "category_id", "root_"."category_id" as "category_id_old__", "root_"."id" from "public"."article" as "root_" where "root_"."id" = ?)
|
|
310
|
+
update "public"."article" set "category_id" = "newData_"."category_id" from "newData_" where "article"."id" = "newData_"."id" returning "category_id_old__"`,
|
|
311
|
+
parameters: [testUuid(2), testUuid(1)],
|
|
312
|
+
response: { rows: [{ category_id_old__: null }] },
|
|
313
|
+
},
|
|
314
|
+
]),
|
|
315
|
+
],
|
|
316
|
+
return: {
|
|
317
|
+
data: {
|
|
318
|
+
updateArticle: {
|
|
319
|
+
ok: true,
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
})
|
|
324
|
+
})
|