@powersync/service-module-mysql 0.0.0-dev-20241021185145 → 0.0.0-dev-20241022094219

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @powersync/service-module-mysql
2
2
 
3
- ## 0.0.0-dev-20241021185145
3
+ ## 0.0.0-dev-20241022094219
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -12,7 +12,7 @@
12
12
  - Updated dependencies [d2ece1b]
13
13
  - Updated dependencies [d51921f]
14
14
  - Updated dependencies [4ecaee2]
15
- - @powersync/service-core@0.0.0-dev-20241021185145
16
- - @powersync/lib-services-framework@0.0.0-dev-20241021185145
17
- - @powersync/service-sync-rules@0.0.0-dev-20241021185145
18
- - @powersync/service-types@0.0.0-dev-20241021185145
15
+ - @powersync/service-core@0.0.0-dev-20241022094219
16
+ - @powersync/lib-services-framework@0.0.0-dev-20241022094219
17
+ - @powersync/service-sync-rules@0.0.0-dev-20241022094219
18
+ - @powersync/service-types@0.0.0-dev-20241022094219
package/dist/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- import { MySQLModule } from './module/MySQLModule.js';
2
- export declare const module: MySQLModule;
3
- export default module;
1
+ export * from './module/MySQLModule.js';
package/dist/index.js CHANGED
@@ -1,4 +1,2 @@
1
- import { MySQLModule } from './module/MySQLModule.js';
2
- export const module = new MySQLModule();
3
- export default module;
1
+ export * from './module/MySQLModule.js';
4
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;AAExC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { api, replication, system, TearDownOptions } from '@powersync/service-core';
2
2
  import * as types from '../types/types.js';
3
+ import { MySQLConnectionConfig } from '../types/types.js';
3
4
  export declare class MySQLModule extends replication.ReplicationModule<types.MySQLConnectionConfig> {
4
5
  constructor();
5
6
  initialize(context: system.ServiceContextContainer): Promise<void>;
@@ -10,4 +11,5 @@ export declare class MySQLModule extends replication.ReplicationModule<types.MyS
10
11
  */
11
12
  private resolveConfig;
12
13
  teardown(options: TearDownOptions): Promise<void>;
14
+ testConnection(config: MySQLConnectionConfig): Promise<void>;
13
15
  }
@@ -4,6 +4,8 @@ import { BinLogReplicator } from '../replication/BinLogReplicator.js';
4
4
  import { MySQLErrorRateLimiter } from '../replication/MySQLErrorRateLimiter.js';
5
5
  import * as types from '../types/types.js';
6
6
  import { MySQLConnectionManagerFactory } from '../replication/MySQLConnectionManagerFactory.js';
