@powersync/service-module-postgres-storage 0.0.0-dev-20260225160713 → 0.0.0-dev-20260511080634

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 (100) hide show
  1. package/CHANGELOG.md +125 -7
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/migrations/scripts/1771424826685-current-data-pending-deletes.d.ts +3 -0
  4. package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +6 -1
  5. package/dist/@types/storage/PostgresCompactor.d.ts +8 -2
  6. package/dist/@types/storage/PostgresReportStorage.d.ts +1 -1
  7. package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +14 -6
  8. package/dist/@types/storage/batch/OperationBatch.d.ts +2 -2
  9. package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +14 -10
  10. package/dist/@types/storage/batch/PostgresPersistedBatch.d.ts +17 -5
  11. package/dist/@types/storage/current-data-store.d.ts +85 -0
  12. package/dist/@types/storage/table-id.d.ts +2 -0
  13. package/dist/@types/types/models/CurrentData.d.ts +18 -3
  14. package/dist/@types/types/models/SyncRules.d.ts +9 -0
  15. package/dist/@types/types/models/models-index.d.ts +1 -1
  16. package/dist/@types/utils/bson.d.ts +1 -1
  17. package/dist/@types/utils/test-utils.d.ts +3 -3
  18. package/dist/@types/utils/utils-index.d.ts +1 -1
  19. package/dist/migrations/migration-utils.js +2 -2
  20. package/dist/migrations/migration-utils.js.map +1 -1
  21. package/dist/migrations/scripts/1684951997326-init.js +24 -100
  22. package/dist/migrations/scripts/1684951997326-init.js.map +1 -1
  23. package/dist/migrations/scripts/1749024804042-snapshot-progress.js +12 -88
  24. package/dist/migrations/scripts/1749024804042-snapshot-progress.js.map +1 -1
  25. package/dist/migrations/scripts/1756282360128-connection-reporting.js +12 -88
  26. package/dist/migrations/scripts/1756282360128-connection-reporting.js.map +1 -1
  27. package/dist/migrations/scripts/1771232439485-storage-version.js +14 -90
  28. package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -1
  29. package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js +8 -0
  30. package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js.map +1 -0
  31. package/dist/migrations/scripts/1771491856000-sync-plan.js +6 -82
  32. package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -1
  33. package/dist/storage/PostgresBucketStorageFactory.js +47 -9
  34. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  35. package/dist/storage/PostgresCompactor.js +14 -6
  36. package/dist/storage/PostgresCompactor.js.map +1 -1
  37. package/dist/storage/PostgresReportStorage.js +3 -3
  38. package/dist/storage/PostgresReportStorage.js.map +1 -1
  39. package/dist/storage/PostgresSyncRulesStorage.js +93 -60
  40. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  41. package/dist/storage/batch/OperationBatch.js +2 -1
  42. package/dist/storage/batch/OperationBatch.js.map +1 -1
  43. package/dist/storage/batch/PostgresBucketBatch.js +297 -215
  44. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  45. package/dist/storage/batch/PostgresPersistedBatch.js +86 -81
  46. package/dist/storage/batch/PostgresPersistedBatch.js.map +1 -1
  47. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +1 -1
  48. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
  49. package/dist/storage/current-data-store.js +270 -0
  50. package/dist/storage/current-data-store.js.map +1 -0
  51. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +3 -3
  52. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
  53. package/dist/storage/table-id.js +8 -0
  54. package/dist/storage/table-id.js.map +1 -0
  55. package/dist/types/models/CurrentData.js +11 -2
  56. package/dist/types/models/CurrentData.js.map +1 -1
  57. package/dist/types/models/SyncRules.js +3 -1
  58. package/dist/types/models/SyncRules.js.map +1 -1
  59. package/dist/types/models/models-index.js +1 -1
  60. package/dist/types/models/models-index.js.map +1 -1
  61. package/dist/utils/bson.js.map +1 -1
  62. package/dist/utils/db.js +9 -0
  63. package/dist/utils/db.js.map +1 -1
  64. package/dist/utils/test-utils.js +39 -108
  65. package/dist/utils/test-utils.js.map +1 -1
  66. package/dist/utils/utils-index.js +1 -1
  67. package/dist/utils/utils-index.js.map +1 -1
  68. package/package.json +12 -13
  69. package/src/migrations/migration-utils.ts +2 -2
  70. package/src/migrations/scripts/1771424826685-current-data-pending-deletes.ts +10 -0
  71. package/src/storage/PostgresBucketStorageFactory.ts +60 -10
  72. package/src/storage/PostgresCompactor.ts +17 -8
  73. package/src/storage/PostgresReportStorage.ts +5 -5
  74. package/src/storage/PostgresSyncRulesStorage.ts +108 -65
  75. package/src/storage/batch/OperationBatch.ts +4 -3
  76. package/src/storage/batch/PostgresBucketBatch.ts +318 -240
  77. package/src/storage/batch/PostgresPersistedBatch.ts +92 -84
  78. package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +3 -1
  79. package/src/storage/current-data-store.ts +326 -0
  80. package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +3 -6
  81. package/src/storage/table-id.ts +9 -0
  82. package/src/types/models/CurrentData.ts +17 -4
  83. package/src/types/models/SyncRules.ts +3 -1
  84. package/src/types/models/models-index.ts +1 -1
  85. package/src/utils/bson.ts +1 -1
  86. package/src/utils/db.ts +10 -0
  87. package/src/utils/test-utils.ts +16 -9
  88. package/src/utils/utils-index.ts +1 -1
  89. package/test/src/__snapshots__/storage.test.ts.snap +151 -0
  90. package/test/src/__snapshots__/storage_compacting.test.ts.snap +17 -0
  91. package/test/src/__snapshots__/storage_sync.test.ts.snap +1393 -16
  92. package/test/src/connection-report-storage.test.ts +4 -4
  93. package/test/src/env.ts +1 -1
  94. package/test/src/migrations.test.ts +1 -1
  95. package/test/src/setup.ts +1 -1
  96. package/test/src/storage.test.ts +138 -131
  97. package/test/src/storage_compacting.test.ts +80 -11
  98. package/test/src/storage_sync.test.ts +57 -54
  99. package/test/src/util.ts +4 -4
  100. package/test/tsconfig.json +0 -1
