@dynamatix/cat-shared 0.0.85 → 0.0.87

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.
@@ -104,13 +104,21 @@ function applyAuditMiddleware(schema, collectionName) {
104
104
  if (auditConfig.fields?.length) {
105
105
  for (const field of auditConfig.fields) {
106
106
  const newValue = doc[field];
107
+ if (field.endsWith('Lid')) {
108
+ const newlookupDoc = await mongoose.models['Lookup'].findById(newValue).lean();
109
+ if (newlookupDoc) {
110
+ lookupName = newlookupDoc.name;
111
+ } else {
112
+ lookupName = '';
113
+ }
114
+ }
107
115
  const fieldDescription = await resolveDescription(field, doc);
108
116
  logs.push({
109
117
  name: fieldDescription,
110
118
  entity: entityDescription,
111
119
  recordId: contextId || doc._id,
112
120
  oldValue: null,
113
- newValue,
121
+ newValue: lookupName || newValue,
114
122
  createdBy: userId,
115
123
  externalData: {
116
124
  description: entityDescription,
@@ -120,21 +128,6 @@ function applyAuditMiddleware(schema, collectionName) {
120
128
  }
121
129
  }
122
130
 
123
- // Overall document creation log (optional)
124
- logs.push({
125
- name: 'created',
126
- entity: entityDescription,
127
- recordId: contextId || doc._id,
128
- oldValue: null,
129
- newValue: 'Document created',
130
- createdBy: userId,
131
- contextId,
132
- externalData: {
133
- description: entityDescription,
134
- contextId
135
- }
136
- });
137
-
138
131
  if (logs.length) {
139
132
  await AuditLog.insertMany(logs);
140
133
  await updateContextAuditCount(contextId, logs.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/cat-shared",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"