@contember/engine-server 1.1.0-rc.3 → 1.2.0-alpha.3
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/MasterContainer.d.ts +27 -25
- package/dist/src/MasterContainer.d.ts.map +1 -1
- package/dist/src/MasterContainer.js +54 -80
- package/dist/src/MasterContainer.js.map +1 -1
- package/dist/src/bootstrap/Initializer.d.ts +3 -3
- package/dist/src/bootstrap/Initializer.d.ts.map +1 -1
- package/dist/src/bootstrap/Initializer.js +15 -6
- package/dist/src/bootstrap/Initializer.js.map +1 -1
- package/dist/src/config/config.d.ts +5 -4
- package/dist/src/config/config.d.ts.map +1 -1
- package/dist/src/config/config.js +2 -2
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/configSchema.d.ts +45 -11
- package/dist/src/config/configSchema.d.ts.map +1 -1
- package/dist/src/config/configSchema.js +20 -18
- package/dist/src/config/configSchema.js.map +1 -1
- package/dist/src/config/configTemplate.d.ts.map +1 -1
- package/dist/src/config/configTemplate.js +23 -0
- package/dist/src/config/configTemplate.js.map +1 -1
- package/dist/src/index.d.ts +9 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/project/ProjectContainer.js +1 -1
- package/dist/src/project/ProjectContainer.js.map +1 -1
- package/dist/src/project/ProjectContainerResolver.d.ts +6 -3
- package/dist/src/project/ProjectContainerResolver.d.ts.map +1 -1
- package/dist/src/project/ProjectContainerResolver.js +4 -16
- package/dist/src/project/ProjectContainerResolver.js.map +1 -1
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts +2 -1
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
- package/dist/src/projectGroup/ProjectGroupContainer.js +8 -4
- package/dist/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts +7 -0
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts.map +1 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js +13 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js.map +1 -0
- package/dist/src/start.js +15 -112
- package/dist/src/start.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/index.d.ts +0 -4
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +0 -4
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/sentry.d.ts +1 -1
- package/dist/src/utils/sentry.d.ts.map +1 -1
- package/dist/src/utils/sentry.js +1 -1
- package/dist/src/utils/sentry.js.map +1 -1
- package/dist/src/utils/serverStartup.d.ts +31 -0
- package/dist/src/utils/serverStartup.d.ts.map +1 -0
- package/dist/src/utils/serverStartup.js +42 -0
- package/dist/src/utils/serverStartup.js.map +1 -0
- package/dist/src/utils/serverTermination.d.ts +12 -0
- package/dist/src/utils/serverTermination.d.ts.map +1 -0
- package/dist/src/utils/serverTermination.js +26 -0
- package/dist/src/utils/serverTermination.js.map +1 -0
- package/dist/tests/e2e/acl-condition-variable.test.d.ts +2 -0
- package/dist/tests/e2e/acl-condition-variable.test.d.ts.map +1 -0
- package/dist/tests/e2e/acl-condition-variable.test.js +77 -0
- package/dist/tests/e2e/acl-condition-variable.test.js.map +1 -0
- package/dist/tests/e2e/assume-membership.test.d.ts +2 -0
- package/dist/tests/e2e/assume-membership.test.d.ts.map +1 -0
- package/dist/tests/e2e/assume-membership.test.js +58 -0
- package/dist/tests/e2e/assume-membership.test.js.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts +2 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.js +50 -0
- package/dist/tests/e2e/content-api-basic.test.js.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts +2 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.js +29 -0
- package/dist/tests/e2e/content-invalid-schema.test.js.map +1 -0
- package/dist/tests/e2e/homepage.test.d.ts +2 -0
- package/dist/tests/e2e/homepage.test.d.ts.map +1 -0
- package/dist/tests/e2e/homepage.test.js +15 -0
- package/dist/tests/e2e/homepage.test.js.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts +2 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.js +43 -0
- package/dist/tests/e2e/tenant-member-access.test.js.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts +2 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.js +63 -0
- package/dist/tests/e2e/x-contember-ref.test.js.map +1 -0
- package/dist/tests/src/requests.d.ts +5 -0
- package/dist/tests/src/requests.d.ts.map +1 -0
- package/dist/tests/src/requests.js +59 -0
- package/dist/tests/src/requests.js.map +1 -0
- package/dist/tests/src/tester.d.ts +19 -0
- package/dist/tests/src/tester.d.ts.map +1 -0
- package/dist/tests/src/tester.js +99 -0
- package/dist/tests/src/tester.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/esbuild.js +7 -14
- package/package.json +23 -23
- package/src/MasterContainer.ts +94 -110
- package/src/bootstrap/Initializer.ts +16 -6
- package/src/config/config.ts +7 -5
- package/src/config/configSchema.ts +30 -33
- package/src/config/configTemplate.ts +23 -0
- package/src/index.ts +15 -2
- package/src/project/ProjectContainer.ts +1 -1
- package/src/project/ProjectContainerResolver.ts +4 -17
- package/src/projectGroup/ProjectGroupContainer.ts +12 -3
- package/src/projectGroup/ProjectGroupResolver.ts +12 -0
- package/src/start.ts +18 -127
- package/src/utils/index.ts +0 -4
- package/src/utils/sentry.ts +1 -1
- package/src/utils/serverStartup.ts +42 -0
- package/src/utils/serverTermination.ts +20 -0
- package/tests/e2e/acl-condition-variable.test.ts +74 -0
- package/tests/e2e/assume-membership.test.ts +64 -0
- package/tests/e2e/content-api-basic.test.ts +51 -0
- package/tests/e2e/content-invalid-schema.test.ts +31 -0
- package/tests/e2e/homepage.test.ts +10 -0
- package/tests/e2e/tenant-member-access.test.ts +51 -0
- package/tests/e2e/x-contember-ref.test.ts +71 -0
- package/tests/src/requests.ts +72 -0
- package/tests/src/tester.ts +118 -0
- package/alpine.dockerfile +0 -30
- package/debian.dockerfile +0 -27
- package/dist/src/http/CollectHttpMetricsMiddelware.d.ts +0 -5
- package/dist/src/http/CollectHttpMetricsMiddelware.d.ts.map +0 -1
- package/dist/src/http/CollectHttpMetricsMiddelware.js +0 -36
- package/dist/src/http/CollectHttpMetricsMiddelware.js.map +0 -1
- package/dist/src/http/ShowMetricsMiddleware.d.ts +0 -4
- package/dist/src/http/ShowMetricsMiddleware.d.ts.map +0 -1
- package/dist/src/http/ShowMetricsMiddleware.js +0 -20
- package/dist/src/http/ShowMetricsMiddleware.js.map +0 -1
- package/dist/src/http/index.d.ts +0 -3
- package/dist/src/http/index.d.ts.map +0 -1
- package/dist/src/http/index.js +0 -19
- package/dist/src/http/index.js.map +0 -1
- package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts +0 -12
- package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts.map +0 -1
- package/dist/src/projectGroup/ProjectGroupContainerResolver.js +0 -36
- package/dist/src/projectGroup/ProjectGroupContainerResolver.js.map +0 -1
- package/dist/src/utils/cluster.d.ts +0 -9
- package/dist/src/utils/cluster.d.ts.map +0 -1
- package/dist/src/utils/cluster.js +0 -47
- package/dist/src/utils/cluster.js.map +0 -1
- package/dist/src/utils/dbMetrics.d.ts +0 -16
- package/dist/src/utils/dbMetrics.d.ts.map +0 -1
- package/dist/src/utils/dbMetrics.js +0 -98
- package/dist/src/utils/dbMetrics.js.map +0 -1
- package/dist/src/utils/timeout.d.ts +0 -2
- package/dist/src/utils/timeout.d.ts.map +0 -1
- package/dist/src/utils/timeout.js +0 -8
- package/dist/src/utils/timeout.js.map +0 -1
- package/dist/src/utils/tuple.d.ts +0 -2
- package/dist/src/utils/tuple.d.ts.map +0 -1
- package/dist/src/utils/tuple.js +0 -6
- package/dist/src/utils/tuple.js.map +0 -1
- package/dist/tests/e2e/http.test.d.ts +0 -2
- package/dist/tests/e2e/http.test.d.ts.map +0 -1
- package/dist/tests/e2e/http.test.js +0 -275
- package/dist/tests/e2e/http.test.js.map +0 -1
- package/jasmine.json +0 -7
- package/src/http/CollectHttpMetricsMiddelware.ts +0 -32
- package/src/http/ShowMetricsMiddleware.ts +0 -12
- package/src/http/index.ts +0 -2
- package/src/projectGroup/ProjectGroupContainerResolver.ts +0 -47
- package/src/utils/cluster.ts +0 -40
- package/src/utils/dbMetrics.ts +0 -111
- package/src/utils/timeout.ts +0 -4
- package/src/utils/tuple.ts +0 -1
- package/tests/e2e/http.test.ts +0 -303
- package/tslint.json +0 -14
package/src/utils/dbMetrics.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import prom from 'prom-client'
|
|
2
|
-
import { Connection, EventManager } from '@contember/database'
|
|
3
|
-
|
|
4
|
-
const labelNames = ['contember_project' as const, 'contember_module' as const, 'contember_project_group' as const]
|
|
5
|
-
type LabelNames = typeof labelNames[number]
|
|
6
|
-
type Labels = { [K in LabelNames]: string }
|
|
7
|
-
type DatabaseMetricsEntry = {
|
|
8
|
-
connection: Connection.PoolStatusProvider & Connection.Queryable
|
|
9
|
-
labels: Labels
|
|
10
|
-
}
|
|
11
|
-
type Unregistrar = () => void
|
|
12
|
-
type DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar
|
|
13
|
-
|
|
14
|
-
export const createDbMetricsRegistrar = (registry: prom.Registry): DatabaseMetricsRegistrar => {
|
|
15
|
-
const dbPoolCollectorInner = createSingleDbPoolMetricsCollector(registry)
|
|
16
|
-
const entries = new Set<DatabaseMetricsEntry>()
|
|
17
|
-
const collector = () => {
|
|
18
|
-
for (const entry of entries) {
|
|
19
|
-
dbPoolCollectorInner(entry.connection, entry.labels)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
registry.registerCollector(collector)
|
|
23
|
-
const sqlMetricsRegistrar = createSqlMetricsRegistrar(registry)
|
|
24
|
-
return entry => {
|
|
25
|
-
entries.add(entry)
|
|
26
|
-
const sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels)
|
|
27
|
-
return () => {
|
|
28
|
-
entries.delete(entry)
|
|
29
|
-
sqlMetricsUnregistrar()
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const createSingleDbPoolMetricsCollector = (registry: prom.Registry) => {
|
|
35
|
-
|
|
36
|
-
const totalCount = new prom.Gauge({
|
|
37
|
-
registers: [registry],
|
|
38
|
-
name: `contember_db_pool_total_count`,
|
|
39
|
-
help: 'The total number of clients existing within the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
40
|
-
labelNames,
|
|
41
|
-
})
|
|
42
|
-
const idleCount = new prom.Gauge({
|
|
43
|
-
registers: [registry],
|
|
44
|
-
name: `contember_db_pool_idle_count`,
|
|
45
|
-
help: 'The number of clients which are not checked out but are currently idle in the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
46
|
-
labelNames,
|
|
47
|
-
})
|
|
48
|
-
const waitingCount = new prom.Gauge({
|
|
49
|
-
registers: [registry],
|
|
50
|
-
name: `contember_db_pool_waiting_count`,
|
|
51
|
-
help: 'The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
52
|
-
labelNames,
|
|
53
|
-
})
|
|
54
|
-
const maxCount = new prom.Gauge({
|
|
55
|
-
registers: [registry],
|
|
56
|
-
name: `contember_db_pool_max_count`,
|
|
57
|
-
help: 'Maximum number of clients the pool should contain by contember_module (tenant or content; system is not used since it uses the same connection) and contember_project for contember_module=content.',
|
|
58
|
-
labelNames,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
return (db: Connection.PoolStatusProvider, labels: Labels) => {
|
|
62
|
-
const poolInfo = db.getPoolStatus()
|
|
63
|
-
totalCount.set(labels, poolInfo.totalCount)
|
|
64
|
-
idleCount.set(labels, poolInfo.idleCount)
|
|
65
|
-
waitingCount.set(labels, poolInfo.waitingCount)
|
|
66
|
-
maxCount.set(labels, poolInfo.maxCount)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
type SqlMetricsRegistrar = (
|
|
70
|
-
connection: Connection.Queryable,
|
|
71
|
-
labels: Labels,
|
|
72
|
-
) => Unregistrar
|
|
73
|
-
const createSqlMetricsRegistrar = (registry: prom.Registry): SqlMetricsRegistrar => {
|
|
74
|
-
const sqlDuration = new prom.Histogram({
|
|
75
|
-
name: 'contember_sql_duration_ms',
|
|
76
|
-
help: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or "unknown" for unknown project)',
|
|
77
|
-
registers: [registry],
|
|
78
|
-
labelNames,
|
|
79
|
-
buckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],
|
|
80
|
-
})
|
|
81
|
-
const sqlErrorRate = new prom.Counter({
|
|
82
|
-
name: 'contember_sql_error_count',
|
|
83
|
-
help: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or "unknown" for unknown project)',
|
|
84
|
-
labelNames,
|
|
85
|
-
registers: [registry],
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
return (connection, labels) => {
|
|
89
|
-
const queryEndCallback: EventManager.ListenerTypes[EventManager.Event.queryEnd] = ({ meta }, { timing }) => {
|
|
90
|
-
sqlDuration.observe(
|
|
91
|
-
{
|
|
92
|
-
...labels,
|
|
93
|
-
contember_module: meta.module || labels.contember_module,
|
|
94
|
-
},
|
|
95
|
-
timing ? timing.selfDuration / 1000 : 0,
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
const queryErrorCallback: EventManager.ListenerTypes[EventManager.Event.queryError] = ({ meta }) => {
|
|
99
|
-
sqlErrorRate.inc({
|
|
100
|
-
...labels,
|
|
101
|
-
contember_module: meta.module || labels.contember_module,
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
connection.eventManager.on(EventManager.Event.queryEnd, queryEndCallback)
|
|
105
|
-
connection.eventManager.on(EventManager.Event.queryError, queryErrorCallback)
|
|
106
|
-
return () => {
|
|
107
|
-
connection.eventManager.removeListener(EventManager.Event.queryEnd, queryEndCallback)
|
|
108
|
-
connection.eventManager.removeListener(EventManager.Event.queryError, queryErrorCallback)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
package/src/utils/timeout.ts
DELETED
package/src/utils/tuple.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const tuple = <T extends unknown[]>(...args: T) => args
|
package/tests/e2e/http.test.ts
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import supertest from 'supertest'
|
|
2
|
-
import * as nodeAssert from 'assert'
|
|
3
|
-
import { assert, beforeAll, test } from 'vitest'
|
|
4
|
-
import { MigrationFilesManager, MigrationsResolver } from '@contember/schema-migrations'
|
|
5
|
-
import { getExampleProjectDirectory } from '@contember/engine-api-tester'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const rootToken = String(process.env.CONTEMBER_ROOT_TOKEN)
|
|
9
|
-
const loginToken = String(process.env.CONTEMBER_LOGIN_TOKEN)
|
|
10
|
-
const apiUrl = String(process.env.CONTEMBER_API_URL)
|
|
11
|
-
let projectSlug = ''
|
|
12
|
-
|
|
13
|
-
// Used to allow prettier formatting of GraphQL queries
|
|
14
|
-
const gql = (strings: TemplateStringsArray) => {
|
|
15
|
-
nodeAssert.strictEqual(strings.length, 1)
|
|
16
|
-
return strings[0]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const executeGraphql = (
|
|
21
|
-
query: string,
|
|
22
|
-
options: { authorizationToken?: string; path?: string; variables?: Record<string, any> } = {},
|
|
23
|
-
) => {
|
|
24
|
-
return supertest(apiUrl)
|
|
25
|
-
.post(options.path || `/content/${projectSlug}/live`)
|
|
26
|
-
.set('Authorization', 'Bearer ' + (options.authorizationToken || rootToken))
|
|
27
|
-
.send({
|
|
28
|
-
query,
|
|
29
|
-
variables: options.variables || {},
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const signIn = async (email: string, password: string): Promise<string> => {
|
|
34
|
-
const response2 = await executeGraphql(
|
|
35
|
-
gql`
|
|
36
|
-
mutation ($email: String!, $password: String!) {
|
|
37
|
-
signIn(email: $email, password: $password) {
|
|
38
|
-
ok
|
|
39
|
-
result {
|
|
40
|
-
token
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`,
|
|
45
|
-
{
|
|
46
|
-
variables: { email, password },
|
|
47
|
-
authorizationToken: loginToken,
|
|
48
|
-
path: '/tenant',
|
|
49
|
-
},
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
return response2.body.data.signIn.result.token
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
beforeAll(async () => {
|
|
56
|
-
projectSlug = 'test' + Date.now()
|
|
57
|
-
const result = await executeGraphql(`
|
|
58
|
-
mutation($projectSlug: String!, $config: Json!) {
|
|
59
|
-
createProject(projectSlug: $projectSlug, config: $config) {
|
|
60
|
-
ok
|
|
61
|
-
error { code }
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`,
|
|
65
|
-
{
|
|
66
|
-
path: '/tenant',
|
|
67
|
-
variables: {
|
|
68
|
-
projectSlug: projectSlug,
|
|
69
|
-
config: {},
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
.expect(response => {
|
|
73
|
-
assert.isOk(response.body)
|
|
74
|
-
assert.isOk(response.body.data)
|
|
75
|
-
assert.isOk(response.body.data.createProject)
|
|
76
|
-
if (!response.body.data.createProject.ok) {
|
|
77
|
-
assert.equal(response.body.data.createProject.error.code, 'ALREADY_EXISTS')
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
.expect(200)
|
|
81
|
-
if (!result.body.data.createProject.ok) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
const migrationFilesManager = new MigrationsResolver(MigrationFilesManager.createForProject(getExampleProjectDirectory(), 'sample'))
|
|
85
|
-
const migrations = await migrationFilesManager.getMigrations()
|
|
86
|
-
assert.isAtLeast(migrations.length, 2)
|
|
87
|
-
await executeGraphql(`
|
|
88
|
-
mutation($migrations: [Migration!]!) {
|
|
89
|
-
migrate(migrations: $migrations) {
|
|
90
|
-
ok
|
|
91
|
-
error { code }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
`,
|
|
95
|
-
{
|
|
96
|
-
path: '/system/' + projectSlug,
|
|
97
|
-
variables: {
|
|
98
|
-
migrations,
|
|
99
|
-
},
|
|
100
|
-
})
|
|
101
|
-
.expect(response => {
|
|
102
|
-
assert.deepStrictEqual(response.body.data, {
|
|
103
|
-
migrate: {
|
|
104
|
-
error: null,
|
|
105
|
-
ok: true,
|
|
106
|
-
},
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test('show homepage', async () => {
|
|
112
|
-
await supertest(apiUrl)
|
|
113
|
-
.get('/')
|
|
114
|
-
.expect(200)
|
|
115
|
-
.expect('App is running')
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test('Content API: create & read tag', async () => {
|
|
119
|
-
await executeGraphql(
|
|
120
|
-
gql`
|
|
121
|
-
mutation {
|
|
122
|
-
createTag(data: { label: "graphql" }) {
|
|
123
|
-
ok
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
`,
|
|
127
|
-
)
|
|
128
|
-
.expect(response => {
|
|
129
|
-
assert.deepStrictEqual(response.body.data, {
|
|
130
|
-
createTag: {
|
|
131
|
-
ok: true,
|
|
132
|
-
},
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
.expect(200)
|
|
136
|
-
|
|
137
|
-
await executeGraphql(
|
|
138
|
-
gql`
|
|
139
|
-
query {
|
|
140
|
-
listTag(filter: { label: { eq: "graphql" } }) {
|
|
141
|
-
label
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`,
|
|
145
|
-
)
|
|
146
|
-
.expect(response => {
|
|
147
|
-
assert.deepStrictEqual(response.body.data, {
|
|
148
|
-
listTag: [
|
|
149
|
-
{
|
|
150
|
-
label: 'graphql',
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
.expect(200)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
test('Content API: X-Contember-Ref header', async () => {
|
|
159
|
-
await executeGraphql(
|
|
160
|
-
gql`
|
|
161
|
-
mutation {
|
|
162
|
-
createTag(data: { label: "typescript" }) {
|
|
163
|
-
ok
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
`,
|
|
167
|
-
).expect(200)
|
|
168
|
-
|
|
169
|
-
const response = await executeGraphql(
|
|
170
|
-
gql`
|
|
171
|
-
query {
|
|
172
|
-
listTag(filter: { label: { eq: "typescript" } }) {
|
|
173
|
-
label
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
`,
|
|
177
|
-
)
|
|
178
|
-
.set('X-Contember-Ref', 'None')
|
|
179
|
-
.expect(response => {
|
|
180
|
-
assert.deepStrictEqual(response.body.data, {
|
|
181
|
-
listTag: [
|
|
182
|
-
{
|
|
183
|
-
label: 'typescript',
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
.expect(200)
|
|
189
|
-
const eventKey = response.get('X-Contember-Ref')
|
|
190
|
-
await executeGraphql(
|
|
191
|
-
gql`
|
|
192
|
-
query {
|
|
193
|
-
listTag {
|
|
194
|
-
label
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
`,
|
|
198
|
-
)
|
|
199
|
-
.set('X-Contember-Ref', eventKey)
|
|
200
|
-
.expect(304)
|
|
201
|
-
|
|
202
|
-
// ignored for mutation
|
|
203
|
-
await executeGraphql(
|
|
204
|
-
gql`
|
|
205
|
-
mutation {
|
|
206
|
-
createTag(data: { label: "typescript" }) {
|
|
207
|
-
ok
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
`,
|
|
211
|
-
)
|
|
212
|
-
.set('X-Contember-Ref', eventKey)
|
|
213
|
-
.expect(200)
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
test('Content API: invalid schema error', async () => {
|
|
217
|
-
await executeGraphql(
|
|
218
|
-
gql`
|
|
219
|
-
mutation {
|
|
220
|
-
createFoo(data: { label: "graphql" }) {
|
|
221
|
-
ok
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
`,
|
|
225
|
-
)
|
|
226
|
-
.expect(400)
|
|
227
|
-
.expect(response => {
|
|
228
|
-
assert.deepStrictEqual(
|
|
229
|
-
response.body.errors[0].message,
|
|
230
|
-
'Cannot query field "createFoo" on type "Mutation". Did you mean "createPost" or "createTag"?',
|
|
231
|
-
)
|
|
232
|
-
})
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
test('Tenant API: sign up, add to a project and check project access', async () => {
|
|
236
|
-
const email = `john+${Date.now()}@doe.com`
|
|
237
|
-
const signUpResponse = await executeGraphql(
|
|
238
|
-
gql`
|
|
239
|
-
mutation($email: String!) {
|
|
240
|
-
signUp(email: $email, password: "123456") {
|
|
241
|
-
ok
|
|
242
|
-
result {
|
|
243
|
-
person {
|
|
244
|
-
identity {
|
|
245
|
-
id
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
`,
|
|
252
|
-
{
|
|
253
|
-
path: '/tenant',
|
|
254
|
-
variables: { email },
|
|
255
|
-
},
|
|
256
|
-
).expect(200)
|
|
257
|
-
|
|
258
|
-
const identityId = signUpResponse.body.data.signUp.result.person.identity.id
|
|
259
|
-
|
|
260
|
-
const authKey = await signIn(email, '123456')
|
|
261
|
-
await executeGraphql(
|
|
262
|
-
gql`
|
|
263
|
-
query {
|
|
264
|
-
listTag {
|
|
265
|
-
id
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
`,
|
|
269
|
-
{ authorizationToken: authKey },
|
|
270
|
-
)
|
|
271
|
-
.expect(404)
|
|
272
|
-
.expect({ errors: [{ message: `Project ${projectSlug} NOT found`, code: 404 }] })
|
|
273
|
-
|
|
274
|
-
await executeGraphql(
|
|
275
|
-
gql`
|
|
276
|
-
mutation ($identity: String!, $projectSlug: String!) {
|
|
277
|
-
addProjectMember(identityId: $identity, projectSlug: $projectSlug, memberships: [{ role: "admin", variables: [] }]) {
|
|
278
|
-
ok
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
`,
|
|
282
|
-
{ path: '/tenant', variables: { identity: identityId, projectSlug } },
|
|
283
|
-
)
|
|
284
|
-
.expect(200)
|
|
285
|
-
.expect(response => {
|
|
286
|
-
assert.deepStrictEqual(response.body.data, { addProjectMember: { ok: true } })
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
await executeGraphql(
|
|
290
|
-
gql`
|
|
291
|
-
query {
|
|
292
|
-
listAuthor {
|
|
293
|
-
id
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
`,
|
|
297
|
-
{ authorizationToken: authKey },
|
|
298
|
-
)
|
|
299
|
-
.expect(response => {
|
|
300
|
-
assert.deepStrictEqual(response.body.data, { listAuthor: [] })
|
|
301
|
-
})
|
|
302
|
-
.expect(200)
|
|
303
|
-
})
|
package/tslint.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"defaultSeverity": "error",
|
|
3
|
-
"extends": ["tslint:recommended"],
|
|
4
|
-
"jsRules": {},
|
|
5
|
-
"rules": {
|
|
6
|
-
"interface-name": [true, "never-prefix"],
|
|
7
|
-
"object-literal-sort-keys": [false],
|
|
8
|
-
"trailing-comma": [false],
|
|
9
|
-
"semicolon": [true, "never"],
|
|
10
|
-
"arrow-parens": [true, "ban-single-arg-parens"],
|
|
11
|
-
"one-line": [true, "check-catch", "check-finally", "check-else"]
|
|
12
|
-
},
|
|
13
|
-
"rulesDirectory": []
|
|
14
|
-
}
|