@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
@@ -1,130 +1,343 @@
1
- import { logger } from '@powersync/lib-services-framework';
1
+ import { logger as defaultLogger } from '@powersync/lib-services-framework';
2
2
  import { bson } from '@powersync/service-core';
3
3
  import { LRUCache } from 'lru-cache';
4
+ const PARAMETER_COMPACTION_BATCH_SIZE = 10_000;
5
+ const PARAMETER_COMPACTION_DELETE_BATCH_SIZE = 1_000;
6
+ const PARAMETER_COMPACTION_CACHE_SIZE = 50_000;
7
+ /**
8
+ * How often progress is persisted during a pass.
9
+ *
10
+ * Kept coarse: replication also updates the `sync_rules` document on every commit.
11
+ */
12
+ const PARAMETER_COMPACTION_PERSIST_INTERVAL_MS = 60_000;
4
13
  /**
5
14
  * Compacts parameter lookup data (the bucket_parameters collection).
6
15
  *
7
- * This scans through the entire collection to find data to compact.
16
+ * Both storage versions persist a per-stream compaction cursor, so a run only scans entries in the
17
+ * un-compacted operation-id range. V1 scans its shared collection using only the `_id` index, so it
18
+ * additionally filters by stream in code.
19
+ *
20
+ * The cursor is a single value covering every collection of the stream, so it can only be advanced
21
+ * to a boundary that all collections have passed. To keep it moving during a long pass, collections
22
+ * are processed in lock-step rather than one after another - see {@link compactCollections}.
8
23
  *
9
24
  * For background, see the `/docs/storage/parameter-lookups.md` file.
10
25
  */
