@powersync/service-core-tests 0.15.5 → 0.17.0
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.
- package/CHANGELOG.md +44 -0
- package/dist/test-utils/AbstractStreamTestContext.d.ts +52 -0
- package/dist/test-utils/AbstractStreamTestContext.js +147 -0
- package/dist/test-utils/AbstractStreamTestContext.js.map +1 -0
- package/dist/test-utils/StorageDataHelpers.d.ts +3 -3
- package/dist/test-utils/StorageDataHelpers.js.map +1 -1
- package/dist/test-utils/general-utils.d.ts +13 -8
- package/dist/test-utils/general-utils.js +39 -25
- package/dist/test-utils/general-utils.js.map +1 -1
- package/dist/test-utils/test-utils-index.d.ts +1 -0
- package/dist/test-utils/test-utils-index.js +1 -0
- package/dist/test-utils/test-utils-index.js.map +1 -1
- package/dist/tests/register-compacting-tests.js +15 -8
- package/dist/tests/register-compacting-tests.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +104 -75
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-data-storage-parameter-tests.js +48 -47
- package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
- package/dist/tests/register-sync-tests.js +6 -3
- package/dist/tests/register-sync-tests.js.map +1 -1
- package/dist/tests/util.d.ts +3 -4
- package/dist/tests/util.js +8 -5
- package/dist/tests/util.js.map +1 -1
- package/package.json +5 -5
- package/src/test-utils/AbstractStreamTestContext.ts +183 -0
- package/src/test-utils/StorageDataHelpers.ts +4 -4
- package/src/test-utils/general-utils.ts +52 -34
- package/src/test-utils/test-utils-index.ts +1 -0
- package/src/tests/register-compacting-tests.ts +15 -8
- package/src/tests/register-data-storage-data-tests.ts +130 -77
- package/src/tests/register-data-storage-parameter-tests.ts +62 -47
- package/src/tests/register-sync-tests.ts +6 -3
- package/src/tests/util.ts +14 -11
- package/tsconfig.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -26,7 +26,8 @@ export function registerDataStorageParameterTests(config: storage.TestStorageCon
|
|
|
26
26
|
|
|
27
27
|
test('save and load parameters', async () => {
|
|
28
28
|
await using factory = await generateStorageFactory();
|
|
29
|
-
const syncRules = await
|
|
29
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
30
|
+
factory,
|
|
30
31
|
updateSyncRulesFromYaml(
|
|
31
32
|
`
|
|
32
33
|
bucket_definitions:
|
|
@@ -40,8 +41,8 @@ bucket_definitions:
|
|
|
40
41
|
}
|
|
41
42
|
)
|
|
42
43
|
);
|
|
43
|
-
const bucketStorage = factory.getInstance(
|
|
44
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
44
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
45
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
45
46
|
|
|
46
47
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
47
48
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -92,7 +93,8 @@ bucket_definitions:
|
|
|
92
93
|
|
|
93
94
|
test('it should use the latest version', async () => {
|
|
94
95
|
await using factory = await generateStorageFactory();
|
|
95
|
-
const syncRules = await
|
|
96
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
97
|
+
factory,
|
|
96
98
|
updateSyncRulesFromYaml(
|
|
97
99
|
`
|
|
98
100
|
bucket_definitions:
|
|
@@ -106,8 +108,8 @@ bucket_definitions:
|
|
|
106
108
|
}
|
|
107
109
|
)
|
|
108
110
|
);
|
|
109
|
-
const bucketStorage = factory.getInstance(
|
|
110
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
111
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
112
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
111
113
|
|
|
112
114
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
113
115
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -163,7 +165,8 @@ bucket_definitions:
|
|
|
163
165
|
|
|
164
166
|
test('it should use the latest version after updates', async () => {
|
|
165
167
|
await using factory = await generateStorageFactory();
|
|
166
|
-
const syncRules = await
|
|
168
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
169
|
+
factory,
|
|
167
170
|
updateSyncRulesFromYaml(
|
|
168
171
|
`
|
|
169
172
|
bucket_definitions:
|
|
@@ -177,8 +180,8 @@ bucket_definitions:
|
|
|
177
180
|
{ storageVersion }
|
|
178
181
|
)
|
|
179
182
|
);
|
|
180
|
-
const bucketStorage = factory.getInstance(
|
|
181
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
183
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
184
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
182
185
|
|
|
183
186
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
184
187
|
const table = await test_utils.resolveTestTable(writer, 'todos', ['id', 'list_id'], config);
|
|
@@ -250,7 +253,8 @@ bucket_definitions:
|
|
|
250
253
|
|
|
251
254
|
test('save and load parameters with different number types', async () => {
|
|
252
255
|
await using factory = await generateStorageFactory();
|
|
253
|
-
const syncRules = await
|
|
256
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
257
|
+
factory,
|
|
254
258
|
updateSyncRulesFromYaml(
|
|
255
259
|
`
|
|
256
260
|
bucket_definitions:
|
|
@@ -264,8 +268,8 @@ bucket_definitions:
|
|
|
264
268
|
}
|
|
265
269
|
)
|
|
266
270
|
);
|
|
267
|
-
const bucketStorage = factory.getInstance(
|
|
268
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
271
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
272
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
269
273
|
|
|
270
274
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
271
275
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -318,7 +322,8 @@ bucket_definitions:
|
|
|
318
322
|
// test this to ensure correct deserialization.
|
|
319
323
|
|
|
320
324
|
await using factory = await generateStorageFactory();
|
|
321
|
-
const syncRules = await
|
|
325
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
326
|
+
factory,
|
|
322
327
|
updateSyncRulesFromYaml(
|
|
323
328
|
`
|
|
324
329
|
bucket_definitions:
|
|
@@ -332,8 +337,8 @@ bucket_definitions:
|
|
|
332
337
|
}
|
|
333
338
|
)
|
|
334
339
|
);
|
|
335
|
-
const bucketStorage = factory.getInstance(
|
|
336
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
340
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
341
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
337
342
|
|
|
338
343
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
339
344
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -385,7 +390,8 @@ bucket_definitions:
|
|
|
385
390
|
|
|
386
391
|
test('save and load parameters with workspaceId', async () => {
|
|
387
392
|
await using factory = await generateStorageFactory();
|
|
388
|
-
const syncRules = await
|
|
393
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
394
|
+
factory,
|
|
389
395
|
updateSyncRulesFromYaml(
|
|
390
396
|
`
|
|
391
397
|
bucket_definitions:
|
|
@@ -400,8 +406,8 @@ bucket_definitions:
|
|
|
400
406
|
}
|
|
401
407
|
)
|
|
402
408
|
);
|
|
403
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
404
|
-
const bucketStorage = factory.getInstance(
|
|
409
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
410
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
405
411
|
|
|
406
412
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
407
413
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', ['id'], config);
|
|
@@ -443,7 +449,8 @@ bucket_definitions:
|
|
|
443
449
|
|
|
444
450
|
test('save and load parameters with dynamic global buckets', async () => {
|
|
445
451
|
await using factory = await generateStorageFactory();
|
|
446
|
-
const syncRules = await
|
|
452
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
453
|
+
factory,
|
|
447
454
|
updateSyncRulesFromYaml(
|
|
448
455
|
`
|
|
449
456
|
bucket_definitions:
|
|
@@ -458,8 +465,8 @@ bucket_definitions:
|
|
|
458
465
|
}
|
|
459
466
|
)
|
|
460
467
|
);
|
|
461
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
462
|
-
const bucketStorage = factory.getInstance(
|
|
468
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
469
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
463
470
|
|
|
464
471
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
465
472
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
@@ -535,7 +542,8 @@ bucket_definitions:
|
|
|
535
542
|
|
|
536
543
|
test('multiple parameter queries', async () => {
|
|
537
544
|
await using factory = await generateStorageFactory();
|
|
538
|
-
const syncRules = await
|
|
545
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
546
|
+
factory,
|
|
539
547
|
updateSyncRulesFromYaml(
|
|
540
548
|
`
|
|
541
549
|
bucket_definitions:
|
|
@@ -552,8 +560,8 @@ bucket_definitions:
|
|
|
552
560
|
}
|
|
553
561
|
)
|
|
554
562
|
);
|
|
555
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
556
|
-
const bucketStorage = factory.getInstance(
|
|
563
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
564
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
557
565
|
|
|
558
566
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
559
567
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
@@ -639,7 +647,8 @@ bucket_definitions:
|
|
|
639
647
|
|
|
640
648
|
test('truncate parameters', async () => {
|
|
641
649
|
await using factory = await generateStorageFactory();
|
|
642
|
-
const syncRules = await
|
|
650
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
651
|
+
factory,
|
|
643
652
|
updateSyncRulesFromYaml(
|
|
644
653
|
`
|
|
645
654
|
bucket_definitions:
|
|
@@ -653,8 +662,8 @@ bucket_definitions:
|
|
|
653
662
|
}
|
|
654
663
|
)
|
|
655
664
|
);
|
|
656
|
-
const bucketStorage = factory.getInstance(
|
|
657
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
665
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
666
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
658
667
|
|
|
659
668
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
660
669
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -732,7 +741,8 @@ bucket_definitions:
|
|
|
732
741
|
|
|
733
742
|
test('sync streams smoke test', async () => {
|
|
734
743
|
await using factory = await generateStorageFactory();
|
|
735
|
-
const syncRules = await
|
|
744
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
745
|
+
factory,
|
|
736
746
|
updateSyncRulesFromYaml(`
|
|
737
747
|
config:
|
|
738
748
|
edition: 3
|
|
@@ -744,8 +754,8 @@ streams:
|
|
|
744
754
|
WHERE data.foo = param.bar AND param.baz = auth.user_id()
|
|
745
755
|
`)
|
|
746
756
|
);
|
|
747
|
-
const bucketStorage = factory.getInstance(
|
|
748
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
757
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
758
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
749
759
|
|
|
750
760
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
751
761
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -786,7 +796,6 @@ streams:
|
|
|
786
796
|
return parameter_sets;
|
|
787
797
|
}
|
|
788
798
|
});
|
|
789
|
-
console.log('whatabuckets', buckets);
|
|
790
799
|
expect(buckets).toHaveLength(1);
|
|
791
800
|
expect(buckets).toMatchObject([
|
|
792
801
|
{
|
|
@@ -800,7 +809,8 @@ streams:
|
|
|
800
809
|
|
|
801
810
|
test('respects parameter limit', async () => {
|
|
802
811
|
await using factory = await generateStorageFactory();
|
|
803
|
-
const syncRules = await
|
|
812
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
813
|
+
factory,
|
|
804
814
|
updateSyncRulesFromYaml(
|
|
805
815
|
`
|
|
806
816
|
config:
|
|
@@ -816,8 +826,8 @@ streams:
|
|
|
816
826
|
}
|
|
817
827
|
)
|
|
818
828
|
);
|
|
819
|
-
const bucketStorage = factory.getInstance(
|
|
820
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
829
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
830
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
821
831
|
|
|
822
832
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
823
833
|
const testTable = await test_utils.resolveTestTable(writer, 'b', ['id'], config);
|
|
@@ -852,7 +862,8 @@ streams:
|
|
|
852
862
|
|
|
853
863
|
test('sync streams store multiple parameter outputs for a single source row and lookup', async () => {
|
|
854
864
|
await using factory = await generateStorageFactory();
|
|
855
|
-
const syncRules = await
|
|
865
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
866
|
+
factory,
|
|
856
867
|
updateSyncRulesFromYaml(`
|
|
857
868
|
config:
|
|
858
869
|
edition: 3
|
|
@@ -865,8 +876,8 @@ streams:
|
|
|
865
876
|
WHERE a.x = x.value AND y.value = auth.user_id()
|
|
866
877
|
`)
|
|
867
878
|
);
|
|
868
|
-
const bucketStorage = factory.getInstance(
|
|
869
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
879
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
880
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
870
881
|
|
|
871
882
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
872
883
|
const tableB = await test_utils.resolveTestTable(writer, 'b', ['id'], config);
|
|
@@ -980,7 +991,8 @@ streams:
|
|
|
980
991
|
|
|
981
992
|
test('can request multiple lookups at once', async () => {
|
|
982
993
|
await using factory = await generateStorageFactory();
|
|
983
|
-
const syncRules = await
|
|
994
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
995
|
+
factory,
|
|
984
996
|
updateSyncRulesFromYaml(`
|
|
985
997
|
config:
|
|
986
998
|
edition: 3
|
|
@@ -993,14 +1005,16 @@ streams:
|
|
|
993
1005
|
query: SELECT * FROM b WHERE p IN (SELECT id FROM param_b WHERE u = auth.user_id())
|
|
994
1006
|
`)
|
|
995
1007
|
);
|
|
996
|
-
const bucketStorage = factory.getInstance(
|
|
1008
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
997
1009
|
const parsedSyncRules = syncRules.parsed(test_utils.PARSE_OPTIONS);
|
|
998
1010
|
const hydrationState = parsedSyncRules.hydrationState;
|
|
999
|
-
const
|
|
1011
|
+
const [parsedSyncConfig] = parsedSyncRules.syncConfigs;
|
|
1012
|
+
expect(parsedSyncConfig).toBeDefined();
|
|
1013
|
+
const syncConfig = parsedSyncConfig.config;
|
|
1000
1014
|
|
|
1001
1015
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1002
|
-
const paramATable = await test_utils.resolveTestTable(writer, 'param_a', ['id'], config);
|
|
1003
|
-
const paramBTable = await test_utils.resolveTestTable(writer, 'param_b', ['id'], config);
|
|
1016
|
+
const paramATable = await test_utils.resolveTestTable(writer, 'param_a', ['id'], config, 1);
|
|
1017
|
+
const paramBTable = await test_utils.resolveTestTable(writer, 'param_b', ['id'], config, 2);
|
|
1004
1018
|
const replicaId = test_utils.rid('id');
|
|
1005
1019
|
|
|
1006
1020
|
// Insert the same row into param_a and param_b
|
|
@@ -1070,7 +1084,8 @@ streams:
|
|
|
1070
1084
|
|
|
1071
1085
|
test('sync streams preserve duplicate downstream lookups with different provenance', async () => {
|
|
1072
1086
|
await using factory = await generateStorageFactory();
|
|
1073
|
-
const syncRules = await
|
|
1087
|
+
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
1088
|
+
factory,
|
|
1074
1089
|
updateSyncRulesFromYaml(
|
|
1075
1090
|
`
|
|
1076
1091
|
config:
|
|
@@ -1091,12 +1106,12 @@ streams:
|
|
|
1091
1106
|
}
|
|
1092
1107
|
)
|
|
1093
1108
|
);
|
|
1094
|
-
const bucketStorage = factory.getInstance(
|
|
1095
|
-
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).
|
|
1109
|
+
const bucketStorage = factory.getInstance(replicationStream);
|
|
1110
|
+
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
1096
1111
|
|
|
1097
1112
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1098
|
-
const tableB = await test_utils.resolveTestTable(writer, 'b', ['id'], config);
|
|
1099
|
-
const tableC = await test_utils.resolveTestTable(writer, 'c', ['id'], config);
|
|
1113
|
+
const tableB = await test_utils.resolveTestTable(writer, 'b', ['id'], config, 1);
|
|
1114
|
+
const tableC = await test_utils.resolveTestTable(writer, 'c', ['id'], config, 2);
|
|
1100
1115
|
|
|
1101
1116
|
await writer.markAllSnapshotDone('1/1');
|
|
1102
1117
|
await writer.save({
|
|
@@ -892,7 +892,8 @@ bucket_definitions:
|
|
|
892
892
|
|
|
893
893
|
const checkpoint2 = await getCheckpointLines(iter);
|
|
894
894
|
|
|
895
|
-
const
|
|
895
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
896
|
+
const { bucket } = test_utils.bucketRequest(syncRulesContent, 'by_user["user1"]');
|
|
896
897
|
expect(
|
|
897
898
|
(checkpoint2[0] as StreamingSyncCheckpointDiff).checkpoint_diff?.updated_buckets?.map((b) => b.bucket)
|
|
898
899
|
).toEqual([bucket]);
|
|
@@ -947,7 +948,8 @@ bucket_definitions:
|
|
|
947
948
|
iter.return?.();
|
|
948
949
|
});
|
|
949
950
|
|
|
950
|
-
const
|
|
951
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
952
|
+
const { bucket } = bucketRequest(syncRulesContent, 'by_user["user1"]');
|
|
951
953
|
const checkpoint1 = await getCheckpointLines(iter);
|
|
952
954
|
|
|
953
955
|
expect((checkpoint1[0] as StreamingSyncCheckpoint).checkpoint?.buckets?.map((b) => b.bucket)).toEqual([bucket]);
|
|
@@ -1038,7 +1040,8 @@ bucket_definitions:
|
|
|
1038
1040
|
|
|
1039
1041
|
await writer.commit('0/1');
|
|
1040
1042
|
|
|
1041
|
-
const
|
|
1043
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
1044
|
+
const { bucket } = test_utils.bucketRequest(syncRulesContent, 'by_user["user1"]');
|
|
1042
1045
|
|
|
1043
1046
|
const checkpoint2 = await getCheckpointLines(iter);
|
|
1044
1047
|
expect(
|
package/src/tests/util.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { storage } from '@powersync/service-core';
|
|
2
2
|
import {
|
|
3
3
|
ParameterIndexLookupCreator,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ParameterLookupDefinitionId,
|
|
5
|
+
ParameterLookupScope,
|
|
6
|
+
SourceTableRef,
|
|
6
7
|
TablePattern
|
|
7
8
|
} from '@powersync/service-sync-rules';
|
|
8
|
-
import { ParameterLookupScope } from '@powersync/service-sync-rules/src/HydrationState.js';
|
|
9
9
|
import { bucketRequest } from '../test-utils/general-utils.js';
|
|
10
10
|
|
|
11
11
|
export function bucketRequestMap(
|
|
12
|
-
syncRules: storage.
|
|
12
|
+
syncRules: storage.PersistedSyncConfigContent,
|
|
13
13
|
buckets: Iterable<readonly [string, bigint]>
|
|
14
14
|
): storage.BucketDataRequest[] {
|
|
15
15
|
return Array.from(buckets, ([bucketName, opId]) => bucketRequest(syncRules, bucketName, opId));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function bucketRequests(
|
|
19
|
-
syncRules: storage.
|
|
19
|
+
syncRules: storage.PersistedSyncConfigContent,
|
|
20
20
|
bucketNames: string[]
|
|
21
21
|
): storage.BucketChecksumRequest[] {
|
|
22
22
|
return bucketNames.map((bucketName) => {
|
|
@@ -26,20 +26,23 @@ export function bucketRequests(
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const EMPTY_LOOKUP_SOURCE: ParameterIndexLookupCreator = {
|
|
29
|
-
get
|
|
29
|
+
get sourceId(): ParameterLookupDefinitionId {
|
|
30
30
|
return {
|
|
31
31
|
lookupName: 'lookup',
|
|
32
|
-
queryId: '0'
|
|
33
|
-
source: EMPTY_LOOKUP_SOURCE
|
|
32
|
+
queryId: '0'
|
|
34
33
|
};
|
|
35
34
|
},
|
|
36
35
|
getSourceTables(): Set<TablePattern> {
|
|
37
36
|
return new Set();
|
|
38
37
|
},
|
|
39
|
-
|
|
40
|
-
return
|
|
38
|
+
createEvaluator(input) {
|
|
39
|
+
return {
|
|
40
|
+
evaluateParameterRow(sourceTable, row) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
41
44
|
},
|
|
42
|
-
tableSyncsParameters(_table:
|
|
45
|
+
tableSyncsParameters(_table: SourceTableRef): boolean {
|
|
43
46
|
return false;
|
|
44
47
|
}
|
|
45
48
|
};
|
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"rootDir": "src",
|
|
5
|
-
"outDir": "dist"
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"sourceMap": true
|
|
5
|
+
"outDir": "dist"
|
|
9
6
|
},
|
|
10
7
|
"include": ["src"],
|
|
11
8
|
"references": [
|
|
@@ -17,6 +14,9 @@
|
|
|
17
14
|
},
|
|
18
15
|
{
|
|
19
16
|
"path": "../service-core"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../../libs/lib-services"
|
|
20
20
|
}
|
|
21
21
|
]
|
|
22
22
|
}
|