@golemio/audit-logs 1.0.1-dev.1660557374 → 1.0.1-dev.1754452191
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/helpers/AuditLogger.js +6 -19
- package/dist/helpers/AuditLogger.js.map +1 -1
- package/dist/repositories/AuditLogsRepository.js +24 -39
- package/dist/repositories/AuditLogsRepository.js.map +1 -1
- package/dist/transformations/AuditLogTransformation.js +6 -1
- package/dist/transformations/AuditLogTransformation.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AuditLogger = void 0;
|
|
13
4
|
const AuditLogsRepository_1 = require("../repositories/AuditLogsRepository");
|
|
@@ -17,17 +8,13 @@ class AuditLogger {
|
|
|
17
8
|
this.auditLogsRepository = new AuditLogsRepository_1.AuditLogsRepository(databaseConnector, logger, config);
|
|
18
9
|
this.auditLogTransformation = new AuditLogTransformation_1.AuditLogTransformation();
|
|
19
10
|
}
|
|
20
|
-
log(auditLog, transaction) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
yield this.auditLogsRepository.insert(transformedAuditLog, transaction);
|
|
24
|
-
});
|
|
11
|
+
async log(auditLog, transaction) {
|
|
12
|
+
const transformedAuditLog = this.auditLogTransformation.transformElement(auditLog);
|
|
13
|
+
await this.auditLogsRepository.insert(transformedAuditLog, transaction);
|
|
25
14
|
}
|
|
26
|
-
batchLog(auditLogs, transaction) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
yield this.auditLogsRepository.bulkInsert(transformedAuditLogs, transaction);
|
|
30
|
-
});
|
|
15
|
+
async batchLog(auditLogs, transaction) {
|
|
16
|
+
const transformedAuditLogs = this.auditLogTransformation.transformArray(auditLogs);
|
|
17
|
+
await this.auditLogsRepository.bulkInsert(transformedAuditLogs, transaction);
|
|
31
18
|
}
|
|
32
19
|
}
|
|
33
20
|
exports.AuditLogger = AuditLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditLogger.js","sourceRoot":"","sources":["../../src/helpers/AuditLogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuditLogger.js","sourceRoot":"","sources":["../../src/helpers/AuditLogger.ts"],"names":[],"mappings":";;;AAIA,6EAA0E;AAC1E,sFAAmF;AAGnF,MAAa,WAAW;IAIpB,YAAY,iBAAqC,EAAE,MAAe,EAAE,MAAwB;QACxF,IAAI,CAAC,mBAAmB,GAAG,IAAI,yCAAmB,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtF,IAAI,CAAC,sBAAsB,GAAG,IAAI,+CAAsB,EAAE,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,QAAmB,EAAE,WAAyB;QAC3D,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACnF,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,SAAsB,EAAE,WAAyB;QACnE,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACnF,MAAM,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;IACjF,CAAC;CACJ;AAlBD,kCAkBC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AuditLogsRepository = void 0;
|
|
13
4
|
const AbstractValidatableRepository_1 = require("@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository");
|
|
@@ -27,41 +18,35 @@ class AuditLogsRepository extends AbstractValidatableRepository_1.AbstractValida
|
|
|
27
18
|
.getConnection()
|
|
28
19
|
.define(this.tableName, AuditLogsModel_1.AuditLogsModel.attributeModel, { schema: this.schema, updatedAt: false });
|
|
29
20
|
}
|
|
30
|
-
insert(data, transaction) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
async insert(data, transaction) {
|
|
22
|
+
try {
|
|
23
|
+
return await this.sequelizeModel.create(data, { transaction });
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err instanceof sequelize_1.ValidationError && err.errors?.length > 0) {
|
|
27
|
+
const mappedErrors = err.errors.map((e) => `${e.message} (${e.value})`).join(", ");
|
|
28
|
+
throw new golemio_errors_1.ValidationError(`Validation error in insert: ${mappedErrors}`, this.constructor.name, err);
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const mappedErrors = err.errors.map((e) => `${e.message} (${e.value})`).join(", ");
|
|
39
|
-
throw new golemio_errors_1.ValidationError(`Validation error in insert: ${mappedErrors}`, this.constructor.name, err);
|
|
40
|
-
}
|
|
41
|
-
if (err instanceof sequelize_1.DatabaseError) {
|
|
42
|
-
throw new golemio_errors_1.GeneralError(`Error in insert: ${err.parent}`, this.constructor.name, err);
|
|
43
|
-
}
|
|
44
|
-
throw new golemio_errors_1.GeneralError("Error in insert", this.constructor.name, err);
|
|
30
|
+
if (err instanceof sequelize_1.DatabaseError) {
|
|
31
|
+
throw new golemio_errors_1.GeneralError(`Error in insert: ${err.parent}`, this.constructor.name, err);
|
|
45
32
|
}
|
|
46
|
-
|
|
33
|
+
throw new golemio_errors_1.GeneralError("Error in insert", this.constructor.name, err);
|
|
34
|
+
}
|
|
47
35
|
}
|
|
48
|
-
bulkInsert(data, transaction) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
async bulkInsert(data, transaction) {
|
|
37
|
+
try {
|
|
38
|
+
return await this.sequelizeModel.bulkCreate(data, { transaction });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof sequelize_1.ValidationError && err.errors?.length > 0) {
|
|
42
|
+
const mappedErrors = err.errors.map((e) => `${e.message} (${e.value})`).join(", ");
|
|
43
|
+
throw new golemio_errors_1.ValidationError(`Validation error in bulkInsert: ${mappedErrors}`, this.constructor.name, err);
|
|
53
44
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const mappedErrors = err.errors.map((e) => `${e.message} (${e.value})`).join(", ");
|
|
57
|
-
throw new golemio_errors_1.ValidationError(`Validation error in bulkInsert: ${mappedErrors}`, this.constructor.name, err);
|
|
58
|
-
}
|
|
59
|
-
if (err instanceof sequelize_1.DatabaseError) {
|
|
60
|
-
throw new golemio_errors_1.GeneralError(`Error in bulkInsert: ${err.parent}`, this.constructor.name, err);
|
|
61
|
-
}
|
|
62
|
-
throw new golemio_errors_1.GeneralError("Error in bulkInsert", this.constructor.name, err);
|
|
45
|
+
if (err instanceof sequelize_1.DatabaseError) {
|
|
46
|
+
throw new golemio_errors_1.GeneralError(`Error in bulkInsert: ${err.parent}`, this.constructor.name, err);
|
|
63
47
|
}
|
|
64
|
-
|
|
48
|
+
throw new golemio_errors_1.GeneralError("Error in bulkInsert", this.constructor.name, err);
|
|
49
|
+
}
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
52
|
exports.AuditLogsRepository = AuditLogsRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditLogsRepository.js","sourceRoot":"","sources":["../../src/repositories/AuditLogsRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuditLogsRepository.js","sourceRoot":"","sources":["../../src/repositories/AuditLogsRepository.ts"],"names":[],"mappings":";;;AAEA,8IAA2I;AAC3I,6EAAyF;AACzF,mFAAkF;AAClF,mEAK6C;AAE7C,6DAA0D;AAG1D,MAAa,mBAAoB,SAAQ,6DAA6B;IAOlE,YAAY,SAA6B,EAAU,MAAe,EAAU,MAAwB;QAChG,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QADsB,WAAM,GAAN,MAAM,CAAS;QAAU,WAAM,GAAN,MAAM,CAAkB;QAL7F,cAAS,GAAG,+BAAc,CAAC,SAAS,CAAC;QAOxC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,uCAAmB,CAAC,qBAAqB,EAAE,+BAAc,CAAC,UAAU,CAAC,CAAC;QAC3F,IAAI,CAAC,cAAc,GAAG,SAAS;aAC1B,aAAa,EAAE;aACf,MAAM,CAAC,IAAI,CAA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,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;gBACnE,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnF,MAAM,IAAI,gCAAe,CAAC,mCAAmC,YAAY,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aAC5G;YACD,IAAI,GAAG,YAAY,yBAAsB,EAAE;gBACvC,MAAM,IAAI,6BAAY,CAAC,wBAAwB,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aAC5F;YACD,MAAM,IAAI,6BAAY,CAAC,qBAAqB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC7E;IACL,CAAC;CACJ;AAhDD,kDAgDC"}
|
|
@@ -6,7 +6,12 @@ class AuditLogTransformation extends AbstractTransformation_1.AbstractTransforma
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.name = "AuditLogTransformation";
|
|
9
|
-
this.transformInternal = (auditLog) => (
|
|
9
|
+
this.transformInternal = (auditLog) => ({
|
|
10
|
+
action: auditLog.action,
|
|
11
|
+
entity: auditLog.entity,
|
|
12
|
+
user_id: auditLog.userId,
|
|
13
|
+
...(auditLog.data ? { data: auditLog.data } : {}),
|
|
14
|
+
});
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
exports.AuditLogTransformation = AuditLogTransformation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditLogTransformation.js","sourceRoot":"","sources":["../../src/transformations/AuditLogTransformation.ts"],"names":[],"mappings":";;;AAAA,6GAA0G;AAO1G,MAAa,sBAAuB,SAAQ,+CAAiD;IAA7F;;QACW,SAAI,GAAG,wBAAwB,CAAC;QAE7B,sBAAiB,GAAG,CAAC,QAAqB,EAAgB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"AuditLogTransformation.js","sourceRoot":"","sources":["../../src/transformations/AuditLogTransformation.ts"],"names":[],"mappings":";;;AAAA,6GAA0G;AAO1G,MAAa,sBAAuB,SAAQ,+CAAiD;IAA7F;;QACW,SAAI,GAAG,wBAAwB,CAAC;QAE7B,sBAAiB,GAAG,CAAC,QAAqB,EAAgB,EAAE,CAAC,CAAC;YACpE,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,QAAQ,CAAC,MAAM;YACxB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC,CAAC;IACP,CAAC;CAAA;AATD,wDASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/audit-logs",
|
|
3
|
-
"version": "1.0.1-dev.
|
|
3
|
+
"version": "1.0.1-dev.1754452191",
|
|
4
4
|
"description": "Golemio Audit Logs Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@commitlint/cli": "^11.0.0",
|
|
36
36
|
"@commitlint/config-conventional": "^11.0.0",
|
|
37
|
-
"@golemio/cli": "1.
|
|
38
|
-
"@golemio/core": "1.
|
|
37
|
+
"@golemio/cli": "1.9.2",
|
|
38
|
+
"@golemio/core": "1.19.3",
|
|
39
39
|
"@golemio/eslint-config": "1.1.2",
|
|
40
40
|
"@types/amqplib": "^0.5.17",
|
|
41
41
|
"@types/chai": "4.2.3",
|