@powersync/service-module-mssql 0.8.3 → 0.10.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/CHANGELOG.md +113 -0
- package/dist/api/MSSQLRouteAPIAdapter.d.ts +2 -2
- package/dist/api/MSSQLRouteAPIAdapter.js +33 -39
- package/dist/api/MSSQLRouteAPIAdapter.js.map +1 -1
- package/dist/common/MSSQLSourceTable.d.ts +12 -2
- package/dist/common/MSSQLSourceTable.js +30 -4
- package/dist/common/MSSQLSourceTable.js.map +1 -1
- package/dist/module/MSSQLModule.js +2 -1
- package/dist/module/MSSQLModule.js.map +1 -1
- package/dist/replication/CDCPoller.d.ts +13 -36
- package/dist/replication/CDCPoller.js +173 -129
- package/dist/replication/CDCPoller.js.map +1 -1
- package/dist/replication/CDCStream.d.ts +11 -14
- package/dist/replication/CDCStream.js +109 -103
- package/dist/replication/CDCStream.js.map +1 -1
- package/dist/replication/CaptureReconciler.d.ts +47 -0
- package/dist/replication/CaptureReconciler.js +155 -0
- package/dist/replication/CaptureReconciler.js.map +1 -0
- package/dist/replication/MSSQLConnectionManager.d.ts +1 -0
- package/dist/replication/MSSQLConnectionManager.js +19 -14
- package/dist/replication/MSSQLConnectionManager.js.map +1 -1
- package/dist/replication/MSSQLTableReconciliationContext.d.ts +21 -0
- package/dist/replication/MSSQLTableReconciliationContext.js +7 -0
- package/dist/replication/MSSQLTableReconciliationContext.js.map +1 -0
- package/dist/replication/SchemaChange.d.ts +67 -0
- package/dist/replication/SchemaChange.js +31 -0
- package/dist/replication/SchemaChange.js.map +1 -0
- package/dist/types/types.d.ts +13 -0
- package/dist/types/types.js +28 -2
- package/dist/types/types.js.map +1 -1
- package/dist/utils/mssql.js +1 -1
- package/dist/utils/schema.d.ts +14 -1
- package/dist/utils/schema.js +43 -45
- package/dist/utils/schema.js.map +1 -1
- package/package.json +9 -9
- package/src/api/MSSQLRouteAPIAdapter.ts +36 -46
- package/src/common/MSSQLSourceTable.ts +32 -4
- package/src/module/MSSQLModule.ts +2 -1
- package/src/replication/CDCPoller.ts +206 -162
- package/src/replication/CDCStream.ts +142 -151
- package/src/replication/CaptureReconciler.ts +186 -0
- package/src/replication/MSSQLConnectionManager.ts +23 -14
- package/src/replication/MSSQLTableReconciliationContext.ts +29 -0
- package/src/replication/SchemaChange.ts +79 -0
- package/src/types/types.ts +47 -2
- package/src/utils/mssql.ts +1 -1
- package/src/utils/schema.ts +60 -54
- package/test/src/CDCPoller.test.ts +382 -0
- package/test/src/CDCStream.test.ts +6 -2
- package/test/src/CDCStreamTestContext.ts +9 -2
- package/test/src/CaptureReconciler.test.ts +171 -0
- package/test/src/MSSQLSourceTable.test.ts +30 -0
- package/test/src/config.test.ts +71 -0
- package/test/src/schema-changes.test.ts +513 -249
- package/test/src/schema.test.ts +17 -0
- package/test/src/util.ts +70 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createConnectionPoolConfig } from '@module/replication/MSSQLConnectionManager.js';
|
|
2
|
+
import { normalizeConnectionConfig } from '@module/types/types.js';
|
|
3
|
+
import { describe, expect, test } from 'vitest';
|
|
4
|
+
|
|
5
|
+
const BASE_CONFIG = {
|
|
6
|
+
type: 'mssql' as const,
|
|
7
|
+
uri: 'mssql://user:password@localhost:1433/powersync_test'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
describe('SQL Server connection config', () => {
|
|
11
|
+
test('passes a custom CA to the SQL Server TLS configuration', () => {
|
|
12
|
+
const cacert = `-----BEGIN CERTIFICATE-----
|
|
13
|
+
test certificate
|
|
14
|
+
-----END CERTIFICATE-----`;
|
|
15
|
+
const normalized = normalizeConnectionConfig({ ...BASE_CONFIG, cacert });
|
|
16
|
+
|
|
17
|
+
expect(normalized.cacert).toBe(cacert);
|
|
18
|
+
expect(createConnectionPoolConfig(normalized, {}).options).toMatchObject({
|
|
19
|
+
encrypt: true,
|
|
20
|
+
trustServerCertificate: false,
|
|
21
|
+
cryptoCredentialsDetails: { ca: cacert }
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('passes a custom TLS server name to the SQL Server TLS configuration', () => {
|
|
26
|
+
const normalized = normalizeConnectionConfig({ ...BASE_CONFIG, tls_servername: 'sql.internal.example' });
|
|
27
|
+
|
|
28
|
+
expect(createConnectionPoolConfig(normalized, {}).options?.serverName).toBe('sql.internal.example');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('rejects a custom CA when server certificate validation is disabled', () => {
|
|
32
|
+
expect(() =>
|
|
33
|
+
normalizeConnectionConfig({
|
|
34
|
+
...BASE_CONFIG,
|
|
35
|
+
cacert: 'certificate',
|
|
36
|
+
additionalConfig: { trustServerCertificate: true }
|
|
37
|
+
})
|
|
38
|
+
).toThrow(/cacert cannot be used with trustServerCertificate/);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('does not configure a custom TLS context without a custom CA', () => {
|
|
42
|
+
const normalized = normalizeConnectionConfig(BASE_CONFIG);
|
|
43
|
+
|
|
44
|
+
expect(createConnectionPoolConfig(normalized, {}).options?.cryptoCredentialsDetails).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('defaults heartbeat_interval_seconds to 60 seconds', () => {
|
|
48
|
+
expect(normalizeConnectionConfig(BASE_CONFIG).heartbeat_interval_seconds).toBe(60);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('uses the default for a null heartbeat_interval_seconds', () => {
|
|
52
|
+
expect(
|
|
53
|
+
normalizeConnectionConfig({ ...BASE_CONFIG, heartbeat_interval_seconds: null }).heartbeat_interval_seconds
|
|
54
|
+
).toBe(60);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('allows the SQL Server maximum heartbeat interval', () => {
|
|
58
|
+
expect(
|
|
59
|
+
normalizeConnectionConfig({ ...BASE_CONFIG, heartbeat_interval_seconds: 60 }).heartbeat_interval_seconds
|
|
60
|
+
).toBe(60);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test.each([0, 4, 61, Number.NaN, Number.POSITIVE_INFINITY])(
|
|
64
|
+
'rejects invalid heartbeat_interval_seconds: %s',
|
|
65
|
+
(heartbeat_interval_seconds) => {
|
|
66
|
+
expect(() => normalizeConnectionConfig({ ...BASE_CONFIG, heartbeat_interval_seconds })).toThrow(
|
|
67
|
+
'heartbeat_interval_seconds'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
});
|