@@ -1,5 +1,99 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`sync - postgres > storage v1 > can override priority when subscribing to stream 1`] = `
4
+ [
5
+ {
6
+ "checkpoint": {
7
+ "buckets": [
8
+ {
9
+ "bucket": "1#todos|0["a"]",
10
+ "checksum": -1712802421,
11
+ "count": 1,
12
+ "priority": 0,
13
+ "subscriptions": [
14
+ {
15
+ "sub": 0,
16
+ },
17
+ {
18
+ "sub": 1,
19
+ },
20
+ ],
21
+ },
22
+ {
23
+ "bucket": "1#todos|0["b"]",
24
+ "checksum": -1291414318,
25
+ "count": 1,
26
+ "priority": 3,
27
+ "subscriptions": [
28
+ {
29
+ "sub": 1,
30
+ },
31
+ ],
32
+ },
33
+ ],
34
+ "last_op_id": "2",
35
+ "streams": [
36
+ {
37
+ "errors": [],
38
+ "is_default": false,
39
+ "name": "todos",
40
+ },
41
+ ],
42
+ "write_checkpoint": undefined,
43
+ },
44
+ },
45
+ {
46
+ "data": {
47
+ "after": "0",
48
+ "bucket": "1#todos|0["a"]",
49
+ "data": [
50
+ {
51
+ "checksum": 2582164875,
52
+ "data": "{"id":"a","description":"Test 1"}",
53
+ "object_id": "a",
54
+ "object_type": "test",
55
+ "op": "PUT",
56
+ "op_id": "1",
57
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
58
+ },
59
+ ],
60
+ "has_more": false,
61
+ "next_after": "1",
62
+ },
63
+ },
64
+ {
65
+ "partial_checkpoint_complete": {
66
+ "last_op_id": "2",
67
+ "priority": 0,
68
+ },
69
+ },
70
+ {
71
+ "data": {
72
+ "after": "0",
73
+ "bucket": "1#todos|0["b"]",
74
+ "data": [
75
+ {
76
+ "checksum": 3003552978,
77
+ "data": "{"id":"b","description":"Test 2"}",
78
+ "object_id": "b",
79
+ "object_type": "test",
80
+ "op": "PUT",
81
+ "op_id": "2",
82
+ "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
83
+ },
84
+ ],
85
+ "has_more": false,
86
+ "next_after": "2",
87
+ },
88
+ },
89
+ {
90
+ "checkpoint_complete": {
91
+ "last_op_id": "2",
92
+ },
93
+ },
94
+ ]
95
+ `;
96
+
3
97
  exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint 1`] = `
4
98
  [
5
99
  {
@@ -104,7 +198,7 @@ exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint
104
198
  ]
105
199
  `;
106
200
 
107
- exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 1`] = `
201
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckets for streams 1`] = `
108
202
  [
109
203
  {
110
204
  "checkpoint": {
@@ -159,13 +253,13 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
159
253
  ]
160
254
  `;
161
255
 
