@dynamatix/cat-shared 0.0.95 → 0.0.97

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.
@@ -135,7 +135,12 @@ function applyAuditMiddleware(schema, collectionName) {
135
135
  });
136
136
  }
137
137
  }
138
- logs = logs.filter(log => log.newValue !== log.oldValue);
138
+ logs = logs.filter(log => {
139
+ // Convert null/undefined to empty string for comparison
140
+ const oldVal = log.oldValue ?? '';
141
+ const newVal = log.newValue ?? '';
142
+ return oldVal !== newVal;
143
+ });
139
144
  if (logs.length) {
140
145
  await AuditLog.insertMany(logs);
141
146
  await updateContextAuditCount(contextId, logs.length);
@@ -191,14 +196,17 @@ function applyAuditMiddleware(schema, collectionName) {
191
196
  }
192
197
  }
193
198
 
194
- if (oldValue !== newValue) {
199
+ // Convert null/undefined to empty string for comparison
200
+ const oldVal = lookupOldName ?? oldValue ?? '';
201
+ const newVal = lookupNewName ?? newValue ?? '';
202
+ if (oldVal !== newVal) {
195
203
  const fieldDescription = await resolveDescription(field, result);
196
204
  logs.push({
197
205
  name: fieldDescription,
198
206
  entity: entityDescription,
199
207
  recordId: contextId || result._id,
200
- oldValue: lookupOldName || oldValue,
201
- newValue: lookupNewName || newValue,
208
+ oldValue: oldVal,
209
+ newValue: newVal,
202
210
  createdBy: userId,
203
211
  externalData: {
204
212
  description: entityDescription,
@@ -208,7 +216,12 @@ function applyAuditMiddleware(schema, collectionName) {
208
216
  }
209
217
  }
210
218
  }
211
- logs = logs.filter(log => log.newValue !== log.oldValue);
219
+ logs = logs.filter(log => {
220
+ // Convert null/undefined to empty string for comparison
221
+ const oldVal = log.oldValue ?? '';
222
+ const newVal = log.newValue ?? '';
223
+ return oldVal !== newVal;
224
+ });
212
225
  if (logs.length) {
213
226
  await AuditLog.insertMany(logs);
214
227
  await updateContextAuditCount(contextId, logs.length);
@@ -258,7 +271,9 @@ function applyAuditMiddleware(schema, collectionName) {
258
271
  contextId: contextId || deletedDoc._id
259
272
  }
260
273
  };
261
- if (log.newValue === log.oldValue) {
274
+ const oldVal = log.oldValue ?? '';
275
+ const newVal = log.newValue ?? '';
276
+ if (oldVal === newVal) {
262
277
  return;
263
278
  }
264
279
  await AuditLog.create(log);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/cat-shared",
3
- "version": "0.0.95",
3
+ "version": "0.0.97",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"