@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.
Files changed (33) hide show
  1. package/CHANGELOG.md +5 -5
  2. package/dist/api/MongoRouteAPIAdapter.d.ts +2 -2
  3. package/dist/api/MongoRouteAPIAdapter.js +1 -1
  4. package/dist/api/MongoRouteAPIAdapter.js.map +1 -1
  5. package/dist/index.d.ts +1 -3
  6. package/dist/index.js +1 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/module/MongoModule.d.ts +1 -0
  9. package/dist/module/MongoModule.js +13 -0
  10. package/dist/module/MongoModule.js.map +1 -1
  11. package/dist/replication/ChangeStream.js +6 -6
  12. package/dist/replication/ChangeStream.js.map +1 -1
  13. package/dist/replication/ChangeStreamReplicationJob.d.ts +0 -1
  14. package/dist/replication/ChangeStreamReplicationJob.js +0 -1
  15. package/dist/replication/ChangeStreamReplicationJob.js.map +1 -1
  16. package/dist/replication/ChangeStreamReplicator.d.ts +2 -2
  17. package/dist/replication/ChangeStreamReplicator.js.map +1 -1
  18. package/dist/replication/replication-utils.d.ts +2 -0
  19. package/dist/replication/replication-utils.js +11 -0
  20. package/dist/replication/replication-utils.js.map +1 -0
  21. package/dist/types/types.js +1 -1
  22. package/package.json +7 -7
  23. package/src/api/MongoRouteAPIAdapter.ts +2 -2
  24. package/src/index.ts +1 -5
  25. package/src/module/MongoModule.ts +13 -0
  26. package/src/replication/ChangeStream.ts +7 -7
  27. package/src/replication/ChangeStreamReplicationJob.ts +0 -3
  28. package/src/replication/ChangeStreamReplicator.ts +2 -2
  29. package/src/replication/replication-utils.ts +12 -0
  30. package/src/types/types.ts +1 -1
  31. package/test/src/change_stream.test.ts +12 -12
  32. package/test/src/change_stream_utils.ts +2 -2
  33. 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 { walStreamTest } from './change_stream_utils.js';
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
- defineWalStreamTests(MONGO_STORAGE_FACTORY);
22
+ defineChangeStreamTests(MONGO_STORAGE_FACTORY);
23
23
  },
24
24
  { timeout: 20_000 }
25
25
  );
26
26
 
27
- function defineWalStreamTests(factory: StorageFactory) {
27
+ function defineChangeStreamTests(factory: StorageFactory) {
28
28
  test(
29
29
  'replicating basic values',
30
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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
- walStreamTest(factory, async (context) => {
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 wal stream need to configure the stream and manage asynchronous
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 walStreamTest(
16
+ export function changeStreamTest(
17
17
  factory: () => Promise<BucketStorageFactory>,
18
18
  test: (context: ChangeStreamTestContext) => Promise<void>
19
19
  ): () => Promise<void> {