@estgbue/mezgeb 0.0.49 → 0.0.51
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 -0
- package/dist/mezgeb/listener/controllers/audit-log-command.controller.d.ts.map +1 -1
- package/dist/mezgeb/listener/controllers/audit-log-command.controller.js +26 -0
- package/dist/mezgeb/listener/services/audit-log-command.service.d.ts +8 -0
- package/dist/mezgeb/listener/services/audit-log-command.service.d.ts.map +1 -1
- package/dist/mezgeb/listener/services/audit-log-command.service.js +35 -26
- package/package.json +1 -1
|
@@ -6,6 +6,10 @@ 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
|
+
getAllAuditLogs(application: string, skip: number, take: number): Promise<{
|
|
10
|
+
count: number;
|
|
11
|
+
items: import("../entities/audit-log-command.entity").AuditLogCommand[];
|
|
12
|
+
}>;
|
|
9
13
|
getAuditLogs(entityId: string, application: string, skip: number, take: number): Promise<{
|
|
10
14
|
count: number;
|
|
11
15
|
items: import("../entities/audit-log-command.entity").AuditLogCommand[];
|
|
@@ -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;
|
|
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;IAkBjD,eAAe,CACG,WAAW,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM;;;;IAqBvB,YAAY,CACG,QAAQ,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM;;;;CAQ9B"}
|
|
@@ -48,6 +48,11 @@ let AuditLogCommandController = class AuditLogCommandController {
|
|
|
48
48
|
yield this.auditLogService.delete(payload);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
getAllAuditLogs(application, skip, take) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return yield this.auditLogService.getAllAuditLogs(application, { skip, take });
|
|
54
|
+
});
|
|
55
|
+
}
|
|
51
56
|
getAuditLogs(entityId, application, skip, take) {
|
|
52
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
58
|
return yield this.auditLogService.getAuditLogs(entityId, application, { skip, take });
|
|
@@ -76,6 +81,27 @@ __decorate([
|
|
|
76
81
|
__metadata("design:paramtypes", [mezgeb_dto_1.ChangeEventDTO]),
|
|
77
82
|
__metadata("design:returntype", Promise)
|
|
78
83
|
], AuditLogCommandController.prototype, "handleRollbackTransaction", null);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, common_1.Get)('all/:application'),
|
|
86
|
+
(0, swagger_1.ApiQuery)({
|
|
87
|
+
name: 'skip',
|
|
88
|
+
type: Number,
|
|
89
|
+
description: 'Number of records to skip for pagination. Optional',
|
|
90
|
+
required: false,
|
|
91
|
+
}),
|
|
92
|
+
(0, swagger_1.ApiQuery)({
|
|
93
|
+
name: 'take',
|
|
94
|
+
type: Number,
|
|
95
|
+
description: 'Number of records to take for pagination. Optional',
|
|
96
|
+
required: false,
|
|
97
|
+
}),
|
|
98
|
+
__param(0, (0, common_1.Param)('application')),
|
|
99
|
+
__param(1, (0, common_1.Query)('skip')),
|
|
100
|
+
__param(2, (0, common_1.Query)('take')),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [String, Number, Number]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], AuditLogCommandController.prototype, "getAllAuditLogs", null);
|
|
79
105
|
__decorate([
|
|
80
106
|
(0, common_1.Get)('/:entityId/:application'),
|
|
81
107
|
(0, swagger_1.ApiQuery)({
|
|
@@ -12,6 +12,14 @@ export declare class AuditLogCommandService {
|
|
|
12
12
|
auditParents(entity: any, method: 'INSERT_CHILD' | 'DELETE_CHILD', childEntityName: string, auditLogId: string): Promise<void>;
|
|
13
13
|
private changeCamelToSnakeCase;
|
|
14
14
|
pluralizeAndChangeCase(word: string): string;
|
|
15
|
+
private buildAuditLogQuery;
|
|
16
|
+
getAllAuditLogs(application: string, paginate?: {
|
|
17
|
+
skip?: number;
|
|
18
|
+
take?: number;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: AuditLogCommand[];
|
|
22
|
+
}>;
|
|
15
23
|
getAuditLogs(entityId: string, application: string, paginate?: {
|
|
16
24
|
skip?: number;
|
|
17
25
|
take?: number;
|
|
@@ -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;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;
|
|
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;IAsBnC,OAAO,CAAC,kBAAkB;IA0CpB,eAAe,CACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;;;;IAO3C,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;;;;YAOnC,gBAAgB;IAgB9B,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -151,34 +151,43 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
151
151
|
}
|
|
152
152
|
return word + 's';
|
|
153
153
|
}
|
|
154
|
+
buildAuditLogQuery(application, entityId, paginate = {}) {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
const dataQuery = this.auditLogCommandRepository.createQueryBuilder('audit_log_commands');
|
|
157
|
+
dataQuery
|
|
158
|
+
.leftJoinAndSelect('audit_log_commands.auditLog', 'auditLog')
|
|
159
|
+
.andWhere('(audit_log_commands.auditLogId IS NULL OR auditLog.application = :application)', { application })
|
|
160
|
+
.andWhere('(audit_log_commands.auditLogId IS NULL OR auditLog.status = :status)', { status: 'Commit' })
|
|
161
|
+
.select([
|
|
162
|
+
'audit_log_commands.id',
|
|
163
|
+
'audit_log_commands.createdAt',
|
|
164
|
+
'audit_log_commands.deletedAt',
|
|
165
|
+
'audit_log_commands.entityName',
|
|
166
|
+
'audit_log_commands.queryMethod',
|
|
167
|
+
'audit_log_commands.changes',
|
|
168
|
+
'audit_log_commands.payload',
|
|
169
|
+
'auditLog.id',
|
|
170
|
+
'auditLog.user',
|
|
171
|
+
])
|
|
172
|
+
.addOrderBy('audit_log_commands.createdAt', 'DESC');
|
|
173
|
+
if (entityId) {
|
|
174
|
+
dataQuery.andWhere('audit_log_commands.entityId = :entityId', { entityId });
|
|
175
|
+
}
|
|
176
|
+
if (paginate) {
|
|
177
|
+
dataQuery.skip((_a = paginate.skip) !== null && _a !== void 0 ? _a : 0).take((_b = paginate.take) !== null && _b !== void 0 ? _b : 10);
|
|
178
|
+
}
|
|
179
|
+
return dataQuery;
|
|
180
|
+
}
|
|
181
|
+
getAllAuditLogs(application_1) {
|
|
182
|
+
return __awaiter(this, arguments, void 0, function* (application, paginate = {}) {
|
|
183
|
+
const dataQuery = this.buildAuditLogQuery(application, undefined, paginate);
|
|
184
|
+
const [items, count] = yield dataQuery.getManyAndCount();
|
|
185
|
+
return { count, items };
|
|
186
|
+
});
|
|
187
|
+
}
|
|
154
188
|
getAuditLogs(entityId_1, application_1) {
|
|
155
189
|
return __awaiter(this, arguments, void 0, function* (entityId, application, paginate = {}) {
|
|
156
|
-
|
|
157
|
-
const dataQuery = this.auditLogCommandRepository.createQueryBuilder('audit_log_commands');
|
|
158
|
-
dataQuery
|
|
159
|
-
.leftJoinAndSelect('audit_log_commands.auditLog', 'auditLog')
|
|
160
|
-
.andWhere('(audit_log_commands.auditLogId IS NULL OR auditLog.application = :application)', { application })
|
|
161
|
-
// .andWhere(
|
|
162
|
-
// `(audit_log_commands.auditLogId IS NULL OR ("auditLog"."user"->>'organizationId')::uuid = :organizationId)`,
|
|
163
|
-
// { organizationId: user.organization.id },
|
|
164
|
-
// )
|
|
165
|
-
.andWhere('(audit_log_commands.auditLogId IS NULL OR auditLog.status = :status)', { status: 'Commit' })
|
|
166
|
-
.andWhere('audit_log_commands.entityId = :entityId', { entityId })
|
|
167
|
-
.select([
|
|
168
|
-
'audit_log_commands.id',
|
|
169
|
-
'audit_log_commands.createdAt',
|
|
170
|
-
'audit_log_commands.deletedAt',
|
|
171
|
-
'audit_log_commands.entityName',
|
|
172
|
-
'audit_log_commands.queryMethod',
|
|
173
|
-
'audit_log_commands.changes',
|
|
174
|
-
'audit_log_commands.payload',
|
|
175
|
-
'auditLog.id',
|
|
176
|
-
'auditLog.user',
|
|
177
|
-
])
|
|
178
|
-
.addOrderBy('audit_log_commands.createdAt', 'DESC');
|
|
179
|
-
if (paginate) {
|
|
180
|
-
dataQuery.skip((_a = paginate.skip) !== null && _a !== void 0 ? _a : 0).take((_b = paginate.take) !== null && _b !== void 0 ? _b : 10);
|
|
181
|
-
}
|
|
190
|
+
const dataQuery = this.buildAuditLogQuery(application, entityId, paginate);
|
|
182
191
|
const [items, count] = yield dataQuery.getManyAndCount();
|
|
183
192
|
return { count, items };
|
|
184
193
|
});
|