@contember/engine-server 1.2.0-alpha.16 → 1.2.0-alpha.17
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/config/configSchema.d.ts +51 -4
- package/dist/src/config/configSchema.d.ts.map +1 -1
- package/dist/src/config/configSchema.js +11 -9
- package/dist/src/config/configSchema.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/configResolver.test.d.ts +2 -0
- package/dist/tests/cases/configResolver.test.d.ts.map +1 -0
- package/dist/tests/cases/configResolver.test.js +67 -0
- package/dist/tests/cases/configResolver.test.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -21
- package/src/config/configSchema.ts +19 -12
- package/tests/cases/configResolver.test.ts +67 -0
package/package.json
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-server",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.17",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"test": "vitest tests/cases",
|
|
8
9
|
"test-e2e": "vitest --no-threads tests/e2e"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
|
-
"@contember/authorization": "^1.2.0-alpha.
|
|
12
|
-
"@contember/config-loader": "^1.2.0-alpha.
|
|
13
|
-
"@contember/database": "^1.2.0-alpha.
|
|
14
|
-
"@contember/database-migrations": "^1.2.0-alpha.
|
|
15
|
-
"@contember/dic": "^1.2.0-alpha.
|
|
16
|
-
"@contember/typesafe": "^1.2.0-alpha.
|
|
17
|
-
"@contember/engine-content-api": "^1.2.0-alpha.
|
|
18
|
-
"@contember/engine-http": "^1.2.0-alpha.
|
|
19
|
-
"@contember/engine-plugins": "^1.2.0-alpha.
|
|
20
|
-
"@contember/engine-s3-plugin": "^1.2.0-alpha.
|
|
21
|
-
"@contember/engine-system-api": "^1.2.0-alpha.
|
|
22
|
-
"@contember/engine-tenant-api": "^1.2.0-alpha.
|
|
23
|
-
"@contember/engine-vimeo-plugin": "^1.2.0-alpha.
|
|
24
|
-
"@contember/logger": "^1.2.0-alpha.
|
|
25
|
-
"@contember/queryable": "^1.2.0-alpha.
|
|
26
|
-
"@contember/schema": "^1.2.0-alpha.
|
|
27
|
-
"@contember/schema-definition": "^1.2.0-alpha.
|
|
28
|
-
"@contember/schema-migrations": "^1.2.0-alpha.
|
|
29
|
-
"@contember/schema-utils": "^1.2.0-alpha.
|
|
12
|
+
"@contember/authorization": "^1.2.0-alpha.17",
|
|
13
|
+
"@contember/config-loader": "^1.2.0-alpha.17",
|
|
14
|
+
"@contember/database": "^1.2.0-alpha.17",
|
|
15
|
+
"@contember/database-migrations": "^1.2.0-alpha.17",
|
|
16
|
+
"@contember/dic": "^1.2.0-alpha.17",
|
|
17
|
+
"@contember/typesafe": "^1.2.0-alpha.17",
|
|
18
|
+
"@contember/engine-content-api": "^1.2.0-alpha.17",
|
|
19
|
+
"@contember/engine-http": "^1.2.0-alpha.17",
|
|
20
|
+
"@contember/engine-plugins": "^1.2.0-alpha.17",
|
|
21
|
+
"@contember/engine-s3-plugin": "^1.2.0-alpha.17",
|
|
22
|
+
"@contember/engine-system-api": "^1.2.0-alpha.17",
|
|
23
|
+
"@contember/engine-tenant-api": "^1.2.0-alpha.17",
|
|
24
|
+
"@contember/engine-vimeo-plugin": "^1.2.0-alpha.17",
|
|
25
|
+
"@contember/logger": "^1.2.0-alpha.17",
|
|
26
|
+
"@contember/queryable": "^1.2.0-alpha.17",
|
|
27
|
+
"@contember/schema": "^1.2.0-alpha.17",
|
|
28
|
+
"@contember/schema-definition": "^1.2.0-alpha.17",
|
|
29
|
+
"@contember/schema-migrations": "^1.2.0-alpha.17",
|
|
30
|
+
"@contember/schema-utils": "^1.2.0-alpha.17",
|
|
30
31
|
"@koa/cors": "^3.1.0",
|
|
31
32
|
"@sentry/node": "^7.1.1",
|
|
32
33
|
"graphql": "^16.5.0",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"uuid": "^8.3.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@contember/engine-api-tester": "^1.2.0-alpha.
|
|
42
|
+
"@contember/engine-api-tester": "^1.2.0-alpha.17",
|
|
42
43
|
"@types/koa-compress": "^4.0.1",
|
|
43
44
|
"@types/node": "^18",
|
|
44
45
|
"@types/supertest": "^2.0.8",
|
|
@@ -27,11 +27,29 @@ const dbConfigOptional = {
|
|
|
27
27
|
}),
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const dbConfigSchemaInner = Typesafe.intersection(
|
|
31
31
|
Typesafe.object(dbConfigRequired),
|
|
32
32
|
Typesafe.partial(dbConfigOptional),
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
+
const readDbSchema = Typesafe.intersection(
|
|
36
|
+
Typesafe.partial(dbConfigRequired),
|
|
37
|
+
Typesafe.partial(dbConfigOptional),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
export const dbConfigSchema = Typesafe.intersection(
|
|
41
|
+
dbConfigSchemaInner,
|
|
42
|
+
Typesafe.partial({
|
|
43
|
+
read: (val: unknown) => {
|
|
44
|
+
const readDb = readDbSchema(val)
|
|
45
|
+
if ('host' in readDb) {
|
|
46
|
+
return readDb
|
|
47
|
+
}
|
|
48
|
+
return undefined
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
)
|
|
52
|
+
|
|
35
53
|
export const tenantConfigSchema = Typesafe.intersection(
|
|
36
54
|
Typesafe.object({
|
|
37
55
|
db: dbConfigSchema,
|
|
@@ -94,10 +112,6 @@ export const stageConfig = Typesafe.record(
|
|
|
94
112
|
),
|
|
95
113
|
)
|
|
96
114
|
|
|
97
|
-
const readDbSchema = Typesafe.intersection(
|
|
98
|
-
Typesafe.partial(dbConfigRequired),
|
|
99
|
-
Typesafe.partial(dbConfigOptional),
|
|
100
|
-
)
|
|
101
115
|
export const projectConfigSchema = Typesafe.object({
|
|
102
116
|
name: Typesafe.union(
|
|
103
117
|
Typesafe.string,
|
|
@@ -114,13 +128,6 @@ export const projectConfigSchema = Typesafe.object({
|
|
|
114
128
|
),
|
|
115
129
|
Typesafe.partial({
|
|
116
130
|
systemSchema: Typesafe.string,
|
|
117
|
-
read: (val: unknown) => {
|
|
118
|
-
const readDb = readDbSchema(val)
|
|
119
|
-
if ('host' in readDb) {
|
|
120
|
-
return readDb
|
|
121
|
-
}
|
|
122
|
-
return undefined
|
|
123
|
-
},
|
|
124
131
|
}),
|
|
125
132
|
),
|
|
126
133
|
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { assert, it } from 'vitest'
|
|
2
|
+
import { createTenantConfigResolver } from '../../src/config/tenantConfigResolver'
|
|
3
|
+
import { configTemplate } from '../../src/config/configTemplate'
|
|
4
|
+
import { createProjectConfigResolver } from '../../src/config/projectConfigResolver'
|
|
5
|
+
|
|
6
|
+
const env = {
|
|
7
|
+
DEFAULT_DB_POOL_IDLE_TIMEOUT_MS: '60000',
|
|
8
|
+
DEFAULT_DB_POOL_MAX_CONNECTIONS: '1000',
|
|
9
|
+
DEFAULT_DB_POOL_MAX_CONNECTING: '10',
|
|
10
|
+
DEFAULT_DB_CONNECTION_TIMEOUT_MS: '5000',
|
|
11
|
+
}
|
|
12
|
+
const tenantConfig = {
|
|
13
|
+
db: {
|
|
14
|
+
host: 'c0.cluster-abc.eu-west-1.rds.amazonaws.com',
|
|
15
|
+
port: 5432,
|
|
16
|
+
user: 'u_test_e',
|
|
17
|
+
password: 'PASSWD',
|
|
18
|
+
database: 'p_test_e',
|
|
19
|
+
read: { host: 'c0.cluster-ro-abc.eu-west-1.rds.amazonaws.com' },
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
it('resolves tenant config config', () => {
|
|
23
|
+
const tenantResolver = createTenantConfigResolver(env, configTemplate.tenant)
|
|
24
|
+
const resolvedTenantConfig = tenantResolver('test', tenantConfig)
|
|
25
|
+
assert.deepEqual(resolvedTenantConfig, {
|
|
26
|
+
db: {
|
|
27
|
+
host: 'c0.cluster-abc.eu-west-1.rds.amazonaws.com',
|
|
28
|
+
port: 5432,
|
|
29
|
+
user: 'u_test_e',
|
|
30
|
+
password: 'PASSWD',
|
|
31
|
+
database: 'p_test_e',
|
|
32
|
+
connectionTimeoutMs: 5000,
|
|
33
|
+
pool: { maxConnections: 1000, maxConnecting: 10, idleTimeoutMs: 60000 },
|
|
34
|
+
read: { host: 'c0.cluster-ro-abc.eu-west-1.rds.amazonaws.com' },
|
|
35
|
+
}, mailer: {}, credentials: {}, secrets: {},
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
it('resolves project config config', () => {
|
|
39
|
+
const tenantResolver = createTenantConfigResolver(env, configTemplate.tenant)
|
|
40
|
+
const resolvedTenantConfig = tenantResolver('test', tenantConfig)
|
|
41
|
+
|
|
42
|
+
const projectConfigResolver = createProjectConfigResolver(env, configTemplate, [])
|
|
43
|
+
const resolvedProjectConfig = projectConfigResolver('test-p', {
|
|
44
|
+
db: {
|
|
45
|
+
useTenantDb: true,
|
|
46
|
+
systemSchema: 'system_test_e',
|
|
47
|
+
}, s3: { prefix: 'test-e/test-e' }, stages: { live: { schema: 'content_test_e_live' } },
|
|
48
|
+
}, {}, resolvedTenantConfig)
|
|
49
|
+
|
|
50
|
+
assert.deepEqual(resolvedProjectConfig as any, {
|
|
51
|
+
name: 'Test p',
|
|
52
|
+
slug: 'test-p',
|
|
53
|
+
stages: [{ name: 'Live', slug: 'live', schema: 'content_test_e_live' }],
|
|
54
|
+
db: {
|
|
55
|
+
host: 'c0.cluster-abc.eu-west-1.rds.amazonaws.com',
|
|
56
|
+
port: 5432,
|
|
57
|
+
user: 'u_test_e',
|
|
58
|
+
password: 'PASSWD',
|
|
59
|
+
database: 'p_test_e',
|
|
60
|
+
connectionTimeoutMs: 5000,
|
|
61
|
+
pool: { maxConnections: 1000, maxConnecting: 10, idleTimeoutMs: 60000 },
|
|
62
|
+
read: { host: 'c0.cluster-ro-abc.eu-west-1.rds.amazonaws.com' },
|
|
63
|
+
useTenantDb: true,
|
|
64
|
+
systemSchema: 'system_test_e',
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
})
|