@contember/engine-content-api 1.2.1 → 1.2.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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=isNullAcl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNullAcl.test.d.ts","sourceRoot":"","sources":["../../../../../../../tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const schema_definition_1 = require("@contember/schema-definition");
10
+ const vitest_1 = require("vitest");
11
+ const test_1 = require("../../../../../src/test");
12
+ const tags_1 = require("../../../../../src/tags");
13
+ const src_1 = require("../../../../../../src");
14
+ const engine_api_tester_1 = require("@contember/engine-api-tester");
15
+ var RowPredicateSubset;
16
+ (function (RowPredicateSubset) {
17
+ RowPredicateSubset.ownerRole = schema_definition_1.AclDefinition.createRole('owner');
18
+ RowPredicateSubset.personIdVariable = schema_definition_1.AclDefinition.createPredefinedVariable('personId', 'personID', RowPredicateSubset.ownerRole);
19
+ let Item = class Item {
20
+ constructor() {
21
+ this.resource = schema_definition_1.SchemaDefinition.oneHasOne(Resource, 'item');
22
+ }
23
+ };
24
+ Item = __decorate([
25
+ schema_definition_1.AclDefinition.allow(RowPredicateSubset.ownerRole, {
26
+ read: true,
27
+ when: { resource: schema_definition_1.AclDefinition.canRead('item') },
28
+ })
29
+ ], Item);
30
+ RowPredicateSubset.Item = Item;
31
+ let Resource = class Resource {
32
+ constructor() {
33
+ this.item = schema_definition_1.SchemaDefinition.oneHasOneInverse(Item, 'resource');
34
+ this.owner = schema_definition_1.SchemaDefinition.manyHasOne(Person, 'resources');
35
+ }
36
+ };
37
+ Resource = __decorate([
38
+ schema_definition_1.AclDefinition.allow(RowPredicateSubset.ownerRole, {
39
+ read: true,
40
+ when: { owner: schema_definition_1.AclDefinition.canRead('resources') },
41
+ })
42
+ ], Resource);
43
+ RowPredicateSubset.Resource = Resource;
44
+ let Person = class Person {
45
+ constructor() {
46
+ this.personId = schema_definition_1.SchemaDefinition.uuidColumn().notNull();
47
+ this.resources = schema_definition_1.SchemaDefinition.oneHasMany(Resource, 'owner');
48
+ }
49
+ };
50
+ Person = __decorate([
51
+ schema_definition_1.AclDefinition.allow(RowPredicateSubset.ownerRole, {
52
+ read: true,
53
+ when: { personId: RowPredicateSubset.personIdVariable },
54
+ })
55
+ ], Person);
56
+ RowPredicateSubset.Person = Person;
57
+ })(RowPredicateSubset || (RowPredicateSubset = {}));
58
+ (0, vitest_1.test)('owner predicate with isNull', async () => {
59
+ const schema = (0, schema_definition_1.createSchema)(RowPredicateSubset);
60
+ const permissions = new src_1.PermissionFactory(schema.model).create(schema.acl, ['owner']);
61
+ await (0, test_1.execute)({
62
+ schema: schema.model,
63
+ permissions: permissions,
64
+ variables: {
65
+ owner__personId: { eq: (0, engine_api_tester_1.testUuid)(0) },
66
+ },
67
+ query: (0, tags_1.GQL) `
68
+ query {
69
+ listItem(filter: {resource: {id: {isNull: true}}}) {
70
+ id
71
+ }
72
+ }`,
73
+ executes: [
74
+ {
75
+ sql: (0, tags_1.SQL) `select "root_"."id" as "root_id" from "public"."item" as "root_"
76
+ left join "public"."resource" as "root_resource" on "root_"."resource_id" = "root_resource"."id"
77
+ left join "public"."person" as "root_resource_owner" on "root_resource"."owner_id" = "root_resource_owner"."id"
78
+ where "root_resource"."id" is null and "root_resource_owner"."person_id" = ? and "root_resource_owner"."person_id" = ?`,
79
+ response: {
80
+ rows: [],
81
+ },
82
+ },
83
+ ],
84
+ return: {
85
+ data: {
86
+ listItem: [],
87
+ },
88
+ },
89
+ });
90
+ });
91
+ //# sourceMappingURL=isNullAcl.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNullAcl.test.js","sourceRoot":"","sources":["../../../../../../../tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts"],"names":[],"mappings":";;;;;;;;AAAA,oEAA0G;AAC1G,mCAA6B;AAC7B,kDAAiD;AACjD,kDAAkD;AAClD,+CAAyD;AACzD,oEAAuD;AAGvD,IAAU,kBAAkB,CA6B3B;AA7BD,WAAU,kBAAkB;IACd,4BAAS,GAAG,iCAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IACnC,mCAAgB,GAAG,iCAAG,CAAC,wBAAwB,CAAC,UAAU,EAAE,UAAU,EAAE,mBAAA,SAAS,CAAC,CAAA;IAM/F,IAAa,IAAI,GAAjB,MAAa,IAAI;QAAjB;YACC,aAAQ,GAAG,oCAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC3C,CAAC;KAAA,CAAA;IAFY,IAAI;QAJhB,iCAAG,CAAC,KAAK,CAAC,mBAAA,SAAS,EAAE;YACrB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,EAAE,QAAQ,EAAE,iCAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;SACvC,CAAC;OACW,IAAI,CAEhB;IAFY,uBAAI,OAEhB,CAAA;IAMD,IAAa,QAAQ,GAArB,MAAa,QAAQ;QAArB;YACC,SAAI,GAAG,oCAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YAC7C,UAAK,GAAG,oCAAG,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAC5C,CAAC;KAAA,CA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