@powersync/service-module-mongodb-storage 0.15.3 → 0.16.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.
- package/CHANGELOG.md +54 -0
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js +1 -1
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js.map +1 -1
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +3 -3
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +1 -1
- package/dist/migrations/db/migrations/1770213298299-storage-version.js.map +1 -1
- package/dist/storage/MongoBucketStorage.d.ts +5 -3
- package/dist/storage/MongoBucketStorage.js +50 -36
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/MongoReportStorage.js.map +1 -1
- package/dist/storage/implementation/BucketDefinitionMapping.d.ts +17 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js +58 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -0
- package/dist/storage/implementation/MongoBucketBatch.d.ts +16 -14
- package/dist/storage/implementation/MongoBucketBatch.js +80 -115
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatchShared.d.ts +5 -0
- package/dist/storage/implementation/MongoBucketBatchShared.js +8 -0
- package/dist/storage/implementation/MongoBucketBatchShared.js.map +1 -0
- package/dist/storage/implementation/MongoChecksums.d.ts +28 -17
- package/dist/storage/implementation/MongoChecksums.js +13 -72
- package/dist/storage/implementation/MongoChecksums.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.d.ts +98 -58
- package/dist/storage/implementation/MongoCompactor.js +229 -296
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoParameterCompactor.d.ts +11 -6
- package/dist/storage/implementation/MongoParameterCompactor.js +11 -8
- package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoPersistedSyncRules.d.ts +14 -0
- package/dist/storage/implementation/MongoPersistedSyncRules.js +64 -0
- package/dist/storage/implementation/MongoPersistedSyncRules.js.map +1 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.d.ts +3 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js +9 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/implementation/MongoStorageProvider.js +1 -1
- package/dist/storage/implementation/MongoStorageProvider.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +49 -30
- package/dist/storage/implementation/MongoSyncBucketStorage.js +96 -388
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +5 -3
- package/dist/storage/implementation/MongoSyncRulesLock.js +12 -10
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js +1 -1
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/OperationBatch.js +1 -1
- package/dist/storage/implementation/common/BucketDataDoc.d.ts +35 -0
- package/dist/storage/implementation/common/BucketDataDoc.js +2 -0
- package/dist/storage/implementation/common/BucketDataDoc.js.map +1 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.d.ts +13 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.js +2 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.js.map +1 -0
- package/dist/storage/implementation/common/PersistedBatch.d.ts +108 -0
- package/dist/storage/implementation/common/PersistedBatch.js +237 -0
- package/dist/storage/implementation/common/PersistedBatch.js.map +1 -0
- package/dist/storage/implementation/common/SingleBucketStore.d.ts +54 -0
- package/dist/storage/implementation/common/SingleBucketStore.js +3 -0
- package/dist/storage/implementation/common/SingleBucketStore.js.map +1 -0
- package/dist/storage/implementation/common/SourceRecordStore.d.ts +36 -0
- package/dist/storage/implementation/common/SourceRecordStore.js +2 -0
- package/dist/storage/implementation/common/SourceRecordStore.js.map +1 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.d.ts +27 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js +57 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js.map +1 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.d.ts +7 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.js +9 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.js.map +1 -0
- package/dist/storage/implementation/db.d.ts +34 -34
- package/dist/storage/implementation/db.js +78 -98
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +63 -34
- package/dist/storage/implementation/models.js +21 -2
- package/dist/storage/implementation/models.js.map +1 -1
- package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +13 -0
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js +22 -0
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.d.ts +12 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.js +56 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.d.ts +23 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.js +52 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.d.ts +9 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.js +20 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.d.ts +41 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js +283 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js.map +1 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +26 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.js +183 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.d.ts +18 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.js +57 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.js.map +1 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.d.ts +19 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js +105 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js.map +1 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.d.ts +12 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.js +20 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.js.map +1 -0
- package/dist/storage/implementation/v1/models.d.ts +34 -0
- package/dist/storage/implementation/v1/models.js +37 -0
- package/dist/storage/implementation/v1/models.js.map +1 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +13 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js +34 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.d.ts +15 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.js +84 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +23 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.js +68 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.d.ts +9 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.js +18 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.d.ts +5 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.js +9 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.d.ts +41 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js +407 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js.map +1 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +29 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.js +259 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.d.ts +18 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.js +48 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.js.map +1 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.d.ts +22 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js +164 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js.map +1 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.d.ts +21 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js +71 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js.map +1 -0
- package/dist/storage/implementation/v3/models.d.ts +43 -0
- package/dist/storage/implementation/v3/models.js +34 -0
- package/dist/storage/implementation/v3/models.js.map +1 -0
- package/dist/storage/storage-index.d.ts +8 -5
- package/dist/storage/storage-index.js +8 -5
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/utils/util.d.ts +11 -4
- package/dist/utils/util.js +25 -4
- package/dist/utils/util.js.map +1 -1
- package/package.json +9 -9
- package/src/migrations/db/migrations/1688556755264-initial-sync-rules.ts +1 -1
- package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +7 -7
- package/src/migrations/db/migrations/1770213298299-storage-version.ts +1 -1
- package/src/storage/MongoBucketStorage.ts +97 -62
- package/src/storage/MongoReportStorage.ts +2 -2
- package/src/storage/implementation/BucketDefinitionMapping.ts +72 -0
- package/src/storage/implementation/MongoBucketBatch.ts +110 -144
- package/src/storage/implementation/MongoBucketBatchShared.ts +11 -0
- package/src/storage/implementation/MongoChecksums.ts +53 -76
- package/src/storage/implementation/MongoCompactor.ts +374 -404
- package/src/storage/implementation/MongoParameterCompactor.ts +37 -24
- package/src/storage/implementation/MongoPersistedSyncRules.ts +76 -0
- package/src/storage/implementation/MongoPersistedSyncRulesContent.ts +18 -1
- package/src/storage/implementation/MongoStorageProvider.ts +1 -1
- package/src/storage/implementation/MongoSyncBucketStorage.ts +190 -457
- package/src/storage/implementation/MongoSyncRulesLock.ts +12 -14
- package/src/storage/implementation/MongoWriteCheckpointAPI.ts +4 -2
- package/src/storage/implementation/OperationBatch.ts +1 -1
- package/src/storage/implementation/common/BucketDataDoc.ts +37 -0
- package/src/storage/implementation/common/MongoSyncBucketStorageContext.ts +15 -0
- package/src/storage/implementation/common/PersistedBatch.ts +364 -0
- package/src/storage/implementation/common/SingleBucketStore.ts +63 -0
- package/src/storage/implementation/common/SourceRecordStore.ts +49 -0
- package/src/storage/implementation/common/VersionedPowerSyncMongoBase.ts +80 -0
- package/src/storage/implementation/createMongoSyncBucketStorage.ts +25 -0
- package/src/storage/implementation/db.ts +107 -128
- package/src/storage/implementation/models.ts +84 -38
- package/src/storage/implementation/v1/MongoBucketBatchV1.ts +32 -0
- package/src/storage/implementation/v1/MongoChecksumsV1.ts +75 -0
- package/src/storage/implementation/v1/MongoCompactorV1.ts +93 -0
- package/src/storage/implementation/v1/MongoParameterCompactorV1.ts +26 -0
- package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +448 -0
- package/src/storage/implementation/v1/PersistedBatchV1.ts +230 -0
- package/src/storage/implementation/v1/SingleBucketStoreV1.ts +74 -0
- package/src/storage/implementation/v1/SourceRecordStoreV1.ts +156 -0
- package/src/storage/implementation/v1/VersionedPowerSyncMongoV1.ts +28 -0
- package/src/storage/implementation/v1/models.ts +84 -0
- package/src/storage/implementation/v3/MongoBucketBatchV3.ts +44 -0
- package/src/storage/implementation/v3/MongoChecksumsV3.ts +120 -0
- package/src/storage/implementation/v3/MongoCompactorV3.ts +107 -0
- package/src/storage/implementation/v3/MongoParameterCompactorV3.ts +24 -0
- package/src/storage/implementation/v3/MongoParameterLookupV3.ts +12 -0
- package/src/storage/implementation/v3/MongoSyncBucketStorageV3.ts +550 -0
- package/src/storage/implementation/v3/PersistedBatchV3.ts +318 -0
- package/src/storage/implementation/v3/SingleBucketStoreV3.ts +68 -0
- package/src/storage/implementation/v3/SourceRecordStoreV3.ts +226 -0
- package/src/storage/implementation/v3/VersionedPowerSyncMongoV3.ts +112 -0
- package/src/storage/implementation/v3/models.ts +96 -0
- package/src/storage/storage-index.ts +8 -5
- package/src/utils/util.ts +36 -7
- package/test/src/__snapshots__/storage_sync.test.ts.snap +282 -0
- package/test/src/connection-report-storage.test.ts +3 -3
- package/test/src/setup.ts +1 -1
- package/test/src/storage.test.ts +2 -2
- package/test/src/storage_compacting.test.ts +57 -29
- package/test/src/storage_sync.test.ts +351 -5
- package/test/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/storage/implementation/PersistedBatch.d.ts +0 -71
- package/dist/storage/implementation/PersistedBatch.js +0 -354
- package/dist/storage/implementation/PersistedBatch.js.map +0 -1
- package/src/storage/implementation/PersistedBatch.ts +0 -432
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { logger as defaultLogger } from '@powersync/lib-services-framework';
|
|
2
|
+
import { utils } from '@powersync/service-core';
|
|
3
|
+
import { JSONBig } from '@powersync/service-jsonbig';
|
|
4
|
+
import { mongoTableId, replicaIdToSubkey } from '../../../utils/util.js';
|
|
5
|
+
import { currentBucketKey, MAX_ROW_SIZE } from '../MongoBucketBatchShared.js';
|
|
6
|
+
/**
|
|
7
|
+
* Maximum size of operations we write in a single transaction.
|
|
8
|
+
*
|
|
9
|
+
* It's tricky to find the exact limit, but from experience, over 100MB
|
|
10
|
+
* can cause an error:
|
|
11
|
+
* > transaction is too large and will not fit in the storage engine cache
|
|
12
|
+
*
|
|
13
|
+
* Additionally, unbounded size here can balloon our memory usage in some edge
|
|
14
|
+
* cases.
|
|
15
|
+
*
|
|
16
|
+
* When we reach this threshold, we commit the transaction and start a new one.
|
|
17
|
+
*/
|
|
18
|
+
const MAX_TRANSACTION_BATCH_SIZE = 30_000_000;
|
|
19
|
+
/**
|
|
20
|
+
* Limit number of documents to write in a single transaction.
|
|
21
|
+
*
|
|
22
|
+
* This has an effect on error message size in some cases.
|
|
23
|
+
*/
|
|
24
|
+
const MAX_TRANSACTION_DOC_COUNT = 2_000;
|
|
25
|
+
/**
|
|
26
|
+
* Keeps track of bulkwrite operations within a transaction.
|
|
27
|
+
*
|
|
28
|
+
* There may be multiple of these batches per transaction, but it may not span
|
|
29
|
+
* multiple transactions.
|
|
30
|
+
*/
|
|
31
|
+
export class PersistedBatch {
|
|
32
|
+
db;
|
|
33
|
+
group_id;
|
|
34
|
+
mapping;
|
|
35
|
+
logger;
|
|
36
|
+
bucketData = [];
|
|
37
|
+
bucketParameters = [];
|
|
38
|
+
bucketStates = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* For debug logging only.
|
|
41
|
+
*/
|
|
42
|
+
debugLastOpId = null;
|
|
43
|
+
/**
|
|
44
|
+
* Very rough estimate of transaction size.
|
|
45
|
+
*/
|
|
46
|
+
currentSize = 0;
|
|
47
|
+
constructor(db, group_id, mapping, writtenSize, options) {
|
|
48
|
+
this.db = db;
|
|
49
|
+
this.group_id = group_id;
|
|
50
|
+
this.mapping = mapping;
|
|
51
|
+
this.currentSize = writtenSize;
|
|
52
|
+
this.logger = options?.logger ?? defaultLogger;
|
|
53
|
+
}
|
|
54
|
+
saveBucketData(options) {
|
|
55
|
+
const remaining_buckets = new Map();
|
|
56
|
+
for (let bucket of options.before_buckets) {
|
|
57
|
+
const mapped = {
|
|
58
|
+
bucket: bucket.bucket,
|
|
59
|
+
definitionId: this.checkDefinitionId(bucket.definitionId),
|
|
60
|
+
id: bucket.id,
|
|
61
|
+
table: bucket.table
|
|
62
|
+
};
|
|
63
|
+
remaining_buckets.set(currentBucketKey(mapped), mapped);
|
|
64
|
+
}
|
|
65
|
+
const dchecksum = BigInt(utils.hashDelete(replicaIdToSubkey(options.table.id, options.sourceKey)));
|
|
66
|
+
for (const evaluated of options.evaluated) {
|
|
67
|
+
const definitionId = this.getBucketDefinitionId(evaluated.source);
|
|
68
|
+
const key = currentBucketKey({
|
|
69
|
+
definitionId: definitionId,
|
|
70
|
+
bucket: evaluated.bucket,
|
|
71
|
+
table: evaluated.table,
|
|
72
|
+
id: evaluated.id
|
|
73
|
+
});
|
|
74
|
+
const recordData = JSONBig.stringify(evaluated.data);
|
|
75
|
+
const checksum = utils.hashData(evaluated.table, evaluated.id, recordData);
|
|
76
|
+
if (recordData.length > MAX_ROW_SIZE) {
|
|
77
|
+
this.logger.error(`Row ${key} too large: ${recordData.length} bytes. Removing.`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
remaining_buckets.delete(key);
|
|
81
|
+
const byteEstimate = recordData.length + 200;
|
|
82
|
+
this.currentSize += byteEstimate;
|
|
83
|
+
const op_id = options.op_seq.next();
|
|
84
|
+
this.debugLastOpId = op_id;
|
|
85
|
+
this.addBucketDataPut({
|
|
86
|
+
bucketKey: {
|
|
87
|
+
bucket: evaluated.bucket,
|
|
88
|
+
definitionId: definitionId,
|
|
89
|
+
replicationStreamId: this.group_id
|
|
90
|
+
},
|
|
91
|
+
op_id,
|
|
92
|
+
bucket: evaluated.bucket,
|
|
93
|
+
sourceTableId: options.table.id,
|
|
94
|
+
sourceKey: options.sourceKey,
|
|
95
|
+
table: evaluated.table,
|
|
96
|
+
rowId: evaluated.id,
|
|
97
|
+
checksum: BigInt(checksum),
|
|
98
|
+
data: recordData
|
|
99
|
+
});
|
|
100
|
+
this.incrementBucket(definitionId, evaluated.bucket, op_id, byteEstimate);
|
|
101
|
+
}
|
|
102
|
+
for (let bucket of remaining_buckets.values()) {
|
|
103
|
+
const definitionId = bucket.definitionId;
|
|
104
|
+
const op_id = options.op_seq.next();
|
|
105
|
+
this.debugLastOpId = op_id;
|
|
106
|
+
this.addBucketDataRemove({
|
|
107
|
+
bucketKey: {
|
|
108
|
+
replicationStreamId: this.group_id,
|
|
109
|
+
definitionId,
|
|
110
|
+
bucket: bucket.bucket
|
|
111
|
+
},
|
|
112
|
+
op_id,
|
|
113
|
+
sourceTableId: options.table.id,
|
|
114
|
+
sourceKey: options.sourceKey,
|
|
115
|
+
table: bucket.table,
|
|
116
|
+
rowId: bucket.id,
|
|
117
|
+
checksum: dchecksum
|
|
118
|
+
});
|
|
119
|
+
this.currentSize += 200;
|
|
120
|
+
this.incrementBucket(definitionId, bucket.bucket, op_id, 200);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get bucketDataCount() {
|
|
124
|
+
return this.bucketData.length;
|
|
125
|
+
}
|
|
126
|
+
incrementBucket(definitionId, bucket, op_id, bytes) {
|
|
127
|
+
const key = `${definitionId ?? ''}:${bucket}`;
|
|
128
|
+
let existingState = this.bucketStates.get(key);
|
|
129
|
+
if (existingState) {
|
|
130
|
+
existingState.lastOp = op_id;
|
|
131
|
+
existingState.incrementCount += 1;
|
|
132
|
+
existingState.incrementBytes += bytes;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.bucketStates.set(key, {
|
|
136
|
+
definitionId,
|
|
137
|
+
bucket,
|
|
138
|
+
lastOp: op_id,
|
|
139
|
+
incrementCount: 1,
|
|
140
|
+
incrementBytes: bytes
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
addBucketDataPut(options) {
|
|
145
|
+
this.bucketData.push({
|
|
146
|
+
bucketKey: options.bucketKey,
|
|
147
|
+
o: options.op_id,
|
|
148
|
+
op: 'PUT',
|
|
149
|
+
source_table: mongoTableId(options.sourceTableId),
|
|
150
|
+
source_key: options.sourceKey,
|
|
151
|
+
table: options.table,
|
|
152
|
+
row_id: options.rowId,
|
|
153
|
+
checksum: options.checksum,
|
|
154
|
+
data: options.data
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
addBucketDataRemove(options) {
|
|
158
|
+
this.bucketData.push({
|
|
159
|
+
bucketKey: options.bucketKey,
|
|
160
|
+
o: options.op_id,
|
|
161
|
+
op: 'REMOVE',
|
|
162
|
+
source_table: mongoTableId(options.sourceTableId),
|
|
163
|
+
source_key: options.sourceKey,
|
|
164
|
+
table: options.table,
|
|
165
|
+
row_id: options.rowId,
|
|
166
|
+
checksum: options.checksum,
|
|
167
|
+
data: null
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
shouldFlushTransaction() {
|
|
171
|
+
return (this.currentSize >= MAX_TRANSACTION_BATCH_SIZE ||
|
|
172
|
+
this.bucketDataCount >= MAX_TRANSACTION_DOC_COUNT ||
|
|
173
|
+
this.currentDataCount >= MAX_TRANSACTION_DOC_COUNT ||
|
|
174
|
+
this.bucketParameters.length >= MAX_TRANSACTION_DOC_COUNT);
|
|
175
|
+
}
|
|
176
|
+
async flush(session, options) {
|
|
177
|
+
const startAt = performance.now();
|
|
178
|
+
let flushedSomething = false;
|
|
179
|
+
if (this.bucketDataCount > 0) {
|
|
180
|
+
flushedSomething = true;
|
|
181
|
+
await this.flushBucketData(session);
|
|
182
|
+
}
|
|
183
|
+
if (this.bucketParameters.length > 0) {
|
|
184
|
+
flushedSomething = true;
|
|
185
|
+
await this.flushBucketParameters(session);
|
|
186
|
+
}
|
|
187
|
+
if (this.currentDataCount > 0) {
|
|
188
|
+
flushedSomething = true;
|
|
189
|
+
await this.flushCurrentData(session);
|
|
190
|
+
}
|
|
191
|
+
if (this.bucketStates.size > 0) {
|
|
192
|
+
flushedSomething = true;
|
|
193
|
+
await this.flushBucketStates(session);
|
|
194
|
+
}
|
|
195
|
+
if (flushedSomething) {
|
|
196
|
+
const duration = Math.round(performance.now() - startAt);
|
|
197
|
+
if (options?.oldestUncommittedChange != null) {
|
|
198
|
+
const replicationLag = Math.round((Date.now() - options.oldestUncommittedChange.getTime()) / 1000);
|
|
199
|
+
this.logger.info(`Flushed ${this.bucketDataCount} + ${this.bucketParameters.length} + ${this.currentDataCount} updates, ${Math.round(this.currentSize / 1024)}kb in ${duration}ms. Last op_id: ${this.debugLastOpId}. Replication lag: ${replicationLag}s`, {
|
|
200
|
+
flushed: {
|
|
201
|
+
duration: duration,
|
|
202
|
+
size: this.currentSize,
|
|
203
|
+
bucket_data_count: this.bucketDataCount,
|
|
204
|
+
parameter_data_count: this.bucketParameters.length,
|
|
205
|
+
current_data_count: this.currentDataCount,
|
|
206
|
+
replication_lag_seconds: replicationLag
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this.logger.info(`Flushed ${this.bucketDataCount} + ${this.bucketParameters.length} + ${this.currentDataCount} updates, ${Math.round(this.currentSize / 1024)}kb in ${duration}ms. Last op_id: ${this.debugLastOpId}`, {
|
|
212
|
+
flushed: {
|
|
213
|
+
duration: duration,
|
|
214
|
+
size: this.currentSize,
|
|
215
|
+
bucket_data_count: this.bucketDataCount,
|
|
216
|
+
parameter_data_count: this.bucketParameters.length,
|
|
217
|
+
current_data_count: this.currentDataCount
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const stats = {
|
|
223
|
+
bucketDataCount: this.bucketDataCount,
|
|
224
|
+
parameterDataCount: this.bucketParameters.length,
|
|
225
|
+
currentDataCount: this.currentDataCount,
|
|
226
|
+
flushedAny: flushedSomething
|
|
227
|
+
};
|
|
228
|
+
this.bucketData = [];
|
|
229
|
+
this.bucketParameters = [];
|
|
230
|
+
this.resetCurrentData();
|
|
231
|
+
this.bucketStates.clear();
|
|
232
|
+
this.currentSize = 0;
|
|
233
|
+
this.debugLastOpId = null;
|
|
234
|
+
return stats;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=PersistedBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersistedBatch.js","sourceRoot":"","sources":["../../../../src/storage/implementation/common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AI,CACd,WAAW,IAAI,CAAC,eAAe,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,MAC/D,IAAI,CAAC,gBACP,aAAa,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,QAAQ,mBAAmB,IAAI,CAAC,aAAa,EAAE,EACxG;oBACE,OAAO,EAAE;wBACP,QAAQ,EAAE,QAAQ;wBAClB,IAAI,EAAE,IAAI,CAAC,WAAW;wBACtB,iBAAiB,EAAE,IAAI,CAAC,eAAe;wBACvC,oBAAoB,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM;wBAClD,kBAAkB,EAAE,IAAI,CAAC,gBAAgB;qBAC1C;iBACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG;YACZ,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM;YAChD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,UAAU,EAAE,gBAAgB;SAC7B,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { mongo } from '@powersync/lib-service-mongodb';
|
|
2
|
+
import { InternalOpId } from '@powersync/service-core';
|
|
3
|
+
import { BucketDataProperties } from '../models.js';
|
|
4
|
+
import { BucketDataDoc, BucketKey } from './BucketDataDoc.js';
|
|
5
|
+
declare const GENERIC_ID: unique symbol;
|
|
6
|
+
export type BucketDataDocumentGenericId = {
|
|
7
|
+
b: string;
|
|
8
|
+
o: InternalOpId;
|
|
9
|
+
[GENERIC_ID]: true;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This document is never actually constructed - we use it as a "virtual" type.
|
|
13
|
+
*
|
|
14
|
+
* The actual implementations are BucketDataDocumentV1 or BucketDataDocumentV3.
|
|
15
|
+
* They don't fully satisfy this interface, but this works to share common implementations.
|
|
16
|
+
*
|
|
17
|
+
* The idea is that we can have a common implementation between V1 & V3, using this type,
|
|
18
|
+
* and operate on MongoDB collections.
|
|
19
|
+
*
|
|
20
|
+
* This interface serves two primary purposes:
|
|
21
|
+
* 1. Captures properties that exist on both V1 and V3 storage models.
|
|
22
|
+
* 2. Gives a common reference when querying or modifying collections.
|
|
23
|
+
*
|
|
24
|
+
* Generics would've been ideal, but they don't play well with MongoDB collections.
|
|
25
|
+
*/
|
|
26
|
+
export interface BucketDataDocumentGeneric extends BucketDataProperties {
|
|
27
|
+
_id: BucketDataDocumentGenericId;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represent read/write access for a single bucket.
|
|
31
|
+
*
|
|
32
|
+
* This does not implement the actual collection operations, but supports the required conversions
|
|
33
|
+
* between in-memory BucketDataDoc and the specific storage formats.
|
|
34
|
+
*/
|
|
35
|
+
export interface SingleBucketStore {
|
|
36
|
+
readonly key: BucketKey;
|
|
37
|
+
readonly collection: mongo.Collection<BucketDataDocumentGeneric>;
|
|
38
|
+
docId(o: InternalOpId): BucketDataDocumentGenericId;
|
|
39
|
+
readonly minId: BucketDataDocumentGenericId;
|
|
40
|
+
readonly maxId: BucketDataDocumentGenericId;
|
|
41
|
+
/**
|
|
42
|
+
* Convert in-memory document -> persisted document.
|
|
43
|
+
*/
|
|
44
|
+
toPersistedDocument(source: Omit<BucketDataDoc, 'bucketKey'>): BucketDataDocumentGeneric;
|
|
45
|
+
/**
|
|
46
|
+
* Convert persisted document -> in-memory document.
|
|
47
|
+
*/
|
|
48
|
+
fromPersistedDocument(doc: BucketDataDocumentGeneric): BucketDataDoc;
|
|
49
|
+
/**
|
|
50
|
+
* Convert partial persisted document -> partial in-memory document.
|
|
51
|
+
*/
|
|
52
|
+
fromPartialPersistedDocument<T extends keyof BucketDataProperties>(doc: Pick<BucketDataDocumentGeneric, '_id' | T>): Pick<BucketDataDoc, 'bucketKey' | 'o' | T>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleBucketStore.js","sourceRoot":"","sources":["../../../../src/storage/implementation/common/SingleBucketStore.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mongo } from '@powersync/lib-service-mongodb';
|
|
2
|
+
import { Logger } from '@powersync/lib-services-framework';
|
|
3
|
+
import { storage } from '@powersync/service-core';
|
|
4
|
+
import { EvaluatedParameters, EvaluatedRow } from '@powersync/service-sync-rules';
|
|
5
|
+
import * as bson from 'bson';
|
|
6
|
+
import { BucketDefinitionId, ParameterIndexId } from '../BucketDefinitionMapping.js';
|
|
7
|
+
export interface SourceRecordLookupEntry {
|
|
8
|
+
sourceTableId: bson.ObjectId;
|
|
9
|
+
replicaId: storage.ReplicaId;
|
|
10
|
+
}
|
|
11
|
+
export interface SourceRecordBucketState {
|
|
12
|
+
definitionId: BucketDefinitionId | null;
|
|
13
|
+
bucket: string;
|
|
14
|
+
table: string;
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SourceRecordLookupState {
|
|
18
|
+
indexId: ParameterIndexId | null;
|
|
19
|
+
lookup: bson.Binary;
|
|
20
|
+
}
|
|
21
|
+
export interface LoadedSourceRecord {
|
|
22
|
+
sourceTableId: bson.ObjectId;
|
|
23
|
+
replicaId: storage.ReplicaId;
|
|
24
|
+
data: bson.Binary | null;
|
|
25
|
+
buckets: SourceRecordBucketState[];
|
|
26
|
+
lookups: SourceRecordLookupState[];
|
|
27
|
+
cacheKey: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SourceRecordStore {
|
|
30
|
+
mapEvaluatedBuckets(evaluated: EvaluatedRow[]): SourceRecordBucketState[];
|
|
31
|
+
mapParameterLookups(paramEvaluated: EvaluatedParameters[]): SourceRecordLookupState[];
|
|
32
|
+
loadSizes(session: mongo.ClientSession, entries: SourceRecordLookupEntry[]): Promise<Map<string, number>>;
|
|
33
|
+
loadDocuments(session: mongo.ClientSession, entries: SourceRecordLookupEntry[], idsOnly: boolean): Promise<Map<string, LoadedSourceRecord>>;
|
|
34
|
+
loadTruncateBatch(session: mongo.ClientSession, sourceTableId: bson.ObjectId, limit: number): Promise<LoadedSourceRecord[]>;
|
|
35
|
+
postCommitCleanup(lastCheckpoint: bigint, logger: Logger): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceRecordStore.js","sourceRoot":"","sources":["../../../../src/storage/implementation/common/SourceRecordStore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mongo } from '@powersync/lib-service-mongodb';
|
|
2
|
+
import { DO_NOT_LOG } from '@powersync/lib-services-framework';
|
|
3
|
+
import { PowerSyncMongo } from '../db.js';
|
|
4
|
+
import { CommonSourceTableDocument, StorageConfig } from '../models.js';
|
|
5
|
+
export declare abstract class BaseVersionedPowerSyncMongo {
|
|
6
|
+
protected readonly upstream: PowerSyncMongo;
|
|
7
|
+
readonly client: mongo.MongoClient;
|
|
8
|
+
readonly db: mongo.Db;
|
|
9
|
+
readonly storageConfig: StorageConfig;
|
|
10
|
+
[DO_NOT_LOG]: boolean;
|
|
11
|
+
constructor(upstream: PowerSyncMongo, storageConfig: StorageConfig);
|
|
12
|
+
get bucket_data(): mongo.Collection<import("../v1/models.js").BucketDataDocumentV1>;
|
|
13
|
+
get op_id_sequence(): mongo.Collection<import("../models.js").IdSequenceDocument>;
|
|
14
|
+
get sync_rules(): mongo.Collection<import("../models.js").SyncRuleDocument>;
|
|
15
|
+
get custom_write_checkpoints(): mongo.Collection<import("../models.js").CustomWriteCheckpointDocument>;
|
|
16
|
+
get write_checkpoints(): mongo.Collection<import("../models.js").WriteCheckpointDocument>;
|
|
17
|
+
get instance(): mongo.Collection<import("../models.js").InstanceDocument>;
|
|
18
|
+
get locks(): mongo.Collection<import("@powersync/lib-service-mongodb").Lock>;
|
|
19
|
+
get checkpoint_events(): mongo.Collection<import("../models.js").CheckpointEventDocument>;
|
|
20
|
+
get connection_report_events(): mongo.Collection<import("../models.js").ClientConnectionDocument>;
|
|
21
|
+
notifyCheckpoint(): Promise<void>;
|
|
22
|
+
protected sourceRecordsCollectionName(replicationStreamId: number, sourceTableId: mongo.ObjectId): string;
|
|
23
|
+
protected sourceTableCollectionName(replicationStreamId: number): string;
|
|
24
|
+
protected listCollectionsByPrefix<T extends mongo.Document>(prefix: string): Promise<mongo.Collection<T>[]>;
|
|
25
|
+
abstract commonSourceTables(replicationStreamId: number): mongo.Collection<CommonSourceTableDocument>;
|
|
26
|
+
abstract initializeStreamStorage(replicationStreamId: number): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DO_NOT_LOG } from '@powersync/lib-services-framework';
|
|
2
|
+
export class BaseVersionedPowerSyncMongo {
|
|
3
|
+
upstream;
|
|
4
|
+
client;
|
|
5
|
+
db;
|
|
6
|
+
storageConfig;
|
|
7
|
+
[DO_NOT_LOG] = true;
|
|
8
|
+
constructor(upstream, storageConfig) {
|
|
9
|
+
this.upstream = upstream;
|
|
10
|
+
this.client = upstream.client;
|
|
11
|
+
this.db = upstream.db;
|
|
12
|
+
this.storageConfig = storageConfig;
|
|
13
|
+
}
|
|
14
|
+
get bucket_data() {
|
|
15
|
+
return this.upstream.bucket_data;
|
|
16
|
+
}
|
|
17
|
+
get op_id_sequence() {
|
|
18
|
+
return this.upstream.op_id_sequence;
|
|
19
|
+
}
|
|
20
|
+
get sync_rules() {
|
|
21
|
+
return this.upstream.sync_rules;
|
|
22
|
+
}
|
|
23
|
+
get custom_write_checkpoints() {
|
|
24
|
+
return this.upstream.custom_write_checkpoints;
|
|
25
|
+
}
|
|
26
|
+
get write_checkpoints() {
|
|
27
|
+
return this.upstream.write_checkpoints;
|
|
28
|
+
}
|
|
29
|
+
get instance() {
|
|
30
|
+
return this.upstream.instance;
|
|
31
|
+
}
|
|
32
|
+
get locks() {
|
|
33
|
+
return this.upstream.locks;
|
|
34
|
+
}
|
|
35
|
+
get checkpoint_events() {
|
|
36
|
+
return this.upstream.checkpoint_events;
|
|
37
|
+
}
|
|
38
|
+
get connection_report_events() {
|
|
39
|
+
return this.upstream.connection_report_events;
|
|
40
|
+
}
|
|
41
|
+
notifyCheckpoint() {
|
|
42
|
+
return this.upstream.notifyCheckpoint();
|
|
43
|
+
}
|
|
44
|
+
sourceRecordsCollectionName(replicationStreamId, sourceTableId) {
|
|
45
|
+
return this.upstream.sourceRecordsCollectionName(replicationStreamId, sourceTableId);
|
|
46
|
+
}
|
|
47
|
+
sourceTableCollectionName(replicationStreamId) {
|
|
48
|
+
return this.upstream.sourceTableCollectionName(replicationStreamId);
|
|
49
|
+
}
|
|
50
|
+
async listCollectionsByPrefix(prefix) {
|
|
51
|
+
const collections = await this.db.listCollections({ name: new RegExp(`^${prefix}`) }, { nameOnly: true }).toArray();
|
|
52
|
+
return collections
|
|
53
|
+
.filter((collection) => collection.name.startsWith(prefix))
|
|
54
|
+
.map((collection) => this.db.collection(collection.name));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=VersionedPowerSyncMongoBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VersionedPowerSyncMongoBase.js","sourceRoot":"","sources":["../../../../src/storage/implementation/common/VersionedPowerSyncMongoBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAA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O,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IACvF,CAAC;IAES,yBAAyB,CAAC,mBAA2B;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IACtE,CAAC;IAES,KAAK,CAAC,uBAAuB,CAA2B,MAAc;QAC9E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAEpH,OAAO,WAAW;aACf,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC1D,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;CAKF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { storage } from '@powersync/service-core';
|
|
2
|
+
import { MongoBucketStorage } from '../MongoBucketStorage.js';
|
|
3
|
+
import { MongoPersistedSyncRulesContent } from './MongoPersistedSyncRulesContent.js';
|
|
4
|
+
import { MongoSyncBucketStorage, MongoSyncBucketStorageOptions } from './MongoSyncBucketStorage.js';
|
|
5
|
+
export { MongoSyncBucketStorageOptions } from './MongoSyncBucketStorage.js';
|
|
6
|
+
export type { MongoSyncBucketStorage };
|
|
7
|
+
export declare function createMongoSyncBucketStorage(factory: MongoBucketStorage, group_id: number, sync_rules: MongoPersistedSyncRulesContent, slot_name: string, writeCheckpointMode: storage.WriteCheckpointMode | undefined, options: MongoSyncBucketStorageOptions): MongoSyncBucketStorage;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MongoSyncBucketStorageV1 } from './v1/MongoSyncBucketStorageV1.js';
|
|
2
|
+
import { MongoSyncBucketStorageV3 } from './v3/MongoSyncBucketStorageV3.js';
|
|
3
|
+
export function createMongoSyncBucketStorage(factory, group_id, sync_rules, slot_name, writeCheckpointMode, options) {
|
|
4
|
+
if (sync_rules.getStorageConfig().incrementalReprocessing) {
|
|
5
|
+
return new MongoSyncBucketStorageV3(factory, group_id, sync_rules, slot_name, writeCheckpointMode, options);
|
|
6
|
+
}
|
|
7
|
+
return new MongoSyncBucketStorageV1(factory, group_id, sync_rules, slot_name, writeCheckpointMode, options);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=createMongoSyncBucketStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMongoSyncBucketStorage.js","sourceRoot":"","sources":["../../../src/storage/implementation/createMongoSyncBucketStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAM5E,MAAM,UAAU,4BAA4B,CAC1C,OAA2B,EAC3B,QAAgB,EAChB,UAA0C,EAC1C,SAAiB,EACjB,mBAA4D,EAC5D,OAAsC;IAEtC,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,CAAC;QAC1D,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IAC9G,CAAC;IAED,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAC9G,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as lib_mongo from '@powersync/lib-service-mongodb';
|
|
2
2
|
import { mongo } from '@powersync/lib-service-mongodb';
|
|
3
|
+
import { DO_NOT_LOG } from '@powersync/lib-services-framework';
|
|
3
4
|
import { MongoStorageConfig } from '../../types/types.js';
|
|
4
|
-
import {
|
|
5
|
+
import { BaseVersionedPowerSyncMongo } from './common/VersionedPowerSyncMongoBase.js';
|
|
6
|
+
import { CheckpointEventDocument, ClientConnectionDocument, CommonSourceTableDocument, CustomWriteCheckpointDocument, IdSequenceDocument, InstanceDocument, SourceTableDocument, StorageConfig, SyncRuleDocument, WriteCheckpointDocument } from './models.js';
|
|
7
|
+
import { BucketDataDocumentV1, BucketParameterDocument, BucketStateDocumentV1, CurrentDataDocument } from './v1/models.js';
|
|
8
|
+
import { BucketDataDocumentV3 } from './v3/models.js';
|
|
5
9
|
export interface PowerSyncMongoOptions {
|
|
6
10
|
/**
|
|
7
11
|
* Optional - uses the database from the MongoClient connection URI if not specified.
|
|
@@ -9,9 +13,9 @@ export interface PowerSyncMongoOptions {
|
|
|
9
13
|
database?: string;
|
|
10
14
|
}
|
|
11
15
|
export declare class PowerSyncMongo {
|
|
16
|
+
[DO_NOT_LOG]: boolean;
|
|
12
17
|
readonly current_data: mongo.Collection<CurrentDataDocument>;
|
|
13
|
-
readonly
|
|
14
|
-
readonly bucket_data: mongo.Collection<BucketDataDocument>;
|
|
18
|
+
readonly bucket_data: mongo.Collection<BucketDataDocumentV1>;
|
|
15
19
|
readonly bucket_parameters: mongo.Collection<BucketParameterDocument>;
|
|
16
20
|
readonly op_id_sequence: mongo.Collection<IdSequenceDocument>;
|
|
17
21
|
readonly sync_rules: mongo.Collection<SyncRuleDocument>;
|
|
@@ -20,13 +24,37 @@ export declare class PowerSyncMongo {
|
|
|
20
24
|
readonly write_checkpoints: mongo.Collection<WriteCheckpointDocument>;
|
|
21
25
|
readonly instance: mongo.Collection<InstanceDocument>;
|
|
22
26
|
readonly locks: mongo.Collection<lib_mongo.locks.Lock>;
|
|
23
|
-
readonly bucket_state: mongo.Collection<
|
|
27
|
+
readonly bucket_state: mongo.Collection<BucketStateDocumentV1>;
|
|
24
28
|
readonly checkpoint_events: mongo.Collection<CheckpointEventDocument>;
|
|
25
29
|
readonly connection_report_events: mongo.Collection<ClientConnectionDocument>;
|
|
26
30
|
readonly client: mongo.MongoClient;
|
|
27
31
|
readonly db: mongo.Db;
|
|
28
32
|
constructor(client: mongo.MongoClient, options?: PowerSyncMongoOptions);
|
|
29
33
|
versioned(storageConfig: StorageConfig): VersionedPowerSyncMongo;
|
|
34
|
+
/**
|
|
35
|
+
* Not safe for user-provided prefix - only for hardcoded values.
|
|
36
|
+
*/
|
|
37
|
+
listBucketDataCollectionsV3(groupId?: number): Promise<mongo.Collection<BucketDataDocumentV3>[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Not safe for user-provided prefix - only for hardcoded values.
|
|
40
|
+
*/
|
|
41
|
+
private collectionsByPrefix;
|
|
42
|
+
/**
|
|
43
|
+
* List all parameter index collections across all replication streams.
|
|
44
|
+
*
|
|
45
|
+
* Primarily used to clear the db.
|
|
46
|
+
*/
|
|
47
|
+
listAllParameterIndexCollectionsV3(): Promise<mongo.Collection<never>[]>;
|
|
48
|
+
/**
|
|
49
|
+
* List all parameter index collections across all replication streams.
|
|
50
|
+
*
|
|
51
|
+
* Primarily used to clear the db.
|
|
52
|
+
*/
|
|
53
|
+
listAllSourceRecordCollectionsV3(): Promise<mongo.Collection<never>[]>;
|
|
54
|
+
listAllBucketStateCollectionsV3(): Promise<mongo.Collection<never>[]>;
|
|
55
|
+
sourceRecordsCollectionName(replicationStreamId: number, sourceTableId: mongo.ObjectId): string;
|
|
56
|
+
sourceTableCollectionName(replicationStreamId: number): string;
|
|
57
|
+
listSourceTableCollections(replicationStreamId?: number): Promise<mongo.Collection<CommonSourceTableDocument>[]>;
|
|
30
58
|
/**
|
|
31
59
|
* Clear all collections.
|
|
32
60
|
*/
|
|
@@ -38,7 +66,7 @@ export declare class PowerSyncMongo {
|
|
|
38
66
|
*/
|
|
39
67
|
drop(): Promise<void>;
|
|
40
68
|
/**
|
|
41
|
-
* Call this after every checkpoint or
|
|
69
|
+
* Call this after every checkpoint or replication stream status update. Rather call too often than too rarely.
|
|
42
70
|
*
|
|
43
71
|
* This is used in a similar way to the Postgres NOTIFY functionality.
|
|
44
72
|
*/
|
|
@@ -59,37 +87,9 @@ export declare class PowerSyncMongo {
|
|
|
59
87
|
* Only use in migrations and tests.
|
|
60
88
|
*/
|
|
61
89
|
createBucketStateIndex2(): Promise<void>;
|
|
62
|
-
initializeStorageVersion(storageConfig: StorageConfig): Promise<void>;
|
|
63
90
|
}
|
|
64
91
|
/**
|
|
65
92
|
* This is similar to PowerSyncMongo, but blocks access to certain collections based on the storage version.
|
|
66
93
|
*/
|
|
67
|
-
export
|
|
68
|
-
#private;
|
|
69
|
-
readonly client: mongo.MongoClient;
|
|
70
|
-
readonly db: mongo.Db;
|
|
71
|
-
readonly storageConfig: StorageConfig;
|
|
72
|
-
constructor(upstream: PowerSyncMongo, storageConfig: StorageConfig);
|
|
73
|
-
/**
|
|
74
|
-
* Uses either `current_data` or `v3_current_data` collection based on the storage version.
|
|
75
|
-
*
|
|
76
|
-
* Use in places where it does not matter which version is used.
|
|
77
|
-
*/
|
|
78
|
-
get common_current_data(): mongo.Collection<CurrentDataDocument>;
|
|
79
|
-
get v1_current_data(): lib_mongo.mongo.Collection<CurrentDataDocument>;
|
|
80
|
-
get v3_current_data(): lib_mongo.mongo.Collection<CurrentDataDocumentV3>;
|
|
81
|
-
get bucket_data(): lib_mongo.mongo.Collection<BucketDataDocument>;
|
|
82
|
-
get bucket_parameters(): lib_mongo.mongo.Collection<BucketParameterDocument>;
|
|
83
|
-
get op_id_sequence(): lib_mongo.mongo.Collection<IdSequenceDocument>;
|
|
84
|
-
get sync_rules(): lib_mongo.mongo.Collection<SyncRuleDocument>;
|
|
85
|
-
get source_tables(): lib_mongo.mongo.Collection<SourceTableDocument>;
|
|
86
|
-
get custom_write_checkpoints(): lib_mongo.mongo.Collection<CustomWriteCheckpointDocument>;
|
|
87
|
-
get write_checkpoints(): lib_mongo.mongo.Collection<WriteCheckpointDocument>;
|
|
88
|
-
get instance(): lib_mongo.mongo.Collection<InstanceDocument>;
|
|
89
|
-
get locks(): lib_mongo.mongo.Collection<lib_mongo.Lock>;
|
|
90
|
-
get bucket_state(): lib_mongo.mongo.Collection<BucketStateDocument>;
|
|
91
|
-
get checkpoint_events(): lib_mongo.mongo.Collection<CheckpointEventDocument>;
|
|
92
|
-
get connection_report_events(): lib_mongo.mongo.Collection<ClientConnectionDocument>;
|
|
93
|
-
notifyCheckpoint(): Promise<void>;
|
|
94
|
-
}
|
|
94
|
+
export type VersionedPowerSyncMongo = BaseVersionedPowerSyncMongo;
|
|
95
95
|
export declare function createPowerSyncMongo(config: MongoStorageConfig, options?: lib_mongo.MongoConnectionOptions): PowerSyncMongo;
|