@contember/engine-system-api 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-system-api",
3
- "version": "1.1.0-rc.1",
3
+ "version": "1.2.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/src/index.d.ts",
@@ -9,22 +9,22 @@
9
9
  "test": "vitest"
10
10
  },
11
11
  "dependencies": {
12
- "@contember/authorization": "^1.1.0-rc.1",
13
- "@contember/database": "^1.1.0-rc.1",
14
- "@contember/database-migrations": "^1.1.0-rc.1",
15
- "@contember/dic": "^1.1.0-rc.1",
16
- "@contember/engine-common": "^1.1.0-rc.1",
17
- "@contember/graphql-utils": "^1.1.0-rc.1",
18
- "@contember/queryable": "^1.1.0-rc.1",
19
- "@contember/schema": "^1.1.0-rc.1",
20
- "@contember/schema-migrations": "^1.1.0-rc.1",
21
- "@contember/schema-utils": "^1.1.0-rc.1",
12
+ "@contember/authorization": "^1.2.0-alpha.2",
13
+ "@contember/database": "^1.2.0-alpha.2",
14
+ "@contember/database-migrations": "^1.2.0-alpha.2",
15
+ "@contember/dic": "^1.2.0-alpha.2",
16
+ "@contember/engine-common": "^1.2.0-alpha.2",
17
+ "@contember/graphql-utils": "^1.2.0-alpha.2",
18
+ "@contember/queryable": "^1.2.0-alpha.2",
19
+ "@contember/schema": "^1.2.0-alpha.2",
20
+ "@contember/schema-migrations": "^1.2.0-alpha.2",
21
+ "@contember/schema-utils": "^1.2.0-alpha.2",
22
22
  "@graphql-tools/utils": "^7.10.0",
23
23
  "graphql-tag": "^2.12.5"
24
24
  },
25
25
  "devDependencies": {
26
- "@contember/engine-api-tester": "^1.1.0-rc.1",
27
- "@contember/schema-definition": "^1.1.0-rc.1",
26
+ "@contember/engine-api-tester": "^1.2.0-alpha.2",
27
+ "@contember/schema-definition": "^1.2.0-alpha.2",
28
28
  "@graphql-codegen/cli": "^1.15.2",
29
29
  "@graphql-codegen/typescript": "^1.15.2",
30
30
  "@graphql-codegen/typescript-operations": "^1.15.2",
@@ -6,7 +6,7 @@ import { SystemDbMigrationsRunnerFactory } from '../SystemContainer'
6
6
  import {
7
7
  Connection,
8
8
  createDatabaseIfNotExists,
9
- DatabaseCredentials,
9
+ DatabaseConfig,
10
10
  retryTransaction,
11
11
  SingleConnection,
12
12
  } from '@contember/database'
@@ -24,7 +24,7 @@ export class ProjectInitializer {
24
24
 
25
25
  public async initialize(
26
26
  databaseContextFactory: DatabaseContextFactory,
27
- project: ProjectConfig & { db?: DatabaseCredentials },
27
+ project: ProjectConfig & { db?: DatabaseConfig },
28
28
  logger: Logger,
29
29
  migrations?: Migration[],
30
30
  ) {
@@ -50,11 +50,15 @@ export class ProjectInitializer {
50
50
  await singleConnection.end()
51
51
  logger.groupEnd()
52
52
  }
53
- return await retryTransaction(() =>
53
+ const result = await retryTransaction(() =>
54
54
  dbContext.transaction(async trx => {
55
55
  await this.initStages(trx, project, logger, migrations)
56
56
  }),
57
57
  )
58
+ if (dbContext.client.connection instanceof Connection) {
59
+ await dbContext.client.connection.clearPool()
60
+ }
61
+ return result
58
62
  }
59
63
 
60
64
  private async initStages(
@@ -8,6 +8,7 @@ import { DatabaseContext } from '../database'
8
8
  import { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'
9
9
  import { MigrateErrorCode } from '../../schema'
10
10
  import { SchemaVersionBuilder } from './SchemaVersionBuilder'
11
+ import { SchemaValidator } from '@contember/schema-utils'
11
12
 
12
13
  export class ProjectMigrator {
13
14
  constructor(
@@ -74,11 +75,12 @@ export class ProjectMigrator {
74
75
  }
75
76
  const latestModification = described[described.length - 1]
76
77
  schema = latestModification.schema
77
- if (latestModification.errors.length > 0) {
78
+ const errors = SchemaValidator.validate(schema)
79
+ if (errors.length > 0) {
78
80
  throw new InvalidSchemaError(
79
81
  migration.version,
80
82
  'Migration generates invalid schema: \n' +
81
- latestModification.errors.map(it => it.path.join('.') + ': ' + it.message).join('\n'),
83
+ errors.map(it => it.path.join('.') + ': ' + it.message).join('\n'),
82
84
  )
83
85
  }
84
86
  }