adapt-authoring-mongodb 1.0.0 → 1.1.1

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.
@@ -3,10 +3,16 @@ on:
3
3
  push:
4
4
  branches:
5
5
  - master
6
+
6
7
  jobs:
7
8
  release:
8
9
  name: Release
9
10
  runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write # to be able to publish a GitHub release
13
+ issues: write # to be able to comment on released issues
14
+ pull-requests: write # to be able to comment on released pull requests
15
+ id-token: write # to enable use of OIDC for trusted publishing and npm provenance
10
16
  steps:
11
17
  - name: Checkout
12
18
  uses: actions/checkout@v3
@@ -16,10 +22,11 @@ jobs:
16
22
  uses: actions/setup-node@v3
17
23
  with:
18
24
  node-version: 'lts/*'
25
+ - name: Update npm
26
+ run: npm install -g npm@latest
19
27
  - name: Install dependencies
20
28
  run: npm ci
21
29
  - name: Release
22
30
  env:
23
31
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
- NPM_TOKEN: ${{ secrets.AAT_NPM_TOKEN }}
25
- run: npx semantic-release
32
+ run: npx semantic-release
@@ -0,0 +1,13 @@
1
+ name: Standard.js formatting check
2
+ on: push
3
+ jobs:
4
+ default:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@master
8
+ - uses: actions/setup-node@master
9
+ with:
10
+ node-version: 'lts/*'
11
+ cache: 'npm'
12
+ - run: npm ci
13
+ - run: npx standard
package/index.js CHANGED
@@ -2,6 +2,5 @@
2
2
  * MongoDB integration
3
3
  * @namespace mongodb
4
4
  */
