/**
 * Notification delivery interfaces — system-communications-notifications.
 *
 * `NotificationType` canonical union owned by spec 97 (notification-preferences).
 * This module re-exports it without redefining the value set.
 */

// canonical union owned by notification-preferences (spec 97)
export type { NotificationType } from './notification-type'

import type { NotificationType } from './notification-type'

export interface ActionButton {
  label: string
  url?: string
  callbackAction?: string
}

export interface DeliverableNotification {
  type: NotificationType
  title: string
  body: string
  entityType?: string
  entityId?: string
  actionButtons?: ActionButton[]
}

export interface DeliveryResult {
  delivered: boolean
  error?: string
}

export interface NotificationAdapter {
  readonly id: 'email' | 'telegram' | 'push'
  canDeliver(userId: string, type: NotificationType): Promise<boolean>
  deliver(userId: string, notification: DeliverableNotification): Promise<DeliveryResult>
}

export interface SendEmailOptions {
  to: string
  templateKey: string
  vars: Record<string, string>
  locale: 'he-IL' | 'en-US'
  /** Optional metadata tags forwarded to Resend; e.g. { invoice_id } for webhook routing */
  tags?: Record<string, string>
}

export interface NotificationPreferences {
  email: NotificationType[]
  telegram: NotificationType[]
}