162
- exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 2`] = `
256
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckets for streams 2`] = `
163
257
  [
164
258
  {
165
259
  "checkpoint": {
166
260
  "buckets": [
167
261
  {
168
- "bucket": "2#test|0[]",
262
+ "bucket": "2#test2|0[]",
169
263
  "checksum": 920318466,
170
264
  "count": 1,
171
265
  "priority": 3,
@@ -181,7 +275,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
181
275
  {
182
276
  "errors": [],
183
277
  "is_default": true,
184
- "name": "test",
278
+ "name": "test2",
185
279
  },
186
280
  ],
187
281
  "write_checkpoint": undefined,
@@ -190,7 +284,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
190
284
  {
191
285
  "data": {
192
286
  "after": "0",
193
- "bucket": "2#test|0[]",
287
+ "bucket": "2#test2|0[]",
194
288
  "data": [
195
289
  {
196
290
  "checksum": 920318466,
@@ -199,7 +293,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
199
293
  "object_type": "test",
200
294
  "op": "PUT",
201
295
  "op_id": "2",
202
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
296
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
203
297
  },
204
298
  ],
205
299
  "has_more": false,
@@ -819,7 +913,7 @@ exports[`sync - postgres > storage v1 > sync updates to data query only 2`] = `
819
913
  "object_type": "lists",
820
914
  "op": "PUT",
821
915
  "op_id": "2",
822
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
916
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
823
917
  },
824
918
  ],
825
919
  "has_more": false,
@@ -1026,7 +1120,7 @@ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 2
1026
1120
  "object_type": "lists",
1027
1121
  "op": "PUT",
1028
1122
  "op_id": "1",
1029
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
1123
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
1030
1124
  },
1031
1125
  ],
1032
1126
  "has_more": false,
@@ -1095,6 +1189,100 @@ exports[`sync - postgres > storage v1 > sync updates to parameter query only 2`]
1095
1189
  ]
1096
1190
  `;
1097
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
+
1098
1286
  exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 1`] = `
1099
1287
  [
1100
1288
  {
@@ -1199,7 +1387,7 @@ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint
1199
1387
  ]
1200
1388
  `;
1201
1389
 
1202
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 1`] = `
1390
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 1`] = `
1203
1391
  [
1204
1392
  {
1205
1393
  "checkpoint": {
@@ -1254,13 +1442,13 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1254
1442
  ]
1255
1443
  `;
1256
1444
 
1257
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 2`] = `
1445
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 2`] = `
1258
1446
  [
1259
1447
  {
1260
1448
  "checkpoint": {
1261
1449
  "buckets": [
1262
1450
  {
1263
- "bucket": "2#test|0[]",
1451
+ "bucket": "2#test2|0[]",
1264
1452
  "checksum": 920318466,
1265
1453
  "count": 1,
1266
1454
  "priority": 3,
@@ -1276,7 +1464,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1276
1464
  {
1277
1465
  "errors": [],
1278
1466
  "is_default": true,
1279
- "name": "test",
1467
+ "name": "test2",
1280
1468
  },
1281
1469
  ],
1282
1470
  "write_checkpoint": undefined,
@@ -1285,7 +1473,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1285
1473
  {
1286
1474
  "data": {
1287
1475
  "after": "0",
1288
- "bucket": "2#test|0[]",
1476
+ "bucket": "2#test2|0[]",
1289
1477
  "data": [
1290
1478
  {
1291
1479
  "checksum": 920318466,
@@ -1294,7 +1482,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1294
1482
  "object_type": "test",
1295
1483
  "op": "PUT",
1296
1484
  "op_id": "2",
1297
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1485
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
1298
1486
  },
1299
1487
  ],
1300
1488
  "has_more": false,
@@ -1914,7 +2102,7 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
1914
2102
  "object_type": "lists",
1915
2103
  "op": "PUT",
1916
2104
  "op_id": "2",
1917
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
2105
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
1918
2106
  },
1919
2107
  ],
1920
2108
  "has_more": false,
@@ -2121,7 +2309,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2
2121
2309
  "object_type": "lists",
2122
2310
  "op": "PUT",
2123
2311
  "op_id": "1",
2124
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
2312
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
2125
2313
  },
2126
2314
  ],
2127
2315
  "has_more": false,
@@ -2189,3 +2377,1192 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`]
2189
2377
  },
2190
2378
  ]
2191
2379
  `;
2380
+
2381
+ exports[`sync - postgres > storage v3 > can override priority when subscribing to stream 1`] = `
2382
+ [
2383
+ {
2384
+ "checkpoint": {
2385
+ "buckets": [
2386
+ {
2387
+ "bucket": "1#todos|0["a"]",
2388
+ "checksum": -1712802421,
2389
+ "count": 1,
2390
+ "priority": 0,
2391
+ "subscriptions": [
2392
+ {
2393
+ "sub": 0,
2394
+ },
2395
+ {
2396
+ "sub": 1,
2397
+ },
2398
+ ],
2399
+ },
2400
+ {
2401
+ "bucket": "1#todos|0["b"]",
2402
+ "checksum": -1291414318,
2403
+ "count": 1,
2404
+ "priority": 3,
2405
+ "subscriptions": [
2406
+ {
2407
+ "sub": 1,
2408
+ },
2409
+ ],
2410
+ },
2411
+ ],
2412
+ "last_op_id": "2",
2413
+ "streams": [
2414
+ {
2415
+ "errors": [],
2416
+ "is_default": false,
2417
+ "name": "todos",
2418
+ },
2419
+ ],
2420
+ "write_checkpoint": undefined,
2421
+ },
2422
+ },
2423
+ {
2424
+ "data": {
2425
+ "after": "0",
2426
+ "bucket": "1#todos|0["a"]",
2427
+ "data": [
2428
+ {
2429
+ "checksum": 2582164875,
2430
+ "data": "{"id":"a","description":"Test 1"}",
2431
+ "object_id": "a",
2432
+ "object_type": "test",
2433
+ "op": "PUT",
2434
+ "op_id": "1",
2435
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2436
+ },
2437
+ ],
2438
+ "has_more": false,
2439
+ "next_after": "1",
2440
+ },
2441
+ },
2442
+ {
2443
+ "partial_checkpoint_complete": {
2444
+ "last_op_id": "2",
2445
+ "priority": 0,
2446
+ },
2447
+ },
2448
+ {
2449
+ "data": {
2450
+ "after": "0",
2451
+ "bucket": "1#todos|0["b"]",
2452
+ "data": [
2453
+ {
2454
+ "checksum": 3003552978,
2455
+ "data": "{"id":"b","description":"Test 2"}",
2456
+ "object_id": "b",
2457
+ "object_type": "test",
2458
+ "op": "PUT",
2459
+ "op_id": "2",
2460
+ "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
2461
+ },
2462
+ ],
2463
+ "has_more": false,
2464
+ "next_after": "2",
2465
+ },
2466
+ },
2467
+ {
2468
+ "checkpoint_complete": {
2469
+ "last_op_id": "2",
2470
+ },
2471
+ },
2472
+ ]
2473
+ `;
2474
+
2475
+ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 1`] = `
2476
+ [
2477
+ {
2478
+ "checkpoint": {
2479
+ "buckets": [
2480
+ {
2481
+ "bucket": "1#mybucket[]",
2482
+ "checksum": -93886621,
2483
+ "count": 2,
2484
+ "priority": 3,
2485
+ "subscriptions": [
2486
+ {
2487
+ "default": 0,
2488
+ },
2489
+ ],
2490
+ },
2491
+ ],
2492
+ "last_op_id": "2",
2493
+ "streams": [
2494
+ {
2495
+ "errors": [],
2496
+ "is_default": true,
2497
+ "name": "mybucket",
2498
+ },
2499
+ ],
2500
+ "write_checkpoint": undefined,
2501
+ },
2502
+ },
2503
+ ]
2504
+ `;
2505
+
2506
+ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 2`] = `
2507
+ [
2508
+ {
2509
+ "data": {
2510
+ "after": "0",
2511
+ "bucket": "1#mybucket[]",
2512
+ "data": [
2513
+ {
2514
+ "checksum": -93886621,
2515
+ "op": "CLEAR",
2516
+ "op_id": "2",
2517
+ },
2518
+ ],
2519
+ "has_more": false,
2520
+ "next_after": "2",
2521
+ },
2522
+ },
2523
+ {
2524
+ "checkpoint_diff": {
2525
+ "last_op_id": "4",
2526
+ "removed_buckets": [],
2527
+ "updated_buckets": [
2528
+ {
2529
+ "bucket": "1#mybucket[]",
2530
+ "checksum": 499012468,
2531
+ "count": 4,
2532
+ "priority": 3,
2533
+ "subscriptions": [
2534
+ {
2535
+ "default": 0,
2536
+ },
2537
+ ],
2538
+ },
2539
+ ],
2540
+ "write_checkpoint": undefined,
2541
+ },
2542
+ },
2543
+ {
2544
+ "data": {
2545
+ "after": "2",
2546
+ "bucket": "1#mybucket[]",
2547
+ "data": [
2548
+ {
2549
+ "checksum": 1859363232,
2550
+ "data": "{"id":"t1","description":"Test 1b"}",
2551
+ "object_id": "t1",
2552
+ "object_type": "test",
2553
+ "op": "PUT",
2554
+ "op_id": "3",
2555
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2556
+ },
2557
+ {
2558
+ "checksum": 3028503153,
2559
+ "data": "{"id":"t2","description":"Test 2b"}",
2560
+ "object_id": "t2",
2561
+ "object_type": "test",
2562
+ "op": "PUT",
2563
+ "op_id": "4",
2564
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2565
+ },
2566
+ ],
2567
+ "has_more": false,
2568
+ "next_after": "4",
2569
+ },
2570
+ },
2571
+ {
2572
+ "checkpoint_complete": {
2573
+ "last_op_id": "4",
2574
+ },
2575
+ },
2576
+ ]
2577
+ `;
2578
+
2579
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 1`] = `
2580
+ [
2581
+ {
2582
+ "checkpoint": {
2583
+ "buckets": [
2584
+ {
2585
+ "bucket": "1#test|0[]",
2586
+ "checksum": 920318466,
2587
+ "count": 1,
2588
+ "priority": 3,
2589
+ "subscriptions": [
2590
+ {
2591
+ "default": 0,
2592
+ },
2593
+ ],
2594
+ },
2595
+ ],
2596
+ "last_op_id": "1",
2597
+ "streams": [
2598
+ {
2599
+ "errors": [],
2600
+ "is_default": true,
2601
+ "name": "test",
2602
+ },
2603
+ ],
2604
+ "write_checkpoint": undefined,
2605
+ },
2606
+ },
2607
+ {
2608
+ "data": {
2609
+ "after": "0",
2610
+ "bucket": "1#test|0[]",
2611
+ "data": [
2612
+ {
2613
+ "checksum": 920318466,
2614
+ "data": "{"id":"t1","description":"Test 1"}",
2615
+ "object_id": "t1",
2616
+ "object_type": "test",
2617
+ "op": "PUT",
2618
+ "op_id": "1",
2619
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2620
+ },
2621
+ ],
2622
+ "has_more": false,
2623
+ "next_after": "1",
2624
+ },
2625
+ },
2626
+ {
2627
+ "checkpoint_complete": {
2628
+ "last_op_id": "1",
2629
+ },
2630
+ },
2631
+ ]
2632
+ `;
2633
+
2634
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 2`] = `
2635
+ [
2636
+ {
2637
+ "checkpoint": {
2638
+ "buckets": [
2639
+ {
2640
+ "bucket": "2#test2|0[]",
2641
+ "checksum": 920318466,
2642
+ "count": 1,
2643
+ "priority": 3,
2644
+ "subscriptions": [
2645
+ {
2646
+ "default": 0,
2647
+ },
2648
+ ],
2649
+ },
2650
+ ],
2651
+ "last_op_id": "2",
2652
+ "streams": [
2653
+ {
2654
+ "errors": [],
2655
+ "is_default": true,
2656
+ "name": "test2",
2657
+ },
2658
+ ],
2659
+ "write_checkpoint": undefined,
2660
+ },
2661
+ },
2662
+ {
2663
+ "data": {
2664
+ "after": "0",
2665
+ "bucket": "2#test2|0[]",
2666
+ "data": [
2667
+ {
2668
+ "checksum": 920318466,
2669
+ "data": "{"id":"t1","description":"Test 1"}",
2670
+ "object_id": "t1",
2671
+ "object_type": "test",
2672
+ "op": "PUT",
2673
+ "op_id": "2",
2674
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
2675
+ },
2676
+ ],
2677
+ "has_more": false,
2678
+ "next_after": "2",
2679
+ },
2680
+ },
2681
+ {
2682
+ "checkpoint_complete": {
2683
+ "last_op_id": "2",
2684
+ },
2685
+ },
2686
+ ]
2687
+ `;
2688
+
2689
+ exports[`sync - postgres > storage v3 > expired token 1`] = `
2690
+ [
2691
+ {
2692
+ "token_expires_in": 0,
2693
+ },
2694
+ ]
2695
+ `;
2696
+
2697
+ exports[`sync - postgres > storage v3 > expiring token 1`] = `
2698
+ [
2699
+ {
2700
+ "checkpoint": {
2701
+ "buckets": [
2702
+ {
2703
+ "bucket": "1#mybucket[]",
2704
+ "checksum": 0,
2705
+ "count": 0,
2706
+ "priority": 3,
2707
+ "subscriptions": [
2708
+ {
2709
+ "default": 0,
2710
+ },
2711
+ ],
2712
+ },
2713
+ ],
2714
+ "last_op_id": "0",
2715
+ "streams": [
2716
+ {
2717
+ "errors": [],
2718
+ "is_default": true,
2719
+ "name": "mybucket",
2720
+ },
2721
+ ],
2722
+ "write_checkpoint": undefined,
2723
+ },
2724
+ },
2725
+ {
2726
+ "checkpoint_complete": {
2727
+ "last_op_id": "0",
2728
+ },
2729
+ },
2730
+ ]
2731
+ `;
2732
+
2733
+ exports[`sync - postgres > storage v3 > expiring token 2`] = `
2734
+ [
2735
+ {
2736
+ "token_expires_in": 0,
2737
+ },
2738
+ ]
2739
+ `;
2740
+
2741
+ exports[`sync - postgres > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2742
+ [
2743
+ {
2744
+ "checkpoint": {
2745
+ "buckets": [
2746
+ {
2747
+ "bucket": "1#mybucket[]",
2748
+ "checksum": -1221282404,
2749
+ "count": 1,
2750
+ "priority": 3,
2751
+ "subscriptions": [
2752
+ {
2753
+ "default": 0,
2754
+ },
2755
+ ],
2756
+ },
2757
+ ],
2758
+ "last_op_id": "1",
2759
+ "streams": [
2760
+ {
2761
+ "errors": [],
2762
+ "is_default": true,
2763
+ "name": "mybucket",
2764
+ },
2765
+ ],
2766
+ "write_checkpoint": undefined,
2767
+ },
2768
+ },
2769
+ {
2770
+ "data": {
2771
+ "after": "0",
2772
+ "bucket": "1#mybucket[]",
2773
+ "data": [
2774
+ {
2775
+ "checksum": 3073684892,
2776
+ "data": "{"id":"t1","description":"sync"}",
2777
+ "object_id": "t1",
2778
+ "object_type": "test",
2779
+ "op": "PUT",
2780
+ "op_id": "1",
2781
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2782
+ },
2783
+ ],
2784
+ "has_more": false,
2785
+ "next_after": "1",
2786
+ },
2787
+ },
2788
+ null,
2789
+ {
2790
+ "checkpoint_complete": {
2791
+ "last_op_id": "1",
2792
+ },
2793
+ },
2794
+ {
2795
+ "checkpoint_diff": {
2796
+ "last_op_id": "1",
2797
+ "removed_buckets": [],
2798
+ "updated_buckets": [],
2799
+ "write_checkpoint": "1",
2800
+ },
2801
+ },
2802
+ {
2803
+ "checkpoint_complete": {
2804
+ "last_op_id": "1",
2805
+ },
2806
+ },
2807
+ ]
2808
+ `;
2809
+
2810
+ exports[`sync - postgres > storage v3 > sync buckets in order 1`] = `
2811
+ [
2812
+ {
2813
+ "checkpoint": {
2814
+ "buckets": [
2815
+ {
2816
+ "bucket": "1#b0[]",
2817
+ "checksum": 920318466,
2818
+ "count": 1,
2819
+ "priority": 2,
2820
+ "subscriptions": [
2821
+ {
2822
+ "default": 0,
2823
+ },
2824
+ ],
2825
+ },
2826
+ {
2827
+ "bucket": "1#b1[]",
2828
+ "checksum": -1382098757,
2829
+ "count": 1,
2830
+ "priority": 1,
2831
+ "subscriptions": [
2832
+ {
2833
+ "default": 1,
2834
+ },
2835
+ ],
2836
+ },
2837
+ ],
2838
+ "last_op_id": "2",
2839
+ "streams": [
2840
+ {
2841
+ "errors": [],
2842
+ "is_default": true,
2843
+ "name": "b0",
2844
+ },
2845
+ {
2846
+ "errors": [],
2847
+ "is_default": true,
2848
+ "name": "b1",
2849
+ },
2850
+ ],
2851
+ "write_checkpoint": undefined,
2852
+ },
2853
+ },
2854
+ {
2855
+ "data": {
2856
+ "after": "0",
2857
+ "bucket": "1#b1[]",
2858
+ "data": [
2859
+ {
2860
+ "checksum": 2912868539,
2861
+ "data": "{"id":"earlier","description":"Test 2"}",
2862
+ "object_id": "earlier",
2863
+ "object_type": "test",
2864
+ "op": "PUT",
2865
+ "op_id": "2",
2866
+ "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
2867
+ },
2868
+ ],
2869
+ "has_more": false,
2870
+ "next_after": "2",
2871
+ },
2872
+ },
2873
+ {
2874
+ "partial_checkpoint_complete": {
2875
+ "last_op_id": "2",
2876
+ "priority": 1,
2877
+ },
2878
+ },
2879
+ {
2880
+ "data": {
2881
+ "after": "0",
2882
+ "bucket": "1#b0[]",
2883
+ "data": [
2884
+ {
2885
+ "checksum": 920318466,
2886
+ "data": "{"id":"t1","description":"Test 1"}",
2887
+ "object_id": "t1",
2888
+ "object_type": "test",
2889
+ "op": "PUT",
2890
+ "op_id": "1",
2891
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2892
+ },
2893
+ ],
2894
+ "has_more": false,
2895
+ "next_after": "1",
2896
+ },
2897
+ },
2898
+ {
2899
+ "checkpoint_complete": {
2900
+ "last_op_id": "2",
2901
+ },
2902
+ },
2903
+ ]
2904
+ `;
2905
+
2906
+ exports[`sync - postgres > storage v3 > sync global data 1`] = `
2907
+ [
2908
+ {
2909
+ "checkpoint": {
2910
+ "buckets": [
2911
+ {
2912
+ "bucket": "1#mybucket[]",
2913
+ "checksum": -93886621,
2914
+ "count": 2,
2915
+ "priority": 3,
2916
+ "subscriptions": [
2917
+ {
2918
+ "default": 0,
2919
+ },
2920
+ ],
2921
+ },
2922
+ ],
2923
+ "last_op_id": "2",
2924
+ "streams": [
2925
+ {
2926
+ "errors": [],
2927
+ "is_default": true,
2928
+ "name": "mybucket",
2929
+ },
2930
+ ],
2931
+ "write_checkpoint": undefined,
2932
+ },
2933
+ },
2934
+ {
2935
+ "data": {
2936
+ "after": "0",
2937
+ "bucket": "1#mybucket[]",
2938
+ "data": [
2939
+ {
2940
+ "checksum": 920318466,
2941
+ "data": "{"id":"t1","description":"Test 1"}",
2942
+ "object_id": "t1",
2943
+ "object_type": "test",
2944
+ "op": "PUT",
2945
+ "op_id": "1",
2946
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2947
+ },
2948
+ {
2949
+ "checksum": 3280762209,
2950
+ "data": "{"id":"t2","description":"Test 2"}",
2951
+ "object_id": "t2",
2952
+ "object_type": "test",
2953
+ "op": "PUT",
2954
+ "op_id": "2",
2955
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2956
+ },
2957
+ ],
2958
+ "has_more": false,
2959
+ "next_after": "2",
2960
+ },
2961
+ },
2962
+ {
2963
+ "checkpoint_complete": {
2964
+ "last_op_id": "2",
2965
+ },
2966
+ },
2967
+ ]
2968
+ `;
2969
+
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`] = `
3165
+ [
3166
+ {
3167
+ "checkpoint": {
3168
+ "buckets": [
3169
+ {
3170
+ "bucket": "1#mybucket[]",
3171
+ "checksum": -852817836,
3172
+ "count": 1,
3173
+ "priority": 3,
3174
+ "subscriptions": [
3175
+ {
3176
+ "default": 0,
3177
+ },
3178
+ ],
3179
+ },
3180
+ ],
3181
+ "last_op_id": "1",
3182
+ "streams": [
3183
+ {
3184
+ "errors": [],
3185
+ "is_default": true,
3186
+ "name": "mybucket",
3187
+ },
3188
+ ],
3189
+ "write_checkpoint": undefined,
3190
+ },
3191
+ },
3192
+ {
3193
+ "data": {
3194
+ "after": "0",
3195
+ "bucket": "1#mybucket[]",
3196
+ "data": [
3197
+ {
3198
+ "checksum": 3442149460n,
3199
+ "data": {
3200
+ "description": "Test
3201
+ "string"",
3202
+ "id": "t1",
3203
+ "large_num": 12345678901234567890n,
3204
+ },
3205
+ "object_id": "t1",
3206
+ "object_type": "test",
3207
+ "op": "PUT",
3208
+ "op_id": "1",
3209
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
3210
+ },
3211
+ ],
3212
+ "has_more": false,
3213
+ "next_after": "1",
3214
+ },
3215
+ },
3216
+ {
3217
+ "checkpoint_complete": {
3218
+ "last_op_id": "1",
3219
+ },
3220
+ },
3221
+ ]
3222
+ `;
3223
+
3224
+ exports[`sync - postgres > storage v3 > sync updates to data query only 1`] = `
3225
+ [
3226
+ {
3227
+ "checkpoint": {
3228
+ "buckets": [
3229
+ {
3230
+ "bucket": "1#by_user["user1"]",
3231
+ "checksum": 0,
3232
+ "count": 0,
3233
+ "priority": 3,
3234
+ "subscriptions": [
3235
+ {
3236
+ "default": 0,
3237
+ },
3238
+ ],
3239
+ },
3240
+ ],
3241
+ "last_op_id": "1",
3242
+ "streams": [
3243
+ {
3244
+ "errors": [],
3245
+ "is_default": true,
3246
+ "name": "by_user",
3247
+ },
3248
+ ],
3249
+ "write_checkpoint": undefined,
3250
+ },
3251
+ },
3252
+ {
3253
+ "checkpoint_complete": {
3254
+ "last_op_id": "1",
3255
+ },
3256
+ },
3257
+ ]
3258
+ `;
3259
+
3260
+ exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
3261
+ [
3262
+ {
3263
+ "checkpoint_diff": {
3264
+ "last_op_id": "2",
3265
+ "removed_buckets": [],
3266
+ "updated_buckets": [
3267
+ {
3268
+ "bucket": "1#by_user["user1"]",
3269
+ "checksum": 1418351250,
3270
+ "count": 1,
3271
+ "priority": 3,
3272
+ "subscriptions": [
3273
+ {
3274
+ "default": 0,
3275
+ },
3276
+ ],
3277
+ },
3278
+ ],
3279
+ "write_checkpoint": undefined,
3280
+ },
3281
+ },
3282
+ {
3283
+ "data": {
3284
+ "after": "0",
3285
+ "bucket": "1#by_user["user1"]",
3286
+ "data": [
3287
+ {
3288
+ "checksum": 1418351250,
3289
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
3290
+ "object_id": "list1",
3291
+ "object_type": "lists",
3292
+ "op": "PUT",
3293
+ "op_id": "2",
3294
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
3295
+ },
3296
+ ],
3297
+ "has_more": false,
3298
+ "next_after": "2",
3299
+ },
3300
+ },
3301
+ {
3302
+ "checkpoint_complete": {
3303
+ "last_op_id": "2",
3304
+ },
3305
+ },
3306
+ ]
3307
+ `;
3308
+
3309
+ exports[`sync - postgres > storage v3 > sync updates to global data 1`] = `
3310
+ [
3311
+ {
3312
+ "checkpoint": {
3313
+ "buckets": [
3314
+ {
3315
+ "bucket": "1#mybucket[]",
3316
+ "checksum": 0,
3317
+ "count": 0,
3318
+ "priority": 3,
3319
+ "subscriptions": [
3320
+ {
3321
+ "default": 0,
3322
+ },
3323
+ ],
3324
+ },
3325
+ ],
3326
+ "last_op_id": "0",
3327
+ "streams": [
3328
+ {
3329
+ "errors": [],
3330
+ "is_default": true,
3331
+ "name": "mybucket",
3332
+ },
3333
+ ],
3334
+ "write_checkpoint": undefined,
3335
+ },
3336
+ },
3337
+ {
3338
+ "checkpoint_complete": {
3339
+ "last_op_id": "0",
3340
+ },
3341
+ },
3342
+ ]
3343
+ `;
3344
+
3345
+ exports[`sync - postgres > storage v3 > sync updates to global data 2`] = `
3346
+ [
3347
+ {
3348
+ "checkpoint_diff": {
3349
+ "last_op_id": "1",
3350
+ "removed_buckets": [],
3351
+ "updated_buckets": [
3352
+ {
3353
+ "bucket": "1#mybucket[]",
3354
+ "checksum": 920318466,
3355
+ "count": 1,
3356
+ "priority": 3,
3357
+ "subscriptions": [
3358
+ {
3359
+ "default": 0,
3360
+ },
3361
+ ],
3362
+ },
3363
+ ],
3364
+ "write_checkpoint": undefined,
3365
+ },
3366
+ },
3367
+ {
3368
+ "data": {
3369
+ "after": "0",
3370
+ "bucket": "1#mybucket[]",
3371
+ "data": [
3372
+ {
3373
+ "checksum": 920318466,
3374
+ "data": "{"id":"t1","description":"Test 1"}",
3375
+ "object_id": "t1",
3376
+ "object_type": "test",
3377
+ "op": "PUT",
3378
+ "op_id": "1",
3379
+ "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
3380
+ },
3381
+ ],
3382
+ "has_more": false,
3383
+ "next_after": "1",
3384
+ },
3385
+ },
3386
+ {
3387
+ "checkpoint_complete": {
3388
+ "last_op_id": "1",
3389
+ },
3390
+ },
3391
+ ]
3392
+ `;
3393
+
3394
+ exports[`sync - postgres > storage v3 > sync updates to global data 3`] = `
3395
+ [
3396
+ {
3397
+ "checkpoint_diff": {
3398
+ "last_op_id": "2",
3399
+ "removed_buckets": [],
3400
+ "updated_buckets": [
3401
+ {
3402
+ "bucket": "1#mybucket[]",
3403
+ "checksum": -93886621,
3404
+ "count": 2,
3405
+ "priority": 3,
3406
+ "subscriptions": [
3407
+ {
3408
+ "default": 0,
3409
+ },
3410
+ ],
3411
+ },
3412
+ ],
3413
+ "write_checkpoint": undefined,
3414
+ },
3415
+ },
3416
+ {
3417
+ "data": {
3418
+ "after": "1",
3419
+ "bucket": "1#mybucket[]",
3420
+ "data": [
3421
+ {
3422
+ "checksum": 3280762209,
3423
+ "data": "{"id":"t2","description":"Test 2"}",
3424
+ "object_id": "t2",
3425
+ "object_type": "test",
3426
+ "op": "PUT",
3427
+ "op_id": "2",
3428
+ "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
3429
+ },
3430
+ ],
3431
+ "has_more": false,
3432
+ "next_after": "2",
3433
+ },
3434
+ },
3435
+ {
3436
+ "checkpoint_complete": {
3437
+ "last_op_id": "2",
3438
+ },
3439
+ },
3440
+ ]
3441
+ `;
3442
+
3443
+ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 1`] = `
3444
+ [
3445
+ {
3446
+ "checkpoint": {
3447
+ "buckets": [],
3448
+ "last_op_id": "0",
3449
+ "streams": [
3450
+ {
3451
+ "errors": [],
3452
+ "is_default": true,
3453
+ "name": "by_user",
3454
+ },
3455
+ ],
3456
+ "write_checkpoint": undefined,
3457
+ },
3458
+ },
3459
+ {
3460
+ "checkpoint_complete": {
3461
+ "last_op_id": "0",
3462
+ },
3463
+ },
3464
+ ]
3465
+ `;
3466
+
3467
+ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2`] = `
3468
+ [
3469
+ {
3470
+ "checkpoint_diff": {
3471
+ "last_op_id": "2",
3472
+ "removed_buckets": [],
3473
+ "updated_buckets": [
3474
+ {
3475
+ "bucket": "1#by_user["user1"]",
3476
+ "checksum": 1418351250,
3477
+ "count": 1,
3478
+ "priority": 3,
3479
+ "subscriptions": [
3480
+ {
3481
+ "default": 0,
3482
+ },
3483
+ ],
3484
+ },
3485
+ ],
3486
+ "write_checkpoint": undefined,
3487
+ },
3488
+ },
3489
+ {
3490
+ "data": {
3491
+ "after": "0",
3492
+ "bucket": "1#by_user["user1"]",
3493
+ "data": [
3494
+ {
3495
+ "checksum": 1418351250,
3496
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
3497
+ "object_id": "list1",
3498
+ "object_type": "lists",
3499
+ "op": "PUT",
3500
+ "op_id": "1",
3501
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
3502
+ },
3503
+ ],
3504
+ "has_more": false,
3505
+ "next_after": "1",
3506
+ },
3507
+ },
3508
+ {
3509
+ "checkpoint_complete": {
3510
+ "last_op_id": "2",
3511
+ },
3512
+ },
3513
+ ]
3514
+ `;
3515
+
3516
+ exports[`sync - postgres > storage v3 > sync updates to parameter query only 1`] = `
3517
+ [
3518
+ {
3519
+ "checkpoint": {
3520
+ "buckets": [],
3521
+ "last_op_id": "0",
3522
+ "streams": [
3523
+ {
3524
+ "errors": [],
3525
+ "is_default": true,
3526
+ "name": "by_user",
3527
+ },
3528
+ ],
3529
+ "write_checkpoint": undefined,
3530
+ },
3531
+ },
3532
+ {
3533
+ "checkpoint_complete": {
3534
+ "last_op_id": "0",
3535
+ },
3536
+ },
3537
+ ]
3538
+ `;
3539
+
3540
+ exports[`sync - postgres > storage v3 > sync updates to parameter query only 2`] = `
3541
+ [
3542
+ {
3543
+ "checkpoint_diff": {
3544
+ "last_op_id": "1",
3545
+ "removed_buckets": [],
3546
+ "updated_buckets": [
3547
+ {
3548
+ "bucket": "1#by_user["user1"]",
3549
+ "checksum": 0,
3550
+ "count": 0,
3551
+ "priority": 3,
3552
+ "subscriptions": [
3553
+ {
3554
+ "default": 0,
3555
+ },
3556
+ ],
3557
+ },
3558
+ ],
3559
+ "write_checkpoint": undefined,
3560
+ },
3561
+ },
3562
+ {
3563
+ "checkpoint_complete": {
3564
+ "last_op_id": "1",
3565
+ },
3566
+ },
3567
+ ]
3568
+ `;