@autofleet/shtinker 1.1.6-beta-3 → 1.1.6-beta-5
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/dist/index.js +4 -1
- package/package.json +2 -2
- package/src/index.ts +5 -1
package/dist/index.js
CHANGED
|
@@ -68,14 +68,17 @@ const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(vo
|
|
|
68
68
|
exports.setAuditContext = setAuditContext;
|
|
69
69
|
const setRabbitAuditContext = (entityType, action) => (endpoint, { userId, automationId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
70
|
var _a;
|
|
71
|
+
console.log({ automationId });
|
|
71
72
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
73
|
+
const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
|
|
74
|
+
const contextAutomationId = currentTrace.context.get('x-af-automation-id');
|
|
72
75
|
if ((_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get) {
|
|
73
76
|
const auditLogContext = {
|
|
74
77
|
entityType,
|
|
75
78
|
action,
|
|
76
79
|
endpoint,
|
|
77
80
|
method: 'rabbit',
|
|
78
|
-
performedBy:
|
|
81
|
+
performedBy: (user === null || user === void 0 ? void 0 : user.id) || contextAutomationId,
|
|
79
82
|
actionOrigin: userId ? types_1.ActionOrigin.USER : types_1.ActionOrigin.AUTOMATION,
|
|
80
83
|
};
|
|
81
84
|
currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditLogContext);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/shtinker",
|
|
3
|
-
"version": "1.1.6-beta-
|
|
3
|
+
"version": "1.1.6-beta-5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@autofleet/logger": "^4.0.6",
|
|
17
17
|
"@autofleet/network": "^1.4.7",
|
|
18
18
|
"@autofleet/netwrok": "^1.0.0",
|
|
19
|
-
"@autofleet/rabbit": "
|
|
19
|
+
"@autofleet/rabbit": "3.2.20-beta-1",
|
|
20
20
|
"@autofleet/zehut": "^3.0.10",
|
|
21
21
|
"sequelize-typescript": "^2.1.5"
|
|
22
22
|
},
|
package/src/index.ts
CHANGED
|
@@ -45,14 +45,18 @@ export const setRabbitAuditContext = (
|
|
|
45
45
|
entityType: string,
|
|
46
46
|
action: string,
|
|
47
47
|
) => async (endpoint: string, { userId, automationId }): Promise<any> => {
|
|
48
|
+
console.log({ automationId });
|
|
49
|
+
|
|
48
50
|
const currentTrace = getCurrentTrace();
|
|
51
|
+
const user = currentTrace.context.get(USER_CONTEXT_KEY);
|
|
52
|
+
const contextAutomationId = currentTrace.context.get('x-af-automation-id');
|
|
49
53
|
if (currentTrace?.context?.get) {
|
|
50
54
|
const auditLogContext: AuditLogContext = {
|
|
51
55
|
entityType,
|
|
52
56
|
action,
|
|
53
57
|
endpoint,
|
|
54
58
|
method: 'rabbit',
|
|
55
|
-
performedBy:
|
|
59
|
+
performedBy: user?.id || contextAutomationId,
|
|
56
60
|
actionOrigin: userId ? ActionOrigin.USER : ActionOrigin.AUTOMATION,
|
|
57
61
|
};
|
|
58
62
|
currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditLogContext);
|