@autofleet/shtinker 1.2.3-beta.0 → 1.2.3-beta.1
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.
- package/package.json +2 -2
- package/src/audit-logger.ts +4 -2
- package/src/index.ts +14 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/shtinker",
|
|
3
|
-
"version": "1.2.3-beta.
|
|
3
|
+
"version": "1.2.3-beta.1",
|
|
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.
|
|
38
|
+
"@autofleet/zehut": "3.1.2-beta.3"
|
|
39
39
|
},
|
|
40
40
|
"author": "Autofleet",
|
|
41
41
|
"license": "ISC"
|
package/src/audit-logger.ts
CHANGED
|
@@ -77,8 +77,10 @@ class AuditLogger {
|
|
|
77
77
|
const currentTrace = getCurrentTrace();
|
|
78
78
|
const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
|
|
79
79
|
if (auditContext) {
|
|
80
|
-
auditContext.
|
|
81
|
-
|
|
80
|
+
if (auditContext.action.includes('bulk')) {
|
|
81
|
+
auditContext.entityId = instance.id;
|
|
82
|
+
currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditContext);
|
|
83
|
+
}
|
|
82
84
|
const changedFieldsRows = getChangedFieldsRows(instance, options);
|
|
83
85
|
const changedCustomFieldsRows = getChangedCustomFieldsRows(instance);
|
|
84
86
|
const payload: AuditLogPayload = {
|
package/src/index.ts
CHANGED
|
@@ -39,16 +39,22 @@ export const setAuditContext = (
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditLogContext);
|
|
42
|
+
|
|
42
43
|
const sendAuditLogContextEvent = async () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
44
|
+
req.off('end', sendAuditLogContextEvent);
|
|
45
|
+
req.off('close', sendAuditLogContextEvent);
|
|
46
|
+
req.off('aborted', sendAuditLogContextEvent);
|
|
47
|
+
req.off('error', sendAuditLogContextEvent);
|
|
48
|
+
await auditLogger.sendAuditLogContext(auditLogContext);
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (action.includes('bulk')) {
|
|
51
|
+
req.once('end', sendAuditLogContextEvent);
|
|
52
|
+
req.once('close', sendAuditLogContextEvent);
|
|
53
|
+
req.once('aborted', sendAuditLogContextEvent);
|
|
54
|
+
req.once('error', sendAuditLogContextEvent);
|
|
55
|
+
} else {
|
|
56
|
+
await auditLogger.sendAuditLogContext(auditLogContext);
|
|
57
|
+
}
|
|
52
58
|
} catch (err) {
|
|
53
59
|
logger.error('coudln\'t set audit context', err);
|
|
54
60
|
}
|