@powersync/service-module-postgres-storage 0.0.0-dev-20260602073133 → 0.0.0-dev-20260909133214

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +179 -6
  2. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.d.ts +3 -0
  3. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.js +42 -0
  4. package/dist/migrations/scripts/1782950400000-checkpoint-requested-at.js.map +1 -0
  5. package/dist/migrations/scripts/1784900000000-source-metadata.d.ts +3 -0
  6. package/dist/migrations/scripts/1784900000000-source-metadata.js +22 -0
  7. package/dist/migrations/scripts/1784900000000-source-metadata.js.map +1 -0
  8. package/dist/migrations/scripts/1788000000000-sync-config-version-label.d.ts +3 -0
  9. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js +12 -0
  10. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js.map +1 -0
  11. package/dist/{@types/storage → storage}/PostgresBucketStorageFactory.d.ts +14 -12
  12. package/dist/storage/PostgresBucketStorageFactory.js +73 -62
  13. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  14. package/dist/{@types/storage → storage}/PostgresCompactor.d.ts +3 -1
  15. package/dist/storage/PostgresCompactor.js +21 -1
  16. package/dist/storage/PostgresCompactor.js.map +1 -1
  17. package/dist/storage/PostgresReportStorage.js.map +1 -1
  18. package/dist/storage/PostgresStorageProvider.js +3 -1
  19. package/dist/storage/PostgresStorageProvider.js.map +1 -1
  20. package/dist/{@types/storage → storage}/PostgresSyncRulesStorage.d.ts +39 -13
  21. package/dist/storage/PostgresSyncRulesStorage.js +266 -181
  22. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  23. package/dist/{@types/storage → storage}/batch/PostgresBucketBatch.d.ts +10 -26
  24. package/dist/storage/batch/PostgresBucketBatch.js +290 -286
  25. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  26. package/dist/{@types/storage → storage}/checkpoints/PostgresWriteCheckpointAPI.d.ts +2 -2
  27. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +163 -26
  28. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
  29. package/dist/{@types/storage → storage}/current-data-store.d.ts +8 -2
  30. package/dist/storage/current-data-store.js +66 -11
  31. package/dist/storage/current-data-store.js.map +1 -1
  32. package/dist/{@types/storage → storage}/storage-index.d.ts +1 -0
  33. package/dist/storage/storage-index.js +1 -0
  34. package/dist/storage/storage-index.js.map +1 -1
  35. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.d.ts +17 -0
  36. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +94 -0
  37. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -0
  38. package/dist/{@types/types → types}/models/ActiveCheckpoint.d.ts +2 -2
  39. package/dist/types/models/ActiveCheckpoint.js +3 -2
  40. package/dist/types/models/ActiveCheckpoint.js.map +1 -1
  41. package/dist/{@types/types → types}/models/ActiveCheckpointNotification.d.ts +2 -2
  42. package/dist/types/models/BucketData.d.ts +22 -0
  43. package/dist/types/models/BucketData.js +7 -6
  44. package/dist/types/models/BucketData.js.map +1 -1
  45. package/dist/{@types/types → types}/models/CurrentData.d.ts +1 -1
  46. package/dist/types/models/CurrentData.js +2 -1
  47. package/dist/types/models/CurrentData.js.map +1 -1
  48. package/dist/{@types/types → types}/models/SdkReporting.d.ts +3 -3
  49. package/dist/types/models/SdkReporting.js +3 -5
  50. package/dist/types/models/SdkReporting.js.map +1 -1
  51. package/dist/{@types/types → types}/models/SourceTable.d.ts +13 -8
  52. package/dist/types/models/SourceTable.js +11 -6
  53. package/dist/types/models/SourceTable.js.map +1 -1
  54. package/dist/{@types/types → types}/models/SyncRules.d.ts +11 -10
  55. package/dist/types/models/SyncRules.js +12 -11
  56. package/dist/types/models/SyncRules.js.map +1 -1
  57. package/dist/{@types/types → types}/models/WriteCheckpoint.d.ts +2 -0
  58. package/dist/types/models/WriteCheckpoint.js +6 -2
  59. package/dist/types/models/WriteCheckpoint.js.map +1 -1
  60. package/dist/{@types/types → types}/types.d.ts +2 -0
  61. package/dist/utils/checkpoints.d.ts +9 -0
  62. package/dist/utils/checkpoints.js +26 -0
  63. package/dist/utils/checkpoints.js.map +1 -0
  64. package/dist/utils/test-utils.js +2 -2
  65. package/dist/utils/test-utils.js.map +1 -1
  66. package/package.json +10 -22
  67. package/src/migrations/scripts/1782950400000-checkpoint-requested-at.ts +51 -0
  68. package/src/migrations/scripts/1784900000000-source-metadata.ts +31 -0
  69. package/src/migrations/scripts/1788000000000-sync-config-version-label.ts +18 -0
  70. package/src/storage/PostgresBucketStorageFactory.ts +82 -65
  71. package/src/storage/PostgresCompactor.ts +25 -1
  72. package/src/storage/PostgresReportStorage.ts +1 -2
  73. package/src/storage/PostgresStorageProvider.ts +3 -1
  74. package/src/storage/PostgresSyncRulesStorage.ts +295 -196
  75. package/src/storage/batch/PostgresBucketBatch.ts +321 -310
  76. package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +176 -26
  77. package/src/storage/current-data-store.ts +66 -11
  78. package/src/storage/storage-index.ts +1 -0
  79. package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +105 -0
  80. package/src/types/models/ActiveCheckpoint.ts +3 -2
  81. package/src/types/models/BucketData.ts +7 -6
  82. package/src/types/models/CurrentData.ts +2 -1
  83. package/src/types/models/SdkReporting.ts +4 -4
  84. package/src/types/models/SourceTable.ts +12 -6
  85. package/src/types/models/SyncRules.ts +12 -11
  86. package/src/types/models/WriteCheckpoint.ts +6 -2
  87. package/src/utils/checkpoints.ts +31 -0
  88. package/src/utils/test-utils.ts +2 -2
  89. package/test/src/__snapshots__/storage_sync.test.ts.snap +44 -1621
  90. package/test/src/checkpoint_notifications.test.ts +528 -0
  91. package/test/src/migrations.test.ts +1 -1
  92. package/test/src/storage.test.ts +235 -11
  93. package/test/src/storage_compacting.test.ts +17 -9
  94. package/test/src/storage_sync.test.ts +55 -8
  95. package/test/src/util.ts +1 -1
  96. package/test/tsconfig.json +1 -3
  97. package/tsconfig.json +1 -4
  98. package/tsconfig.tsbuildinfo +1 -0
  99. package/dist/.tsbuildinfo +0 -1
  100. package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +0 -9
  101. package/dist/@types/types/models/BucketData.d.ts +0 -22
  102. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +0 -49
  103. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +0 -1
  104. package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +0 -54
  105. /package/dist/{@types/index.d.ts → index.d.ts} +0 -0
  106. /package/dist/{@types/migrations → migrations}/PostgresMigrationAgent.d.ts +0 -0
  107. /package/dist/{@types/migrations → migrations}/PostgresMigrationStore.d.ts +0 -0
  108. /package/dist/{@types/migrations → migrations}/migration-utils.d.ts +0 -0
  109. /package/dist/{@types/migrations → migrations}/scripts/1684951997326-init.d.ts +0 -0
  110. /package/dist/{@types/migrations → migrations}/scripts/1749024804042-snapshot-progress.d.ts +0 -0
  111. /package/dist/{@types/migrations → migrations}/scripts/1756282360128-connection-reporting.d.ts +0 -0
  112. /package/dist/{@types/migrations → migrations}/scripts/1771232439485-storage-version.d.ts +0 -0
  113. /package/dist/{@types/migrations → migrations}/scripts/1771424826685-current-data-pending-deletes.d.ts +0 -0
  114. /package/dist/{@types/migrations → migrations}/scripts/1771491856000-sync-plan.d.ts +0 -0
  115. /package/dist/{@types/module → module}/PostgresStorageModule.d.ts +0 -0
  116. /package/dist/{@types/storage → storage}/PostgresReportStorage.d.ts +0 -0
  117. /package/dist/{@types/storage → storage}/PostgresStorageProvider.d.ts +0 -0
  118. /package/dist/{@types/storage → storage}/batch/OperationBatch.d.ts +0 -0
  119. /package/dist/{@types/storage → storage}/batch/PostgresPersistedBatch.d.ts +0 -0
  120. /package/dist/{@types/storage → storage}/table-id.d.ts +0 -0
  121. /package/dist/{@types/types → types}/codecs.d.ts +0 -0
  122. /package/dist/{@types/types → types}/models/BucketParameters.d.ts +0 -0
  123. /package/dist/{@types/types → types}/models/Instance.d.ts +0 -0
  124. /package/dist/{@types/types → types}/models/Migration.d.ts +0 -0
  125. /package/dist/{@types/types → types}/models/json.d.ts +0 -0
  126. /package/dist/{@types/types → types}/models/models-index.d.ts +0 -0
  127. /package/dist/{@types/utils → utils}/application-name.d.ts +0 -0
  128. /package/dist/{@types/utils → utils}/bson.d.ts +0 -0
  129. /package/dist/{@types/utils → utils}/bucket-data.d.ts +0 -0
  130. /package/dist/{@types/utils → utils}/db.d.ts +0 -0
  131. /package/dist/{@types/utils → utils}/test-utils.d.ts +0 -0
  132. /package/dist/{@types/utils → utils}/ts-codec.d.ts +0 -0
  133. /package/dist/{@types/utils → utils}/utils-index.d.ts +0 -0
