@contember/engine-content-api 1.3.6 → 1.3.8

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=relationAcl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationAcl.test.d.ts","sourceRoot":"","sources":["../../../../../../../tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,238 @@
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 RelationAclManyHasOne;
16
+ (function (RelationAclManyHasOne) {
17
+ RelationAclManyHasOne.readerRole = schema_definition_1.c.createRole('reader');
18
+ let Article = class Article {
19
+ constructor() {
20
+ this.title = schema_definition_1.c.stringColumn().notNull();
21
+ this.author = schema_definition_1.c.manyHasOne(Author).notNull();
22
+ this.discloseAuthor = schema_definition_1.c.boolColumn().notNull();
23
+ }
24
+ };
25
+ Article = __decorate([
26
+ schema_definition_1.c.Allow(RelationAclManyHasOne.readerRole, {
27
+ read: ['title'],
28
+ }),
29
+ schema_definition_1.c.Allow(RelationAclManyHasOne.readerRole, {
30
+ when: { discloseAuthor: { eq: true } },
31
+ read: ['author'],
32
+ })
33
+ ], Article);
34
+ RelationAclManyHasOne.Article = Article;
35
+ let Author = class Author {
36
+ constructor() {
37
+ this.name = schema_definition_1.c.stringColumn().notNull();
38
+ }
39
+ };
40
+ Author = __decorate([
41
+ schema_definition_1.c.Allow(RelationAclManyHasOne.readerRole, {
42
+ read: true,
43
+ })
44
+ ], Author);
45
+ RelationAclManyHasOne.Author = Author;
46
+ })(RelationAclManyHasOne || (RelationAclManyHasOne = {}));
47
+ (0, vitest_1.test)('can read same entity only over relation of some rows - many has one', async () => {
48
+ const schema = (0, schema_definition_1.createSchema)(RelationAclManyHasOne);
49
+ const permissions = new src_1.PermissionFactory().create(schema, ['reader']);
50
+ await (0, test_1.execute)({
51
+ schema: schema.model,
52
+ permissions: permissions,
53
+ variables: {},
54
+ query: (0, tags_1.GQL) `
55
+ query {
56
+ listArticle {
57
+ title
58
+ author {
59
+ name
60
+ }
61
+ }
62
+ }`,
63
+ executes: [
64
+ {
65
+ sql: (0, tags_1.SQL) `select "root_"."title" as "root_title", "root_"."disclose_author" = ? as "root___predicate_discloseAuthor_eq_true", "root_"."author_id" as "root_author", "root_"."id" as "root_id"
66
+ from "public"."article" as "root_"`,
67
+ response: {
68
+ rows: [
69
+ {
70
+ root_id: (0, engine_api_tester_1.testUuid)(1),
71
+ root_title: 'Article A',
72
+ root___predicate_discloseAuthor_eq_true: true,
73
+ root_author: (0, engine_api_tester_1.testUuid)(10),
74
+ },
75
+ {
76
+ root_id: (0, engine_api_tester_1.testUuid)(2),
77
+ root_title: 'Article B',
78
+ root___predicate_discloseAuthor_eq_true: false,
79
+ root_author: (0, engine_api_tester_1.testUuid)(10),
80
+ },
81
+ ],
82
+ },
83
+ },
84
+ {
85
+ sql: (0, tags_1.SQL) `select "root_"."id" as "root_id", "root_"."name" as "root_name", "root_"."id" as "root_id" from "public"."author" as "root_" where "root_"."id" in (?)`,
86
+ parameters: [(0, engine_api_tester_1.testUuid)(10)],
87
+ response: {
88
+ rows: [
89
+ {
90
+ root_id: (0, engine_api_tester_1.testUuid)(10),
91
+ root_name: 'John doe',
92
+ },
93
+ ],
94
+ },
95
+ },
96
+ ],
97
+ return: {
98
+ data: {
99
+ listArticle: [
100
+ {
101
+ title: 'Article A',
102
+ author: {
103
+ name: 'John doe',
104
+ },
105
+ },
106
+ {
107
+ title: 'Article B',
108
+ author: null,
109
+ },
110
+ ],
111
+ },
112
+ },
113
+ });
114
+ });
115
+ var RelationAclManyHasMany;
116
+ (function (RelationAclManyHasMany) {
117
+ RelationAclManyHasMany.readerRole = schema_definition_1.c.createRole('reader');
118
+ let Article = class Article {
119
+ constructor() {
120
+ this.title = schema_definition_1.c.stringColumn().notNull();
121
+ this.authors = schema_definition_1.c.manyHasMany(Author);
122
+ this.discloseAuthor = schema_definition_1.c.boolColumn().notNull();
123
+ }
124
+ };
125
+ Article = __decorate([
126
+ schema_definition_1.c.Allow(RelationAclManyHasMany.readerRole, {
127
+ read: ['title'],
128
+ }),
129
+ schema_definition_1.c.Allow(RelationAclManyHasMany.readerRole, {
130
+ when: { discloseAuthor: { eq: true } },
131
+ read: ['authors'],
132
+ })
133
+ ], Article);
134
+ RelationAclManyHasMany.Article = Article;
135
+ let Author = class Author {
136
+ constructor() {
137
+ this.name = schema_definition_1.c.stringColumn().notNull();
138
+ }
139
+ };
140
+ Author = __decorate([
141
+ schema_definition_1.c.Allow(RelationAclManyHasMany.readerRole, {
142
+ read: true,
143
+ })
144
+ ], Author);
145
+ RelationAclManyHasMany.Author = Author;
146
+ })(RelationAclManyHasMany || (RelationAclManyHasMany = {}));
147
+ (0, vitest_1.test)('can read same entity only over relation of some rows - many has many', async () => {
148
+ const schema = (0, schema_definition_1.createSchema)(RelationAclManyHasMany);
149
+ const permissions = new src_1.PermissionFactory().create(schema, ['reader']);
150
+ await (0, test_1.execute)({
151
+ schema: schema.model,
152
+ permissions: permissions,
153
+ variables: {},
154
+ query: (0, tags_1.GQL) `
155
+ query {
156
+ listArticle {
157
+ title
158
+ authors {
159
+ name
160
+ }
161
+ }
162
+ }`,
163
+ executes: [
164
+ {
165
+ sql: (0, tags_1.SQL) `select "root_"."title" as "root_title", "root_"."disclose_author" = ? as "root___predicate_discloseauthor_eq_true", "root_"."id" as "root_id", "root_"."id" as "root_id"
166
+ from "public"."article" as "root_"`,
167
+ response: {
168
+ rows: [
169
+ {
170
+ root_id: (0, engine_api_tester_1.testUuid)(1),
171
+ root_title: 'Article A',
172
+ root___predicate_discloseAuthor_eq_true: true,
173
+ },
174
+ {
175
+ root_id: (0, engine_api_tester_1.testUuid)(2),
176
+ root_title: 'Article B',
177
+ root___predicate_discloseAuthor_eq_true: false,
178
+ },
179
+ ],
180
+ },
181
+ },
182
+ {
183
+ sql: (0, tags_1.SQL) `select "junction_"."author_id", "junction_"."article_id" from "public"."article_authors" as "junction_" where "junction_"."article_id" in (?)`,
184
+ parameters: [(0, engine_api_tester_1.testUuid)(1)],
185
+ response: {
186
+ rows: [
187
+ {
188
+ article_id: (0, engine_api_tester_1.testUuid)(1),
189
+ author_id: (0, engine_api_tester_1.testUuid)(10),
190
+ },
191
+ {
192
+ article_id: (0, engine_api_tester_1.testUuid)(1),
193
+ author_id: (0, engine_api_tester_1.testUuid)(11),
194
+ },
195
+ ],
196
+ },
197
+ },
198
+ {
199
+ sql: (0, tags_1.SQL) `select "root_"."name" as "root_name", "root_"."id" as "root_id" from "public"."author" as "root_" where "root_"."id" in (?, ?)`,
200
+ parameters: [(0, engine_api_tester_1.testUuid)(10), (0, engine_api_tester_1.testUuid)(11)],
201
+ response: {
202
+ rows: [
203
+ {
204
+ root_id: (0, engine_api_tester_1.testUuid)(10),
205
+ root_name: 'John doe',
206
+ },
207
+ {
208
+ root_id: (0, engine_api_tester_1.testUuid)(11),
209
+ root_name: 'Jack doe',
210
+ },
211
+ ],
212
+ },
213
+ },
214
+ ],
215
+ return: {
216
+ data: {
217
+ listArticle: [
218
+ {
219
+ title: 'Article A',
220
+ authors: [
221
+ {
222
+ name: 'John doe',
223
+ },
224
+ {
225
+ name: 'Jack doe',
226
+ },
227
+ ],
228
+ },
229
+ {
230
+ title: 'Article B',
231
+ authors: [],
232
+ },
233
+ ],
234
+ },
235
+ },
236
+ });
237
+ });
238
+ //# sourceMappingURL=relationAcl.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationAcl.test.js","sourceRoot":"","sources":["../../../../../../../tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts"],"names":[],"mappings":";;;;;;;;AAAA,oEAA8D;AAC9D,mCAA6B;AAC7B,kDAAiD;AACjD,kDAAkD;AAClD,+CAAyD;AACzD,oEAAuD;AAGvD,IAAU,qBAAqB,CAsB9B;AAtBD,WAAU,qBAAqB;IACjB,gCAAU,GAAG,qBAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAShD,IAAa,OAAO,GAApB,MAAa,OAAO;QAApB;YACC,UAAK,GAAG,qBAAC,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,CAAA;YAClC,WAAM,GAAG,qBAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;YACvC,mBAAc,GAAG,qBAAC,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAA;QAC1C,CAAC;KAAA,CAAA;IAJY,OAAO;QAPnB,qBAAC,CAAC,KAAK,CAAC,sBAAA,UAAU,EAAE;YACpB,IAAI,EAAE,CAAC,OAAO,CAAC;SACf,CAAC;QACD,qBAAC,CAAC,KAAK,CAAC,sBAAA,UAAU,EAAE;YACpB,IAAI,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YACtC,IAAI,EAAE,CAAC,QAAQ,CAAC;SAChB,CAAC;OACW,OAAO,CAInB;IAJY,6BAAO,UAInB,CAAA;IAKD,IAAa,MAAM,GAAnB,MAAa,MAAM;QAAnB;YACC,SAAI,GAAG,qBAAC,CAAC,YA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