@lowdefy/connection-mongodb 5.6.0 → 6.0.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.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { MongoClient } from 'mongodb';
16
- import { MongoDBAdapter as NextAuthMongoDBAdapter } from '@next-auth/mongodb-adapter';
16
+ import { MongoDBAdapter as AuthJsMongoDBAdapter } from '@auth/mongodb-adapter';
17
17
  /*
18
18
  Default collections are:
19
19
  {
@@ -26,6 +26,6 @@ Default collections are:
26
26
  function MongoDBAdapter({ properties }) {
27
27
  const { databaseUri, mongoDBClientOptions, options } = properties;
28
28
  const clientPromise = new MongoClient(databaseUri, mongoDBClientOptions).connect();
29
- return NextAuthMongoDBAdapter(clientPromise, options);
29
+ return AuthJsMongoDBAdapter(clientPromise, options);
30
30
  }
31
31
  export default MongoDBAdapter;
@@ -0,0 +1,64 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import getCollection from '../getCollection.js';
16
+ import { serialize, deserialize } from '../serialize.js';
17
+ import schema from './schema.js';
18
+ // Websocket source resolver — opens a MongoDB change stream and publishes
19
+ // each change event to the channel's subscribers. Runs from the first
20
+ // subscriber until the last one leaves (abort signal). Requires MongoDB to
21
+ // run as a replica set (change streams are not available on standalone
22
+ // deployments).
23
+ async function MongoDBChangeStream({ connection, properties, publish, signal }) {
24
+ const { fullDocument, pipeline } = deserialize(properties ?? {});
25
+ // The client is cached and shared with all other requests on this connection,
26
+ // so only the stream may be closed here, never the client.
27
+ const collection = await getCollection({
28
+ connection
29
+ });
30
+ if (signal.aborted) {
31
+ return;
32
+ }
33
+ const stream = collection.watch(pipeline ?? [], {
34
+ fullDocument: fullDocument ?? 'updateLookup'
35
+ });
36
+ signal.addEventListener('abort', ()=>{
37
+ stream.close().catch(()=>{
38
+ // Already closed — nothing to clean up.
39
+ });
40
+ }, {
41
+ once: true
42
+ });
43
+ try {
44
+ for await (const change of stream){
45
+ publish({
46
+ data: serialize(change)
47
+ });
48
+ }
49
+ } catch (error) {
50
+ // Closing the stream on abort surfaces as an error on the iterator.
51
+ if (!signal.aborted) {
52
+ throw error;
53
+ }
54
+ } finally{
55
+ await stream.close().catch(()=>{
56
+ // Already closed — nothing to clean up.
57
+ });
58
+ }
59
+ }
60
+ MongoDBChangeStream.schema = schema;
61
+ MongoDBChangeStream.meta = {
62
+ publish: false
63
+ };
64
+ export default MongoDBChangeStream;
@@ -0,0 +1,33 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Websocket Schema - MongoDBChangeStream',
18
+ type: 'object',
19
+ properties: {
20
+ pipeline: {
21
+ type: 'array',
22
+ description: 'Aggregation pipeline stages applied to the change stream (e.g. $match on operationType or fullDocument fields).'
23
+ },
24
+ fullDocument: {
25
+ type: 'string',
26
+ default: 'updateLookup',
27
+ description: 'The fullDocument option for the change stream. "updateLookup" includes the current document on updates.'
28
+ }
29
+ },
30
+ errorMessage: {
31
+ type: 'MongoDBChangeStream properties should be an object.'
32
+ }
33
+ };
package/dist/types.js CHANGED
@@ -36,5 +36,8 @@
36
36
  'MongoDBAdapter',
37
37
  'MultiAppMongoDBAdapter'
38
38
  ]
39
- }
39
+ },
40
+ websockets: [
41
+ 'MongoDBChangeStream'
42
+ ]
40
43
  };
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export { default as MongoDBChangeStream } from './connections/MongoDBCollection/MongoDBChangeStream/MongoDBChangeStream.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/connection-mongodb",
3
- "version": "5.6.0",
3
+ "version": "6.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -34,28 +34,28 @@
34
34
  "exports": {
35
35
  "./auth/adapters": "./dist/auth/adapters.js",
36
36
  "./connections": "./dist/connections.js",
37
- "./types": "./dist/types.js"
37
+ "./types": "./dist/types.js",
38
+ "./websockets": "./dist/websockets.js"
38
39
  },
39
40
  "files": [
40
41
  "dist/*"
41
42
  ],
42
43
  "dependencies": {
43
- "@lowdefy/helpers": "5.6.0",
44
+ "@auth/mongodb-adapter": "3.11.2",
45
+ "@lowdefy/helpers": "6.0.0",
44
46
  "@next-auth/mongodb-adapter": "1.1.3",
45
- "mongodb": "6.3.0",
47
+ "mongodb": "7.2.0",
46
48
  "saslprep": "1.0.3",
47
49
  "uuid": "13.0.0"
48
50
  },
49
51
  "devDependencies": {
50
- "@lowdefy/ajv": "5.6.0",
52
+ "@lowdefy/ajv": "6.0.0",
51
53
  "@shelf/jest-mongodb": "4.3.2",
52
- "@swc/cli": "0.8.0",
53
- "@swc/core": "1.15.18",
54
+ "@swc/cli": "0.8.1",
55
+ "@swc/core": "1.15.32",
54
56
  "@swc/jest": "0.2.39",
55
57
  "jest": "28.1.3",
56
58
  "jest-environment-node": "28.1.3",
57
- "next": "16.1.6",
58
- "next-auth": "4.24.10",
59
59
  "react": "18.2.0",
60
60
  "react-dom": "18.2.0"
61
61
  },