import type { DateValue, IdObject } from "./common.js"; import type EJSONType from "../../EJSONType.js"; type ObjectIDInstance = InstanceType; export type NotificationId = ObjectIDInstance | IdObject | string; /** Auteur APRÈS aplatissement par _transformData (la map oid->objet devient un objet). */ export interface NotificationAuthor { id?: string; type?: string; name: string; profilThumbImageUrl?: string; [k: string]: unknown; } export interface NotificationTarget { type: string; id: string; parent?: { id: string; type: string; }; } /** État lu/vu, par destinataire. Un champ ABSENT (clé unset côté serveur) = état "faux". */ export interface NotificationReadState { isUnread?: boolean; isUnseen?: boolean; } export interface NotificationNotify { objectType?: string; /** keyé par oid de destinataire -> état lu/vu de CE destinataire. */ id: Record; displayName?: string; icon?: string; url?: string; label?: string; labelArray?: Record; labelAuthorObject?: string; repeat?: boolean; [k: string]: unknown; } /** Un élément du tableau `notif` (forme transformée). created/updated : Date instance OU {sec,usec}. */ export interface NotificationItemData { id: string; _id: NotificationId; type: string; verb: string; author: NotificationAuthor; created: Date | DateValue; updated: Date | DateValue; target: NotificationTarget; notify: NotificationNotify; timestamp?: number; timeAgo?: string; [k: string]: unknown; } /** * Réponse de GET_NOTIFICATIONS (mode liste, body indexMin) APRÈS transform : * `notif` est un tableau (la map oid->item est convertie). Vide => []. */ export interface GetNotificationsResult { notif: NotificationItemData[]; [k: string]: unknown; } /** * Réponse de GET_NOTIFICATIONS_COUNT (mode badge, body refreshTimestamp non-nul) : * `notif` = notifications mises à jour APRÈS le timestamp (souvent [] si timestamp = maintenant), * `countNotif` = nombre TOTAL de notifications NON VUES (isUnseen) — indépendant du timestamp. * countNotif n'est présent QUE si refreshTimestamp est fourni et non-nul (sinon mode liste). */ export interface GetNotificationsCountResult { notif: NotificationItemData[]; countNotif?: number; [k: string]: unknown; } export {};