/** * 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; /** * Find notification by ID */ findById(id: string): Promise; /** * Find notifications by filters */ findByFilters(filters: NotificationFilters): Promise; /** * Count notifications matching filters */ count(filters: NotificationFilters): Promise; /** * Find unread notifications for a user */ findUnreadByUser(userId: string, limit?: number): Promise; /** * Count unread notifications for a user */ countUnreadByUser(userId: string): Promise; /** * Find recent notifications for a user */ findRecentByUser(userId: string, limit?: number): Promise; /** * Mark a notification as read */ markAsRead(id: string): Promise; /** * Mark all notifications as read for a user */ markAllAsReadForUser(userId: string): Promise; /** * Delete a notification */ delete(id: string): Promise; /** * Delete old read notifications * Returns the number of deleted records */ deleteOldReadNotifications(olderThanDays: number): Promise; }