import { z } from 'zod'; /** * In-app notifications (issue #94, data-model.md §notifications): watchers * learn about page changes (version snapshots, ADR 0013's change unit) and * new comments. Generation excludes the actor and re-checks page read * permission at delivery time. */ export const NOTIFICATION_TYPES = ['page_changed', 'comment_added'] as const; export type NotificationType = (typeof NOTIFICATION_TYPES)[number]; export interface NotificationPayload { pageId: string; pageTitle: string; pageSlug: string; pondSlug: string; pondName: string; /** Display names of the acting users (first few, for the list entry). */ actorNames: string[]; } export interface NotificationView { id: string; type: NotificationType; payload: NotificationPayload; createdAt: string; readAt: string | null; } export const NOTIFICATION_PAGE_SIZE = 20; export const notificationListQuerySchema = z.object({ page: z.coerce.number().int().min(1).default(1), }); export type NotificationListQuery = z.infer; export interface NotificationListView { notifications: NotificationView[]; unreadCount: number; page: number; pageCount: number; } /** E-mail digest cadence (issue #95). */ export const DIGEST_FREQUENCIES = ['hourly', 'daily', 'off'] as const; export type DigestFrequency = (typeof DIGEST_FREQUENCIES)[number];