@powersync/service-module-mongodb-storage 0.20.0 → 0.22.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 (192) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/storage/MongoBucketStorage.d.ts +36 -3
  3. package/dist/storage/MongoBucketStorage.js +372 -207
  4. package/dist/storage/MongoBucketStorage.js.map +1 -1
  5. package/dist/storage/implementation/MongoBucketBatch.d.ts +17 -5
  6. package/dist/storage/implementation/MongoBucketBatch.js +44 -17
  7. package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
  8. package/dist/storage/implementation/MongoCompactor.d.ts +19 -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/MongoParameterCompactor.d.ts +83 -10
  12. package/dist/storage/implementation/MongoParameterCompactor.js +309 -96
  13. package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -1
  14. package/dist/storage/implementation/MongoParsedSyncConfigSet.d.ts +9 -1
  15. package/dist/storage/implementation/MongoParsedSyncConfigSet.js +29 -0
  16. package/dist/storage/implementation/MongoParsedSyncConfigSet.js.map +1 -1
  17. package/dist/storage/implementation/MongoPersistedSyncConfigContent.js +4 -2
  18. package/dist/storage/implementation/MongoPersistedSyncConfigContent.js.map +1 -1
  19. package/dist/storage/implementation/MongoStorageProvider.js +7 -3
  20. package/dist/storage/implementation/MongoStorageProvider.js.map +1 -1
  21. package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +27 -11
  22. package/dist/storage/implementation/MongoSyncBucketStorage.js +78 -31
  23. package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
  24. package/dist/storage/implementation/MongoSyncRulesLock.js +21 -9
  25. package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
  26. package/dist/storage/implementation/MongoWriteBatch.d.ts +49 -0
  27. package/dist/storage/implementation/MongoWriteBatch.js +149 -0
  28. package/dist/storage/implementation/MongoWriteBatch.js.map +1 -0
  29. package/dist/storage/implementation/MongoWriteCheckpointAPI.d.ts +9 -7
  30. package/dist/storage/implementation/MongoWriteCheckpointAPI.js +9 -30
  31. package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
  32. package/dist/storage/implementation/SyncRuleStateUpdate.d.ts +11 -5
  33. package/dist/storage/implementation/SyncRuleStateUpdate.js +14 -6
  34. package/dist/storage/implementation/SyncRuleStateUpdate.js.map +1 -1
  35. package/dist/storage/implementation/common/MongoSyncBucketStorageCheckpoint.d.ts +22 -2
  36. package/dist/storage/implementation/common/PersistedBatch.d.ts +32 -4
  37. package/dist/storage/implementation/common/PersistedBatch.js +49 -6
  38. package/dist/storage/implementation/common/PersistedBatch.js.map +1 -1
  39. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.d.ts +3 -0
  40. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js +3 -0
  41. package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js.map +1 -1
  42. package/dist/storage/implementation/db.d.ts +9 -1
  43. package/dist/storage/implementation/db.js +27 -1
  44. package/dist/storage/implementation/db.js.map +1 -1
  45. package/dist/storage/implementation/models.d.ts +31 -0
  46. package/dist/storage/implementation/models.js.map +1 -1
  47. package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +2 -0
  48. package/dist/storage/implementation/v1/MongoBucketBatchV1.js +33 -4
  49. package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -1
  50. package/dist/storage/implementation/v1/MongoCompactorV1.d.ts +38 -6
  51. package/dist/storage/implementation/v1/MongoCompactorV1.js +247 -20
  52. package/dist/storage/implementation/v1/MongoCompactorV1.js.map +1 -1
  53. package/dist/storage/implementation/v1/MongoParameterCompactorV1.d.ts +16 -2
  54. package/dist/storage/implementation/v1/MongoParameterCompactorV1.js +20 -9
  55. package/dist/storage/implementation/v1/MongoParameterCompactorV1.js.map +1 -1
  56. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.d.ts +18 -11
  57. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js +65 -16
  58. package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js.map +1 -1
  59. package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +7 -5
  60. package/dist/storage/implementation/v1/PersistedBatchV1.js +22 -28
  61. package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -1
  62. package/dist/storage/implementation/v1/models.js +1 -0
  63. package/dist/storage/implementation/v1/models.js.map +1 -1
  64. package/dist/storage/implementation/v3/CompactionLease.d.ts +50 -0
  65. package/dist/storage/implementation/v3/CompactionLease.js +131 -0
  66. package/dist/storage/implementation/v3/CompactionLease.js.map +1 -0
  67. package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +10 -2
  68. package/dist/storage/implementation/v3/MongoBucketBatchV3.js +100 -26
  69. package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -1
  70. package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +82 -25
  71. package/dist/storage/implementation/v3/MongoCompactorV3.js +698 -159
  72. package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -1
  73. package/dist/storage/implementation/v3/MongoParameterCompactorV3.d.ts +18 -0
  74. package/dist/storage/implementation/v3/MongoParameterCompactorV3.js +23 -0
  75. package/dist/storage/implementation/v3/MongoParameterCompactorV3.js.map +1 -0
  76. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.d.ts +2 -15
  77. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.js +60 -92
  78. package/dist/storage/implementation/v3/MongoStoppedSyncConfigCleanup.js.map +1 -1
  79. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.d.ts +19 -9
  80. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js +91 -31
  81. package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js.map +1 -1
  82. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.d.ts +26 -0
  83. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.js +82 -0
  84. package/dist/storage/implementation/v3/MongoWriteCheckpointAPIV3.js.map +1 -0
  85. package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +14 -8
  86. package/dist/storage/implementation/v3/PersistedBatchV3.js +76 -42
  87. package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -1
  88. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.d.ts +12 -2
  89. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js +42 -3
  90. package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js.map +1 -1
  91. package/dist/storage/implementation/v3/bucket-format.js +2 -0
  92. package/dist/storage/implementation/v3/bucket-format.js.map +1 -1
  93. package/dist/storage/implementation/v3/compact-utils.d.ts +107 -0
  94. package/dist/storage/implementation/v3/compact-utils.js +216 -0
  95. package/dist/storage/implementation/v3/compact-utils.js.map +1 -0
  96. package/dist/storage/implementation/v3/compaction-constants.d.ts +5 -0
  97. package/dist/storage/implementation/v3/compaction-constants.js +6 -0
  98. package/dist/storage/implementation/v3/compaction-constants.js.map +1 -0
  99. package/dist/storage/implementation/v3/models.d.ts +84 -4
  100. package/dist/storage/implementation/v3/models.js.map +1 -1
  101. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.d.ts +7 -8
  102. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js +16 -5
  103. package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js.map +1 -1
  104. package/dist/storage/implementation/v3/object-storage/ObjectStorage.d.ts +14 -11
  105. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.d.ts +6 -8
  106. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js +17 -11
  107. package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js.map +1 -1
  108. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.d.ts +38 -0
  109. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js +164 -0
  110. package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js.map +1 -0
  111. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.d.ts +37 -12
  112. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js +197 -25
  113. package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js.map +1 -1
  114. package/dist/storage/implementation/v3/source-table-utils.d.ts +6 -6
  115. package/dist/storage/implementation/v3/source-table-utils.js +30 -37
  116. package/dist/storage/implementation/v3/source-table-utils.js.map +1 -1
  117. package/dist/storage/storage-index.d.ts +2 -1
  118. package/dist/storage/storage-index.js +1 -0
  119. package/dist/storage/storage-index.js.map +1 -1
  120. package/dist/types/types.d.ts +28 -1
  121. package/dist/types/types.js +28 -7
  122. package/dist/types/types.js.map +1 -1
  123. package/dist/utils/test-utils.js +1 -0
  124. package/dist/utils/test-utils.js.map +1 -1
  125. package/dist/utils/util.js +3 -1
  126. package/dist/utils/util.js.map +1 -1
  127. package/package.json +10 -9
  128. package/src/storage/MongoBucketStorage.ts +507 -269
  129. package/src/storage/implementation/MongoBucketBatch.ts +67 -24
  130. package/src/storage/implementation/MongoCompactor.ts +35 -346
  131. package/src/storage/implementation/MongoParameterCompactor.ts +388 -102
  132. package/src/storage/implementation/MongoParsedSyncConfigSet.ts +34 -0
  133. package/src/storage/implementation/MongoPersistedSyncConfigContent.ts +4 -2
  134. package/src/storage/implementation/MongoStorageProvider.ts +15 -3
  135. package/src/storage/implementation/MongoSyncBucketStorage.ts +114 -40
  136. package/src/storage/implementation/MongoSyncRulesLock.ts +22 -9
  137. package/src/storage/implementation/MongoWriteBatch.ts +172 -0
  138. package/src/storage/implementation/MongoWriteCheckpointAPI.ts +16 -46
  139. package/src/storage/implementation/SyncRuleStateUpdate.ts +13 -6
  140. package/src/storage/implementation/common/MongoSyncBucketStorageCheckpoint.ts +24 -2
  141. package/src/storage/implementation/common/PersistedBatch.ts +66 -10
  142. package/src/storage/implementation/common/VersionedPowerSyncMongoBase.ts +4 -0
  143. package/src/storage/implementation/db.ts +35 -2
  144. package/src/storage/implementation/models.ts +34 -0
  145. package/src/storage/implementation/v1/MongoBucketBatchV1.ts +46 -6
  146. package/src/storage/implementation/v1/MongoCompactorV1.ts +327 -40
  147. package/src/storage/implementation/v1/MongoParameterCompactorV1.ts +25 -9
  148. package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +87 -27
  149. package/src/storage/implementation/v1/PersistedBatchV1.ts +25 -30
  150. package/src/storage/implementation/v1/models.ts +1 -0
  151. package/src/storage/implementation/v3/CompactionLease.ts +152 -0
  152. package/src/storage/implementation/v3/MongoBucketBatchV3.ts +138 -34
  153. package/src/storage/implementation/v3/MongoCompactorV3.ts +958 -225
  154. package/src/storage/implementation/v3/MongoParameterCompactorV3.ts +34 -0
  155. package/src/storage/implementation/v3/MongoStoppedSyncConfigCleanup.ts +100 -109
  156. package/src/storage/implementation/v3/MongoSyncBucketStorageV3.ts +111 -41
  157. package/src/storage/implementation/v3/MongoWriteCheckpointAPIV3.ts +111 -0
  158. package/src/storage/implementation/v3/PersistedBatchV3.ts +93 -48
  159. package/src/storage/implementation/v3/VersionedPowerSyncMongoV3.ts +55 -4
  160. package/src/storage/implementation/v3/bucket-format.ts +2 -0
  161. package/src/storage/implementation/v3/compact-utils.ts +320 -0
  162. package/src/storage/implementation/v3/compaction-constants.ts +5 -0
  163. package/src/storage/implementation/v3/models.ts +91 -3
  164. package/src/storage/implementation/v3/object-storage/BucketDataObjectStorage.ts +24 -9
  165. package/src/storage/implementation/v3/object-storage/ObjectStorage.ts +20 -5
  166. package/src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts +26 -14
  167. package/src/storage/implementation/v3/object-storage/ObjectStorageUsage.ts +229 -0
  168. package/src/storage/implementation/v3/object-storage/S3ObjectStorage.ts +279 -29
  169. package/src/storage/implementation/v3/source-table-utils.ts +39 -41
  170. package/src/storage/storage-index.ts +2 -0
  171. package/src/types/types.ts +42 -7
  172. package/src/utils/test-utils.ts +1 -0
  173. package/src/utils/util.ts +3 -1
  174. package/test/src/__snapshots__/storage.test.ts.snap +25 -0
  175. package/test/src/__snapshots__/storage_sync.test.ts.snap +605 -16
  176. package/test/src/chunk_compaction_config.test.ts +38 -0
  177. package/test/src/cleanup-stopped-sync-configs.test.ts +40 -13
  178. package/test/src/compact-utils.test.ts +226 -0
  179. package/test/src/helpers/MemoryObjectStorage.ts +14 -6
  180. package/test/src/object_storage_usage.test.ts +267 -0
  181. package/test/src/parameter_compacting_v1.test.ts +120 -0
  182. package/test/src/parameter_compacting_v3.test.ts +192 -0
  183. package/test/src/parameter_compaction_fence.test.ts +276 -0
  184. package/test/src/storage.test.ts +273 -22
  185. package/test/src/storage_compacting.test.ts +968 -246
  186. package/test/src/storage_s3_checksums.test.ts +3 -4
  187. package/test/src/storage_s3_compaction_lifecycle.test.ts +138 -12
  188. package/test/src/storage_s3_reading.test.ts +290 -2
  189. package/test/src/storage_s3_writing.test.ts +1 -0
  190. package/test/src/storage_sync.test.ts +336 -41
  191. package/test/src/util.ts +1 -1
  192. package/tsconfig.tsbuildinfo +1 -1
