@venturialstd/audit 0.0.2
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/audit.module.d.ts +17 -0
- package/dist/audit.module.d.ts.map +1 -0
- package/dist/audit.module.js +64 -0
- package/dist/audit.module.js.map +1 -0
- package/dist/constants/audit.constant.d.ts +19 -0
- package/dist/constants/audit.constant.d.ts.map +1 -0
- package/dist/constants/audit.constant.js +20 -0
- package/dist/constants/audit.constant.js.map +1 -0
- package/dist/controllers/audit.controller.d.ts +9 -0
- package/dist/controllers/audit.controller.d.ts.map +1 -0
- package/dist/controllers/audit.controller.js +98 -0
- package/dist/controllers/audit.controller.js.map +1 -0
- package/dist/dtos/audit-log-params.dto.d.ts +40 -0
- package/dist/dtos/audit-log-params.dto.d.ts.map +1 -0
- package/dist/dtos/audit-log-params.dto.js +3 -0
- package/dist/dtos/audit-log-params.dto.js.map +1 -0
- package/dist/entities/audit-log-change.entity.d.ts +10 -0
- package/dist/entities/audit-log-change.entity.d.ts.map +1 -0
- package/dist/entities/audit-log-change.entity.js +52 -0
- package/dist/entities/audit-log-change.entity.js.map +1 -0
- package/dist/entities/audit-log.entity.d.ts +36 -0
- package/dist/entities/audit-log.entity.d.ts.map +1 -0
- package/dist/entities/audit-log.entity.js +135 -0
- package/dist/entities/audit-log.entity.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/services/audit-query.service.d.ts +31 -0
- package/dist/services/audit-query.service.d.ts.map +1 -0
- package/dist/services/audit-query.service.js +83 -0
- package/dist/services/audit-query.service.js.map +1 -0
- package/dist/services/audit.service.d.ts +19 -0
- package/dist/services/audit.service.d.ts.map +1 -0
- package/dist/services/audit.service.js +108 -0
- package/dist/services/audit.service.js.map +1 -0
- package/package.json +28 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DynamicModule, InjectionToken } from '@nestjs/common';
|
|
2
|
+
import { type IAuditUserLookup } from './services/audit-query.service';
|
|
3
|
+
export interface AuditModuleOptions {
|
|
4
|
+
/** Optional: join with users table when querying with details (actorType 'user') */
|
|
5
|
+
userLookup?: IAuditUserLookup;
|
|
6
|
+
}
|
|
7
|
+
export interface AuditModuleAsyncOptions {
|
|
8
|
+
imports?: DynamicModule['imports'];
|
|
9
|
+
inject?: InjectionToken[];
|
|
10
|
+
useFactory: (...args: unknown[]) => AuditModuleOptions | Promise<AuditModuleOptions>;
|
|
11
|
+
}
|
|
12
|
+
export declare class AuditModule {
|
|
13
|
+
static forRoot(options?: AuditModuleOptions): DynamicModule;
|
|
14
|
+
static forRootAsync(asyncOptions: AuditModuleAsyncOptions): DynamicModule;
|
|
15
|
+
static forFeature(): DynamicModule;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=audit.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.module.d.ts","sourceRoot":"","sources":["../src/audit.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAMvE,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAG7G,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtF;AAED,qBACa,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,kBAAuB,GAAG,aAAa;IAgB/D,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,uBAAuB,GAAG,aAAa;IAwBzE,MAAM,CAAC,UAAU,IAAI,aAAa;CAGnC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var AuditModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuditModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
13
|
+
const audit_controller_1 = require("./controllers/audit.controller");
|
|
14
|
+
const audit_log_change_entity_1 = require("./entities/audit-log-change.entity");
|
|
15
|
+
const audit_log_entity_1 = require("./entities/audit-log.entity");
|
|
16
|
+
const audit_query_service_1 = require("./services/audit-query.service");
|
|
17
|
+
const audit_service_1 = require("./services/audit.service");
|
|
18
|
+
let AuditModule = AuditModule_1 = class AuditModule {
|
|
19
|
+
static forRoot(options = {}) {
|
|
20
|
+
const providers = [
|
|
21
|
+
audit_service_1.AuditService,
|
|
22
|
+
audit_query_service_1.AuditQueryService,
|
|
23
|
+
{ provide: audit_query_service_1.AUDIT_USER_LOOKUP, useValue: options.userLookup ?? null },
|
|
24
|
+
];
|
|
25
|
+
return {
|
|
26
|
+
module: AuditModule_1,
|
|
27
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([audit_log_entity_1.AuditLog, audit_log_change_entity_1.AuditLogChange])],
|
|
28
|
+
controllers: [audit_controller_1.AuditController],
|
|
29
|
+
providers,
|
|
30
|
+
exports: [audit_service_1.AuditService, audit_query_service_1.AuditQueryService],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
static forRootAsync(asyncOptions) {
|
|
34
|
+
return {
|
|
35
|
+
module: AuditModule_1,
|
|
36
|
+
imports: [
|
|
37
|
+
...(asyncOptions.imports ?? []),
|
|
38
|
+
typeorm_1.TypeOrmModule.forFeature([audit_log_entity_1.AuditLog, audit_log_change_entity_1.AuditLogChange]),
|
|
39
|
+
],
|
|
40
|
+
controllers: [audit_controller_1.AuditController],
|
|
41
|
+
providers: [
|
|
42
|
+
audit_service_1.AuditService,
|
|
43
|
+
audit_query_service_1.AuditQueryService,
|
|
44
|
+
{
|
|
45
|
+
provide: audit_query_service_1.AUDIT_USER_LOOKUP,
|
|
46
|
+
useFactory: async (...args) => {
|
|
47
|
+
const options = await Promise.resolve(asyncOptions.useFactory(...args));
|
|
48
|
+
return options.userLookup ?? null;
|
|
49
|
+
},
|
|
50
|
+
inject: asyncOptions.inject ?? [],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
exports: [audit_service_1.AuditService, audit_query_service_1.AuditQueryService],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static forFeature() {
|
|
57
|
+
return AuditModule_1.forRoot({});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.AuditModule = AuditModule;
|
|
61
|
+
exports.AuditModule = AuditModule = AuditModule_1 = __decorate([
|
|
62
|
+
(0, common_1.Module)({})
|
|
63
|
+
], AuditModule);
|
|
64
|
+
//# sourceMappingURL=audit.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.module.js","sourceRoot":"","sources":["../src/audit.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuE;AACvE,6CAAgD;AAEhD,qEAAiE;AACjE,gFAAoE;AACpE,kEAAuD;AACvD,wEAA6G;AAC7G,4DAAwD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AO,aAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AA5CY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CA4CvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actor types for the Flexible Actor Model (ID-Only).
|
|
3
|
+
* Used by audit logs to identify who performed an action without duplicating data.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ACTOR_TYPE: {
|
|
6
|
+
readonly USER: "user";
|
|
7
|
+
readonly SYSTEM: "system";
|
|
8
|
+
readonly EXTERNAL: "external";
|
|
9
|
+
readonly AUTOMATION: "automation";
|
|
10
|
+
readonly WEBHOOK: "webhook";
|
|
11
|
+
};
|
|
12
|
+
export type ActorType = (typeof ACTOR_TYPE)[keyof typeof ACTOR_TYPE];
|
|
13
|
+
export declare const AUDIT_LOG_STATUS: {
|
|
14
|
+
readonly SUCCESS: "success";
|
|
15
|
+
readonly FAILED: "failed";
|
|
16
|
+
readonly PENDING: "pending";
|
|
17
|
+
};
|
|
18
|
+
export type AuditLogStatus = (typeof AUDIT_LOG_STATUS)[keyof typeof AUDIT_LOG_STATUS];
|
|
19
|
+
//# sourceMappingURL=audit.constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.constant.d.ts","sourceRoot":"","sources":["../../src/constants/audit.constant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUDIT_LOG_STATUS = exports.ACTOR_TYPE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Actor types for the Flexible Actor Model (ID-Only).
|
|
6
|
+
* Used by audit logs to identify who performed an action without duplicating data.
|
|
7
|
+
*/
|
|
8
|
+
exports.ACTOR_TYPE = {
|
|
9
|
+
USER: 'user',
|
|
10
|
+
SYSTEM: 'system',
|
|
11
|
+
EXTERNAL: 'external',
|
|
12
|
+
AUTOMATION: 'automation',
|
|
13
|
+
WEBHOOK: 'webhook',
|
|
14
|
+
};
|
|
15
|
+
exports.AUDIT_LOG_STATUS = {
|
|
16
|
+
SUCCESS: 'success',
|
|
17
|
+
FAILED: 'failed',
|
|
18
|
+
PENDING: 'pending',
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=audit.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.constant.js","sourceRoot":"","sources":["../../src/constants/audit.constant.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACV,CAAC;AAIE,QAAA,gBAAgB,GAAG;IAC9B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuditQueryService, type AuditLogWithActor } from '../services/audit-query.service';
|
|
2
|
+
import type { AuditLog } from '../entities/audit-log.entity';
|
|
3
|
+
export declare class AuditController {
|
|
4
|
+
private readonly auditQueryService;
|
|
5
|
+
constructor(auditQueryService: AuditQueryService);
|
|
6
|
+
getLogs(actorType?: string, actorId?: string, entityType?: string, entityId?: string, action?: string, from?: string, to?: string, withDetails?: string, limit?: string, offset?: string): Promise<AuditLogWithActor[] | AuditLog[]>;
|
|
7
|
+
getLogsByActor(actorType: string, actorId: string, withDetails?: string, limit?: string, offset?: string): Promise<AuditLogWithActor[] | AuditLog[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=audit.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/audit.controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,qBAEa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,iBAAiB;IAU3D,OAAO,CACS,SAAS,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,EACf,EAAE,CAAC,EAAE,MAAM,EACF,WAAW,CAAC,EAAE,MAAM,EAC1B,KAAK,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,iBAAiB,EAAE,GAAG,QAAQ,EAAE,CAAC;IAsBtC,cAAc,CACE,SAAS,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,EAC1B,KAAK,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,iBAAiB,EAAE,GAAG,QAAQ,EAAE,CAAC;CAY7C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuditController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const audit_query_service_1 = require("../services/audit-query.service");
|
|
19
|
+
let AuditController = class AuditController {
|
|
20
|
+
auditQueryService;
|
|
21
|
+
constructor(auditQueryService) {
|
|
22
|
+
this.auditQueryService = auditQueryService;
|
|
23
|
+
}
|
|
24
|
+
async getLogs(actorType, actorId, entityType, entityId, action, from, to, withDetails, limit, offset) {
|
|
25
|
+
const filters = {
|
|
26
|
+
actorType,
|
|
27
|
+
actorId,
|
|
28
|
+
entityType,
|
|
29
|
+
entityId,
|
|
30
|
+
action,
|
|
31
|
+
limit: limit ? parseInt(limit, 10) : undefined,
|
|
32
|
+
offset: offset ? parseInt(offset, 10) : undefined,
|
|
33
|
+
};
|
|
34
|
+
if (from)
|
|
35
|
+
filters.from = new Date(from);
|
|
36
|
+
if (to)
|
|
37
|
+
filters.to = new Date(to);
|
|
38
|
+
if (withDetails === 'true' || withDetails === '1') {
|
|
39
|
+
return this.auditQueryService.queryWithActorDetails(filters);
|
|
40
|
+
}
|
|
41
|
+
return this.auditQueryService.query(filters);
|
|
42
|
+
}
|
|
43
|
+
async getLogsByActor(actorType, actorId, withDetails, limit, offset) {
|
|
44
|
+
const filters = {
|
|
45
|
+
actorType,
|
|
46
|
+
actorId,
|
|
47
|
+
limit: limit ? parseInt(limit, 10) : undefined,
|
|
48
|
+
offset: offset ? parseInt(offset, 10) : undefined,
|
|
49
|
+
};
|
|
50
|
+
if (withDetails === 'true' || withDetails === '1') {
|
|
51
|
+
return this.auditQueryService.queryWithActorDetails(filters);
|
|
52
|
+
}
|
|
53
|
+
return this.auditQueryService.query(filters);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.AuditController = AuditController;
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, common_1.Get)('logs'),
|
|
59
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get audit logs with optional filters' }),
|
|
60
|
+
(0, swagger_1.ApiQuery)({ name: 'actorType', required: false }),
|
|
61
|
+
(0, swagger_1.ApiQuery)({ name: 'actorId', required: false }),
|
|
62
|
+
(0, swagger_1.ApiQuery)({ name: 'withDetails', required: false, type: Boolean }),
|
|
63
|
+
(0, swagger_1.ApiQuery)({ name: 'limit', required: false }),
|
|
64
|
+
(0, swagger_1.ApiQuery)({ name: 'offset', required: false }),
|
|
65
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'List of audit logs' }),
|
|
66
|
+
__param(0, (0, common_1.Query)('actorType')),
|
|
67
|
+
__param(1, (0, common_1.Query)('actorId')),
|
|
68
|
+
__param(2, (0, common_1.Query)('entityType')),
|
|
69
|
+
__param(3, (0, common_1.Query)('entityId')),
|
|
70
|
+
__param(4, (0, common_1.Query)('action')),
|
|
71
|
+
__param(5, (0, common_1.Query)('from')),
|
|
72
|
+
__param(6, (0, common_1.Query)('to')),
|
|
73
|
+
__param(7, (0, common_1.Query)('withDetails')),
|
|
74
|
+
__param(8, (0, common_1.Query)('limit')),
|
|
75
|
+
__param(9, (0, common_1.Query)('offset')),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [String, String, String, String, String, String, String, String, String, String]),
|
|
78
|
+
__metadata("design:returntype", Promise)
|
|
79
|
+
], AuditController.prototype, "getLogs", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_1.Get)('actor/:actorType/:actorId/logs'),
|
|
82
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get audit logs for a specific actor' }),
|
|
83
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'List of audit logs for the actor' }),
|
|
84
|
+
__param(0, (0, common_1.Param)('actorType')),
|
|
85
|
+
__param(1, (0, common_1.Param)('actorId')),
|
|
86
|
+
__param(2, (0, common_1.Query)('withDetails')),
|
|
87
|
+
__param(3, (0, common_1.Query)('limit')),
|
|
88
|
+
__param(4, (0, common_1.Query)('offset')),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", [String, String, String, String, String]),
|
|
91
|
+
__metadata("design:returntype", Promise)
|
|
92
|
+
], AuditController.prototype, "getLogsByActor", null);
|
|
93
|
+
exports.AuditController = AuditController = __decorate([
|
|
94
|
+
(0, swagger_1.ApiTags)('audit'),
|
|
95
|
+
(0, common_1.Controller)('audit'),
|
|
96
|
+
__metadata("design:paramtypes", [audit_query_service_1.AuditQueryService])
|
|
97
|
+
], AuditController);
|
|
98
|
+
//# sourceMappingURL=audit.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.controller.js","sourceRoot":"","sources":["../../src/controllers/audit.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,6CAA+E;AAG/E,yEAA4F;AAKrF,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAU/D,AAAN,K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A,cAAK,EAAC,aAAa,CAAC,CAAA;IACpB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IACd,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;8CAkBjB;AAKK;IAHL,IAAA,YAAG,EAAC,gCAAgC,CAAC;IACrC,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC;IAChE,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IAE3E,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;IACpB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IACd,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;qDAYjB;0BA7DU,eAAe;IAF3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAE8B,uCAAiB;GADtD,eAAe,CA8D3B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for the generic audit log() method.
|
|
3
|
+
* Flexible Actor Model: actorType + actorId only; no duplicated actor data.
|
|
4
|
+
*/
|
|
5
|
+
export interface AuditLogChangeDto {
|
|
6
|
+
field: string;
|
|
7
|
+
oldValue: unknown;
|
|
8
|
+
newValue: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface AuditLogParams {
|
|
11
|
+
actorType: string;
|
|
12
|
+
actorId: string | null;
|
|
13
|
+
entityType: string;
|
|
14
|
+
entityId?: string | null;
|
|
15
|
+
action: string;
|
|
16
|
+
category?: string | null;
|
|
17
|
+
description?: string | null;
|
|
18
|
+
changes?: AuditLogChangeDto[];
|
|
19
|
+
ipAddress?: string | null;
|
|
20
|
+
userAgent?: string | null;
|
|
21
|
+
location?: string | null;
|
|
22
|
+
metadata?: Record<string, unknown> | null;
|
|
23
|
+
requestId?: string | null;
|
|
24
|
+
correlationId?: string | null;
|
|
25
|
+
status?: string;
|
|
26
|
+
errorMessage?: string | null;
|
|
27
|
+
expiresAt?: Date | null;
|
|
28
|
+
}
|
|
29
|
+
export interface AuditQueryFilters {
|
|
30
|
+
actorType?: string;
|
|
31
|
+
actorId?: string;
|
|
32
|
+
entityType?: string;
|
|
33
|
+
entityId?: string;
|
|
34
|
+
action?: string;
|
|
35
|
+
from?: Date;
|
|
36
|
+
to?: Date;
|
|
37
|
+
limit?: number;
|
|
38
|
+
offset?: number;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=audit-log-params.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-params.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/audit-log-params.dto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-params.dto.js","sourceRoot":"","sources":["../../src/dtos/audit-log-params.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuditLog } from './audit-log.entity';
|
|
2
|
+
export declare class AuditLogChange {
|
|
3
|
+
id: string;
|
|
4
|
+
auditLogId: string;
|
|
5
|
+
auditLog: AuditLog;
|
|
6
|
+
field: string;
|
|
7
|
+
oldValue: unknown;
|
|
8
|
+
newValue: unknown;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=audit-log-change.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-change.entity.d.ts","sourceRoot":"","sources":["../../src/entities/audit-log-change.entity.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,qBACa,cAAc;IAEzB,EAAE,EAAG,MAAM,CAAC;IAGZ,UAAU,EAAG,MAAM,CAAC;IAIpB,QAAQ,EAAG,QAAQ,CAAC;IAGpB,KAAK,EAAG,MAAM,CAAC;IAGf,QAAQ,EAAG,OAAO,CAAC;IAGnB,QAAQ,EAAG,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuditLogChange = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const audit_log_entity_1 = require("./audit-log.entity");
|
|
15
|
+
let AuditLogChange = class AuditLogChange {
|
|
16
|
+
id;
|
|
17
|
+
auditLogId;
|
|
18
|
+
auditLog;
|
|
19
|
+
field;
|
|
20
|
+
oldValue;
|
|
21
|
+
newValue;
|
|
22
|
+
};
|
|
23
|
+
exports.AuditLogChange = AuditLogChange;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], AuditLogChange.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], AuditLogChange.prototype, "auditLogId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.ManyToOne)(() => audit_log_entity_1.AuditLog, (log) => log.changes, { onDelete: 'CASCADE' }),
|
|
34
|
+
(0, typeorm_1.JoinColumn)({ name: 'auditLogId' }),
|
|
35
|
+
__metadata("design:type", audit_log_entity_1.AuditLog)
|
|
36
|
+
], AuditLogChange.prototype, "auditLog", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255 }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], AuditLogChange.prototype, "field", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
43
|
+
__metadata("design:type", Object)
|
|
44
|
+
], AuditLogChange.prototype, "oldValue", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], AuditLogChange.prototype, "newValue", void 0);
|
|
49
|
+
exports.AuditLogChange = AuditLogChange = __decorate([
|
|
50
|
+
(0, typeorm_1.Entity)('audit_log_change')
|
|
51
|
+
], AuditLogChange);
|
|
52
|
+
//# sourceMappingURL=audit-log-change.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-change.entity.js","sourceRoot":"","sources":["../../src/entities/audit-log-change.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAEjB,yDAA8C;AAGvC,IAAM,cAAc,GAApB,MAAM,cAAc;IAEzB,EAAE,CAAU;IAGZ,UAAU,CAAU;IAIpB,QAAQ,CAAY;IAGpB,KAAK,CAAU;IAGf,QAAQ,CAAW;IAGnB,QAAQ,CAAW;CACpB,CAAA;AAnBY,wCAAc;AAEzB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;0CACnB;AAGZ;IADC,IAAA,gBAAM,GAAE;;kDACW;AAIpB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2BAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACxE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACxB,2BAAQ;gDAAC;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;6CAC1B;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACvB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACvB;yBAlBR,cAAc;IAD1B,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,cAAc,CAmB1B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuditLogChange } from './audit-log-change.entity';
|
|
2
|
+
export declare class AuditLog {
|
|
3
|
+
id: string;
|
|
4
|
+
/** WHO: type of actor (user, system, external, automation, webhook) */
|
|
5
|
+
actorType: string;
|
|
6
|
+
/** WHO: identifier for the actor (user UUID, external entity ID, automation name, etc.) */
|
|
7
|
+
actorId: string | null;
|
|
8
|
+
/** WHAT: type of entity affected (e.g. workflow, transaction, account) */
|
|
9
|
+
entityType: string;
|
|
10
|
+
/** WHAT: ID of the affected entity */
|
|
11
|
+
entityId: string | null;
|
|
12
|
+
/** Action performed (e.g. created, updated, deleted, login_success) */
|
|
13
|
+
action: string;
|
|
14
|
+
/** Optional category (e.g. security, workflow_management) */
|
|
15
|
+
category: string | null;
|
|
16
|
+
/** Optional detailed description */
|
|
17
|
+
description: string | null;
|
|
18
|
+
/** WHEN */
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
/** WHERE: optional origin */
|
|
21
|
+
ipAddress: string | null;
|
|
22
|
+
userAgent: string | null;
|
|
23
|
+
location: string | null;
|
|
24
|
+
/** Field-level changes */
|
|
25
|
+
changes: AuditLogChange[];
|
|
26
|
+
/** Extra context (jsonb) */
|
|
27
|
+
metadata: Record<string, unknown> | null;
|
|
28
|
+
requestId: string | null;
|
|
29
|
+
correlationId: string | null;
|
|
30
|
+
/** Result of the action */
|
|
31
|
+
status: string;
|
|
32
|
+
errorMessage: string | null;
|
|
33
|
+
/** Optional retention: when this log can be purged */
|
|
34
|
+
expiresAt: Date | null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=audit-log.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.entity.d.ts","sourceRoot":"","sources":["../../src/entities/audit-log.entity.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,qBAKa,QAAQ;IAEnB,EAAE,EAAG,MAAM,CAAC;IAEZ,uEAAuE;IAGvE,SAAS,EAAG,MAAM,CAAC;IAEnB,2FAA2F;IAG3F,OAAO,EAAG,MAAM,GAAG,IAAI,CAAC;IAExB,0EAA0E;IAE1E,UAAU,EAAG,MAAM,CAAC;IAEpB,sCAAsC;IAEtC,QAAQ,EAAG,MAAM,GAAG,IAAI,CAAC;IAEzB,uEAAuE;IAEvE,MAAM,EAAG,MAAM,CAAC;IAEhB,6DAA6D;IAE7D,QAAQ,EAAG,MAAM,GAAG,IAAI,CAAC;IAEzB,oCAAoC;IAEpC,WAAW,EAAG,MAAM,GAAG,IAAI,CAAC;IAE5B,WAAW;IAEX,SAAS,EAAG,IAAI,CAAC;IAEjB,6BAA6B;IAE7B,SAAS,EAAG,MAAM,GAAG,IAAI,CAAC;IAG1B,SAAS,EAAG,MAAM,GAAG,IAAI,CAAC;IAG1B,QAAQ,EAAG,MAAM,GAAG,IAAI,CAAC;IAEzB,0BAA0B;IAE1B,OAAO,EAAG,cAAc,EAAE,CAAC;IAE3B,4BAA4B;IAE5B,QAAQ,EAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAG1C,SAAS,EAAG,MAAM,GAAG,IAAI,CAAC;IAG1B,aAAa,EAAG,MAAM,GAAG,IAAI,CAAC;IAE9B,2BAA2B;IAE3B,MAAM,EAAG,MAAM,CAAC;IAGhB,YAAY,EAAG,MAAM,GAAG,IAAI,CAAC;IAE7B,sDAAsD;IAEtD,SAAS,EAAG,IAAI,GAAG,IAAI,CAAC;CACzB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuditLog = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const audit_log_change_entity_1 = require("./audit-log-change.entity");
|
|
15
|
+
let AuditLog = class AuditLog {
|
|
16
|
+
id;
|
|
17
|
+
/** WHO: type of actor (user, system, external, automation, webhook) */
|
|
18
|
+
actorType;
|
|
19
|
+
/** WHO: identifier for the actor (user UUID, external entity ID, automation name, etc.) */
|
|
20
|
+
actorId;
|
|
21
|
+
/** WHAT: type of entity affected (e.g. workflow, transaction, account) */
|
|
22
|
+
entityType;
|
|
23
|
+
/** WHAT: ID of the affected entity */
|
|
24
|
+
entityId;
|
|
25
|
+
/** Action performed (e.g. created, updated, deleted, login_success) */
|
|
26
|
+
action;
|
|
27
|
+
/** Optional category (e.g. security, workflow_management) */
|
|
28
|
+
category;
|
|
29
|
+
/** Optional detailed description */
|
|
30
|
+
description;
|
|
31
|
+
/** WHEN */
|
|
32
|
+
timestamp;
|
|
33
|
+
/** WHERE: optional origin */
|
|
34
|
+
ipAddress;
|
|
35
|
+
userAgent;
|
|
36
|
+
location;
|
|
37
|
+
/** Field-level changes */
|
|
38
|
+
changes;
|
|
39
|
+
/** Extra context (jsonb) */
|
|
40
|
+
metadata;
|
|
41
|
+
requestId;
|
|
42
|
+
correlationId;
|
|
43
|
+
/** Result of the action */
|
|
44
|
+
status;
|
|
45
|
+
errorMessage;
|
|
46
|
+
/** Optional retention: when this log can be purged */
|
|
47
|
+
expiresAt;
|
|
48
|
+
};
|
|
49
|
+
exports.AuditLog = AuditLog;
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], AuditLog.prototype, "id", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Index)(),
|
|
56
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 50 }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], AuditLog.prototype, "actorType", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.Index)(),
|
|
61
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], AuditLog.prototype, "actorId", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100 }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], AuditLog.prototype, "entityType", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], AuditLog.prototype, "entityId", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100 }),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], AuditLog.prototype, "action", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
|
|
78
|
+
__metadata("design:type", Object)
|
|
79
|
+
], AuditLog.prototype, "category", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], AuditLog.prototype, "description", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
|
|
86
|
+
__metadata("design:type", Date)
|
|
87
|
+
], AuditLog.prototype, "timestamp", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 45, nullable: true }),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], AuditLog.prototype, "ipAddress", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
94
|
+
__metadata("design:type", Object)
|
|
95
|
+
], AuditLog.prototype, "userAgent", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], AuditLog.prototype, "location", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.OneToMany)(() => audit_log_change_entity_1.AuditLogChange, (change) => change.auditLog, { cascade: true }),
|
|
102
|
+
__metadata("design:type", Array)
|
|
103
|
+
], AuditLog.prototype, "changes", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
106
|
+
__metadata("design:type", Object)
|
|
107
|
+
], AuditLog.prototype, "metadata", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
110
|
+
__metadata("design:type", Object)
|
|
111
|
+
], AuditLog.prototype, "requestId", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
114
|
+
__metadata("design:type", Object)
|
|
115
|
+
], AuditLog.prototype, "correlationId", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 50, default: 'success' }),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], AuditLog.prototype, "status", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], AuditLog.prototype, "errorMessage", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
126
|
+
__metadata("design:type", Object)
|
|
127
|
+
], AuditLog.prototype, "expiresAt", void 0);
|
|
128
|
+
exports.AuditLog = AuditLog = __decorate([
|
|
129
|
+
(0, typeorm_1.Entity)('audit_logs'),
|
|
130
|
+
(0, typeorm_1.Index)(['actorType', 'actorId']),
|
|
131
|
+
(0, typeorm_1.Index)(['actorType', 'timestamp']),
|
|
132
|
+
(0, typeorm_1.Index)(['entityType', 'entityId']),
|
|
133
|
+
(0, typeorm_1.Index)(['timestamp'])
|
|
134
|
+
], AuditLog);
|
|
135
|
+
//# sourceMappingURL=audit-log.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.entity.js","sourceRoot":"","sources":["../../src/entities/audit-log.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AAEjB,uEAA2D;AAOpD,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEnB,EAAE,CAAU;IAEZ,uEAAuE;IAGvE,SAAS,CAAU;IAEnB,2FAA2F;IAG3F,OAAO,CAAiB;IAExB,0EAA0E;IAE1E,UAAU,CAAU;IAEpB,sCAAsC;IAEtC,QAAQ,CAAiB;IAEzB,uEAAuE;IAEvE,MAAM,CAAU;IAEhB,6DAA6D;IAE7D,QAAQ,CAAiB;IAEzB,oCAAoC;IAEpC,WAAW,CAAiB;IAE5B,WAAW;IAEX,SAAS,CAAQ;IAEjB,6BAA6B;IAE7B,SAAS,CAAiB;IAG1B,SAAS,CAAiB;IAG1B,QAAQ,CAAiB;IAEzB,0BAA0B;IAE1B,OAAO,CAAoB;IAE3B,4BAA4B;IAE5B,QAAQ,CAAkC;IAG1C,SAAS,CAAiB;IAG1B,aAAa,CAAiB;IAE9B,2BAA2B;IAE3B,MAAM,CAAU;IAGhB,YAAY,CAAiB;IAE7B,sDAAsD;IAEtD,SAAS,CAAe;CACzB,CAAA;AAxEY,4BAAQ;AAEnB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;oCACnB;AAKZ;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;2CACrB;AAKnB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACjC;AAIxB;IADC,IAAA,gBAAM,EAAC,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C,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAC/B;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CAC3B;AAI9B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;;wCAC5C;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACZ;AAI7B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACxB;mBAvEb,QAAQ;IALpB,IAAA,gBAAM,EAAC,YAAY,CAAC;IACpB,IAAA,eAAK,EAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/B,IAAA,eAAK,EAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACjC,IAAA,eAAK,EAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACjC,IAAA,eAAK,EAAC,CAAC,WAAW,CAAC,CAAC;GACR,QAAQ,CAwEpB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ACTOR_TYPE, AUDIT_LOG_STATUS } from './constants/audit.constant';
|
|
2
|
+
export type { ActorType, AuditLogStatus } from './constants/audit.constant';
|
|
3
|
+
export { AuditController } from './controllers/audit.controller';
|
|
4
|
+
export type { AuditLogChangeDto, AuditLogParams, AuditQueryFilters } from './dtos/audit-log-params.dto';
|
|
5
|
+
export { AuditLogChange } from './entities/audit-log-change.entity';
|
|
6
|
+
export { AuditLog } from './entities/audit-log.entity';
|
|
7
|
+
export { AuditModule } from './audit.module';
|
|
8
|
+
export type { AuditModuleOptions, AuditModuleAsyncOptions } from './audit.module';
|
|
9
|
+
export { AUDIT_USER_LOOKUP, AuditQueryService, type IAuditUserLookup, type AuditLogWithActor, } from './services/audit-query.service';
|
|
10
|
+
export { AuditService } from './services/audit.service';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACxG,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditService = exports.AuditQueryService = exports.AUDIT_USER_LOOKUP = exports.AuditModule = exports.AuditLog = exports.AuditLogChange = exports.AuditController = exports.AUDIT_LOG_STATUS = exports.ACTOR_TYPE = void 0;
|
|
4
|
+
var audit_constant_1 = require("./constants/audit.constant");
|
|
5
|
+
Object.defineProperty(exports, "ACTOR_TYPE", { enumerable: true, get: function () { return audit_constant_1.ACTOR_TYPE; } });
|
|
6
|
+
Object.defineProperty(exports, "AUDIT_LOG_STATUS", { enumerable: true, get: function () { return audit_constant_1.AUDIT_LOG_STATUS; } });
|
|
7
|
+
var audit_controller_1 = require("./controllers/audit.controller");
|
|
8
|
+
Object.defineProperty(exports, "AuditController", { enumerable: true, get: function () { return audit_controller_1.AuditController; } });
|
|
9
|
+
var audit_log_change_entity_1 = require("./entities/audit-log-change.entity");
|
|
10
|
+
Object.defineProperty(exports, "AuditLogChange", { enumerable: true, get: function () { return audit_log_change_entity_1.AuditLogChange; } });
|
|
11
|
+
var audit_log_entity_1 = require("./entities/audit-log.entity");
|
|
12
|
+
Object.defineProperty(exports, "AuditLog", { enumerable: true, get: function () { return audit_log_entity_1.AuditLog; } });
|
|
13
|
+
var audit_module_1 = require("./audit.module");
|
|
14
|
+
Object.defineProperty(exports, "AuditModule", { enumerable: true, get: function () { return audit_module_1.AuditModule; } });
|
|
15
|
+
var audit_query_service_1 = require("./services/audit-query.service");
|
|
16
|
+
Object.defineProperty(exports, "AUDIT_USER_LOOKUP", { enumerable: true, get: function () { return audit_query_service_1.AUDIT_USER_LOOKUP; } });
|
|
17
|
+
Object.defineProperty(exports, "AuditQueryService", { enumerable: true, get: function () { return audit_query_service_1.AuditQueryService; } });
|
|
18
|
+
var audit_service_1 = require("./services/audit.service");
|
|
19
|
+
Object.defineProperty(exports, "AuditService", { enumerable: true, get: function () { return audit_service_1.AuditService; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA0E;AAAjE,4GAAA,UAAU,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAErC,mEAAiE;AAAxD,mHAAA,eAAe,OAAA;AAExB,8EAAoE;AAA3D,yHAAA,cAAc,OAAA;AACvB,gEAAuD;AAA9C,4GAAA,QAAQ,OAAA;AACjB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAEpB,sEAKwC;AAJtC,wHAAA,iBAAiB,OAAA;AACjB,wHAAA,iBAAiB,OAAA;AAInB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { AuditLog } from '../entities/audit-log.entity';
|
|
3
|
+
import type { AuditQueryFilters } from '../dtos/audit-log-params.dto';
|
|
4
|
+
/** Optional: provide to enrich audit logs with user details when actorType is 'user'. */
|
|
5
|
+
export interface IAuditUserLookup {
|
|
6
|
+
findByIds(ids: string[]): Promise<Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
} & Record<string, unknown>>>;
|
|
9
|
+
}
|
|
10
|
+
export declare const AUDIT_USER_LOOKUP = "AUDIT_USER_LOOKUP";
|
|
11
|
+
export interface AuditLogWithActor extends AuditLog {
|
|
12
|
+
actor?: {
|
|
13
|
+
type: string;
|
|
14
|
+
id: string | null;
|
|
15
|
+
} | Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare class AuditQueryService {
|
|
18
|
+
private readonly auditLogRepo;
|
|
19
|
+
private readonly userLookup;
|
|
20
|
+
constructor(auditLogRepo: Repository<AuditLog>, userLookup: IAuditUserLookup | null);
|
|
21
|
+
/**
|
|
22
|
+
* Query audit logs by filters. No join; returns only stored data (actorType + actorId).
|
|
23
|
+
*/
|
|
24
|
+
query(filters: AuditQueryFilters): Promise<AuditLog[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Query audit logs and optionally join with users table for display.
|
|
27
|
+
* When actorType is 'user', actor will be the full user object if AUDIT_USER_LOOKUP is provided.
|
|
28
|
+
*/
|
|
29
|
+
queryWithActorDetails(filters: AuditQueryFilters): Promise<AuditLogWithActor[]>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=audit-query.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-query.service.d.ts","sourceRoot":"","sources":["../../src/services/audit-query.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACpF;AAED,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvE;AAED,qBACa,iBAAiB;IAG1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAG7B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAHV,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,EAGlC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAGtD;;OAEG;IACG,KAAK,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAkB5D;;;OAGG;IACG,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAoBtF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuditQueryService = exports.AUDIT_USER_LOOKUP = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const audit_constant_1 = require("../constants/audit.constant");
|
|
20
|
+
const audit_log_entity_1 = require("../entities/audit-log.entity");
|
|
21
|
+
exports.AUDIT_USER_LOOKUP = 'AUDIT_USER_LOOKUP';
|
|
22
|
+
let AuditQueryService = class AuditQueryService {
|
|
23
|
+
auditLogRepo;
|
|
24
|
+
userLookup;
|
|
25
|
+
constructor(auditLogRepo, userLookup) {
|
|
26
|
+
this.auditLogRepo = auditLogRepo;
|
|
27
|
+
this.userLookup = userLookup;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Query audit logs by filters. No join; returns only stored data (actorType + actorId).
|
|
31
|
+
*/
|
|
32
|
+
async query(filters) {
|
|
33
|
+
const qb = this.auditLogRepo
|
|
34
|
+
.createQueryBuilder('log')
|
|
35
|
+
.orderBy('log.timestamp', 'DESC')
|
|
36
|
+
.take(filters.limit ?? 100)
|
|
37
|
+
.skip(filters.offset ?? 0);
|
|
38
|
+
if (filters.actorType)
|
|
39
|
+
qb.andWhere('log.actorType = :actorType', { actorType: filters.actorType });
|
|
40
|
+
if (filters.actorId)
|
|
41
|
+
qb.andWhere('log.actorId = :actorId', { actorId: filters.actorId });
|
|
42
|
+
if (filters.entityType)
|
|
43
|
+
qb.andWhere('log.entityType = :entityType', { entityType: filters.entityType });
|
|
44
|
+
if (filters.entityId)
|
|
45
|
+
qb.andWhere('log.entityId = :entityId', { entityId: filters.entityId });
|
|
46
|
+
if (filters.action)
|
|
47
|
+
qb.andWhere('log.action = :action', { action: filters.action });
|
|
48
|
+
if (filters.from)
|
|
49
|
+
qb.andWhere('log.timestamp >= :from', { from: filters.from });
|
|
50
|
+
if (filters.to)
|
|
51
|
+
qb.andWhere('log.timestamp <= :to', { to: filters.to });
|
|
52
|
+
return qb.getMany();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Query audit logs and optionally join with users table for display.
|
|
56
|
+
* When actorType is 'user', actor will be the full user object if AUDIT_USER_LOOKUP is provided.
|
|
57
|
+
*/
|
|
58
|
+
async queryWithActorDetails(filters) {
|
|
59
|
+
const logs = await this.query(filters);
|
|
60
|
+
const userLogs = logs.filter((log) => log.actorType === audit_constant_1.ACTOR_TYPE.USER);
|
|
61
|
+
const userIds = [...new Set(userLogs.map((log) => log.actorId).filter(Boolean))];
|
|
62
|
+
let userMap = new Map();
|
|
63
|
+
if (this.userLookup && userIds.length > 0) {
|
|
64
|
+
const users = await this.userLookup.findByIds(userIds);
|
|
65
|
+
userMap = new Map(users.map((u) => [u.id, u]));
|
|
66
|
+
}
|
|
67
|
+
return logs.map((log) => ({
|
|
68
|
+
...log,
|
|
69
|
+
actor: log.actorType === audit_constant_1.ACTOR_TYPE.USER && log.actorId
|
|
70
|
+
? (userMap.get(log.actorId) ?? { type: log.actorType, id: log.actorId })
|
|
71
|
+
: { type: log.actorType, id: log.actorId },
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.AuditQueryService = AuditQueryService;
|
|
76
|
+
exports.AuditQueryService = AuditQueryService = __decorate([
|
|
77
|
+
(0, common_1.Injectable)(),
|
|
78
|
+
__param(0, (0, typeorm_1.InjectRepository)(audit_log_entity_1.AuditLog)),
|
|
79
|
+
__param(1, (0, common_1.Optional)()),
|
|
80
|
+
__param(1, (0, common_1.Inject)(exports.AUDIT_USER_LOOKUP)),
|
|
81
|
+
__metadata("design:paramtypes", [typeorm_2.Repository, Object])
|
|
82
|
+
], AuditQueryService);
|
|
83
|
+
//# sourceMappingURL=audit-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-query.service.js","sourceRoot":"","sources":["../../src/services/audit-query.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,6CAAmD;AACnD,qCAAqC;AAErC,gEAAyD;AACzD,mEAAwD;AAQ3C,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAO9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGT;IAGA;IALnB,YAEmB,YAAkC,EAGlC,UAAmC;QAHnC,iBAAY,GAAZ,YAAY,CAAsB;QAGlC,eAAU,GAAV,UAAU,CAAyB;IACnD,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,OAA0B;QACpC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY;aACzB,kBAAkB,CAAC,KAAK,CAAC;aACzB,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;aAChC,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC;aAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;QAE7B,IAAI,OAAO,CAAC,SAAS;YAAE,EAAE,CAAC,QAAQ,CAAC,4BAA4B,EAAE,EAAE,SAA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
import { Repository } from 'typeorm';
|
|
2
|
+
import { AuditLogChange } from '../entities/audit-log-change.entity';
|
|
3
|
+
import { AuditLog } from '../entities/audit-log.entity';
|
|
4
|
+
import type { AuditLogParams } from '../dtos/audit-log-params.dto';
|
|
5
|
+
export declare class AuditService {
|
|
6
|
+
private readonly auditLogRepo;
|
|
7
|
+
private readonly auditLogChangeRepo;
|
|
8
|
+
constructor(auditLogRepo: Repository<AuditLog>, auditLogChangeRepo: Repository<AuditLogChange>);
|
|
9
|
+
/**
|
|
10
|
+
* Generic log method. Flexible Actor Model: only actorType + actorId stored.
|
|
11
|
+
*/
|
|
12
|
+
log(params: AuditLogParams): Promise<AuditLog>;
|
|
13
|
+
logUserAction(userId: string, params: Omit<AuditLogParams, 'actorType' | 'actorId'>): Promise<AuditLog>;
|
|
14
|
+
logSystemAction(systemId: string, params: Omit<AuditLogParams, 'actorType' | 'actorId'>): Promise<AuditLog>;
|
|
15
|
+
logExternalAction(externalId: string, params: Omit<AuditLogParams, 'actorType' | 'actorId'>): Promise<AuditLog>;
|
|
16
|
+
logAutomationAction(automationName: string, params: Omit<AuditLogParams, 'actorType' | 'actorId'>): Promise<AuditLog>;
|
|
17
|
+
logWebhookAction(webhookId: string, params: Omit<AuditLogParams, 'actorType' | 'actorId'>): Promise<AuditLog>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=audit.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.service.d.ts","sourceRoot":"","sources":["../../src/services/audit.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,qBACa,YAAY;IAGrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAE7B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAFlB,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,EAElC,kBAAkB,EAAE,UAAU,CAAC,cAAc,CAAC;IAGjE;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAqC9C,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,QAAQ,CAAC;IAQd,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,QAAQ,CAAC;IAQd,iBAAiB,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,QAAQ,CAAC;IAQd,mBAAmB,CACvB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,QAAQ,CAAC;IAQd,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,QAAQ,CAAC;CAOrB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuditService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const audit_constant_1 = require("../constants/audit.constant");
|
|
20
|
+
const audit_log_change_entity_1 = require("../entities/audit-log-change.entity");
|
|
21
|
+
const audit_log_entity_1 = require("../entities/audit-log.entity");
|
|
22
|
+
let AuditService = class AuditService {
|
|
23
|
+
auditLogRepo;
|
|
24
|
+
auditLogChangeRepo;
|
|
25
|
+
constructor(auditLogRepo, auditLogChangeRepo) {
|
|
26
|
+
this.auditLogRepo = auditLogRepo;
|
|
27
|
+
this.auditLogChangeRepo = auditLogChangeRepo;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generic log method. Flexible Actor Model: only actorType + actorId stored.
|
|
31
|
+
*/
|
|
32
|
+
async log(params) {
|
|
33
|
+
const log = this.auditLogRepo.create({
|
|
34
|
+
actorType: params.actorType,
|
|
35
|
+
actorId: params.actorId ?? null,
|
|
36
|
+
entityType: params.entityType,
|
|
37
|
+
entityId: params.entityId ?? null,
|
|
38
|
+
action: params.action,
|
|
39
|
+
category: params.category ?? null,
|
|
40
|
+
description: params.description ?? null,
|
|
41
|
+
ipAddress: params.ipAddress ?? null,
|
|
42
|
+
userAgent: params.userAgent ?? null,
|
|
43
|
+
location: params.location ?? null,
|
|
44
|
+
metadata: params.metadata ?? null,
|
|
45
|
+
requestId: params.requestId ?? null,
|
|
46
|
+
correlationId: params.correlationId ?? null,
|
|
47
|
+
status: params.status ?? audit_constant_1.AUDIT_LOG_STATUS.SUCCESS,
|
|
48
|
+
errorMessage: params.errorMessage ?? null,
|
|
49
|
+
expiresAt: params.expiresAt ?? null,
|
|
50
|
+
});
|
|
51
|
+
const saved = await this.auditLogRepo.save(log);
|
|
52
|
+
if (params.changes?.length) {
|
|
53
|
+
const changeEntities = params.changes.map((c) => this.auditLogChangeRepo.create({
|
|
54
|
+
auditLogId: saved.id,
|
|
55
|
+
field: c.field,
|
|
56
|
+
oldValue: c.oldValue,
|
|
57
|
+
newValue: c.newValue,
|
|
58
|
+
}));
|
|
59
|
+
await this.auditLogChangeRepo.save(changeEntities);
|
|
60
|
+
saved.changes = changeEntities;
|
|
61
|
+
}
|
|
62
|
+
return saved;
|
|
63
|
+
}
|
|
64
|
+
async logUserAction(userId, params) {
|
|
65
|
+
return this.log({
|
|
66
|
+
...params,
|
|
67
|
+
actorType: audit_constant_1.ACTOR_TYPE.USER,
|
|
68
|
+
actorId: userId,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async logSystemAction(systemId, params) {
|
|
72
|
+
return this.log({
|
|
73
|
+
...params,
|
|
74
|
+
actorType: audit_constant_1.ACTOR_TYPE.SYSTEM,
|
|
75
|
+
actorId: systemId,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async logExternalAction(externalId, params) {
|
|
79
|
+
return this.log({
|
|
80
|
+
...params,
|
|
81
|
+
actorType: audit_constant_1.ACTOR_TYPE.EXTERNAL,
|
|
82
|
+
actorId: externalId,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async logAutomationAction(automationName, params) {
|
|
86
|
+
return this.log({
|
|
87
|
+
...params,
|
|
88
|
+
actorType: audit_constant_1.ACTOR_TYPE.AUTOMATION,
|
|
89
|
+
actorId: automationName,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async logWebhookAction(webhookId, params) {
|
|
93
|
+
return this.log({
|
|
94
|
+
...params,
|
|
95
|
+
actorType: audit_constant_1.ACTOR_TYPE.WEBHOOK,
|
|
96
|
+
actorId: webhookId,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.AuditService = AuditService;
|
|
101
|
+
exports.AuditService = AuditService = __decorate([
|
|
102
|
+
(0, common_1.Injectable)(),
|
|
103
|
+
__param(0, (0, typeorm_1.InjectRepository)(audit_log_entity_1.AuditLog)),
|
|
104
|
+
__param(1, (0, typeorm_1.InjectRepository)(audit_log_change_entity_1.AuditLogChange)),
|
|
105
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
106
|
+
typeorm_2.Repository])
|
|
107
|
+
], AuditService);
|
|
108
|
+
//# sourceMappingURL=audit.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.service.js","sourceRoot":"","sources":["../../src/services/audit.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAErC,gEAA2E;AAC3E,iFAAqE;AACrE,mEAAwD;AAIjD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGJ;IAEA;IAJnB,YAEmB,YAAkC,EAElC,kBAA8C;QAF9C,iBAAY,GAAZ,YAAY,CAAsB;QAElC,uBAAkB,GAAlB,kBAAkB,CAA4B;IAC9D,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,MAAsB;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YACnC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;YAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;YACjC,MAAM,EA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it",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Business-agnostic audit logging with Flexible Actor Model (ID-Only)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prebuild": "rimraf dist",
|
|
13
|
+
"build": "tsc -p tsconfig.json"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@nestjs/common": "^11.0.0",
|
|
17
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
18
|
+
"typeorm": "^0.3.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@nestjs/common": "^11.0.11",
|
|
22
|
+
"@nestjs/testing": "^11.0.5",
|
|
23
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
24
|
+
"typeorm": "^0.3.20",
|
|
25
|
+
"typescript": "^5.9.0",
|
|
26
|
+
"rimraf": "^6.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|