adapt-authoring-mongodb 0.0.1 → 1.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.
package/.eslintignore CHANGED
@@ -1 +1 @@
1
- node_modules
1
+ node_modules
package/.eslintrc CHANGED
@@ -1,14 +1,14 @@
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
+ {
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,55 +1,55 @@
1
- name: Bug Report
2
- description: File a bug report
3
- labels: ["bug"]
4
- body:
5
- - type: markdown
6
- attributes:
7
- value: |
8
- Thanks for taking the time to fill out this bug report!
9
- - type: textarea
10
- id: description
11
- attributes:
12
- label: What happened?
13
- description: Please describe the issue
14
- validations:
15
- required: true
16
- - type: textarea
17
- id: expected
18
- attributes:
19
- label: Expected behaviour
20
- description: Tell us what should have happened
21
- - type: textarea
22
- id: repro-steps
23
- attributes:
24
- label: Steps to reproduce
25
- description: Tell us how to reproduce the issue
26
- validations:
27
- required: true
28
- - type: input
29
- id: aat-version
30
- attributes:
31
- label: Authoring tool version
32
- description: What version of the Adapt authoring tool are you running?
33
- validations:
34
- required: true
35
- - type: input
36
- id: fw-version
37
- attributes:
38
- label: Framework version
39
- description: What version of the Adapt framework are you running?
40
- - type: dropdown
41
- id: browsers
42
- attributes:
43
- label: What browsers are you seeing the problem on?
44
- multiple: true
45
- options:
46
- - Firefox
47
- - Chrome
48
- - Safari
49
- - Microsoft Edge
50
- - type: textarea
51
- id: logs
52
- attributes:
53
- label: Relevant log output
54
- description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
55
- render: sh
1
+ name: Bug Report
2
+ description: File a bug report
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to fill out this bug report!
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: What happened?
13
+ description: Please describe the issue
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: expected
18
+ attributes:
19
+ label: Expected behaviour
20
+ description: Tell us what should have happened
21
+ - type: textarea
22
+ id: repro-steps
23
+ attributes:
24
+ label: Steps to reproduce
25
+ description: Tell us how to reproduce the issue
26
+ validations:
27
+ required: true
28
+ - type: input
29
+ id: aat-version
30
+ attributes:
31
+ label: Authoring tool version
32
+ description: What version of the Adapt authoring tool are you running?
33
+ validations:
34
+ required: true
35
+ - type: input
36
+ id: fw-version
37
+ attributes:
38
+ label: Framework version
39
+ description: What version of the Adapt framework are you running?
40
+ - type: dropdown
41
+ id: browsers
42
+ attributes:
43
+ label: What browsers are you seeing the problem on?
44
+ multiple: true
45
+ options:
46
+ - Firefox
47
+ - Chrome
48
+ - Safari
49
+ - Microsoft Edge
50
+ - type: textarea
51
+ id: logs
52
+ attributes:
53
+ label: Relevant log output
54
+ description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
55
+ render: sh
@@ -1,22 +1,22 @@
1
- name: Feature request
2
- description: Request a new feature
3
- labels: ["enhancement"]
4
- body:
5
- - type: markdown
6
- attributes:
7
- value: |
8
- Thanks for taking the time to request a new feature in the Adapt authoring tool! The Adapt team will consider all new feature requests, but unfortunately cannot commit to every one.
9
- - type: textarea
10
- id: description
11
- attributes:
12
- label: Feature description
13
- description: Please describe your feature request
14
- validations:
15
- required: true
16
- - type: checkboxes
17
- id: contribute
18
- attributes:
19
- label: Can you work on this feature?
20
- description: If you are able to commit your own time to work on this feature, it will greatly increase the liklihood of it being implemented by the core dev team. Otherwise, it will be triaged and prioritised alongside the core team's current priorities.
21
- options:
22
- - label: I can contribute
1
+ name: Feature request
2
+ description: Request a new feature
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to request a new feature in the Adapt authoring tool! The Adapt team will consider all new feature requests, but unfortunately cannot commit to every one.
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: Feature description
13
+ description: Please describe your feature request
14
+ validations:
15
+ required: true
16
+ - type: checkboxes
17
+ id: contribute
18
+ attributes:
19
+ label: Can you work on this feature?
20
+ description: If you are able to commit your own time to work on this feature, it will greatly increase the liklihood of it being implemented by the core dev team. Otherwise, it will be triaged and prioritised alongside the core team's current priorities.
21
+ options:
22
+ - label: I can contribute
@@ -1,11 +1,11 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "npm" # See documentation for possible values
9
- directory: "/" # Location of package manifests
10
- schedule:
11
- interval: "weekly"
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -1,25 +1,25 @@
1
- [//]: # (Please title your PR according to eslint commit conventions)
2
- [//]: # (See https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint#eslint-convention for details)
3
-
4
- [//]: # (Add a link to the original issue)
5
-
6
- [//]: # (Delete as appropriate)
7
- ### Fix
8
- * A sentence describing each fix
9
-
10
- ### Update
11
- * A sentence describing each udpate
12
-
13
- ### New
14
- * A sentence describing each new feature
15
-
16
- ### Breaking
17
- * A sentence describing each breaking change
18
-
19
- [//]: # (List appropriate steps for testing if needed)
20
- ### Testing
21
- 1. Steps for testing
22
-
23
- [//]: # (Mention any other dependencies)
24
-
25
-
1
+ [//]: # (Please title your PR according to eslint commit conventions)
2
+ [//]: # (See https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint#eslint-convention for details)
3
+
4
+ [//]: # (Add a link to the original issue)
5
+
6
+ [//]: # (Delete as appropriate)
7
+ ### Fix
8
+ * A sentence describing each fix
9
+
10
+ ### Update
11
+ * A sentence describing each udpate
12
+
13
+ ### New
14
+ * A sentence describing each new feature
15
+
16
+ ### Breaking
17
+ * A sentence describing each breaking change
18
+
19
+ [//]: # (List appropriate steps for testing if needed)
20
+ ### Testing
21
+ 1. Steps for testing
22
+
23
+ [//]: # (Mention any other dependencies)
24
+
25
+
@@ -1,16 +1,16 @@
1
- name: Add labelled PRs to project
2
-
3
- on:
4
- pull_request:
5
- types: [ labeled ]
6
-
7
- jobs:
8
- add-to-project:
9
- if: ${{ github.event.label.name == 'dependencies' }}
10
- name: Add to main project
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/add-to-project@v0.1.0
14
- with:
15
- project-url: https://github.com/orgs/adapt-security/projects/5
16
- github-token: ${{ secrets.PROJECTS_SECRET }}
1
+ name: Add labelled PRs to project
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ labeled ]
6
+
7
+ jobs:
8
+ add-to-project:
9
+ if: ${{ github.event.label.name == 'dependencies' }}
10
+ name: Add to main project
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/add-to-project@v0.1.0
14
+ with:
15
+ project-url: https://github.com/orgs/adapt-security/projects/5
16
+ github-token: ${{ secrets.PROJECTS_SECRET }}
@@ -1,19 +1,19 @@
1
- name: Add to main project
2
-
3
- on:
4
- issues:
5
- types:
6
- - opened
7
- pull_request:
8
- types:
9
- - opened
10
-
11
- jobs:
12
- add-to-project:
13
- name: Add to main project
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/add-to-project@v0.1.0
17
- with:
18
- project-url: https://github.com/orgs/adapt-security/projects/5
19
- github-token: ${{ secrets.PROJECTS_SECRET }}
1
+ name: Add to main project
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+ pull_request:
8
+ types:
9
+ - opened
10
+
11
+ jobs:
12
+ add-to-project:
13
+ name: Add to main project
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/add-to-project@v0.1.0
17
+ with:
18
+ project-url: https://github.com/orgs/adapt-security/projects/5
19
+ github-token: ${{ secrets.PROJECTS_SECRET }}
@@ -0,0 +1,25 @@
1
+ name: Release
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ jobs:
7
+ release:
8
+ name: Release
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout
12
+ uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 0
15
+ - name: Setup Node.js
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: 'lts/*'
19
+ - name: Install dependencies
20
+ run: npm ci
21
+ - name: Release
22
+ env:
23
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
+ NPM_TOKEN: ${{ secrets.AAT_NPM_TOKEN }}
25
+ run: npx semantic-release
@@ -1,9 +1,9 @@
1
- {
2
- "essentialType": "db",
3
- "documentation": {
4
- "enable": true,
5
- "manualPages": {
6
- "using-mongodb.md": "basics"
7
- }
8
- }
9
- }
1
+ {
2
+ "essentialType": "db",
3
+ "documentation": {
4
+ "enable": true,
5
+ "manualPages": {
6
+ "using-mongodb.md": "basics"
7
+ }
8
+ }
9
+ }
@@ -1,16 +1,16 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "type": "object",
4
- "properties": {
5
- "connectionUri": {
6
- "description": "The MongoDB connection URI used to connect to your MongoDB deployment.",
7
- "type": "string",
8
- "format": "uri",
9
- "examples": [
10
- "mongodb://0.0.0.0/adapt-authoring",
11
- "mongodb://test1.adaptlearning.org:27018,test2.adaptlearning.org:27019/?replicaSet=test"
12
- ]
13
- }
14
- },
15
- "required": ["connectionUri"]
16
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "connectionUri": {
6
+ "description": "The MongoDB connection URI used to connect to your MongoDB deployment.",
7
+ "type": "string",
8
+ "format": "uri",
9
+ "examples": [
10
+ "mongodb://0.0.0.0/adapt-authoring",
11
+ "mongodb://test1.adaptlearning.org:27018,test2.adaptlearning.org:27019/?replicaSet=test"
12
+ ]
13
+ }
14
+ },
15
+ "required": ["connectionUri"]
16
+ }
@@ -1,66 +1,66 @@
1
- # Using MongoDB
2
- The `adapt-authoring-mongodb` module adds the ability to work with MongoDB databases.
3
-
4
- ## Installing MongoDB
5
- To save data with the authoring tool, you'll need either a local MongoDB install, or a hosted solution.
6
-
7
- If you're new to hosting web applications/MongoDB and are intending to make your install accessible via the internet, we'd suggest going with a hosted solution.
8
-
9
- For instructions on installing MongoDB, see the [MongoDB docs](https://docs.mongodb.com/manual/installation/#mongodb-community-edition-installation-tutorials).
10
-
11
- ## Using the module
12
- The `adapt-authoring-mongodb` module uses MongoDB's [Node.js driver](https://mongodb.github.io/node-mongodb-native/4.2) behind-the-scenes for communicating with MongoDB.
13
-
14
- Where possible, the MongoDBModule API has been designed to mirror the MongoDB Node.js driver API in both naming convensions and parameter naming/order. In some cases this has been changed for ease-of-use (e.g. `insertOne` has been renamed to `insert`). Please see the [Adapt authoring reference for the MongoDBModule](/class/node_modules/adapt-authoring-mongodb/lib/MongoDBModule.js~MongoDBModule.html) for more information (details on which of the MongoDB Node.js driver functions are used is specified there).
15
-
16
- > If you're new to working with MongoDB, check out this [Quick Start](https://mongodb.github.io/node-mongodb-native/4.2/#quick-start) guide in the official docs for a good overview.
17
-
18
- ### Basic use
19
- The following functions provide the most common functionality, and will likely be the functions you use most often. Please see the [API reference]([/class/node_modules/adapt-authoring-mongodb/lib/MongoDBModule.js~MongoDBModule.html](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html)) for full details.
20
-
21
- #### `find(collectionName, query, options)`
22
- Retrieves a document.
23
-
24
- #### `insert(collectionName, data, options)`
25
- Inserts a new document.
26
-
27
- #### `replace(collectionName, query, data, options)`
28
- Completely replaces an existing document.
29
-
30
- #### `update(collectionName, query, data, options)`
31
- Updates only specific fields of an existing document.
32
-
33
- #### `delete(collectionName, query, options)`
34
- Removes an existing document.
35
-
36
- ### Querying the database
37
- The `find` function is used to retrieve documents from the database.
38
-
39
-
40
- #### Examples
41
- Note that the MongoDB module, as with the rest of the application, makes heavy use of promises, and will return a pending Promise for all relevant functions.
42
-
43
- Inserting a document into the 'test' collection:
44
- ```
45
- try {
46
- const data = await mongodb.insert('test', { hello: 'world' });
47
- } catch(e) {
48
- // handle error
49
- }
50
- ```
51
-
52
- ### Advanced use
53
- It is possible to access the Node.js driver API directly from the MongoDBModule instance to allow for extra functionality not covered by the MongoDBModule itself. An example of this being creating an aggregation pipeline.
54
-
55
- There are two methods of accessing the driver API. Which one you use is entirely up to you, and mostly comes down to code brevity:
56
- - Using the MongoDB client instance [[Adapt docs](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html#client), [MongoDB Node.js driver docs](https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html)]
57
- - Using the MongoDB collection [[Adapt docs](), [MongoDB Node.js driver docs](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html#getCollection)]
58
-
59
- ```
60
- // using the client instance
61
- mongodb.client.db.collection('mycollection').aggregate(/* args */)
62
- // using MongoDBModule#getCollection
63
- mongodb.getCollection('mycollection').aggregate(/* args */)
64
- ```
65
-
1
+ # Using MongoDB
2
+ The `adapt-authoring-mongodb` module adds the ability to work with MongoDB databases.
3
+
4
+ ## Installing MongoDB
5
+ To save data with the authoring tool, you'll need either a local MongoDB install, or a hosted solution.
6
+
7
+ If you're new to hosting web applications/MongoDB and are intending to make your install accessible via the internet, we'd suggest going with a hosted solution.
8
+
9
+ For instructions on installing MongoDB, see the [MongoDB docs](https://docs.mongodb.com/manual/installation/#mongodb-community-edition-installation-tutorials).
10
+
11
+ ## Using the module
12
+ The `adapt-authoring-mongodb` module uses MongoDB's [Node.js driver](https://mongodb.github.io/node-mongodb-native/4.2) behind-the-scenes for communicating with MongoDB.
13
+
14
+ Where possible, the MongoDBModule API has been designed to mirror the MongoDB Node.js driver API in both naming convensions and parameter naming/order. In some cases this has been changed for ease-of-use (e.g. `insertOne` has been renamed to `insert`). Please see the [Adapt authoring reference for the MongoDBModule](/class/node_modules/adapt-authoring-mongodb/lib/MongoDBModule.js~MongoDBModule.html) for more information (details on which of the MongoDB Node.js driver functions are used is specified there).
15
+
16
+ > If you're new to working with MongoDB, check out this [Quick Start](https://mongodb.github.io/node-mongodb-native/4.2/#quick-start) guide in the official docs for a good overview.
17
+
18
+ ### Basic use
19
+ The following functions provide the most common functionality, and will likely be the functions you use most often. Please see the [API reference]([/class/node_modules/adapt-authoring-mongodb/lib/MongoDBModule.js~MongoDBModule.html](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html)) for full details.
20
+
21
+ #### `find(collectionName, query, options)`
22
+ Retrieves a document.
23
+
24
+ #### `insert(collectionName, data, options)`
25
+ Inserts a new document.
26
+
27
+ #### `replace(collectionName, query, data, options)`
28
+ Completely replaces an existing document.
29
+
30
+ #### `update(collectionName, query, data, options)`
31
+ Updates only specific fields of an existing document.
32
+
33
+ #### `delete(collectionName, query, options)`
34
+ Removes an existing document.
35
+
36
+ ### Querying the database
37
+ The `find` function is used to retrieve documents from the database.
38
+
39
+
40
+ #### Examples
41
+ Note that the MongoDB module, as with the rest of the application, makes heavy use of promises, and will return a pending Promise for all relevant functions.
42
+
43
+ Inserting a document into the 'test' collection:
44
+ ```
45
+ try {
46
+ const data = await mongodb.insert('test', { hello: 'world' });
47
+ } catch(e) {
48
+ // handle error
49
+ }
50
+ ```
51
+
52
+ ### Advanced use
53
+ It is possible to access the Node.js driver API directly from the MongoDBModule instance to allow for extra functionality not covered by the MongoDBModule itself. An example of this being creating an aggregation pipeline.
54
+
55
+ There are two methods of accessing the driver API. Which one you use is entirely up to you, and mostly comes down to code brevity:
56
+ - Using the MongoDB client instance [[Adapt docs](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html#client), [MongoDB Node.js driver docs](https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html)]
57
+ - Using the MongoDB collection [[Adapt docs](), [MongoDB Node.js driver docs](https://tomtaylor.codes/ls/jsdoc3/MongoDBModule.html#getCollection)]
58
+
59
+ ```
60
+ // using the client instance
61
+ mongodb.client.db.collection('mycollection').aggregate(/* args */)
62
+ // using MongoDBModule#getCollection
63
+ mongodb.getCollection('mycollection').aggregate(/* args */)
64
+ ```
65
+
66
66
  See the [MongoDB Node.js driver docs](https://mongodb.github.io/node-mongodb-native/4.2/classes/Collection.html) for the full API.
@@ -1,43 +1,43 @@
1
- {
2
- "INVALID_OBJECTID": {
3
- "data": {
4
- "value": "The value"
5
- },
6
- "description": "Not a valid ObjectId",
7
- "statusCode": 400
8
- },
9
- "MONGO_CONN_FAILED": {
10
- "data": {
11
- "error": "The error message"
12
- },
13
- "description": "An error occurred connecting to the MongoDB instance",
14
- "statusCode": 500
15
- },
16
- "MONGO_DUPL_INDEX": {
17
- "data": {
18
- "action": "The action being performed on the database collection",
19
- "collectionName": "Name of the collection being processed",
20
- "error": "The error message"
21
- },
22
- "description": "A document already exists with the same indexed value",
23
- "statusCode": 400
24
- },
25
- "MONGO_ERROR": {
26
- "data": {
27
- "action": "The action being performed on the database collection",
28
- "collectionName": "Name of the collection being processed",
29
- "error": "The error message"
30
- },
31
- "description": "An error occurred while performing a MongoDB action",
32
- "statusCode": 500
33
- },
34
- "MONGO_IMMUTABLE_FIELD": {
35
- "data": {
36
- "action": "The action being performed on the database collection",
37
- "collectionName": "Name of the collection being processed",
38
- "error": "The error message"
39
- },
40
- "description": "Attempting to modify an immutable field",
41
- "statusCode": 400
42
- }
1
+ {
2
+ "INVALID_OBJECTID": {
3
+ "data": {
4
+ "value": "The value"
5
+ },
6
+ "description": "Not a valid ObjectId",
7
+ "statusCode": 400
8
+ },
9
+ "MONGO_CONN_FAILED": {
10
+ "data": {
11
+ "error": "The error message"
12
+ },
13
+ "description": "An error occurred connecting to the MongoDB instance",
14
+ "statusCode": 500
15
+ },
16
+ "MONGO_DUPL_INDEX": {
17
+ "data": {
18
+ "action": "The action being performed on the database collection",
19
+ "collectionName": "Name of the collection being processed",
20
+ "error": "The error message"
21
+ },
22
+ "description": "A document already exists with the same indexed value",
23
+ "statusCode": 400
24
+ },
25
+ "MONGO_ERROR": {
26
+ "data": {
27
+ "action": "The action being performed on the database collection",
28
+ "collectionName": "Name of the collection being processed",
29
+ "error": "The error message"
30
+ },
31
+ "description": "An error occurred while performing a MongoDB action",
32
+ "statusCode": 500
33
+ },
34
+ "MONGO_IMMUTABLE_FIELD": {
35
+ "data": {
36
+ "action": "The action being performed on the database collection",
37
+ "collectionName": "Name of the collection being processed",
38
+ "error": "The error message"
39
+ },
40
+ "description": "Attempting to modify an immutable field",
41
+ "statusCode": 400
42
+ }
43
43
  }
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- /**
2
- * MongoDB integration
3
- * @namespace mongodb
4
- */
5
- export { default as ObjectIdUtils } from './lib/ObjectIdUtils.js'
6
- export { default } from './lib/MongoDBModule.js'
1
+ /**
2
+ * MongoDB integration
3
+ * @namespace mongodb
4
+ */
5
+ export { default as ObjectIdUtils } from './lib/ObjectIdUtils.js'
6
+ export { default } from './lib/MongoDBModule.js'
7
7