@powersync/service-module-mongodb-storage 0.9.4 → 0.10.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 (43) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/migrations/db/migrations/1749720702136-checkpoint-events.d.ts +3 -0
  3. package/dist/migrations/db/migrations/1749720702136-checkpoint-events.js +34 -0
  4. package/dist/migrations/db/migrations/1749720702136-checkpoint-events.js.map +1 -0
  5. package/dist/storage/MongoBucketStorage.js +5 -0
  6. package/dist/storage/MongoBucketStorage.js.map +1 -1
  7. package/dist/storage/implementation/MongoBucketBatch.d.ts +9 -3
  8. package/dist/storage/implementation/MongoBucketBatch.js +117 -37
  9. package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
  10. package/dist/storage/implementation/MongoPersistedSyncRulesContent.d.ts +1 -0
  11. package/dist/storage/implementation/MongoPersistedSyncRulesContent.js +2 -0
  12. package/dist/storage/implementation/MongoPersistedSyncRulesContent.js.map +1 -1
  13. package/dist/storage/implementation/MongoStorageProvider.js +23 -1
  14. package/dist/storage/implementation/MongoStorageProvider.js.map +1 -1
  15. package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +14 -5
  16. package/dist/storage/implementation/MongoSyncBucketStorage.js +161 -159
  17. package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
  18. package/dist/storage/implementation/MongoTestStorageFactoryGenerator.js +2 -0
  19. package/dist/storage/implementation/MongoTestStorageFactoryGenerator.js.map +1 -1
  20. package/dist/storage/implementation/MongoWriteCheckpointAPI.d.ts +9 -15
  21. package/dist/storage/implementation/MongoWriteCheckpointAPI.js +55 -191
  22. package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
  23. package/dist/storage/implementation/PersistedBatch.d.ts +6 -2
  24. package/dist/storage/implementation/PersistedBatch.js +39 -7
  25. package/dist/storage/implementation/PersistedBatch.js.map +1 -1
  26. package/dist/storage/implementation/db.d.ts +12 -1
  27. package/dist/storage/implementation/db.js +39 -0
  28. package/dist/storage/implementation/db.js.map +1 -1
  29. package/dist/storage/implementation/models.d.ts +29 -1
  30. package/package.json +7 -7
  31. package/src/migrations/db/migrations/1749720702136-checkpoint-events.ts +50 -0
  32. package/src/storage/MongoBucketStorage.ts +5 -0
  33. package/src/storage/implementation/MongoBucketBatch.ts +160 -49
  34. package/src/storage/implementation/MongoPersistedSyncRulesContent.ts +2 -0
  35. package/src/storage/implementation/MongoStorageProvider.ts +27 -1
  36. package/src/storage/implementation/MongoSyncBucketStorage.ts +187 -200
  37. package/src/storage/implementation/MongoTestStorageFactoryGenerator.ts +3 -0
  38. package/src/storage/implementation/MongoWriteCheckpointAPI.ts +66 -255
  39. package/src/storage/implementation/PersistedBatch.ts +50 -11
  40. package/src/storage/implementation/db.ts +42 -0
  41. package/src/storage/implementation/models.ts +32 -1
  42. package/test/src/__snapshots__/storage_sync.test.ts.snap +147 -0
  43. package/tsconfig.tsbuildinfo +1 -1
@@ -309,6 +309,153 @@ exports[`sync - mongodb > sync global data 1`] = `
309
309
  ]
310
310
  `;
311
311
 
312
+ exports[`sync - mongodb > sync interrupts low-priority buckets on new checkpoints (2) 1`] = `
313
+ [
314
+ {
315
+ "checkpoint": {
316
+ "buckets": [
317
+ {
318
+ "bucket": "b0a[]",
319
+ "checksum": -659831575,
320
+ "count": 2000,
321
+ "priority": 2,
322
+ },
323
+ {
324
+ "bucket": "b0b[]",
325
+ "checksum": -659831575,
326
+ "count": 2000,
327
+ "priority": 2,
328
+ },
329
+ {
330
+ "bucket": "b1[]",
331
+ "checksum": -1096116670,
332
+ "count": 1,
333
+ "priority": 1,
334
+ },
335
+ ],
336
+ "last_op_id": "4001",
337
+ "write_checkpoint": undefined,
338
+ },
339
+ },
340
+ {
341
+ "data": {
342
+ "after": "0",
343
+ "bucket": "b1[]",
344
+ "data": undefined,
345
+ "has_more": false,
346
+ "next_after": "1",
347
+ },
348
+ },
349
+ {
350
+ "partial_checkpoint_complete": {
351
+ "last_op_id": "4001",
352
+ "priority": 1,
353
+ },
354
+ },
355
+ {
356
+ "data": {
357
+ "after": "0",
358
+ "bucket": "b0a[]",
359
+ "data": undefined,
360
+ "has_more": true,
361
+ "next_after": "2000",
362
+ },
363
+ },
364
+ {
365
+ "data": {
366
+ "after": "2000",
367
+ "bucket": "b0a[]",
368
+ "data": undefined,
369
+ "has_more": true,
370
+ "next_after": "4000",
371
+ },
372
+ },
373
+ {
374
+ "checkpoint_diff": {
375
+ "last_op_id": "4004",
376
+ "removed_buckets": [],
377
+ "updated_buckets": [
378
+ {
379
+ "bucket": "b0a[]",
380
+ "checksum": 883076828,
381
+ "count": 2001,
382
+ "priority": 2,
383
+ },
384
+ {
385
+ "bucket": "b0b[]",
386
+ "checksum": 883076828,
387
+ "count": 2001,
388
+ "priority": 2,
389
+ },
390
+ {
391
+ "bucket": "b1[]",
392
+ "checksum": 1841937527,
393
+ "count": 2,
394
+ "priority": 1,
395
+ },
396
+ ],
397
+ "write_checkpoint": undefined,
398
+ },
399
+ },
400
+ {
401
+ "data": {
402
+ "after": "1",
403
+ "bucket": "b1[]",
404
+ "data": undefined,
405
+ "has_more": false,
406
+ "next_after": "4002",
407
+ },
408
+ },
409
+ {
410
+ "partial_checkpoint_complete": {
411
+ "last_op_id": "4004",
412
+ "priority": 1,
413
+ },
414
+ },
415
+ {
416
+ "data": {
417
+ "after": "4000",
418
+ "bucket": "b0a[]",
419
+ "data": undefined,
420
+ "has_more": false,
421
+ "next_after": "4003",
422
+ },
423
+ },
424
+ {
425
+ "data": {
426
+ "after": "0",
427
+ "bucket": "b0b[]",
428
+ "data": undefined,
429
+ "has_more": true,
430
+ "next_after": "1999",
431
+ },
432
+ },
433
+ {
434
+ "data": {
435
+ "after": "1999",
436
+ "bucket": "b0b[]",
437
+ "data": undefined,
438
+ "has_more": true,
439
+ "next_after": "3999",
440
+ },
441
+ },
442
+ {
443
+ "data": {
444
+ "after": "3999",
445
+ "bucket": "b0b[]",
446
+ "data": undefined,
447
+ "has_more": false,
448
+ "next_after": "4004",
449
+ },
450
+ },
451
+ {
452
+ "checkpoint_complete": {
453
+ "last_op_id": "4004",
454
+ },
455
+ },
456
+ ]
457
+ `;
458
+
312
459
  exports[`sync - mongodb > sync legacy non-raw data 1`] = `
313
460
  [
314
461
  {