7
+ import { checkSourceConfiguration } from '../common/check-source-configuration.js';
8
+ import { MySQLConnectionManager } from '../replication/MySQLConnectionManager.js';
7
9
  export class MySQLModule extends replication.ReplicationModule {
8
10
  constructor() {
9
11
  super({
@@ -42,5 +44,20 @@ export class MySQLModule extends replication.ReplicationModule {
42
44
  async teardown(options) {
43
45
  // No specific teardown required for MySQL
44
46
  }
47
+ async testConnection(config) {
48
+ this.decodeConfig(config);
49
+ const normalisedConfig = this.resolveConfig(this.decodedConfig);
50
+ const connectionManager = new MySQLConnectionManager(normalisedConfig, {});
51
+ const connection = await connectionManager.getConnection();
52
+ try {
53
+ const errors = await checkSourceConfiguration(connection);
54
+ if (errors.length > 0) {
55
+ throw new Error(errors.join('\n'));
56
+ }
57
+ }
58
+ finally {
59
+ await connectionManager.end();
60
+ }
61
+ }
45
62
  }
46
63
  //# sourceMappingURL=MySQLModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MySQLModule.js","sourceRoot":"","sources":["../../src/module/MySQLModule.ts"],"names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;YACrC,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,iBAAiB,CAAC,GAAG,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@powersync/service-module-mysql",
3
3
  "repository": "https://github.com/powersync-ja/powersync-service",
4
4
  "types": "dist/index.d.ts",
5
- "version": "0.0.0-dev-20241021185145",
5
+ "version": "0.0.0-dev-20241022094219",
6
6
  "license": "FSL-1.1-Apache-2.0",
7
7
  "main": "dist/index.js",
8
8
  "type": "module",
@@ -29,10 +29,10 @@
29
29
  "ts-codec": "^1.2.2",
30
30
  "uri-js": "^4.4.1",
31
31
  "uuid": "^9.0.1",
32
- "@powersync/lib-services-framework": "0.0.0-dev-20241021185145",
33
- "@powersync/service-core": "0.0.0-dev-20241021185145",
34
- "@powersync/service-sync-rules": "0.0.0-dev-20241021185145",
35
- "@powersync/service-types": "0.0.0-dev-20241021185145"
32
+ "@powersync/lib-services-framework": "0.0.0-dev-20241022094219",
33
+ "@powersync/service-core": "0.0.0-dev-20241022094219",
34
+ "@powersync/service-sync-rules": "0.0.0-dev-20241022094219",
35
+ "@powersync/service-types": "0.0.0-dev-20241022094219"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/semver": "^7.5.4",
@@ -1,7 +1,7 @@
1
1
  import mysqlPromise from 'mysql2/promise';
2
2
  import * as mysql_utils from '../utils/mysql_utils.js';
3
3
 
4
- export async function checkSourceConfiguration(connection: mysqlPromise.Connection) {
4
+ export async function checkSourceConfiguration(connection: mysqlPromise.Connection): Promise<string[]> {
5
5
  const errors: string[] = [];
6
6
  const [[result]] = await mysql_utils.retriedQuery({
7
7
  connection,
package/src/index.ts CHANGED
@@ -1,5 +1 @@
1
- import { MySQLModule } from './module/MySQLModule.js';
2
-
3
- export const module = new MySQLModule();
4
-
5
- export default module;
1
+ export * from './module/MySQLModule.js';
@@ -5,6 +5,9 @@ import { BinLogReplicator } from '../replication/BinLogReplicator.js';
5
5
  import { MySQLErrorRateLimiter } from '../replication/MySQLErrorRateLimiter.js';
6
6
  import * as types from '../types/types.js';
7
7
  import { MySQLConnectionManagerFactory } from '../replication/MySQLConnectionManagerFactory.js';
8
+ import { MySQLConnectionConfig } from '../types/types.js';
9
+ import { checkSourceConfiguration } from '../common/check-source-configuration.js';
10
+ import { MySQLConnectionManager } from '../replication/MySQLConnectionManager.js';
8
11
 
9
12
  export class MySQLModule extends replication.ReplicationModule<types.MySQLConnectionConfig> {
10
13
  constructor() {
@@ -50,4 +53,19 @@ export class MySQLModule extends replication.ReplicationModule<types.MySQLConnec
50
53
  async teardown(options: TearDownOptions): Promise<void> {
51
54
  // No specific teardown required for MySQL
52
55
  }
56
+
57
+ async testConnection(config: MySQLConnectionConfig): Promise<void> {
58
+ this.decodeConfig(config);
59
+ const normalisedConfig = this.resolveConfig(this.decodedConfig!);
60
+ const connectionManager = new MySQLConnectionManager(normalisedConfig, {});
61
+ const connection = await connectionManager.getConnection();
62
+ try {
63
+ const errors = await checkSourceConfiguration(connection);
64
+ if (errors.length > 0) {
65
+ throw new Error(errors.join('\n'));
66
+ }
67
+ } finally {
68
+ await connectionManager.end();
69
+ }
70
+ }
53
71
  }