adapt-authoring-content 2.1.7 → 2.1.8

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.
@@ -150,9 +150,16 @@ class ContentModule extends AbstractApiModule {
150
150
  }
151
151
  const descendants = await getDescendants(q => this.find(q), targetDoc)
152
152
 
153
- await Promise.all([...descendants, targetDoc].map(d => {
154
- return super.delete({ _id: d._id }, options, mongoOptions)
155
- }))
153
+ // bulk-delete descendants directly to avoid per-item memory overhead and hook storms
154
+ if (descendants.length > 0) {
155
+ const mongodb = await this.app.waitForModule('mongodb')
156
+ await mongodb.deleteMany(this.collectionName, { _id: { $in: descendants.map(d => d._id) } }, mongoOptions)
157
+ }
158
+ // delete target via super.delete to trigger deleteHook middleware (e.g. multilang)
159
+ await super.delete({ _id: targetDoc._id }, options, mongoOptions)
160
+ if (descendants.length > 0 && options.invokePostHook !== false) {
161
+ await this.postDeleteHook.invoke(descendants)
162
+ }
156
163
  await Promise.all([
157
164
  this.updateEnabledPlugins(targetDoc, {}, options, mongoOptions),
158
165
  this.updateSortOrder(targetDoc, undefined, options, mongoOptions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-content",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
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",