@@ -2298,7 +2298,596 @@ 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`] = `
2301
+ exports[`sync - mongodb > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2302
+ [
2303
+ {
2304
+ "checkpoint": {
2305
+ "buckets": [
2306
+ {
2307
+ "bucket": "mybucket.1.1[]",
2308
+ "checksum": -1221282404,
2309
+ "count": 1,
2310
+ "priority": 3,
2311
+ "subscriptions": [
2312
+ {
2313
+ "default": 0,
2314
+ },
2315
+ ],
2316
+ },
2317
+ ],
2318
+ "last_op_id": "1",
2319
+ "streams": [
2320
+ {
2321
+ "errors": [],
2322
+ "is_default": true,
2323
+ "name": "mybucket",
2324
+ },
2325
+ ],
2326
+ "write_checkpoint": undefined,
2327
+ },
2328
+ },
2329
+ {
2330
+ "data": {
2331
+ "after": "0",
2332
+ "bucket": "mybucket.1.1[]",
2333
+ "data": [
2334
+ {
2335
+ "checksum": 3073684892,
2336
+ "data": "{"id":"t1","description":"sync"}",
2337
+ "object_id": "t1",
2338
+ "object_type": "test",
2339
+ "op": "PUT",
2340
+ "op_id": "1",
2341
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
2342
+ },
2343
+ ],
2344
+ "has_more": false,
2345
+ "next_after": "1",
2346
+ },
2347
+ },
2348
+ null,
2349
+ {
2350
+ "checkpoint_complete": {
2351
+ "last_op_id": "1",
2352
+ },
2353
+ },
2354
+ {
2355
+ "checkpoint_diff": {
2356
+ "last_op_id": "1",
2357
+ "removed_buckets": [],
2358
+ "updated_buckets": [],
2359
+ "write_checkpoint": "1",
2360
+ },
2361
+ },
2362
+ {
2363
+ "checkpoint_complete": {
2364
+ "last_op_id": "1",
2365
+ },
2366
+ },
2367
+ ]
2368
+ `;
2369
+
2370
+ exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
2371
+ [
2372
+ {
2373
+ "checkpoint": {
2374
+ "buckets": [
2375
+ {
2376
+ "bucket": "by_user.1.1["user1"]",
2377
+ "checksum": 0,
2378
+ "count": 0,
2379
+ "priority": 3,
2380
+ "subscriptions": [
2381
+ {
2382
+ "default": 0,
2383
+ },
2384
+ ],
2385
+ },
2386
+ ],
2387
+ "last_op_id": "1",
2388
+ "streams": [
2389
+ {
2390
+ "errors": [],
2391
+ "is_default": true,
2392
+ "name": "by_user",
2393
+ },
2394
+ ],
2395
+ "write_checkpoint": undefined,
2396
+ },
2397
+ },
2398
+ {
2399
+ "checkpoint_complete": {
2400
+ "last_op_id": "1",
2401
+ },
2402
+ },
2403
+ ]
2404
+ `;
2405
+
2406
+ exports[`sync - mongodb > storage v3 > sync updates to data query only 2`] = `
2407
+ [
2408
+ {
2409
+ "checkpoint_diff": {
2410
+ "last_op_id": "2",
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,
2426
+ },
2427
+ },
2428
+ {
2429
+ "data": {
2430
+ "after": "1",
2431
+ "bucket": "by_user.1.1["user1"]",
2432
+ "data": [
2433
+ {
2434
+ "checksum": 1418351250,
2435
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2436
+ "object_id": "list1",
2437
+ "object_type": "lists",
2438
+ "op": "PUT",
2439
+ "op_id": "2",
2440
+ "subkey": "ae9cbda1-5d8a-5a61-aaa4-366940758339",
2441
+ },
2442
+ ],
2443
+ "has_more": false,
2444
+ "next_after": "2",
2445
+ },
2446
+ },
2447
+ {
2448
+ "checkpoint_complete": {
2449
+ "last_op_id": "2",
2450
+ },
2451
+ },
2452
+ ]
2453
+ `;
2454
+
2455
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 1`] = `
2456
+ [
2457
+ {
2458
+ "checkpoint": {
2459
+ "buckets": [],
2460
+ "last_op_id": "0",
2461
+ "streams": [
2462
+ {
2463
+ "errors": [],
2464
+ "is_default": true,
2465
+ "name": "by_user",
2466
+ },
2467
+ ],
2468
+ "write_checkpoint": undefined,
2469
+ },
2470
+ },
2471
+ {
2472
+ "checkpoint_complete": {
2473
+ "last_op_id": "0",
2474
+ },
2475
+ },
2476
+ ]
2477
+ `;
2478
+
2479
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query + data 2`] = `
2480
+ [
2481
+ {
2482
+ "checkpoint_diff": {
2483
+ "last_op_id": "2",
2484
+ "removed_buckets": [],
2485
+ "updated_buckets": [
2486
+ {
2487
+ "bucket": "by_user.1.1["user1"]",
2488
+ "checksum": 1418351250,
2489
+ "count": 1,
2490
+ "priority": 3,
2491
+ "subscriptions": [
2492
+ {
2493
+ "default": 0,
2494
+ },
2495
+ ],
2496
+ },
2497
+ ],
2498
+ "write_checkpoint": undefined,
2499
+ },
2500
+ },
2501
+ {
2502
+ "data": {
2503
+ "after": "0",
2504
+ "bucket": "by_user.1.1["user1"]",
2505
+ "data": [
2506
+ {
2507
+ "checksum": 1418351250,
2508
+ "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2509
+ "object_id": "list1",
2510
+ "object_type": "lists",
2511
+ "op": "PUT",
2512
+ "op_id": "1",
2513
+ "subkey": "ae9cbda1-5d8a-5a61-aaa4-366940758339",
2514
+ },
2515
+ ],
2516
+ "has_more": false,
2517
+ "next_after": "1",
2518
+ },
2519
+ },
2520
+ {
2521
+ "checkpoint_complete": {
2522
+ "last_op_id": "2",
2523
+ },
2524
+ },
2525
+ ]
2526
+ `;
2527
+
2528
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query only 1`] = `
2529
+ [
2530
+ {
2531
+ "checkpoint": {
2532
+ "buckets": [],
2533
+ "last_op_id": "0",
2534
+ "streams": [
2535
+ {
2536
+ "errors": [],
2537
+ "is_default": true,
2538
+ "name": "by_user",
2539
+ },
2540
+ ],
2541
+ "write_checkpoint": undefined,
2542
+ },
2543
+ },
2544
+ {
2545
+ "checkpoint_complete": {
2546
+ "last_op_id": "0",
2547
+ },
2548
+ },
2549
+ ]
2550
+ `;
2551
+
2552
+ exports[`sync - mongodb > storage v3 > sync updates to parameter query only 2`] = `
2553
+ [
2554
+ {
2555
+ "checkpoint_diff": {
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": "2",
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": "2",
2875
+ "subkey": "bfe6a7fc-1a36-5a95-877f-518ff63ecb56",
2876
+ },
2877
+ ],
2878
+ "has_more": false,
2879
+ "next_after": "2",
2880
+ },
2881
+ },
2882
+ {
2883
+ "checkpoint_complete": {
2884
+ "last_op_id": "2",
2885
+ },
2886
+ },
2887
+ ]
2888
+ `;
2889
+
2890
+ exports[`sync - mongodb > storage v4 > expired token 1`] = `
2302
2891
  [
2303
2892
  {
2304
2893
  "token_expires_in": 0,
@@ -2306,7 +2895,7 @@ exports[`sync - mongodb > storage v3 > expired token 1`] = `
2306
2895
  ]
