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

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.
@@ -1,4 +1,4 @@
1
- import { logger } from '@powersync/lib-services-framework';
1
+ import { ErrorCode, logger, ServiceError } from '@powersync/lib-services-framework';
2
2
  import { TablePattern } from '@powersync/service-sync-rules';
3
3
  import sql from 'mssql';
4
4
  import { MSSQLConnectionManager } from '../replication/MSSQLConnectionManager.js';
@@ -150,6 +150,13 @@ export async function getTablesFromPattern(
150
150
  connectionManager: MSSQLConnectionManager,
151
151
  tablePattern: TablePattern
152
152
  ): Promise<ResolvedTable[]> {
153
+ if (tablePattern.isSchemaWildcard) {
154
+ throw new ServiceError(
155
+ ErrorCode.PSYNC_R2201,
156
+ 'Schema wildcards ("%") in table patterns are not supported for SQL Server connections.'
157
+ );
158
+ }
159
+
153
160
  if (tablePattern.isWildcard) {
154
161
  const { recordset: tableResults } = await connectionManager.query(
155
162
  `
@@ -26,7 +26,7 @@ export class CDCStreamTestContext implements AsyncDisposable {
26
26
  private _cdcStream?: CDCStream;
27
27
  private abortController = new AbortController();
28
28
  private streamPromise?: Promise<void>;
29
- private syncRulesContent?: storage.PersistedSyncRulesContent;
29
+ private syncRulesContent?: storage.PersistedSyncConfigContent;
30
30
  public storage?: SyncRulesBucketStorage;
31
31
  private snapshotPromise?: Promise<void>;
32
32
  private replicationDone = false;
@@ -75,37 +75,37 @@ export class CDCStreamTestContext implements AsyncDisposable {
75
75
  }
76
76
 
77
77
  async updateSyncRules(content: string) {
78
- const syncRules = await this.factory.updateSyncRules(
78
+ const replicationStream = await this.factory.updateSyncRules(
79
79
  updateSyncRulesFromYaml(content, { validate: true, storageVersion: LEGACY_STORAGE_VERSION })
80
80
  );
81
- this.syncRulesContent = syncRules;
82
- this.storage = this.factory.getInstance(syncRules);
81
+ this.syncRulesContent = replicationStream.syncConfigContent[0];
82
+ this.storage = this.factory.getInstance(replicationStream);
83
83
  return this.storage!;
84
84
  }
85
85
 
86
86
  async loadNextSyncRules() {
87
- const syncRules = await this.factory.getNextSyncRulesContent();
88
- if (syncRules == null) {
87
+ const syncConfig = await this.factory.getDeployingSyncConfig();
88
+ if (syncConfig == null) {
89
89
  throw new Error(`Next replication stream not available`);
90
90
  }
91
91
 
92
- this.syncRulesContent = syncRules;
93
- this.storage = this.factory.getInstance(syncRules);
92
+ this.syncRulesContent = syncConfig.content;
93
+ this.storage = syncConfig.storage;
94
94
  return this.storage!;
95
95
  }
96
96
 
97
97
  async loadActiveSyncRules() {
98
- const syncRules = await this.factory.getActiveSyncRulesContent();
99
- if (syncRules == null) {
98
+ const syncConfig = await this.factory.getActiveSyncConfig();
99
+ if (syncConfig == null) {
100
100
  throw new Error(`Active replication stream not available`);
101
101
  }
102
102
 
103
- this.syncRulesContent = syncRules;
104
- this.storage = this.factory.getInstance(syncRules);
103
+ this.syncRulesContent = syncConfig.content;
104
+ this.storage = syncConfig.storage;
105
105
  return this.storage!;
106
106
  }
107
107
 
108
- private getSyncRulesContent(): storage.PersistedSyncRulesContent {
108
+ private getSyncConfigContent(): storage.PersistedSyncConfigContent {
109
109
  if (this.syncRulesContent == null) {
110
110
  throw new Error('Sync config not configured - call updateSyncRules() first');
111
111
  }
@@ -183,8 +183,8 @@ export class CDCStreamTestContext implements AsyncDisposable {
183
183
 
184
184
  async getBucketsDataBatch(buckets: Record<string, InternalOpId>, options?: { timeout?: number }) {
185
185
  let checkpoint = await this.getCheckpoint(options);
186
- const syncRules = this.getSyncRulesContent();
187
- const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(syncRules, bucket, start));
186
+ const syncConfigContent = this.getSyncConfigContent();
187
+ const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(syncConfigContent, bucket, start));
188
188
  return test_utils.fromAsync(this.storage!.getBucketDataBatch(checkpoint, map));
189
189
  }
190
190
 
@@ -196,19 +196,19 @@ export class CDCStreamTestContext implements AsyncDisposable {
196
196
  if (typeof start == 'string') {
197
197
  start = BigInt(start);
198
198
  }
199
- const syncRules = this.getSyncRulesContent();
199
+ const syncConfigContent = this.getSyncConfigContent();
200
200
  const checkpoint = await this.getCheckpoint(options);
201
- let map = [bucketRequest(syncRules, bucket, start)];
201
+ let map = [bucketRequest(syncConfigContent, bucket, start)];
202
202
  let data: OplogEntry[] = [];
203
203
  while (true) {
204
204
  const batch = this.storage!.getBucketDataBatch(checkpoint, map);
205
205
 
206
- const batches = await test_utils.fromAsync(batch);
206
+ const batches = await test_utils.getBatchArray(batch);
207
207
  data = data.concat(batches[0]?.chunkData.data ?? []);
208
208
  if (batches.length == 0 || !batches[0]!.chunkData.has_more) {
209
209
  break;
210
210
  }
211
- map = [bucketRequest(syncRules, bucket, BigInt(batches[0]!.chunkData.next_after))];
211
+ map = [bucketRequest(syncConfigContent, bucket, BigInt(batches[0]!.chunkData.next_after))];
212
212
  }
213
213
  return data;
214
214
  }
@@ -226,11 +226,11 @@ export class CDCStreamTestContext implements AsyncDisposable {
226
226
  if (typeof start == 'string') {
227
227
  start = BigInt(start);
228
228
  }
229
- const { checkpoint } = await this.storage!.getCheckpoint();
230
- const syncRules = this.getSyncRulesContent();
231
- const map = [bucketRequest(syncRules, bucket, start)];
229
+ const checkpoint = await this.storage!.getCheckpoint();
230
+ const syncConfigContent = this.getSyncConfigContent();
231
+ const map = [bucketRequest(syncConfigContent, bucket, start)];
232
232
  const batch = this.storage!.getBucketDataBatch(checkpoint, map);
233
- const batches = await test_utils.fromAsync(batch);
233
+ const batches = await test_utils.getBatchArray(batch);
234
234
  return batches[0]?.chunkData.data ?? [];
235
235
  }
236
236
  }
package/test/src/util.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as types from '@module/types/types.js';
2
2
  import { logger } from '@powersync/lib-services-framework';
3
- import { BucketStorageFactory, InternalOpId, ReplicationCheckpoint, TestStorageConfig } from '@powersync/service-core';
3
+ import { BucketStorageFactory, ReplicationCheckpoint, TestStorageConfig } from '@powersync/service-core';
4
4
 
5
5
  import * as mongo_storage from '@powersync/service-module-mongodb-storage';
6
6
  import * as postgres_storage from '@powersync/service-module-postgres-storage';
@@ -194,7 +194,7 @@ export async function getClientCheckpoint(
194
194
  connectionManager: MSSQLConnectionManager,
195
195
  storageFactory: BucketStorageFactory,
196
196
  options?: { timeout?: number }
197
- ): Promise<InternalOpId> {
197
+ ): Promise<ReplicationCheckpoint> {
198
198
  const start = Date.now();
199
199
 
200
200
  const lsn = await getLatestLSN(connectionManager);
@@ -208,13 +208,13 @@ export async function getClientCheckpoint(
208
208
 
209
209
  logger.info(`Test Assertion: Waiting for LSN checkpoint: ${lsn}`);
210
210
  while (Date.now() - start < timeout) {
211
- const storage = await storageFactory.getActiveStorage();
211
+ const storage = (await storageFactory.getActiveSyncConfig())?.storage;
212
212
  const cp = await storage?.getCheckpoint();
213
213
  if (cp != null) {
214
214
  lastCp = cp;
215
215
  if (cp.lsn != null && cp.lsn >= lsn.toString()) {
216
216
  logger.info(`Test Assertion: Got write checkpoint: ${lsn} : ${cp.checkpoint}`);
217
- return cp.checkpoint;
217
+ return cp;
218
218
  }
219
219
  }
220
220
 
package/tsconfig.json CHANGED
@@ -3,9 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "rootDir": "src",
5
5
  "outDir": "dist",
6
- "esModuleInterop": true,
7
- "skipLibCheck": true,
8
- "sourceMap": true,
9
6
  "typeRoots": ["./node_modules/@types"]
10
7
  },
11
8
  "include": ["src"],