@@ -589,1396 +589,13 @@ exports[`sync - postgres > storage v1 > sync global data 1`] = `
589
589
  ]
590
590
  `;
591
591
 
592
- exports[`sync - postgres > storage v1 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
593
- [
594
- {
595
- "checkpoint": {
596
- "buckets": [
597
- {
598
- "bucket": "b0a[]",
599
- "checksum": -659831575,
600
- "count": 2000,
601
- "priority": 2,
602
- "subscriptions": [
603
- {
604
- "default": 0,
605
- },
606
- ],
607
- },
608
- {
609
- "bucket": "b0b[]",
610
- "checksum": -659831575,
611
- "count": 2000,
612
- "priority": 2,
613
- "subscriptions": [
614
- {
615
- "default": 1,
616
- },
617
- ],
618
- },
619
- {
620
- "bucket": "b1[]",
621
- "checksum": -1096116670,
622
- "count": 1,
623
- "priority": 1,
624
- "subscriptions": [
625
- {
626
- "default": 2,
627
- },
628
- ],
629
- },
630
- ],
631
- "last_op_id": "4001",
632
- "streams": [
633
- {
634
- "errors": [],
635
- "is_default": true,
636
- "name": "b0a",
637
- },
638
- {
639
- "errors": [],
640
- "is_default": true,
641
- "name": "b0b",
642
- },
643
- {
644
- "errors": [],
645
- "is_default": true,
646
- "name": "b1",
647
- },
648
- ],
649
- "write_checkpoint": undefined,
650
- },
651
- },
652
- {
653
- "data": {
654
- "after": "0",
655
- "bucket": "b1[]",
656
- "data": undefined,
657
- "has_more": false,
658
- "next_after": "1",
659
- },
660
- },
661
- {
662
- "partial_checkpoint_complete": {
663
- "last_op_id": "4001",
664
- "priority": 1,
665
- },
666
- },
667
- {
668
- "data": {
669
- "after": "0",
670
- "bucket": "b0a[]",
671
- "data": undefined,
672
- "has_more": true,
673
- "next_after": "2000",
674
- },
675
- },
676
- {
677
- "data": {
678
- "after": "2000",
679
- "bucket": "b0a[]",
680
- "data": undefined,
681
- "has_more": true,
682
- "next_after": "4000",
683
- },
684
- },
685
- {
686
- "checkpoint_diff": {
687
- "last_op_id": "4004",
688
- "removed_buckets": [],
689
- "updated_buckets": [
690
- {
691
- "bucket": "b0a[]",
692
- "checksum": 883076828,
693
- "count": 2001,
694
- "priority": 2,
695
- "subscriptions": [
696
- {
697
- "default": 0,
698
- },
699
- ],
700
- },
701
- {
702
- "bucket": "b0b[]",
703
- "checksum": 883076828,
704
- "count": 2001,
705
- "priority": 2,
706
- "subscriptions": [
707
- {
708
- "default": 1,
709
- },
710
- ],
711
- },
712
- {
713
- "bucket": "b1[]",
714
- "checksum": 1841937527,
715
- "count": 2,
716
- "priority": 1,
717
- "subscriptions": [
718
- {
719
- "default": 2,
720
- },
721
- ],
722
- },
723
- ],
724
- "write_checkpoint": undefined,
725
- },
726
- },
727
- {
728
- "data": {
729
- "after": "1",
730
- "bucket": "b1[]",
731
- "data": undefined,
732
- "has_more": false,
733
- "next_after": "4002",
734
- },
735
- },
736
- {
737
- "partial_checkpoint_complete": {
738
- "last_op_id": "4004",
739
- "priority": 1,
740
- },
741
- },
742
- {
743
- "data": {
744
- "after": "4000",
745
- "bucket": "b0a[]",
746
- "data": undefined,
747
- "has_more": false,
748
- "next_after": "4003",
749
- },
750
- },
751
- {
752
- "data": {
753
- "after": "0",
754
- "bucket": "b0b[]",
755
- "data": undefined,
756
- "has_more": true,
757
- "next_after": "1999",
758
- },
759
- },
760
- {
761
- "data": {
762
- "after": "1999",
763
- "bucket": "b0b[]",
764
- "data": undefined,
765
- "has_more": true,
766
- "next_after": "3999",
767
- },
768
- },
769
- {
770
- "data": {
771
- "after": "3999",
772
- "bucket": "b0b[]",
773
- "data": undefined,
774
- "has_more": false,
775
- "next_after": "4004",
776
- },
777
- },
778
- {
779
- "checkpoint_complete": {
780
- "last_op_id": "4004",
781
- },
782
- },
783
- ]
784
- `;
785
-
786
- exports[`sync - postgres > storage v1 > sync legacy non-raw data 1`] = `
787
- [
788
- {
789
- "checkpoint": {
790
- "buckets": [
791
- {
792
- "bucket": "mybucket[]",
793
- "checksum": -852817836,
794
- "count": 1,
795
- "priority": 3,
796
- "subscriptions": [
797
- {
798
- "default": 0,
799
- },
800
- ],
801
- },
802
- ],
803
- "last_op_id": "1",
804
- "streams": [
805
- {
806
- "errors": [],
807
- "is_default": true,
808
- "name": "mybucket",
809
- },
810
- ],
811
- "write_checkpoint": undefined,
812
- },
813
- },
814
- {
815
- "data": {
816
- "after": "0",
817
- "bucket": "mybucket[]",
818
- "data": [
819
- {
820
- "checksum": 3442149460n,
821
- "data": {
822
- "description": "Test
823
- "string"",
824
- "id": "t1",
825
- "large_num": 12345678901234567890n,
826
- },
827
- "object_id": "t1",
828
- "object_type": "test",
829
- "op": "PUT",
830
- "op_id": "1",
831
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
832
- },
833
- ],
834
- "has_more": false,
835
- "next_after": "1",
836
- },
837
- },
838
- {
839
- "checkpoint_complete": {
840
- "last_op_id": "1",
841
- },
842
- },
843
- ]
844
- `;
845
-
846
- exports[`sync - postgres > storage v1 > sync updates to data query only 1`] = `
847
- [
848
- {
849
- "checkpoint": {
850
- "buckets": [
851
- {
852
- "bucket": "by_user["user1"]",
853
- "checksum": 0,
854
- "count": 0,
855
- "priority": 3,
856
- "subscriptions": [
857
- {
858
- "default": 0,
859
- },
860
- ],
861
- },
862
- ],
863
- "last_op_id": "1",
864
- "streams": [
865
- {
866
- "errors": [],
867
- "is_default": true,
868
- "name": "by_user",
869
- },
870
- ],
871
- "write_checkpoint": undefined,
872
- },
873
- },
874
- {
875
- "checkpoint_complete": {
876
- "last_op_id": "1",
877
- },
878
- },
879
- ]
880
- `;
881
-
882
- exports[`sync - postgres > storage v1 > sync updates to data query only 2`] = `
883
- [
884
- {
885
- "checkpoint_diff": {
886
- "last_op_id": "2",
887
- "removed_buckets": [],
888
- "updated_buckets": [
889
- {
890
- "bucket": "by_user["user1"]",
891
- "checksum": 1418351250,
892
- "count": 1,
893
- "priority": 3,
894
- "subscriptions": [
895
- {
896
- "default": 0,
897
- },
898
- ],
899
- },
900
- ],
901
- "write_checkpoint": undefined,
902
- },
903
- },
904
- {
905
- "data": {
906
- "after": "0",
907
- "bucket": "by_user["user1"]",
908
- "data": [
909
- {
910
- "checksum": 1418351250,
911
- "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
912
- "object_id": "list1",
913
- "object_type": "lists",
914
- "op": "PUT",
915
- "op_id": "2",
916
- "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
917
- },
918
- ],
919
- "has_more": false,
920
- "next_after": "2",
921
- },
922
- },
923
- {
924
- "checkpoint_complete": {
925
- "last_op_id": "2",
926
- },
927
- },
928
- ]
929
- `;
930
-
931
- exports[`sync - postgres > storage v1 > sync updates to global data 1`] = `
932
- [
933
- {
934
- "checkpoint": {
935
- "buckets": [
936
- {
937
- "bucket": "mybucket[]",
938
- "checksum": 0,
939
- "count": 0,
940
- "priority": 3,
941
- "subscriptions": [
942
- {
943
- "default": 0,
944
- },
945
- ],
946
- },
947
- ],
948
- "last_op_id": "0",
949
- "streams": [
950
- {
951
- "errors": [],
952
- "is_default": true,
953
- "name": "mybucket",
954
- },
955
- ],
956
- "write_checkpoint": undefined,
957
- },
958
- },
959
- {
960
- "checkpoint_complete": {
961
- "last_op_id": "0",
962
- },
963
- },
964
- ]
965
- `;
966
-
967
- exports[`sync - postgres > storage v1 > sync updates to global data 2`] = `
968
- [
969
- {
970
- "checkpoint_diff": {
971
- "last_op_id": "1",
972
- "removed_buckets": [],
973
- "updated_buckets": [
974
- {
975
- "bucket": "mybucket[]",
976
- "checksum": 920318466,
977
- "count": 1,
978
- "priority": 3,
979
- "subscriptions": [
980
- {
981
- "default": 0,
982
- },
983
- ],
984
- },
985
- ],
986
- "write_checkpoint": undefined,
987
- },
988
- },
989
- {
990
- "data": {
991
- "after": "0",
992
- "bucket": "mybucket[]",
993
- "data": [
994
- {
995
- "checksum": 920318466,
996
- "data": "{"id":"t1","description":"Test 1"}",
997
- "object_id": "t1",
998
- "object_type": "test",
999
- "op": "PUT",
1000
- "op_id": "1",
1001
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1002
- },
1003
- ],
1004
- "has_more": false,
1005
- "next_after": "1",
1006
- },
1007
- },
1008
- {
1009
- "checkpoint_complete": {
1010
- "last_op_id": "1",
1011
- },
1012
- },
1013
- ]
1014
- `;
1015
-
1016
- exports[`sync - postgres > storage v1 > sync updates to global data 3`] = `
1017
- [
1018
- {
1019
- "checkpoint_diff": {
1020
- "last_op_id": "2",
1021
- "removed_buckets": [],
1022
- "updated_buckets": [
1023
- {
1024
- "bucket": "mybucket[]",
1025
- "checksum": -93886621,
1026
- "count": 2,
1027
- "priority": 3,
1028
- "subscriptions": [
1029
- {
1030
- "default": 0,
1031
- },
1032
- ],
1033
- },
1034
- ],
1035
- "write_checkpoint": undefined,
1036
- },
1037
- },
1038
- {
1039
- "data": {
1040
- "after": "1",
1041
- "bucket": "mybucket[]",
1042
- "data": [
1043
- {
1044
- "checksum": 3280762209,
1045
- "data": "{"id":"t2","description":"Test 2"}",
1046
- "object_id": "t2",
1047
- "object_type": "test",
1048
- "op": "PUT",
1049
- "op_id": "2",
1050
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
1051
- },
1052
- ],
1053
- "has_more": false,
1054
- "next_after": "2",
1055
- },
1056
- },
1057
- {
1058
- "checkpoint_complete": {
1059
- "last_op_id": "2",
1060
- },
1061
- },
1062
- ]
1063
- `;
1064
-
1065
- exports[`sync - postgres > storage v1 > sync updates to parameter query + data 1`] = `
1066
- [
1067
- {
1068
- "checkpoint": {
1069
- "buckets": [],
1070
- "last_op_id": "0",
1071
- "streams": [
1072
- {
1073
- "errors": [],
1074
- "is_default": true,
1075
- "name": "by_user",
1076
- },
1077
- ],
1078
- "write_checkpoint": undefined,
1079
- },
1080
- },
1081
- {
1082
- "checkpoint_complete": {
1083
- "last_op_id": "0",
1084
- },
1085
- },
1086
- ]
1087
- `;
1088
-
1089
- exports[`sync - postgres > storage v1 > sync updates to parameter query + data 2`] = `
1090
- [
1091
- {
1092
- "checkpoint_diff": {
1093
- "last_op_id": "2",
1094
- "removed_buckets": [],
1095
- "updated_buckets": [
1096
- {
1097
- "bucket": "by_user["user1"]",
1098
- "checksum": 1418351250,
1099
- "count": 1,
1100
- "priority": 3,
1101
- "subscriptions": [
1102
- {
1103
- "default": 0,
1104
- },
1105
- ],
1106
- },
1107
- ],
1108
- "write_checkpoint": undefined,
1109
- },
1110
- },
1111
- {
1112
- "data": {
1113
- "after": "0",
1114
- "bucket": "by_user["user1"]",
1115
- "data": [
1116
- {
1117
- "checksum": 1418351250,
1118
- "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
1119
- "object_id": "list1",
1120
- "object_type": "lists",
1121
- "op": "PUT",
1122
- "op_id": "1",
1123
- "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
1124
- },
1125
- ],
1126
- "has_more": false,
1127
- "next_after": "1",
1128
- },
1129
- },
1130
- {
1131
- "checkpoint_complete": {
1132
- "last_op_id": "2",
1133
- },
1134
- },
1135
- ]
1136
- `;
1137
-
1138
- exports[`sync - postgres > storage v1 > sync updates to parameter query only 1`] = `
1139
- [
1140
- {
1141
- "checkpoint": {
1142
- "buckets": [],
1143
- "last_op_id": "0",
1144
- "streams": [
1145
- {
1146
- "errors": [],
1147
- "is_default": true,
1148
- "name": "by_user",
1149
- },
1150
- ],
1151
- "write_checkpoint": undefined,
1152
- },
1153
- },
1154
- {
1155
- "checkpoint_complete": {
1156
- "last_op_id": "0",
1157
- },
1158
- },
1159
- ]
1160
- `;
1161
-
1162
- exports[`sync - postgres > storage v1 > sync updates to parameter query only 2`] = `
1163
- [
1164
- {
1165
- "checkpoint_diff": {
1166
- "last_op_id": "1",
1167
- "removed_buckets": [],
1168
- "updated_buckets": [
1169
- {
1170
- "bucket": "by_user["user1"]",
1171
- "checksum": 0,
1172
- "count": 0,
1173
- "priority": 3,
1174
- "subscriptions": [
1175
- {
1176
- "default": 0,
1177
- },
1178
- ],
1179
- },
1180
- ],
1181
- "write_checkpoint": undefined,
1182
- },
1183
- },
1184
- {
1185
- "checkpoint_complete": {
1186
- "last_op_id": "1",
1187
- },
1188
- },
1189
- ]
1190
- `;
1191
-
1192
- exports[`sync - postgres > storage v2 > can override priority when subscribing to stream 1`] = `
1193
- [
1194
- {
1195
- "checkpoint": {
1196
- "buckets": [
1197
- {
1198
- "bucket": "1#todos|0["a"]",
1199
- "checksum": -1712802421,
1200
- "count": 1,
1201
- "priority": 0,
1202
- "subscriptions": [
1203
- {
1204
- "sub": 0,
1205
- },
1206
- {
1207
- "sub": 1,
1208
- },
1209
- ],
1210
- },
1211
- {
1212
- "bucket": "1#todos|0["b"]",
1213
- "checksum": -1291414318,
1214
- "count": 1,
1215
- "priority": 3,
1216
- "subscriptions": [
1217
- {
1218
- "sub": 1,
1219
- },
1220
- ],
1221
- },
1222
- ],
1223
- "last_op_id": "2",
1224
- "streams": [
1225
- {
1226
- "errors": [],
1227
- "is_default": false,
1228
- "name": "todos",
1229
- },
1230
- ],
1231
- "write_checkpoint": undefined,
1232
- },
1233
- },
1234
- {
1235
- "data": {
1236
- "after": "0",
1237
- "bucket": "1#todos|0["a"]",
1238
- "data": [
1239
- {
1240
- "checksum": 2582164875,
1241
- "data": "{"id":"a","description":"Test 1"}",
1242
- "object_id": "a",
1243
- "object_type": "test",
1244
- "op": "PUT",
1245
- "op_id": "1",
1246
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1247
- },
1248
- ],
1249
- "has_more": false,
1250
- "next_after": "1",
1251
- },
1252
- },
1253
- {
1254
- "partial_checkpoint_complete": {
1255
- "last_op_id": "2",
1256
- "priority": 0,
1257
- },
1258
- },
1259
- {
1260
- "data": {
1261
- "after": "0",
1262
- "bucket": "1#todos|0["b"]",
1263
- "data": [
1264
- {
1265
- "checksum": 3003552978,
1266
- "data": "{"id":"b","description":"Test 2"}",
1267
- "object_id": "b",
1268
- "object_type": "test",
1269
- "op": "PUT",
1270
- "op_id": "2",
1271
- "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
1272
- },
1273
- ],
1274
- "has_more": false,
1275
- "next_after": "2",
1276
- },
1277
- },
1278
- {
1279
- "checkpoint_complete": {
1280
- "last_op_id": "2",
1281
- },
1282
- },
1283
- ]
1284
- `;
1285
-
1286
- exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 1`] = `
1287
- [
1288
- {
1289
- "checkpoint": {
1290
- "buckets": [
1291
- {
1292
- "bucket": "1#mybucket[]",
1293
- "checksum": -93886621,
1294
- "count": 2,
1295
- "priority": 3,
1296
- "subscriptions": [
1297
- {
1298
- "default": 0,
1299
- },
1300
- ],
1301
- },
1302
- ],
1303
- "last_op_id": "2",
1304
- "streams": [
1305
- {
1306
- "errors": [],
1307
- "is_default": true,
1308
- "name": "mybucket",
1309
- },
1310
- ],
1311
- "write_checkpoint": undefined,
1312
- },
1313
- },
1314
- ]
1315
- `;
1316
-
1317
- exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 2`] = `
1318
- [
1319
- {
1320
- "data": {
1321
- "after": "0",
1322
- "bucket": "1#mybucket[]",
1323
- "data": [
1324
- {
1325
- "checksum": -93886621,
1326
- "op": "CLEAR",
1327
- "op_id": "2",
1328
- },
1329
- ],
1330
- "has_more": false,
1331
- "next_after": "2",
1332
- },
1333
- },
1334
- {
1335
- "checkpoint_diff": {
1336
- "last_op_id": "4",
1337
- "removed_buckets": [],
1338
- "updated_buckets": [
1339
- {
1340
- "bucket": "1#mybucket[]",
1341
- "checksum": 499012468,
1342
- "count": 4,
1343
- "priority": 3,
1344
- "subscriptions": [
1345
- {
1346
- "default": 0,
1347
- },
1348
- ],
1349
- },
1350
- ],
1351
- "write_checkpoint": undefined,
1352
- },
1353
- },
1354
- {
1355
- "data": {
1356
- "after": "2",
1357
- "bucket": "1#mybucket[]",
1358
- "data": [
1359
- {
1360
- "checksum": 1859363232,
1361
- "data": "{"id":"t1","description":"Test 1b"}",
1362
- "object_id": "t1",
1363
- "object_type": "test",
1364
- "op": "PUT",
1365
- "op_id": "3",
1366
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1367
- },
1368
- {
1369
- "checksum": 3028503153,
1370
- "data": "{"id":"t2","description":"Test 2b"}",
1371
- "object_id": "t2",
1372
- "object_type": "test",
1373
- "op": "PUT",
1374
- "op_id": "4",
1375
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
1376
- },
1377
- ],
1378
- "has_more": false,
1379
- "next_after": "4",
1380
- },
1381
- },
1382
- {
1383
- "checkpoint_complete": {
1384
- "last_op_id": "4",
1385
- },
1386
- },
1387
- ]
1388
- `;
1389
-
1390
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 1`] = `
1391
- [
1392
- {
1393
- "checkpoint": {
1394
- "buckets": [
1395
- {
1396
- "bucket": "1#test|0[]",
1397
- "checksum": 920318466,
1398
- "count": 1,
1399
- "priority": 3,
1400
- "subscriptions": [
1401
- {
1402
- "default": 0,
1403
- },
1404
- ],
1405
- },
1406
- ],
1407
- "last_op_id": "1",
1408
- "streams": [
1409
- {
1410
- "errors": [],
1411
- "is_default": true,
1412
- "name": "test",
1413
- },
1414
- ],
1415
- "write_checkpoint": undefined,
1416
- },
1417
- },
1418
- {
1419
- "data": {
1420
- "after": "0",
1421
- "bucket": "1#test|0[]",
1422
- "data": [
1423
- {
1424
- "checksum": 920318466,
1425
- "data": "{"id":"t1","description":"Test 1"}",
1426
- "object_id": "t1",
1427
- "object_type": "test",
1428
- "op": "PUT",
1429
- "op_id": "1",
1430
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1431
- },
1432
- ],
1433
- "has_more": false,
1434
- "next_after": "1",
1435
- },
1436
- },
1437
- {
1438
- "checkpoint_complete": {
1439
- "last_op_id": "1",
1440
- },
1441
- },
1442
- ]
1443
- `;
1444
-
1445
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 2`] = `
1446
- [
1447
- {
1448
- "checkpoint": {
1449
- "buckets": [
1450
- {
1451
- "bucket": "2#test2|0[]",
1452
- "checksum": 920318466,
1453
- "count": 1,
1454
- "priority": 3,
1455
- "subscriptions": [
1456
- {
1457
- "default": 0,
1458
- },
1459
- ],
1460
- },
1461
- ],
1462
- "last_op_id": "2",
1463
- "streams": [
1464
- {
1465
- "errors": [],
1466
- "is_default": true,
1467
- "name": "test2",
1468
- },
1469
- ],
1470
- "write_checkpoint": undefined,
1471
- },
1472
- },
1473
- {
1474
- "data": {
1475
- "after": "0",
1476
- "bucket": "2#test2|0[]",
1477
- "data": [
1478
- {
1479
- "checksum": 920318466,
1480
- "data": "{"id":"t1","description":"Test 1"}",
1481
- "object_id": "t1",
1482
- "object_type": "test",
1483
- "op": "PUT",
1484
- "op_id": "2",
1485
- "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
1486
- },
1487
- ],
1488
- "has_more": false,
1489
- "next_after": "2",
1490
- },
1491
- },
1492
- {
1493
- "checkpoint_complete": {
1494
- "last_op_id": "2",
1495
- },
1496
- },
1497
- ]
1498
- `;
1499
-
1500
- exports[`sync - postgres > storage v2 > expired token 1`] = `
1501
- [
1502
- {
1503
- "token_expires_in": 0,
1504
- },
1505
- ]
1506
- `;
1507
-
1508
- exports[`sync - postgres > storage v2 > expiring token 1`] = `
1509
- [
1510
- {
1511
- "checkpoint": {
1512
- "buckets": [
1513
- {
1514
- "bucket": "1#mybucket[]",
1515
- "checksum": 0,
1516
- "count": 0,
1517
- "priority": 3,
1518
- "subscriptions": [
1519
- {
1520
- "default": 0,
1521
- },
1522
- ],
1523
- },
1524
- ],
1525
- "last_op_id": "0",
1526
- "streams": [
1527
- {
1528
- "errors": [],
1529
- "is_default": true,
1530
- "name": "mybucket",
1531
- },
1532
- ],
1533
- "write_checkpoint": undefined,
1534
- },
1535
- },
1536
- {
1537
- "checkpoint_complete": {
1538
- "last_op_id": "0",
1539
- },
1540
- },
1541
- ]
1542
- `;
1543
-
1544
- exports[`sync - postgres > storage v2 > expiring token 2`] = `
1545
- [
1546
- {
1547
- "token_expires_in": 0,
1548
- },
1549
- ]
1550
- `;
1551
-
1552
- exports[`sync - postgres > storage v2 > sends checkpoint complete line for empty checkpoint 1`] = `
1553
- [
1554
- {
1555
- "checkpoint": {
1556
- "buckets": [
1557
- {
1558
- "bucket": "1#mybucket[]",
1559
- "checksum": -1221282404,
1560
- "count": 1,
1561
- "priority": 3,
1562
- "subscriptions": [
1563
- {
1564
- "default": 0,
1565
- },
1566
- ],
1567
- },
1568
- ],
1569
- "last_op_id": "1",
1570
- "streams": [
1571
- {
1572
- "errors": [],
1573
- "is_default": true,
1574
- "name": "mybucket",
1575
- },
1576
- ],
1577
- "write_checkpoint": undefined,
1578
- },
1579
- },
1580
- {
1581
- "data": {
1582
- "after": "0",
1583
- "bucket": "1#mybucket[]",
1584
- "data": [
1585
- {
1586
- "checksum": 3073684892,
1587
- "data": "{"id":"t1","description":"sync"}",
1588
- "object_id": "t1",
1589
- "object_type": "test",
1590
- "op": "PUT",
1591
- "op_id": "1",
1592
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1593
- },
1594
- ],
1595
- "has_more": false,
1596
- "next_after": "1",
1597
- },
1598
- },
1599
- null,
1600
- {
1601
- "checkpoint_complete": {
1602
- "last_op_id": "1",
1603
- },
1604
- },
1605
- {
1606
- "checkpoint_diff": {
1607
- "last_op_id": "1",
1608
- "removed_buckets": [],
1609
- "updated_buckets": [],
1610
- "write_checkpoint": "1",
1611
- },
1612
- },
1613
- {
1614
- "checkpoint_complete": {
1615
- "last_op_id": "1",
1616
- },
1617
- },
1618
- ]
1619
- `;
1620
-
1621
- exports[`sync - postgres > storage v2 > sync buckets in order 1`] = `
1622
- [
1623
- {
1624
- "checkpoint": {
1625
- "buckets": [
1626
- {
1627
- "bucket": "1#b0[]",
1628
- "checksum": 920318466,
1629
- "count": 1,
1630
- "priority": 2,
1631
- "subscriptions": [
1632
- {
1633
- "default": 0,
1634
- },
1635
- ],
1636
- },
1637
- {
1638
- "bucket": "1#b1[]",
1639
- "checksum": -1382098757,
1640
- "count": 1,
1641
- "priority": 1,
1642
- "subscriptions": [
1643
- {
1644
- "default": 1,
1645
- },
1646
- ],
1647
- },
1648
- ],
1649
- "last_op_id": "2",
1650
- "streams": [
1651
- {
1652
- "errors": [],
1653
- "is_default": true,
1654
- "name": "b0",
1655
- },
1656
- {
1657
- "errors": [],
1658
- "is_default": true,
1659
- "name": "b1",
1660
- },
1661
- ],
1662
- "write_checkpoint": undefined,
1663
- },
1664
- },
1665
- {
1666
- "data": {
1667
- "after": "0",
1668
- "bucket": "1#b1[]",
1669
- "data": [
1670
- {
1671
- "checksum": 2912868539,
1672
- "data": "{"id":"earlier","description":"Test 2"}",
1673
- "object_id": "earlier",
1674
- "object_type": "test",
1675
- "op": "PUT",
1676
- "op_id": "2",
1677
- "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
1678
- },
1679
- ],
1680
- "has_more": false,
1681
- "next_after": "2",
1682
- },
1683
- },
1684
- {
1685
- "partial_checkpoint_complete": {
1686
- "last_op_id": "2",
1687
- "priority": 1,
1688
- },
1689
- },
1690
- {
1691
- "data": {
1692
- "after": "0",
1693
- "bucket": "1#b0[]",
1694
- "data": [
1695
- {
1696
- "checksum": 920318466,
1697
- "data": "{"id":"t1","description":"Test 1"}",
1698
- "object_id": "t1",
1699
- "object_type": "test",
1700
- "op": "PUT",
1701
- "op_id": "1",
1702
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1703
- },
1704
- ],
1705
- "has_more": false,
1706
- "next_after": "1",
1707
- },
1708
- },
1709
- {
1710
- "checkpoint_complete": {
1711
- "last_op_id": "2",
1712
- },
1713
- },
1714
- ]
1715
- `;
1716
-
1717
- exports[`sync - postgres > storage v2 > sync global data 1`] = `
1718
- [
1719
- {
1720
- "checkpoint": {
1721
- "buckets": [
1722
- {
1723
- "bucket": "1#mybucket[]",
1724
- "checksum": -93886621,
1725
- "count": 2,
1726
- "priority": 3,
1727
- "subscriptions": [
1728
- {
1729
- "default": 0,
1730
- },
1731
- ],
1732
- },
1733
- ],
1734
- "last_op_id": "2",
1735
- "streams": [
1736
- {
1737
- "errors": [],
1738
- "is_default": true,
1739
- "name": "mybucket",
1740
- },
1741
- ],
1742
- "write_checkpoint": undefined,
1743
- },
1744
- },
1745
- {
1746
- "data": {
1747
- "after": "0",
1748
- "bucket": "1#mybucket[]",
1749
- "data": [
1750
- {
1751
- "checksum": 920318466,
1752
- "data": "{"id":"t1","description":"Test 1"}",
1753
- "object_id": "t1",
1754
- "object_type": "test",
1755
- "op": "PUT",
1756
- "op_id": "1",
1757
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1758
- },
1759
- {
1760
- "checksum": 3280762209,
1761
- "data": "{"id":"t2","description":"Test 2"}",
1762
- "object_id": "t2",
1763
- "object_type": "test",
1764
- "op": "PUT",
1765
- "op_id": "2",
1766
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
1767
- },
1768
- ],
1769
- "has_more": false,
1770
- "next_after": "2",
1771
- },
1772
- },
1773
- {
1774
- "checkpoint_complete": {
1775
- "last_op_id": "2",
1776
- },
1777
- },
1778
- ]
1779
- `;
1780
-
1781
- exports[`sync - postgres > storage v2 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
1782
- [
1783
- {
1784
- "checkpoint": {
1785
- "buckets": [
1786
- {
1787
- "bucket": "1#b0a[]",
1788
- "checksum": -659831575,
1789
- "count": 2000,
1790
- "priority": 2,
1791
- "subscriptions": [
1792
- {
1793
- "default": 0,
1794
- },
1795
- ],
1796
- },
1797
- {
1798
- "bucket": "1#b0b[]",
1799
- "checksum": -659831575,
1800
- "count": 2000,
1801
- "priority": 2,
1802
- "subscriptions": [
1803
- {
1804
- "default": 1,
1805
- },
1806
- ],
1807
- },
1808
- {
1809
- "bucket": "1#b1[]",
1810
- "checksum": -1096116670,
1811
- "count": 1,
1812
- "priority": 1,
1813
- "subscriptions": [
1814
- {
1815
- "default": 2,
1816
- },
1817
- ],
1818
- },
1819
- ],
1820
- "last_op_id": "4001",
1821
- "streams": [
1822
- {
1823
- "errors": [],
1824
- "is_default": true,
1825
- "name": "b0a",
1826
- },
1827
- {
1828
- "errors": [],
1829
- "is_default": true,
1830
- "name": "b0b",
1831
- },
1832
- {
1833
- "errors": [],
1834
- "is_default": true,
1835
- "name": "b1",
1836
- },
1837
- ],
1838
- "write_checkpoint": undefined,
1839
- },
1840
- },
1841
- {
1842
- "data": {
1843
- "after": "0",
1844
- "bucket": "1#b1[]",
1845
- "data": undefined,
1846
- "has_more": false,
1847
- "next_after": "1",
1848
- },
1849
- },
1850
- {
1851
- "partial_checkpoint_complete": {
1852
- "last_op_id": "4001",
1853
- "priority": 1,
1854
- },
1855
- },
1856
- {
1857
- "data": {
1858
- "after": "0",
1859
- "bucket": "1#b0a[]",
1860
- "data": undefined,
1861
- "has_more": true,
1862
- "next_after": "2000",
1863
- },
1864
- },
1865
- {
1866
- "data": {
1867
- "after": "2000",
1868
- "bucket": "1#b0a[]",
1869
- "data": undefined,
1870
- "has_more": true,
1871
- "next_after": "4000",
1872
- },
1873
- },
1874
- {
1875
- "checkpoint_diff": {
1876
- "last_op_id": "4004",
1877
- "removed_buckets": [],
1878
- "updated_buckets": [
1879
- {
1880
- "bucket": "1#b0a[]",
1881
- "checksum": 883076828,
1882
- "count": 2001,
1883
- "priority": 2,
1884
- "subscriptions": [
1885
- {
1886
- "default": 0,
1887
- },
1888
- ],
1889
- },
1890
- {
1891
- "bucket": "1#b0b[]",
1892
- "checksum": 883076828,
1893
- "count": 2001,
1894
- "priority": 2,
1895
- "subscriptions": [
1896
- {
1897
- "default": 1,
1898
- },
1899
- ],
1900
- },
1901
- {
1902
- "bucket": "1#b1[]",
1903
- "checksum": 1841937527,
1904
- "count": 2,
1905
- "priority": 1,
1906
- "subscriptions": [
1907
- {
1908
- "default": 2,
1909
- },
1910
- ],
1911
- },
1912
- ],
1913
- "write_checkpoint": undefined,
1914
- },
1915
- },
1916
- {
1917
- "data": {
1918
- "after": "1",
1919
- "bucket": "1#b1[]",
1920
- "data": undefined,
1921
- "has_more": false,
1922
- "next_after": "4002",
1923
- },
1924
- },
1925
- {
1926
- "partial_checkpoint_complete": {
1927
- "last_op_id": "4004",
1928
- "priority": 1,
1929
- },
1930
- },
1931
- {
1932
- "data": {
1933
- "after": "4000",
1934
- "bucket": "1#b0a[]",
1935
- "data": undefined,
1936
- "has_more": false,
1937
- "next_after": "4003",
1938
- },
1939
- },
1940
- {
1941
- "data": {
1942
- "after": "0",
1943
- "bucket": "1#b0b[]",
1944
- "data": undefined,
1945
- "has_more": true,
1946
- "next_after": "1999",
1947
- },
1948
- },
1949
- {
1950
- "data": {
1951
- "after": "1999",
1952
- "bucket": "1#b0b[]",
1953
- "data": undefined,
1954
- "has_more": true,
1955
- "next_after": "3999",
1956
- },
1957
- },
1958
- {
1959
- "data": {
1960
- "after": "3999",
1961
- "bucket": "1#b0b[]",
1962
- "data": undefined,
1963
- "has_more": false,
1964
- "next_after": "4004",
1965
- },
1966
- },
1967
- {
1968
- "checkpoint_complete": {
1969
- "last_op_id": "4004",
1970
- },
1971
- },
1972
- ]
1973
- `;
1974
-
1975
- exports[`sync - postgres > storage v2 > sync legacy non-raw data 1`] = `
592
+ exports[`sync - postgres > storage v1 > sync legacy non-raw data 1`] = `
1976
593
  [
1977
594
  {
1978
595
  "checkpoint": {
1979
596
  "buckets": [
1980
597
  {
1981
- "bucket": "1#mybucket[]",
598
+ "bucket": "mybucket[]",
1982
599
  "checksum": -852817836,
1983
600
  "count": 1,
1984
601
  "priority": 3,
@@ -2003,7 +620,7 @@ exports[`sync - postgres > storage v2 > sync legacy non-raw data 1`] = `
2003
620
  {
2004
621
  "data": {
2005
622
  "after": "0",
2006
- "bucket": "1#mybucket[]",
623
+ "bucket": "mybucket[]",
2007
624
  "data": [
2008
625
  {
2009
626
  "checksum": 3442149460n,
@@ -2032,13 +649,13 @@ exports[`sync - postgres > storage v2 > sync legacy non-raw data 1`] = `
2032
649
  ]
2033
650
  `;
2034
651
 
2035
- exports[`sync - postgres > storage v2 > sync updates to data query only 1`] = `
652
+ exports[`sync - postgres > storage v1 > sync updates to data query only 1`] = `
2036
653
  [
2037
654
  {
2038
655
  "checkpoint": {
2039
656
  "buckets": [
2040
657
  {
2041
- "bucket": "1#by_user["user1"]",
658
+ "bucket": "by_user["user1"]",
2042
659
  "checksum": 0,
2043
660
  "count": 0,
2044
661
  "priority": 3,
@@ -2068,7 +685,7 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 1`] = `
2068
685
  ]
2069
686
  `;
2070
687
 
2071
- exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
688
+ exports[`sync - postgres > storage v1 > sync updates to data query only 2`] = `
2072
689
  [
2073
690
  {
2074
691
  "checkpoint_diff": {
@@ -2076,7 +693,7 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
2076
693
  "removed_buckets": [],
2077
694
  "updated_buckets": [
2078
695
  {
2079
- "bucket": "1#by_user["user1"]",
696
+ "bucket": "by_user["user1"]",
2080
697
  "checksum": 1418351250,
2081
698
  "count": 1,
2082
699
  "priority": 3,
@@ -2093,7 +710,7 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
2093
710
  {
2094
711
  "data": {
2095
712
  "after": "0",
2096
- "bucket": "1#by_user["user1"]",
713
+ "bucket": "by_user["user1"]",
2097
714
  "data": [
2098
715
  {
2099
716
  "checksum": 1418351250,
@@ -2117,13 +734,13 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
2117
734
  ]
2118
735
  `;
2119
736
 
2120
- exports[`sync - postgres > storage v2 > sync updates to global data 1`] = `
737
+ exports[`sync - postgres > storage v1 > sync updates to global data 1`] = `
2121
738
  [
2122
739
  {
2123
740
  "checkpoint": {
2124
741
  "buckets": [
2125
742
  {
2126
- "bucket": "1#mybucket[]",
743
+ "bucket": "mybucket[]",
2127
744
  "checksum": 0,
2128
745
  "count": 0,
2129
746
  "priority": 3,
@@ -2153,7 +770,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 1`] = `
2153
770
  ]
2154
771
  `;
2155
772
 
2156
- exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
773
+ exports[`sync - postgres > storage v1 > sync updates to global data 2`] = `
2157
774
  [
2158
775
  {
2159
776
  "checkpoint_diff": {
@@ -2161,7 +778,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
2161
778
  "removed_buckets": [],
2162
779
  "updated_buckets": [
2163
780
  {
2164
- "bucket": "1#mybucket[]",
781
+ "bucket": "mybucket[]",
2165
782
  "checksum": 920318466,
2166
783
  "count": 1,
2167
784
  "priority": 3,
@@ -2178,7 +795,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
2178
795
  {
2179
796
  "data": {
2180
797
  "after": "0",
2181
- "bucket": "1#mybucket[]",
798
+ "bucket": "mybucket[]",
2182
799
  "data": [
2183
800
  {
2184
801
  "checksum": 920318466,
@@ -2202,7 +819,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
2202
819
  ]
2203
820
  `;
2204
821
 
2205
- exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
822
+ exports[`sync - postgres > storage v1 > sync updates to global data 3`] = `
2206
823
  [
2207
824
  {
2208
825
  "checkpoint_diff": {
@@ -2210,7 +827,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
2210
827
  "removed_buckets": [],
2211
828
  "updated_buckets": [
2212
829
  {
2213
- "bucket": "1#mybucket[]",
830
+ "bucket": "mybucket[]",
2214
831
  "checksum": -93886621,
2215
832
  "count": 2,
2216
833
  "priority": 3,
@@ -2227,7 +844,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
2227
844
  {
2228
845
  "data": {
2229
846
  "after": "1",
2230
- "bucket": "1#mybucket[]",
847
+ "bucket": "mybucket[]",
2231
848
  "data": [
2232
849
  {
2233
850
  "checksum": 3280762209,
@@ -2251,7 +868,7 @@ exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
2251
868
  ]
2252
869
  `;
2253
870
 
2254
- exports[`sync - postgres > storage v2 > sync updates to parameter query + data 1`] = `
871
+ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 1`] = `
2255
872
  [
2256
873
  {
2257
874
  "checkpoint": {
@@ -2275,7 +892,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 1
2275
892
  ]
2276
893
  `;
2277
894
 
2278
- exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2`] = `
895
+ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 2`] = `
2279
896
  [
2280
897
  {
2281
898
  "checkpoint_diff": {
@@ -2283,7 +900,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2
2283
900
  "removed_buckets": [],
2284
901
  "updated_buckets": [
2285
902
  {
2286
- "bucket": "1#by_user["user1"]",
903
+ "bucket": "by_user["user1"]",
2287
904
  "checksum": 1418351250,
2288
905
  "count": 1,
2289
906
  "priority": 3,
@@ -2300,7 +917,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2
2300
917
  {
2301
918
  "data": {
2302
919
  "after": "0",
2303
- "bucket": "1#by_user["user1"]",
920
+ "bucket": "by_user["user1"]",
2304
921
  "data": [
2305
922
  {
2306
923
  "checksum": 1418351250,
@@ -2324,7 +941,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2
2324
941
  ]
2325
942
  `;
2326
943
 
2327
- exports[`sync - postgres > storage v2 > sync updates to parameter query only 1`] = `
944
+ exports[`sync - postgres > storage v1 > sync updates to parameter query only 1`] = `
2328
945
  [
2329
946
  {
2330
947
  "checkpoint": {
@@ -2348,7 +965,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 1`]
2348
965
  ]
2349
966
  `;
2350
967
 
2351
- exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`] = `
968
+ exports[`sync - postgres > storage v1 > sync updates to parameter query only 2`] = `
2352
969
  [
2353
970
  {
2354
971
  "checkpoint_diff": {
@@ -2356,7 +973,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`]
2356
973
  "removed_buckets": [],
2357
974
  "updated_buckets": [
2358
975
  {
2359
- "bucket": "1#by_user["user1"]",
976
+ "bucket": "by_user["user1"]",
2360
977
  "checksum": 0,
2361
978
  "count": 0,
2362
979
  "priority": 3,
@@ -2378,7 +995,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`]
2378
995
  ]
2379
996
  `;
2380
997
 
2381
- exports[`sync - postgres > storage v3 > can override priority when subscribing to stream 1`] = `
998
+ exports[`sync - postgres > storage v2 > can override priority when subscribing to stream 1`] = `
2382
999
  [
2383
1000
  {
2384
1001
  "checkpoint": {
@@ -2472,7 +1089,7 @@ exports[`sync - postgres > storage v3 > can override priority when subscribing t
2472
1089
  ]
2473
1090
  `;
2474
1091
 
2475
- exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 1`] = `
1092
+ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 1`] = `
2476
1093
  [
2477
1094
  {
2478
1095
  "checkpoint": {
@@ -2503,7 +1120,7 @@ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint
2503
1120
  ]
2504
1121
  `;
2505
1122
 
2506
- exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 2`] = `
1123
+ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 2`] = `
2507
1124
  [
2508
1125
  {
2509
1126
  "data": {
@@ -2576,7 +1193,7 @@ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint
2576
1193
  ]
2577
1194
  `;
2578
1195
 
2579
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 1`] = `
1196
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 1`] = `
2580
1197
  [
2581
1198
  {
2582
1199
  "checkpoint": {
@@ -2631,7 +1248,7 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for str
2631
1248
  ]
2632
1249
  `;
2633
1250
 
2634
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 2`] = `
1251
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 2`] = `
2635
1252
  [
2636
1253
  {
2637
1254
  "checkpoint": {
@@ -2686,7 +1303,7 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for str
2686
1303
  ]
2687
1304
  `;
2688
1305
 
2689
- exports[`sync - postgres > storage v3 > expired token 1`] = `
1306
+ exports[`sync - postgres > storage v2 > expired token 1`] = `
2690
1307
  [
2691
1308
  {
2692
1309
  "token_expires_in": 0,
@@ -2694,7 +1311,7 @@ exports[`sync - postgres > storage v3 > expired token 1`] = `
2694
1311
  ]
2695
1312
  `;
2696
1313
 
2697
- exports[`sync - postgres > storage v3 > expiring token 1`] = `
1314
+ exports[`sync - postgres > storage v2 > expiring token 1`] = `
2698
1315
  [
2699
1316
  {
2700
1317
  "checkpoint": {
@@ -2730,7 +1347,7 @@ exports[`sync - postgres > storage v3 > expiring token 1`] = `
2730
1347
  ]
2731
1348
  `;
2732
1349
 
2733
- exports[`sync - postgres > storage v3 > expiring token 2`] = `
1350
+ exports[`sync - postgres > storage v2 > expiring token 2`] = `
2734
1351
  [
2735
1352
  {
2736
1353
  "token_expires_in": 0,
@@ -2738,7 +1355,7 @@ exports[`sync - postgres > storage v3 > expiring token 2`] = `
2738
1355
  ]
2739
1356
  `;
2740
1357
 
2741
- exports[`sync - postgres > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
1358
+ exports[`sync - postgres > storage v2 > sends checkpoint complete line for empty checkpoint 1`] = `
2742
1359
  [
2743
1360
  {
2744
1361
  "checkpoint": {
@@ -2807,7 +1424,7 @@ exports[`sync - postgres > storage v3 > sends checkpoint complete line for empty
2807
1424
  ]
2808
1425
  `;
2809
1426
 
2810
- exports[`sync - postgres > storage v3 > sync buckets in order 1`] = `
1427
+ exports[`sync - postgres > storage v2 > sync buckets in order 1`] = `
2811
1428
  [
2812
1429
  {
2813
1430
  "checkpoint": {
@@ -2903,7 +1520,7 @@ exports[`sync - postgres > storage v3 > sync buckets in order 1`] = `
2903
1520
  ]
2904
1521
  `;
2905
1522
 
2906
- exports[`sync - postgres > storage v3 > sync global data 1`] = `
1523
+ exports[`sync - postgres > storage v2 > sync global data 1`] = `
2907
1524
  [
2908
1525
  {
2909
1526
  "checkpoint": {
@@ -2967,201 +1584,7 @@ exports[`sync - postgres > storage v3 > sync global data 1`] = `
2967
1584
  ]
2968
1585
  `;
2969
1586
 
2970
- exports[`sync - postgres > storage v3 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
2971
- [
2972
- {
2973
- "checkpoint": {
2974
- "buckets": [
2975
- {
2976
- "bucket": "1#b0a[]",
2977
- "checksum": -659831575,
2978
- "count": 2000,
2979
- "priority": 2,
2980
- "subscriptions": [
2981
- {
2982
- "default": 0,
2983
- },
2984
- ],
2985
- },
2986
- {
2987
- "bucket": "1#b0b[]",
2988
- "checksum": -659831575,
2989
- "count": 2000,
2990
- "priority": 2,
2991
- "subscriptions": [
2992
- {
2993
- "default": 1,
2994
- },
2995
- ],
2996
- },
2997
- {
2998
- "bucket": "1#b1[]",
2999
- "checksum": -1096116670,
3000
- "count": 1,
3001
- "priority": 1,
3002
- "subscriptions": [
3003
- {
3004
- "default": 2,
3005
- },
3006
- ],
3007
- },
3008
- ],
3009
- "last_op_id": "4001",
3010
- "streams": [
3011
- {
3012
- "errors": [],
3013
- "is_default": true,
3014
- "name": "b0a",
3015
- },
3016
- {
3017
- "errors": [],
3018
- "is_default": true,
3019
- "name": "b0b",
3020
- },
3021
- {
3022
- "errors": [],
3023
- "is_default": true,
3024
- "name": "b1",
3025
- },
3026
- ],
3027
- "write_checkpoint": undefined,
3028
- },
3029
- },
3030
- {
3031
- "data": {
3032
- "after": "0",
3033
- "bucket": "1#b1[]",
3034
- "data": undefined,
3035
- "has_more": false,
3036
- "next_after": "1",
3037
- },
3038
- },
3039
- {
3040
- "partial_checkpoint_complete": {
3041
- "last_op_id": "4001",
3042
- "priority": 1,
3043
- },
3044
- },
3045
- {
3046
- "data": {
3047
- "after": "0",
3048
- "bucket": "1#b0a[]",
3049
- "data": undefined,
3050
- "has_more": true,
3051
- "next_after": "2000",
3052
- },
3053
- },
3054
- {
3055
- "data": {
3056
- "after": "2000",
3057
- "bucket": "1#b0a[]",
3058
- "data": undefined,
3059
- "has_more": true,
3060
- "next_after": "4000",
3061
- },
3062
- },
3063
- {
3064
- "checkpoint_diff": {
3065
- "last_op_id": "4004",
3066
- "removed_buckets": [],
3067
- "updated_buckets": [
3068
- {
3069
- "bucket": "1#b0a[]",
3070
- "checksum": 883076828,
3071
- "count": 2001,
3072
- "priority": 2,
3073
- "subscriptions": [
3074
- {
3075
- "default": 0,
3076
- },
3077
- ],
3078
- },
3079
- {
3080
- "bucket": "1#b0b[]",
3081
- "checksum": 883076828,
3082
- "count": 2001,
3083
- "priority": 2,
3084
- "subscriptions": [
3085
- {
3086
- "default": 1,
3087
- },
3088
- ],
3089
- },
3090
- {
3091
- "bucket": "1#b1[]",
3092
- "checksum": 1841937527,
3093
- "count": 2,
3094
- "priority": 1,
3095
- "subscriptions": [
3096
- {
3097
- "default": 2,
3098
- },
3099
- ],
3100
- },
3101
- ],
3102
- "write_checkpoint": undefined,
3103
- },
3104
- },
3105
- {
3106
- "data": {
3107
- "after": "1",
3108
- "bucket": "1#b1[]",
3109
- "data": undefined,
3110
- "has_more": false,
3111
- "next_after": "4002",
3112
- },
3113
- },
3114
- {
3115
- "partial_checkpoint_complete": {
3116
- "last_op_id": "4004",
3117
- "priority": 1,
3118
- },
3119
- },
3120
- {
3121
- "data": {
3122
- "after": "4000",
3123
- "bucket": "1#b0a[]",
3124
- "data": undefined,
3125
- "has_more": false,
3126
- "next_after": "4003",
3127
- },
3128
- },
3129
- {
3130
- "data": {
3131
- "after": "0",
3132
- "bucket": "1#b0b[]",
3133
- "data": undefined,
3134
- "has_more": true,
3135
- "next_after": "1999",
3136
- },
3137
- },
3138
- {
3139
- "data": {
3140
- "after": "1999",
3141
- "bucket": "1#b0b[]",
3142
- "data": undefined,
3143
- "has_more": true,
3144
- "next_after": "3999",
3145
- },
3146
- },
3147
- {
3148
- "data": {
3149
- "after": "3999",
3150
- "bucket": "1#b0b[]",
3151
- "data": undefined,
3152
- "has_more": false,
3153
- "next_after": "4004",
3154
- },
3155
- },
3156
- {
3157
- "checkpoint_complete": {
3158
- "last_op_id": "4004",
3159
- },
3160
- },
3161
- ]
3162
- `;
3163
-
3164
- exports[`sync - postgres > storage v3 > sync legacy non-raw data 1`] = `
1587
+ exports[`sync - postgres > storage v2 > sync legacy non-raw data 1`] = `
3165
1588
  [
3166
1589
  {
3167
1590
  "checkpoint": {
@@ -3221,7 +1644,7 @@ exports[`sync - postgres > storage v3 > sync legacy non-raw data 1`] = `
3221
1644
  ]
3222
1645
  `;
3223
1646
 
3224
- exports[`sync - postgres > storage v3 > sync updates to data query only 1`] = `
1647
+ exports[`sync - postgres > storage v2 > sync updates to data query only 1`] = `
3225
1648
  [
3226
1649
  {
3227
1650
  "checkpoint": {
@@ -3257,7 +1680,7 @@ exports[`sync - postgres > storage v3 > sync updates to data query only 1`] = `
3257
1680
  ]
3258
1681
  `;
3259
1682
 
3260
- exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
1683
+ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
3261
1684
  [
3262
1685
  {
3263
1686
  "checkpoint_diff": {
@@ -3306,7 +1729,7 @@ exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
3306
1729
  ]
3307
1730
  `;
3308
1731
 
3309
- exports[`sync - postgres > storage v3 > sync updates to global data 1`] = `
1732
+ exports[`sync - postgres > storage v2 > sync updates to global data 1`] = `
3310
1733
  [
3311
1734
  {
3312
1735
  "checkpoint": {
@@ -3342,7 +1765,7 @@ exports[`sync - postgres > storage v3 > sync updates to global data 1`] = `
3342
1765
  ]
3343
1766
  `;
3344
1767
 
3345
- exports[`sync - postgres > storage v3 > sync updates to global data 2`] = `
1768
+ exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
3346
1769
  [
3347
1770
  {
3348
1771
  "checkpoint_diff": {
@@ -3391,7 +1814,7 @@ exports[`sync - postgres > storage v3 > sync updates to global data 2`] = `
3391
1814
  ]
3392
1815
  `;
3393
1816
 
3394
- exports[`sync - postgres > storage v3 > sync updates to global data 3`] = `
1817
+ exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
3395
1818
  [
3396
1819
  {
3397
1820
  "checkpoint_diff": {
@@ -3440,7 +1863,7 @@ exports[`sync - postgres > storage v3 > sync updates to global data 3`] = `
3440
1863
  ]
3441
1864
  `;
3442
1865
 
3443
- exports[`sync - postgres > storage v3 > sync updates to parameter query + data 1`] = `
1866
+ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 1`] = `
3444
1867
  [
3445
1868
  {
3446
1869
  "checkpoint": {
@@ -3464,7 +1887,7 @@ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 1
3464
1887
  ]
3465
1888
  `;
3466
1889
 
3467
- exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2`] = `
1890
+ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2`] = `
3468
1891
  [
3469
1892
  {
3470
1893
  "checkpoint_diff": {
@@ -3513,7 +1936,7 @@ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2
3513
1936
  ]
3514
1937
  `;
3515
1938
 
3516
- exports[`sync - postgres > storage v3 > sync updates to parameter query only 1`] = `
1939
+ exports[`sync - postgres > storage v2 > sync updates to parameter query only 1`] = `
3517
1940
  [
3518
1941
  {
3519
1942
  "checkpoint": {
@@ -3537,7 +1960,7 @@ exports[`sync - postgres > storage v3 > sync updates to parameter query only 1`]
3537
1960
  ]
3538
1961
  `;
3539
1962
 
3540
- exports[`sync - postgres > storage v3 > sync updates to parameter query only 2`] = `
1963
+ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`] = `
3541
1964
  [
3542
1965
  {
3543
1966
  "checkpoint_diff": {