/**
 * Audit Log Repository Port
 *
 * Defines the interface for Audit Log persistence operations.
 * This is a secondary port (output port) in hexagonal architecture.
 */

import { AuditLog } from '../../entities/audit-log.entity';

export const AUDIT_LOG_REPOSITORY = 'AuditLogRepository';

export interface AuditLogFilters {
  userId?: string;
  organizationId?: string;
  action?: string[];
  resourceType?: string;
  resourceId?: string;
  dateFrom?: Date;
  dateTo?: Date;
  limit?: number;
  offset?: number;
}

export interface AuditLogRepository {
  /**
   * Save an audit log entry
   */
  save(auditLog: AuditLog): Promise<void>;

  /**
   * Find audit log by ID
   */
  findById(id: string): Promise<AuditLog | null>;

  /**
   * Find audit logs by filters
   */
  findByFilters(filters: AuditLogFilters): Promise<AuditLog[]>;

  /**
   * Count audit logs matching filters
   */
  count(filters: AuditLogFilters): Promise<number>;

  /**
   * Find audit logs for a specific resource
   */
  findByResource(resourceType: string, resourceId: string): Promise<AuditLog[]>;

  /**
   * Find recent audit logs for an organization
   */
  findRecentByOrganization(organizationId: string, limit: number): Promise<AuditLog[]>;

  /**
   * Find audit logs by user
   */
  findByUser(userId: string, limit: number): Promise<AuditLog[]>;
}
