@powersync/service-module-mssql 0.0.0-dev-20260602073133 → 0.0.0-dev-20260909133214

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 (64) hide show
  1. package/CHANGELOG.md +209 -4
  2. package/dist/api/MSSQLRouteAPIAdapter.d.ts +4 -5
  3. package/dist/api/MSSQLRouteAPIAdapter.js +33 -39
  4. package/dist/api/MSSQLRouteAPIAdapter.js.map +1 -1
  5. package/dist/common/MSSQLSourceTable.d.ts +12 -2
  6. package/dist/common/MSSQLSourceTable.js +30 -4
  7. package/dist/common/MSSQLSourceTable.js.map +1 -1
  8. package/dist/module/MSSQLModule.js +2 -1
  9. package/dist/module/MSSQLModule.js.map +1 -1
  10. package/dist/replication/CDCPoller.d.ts +13 -36
  11. package/dist/replication/CDCPoller.js +173 -129
  12. package/dist/replication/CDCPoller.js.map +1 -1
  13. package/dist/replication/CDCReplicationJob.js +1 -1
  14. package/dist/replication/CDCReplicationJob.js.map +1 -1
  15. package/dist/replication/CDCReplicator.js +1 -1
  16. package/dist/replication/CDCReplicator.js.map +1 -1
  17. package/dist/replication/CDCStream.d.ts +11 -14
  18. package/dist/replication/CDCStream.js +124 -115
  19. package/dist/replication/CDCStream.js.map +1 -1
  20. package/dist/replication/CaptureReconciler.d.ts +47 -0
  21. package/dist/replication/CaptureReconciler.js +155 -0
  22. package/dist/replication/CaptureReconciler.js.map +1 -0
  23. package/dist/replication/MSSQLConnectionManager.d.ts +1 -0
  24. package/dist/replication/MSSQLConnectionManager.js +19 -14
  25. package/dist/replication/MSSQLConnectionManager.js.map +1 -1
  26. package/dist/replication/MSSQLTableReconciliationContext.d.ts +21 -0
  27. package/dist/replication/MSSQLTableReconciliationContext.js +7 -0
  28. package/dist/replication/MSSQLTableReconciliationContext.js.map +1 -0
  29. package/dist/replication/SchemaChange.d.ts +67 -0
  30. package/dist/replication/SchemaChange.js +31 -0
  31. package/dist/replication/SchemaChange.js.map +1 -0
  32. package/dist/types/types.d.ts +13 -0
  33. package/dist/types/types.js +28 -2
  34. package/dist/types/types.js.map +1 -1
  35. package/dist/utils/mssql.js +1 -1
  36. package/dist/utils/schema.d.ts +14 -1
  37. package/dist/utils/schema.js +43 -45
  38. package/dist/utils/schema.js.map +1 -1
  39. package/package.json +11 -21
  40. package/src/api/MSSQLRouteAPIAdapter.ts +38 -49
  41. package/src/common/MSSQLSourceTable.ts +32 -4
  42. package/src/module/MSSQLModule.ts +2 -1
  43. package/src/replication/CDCPoller.ts +206 -162
  44. package/src/replication/CDCReplicationJob.ts +1 -1
  45. package/src/replication/CDCReplicator.ts +1 -1
  46. package/src/replication/CDCStream.ts +157 -163
  47. package/src/replication/CaptureReconciler.ts +186 -0
  48. package/src/replication/MSSQLConnectionManager.ts +23 -14
  49. package/src/replication/MSSQLTableReconciliationContext.ts +29 -0
  50. package/src/replication/SchemaChange.ts +79 -0
  51. package/src/types/types.ts +47 -2
  52. package/src/utils/mssql.ts +1 -1
  53. package/src/utils/schema.ts +60 -54
  54. package/test/src/CDCPoller.test.ts +382 -0
  55. package/test/src/CDCStream.test.ts +6 -2
  56. package/test/src/CDCStreamTestContext.ts +30 -23
  57. package/test/src/CaptureReconciler.test.ts +171 -0
  58. package/test/src/MSSQLSourceTable.test.ts +30 -0
  59. package/test/src/config.test.ts +71 -0
  60. package/test/src/schema-changes.test.ts +513 -249
  61. package/test/src/schema.test.ts +17 -0
  62. package/test/src/util.ts +73 -9
  63. package/tsconfig.json +0 -3
  64. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,209 @@
1
1
  # @powersync/service-module-mssql
2
2
 