5
- export { default as ObjectIdUtils } from './lib/ObjectIdUtils.js'
6
- export { default } from './lib/MongoDBModule.js'
7
-
5
+ export { default as ObjectIdUtils } from './lib/ObjectIdUtils.js'
6
+ export { default } from './lib/MongoDBModule.js'
@@ -125,7 +125,8 @@ class MongoDBModule extends AbstractModule {
125
125
  this.ObjectId.parseIds(query)
126
126
  this.parseOptions(options)
127
127
  try {
128
- return await this.getCollection(collectionName).find(query, options).toArray()
128
+ const cursor = this.getCollection(collectionName).find(query, options)
129
+ return options?.returnCursor === true ? cursor : await cursor.toArray()
129
130
  } catch (e) {
130
131
  this.log('error', `failed to find docs, ${e.message}`)
131
132
  throw this.getError(collectionName, 'find', e)
package/lib/typedefs.js CHANGED
@@ -60,4 +60,4 @@
60
60
  * @memberof mongodb
61
61
  * @external MongoDBUpdateOptions
62
62
  * @see {@link https://mongodb.github.io/node-mongodb-native/4.2/interfaces/UpdateOptions.html}
63
- */
63
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-mongodb",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Module for saving to a MongoDB instance",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-mongodb",
6
6
  "license": "GPL-3.0",
@@ -14,16 +14,15 @@
14
14
  "adapt-authoring-core": "github:adapt-security/adapt-authoring-core"
15
15
  },
16
16
  "devDependencies": {
17
- "eslint": "^9.12.0",
18
- "standard": "^17.1.0",
19
- "@semantic-release/commit-analyzer": "^9.0.2",
17
+ "@semantic-release/commit-analyzer": "^13.0.1",
20
18
  "@semantic-release/git": "^10.0.1",
21
- "@semantic-release/github": "^8.0.5",
22
- "@semantic-release/npm": "^9.0.1",
23
- "@semantic-release/release-notes-generator": "^10.0.3",
24
- "conventional-changelog-eslint": "^3.0.9",
25
- "semantic-release": "^21.0.1",
26
- "semantic-release-replace-plugin": "^1.2.7"
19
+ "@semantic-release/github": "^12.0.2",
20
+ "@semantic-release/npm": "^13.1.2",
21
+ "@semantic-release/release-notes-generator": "^14.1.0",
22
+ "conventional-changelog-eslint": "^6.0.0",
23
+ "semantic-release": "^25.0.2",
24
+ "semantic-release-replace-plugin": "^1.2.7",
25
+ "standard": "^17.1.0"
27
26
  },
28
27
  "release": {
29
28
  "plugins": [
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- node_modules
package/.eslintrc DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "env": {
3
- "browser": false,
4
- "node": true,
5
- "commonjs": false,
6
- "es2020": true
7
- },
8
- "extends": [
9
- "standard"
10
- ],
11
- "parserOptions": {
12
- "ecmaVersion": 2020
13
- }
14
- }
@@ -1,109 +0,0 @@
1
- const MongoDBModule = require('../lib/MongoDBModule');
2
- const should = require('should');
3
-
4
- describe('MongoDB module', function() {
5
- describe('#readyState()', function() {
6
- it('should return a number', function() {
7
- false.should.be.true();
8
- });
9
- it('should return a value even if no connection', function() {
10
- false.should.be.true();
11
- });
12
- });
13
- describe('#isConnected()', function() {
14
- it('should return true if connected', function() {
15
- false.should.be.true();
16
- });
17
- it('should return false if not connected', function() {
18
- false.should.be.true();
19
- });
20
- });
21
- describe('#connectionURI()', function() {
22
- it('should return a valid connection string', function() {
23
- false.should.be.true();
24
- });
25
- it('should not include undefined values', function() {
26
- false.should.be.true();
27
- });
28
- });
29
- describe('#getCollection()', function() {
30
- it('should return a MongoDB collection', function() {
31
- false.should.be.true();
32
- });
33
- });
34
- describe('#connect()', function() {
35
- it('should establish a connection to specified MongoDB instance', function() {
36
- false.should.be.true();
37
- });
38
- it('should fail gracefully on error', function() {
39
- false.should.be.true();
40
- });
41
- });
42
- describe('#insert()', function() {
43
- it('should return a promise', function() {
44
- false.should.be.true();
45
- });
46
- it('should return an error if no data is passed', function() {
47
- false.should.be.true();
48
- });
49
- it('should return the inserted document', function() {
50
- false.should.be.true();
51
- });
52
- });
53
- describe('#find()', function() {
54
- it('should return a promise', function() {
55
- false.should.be.true();
56
- });
57
- it('should return an error if invalid query data is passed', function() {
58
- false.should.be.true();
59
- });
60
- it('should return an error if invalid model type is specified', function() {
61
- false.should.be.true();
62
- });
63
- it('should populate specified attributes', function() {
64
- false.should.be.true();
65
- });
66
- it('should return matching documents', function() {
67
- false.should.be.true();
68
- });
69
- });
70
- describe('#replace()', function() {
71
- it('should return a promise', function() {
72
- false.should.be.true();
73
- });
74
- it('should return an error if invalid query data is passed', function() {
75
- false.should.be.true();
76
- });
77
- it('should return an error if invalid model type is specified', function() {
78
- false.should.be.true();
79
- });
80
- it('should replace matching document(s)', function() {
81
- false.should.be.true();
82
- });
83
- });
84
- describe('#delete()', function() {
85
- it('should return a promise', function() {
86
- false.should.be.true();
87
- });
88
- it('should return an error if invalid query data is passed', function() {
89
- false.should.be.true();
90
- });
91
- it('should return an error if invalid model type is specified', function() {
92
- false.should.be.true();
93
- });
94
- it('should delete matching document(s)', function() {
95
- false.should.be.true();
96
- });
97
- });
98
- describe('#formatError()', function() {
99
- it('should return an Error', function() {
100
- false.should.be.true();
101
- });
102
- it('should set custom statusCode', function() {
103
- false.should.be.true();
104
- });
105
- it('should set default statusCode', function() {
106
- false.should.be.true();
107
- });
108
- });
109
- });
@@ -1,37 +0,0 @@
1
- const should = require('should');
2
-
3
- describe('ObjectId Utils', function() {
4
- describe('#isValid', function() {
5
- it('should return false for empty/undefined param', function() {
6
- false.should.be.true();
7
- });
8
- it('should return true for valid string', function() {
9
- false.should.be.true();
10
- });
11
- it('should return true for invalid type', function() {
12
- false.should.be.true();
13
- });
14
- it('should return true for invalid string', function() {
15
- false.should.be.true();
16
- });
17
- });
18
- describe('#parse', function() {
19
- it('should return an ObjectId instance', function() {
20
- false.should.be.true();
21
- });
22
- it('should throw an error on invalid input', function() {
23
- false.should.be.true();
24
- });
25
- });
26
- describe('#parseParamIds', function() {
27
- it('parse a valid _id to an ObjectId', function() {
28
- false.should.be.true();
29
- });
30
- it('throw an error on invalid _id', function() {
31
- false.should.be.true();
32
- });
33
- it('ignore non _id fields', function() {
34
- false.should.be.true();
35
- });
36
- });
37
- });