/**
 * @copyright NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

enum AuditAction {
  login = "LOGIN",
  logout = "LOGOUT",
  loginFailed = "LOGIN_FAILED",
  commentCreate = "COMMENT_CREATE",
  commentUpdate = "COMMENT_UPDATE",
  commentDelete = "COMMENT_DELETE",
  entryCreate = "ENTRY_CREATE",
  entryUpdate = "ENTRY_UPDATE",
  entryDelete = "ENTRY_DELETE",
  like = "LIKE",
  unlike = "UNLIKE",
  userBan = "USER_BAN",
  userUnban = "USER_UNBAN",
  rateLimitExceeded = "RATE_LIMIT_EXCEEDED",
  csrfValidationFailed = "CSRF_VALIDATION_FAILED",
  unauthorizedAccess = "UNAUTHORIZED_ACCESS",
  achievementUnlocked = "ACHIEVEMENT_UNLOCKED",
}

enum AuditCategory {
  auth = "AUTH",
  content = "CONTENT",
  admin = "ADMIN",
  security = "SECURITY",
}

interface AuditLogUser {
  id:       string;
  username: string;
  avatar?:  string;
}

interface AuditLog {
  id:            string;
  action:        AuditAction;
  category:      AuditCategory;
  userId?:       string;
  user?:         AuditLogUser;
  targetUserId?: string;
  targetUser?:   AuditLogUser;
  resourceType?: string;
  resourceId?:   string;
  details?:      string;
  userAgent?:    string;
  success:       boolean;
  createdAt:     Date;
}

interface AuditLogFilters {
  action?:    AuditAction;
  category?:  AuditCategory;
  userId?:    string;
  success?:   boolean;
  startDate?: Date;
  endDate?:   Date;
  page?:      number;
  limit?:     number;
}

export {
  AuditAction,
  AuditCategory,
  type AuditLog,
  type AuditLogFilters,
  type AuditLogUser,
};
