@biorate/migrations 1.102.1 → 1.105.0
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/.nyc_output/4140a03c-b5db-4a30-82b3-ffcf324ca573.json +1 -0
- package/.nyc_output/processinfo/4140a03c-b5db-4a30-82b3-ffcf324ca573.json +1 -0
- package/.nyc_output/processinfo/fa0d2142-a700-4a9d-976f-ed981d166a22.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +16 -0
- package/coverage/lcov-report/file:/www/biorate/core/packages/@biorate/migrations/src/default.config.ts.html +3 -3
- package/coverage/lcov-report/file:/www/biorate/core/packages/@biorate/migrations/src/errors.ts.html +118 -0
- package/coverage/lcov-report/file:/www/biorate/core/packages/@biorate/migrations/src/index.html +26 -11
- package/coverage/lcov-report/file:/www/biorate/core/packages/@biorate/migrations/src/index.ts.html +1 -1
- package/coverage/lcov-report/file:/www/biorate/core/packages/@biorate/migrations/src/root.ts.html +3 -3
- package/coverage/lcov-report/index.html +26 -26
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/amqp.ts.html +1 -1
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/clickhouse.ts.html +5 -5
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/index.html +43 -28
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/index.ts.html +3 -3
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/kafka.ts.html +1 -1
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/migration.ts.html +1 -1
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/minio.ts.html +6 -6
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/mongodb.ts.html +5 -5
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/schema-registry.ts.html +118 -0
- package/coverage/lcov-report/types/file:/www/biorate/core/packages/@biorate/migrations/src/types/sequelize.ts.html +1 -1
- package/coverage/lcov.info +128 -61
- package/dist/src/default.config.js +9 -0
- package/dist/src/default.config.js.map +1 -1
- package/dist/src/errors.js +10 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/root.js +4 -0
- package/dist/src/root.js.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/migration.js +1 -1
- package/dist/src/types/migration.js.map +1 -1
- package/dist/src/types/schema-registry.js +53 -0
- package/dist/src/types/schema-registry.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -17
- package/src/default.config.ts +12 -0
- package/src/errors.ts +7 -5
- package/src/root.ts +15 -12
- package/src/types/index.ts +1 -0
- package/src/types/migration.ts +2 -2
- package/src/types/schema-registry.ts +55 -0
- package/.nyc_output/4ee80c21-d537-4c02-ace7-22a029984c25.json +0 -1
- package/.nyc_output/processinfo/4ee80c21-d537-4c02-ace7-22a029984c25.json +0 -1
- package/.nyc_output/processinfo/d9feaa95-3d67-4c09-8a17-5181663a6941.json +0 -1
- /package/.nyc_output/{d9feaa95-3d67-4c09-8a17-5181663a6941.json → fa0d2142-a700-4a9d-976f-ed981d166a22.json} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@biorate/migrations",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.105.0",
|
4
4
|
"description": "Migrations tools",
|
5
5
|
"main": "dist",
|
6
6
|
"scripts": {
|
@@ -23,23 +23,24 @@
|
|
23
23
|
"author": "llevkin",
|
24
24
|
"license": "MIT",
|
25
25
|
"dependencies": {
|
26
|
-
"@biorate/amqp": "1.
|
27
|
-
"@biorate/clickhouse": "1.
|
28
|
-
"@biorate/config": "1.
|
29
|
-
"@biorate/config-loader": "1.
|
30
|
-
"@biorate/config-loader-env": "1.
|
31
|
-
"@biorate/config-loader-fs": "1.
|
32
|
-
"@biorate/config-loader-vault": "1.
|
33
|
-
"@biorate/connector": "1.
|
26
|
+
"@biorate/amqp": "1.104.0",
|
27
|
+
"@biorate/clickhouse": "1.104.0",
|
28
|
+
"@biorate/config": "1.104.0",
|
29
|
+
"@biorate/config-loader": "1.104.0",
|
30
|
+
"@biorate/config-loader-env": "1.104.0",
|
31
|
+
"@biorate/config-loader-fs": "1.104.0",
|
32
|
+
"@biorate/config-loader-vault": "1.104.0",
|
33
|
+
"@biorate/connector": "1.104.0",
|
34
34
|
"@biorate/errors": "1.102.0",
|
35
|
-
"@biorate/inversion": "1.
|
36
|
-
"@biorate/kafkajs": "1.
|
37
|
-
"@biorate/minio": "1.
|
38
|
-
"@biorate/mongodb": "1.
|
39
|
-
"@biorate/proxy": "1.
|
40
|
-
"@biorate/
|
35
|
+
"@biorate/inversion": "1.104.0",
|
36
|
+
"@biorate/kafkajs": "1.104.0",
|
37
|
+
"@biorate/minio": "1.104.0",
|
38
|
+
"@biorate/mongodb": "1.104.0",
|
39
|
+
"@biorate/proxy": "1.104.0",
|
40
|
+
"@biorate/schema-registry": "1.105.0",
|
41
|
+
"@biorate/sequelize": "1.104.0",
|
41
42
|
"@biorate/tools": "1.102.1",
|
42
|
-
"@biorate/vault": "1.
|
43
|
+
"@biorate/vault": "1.104.0"
|
43
44
|
},
|
44
|
-
"gitHead": "
|
45
|
+
"gitHead": "cf91bcf6bed75b18660eaad219c78d97bdf69ff2"
|
45
46
|
}
|
package/src/default.config.ts
CHANGED
@@ -12,6 +12,10 @@ import { IClickhouseConnector, ClickhouseConnector } from '@biorate/clickhouse';
|
|
12
12
|
import { IAmqpConnector, AmqpConnector } from '@biorate/amqp';
|
13
13
|
import { IKafkaJSAdminConnector, KafkaJSAdminConnector } from '@biorate/kafkajs';
|
14
14
|
import { IProxyConnector, ProxyConnector } from '@biorate/proxy';
|
15
|
+
import {
|
16
|
+
ISchemaRegistryConnector,
|
17
|
+
SchemaRegistryConnector,
|
18
|
+
} from '@biorate/schema-registry';
|
15
19
|
import { Root } from './';
|
16
20
|
import * as Migrations from './types';
|
17
21
|
|
@@ -42,11 +46,19 @@ container
|
|
42
46
|
.to(KafkaJSAdminConnector)
|
43
47
|
.inSingletonScope();
|
44
48
|
container.bind<IProxyConnector>(Types.Proxy).to(ProxyConnector).inSingletonScope();
|
49
|
+
container
|
50
|
+
.bind<ISchemaRegistryConnector>(Types.SchemaRegistry)
|
51
|
+
.to(SchemaRegistryConnector)
|
52
|
+
.inSingletonScope();
|
45
53
|
container.bind<Migrations.Sequelize>(Migrations.Sequelize).toSelf().inSingletonScope();
|
46
54
|
container.bind<Migrations.Minio>(Migrations.Minio).toSelf().inSingletonScope();
|
47
55
|
container.bind<Migrations.Mongodb>(Migrations.Mongodb).toSelf().inSingletonScope();
|
48
56
|
container.bind<Migrations.Kafka>(Migrations.Kafka).toSelf().inSingletonScope();
|
49
57
|
container.bind<Migrations.Clickhouse>(Migrations.Clickhouse).toSelf().inSingletonScope();
|
50
58
|
container.bind<Migrations.Amqp>(Migrations.Amqp).toSelf().inSingletonScope();
|
59
|
+
container
|
60
|
+
.bind<Migrations.SchemaRegistry>(Migrations.SchemaRegistry)
|
61
|
+
.toSelf()
|
62
|
+
.inSingletonScope();
|
51
63
|
container.bind<Root>(Root).toSelf().inSingletonScope();
|
52
64
|
container.get<Root>(Root).$run().catch(console.error);
|
package/src/errors.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
import { BaseError } from '@biorate/errors';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
export class SchemaRegistryWrongFileNameError extends BaseError {
|
4
|
+
public constructor(name: string) {
|
5
|
+
super(`Schema registry wrong filename: [%s], pattern: "00001_filename.avsc.json"`, [
|
6
|
+
name,
|
7
|
+
]);
|
8
|
+
}
|
9
|
+
}
|
package/src/root.ts
CHANGED
@@ -7,29 +7,32 @@ import * as Migrations from './types';
|
|
7
7
|
|
8
8
|
@injectable()
|
9
9
|
export class Root extends Core() {
|
10
|
-
@inject(Types.Config) public config: IConfig;
|
10
|
+
@inject(Types.Config) public readonly config: IConfig;
|
11
11
|
|
12
|
-
@inject(Types.ConfigLoaderEnv) public configLoaderEnv: ConfigLoader;
|
12
|
+
@inject(Types.ConfigLoaderEnv) public readonly configLoaderEnv: ConfigLoader;
|
13
13
|
|
14
|
-
@inject(Types.ConfigLoaderFs) public configLoaderFs: ConfigLoader;
|
14
|
+
@inject(Types.ConfigLoaderFs) public readonly configLoaderFs: ConfigLoader;
|
15
15
|
|
16
|
-
@inject(Types.ConfigLoaderVault) public configLoaderVault: ConfigLoader;
|
16
|
+
@inject(Types.ConfigLoaderVault) public readonly configLoaderVault: ConfigLoader;
|
17
17
|
|
18
|
-
@inject(Types.Vault) public vault: IVaultConnector;
|
18
|
+
@inject(Types.Vault) public readonly vault: IVaultConnector;
|
19
19
|
|
20
|
-
@inject(Types.Proxy) public proxy: IProxyConnector;
|
20
|
+
@inject(Types.Proxy) public readonly proxy: IProxyConnector;
|
21
21
|
|
22
|
-
@inject(Migrations.Sequelize) public sequelize: Migrations.Sequelize;
|
22
|
+
@inject(Migrations.Sequelize) public readonly sequelize: Migrations.Sequelize;
|
23
23
|
|
24
|
-
@inject(Migrations.Minio)
|
24
|
+
@inject(Migrations.Minio) public readonly minio: Migrations.Minio;
|
25
25
|
|
26
|
-
@inject(Migrations.Mongodb)
|
26
|
+
@inject(Migrations.Mongodb) public readonly mongodb: Migrations.Mongodb;
|
27
27
|
|
28
|
-
@inject(Migrations.Kafka) public kafkaJSAdmin: Migrations.Kafka;
|
28
|
+
@inject(Migrations.Kafka) public readonly kafkaJSAdmin: Migrations.Kafka;
|
29
29
|
|
30
|
-
@inject(Migrations.Clickhouse) public clickhouse: Migrations.Clickhouse;
|
30
|
+
@inject(Migrations.Clickhouse) public readonly clickhouse: Migrations.Clickhouse;
|
31
31
|
|
32
|
-
@inject(Migrations.Amqp) public amqp: Migrations.Amqp;
|
32
|
+
@inject(Migrations.Amqp) public readonly amqp: Migrations.Amqp;
|
33
|
+
|
34
|
+
@inject(Migrations.SchemaRegistry)
|
35
|
+
public readonly schemaRegistry: Migrations.SchemaRegistry;
|
33
36
|
|
34
37
|
@init() protected async initialize() {
|
35
38
|
process.exit();
|
package/src/types/index.ts
CHANGED
package/src/types/migration.ts
CHANGED
@@ -31,7 +31,7 @@ export abstract class Migration {
|
|
31
31
|
this.path(...args, item),
|
32
32
|
);
|
33
33
|
} catch {
|
34
|
-
return []
|
34
|
+
return <string[]>[];
|
35
35
|
}
|
36
36
|
}
|
37
37
|
/**
|
@@ -55,7 +55,7 @@ export abstract class Migration {
|
|
55
55
|
* @description Initialize method
|
56
56
|
*/
|
57
57
|
@init() protected async initialize() {
|
58
|
-
console.
|
58
|
+
console.info(this.constructor.name);
|
59
59
|
await this.process();
|
60
60
|
}
|
61
61
|
/**
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { kebabCase } from 'lodash';
|
2
|
+
import { inject, Types } from '@biorate/inversion';
|
3
|
+
import {
|
4
|
+
ISchemaRegistryConnector,
|
5
|
+
ISchemaRegistryConfig,
|
6
|
+
ISchemaRegistryConnection,
|
7
|
+
ICompatibilities,
|
8
|
+
} from '@biorate/schema-registry';
|
9
|
+
import { Migration } from './migration';
|
10
|
+
import { SchemaRegistryWrongFileNameError } from '../errors';
|
11
|
+
/**
|
12
|
+
* @description Schema registry migration class
|
13
|
+
*/
|
14
|
+
export class SchemaRegistry extends Migration {
|
15
|
+
@inject(Types.SchemaRegistry) protected connector: ISchemaRegistryConnector;
|
16
|
+
/**
|
17
|
+
* @description Get migration type
|
18
|
+
*/
|
19
|
+
protected override get type() {
|
20
|
+
return kebabCase(this.constructor.name);
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* @description Schema registry process method realization
|
24
|
+
*/
|
25
|
+
protected async process() {
|
26
|
+
await this.forEach<
|
27
|
+
ISchemaRegistryConfig & { compatibility?: ICompatibilities },
|
28
|
+
ISchemaRegistryConnection
|
29
|
+
>(
|
30
|
+
'SchemaRegistry',
|
31
|
+
async (config, connection, paths) =>
|
32
|
+
await this.forEachPath(paths, async (file, fullName) => {
|
33
|
+
const name = fullName.split('_')?.[1]?.replace('.json', '');
|
34
|
+
if (!name) throw new SchemaRegistryWrongFileNameError(fullName);
|
35
|
+
const schema = <Record<string, unknown>>require(file);
|
36
|
+
await connection.putConfig({
|
37
|
+
subject: name,
|
38
|
+
compatibility: config.compatibility ?? 'FORWARD',
|
39
|
+
});
|
40
|
+
try {
|
41
|
+
await connection.postSubjects({
|
42
|
+
subject: name,
|
43
|
+
schema,
|
44
|
+
});
|
45
|
+
} catch {
|
46
|
+
await connection.postSubjectsVersions({
|
47
|
+
subject: name,
|
48
|
+
schema,
|
49
|
+
});
|
50
|
+
this.log(config.name, fullName);
|
51
|
+
}
|
52
|
+
}),
|
53
|
+
);
|
54
|
+
}
|
55
|
+
}
|