@powersync/service-module-mongodb 0.16.0 → 0.17.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 +33 -0
- package/dist/api/MongoRouteAPIAdapter.js +12 -21
- package/dist/api/MongoRouteAPIAdapter.js.map +1 -1
- package/dist/replication/ChangeStream.d.ts +18 -37
- package/dist/replication/ChangeStream.js +136 -351
- package/dist/replication/ChangeStream.js.map +1 -1
- package/dist/replication/MongoRelation.d.ts +1 -1
- package/dist/replication/MongoRelation.js +41 -21
- package/dist/replication/MongoRelation.js.map +1 -1
- package/dist/replication/MongoSnapshotter.d.ts +81 -0
- package/dist/replication/MongoSnapshotter.js +594 -0
- package/dist/replication/MongoSnapshotter.js.map +1 -0
- package/package.json +8 -8
- package/src/api/MongoRouteAPIAdapter.ts +13 -21
- package/src/replication/ChangeStream.ts +150 -426
- package/src/replication/MongoRelation.ts +51 -25
- package/src/replication/MongoSnapshotter.ts +729 -0
- package/test/src/change_stream.test.ts +210 -17
- package/test/src/change_stream_utils.ts +24 -17
- package/test/src/checkpoint_retry.test.ts +131 -0
- package/test/src/resuming_snapshots.test.ts +10 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as lib_mongo from '@powersync/lib-service-mongodb';
|
|
2
2
|
import { mongo } from '@powersync/lib-service-mongodb';
|
|
3
|
-
import { api, ParseSyncRulesOptions, ReplicationHeadCallback
|
|
3
|
+
import { api, ParseSyncRulesOptions, ReplicationHeadCallback } from '@powersync/service-core';
|
|
4
4
|
import * as sync_rules from '@powersync/service-sync-rules';
|
|
5
5
|
import * as service_types from '@powersync/service-types';
|
|
6
6
|
|
|
@@ -137,23 +137,19 @@ export class MongoRouteAPIAdapter implements api.RouteAPI {
|
|
|
137
137
|
if (tablePattern.isWildcard) {
|
|
138
138
|
patternResult.tables = [];
|
|
139
139
|
for (let collection of collections) {
|
|
140
|
-
const
|
|
141
|
-
id: '', // not used
|
|
140
|
+
const ref: sync_rules.SourceTableRef = {
|
|
142
141
|
connectionTag: this.connectionTag,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
replicaIdColumns: [],
|
|
147
|
-
snapshotComplete: true
|
|
148
|
-
});
|
|
142
|
+
schema,
|
|
143
|
+
name: collection.name
|
|
144
|
+
};
|
|
149
145
|
let errors: service_types.ReplicationError[] = [];
|
|
150
146
|
if (collection.type == 'view') {
|
|
151
147
|
errors.push({ level: 'warning', message: `Collection ${schema}.${tablePattern.name} is a view` });
|
|
152
148
|
} else {
|
|
153
149
|
errors.push(...validatePostImages(schema, collection));
|
|
154
150
|
}
|
|
155
|
-
const syncData = sqlSyncRules.tableSyncsData(
|
|
156
|
-
const syncParameters = sqlSyncRules.tableSyncsParameters(
|
|
151
|
+
const syncData = sqlSyncRules.tableSyncsData(ref);
|
|
152
|
+
const syncParameters = sqlSyncRules.tableSyncsParameters(ref);
|
|
157
153
|
patternResult.tables.push({
|
|
158
154
|
schema,
|
|
159
155
|
name: collection.name,
|
|
@@ -164,18 +160,14 @@ export class MongoRouteAPIAdapter implements api.RouteAPI {
|
|
|
164
160
|
});
|
|
165
161
|
}
|
|
166
162
|
} else {
|
|
167
|
-
const
|
|
168
|
-
id: '', // not used
|
|
163
|
+
const ref: sync_rules.SourceTableRef = {
|
|
169
164
|
connectionTag: this.connectionTag,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
replicaIdColumns: [],
|
|
174
|
-
snapshotComplete: true
|
|
175
|
-
});
|
|
165
|
+
schema,
|
|
166
|
+
name: tablePattern.name
|
|
167
|
+
};
|
|
176
168
|
|
|
177
|
-
const syncData = sqlSyncRules.tableSyncsData(
|
|
178
|
-
const syncParameters = sqlSyncRules.tableSyncsParameters(
|
|
169
|
+
const syncData = sqlSyncRules.tableSyncsData(ref);
|
|
170
|
+
const syncParameters = sqlSyncRules.tableSyncsParameters(ref);
|
|
179
171
|
const collection = collections[0];
|
|
180
172
|
|
|
181
173
|
let errors: service_types.ReplicationError[] = [];
|