@powersync/service-core-tests 0.12.16 → 0.13.1

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,9 +1,9 @@
1
- import { storage } from '@powersync/service-core';
2
- import { ParameterLookup, RequestParameters } from '@powersync/service-sync-rules';
3
- import { SqlBucketDescriptor } from '@powersync/service-sync-rules/src/SqlBucketDescriptor.js';
1
+ import { JwtPayload, storage } from '@powersync/service-core';
2
+ import { RequestParameters, ScopedParameterLookup, SqliteJsonRow } from '@powersync/service-sync-rules';
4
3
  import { expect, test } from 'vitest';
5
4
  import * as test_utils from '../test-utils/test-utils-index.js';
6
5
  import { TEST_TABLE } from './util.js';
6
+ import { ParameterLookupScope } from '@powersync/service-sync-rules/src/HydrationState.js';
7
7
 
8
8
  /**
9
9
  * @example
@@ -16,6 +16,8 @@ import { TEST_TABLE } from './util.js';
16
16
  * ```
17
17
  */
18
18
  export function registerDataStorageParameterTests(generateStorageFactory: storage.TestStorageFactory) {
19
+ const MYBUCKET_1: ParameterLookupScope = { lookupName: 'mybucket', queryId: '1' };
20
+
19
21
  test('save and load parameters', async () => {
20
22
  await using factory = await generateStorageFactory();
21
23
  const syncRules = await factory.updateSyncRules({
@@ -58,7 +60,7 @@ bucket_definitions:
58
60
  });
59
61
 
60
62
  const checkpoint = await bucketStorage.getCheckpoint();
61
- const parameters = await checkpoint.getParameterSets([ParameterLookup.normalized('mybucket', '1', ['user1'])]);
63
+ const parameters = await checkpoint.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
62
64
  expect(parameters).toEqual([
63
65
  {
64
66
  group_id: 'group1a'
@@ -106,7 +108,7 @@ bucket_definitions:
106
108
  });
107
109
  const checkpoint2 = await bucketStorage.getCheckpoint();
108
110
 
109
- const parameters = await checkpoint2.getParameterSets([ParameterLookup.normalized('mybucket', '1', ['user1'])]);
111
+ const parameters = await checkpoint2.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
110
112
  expect(parameters).toEqual([
111
113
  {
112
114
  group_id: 'group2'
@@ -114,7 +116,7 @@ bucket_definitions:
114
116
  ]);
115
117
 
116
118
  // Use the checkpoint to get older data if relevant
117
- const parameters2 = await checkpoint1.getParameterSets([ParameterLookup.normalized('mybucket', '1', ['user1'])]);
119
+ const parameters2 = await checkpoint1.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
118
120
  expect(parameters2).toEqual([
119
121
  {
120
122
  group_id: 'group1'
@@ -183,8 +185,8 @@ bucket_definitions:
183
185
  // association of `list1`::`todo2`
184
186
  const checkpoint = await bucketStorage.getCheckpoint();
185
187
  const parameters = await checkpoint.getParameterSets([
186
- ParameterLookup.normalized('mybucket', '1', ['list1']),
187
- ParameterLookup.normalized('mybucket', '1', ['list2'])
188
+ ScopedParameterLookup.direct(MYBUCKET_1, ['list1']),
189
+ ScopedParameterLookup.direct(MYBUCKET_1, ['list2'])
188
190
  ]);
189
191
 
190
192
  expect(parameters.sort((a, b) => (a.todo_id as string).localeCompare(b.todo_id as string))).toEqual([
@@ -232,16 +234,14 @@ bucket_definitions:
232
234
  const checkpoint = await bucketStorage.getCheckpoint();
233
235
 
234
236
  const parameters1 = await checkpoint.getParameterSets([
235
- ParameterLookup.normalized('mybucket', '1', [314n, 314, 3.14])
237
+ ScopedParameterLookup.direct(MYBUCKET_1, [314n, 314, 3.14])
236
238
  ]);
237
239
  expect(parameters1).toEqual([TEST_PARAMS]);
238
240
  const parameters2 = await checkpoint.getParameterSets([
239
- ParameterLookup.normalized('mybucket', '1', [314, 314n, 3.14])
241
+ ScopedParameterLookup.direct(MYBUCKET_1, [314, 314n, 3.14])
240
242
  ]);
241
243
  expect(parameters2).toEqual([TEST_PARAMS]);
242
- const parameters3 = await checkpoint.getParameterSets([
243
- ParameterLookup.normalized('mybucket', '1', [314n, 314, 3])
244
- ]);
244
+ const parameters3 = await checkpoint.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, [314n, 314, 3])]);
245
245
  expect(parameters3).toEqual([]);
246
246
  });
247
247
 
@@ -295,7 +295,7 @@ bucket_definitions:
295
295
  const checkpoint = await bucketStorage.getCheckpoint();
296
296
 
297
297
  const parameters1 = await checkpoint.getParameterSets([
298
- ParameterLookup.normalized('mybucket', '1', [1152921504606846976n])
298
+ ScopedParameterLookup.direct(MYBUCKET_1, [1152921504606846976n])
299
299
  ]);
300
300
  expect(parameters1).toEqual([TEST_PARAMS]);
301
301
  });
@@ -314,7 +314,7 @@ bucket_definitions:
314
314
  data: []
315
315
  `
316
316
  });
317
- const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).sync_rules;
317
+ const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
318
318
  const bucketStorage = factory.getInstance(syncRules);
319
319
 
320
320
  await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
@@ -331,23 +331,19 @@ bucket_definitions:
331
331
  });
332
332
  const checkpoint = await bucketStorage.getCheckpoint();
333
333
 
334
- const parameters = new RequestParameters({ sub: 'u1' }, {});
335
-
336
- const q1 = (sync_rules.bucketSources[0] as SqlBucketDescriptor).parameterQueries[0];
334
+ const parameters = new RequestParameters(new JwtPayload({ sub: 'u1' }), {});
337
335
 
338
- const lookups = q1.getLookups(parameters);
339
- expect(lookups).toEqual([ParameterLookup.normalized('by_workspace', '1', ['u1'])]);
336
+ const querier = sync_rules.getBucketParameterQuerier(test_utils.querierOptions(parameters)).querier;
340
337
 
341
- const parameter_sets = await checkpoint.getParameterSets(lookups);
342
- expect(parameter_sets).toEqual([{ workspace_id: 'workspace1' }]);
338
+ const buckets = await querier.queryDynamicBucketDescriptions({
339
+ async getParameterSets(lookups) {
340
+ expect(lookups).toEqual([ScopedParameterLookup.direct({ lookupName: 'by_workspace', queryId: '1' }, ['u1'])]);
343
341
 
344
- const buckets = await sync_rules
345
- .getBucketParameterQuerier(test_utils.querierOptions(parameters))
346
- .querier.queryDynamicBucketDescriptions({
347
- getParameterSets(lookups) {
348
- return checkpoint.getParameterSets(lookups);
349
- }
350
- });
342
+ const parameter_sets = await checkpoint.getParameterSets(lookups);
343
+ expect(parameter_sets).toEqual([{ workspace_id: 'workspace1' }]);
344
+ return parameter_sets;
345
+ }
346
+ });
351
347
  expect(buckets).toEqual([
352
348
  { bucket: 'by_workspace["workspace1"]', priority: 3, definition: 'by_workspace', inclusion_reasons: ['default'] }
353
349
  ]);
@@ -367,7 +363,7 @@ bucket_definitions:
367
363
  data: []
368
364
  `
369
365
  });
370
- const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).sync_rules;
366
+ const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
371
367
  const bucketStorage = factory.getInstance(syncRules);
