@powersync/service-module-mssql 0.0.0-dev-20251128080741 → 0.0.0-dev-20251128112734
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 +6 -6
- package/dist/module/MSSQLModule.js +1 -1
- package/dist/module/MSSQLModule.js.map +1 -1
- package/dist/replication/CDCPoller.d.ts +2 -2
- package/dist/replication/CDCPoller.js +2 -2
- package/dist/replication/CDCPoller.js.map +1 -1
- package/dist/replication/CDCReplicationJob.d.ts +2 -2
- package/dist/replication/CDCReplicationJob.js +1 -1
- package/dist/replication/CDCReplicationJob.js.map +1 -1
- package/dist/replication/CDCReplicator.d.ts +2 -2
- package/dist/replication/CDCReplicator.js +1 -1
- package/dist/replication/CDCReplicator.js.map +1 -1
- package/dist/replication/CDCStream.d.ts +2 -2
- package/dist/replication/CDCStream.js +2 -2
- package/dist/replication/CDCStream.js.map +1 -1
- package/dist/replication/MSSQLConnectionManager.js +1 -1
- package/dist/replication/MSSQLConnectionManager.js.map +1 -1
- package/dist/types/types.d.ts +34 -22
- package/dist/types/types.js +22 -21
- package/dist/types/types.js.map +1 -1
- package/package.json +9 -9
- package/src/module/MSSQLModule.ts +1 -1
- package/src/replication/CDCPoller.ts +4 -4
- package/src/replication/CDCReplicationJob.ts +3 -3
- package/src/replication/CDCReplicator.ts +3 -3
- package/src/replication/CDCStream.ts +4 -4
- package/src/replication/MSSQLConnectionManager.ts +1 -1
- package/src/types/types.ts +39 -41
- package/test/src/CDCStream.test.ts +1 -7
- package/test/src/CDCStreamTestContext.ts +5 -5
- package/test/src/CDCStream_resumable_snapshot.test.ts +1 -2
- package/test/src/util.ts +5 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,11 +2,11 @@ import { replication, storage } from '@powersync/service-core';
|
|
|
2
2
|
import { MSSQLConnectionManagerFactory } from './MSSQLConnectionManagerFactory.js';
|
|
3
3
|
import { CDCReplicationJob } from './CDCReplicationJob.js';
|
|
4
4
|
import { MSSQLModule } from '../module/MSSQLModule.js';
|
|
5
|
-
import {
|
|
5
|
+
import { AdditionalConfig } from '../types/types.js';
|
|
6
6
|
|
|
7
7
|
export interface CDCReplicatorOptions extends replication.AbstractReplicatorOptions {
|
|
8
8
|
connectionFactory: MSSQLConnectionManagerFactory;
|
|
9
|
-
|
|
9
|
+
additionalConfig: AdditionalConfig;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export class CDCReplicator extends replication.AbstractReplicator<CDCReplicationJob> {
|
|
@@ -27,7 +27,7 @@ export class CDCReplicator extends replication.AbstractReplicator<CDCReplication
|
|
|
27
27
|
lock: options.lock,
|
|
28
28
|
connectionFactory: this.connectionFactory,
|
|
29
29
|
rateLimiter: this.rateLimiter,
|
|
30
|
-
|
|
30
|
+
additionalConfig: this.cdcReplicatorOptions.additionalConfig
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ import { LSN } from '../common/LSN.js';
|
|
|
39
39
|
import { MSSQLSourceTable } from '../common/MSSQLSourceTable.js';
|
|
40
40
|
import { MSSQLSourceTableCache } from '../common/MSSQLSourceTableCache.js';
|
|
41
41
|
import { CDCEventHandler, CDCPoller } from './CDCPoller.js';
|
|
42
|
-
import {
|
|
42
|
+
import { AdditionalConfig } from '../types/types.js';
|
|
43
43
|
|
|
44
44
|
export interface CDCStreamOptions {
|
|
45
45
|
connections: MSSQLConnectionManager;
|
|
@@ -54,7 +54,7 @@ export interface CDCStreamOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
snapshotBatchSize?: number;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
additionalConfig: AdditionalConfig;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export enum SnapshotStatus {
|
|
@@ -589,8 +589,8 @@ export class CDCStream {
|
|
|
589
589
|
eventHandler,
|
|
590
590
|
sourceTables,
|
|
591
591
|
startLSN,
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
logger: this.logger,
|
|
593
|
+
additionalConfig: this.options.additionalConfig
|
|
594
594
|
});
|
|
595
595
|
|
|
596
596
|
this.abortSignal.addEventListener(
|
|
@@ -31,7 +31,7 @@ export class MSSQLConnectionManager extends BaseObserver<MSSQLConnectionManagerL
|
|
|
31
31
|
options: {
|
|
32
32
|
appName: `powersync/${POWERSYNC_VERSION}`,
|
|
33
33
|
encrypt: true, // Required for Azure
|
|
34
|
-
trustServerCertificate: options.trustServerCertificate
|
|
34
|
+
trustServerCertificate: options.additionalConfig.trustServerCertificate
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}
|
package/src/types/types.ts
CHANGED
|
@@ -63,23 +63,44 @@ export const DefaultAuthentication = t.object({
|
|
|
63
63
|
});
|
|
64
64
|
export type DefaultAuthentication = t.Decoded<typeof DefaultAuthentication>;
|
|
65
65
|
|
|
66
|
-
export
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
export const AdditionalConfig = t.object({
|
|
67
|
+
/**
|
|
68
|
+
* Interval in milliseconds to wait between polling cycles. Defaults to 1000 milliseconds.
|
|
69
|
+
*/
|
|
70
|
+
pollingIntervalMs: t.number.optional(),
|
|
71
|
+
/**
|
|
72
|
+
* Maximum number of transactions to poll per polling cycle. Defaults to 10.
|
|
73
|
+
*/
|
|
74
|
+
pollingBatchSize: t.number.optional(),
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Whether to trust the server certificate. Set to true for local development and self-signed certificates.
|
|
78
|
+
* Default is false.
|
|
79
|
+
*/
|
|
80
|
+
trustServerCertificate: t.boolean.optional()
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export interface AdditionalConfig {
|
|
84
|
+
/**
|
|
85
|
+
* Interval in milliseconds to wait between polling cycles. Defaults to 1000 milliseconds.
|
|
86
|
+
*/
|
|
87
|
+
pollingIntervalMs: number;
|
|
73
88
|
/**
|
|
74
89
|
* Maximum number of transactions to poll per polling cycle. Defaults to 10.
|
|
75
90
|
*/
|
|
76
|
-
|
|
91
|
+
pollingBatchSize: number;
|
|
77
92
|
/**
|
|
78
|
-
*
|
|
93
|
+
* Whether to trust the server certificate. Set to true for local development and self-signed certificates.
|
|
94
|
+
* Default is false.
|
|
79
95
|
*/
|
|
80
|
-
|
|
96
|
+
trustServerCertificate: boolean;
|
|
81
97
|
}
|
|
82
98
|
|
|
99
|
+
export type AuthenticationType =
|
|
100
|
+
| DefaultAuthentication
|
|
101
|
+
| AzureActiveDirectoryPasswordAuthentication
|
|
102
|
+
| AzureActiveDirectoryServicePrincipalSecret;
|
|
103
|
+
|
|
83
104
|
export interface NormalizedMSSQLConnectionConfig {
|
|
84
105
|
id: string;
|
|
85
106
|
tag: string;
|
|
@@ -93,14 +114,9 @@ export interface NormalizedMSSQLConnectionConfig {
|
|
|
93
114
|
|
|
94
115
|
authentication?: AuthenticationType;
|
|
95
116
|
|
|
96
|
-
cdcPollingOptions: CDCPollingOptions;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Whether to trust the server certificate. Set to true for local development and self-signed certificates.
|
|
100
|
-
* Default is false.
|
|
101
|
-
*/
|
|
102
|
-
trustServerCertificate: boolean;
|
|
103
117
|
lookup?: LookupFunction;
|
|
118
|
+
|
|
119
|
+
additionalConfig: AdditionalConfig;
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
export const MSSQLConnectionConfig = service_types.configFile.DataSourceConfig.and(
|
|
@@ -118,18 +134,8 @@ export const MSSQLConnectionConfig = service_types.configFile.DataSourceConfig.a
|
|
|
118
134
|
.or(AzureActiveDirectoryServicePrincipalSecret)
|
|
119
135
|
.optional(),
|
|
120
136
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
intervalMs: t.number.optional()
|
|
124
|
-
}).optional(),
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Whether to trust the server certificate. Set to true for local development and self-signed certificates.
|
|
128
|
-
* Default is false.
|
|
129
|
-
*/
|
|
130
|
-
trustServerCertificate: t.boolean.optional(),
|
|
131
|
-
|
|
132
|
-
reject_ip_ranges: t.array(t.string).optional()
|
|
137
|
+
reject_ip_ranges: t.array(t.string).optional(),
|
|
138
|
+
additionalConfig: AdditionalConfig.optional()
|
|
133
139
|
})
|
|
134
140
|
);
|
|
135
141
|
|
|
@@ -203,19 +209,11 @@ export function normalizeConnectionConfig(options: MSSQLConnectionConfig): Norma
|
|
|
203
209
|
lookup,
|
|
204
210
|
authentication: options.authentication,
|
|
205
211
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Interval in milliseconds to wait between polling cycles. Defaults to 1 second.
|
|
214
|
-
*/
|
|
215
|
-
intervalMs: options.cdcPollingOptions?.intervalMs ?? 1000,
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
trustServerCertificate: options.trustServerCertificate ?? false,
|
|
212
|
+
additionalConfig: {
|
|
213
|
+
pollingIntervalMs: options.additionalConfig?.pollingIntervalMs ?? 1000,
|
|
214
|
+
pollingBatchSize: options.additionalConfig?.pollingBatchSize ?? 10,
|
|
215
|
+
trustServerCertificate: options.additionalConfig?.trustServerCertificate ?? false
|
|
216
|
+
}
|
|
219
217
|
} satisfies NormalizedMSSQLConnectionConfig;
|
|
220
218
|
}
|
|
221
219
|
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
2
|
import { METRICS_HELPER, putOp, removeOp } from '@powersync/service-core-tests';
|
|
3
3
|
import { ReplicationMetric } from '@powersync/service-types';
|
|
4
|
-
import {
|
|
5
|
-
createTestTable,
|
|
6
|
-
describeWithStorage,
|
|
7
|
-
INITIALIZED_MONGO_STORAGE_FACTORY,
|
|
8
|
-
insertTestData,
|
|
9
|
-
waitForPendingCDCChanges
|
|
10
|
-
} from './util.js';
|
|
4
|
+
import { createTestTable, describeWithStorage, insertTestData, waitForPendingCDCChanges } from './util.js';
|
|
11
5
|
import { storage } from '@powersync/service-core';
|
|
12
6
|
import { CDCStreamTestContext } from './CDCStreamTestContext.js';
|
|
13
7
|
import { getLatestReplicatedLSN } from '@module/utils/mssql.js';
|
|
@@ -12,7 +12,6 @@ import { clearTestDb, getClientCheckpoint, TEST_CONNECTION_OPTIONS } from './uti
|
|
|
12
12
|
import { CDCStream, CDCStreamOptions } from '@module/replication/CDCStream.js';
|
|
13
13
|
import { MSSQLConnectionManager } from '@module/replication/MSSQLConnectionManager.js';
|
|
14
14
|
import timers from 'timers/promises';
|
|
15
|
-
import { CDCPollingOptions } from '@module/types/types.js';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Tests operating on the change data capture need to configure the stream and manage asynchronous
|
|
@@ -110,10 +109,11 @@ export class CDCStreamTestContext implements AsyncDisposable {
|
|
|
110
109
|
metrics: METRICS_HELPER.metricsEngine,
|
|
111
110
|
connections: this.connectionManager,
|
|
112
111
|
abortSignal: this.abortController.signal,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
additionalConfig: {
|
|
113
|
+
pollingBatchSize: 10,
|
|
114
|
+
pollingIntervalMs: 1000,
|
|
115
|
+
trustServerCertificate: true
|
|
116
|
+
},
|
|
117
117
|
...this.cdcStreamOptions
|
|
118
118
|
};
|
|
119
119
|
this._cdcStream = new CDCStream(options);
|
|
@@ -46,10 +46,9 @@ async function testResumingReplication(factory: TestStorageFactory, stopAfter: n
|
|
|
46
46
|
await createTestTableWithBasicId(connectionManager, 'test_data1');
|
|
47
47
|
await createTestTableWithBasicId(connectionManager, 'test_data2');
|
|
48
48
|
|
|
49
|
-
let beforeLSN = await getLatestReplicatedLSN(connectionManager);
|
|
50
49
|
await connectionManager.query(`INSERT INTO test_data1(description) SELECT 'value' FROM GENERATE_SERIES(1, 1000, 1)`);
|
|
50
|
+
let beforeLSN = await getLatestReplicatedLSN(connectionManager);
|
|
51
51
|
await connectionManager.query(`INSERT INTO test_data2(description) SELECT 'value' FROM GENERATE_SERIES(1, 10000, 1)`);
|
|
52
|
-
|
|
53
52
|
await waitForPendingCDCChanges(beforeLSN, connectionManager);
|
|
54
53
|
|
|
55
54
|
const p = context.replicateSnapshot();
|
package/test/src/util.ts
CHANGED
|
@@ -37,7 +37,11 @@ export function describeWithStorage(options: TestOptions, fn: (factory: TestStor
|
|
|
37
37
|
export const TEST_CONNECTION_OPTIONS = types.normalizeConnectionConfig({
|
|
38
38
|
type: 'mssql',
|
|
39
39
|
uri: TEST_URI,
|
|
40
|
-
|
|
40
|
+
additionalConfig: {
|
|
41
|
+
pollingBatchSize: 10,
|
|
42
|
+
pollingIntervalMs: 1000,
|
|
43
|
+
trustServerCertificate: true
|
|
44
|
+
}
|
|
41
45
|
});
|
|
42
46
|
|
|
43
47
|
/**
|