@contember/engine-server 1.1.0-rc.1 → 1.2.0-alpha.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.
Files changed (163) hide show
  1. package/dist/src/MasterContainer.d.ts +12 -25
  2. package/dist/src/MasterContainer.d.ts.map +1 -1
  3. package/dist/src/MasterContainer.js +36 -80
  4. package/dist/src/MasterContainer.js.map +1 -1
  5. package/dist/src/bootstrap/Initializer.d.ts +3 -3
  6. package/dist/src/bootstrap/Initializer.d.ts.map +1 -1
  7. package/dist/src/bootstrap/Initializer.js +15 -6
  8. package/dist/src/bootstrap/Initializer.js.map +1 -1
  9. package/dist/src/config/config.d.ts +5 -4
  10. package/dist/src/config/config.d.ts.map +1 -1
  11. package/dist/src/config/config.js +2 -2
  12. package/dist/src/config/config.js.map +1 -1
  13. package/dist/src/config/configSchema.d.ts +45 -11
  14. package/dist/src/config/configSchema.d.ts.map +1 -1
  15. package/dist/src/config/configSchema.js +20 -18
  16. package/dist/src/config/configSchema.js.map +1 -1
  17. package/dist/src/config/configTemplate.d.ts.map +1 -1
  18. package/dist/src/config/configTemplate.js +23 -0
  19. package/dist/src/config/configTemplate.js.map +1 -1
  20. package/dist/src/index.d.ts +9 -3
  21. package/dist/src/index.d.ts.map +1 -1
  22. package/dist/src/index.js +23 -4
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/project/ProjectContainer.js +1 -1
  25. package/dist/src/project/ProjectContainer.js.map +1 -1
  26. package/dist/src/project/ProjectContainerResolver.d.ts +6 -3
  27. package/dist/src/project/ProjectContainerResolver.d.ts.map +1 -1
  28. package/dist/src/project/ProjectContainerResolver.js +4 -16
  29. package/dist/src/project/ProjectContainerResolver.js.map +1 -1
  30. package/dist/src/projectGroup/ProjectGroupContainer.d.ts +2 -1
  31. package/dist/src/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
  32. package/dist/src/projectGroup/ProjectGroupContainer.js +8 -4
  33. package/dist/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  34. package/dist/src/projectGroup/ProjectGroupResolver.d.ts +7 -0
  35. package/dist/src/projectGroup/ProjectGroupResolver.d.ts.map +1 -0
  36. package/dist/src/projectGroup/ProjectGroupResolver.js +13 -0
  37. package/dist/src/projectGroup/ProjectGroupResolver.js.map +1 -0
  38. package/dist/src/start.js +15 -112
  39. package/dist/src/start.js.map +1 -1
  40. package/dist/src/tsconfig.tsbuildinfo +1 -1
  41. package/dist/src/utils/index.d.ts +0 -4
  42. package/dist/src/utils/index.d.ts.map +1 -1
  43. package/dist/src/utils/index.js +0 -4
  44. package/dist/src/utils/index.js.map +1 -1
  45. package/dist/src/utils/serverStartup.d.ts +31 -0
  46. package/dist/src/utils/serverStartup.d.ts.map +1 -0
  47. package/dist/src/utils/serverStartup.js +42 -0
  48. package/dist/src/utils/serverStartup.js.map +1 -0
  49. package/dist/src/utils/serverTermination.d.ts +12 -0
  50. package/dist/src/utils/serverTermination.d.ts.map +1 -0
  51. package/dist/src/utils/serverTermination.js +26 -0
  52. package/dist/src/utils/serverTermination.js.map +1 -0
  53. package/dist/tests/e2e/acl-condition-variable.test.d.ts +2 -0
  54. package/dist/tests/e2e/acl-condition-variable.test.d.ts.map +1 -0
  55. package/dist/tests/e2e/acl-condition-variable.test.js +77 -0
  56. package/dist/tests/e2e/acl-condition-variable.test.js.map +1 -0
  57. package/dist/tests/e2e/assume-membership.test.d.ts +2 -0
  58. package/dist/tests/e2e/assume-membership.test.d.ts.map +1 -0
  59. package/dist/tests/e2e/assume-membership.test.js +58 -0
  60. package/dist/tests/e2e/assume-membership.test.js.map +1 -0
  61. package/dist/tests/e2e/content-api-basic.test.d.ts +2 -0
  62. package/dist/tests/e2e/content-api-basic.test.d.ts.map +1 -0
  63. package/dist/tests/e2e/content-api-basic.test.js +50 -0
  64. package/dist/tests/e2e/content-api-basic.test.js.map +1 -0
  65. package/dist/tests/e2e/content-invalid-schema.test.d.ts +2 -0
  66. package/dist/tests/e2e/content-invalid-schema.test.d.ts.map +1 -0
  67. package/dist/tests/e2e/content-invalid-schema.test.js +29 -0
  68. package/dist/tests/e2e/content-invalid-schema.test.js.map +1 -0
  69. package/dist/tests/e2e/homepage.test.d.ts +2 -0
  70. package/dist/tests/e2e/homepage.test.d.ts.map +1 -0
  71. package/dist/tests/e2e/homepage.test.js +15 -0
  72. package/dist/tests/e2e/homepage.test.js.map +1 -0
  73. package/dist/tests/e2e/tenant-member-access.test.d.ts +2 -0
  74. package/dist/tests/e2e/tenant-member-access.test.d.ts.map +1 -0
  75. package/dist/tests/e2e/tenant-member-access.test.js +43 -0
  76. package/dist/tests/e2e/tenant-member-access.test.js.map +1 -0
  77. package/dist/tests/e2e/x-contember-ref.test.d.ts +2 -0
  78. package/dist/tests/e2e/x-contember-ref.test.d.ts.map +1 -0
  79. package/dist/tests/e2e/x-contember-ref.test.js +63 -0
  80. package/dist/tests/e2e/x-contember-ref.test.js.map +1 -0
  81. package/dist/tests/src/requests.d.ts +5 -0
  82. package/dist/tests/src/requests.d.ts.map +1 -0
  83. package/dist/tests/src/requests.js +59 -0
  84. package/dist/tests/src/requests.js.map +1 -0
  85. package/dist/tests/src/tester.d.ts +19 -0
  86. package/dist/tests/src/tester.d.ts.map +1 -0
  87. package/dist/tests/src/tester.js +99 -0
  88. package/dist/tests/src/tester.js.map +1 -0
  89. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  90. package/esbuild.js +7 -14
  91. package/package.json +20 -20
  92. package/src/MasterContainer.ts +58 -110
  93. package/src/bootstrap/Initializer.ts +16 -6
  94. package/src/config/config.ts +7 -5
  95. package/src/config/configSchema.ts +30 -33
  96. package/src/config/configTemplate.ts +23 -0
  97. package/src/index.ts +15 -2
  98. package/src/project/ProjectContainer.ts +1 -1
  99. package/src/project/ProjectContainerResolver.ts +4 -17
  100. package/src/projectGroup/ProjectGroupContainer.ts +12 -3
  101. package/src/projectGroup/ProjectGroupResolver.ts +12 -0
  102. package/src/start.ts +18 -127
  103. package/src/utils/index.ts +0 -4
  104. package/src/utils/serverStartup.ts +42 -0
  105. package/src/utils/serverTermination.ts +20 -0
  106. package/tests/e2e/acl-condition-variable.test.ts +74 -0
  107. package/tests/e2e/assume-membership.test.ts +64 -0
  108. package/tests/e2e/content-api-basic.test.ts +51 -0
  109. package/tests/e2e/content-invalid-schema.test.ts +31 -0
  110. package/tests/e2e/homepage.test.ts +10 -0
  111. package/tests/e2e/tenant-member-access.test.ts +51 -0
  112. package/tests/e2e/x-contember-ref.test.ts +71 -0
  113. package/tests/src/requests.ts +72 -0
  114. package/tests/src/tester.ts +118 -0
  115. package/alpine.dockerfile +0 -30
  116. package/debian.dockerfile +0 -27
  117. package/dist/src/http/CollectHttpMetricsMiddelware.d.ts +0 -5
  118. package/dist/src/http/CollectHttpMetricsMiddelware.d.ts.map +0 -1
  119. package/dist/src/http/CollectHttpMetricsMiddelware.js +0 -36
  120. package/dist/src/http/CollectHttpMetricsMiddelware.js.map +0 -1
  121. package/dist/src/http/ShowMetricsMiddleware.d.ts +0 -4
  122. package/dist/src/http/ShowMetricsMiddleware.d.ts.map +0 -1
  123. package/dist/src/http/ShowMetricsMiddleware.js +0 -20
  124. package/dist/src/http/ShowMetricsMiddleware.js.map +0 -1
  125. package/dist/src/http/index.d.ts +0 -3
  126. package/dist/src/http/index.d.ts.map +0 -1
  127. package/dist/src/http/index.js +0 -19
  128. package/dist/src/http/index.js.map +0 -1
  129. package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts +0 -12
  130. package/dist/src/projectGroup/ProjectGroupContainerResolver.d.ts.map +0 -1
  131. package/dist/src/projectGroup/ProjectGroupContainerResolver.js +0 -36
  132. package/dist/src/projectGroup/ProjectGroupContainerResolver.js.map +0 -1
  133. package/dist/src/utils/cluster.d.ts +0 -9
  134. package/dist/src/utils/cluster.d.ts.map +0 -1
  135. package/dist/src/utils/cluster.js +0 -47
  136. package/dist/src/utils/cluster.js.map +0 -1
  137. package/dist/src/utils/dbMetrics.d.ts +0 -16
  138. package/dist/src/utils/dbMetrics.d.ts.map +0 -1
  139. package/dist/src/utils/dbMetrics.js +0 -98
  140. package/dist/src/utils/dbMetrics.js.map +0 -1
  141. package/dist/src/utils/timeout.d.ts +0 -2
  142. package/dist/src/utils/timeout.d.ts.map +0 -1
  143. package/dist/src/utils/timeout.js +0 -8
  144. package/dist/src/utils/timeout.js.map +0 -1
  145. package/dist/src/utils/tuple.d.ts +0 -2
  146. package/dist/src/utils/tuple.d.ts.map +0 -1
  147. package/dist/src/utils/tuple.js +0 -6
  148. package/dist/src/utils/tuple.js.map +0 -1
  149. package/dist/tests/e2e/http.test.d.ts +0 -2
  150. package/dist/tests/e2e/http.test.d.ts.map +0 -1
  151. package/dist/tests/e2e/http.test.js +0 -275
  152. package/dist/tests/e2e/http.test.js.map +0 -1
  153. package/jasmine.json +0 -7
  154. package/src/http/CollectHttpMetricsMiddelware.ts +0 -32
  155. package/src/http/ShowMetricsMiddleware.ts +0 -12
  156. package/src/http/index.ts +0 -2
  157. package/src/projectGroup/ProjectGroupContainerResolver.ts +0 -47
  158. package/src/utils/cluster.ts +0 -40
  159. package/src/utils/dbMetrics.ts +0 -111
  160. package/src/utils/timeout.ts +0 -4
  161. package/src/utils/tuple.ts +0 -1
  162. package/tests/e2e/http.test.ts +0 -303
  163. package/tslint.json +0 -14
@@ -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
- }