@autofleet/shtinker 1.2.3-beta.1 → 1.2.3-beta.3

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.
@@ -74,8 +74,10 @@ class AuditLogger {
74
74
  const currentTrace = (0, zehut_1.getCurrentPayload)();
75
75
  const auditContext = (_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get(const_1.AUDIT_LOG_CONTEXT_KEY);
76
76
  if (auditContext) {
77
- auditContext.entityId = instance.id;
78
- currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditContext);
77
+ if (auditContext.action.includes('bulk')) {
78
+ auditContext.entityId = instance.id;
79
+ currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditContext);
80
+ }
79
81
  const changedFieldsRows = getChangedFieldsRows(instance, options);
80
82
  const changedCustomFieldsRows = getChangedCustomFieldsRows(instance);
81
83
  const payload = {
package/dist/index.js CHANGED
@@ -62,16 +62,21 @@ const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(vo
62
62
  };
63
63
  currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditLogContext);
64
64
  const sendAuditLogContextEvent = () => __awaiter(void 0, void 0, void 0, function* () {
65
- try {
66
- yield auditLogger.sendAuditLogContext(auditLogContext);
67
- }
68
- finally {
69
- req.removeListener('end', sendAuditLogContextEvent);
70
- req.removeListener('error', sendAuditLogContextEvent);
71
- }
65
+ req.off('end', sendAuditLogContextEvent);
66
+ req.off('close', sendAuditLogContextEvent);
67
+ req.off('aborted', sendAuditLogContextEvent);
68
+ req.off('error', sendAuditLogContextEvent);
69
+ yield auditLogger.sendAuditLogContext(auditLogContext);
72
70
  });
73
- req.once('end', sendAuditLogContextEvent);
74
- req.once('error', sendAuditLogContextEvent);
71
+ if (action.includes('bulk')) {
72
+ req.once('end', sendAuditLogContextEvent);
73
+ req.once('close', sendAuditLogContextEvent);
74
+ req.once('aborted', sendAuditLogContextEvent);
75
+ req.once('error', sendAuditLogContextEvent);
76
+ }
77
+ else {
78
+ yield auditLogger.sendAuditLogContext(auditLogContext);
79
+ }
75
80
  }
76
81
  catch (err) {
77
82
  logger_1.default.error('coudln\'t set audit context', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.2.3-beta.1",
3
+ "version": "1.2.3-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "typescript": "^4.9.5"
36
36
  },
37
37
  "peerDependencies": {
38
- "@autofleet/zehut": "3.1.2-beta.3"
38
+ "@autofleet/zehut": "3.1.2-beta.4"
39
39
  },
40
40
  "author": "Autofleet",
41
41
  "license": "ISC"