3
- ## 0.0.0-dev-20260602073133
3
+ ## 0.0.0-dev-20260909133214
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [70b00a4]
8
+ - @powersync/service-sync-rules@0.0.0-dev-20260909133214
9
+ - @powersync/lib-services-framework@0.0.0-dev-20260909133214
10
+ - @powersync/service-core@0.0.0-dev-20260909133214
11
+
12
+ ## 0.10.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 4e4063b: Optimize runtime type checks, closes https://github.com/powersync-ja/powersync-service/issues/771.
17
+ - 2407f71: Apply timeouts and abortSignal handling to all S3 operations. The broad timeouts can be configured using the new `storage.object_storage.defaults_mode` option, or the `AWS_DEFAULTS_MODE` environment variable. Upgrade S3 SDK to fix further timeout issues.
18
+ - Updated dependencies [e11c54b]
19
+ - Updated dependencies [4b6a23e]
20
+ - Updated dependencies [189bd9e]
21
+ - Updated dependencies [bb08068]
22
+ - Updated dependencies [0077a8d]
23
+ - Updated dependencies [332d649]
24
+ - Updated dependencies [33a3c23]
25
+ - Updated dependencies [fccdff2]
26
+ - Updated dependencies [989d9e1]
27
+ - Updated dependencies [646c0de]
28
+ - Updated dependencies [cc121b3]
29
+ - Updated dependencies [4e4063b]
30
+ - Updated dependencies [2407f71]
31
+ - Updated dependencies [10131ca]
32
+ - Updated dependencies [4037e8f]
33
+ - Updated dependencies [3972bac]
34
+ - Updated dependencies [dd7a22f]
35
+ - Updated dependencies [a997c88]
36
+ - @powersync/service-core@1.26.0
37
+ - @powersync/service-sync-rules@0.41.0
38
+ - @powersync/service-types@0.18.0
39
+ - @powersync/lib-services-framework@0.10.1
40
+
41
+ ## 0.10.0
42
+
43
+ ### Minor Changes
44
+
45
+ - 3ca835d: Add custom CA certificate support for MSSQL connections.
46
+
47
+ The new `cacert` option allows PowerSync to validate SQL Server certificates issued by a private CA
48
+ without enabling `trustServerCertificate`. An optional `tls_servername` can be specified when the connection
49
+ hostname differs from the name in the server certificate.
50
+
51
+ - 798d739: Pin MSSQL source-table bindings to a specific CDC capture instance.
52
+
53
+ A source table now persists the object ID of the CDC change table it replicates from, and restores that
54
+ binding across restarts, so a stream always replicates the capture schema it started with. Existing
55
+ bindings without this metadata are backfilled at job startup with the same capture instance the previous
56
+ streaming logic would have selected.
57
+
58
+ SQL Server allows two capture instances per table. When a newer one appears, the current replication
59
+ process keeps polling the instance it is bound to and warns. Deploy a new sync config to use the newer
60
+ instance; the active sync config can continue serving clients through the old instance while the new sync
61
+ config snapshots and catches up. Keep the old instance available until the new sync config becomes active.
62
+
63
+ If CDC is disabled for a bound table, or its capture instance is removed while the source table and replica
64
+ identity remain unchanged, replication stops with `PSYNC_S1601`. A newly configured table that cannot be
65
+ replicated yet — it does not exist, or CDC has not been enabled for it — stops replication with
66
+ `PSYNC_S1602` rather than being skipped. Dropping, recreating, or otherwise changing the source identity of
67
+ a previously bound table stops replication with `PSYNC_S1603`.
68
+
69
+ - 798d739: [Breaking Change]
70
+
71
+ Pin the replicated schema at the start of replication for SQL Server connections.
72
+
73
+ SQL Server does not deliver schema changes in the replication stream, so they can only be found by
74
+ polling, and a poll is never atomic with a commit. That leaves a gap where checkpoints are committed
75
+ against a schema that has already changed — producing a state the source database was never in, which
76
+ clients cannot detect. PowerSync therefore no longer adopts schema changes automatically.
77
+
78
+ The recommended schema-change workflow treats a sync config deployment as the consistency boundary. A
79
+ replication stream keeps the exact table set and CDC capture-instance identities it selected when it
80
+ started; it does not adopt schema or table changes in place. Tables must therefore be listed explicitly
81
+ rather than selected with wildcards.
82
+
83
+ What this means when making schema changes:
84
+
85
+ - **Add a table:** create the table, enable CDC, add its exact qualified name to the sync config, and
86
+ deploy a new sync config. The new sync config snapshots the table before becoming active.
87
+ - **Change captured columns:** where SQL Server allows a rolling change, apply the DDL and create a second
88
+ capture instance with the desired captured columns. Update explicit sync queries if needed, deploy a
89
+ new sync config, wait for its snapshots to finish and for it to become active, and only then remove the
90
+ old capture instance.
91
+ - **Make an identity-breaking change:** for a primary-key change, identity-column rename, or another
92
+ change that requires CDC to be disabled, disable CDC, apply the DDL, re-enable CDC, update the sync
93
+ config if needed, and deploy a new sync config. The current replication process cannot adopt the
94
+ replacement in place, so this results in downtime. If it observes CDC being disabled first, it stops
95
+ with `PSYNC_S1601` because its capture instance was removed. If it next reconciles after the replica
96
+ identity has changed, it stops with `PSYNC_S1603` instead. Disabling and re-enabling CDC without changing
97
+ the replica identity stops with `PSYNC_S1601`.
98
+ - **Drop a table:** remove it from the sync config, deploy a new sync config and wait for it to become
99
+ active, and only then drop the source table. Dropping the table first stops replication with
100
+ `PSYNC_S1603`; already-replicated data is retained until the new sync config becomes active.
101
+ - **Rename or drop/recreate a table:** update the sync config to express the intended table explicitly,
102
+ ensure the resulting table is CDC-enabled with the expected schema and replica identity, and deploy a
103
+ new sync config. The current replication process stops with `PSYNC_S1603` if its bound table is removed.
104
+ - **No deployment is needed** for changes that do not affect the captured row shape or replica identity,
105
+ such as many index, constraint, or default changes. A non-identity column change also needs no PowerSync
106
+ action if that changed column does not need to be replicated; otherwise use the rolling capture-instance
107
+ workflow above.
108
+
109
+ This sequencing keeps the old table or capture instance available while the new sync config snapshots and
110
+ becomes active whenever a rolling transition is possible. If a pinned capture instance or bound table is
111
+ removed first, the current replication process stops and a new sync config must be deployed.
112
+
113
+ - 9d0b129: MSSQL CDCPoller improvements and fixes:
114
+
115
+ - Ensure correct ordering of CDC results which previously could cause inconsistencies when handling deferred updates
116
+ - Correctly count processed transactions in each polling cycle
117
+ - CDC polling query now streams results
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [27b56cb]
122
+ - Updated dependencies [798d739]
123
+ - @powersync/service-core@1.25.0
124
+
125
+ ## 0.9.0
126
+
127
+ ### Minor Changes
128
+
129
+ - 087b61e: Configurable heartbeat_interval_seconds for MongoDB, Postgres, SQL Server.
130
+ - 2189250: Add `/sync/checkpoint-request` for client-supplied checkpoint request ids, previously called write checkpoint ids. The route returns the stored `checkpoint_request_id`, storage now treats managed request ids as monotonic per user/client, custom checkpoint request ids continue to use the existing `checkpoint` field for backwards compatibility, and `checkpoint_requested_at` metadata lets compact jobs remove expired request-derived checkpoint records.
131
+
132
+ This release includes storage migrations for the checkpoint request metadata. Self-hosters should run migrations as part of the upgrade.
133
+
134
+ ### Patch Changes
135
+
136
+ - be42e25: Throw a clear error (`PSYNC_R2201`) when a schema wildcard is used in a table pattern with MongoDB, MySQL, SQL Server or Convex connections, instead of silently discovering no tables.
137
+ - Updated dependencies [087b61e]
138
+ - Updated dependencies [2189250]
139
+ - Updated dependencies [922f974]
140
+ - Updated dependencies [c4860c9]
141
+ - Updated dependencies [483415d]
142
+ - Updated dependencies [8daa300]
143
+ - Updated dependencies [aab068b]
144
+ - Updated dependencies [37591e9]
145
+ - Updated dependencies [be42e25]
146
+ - Updated dependencies [be42e25]
147
+ - Updated dependencies [cb4c627]
148
+ - @powersync/service-core@1.24.0
149
+ - @powersync/lib-services-framework@0.10.0
150
+ - @powersync/service-types@0.17.0
151
+ - @powersync/service-sync-rules@0.40.0
152
+ - @powersync/service-errors@0.5.0
153
+
154
+ ## 0.8.3
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies [ea71bf3]
159
+ - Updated dependencies [ea31f64]
160
+ - Updated dependencies [edc6ed4]
161
+ - @powersync/service-sync-rules@0.39.0
162
+ - @powersync/service-core@1.23.3
163
+ - @powersync/lib-services-framework@0.9.8
164
+
165
+ ## 0.8.2
166
+
167
+ ### Patch Changes
168
+
169
+ - e4f683d: [MongoDB Storage] Add experimental option to allow reading data from secondaries.
170
+ - Updated dependencies [71d4a0a]
171
+ - Updated dependencies [e4f683d]
172
+ - Updated dependencies [71d4a0a]
173
+ - Updated dependencies [a6ae678]
174
+ - Updated dependencies [c2edf86]
175
+ - Updated dependencies [df9ab1e]
176
+ - @powersync/service-core@1.23.2
177
+ - @powersync/service-sync-rules@0.38.1
178
+ - @powersync/service-types@0.16.1
179
+ - @powersync/lib-services-framework@0.9.7
180
+
181
+ ## 0.8.1
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [7e65360]
186
+ - @powersync/service-core@1.23.1
187
+
188
+ ## 0.8.0
189
+
190
+ ### Minor Changes
191
+
192
+ - a91a08f: [Experimental] Enable incremental reprocessing for MongoDB source + MongoDB storage. This includes significant changes to the v3 storage format.
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [a91a08f]
197
+ - Updated dependencies [184c39f]
198
+ - Updated dependencies [c3f75df]
199
+ - Updated dependencies [4bd35ea]
200
+ - @powersync/service-core@1.23.0
201
+ - @powersync/service-types@0.16.0
202
+ - @powersync/service-errors@0.4.4
203
+ - @powersync/service-sync-rules@0.38.0
204
+ - @powersync/lib-services-framework@0.9.6
205
+
206
+ ## 0.7.0
4
207
 
