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

import { Notification } from '../../entities/notification.entity';

export const NOTIFICATION_REPOSITORY = 'NotificationRepository';

export interface NotificationFilters {
  userId?: string;
  organizationId?: string;
  type?: string[];
  read?: boolean;
  priority?: string[];
  startDate?: Date;
  endDate?: Date;
  offset?: number;
  limit?: number;
}

export interface NotificationRepository {
  /**
   * Save a notification entity
   */
  save(notification: Notification): Promise<void>;

  /**
   * Find notification by ID
   */
  findById(id: string): Promise<Notification | null>;

  /**
   * Find notifications by filters
   */
  findByFilters(filters: NotificationFilters): Promise<Notification[]>;

  /**
   * Count notifications matching filters
   */
  count(filters: NotificationFilters): Promise<number>;

  /**
   * Find unread notifications for a user
   */
  findUnreadByUser(userId: string, limit?: number): Promise<Notification[]>;

  /**
   * Count unread notifications for a user
   */
  countUnreadByUser(userId: string): Promise<number>;

  /**
   * Find recent notifications for a user
   */
  findRecentByUser(userId: string, limit?: number): Promise<Notification[]>;

  /**
   * Mark a notification as read
   */
  markAsRead(id: string): Promise<void>;

  /**
   * Mark all notifications as read for a user
   */
  markAllAsReadForUser(userId: string): Promise<void>;

  /**
   * Delete a notification
   */
  delete(id: string): Promise<void>;

  /**
   * Delete old read notifications
   * Returns the number of deleted records
   */
  deleteOldReadNotifications(olderThanDays: number): Promise<number>;
}
