@powersync/service-module-mongodb 0.0.0-dev-20250110114939 → 0.0.0-dev-20250117095455

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 CHANGED
@@ -1,15 +1,42 @@
1
1
  # @powersync/service-module-mongodb
2
2
 
3
- ## 0.0.0-dev-20250110114939
3
+ ## 0.0.0-dev-20250117095455
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - c6401d6: Shared MongoDB dependency between modules. This should help avoid potential multiple versions of MongoDB being present in a project.
7
+ - b07189d: Allow limiting IP ranges of outgoing connections
8
8
 
9
9
  ### Patch Changes
10
10
 
11
- - Updated dependencies [c6401d6]
12
- - @powersync/lib-service-mongodb@0.0.0-dev-20250110114939
11
+ - Updated dependencies [b07189d]
12
+ - Updated dependencies [b07189d]
13
+ - Updated dependencies [b07189d]
14
+ - @powersync/service-core@0.0.0-dev-20250117095455
15
+ - @powersync/service-types@0.0.0-dev-20250117095455
16
+ - @powersync/lib-services-framework@0.0.0-dev-20250117095455
17
+ - @powersync/lib-service-mongodb@0.0.0-dev-20250117095455
18
+
19
+ ## 0.3.1
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [9d9ff08]
24
+ - Updated dependencies [9d9ff08]
25
+ - Updated dependencies [9d9ff08]
26
+ - @powersync/service-core@0.15.0
27
+ - @powersync/lib-services-framework@0.4.0
28
+ - @powersync/lib-service-mongodb@0.3.1
29
+
30
+ ## 0.3.0
31
+
32
+ ### Minor Changes
33
+
34
+ - 9709b2d: Shared MongoDB dependency between modules. This should help avoid potential multiple versions of MongoDB being present in a project.
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [9709b2d]
39
+ - @powersync/lib-service-mongodb@0.3.0
13
40
 
14
41
  ## 0.2.0
15
42
 
@@ -8,6 +8,7 @@ export class MongoManager {
8
8
  username: options.username,
9
9
  password: options.password
10
10
  },
11
+ lookup: options.lookup,
11
12
  // Time for connection to timeout
12
13
  connectTimeoutMS: 5000,
13
14
  // Time for individual requests to timeout
