import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, } from 'typeorm'; export enum AuditAction { UserActivated = 'USER_ACTIVATED', UserDeactivated = 'USER_DEACTIVATED', UserRoleAssigned = 'USER_ROLE_ASSIGNED', UserRoleRemoved = 'USER_ROLE_REMOVED', RoleCreated = 'ROLE_CREATED', RoleUpdated = 'ROLE_UPDATED', RoleDeleted = 'ROLE_DELETED', RolePermissionsUpdated = 'ROLE_PERMISSIONS_UPDATED', SessionRevoked = 'SESSION_REVOKED', AllUserSessionsRevoked = 'ALL_USER_SESSIONS_REVOKED', NotificationCreated = 'NOTIFICATION_CREATED', } @Entity('audit_logs') export class AuditLogEntity { @PrimaryGeneratedColumn('uuid') id!: string; @Index('idx_audit_created_at') @CreateDateColumn({ name: 'created_at', type: 'datetime', precision: 3 }) createdAt!: Date; @Column({ name: 'actor_user_id', type: 'char', length: 36, nullable: true }) actorUserId!: string | null; @Column({ type: 'varchar', length: 80 }) action!: AuditAction; @Column({ name: 'target_type', type: 'varchar', length: 80 }) targetType!: string; @Column({ name: 'target_id', type: 'varchar', length: 120 }) targetId!: string; @Column({ type: 'json', nullable: true }) metadata!: Record | null; @Column({ name: 'request_id', type: 'varchar', length: 128 }) requestId!: string; }