5
208
  ### Minor Changes
6
209
 
@@ -10,6 +213,7 @@
10
213
  ### Patch Changes
11
214
 
12
215
  - 6e2a57e: Refactor HydratedSyncConfig to support multiple SyncConfigs.
216
+ - Updated dependencies [17fd96b]
13
217
  - Updated dependencies [6e2a57e]
14
218
  - Updated dependencies [ec6df9f]
15
219
  - Updated dependencies [99d33d5]
@@ -22,11 +226,12 @@
22
226
  - Updated dependencies [92cc83b]
23
227
  - Updated dependencies [0aab0f9]
24
228
  - Updated dependencies [15e2466]
229
+ - Updated dependencies [ebeaa3b]
25
230
  - Updated dependencies [b116857]
26
231
  - Updated dependencies [a94b6c3]
27
- - @powersync/service-sync-rules@0.0.0-dev-20260602073133
28
- - @powersync/service-core@0.0.0-dev-20260602073133
29
- - @powersync/lib-services-framework@0.0.0-dev-20260602073133
232
+ - @powersync/service-core@1.22.0
233
+ - @powersync/service-sync-rules@0.37.0
234
+ - @powersync/lib-services-framework@0.9.5
30
235
 
31
236
  ## 0.6.4
32
237
 
@@ -1,19 +1,18 @@
1
- import { api, ParseSyncRulesOptions, PatternResult, ReplicationHeadCallback, ReplicationLagOptions } from '@powersync/service-core';
1
+ import { api, ParseSyncConfigOptions, PatternResult, ReplicationLagOptions } from '@powersync/service-core';
2
2
  import { SqlSyncRules, TablePattern } from '@powersync/service-sync-rules';
