@autofleet/shtinker 1.1.6-beta-2 → 1.1.6-beta-4
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.d.ts +4 -1
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/src/index.ts +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import AuditLogger from './audit-logger';
|
|
|
2
2
|
import { AuditLoggerOptions } from './types';
|
|
3
3
|
export declare const enableAuditing: (options: AuditLoggerOptions) => void;
|
|
4
4
|
export declare const setAuditContext: (entityType: string, action: string) => (req: any, res: any, next: any) => Promise<any>;
|
|
5
|
-
export declare const setRabbitAuditContext: (entityType: string, action: string) => (endpoint: string
|
|
5
|
+
export declare const setRabbitAuditContext: (entityType: string, action: string) => (endpoint: string, { userId, automationId }: {
|
|
6
|
+
userId: any;
|
|
7
|
+
automationId: any;
|
|
8
|
+
}) => Promise<any>;
|
|
6
9
|
export * from './types';
|
|
7
10
|
export * from './const';
|
|
8
11
|
export default AuditLogger;
|
package/dist/index.js
CHANGED
|
@@ -66,17 +66,17 @@ const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(vo
|
|
|
66
66
|
return next();
|
|
67
67
|
});
|
|
68
68
|
exports.setAuditContext = setAuditContext;
|
|
69
|
-
const setRabbitAuditContext = (entityType, action) => (endpoint) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const setRabbitAuditContext = (entityType, action) => (endpoint, { userId, automationId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
70
|
var _a;
|
|
71
71
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
72
72
|
if ((_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get) {
|
|
73
|
-
const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
|
|
74
73
|
const auditLogContext = {
|
|
75
74
|
entityType,
|
|
76
75
|
action,
|
|
77
76
|
endpoint,
|
|
78
77
|
method: 'rabbit',
|
|
79
|
-
performedBy:
|
|
78
|
+
performedBy: userId || automationId,
|
|
79
|
+
actionOrigin: userId ? types_1.ActionOrigin.USER : types_1.ActionOrigin.AUTOMATION,
|
|
80
80
|
};
|
|
81
81
|
currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditLogContext);
|
|
82
82
|
yield auditLogger.sendAuditLogContext(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-4",
|
|
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
|
@@ -44,16 +44,16 @@ export const setAuditContext = (
|
|
|
44
44
|
export const setRabbitAuditContext = (
|
|
45
45
|
entityType: string,
|
|
46
46
|
action: string,
|
|
47
|
-
) => async (endpoint: string): Promise<any> => {
|
|
47
|
+
) => async (endpoint: string, { userId, automationId }): Promise<any> => {
|
|
48
48
|
const currentTrace = getCurrentTrace();
|
|
49
49
|
if (currentTrace?.context?.get) {
|
|
50
|
-
const user = currentTrace.context.get(USER_CONTEXT_KEY);
|
|
51
50
|
const auditLogContext: AuditLogContext = {
|
|
52
51
|
entityType,
|
|
53
52
|
action,
|
|
54
53
|
endpoint,
|
|
55
54
|
method: 'rabbit',
|
|
56
|
-
performedBy:
|
|
55
|
+
performedBy: userId || automationId,
|
|
56
|
+
actionOrigin: userId ? ActionOrigin.USER : ActionOrigin.AUTOMATION,
|
|
57
57
|
};
|
|
58
58
|
currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditLogContext);
|
|
59
59
|
await auditLogger.sendAuditLogContext(auditLogContext);
|