adapt-authoring-content 2.1.4 → 2.1.5

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.
@@ -40,7 +40,7 @@ class ContentModule extends AbstractApiModule {
40
40
  await mongodb.setIndex(this.collectionName, { _courseId: 1, _parentId: 1, _type: 1 })
41
41
  await mongodb.setIndex(this.collectionName, { _courseId: 1, _friendlyId: 1 }, {
42
42
  unique: true,
43
- partialFilterExpression: { _friendlyId: { $type: 'string' } }
43
+ partialFilterExpression: { _friendlyId: { $type: 'string', $gt: '' } }
44
44
  })
45
45
  }
46
46
 
@@ -362,6 +362,7 @@ class ContentModule extends AbstractApiModule {
362
362
  */
363
363
  async handleClone (req, res, next) {
364
364
  try {
365
+ await this.requestHook.invoke(req)
365
366
  const { _id, _parentId } = req.body
366
367
  const source = await this.findOne({ _id: req.body._id })
367
368
  await this.checkAccess(req, source)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-content",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
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",
@@ -72,6 +72,7 @@ function createInstance (overrides = {}) {
72
72
  checkAccess: mock.fn(async (req, data) => data),
73
73
  log: mock.fn(),
74
74
 
75
+ requestHook: createMockHook(),
75
76
  preCloneHook: createMockHook(),
76
77
  postCloneHook: createMockHook(),
77
78
 
@@ -870,9 +871,10 @@ describe('ContentModule', () => {
870
871
  assert.equal(next.mock.calls[0].arguments[0], error)
871
872
  })
872
873
 
873
- it('should call checkAccess before cloning', async () => {
874
+ it('should call requestHook, checkAccess, then clone in order', async () => {
874
875
  const callOrder = []
875
876
  const inst = createInstance()
877
+ inst.requestHook = { invoke: mock.fn(async () => { callOrder.push('requestHook') }) }
876
878
  inst.findOne = mock.fn(async () => {
877
879
  callOrder.push('findOne')
878
880
  return { _id: 'orig' }
@@ -895,7 +897,7 @@ describe('ContentModule', () => {
895
897
 
896
898
  await ContentModule.prototype.handleClone.call(inst, req, res, mock.fn())
897
899
 
898
- assert.deepEqual(callOrder, ['findOne', 'checkAccess', 'clone'])
900
+ assert.deepEqual(callOrder, ['requestHook', 'findOne', 'checkAccess', 'clone'])
899
901
  })
900
902
  })
901
903