@powersync/service-core-tests 0.0.0-dev-20250827091123 → 0.0.0-dev-20250828090417

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.
@@ -7,7 +7,7 @@ import {
7
7
  utils
8
8
  } from '@powersync/service-core';
9
9
  import { JSONBig } from '@powersync/service-jsonbig';
10
- import { RequestParameters } from '@powersync/service-sync-rules';
10
+ import { BucketSourceType, RequestParameters } from '@powersync/service-sync-rules';
11
11
  import path from 'path';
12
12
  import * as timers from 'timers/promises';
13
13
  import { fileURLToPath } from 'url';
@@ -82,7 +82,10 @@ export function registerSyncTests(factory: storage.TestStorageFactory) {
82
82
  const stream = sync.streamResponse({
83
83
  syncContext,
84
84
  bucketStorage: bucketStorage,
85
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
85
+ syncRules: {
86
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
87
+ version: bucketStorage.group_id
88
+ },
86
89
  params: {
87
90
  buckets: [],
88
91
  include_checksum: true,
@@ -143,7 +146,10 @@ bucket_definitions:
143
146
  const stream = sync.streamResponse({
144
147
  syncContext,
145
148
  bucketStorage,
146
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
149
+ syncRules: {
150
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
151
+ version: bucketStorage.group_id
152
+ },
147
153
  params: {
148
154
  buckets: [],
149
155
  include_checksum: true,
@@ -206,7 +212,10 @@ bucket_definitions:
206
212
  const stream = sync.streamResponse({
207
213
  syncContext,
208
214
  bucketStorage,
209
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
215
+ syncRules: {
216
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
217
+ version: bucketStorage.group_id
218
+ },
210
219
  params: {
211
220
  buckets: [],
212
221
  include_checksum: true,
@@ -316,7 +325,10 @@ bucket_definitions:
316
325
  const stream = sync.streamResponse({
317
326
  syncContext,
318
327
  bucketStorage,
319
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
328
+ syncRules: {
329
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
330
+ version: bucketStorage.group_id
331
+ },
320
332
  params: {
321
333
  buckets: [],
322
334
  include_checksum: true,
@@ -457,7 +469,10 @@ bucket_definitions:
457
469
  const stream = sync.streamResponse({
458
470
  syncContext,
459
471
  bucketStorage,
460
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
472
+ syncRules: {
473
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
474
+ version: bucketStorage.group_id
475
+ },
461
476
  params: {
462
477
  buckets: [],
463
478
  include_checksum: true,
@@ -573,7 +588,10 @@ bucket_definitions:
573
588
  const stream = sync.streamResponse({
574
589
  syncContext,
575
590
  bucketStorage,
576
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
591
+ syncRules: {
592
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
593
+ version: bucketStorage.group_id
594
+ },
577
595
  params: {
578
596
  buckets: [],
579
597
  include_checksum: true,
@@ -639,7 +657,10 @@ bucket_definitions:
639
657
  const stream = sync.streamResponse({
640
658
  syncContext,
641
659
  bucketStorage,
642
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
660
+ syncRules: {
661
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
662
+ version: bucketStorage.group_id
663
+ },
643
664
  params: {
644
665
  buckets: [],
645
666
  include_checksum: true,
@@ -668,7 +689,10 @@ bucket_definitions:
668
689
  const stream = sync.streamResponse({
669
690
  syncContext,
670
691
  bucketStorage,
671
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
692
+ syncRules: {
693
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
694
+ version: bucketStorage.group_id
695
+ },
672
696
  params: {
673
697
  buckets: [],
674
698
  include_checksum: true,
@@ -699,7 +723,10 @@ bucket_definitions:
699
723
  const stream = sync.streamResponse({
700
724
  syncContext,
701
725
  bucketStorage,
702
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
726
+ syncRules: {
727
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
728
+ version: bucketStorage.group_id
729
+ },
703
730
  params: {
704
731
  buckets: [],
705
732
  include_checksum: true,
@@ -773,7 +800,10 @@ bucket_definitions:
773
800
  const stream = sync.streamResponse({
774
801
  syncContext,
775
802
  bucketStorage,
776
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
803
+ syncRules: {
804
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
805
+ version: bucketStorage.group_id
806
+ },
777
807
  params: {
778
808
  buckets: [],
779
809
  include_checksum: true,
@@ -849,7 +879,10 @@ bucket_definitions:
849
879
  const stream = sync.streamResponse({
850
880
  syncContext,
851
881
  bucketStorage,
852
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
882
+ syncRules: {
883
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
884
+ version: bucketStorage.group_id
885
+ },
853
886
  params: {
854
887
  buckets: [],
855
888
  include_checksum: true,
@@ -916,7 +949,10 @@ bucket_definitions:
916
949
  const stream = sync.streamResponse({
917
950
  syncContext,
918
951
  bucketStorage,
919
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
952
+ syncRules: {
953
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
954
+ version: bucketStorage.group_id
955
+ },
920
956
  params: {
921
957
  buckets: [],
922
958
  include_checksum: true,
@@ -984,7 +1020,10 @@ bucket_definitions:
984
1020
  const stream = sync.streamResponse({
985
1021
  syncContext,
986
1022
  bucketStorage,
987
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1023
+ syncRules: {
1024
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1025
+ version: bucketStorage.group_id
1026
+ },
988
1027
  params: {
989
1028
  buckets: [],
990
1029
  include_checksum: true,
@@ -1047,7 +1086,10 @@ bucket_definitions:
1047
1086
  const stream = sync.streamResponse({
1048
1087
  syncContext,
1049
1088
  bucketStorage,
1050
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1089
+ syncRules: {
1090
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1091
+ version: bucketStorage.group_id
1092
+ },
1051
1093
  params: {
1052
1094
  buckets: [],
1053
1095
  include_checksum: true,
@@ -1173,7 +1215,10 @@ bucket_definitions:
1173
1215
  const params: sync.SyncStreamParameters = {
1174
1216
  syncContext,
1175
1217
  bucketStorage,
1176
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1218
+ syncRules: {
1219
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1220
+ version: bucketStorage.group_id
1221
+ },
1177
1222
  params: {
1178
1223
  buckets: [],
1179
1224
  include_checksum: true,
@@ -1211,6 +1256,59 @@ bucket_definitions:
1211
1256
  })
1212
1257
  });
1213
1258
  });
1259
+
1260
+ test('encodes sync rules id in buckes for streams', async () => {
1261
+ await using f = await factory();
1262
+ const rules = `
1263
+ streams:
1264
+ test:
1265
+ auto_subscribe: true
1266
+ query: SELECT * FROM test;
1267
+
1268
+ config:
1269
+ edition: 2
1270
+ `;
1271
+
1272
+ for (let i = 0; i < 2; i++) {
1273
+ const syncRules = await f.updateSyncRules({
1274
+ content: rules
1275
+ });
1276
+ const bucketStorage = f.getInstance(syncRules);
1277
+
1278
+ await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
1279
+ await batch.save({
1280
+ sourceTable: TEST_TABLE,
1281
+ tag: storage.SaveOperationTag.INSERT,
1282
+ after: {
1283
+ id: 't1',
1284
+ description: 'Test 1'
1285
+ },
1286
+ afterReplicaId: 't1'
1287
+ });
1288
+ await batch.commit('0/1');
1289
+ });
1290
+
1291
+ const stream = sync.streamResponse({
1292
+ syncContext,
1293
+ bucketStorage: bucketStorage,
1294
+ syncRules: {
1295
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1296
+ version: bucketStorage.group_id
1297
+ },
1298
+ params: {
1299
+ buckets: [],
1300
+ include_checksum: true,
1301
+ raw_data: true
1302
+ },
1303
+ tracker,
1304
+ token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
1305
+ isEncodingAsBson: false
1306
+ });
1307
+
1308
+ const lines = await consumeCheckpointLines(stream);
1309
+ expect(lines).toMatchSnapshot();
1310
+ }
1311
+ });
1214
1312
  }
1215
1313
 
1216
1314
  /**
@@ -4,4 +4,3 @@ export * from './register-parameter-compacting-tests.js';
4
4
  export * from './register-data-storage-tests.js';
5
5
  export * from './register-migration-tests.js';
6
6
  export * from './register-sync-tests.js';
7
- export * from './register-report-tests.js';