372
368
 
373
369
  await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
@@ -406,24 +402,22 @@ bucket_definitions:
406
402
 
407
403
  const checkpoint = await bucketStorage.getCheckpoint();
408
404
 
409
- const parameters = new RequestParameters({ sub: 'unknown' }, {});
405
+ const parameters = new RequestParameters(new JwtPayload({ sub: 'unknown' }), {});
410
406
 
411
- const q1 = (sync_rules.bucketSources[0] as SqlBucketDescriptor).parameterQueries[0];
407
+ const querier = sync_rules.getBucketParameterQuerier(test_utils.querierOptions(parameters)).querier;
412
408
 
413
- const lookups = q1.getLookups(parameters);
414
- expect(lookups).toEqual([ParameterLookup.normalized('by_public_workspace', '1', [])]);
409
+ const buckets = await querier.queryDynamicBucketDescriptions({
410
+ async getParameterSets(lookups) {
411
+ expect(lookups).toEqual([
412
+ ScopedParameterLookup.direct({ lookupName: 'by_public_workspace', queryId: '1' }, [])
413
+ ]);
415
414
 
416
- const parameter_sets = await checkpoint.getParameterSets(lookups);
417
- parameter_sets.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
418
- expect(parameter_sets).toEqual([{ workspace_id: 'workspace1' }, { workspace_id: 'workspace3' }]);
419
-
420
- const buckets = await sync_rules
421
- .getBucketParameterQuerier(test_utils.querierOptions(parameters))
422
- .querier.queryDynamicBucketDescriptions({
423
- getParameterSets(lookups) {
424
- return checkpoint.getParameterSets(lookups);
425
- }
426
- });
415
+ const parameter_sets = await checkpoint.getParameterSets(lookups);
416
+ parameter_sets.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
417
+ expect(parameter_sets).toEqual([{ workspace_id: 'workspace1' }, { workspace_id: 'workspace3' }]);
418
+ return parameter_sets;
419
+ }
420
+ });
427
421
  buckets.sort((a, b) => a.bucket.localeCompare(b.bucket));
