@contember/engine-content-api 1.2.0-alpha.2 → 1.2.0-alpha.5
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 +0 -1
- package/dist/src/acl/VariableInjector.d.ts.map +1 -1
- package/dist/src/acl/VariableInjector.js +4 -16
- package/dist/src/acl/VariableInjector.js.map +1 -1
- package/dist/src/acl/VariableUtils.d.ts +2 -13
- package/dist/src/acl/VariableUtils.d.ts.map +1 -1
- package/dist/src/acl/VariableUtils.js +6 -23
- package/dist/src/acl/VariableUtils.js.map +1 -1
- package/dist/src/input-validation/EntityRulesResolver.js +3 -3
- package/dist/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/src/input-validation/ValidationContext.d.ts +2 -2
- package/dist/src/input-validation/ValidationContext.d.ts.map +1 -1
- package/dist/src/input-validation/ValidationContext.js.map +1 -1
- package/dist/src/introspection/content-schema.types.d.ts +19 -223
- package/dist/src/introspection/content-schema.types.d.ts.map +1 -1
- package/dist/src/introspection/content-schema.types.js +2 -2
- package/dist/src/introspection/content-schema.types.js.map +1 -1
- package/dist/src/resolvers/GraphQlQueryAstFactory.js +2 -2
- package/dist/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/src/resolvers/MutationResolver.js +14 -14
- package/dist/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/src/resolvers/ReadHelpers.js +7 -7
- package/dist/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/src/schema/MutationProvider.js +4 -4
- package/dist/src/schema/MutationProvider.js.map +1 -1
- package/dist/src/schema/QueryProvider.js +3 -3
- package/dist/src/schema/QueryProvider.js.map +1 -1
- package/dist/src/schema/ResultSchemaTypeProvider.d.ts +2 -2
- package/dist/src/schema/ResultSchemaTypeProvider.d.ts.map +1 -1
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts +4 -4
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js +38 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js +1 -6
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js +2 -12
- package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js +1 -6
- package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js +4 -24
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js +1 -6
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js +4 -24
- package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js +6 -3
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js.map +1 -1
- package/dist/tests/cases/unit/aclVariablesFactory.test.js +4 -32
- package/dist/tests/cases/unit/aclVariablesFactory.test.js.map +1 -1
- package/dist/tests/cases/unit/orderbyHelper.test.js +1 -0
- package/dist/tests/cases/unit/orderbyHelper.test.js.map +1 -1
- package/dist/tests/cases/unit/predicatesInjector.test.js +1 -6
- package/dist/tests/cases/unit/predicatesInjector.test.js.map +1 -1
- package/dist/tests/cases/unit/variableInjector.test.js +2 -13
- package/dist/tests/cases/unit/variableInjector.test.js.map +1 -1
- package/dist/tests/src/testGraphql.d.ts.map +1 -1
- package/dist/tests/src/testGraphql.js +6 -1
- package/dist/tests/src/testGraphql.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/graphql.codegen.yml +0 -3
- package/package.json +16 -16
- package/src/acl/VariableInjector.ts +2 -17
- package/src/acl/VariableUtils.ts +7 -28
- package/src/input-validation/EntityRulesResolver.ts +3 -3
- package/src/input-validation/ValidationContext.ts +2 -2
- package/src/introspection/content-schema.types.ts +19 -286
- package/src/resolvers/GraphQlQueryAstFactory.ts +3 -3
- package/tests/cases/integration/graphQlDb/insert/insertSequence.test.ts +34 -0
- package/tests/cases/integration/graphQlRequests/delete/aclDelete.test.ts +1 -6
- package/tests/cases/integration/graphQlRequests/insert/acl/setField.test.ts +2 -12
- package/tests/cases/integration/graphQlRequests/insert/aclInsert.test.ts +1 -6
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +4 -24
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +1 -6
- package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +5 -25
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +5 -5
- package/tests/cases/unit/aclVariablesFactory.test.ts +5 -34
- package/tests/cases/unit/orderbyHelper.test.ts +1 -0
- package/tests/cases/unit/predicatesInjector.test.ts +1 -6
- package/tests/cases/unit/variableInjector.test.ts +2 -13
- package/tests/src/testGraphql.ts +6 -1
|
@@ -34,12 +34,7 @@ test('set a name - allowed', async () => {
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
variables: {
|
|
37
|
-
name_variable: {
|
|
38
|
-
definition: {
|
|
39
|
-
type: Acl.VariableType.condition,
|
|
40
|
-
},
|
|
41
|
-
value: [{ in: ['John', 'Jack'] }],
|
|
42
|
-
},
|
|
37
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
43
38
|
},
|
|
44
39
|
executes: [
|
|
45
40
|
...sqlTransaction([
|
|
@@ -94,12 +89,7 @@ test('set a name - denied', async () => {
|
|
|
94
89
|
},
|
|
95
90
|
},
|
|
96
91
|
variables: {
|
|
97
|
-
name_variable: {
|
|
98
|
-
definition: {
|
|
99
|
-
type: Acl.VariableType.condition,
|
|
100
|
-
},
|
|
101
|
-
value: [{ in: ['John', 'Jack'] }],
|
|
102
|
-
},
|
|
92
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
103
93
|
},
|
|
104
94
|
executes: [
|
|
105
95
|
...failedTransaction([
|
|
@@ -27,12 +27,7 @@ test('insert author (with acl)', async () => {
|
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
variables: {
|
|
30
|
-
name_variable: {
|
|
31
|
-
definition: {
|
|
32
|
-
type: Acl.VariableType.condition,
|
|
33
|
-
},
|
|
34
|
-
value: [{ in: ['John', 'Jack'] }],
|
|
35
|
-
},
|
|
30
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
36
31
|
},
|
|
37
32
|
query: GQL`
|
|
38
33
|
mutation {
|
|
@@ -45,12 +45,7 @@ test('querying id and title', async () => {
|
|
|
45
45
|
schema: schema,
|
|
46
46
|
permissions: permissions,
|
|
47
47
|
variables: {
|
|
48
|
-
localeVariable: {
|
|
49
|
-
definition: {
|
|
50
|
-
type: Acl.VariableType.condition,
|
|
51
|
-
},
|
|
52
|
-
value: [{ in: ['cs'] }],
|
|
53
|
-
},
|
|
48
|
+
localeVariable: { in: ['cs'] },
|
|
54
49
|
},
|
|
55
50
|
query: GQL`
|
|
56
51
|
query {
|
|
@@ -126,12 +121,7 @@ test('querying with extra where', async () => {
|
|
|
126
121
|
schema: schema,
|
|
127
122
|
permissions: permissions,
|
|
128
123
|
variables: {
|
|
129
|
-
localeVariable: {
|
|
130
|
-
definition: {
|
|
131
|
-
type: Acl.VariableType.condition,
|
|
132
|
-
},
|
|
133
|
-
value: [{ in: ['cs'] }],
|
|
134
|
-
},
|
|
124
|
+
localeVariable: { in: ['cs'] },
|
|
135
125
|
},
|
|
136
126
|
query: GQL`
|
|
137
127
|
query {
|
|
@@ -177,12 +167,7 @@ test('querying only id', async () => {
|
|
|
177
167
|
schema: schema,
|
|
178
168
|
permissions: permissions,
|
|
179
169
|
variables: {
|
|
180
|
-
localeVariable: {
|
|
181
|
-
definition: {
|
|
182
|
-
type: Acl.VariableType.condition,
|
|
183
|
-
},
|
|
184
|
-
value: [{ in: ['cs'] }],
|
|
185
|
-
},
|
|
170
|
+
localeVariable: { in: ['cs'] },
|
|
186
171
|
},
|
|
187
172
|
query: GQL`
|
|
188
173
|
query {
|
|
@@ -254,12 +239,7 @@ test('querying on nested field', async () => {
|
|
|
254
239
|
schema: schema,
|
|
255
240
|
permissions: permissions,
|
|
256
241
|
variables: {
|
|
257
|
-
localeVariable: {
|
|
258
|
-
definition: {
|
|
259
|
-
type: Acl.VariableType.condition,
|
|
260
|
-
},
|
|
261
|
-
value: [{ in: ['cs'] }],
|
|
262
|
-
},
|
|
242
|
+
localeVariable: { in: ['cs'] },
|
|
263
243
|
},
|
|
264
244
|
query: GQL`
|
|
265
245
|
query {
|
|
@@ -58,12 +58,7 @@ test('querying post + author name', async () => {
|
|
|
58
58
|
schema: schema,
|
|
59
59
|
permissions: permissions,
|
|
60
60
|
variables: {
|
|
61
|
-
countryVariable: {
|
|
62
|
-
definition: {
|
|
63
|
-
type: Acl.VariableType.condition,
|
|
64
|
-
},
|
|
65
|
-
value: [{ in: ['Czechia'] }],
|
|
66
|
-
},
|
|
61
|
+
countryVariable: { in: ['Czechia'] },
|
|
67
62
|
},
|
|
68
63
|
query: GQL`
|
|
69
64
|
query {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from 'vitest'
|
|
2
2
|
import { execute, failedTransaction, sqlTransaction } from '../../../../../src/test'
|
|
3
3
|
import { SchemaBuilder } from '@contember/schema-definition'
|
|
4
|
-
import {
|
|
4
|
+
import { Model } from '@contember/schema'
|
|
5
5
|
import { GQL, SQL } from '../../../../../src/tags'
|
|
6
6
|
import { testUuid } from '../../../../../src/testUuid'
|
|
7
7
|
|
|
@@ -35,12 +35,7 @@ test('update name', async () => {
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
variables: {
|
|
38
|
-
name_variable: {
|
|
39
|
-
definition: {
|
|
40
|
-
type: Acl.VariableType.condition,
|
|
41
|
-
},
|
|
42
|
-
value: [{ in: ['John', 'Jack'] }],
|
|
43
|
-
},
|
|
38
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
44
39
|
},
|
|
45
40
|
executes: [
|
|
46
41
|
...sqlTransaction([
|
|
@@ -103,12 +98,7 @@ test('update name - denied', async () => {
|
|
|
103
98
|
},
|
|
104
99
|
},
|
|
105
100
|
variables: {
|
|
106
|
-
name_variable: {
|
|
107
|
-
definition: {
|
|
108
|
-
type: Acl.VariableType.condition,
|
|
109
|
-
},
|
|
110
|
-
value: [{ in: ['John', 'Jack'] }],
|
|
111
|
-
},
|
|
101
|
+
name_variable: { in: ['John', 'Jack'] },
|
|
112
102
|
},
|
|
113
103
|
executes: [
|
|
114
104
|
...failedTransaction([
|
|
@@ -186,18 +176,8 @@ test('update m:n', async () => {
|
|
|
186
176
|
},
|
|
187
177
|
},
|
|
188
178
|
variables: {
|
|
189
|
-
post_name_variable: {
|
|
190
|
-
|
|
191
|
-
type: Acl.VariableType.condition,
|
|
192
|
-
},
|
|
193
|
-
value: [{ in: ['Lorem ipsum', 'Dolor sit'] }],
|
|
194
|
-
},
|
|
195
|
-
category_name_variable: {
|
|
196
|
-
definition: {
|
|
197
|
-
type: Acl.VariableType.condition,
|
|
198
|
-
},
|
|
199
|
-
value: [{ in: ['foo', 'bar'] }],
|
|
200
|
-
},
|
|
179
|
+
post_name_variable: { in: ['Lorem ipsum', 'Dolor sit'] },
|
|
180
|
+
category_name_variable: { in: ['foo', 'bar'] },
|
|
201
181
|
},
|
|
202
182
|
query: GQL`mutation {
|
|
203
183
|
updatePost(by: {id: "${testUuid(1)}"}, data: {categories: [
|
|
@@ -30,20 +30,20 @@ const testSchema = async (test: Test) => {
|
|
|
30
30
|
const graphQlSchemaBuilder = schemaFactory.create(schemaWithAcl, authorizator)
|
|
31
31
|
const graphQlSchema = graphQlSchemaBuilder.build()
|
|
32
32
|
|
|
33
|
-
const result = await graphql(
|
|
34
|
-
graphQlSchema,
|
|
35
|
-
`
|
|
33
|
+
const result = await graphql({
|
|
34
|
+
schema: graphQlSchema,
|
|
35
|
+
source: `
|
|
36
36
|
{
|
|
37
37
|
_info {
|
|
38
38
|
description
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
`,
|
|
42
|
-
)
|
|
42
|
+
})
|
|
43
43
|
const errors = (result.errors || []).map(it => it.message)
|
|
44
44
|
assert.deepEqual(errors, [])
|
|
45
45
|
|
|
46
|
-
const textSchema = printSchema(graphQlSchema)
|
|
46
|
+
const textSchema = printSchema(graphQlSchema) + '\n'
|
|
47
47
|
|
|
48
48
|
const filename = path.join(__dirname, test.graphQlSchemaFile)
|
|
49
49
|
let expectedSchema: string
|
|
@@ -18,12 +18,8 @@ describe('create acl variables', () => {
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
-
}, {
|
|
22
|
-
|
|
23
|
-
personId: null,
|
|
24
|
-
memberships: [{ role: 'author', variables: [{ name: 'authorID', values: [testUuid(2)] }] }],
|
|
25
|
-
}), {
|
|
26
|
-
author__authorID: { definition, value: [testUuid(2)] },
|
|
21
|
+
}, [{ role: 'author', variables: [{ name: 'authorID', condition: { in: [testUuid(2)] } }] }]), {
|
|
22
|
+
author__authorID: { in: [testUuid(2)] },
|
|
27
23
|
})
|
|
28
24
|
})
|
|
29
25
|
|
|
@@ -39,34 +35,9 @@ describe('create acl variables', () => {
|
|
|
39
35
|
entities: {},
|
|
40
36
|
},
|
|
41
37
|
},
|
|
42
|
-
}, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
memberships: [{ role: 'author', variables: [] }],
|
|
46
|
-
}), {
|
|
47
|
-
author__authorID: { definition, value: [] },
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
it('predefined', () => {
|
|
53
|
-
const definition: Acl.PredefinedVariable = { type: Acl.VariableType.predefined, value: 'identityID' }
|
|
54
|
-
assert.deepStrictEqual(createAclVariables({
|
|
55
|
-
roles: {
|
|
56
|
-
author: {
|
|
57
|
-
stages: '*',
|
|
58
|
-
variables: {
|
|
59
|
-
authorIdentity: definition,
|
|
60
|
-
},
|
|
61
|
-
entities: {},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
}, {
|
|
65
|
-
identityId: testUuid(1),
|
|
66
|
-
personId: null,
|
|
67
|
-
memberships: [{ role: 'author', variables: [] }],
|
|
68
|
-
}), {
|
|
69
|
-
author__authorIdentity: { definition, value: [testUuid(1)] },
|
|
38
|
+
}, [{ role: 'author', variables: [] }],
|
|
39
|
+
), {
|
|
40
|
+
author__authorID: { never: true },
|
|
70
41
|
})
|
|
71
42
|
})
|
|
72
43
|
})
|
|
@@ -45,12 +45,7 @@ const permissions: Acl.Permissions = {
|
|
|
45
45
|
describe('Predicates injector', () => {
|
|
46
46
|
|
|
47
47
|
const variables: Acl.VariablesMap = {
|
|
48
|
-
localeVariable: {
|
|
49
|
-
definition: {
|
|
50
|
-
type: Acl.VariableType.condition,
|
|
51
|
-
},
|
|
52
|
-
value: [{ in: ['cs'] }],
|
|
53
|
-
},
|
|
48
|
+
localeVariable: { in: ['cs'] },
|
|
54
49
|
}
|
|
55
50
|
it('injects predicate', () => {
|
|
56
51
|
const injector = new PredicatesInjector(
|
|
@@ -19,19 +19,8 @@ describe('Variable injector', () => {
|
|
|
19
19
|
|
|
20
20
|
const ids = ['91528a5c-839b-4114-9952-d661914a607f', '1e2f3937-a0b1-4105-8aae-6da8ac9fc146']
|
|
21
21
|
const injector = new VariableInjector(schema, {
|
|
22
|
-
site: {
|
|
23
|
-
|
|
24
|
-
type: Acl.VariableType.entity,
|
|
25
|
-
entityName: 'Site',
|
|
26
|
-
},
|
|
27
|
-
value: ids,
|
|
28
|
-
},
|
|
29
|
-
locale: {
|
|
30
|
-
definition: {
|
|
31
|
-
type: Acl.VariableType.condition,
|
|
32
|
-
},
|
|
33
|
-
value: [{ eq: 'cs' }],
|
|
34
|
-
},
|
|
22
|
+
site: { in: ids },
|
|
23
|
+
locale: { eq: 'cs' },
|
|
35
24
|
})
|
|
36
25
|
const result = injector.inject(schema.entities['PostLocale'], {
|
|
37
26
|
or: [
|
package/tests/src/testGraphql.ts
CHANGED
|
@@ -10,7 +10,12 @@ export interface Test {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const executeGraphQlTest = async (test: Test) => {
|
|
13
|
-
const rawResponse = await graphql(
|
|
13
|
+
const rawResponse = await graphql({
|
|
14
|
+
schema: test.schema,
|
|
15
|
+
source: test.query,
|
|
16
|
+
contextValue: test.context,
|
|
17
|
+
variableValues: test.queryVariables,
|
|
18
|
+
})
|
|
14
19
|
const response = JSON.parse(JSON.stringify(rawResponse))
|
|
15
20
|
if ('errors' in rawResponse) {
|
|
16
21
|
if (rawResponse.errors?.length === 1 && 'originalError' in (rawResponse.errors as any)[0]) {
|