/** * Notifications Mapper * * Transforms data between API DTOs, domain models, and store state. * Supports IN_APP notifications only (not email/sms/push). * * Methods: * - toDomain: API DTO → Domain Model * - toQueryDTO: Filters → Query params * - toStoreState: Domain → Zustand store * - fromStoreState: Store → Domain * - toDbRow: Domain/Event payload → Database row * - toCreateDTO/toUpdateDTO/toPatchDTO: For backend operations */ import { BaseMapper } from '../../base'; import type { NotificationsEntity, NotificationsResponseDTO, NotificationStoreItem, QueryNotificationsDTO, CreateNotificationsDTO, UpdateNotificationsDTO, PatchNotificationsDTO, NotificationsDatabaseRow, NotificationCreatedStreamData } from '@plyaz/types/core'; /** Preference fields that can be toggled */ type PreferenceToggleField = 'marketing_enabled' | 'promotional_enabled' | 'social_enabled' | 'system_enabled'; /** * Notifications Mapper implementation * Supports IN_APP notifications only */ declare class NotificationsMapperClass extends BaseMapper { /** * Map DTO channel to DB channel (uppercase) * DTO: email, sms, push → DB: EMAIL, SMS, PUSH */ static mapChannelToDb(channel?: string | null): NotificationsDatabaseRow['channel']; /** * Map category to DB format */ static mapCategoryToDb(category?: string | null): NotificationsDatabaseRow['category']; /** * API DTO → Domain Model * Handles both snake_case (DTO) and camelCase (Entity) input formats */ toDomain(dto: NotificationsResponseDTO | NotificationsEntity): NotificationsEntity; /** * Database Row → API Response DTO (for backend) */ toResponseDTO(row: NotificationsDatabaseRow): NotificationsResponseDTO; /** * Filters → Query params DTO (GET) */ toQueryDTO(filters: Partial): QueryNotificationsDTO; /** * Domain → Store state (serializable) * For IN_APP notifications store */ toStoreState(domain: NotificationsEntity): NotificationStoreItem; /** * Store state → Domain (restore) */ fromStoreState(state: NotificationStoreItem): NotificationsEntity; /** * Domain Entity → Create DTO (for backend) */ toCreateDTO(entity: NotificationsEntity): CreateNotificationsDTO; /** * Domain Entity → Update DTO (for backend) */ toUpdateDTO(entity: NotificationsEntity): UpdateNotificationsDTO; /** * Partial Domain → Patch DTO (for backend) */ toPatchDTO(partial: Partial): PatchNotificationsDTO; /** * Domain Entity → Stream Data (for broadcasting via SSE/WebSocket) * Used by backend afterCreate hook to emit notification:created event */ toStreamData(entity: NotificationsEntity): NotificationCreatedStreamData; /** * Stream Data → Store Item (for frontend store) * Used by frontend stream handler to add notification to store */ fromStreamData(streamData: NotificationCreatedStreamData): NotificationStoreItem; /** * Convert event payload/entity to database row format * Used by event handlers to persist notifications to DB */ toDbRow(payload: Partial | Record, userId?: string): Partial; /** Category to preference field mapping */ private static readonly CATEGORY_PREFERENCE_MAP; /** * Map notification category to preference database field. * Returns the field name to disable for unsubscribe. */ static mapCategoryToPreferenceField(category: string): PreferenceToggleField | undefined; } export { NotificationsMapperClass }; export declare const NotificationsMapper: NotificationsMapperClass; //# sourceMappingURL=NotificationsMapper.d.ts.map