import { GeeniusError } from '@geenius/tools/errors'; import { SEOMeta } from '@geenius/seo/shared'; /** * @module NotificationTypes * @package @geenius/notifications/shared * @description Declares the shared notifications domain model used by every * package variant. These types define the publishable contract for inbox items, * preferences, and package-level configuration. */ /** * Ordered list of supported delivery channels. */ declare const NOTIFICATION_CHANNELS: readonly ['in-app', 'email', 'push', 'sms']; /** * Ordered list of supported notification status values. */ declare const NOTIFICATION_STATUSES: readonly ['unread', 'read', 'dismissed']; /** * Ordered list of supported notification types. */ declare const NOTIFICATION_TYPES: readonly [ 'info', 'success', 'warning', 'error', 'mention', 'invite', 'payment', 'system' ]; /** * Supported delivery channels for a notification record. */ type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number]; /** * Read state tracked for inbox items. */ type NotificationStatus = (typeof NOTIFICATION_STATUSES)[number]; /** * Semantic notification categories exposed to UI filters and badges. */ type NotificationType = (typeof NOTIFICATION_TYPES)[number]; /** * Realtime transport strategies supported by the package configuration. */ type NotificationRealtimeTransport = 'convex' | 'polling'; /** * Arbitrary scalar metadata attached to a notification. */ type NotificationMetadata = Record; /** * Quiet-hour window used to suppress deliveries. * * @property start 24-hour start time in `HH:mm` format. * @property end 24-hour end time in `HH:mm` format. */ interface NotificationQuietHours { start: string; end: string; } /** * Provider configuration for a delivery channel that relies on a third-party * notification service. * * @property provider Stable provider identifier such as `onesignal` or `resend`. * @property apiKey Optional credential or token reference for the provider. * @property endpoint Optional custom API or webhook endpoint. */ interface NotificationProviderConfig { provider: string; apiKey?: string; endpoint?: string; } /** * Shared notification record rendered by inbox, bell, and panel components. * * @property id Stable notification identifier. * @property type Semantic classification used for UI grouping and styling. * @property title Short headline presented in the inbox. * @property body Secondary copy that explains the event. * @property channel Delivery channel that carried the notification. * @property status Read-state value used for badges and filters. * @property userId Identifier for the receiving user. * @property metadata Optional structured metadata attached to the event. * @property createdAt ISO timestamp for when the item was created. * @property readAt Optional ISO timestamp for when the item was read. */ interface Notification { id: string; type: NotificationType; title: string; body: string; channel: NotificationChannel; status: NotificationStatus; userId: string; actorId?: string; actorName?: string; actorAvatar?: string; resourceType?: string; resourceId?: string; resourceUrl?: string; actionLabel?: string; actionUrl?: string; metadata?: NotificationMetadata; createdAt: string; readAt?: string; } /** * Channel and type-level delivery preferences for a single user. * * @property userId Identifier for the user whose preferences are stored. * @property channels Per-channel enablement flags. * @property types Per-notification-type enablement flags. * @property quietHours Optional delivery suppression window. * @property timezone Optional IANA timezone used to interpret quiet hours. */ interface NotificationPreferences { userId: string; channels: Record; types: Record; quietHours?: NotificationQuietHours; timezone?: string; } /** * Paged notification response returned by inbox queries. * * @property notifications Page of notifications. * @property unreadCount Aggregate unread count for the current user. * @property hasMore Indicates whether more results are available. */ interface NotificationBatch { notifications: Notification[]; unreadCount: number; hasMore: boolean; } /** * Resolved package configuration used to initialize notification behavior. * * @property enabledChannels Channels allowed by default for deliveries. * @property defaultChannel Default channel used when no explicit channel is supplied. * @property realtime Optional realtime transport settings for inbox refreshes. * @property defaultPreferences Optional default user preference template. * @property providers Optional third-party provider mapping for delivery channels. */ interface NotificationConfig { enabledChannels: NotificationChannel[]; defaultChannel: NotificationChannel; realtime?: { enabled: boolean; transport: NotificationRealtimeTransport; pollIntervalMs?: number; }; defaultPreferences?: Omit; providers?: Partial, NotificationProviderConfig>>; } /** * @module NotificationConfig * @package @geenius/notifications/shared * @description Provides configuration helpers for initializing the shared * notifications package. This module resolves defaults, validates the * configuration, and exposes a typed runtime error for configuration failures. */ /** * Typed configuration error thrown when the notifications package is misused. */ declare class NotificationsConfigError extends GeeniusError { /** * Creates a configuration error for the notifications package. * * @param message Human-readable explanation of the configuration issue. * @param context Optional contextual data that helps diagnose the issue. */ constructor(message: string, context?: Record); } /** * Resolves a partial configuration against the package defaults. * * @param overrides Partial configuration supplied by the consumer. * @returns A fully resolved notification configuration. * * @example * ```ts * const config = defineNotificationsConfig({ * enabledChannels: ['in-app', 'email'], * realtime: { enabled: true, transport: 'convex' }, * }) * ``` */ declare function defineNotificationsConfig(overrides?: Partial): NotificationConfig; /** * Merges an existing configuration with partial overrides. * * @param base Current resolved notification configuration. * @param overrides Partial configuration updates to apply. * @returns A new resolved notification configuration. */ declare function mergeNotificationsConfig(base: NotificationConfig, overrides: Partial): NotificationConfig; /** * Stores the resolved configuration for later package access. * * @param config Full or partial notification configuration. * @returns The resolved configuration stored by the package. * @throws {NotificationsConfigError} Thrown when the supplied config is invalid. * * @example * ```ts * configureNotifications({ * enabledChannels: ['in-app', 'email'], * defaultChannel: 'in-app', * realtime: { enabled: true, transport: 'convex' }, * }) * ``` */ declare function configureNotifications(config: NotificationConfig | Partial): NotificationConfig; /** * Returns the stored notifications configuration. * * @returns The currently configured notification settings. * @throws {NotificationsConfigError} Thrown when the package was not configured. */ declare function getNotificationsConfig(): NotificationConfig; /** * Reports whether the package currently has a stored configuration. * * @returns `true` when configureNotifications has been called. */ declare function isNotificationsConfigured(): boolean; /** * Clears the in-memory configuration state. * * @returns Nothing. */ declare function resetNotificationsConfig(): void; /** * @module NotificationsFsl * @package @geenius/notifications/shared * @description Centralizes the shared FSL inputs for the notifications package * so every runtime variant consumes the same translation keys, localized date * labels, and SEO metadata builder. */ type NotificationParams = Record; type NotificationTranslator = (key: string, params?: NotificationParams) => string; declare const NOTIFICATION_DEFAULT_TRANSLATIONS: { notifications: { common: { title: string; markAllRead: string; viewAll: string; view: string; dismiss: string; unreadSummary_zero: string; unreadSummary_one: string; unreadSummary_other: string; }; filters: { status: { all: string; unread: string; read: string; }; typeAll: string; }; channels: { inApp: string; email: string; push: string; sms: string; }; types: { info: string; success: string; warning: string; error: string; mention: string; invite: string; payment: string; system: string; }; empty: { title: string; description: string; }; bell: { openAria: string; countOverflowAria: string; countAria_one: string; countAria_other: string; }; item: { markReadAria: string; notificationAria: string; }; panel: { closeAria: string; }; preferences: { pageTitle: string; pageDescription: string; formAria: string; sections: { channels: string; types: string; quietHours: string; }; fields: { start: string; end: string; }; toggleChannelAria: string; toggleTypeAria: string; }; time: { justNow: string; minutes_one: string; minutes_other: string; hours_one: string; hours_other: string; days_one: string; days_other: string; weeks_one: string; weeks_other: string; }; dateBuckets: { today: string; yesterday: string; }; seo: { notificationsTitle: string; notificationsDescription: string; preferencesTitle: string; preferencesDescription: string; imageAlt: string; }; }; }; declare const NOTIFICATION_CHANNEL_TRANSLATION_KEYS: Readonly>; declare const NOTIFICATION_TYPE_TRANSLATION_KEYS: Readonly>; declare const NOTIFICATION_STATUS_TRANSLATION_KEYS: Readonly>>; declare function translateNotifications(key: string, params?: NotificationParams): string; declare function pluralizeNotifications(key: string, count: number, params?: NotificationParams): string; declare function getNotificationChannelLabel(channel: string, translator?: NotificationTranslator): string; declare function getNotificationTypeLabel(type: string, translator?: NotificationTranslator): string; declare function getNotificationStatusLabel(status: NotificationStatus | 'all', translator?: NotificationTranslator): string; declare function formatNotificationDateLabel(createdAt: string | Date, translator?: NotificationTranslator, locale?: string): string; declare function formatNotificationRelativeTime(createdAt: string, translator?: NotificationTranslator, locale?: string): string; declare function groupNotificationsForDisplay(notifications: Notification[], translator?: NotificationTranslator, locale?: string): Map; interface BuildNotificationsSeoMetaOptions { title: string; description: string; path: string; keywords: string[]; } declare function buildNotificationsSeoMeta(options: BuildNotificationsSeoMetaOptions): SEOMeta; /** * @module NotificationsShared * @package @geenius/notifications/shared * @description Exposes the shared notification contract, configuration * primitives, and presentation helpers consumed by every package variant. * This is the root public API for the framework-agnostic notifications layer. */ /** Re-exports shared configuration helpers for notifications consumers. */ /** * Shared UI metadata for notification badges and inbox treatments. * * @property label Human-readable label used in filters and badges. * @property color OKLCH color token used for accents and backgrounds. * @property icon Short visual marker used in list items and chips. */ interface NotificationTypeDescriptor { label: string; color: string; icon: string; } /** * Map of notification type metadata used by every UI variant. */ declare const TYPE_CONFIG: Record; /** * Human-readable labels for supported notification channels. */ declare const CHANNEL_LABELS: Record; /** * Default per-channel preference state used when preferences do not yet exist. */ declare const DEFAULT_CHANNEL_PREFS: Record; /** * Default per-type preference state used for new users. */ declare const DEFAULT_TYPE_PREFS: Record; /** * Returns the configured icon for a notification type key. * * @param type Notification type or arbitrary string key. * @returns The icon configured for the type, or the default info icon. */ declare function getNotificationIcon(type: string): string; /** * Returns the configured accent color for a notification type key. * * @param type Notification type or arbitrary string key. * @returns The OKLCH color configured for the type, or a neutral fallback. */ declare function getNotificationColor(type: string): string; /** * Formats a notification timestamp into a compact relative label. * * @param createdAt ISO timestamp associated with the notification. * @returns A compact relative time string such as `5m ago`. */ declare function formatNotificationTime(createdAt: string): string; /** * Groups notifications into date buckets suitable for inbox sections. * * @param notifications Notification records to group. * @returns A map keyed by display labels such as `Today` and `Yesterday`. * * @example * ```ts * const grouped = groupByDate(notifications) * const todayItems = grouped.get('Today') ?? [] * ``` */ declare function groupByDate(notifications: Notification[]): Map; /** * Returns a new array with every unread notification marked as read. * * @param notifications Notification records to update. * @returns A new array with unread notifications marked as read. */ declare function markAllRead(notifications: Notification[]): Notification[]; export { CHANNEL_LABELS, DEFAULT_CHANNEL_PREFS, DEFAULT_TYPE_PREFS, NOTIFICATION_CHANNELS, NOTIFICATION_CHANNEL_TRANSLATION_KEYS, NOTIFICATION_DEFAULT_TRANSLATIONS, NOTIFICATION_STATUSES, NOTIFICATION_STATUS_TRANSLATION_KEYS, NOTIFICATION_TYPES, NOTIFICATION_TYPE_TRANSLATION_KEYS, type Notification, type NotificationBatch, type NotificationChannel, type NotificationConfig, type NotificationMetadata, type NotificationPreferences, type NotificationProviderConfig, type NotificationQuietHours, type NotificationRealtimeTransport, type NotificationStatus, type NotificationType, type NotificationTypeDescriptor, NotificationsConfigError, TYPE_CONFIG, buildNotificationsSeoMeta, configureNotifications, defineNotificationsConfig, formatNotificationDateLabel, formatNotificationRelativeTime, formatNotificationTime, getNotificationChannelLabel, getNotificationColor, getNotificationIcon, getNotificationStatusLabel, getNotificationTypeLabel, getNotificationsConfig, groupByDate, groupNotificationsForDisplay, isNotificationsConfigured, markAllRead, mergeNotificationsConfig, pluralizeNotifications, resetNotificationsConfig, translateNotifications };