/** * Event Notification Interfaces * * Defines interfaces for event notifications, reminders, and alerts */ import { CalendarEvent } from './event.interfaces'; /** * Notification types */ export type NotificationType = 'reminder' | 'starting' | 'ending' | 'cancelled' | 'rescheduled' | 'invitation' | 'response' | 'conflict' | 'overdue' | 'daily_summary' | 'weekly_summary'; /** * Notification channels */ export type NotificationChannel = 'popup' | 'email' | 'sms' | 'push' | 'webhook' | 'slack' | 'teams' | 'custom'; /** * Notification priority */ export type NotificationPriority = 'low' | 'normal' | 'high' | 'urgent'; /** * Notification template */ export interface NotificationTemplate { /** Template ID */ id: string; /** Template name */ name: string; /** Notification type */ type: NotificationType; /** Supported channels */ channels: NotificationChannel[]; /** Subject template */ subject: string; /** Body template (supports placeholders) */ body: string; /** HTML body template */ htmlBody?: string; /** Placeholders available */ placeholders: string[]; /** Default priority */ defaultPriority: NotificationPriority; /** Template variables */ variables?: Record; } /** * Notification configuration */ export interface NotificationConfig { /** User ID */ userId: string; /** Enabled notification types */ enabledTypes: NotificationType[]; /** Channel preferences per type */ channelPreferences: Record; /** Quiet hours */ quietHours?: { start: string; end: string; timeZone: string; days?: number[]; }; /** Digest settings */ digestSettings?: { enabled: boolean; frequency: 'daily' | 'weekly'; time: string; channel: NotificationChannel; }; /** Custom thresholds */ customThresholds?: Record; } /** * Notification request */ export interface NotificationRequest { /** Unique ID */ id: string; /** Notification type */ type: NotificationType; /** Target user */ userId: string; /** Related event */ event: CalendarEvent; /** Delivery channel */ channel: NotificationChannel; /** Priority */ priority: NotificationPriority; /** Subject */ subject: string; /** Message body */ body: string; /** HTML body */ htmlBody?: string; /** Scheduled delivery time */ scheduledAt: Date; /** Expiration time */ expiresAt?: Date; /** Retry configuration */ retryConfig?: { maxAttempts: number; retryDelay: number; backoffMultiplier: number; }; /** Custom data */ customData?: Record; } /** * Notification status */ export interface NotificationStatus { /** Notification ID */ id: string; /** Current status */ status: 'pending' | 'sent' | 'delivered' | 'failed' | 'cancelled' | 'expired'; /** Delivery attempts */ attempts: number; /** Last attempt time */ lastAttempt?: Date; /** Next retry time */ nextRetry?: Date; /** Error details */ error?: string; /** Delivery timestamp */ deliveredAt?: Date; /** User interaction */ interaction?: { opened: boolean; clicked: boolean; dismissed: boolean; timestamp: Date; }; } /** * Notification history */ export interface NotificationHistory { /** History ID */ id: string; /** User ID */ userId: string; /** Notification type */ type: NotificationType; /** Related event ID */ eventId: string; /** Channel used */ channel: NotificationChannel; /** Sent timestamp */ sentAt: Date; /** Status */ status: NotificationStatus['status']; /** Subject */ subject: string; /** Interaction data */ interaction?: NotificationStatus['interaction']; } /** * Bulk notification request */ export interface BulkNotificationRequest { /** Bulk operation ID */ batchId: string; /** Notification requests */ notifications: NotificationRequest[]; /** Batch options */ options: { /** Parallel processing limit */ parallelLimit?: number; /** Continue on errors */ continueOnError?: boolean; /** Progress callback */ onProgress?: (completed: number, total: number) => void; }; } /** * Notification analytics */ export interface NotificationAnalytics { /** Date range */ dateRange: { start: Date; end: Date; }; /** Total notifications sent */ totalSent: number; /** Delivery rate by channel */ deliveryRates: Record; /** Open rates by type */ openRates: Record; /** Click-through rates */ clickRates: Record; /** Most effective channels */ topChannels: Array<{ channel: NotificationChannel; effectiveness: number; }>; /** User engagement scores */ engagementScores: Record; /** Error statistics */ errorStats: Record; } /** * Event notification service interface */ export interface IEventNotificationService { /** * Initialize notification service */ initialize(defaultConfig?: Partial): Promise; /** * Send immediate notification */ sendNotification(request: NotificationRequest): Promise; /** * Schedule notification */ scheduleNotification(request: NotificationRequest): Promise; /** * Send bulk notifications */ sendBulkNotifications(request: BulkNotificationRequest): Promise; /** * Cancel scheduled notification */ cancelNotification(notificationId: string): Promise; /** * Get notification status */ getNotificationStatus(notificationId: string): Promise; /** * Configure user notification preferences */ configureUserNotifications(userId: string, config: NotificationConfig): Promise; /** * Get user notification configuration */ getUserNotificationConfig(userId: string): Promise; /** * Create notification template */ createTemplate(template: NotificationTemplate): Promise; /** * Update notification template */ updateTemplate(templateId: string, updates: Partial): Promise; /** * Get notification templates */ getTemplates(type?: NotificationType): Promise; /** * Delete notification template */ deleteTemplate(templateId: string): Promise; /** * Process event for automatic notifications */ processEventNotifications(event: CalendarEvent, action: 'created' | 'updated' | 'deleted' | 'reminder'): Promise; /** * Get notification history */ getNotificationHistory(userId?: string, dateRange?: { start: Date; end: Date; }, type?: NotificationType): Promise; /** * Mark notification as read/interacted */ markNotificationInteraction(notificationId: string, interaction: 'opened' | 'clicked' | 'dismissed'): Promise; /** * Get pending notifications */ getPendingNotifications(userId?: string): Promise; /** * Get notification analytics */ getAnalytics(dateRange: { start: Date; end: Date; }, userId?: string): Promise; /** * Test notification delivery */ testNotification(userId: string, channel: NotificationChannel, message: string): Promise; /** * Cleanup expired notifications */ cleanupExpiredNotifications(): Promise; /** * Subscribe to notification events */ onNotificationSent(callback: (notification: NotificationRequest, status: NotificationStatus) => void): () => void; /** * Subscribe to notification failures */ onNotificationFailed(callback: (notification: NotificationRequest, error: string) => void): () => void; }