@powersync/service-module-mongodb-storage 0.0.0-dev-20260803144812 → 0.0.0-dev-20260929095716

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 (213) hide show
  1. package/CHANGELOG.md +129 -7
  2. package/dist/storage/MongoBucketStorage.d.ts +42 -5
  3. package/dist/storage/MongoBucketStorage.js +404 -215
  4. package/dist/storage/MongoBucketStorage.js.map +1 -1
  5. package/dist/storage/implementation/MongoBucketBatch.d.ts +39 -14
  6. package/dist/storage/implementation/MongoBucketBatch.js +169 -98
  7. package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
  8. package/dist/storage/implementation/MongoCompactor.d.ts +21 -79
  9. package/dist/storage/implementation/MongoCompactor.js +27 -238
  10. package/dist/storage/implementation/MongoCompactor.js.map +1 -1
  11. package/dist/storage/implementation/MongoIdSequence.d.ts +10 -1
  12. package/dist/storage/implementation/MongoIdSequence.js +14 -1
  13. package/dist/storage/implementation/MongoIdSequence.js.map +1 -1
  14. package/dist/storage/implementation/MongoOpIdAllocator.d.ts +27 -0
  15. package/dist/storage/implementation/MongoOpIdAllocator.js +97 -0
  16. package/dist/storage/implementation/MongoOpIdAllocator.js.map +1 -0
  17. package/dist/storage/implementation/MongoParameterCompactor.d.ts +83 -10
  18. package/dist/storage/implementation/MongoParameterCompactor.js +309 -96
  19. package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -1
  20. package/dist/storage/implementation/MongoParsedSyncConfigSet.d.ts +9 -1
  21. package/dist/storage/implementation/MongoParsedSyncConfigSet.js +35 -2
  22. package/dist/storage/implementation/MongoParsedSyncConfigSet.js.map +1 -1
  23. package/dist/storage/implementation/MongoPersistedReplicationStream.d.ts +2 -1
  24. package/dist/storage/implementation/MongoPersistedReplicationStream.js +7 -4
  25. package/dist/storage/implementation/MongoPersistedReplicationStream.js.map +1 -1
  26. package/dist/storage/implementation/MongoPersistedSyncConfigContent.d.ts +3 -3
  27. package/dist/storage/implementation/MongoPersistedSyncConfigContent.js +10 -8
  28. package/dist/storage/implementation/MongoPersistedSyncConfigContent.js.map +1 -1
  29. package/dist/storage/implementation/MongoStorageProvider.js +8 -4
  30. package/dist/storage/implementation/MongoStorageProvider.js.map +1 -1
  31. package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +32 -11
  32. package/dist/storage/implementation/MongoSyncBucketStorage.js +95 -31
  33. package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
  34. package/dist/storage/implementation/MongoSyncRulesLock.d.ts +26 -2
  35. package/dist/storage/implementation/MongoSyncRulesLock.js +59 -10
  36. package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
  37. package/dist/storage/implementation/MongoWriteBatch.d.ts +49 -0
  38. package/dist/storage/implementation/MongoWriteBatch.js +149 -0
  39. package/dist/storage/implementation/MongoWriteBatch.js.map +1 -0
  40. package/dist/storage/implementation/MongoWriteCheckpointAPI.d.ts +9 -7
  41. package/dist/storage/implementation/MongoWriteCheckpointAPI.js +9 -30
  42. package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
  43. package/dist/storage/implementation/SyncRuleStateUpdate.d.ts +11 -5
  44. package/dist/storage/implementation/SyncRuleStateUpdate.js +14 -6
  45. package/dist/storage/implementation/SyncRuleStateUpdate.js.map +1 -1
  46. package/dist/storage/implementation/common/MongoSyncBucketStorageCheckpoint.d.ts +22 -2
  47. package/dist/storage/implementation/common/PersistedBatch.d.ts +32 -4
  48. package/dist/storage/implementation/common/PersistedBatch.js +57 -14
  49. package/dist/storage/implementation/common/PersistedBatch.js.map +1 -1
  50. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.d.ts +3 -0
  51. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js +3 -0
  52. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js.map +1 -1
  53. package/dist/storage/implementation/db.d.ts +9 -1
  54. package/dist/storage/implementation/db.js +28 -1
  55. package/dist/storage/implementation/db.js.map +1 -1
  56. package/dist/storage/implementation/models.d.ts +35 -0
  57. package/dist/storage/implementation/models.js.map +1 -1
  58. package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +11 -0
  59. package/dist/storage/implementation/v1/MongoBucketBatchV1.js +227 -221
  60. package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -1
  61. package/dist/storage/implementation/v1/MongoCompactorV1.d.ts +38 -6
  62. package/dist/storage/implementation/v1/MongoCompactorV1.js +247 -20
  63. package/dist/storage/implementation/v1/MongoCompactorV1.js.map +1 -1
  64. package/dist/storage/implementation/v1/MongoParameterCompactorV1.d.ts +16 -2
  65. package/dist/storage/implementation/v1/MongoParameterCompactorV1.js +20 -9
  66. package/dist/storage/implementation/v1/MongoParameterCompactorV1.js.map +1 -1
  67. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.d.ts +18 -11
  68. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js +66 -17
  69. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js.map +1 -1
  70. package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +7 -5
  71. package/dist/storage/implementation/v1/PersistedBatchV1.js +22 -28
  72. package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -1
  73. package/dist/storage/implementation/v1/models.js +1 -0
  74. package/dist/storage/implementation/v1/models.js.map +1 -1
  75. package/dist/storage/implementation/v3/CompactionLease.d.ts +50 -0
  76. package/dist/storage/implementation/v3/CompactionLease.js +131 -0
  77. package/dist/storage/implementation/v3/CompactionLease.js.map +1 -0
  78. package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +14 -2
  79. package/dist/storage/implementation/v3/MongoBucketBatchV3.js +261 -194
  80. package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -1
  81. package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +83 -25
  82. package/dist/storage/implementation/v3/MongoCompactorV3.js +702 -159
  83. package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -1
  84. package/dist/storage/implementation/v3/MongoParameterCompactorV3.d.ts +18 -0
  85. package/dist/storage/implementation/v3/MongoParameterCompactorV3.js +23 -0
  86. package/dist/storage/implementation/v3/MongoParameterCompactorV3.js.map +1 -0
  87. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.d.ts +2 -15
  88. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.js +60 -92
  89. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.js.map +1 -1
  90. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.d.ts +19 -9
  91. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js +92 -32
  92. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js.map +1 -1
  93. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.d.ts +26 -0
  94. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.js +82 -0
  95. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.js.map +1 -0
  96. package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +14 -8
  97. package/dist/storage/implementation/v3/PersistedBatchV3.js +77 -45
  98. package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -1
  99. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.d.ts +12 -2
  100. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js +42 -3
  101. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js.map +1 -1
  102. package/dist/storage/implementation/v3/bucket-format.js +2 -0
  103. package/dist/storage/implementation/v3/bucket-format.js.map +1 -1
  104. package/dist/storage/implementation/v3/compact-utils.d.ts +108 -0
  105. package/dist/storage/implementation/v3/compact-utils.js +223 -0
  106. package/dist/storage/implementation/v3/compact-utils.js.map +1 -0
  107. package/dist/storage/implementation/v3/compaction-constants.d.ts +5 -0
  108. package/dist/storage/implementation/v3/compaction-constants.js +6 -0
  109. package/dist/storage/implementation/v3/compaction-constants.js.map +1 -0
  110. package/dist/storage/implementation/v3/models.d.ts +90 -6
  111. package/dist/storage/implementation/v3/models.js.map +1 -1
  112. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.d.ts +7 -8
  113. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js +16 -5
  114. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js.map +1 -1
  115. package/dist/storage/implementation/v3/object-storage/ObjectStorage.d.ts +14 -11
  116. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.d.ts +6 -8
  117. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js +17 -11
  118. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js.map +1 -1
  119. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.d.ts +38 -0
  120. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js +164 -0
  121. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js.map +1 -0
  122. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.d.ts +37 -12
  123. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js +197 -25
  124. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js.map +1 -1
  125. package/dist/storage/implementation/v3/source-table-utils.d.ts +15 -7
  126. package/dist/storage/implementation/v3/source-table-utils.js +49 -57
  127. package/dist/storage/implementation/v3/source-table-utils.js.map +1 -1
  128. package/dist/storage/storage-index.d.ts +2 -1
  129. package/dist/storage/storage-index.js +1 -0
  130. package/dist/storage/storage-index.js.map +1 -1
  131. package/dist/types/types.d.ts +28 -1
  132. package/dist/types/types.js +28 -7
  133. package/dist/types/types.js.map +1 -1
  134. package/dist/utils/test-utils.d.ts +4 -2
  135. package/dist/utils/test-utils.js +7 -4
  136. package/dist/utils/test-utils.js.map +1 -1
  137. package/dist/utils/util.js +3 -1
  138. package/dist/utils/util.js.map +1 -1
  139. package/package.json +10 -9
  140. package/src/storage/MongoBucketStorage.ts +545 -277
  141. package/src/storage/implementation/MongoBucketBatch.ts +258 -124
  142. package/src/storage/implementation/MongoCompactor.ts +37 -346
  143. package/src/storage/implementation/MongoIdSequence.ts +21 -1
  144. package/src/storage/implementation/MongoOpIdAllocator.ts +105 -0
  145. package/src/storage/implementation/MongoParameterCompactor.ts +388 -102
  146. package/src/storage/implementation/MongoParsedSyncConfigSet.ts +46 -1
  147. package/src/storage/implementation/MongoPersistedReplicationStream.ts +12 -4
  148. package/src/storage/implementation/MongoPersistedSyncConfigContent.ts +48 -29
  149. package/src/storage/implementation/MongoStorageProvider.ts +16 -4
  150. package/src/storage/implementation/MongoSyncBucketStorage.ts +133 -40
  151. package/src/storage/implementation/MongoSyncRulesLock.ts +78 -12
  152. package/src/storage/implementation/MongoWriteBatch.ts +172 -0
  153. package/src/storage/implementation/MongoWriteCheckpointAPI.ts +16 -46
  154. package/src/storage/implementation/SyncRuleStateUpdate.ts +13 -6
  155. package/src/storage/implementation/common/MongoSyncBucketStorageCheckpoint.ts +24 -2
  156. package/src/storage/implementation/common/PersistedBatch.ts +76 -20
  157. package/src/storage/implementation/common/VersionedPowerSyncMongoBase.ts +4 -0
  158. package/src/storage/implementation/db.ts +36 -2
  159. package/src/storage/implementation/models.ts +39 -0
  160. package/src/storage/implementation/v1/MongoBucketBatchV1.ts +272 -254
  161. package/src/storage/implementation/v1/MongoCompactorV1.ts +327 -40
  162. package/src/storage/implementation/v1/MongoParameterCompactorV1.ts +25 -9
  163. package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +88 -28
  164. package/src/storage/implementation/v1/PersistedBatchV1.ts +25 -30
  165. package/src/storage/implementation/v1/models.ts +1 -0
  166. package/src/storage/implementation/v3/CompactionLease.ts +152 -0
  167. package/src/storage/implementation/v3/MongoBucketBatchV3.ts +339 -247
  168. package/src/storage/implementation/v3/MongoCompactorV3.ts +955 -225
  169. package/src/storage/implementation/v3/MongoParameterCompactorV3.ts +34 -0
  170. package/src/storage/implementation/v3/MongoStoppedSyncConfigCleanup.ts +100 -109
  171. package/src/storage/implementation/v3/MongoSyncBucketStorageV3.ts +112 -42
  172. package/src/storage/implementation/v3/MongoWriteCheckpointAPIV3.ts +111 -0
  173. package/src/storage/implementation/v3/PersistedBatchV3.ts +94 -51
  174. package/src/storage/implementation/v3/VersionedPowerSyncMongoV3.ts +55 -4
  175. package/src/storage/implementation/v3/bucket-format.ts +2 -0
  176. package/src/storage/implementation/v3/compact-utils.ts +329 -0
  177. package/src/storage/implementation/v3/compaction-constants.ts +5 -0
  178. package/src/storage/implementation/v3/models.ts +97 -4
  179. package/src/storage/implementation/v3/object-storage/BucketDataObjectStorage.ts +24 -9
  180. package/src/storage/implementation/v3/object-storage/ObjectStorage.ts +20 -5
  181. package/src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts +26 -14
  182. package/src/storage/implementation/v3/object-storage/ObjectStorageUsage.ts +229 -0
  183. package/src/storage/implementation/v3/object-storage/S3ObjectStorage.ts +279 -29
  184. package/src/storage/implementation/v3/source-table-utils.ts +82 -76
  185. package/src/storage/storage-index.ts +2 -0
  186. package/src/types/types.ts +42 -7
  187. package/src/utils/test-utils.ts +9 -5
  188. package/src/utils/util.ts +3 -1
  189. package/test/src/__snapshots__/storage.test.ts.snap +25 -0
  190. package/test/src/__snapshots__/storage_sync.test.ts.snap +794 -205
  191. package/test/src/chunk_compaction_config.test.ts +38 -0
  192. package/test/src/cleanup-stopped-sync-configs.test.ts +59 -26
  193. package/test/src/compact-utils.test.ts +251 -0
  194. package/test/src/concurrent_writers.test.ts +599 -0
  195. package/test/src/connection_config.test.ts +159 -0
  196. package/test/src/helpers/MemoryObjectStorage.ts +14 -6
  197. package/test/src/helpers/concurrentWriter.mjs +29 -0
  198. package/test/src/helpers/s3TestFactory.ts +12 -12
  199. package/test/src/object_storage_usage.test.ts +268 -0
  200. package/test/src/parameter_compacting_v1.test.ts +120 -0
  201. package/test/src/parameter_compacting_v3.test.ts +192 -0
  202. package/test/src/parameter_compaction_fence.test.ts +276 -0
  203. package/test/src/storage.test.ts +280 -24
  204. package/test/src/storage_compacting.test.ts +1097 -253
  205. package/test/src/storage_object_storage_inline_threshold.test.ts +3 -3
  206. package/test/src/storage_s3_checksums.test.ts +6 -7
  207. package/test/src/storage_s3_compaction_lifecycle.test.ts +143 -17
  208. package/test/src/storage_s3_reading.test.ts +294 -6
  209. package/test/src/storage_s3_writing.test.ts +4 -3
  210. package/test/src/storage_sync.test.ts +412 -80
  211. package/test/src/storeCurrentData.test.ts +5 -5
  212. package/test/src/util.ts +1 -1
  213. package/tsconfig.tsbuildinfo +1 -1
