@estgbue/mezgeb 0.0.46 → 0.0.48
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.
|
@@ -61,16 +61,16 @@ let ClientLoggerInterceptor = class ClientLoggerInterceptor {
|
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
63
|
handleRequestAuditInitiation(context, next, requestId) {
|
|
64
|
-
var _a, _b, _c, _d, _e;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
65
65
|
const req = context.switchToHttp().getRequest();
|
|
66
|
-
const { ip, ips, method, originalUrl, headers, body, params, user } = req;
|
|
66
|
+
const { ip, ips, method, originalUrl, headers, body, params, auditUser, user } = req;
|
|
67
67
|
const ds = this.connection;
|
|
68
|
-
const userPayload = (ds.user = Object.assign({ id: user === null || user === void 0 ? void 0 : user.id, name: `${user === null || user === void 0 ? void 0 : user.firstName} ${user === null || user === void 0 ? void 0 : user.lastName}`, organizationId: (
|
|
68
|
+
const userPayload = (ds.user = Object.assign({ id: (_a = auditUser === null || auditUser === void 0 ? void 0 : auditUser.id) !== null && _a !== void 0 ? _a : user === null || user === void 0 ? void 0 : user.id, name: `${(_b = auditUser === null || auditUser === void 0 ? void 0 : auditUser.firstName) !== null && _b !== void 0 ? _b : user === null || user === void 0 ? void 0 : user.firstName} ${(_c = auditUser === null || auditUser === void 0 ? void 0 : auditUser.lastName) !== null && _c !== void 0 ? _c : user === null || user === void 0 ? void 0 : user.lastName}`, organizationId: (_e = (_d = auditUser === null || auditUser === void 0 ? void 0 : auditUser.organization) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : (_f = user === null || user === void 0 ? void 0 : user.organization) === null || _f === void 0 ? void 0 : _f.id, organizationName: (_h = (_g = auditUser === null || auditUser === void 0 ? void 0 : auditUser.organization) === null || _g === void 0 ? void 0 : _g.name) !== null && _h !== void 0 ? _h : (_j = user === null || user === void 0 ? void 0 : user.organization) === null || _j === void 0 ? void 0 : _j.name }, (auditUser !== null && auditUser !== void 0 ? auditUser : user)));
|
|
69
69
|
const log = {
|
|
70
70
|
id: requestId,
|
|
71
71
|
requestMethod: method,
|
|
72
|
-
application: (
|
|
73
|
-
module: (
|
|
72
|
+
application: (_l = (_k = process.env.APPLICATION_NAME) !== null && _k !== void 0 ? _k : process.env.APP_NAME) !== null && _l !== void 0 ? _l : 'DEFAULT',
|
|
73
|
+
module: (_m = originalUrl.split('/')[2]) !== null && _m !== void 0 ? _m : 'DEFAULT',
|
|
74
74
|
requestBody: originalUrl.includes('/auth') ? {} : body,
|
|
75
75
|
requestHeader: this.mapHeaders(headers),
|
|
76
76
|
statusCode: 201,
|
|
@@ -41,7 +41,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
41
41
|
}
|
|
42
42
|
update(itemData) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
var _a, _b, _c, _d
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
45
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
46
46
|
const after = (_b = itemData.after) !== null && _b !== void 0 ? _b : {};
|
|
47
47
|
const entityId = (_d = (_c = itemData.entityId) !== null && _c !== void 0 ? _c : before === null || before === void 0 ? void 0 : before.id) !== null && _d !== void 0 ? _d : after === null || after === void 0 ? void 0 : after.id;
|
|
@@ -57,7 +57,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
57
57
|
...Object.keys(after || {}),
|
|
58
58
|
]);
|
|
59
59
|
for (const key of keys) {
|
|
60
|
-
if (key === 'updatedAt')
|
|
60
|
+
if (key === 'updatedAt' || key === 'amharicUpdatedAt')
|
|
61
61
|
continue;
|
|
62
62
|
const fromValue = before === null || before === void 0 ? void 0 : before[key];
|
|
63
63
|
const toValue = after === null || after === void 0 ? void 0 : after[key];
|
|
@@ -75,7 +75,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
75
75
|
}
|
|
76
76
|
if (changes.length === 0)
|
|
77
77
|
return;
|
|
78
|
-
const newAuditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, auditItem), { entity: after, entityId, auditLogId: itemData.requestId, parentId: auditItem.id, id: undefined, createdAt: new Date(
|
|
78
|
+
const newAuditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, auditItem), { entity: after, entityId, auditLogId: itemData.requestId, parentId: auditItem.id, id: undefined, createdAt: new Date(), queryMethod: 'UPDATE', changes }));
|
|
79
79
|
console.log({ changes });
|
|
80
80
|
common_1.Logger.log(`Creating update audit log command for ${itemData.entityName} with ID ${entityId} from ${itemData.before} to ${itemData.after}`);
|
|
81
81
|
yield this.auditLogCommandRepository.insert(newAuditItem);
|
|
@@ -83,7 +83,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
83
83
|
}
|
|
84
84
|
delete(itemData) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
var _a, _b
|
|
86
|
+
var _a, _b;
|
|
87
87
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
88
88
|
const entityId = (_b = itemData.entityId) !== null && _b !== void 0 ? _b : before === null || before === void 0 ? void 0 : before.id;
|
|
89
89
|
common_1.Logger.log(`Creating delete audit log command for ${itemData.entityName} with ID ${entityId}`);
|
|
@@ -92,7 +92,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
92
92
|
const auditItem = yield this.getAuditItemById(itemData.entityName, entityId);
|
|
93
93
|
if (!auditItem)
|
|
94
94
|
return;
|
|
95
|
-
const newAuditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, auditItem), { entity: before, entityId, auditLogId: itemData.requestId, parentId: auditItem.id, id: undefined, createdAt: new Date(
|
|
95
|
+
const newAuditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, auditItem), { entity: before, entityId, auditLogId: itemData.requestId, parentId: auditItem.id, id: undefined, createdAt: new Date(), queryMethod: 'DELETE' }));
|
|
96
96
|
yield this.auditLogCommandRepository.insert(newAuditItem);
|
|
97
97
|
});
|
|
98
98
|
}
|