@powersync/service-module-mysql 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.
@@ -33,7 +33,7 @@ export class BinlogStreamTestContext {
33
33
  private streamPromise?: Promise<void>;
34
34
  public storage?: SyncRulesBucketStorage;
35
35
  private replicationDone = false;
36
- private syncRulesContent?: storage.PersistedSyncRulesContent;
36
+ private syncRulesContent?: storage.PersistedSyncConfigContent;
37
37
 
38
38
  static async open(factory: storage.TestStorageFactory, options?: { doNotClear?: boolean }) {
39
39
  const f = await factory({ doNotClear: options?.doNotClear });
@@ -71,38 +71,38 @@ export class BinlogStreamTestContext {
71
71
  }
72
72
 
73
73
  async updateSyncRules(content: string): Promise<SyncRulesBucketStorage> {
74
- const syncRules = await this.factory.updateSyncRules(
74
+ const replicationStream = await this.factory.updateSyncRules(
75
75
  updateSyncRulesFromYaml(content, { validate: true, storageVersion: LEGACY_STORAGE_VERSION })
76
76
  );
77
- this.syncRulesContent = syncRules;
78
- this.storage = this.factory.getInstance(syncRules);
77
+ this.syncRulesContent = replicationStream.syncConfigContent[0];
78
+ this.storage = this.factory.getInstance(replicationStream);
79
79
  return this.storage!;
80
80
  }
81
81
 
82
82
  async loadNextSyncRules() {
83
- const syncRules = await this.factory.getNextSyncRulesContent();
84
- if (syncRules == null) {
83
+ const syncConfig = await this.factory.getDeployingSyncConfig();
84
+ if (syncConfig == null) {
85
85
  throw new Error(`Next replication stream not available`);
86
86
  }
87
87
 
88
- this.syncRulesContent = syncRules;
89
- this.storage = this.factory.getInstance(syncRules);
88
+ this.syncRulesContent = syncConfig.content;
89
+ this.storage = syncConfig.storage;
90
90
  return this.storage!;
91
91
  }
92
92
 
93
93
  async loadActiveSyncRules() {
94
- const syncRules = await this.factory.getActiveSyncRulesContent();
95
- if (syncRules == null) {
94
+ const syncConfig = await this.factory.getActiveSyncConfig();
95
+ if (syncConfig == null) {
96
96
  throw new Error(`Active replication stream not available`);
97
97
  }
98
98
 
99
- this.syncRulesContent = syncRules;
100
- this.storage = this.factory.getInstance(syncRules);
99
+ this.syncRulesContent = syncConfig.content;
100
+ this.storage = syncConfig.storage;
101
101
  this.replicationDone = true;
102
102
  return this.storage!;
103
103
  }
104
104
 
105
- private getSyncRulesContent(): storage.PersistedSyncRulesContent {
105
+ private getSyncConfigContent(): storage.PersistedSyncConfigContent {
106
106
  if (this.syncRulesContent == null) {
107
107
  throw new Error('Sync config not configured - call updateSyncRules() first');
108
108
  }
@@ -148,7 +148,7 @@ export class BinlogStreamTestContext {
148
148
  });
149
149
  }
150
150
 
151
- async getCheckpoint(options?: { timeout?: number }): Promise<InternalOpId> {
151
+ async getCheckpoint(options?: { timeout?: number }): Promise<ReplicationCheckpoint> {
152
152
  const connection = await this.connectionManager.getConnection();
153
153
  let checkpoint = await Promise.race([
154
154
  getClientCheckpoint(connection, this.factory, { timeout: options?.timeout ?? 60_000 }),
@@ -165,9 +165,9 @@ export class BinlogStreamTestContext {
165
165
 
166
166
  async getBucketsDataBatch(buckets: Record<string, InternalOpId>, options?: { timeout?: number }) {
167
167
  const checkpoint = await this.getCheckpoint(options);
168
- const syncRules = this.getSyncRulesContent();
169
- const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(syncRules, bucket, start));
170
- return test_utils.fromAsync(this.storage!.getBucketDataBatch(checkpoint, map));
168
+ const syncConfigContent = this.getSyncConfigContent();
169
+ const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(syncConfigContent, bucket, start));
170
+ return test_utils.getBatchArray(this.storage!.getBucketDataBatch(checkpoint, map));
171
171
  }
172
172
 
173
173
  async getBucketData(
@@ -179,11 +179,11 @@ export class BinlogStreamTestContext {
179
179
  if (typeof start == 'string') {
180
180
  start = BigInt(start);
181
181
  }
182
- const syncRules = this.getSyncRulesContent();
182
+ const syncConfigContent = this.getSyncConfigContent();
183
183
  const checkpoint = await this.getCheckpoint(options);
184
- const map = [bucketRequest(syncRules, bucket, start)];
184
+ const map = [bucketRequest(syncConfigContent, bucket, start)];
185
185
  const batch = this.storage!.getBucketDataBatch(checkpoint, map);
186
- const batches = await test_utils.fromAsync(batch);
186
+ const batches = await test_utils.getBatchArray(batch);
187
187
  return batches[0]?.chunkData.data ?? [];
188
188
  }
189
189
  }
@@ -192,7 +192,7 @@ export async function getClientCheckpoint(
192
192
  connection: mysqlPromise.Connection,
193
193
  storageFactory: BucketStorageFactory,
194
194
  options?: { timeout?: number }
195
- ): Promise<InternalOpId> {
195
+ ): Promise<ReplicationCheckpoint> {
196
196
  const start = Date.now();
197
197
  const gtid = await readExecutedGtid(connection);
198
198
  // This old API needs a persisted checkpoint id.
@@ -203,14 +203,14 @@ export async function getClientCheckpoint(
203
203
 
204
204
  logger.info('Expected Checkpoint: ' + gtid.comparable);
205
205
  while (Date.now() - start < timeout) {
206
- const storage = await storageFactory.getActiveStorage();
206
+ const storage = (await storageFactory.getActiveSyncConfig())?.storage;
207
207
  const cp = await storage?.getCheckpoint();
208
208
  if (cp == null) {
209
209
  throw new Error('No replication stream available');
210
210
  }
211
211
  lastCp = cp;
212
212
  if (cp.lsn && cp.lsn >= gtid.comparable) {
213
- return cp.checkpoint;
213
+ return cp;
214
214
  }
215
215
 
216
216
  await new Promise((resolve) => setTimeout(resolve, 30));
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", "./src/replication/zongji.d.ts"]
10
7
  },
11
8
  "include": ["src"],