@dynamatix/cat-shared 0.0.89 → 0.0.90

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.
@@ -87,6 +87,13 @@ async function resolveEntityDescription(doc, auditConfig) {
87
87
  return value;
88
88
  }
89
89
 
90
+ // Add new function to resolve deletion description
91
+ async function resolveDeletionDescription(doc, auditConfig) {
92
+ if (!auditConfig.descriptionResolutorForDeletion) return '';
93
+ const expression = auditConfig.descriptionResolutorForDeletion;
94
+ return await resolveExpressionDescription(doc, expression, 'direct');
95
+ }
96
+
90
97
  function applyAuditMiddleware(schema, collectionName) {
91
98
  // Handle creation audit
92
99
  schema.post('save', async function (doc) {
@@ -223,9 +230,10 @@ function applyAuditMiddleware(schema, collectionName) {
223
230
  const contextId = context?.contextId;
224
231
 
225
232
  const entityDescription = await resolveEntityDescription(result, auditConfig);
233
+ const deletionDescription = await resolveDeletionDescription(result, auditConfig);
226
234
 
227
235
  const log = {
228
- name: 'Entity Deletion',
236
+ name: deletionDescription || 'Entity Deletion',
229
237
  entity: entityDescription,
230
238
  recordId: contextId || result._id,
231
239
  oldValue: '',
@@ -6,6 +6,7 @@ const auditConfigSchema = new mongoose.Schema({
6
6
  trackCreation: { type: Boolean, default: false },
7
7
  trackDeletion: { type: Boolean, default: false },
8
8
  descriptionResolutorForExternalData: { type: String, default: null },
9
+ descriptionResolutorForDeletion: { type: String, default: null },
9
10
  });
10
11
 
11
12
  const AuditConfigModel = mongoose.models.AuditConfig || mongoose.model('AuditConfig', auditConfigSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/cat-shared",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"