428
422
  expect(buckets).toEqual([
429
423
  {
@@ -457,7 +451,7 @@ bucket_definitions:
457
451
  data: []
458
452
  `
459
453
  });
460
- const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).sync_rules;
454
+ const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
461
455
  const bucketStorage = factory.getInstance(syncRules);
462
456
 
463
457
  await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
@@ -508,35 +502,31 @@ bucket_definitions:
508
502
 
509
503
  const checkpoint = await bucketStorage.getCheckpoint();
510
504
 
511
- const parameters = new RequestParameters({ sub: 'u1' }, {});
505
+ const parameters = new RequestParameters(new JwtPayload({ sub: 'u1' }), {});
512
506
 
513
507
  // Test intermediate values - could be moved to sync_rules.test.ts
514
- const q1 = (sync_rules.bucketSources[0] as SqlBucketDescriptor).parameterQueries[0];
515
- const lookups1 = q1.getLookups(parameters);
516
- expect(lookups1).toEqual([ParameterLookup.normalized('by_workspace', '1', [])]);
517
-
518
- const parameter_sets1 = await checkpoint.getParameterSets(lookups1);
519
- parameter_sets1.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
520
- expect(parameter_sets1).toEqual([{ workspace_id: 'workspace1' }]);
521
-
522
- const q2 = (sync_rules.bucketSources[0] as SqlBucketDescriptor).parameterQueries[1];
523
- const lookups2 = q2.getLookups(parameters);
524
- expect(lookups2).toEqual([ParameterLookup.normalized('by_workspace', '2', ['u1'])]);
525
-
526
- const parameter_sets2 = await checkpoint.getParameterSets(lookups2);
527
- parameter_sets2.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
528
- expect(parameter_sets2).toEqual([{ workspace_id: 'workspace3' }]);
508
+ const querier = sync_rules.getBucketParameterQuerier(test_utils.querierOptions(parameters)).querier;
529
509
 
530
510
  // Test final values - the important part
511
+ const foundLookups: ScopedParameterLookup[] = [];
512
+ const parameter_sets: SqliteJsonRow[] = [];
531
513
  const buckets = (
532
- await sync_rules
533
- .getBucketParameterQuerier(test_utils.querierOptions(parameters))
534
- .querier.queryDynamicBucketDescriptions({
535
- getParameterSets(lookups) {
536
- return checkpoint.getParameterSets(lookups);
537
- }
538
- })
514
+ await querier.queryDynamicBucketDescriptions({
515
+ async getParameterSets(lookups) {
516
+ foundLookups.push(...lookups);
517
+ const output = await checkpoint.getParameterSets(lookups);
518
+ parameter_sets.push(...output);
519
+ return output;
520
+ }
521
+ })
539
522
  ).map((e) => e.bucket);
523
+ expect(foundLookups).toEqual([
524
+ ScopedParameterLookup.direct({ lookupName: 'by_workspace', queryId: '1' }, []),
525
+ ScopedParameterLookup.direct({ lookupName: 'by_workspace', queryId: '2' }, ['u1'])
526
+ ]);
527
+ parameter_sets.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
528
+ expect(parameter_sets).toEqual([{ workspace_id: 'workspace1' }, { workspace_id: 'workspace3' }]);
529
+
540
530
  buckets.sort();
541
531
  expect(buckets).toEqual(['by_workspace["workspace1"]', 'by_workspace["workspace3"]']);
542
532
  });
@@ -572,7 +562,7 @@ bucket_definitions:
572
562
 
573
563
  const checkpoint = await bucketStorage.getCheckpoint();
574
564
 
575
- const parameters = await checkpoint.getParameterSets([ParameterLookup.normalized('mybucket', '1', ['user1'])]);
565
+ const parameters = await checkpoint.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
576
566
  expect(parameters).toEqual([]);
577
567
  });
578
568
 
@@ -1,5 +1,5 @@
1
1
  import { storage } from '@powersync/service-core';
2
- import { ParameterLookup } from '@powersync/service-sync-rules';
2
+ import { ScopedParameterLookup } from '@powersync/service-sync-rules';
3
3
  import { expect, test } from 'vitest';
4
4
  import * as test_utils from '../test-utils/test-utils-index.js';
5
5
 
@@ -40,7 +40,7 @@ bucket_definitions:
40
40
  await batch.commit('1/1');
41
41
  });
42
42
 
43
- const lookup = ParameterLookup.normalized('test', '1', ['t1']);
43
+ const lookup = ScopedParameterLookup.direct({ lookupName: 'test', queryId: '1' }, ['t1']);
44
44
 
45
45
  const checkpoint1 = await bucketStorage.getCheckpoint();
46
46
  const parameters1 = await checkpoint1.getParameterSets([lookup]);
@@ -151,7 +151,7 @@ bucket_definitions:
151
151
  await batch.commit('3/1');
152
152
  });
153
153
 
154
- const lookup = ParameterLookup.normalized('test', '1', ['u1']);
154
+ const lookup = ScopedParameterLookup.direct({ lookupName: 'test', queryId: '1' }, ['u1']);
155
155
 
156
156
  const checkpoint1 = await bucketStorage.getCheckpoint();
157
157
  const parameters1 = await checkpoint1.getParameterSets([lookup]);
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  createCoreAPIMetrics,
3
+ JwtPayload,
3
4
  storage,
4
5
  StreamingSyncCheckpoint,
5
6
  StreamingSyncCheckpointDiff,
@@ -82,17 +83,14 @@ export function registerSyncTests(factory: storage.TestStorageFactory) {
82
83
  const stream = sync.streamResponse({
83
84
  syncContext,
84
85
  bucketStorage: bucketStorage,
85
- syncRules: {
86
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
87
- version: bucketStorage.group_id
88
- },
86
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
89
87
  params: {
90
88
  buckets: [],
91
89
  include_checksum: true,
92
90
  raw_data: true
93
91
  },
94
92
  tracker,
95
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
93
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
96
94
  isEncodingAsBson: false
97
95
  });
98
96
 
@@ -146,17 +144,14 @@ bucket_definitions:
146
144
  const stream = sync.streamResponse({
147
145
  syncContext,
148
146
  bucketStorage,
149
- syncRules: {
150
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
151
- version: bucketStorage.group_id
152
- },
147
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
153
148
  params: {
154
149
  buckets: [],
155
150
  include_checksum: true,
156
151
  raw_data: true
157
152
  },
158
153
  tracker,
159
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
154
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
160
155
  isEncodingAsBson: false
161
156
  });
162
157
 
@@ -212,17 +207,14 @@ bucket_definitions:
212
207
  const stream = sync.streamResponse({
213
208
  syncContext,
214
209
  bucketStorage,
215
- syncRules: {
216
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
217
- version: bucketStorage.group_id
218
- },
210
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
219
211
  params: {
220
212
  buckets: [],
221
213
  include_checksum: true,
222
214
  raw_data: true
223
215
  },
224
216
  tracker,
225
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
217
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
226
218
  isEncodingAsBson: false
227
219
  });
228
220
 
@@ -325,17 +317,14 @@ bucket_definitions:
325
317
  const stream = sync.streamResponse({
326
318
  syncContext,
327
319
  bucketStorage,
328
- syncRules: {
329
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
330
- version: bucketStorage.group_id
331
- },
320
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
332
321
  params: {
333
322
  buckets: [],
334
323
  include_checksum: true,
335
324
  raw_data: true
336
325
  },
337
326
  tracker,
338
- token: { sub: 'user_one', exp: Date.now() / 1000 + 100000 } as any,
327
+ token: new JwtPayload({ sub: 'user_one', exp: Date.now() / 1000 + 100000 }),
339
328
  isEncodingAsBson: false
340
329
  });
341
330
 
@@ -469,17 +458,14 @@ bucket_definitions:
469
458
  const stream = sync.streamResponse({
470
459
  syncContext,
471
460
  bucketStorage,
472
- syncRules: {
473
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
474
- version: bucketStorage.group_id
475
- },
461
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
476
462
  params: {
477
463
  buckets: [],
478
464
  include_checksum: true,
479
465
  raw_data: true
480
466
  },
481
467
  tracker,
482
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
468
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
483
469
  isEncodingAsBson: false
484
470
  });
485
471
 
@@ -588,17 +574,14 @@ bucket_definitions:
588
574
  const stream = sync.streamResponse({
589
575
  syncContext,
590
576
  bucketStorage,
591
- syncRules: {
592
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
593
- version: bucketStorage.group_id
594
- },
577
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
595
578
  params: {
596
579
  buckets: [],
597
580
  include_checksum: true,
598
581
  raw_data: true
599
582
  },
600
583
  tracker,
601
- token: { sub: '', exp: Date.now() / 1000 + 100000 } as any,
584
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 100000 }),
602
585
  isEncodingAsBson: false
603
586
  });
604
587
 
@@ -657,17 +640,14 @@ bucket_definitions:
657
640
  const stream = sync.streamResponse({
658
641
  syncContext,
659
642
  bucketStorage,
660
- syncRules: {
661
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
662
- version: bucketStorage.group_id
663
- },
643
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
664
644
  params: {
665
645
  buckets: [],
666
646
  include_checksum: true,
667
647
  raw_data: false
668
648
  },
669
649
  tracker,
670
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
650
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
671
651
  isEncodingAsBson: false
672
652
  });
673
653
 
@@ -689,17 +669,14 @@ bucket_definitions:
689
669
  const stream = sync.streamResponse({
690
670
  syncContext,
691
671
  bucketStorage,
692
- syncRules: {
693
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
694
- version: bucketStorage.group_id
695
- },
672
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
696
673
  params: {
697
674
  buckets: [],
698
675
  include_checksum: true,
699
676
  raw_data: true
700
677
  },
701
678
  tracker,
702
- token: { sub: '', exp: 0 } as any,
679
+ token: new JwtPayload({ sub: '', exp: 0 }),
703
680
  isEncodingAsBson: false
704
681
  });
705
682
 
@@ -723,17 +700,14 @@ bucket_definitions:
723
700
  const stream = sync.streamResponse({
724
701
  syncContext,
725
702
  bucketStorage,
726
- syncRules: {
727
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
728
- version: bucketStorage.group_id
729
- },
703
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
730
704
  params: {
731
705
  buckets: [],
732
706
  include_checksum: true,
733
707
  raw_data: true
734
708
  },
735
709
  tracker,
736
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
710
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
737
711
  isEncodingAsBson: false
738
712
  });
739
713
  const iter = stream[Symbol.asyncIterator]();
@@ -800,17 +774,14 @@ bucket_definitions:
800
774
  const stream = sync.streamResponse({
801
775
  syncContext,
802
776
  bucketStorage,
803
- syncRules: {
804
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
805
- version: bucketStorage.group_id
806
- },
777
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
807
778
  params: {
808
779
  buckets: [],
809
780
  include_checksum: true,
810
781
  raw_data: true
811
782
  },
812
783
  tracker,
813
- token: { sub: 'user1', exp: Date.now() / 1000 + 100 } as any,
784
+ token: new JwtPayload({ sub: 'user1', exp: Date.now() / 1000 + 100 }),
814
785
  isEncodingAsBson: false
815
786
  });
816
787
  const iter = stream[Symbol.asyncIterator]();
@@ -879,17 +850,14 @@ bucket_definitions:
879
850
  const stream = sync.streamResponse({
880
851
  syncContext,
881
852
  bucketStorage,
882
- syncRules: {
883
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
884
- version: bucketStorage.group_id
885
- },
853
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
886
854
  params: {
887
855
  buckets: [],
888
856
  include_checksum: true,
889
857
  raw_data: true
890
858
  },
891
859
  tracker,
892
- token: { sub: 'user1', exp: Date.now() / 1000 + 100 } as any,
860
+ token: new JwtPayload({ sub: 'user1', exp: Date.now() / 1000 + 100 }),
893
861
  isEncodingAsBson: false
894
862
  });
895
863
  const iter = stream[Symbol.asyncIterator]();
@@ -949,17 +917,14 @@ bucket_definitions:
949
917
  const stream = sync.streamResponse({
950
918
  syncContext,
951
919
  bucketStorage,
952
- syncRules: {
953
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
954
- version: bucketStorage.group_id
955
- },
920
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
956
921
  params: {
957
922
  buckets: [],
958
923
  include_checksum: true,
959
924
  raw_data: true
960
925
  },
961
926
  tracker,
962
- token: { sub: 'user1', exp: Date.now() / 1000 + 100 } as any,
927
+ token: new JwtPayload({ sub: 'user1', exp: Date.now() / 1000 + 100 }),
963
928
  isEncodingAsBson: false
964
929
  });
965
930
  const iter = stream[Symbol.asyncIterator]();
@@ -1020,17 +985,14 @@ bucket_definitions:
1020
985
  const stream = sync.streamResponse({
1021
986
  syncContext,
1022
987
  bucketStorage,
1023
- syncRules: {
1024
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1025
- version: bucketStorage.group_id
1026
- },
988
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1027
989
  params: {
1028
990
  buckets: [],
1029
991
  include_checksum: true,
1030
992
  raw_data: true
1031
993
  },
1032
994
  tracker,
1033
- token: { sub: '', exp: exp } as any,
995
+ token: new JwtPayload({ sub: '', exp: exp }),
1034
996
  isEncodingAsBson: false
1035
997
  });
1036
998
  const iter = stream[Symbol.asyncIterator]();
@@ -1086,17 +1048,14 @@ bucket_definitions:
1086
1048
  const stream = sync.streamResponse({
1087
1049
  syncContext,
1088
1050
  bucketStorage,
1089
- syncRules: {
1090
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1091
- version: bucketStorage.group_id
1092
- },
1051
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1093
1052
  params: {
1094
1053
  buckets: [],
1095
1054
  include_checksum: true,
1096
1055
  raw_data: true
1097
1056
  },
1098
1057
  tracker,
1099
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
1058
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
1100
1059
  isEncodingAsBson: false
1101
1060
  });
1102
1061
 
@@ -1142,7 +1101,8 @@ bucket_definitions:
1142
1101
  });
1143
1102
 
1144
1103
  await bucketStorage.compact({
1145
- minBucketChanges: 1
1104
+ minBucketChanges: 1,
1105
+ minChangeRatio: 0
1146
1106
  });
1147
1107
 
1148
1108
  const lines2 = await getCheckpointLines(iter, { consume: true });
@@ -1217,17 +1177,14 @@ bucket_definitions:
1217
1177
  const params: sync.SyncStreamParameters = {
1218
1178
  syncContext,
1219
1179
  bucketStorage,
1220
- syncRules: {
1221
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1222
- version: bucketStorage.group_id
1223
- },
1180
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1224
1181
  params: {
1225
1182
  buckets: [],
1226
1183
  include_checksum: true,
1227
1184
  raw_data: true
1228
1185
  },
1229
1186
  tracker,
1230
- token: { sub: 'test', exp: Date.now() / 1000 + 10 } as any,
1187
+ token: new JwtPayload({ sub: 'test', exp: Date.now() / 1000 + 10 }),
1231
1188
  isEncodingAsBson: false
1232
1189
  };
1233
1190
  const stream1 = sync.streamResponse(params);
@@ -1293,17 +1250,14 @@ config:
1293
1250
  const stream = sync.streamResponse({
1294
1251
  syncContext,
1295
1252
  bucketStorage: bucketStorage,
1296
- syncRules: {
1297
- syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1298
- version: bucketStorage.group_id
1299
- },
1253
+ syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
1300
1254
  params: {
1301
1255
  buckets: [],
1302
1256
  include_checksum: true,
1303
1257
  raw_data: true
1304
1258
  },
1305
1259
  tracker,
1306
- token: { sub: '', exp: Date.now() / 1000 + 10 } as any,
1260
+ token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
1307
1261
  isEncodingAsBson: false
1308
1262
  });
1309
1263
 
package/tsconfig.json CHANGED
@@ -9,26 +9,14 @@
9
9
  },
10
10
  "include": ["src"],
11
11
  "references": [
12
- {
13
- "path": "../types"
14
- },
15
- {
16
- "path": "../rsocket-router"
17
- },
18
12
  {
19
13
  "path": "../jsonbig"
20
14
  },
21
- {
22
- "path": "../jpgwire"
23
- },
24
15
  {
25
16
  "path": "../sync-rules"
26
17
  },
27
18
  {
28
19
  "path": "../service-core"
29
- },
30
- {
31
- "path": "../../libs/lib-services"
32
20
  }
33
21
  ]
34
22
  }