@@ -270,7 +270,7 @@ exports[`sync - mongodb > storage v1 > encodes sync rules id in buckets for stre
270
270
  ],
271
271
  },
272
272
  ],
273
- "last_op_id": "2",
273
+ "last_op_id": "65537",
274
274
  "streams": [
275
275
  {
276
276
  "errors": [],
@@ -292,17 +292,17 @@ exports[`sync - mongodb > storage v1 > encodes sync rules id in buckets for stre
292
292
  "object_id": "t1",
293
293
  "object_type": "test",
294
294
  "op": "PUT",
295
- "op_id": "2",
295
+ "op_id": "65537",
296
296
  "subkey": "bfe6a7fc-1a36-5a95-877f-518ff63ecb56",
297
297
  },
298
298
  ],
299
299
  "has_more": false,
300
- "next_after": "2",
300
+ "next_after": "65537",
301
301
  },
302
302
  },
303
303
  {
304
304
  "checkpoint_complete": {
305
- "last_op_id": "2",
305
+ "last_op_id": "65537",
306
306
  },
307
307
  },
308
308
  ]
@@ -1265,7 +1265,7 @@ exports[`sync - mongodb > storage v2 > encodes sync rules id in buckets for stre
1265
1265
  ],
1266
1266
  },
1267
1267
  ],
1268
- "last_op_id": "2",
1268
+ "last_op_id": "65537",
1269
1269
  "streams": [
1270
1270
  {
1271
1271
  "errors": [],
@@ -1287,17 +1287,17 @@ exports[`sync - mongodb > storage v2 > encodes sync rules id in buckets for stre
1287
1287
  "object_id": "t1",
1288
1288
  "object_type": "test",
1289
1289
  "op": "PUT",
1290
- "op_id": "2",
1290
+ "op_id": "65537",
1291
1291
  "subkey": "bfe6a7fc-1a36-5a95-877f-518ff63ecb56",
1292
1292
  },
