adapt-authoring-api 1.2.0 → 1.3.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
|
-
|
|
25
|
-
run: npx semantic-release
|
|
32
|
+
run: npx semantic-release
|
package/lib/AbstractApiModule.js
CHANGED
|
@@ -514,13 +514,15 @@ class AbstractApiModule extends AbstractModule {
|
|
|
514
514
|
* @return {Promise} Rejects if access should be blocked
|
|
515
515
|
*/
|
|
516
516
|
async checkAccess (req, data) {
|
|
517
|
+
if (req.auth.isSuper) {
|
|
518
|
+
return data
|
|
519
|
+
}
|
|
517
520
|
const isArray = Array.isArray(data)
|
|
518
521
|
const filtered = []
|
|
519
522
|
let error
|
|
520
523
|
await Promise.allSettled((isArray ? data : [data]).map(async r => {
|
|
521
524
|
try {
|
|
522
|
-
if (!this.accessCheckHook.hasObservers ||
|
|
523
|
-
(await this.accessCheckHook.invoke(req, r)).some(Boolean)) {
|
|
525
|
+
if (!this.accessCheckHook.hasObservers || (await this.accessCheckHook.invoke(req, r)).some(Boolean)) {
|
|
524
526
|
filtered.push(r)
|
|
525
527
|
}
|
|
526
528
|
} catch (e) {
|
|
@@ -573,11 +575,14 @@ class AbstractApiModule extends AbstractModule {
|
|
|
573
575
|
* @param {external:MongoDBFindOptions} mongoOptions Options to be passed to the MongoDB function
|
|
574
576
|
* @return {Promise} Resolves with the single DB document
|
|
575
577
|
*/
|
|
576
|
-
async findOne (query, options, mongoOptions) {
|
|
578
|
+
async findOne (query, options = {}, mongoOptions = {}) {
|
|
577
579
|
const results = await this.find(query, options, mongoOptions)
|
|
578
580
|
if (results.length > 1) {
|
|
579
581
|
throw this.app.errors.TOO_MANY_RESULTS.setData({ actual: results.length, expected: 1, query })
|
|
580
582
|
}
|
|
583
|
+
if (options.strict !== false && !results.length) {
|
|
584
|
+
throw this.app.errors.NOT_FOUND.setData({ id: query, type: options.schemaName })
|
|
585
|
+
}
|
|
581
586
|
return results[0]
|
|
582
587
|
}
|
|
583
588
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Abstract module for creating APIs",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-api",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"adapt-authoring-mongodb": "github:adapt-security/adapt-authoring-mongodb"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"
|
|
21
|
-
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
20
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
22
21
|
"@semantic-release/git": "^10.0.1",
|
|
23
|
-
"@semantic-release/github": "^
|
|
24
|
-
"@semantic-release/npm": "^
|
|
25
|
-
"@semantic-release/release-notes-generator": "^
|
|
26
|
-
"conventional-changelog-eslint": "^
|
|
27
|
-
"semantic-release": "^
|
|
28
|
-
"semantic-release-replace-plugin": "^1.2.7"
|
|
22
|
+
"@semantic-release/github": "^12.0.2",
|
|
23
|
+
"@semantic-release/npm": "^13.1.2",
|
|
24
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
25
|
+
"conventional-changelog-eslint": "^6.0.0",
|
|
26
|
+
"semantic-release": "^25.0.2",
|
|
27
|
+
"semantic-release-replace-plugin": "^1.2.7",
|
|
28
|
+
"standard": "^17.1.0"
|
|
29
29
|
},
|
|
30
30
|
"release": {
|
|
31
31
|
"plugins": [
|