11
26
  export class MongoParameterCompactor {
12
27
  db;
13
- group_id;
28
+ replicationStreamId;
14
29
  checkpoint;
15
30
  options;
16
- getCollectionsCb;
17
- constructor(db, group_id, checkpoint, options, getCollectionsCb) {
31
+ parameterCompactionBatchSize;
32
+ parameterCompactionPersistIntervalMs;
33
+ logger;
34
+ signal;
35
+ constructor(db, replicationStreamId, checkpoint, options, parameterCompactionBatchSize = PARAMETER_COMPACTION_BATCH_SIZE, parameterCompactionPersistIntervalMs = PARAMETER_COMPACTION_PERSIST_INTERVAL_MS) {
18
36
  this.db = db;
19
- this.group_id = group_id;
37
+ this.replicationStreamId = replicationStreamId;
20
38
  this.checkpoint = checkpoint;
21
39
  this.options = options;
22
- this.getCollectionsCb = getCollectionsCb;
40
+ this.parameterCompactionBatchSize = parameterCompactionBatchSize;
41
+ this.parameterCompactionPersistIntervalMs = parameterCompactionPersistIntervalMs;
42
+ this.logger = options.logger ?? defaultLogger;
43
+ this.signal = options.signal;
23
44
  }
45
+ /**
46
+ * Set once the invalidation fence for this pass has been persisted. See
47
+ * {@link ensureInvalidationFence}.
48
+ */
49
+ #invalidationFencePersisted = false;
24
50
  async compact() {
25
- logger.info(`Compacting parameters for sync config ${this.group_id} up to checkpoint ${this.checkpoint}`);
26
- for (const collection of await this.getCollections()) {
27
- await this.compactCollection(collection);
28
- }
51
+ const startedAt = Date.now();
52
+ this.signal?.throwIfAborted();
53
+ const compactedBefore = await this.readCompactedBefore();
54
+ this.logger.info(`Incrementally compacting parameters from ${compactedBefore} up to checkpoint ${this.checkpoint}`);
55
+ const result = await this.compactCollections(compactedBefore);
56
+ // Persist only after every collection has completed. This uses $max so an overlapping
57
+ // compactor cannot move the cursor backwards.
58
+ await this.persistCompactedBefore(this.checkpoint);
59
+ const durationSeconds = (Date.now() - startedAt) / 1000;
60
+ this.logger.info(`Incremental parameter compaction completed: ` +
61
+ `collections=${result.collections}, scanned=${result.scannedEntries}, ` +
62
+ `deleted=${result.deletedEntries}, cursor=${compactedBefore}->${this.checkpoint}, ` +
63
+ `fence=${this.#invalidationFencePersisted ? this.checkpoint : 'unchanged'}, duration=${durationSeconds.toFixed(1)}s`);
29
64
  }
30
- async getCollections() {
31
- if (this.getCollectionsCb == null) {
32
- throw new Error('getCollections callback not provided');
33
- }
34
- const collections = await this.getCollectionsCb();
35
- // Cast from the version-specific collection type to the generic Document type
36
- // used by the parameter compactor base class.
37
- return collections.map((collection) => collection);
38
- }
39
- collectionFilter() {
40
- return {};
65
+ /**
66
+ * The exclusive operation-id boundary through which this stream's parameter indexes have all
67
+ * been compacted.
68
+ */
69
+ async readCompactedBefore() {
70
+ const stream = await this.db.sync_rules.findOne({ _id: this.replicationStreamId }, { projection: { parameter_compaction: 1 } });
71
+ return stream?.parameter_compaction?.compacted_before == null
72
+ ? 0n
73
+ : BigInt(stream.parameter_compaction.compacted_before);
41
74
  }
42
- deleteFilter(doc) {
43
- return {
44
- lookup: doc.lookup,
45
- _id: { $lte: doc._id },
46
- key: doc.key
47
- };
75
+ async persistCompactedBefore(compactedBefore) {
76
+ await this.db.sync_rules.updateOne({ _id: this.replicationStreamId }, {
77
+ $max: { 'parameter_compaction.compacted_before': compactedBefore }
78
+ });
48
79
  }
49
- async compactCollection(collection) {
50
- // This is the currently-active checkpoint.
51
- // We do not remove any data that may be used by this checkpoint.
52
- // snapshot queries ensure that if any clients are still using older checkpoints, they would
53
- // not be affected by this compaction.
54
- const checkpoint = this.checkpoint;
55
- // Index on {'key.g': 1, lookup: 1, _id: 1}
56
- // In theory, we could let MongoDB do more of the work here, by grouping by (key, lookup)
57
- // in MongoDB already. However, that risks running into cases where MongoDB needs to process
58
- // very large amounts of data before returning results, which could lead to timeouts.
59
- const cursor = collection.find(this.collectionFilter(), {
60
- sort: { lookup: 1, _id: 1 },
61
- batchSize: 10_000,
62
- projection: { _id: 1, key: 1, lookup: 1, bucket_parameters: 1 }
80
+ /**
81
+ * Commits the checkpoint-change invalidation fence before the first delete of this pass.
82
+ *
83
+ * Checkpoint change detection finds changed lookups by querying parameter entries in
84
+ * (lastCheckpoint, nextCheckpoint]. Compaction physically removes entries in that range, so a
85
+ * checkpoint that can no longer see the full history must instead invalidate all parameter
86
+ * buckets. The fence records the boundary below which that history may be missing.
87
+ *
88
+ * The fence must be committed before the first delete: MongoDB snapshot ordering then
89
+ * guarantees that a checkpoint snapshot which observes a deletion also observes the fence.
90
+ *
91
+ * This deliberately isn't the same value as the compaction cursor. If the pass fails halfway,
92
+ * the fence only causes conservative invalidation, while an advanced cursor would skip
93
+ * deletion work that never completed.
94
+ */
95
+ async ensureInvalidationFence() {
96
+ // We can consider incrementally updating the fence based on the current cursor position instead
97
+ // of the checkpoint. That would result in lower risk of triggering invalidations, but it would
98
+ // result in a higher number of updates to the `sync_rules` collection, which can make it
99
+ // counter-productive.
100
+ // Another option is to introduce an artificial delay of a couple of seconds before writing the fence,
101
+ // giving some chance for every API process to catch up. Note that the delay would have to apply
102
+ // to both the deletes and the fence - the fence write must still happen before we do any deletes.
103
+ if (this.#invalidationFencePersisted) {
104
+ return;
105
+ }
106
+ await this.db.sync_rules.updateOne({ _id: this.replicationStreamId }, {
107
+ $max: { 'parameter_compaction.checkpoint_changes_invalid_before': this.checkpoint }
63
108
  });
64
- // The index doesn't cover sorting by key, so we keep our own cache of the last seen key.
65
- let lastByKey = new LRUCache({
66
- max: this.options.compactParameterCacheLimit ?? 10_000
109
+ this.#invalidationFencePersisted = true;
110
+ }
111
+ /**
112
+ * Processes every collection of the stream, in lock-step: each turn takes one batch from the
113
+ * collection that has processed the least so far.
114
+ *
115
+ * The persisted cursor is the minimum position over all collections, which is exactly the
116
+ * boundary that all of them have passed, so it can be advanced periodically during the pass.
117
+ * Always picking the collection that is furthest behind also keeps each of them within one batch
118
+ * of that boundary, bounding the work an interrupted pass has to repeat.
119
+ *
120
+ * V1 storage always has a single collection; V3 has a collection per defined index. So in V1 the
121
+ * ame process collapses to compacting the single collection in order, while V3 can alternate between
122
+ * collections.
123
+ */
124
+ async compactCollections(compactedBefore) {
125
+ const scopes = (await this.getCollections()).map((collection) => ({
126
+ collection,
127
+ position: compactedBefore,
128
+ scannedEntries: 0,
129
+ deletedEntries: 0
130
+ }));
131
+ // Shared by all scopes, so the memory bound does not depend on the number of parameter indexes.
132
+ // It is safe for items to be evicted: that just changes deletes from "delete by _id" to
133
+ // the more expensive "delete by range filter".
134
+ const previousByIdentity = new LRUCache({
135
+ max: this.options.compactParameterCacheLimit ?? PARAMETER_COMPACTION_CACHE_SIZE
67
136
  });
68
- let removeIds = [];
69
- let removeDeleted = [];
70
- let checkedEntries = 0;
71
- let checkedEntriesAtLastLog = 0;
72
- let lastProgressLogTime = Date.now();
73
- const flush = async (force) => {
74
- if (removeIds.length >= 1000 || (force && removeIds.length > 0)) {
75
- // MongoDB Filter<T> doesn't fully match our dynamic delete filter shape here.
76
- const results = await collection.deleteMany({ _id: { $in: removeIds } });
77
- logger.info(`Removed ${results.deletedCount} (${removeIds.length}) superseded parameter entries`);
78
- removeIds = [];
137
+ let persistedFrontier = compactedBefore;
138
+ let lastPersistedAt = Date.now();
139
+ while (true) {
140
+ // Interrupting between batches is equivalent to a crash: deletes are idempotent, and the
141
+ // cursor never covers a batch that did not complete.
142
+ this.signal?.throwIfAborted();
143
+ const { frontier, scope } = this.frontier(scopes);
144
+ if (frontier > persistedFrontier && Date.now() - lastPersistedAt >= this.parameterCompactionPersistIntervalMs) {
145
+ await this.persistCompactedBefore(frontier);
146
+ persistedFrontier = frontier;
147
+ lastPersistedAt = Date.now();
148
+ this.logger.info(`Parameter compaction progress: ` + `cursor=${frontier}, target=${this.checkpoint}`);
149
+ }
150
+ if (scope == null) {
151
+ // All scopes have been processed up to the target checkpoint.
152
+ break;
79
153
  }
80
- if (removeDeleted.length > 10 || (force && removeDeleted.length > 0)) {
81
- const results = await collection.bulkWrite(removeDeleted);
82
- logger.info(`Removed ${results.deletedCount} (${removeDeleted.length}) deleted parameter entries`);
83
- removeDeleted = [];
154
+ // The scope on the frontier has processed the least, so taking its next batch is what keeps
155
+ // every scope within one batch of the cursor.
156
+ await this.compactBatch(scope, previousByIdentity);
157
+ if (scope.position >= this.checkpoint && scope.scannedEntries > 0) {
158
+ this.logger.info(`Parameter compaction completed for ${scope.collection.collectionName}: ` +
159
+ `scanned=${scope.scannedEntries}, deleted=${scope.deletedEntries}`);
84
160
  }
161
+ }
162
+ return {
163
+ collections: scopes.length,
164
+ scannedEntries: scopes.reduce((total, scope) => total + scope.scannedEntries, 0),
165
+ deletedEntries: scopes.reduce((total, scope) => total + scope.deletedEntries, 0)
85
166
  };
86
- while (await cursor.hasNext()) {
87
- // readBufferedDocuments returns a generic type; we know the shape from our projection.
88
- const batch = cursor.readBufferedDocuments();
89
- checkedEntries += batch.length;
90
- const now = Date.now();
91
- if (now - lastProgressLogTime >= 60_000) {
92
- const elapsedSeconds = (now - lastProgressLogTime) / 1000;
93
- const rate = (checkedEntries - checkedEntriesAtLastLog) / elapsedSeconds;
94
- logger.info(`Checked ${checkedEntries} parameter index entries for compaction (${rate.toFixed(1)} entries/s)`);
95
- lastProgressLogTime = now;
96
- checkedEntriesAtLastLog = checkedEntries;
167
+ }
168
+ /**
169
+ * The boundary that every scope has processed past, capped at the target checkpoint, and the
170
+ * scope sitting on it.
171
+ *
172
+ * The frontier is the furthest the cursor may be advanced. The scope is the one that has
173
+ * processed the least, or null once all of them have reached the target checkpoint.
174
+ */
175
+ frontier(scopes) {
176
+ let frontier = this.checkpoint;
177
+ let scope = null;
178
+ for (const candidate of scopes) {
179
+ if (candidate.position < frontier) {
180
+ frontier = candidate.position;
181
+ scope = candidate;
97
182
  }
98
- for (const doc of batch) {
99
- if (doc._id >= checkpoint) {
100
- continue;
183
+ }
184
+ return { frontier, scope };
185
+ }
186
+ /**
187
+ * Reads and processes one batch from the scope, and advances its position past that batch.
188
+ */
189
+ async compactBatch(scope, previousByIdentity) {
190
+ const batchStartedAt = Date.now();
191
+ const collection = scope.collection;
192
+ // Typed as Document: `_id` here is an InternalOpId (bigint), not the driver's default ObjectId.
193
+ const filter = { _id: { $gte: scope.position, $lt: this.checkpoint } };
194
+ const batch = (await collection
195
+ .find(filter, {
196
+ sort: { _id: 1 },
197
+ limit: this.parameterCompactionBatchSize,
198
+ batchSize: this.parameterCompactionBatchSize + 1,
199
+ projection: { _id: 1, key: 1, lookup: 1, bucket_parameters: { $slice: 1 } }
200
+ })
201
+ .toArray());
202
+ if (batch.length < this.parameterCompactionBatchSize) {
203
+ // Fewer documents than we asked for: this collection has nothing left in the range.
204
+ scope.position = this.checkpoint;
205
+ }
206
+ else {
207
+ scope.position = batch.at(-1)._id + 1n;
208
+ }
209
+ if (batch.length == 0) {
210
+ return;
211
+ }
212
+ scope.scannedEntries += batch.length;
213
+ const deletedBeforeBatch = scope.deletedEntries;
214
+ // Keep the latest document for each identity and remove all earlier documents from this
215
+ // batch by _id, avoiding a range query for documents that have already been read.
216
+ const newestByIdentity = new Map();
217
+ const supersededIds = [];
218
+ for (const document of batch) {
219
+ if (!this.shouldCompactDocument(document)) {
220
+ continue;
221
+ }
222
+ const identity = identityKey(scope, document);
223
+ const previous = newestByIdentity.get(identity);
224
+ if (previous != null) {
225
+ supersededIds.push(previous._id);
226
+ }
227
+ newestByIdentity.set(identity, document);
228
+ }
229
+ const leadingHistoryDeletes = new Map();
230
+ const tombstoneIds = [];
231
+ for (const [identity, document] of newestByIdentity) {
232
+ const previous = previousByIdentity.get(identity);
233
+ if (previous == null) {
234
+ // Have not seen this (key, lookup) before, or it has been evicted from the cache.
235
+ // Delete the entire leading range.
236
+ // This should have decent performance on V3 storage; can be slow in some cases on V1.
237
+ const lookupIdentity = document.lookup.toString('base64');
238
+ const existing = leadingHistoryDeletes.get(lookupIdentity);
239
+ if (existing == null) {
240
+ leadingHistoryDeletes.set(lookupIdentity, { lookup: document.lookup, keys: [document.key] });
101
241
  }
102
- const uniqueKey = bson.serialize({
103
- k: doc.key,
104
- l: doc.lookup
105
- }).toString('base64');
106
- const previous = lastByKey.get(uniqueKey);
107
- if (previous != null && previous < doc._id) {
108
- // We have a newer entry for the same key, so we can remove the old one.
109
- removeIds.push(previous);
242
+ else {
243
+ existing.keys.push(document.key);
110
244
  }
111
- lastByKey.set(uniqueKey, doc._id);
112
- if (doc.bucket_parameters?.length == 0) {
113
- // This is a delete operation, so we can remove it completely.
114
- // For this we cannot remove the operation itself only: There is a possibility that
115
- // there is still an earlier operation with the same key and lookup, that we don't have
116
- // in the cache due to cache size limits. So we need to explicitly remove all earlier operations.
117
- removeDeleted.push({
118
- deleteMany: {
119
- filter: this.deleteFilter(doc)
120
- }
121
- });
245
+ }
246
+ else if (previous.retainedId != null) {
247
+ // We have already deleted the leading range for this (key, lookup). Only delete the last remaining
248
+ // one by _id. This is always fast.
249
+ supersededIds.push(previous.retainedId);
250
+ }
251
+ if (document.bucket_parameters?.length == 0) {
252
+ tombstoneIds.push(document._id);
253
+ }
254
+ }
255
+ // Phase 1: Delete documents read in this batch, plus retained documents from a prior batch.
256
+ scope.deletedEntries += await this.deleteByIds(collection, supersededIds);
257
+ // Phase 2: Delete leading history once per lookup group. The batch is read with
258
+ // `_id < checkpoint`, so this range is checkpoint-bounded.
259
+ const deleteBefore = batch[0]._id;
260
+ // The deletes are collected into bulkWrite commands: With high lookup cardinality there is a
261
+ // group per identity, and a command per group would mean a round trip per identity.
262
+ let deleteOperations = [];
263
+ let pendingKeys = 0;
264
+ const flushDeleteOperations = async () => {
265
+ if (deleteOperations.length == 0) {
266
+ return;
267
+ }
268
+ // Safe to stop here: an interrupted batch leaves phase 3 tombstones in place, and the
269
+ // remaining deletes are repeated by the next pass.
270
+ this.signal?.throwIfAborted();
271
+ await this.ensureInvalidationFence();
272
+ const result = await collection.bulkWrite(deleteOperations, { ordered: false });
273
+ scope.deletedEntries += result.deletedCount;
274
+ deleteOperations = [];
275
+ pendingKeys = 0;
276
+ };
277
+ for (const { lookup, keys } of leadingHistoryDeletes.values()) {
278
+ for (const keyBatch of chunk(keys, PARAMETER_COMPACTION_DELETE_BATCH_SIZE)) {
279
+ deleteOperations.push({
280
+ deleteMany: { filter: this.leadingHistoryDeleteFilter(lookup, keyBatch, deleteBefore) }
281
+ });
282
+ // Bound the command size by the total number of keys it covers, not by the number of
283
+ // operations: a single group may already cover the entire batch.
284
+ pendingKeys += keyBatch.length;
285
+ if (pendingKeys >= PARAMETER_COMPACTION_DELETE_BATCH_SIZE) {
286
+ await flushDeleteOperations();
122
287
  }
123
288
  }
124
- await flush(false);
125
289
  }
126
- await flush(true);
127
- logger.info(`Parameter compaction completed for ${collection.collectionName}`);
290
+ // Phase 3 requires all leading history to be deleted first.
291
+ await flushDeleteOperations();
292
+ // Phase 3: A tombstone is removed only after all preceding history has been removed.
293
+ scope.deletedEntries += await this.deleteByIds(collection, tombstoneIds);
294
+ // Update the LRU only after all phases succeed. An evicted identity safely falls back to a
295
+ // grouped leading-history delete when it appears again.
296
+ for (const [identity, document] of newestByIdentity) {
297
+ // Tombstones are recorded as `retainedId: null`: phases 2 and 3 removed the entire history
298
+ // for the identity, including the tombstone, so a later sighting needs neither delete.
299
+ previousByIdentity.set(identity, {
300
+ retainedId: document.bucket_parameters?.length == 0 ? null : document._id
301
+ });
302
+ }
303
+ const batchDurationSeconds = (Date.now() - batchStartedAt) / 1000;
304
+ this.logger.info(`Compacted parameter batch in ${collection.collectionName}: ` +
305
+ `_id ${batch[0]._id}..${batch.at(-1)._id}, scanned=${batch.length} (${scope.scannedEntries} total), ` +
306
+ `batchIdentities=${newestByIdentity.size}, exactIds=${supersededIds.length + tombstoneIds.length}, ` +
307
+ `lookupGroups=${leadingHistoryDeletes.size}, deleted=${scope.deletedEntries - deletedBeforeBatch}, ` +
308
+ `duration=${batchDurationSeconds.toFixed(1)}s`);
309
+ }
310
+ /** Deletes documents by `_id`, chunked to bound the command size. Returns the number deleted. */
311
+ async deleteByIds(collection, ids) {
312
+ let deletedEntries = 0;
313
+ for (const idBatch of chunk(ids, PARAMETER_COMPACTION_DELETE_BATCH_SIZE)) {
314
+ this.signal?.throwIfAborted();
315
+ await this.ensureInvalidationFence();
316
+ // Cast: `_id` here is an InternalOpId (bigint), not the driver's default ObjectId.
317
+ const result = await collection.deleteMany({ _id: { $in: idBatch } });
318
+ deletedEntries += result.deletedCount;
319
+ }
320
+ return deletedEntries;
321
+ }
322
+ }
323
+ /**
324
+ * Identifies a (key, lookup) pair within one collection.
325
+ *
326
+ * The collection is part of the identity: V3 keeps the parameter index id in the collection name
327
+ * rather than in the lookup, so the same (key, lookup) can appear in multiple collections meaning
328
+ * different things. Deleting the history of one says nothing about the other.
329
+ */
330
+ function identityKey(scope, document) {
331
+ const serialized = bson.serialize({
332
+ c: scope.collection.collectionName,
333
+ k: document.key,
334
+ l: document.lookup
335
+ });
336
+ return serialized.toString('base64');
337
+ }
338
+ function* chunk(items, size) {
339
+ for (let offset = 0; offset < items.length; offset += size) {
340
+ yield items.slice(offset, offset + size);
128
341
  }
129
342
  }
130
343
  //# sourceMappingURL=MongoParameterCompactor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MongoParameterCompactor.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoParameterCompactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAgC,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAUrC;;;;;;GAMG;AACH,MAAM,OAAO,uBAAuB;IAEb;IACA;IACA;IACA;IACA;IALrB,YACqB,EAA2B,EAC3B,QAAgB,EAChB,UAAwB,EACxB,OAAuB,EACvB,gB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C;gBAC1C,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;oBAC3C,wEAAwE;oBACxE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC3B,CAAC;gBACD,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;gBAElC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;oBACvC,8DAA8D;oBAC9D,mFAAmF;oBACnF,uFAAuF;oBACvF,iGAAiG;oBACjG,aAAa,CAAC,IAAI,CAAC;wBACjB,UAAU,EAAE;4BACV,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;yBAC/B;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,sCAAsC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;IACjF,CAAC;CACF"}
1
+ {"version":3,"file":"MongoParameterCompactor.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoParameterCompactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAU,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,IAAI,EAAgC,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAgBrC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AAC/C,MAAM,sCAAsC,GAAG,KAAK,CAAC;AACrD,MAAM,+BAA+B,GAAG,MAAM,CAAC;AAC/C;;;;GAIG;AACH,MAAM,wCAAwC,GAAG,MAAM,CAAC;AA+BxD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAgB,uBAAuB;IAKtB;IACA;IACA;IACA;IACA;IACA;I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GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;QAC3D,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { BucketDefinitionMapping, storage, SyncConfigWithMapping } from '@powersync/service-core';
2
- import { HydratedSyncConfig, HydrationState, SyncConfigWithErrors } from '@powersync/service-sync-rules';
2
+ import { EventDefinitionId, HydratedEventDescriptor, HydratedSyncConfig, HydrationState, SyncConfigWithErrors } from '@powersync/service-sync-rules';
3
3
  import { StorageConfig } from './models.js';
4
4
  export declare class MongoParsedSyncConfigSet implements storage.ParsedSyncConfigSet {
5
5
  #private;
@@ -10,4 +10,12 @@ export declare class MongoParsedSyncConfigSet implements storage.ParsedSyncConfi
10
10
  readonly mapping: BucketDefinitionMapping;
11
11
  constructor(replicationStreamId: number, storageConfig: StorageConfig, slotName: string, syncConfigs: SyncConfigWithMapping[]);
12
12
  get hydratedSyncConfig(): HydratedSyncConfig;
13
+ /**
14
+ * Hydrated events for the replication stream, keyed by their assigned storage id.
15
+ *
16
+ * Each config's events are resolved against that config's own (single-config) mapping, so the resolution is
17
+ * unambiguous, and the result is deduplicated by assigned id: unchanged events shared across configs collapse to
18
+ * one entry, while a changed event keeps a separate entry under its new id.
19
+ */
20
+ get eventById(): ReadonlyMap<EventDefinitionId, HydratedEventDescriptor>;
13
21
  }
@@ -9,9 +9,11 @@ export class MongoParsedSyncConfigSet {
9
9
  syncConfigs;
10
10
  replicationStreamName;
11
11
  mapping;
12
+ #configsWithMapping;
12
13
  constructor(replicationStreamId, storageConfig, slotName, syncConfigs) {
13
14
  this.replicationStreamId = replicationStreamId;
14
15
  this.replicationStreamName = slotName;
16
+ this.#configsWithMapping = [...syncConfigs];
15
17
  this.syncConfigs = syncConfigs.map((config) => config.syncConfig);
16
18
  if (this.syncConfigs.length == 0) {
17
19
  throw new ServiceAssertionError(`At least one sync config is required`);
@@ -60,5 +62,32 @@ export class MongoParsedSyncConfigSet {
60
62
  });
61
63
  return this.#hydratedSyncConfig;
62
64
  }
65
+ #eventById;
66
+ /**
67
+ * Hydrated events for the replication stream, keyed by their assigned storage id.
68
+ *
69
+ * Each config's events are resolved against that config's own (single-config) mapping, so the resolution is
70
+ * unambiguous, and the result is deduplicated by assigned id: unchanged events shared across configs collapse to
71
+ * one entry, while a changed event keeps a separate entry under its new id.
72
+ */
73
+ get eventById() {
74
+ if (this.#eventById == null) {
75
+ const map = new Map();
76
+ const byDefinition = this.hydratedSyncConfig.eventDescriptorsByDefinition;
77
+ for (const config of this.#configsWithMapping) {
78
+ if (config.mapping == null) {
79
+ continue;
80
+ }
81
+ for (const event of byDefinition.get(config.syncConfig.config) ?? []) {
82
+ const id = config.mapping.eventId(event);
83
+ if (!map.has(id)) {
84
+ map.set(id, event);
85
+ }
86
+ }
87
+ }
88
+ this.#eventById = map;
89
+ }
90
+ return this.#eventById;
91
+ }
63
92
  }
64
93
  //# sourceMappingURL=MongoParsedSyncConfigSet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MongoParsedSyncConfigSet.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoParsedSyncConfigSet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAEL,sCAAsC,EACtC,uCAAuC,EAIxC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAElB,UAAU,EAEV,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,OAAO,wBAAwB;IAOjB;IANF,cAAc,CAAiB;IAC/B,WAAW,CAAyB;IACpC,qBAAqB,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gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
@@ -51,7 +51,8 @@ export class MongoPersistedSyncConfigContentV1 extends MongoPersistedSyncConfigC
51
51
  storageVersion: doc.storage_version ?? storage.LEGACY_STORAGE_VERSION,
52
52
  mapping: new SingleSyncConfigBucketDefinitionMapping(),
53
53
  syncConfigId: null,
54
- syncConfigState: doc.state
54
+ syncConfigState: doc.state,
55
+ version_label: doc.version_label ?? undefined
55
56
  });
56
57
  }
57
58
  async getSyncConfigStatus() {
@@ -76,7 +77,8 @@ export class MongoPersistedSyncConfigContentV3 extends MongoPersistedSyncConfigC
76
77
  storageVersion: doc.storage_version,
77
78
  mapping: SingleSyncConfigBucketDefinitionMapping.fromPersistedMapping(config.rule_mapping),
78
79
  syncConfigId: config._id,
79
- syncConfigState: state.state
80
+ syncConfigState: state.state,
81
+ version_label: config.version_label
80
82
  });
81
83
  }
82
84
  async getSyncConfigStatus() {
@@ -1 +1 @@
1
- {"version":3,"file":"MongoPersistedSyncConfigContent.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoPersistedSyncConfigContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,uCAAuC,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAS3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,OAAgB,mCAAoC,SAAQ,OAAO,CAAC,0BAA0B;IAK7E;IAJL,OAAO,CAA0C;IACjD,kBAAkB,CAAuB;IAEzD,YACqB,EAAkB,EACrC,OAGC;QAED,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QACnD,KA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GAAG,CAAC,mBAAmB;QAC5C,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;QAC5C,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,GAAgC,EAChC,KAA4B;IAE5B,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,mBAAmB,EAAE,GAAG,CAAC,GAAG;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;QAC9C,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;QAC5C,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"MongoPersistedSyncConfigContent.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoPersistedSyncConfigContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,uCAAuC,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAS3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,OAAgB,mCAAoC,SAAQ,OAAO,CAAC,0BAA0B;IAK7E;IAJL,OAAO,CAA0C;IACjD,kBAAkB,CAAuB;IAEzD,YACqB,EAAkB,EACrC,OAGC;QAED,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QACnD,KAAK,CAA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