2307
2896
  `;
2308
2897
 
2309
- exports[`sync - mongodb > storage v3 > expiring token 1`] = `
2898
+ exports[`sync - mongodb > storage v4 > expiring token 1`] = `
2310
2899
  [
2311
2900
  {
2312
2901
  "checkpoint": {
@@ -2342,7 +2931,7 @@ exports[`sync - mongodb > storage v3 > expiring token 1`] = `
2342
2931
  ]
2343
2932
  `;
2344
2933
 
2345
- exports[`sync - mongodb > storage v3 > expiring token 2`] = `
2934
+ exports[`sync - mongodb > storage v4 > expiring token 2`] = `
2346
2935
  [
2347
2936
  {
2348
2937
  "token_expires_in": 0,
@@ -2350,7 +2939,7 @@ exports[`sync - mongodb > storage v3 > expiring token 2`] = `
2350
2939
  ]
2351
2940
  `;
2352
2941
 
2353
- exports[`sync - mongodb > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2942
+ exports[`sync - mongodb > storage v4 > sends checkpoint complete line for empty checkpoint 1`] = `
2354
2943
  [
2355
2944
  {
2356
2945
  "checkpoint": {
@@ -2419,7 +3008,7 @@ exports[`sync - mongodb > storage v3 > sends checkpoint complete line for empty
2419
3008
  ]
