UNPKG

@kitstack/nest-powertools

Version:

A comprehensive collection of NestJS powertools, decorators, and utilities to supercharge your backend development

38 lines (37 loc) 1.76 kB
import { type NestInterceptor, type ExecutionContext, type CallHandler } from '@nestjs/common'; import type { Observable } from 'rxjs'; import type { AuditConfig, AuditLogEntry, AuditStorage, AuditAction } from '../types/hooks'; export declare class MongoAuditStorage implements AuditStorage { private readonly logger; save(entry: AuditLogEntry): Promise<void>; find(filters: Partial<AuditLogEntry>): Promise<AuditLogEntry[]>; findById(id: string): Promise<AuditLogEntry | null>; } export declare class InMemoryAuditStorage implements AuditStorage { private logs; private readonly logger; save(entry: AuditLogEntry): Promise<void>; find(filters: Partial<AuditLogEntry>): Promise<AuditLogEntry[]>; findById(id: string): Promise<AuditLogEntry | null>; getAllLogs(): AuditLogEntry[]; clearLogs(): void; } export declare class AuditInterceptor implements NestInterceptor { private readonly auditStorage; private readonly logger; constructor(auditStorage: AuditStorage); intercept(context: ExecutionContext, next: CallHandler): Observable<any>; private getAuditConfig; private extractResourceFromContext; private extractResourceId; private sanitizeData; } export declare const Audit: (action: AuditAction | string, options?: Omit<AuditConfig, "action">) => MethodDecorator; export declare class AuditService { private readonly auditStorage; constructor(auditStorage: AuditStorage); getAuditLogs(filters?: Partial<AuditLogEntry>): Promise<AuditLogEntry[]>; getAuditLogById(id: string): Promise<AuditLogEntry | null>; getUserAuditLogs(userId: string): Promise<AuditLogEntry[]>; getResourceAuditLogs(resource: string, resourceId?: string): Promise<AuditLogEntry[]>; }