@powersync/service-module-mongodb 0.0.0-dev-20241022111143 → 0.0.0-dev-20241023230541
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 +5 -5
- package/dist/api/MongoRouteAPIAdapter.d.ts +2 -2
- package/dist/api/MongoRouteAPIAdapter.js +1 -1
- package/dist/api/MongoRouteAPIAdapter.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/module/MongoModule.d.ts +1 -0
- package/dist/module/MongoModule.js +13 -0
- package/dist/module/MongoModule.js.map +1 -1
- package/dist/replication/ChangeStream.js +6 -6
- package/dist/replication/ChangeStream.js.map +1 -1
- package/dist/replication/ChangeStreamReplicationJob.d.ts +0 -1
- package/dist/replication/ChangeStreamReplicationJob.js +0 -1
- package/dist/replication/ChangeStreamReplicationJob.js.map +1 -1
- package/dist/replication/ChangeStreamReplicator.d.ts +2 -2
- package/dist/replication/ChangeStreamReplicator.js.map +1 -1
- package/dist/replication/replication-utils.d.ts +2 -0
- package/dist/replication/replication-utils.js +11 -0
- package/dist/replication/replication-utils.js.map +1 -0
- package/dist/types/types.js +1 -1
- package/package.json +7 -7
- package/src/api/MongoRouteAPIAdapter.ts +2 -2
- package/src/index.ts +1 -5
- package/src/module/MongoModule.ts +13 -0
- package/src/replication/ChangeStream.ts +7 -7
- package/src/replication/ChangeStreamReplicationJob.ts +0 -3
- package/src/replication/ChangeStreamReplicator.ts +2 -2
- package/src/replication/replication-utils.ts +12 -0
- package/src/types/types.ts +1 -1
- package/test/src/change_stream.test.ts +12 -12
- package/test/src/change_stream_utils.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,7 +3,7 @@ import { MONGO_STORAGE_FACTORY } from '@core-tests/util.js';
|
|
|
3
3
|
import { BucketStorageFactory } from '@powersync/service-core';
|
|
4
4
|
import * as crypto from 'crypto';
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
|
-
import {
|
|
6
|
+
import { changeStreamTest } from './change_stream_utils.js';
|
|
7
7
|
import * as mongo from 'mongodb';
|
|
8
8
|
import { setTimeout } from 'node:timers/promises';
|
|
9
9
|
|
|
@@ -19,15 +19,15 @@ bucket_definitions:
|
|
|
19
19
|
describe(
|
|
20
20
|
'change stream - mongodb',
|
|
21
21
|
function () {
|
|
22
|
-
|
|
22
|
+
defineChangeStreamTests(MONGO_STORAGE_FACTORY);
|
|
23
23
|
},
|
|
24
24
|
{ timeout: 20_000 }
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
function
|
|
27
|
+
function defineChangeStreamTests(factory: StorageFactory) {
|
|
28
28
|
test(
|
|
29
29
|
'replicating basic values',
|
|
30
|
-
|
|
30
|
+
changeStreamTest(factory, async (context) => {
|
|
31
31
|
const { db } = context;
|
|
32
32
|
await context.updateSyncRules(`
|
|
33
33
|
bucket_definitions:
|
|
@@ -66,7 +66,7 @@ bucket_definitions:
|
|
|
66
66
|
|
|
67
67
|
test(
|
|
68
68
|
'no fullDocument available',
|
|
69
|
-
|
|
69
|
+
changeStreamTest(factory, async (context) => {
|
|
70
70
|
const { db, client } = context;
|
|
71
71
|
await context.updateSyncRules(`
|
|
72
72
|
bucket_definitions:
|
|
@@ -111,7 +111,7 @@ bucket_definitions:
|
|
|
111
111
|
|
|
112
112
|
test(
|
|
113
113
|
'replicating case sensitive table',
|
|
114
|
-
|
|
114
|
+
changeStreamTest(factory, async (context) => {
|
|
115
115
|
const { db } = context;
|
|
116
116
|
await context.updateSyncRules(`
|
|
117
117
|
bucket_definitions:
|
|
@@ -136,7 +136,7 @@ bucket_definitions:
|
|
|
136
136
|
|
|
137
137
|
test(
|
|
138
138
|
'replicating large values',
|
|
139
|
-
|
|
139
|
+
changeStreamTest(factory, async (context) => {
|
|
140
140
|
const { db } = context;
|
|
141
141
|
await context.updateSyncRules(`
|
|
142
142
|
bucket_definitions:
|
|
@@ -168,7 +168,7 @@ bucket_definitions:
|
|
|
168
168
|
|
|
169
169
|
test(
|
|
170
170
|
'replicating dropCollection',
|
|
171
|
-
|
|
171
|
+
changeStreamTest(factory, async (context) => {
|
|
172
172
|
const { db } = context;
|
|
173
173
|
const syncRuleContent = `
|
|
174
174
|
bucket_definitions:
|
|
@@ -200,7 +200,7 @@ bucket_definitions:
|
|
|
200
200
|
|
|
201
201
|
test(
|
|
202
202
|
'replicating renameCollection',
|
|
203
|
-
|
|
203
|
+
changeStreamTest(factory, async (context) => {
|
|
204
204
|
const { db } = context;
|
|
205
205
|
const syncRuleContent = `
|
|
206
206
|
bucket_definitions:
|
|
@@ -232,7 +232,7 @@ bucket_definitions:
|
|
|
232
232
|
|
|
233
233
|
test(
|
|
234
234
|
'initial sync',
|
|
235
|
-
|
|
235
|
+
changeStreamTest(factory, async (context) => {
|
|
236
236
|
const { db } = context;
|
|
237
237
|
await context.updateSyncRules(BASIC_SYNC_RULES);
|
|
238
238
|
|
|
@@ -251,7 +251,7 @@ bucket_definitions:
|
|
|
251
251
|
// Not correctly implemented yet
|
|
252
252
|
test.skip(
|
|
253
253
|
'large record',
|
|
254
|
-
|
|
254
|
+
changeStreamTest(factory, async (context) => {
|
|
255
255
|
await context.updateSyncRules(`bucket_definitions:
|
|
256
256
|
global:
|
|
257
257
|
data:
|
|
@@ -287,7 +287,7 @@ bucket_definitions:
|
|
|
287
287
|
|
|
288
288
|
test(
|
|
289
289
|
'table not in sync rules',
|
|
290
|
-
|
|
290
|
+
changeStreamTest(factory, async (context) => {
|
|
291
291
|
const { db } = context;
|
|
292
292
|
await context.updateSyncRules(BASIC_SYNC_RULES);
|
|
293
293
|
|
|
@@ -8,12 +8,12 @@ import * as mongo from 'mongodb';
|
|
|
8
8
|
import { createCheckpoint } from '@module/replication/MongoRelation.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Tests operating on the
|
|
11
|
+
* Tests operating on the mongo change stream need to configure the stream and manage asynchronous
|
|
12
12
|
* replication, which gets a little tricky.
|
|
13
13
|
*
|
|
14
14
|
* This wraps a test in a function that configures all the context, and tears it down afterwards.
|
|
15
15
|
*/
|
|
16
|
-
export function
|
|
16
|
+
export function changeStreamTest(
|
|
17
17
|
factory: () => Promise<BucketStorageFactory>,
|
|
18
18
|
test: (context: ChangeStreamTestContext) => Promise<void>
|
|
19
19
|
): () => Promise<void> {
|