3
3
  import * as service_types from '@powersync/service-types';
4
- import { ExecuteSqlResponse } from '@powersync/service-types/dist/routes.js';
5
4
  import { MSSQLConnectionManager } from '../replication/MSSQLConnectionManager.js';
6
5
  import * as types from '../types/types.js';
7
6
  export declare class MSSQLRouteAPIAdapter implements api.RouteAPI {
8
7
  protected config: types.ResolvedMSSQLConnectionConfig;
9
8
  protected connectionManager: MSSQLConnectionManager;
10
9
  constructor(config: types.ResolvedMSSQLConnectionConfig);
11
- createReplicationHead<T>(callback: ReplicationHeadCallback<T>): Promise<T>;
12
- executeQuery(query: string, params: any[]): Promise<ExecuteSqlResponse>;
10
+ createReplicationHead<T>(callback: api.ReplicationHeadCallback<T>): Promise<T>;
11
+ executeQuery(query: string, params: any[]): Promise<service_types.internal_routes.ExecuteSqlResponse>;
13
12
  getConnectionSchema(): Promise<service_types.DatabaseSchema[]>;
14
13
  getConnectionStatus(): Promise<service_types.ConnectionStatusV2>;
15
14
  getDebugTablesInfo(tablePatterns: TablePattern[], sqlSyncRules: SqlSyncRules): Promise<PatternResult[]>;
16
- getParseSyncRulesOptions(): ParseSyncRulesOptions;
15
+ getParseSyncRulesOptions(): ParseSyncConfigOptions;
17
16
  getReplicationLagBytes(options: ReplicationLagOptions): Promise<number | undefined>;
18
17
  getSourceConfig(): Promise<service_types.configFile.ResolvedDataSourceConfig>;
19
18
  [Symbol.asyncDispose](): Promise<void>;
@@ -4,7 +4,7 @@ import { toExpressionTypeFromMSSQLType } from '../common/mssqls-to-sqlite.js';
4
4
  import { MSSQLConnectionManager } from '../replication/MSSQLConnectionManager.js';
5
5
  import * as types from '../types/types.js';
6
6
  import { checkSourceConfiguration, createCheckpoint, getDebugTableInfo, getLatestLSN, POWERSYNC_CHECKPOINTS_TABLE } from '../utils/mssql.js';
7
- import { getTablesFromPattern } from '../utils/schema.js';
7
+ import { getTablesFromPattern, unsupportedTablePatternMessage } from '../utils/schema.js';
8
8
  export class MSSQLRouteAPIAdapter {
9
9
  config;
10
10
  connectionManager;
@@ -13,11 +13,13 @@ export class MSSQLRouteAPIAdapter {
13
13
  this.connectionManager = new MSSQLConnectionManager(config, {});
14
14
  }
15
15
  async createReplicationHead(callback) {
16
- const currentLSN = await getLatestLSN(this.connectionManager);
17
- const result = await callback(currentLSN.toString());
18
- // Updates the powersync checkpoints table on the source database, ensuring that an update with a newer LSN will be captured by the CDC.
19
- await createCheckpoint(this.connectionManager);
20
- return result;
16
+ const currentLSN = (await getLatestLSN(this.connectionManager)).toString();
17
+ const { response, shouldAdvance } = await callback(currentLSN);
18
+ if (shouldAdvance) {
19
+ // Updates the powersync checkpoints table on the source database, ensuring that an update with a newer LSN will be captured by the CDC.
20
+ await createCheckpoint(this.connectionManager);
21
+ }
22
+ return response;
21
23
  }
22
24
  async executeQuery(query, params) {
23
25
  return service_types.internal_routes.ExecuteSqlResponse.encode({
@@ -152,43 +154,35 @@ export class MSSQLRouteAPIAdapter {
152
154
  wildcard: tablePattern.isWildcard
153
155
  };
154
156
  result.push(patternResult);
155
- const tables = await getTablesFromPattern(this.connectionManager, tablePattern);
156
- if (tablePattern.isWildcard) {
157
- patternResult.tables = [];
158
- for (const table of tables) {
159
- const details = await getDebugTableInfo({
160
- connectionManager: this.connectionManager,
161
- tablePattern,
162
- table,
163
- syncRules: sqlSyncRules
164
- });
165
- patternResult.tables.push(details);
166
- }
167
- }
168
- else {
169
- if (tables.length == 0) {
170
- // This should technically never happen, but we'll handle it anyway.
171
- const resolvedTable = {
172
- objectId: 0,
173
- schema: schema,
174
- name: tablePattern.name
175
- };
176
- patternResult.table = await getDebugTableInfo({
177
- connectionManager: this.connectionManager,
178
- tablePattern,
179
- table: resolvedTable,
180
- syncRules: sqlSyncRules
181
- });
157
+ // Unsupported patterns are reported per pattern here, rather than failing the whole request.
158
+ const unsupported = unsupportedTablePatternMessage(tablePattern);
159
+ if (unsupported != null) {
160
+ const unsupportedTable = {
161
+ schema,
162
+ name: tablePattern.tablePattern,
163
+ pattern: tablePattern.tablePattern,
164
+ replication_id: [],
165
+ data_queries: false,
166
+ parameter_queries: false,
167
+ errors: [{ level: 'fatal', message: unsupported }]
168
+ };
169
+ if (patternResult.wildcard) {
170
+ patternResult.tables = [unsupportedTable];
182
171
  }
183
172
  else {
184
- patternResult.table = await getDebugTableInfo({
185
- connectionManager: this.connectionManager,
186
- tablePattern,
187
- table: tables[0],
188
- syncRules: sqlSyncRules
189
- });
173
+ patternResult.table = unsupportedTable;
190
174
  }
175
+ continue;
191
176
  }
177
+ const tables = await getTablesFromPattern(this.connectionManager, tablePattern);
178
+ // A missing table is still reported, so that its errors are surfaced.
179
+ const resolvedTable = tables[0] ?? { objectId: 0, schema: schema, name: tablePattern.name };
180
+ patternResult.table = await getDebugTableInfo({
181
+ connectionManager: this.connectionManager,
182
+ tablePattern,
183
+ table: resolvedTable,
184
+ syncRules: sqlSyncRules
185
+ });
192
186
  }
193
187
  return result;
194
188
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MSSQLRouteAPIAdapter.js","sourceRoot":"","sources":["../../src/api/MSSQLRouteAPIAdapter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAE1D,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,2BAA2B,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAiB,MAAM,oBAAoB,CAAC;AAEzE,MAAM,OAAO,oBAAoB;IAGT;IAFZ,iBAAiB,CAAyB;IAEpD,YAAsB,MAA2C;QAA3C,WAAM,GAAN,MAAM,CAAqC;QAC/D,IAAI,CAAC,iBAAiB,GAAG,IAAI,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAI,QAAoC;QACjE,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9D,MAAM,MA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,MAAM;SAC7C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,OAA8B;QACzD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;CACF"}
@@ -19,12 +19,22 @@ export declare class MSSQLSourceTable {
19
19
  */
20
20
  readonly sourceTables: SourceTable[];
21
21
  readonly ref: SourceEntityDescriptor;
22
+ /**
23
+ * Decoded once, since the persisted metadata only changes when a SourceTable is replaced.
24
+ */
25
+ private captureObjectId;
22
26
  constructor(ref: SourceEntityDescriptor, sourceTables: SourceTable[]);
23
27
  updateSourceTable(updated: SourceTable): void;
24
28
  getReplicatedSourceTables(): SourceTable[];
25
29
  enabledForCDC(): boolean;
26
- setCaptureInstance(captureInstance: CaptureInstance): void;
27
- clearCaptureInstance(): void;
30
+ /**
31
+ * Persisted capture-table object id, or null for a legacy binding.
32
+ */
33
+ get pinnedCaptureObjectId(): number | null;
34
+ /**
35
+ * Bind the available capture instance matching this table's persisted identity.
36
+ */
37
+ setCaptureInstance(availableInstances: readonly CaptureInstance[]): void;
28
38
  get allChangesFunction(): string;
29
39
  get netChangesFunction(): string;
30
40
  /**
@@ -1,4 +1,5 @@
1
1
  import { ServiceAssertionError } from '@powersync/service-errors';
2
+ import { readCaptureMetadata } from '../replication/CaptureReconciler.js';
2
3
  import { toQualifiedTableName } from '../utils/mssql.js';
3
4
  /**
4
5
  * The cdc schema in SQL Server is reserved and created when enabling CDC on a database.
@@ -19,9 +20,14 @@ export class MSSQLSourceTable {
19
20
  */
20
21
  sourceTables;
21
22
  ref;
23
+ /**
24
+ * Decoded once, since the persisted metadata only changes when a SourceTable is replaced.
25
+ */
26
+ captureObjectId;
22
27
  constructor(ref, sourceTables) {
23
28
  this.sourceTables = sourceTables;
24
29
  this.ref = ref;
30
+ this.captureObjectId = readPinnedCaptureObjectId(sourceTables);
25
31
  }
26
32
  updateSourceTable(updated) {
27
33
  const index = this.sourceTables.findIndex((table) => table.id == updated.id);
@@ -29,6 +35,7 @@ export class MSSQLSourceTable {
29
35
  throw new ServiceAssertionError(`No SourceTable found for table: ${updated.id}`);
30
36
  }
31
37
  this.sourceTables[index] = updated;
38
+ this.captureObjectId = readPinnedCaptureObjectId(this.sourceTables);
32
39
  }
33
40
  getReplicatedSourceTables() {
34
41
  return this.sourceTables.filter((sourceTable) => sourceTable.syncAny);
@@ -36,11 +43,18 @@ export class MSSQLSourceTable {
36
43
  enabledForCDC() {
37
44
  return this.captureInstance !== null;
38
45
  }
39
- setCaptureInstance(captureInstance) {
40
- this.captureInstance = captureInstance;
46
+ /**
47
+ * Persisted capture-table object id, or null for a legacy binding.
48
+ */
49
+ get pinnedCaptureObjectId() {
50
+ return this.captureObjectId;
41
51
  }
42
- clearCaptureInstance() {
43
- this.captureInstance = null;
52
+ /**
53
+ * Bind the available capture instance matching this table's persisted identity.
54
+ */
55
+ setCaptureInstance(availableInstances) {
56
+ this.captureInstance =
57
+ availableInstances.find((instance) => instance.objectId === this.pinnedCaptureObjectId) ?? null;
44
58
  }
45
59
  get allChangesFunction() {
46
60
  if (!this.captureInstance) {
@@ -68,4 +82,16 @@ export class MSSQLSourceTable {
68
82
  return toQualifiedTableName(this.ref.schema, this.ref.name);
69
83
  }
70
84
  }
85
+ /**
86
+ * The pinned capture-table object id shared by these records, or null for a legacy binding.
87
+ */
88
+ function readPinnedCaptureObjectId(sourceTables) {
89
+ for (const sourceTable of sourceTables) {
90
+ const metadata = readCaptureMetadata(sourceTable.sourceMetadata);
91
+ if (metadata != null) {
92
+ return metadata.captureTableObjectId;
93
+ }
94
+ }
95
+ return null;
96
+ }
71
97
  //# sourceMappingURL=MSSQLSourceTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSSQLSourceTable.js","sourceRoot":"","sources":["../../src/common/MSSQLSourceTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACI,eAAe,GAA2B,IAAI,CAAC;IAEtD;;OAEG;IACa,YAAY,CAAgB;IAE5B,GAAG,CAAyB;IAE5C,YAAY,GAA2B,EAAE,YAA2B;QAClE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,iBAAiB,CAAC,OAAoB;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7E,IAAI,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,qBAAqB,CAAC,mCAAmC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACrC,CAAC;IAED,yBAAyB;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC;IACvC,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACz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kB;QACpB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAqB,CAAC,sCAAsC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,GAAG,UAAU,2BAA2B,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC7E,CAAC;IAED,IAAI,kBAAkB;QACpB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAqB,CAAC,sCAAsC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,GAAG,UAAU,2BAA2B,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,QAAkB,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAC,YAA2B;IAC5D,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACjE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC,oBAAoB,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -29,7 +29,8 @@ export class MSSQLModule extends replication.ReplicationModule {
29
29
  metricsEngine: context.metricsEngine,
30
30
  connectionFactory: connectionFactory,
31
31
  rateLimiter: new MSSQLErrorRateLimiter(),
32
- additionalConfig: normalisedConfig.additionalConfig
32
+ additionalConfig: normalisedConfig.additionalConfig,
33
+ heartbeatIntervalSeconds: normalisedConfig.heartbeat_interval_seconds
33
34
  });
34
35
  }
35
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MSSQLModule.js","sourceRoot":"","sources":["../../src/module/MSSQLModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kCAAkC,EAElC,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,OAAO,WAAY,SAAQ,WAAW,CAAC,iBAA8C;IACzF;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,KAAK,CAAC,qBAAqB;YACjC,YAAY,EAAE,KAAK,CAAC,qBAAqB;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAuC,IAAkB,CAAC;IAEpE,qBAAqB;QAC7B,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAc,CAAC,CAAC,CAAC;IAC3E,CAAC;IAES,gBAAgB,CAAC,OAA8B;QACvD,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAc,CAAC,CAAC;QACjE,MAAM,gBAAgB,GAAG,IAAI,kCAAkC,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAClG,MAAM,iBAAiB,GAAG,IAAI,6BAA6B,CAAC,gBAAgB,CAAC,C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;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,iBAAiB,CAAC,GAAG,EAAE,CAAC;QAChC,CAAC;QACD,OAAO;YACL,qBAAqB,EAAE,gBAAgB,CAAC,QAAQ;SACjD,CAAC;IACJ,CAAC;CACF"}
@@ -1,32 +1,11 @@
1
1
  import { Logger } from '@powersync/lib-services-framework';
2
- import { TablePattern } from '@powersync/service-sync-rules';
3
2
  import sql from 'mssql';
4
- import { CaptureInstance } from '../common/CaptureInstance.js';
5
3
  import { LSN } from '../common/LSN.js';
6
4
  import { MSSQLSourceTable } from '../common/MSSQLSourceTable.js';
7
5
  import { AdditionalConfig } from '../types/types.js';
8
- import { SourceTableChangeRef } from '../utils/schema.js';
9
6
  import { MSSQLConnectionManager } from './MSSQLConnectionManager.js';
10
- export declare enum SchemaChangeType {
11
- TABLE_RENAME = "table_rename",
12
- TABLE_DROP = "table_drop",
13
- TABLE_CREATE = "table_create",
14
- TABLE_COLUMN_CHANGES = "table_column_changes",
15
- NEW_CAPTURE_INSTANCE = "new_capture_instance",
16
- MISSING_CAPTURE_INSTANCE = "missing_capture_instance"
17
- }
18
- export interface SchemaChange {
19
- type: SchemaChangeType;
20
- /**
21
- * The table that the schema change applies to. Populated for table drops, renames, new capture instances, and DDL changes.
22
- */
23
- table?: MSSQLSourceTable;
24
- /**
25
- * Populated for new tables or renames, but only if the new table matches a sync config source table.
26
- */
27
- newTable?: SourceTableChangeRef;
28
- newCaptureInstance?: CaptureInstance;
29
- }
7
+ import { SchemaChange } from './SchemaChange.js';
8
+ export declare const DEFAULT_SCHEMA_CHECK_INTERVAL_MS = 60000;
30
9
  export interface CDCEventHandler {
31
10
  onInsert: (row: any, table: MSSQLSourceTable, columns: sql.IColumnMetadata) => Promise<void>;
32
11
  onUpdate: (rowAfter: any, rowBefore: any, table: MSSQLSourceTable, columns: sql.IColumnMetadata) => Promise<void>;
@@ -34,16 +13,11 @@ export interface CDCEventHandler {
34
13
  onCommit: (lsn: string, transactionCount: number) => Promise<void>;
35
14
  onSchemaChange: (change: SchemaChange) => Promise<void>;
36
15
  }
37
- export declare const DEFAULT_SCHEMA_CHECK_INTERVAL_MS = 60000;
38
16
  export interface CDCPollerOptions {
39
17
  connectionManager: MSSQLConnectionManager;
40
18
  eventHandler: CDCEventHandler;
41
19
  /** CDC enabled source tables from the sync config to replicate */
42
20
  getReplicatedTables: () => MSSQLSourceTable[];
43
- /** All table patterns from the sync config. Can contain tables that need to be replicated
44
- * but do not yet have CDC enabled
45
- */
46
- sourceTables: TablePattern[];
47
21
  startLSN: LSN;
48
22
  logger?: Logger;
49
23
  additionalConfig: AdditionalConfig;
@@ -55,16 +29,20 @@ export interface CDCPollerOptions {
55
29
  schemaCheckIntervalMs?: number;
56
30
  }
57
31
  /**
32
+ * Polls SQL Server CDC change tables for changes at a configurable interval.
58
33
  *
34
+ * Processes changes in commit order, groups CDC rows into logical insert,
35
+ * update, and delete operations. It only commits once all the operations recorded in a polling cycle have been processed.
36
+ * Periodically runs checks to detect schema and capture-instance changes.
59
37
  */
60
38
  export declare class CDCPoller {
61
- options: CDCPollerOptions;
39
+ private options;
62
40
  private connectionManager;
63
41
  private eventHandler;
64
42
  private currentLSN;
65
43
  private logger;
66
- private listenerError;
67
44
  private captureInstances;
45
+ private pollingError;
68
46
  private isStopped;
69
47
  private isStopping;
70
48
  private isPolling;
@@ -77,13 +55,12 @@ export declare class CDCPoller {
77
55
  stop(): Promise<void>;
78
56
  replicateUntilStopped(): Promise<void>;
79
57
  private poll;
80
- private pollTable;
81
- private shouldCheckSchema;
82
58
  /**
83
- * Checks the given table for pending schema changes that can lead to inconsistencies in the replicated data if not handled.
84
- * Returns the SchemaChange if any are found, null otherwise.
59
+ * Processes the changes this table has within the given bounds, and returns the LSNs of the
60
+ * transactions those changes belong to. The LSNs are returned in their string form so that the
61
+ * caller can deduplicate them across tables by value.
85
62
  */
63
+ private pollTable;
64
+ private shouldCheckSchema;
86
65
  private checkForSchemaChanges;
87
- private checkForNewTables;
88
- private tableMatchesSyncRules;
89
66
  }