@powersync/service-module-postgres-storage 0.11.2 → 0.13.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/migrations/scripts/1771232439485-storage-version.d.ts +3 -0
  4. package/dist/@types/migrations/scripts/1771424826685-current-data-pending-deletes.d.ts +3 -0
  5. package/dist/@types/migrations/scripts/1771491856000-sync-plan.d.ts +3 -0
  6. package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +6 -10
  7. package/dist/@types/storage/PostgresCompactor.d.ts +10 -3
  8. package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +5 -3
  9. package/dist/@types/storage/batch/OperationBatch.d.ts +2 -2
  10. package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +12 -9
  11. package/dist/@types/storage/batch/PostgresPersistedBatch.d.ts +17 -5
  12. package/dist/@types/storage/current-data-store.d.ts +85 -0
  13. package/dist/@types/storage/current-data-table.d.ts +9 -0
  14. package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +1 -10
  15. package/dist/@types/storage/table-id.d.ts +2 -0
  16. package/dist/@types/types/models/CurrentData.d.ts +18 -3
  17. package/dist/@types/types/models/SyncRules.d.ts +12 -2
  18. package/dist/@types/types/models/json.d.ts +11 -0
  19. package/dist/@types/types/types.d.ts +2 -0
  20. package/dist/@types/utils/bson.d.ts +1 -1
  21. package/dist/@types/utils/db.d.ts +9 -0
  22. package/dist/@types/utils/test-utils.d.ts +1 -1
  23. package/dist/migrations/scripts/1771232439485-storage-version.js +111 -0
  24. package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -0
  25. package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js +8 -0
  26. package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js.map +1 -0
  27. package/dist/migrations/scripts/1771491856000-sync-plan.js +91 -0
  28. package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -0
  29. package/dist/storage/PostgresBucketStorageFactory.js +56 -58
  30. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  31. package/dist/storage/PostgresCompactor.js +55 -66
  32. package/dist/storage/PostgresCompactor.js.map +1 -1
  33. package/dist/storage/PostgresSyncRulesStorage.js +23 -15
  34. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  35. package/dist/storage/batch/OperationBatch.js +2 -1
  36. package/dist/storage/batch/OperationBatch.js.map +1 -1
  37. package/dist/storage/batch/PostgresBucketBatch.js +286 -213
  38. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  39. package/dist/storage/batch/PostgresPersistedBatch.js +86 -81
  40. package/dist/storage/batch/PostgresPersistedBatch.js.map +1 -1
  41. package/dist/storage/current-data-store.js +270 -0
  42. package/dist/storage/current-data-store.js.map +1 -0
  43. package/dist/storage/current-data-table.js +22 -0
  44. package/dist/storage/current-data-table.js.map +1 -0
  45. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +14 -30
  46. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
  47. package/dist/storage/table-id.js +8 -0
  48. package/dist/storage/table-id.js.map +1 -0
  49. package/dist/types/models/CurrentData.js +11 -2
  50. package/dist/types/models/CurrentData.js.map +1 -1
  51. package/dist/types/models/SyncRules.js +12 -1
  52. package/dist/types/models/SyncRules.js.map +1 -1
  53. package/dist/types/models/json.js +21 -0
  54. package/dist/types/models/json.js.map +1 -0
  55. package/dist/utils/bson.js.map +1 -1
  56. package/dist/utils/db.js +41 -0
  57. package/dist/utils/db.js.map +1 -1
  58. package/dist/utils/test-utils.js +50 -14
  59. package/dist/utils/test-utils.js.map +1 -1
  60. package/package.json +9 -9
  61. package/src/migrations/scripts/1771232439485-storage-version.ts +44 -0
  62. package/src/migrations/scripts/1771424826685-current-data-pending-deletes.ts +10 -0
  63. package/src/migrations/scripts/1771491856000-sync-plan.ts +21 -0
  64. package/src/storage/PostgresBucketStorageFactory.ts +69 -68
  65. package/src/storage/PostgresCompactor.ts +63 -72
  66. package/src/storage/PostgresSyncRulesStorage.ts +30 -17
  67. package/src/storage/batch/OperationBatch.ts +4 -3
  68. package/src/storage/batch/PostgresBucketBatch.ts +306 -238
  69. package/src/storage/batch/PostgresPersistedBatch.ts +92 -84
  70. package/src/storage/current-data-store.ts +326 -0
  71. package/src/storage/current-data-table.ts +26 -0
  72. package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +13 -33
  73. package/src/storage/table-id.ts +9 -0
  74. package/src/types/models/CurrentData.ts +17 -4
  75. package/src/types/models/SyncRules.ts +16 -1
  76. package/src/types/models/json.ts +26 -0
  77. package/src/utils/bson.ts +1 -1
  78. package/src/utils/db.ts +47 -0
  79. package/src/utils/test-utils.ts +42 -15
  80. package/test/src/__snapshots__/storage.test.ts.snap +148 -6
  81. package/test/src/__snapshots__/storage_compacting.test.ts.snap +17 -0
  82. package/test/src/__snapshots__/storage_sync.test.ts.snap +2211 -21
  83. package/test/src/migrations.test.ts +9 -2
  84. package/test/src/storage.test.ts +137 -131
  85. package/test/src/storage_compacting.test.ts +113 -2
  86. package/test/src/storage_sync.test.ts +148 -4
  87. package/test/src/util.ts +5 -2
@@ -1,6 +1,6 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
- exports[`sync - postgres > compacting data - invalidate checkpoint 1`] = `
3
+ exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint 1`] = `
4
4
  [
5
5
  {
6
6
  "checkpoint": {
@@ -31,7 +31,7 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 1`] = `
31
31
  ]
32
32
  `;
33
33
 
34
- exports[`sync - postgres > compacting data - invalidate checkpoint 2`] = `
34
+ exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint 2`] = `
35
35
  [
36
36
  {
37
37
  "data": {
@@ -104,7 +104,7 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 2`] = `
104
104
  ]
105
105
  `;
106
106
 
107
- exports[`sync - postgres > encodes sync rules id in buckes for streams 1`] = `
107
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 1`] = `
108
108
  [
109
109
  {
110
110
  "checkpoint": {
@@ -159,7 +159,7 @@ exports[`sync - postgres > encodes sync rules id in buckes for streams 1`] = `
159
159
  ]