1293
1293
  ],
1294
1294
  "has_more": false,
1295
- "next_after": "2",
1295
+ "next_after": "65537",
1296
1296
  },
1297
1297
  },
1298
1298
  {
1299
1299
  "checkpoint_complete": {
1300
- "last_op_id": "2",
1300
+ "last_op_id": "65537",
1301
1301
  },
1302
1302
  },
1303
1303
  ]
@@ -2298,58 +2298,6 @@ exports[`sync - mongodb > storage v3 > encodes sync rules id in buckets for stre
2298
2298
  ]
2299
2299
  `;
2300
2300
 
2301
- exports[`sync - mongodb > storage v3 > expired token 1`] = `
2302
- [
2303
- {
2304
- "token_expires_in": 0,
2305
- },
2306
- ]
2307
- `;
2308
-
2309
- exports[`sync - mongodb > storage v3 > expiring token 1`] = `
2310
- [
2311
- {
2312
- "checkpoint": {
2313
- "buckets": [
2314
- {
2315
- "bucket": "mybucket.1.1[]",
2316
- "checksum": 0,
2317
- "count": 0,
2318
- "priority": 3,
2319
- "subscriptions": [
2320
- {
2321
- "default": 0,
2322
- },
2323
- ],
2324
- },
2325
- ],
2326
- "last_op_id": "0",
2327
- "streams": [
2328
- {
2329
- "errors": [],
2330
- "is_default": true,
2331
- "name": "mybucket",
2332
- },
2333
- ],
2334
- "write_checkpoint": undefined,
2335
- },
2336
- },
2337
- {
2338
- "checkpoint_complete": {
2339
- "last_op_id": "0",
2340
- },
2341
- },
2342
- ]
2343
- `;
2344
-
2345
- exports[`sync - mongodb > storage v3 > expiring token 2`] = `
2346
- [
2347
- {
2348
- "token_expires_in": 0,
2349
- },
2350
- ]
2351
- `;
2352
-
2353
2301
  exports[`sync - mongodb > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2354
2302
  [
2355
2303
  {
@@ -2419,92 +2367,81 @@ exports[`sync - mongodb > storage v3 > sends checkpoint complete line for empty
2419
2367
  ]
2420
2368
  `;
2421
2369
 
2422
- exports[`sync - mongodb > storage v3 > sync buckets in order 1`] = `
2370
+ exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
2423
2371
  [
2424
2372
  {
2425
2373
  "checkpoint": {
2426
2374
  "buckets": [
2427
2375
  {
2428
- "bucket": "b0.1.1[]",
2429
- "checksum": 920318466,
2430
- "count": 1,
2431
- "priority": 2,
2376
+ "bucket": "by_user.1.1["user1"]",
2377
+ "checksum": 0,
2378
+ "count": 0,
2379
+ "priority": 3,
2432
2380
  "subscriptions": [
2433
2381
  {
2434
2382
  "default": 0,
2435
2383
  },
2436
2384
  ],
2437
2385
  },
2438
- {
2439
- "bucket": "b1.1.2[]",
2440
- "checksum": -1382098757,
2441
- "count": 1,
2442
- "priority": 1,
2443
- "subscriptions": [
2444
- {
2445
- "default": 1,
2446
- },
2447
- ],
2448
- },
2449
2386
  ],
2450
- "last_op_id": "2",
2387
+ "last_op_id": "1",
2451
2388
  "streams": [
2452
2389
  {
2453
2390
  "errors": [],
2454
2391
  "is_default": true,
2455
- "name": "b0",
2456
- },
2457
- {
2458
- "errors": [],
2459
- "is_default": true,
2460
- "name": "b1",
2392
+ "name": "by_user",
2461
2393
  },
2462
2394
  ],
2463
2395
  "write_checkpoint": undefined,
2464
2396
  },
2465
2397
  },
2466
2398
  {
2467
- "data": {
2468
- "after": "0",
2469
- "bucket": "b1.1.2[]",
2470
- "data": [
2471
- {
2472
- "checksum": 2912868539,
2473
- "data": "{"id":"earlier","description":"Test 2"}",
2474
- "object_id": "earlier",
2475
- "object_type": "test",
2476
- "op": "PUT",
2477
- "op_id": "2",
2478
- "subkey": "0dfe86bd-d15b-5fd0-9c7b-a31693030ee0",
2479
- },
2480
- ],
2481
- "has_more": false,
2482
- "next_after": "2",
2399
+ "checkpoint_complete": {
2400
+ "last_op_id": "1",
2483
2401
  },
2484
2402
  },
2403
+ ]
2404
+ `;
2405
+
2406
+ exports[`sync - mongodb > storage v3 > sync updates to data query only 2`] = `
2407
+ [
2485
2408
  {
2486
- "partial_checkpoint_complete": {
2409
+ "checkpoint_diff": {
2487
2410
  "last_op_id": "2",
2488
- "priority": 1,
2411
+ "removed_buckets": [],
2412
+ "updated_buckets": [
2413
+ {
2414
+ "bucket": "by_user.1.1["user1"]",
2415
+ "checksum": 1418351250,
2416
+ "count": 1,
2417
+ "priority": 3,
2418
+ "subscriptions": [
2419
+ {
2420
+ "default": 0,
2421
+ },
2422
+ ],
2423
+ },
2424
+ ],
2425
+ "write_checkpoint": undefined,
2489
2426
  },
2490
2427
  },
2491
2428
  {
2492
2429
  "data": {
2493
- "after": "0",
2494
- "bucket": "b0.1.1[]",
2430
+ "after": "1",
2431
+ "bucket": "by_user.1.1["user1"]",
2495
2432
  "data": [
2496
2433
  {
2497
- "checksum": 920318466,
2498
- "data": "{"id":"t1","description":"Test 1"}",
2499
- "object_id": "t1",
2500
- "object_type": "test",
2434
+ "checksum": 1418351250,
2435
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2436
+ "object_id": "list1",
2437
+ "object_type": "lists",
2501
2438
  "op": "PUT",
2502
- "op_id": "1",
2503
- "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2439
+ "op_id": "2",
2440
+ "subkey": "ae9cbda1-5d8a-5a61-aaa4-366940758339",
2504
2441
  },
2505
2442
  ],
2506
2443
  "has_more": false,
2507
- "next_after": "1",
2444
+ "next_after": "2",
2508
2445
  },
2509
2446
  },
2510
2447
  {
@@ -2515,78 +2452,40 @@ exports[`sync - mongodb > storage v3 > sync buckets in order 1`] = `
2515
2452
  ]
2516
2453
  `;
2517
2454
 
2518
- exports[`sync - mongodb > storage v3 > sync global data 1`] = `
2455
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 1`] = `
2519
2456
  [
2520
2457
  {
2521
2458
  "checkpoint": {
2522
- "buckets": [
2523
- {
2524
- "bucket": "mybucket.1.1[]",
2525
- "checksum": -93886621,
2526
- "count": 2,
2527
- "priority": 3,
2528
- "subscriptions": [
2529
- {
2530
- "default": 0,
2531
- },
2532
- ],
2533
- },
2534
- ],
2535
- "last_op_id": "2",
2459
+ "buckets": [],
2460
+ "last_op_id": "0",
2536
2461
  "streams": [
2537
2462
  {
2538
2463
  "errors": [],
2539
2464
  "is_default": true,
2540
- "name": "mybucket",
2465
+ "name": "by_user",
2541
2466
  },
2542
2467
  ],
2543
2468
  "write_checkpoint": undefined,
2544
2469
  },
2545
2470
  },
2546
- {
2547
- "data": {
2548
- "after": "0",
2549
- "bucket": "mybucket.1.1[]",
2550
- "data": [
2551
- {
2552
- "checksum": 920318466,
2553
- "data": "{"id":"t1","description":"Test 1"}",
2554
- "object_id": "t1",
2555
- "object_type": "test",
2556
- "op": "PUT",
2557
- "op_id": "1",
2558
- "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2559
- },
2560
- {
2561
- "checksum": 3280762209,
2562
- "data": "{"id":"t2","description":"Test 2"}",
2563
- "object_id": "t2",
2564
- "object_type": "test",
2565
- "op": "PUT",
2566
- "op_id": "2",
2567
- "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
2568
- },
2569
- ],
2570
- "has_more": false,
2571
- "next_after": "2",
2572
- },
2573
- },
2574
2471
  {
2575
2472
  "checkpoint_complete": {
2576
- "last_op_id": "2",
2473
+ "last_op_id": "0",
2577
2474
  },
2578
2475
  },
2579
2476
  ]
2580
2477
  `;
2581
2478
 
2582
- exports[`sync - mongodb > storage v3 > sync legacy non-raw data 1`] = `
2479
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 2`] = `
2583
2480
  [
2584
2481
  {
2585
- "checkpoint": {
2586
- "buckets": [
2482
+ "checkpoint_diff": {
2483
+ "last_op_id": "2",
2484
+ "removed_buckets": [],
2485
+ "updated_buckets": [
2587
2486
  {
2588
- "bucket": "mybucket.1.1[]",
2589
- "checksum": -852817836,
2487
+ "bucket": "by_user.1.1["user1"]",
2488
+ "checksum": 1418351250,
2590
2489
  "count": 1,
2591
2490
  "priority": 3,
2592
2491
  "subscriptions": [
@@ -2596,35 +2495,22 @@ exports[`sync - mongodb > storage v3 > sync legacy non-raw data 1`] = `
2596
2495
  ],
2597
2496
  },
2598
2497
  ],
