@estgbue/mezgeb 0.0.43 → 0.0.45
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/client/client-save-update.d.ts +1 -0
- package/dist/mezgeb/client/client-save-update.d.ts.map +1 -1
- package/dist/mezgeb/client/client-save-update.js +6 -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 +5 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Repository, FindOptionsWhere, ObjectLiteral } from "typeorm";
|
|
2
2
|
export declare const safeSave: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>, patch: Partial<T>) => Promise<T>;
|
|
3
|
+
export declare const safeRemove: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>) => Promise<T>;
|
|
3
4
|
//# sourceMappingURL=client-save-update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-save-update.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client-save-update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,QAAQ,GAAU,CAAC,SAAS,aAAa,EACpD,MAAM,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,gBAAgB,CAAC,CAAC,CAAC,EAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,KAChB,OAAO,CAAC,CAAC,CAMX,CAAA"}
|
|
1
|
+
{"version":3,"file":"client-save-update.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client-save-update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,QAAQ,GAAU,CAAC,SAAS,aAAa,EACpD,MAAM,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,gBAAgB,CAAC,CAAC,CAAC,EAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,KAChB,OAAO,CAAC,CAAC,CAMX,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,CAAC,SAAS,aAAa,EACtD,MAAM,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAC9B,OAAO,CAAC,CAAC,CAIX,CAAA"}
|
|
@@ -9,10 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.safeSave = void 0;
|
|
12
|
+
exports.safeRemove = exports.safeSave = void 0;
|
|
13
13
|
const safeSave = (repo, conditions, patch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
14
|
const entity = yield repo.findOneByOrFail(conditions);
|
|
15
15
|
Object.assign(entity, patch);
|
|
16
16
|
return repo.save(entity);
|
|
17
17
|
});
|
|
18
18
|
exports.safeSave = safeSave;
|
|
19
|
+
const safeRemove = (repo, conditions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const entity = yield repo.findOneByOrFail(conditions);
|
|
21
|
+
return repo.remove(entity);
|
|
22
|
+
});
|
|
23
|
+
exports.safeRemove = safeRemove;
|
|
@@ -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;IAU/B,MAAM,CAAC,QAAQ,EAAE,cAAc;IA+D/B,MAAM,CAAC,QAAQ,EAAE,cAAc;IA2B/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;YAwCnC,gBAAgB;IAgB9B,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -35,6 +35,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
35
35
|
create(itemData) {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
const auditItem = this.auditLogCommandRepository.create(Object.assign(Object.assign({}, itemData), { auditLogId: itemData.requestId, queryMethod: 'INSERT' }));
|
|
38
|
+
common_1.Logger.log(`Creating insert audit log command for ${itemData.entityName} with ID ${itemData.entityId}`);
|
|
38
39
|
yield this.auditLogCommandRepository.insert(auditItem);
|
|
39
40
|
});
|
|
40
41
|
}
|
|
@@ -44,6 +45,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
44
45
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
45
46
|
const after = (_b = itemData.after) !== null && _b !== void 0 ? _b : {};
|
|
46
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;
|
|
48
|
+
common_1.Logger.log({ entityId, before, after });
|
|
47
49
|
if (!entityId || !itemData.entityName)
|
|
48
50
|
return;
|
|
49
51
|
const auditItem = yield this.getAuditItemById(itemData.entityName, entityId);
|
|
@@ -74,6 +76,8 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
74
76
|
if (changes.length === 0)
|
|
75
77
|
return;
|
|
76
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((_e = itemData.createdAt) !== null && _e !== void 0 ? _e : new Date()), queryMethod: 'UPDATE', changes }));
|
|
79
|
+
console.log({ changes });
|
|
80
|
+
common_1.Logger.log(`Creating update audit log command for ${itemData.entityName} with ID ${entityId} from ${itemData.before} to ${itemData.after}`);
|
|
77
81
|
yield this.auditLogCommandRepository.insert(newAuditItem);
|
|
78
82
|
});
|
|
79
83
|
}
|
|
@@ -82,6 +86,7 @@ let AuditLogCommandService = class AuditLogCommandService {
|
|
|
82
86
|
var _a, _b, _c;
|
|
83
87
|
const before = (_a = itemData.before) !== null && _a !== void 0 ? _a : {};
|
|
84
88
|
const entityId = (_b = itemData.entityId) !== null && _b !== void 0 ? _b : before === null || before === void 0 ? void 0 : before.id;
|
|
89
|
+
common_1.Logger.log(`Creating delete audit log command for ${itemData.entityName} with ID ${entityId}`);
|
|
85
90
|
if (!entityId || !itemData.entityName)
|
|
86
91
|
return;
|
|
87
92
|
const auditItem = yield this.getAuditItemById(itemData.entityName, entityId);
|