2420
3009
  `;
2421
3010
 
2422
- exports[`sync - mongodb > storage v3 > sync buckets in order 1`] = `
3011
+ exports[`sync - mongodb > storage v4 > sync buckets in order 1`] = `
2423
3012
  [
2424
3013
  {
2425
3014
  "checkpoint": {
@@ -2515,7 +3104,7 @@ exports[`sync - mongodb > storage v3 > sync buckets in order 1`] = `
2515
3104
  ]
2516
3105
  `;
2517
3106
 
2518
- exports[`sync - mongodb > storage v3 > sync global data 1`] = `
3107
+ exports[`sync - mongodb > storage v4 > sync global data 1`] = `
2519
3108
  [
2520
3109
  {
2521
3110
  "checkpoint": {
@@ -2579,7 +3168,7 @@ exports[`sync - mongodb > storage v3 > sync global data 1`] = `
2579
3168
  ]
2580
3169
  `;
2581
3170
 
2582
- exports[`sync - mongodb > storage v3 > sync legacy non-raw data 1`] = `
3171
+ exports[`sync - mongodb > storage v4 > sync legacy non-raw data 1`] = `
2583
3172
  [
2584
3173
  {
2585
3174
  "checkpoint": {
@@ -2639,7 +3228,7 @@ exports[`sync - mongodb > storage v3 > sync legacy non-raw data 1`] = `
2639
3228
  ]
2640
3229
  `;
2641
3230
 
2642
- exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
3231
+ exports[`sync - mongodb > storage v4 > sync updates to data query only 1`] = `
2643
3232
  [
2644
3233
  {
2645
3234
  "checkpoint": {
@@ -2675,7 +3264,7 @@ exports[`sync - mongodb > storage v3 > sync updates to data query only 1`] = `
2675
3264
  ]
2676
3265
  `;
2677
3266
 
2678
- exports[`sync - mongodb > storage v3 > sync updates to data query only 2`] = `
3267
+ exports[`sync - mongodb > storage v4 > sync updates to data query only 2`] = `
2679
3268
  [
2680
3269
  {
2681
3270
  "checkpoint_diff": {
@@ -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": {