160
160
  `;
161
161
 
162
- exports[`sync - postgres > encodes sync rules id in buckes for streams 2`] = `
162
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 2`] = `
163
163
  [
164
164
  {
165
165
  "checkpoint": {
@@ -214,7 +214,7 @@ exports[`sync - postgres > encodes sync rules id in buckes for streams 2`] = `
214
214
  ]
215
215
  `;
216
216
 
217
- exports[`sync - postgres > expired token 1`] = `
217
+ exports[`sync - postgres > storage v1 > expired token 1`] = `
218
218
  [
219
219
  {
220
220
  "token_expires_in": 0,
@@ -222,7 +222,7 @@ exports[`sync - postgres > expired token 1`] = `
222
222
  ]
223
223
  `;
224
224
 
225
- exports[`sync - postgres > expiring token 1`] = `
225
+ exports[`sync - postgres > storage v1 > expiring token 1`] = `
226
226
  [
227
227
  {
228
228
  "checkpoint": {
@@ -258,7 +258,7 @@ exports[`sync - postgres > expiring token 1`] = `
258
258
  ]
259
259
  `;
260
260
 
261
- exports[`sync - postgres > expiring token 2`] = `
261
+ exports[`sync - postgres > storage v1 > expiring token 2`] = `
262
262
  [
263
263
  {
264
264
  "token_expires_in": 0,
@@ -266,7 +266,7 @@ exports[`sync - postgres > expiring token 2`] = `
266
266
  ]
267
267
  `;
268
268
 
269
- exports[`sync - postgres > sends checkpoint complete line for empty checkpoint 1`] = `
269
+ exports[`sync - postgres > storage v1 > sends checkpoint complete line for empty checkpoint 1`] = `
270
270
  [
271
271
  {
272
272
  "checkpoint": {
@@ -335,7 +335,7 @@ exports[`sync - postgres > sends checkpoint complete line for empty checkpoint 1
335
335
  ]
336
336
  `;
337
337
 
338
- exports[`sync - postgres > sync buckets in order 1`] = `
338
+ exports[`sync - postgres > storage v1 > sync buckets in order 1`] = `
339
339
  [
340
340
  {
341
341
  "checkpoint": {
@@ -431,7 +431,7 @@ exports[`sync - postgres > sync buckets in order 1`] = `
431
431
  ]
432
432
  `;
433
433
 
434
- exports[`sync - postgres > sync global data 1`] = `
434
+ exports[`sync - postgres > storage v1 > sync global data 1`] = `
435
435
  [
436
436
  {
437
437
  "checkpoint": {
@@ -495,7 +495,7 @@ exports[`sync - postgres > sync global data 1`] = `
495
495
  ]
496
496
  `;
497
497
 
498
- exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
498
+ exports[`sync - postgres > storage v1 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
499
499
  [
500
500
  {
501
501
  "checkpoint": {
@@ -689,7 +689,7 @@ exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoin
689
689
  ]
690
690
  `;
691
691
 
692
- exports[`sync - postgres > sync legacy non-raw data 1`] = `
692
+ exports[`sync - postgres > storage v1 > sync legacy non-raw data 1`] = `
693
693
  [
694
694
  {
695
695
  "checkpoint": {
@@ -749,7 +749,7 @@ exports[`sync - postgres > sync legacy non-raw data 1`] = `
749
749
  ]
750
750
  `;
751
751
 
752
- exports[`sync - postgres > sync updates to data query only 1`] = `
752
+ exports[`sync - postgres > storage v1 > sync updates to data query only 1`] = `
753
753
  [
754
754
  {
755
755
  "checkpoint": {
@@ -785,7 +785,7 @@ exports[`sync - postgres > sync updates to data query only 1`] = `
785
785
  ]
786
786
  `;
787
787
 
788
- exports[`sync - postgres > sync updates to data query only 2`] = `
788
+ exports[`sync - postgres > storage v1 > sync updates to data query only 2`] = `
789
789
  [
790
790
  {
791
791
  "checkpoint_diff": {
@@ -834,7 +834,7 @@ exports[`sync - postgres > sync updates to data query only 2`] = `
834
834
  ]
835
835
  `;
836
836
 
837
- exports[`sync - postgres > sync updates to global data 1`] = `
837
+ exports[`sync - postgres > storage v1 > sync updates to global data 1`] = `
838
838
  [
839
839
  {
840
840
  "checkpoint": {
@@ -870,7 +870,7 @@ exports[`sync - postgres > sync updates to global data 1`] = `
870
870
  ]
871
871
  `;
872
872
 
873
- exports[`sync - postgres > sync updates to global data 2`] = `
873
+ exports[`sync - postgres > storage v1 > sync updates to global data 2`] = `
874
874
  [
875
875
  {
876
876
  "checkpoint_diff": {
@@ -919,7 +919,7 @@ exports[`sync - postgres > sync updates to global data 2`] = `
919
919
  ]
920
920
  `;
921
921
 
922
- exports[`sync - postgres > sync updates to global data 3`] = `
922
+ exports[`sync - postgres > storage v1 > sync updates to global data 3`] = `
923
923
  [
924
924
  {
925
925
  "checkpoint_diff": {
@@ -968,7 +968,7 @@ exports[`sync - postgres > sync updates to global data 3`] = `
968
968
  ]
969
969
  `;
970
970
 
971
- exports[`sync - postgres > sync updates to parameter query + data 1`] = `
971
+ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 1`] = `
972
972
  [
973
973
  {
974
974
  "checkpoint": {
@@ -992,7 +992,7 @@ exports[`sync - postgres > sync updates to parameter query + data 1`] = `
992
992
  ]
993
993
  `;
994
994
 
995
- exports[`sync - postgres > sync updates to parameter query + data 2`] = `
995
+ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 2`] = `
996
996
  [
997
997
  {
998
998
  "checkpoint_diff": {
@@ -1041,7 +1041,7 @@ exports[`sync - postgres > sync updates to parameter query + data 2`] = `
1041
1041
  ]
1042
1042
  `;
1043
1043
 
1044
- exports[`sync - postgres > sync updates to parameter query only 1`] = `
1044
+ exports[`sync - postgres > storage v1 > sync updates to parameter query only 1`] = `
1045
1045
  [
1046
1046
  {
1047
1047
  "checkpoint": {
@@ -1065,7 +1065,7 @@ exports[`sync - postgres > sync updates to parameter query only 1`] = `
1065
1065
  ]
1066
1066
  `;
1067
1067
 
1068
- exports[`sync - postgres > sync updates to parameter query only 2`] = `
1068
+ exports[`sync - postgres > storage v1 > sync updates to parameter query only 2`] = `
1069
1069
  [
1070
1070
  {
1071
1071
  "checkpoint_diff": {
@@ -1094,3 +1094,2193 @@ exports[`sync - postgres > sync updates to parameter query only 2`] = `
1094
1094
  },
1095
1095
  ]
1096
1096
  `;
1097
+
1098
+ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 1`] = `
1099
+ [
1100
+ {
1101
+ "checkpoint": {
1102
+ "buckets": [
1103
+ {
1104
+ "bucket": "1#mybucket[]",
1105
+ "checksum": -93886621,
1106
+ "count": 2,
1107
+ "priority": 3,
1108
+ "subscriptions": [
1109
+ {
1110
+ "default": 0,
1111
+ },
1112
+ ],
1113
+ },
1114
+ ],
1115
+ "last_op_id": "2",
1116
+ "streams": [
1117
+ {
1118
+ "errors": [],
1119
+ "is_default": true,
1120
+ "name": "mybucket",
1121
+ },
1122
+ ],
1123
+ "write_checkpoint": undefined,
1124
+ },
1125
+ },
1126
+ ]
1127
+ `;
1128
+
1129
+ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 2`] = `
1130
+ [
1131
+ {
1132
+ "data": {
1133
+ "after": "0",
1134
+ "bucket": "1#mybucket[]",
1135
+ "data": [
1136
+ {
1137
+ "checksum": -93886621,
1138
+ "op": "CLEAR",
1139
+ "op_id": "2",
1140
+ },
1141
+ ],
1142
+ "has_more": false,
1143
+ "next_after": "2",
1144
+ },
1145
+ },
1146
+ {
1147
+ "checkpoint_diff": {
1148
+ "last_op_id": "4",
1149
+ "removed_buckets": [],
1150
+ "updated_buckets": [
1151
+ {
1152
+ "bucket": "1#mybucket[]",
1153
+ "checksum": 499012468,
1154
+ "count": 4,
1155
+ "priority": 3,
1156
+ "subscriptions": [
1157
+ {
1158
+ "default": 0,
1159
+ },
1160
+ ],
1161
+ },
1162
+ ],
1163
+ "write_checkpoint": undefined,
1164
+ },
1165
+ },
1166
+ {
1167
+ "data": {
1168
+ "after": "2",
1169
+ "bucket": "1#mybucket[]",
1170
+ "data": [
1171
+ {
1172
+ "checksum": 1859363232,
1173
+ "data": "{"id":"t1","description":"Test 1b"}",
1174
+ "object_id": "t1",
1175
+ "object_type": "test",
1176
+ "op": "PUT",
1177
+ "op_id": "3",
1178
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1179
+ },
1180
+ {
1181
+ "checksum": 3028503153,
1182
+ "data": "{"id":"t2","description":"Test 2b"}",
1183
+ "object_id": "t2",
1184
+ "object_type": "test",
1185
+ "op": "PUT",
1186
+ "op_id": "4",
1187
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
1188
+ },
1189
+ ],
1190
+ "has_more": false,
1191
+ "next_after": "4",
1192
+ },
1193
+ },
1194
+ {
1195
+ "checkpoint_complete": {
1196
+ "last_op_id": "4",
1197
+ },
1198
+ },
1199
+ ]
1200
+ `;
1201
+
1202
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 1`] = `
1203
+ [
1204
+ {
1205
+ "checkpoint": {
1206
+ "buckets": [
1207
+ {
1208
+ "bucket": "1#test|0[]",
1209
+ "checksum": 920318466,
1210
+ "count": 1,
1211
+ "priority": 3,
1212
+ "subscriptions": [
1213
+ {
1214
+ "default": 0,
1215
+ },
1216
+ ],
1217
+ },
1218
+ ],
1219
+ "last_op_id": "1",
1220
+ "streams": [
1221
+ {
1222
+ "errors": [],
1223
+ "is_default": true,
1224
+ "name": "test",
1225
+ },
1226
+ ],
1227
+ "write_checkpoint": undefined,
1228
+ },
1229
+ },
1230
+ {
1231
+ "data": {
1232
+ "after": "0",
1233
+ "bucket": "1#test|0[]",
1234
+ "data": [
1235
+ {
1236
+ "checksum": 920318466,
1237
+ "data": "{"id":"t1","description":"Test 1"}",
1238
+ "object_id": "t1",
1239
+ "object_type": "test",
1240
+ "op": "PUT",
1241
+ "op_id": "1",
1242
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1243
+ },
1244
+ ],
1245
+ "has_more": false,
1246
+ "next_after": "1",
1247
+ },
1248
+ },
1249
+ {
1250
+ "checkpoint_complete": {
1251
+ "last_op_id": "1",
1252
+ },
1253
+ },
1254
+ ]
1255
+ `;
1256
+
1257
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 2`] = `
1258
+ [
1259
+ {
1260
+ "checkpoint": {
1261
+ "buckets": [
1262
+ {
1263
+ "bucket": "2#test|0[]",
1264
+ "checksum": 920318466,
1265
+ "count": 1,
1266
+ "priority": 3,
1267
+ "subscriptions": [
1268
+ {
1269
+ "default": 0,
1270
+ },
1271
+ ],
1272
+ },
1273
+ ],
1274
+ "last_op_id": "2",
1275
+ "streams": [
1276
+ {
1277
+ "errors": [],
1278
+ "is_default": true,
1279
+ "name": "test",
1280
+ },
1281
+ ],
1282
+ "write_checkpoint": undefined,
1283
+ },
1284
+ },
1285
+ {
1286
+ "data": {
1287
+ "after": "0",
1288
+ "bucket": "2#test|0[]",
1289
+ "data": [
1290
+ {
1291
+ "checksum": 920318466,
1292
+ "data": "{"id":"t1","description":"Test 1"}",
1293
+ "object_id": "t1",
1294
+ "object_type": "test",
1295
+ "op": "PUT",
1296
+ "op_id": "2",
1297
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1298
+ },
1299
+ ],
1300
+ "has_more": false,
1301
+ "next_after": "2",
1302
+ },
1303
+ },
1304
+ {
1305
+ "checkpoint_complete": {
1306
+ "last_op_id": "2",
1307
+ },
1308
+ },
1309
+ ]
1310
+ `;
1311
+
1312
+ exports[`sync - postgres > storage v2 > expired token 1`] = `
1313
+ [
1314
+ {
1315
+ "token_expires_in": 0,
1316
+ },
1317
+ ]
1318
+ `;
1319
+
1320
+ exports[`sync - postgres > storage v2 > expiring token 1`] = `
1321
+ [
1322
+ {
1323
+ "checkpoint": {
1324
+ "buckets": [
1325
+ {
1326
+ "bucket": "1#mybucket[]",
1327
+ "checksum": 0,
1328
+ "count": 0,
1329
+ "priority": 3,
1330
+ "subscriptions": [
1331
+ {
1332
+ "default": 0,
1333
+ },
1334
+ ],
1335
+ },
1336
+ ],
1337
+ "last_op_id": "0",
1338
+ "streams": [
1339
+ {
1340
+ "errors": [],
1341
+ "is_default": true,
1342
+ "name": "mybucket",
1343
+ },
1344
+ ],
1345
+ "write_checkpoint": undefined,
1346
+ },
1347
+ },
1348
+ {
1349
+ "checkpoint_complete": {
1350
+ "last_op_id": "0",
1351
+ },
1352
+ },
1353
+ ]
1354
+ `;
1355
+
1356
+ exports[`sync - postgres > storage v2 > expiring token 2`] = `
1357
+ [
1358
+ {
1359
+ "token_expires_in": 0,
1360
+ },
1361
+ ]
1362
+ `;
1363
+
1364
+ exports[`sync - postgres > storage v2 > sends checkpoint complete line for empty checkpoint 1`] = `
1365
+ [
1366
+ {
1367
+ "checkpoint": {
1368
+ "buckets": [
1369
+ {
1370
+ "bucket": "1#mybucket[]",
1371
+ "checksum": -1221282404,
1372
+ "count": 1,
1373
+ "priority": 3,
1374
+ "subscriptions": [
1375
+ {
1376
+ "default": 0,
1377
+ },
1378
+ ],
1379
+ },
1380
+ ],
1381
+ "last_op_id": "1",
1382
+ "streams": [
1383
+ {
1384
+ "errors": [],
1385
+ "is_default": true,
1386
+ "name": "mybucket",
1387
+ },
1388
+ ],
1389
+ "write_checkpoint": undefined,
1390
+ },
1391
+ },
1392
+ {
1393
+ "data": {
1394
+ "after": "0",
1395
+ "bucket": "1#mybucket[]",
1396
+ "data": [
1397
+ {
1398
+ "checksum": 3073684892,
1399
+ "data": "{"id":"t1","description":"sync"}",
1400
+ "object_id": "t1",
1401
+ "object_type": "test",
1402
+ "op": "PUT",
1403
+ "op_id": "1",
1404
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1405
+ },
1406
+ ],
1407
+ "has_more": false,
1408
+ "next_after": "1",
1409
+ },
1410
+ },
1411
+ null,
1412
+ {
1413
+ "checkpoint_complete": {
1414
+ "last_op_id": "1",
1415
+ },
1416
+ },
1417
+ {
1418
+ "checkpoint_diff": {
1419
+ "last_op_id": "1",
1420
+ "removed_buckets": [],
1421
+ "updated_buckets": [],
1422
+ "write_checkpoint": "1",
1423
+ },
1424
+ },
1425
+ {
1426
+ "checkpoint_complete": {
1427
+ "last_op_id": "1",
1428
+ },
1429
+ },
1430
+ ]
1431
+ `;
1432
+
1433
+ exports[`sync - postgres > storage v2 > sync buckets in order 1`] = `
1434
+ [
1435
+ {
1436
+ "checkpoint": {
1437
+ "buckets": [
1438
+ {
1439
+ "bucket": "1#b0[]",
1440
+ "checksum": 920318466,
1441
+ "count": 1,
1442
+ "priority": 2,
1443
+ "subscriptions": [
1444
+ {
1445
+ "default": 0,
1446
+ },
1447
+ ],
1448
+ },
1449
+ {
1450
+ "bucket": "1#b1[]",
1451
+ "checksum": -1382098757,
1452
+ "count": 1,
1453
+ "priority": 1,
1454
+ "subscriptions": [
1455
+ {
1456
+ "default": 1,
1457
+ },
1458
+ ],
1459
+ },
1460
+ ],
1461
+ "last_op_id": "2",
1462
+ "streams": [
1463
+ {
1464
+ "errors": [],
1465
+ "is_default": true,
1466
+ "name": "b0",
1467
+ },
1468
+ {
1469
+ "errors": [],
1470
+ "is_default": true,
1471
+ "name": "b1",
1472
+ },
1473
+ ],
1474
+ "write_checkpoint": undefined,
1475
+ },
1476
+ },
1477
+ {
1478
+ "data": {
1479
+ "after": "0",
1480
+ "bucket": "1#b1[]",
1481
+ "data": [
1482
+ {
1483
+ "checksum": 2912868539,
1484
+ "data": "{"id":"earlier","description":"Test 2"}",
1485
+ "object_id": "earlier",
1486
+ "object_type": "test",
1487
+ "op": "PUT",
1488
+ "op_id": "2",
1489
+ "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
1490
+ },
1491
+ ],
1492
+ "has_more": false,
1493
+ "next_after": "2",
1494
+ },
1495
+ },
1496
+ {
1497
+ "partial_checkpoint_complete": {
1498
+ "last_op_id": "2",
1499
+ "priority": 1,
1500
+ },
1501
+ },
1502
+ {
1503
+ "data": {
1504
+ "after": "0",
1505
+ "bucket": "1#b0[]",
1506
+ "data": [
1507
+ {
1508
+ "checksum": 920318466,
1509
+ "data": "{"id":"t1","description":"Test 1"}",
1510
+ "object_id": "t1",
1511
+ "object_type": "test",
1512
+ "op": "PUT",
1513
+ "op_id": "1",
1514
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1515
+ },
1516
+ ],
1517
+ "has_more": false,
1518
+ "next_after": "1",
1519
+ },
1520
+ },
1521
+ {
1522
+ "checkpoint_complete": {
1523
+ "last_op_id": "2",
1524
+ },
1525
+ },
1526
+ ]
1527
+ `;
1528
+
1529
+ exports[`sync - postgres > storage v2 > sync global data 1`] = `
1530
+ [
1531
+ {
1532
+ "checkpoint": {
1533
+ "buckets": [
1534
+ {
1535
+ "bucket": "1#mybucket[]",
1536
+ "checksum": -93886621,
1537
+ "count": 2,
1538
+ "priority": 3,
1539
+ "subscriptions": [
1540
+ {
1541
+ "default": 0,
1542
+ },
1543
+ ],
1544
+ },
1545
+ ],
1546
+ "last_op_id": "2",
1547
+ "streams": [
1548
+ {
1549
+ "errors": [],
1550
+ "is_default": true,
1551
+ "name": "mybucket",
1552
+ },
1553
+ ],
1554
+ "write_checkpoint": undefined,
1555
+ },
1556
+ },
1557
+ {
1558
+ "data": {
1559
+ "after": "0",
1560
+ "bucket": "1#mybucket[]",
1561
+ "data": [
1562
+ {
1563
+ "checksum": 920318466,
1564
+ "data": "{"id":"t1","description":"Test 1"}",
1565
+ "object_id": "t1",
1566
+ "object_type": "test",
1567
+ "op": "PUT",
1568
+ "op_id": "1",
1569
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1570
+ },
1571
+ {
1572
+ "checksum": 3280762209,
1573
+ "data": "{"id":"t2","description":"Test 2"}",
1574
+ "object_id": "t2",
1575
+ "object_type": "test",
1576
+ "op": "PUT",
1577
+ "op_id": "2",
1578
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
1579
+ },
1580
+ ],
1581
+ "has_more": false,
1582
+ "next_after": "2",
1583
+ },
1584
+ },
1585
+ {
1586
+ "checkpoint_complete": {
1587
+ "last_op_id": "2",
1588
+ },
1589
+ },
1590
+ ]
1591
+ `;
1592
+
1593
+ exports[`sync - postgres > storage v2 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
1594
+ [
1595
+ {
1596
+ "checkpoint": {
1597
+ "buckets": [
1598
+ {
1599
+ "bucket": "1#b0a[]",
1600
+ "checksum": -659831575,
1601
+ "count": 2000,
1602
+ "priority": 2,
1603
+ "subscriptions": [
1604
+ {
1605
+ "default": 0,
1606
+ },
1607
+ ],
1608
+ },
1609
+ {
1610
+ "bucket": "1#b0b[]",
1611
+ "checksum": -659831575,
1612
+ "count": 2000,
1613
+ "priority": 2,
1614
+ "subscriptions": [
1615
+ {
1616
+ "default": 1,
1617
+ },
1618
+ ],
1619
+ },
1620
+ {
1621
+ "bucket": "1#b1[]",
1622
+ "checksum": -1096116670,
1623
+ "count": 1,
1624
+ "priority": 1,
1625
+ "subscriptions": [
1626
+ {
1627
+ "default": 2,
1628
+ },
1629
+ ],
1630
+ },
1631
+ ],
1632
+ "last_op_id": "4001",
1633
+ "streams": [
1634
+ {
1635
+ "errors": [],
1636
+ "is_default": true,
1637
+ "name": "b0a",
1638
+ },
1639
+ {
1640
+ "errors": [],
1641
+ "is_default": true,
1642
+ "name": "b0b",
1643
+ },
1644
+ {
1645
+ "errors": [],
1646
+ "is_default": true,
1647
+ "name": "b1",
1648
+ },
1649
+ ],
1650
+ "write_checkpoint": undefined,
1651
+ },
1652
+ },
1653
+ {
1654
+ "data": {
1655
+ "after": "0",
1656
+ "bucket": "1#b1[]",
1657
+ "data": undefined,
1658
+ "has_more": false,
1659
+ "next_after": "1",
1660
+ },
1661
+ },
1662
+ {
1663
+ "partial_checkpoint_complete": {
1664
+ "last_op_id": "4001",
1665
+ "priority": 1,
1666
+ },
1667
+ },
1668
+ {
1669
+ "data": {
1670
+ "after": "0",
1671
+ "bucket": "1#b0a[]",
1672
+ "data": undefined,
1673
+ "has_more": true,
1674
+ "next_after": "2000",
1675
+ },
1676
+ },
1677
+ {
1678
+ "data": {
1679
+ "after": "2000",
1680
+ "bucket": "1#b0a[]",
1681
+ "data": undefined,
1682
+ "has_more": true,
1683
+ "next_after": "4000",
1684
+ },
1685
+ },
1686
+ {
1687
+ "checkpoint_diff": {
1688
+ "last_op_id": "4004",
1689
+ "removed_buckets": [],
1690
+ "updated_buckets": [
1691
+ {
1692
+ "bucket": "1#b0a[]",
1693
+ "checksum": 883076828,
1694
+ "count": 2001,
1695
+ "priority": 2,
1696
+ "subscriptions": [
1697
+ {
1698
+ "default": 0,
1699
+ },
1700
+ ],
1701
+ },
1702
+ {
1703
+ "bucket": "1#b0b[]",
1704
+ "checksum": 883076828,
1705
+ "count": 2001,
1706
+ "priority": 2,
1707
+ "subscriptions": [
1708
+ {
1709
+ "default": 1,
1710
+ },
1711
+ ],
1712
+ },
1713
+ {
1714
+ "bucket": "1#b1[]",
1715
+ "checksum": 1841937527,
1716
+ "count": 2,
1717
+ "priority": 1,
1718
+ "subscriptions": [
1719
+ {
1720
+ "default": 2,
1721
+ },
1722
+ ],
1723
+ },
1724
+ ],
1725
+ "write_checkpoint": undefined,
1726
+ },
1727
+ },
1728
+ {
1729
+ "data": {
1730
+ "after": "1",
1731
+ "bucket": "1#b1[]",
1732
+ "data": undefined,
1733
+ "has_more": false,
1734
+ "next_after": "4002",
1735
+ },
1736
+ },
1737
+ {
1738
+ "partial_checkpoint_complete": {
1739
+ "last_op_id": "4004",
1740
+ "priority": 1,
1741
+ },
1742
+ },
1743
+ {
1744
+ "data": {
1745
+ "after": "4000",
1746
+ "bucket": "1#b0a[]",
1747
+ "data": undefined,
1748
+ "has_more": false,
1749
+ "next_after": "4003",
1750
+ },
1751
+ },
1752
+ {
1753
+ "data": {
1754
+ "after": "0",
1755
+ "bucket": "1#b0b[]",
1756
+ "data": undefined,
1757
+ "has_more": true,
1758
+ "next_after": "1999",
1759
+ },
1760
+ },
1761
+ {
1762
+ "data": {
1763
+ "after": "1999",
1764
+ "bucket": "1#b0b[]",
1765
+ "data": undefined,
1766
+ "has_more": true,
1767
+ "next_after": "3999",
1768
+ },
1769
+ },
1770
+ {
1771
+ "data": {
1772
+ "after": "3999",
1773
+ "bucket": "1#b0b[]",
1774
+ "data": undefined,
1775
+ "has_more": false,
1776
+ "next_after": "4004",
1777
+ },
1778
+ },
1779
+ {
1780
+ "checkpoint_complete": {
1781
+ "last_op_id": "4004",
1782
+ },
1783
+ },
1784
+ ]
1785
+ `;
1786
+
1787
+ exports[`sync - postgres > storage v2 > sync legacy non-raw data 1`] = `
1788
+ [
1789
+ {
1790
+ "checkpoint": {
1791
+ "buckets": [
1792
+ {
1793
+ "bucket": "1#mybucket[]",
1794
+ "checksum": -852817836,
1795
+ "count": 1,
1796
+ "priority": 3,
1797
+ "subscriptions": [
1798
+ {
1799
+ "default": 0,
1800
+ },
1801
+ ],
1802
+ },
1803
+ ],
1804
+ "last_op_id": "1",
1805
+ "streams": [
1806
+ {
1807
+ "errors": [],
1808
+ "is_default": true,
1809
+ "name": "mybucket",
1810
+ },
1811
+ ],
1812
+ "write_checkpoint": undefined,
1813
+ },
1814
+ },
1815
+ {
1816
+ "data": {
1817
+ "after": "0",
1818
+ "bucket": "1#mybucket[]",
1819
+ "data": [
1820
+ {
1821
+ "checksum": 3442149460n,
1822
+ "data": {
1823
+ "description": "Test
1824
+ "string"",
1825
+ "id": "t1",
1826
+ "large_num": 12345678901234567890n,
1827
+ },
1828
+ "object_id": "t1",
1829
+ "object_type": "test",
1830
+ "op": "PUT",
1831
+ "op_id": "1",
1832
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1833
+ },
1834
+ ],
1835
+ "has_more": false,
1836
+ "next_after": "1",
1837
+ },
1838
+ },
1839
+ {
1840
+ "checkpoint_complete": {
1841
+ "last_op_id": "1",
1842
+ },
1843
+ },
1844
+ ]
1845
+ `;
1846
+
1847
+ exports[`sync - postgres > storage v2 > sync updates to data query only 1`] = `
1848
+ [
1849
+ {
1850
+ "checkpoint": {
1851
+ "buckets": [
1852
+ {
1853
+ "bucket": "1#by_user["user1"]",
1854
+ "checksum": 0,
1855
+ "count": 0,
1856
+ "priority": 3,
1857
+ "subscriptions": [
1858
+ {
1859
+ "default": 0,
1860
+ },
1861
+ ],
1862
+ },
1863
+ ],
1864
+ "last_op_id": "1",
1865
+ "streams": [
1866
+ {
1867
+ "errors": [],
1868
+ "is_default": true,
1869
+ "name": "by_user",
1870
+ },
1871
+ ],
1872
+ "write_checkpoint": undefined,
1873
+ },
1874
+ },
1875
+ {
1876
+ "checkpoint_complete": {
1877
+ "last_op_id": "1",
1878
+ },
1879
+ },
1880
+ ]
1881
+ `;
1882
+
1883
+ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
1884
+ [
1885
+ {
1886
+ "checkpoint_diff": {
1887
+ "last_op_id": "2",
1888
+ "removed_buckets": [],
1889
+ "updated_buckets": [
1890
+ {
1891
+ "bucket": "1#by_user["user1"]",
1892
+ "checksum": 1418351250,
1893
+ "count": 1,
1894
+ "priority": 3,
1895
+ "subscriptions": [
1896
+ {
1897
+ "default": 0,
1898
+ },
1899
+ ],
1900
+ },
1901
+ ],
1902
+ "write_checkpoint": undefined,
1903
+ },
1904
+ },
1905
+ {
1906
+ "data": {
1907
+ "after": "0",
1908
+ "bucket": "1#by_user["user1"]",
1909
+ "data": [
1910
+ {
1911
+ "checksum": 1418351250,
1912
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
1913
+ "object_id": "list1",
1914
+ "object_type": "lists",
1915
+ "op": "PUT",
1916
+ "op_id": "2",
1917
+ "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
1918
+ },
1919
+ ],
1920
+ "has_more": false,
1921
+ "next_after": "2",
1922
+ },
1923
+ },
1924
+ {
1925
+ "checkpoint_complete": {
1926
+ "last_op_id": "2",
1927
+ },
1928
+ },
1929
+ ]
1930
+ `;
1931
+
1932
+ exports[`sync - postgres > storage v2 > sync updates to global data 1`] = `
1933
+ [
1934
+ {
1935
+ "checkpoint": {
1936
+ "buckets": [
1937
+ {
1938
+ "bucket": "1#mybucket[]",
1939
+ "checksum": 0,
1940
+ "count": 0,
1941
+ "priority": 3,
1942
+ "subscriptions": [
1943
+ {
1944
+ "default": 0,
1945
+ },
1946
+ ],
1947
+ },
1948
+ ],
1949
+ "last_op_id": "0",
1950
+ "streams": [
1951
+ {
1952
+ "errors": [],
1953
+ "is_default": true,
1954
+ "name": "mybucket",
1955
+ },
1956
+ ],
1957
+ "write_checkpoint": undefined,
1958
+ },
1959
+ },
1960
+ {
1961
+ "checkpoint_complete": {
1962
+ "last_op_id": "0",
1963
+ },
1964
+ },
1965
+ ]
1966
+ `;
1967
+
1968
+ exports[`sync - postgres > storage v2 > sync updates to global data 2`] = `
1969
+ [
1970
+ {
1971
+ "checkpoint_diff": {
1972
+ "last_op_id": "1",
1973
+ "removed_buckets": [],
1974
+ "updated_buckets": [
1975
+ {
1976
+ "bucket": "1#mybucket[]",
1977
+ "checksum": 920318466,
1978
+ "count": 1,
1979
+ "priority": 3,
1980
+ "subscriptions": [
1981
+ {
1982
+ "default": 0,
1983
+ },
1984
+ ],
1985
+ },
1986
+ ],
1987
+ "write_checkpoint": undefined,
1988
+ },
1989
+ },
1990
+ {
1991
+ "data": {
1992
+ "after": "0",
1993
+ "bucket": "1#mybucket[]",
1994
+ "data": [
1995
+ {
1996
+ "checksum": 920318466,
1997
+ "data": "{"id":"t1","description":"Test 1"}",
1998
+ "object_id": "t1",
1999
+ "object_type": "test",
2000
+ "op": "PUT",
2001
+ "op_id": "1",
2002
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2003
+ },
2004
+ ],
2005
+ "has_more": false,
2006
+ "next_after": "1",
2007
+ },
2008
+ },
2009
+ {
2010
+ "checkpoint_complete": {
2011
+ "last_op_id": "1",
2012
+ },
2013
+ },
2014
+ ]
2015
+ `;
2016
+
2017
+ exports[`sync - postgres > storage v2 > sync updates to global data 3`] = `
2018
+ [
2019
+ {
2020
+ "checkpoint_diff": {
2021
+ "last_op_id": "2",
2022
+ "removed_buckets": [],
2023
+ "updated_buckets": [
2024
+ {
2025
+ "bucket": "1#mybucket[]",
2026
+ "checksum": -93886621,
2027
+ "count": 2,
2028
+ "priority": 3,
2029
+ "subscriptions": [
2030
+ {
2031
+ "default": 0,
2032
+ },
2033
+ ],
2034
+ },
2035
+ ],
2036
+ "write_checkpoint": undefined,
2037
+ },
2038
+ },
2039
+ {
2040
+ "data": {
2041
+ "after": "1",
2042
+ "bucket": "1#mybucket[]",
2043
+ "data": [
2044
+ {
2045
+ "checksum": 3280762209,
2046
+ "data": "{"id":"t2","description":"Test 2"}",
2047
+ "object_id": "t2",
2048
+ "object_type": "test",
2049
+ "op": "PUT",
2050
+ "op_id": "2",
2051
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2052
+ },
2053
+ ],
2054
+ "has_more": false,
2055
+ "next_after": "2",
2056
+ },
2057
+ },
2058
+ {
2059
+ "checkpoint_complete": {
2060
+ "last_op_id": "2",
2061
+ },
2062
+ },
2063
+ ]
2064
+ `;
2065
+
2066
+ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 1`] = `
2067
+ [
2068
+ {
2069
+ "checkpoint": {
2070
+ "buckets": [],
2071
+ "last_op_id": "0",
2072
+ "streams": [
2073
+ {
2074
+ "errors": [],
2075
+ "is_default": true,
2076
+ "name": "by_user",
2077
+ },
2078
+ ],
2079
+ "write_checkpoint": undefined,
2080
+ },
2081
+ },
2082
+ {
2083
+ "checkpoint_complete": {
2084
+ "last_op_id": "0",
2085
+ },
2086
+ },
2087
+ ]
2088
+ `;
2089
+
2090
+ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2`] = `
2091
+ [
2092
+ {
2093
+ "checkpoint_diff": {
2094
+ "last_op_id": "2",
2095
+ "removed_buckets": [],
2096
+ "updated_buckets": [
2097
+ {
2098
+ "bucket": "1#by_user["user1"]",
2099
+ "checksum": 1418351250,
2100
+ "count": 1,
2101
+ "priority": 3,
2102
+ "subscriptions": [
2103
+ {
2104
+ "default": 0,
2105
+ },
2106
+ ],
2107
+ },
2108
+ ],
2109
+ "write_checkpoint": undefined,
2110
+ },
2111
+ },
2112
+ {
2113
+ "data": {
2114
+ "after": "0",
2115
+ "bucket": "1#by_user["user1"]",
2116
+ "data": [
2117
+ {
2118
+ "checksum": 1418351250,
2119
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2120
+ "object_id": "list1",
2121
+ "object_type": "lists",
2122
+ "op": "PUT",
2123
+ "op_id": "1",
2124
+ "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
2125
+ },
2126
+ ],
2127
+ "has_more": false,
2128
+ "next_after": "1",
2129
+ },
2130
+ },
2131
+ {
2132
+ "checkpoint_complete": {
2133
+ "last_op_id": "2",
2134
+ },
2135
+ },
2136
+ ]
2137
+ `;
2138
+
2139
+ exports[`sync - postgres > storage v2 > sync updates to parameter query only 1`] = `
2140
+ [
2141
+ {
2142
+ "checkpoint": {
2143
+ "buckets": [],
2144
+ "last_op_id": "0",
2145
+ "streams": [
2146
+ {
2147
+ "errors": [],
2148
+ "is_default": true,
2149
+ "name": "by_user",
2150
+ },
2151
+ ],
2152
+ "write_checkpoint": undefined,
2153
+ },
2154
+ },
2155
+ {
2156
+ "checkpoint_complete": {
2157
+ "last_op_id": "0",
2158
+ },
2159
+ },
2160
+ ]
2161
+ `;
2162
+
2163
+ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`] = `
2164
+ [
2165
+ {
2166
+ "checkpoint_diff": {
2167
+ "last_op_id": "1",
2168
+ "removed_buckets": [],
2169
+ "updated_buckets": [
2170
+ {
2171
+ "bucket": "1#by_user["user1"]",
2172
+ "checksum": 0,
2173
+ "count": 0,
2174
+ "priority": 3,
2175
+ "subscriptions": [
2176
+ {
2177
+ "default": 0,
2178
+ },
2179
+ ],
2180
+ },
2181
+ ],
2182
+ "write_checkpoint": undefined,
2183
+ },
2184
+ },
2185
+ {
2186
+ "checkpoint_complete": {
2187
+ "last_op_id": "1",
2188
+ },
2189
+ },
2190
+ ]
2191
+ `;
2192
+
2193
+ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 1`] = `
2194
+ [
2195
+ {
2196
+ "checkpoint": {
2197
+ "buckets": [
2198
+ {
2199
+ "bucket": "1#mybucket[]",
2200
+ "checksum": -93886621,
2201
+ "count": 2,
2202
+ "priority": 3,
2203
+ "subscriptions": [
2204
+ {
2205
+ "default": 0,
2206
+ },
2207
+ ],
2208
+ },
2209
+ ],
2210
+ "last_op_id": "2",
2211
+ "streams": [
2212
+ {
2213
+ "errors": [],
2214
+ "is_default": true,
2215
+ "name": "mybucket",
2216
+ },
2217
+ ],
2218
+ "write_checkpoint": undefined,
2219
+ },
2220
+ },
2221
+ ]
2222
+ `;
2223
+
2224
+ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 2`] = `
2225
+ [
2226
+ {
2227
+ "data": {
2228
+ "after": "0",
2229
+ "bucket": "1#mybucket[]",
2230
+ "data": [
2231
+ {
2232
+ "checksum": -93886621,
2233
+ "op": "CLEAR",
2234
+ "op_id": "2",
2235
+ },
2236
+ ],
2237
+ "has_more": false,
2238
+ "next_after": "2",
2239
+ },
2240
+ },
2241
+ {
2242
+ "checkpoint_diff": {
2243
+ "last_op_id": "4",
2244
+ "removed_buckets": [],
2245
+ "updated_buckets": [
2246
+ {
2247
+ "bucket": "1#mybucket[]",
2248
+ "checksum": 499012468,
2249
+ "count": 4,
2250
+ "priority": 3,
2251
+ "subscriptions": [
2252
+ {
2253
+ "default": 0,
2254
+ },
2255
+ ],
2256
+ },
2257
+ ],
2258
+ "write_checkpoint": undefined,
2259
+ },
2260
+ },
2261
+ {
2262
+ "data": {
2263
+ "after": "2",
2264
+ "bucket": "1#mybucket[]",
2265
+ "data": [
2266
+ {
2267
+ "checksum": 1859363232,
2268
+ "data": "{"id":"t1","description":"Test 1b"}",
2269
+ "object_id": "t1",
2270
+ "object_type": "test",
2271
+ "op": "PUT",
2272
+ "op_id": "3",
2273
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2274
+ },
2275
+ {
2276
+ "checksum": 3028503153,
2277
+ "data": "{"id":"t2","description":"Test 2b"}",
2278
+ "object_id": "t2",
2279
+ "object_type": "test",
2280
+ "op": "PUT",
2281
+ "op_id": "4",
2282
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2283
+ },
2284
+ ],
2285
+ "has_more": false,
2286
+ "next_after": "4",
2287
+ },
2288
+ },
2289
+ {
2290
+ "checkpoint_complete": {
2291
+ "last_op_id": "4",
2292
+ },
2293
+ },
2294
+ ]
2295
+ `;
2296
+
2297
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for streams 1`] = `
2298
+ [
2299
+ {
2300
+ "checkpoint": {
2301
+ "buckets": [
2302
+ {
2303
+ "bucket": "1#test|0[]",
2304
+ "checksum": 920318466,
2305
+ "count": 1,
2306
+ "priority": 3,
2307
+ "subscriptions": [
2308
+ {
2309
+ "default": 0,
2310
+ },
2311
+ ],
2312
+ },
2313
+ ],
2314
+ "last_op_id": "1",
2315
+ "streams": [
2316
+ {
2317
+ "errors": [],
2318
+ "is_default": true,
2319
+ "name": "test",
2320
+ },
2321
+ ],
2322
+ "write_checkpoint": undefined,
2323
+ },
2324
+ },
2325
+ {
2326
+ "data": {
2327
+ "after": "0",
2328
+ "bucket": "1#test|0[]",
2329
+ "data": [
2330
+ {
2331
+ "checksum": 920318466,
2332
+ "data": "{"id":"t1","description":"Test 1"}",
2333
+ "object_id": "t1",
2334
+ "object_type": "test",
2335
+ "op": "PUT",
2336
+ "op_id": "1",
2337
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2338
+ },
2339
+ ],
2340
+ "has_more": false,
2341
+ "next_after": "1",
2342
+ },
2343
+ },
2344
+ {
2345
+ "checkpoint_complete": {
2346
+ "last_op_id": "1",
2347
+ },
2348
+ },
2349
+ ]
2350
+ `;
2351
+
2352
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for streams 2`] = `
2353
+ [
2354
+ {
2355
+ "checkpoint": {
2356
+ "buckets": [
2357
+ {
2358
+ "bucket": "2#test|0[]",
2359
+ "checksum": 920318466,
2360
+ "count": 1,
2361
+ "priority": 3,
2362
+ "subscriptions": [
2363
+ {
2364
+ "default": 0,
2365
+ },
2366
+ ],
2367
+ },
2368
+ ],
2369
+ "last_op_id": "2",
2370
+ "streams": [
2371
+ {
2372
+ "errors": [],
2373
+ "is_default": true,
2374
+ "name": "test",
2375
+ },
2376
+ ],
2377
+ "write_checkpoint": undefined,
2378
+ },
2379
+ },
2380
+ {
2381
+ "data": {
2382
+ "after": "0",
2383
+ "bucket": "2#test|0[]",
2384
+ "data": [
2385
+ {
2386
+ "checksum": 920318466,
2387
+ "data": "{"id":"t1","description":"Test 1"}",
2388
+ "object_id": "t1",
2389
+ "object_type": "test",
2390
+ "op": "PUT",
2391
+ "op_id": "2",
2392
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2393
+ },
2394
+ ],
2395
+ "has_more": false,
2396
+ "next_after": "2",
2397
+ },
2398
+ },
2399
+ {
2400
+ "checkpoint_complete": {
2401
+ "last_op_id": "2",
2402
+ },
2403
+ },
2404
+ ]
2405
+ `;
2406
+
2407
+ exports[`sync - postgres > storage v3 > expired token 1`] = `
2408
+ [
2409
+ {
2410
+ "token_expires_in": 0,
2411
+ },
2412
+ ]
2413
+ `;
2414
+
2415
+ exports[`sync - postgres > storage v3 > expiring token 1`] = `
2416
+ [
2417
+ {
2418
+ "checkpoint": {
2419
+ "buckets": [
2420
+ {
2421
+ "bucket": "1#mybucket[]",
2422
+ "checksum": 0,
2423
+ "count": 0,
2424
+ "priority": 3,
2425
+ "subscriptions": [
2426
+ {
2427
+ "default": 0,
2428
+ },
2429
+ ],
2430
+ },
2431
+ ],
2432
+ "last_op_id": "0",
2433
+ "streams": [
2434
+ {
2435
+ "errors": [],
2436
+ "is_default": true,
2437
+ "name": "mybucket",
2438
+ },
2439
+ ],
2440
+ "write_checkpoint": undefined,
2441
+ },
2442
+ },
2443
+ {
2444
+ "checkpoint_complete": {
2445
+ "last_op_id": "0",
2446
+ },
2447
+ },
2448
+ ]
2449
+ `;
2450
+
2451
+ exports[`sync - postgres > storage v3 > expiring token 2`] = `
2452
+ [
2453
+ {
2454
+ "token_expires_in": 0,
2455
+ },
2456
+ ]
2457
+ `;
2458
+
2459
+ exports[`sync - postgres > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2460
+ [
2461
+ {
2462
+ "checkpoint": {
2463
+ "buckets": [
2464
+ {
2465
+ "bucket": "1#mybucket[]",
2466
+ "checksum": -1221282404,
2467
+ "count": 1,
2468
+ "priority": 3,
2469
+ "subscriptions": [
2470
+ {
2471
+ "default": 0,
2472
+ },
2473
+ ],
2474
+ },
2475
+ ],
2476
+ "last_op_id": "1",
2477
+ "streams": [
2478
+ {
2479
+ "errors": [],
2480
+ "is_default": true,
2481
+ "name": "mybucket",
2482
+ },
2483
+ ],
2484
+ "write_checkpoint": undefined,
2485
+ },
2486
+ },
2487
+ {
2488
+ "data": {
2489
+ "after": "0",
2490
+ "bucket": "1#mybucket[]",
2491
+ "data": [
2492
+ {
2493
+ "checksum": 3073684892,
2494
+ "data": "{"id":"t1","description":"sync"}",
2495
+ "object_id": "t1",
2496
+ "object_type": "test",
2497
+ "op": "PUT",
2498
+ "op_id": "1",
2499
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2500
+ },
2501
+ ],
2502
+ "has_more": false,
2503
+ "next_after": "1",
2504
+ },
2505
+ },
2506
+ null,
2507
+ {
2508
+ "checkpoint_complete": {
2509
+ "last_op_id": "1",
2510
+ },
2511
+ },
2512
+ {
2513
+ "checkpoint_diff": {
2514
+ "last_op_id": "1",
2515
+ "removed_buckets": [],
2516
+ "updated_buckets": [],
2517
+ "write_checkpoint": "1",
2518
+ },
2519
+ },
2520
+ {
2521
+ "checkpoint_complete": {
2522
+ "last_op_id": "1",
2523
+ },
2524
+ },
2525
+ ]
2526
+ `;
2527
+
2528
+ exports[`sync - postgres > storage v3 > sync buckets in order 1`] = `
2529
+ [
2530
+ {
2531
+ "checkpoint": {
2532
+ "buckets": [
2533
+ {
2534
+ "bucket": "1#b0[]",
2535
+ "checksum": 920318466,
2536
+ "count": 1,
2537
+ "priority": 2,
2538
+ "subscriptions": [
2539
+ {
2540
+ "default": 0,
2541
+ },
2542
+ ],
2543
+ },
2544
+ {
2545
+ "bucket": "1#b1[]",
2546
+ "checksum": -1382098757,
2547
+ "count": 1,
2548
+ "priority": 1,
2549
+ "subscriptions": [
2550
+ {
2551
+ "default": 1,
2552
+ },
2553
+ ],
2554
+ },
2555
+ ],
2556
+ "last_op_id": "2",
2557
+ "streams": [
2558
+ {
2559
+ "errors": [],
2560
+ "is_default": true,
2561
+ "name": "b0",
2562
+ },
2563
+ {
2564
+ "errors": [],
2565
+ "is_default": true,
2566
+ "name": "b1",
2567
+ },
2568
+ ],
2569
+ "write_checkpoint": undefined,
2570
+ },
2571
+ },
2572
+ {
2573
+ "data": {
2574
+ "after": "0",
2575
+ "bucket": "1#b1[]",
2576
+ "data": [
2577
+ {
2578
+ "checksum": 2912868539,
2579
+ "data": "{"id":"earlier","description":"Test 2"}",
2580
+ "object_id": "earlier",
2581
+ "object_type": "test",
2582
+ "op": "PUT",
2583
+ "op_id": "2",
2584
+ "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
2585
+ },
2586
+ ],
2587
+ "has_more": false,
2588
+ "next_after": "2",
2589
+ },
2590
+ },
2591
+ {
2592
+ "partial_checkpoint_complete": {
2593
+ "last_op_id": "2",
2594
+ "priority": 1,
2595
+ },
2596
+ },
2597
+ {
2598
+ "data": {
2599
+ "after": "0",
2600
+ "bucket": "1#b0[]",
2601
+ "data": [
2602
+ {
2603
+ "checksum": 920318466,
2604
+ "data": "{"id":"t1","description":"Test 1"}",
2605
+ "object_id": "t1",
2606
+ "object_type": "test",
2607
+ "op": "PUT",
2608
+ "op_id": "1",
2609
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2610
+ },
2611
+ ],
2612
+ "has_more": false,
2613
+ "next_after": "1",
2614
+ },
2615
+ },
2616
+ {
2617
+ "checkpoint_complete": {
2618
+ "last_op_id": "2",
2619
+ },
2620
+ },
2621
+ ]
2622
+ `;
2623
+
2624
+ exports[`sync - postgres > storage v3 > sync global data 1`] = `
2625
+ [
2626
+ {
2627
+ "checkpoint": {
2628
+ "buckets": [
2629
+ {
2630
+ "bucket": "1#mybucket[]",
2631
+ "checksum": -93886621,
2632
+ "count": 2,
2633
+ "priority": 3,
2634
+ "subscriptions": [
2635
+ {
2636
+ "default": 0,
2637
+ },
2638
+ ],
2639
+ },
2640
+ ],
2641
+ "last_op_id": "2",
2642
+ "streams": [
2643
+ {
2644
+ "errors": [],
2645
+ "is_default": true,
2646
+ "name": "mybucket",
2647
+ },
2648
+ ],
2649
+ "write_checkpoint": undefined,
2650
+ },
2651
+ },
2652
+ {
2653
+ "data": {
2654
+ "after": "0",
2655
+ "bucket": "1#mybucket[]",
2656
+ "data": [
2657
+ {
2658
+ "checksum": 920318466,
2659
+ "data": "{"id":"t1","description":"Test 1"}",
2660
+ "object_id": "t1",
2661
+ "object_type": "test",
2662
+ "op": "PUT",
2663
+ "op_id": "1",
2664
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2665
+ },
2666
+ {
2667
+ "checksum": 3280762209,
2668
+ "data": "{"id":"t2","description":"Test 2"}",
2669
+ "object_id": "t2",
2670
+ "object_type": "test",
2671
+ "op": "PUT",
2672
+ "op_id": "2",
2673
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2674
+ },
2675
+ ],
2676
+ "has_more": false,
2677
+ "next_after": "2",
2678
+ },
2679
+ },
2680
+ {
2681
+ "checkpoint_complete": {
2682
+ "last_op_id": "2",
2683
+ },
2684
+ },
2685
+ ]
2686
+ `;
2687
+
2688
+ exports[`sync - postgres > storage v3 > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
2689
+ [
2690
+ {
2691
+ "checkpoint": {
2692
+ "buckets": [
2693
+ {
2694
+ "bucket": "1#b0a[]",
2695
+ "checksum": -659831575,
2696
+ "count": 2000,
2697
+ "priority": 2,
2698
+ "subscriptions": [
2699
+ {
2700
+ "default": 0,
2701
+ },
2702
+ ],
2703
+ },
2704
+ {
2705
+ "bucket": "1#b0b[]",
2706
+ "checksum": -659831575,
2707
+ "count": 2000,
2708
+ "priority": 2,
2709
+ "subscriptions": [
2710
+ {
2711
+ "default": 1,
2712
+ },
2713
+ ],
2714
+ },
2715
+ {
2716
+ "bucket": "1#b1[]",
2717
+ "checksum": -1096116670,
2718
+ "count": 1,
2719
+ "priority": 1,
2720
+ "subscriptions": [
2721
+ {
2722
+ "default": 2,
2723
+ },
2724
+ ],
2725
+ },
2726
+ ],
2727
+ "last_op_id": "4001",
2728
+ "streams": [
2729
+ {
2730
+ "errors": [],
2731
+ "is_default": true,
2732
+ "name": "b0a",
2733
+ },
2734
+ {
2735
+ "errors": [],
2736
+ "is_default": true,
2737
+ "name": "b0b",
2738
+ },
2739
+ {
2740
+ "errors": [],
2741
+ "is_default": true,
2742
+ "name": "b1",
2743
+ },
2744
+ ],
2745
+ "write_checkpoint": undefined,
2746
+ },
2747
+ },
2748
+ {
2749
+ "data": {
2750
+ "after": "0",
2751
+ "bucket": "1#b1[]",
2752
+ "data": undefined,
2753
+ "has_more": false,
2754
+ "next_after": "1",
2755
+ },
2756
+ },
2757
+ {
2758
+ "partial_checkpoint_complete": {
2759
+ "last_op_id": "4001",
2760
+ "priority": 1,
2761
+ },
2762
+ },
2763
+ {
2764
+ "data": {
2765
+ "after": "0",
2766
+ "bucket": "1#b0a[]",
2767
+ "data": undefined,
2768
+ "has_more": true,
2769
+ "next_after": "2000",
2770
+ },
2771
+ },
2772
+ {
2773
+ "data": {
2774
+ "after": "2000",
2775
+ "bucket": "1#b0a[]",
2776
+ "data": undefined,
2777
+ "has_more": true,
2778
+ "next_after": "4000",
2779
+ },
2780
+ },
2781
+ {
2782
+ "checkpoint_diff": {
2783
+ "last_op_id": "4004",
2784
+ "removed_buckets": [],
2785
+ "updated_buckets": [
2786
+ {
2787
+ "bucket": "1#b0a[]",
2788
+ "checksum": 883076828,
2789
+ "count": 2001,
2790
+ "priority": 2,
2791
+ "subscriptions": [
2792
+ {
2793
+ "default": 0,
2794
+ },
2795
+ ],
2796
+ },
2797
+ {
2798
+ "bucket": "1#b0b[]",
2799
+ "checksum": 883076828,
2800
+ "count": 2001,
2801
+ "priority": 2,
2802
+ "subscriptions": [
2803
+ {
2804
+ "default": 1,
2805
+ },
2806
+ ],
2807
+ },
2808
+ {
2809
+ "bucket": "1#b1[]",
2810
+ "checksum": 1841937527,
2811
+ "count": 2,
2812
+ "priority": 1,
2813
+ "subscriptions": [
2814
+ {
2815
+ "default": 2,
2816
+ },
2817
+ ],
2818
+ },
2819
+ ],
2820
+ "write_checkpoint": undefined,
2821
+ },
2822
+ },
2823
+ {
2824
+ "data": {
2825
+ "after": "1",
2826
+ "bucket": "1#b1[]",
2827
+ "data": undefined,
2828
+ "has_more": false,
2829
+ "next_after": "4002",
2830
+ },
2831
+ },
2832
+ {
2833
+ "partial_checkpoint_complete": {
2834
+ "last_op_id": "4004",
2835
+ "priority": 1,
2836
+ },
2837
+ },
2838
+ {
2839
+ "data": {
2840
+ "after": "4000",
2841
+ "bucket": "1#b0a[]",
2842
+ "data": undefined,
2843
+ "has_more": false,
2844
+ "next_after": "4003",
2845
+ },
2846
+ },
2847
+ {
2848
+ "data": {
2849
+ "after": "0",
2850
+ "bucket": "1#b0b[]",
2851
+ "data": undefined,
2852
+ "has_more": true,
2853
+ "next_after": "1999",
2854
+ },
2855
+ },
2856
+ {
2857
+ "data": {
2858
+ "after": "1999",
2859
+ "bucket": "1#b0b[]",
2860
+ "data": undefined,
2861
+ "has_more": true,
2862
+ "next_after": "3999",
2863
+ },
2864
+ },
2865
+ {
2866
+ "data": {
2867
+ "after": "3999",
2868
+ "bucket": "1#b0b[]",
2869
+ "data": undefined,
2870
+ "has_more": false,
2871
+ "next_after": "4004",
2872
+ },
2873
+ },
2874
+ {
2875
+ "checkpoint_complete": {
2876
+ "last_op_id": "4004",
2877
+ },
2878
+ },
2879
+ ]
2880
+ `;
2881
+
2882
+ exports[`sync - postgres > storage v3 > sync legacy non-raw data 1`] = `
2883
+ [
2884
+ {
2885
+ "checkpoint": {
2886
+ "buckets": [
2887
+ {
2888
+ "bucket": "1#mybucket[]",
2889
+ "checksum": -852817836,
2890
+ "count": 1,
2891
+ "priority": 3,
2892
+ "subscriptions": [
2893
+ {
2894
+ "default": 0,
2895
+ },
2896
+ ],
2897
+ },
2898
+ ],
2899
+ "last_op_id": "1",
2900
+ "streams": [
2901
+ {
2902
+ "errors": [],
2903
+ "is_default": true,
2904
+ "name": "mybucket",
2905
+ },
2906
+ ],
2907
+ "write_checkpoint": undefined,
2908
+ },
2909
+ },
2910
+ {
2911
+ "data": {
2912
+ "after": "0",
2913
+ "bucket": "1#mybucket[]",
2914
+ "data": [
2915
+ {
2916
+ "checksum": 3442149460n,
2917
+ "data": {
2918
+ "description": "Test
2919
+ "string"",
2920
+ "id": "t1",
2921
+ "large_num": 12345678901234567890n,
2922
+ },
2923
+ "object_id": "t1",
2924
+ "object_type": "test",
2925
+ "op": "PUT",
2926
+ "op_id": "1",
2927
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2928
+ },
2929
+ ],
2930
+ "has_more": false,
2931
+ "next_after": "1",
2932
+ },
2933
+ },
2934
+ {
2935
+ "checkpoint_complete": {
2936
+ "last_op_id": "1",
2937
+ },
2938
+ },
2939
+ ]
2940
+ `;
2941
+
2942
+ exports[`sync - postgres > storage v3 > sync updates to data query only 1`] = `
2943
+ [
2944
+ {
2945
+ "checkpoint": {
2946
+ "buckets": [
2947
+ {
2948
+ "bucket": "1#by_user["user1"]",
2949
+ "checksum": 0,
2950
+ "count": 0,
2951
+ "priority": 3,
2952
+ "subscriptions": [
2953
+ {
2954
+ "default": 0,
2955
+ },
2956
+ ],
2957
+ },
2958
+ ],
2959
+ "last_op_id": "1",
2960
+ "streams": [
2961
+ {
2962
+ "errors": [],
2963
+ "is_default": true,
2964
+ "name": "by_user",
2965
+ },
2966
+ ],
2967
+ "write_checkpoint": undefined,
2968
+ },
2969
+ },
2970
+ {
2971
+ "checkpoint_complete": {
2972
+ "last_op_id": "1",
2973
+ },
2974
+ },
2975
+ ]
2976
+ `;
2977
+
2978
+ exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
2979
+ [
2980
+ {
2981
+ "checkpoint_diff": {
2982
+ "last_op_id": "2",
2983
+ "removed_buckets": [],
2984
+ "updated_buckets": [
2985
+ {
2986
+ "bucket": "1#by_user["user1"]",
2987
+ "checksum": 1418351250,
2988
+ "count": 1,
2989
+ "priority": 3,
2990
+ "subscriptions": [
2991
+ {
2992
+ "default": 0,
2993
+ },
2994
+ ],
2995
+ },
2996
+ ],
2997
+ "write_checkpoint": undefined,
2998
+ },
2999
+ },
3000
+ {
3001
+ "data": {
3002
+ "after": "0",
3003
+ "bucket": "1#by_user["user1"]",
3004
+ "data": [
3005
+ {
3006
+ "checksum": 1418351250,
3007
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
3008
+ "object_id": "list1",
3009
+ "object_type": "lists",
3010
+ "op": "PUT",
3011
+ "op_id": "2",
3012
+ "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
3013
+ },
3014
+ ],
3015
+ "has_more": false,
3016
+ "next_after": "2",
3017
+ },
3018
+ },
3019
+ {
3020
+ "checkpoint_complete": {
3021
+ "last_op_id": "2",
3022
+ },
3023
+ },
3024
+ ]
3025
+ `;
3026
+
3027
+ exports[`sync - postgres > storage v3 > sync updates to global data 1`] = `
3028
+ [
3029
+ {
3030
+ "checkpoint": {
3031
+ "buckets": [
3032
+ {
3033
+ "bucket": "1#mybucket[]",
3034
+ "checksum": 0,
3035
+ "count": 0,
3036
+ "priority": 3,
3037
+ "subscriptions": [
3038
+ {
3039
+ "default": 0,
3040
+ },
3041
+ ],
3042
+ },
3043
+ ],
3044
+ "last_op_id": "0",
3045
+ "streams": [
3046
+ {
3047
+ "errors": [],
3048
+ "is_default": true,
3049
+ "name": "mybucket",
3050
+ },
3051
+ ],
3052
+ "write_checkpoint": undefined,
3053
+ },
3054
+ },
3055
+ {
3056
+ "checkpoint_complete": {
3057
+ "last_op_id": "0",
3058
+ },
3059
+ },
3060
+ ]
3061
+ `;
3062
+
3063
+ exports[`sync - postgres > storage v3 > sync updates to global data 2`] = `
3064
+ [
3065
+ {
3066
+ "checkpoint_diff": {
3067
+ "last_op_id": "1",
3068
+ "removed_buckets": [],
3069
+ "updated_buckets": [
3070
+ {
3071
+ "bucket": "1#mybucket[]",
3072
+ "checksum": 920318466,
3073
+ "count": 1,
3074
+ "priority": 3,
3075
+ "subscriptions": [
3076
+ {
3077
+ "default": 0,
3078
+ },
3079
+ ],
3080
+ },
3081
+ ],
3082
+ "write_checkpoint": undefined,
3083
+ },
3084
+ },
3085
+ {
3086
+ "data": {
3087
+ "after": "0",
3088
+ "bucket": "1#mybucket[]",
3089
+ "data": [
3090
+ {
3091
+ "checksum": 920318466,
3092
+ "data": "{"id":"t1","description":"Test 1"}",
3093
+ "object_id": "t1",
3094
+ "object_type": "test",
3095
+ "op": "PUT",
3096
+ "op_id": "1",
3097
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
3098
+ },
3099
+ ],
3100
+ "has_more": false,
3101
+ "next_after": "1",
3102
+ },
3103
+ },
3104
+ {
3105
+ "checkpoint_complete": {
3106
+ "last_op_id": "1",
3107
+ },
3108
+ },
3109
+ ]
3110
+ `;
3111
+
3112
+ exports[`sync - postgres > storage v3 > sync updates to global data 3`] = `
3113
+ [
3114
+ {
3115
+ "checkpoint_diff": {
3116
+ "last_op_id": "2",
3117
+ "removed_buckets": [],
3118
+ "updated_buckets": [
3119
+ {
3120
+ "bucket": "1#mybucket[]",
3121
+ "checksum": -93886621,
3122
+ "count": 2,
3123
+ "priority": 3,
3124
+ "subscriptions": [
3125
+ {
3126
+ "default": 0,
3127
+ },
3128
+ ],
3129
+ },
3130
+ ],
3131
+ "write_checkpoint": undefined,
3132
+ },
3133
+ },
3134
+ {
3135
+ "data": {
3136
+ "after": "1",
3137
+ "bucket": "1#mybucket[]",
3138
+ "data": [
3139
+ {
3140
+ "checksum": 3280762209,
3141
+ "data": "{"id":"t2","description":"Test 2"}",
3142
+ "object_id": "t2",
3143
+ "object_type": "test",
3144
+ "op": "PUT",
3145
+ "op_id": "2",
3146
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
3147
+ },
3148
+ ],
3149
+ "has_more": false,
3150
+ "next_after": "2",
3151
+ },
3152
+ },
3153
+ {
3154
+ "checkpoint_complete": {
3155
+ "last_op_id": "2",
3156
+ },
3157
+ },
3158
+ ]
3159
+ `;
3160
+
3161
+ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 1`] = `
3162
+ [
3163
+ {
3164
+ "checkpoint": {
3165
+ "buckets": [],
3166
+ "last_op_id": "0",
3167
+ "streams": [
3168
+ {
3169
+ "errors": [],
3170
+ "is_default": true,
3171
+ "name": "by_user",
3172
+ },
3173
+ ],
3174
+ "write_checkpoint": undefined,
3175
+ },
3176
+ },
3177
+ {
3178
+ "checkpoint_complete": {
3179
+ "last_op_id": "0",
3180
+ },
3181
+ },
3182
+ ]
3183
+ `;
3184
+
3185
+ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2`] = `
3186
+ [
3187
+ {
3188
+ "checkpoint_diff": {
3189
+ "last_op_id": "2",
3190
+ "removed_buckets": [],
3191
+ "updated_buckets": [
3192
+ {
3193
+ "bucket": "1#by_user["user1"]",
3194
+ "checksum": 1418351250,
3195
+ "count": 1,
3196
+ "priority": 3,
3197
+ "subscriptions": [
3198
+ {
3199
+ "default": 0,
3200
+ },
3201
+ ],
3202
+ },
3203
+ ],
3204
+ "write_checkpoint": undefined,
3205
+ },
3206
+ },
3207
+ {
3208
+ "data": {
3209
+ "after": "0",
3210
+ "bucket": "1#by_user["user1"]",
3211
+ "data": [
3212
+ {
3213
+ "checksum": 1418351250,
3214
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
3215
+ "object_id": "list1",
3216
+ "object_type": "lists",
3217
+ "op": "PUT",
3218
+ "op_id": "1",
3219
+ "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
3220
+ },
3221
+ ],
3222
+ "has_more": false,
3223
+ "next_after": "1",
3224
+ },
3225
+ },
3226
+ {
3227
+ "checkpoint_complete": {
3228
+ "last_op_id": "2",
3229
+ },
3230
+ },
3231
+ ]
3232
+ `;
3233
+
3234
+ exports[`sync - postgres > storage v3 > sync updates to parameter query only 1`] = `
3235
+ [
3236
+ {
3237
+ "checkpoint": {
3238
+ "buckets": [],
3239
+ "last_op_id": "0",
3240
+ "streams": [
3241
+ {
3242
+ "errors": [],
3243
+ "is_default": true,
3244
+ "name": "by_user",
3245
+ },
3246
+ ],
3247
+ "write_checkpoint": undefined,
3248
+ },
3249
+ },
3250
+ {
3251
+ "checkpoint_complete": {
3252
+ "last_op_id": "0",
3253
+ },
3254
+ },
3255
+ ]
3256
+ `;
3257
+
3258
+ exports[`sync - postgres > storage v3 > sync updates to parameter query only 2`] = `
3259
+ [
3260
+ {
3261
+ "checkpoint_diff": {
3262
+ "last_op_id": "1",
3263
+ "removed_buckets": [],
3264
+ "updated_buckets": [
3265
+ {
3266
+ "bucket": "1#by_user["user1"]",
3267
+ "checksum": 0,
3268
+ "count": 0,
3269
+ "priority": 3,
3270
+ "subscriptions": [
3271
+ {
3272
+ "default": 0,
3273
+ },
3274
+ ],
3275
+ },
3276
+ ],
3277
+ "write_checkpoint": undefined,
3278
+ },
3279
+ },
3280
+ {
3281
+ "checkpoint_complete": {
3282
+ "last_op_id": "1",
3283
+ },
3284
+ },
3285
+ ]
3286
+ `;