2599
- "last_op_id": "1",
2600
- "streams": [
2601
- {
2602
- "errors": [],
2603
- "is_default": true,
2604
- "name": "mybucket",
2605
- },
2606
- ],
2607
2498
  "write_checkpoint": undefined,
2608
2499
  },
2609
2500
  },
2610
2501
  {
2611
2502
  "data": {
2612
2503
  "after": "0",
2613
- "bucket": "mybucket.1.1[]",
2504
+ "bucket": "by_user.1.1["user1"]",
2614
2505
  "data": [
2615
2506
  {
2616
- "checksum": 3442149460n,
2617
- "data": {
2618
- "description": "Test
2619
- "string"",
2620
- "id": "t1",
2621
- "large_num": 12345678901234567890n,
2622
- },
2623
- "object_id": "t1",
2624
- "object_type": "test",
2507
+ "checksum": 1418351250,
2508
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2509
+ "object_id": "list1",
2510
+ "object_type": "lists",
2625
2511
  "op": "PUT",
2626
2512
  "op_id": "1",
2627
- "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2513
+ "subkey": "ae9cbda1-5d8a-5a61-aaa4-366940758339",
2628
2514
  },
2629
2515
  ],
2630
2516
  "has_more": false,
@@ -2633,30 +2519,18 @@ exports[`sync - mongodb > storage v3 > sync legacy non-raw data 1`] = `
2633
2519
  },
2634
2520
  {
2635
2521
  "checkpoint_complete": {
2636
- "last_op_id": "1",
2522
+ "last_op_id": "2",
2637
2523
  },
2638
2524
  },
2639
2525
  ]
2640
2526
  `;
2641
2527
 
2642
- exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
2528
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query only 1`] = `
2643
2529
  [
2644
2530
  {
2645
2531
  "checkpoint": {
2646
- "buckets": [
2647
- {
2648
- "bucket": "by_user.1.1["user1"]",
2649
- "checksum": 0,
2650
- "count": 0,
2651
- "priority": 3,
2652
- "subscriptions": [
2653
- {
2654
- "default": 0,
2655
- },
2656
- ],
2657
- },
2658
- ],
2659
- "last_op_id": "1",
2532
+ "buckets": [],
2533
+ "last_op_id": "0",
2660
2534
  "streams": [
2661
2535
  {
2662
2536
  "errors": [],
@@ -2669,17 +2543,732 @@ exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
2669
2543
  },
2670
2544
  {
2671
2545
  "checkpoint_complete": {
2672
- "last_op_id": "1",
2546
+ "last_op_id": "0",
2673
2547
  },
2674
2548
  },
2675
2549
  ]
2676
2550
  `;
2677
2551
 
2678
- exports[`sync - mongodb > storage v3 > sync updates to data query only 2`] = `
2552
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query only 2`] = `
2679
2553
  [
2680
2554
  {
2681
2555
  "checkpoint_diff": {
2682
- "last_op_id": "2",
2556
+ "last_op_id": "1",
2557
+ "removed_buckets": [],
2558
+ "updated_buckets": [
2559
+ {
2560
+ "bucket": "by_user.1.1["user1"]",
2561
+ "checksum": 0,
2562
+ "count": 0,
2563
+ "priority": 3,
2564
+ "subscriptions": [
2565
+ {
2566
+ "default": 0,
2567
+ },
2568
+ ],
2569
+ },
2570
+ ],
2571
+ "write_checkpoint": undefined,
2572
+ },
2573
+ },
2574
+ {
2575
+ "checkpoint_complete": {
2576
+ "last_op_id": "1",
2577
+ },
2578
+ },
2579
+ ]
2580
+ `;
2581
+
2582
+ exports[`sync - mongodb > storage v4 > can override priority when subscribing to stream 1`] = `
2583
+ [
2584
+ {
2585
+ "checkpoint": {
2586
+ "buckets": [
2587
+ {
2588
+ "bucket": "todos|0.1.1["a"]",
2589
+ "checksum": -1712802421,
2590
+ "count": 1,
2591
+ "priority": 0,
2592
+ "subscriptions": [
2593
+ {
2594
+ "sub": 0,
2595
+ },
2596
+ {
2597
+ "sub": 1,
2598
+ },
2599
+ ],
2600
+ },
2601
+ {
2602
+ "bucket": "todos|0.1.1["b"]",
2603
+ "checksum": -1291414318,
2604
+ "count": 1,
2605
+ "priority": 3,
2606
+ "subscriptions": [
2607
+ {
2608
+ "sub": 1,
2609
+ },
2610
+ ],
2611
+ },
2612
+ ],
2613
+ "last_op_id": "2",
2614
+ "streams": [
2615
+ {
2616
+ "errors": [],
2617
+ "is_default": false,
2618
+ "name": "todos",
2619
+ },
2620
+ ],
2621
+ "write_checkpoint": undefined,
2622
+ },
2623
+ },
2624
+ {
2625
+ "data": {
2626
+ "after": "0",
2627
+ "bucket": "todos|0.1.1["a"]",
2628
+ "data": [
2629
+ {
2630
+ "checksum": 2582164875,
2631
+ "data": "{"id":"a","description":"Test 1"}",
2632
+ "object_id": "a",
2633
+ "object_type": "test",
2634
+ "op": "PUT",
2635
+ "op_id": "1",
2636
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2637
+ },
2638
+ ],
2639
+ "has_more": false,
2640
+ "next_after": "1",
2641
+ },
2642
+ },
2643
+ {
2644
+ "partial_checkpoint_complete": {
2645
+ "last_op_id": "2",
2646
+ "priority": 0,
2647
+ },
2648
+ },
2649
+ {
2650
+ "data": {
2651
+ "after": "0",
2652
+ "bucket": "todos|0.1.1["b"]",
2653
+ "data": [
2654
+ {
2655
+ "checksum": 3003552978,
2656
+ "data": "{"id":"b","description":"Test 2"}",
2657
+ "object_id": "b",
2658
+ "object_type": "test",
2659
+ "op": "PUT",
2660
+ "op_id": "2",
2661
+ "subkey": "0dfe86bd-d15b-5fd0-9c7b-a31693030ee0",
2662
+ },
2663
+ ],
2664
+ "has_more": false,
2665
+ "next_after": "2",
2666
+ },
2667
+ },
2668
+ {
2669
+ "checkpoint_complete": {
2670
+ "last_op_id": "2",
2671
+ },
2672
+ },
2673
+ ]
2674
+ `;
2675
+
2676
+ exports[`sync - mongodb > storage v4 > compacting data - invalidate checkpoint 1`] = `
2677
+ [
2678
+ {
2679
+ "checkpoint": {
2680
+ "buckets": [
2681
+ {
2682
+ "bucket": "mybucket.1.1[]",
2683
+ "checksum": -93886621,
2684
+ "count": 2,
2685
+ "priority": 3,
2686
+ "subscriptions": [
2687
+ {
2688
+ "default": 0,
2689
+ },
2690
+ ],
2691
+ },
2692
+ ],
2693
+ "last_op_id": "2",
2694
+ "streams": [
2695
+ {
2696
+ "errors": [],
2697
+ "is_default": true,
2698
+ "name": "mybucket",
2699
+ },
2700
+ ],
2701
+ "write_checkpoint": undefined,
2702
+ },
2703
+ },
2704
+ ]
2705
+ `;
2706
+
2707
+ exports[`sync - mongodb > storage v4 > compacting data - invalidate checkpoint 2`] = `
2708
+ [
2709
+ {
2710
+ "data": {
2711
+ "after": "0",
2712
+ "bucket": "mybucket.1.1[]",
2713
+ "data": [
2714
+ {
2715
+ "checksum": -93886621,
2716
+ "op": "CLEAR",
2717
+ "op_id": "2",
2718
+ },
2719
+ ],
2720
+ "has_more": false,
2721
+ "next_after": "2",
2722
+ },
2723
+ },
2724
+ {
2725
+ "checkpoint_diff": {
2726
+ "last_op_id": "4",
2727
+ "removed_buckets": [],
2728
+ "updated_buckets": [
2729
+ {
2730
+ "bucket": "mybucket.1.1[]",
2731
+ "checksum": 499012468,
2732
+ "count": 4,
2733
+ "priority": 3,
2734
+ "subscriptions": [
2735
+ {
2736
+ "default": 0,
2737
+ },
2738
+ ],
2739
+ },
2740
+ ],
2741
+ "write_checkpoint": undefined,
2742
+ },
2743
+ },
2744
+ {
2745
+ "data": {
2746
+ "after": "2",
2747
+ "bucket": "mybucket.1.1[]",
2748
+ "data": [
2749
+ {
2750
+ "checksum": 1859363232,
2751
+ "data": "{"id":"t1","description":"Test 1b"}",
2752
+ "object_id": "t1",
2753
+ "object_type": "test",
2754
+ "op": "PUT",
2755
+ "op_id": "3",
2756
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2757
+ },
2758
+ {
2759
+ "checksum": 3028503153,
2760
+ "data": "{"id":"t2","description":"Test 2b"}",
2761
+ "object_id": "t2",
2762
+ "object_type": "test",
2763
+ "op": "PUT",
2764
+ "op_id": "4",
2765
+ "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
2766
+ },
2767
+ ],
2768
+ "has_more": false,
2769
+ "next_after": "4",
2770
+ },
2771
+ },
2772
+ {
2773
+ "checkpoint_complete": {
2774
+ "last_op_id": "4",
2775
+ },
2776
+ },
2777
+ ]
2778
+ `;
2779
+
2780
+ exports[`sync - mongodb > storage v4 > encodes sync rules id in buckets for streams 1`] = `
2781
+ [
2782
+ {
2783
+ "checkpoint": {
2784
+ "buckets": [
2785
+ {
2786
+ "bucket": "test|0.1.1[]",
2787
+ "checksum": 920318466,
2788
+ "count": 1,
2789
+ "priority": 3,
2790
+ "subscriptions": [
2791
+ {
2792
+ "default": 0,
2793
+ },
2794
+ ],
2795
+ },
2796
+ ],
2797
+ "last_op_id": "1",
2798
+ "streams": [
2799
+ {
2800
+ "errors": [],
2801
+ "is_default": true,
2802
+ "name": "test",
2803
+ },
2804
+ ],
2805
+ "write_checkpoint": undefined,
2806
+ },
2807
+ },
2808
+ {
2809
+ "data": {
2810
+ "after": "0",
2811
+ "bucket": "test|0.1.1[]",
2812
+ "data": [
2813
+ {
2814
+ "checksum": 920318466,
2815
+ "data": "{"id":"t1","description":"Test 1"}",
2816
+ "object_id": "t1",
2817
+ "object_type": "test",
2818
+ "op": "PUT",
2819
+ "op_id": "1",
2820
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2821
+ },
2822
+ ],
2823
+ "has_more": false,
2824
+ "next_after": "1",
2825
+ },
2826
+ },
2827
+ {
2828
+ "checkpoint_complete": {
2829
+ "last_op_id": "1",
2830
+ },
2831
+ },
2832
+ ]
2833
+ `;
2834
+
2835
+ exports[`sync - mongodb > storage v4 > encodes sync rules id in buckets for streams 2`] = `
2836
+ [
2837
+ {
2838
+ "checkpoint": {
2839
+ "buckets": [
2840
+ {
2841
+ "bucket": "test2|0.2.1[]",
2842
+ "checksum": 920318466,
2843
+ "count": 1,
2844
+ "priority": 3,
2845
+ "subscriptions": [
2846
+ {
2847
+ "default": 0,
2848
+ },
2849
+ ],
2850
+ },
2851
+ ],
2852
+ "last_op_id": "65537",
2853
+ "streams": [
2854
+ {
2855
+ "errors": [],
2856
+ "is_default": true,
2857
+ "name": "test2",
2858
+ },
2859
+ ],
2860
+ "write_checkpoint": undefined,
2861
+ },
2862
+ },
2863
+ {
2864
+ "data": {
2865
+ "after": "0",
2866
+ "bucket": "test2|0.2.1[]",
2867
+ "data": [
2868
+ {
2869
+ "checksum": 920318466,
2870
+ "data": "{"id":"t1","description":"Test 1"}",
2871
+ "object_id": "t1",
2872
+ "object_type": "test",
2873
+ "op": "PUT",
2874
+ "op_id": "65537",
2875
+ "subkey": "bfe6a7fc-1a36-5a95-877f-518ff63ecb56",
2876
+ },
2877
+ ],
2878
+ "has_more": false,
2879
+ "next_after": "65537",
2880
+ },
2881
+ },
2882
+ {
2883
+ "checkpoint_complete": {
2884
+ "last_op_id": "65537",
2885
+ },
2886
+ },
2887
+ ]
2888
+ `;
2889
+
2890
+ exports[`sync - mongodb > storage v4 > expired token 1`] = `
2891
+ [
2892
+ {
2893
+ "token_expires_in": 0,
2894
+ },
2895
+ ]
2896
+ `;
2897
+
2898
+ exports[`sync - mongodb > storage v4 > expiring token 1`] = `
2899
+ [
2900
+ {
2901
+ "checkpoint": {
2902
+ "buckets": [
2903
+ {
2904
+ "bucket": "mybucket.1.1[]",
2905
+ "checksum": 0,
2906
+ "count": 0,
2907
+ "priority": 3,
2908
+ "subscriptions": [
2909
+ {
2910
+ "default": 0,
2911
+ },
2912
+ ],
2913
+ },
2914
+ ],
2915
+ "last_op_id": "0",
2916
+ "streams": [
2917
+ {
2918
+ "errors": [],
2919
+ "is_default": true,
2920
+ "name": "mybucket",
2921
+ },
2922
+ ],
2923
+ "write_checkpoint": undefined,
2924
+ },
2925
+ },
2926
+ {
2927
+ "checkpoint_complete": {
2928
+ "last_op_id": "0",
2929
+ },
2930
+ },
2931
+ ]
2932
+ `;
2933
+
2934
+ exports[`sync - mongodb > storage v4 > expiring token 2`] = `
2935
+ [
2936
+ {
2937
+ "token_expires_in": 0,
2938
+ },
2939
+ ]
2940
+ `;
2941
+
2942
+ exports[`sync - mongodb > storage v4 > sends checkpoint complete line for empty checkpoint 1`] = `
2943
+ [
2944
+ {
2945
+ "checkpoint": {
2946
+ "buckets": [
2947
+ {
2948
+ "bucket": "mybucket.1.1[]",
2949
+ "checksum": -1221282404,
2950
+ "count": 1,
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": "mybucket",
2965
+ },
2966
+ ],
2967
+ "write_checkpoint": undefined,
2968
+ },
2969
+ },
2970
+ {
2971
+ "data": {
2972
+ "after": "0",
2973
+ "bucket": "mybucket.1.1[]",
2974
+ "data": [
2975
+ {
2976
+ "checksum": 3073684892,
2977
+ "data": "{"id":"t1","description":"sync"}",
2978
+ "object_id": "t1",
2979
+ "object_type": "test",
2980
+ "op": "PUT",
2981
+ "op_id": "1",
2982
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2983
+ },
2984
+ ],
2985
+ "has_more": false,
2986
+ "next_after": "1",
2987
+ },
2988
+ },
2989
+ null,
2990
+ {
2991
+ "checkpoint_complete": {
2992
+ "last_op_id": "1",
2993
+ },
2994
+ },
2995
+ {
2996
+ "checkpoint_diff": {
2997
+ "last_op_id": "1",
2998
+ "removed_buckets": [],
2999
+ "updated_buckets": [],
3000
+ "write_checkpoint": "1",
3001
+ },
3002
+ },
3003
+ {
3004
+ "checkpoint_complete": {
3005
+ "last_op_id": "1",
3006
+ },
3007
+ },
3008
+ ]
3009
+ `;
3010
+
3011
+ exports[`sync - mongodb > storage v4 > sync buckets in order 1`] = `
3012
+ [
3013
+ {
3014
+ "checkpoint": {
3015
+ "buckets": [
3016
+ {
3017
+ "bucket": "b0.1.1[]",
3018
+ "checksum": 920318466,
3019
+ "count": 1,
3020
+ "priority": 2,
3021
+ "subscriptions": [
3022
+ {
3023
+ "default": 0,
3024
+ },
3025
+ ],
3026
+ },
3027
+ {
3028
+ "bucket": "b1.1.2[]",
3029
+ "checksum": -1382098757,
3030
+ "count": 1,
3031
+ "priority": 1,
3032
+ "subscriptions": [
3033
+ {
3034
+ "default": 1,
3035
+ },
3036
+ ],
3037
+ },
3038
+ ],
3039
+ "last_op_id": "2",
3040
+ "streams": [
3041
+ {
3042
+ "errors": [],
3043
+ "is_default": true,
3044
+ "name": "b0",
3045
+ },
3046
+ {
3047
+ "errors": [],
3048
+ "is_default": true,
3049
+ "name": "b1",
3050
+ },
3051
+ ],
3052
+ "write_checkpoint": undefined,
3053
+ },
3054
+ },
3055
+ {
3056
+ "data": {
3057
+ "after": "0",
3058
+ "bucket": "b1.1.2[]",
3059
+ "data": [
3060
+ {
3061
+ "checksum": 2912868539,
3062
+ "data": "{"id":"earlier","description":"Test 2"}",
3063
+ "object_id": "earlier",
3064
+ "object_type": "test",
3065
+ "op": "PUT",
3066
+ "op_id": "2",
3067
+ "subkey": "0dfe86bd-d15b-5fd0-9c7b-a31693030ee0",
3068
+ },
3069
+ ],
3070
+ "has_more": false,
3071
+ "next_after": "2",
3072
+ },
3073
+ },
3074
+ {
3075
+ "partial_checkpoint_complete": {
3076
+ "last_op_id": "2",
3077
+ "priority": 1,
3078
+ },
3079
+ },
3080
+ {
3081
+ "data": {
3082
+ "after": "0",
3083
+ "bucket": "b0.1.1[]",
3084
+ "data": [
3085
+ {
3086
+ "checksum": 920318466,
3087
+ "data": "{"id":"t1","description":"Test 1"}",
3088
+ "object_id": "t1",
3089
+ "object_type": "test",
3090
+ "op": "PUT",
3091
+ "op_id": "1",
3092
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
3093
+ },
3094
+ ],
3095
+ "has_more": false,
3096
+ "next_after": "1",
3097
+ },
3098
+ },
3099
+ {
3100
+ "checkpoint_complete": {
3101
+ "last_op_id": "2",
3102
+ },
3103
+ },
3104
+ ]
3105
+ `;
3106
+
3107
+ exports[`sync - mongodb > storage v4 > sync global data 1`] = `
3108
+ [
3109
+ {
3110
+ "checkpoint": {
3111
+ "buckets": [
3112
+ {
3113
+ "bucket": "mybucket.1.1[]",
3114
+ "checksum": -93886621,
3115
+ "count": 2,
3116
+ "priority": 3,
3117
+ "subscriptions": [
3118
+ {
3119
+ "default": 0,
3120
+ },
3121
+ ],
3122
+ },
3123
+ ],
3124
+ "last_op_id": "2",
3125
+ "streams": [
3126
+ {
3127
+ "errors": [],
3128
+ "is_default": true,
3129
+ "name": "mybucket",
3130
+ },
3131
+ ],
3132
+ "write_checkpoint": undefined,
3133
+ },
3134
+ },
3135
+ {
3136
+ "data": {
3137
+ "after": "0",
3138
+ "bucket": "mybucket.1.1[]",
3139
+ "data": [
3140
+ {
3141
+ "checksum": 920318466,
3142
+ "data": "{"id":"t1","description":"Test 1"}",
3143
+ "object_id": "t1",
3144
+ "object_type": "test",
3145
+ "op": "PUT",
3146
+ "op_id": "1",
3147
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
3148
+ },
3149
+ {
3150
+ "checksum": 3280762209,
3151
+ "data": "{"id":"t2","description":"Test 2"}",
3152
+ "object_id": "t2",
3153
+ "object_type": "test",
3154
+ "op": "PUT",
3155
+ "op_id": "2",
3156
+ "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
3157
+ },
3158
+ ],
3159
+ "has_more": false,
3160
+ "next_after": "2",
3161
+ },
3162
+ },
3163
+ {
3164
+ "checkpoint_complete": {
3165
+ "last_op_id": "2",
3166
+ },
3167
+ },
3168
+ ]
3169
+ `;
3170
+
3171
+ exports[`sync - mongodb > storage v4 > sync legacy non-raw data 1`] = `
3172
+ [
3173
+ {
3174
+ "checkpoint": {
3175
+ "buckets": [
3176
+ {
3177
+ "bucket": "mybucket.1.1[]",
3178
+ "checksum": -852817836,
3179
+ "count": 1,
3180
+ "priority": 3,
3181
+ "subscriptions": [
3182
+ {
3183
+ "default": 0,
3184
+ },
3185
+ ],
3186
+ },
3187
+ ],
3188
+ "last_op_id": "1",
3189
+ "streams": [
3190
+ {
3191
+ "errors": [],
3192
+ "is_default": true,
3193
+ "name": "mybucket",
3194
+ },
3195
+ ],
3196
+ "write_checkpoint": undefined,
3197
+ },
3198
+ },
3199
+ {
3200
+ "data": {
3201
+ "after": "0",
3202
+ "bucket": "mybucket.1.1[]",
3203
+ "data": [
3204
+ {
3205
+ "checksum": 3442149460n,
3206
+ "data": {
3207
+ "description": "Test
3208
+ "string"",
3209
+ "id": "t1",
3210
+ "large_num": 12345678901234567890n,
3211
+ },
3212
+ "object_id": "t1",
3213
+ "object_type": "test",
3214
+ "op": "PUT",
3215
+ "op_id": "1",
3216
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
3217
+ },
3218
+ ],
3219
+ "has_more": false,
3220
+ "next_after": "1",
3221
+ },
3222
+ },
3223
+ {
3224
+ "checkpoint_complete": {
3225
+ "last_op_id": "1",
3226
+ },
3227
+ },
3228
+ ]
3229
+ `;
3230
+
3231
+ exports[`sync - mongodb > storage v4 > sync updates to data query only 1`] = `
3232
+ [
3233
+ {
3234
+ "checkpoint": {
3235
+ "buckets": [
3236
+ {
3237
+ "bucket": "by_user.1.1["user1"]",
3238
+ "checksum": 0,
3239
+ "count": 0,
3240
+ "priority": 3,
3241
+ "subscriptions": [
3242
+ {
3243
+ "default": 0,
3244
+ },
3245
+ ],
3246
+ },
3247
+ ],
3248
+ "last_op_id": "1",
3249
+ "streams": [
3250
+ {
3251
+ "errors": [],
3252
+ "is_default": true,
3253
+ "name": "by_user",
3254
+ },
3255
+ ],
3256
+ "write_checkpoint": undefined,
3257
+ },
3258
+ },
3259
+ {
3260
+ "checkpoint_complete": {
3261
+ "last_op_id": "1",
3262
+ },
3263
+ },
3264
+ ]
3265
+ `;
3266
+
3267
+ exports[`sync - mongodb > storage v4 > sync updates to data query only 2`] = `
3268
+ [
3269
+ {
3270
+ "checkpoint_diff": {
3271
+ "last_op_id": "2",
2683
3272
  "removed_buckets": [],
2684
3273
  "updated_buckets": [
2685
3274
  {
@@ -2724,7 +3313,7 @@ exports[`sync - mongodb > storage v3 > sync updates to data query only 2`] = `
2724
3313
  ]
2725
3314
  `;
2726
3315
 
2727
- exports[`sync - mongodb > storage v3 > sync updates to global data 1`] = `
3316
+ exports[`sync - mongodb > storage v4 > sync updates to global data 1`] = `
2728
3317
  [
2729
3318
  {
2730
3319
  "checkpoint": {
@@ -2760,7 +3349,7 @@ exports[`sync - mongodb > storage v3 > sync updates to global data 1`] = `
2760
3349
  ]
2761
3350
  `;
2762
3351
 
2763
- exports[`sync - mongodb > storage v3 > sync updates to global data 2`] = `
3352
+ exports[`sync - mongodb > storage v4 > sync updates to global data 2`] = `
2764
3353
  [
2765
3354
  {
2766
3355
  "checkpoint_diff": {
@@ -2809,7 +3398,7 @@ exports[`sync - mongodb > storage v3 > sync updates to global data 2`] = `
2809
3398
  ]
2810
3399
  `;
2811
3400
 
2812
- exports[`sync - mongodb > storage v3 > sync updates to global data 3`] = `
3401
+ exports[`sync - mongodb > storage v4 > sync updates to global data 3`] = `
2813
3402
  [
2814
3403
  {
2815
3404
  "checkpoint_diff": {
@@ -2858,7 +3447,7 @@ exports[`sync - mongodb > storage v3 > sync updates to global data 3`] = `
2858
3447
  ]
2859
3448
  `;
2860
3449
 
2861
- exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 1`] = `
3450
+ exports[`sync - mongodb > storage v4 > sync updates to parameter query + data 1`] = `
2862
3451
  [
2863
3452
  {
2864
3453
  "checkpoint": {
@@ -2882,7 +3471,7 @@ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 1`
2882
3471
  ]
2883
3472
  `;
2884
3473
 
2885
- exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 2`] = `
3474
+ exports[`sync - mongodb > storage v4 > sync updates to parameter query + data 2`] = `
2886
3475
  [
2887
3476
  {
2888
3477
  "checkpoint_diff": {
@@ -2931,7 +3520,7 @@ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 2`
2931
3520
  ]
2932
3521
  `;
2933
3522
 
2934
- exports[`sync - mongodb > storage v3 > sync updates to parameter query only 1`] = `
3523
+ exports[`sync - mongodb > storage v4 > sync updates to parameter query only 1`] = `
2935
3524
  [
2936
3525
  {
2937
3526
  "checkpoint": {
@@ -2955,7 +3544,7 @@ exports[`sync - mongodb > storage v3 > sync updates to parameter query only 1`]
2955
3544
  ]
2956
3545
  `;
2957
3546
 
2958
- exports[`sync - mongodb > storage v3 > sync updates to parameter query only 2`] = `
3547
+ exports[`sync - mongodb > storage v4 > sync updates to parameter query only 2`] = `
2959
3548
  [
2960
3549
  {
2961
3550
  "checkpoint_diff": {