@estgbue/mezgeb 0.0.47 → 0.0.49
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/mezgeb/listener/controllers/audit-log-command.controller.d.ts +4 -1
- package/dist/mezgeb/listener/controllers/audit-log-command.controller.d.ts.map +1 -1
- package/dist/mezgeb/listener/services/audit-log-command.service.d.ts +4 -1
- package/dist/mezgeb/listener/services/audit-log-command.service.d.ts.map +1 -1
- package/dist/mezgeb/listener/services/audit-log-command.service.js +8 -5
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ export declare class AuditLogCommandController {
|
|
|
6
6
|
handleAuditLog(data: CreateEventDTO): Promise<void>;
|
|
7
7
|
handleApproveTransaction(payload: ChangeEventDTO): Promise<void>;
|
|
8
8
|
handleRollbackTransaction(payload: ChangeEventDTO): Promise<void>;
|
|
9
|
-
getAuditLogs(entityId: string, application: string, skip: number, take: number): Promise<
|
|
9
|
+
getAuditLogs(entityId: string, application: string, skip: number, take: number): Promise<{
|
|
10
|
+
count: number;
|
|
11
|
+
items: import("../entities/audit-log-command.entity").AuditLogCommand[];
|
|
12
|
+
}>;
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=audit-log-command.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-log-command.controller.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/controllers/audit-log-command.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAI/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElE,qBAGa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,sBAAsB;IAI9D,cAAc,CAAC,IAAI,EAAE,cAAc;IAMnC,wBAAwB,CAAC,OAAO,EAAE,cAAc;IAMhD,yBAAyB,CAAC,OAAO,EAAE,cAAc;IAiBjD,YAAY,CACG,QAAQ,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"audit-log-command.controller.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/controllers/audit-log-command.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAI/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElE,qBAGa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,sBAAsB;IAI9D,cAAc,CAAC,IAAI,EAAE,cAAc;IAMnC,wBAAwB,CAAC,OAAO,EAAE,cAAc;IAMhD,yBAAyB,CAAC,OAAO,EAAE,cAAc;IAiBjD,YAAY,CACG,QAAQ,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM;;;;CAQ9B"}
|
|
@@ -15,7 +15,10 @@ export declare class AuditLogCommandService {
|
|
|
15
15
|
getAuditLogs(entityId: string, application: string, paginate?: {
|
|
16
16
|
skip?: number;
|
|
17
17
|
take?: number;
|
|
18
|
-
}): Promise<
|
|
18
|
+
}): Promise<{
|
|
19
|
+
count: number;
|
|
20
|
+
items: AuditLogCommand[];
|
|
21
|
+
}>;
|
|
19
22
|
private getAuditItemById;
|
|
20
23
|
private parseInput;
|
|
21
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-log-command.service.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/services/audit-log-command.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEjF,qBACa,sBAAsB;IAG/B,OAAO,CAAC,kBAAkB;IAE1B,OAAO,CAAC,yBAAyB;gBAFzB,kBAAkB,EAAE,UAAU,CAAC,QAAQ,CAAC,EAExC,yBAAyB,EAAE,UAAU,CAAC,eAAe,CAAC;IAG1D,MAAM,CAAC,QAAQ,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"audit-log-command.service.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/services/audit-log-command.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEjF,qBACa,sBAAsB;IAG/B,OAAO,CAAC,kBAAkB;IAE1B,OAAO,CAAC,yBAAyB;gBAFzB,kBAAkB,EAAE,UAAU,CAAC,QAAQ,CAAC,EAExC,yBAAyB,EAAE,UAAU,CAAC,eAAe,CAAC;IAG1D,MAAM,CAAC,QAAQ,EAAE,cAAc;IAgB/B,MAAM,CAAC,QAAQ,EAAE,cAAc;IA+D/B,MAAM,CAAC,QAAQ,EAAE,cAAc;IAiC/B,YAAY,CAChB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,cAAc,GAAG,cAAc,EACvC,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM;IA0CpB,OAAO,CAAC,sBAAsB;IAI9B,sBAAsB,CAAC,IAAI,EAAE,MAAM;IAsB7B,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;;;;YAyCnC,gBAAgB;IAgB9B,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -37,11 +37,12 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
37
37
|
const auditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, itemData), { auditLogId: itemData.requestId, queryMethod: 'INSERT' }));
|
|
38
38
|
common_1.Logger.log(`Creating insert audit log command for ${itemData.entityName} with ID ${itemData.entityId}`);
|
|
39
39
|
yield this.auditLogCommandRepository.insert(auditItem);
|
|
40
|
+
yield this.auditParents(itemData.entity, 'INSERT_CHILD', itemData.entityName, itemData.requestId);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
update(itemData) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
var _a, _b, _c, _d
|
|
45
|
+
var _a, _b, _c, _d;
|
|
45
46
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
46
47
|
const after = (_b = itemData.after) !== null && _b !== void 0 ? _b : {};
|
|
47
48
|
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;
|
|
@@ -75,7 +76,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
75
76
|
}
|
|
76
77
|
if (changes.length === 0)
|
|
77
78
|
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(
|
|
79
|
+
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
80
|
console.log({ changes });
|
|
80
81
|
common_1.Logger.log(`Creating update audit log command for ${itemData.entityName} with ID ${entityId} from ${itemData.before} to ${itemData.after}`);
|
|
81
82
|
yield this.auditLogCommandRepository.insert(newAuditItem);
|
|
@@ -83,7 +84,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
83
84
|
}
|
|
84
85
|
delete(itemData) {
|
|
85
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
var _a, _b
|
|
87
|
+
var _a, _b;
|
|
87
88
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
88
89
|
const entityId = (_b = itemData.entityId) !== null && _b !== void 0 ? _b : before === null || before === void 0 ? void 0 : before.id;
|
|
89
90
|
common_1.Logger.log(`Creating delete audit log command for ${itemData.entityName} with ID ${entityId}`);
|
|
@@ -92,8 +93,9 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
92
93
|
const auditItem = yield this.getAuditItemById(itemData.entityName, entityId);
|
|
93
94
|
if (!auditItem)
|
|
94
95
|
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(
|
|
96
|
+
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
97
|
yield this.auditLogCommandRepository.insert(newAuditItem);
|
|
98
|
+
yield this.auditParents(auditItem.entity, 'DELETE_CHILD', itemData.entityName, itemData.requestId);
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
auditParents(entity, method, childEntityName, auditLogId) {
|
|
@@ -177,7 +179,8 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
177
179
|
if (paginate) {
|
|
178
180
|
dataQuery.skip((_a = paginate.skip) !== null && _a !== void 0 ? _a : 0).take((_b = paginate.take) !== null && _b !== void 0 ? _b : 10);
|
|
179
181
|
}
|
|
180
|
-
|
|
182
|
+
const [items, count] = yield dataQuery.getManyAndCount();
|
|
183
|
+
return { count, items };
|
|
181
184
|
});
|
|
182
185
|
}
|
|
183
186
|
getAuditItemById(entityName, entityId) {
|