@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.
Files changed (33) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/dist/module/MSSQLModule.js +1 -1
  3. package/dist/module/MSSQLModule.js.map +1 -1
  4. package/dist/replication/CDCPoller.d.ts +2 -2
  5. package/dist/replication/CDCPoller.js +2 -2
  6. package/dist/replication/CDCPoller.js.map +1 -1
  7. package/dist/replication/CDCReplicationJob.d.ts +2 -2
  8. package/dist/replication/CDCReplicationJob.js +1 -1
  9. package/dist/replication/CDCReplicationJob.js.map +1 -1
  10. package/dist/replication/CDCReplicator.d.ts +2 -2
  11. package/dist/replication/CDCReplicator.js +1 -1
  12. package/dist/replication/CDCReplicator.js.map +1 -1
  13. package/dist/replication/CDCStream.d.ts +2 -2
  14. package/dist/replication/CDCStream.js +2 -2
  15. package/dist/replication/CDCStream.js.map +1 -1
  16. package/dist/replication/MSSQLConnectionManager.js +1 -1
  17. package/dist/replication/MSSQLConnectionManager.js.map +1 -1
  18. package/dist/types/types.d.ts +34 -22
  19. package/dist/types/types.js +22 -21
  20. package/dist/types/types.js.map +1 -1
  21. package/package.json +9 -9
  22. package/src/module/MSSQLModule.ts +1 -1
  23. package/src/replication/CDCPoller.ts +4 -4
  24. package/src/replication/CDCReplicationJob.ts +3 -3
  25. package/src/replication/CDCReplicator.ts +3 -3
  26. package/src/replication/CDCStream.ts +4 -4
  27. package/src/replication/MSSQLConnectionManager.ts +1 -1
  28. package/src/types/types.ts +39 -41
  29. package/test/src/CDCStream.test.ts +1 -7
  30. package/test/src/CDCStreamTestContext.ts +5 -5
  31. package/test/src/CDCStream_resumable_snapshot.test.ts +1 -2
  32. package/test/src/util.ts +5 -1
  33. 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 { CDCPollingOptions } from '../types/types.js';
5
+ import { AdditionalConfig } from '../types/types.js';
6
6
 
7
7
  export interface CDCReplicatorOptions extends replication.AbstractReplicatorOptions {
8
8
  connectionFactory: MSSQLConnectionManagerFactory;
9
- pollingOptions: CDCPollingOptions;
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
- pollingOptions: this.cdcReplicatorOptions.pollingOptions
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 { CDCPollingOptions } from '../types/types.js';
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
- pollingOptions: CDCPollingOptions;
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
- pollingOptions: this.options.pollingOptions,
593
- logger: this.logger
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
  }
@@ -63,23 +63,44 @@ export const DefaultAuthentication = t.object({
63
63
  });
64
64
  export type DefaultAuthentication = t.Decoded<typeof DefaultAuthentication>;
65
65
 
66
- export type AuthenticationType =
67
- | DefaultAuthentication
68
- | AzureActiveDirectoryPasswordAuthentication
69
- | AzureActiveDirectoryServicePrincipalSecret;
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
- export interface CDCPollingOptions {
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
- batchSize: number;
91
+ pollingBatchSize: number;
77
92
  /**
78
- * Interval in milliseconds to wait between polling cycles. Defaults to 1 second.
93
+ * Whether to trust the server certificate. Set to true for local development and self-signed certificates.
94
+ * Default is false.
79
95
  */
80
- intervalMs: number;
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
- cdcPollingOptions: t.object({
122
- batchSize: t.number.optional(),
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
- cdcPollingOptions: {
207
- /**
208
- * Maximum number of transactions to poll per polling cycle. Defaults to 10.
209
- */
210
- batchSize: options.cdcPollingOptions?.batchSize ?? 10,
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
- pollingOptions: {
114
- batchSize: 10,
115
- intervalMs: 1000
116
- } satisfies CDCPollingOptions,
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
- trustServerCertificate: true
40
+ additionalConfig: {
41
+ pollingBatchSize: 10,
42
+ pollingIntervalMs: 1000,
43
+ trustServerCertificate: true
44
+ }
41
45
  });
42
46
 
43
47
  /**