@autofleet/shtinker 1.1.5-beta.0 → 1.1.5-beta.10
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/audit-logger.js +6 -0
- package/dist/index.js +2 -1
- package/package.json +3 -3
- package/src/audit-logger.ts +6 -0
- package/src/index.ts +2 -1
package/dist/audit-logger.js
CHANGED
|
@@ -18,6 +18,7 @@ const logger_1 = __importDefault(require("./logger"));
|
|
|
18
18
|
const getAuditContext = () => {
|
|
19
19
|
var _a;
|
|
20
20
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
21
|
+
logger_1.default.info('MATAN getAuditContext currentTrace: ', { currentTrace });
|
|
21
22
|
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);
|
|
22
23
|
return auditContext;
|
|
23
24
|
};
|
|
@@ -40,8 +41,10 @@ class AuditLogger {
|
|
|
40
41
|
modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
|
|
41
42
|
try {
|
|
42
43
|
const auditContext = getAuditContext();
|
|
44
|
+
logger_1.default.info('MATAN auditContext: ', { auditContext });
|
|
43
45
|
if (auditContext) {
|
|
44
46
|
const changedProperties = getChangedFields(instance, options);
|
|
47
|
+
logger_1.default.info('MATAN changedProperties from shtinker:', { changedProperties });
|
|
45
48
|
const payload = {
|
|
46
49
|
entityType: modelName,
|
|
47
50
|
entityId: instance.id,
|
|
@@ -51,6 +54,8 @@ class AuditLogger {
|
|
|
51
54
|
newValue: instance.get(property),
|
|
52
55
|
})),
|
|
53
56
|
};
|
|
57
|
+
const entityId = instance.id;
|
|
58
|
+
logger_1.default.info('MATAN entityId from shtinker:', { entityId });
|
|
54
59
|
this.sendAuditLogRows(payload);
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -73,6 +78,7 @@ class AuditLogger {
|
|
|
73
78
|
sendAuditLogRows(payload) {
|
|
74
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
80
|
try {
|
|
81
|
+
logger_1.default.info('MATAN sendAuditLogRows from shtinker: ', { payload });
|
|
76
82
|
yield this.rabbit.sendToQueue(const_1.AUDIT_LOG_ROWS_QUEUE, payload);
|
|
77
83
|
}
|
|
78
84
|
catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ exports.enableAuditing = enableAuditing;
|
|
|
42
42
|
const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
44
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
45
|
-
logger_1.default.info('
|
|
45
|
+
logger_1.default.info('currentTrace: ', { currentTrace });
|
|
46
46
|
if (currentTrace && currentTrace.context && currentTrace.context.get) {
|
|
47
47
|
const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
|
|
48
48
|
const auditLogContext = {
|
|
@@ -65,6 +65,7 @@ exports.setAuditContext = setAuditContext;
|
|
|
65
65
|
const setRabbitAuditContext = (entityType, action) => (endpoint) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
66
|
var _a;
|
|
67
67
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
68
|
+
logger_1.default.info('MATAN currentTrace: ', currentTrace);
|
|
68
69
|
if ((_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get) {
|
|
69
70
|
const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
|
|
70
71
|
const auditLogContext = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/shtinker",
|
|
3
|
-
"version": "1.1.5-beta.
|
|
3
|
+
"version": "1.1.5-beta.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"@autofleet/errors": "^1.2.2",
|
|
16
16
|
"@autofleet/logger": "^2.0.5",
|
|
17
17
|
"@autofleet/network": "^1.4.7",
|
|
18
|
-
"@autofleet/rabbit": "
|
|
19
|
-
"@autofleet/zehut": "
|
|
18
|
+
"@autofleet/rabbit": "3.2.14-beta.7",
|
|
19
|
+
"@autofleet/zehut": "3.0.8",
|
|
20
20
|
"sequelize-typescript": "^2.1.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
package/src/audit-logger.ts
CHANGED
|
@@ -8,6 +8,7 @@ import logger from './logger';
|
|
|
8
8
|
|
|
9
9
|
const getAuditContext = () => {
|
|
10
10
|
const currentTrace = getCurrentTrace();
|
|
11
|
+
logger.info('MATAN getAuditContext currentTrace: ', { currentTrace });
|
|
11
12
|
const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
|
|
12
13
|
return auditContext;
|
|
13
14
|
};
|
|
@@ -39,8 +40,10 @@ class AuditLogger {
|
|
|
39
40
|
modelType.addHook('afterSave', async (instance: any, options: any) => {
|
|
40
41
|
try {
|
|
41
42
|
const auditContext = getAuditContext();
|
|
43
|
+
logger.info('MATAN auditContext: ', { auditContext });
|
|
42
44
|
if (auditContext) {
|
|
43
45
|
const changedProperties = getChangedFields(instance, options);
|
|
46
|
+
logger.info('MATAN changedProperties from shtinker:', { changedProperties });
|
|
44
47
|
const payload: AuditLogPayload = {
|
|
45
48
|
entityType: modelName,
|
|
46
49
|
entityId: instance.id,
|
|
@@ -50,6 +53,8 @@ class AuditLogger {
|
|
|
50
53
|
newValue: instance.get(property),
|
|
51
54
|
})),
|
|
52
55
|
};
|
|
56
|
+
const entityId = instance.id;
|
|
57
|
+
logger.info('MATAN entityId from shtinker:', { entityId });
|
|
53
58
|
this.sendAuditLogRows(payload);
|
|
54
59
|
}
|
|
55
60
|
} catch (error) {
|
|
@@ -69,6 +74,7 @@ class AuditLogger {
|
|
|
69
74
|
|
|
70
75
|
async sendAuditLogRows(payload: AuditLogPayload): Promise<void> {
|
|
71
76
|
try {
|
|
77
|
+
logger.info('MATAN sendAuditLogRows from shtinker: ', { payload });
|
|
72
78
|
await this.rabbit.sendToQueue(AUDIT_LOG_ROWS_QUEUE, payload);
|
|
73
79
|
} catch (err) {
|
|
74
80
|
logger.error('Failed to send audit log rows', err);
|
package/src/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const setAuditContext = (
|
|
|
19
19
|
) => async (req: any, res: any, next: any): Promise<any> => {
|
|
20
20
|
try {
|
|
21
21
|
const currentTrace = getCurrentTrace();
|
|
22
|
-
logger.info('
|
|
22
|
+
logger.info('currentTrace: ', { currentTrace });
|
|
23
23
|
if (currentTrace && currentTrace.context && currentTrace.context.get) {
|
|
24
24
|
const user = currentTrace.context.get(USER_CONTEXT_KEY);
|
|
25
25
|
const auditLogContext: AuditLogContext = {
|
|
@@ -43,6 +43,7 @@ export const setRabbitAuditContext = (
|
|
|
43
43
|
action: string,
|
|
44
44
|
) => async (endpoint: string): Promise<any> => {
|
|
45
45
|
const currentTrace = getCurrentTrace();
|
|
46
|
+
logger.info('MATAN currentTrace: ', currentTrace);
|
|
46
47
|
if (currentTrace?.context?.get) {
|
|
47
48
|
const user = currentTrace.context.get(USER_CONTEXT_KEY);
|
|
48
49
|
const auditLogContext: AuditLogContext = {
|