@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.
@@ -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, SourceTable } from '@powersync/service-core';
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 sourceTable = new SourceTable({
141
- id: '', // not used
140
+ const ref: sync_rules.SourceTableRef = {
142
141
  connectionTag: this.connectionTag,
143
- objectId: collection.name,
144
- schema: schema,
145
- name: collection.name,
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(sourceTable);
156
- const syncParameters = sqlSyncRules.tableSyncsParameters(sourceTable);
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 sourceTable = new SourceTable({
168
- id: '', // not used
163
+ const ref: sync_rules.SourceTableRef = {
169
164
  connectionTag: this.connectionTag,
170
- objectId: tablePattern.name,
171
- schema: schema,
172
- name: tablePattern.name,
173
- replicaIdColumns: [],
174
- snapshotComplete: true
175
- });
165
+ schema,
166
+ name: tablePattern.name
167
+ };
176
168
 
177
- const syncData = sqlSyncRules.tableSyncsData(sourceTable);
178
- const syncParameters = sqlSyncRules.tableSyncsParameters(sourceTable);
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[] = [];