adapt-authoring-content 1.0.1 → 1.2.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/.github/workflows/standardjs.yml +13 -0
- package/lib/ContentModule.js +16 -1
- package/package.json +1 -2
- package/.eslintignore +0 -1
- package/.eslintrc +0 -14
|
@@ -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/lib/ContentModule.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractApiModule, AbstractApiUtils } from 'adapt-authoring-api'
|
|
2
|
+
import { Hook } from 'adapt-authoring-core'
|
|
2
3
|
import apidefs from './apidefs.js'
|
|
3
4
|
/**
|
|
4
5
|
* Module which handles course content
|
|
@@ -34,6 +35,16 @@ class ContentModule extends AbstractApiModule {
|
|
|
34
35
|
/** @override */
|
|
35
36
|
async init () {
|
|
36
37
|
await super.init()
|
|
38
|
+
/**
|
|
39
|
+
* Hook invoked before content data is cloned
|
|
40
|
+
* @type {Hook}
|
|
41
|
+
*/
|
|
42
|
+
this.preCloneHook = new Hook({ mutable: true })
|
|
43
|
+
/**
|
|
44
|
+
* Hook invoked after content data is cloned
|
|
45
|
+
* @type {Hook}
|
|
46
|
+
*/
|
|
47
|
+
this.postCloneHook = new Hook()
|
|
37
48
|
|
|
38
49
|
const [authored, jsonschema, mongodb, tags] = await this.app.waitForModule('authored', 'jsonschema', 'mongodb', 'tags')
|
|
39
50
|
|
|
@@ -231,12 +242,14 @@ class ContentModule extends AbstractApiModule {
|
|
|
231
242
|
* @param {Object} customData Data to be applied to the content item
|
|
232
243
|
* @return {Promise}
|
|
233
244
|
*/
|
|
234
|
-
async clone (userId, _id, _parentId, customData = {}) {
|
|
245
|
+
async clone (userId, _id, _parentId, customData = {}, options = {}) {
|
|
235
246
|
const [originalDoc] = await this.find({ _id })
|
|
236
247
|
if (!originalDoc) {
|
|
237
248
|
throw this.app.errors.NOT_FOUND
|
|
238
249
|
.setData({ type: originalDoc?._type, id: _id })
|
|
239
250
|
}
|
|
251
|
+
if (options.invokePreHook) await this.preCloneHook.invoke(originalDoc)
|
|
252
|
+
|
|
240
253
|
const [parent] = _parentId ? await this.find({ _id: _parentId }) : []
|
|
241
254
|
|
|
242
255
|
if (!parent && originalDoc._type !== 'course' && originalDoc._type !== 'config') {
|
|
@@ -268,6 +281,8 @@ class ContentModule extends AbstractApiModule {
|
|
|
268
281
|
for (let i = 0; i < children.length; i++) {
|
|
269
282
|
await this.clone(userId, children[i]._id, newData._id)
|
|
270
283
|
}
|
|
284
|
+
if (options.invokePostHook) await this.postCloneHook.invoke(originalDoc, newData)
|
|
285
|
+
|
|
271
286
|
return newData
|
|
272
287
|
}
|
|
273
288
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-content",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Module for managing Adapt content",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-content",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"repository": "github:adapt-security/adapt-authoring-content",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"eslint": "^9.12.0",
|
|
12
11
|
"standard": "^17.1.0",
|
|
13
12
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
14
13
|
"@semantic-release/git": "^10.0.1",
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
node_modules
|