import type { RedisOptions } from 'ioredis'; import type { MessagingTransport } from './transport/transport.interface.js'; import type { RetryStrategyConfig } from '@omnitron-dev/titan/utils'; import type { NotificationChannel } from './channel/channel.interface.js'; export interface NotificationsModuleOptions { transport?: { useTransport?: MessagingTransport; rotif?: RotifTransportOptions; }; redis?: RedisOptions | string; rateLimiter?: IRateLimiter; preferenceStore?: IPreferenceStore; channelRouter?: IChannelRouter; defaultChannels?: string[]; isGlobal?: boolean; channels?: NotificationChannel[]; enableInApp?: boolean; enableWebhook?: boolean; inAppConfig?: { keyPrefix?: string; defaultTTL?: number; maxNotificationsPerUser?: number; enableRealtime?: boolean; }; webhookConfig?: { timeout?: number; retries?: number; signatureSecret?: string; signatureHeader?: string; }; templates?: { enabled?: boolean; cacheEnabled?: boolean; cacheTTL?: number; }; rateLimiterConfig?: { keyPrefix?: string; defaultLimits?: { perMinute?: number; perHour?: number; perDay?: number; burstLimit?: number; }; channelLimits?: Record; enableBurstDetection?: boolean; }; preferenceStoreConfig?: { keyPrefix?: string; defaultPreferences?: Partial; }; } export interface NotificationsModuleAsyncOptions { imports?: any[]; useFactory?: (...args: any[]) => Promise | NotificationsModuleOptions; inject?: any[]; useExisting?: any; useClass?: any; isGlobal?: boolean; } export interface NotificationsOptionsFactory { createNotificationsOptions(): Promise | NotificationsModuleOptions; } export interface RotifTransportOptions { maxRetries?: number; retryDelay?: number | ((attempt: number) => number); retryStrategy?: RetryStrategyConfig; deduplicationTTL?: number; maxStreamLength?: number; disableDelayed?: boolean; } export interface NotificationPayload { id?: string; type: NotificationType; title: string; message: string; data?: Record; priority?: NotificationPriority; metadata?: NotificationMetadata; } export type NotificationType = 'info' | 'success' | 'warning' | 'error' | 'critical' | 'alert' | 'reminder' | 'announcement'; export type NotificationPriority = 'low' | 'normal' | 'high' | 'urgent'; export interface NotificationMetadata { category?: string; tags?: string[]; ttl?: number; deduplicationKey?: string; } export interface NotificationRecipient { id: string; email?: string; phone?: string; pushTokens?: string[]; webhookUrl?: string; locale?: string; } export interface SendOptions { channels?: string[]; scheduledAt?: Date | number; retries?: number; timeout?: number; fallbackChannels?: string[]; metadata?: Record; } export interface SendResult { notificationId: string; status: 'sent' | 'scheduled' | 'failed' | 'queued'; channels: ChannelResult[]; timestamp: number; error?: string; } export interface ChannelResult { channel: string; status: 'success' | 'failed' | 'skipped'; deliveredAt?: number; messageId?: string; error?: string; metadata?: Record; } export interface BroadcastOptions { channels?: string[]; filters?: RecipientFilter[]; batchSize?: number; throttle?: number; metadata?: Record; } export interface RecipientFilter { field: string; operator: 'eq' | 'ne' | 'in' | 'nin' | 'gt' | 'lt' | 'gte' | 'lte'; value: any; } export interface BroadcastResult { broadcastId: string; totalRecipients: number; successCount: number; failureCount: number; skippedCount: number; timestamp: number; errors?: Array<{ recipientId: string; error: string; }>; } export interface ScheduleResult extends SendResult { scheduledAt: number; jobId: string; } export interface NotificationTransport { send(recipient: NotificationRecipient, payload: NotificationPayload, options?: SendOptions): Promise; broadcast(recipients: NotificationRecipient[], payload: NotificationPayload, options?: BroadcastOptions): Promise; schedule(recipient: NotificationRecipient, payload: NotificationPayload, scheduledAt: Date | number, options?: SendOptions): Promise; cancel(notificationId: string): Promise; getStatus(notificationId: string): Promise; } export interface IRateLimiter { checkLimit(recipientId: string, channel: string, type?: NotificationType): Promise<{ allowed: boolean; retryAfter?: number; }>; recordSent(recipientId: string, channel: string, type?: NotificationType): Promise; reset(recipientId: string, channel?: string): Promise; } export interface IPreferenceStore { getPreferences(recipientId: string): Promise; setPreferences(recipientId: string, preferences: Partial): Promise; updatePreferences(recipientId: string, updates: Partial): Promise; deletePreferences(recipientId: string): Promise; } export interface NotificationPreferences { channels: { [channel: string]: { enabled: boolean; types?: NotificationType[]; quietHours?: { start: string; end: string; }; }; }; globalMute?: boolean; locale?: string; timezone?: string; } export interface IChannelRouter { route(recipient: NotificationRecipient, payload: NotificationPayload, requestedChannels?: string[]): Promise; canSendViaChannel(recipient: NotificationRecipient, channel: string, payload: NotificationPayload): Promise; } export interface NotificationsHealthStatus { status: 'healthy' | 'degraded' | 'unhealthy'; transport: { connected: boolean; latency?: number; error?: string; }; redis?: { connected: boolean; latency?: number; error?: string; }; features: { rateLimiter: boolean; preferenceStore: boolean; channelRouter: boolean; }; metrics?: { totalSent: number; totalFailed: number; queuedCount: number; averageLatency: number; }; timestamp: number; } export interface NotificationEvent { type: 'sent' | 'failed' | 'scheduled' | 'cancelled' | 'delivered'; notificationId: string; recipientId: string; channel: string; timestamp: number; metadata?: Record; error?: string; } export interface StoredNotification { id: string; recipientId: string; payload: NotificationPayload; createdAt: number; readAt?: number; dismissedAt?: number; expiresAt?: number; } //# sourceMappingURL=notifications.types.d.ts.map