adapt-authoring-courseassets 1.3.0 → 1.4.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.
@@ -1,4 +1,4 @@
1
- name: Standard.js formatting check
1
+ name: Lint
2
2
  on: push
3
3
  jobs:
4
4
  default:
@@ -9,4 +9,4 @@ jobs:
9
9
  with:
10
10
  node-version: 'lts/*'
11
11
  - run: npm install
12
- - run: npx standard
12
+ - run: npx standard
@@ -1,4 +1,4 @@
1
- import AbstractApiModule from 'adapt-authoring-api'
1
+ import { AbstractApiModule } from 'adapt-authoring-api'
2
2
  import { extractAssetIds } from './utils.js'
3
3
  /**
4
4
  * Module which handles courseassets automatically using on content events
@@ -8,6 +8,7 @@ import { extractAssetIds } from './utils.js'
8
8
  class CourseAssetsModule extends AbstractApiModule {
9
9
  /** @override */
10
10
  async setValues () {
11
+ await super.setValues()
11
12
  /** @ignore */ this.schemaName = 'courseasset'
12
13
  /** @ignore */ this.collectionName = 'courseassets'
13
14
  }
@@ -78,10 +79,7 @@ class CourseAssetsModule extends AbstractApiModule {
78
79
  return
79
80
  }
80
81
  await Promise.all(ids.map(async _id => {
81
- const [asset] = await this.assets.find({ _id })
82
- if (!asset) {
83
- throw this.app.errors.NOT_FOUND.setData({ type: 'asset', id: _id })
84
- }
82
+ const asset = await this.assets.findOne({ _id })
85
83
  await this.insert({ courseId, contentId, assetId: _id })
86
84
  }))
87
85
  this.log('debug', 'UPDATE', courseId, contentId)
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "adapt-authoring-courseassets",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "Module for managing course asset usage",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-courseassets",
6
6
  "license": "GPL-3.0",
7
7
  "type": "module",
8
8
  "main": "index.js",
9
9
  "repository": "github:adapt-security/adapt-authoring-courseassets",
10
+ "dependencies": {
11
+ "adapt-authoring-api": "^3.0.0"
12
+ },
10
13
  "peerDependencies": {
11
14
  "adapt-authoring-assets": "^1.3.1",
12
15
  "adapt-authoring-content": "^2.0.0",
package/routes.json CHANGED
@@ -1,13 +1,34 @@
1
1
  {
2
2
  "root": "courseassets",
3
+ "schemaName": "courseasset",
4
+ "collectionName": "courseassets",
3
5
  "useDefaultRoutes": false,
4
6
  "routes": [
5
7
  {
6
8
  "route": "/query",
7
9
  "validate": false,
8
10
  "modifying": false,
9
- "handlers": { "post": "query" },
10
- "permissions": { "post": ["read:${scope}"] }
11
+ "handlers": { "post": "queryHandler" },
12
+ "permissions": { "post": ["read:${scope}"] },
13
+ "meta": {
14
+ "post": {
15
+ "summary": "Query all courseassets",
16
+ "parameters": [
17
+ { "name": "limit", "in": "query", "description": "How many results to return" },
18
+ { "name": "page", "in": "query", "description": "The page of results to return" }
19
+ ],
20
+ "responses": {
21
+ "200": {
22
+ "description": "List of courseasset documents",
23
+ "content": {
24
+ "application/json": {
25
+ "schema": { "type": "array", "items": { "$ref": "#/components/schemas/courseasset" } }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
11
32
  }
12
33
  ]
13
34
  }