diff --git a/src/modules/notifications.types.ts b/src/modules/notifications.types.ts new file mode 100644 index 0000000..a7bdd7d --- /dev/null +++ b/src/modules/notifications.types.ts @@ -0,0 +1,83 @@ +export type NotificationChannel = "email" | "sms" | "push" | "in_app"; + +export type NotificationPriority = "low" | "normal" | "high" | "urgent"; + +/** + * A notification recipient. + */ +export type NotificationRecipient = { + userId: string; + channels?: NotificationChannel[]; +}; + +export type NotificationTemplate = { + id: string; + name: string; + subject?: string; + body: string; + channel: NotificationChannel; +}; + +export type SendNotificationParams = { + recipientId: string; + templateId?: string; + channel: NotificationChannel; + subject?: string; + body: string; + priority?: NotificationPriority; + metadata?: Record; + scheduledAt?: string; +}; + +export type BulkNotificationParams = { + recipientIds: string[]; + templateId: string; + channel: NotificationChannel; + variables?: Record; + priority?: NotificationPriority; +}; + +export type NotificationResult = { + id: string; + status: "queued" | "sent" | "delivered" | "failed"; + sentAt?: string; + error?: string; +}; + +export type NotificationPreferences = { + userId: string; + enabledChannels: NotificationChannel[]; + quietHoursStart?: string; + quietHoursEnd?: string; + unsubscribedTopics: string[]; +}; + +export type ListNotificationsParams = { + status?: "queued" | "sent" | "delivered" | "failed"; + channel?: NotificationChannel; + limit?: number; + skip?: number; +}; + +export interface NotificationsModule { + send(params: SendNotificationParams): Promise; + + sendBulk(params: BulkNotificationParams): Promise; + + getPreferences(userId: string): Promise; + + updatePreferences( + userId: string, + preferences: Partial> + ): Promise; + + list(params?: ListNotificationsParams): Promise; + + /** + * Cancels a scheduled notification before it is sent. + * + * @param notificationId - The ID of the notification to cancel. + * @returns Promise resolving to `true` if the notification was successfully cancelled. + */ + cancel(notificationId: string): Promise; +}