@@ -1 +1 @@
1
- {"version":3,"file":"MongoManager.js","sourceRoot":"","sources":["../../src/replication/MongoManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAIvD,MAAM,OAAO,YAAY;IAOvB,YACS,OAAwC,EAC/C,SAAoC;QAD7B,YAAO,GAAP,OAAO,CAAiC;QAG/C,2EAA2E;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE;YAC/C,IAAI,EAAE;gBACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B;YACD,iCAAiC;YACjC,gBAAgB,EAAE,IAAK;YACvB,0CAA0C;YAC1C,eAAe,EAAE,KAAM;YACvB,6CAA6C;YAC7C,wBAAwB,EAAE,KAAM;YAEhC,8BAA8B;YAC9B,2CAA2C;YAC3C,yFAAyF;YACzF,WAAW,EAAE,CAAC;YAEd,aAAa,EAAE,CAAC;YAChB,aAAa,EAAE,KAAM;YACrB,GAAG,SAAS;SACb,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,mBAAmB;IACrB,CAAC;CACF"}
1
+ {"version":3,"file":"MongoManager.js","sourceRoot":"","sources":["../../src/replication/MongoManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAIvD,MAAM,OAAO,YAAY;IAOvB,YACS,OAAwC,EAC/C,SAAoC;QAD7B,YAAO,GAAP,OAAO,CAAiC;QAG/C,2EAA2E;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE;YAC/C,IAAI,EAAE;gBACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B;YAED,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,iCAAiC;YACjC,gBAAgB,EAAE,IAAK;YACvB,0CAA0C;YAC1C,eAAe,EAAE,KAAM;YACvB,6CAA6C;YAC7C,wBAAwB,EAAE,KAAM;YAEhC,8BAA8B;YAC9B,2CAA2C;YAC3C,yFAAyF;YACzF,WAAW,EAAE,CAAC;YAEd,aAAa,EAAE,CAAC;YAChB,aAAa,EAAE,KAAM;YACrB,GAAG,SAAS;SACb,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,mBAAmB;IACrB,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
+ import { LookupFunction } from 'node:net';
1
2
  import * as t from 'ts-codec';
2
3
  export declare enum PostImagesOption {
3
4
  /**
@@ -39,6 +40,7 @@ export interface NormalizedMongoConnectionConfig {
39
40
  database: string;
40
41
  username?: string;
41
42
  password?: string;
43
+ lookup?: LookupFunction;
42
44
  postImages: PostImagesOption;
43
45
  }
44
46
  export declare const MongoConnectionConfig: t.Intersection<t.Codec<{
@@ -47,6 +49,7 @@ export declare const MongoConnectionConfig: t.Intersection<t.Codec<{
47
49
  database?: string | undefined;
48
50
  username?: string | undefined;
49
51
  password?: string | undefined;
52
+ reject_ip_ranges?: string[] | undefined;
50
53
  } & {
51
54
  type: string;
52
55
  id?: string | undefined;
@@ -58,6 +61,7 @@ export declare const MongoConnectionConfig: t.Intersection<t.Codec<{
58
61
  database?: string | undefined;
59
62
  username?: string | undefined;
60
63
  password?: string | undefined;
64
+ reject_ip_ranges?: string[] | undefined;
61
65
  } & {
62
66
  type: string;
63
67
  id?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAN,IAAY,gBAkCX;AAlCD,WAAY,gBAAgB;IAC1B;;;;;;;OAOG;IACH,+BAAW,CAAA;IAEX;;;;;;;OAOG;IACH,qDAAiC,CAAA;IAEjC;;;;;;;;;;;OAWG;IACH,2CAAuB,CAAA;AACzB,CAAC,EAlCW,gBAAgB,KAAhB,gBAAgB,QAkC3B;AAeD,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAC/G,CAAC,CAAC,MAAM,CAAC;IACP,gCAAgC;IAChC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE;CACpG,CAAC,CACH,CAAC;AAaF;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,OA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IAErD,OAAO;QACL,GAAG,IAAI;QACP,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,SAAS;QAC3B,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,SAAS;QAC7B,UAAU,EAAG,OAAO,CAAC,WAA4C,IAAI,gBAAgB,CAAC,GAAG;KAC1F,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@powersync/service-module-mongodb",
3
3
  "repository": "https://github.com/powersync-ja/powersync-service",
4
4
  "types": "dist/index.d.ts",
5
- "version": "0.0.0-dev-20250110114939",
5
+ "version": "0.0.0-dev-20250117095455",
6
6
  "main": "dist/index.js",
7
7
  "license": "FSL-1.1-Apache-2.0",
8
8
  "type": "module",
@@ -25,17 +25,18 @@
25
25
  "bson": "^6.8.0",
26
26
  "ts-codec": "^1.3.0",
27
27
  "uuid": "^9.0.1",
28
- "@powersync/lib-services-framework": "0.3.0",
29
- "@powersync/service-core": "0.14.0",
28
+ "@powersync/lib-services-framework": "0.0.0-dev-20250117095455",
29
+ "@powersync/service-core": "0.0.0-dev-20250117095455",
30
30
  "@powersync/service-jsonbig": "0.17.10",
31
31
  "@powersync/service-sync-rules": "0.23.1",
32
- "@powersync/service-types": "0.7.0",
33
- "@powersync/lib-service-mongodb": "0.0.0-dev-20250110114939"
32
+ "@powersync/service-types": "0.0.0-dev-20250117095455",
33
+ "@powersync/lib-service-mongodb": "0.0.0-dev-20250117095455"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/uuid": "^9.0.4",
37
- "@powersync/service-module-mongodb-storage": "0.0.0-dev-20250110114939",
38
- "@powersync/service-core-tests": "0.2.0"
37
+ "@powersync/service-core-tests": "0.0.0-dev-20250117095455",
38
+ "@powersync/service-module-mongodb-storage": "0.0.0-dev-20250117095455",
39
+ "@powersync/service-module-postgres-storage": "0.0.0-dev-20250117095455"
39
40
  },
40
41
  "scripts": {
41
42
  "build": "tsc -b",
@@ -19,6 +19,8 @@ export class MongoManager {
19
19
  username: options.username,
20
20
  password: options.password
21
21
  },
22
+
23
+ lookup: options.lookup,
22
24
  // Time for connection to timeout
23
25
  connectTimeoutMS: 5_000,
24
26
  // Time for individual requests to timeout
@@ -1,5 +1,6 @@
1
1
  import * as lib_mongo from '@powersync/lib-service-mongodb/types';
2
2
  import * as service_types from '@powersync/service-types';
3
+ import { LookupFunction } from 'node:net';
3
4
  import * as t from 'ts-codec';
4
5
 
5
6
  export enum PostImagesOption {
@@ -48,6 +49,8 @@ export interface NormalizedMongoConnectionConfig {
48
49
  username?: string;
49
50
  password?: string;
50
51
 
52
+ lookup?: LookupFunction;
53
+
51
54
  postImages: PostImagesOption;
52
55
  }
53
56
 
@@ -8,7 +8,8 @@ import { test_utils } from '@powersync/service-core-tests';
8
8
 
9
9
  import { PostImagesOption } from '@module/types/types.js';
10
10
  import { ChangeStreamTestContext } from './change_stream_utils.js';
11
- import { INITIALIZED_MONGO_STORAGE_FACTORY } from './util.js';
11
+ import { env } from './env.js';
12
+ import { INITIALIZED_MONGO_STORAGE_FACTORY, INITIALIZED_POSTGRES_STORAGE_FACTORY } from './util.js';
12
13
 
13
14
  const BASIC_SYNC_RULES = `
14
15
  bucket_definitions:
@@ -17,10 +18,14 @@ bucket_definitions:
17
18
  - SELECT _id as id, description FROM "test_data"
18
19
  `;
19
20
 
20
- describe('change stream - mongodb', { timeout: 20_000 }, function () {
21
+ describe.skipIf(!env.TEST_MONGO_STORAGE)('change stream - mongodb', { timeout: 20_000 }, function () {
21
22
  defineChangeStreamTests(INITIALIZED_MONGO_STORAGE_FACTORY);
22
23
  });
23
24
 
25
+ describe.skipIf(!env.TEST_POSTGRES_STORAGE)('change stream - postgres', { timeout: 20_000 }, function () {
26
+ defineChangeStreamTests(INITIALIZED_POSTGRES_STORAGE_FACTORY);
27
+ });
28
+
24
29
  function defineChangeStreamTests(factory: storage.TestStorageFactory) {
25
30
  test('replicating basic values', async () => {
26
31
  await using context = await ChangeStreamTestContext.open(factory);
@@ -38,6 +38,7 @@ export class ChangeStreamTestContext {
38
38
  this.abortController.abort();
39
39
  await this.streamPromise?.catch((e) => e);
40
40
  await this.connectionManager.destroy();
41
+ await this.factory[Symbol.asyncDispose]();
41
42
  }
42
43
 
43
44
  async [Symbol.asyncDispose]() {
@@ -157,7 +158,6 @@ export async function getClientCheckpoint(
157
158
  if (cp.lsn && cp.lsn >= lsn) {
158
159
  return cp.checkpoint;
159
160
  }
160
-
161
161
  await new Promise((resolve) => setTimeout(resolve, 30));
162
162
  }
163
163
 
package/test/src/env.ts CHANGED
@@ -3,6 +3,9 @@ import { utils } from '@powersync/lib-services-framework';
3
3
  export const env = utils.collectEnvironmentVariables({
4
4
  MONGO_TEST_URL: utils.type.string.default('mongodb://localhost:27017/powersync_test'),
5
5
  MONGO_TEST_DATA_URL: utils.type.string.default('mongodb://localhost:27017/powersync_test_data'),
6
+ PG_STORAGE_TEST_URL: utils.type.string.default('postgres://postgres:postgres@localhost:5431/powersync_storage_test'),
6
7
  CI: utils.type.boolean.default('false'),
7
- SLOW_TESTS: utils.type.boolean.default('false')
8
+ SLOW_TESTS: utils.type.boolean.default('false'),
9
+ TEST_MONGO_STORAGE: utils.type.boolean.default('true'),
10
+ TEST_POSTGRES_STORAGE: utils.type.boolean.default('true')
8
11
  });
package/test/src/setup.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { container } from '@powersync/lib-services-framework';
2
2
  import { test_utils } from '@powersync/service-core-tests';
3
+ import { beforeEach } from 'node:test';
3
4
  import { beforeAll } from 'vitest';
4
5
 
5
6
  beforeAll(async () => {
@@ -8,3 +9,7 @@ beforeAll(async () => {
8
9
 
9
10
  await test_utils.initMetrics();
10
11
  });
12
+
13
+ beforeEach(async () => {
14
+ await test_utils.resetMetrics();
15
+ });
@@ -6,9 +6,9 @@ import { storage } from '@powersync/service-core';
6
6
 
7
7
  import { ChangeStreamTestContext, setSnapshotHistorySeconds } from './change_stream_utils.js';
8
8
  import { env } from './env.js';
9
- import { INITIALIZED_MONGO_STORAGE_FACTORY } from './util.js';
9
+ import { INITIALIZED_MONGO_STORAGE_FACTORY, INITIALIZED_POSTGRES_STORAGE_FACTORY } from './util.js';
10
10
 
11
- describe('change stream slow tests - mongodb', { timeout: 60_000 }, function () {
11
+ describe.skipIf(!env.TEST_MONGO_STORAGE)('change stream slow tests - mongodb', { timeout: 60_000 }, function () {
12
12
  if (env.CI || env.SLOW_TESTS) {
13
13
  defineSlowTests(INITIALIZED_MONGO_STORAGE_FACTORY);
14
14
  } else {
@@ -17,6 +17,15 @@ describe('change stream slow tests - mongodb', { timeout: 60_000 }, function ()
17
17
  }
18
18
  });
19
19
 
20
+ describe.skipIf(!env.TEST_POSTGRES_STORAGE)('change stream slow tests - postgres', { timeout: 60_000 }, function () {
21
+ if (env.CI || env.SLOW_TESTS) {
22
+ defineSlowTests(INITIALIZED_POSTGRES_STORAGE_FACTORY);
23
+ } else {
24
+ // Need something in this file.
25
+ test('no-op', () => {});
26
+ }
27
+ });
28
+
20
29
  function defineSlowTests(factory: storage.TestStorageFactory) {
21
30
  test('replicating snapshot with lots of data', async () => {
22
31
  await using context = await ChangeStreamTestContext.open(factory);
package/test/src/util.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { mongo } from '@powersync/lib-service-mongodb';
2
2
  import * as mongo_storage from '@powersync/service-module-mongodb-storage';
3
+ import * as postgres_storage from '@powersync/service-module-postgres-storage';
3
4
 
4
5
  import * as types from '@module/types/types.js';
5
6
  import { env } from './env.js';
@@ -16,6 +17,10 @@ export const INITIALIZED_MONGO_STORAGE_FACTORY = mongo_storage.MongoTestStorageF
16
17
  isCI: env.CI
17
18
  });
18
19
 
20
+ export const INITIALIZED_POSTGRES_STORAGE_FACTORY = postgres_storage.PostgresTestStorageFactoryGenerator({
21
+ url: env.PG_STORAGE_TEST_URL
22
+ });
23
+
19
24
  export async function clearTestDb(db: mongo.Db) {
20
25
  await db.dropDatabase();
21
26
  }