@contember/engine-content-api 1.3.11 → 1.3.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-content-api",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/src/index.d.ts",
@@ -13,20 +13,20 @@
13
13
  "test": "vitest --dir ./tests/cases --no-threads"
14
14
  },
15
15
  "dependencies": {
16
- "@contember/database": "1.3.11",
17
- "@contember/dic": "1.3.11",
18
- "@contember/graphql-utils": "1.3.11",
19
- "@contember/logger": "1.3.11",
20
- "@contember/schema": "1.3.11",
21
- "@contember/schema-definition": "1.3.11",
22
- "@contember/schema-utils": "1.3.11",
16
+ "@contember/database": "1.3.12",
17
+ "@contember/dic": "1.3.12",
18
+ "@contember/graphql-utils": "1.3.12",
19
+ "@contember/logger": "1.3.12",
20
+ "@contember/schema": "1.3.12",
21
+ "@contember/schema-definition": "1.3.12",
22
+ "@contember/schema-utils": "1.3.12",
23
23
  "fast-deep-equal": "^3.1.3",
24
24
  "graphql-tag": "^2.12.5"
25
25
  },
26
26
  "devDependencies": {
27
- "@contember/database-tester": "1.3.11",
28
- "@contember/engine-api-tester": "1.3.11",
29
- "@contember/schema-definition": "1.3.11",
27
+ "@contember/database-tester": "1.3.12",
28
+ "@contember/engine-api-tester": "1.3.12",
29
+ "@contember/schema-definition": "1.3.12",
30
30
  "@graphql-codegen/cli": "^2.6.2",
31
31
  "@graphql-codegen/typescript": "^2.5.1",
32
32
  "@graphql-codegen/typescript-operations": "^2.4.2",
@@ -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 builtQb = this.whereBuilder.build(qb, entity, this.pathFactory.create([]), expandedWhere)
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 'vitest'
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
+ })