@communecter/cocolight-api-client 1.0.141 → 1.0.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ import type { DateValue, IdObject } from "./common.js";
2
+ import type EJSONType from "../../EJSONType.js";
3
+
4
+ // L'_id peut arriver sous 3 formes selon le chemin d'appel :
5
+ // - instance ObjectID (transform + _fromJSONValue actif — cas observé sur User.getNotifications)
6
+ // - { $id } (forme normalisée non-revivée)
7
+ // - string hex (24)
8
+ type ObjectIDInstance = InstanceType<typeof EJSONType["ObjectID"]>;
9
+ export type NotificationId = ObjectIDInstance | IdObject | string;
10
+
11
+ /** Auteur APRÈS aplatissement par _transformData (la map oid->objet devient un objet). */
12
+ export interface NotificationAuthor {
13
+ id?: string;
14
+ type?: string;
15
+ name: string;
16
+ profilThumbImageUrl?: string; // complété en URL absolue par la normalisation image
17
+ [k: string]: unknown;
18
+ }
19
+
20
+ export interface NotificationTarget {
21
+ type: string;
22
+ id: string;
23
+ parent?: { id: string; type: string };
24
+ }
25
+
26
+ /** État lu/vu, par destinataire. Un champ ABSENT (clé unset côté serveur) = état "faux". */
27
+ export interface NotificationReadState {
28
+ isUnread?: boolean;
29
+ isUnseen?: boolean;
30
+ }
31
+
32
+ export interface NotificationNotify {
33
+ objectType?: string;
34
+ /** keyé par oid de destinataire -> état lu/vu de CE destinataire. */
35
+ id: Record<string, NotificationReadState>;
36
+ displayName?: string;
37
+ icon?: string;
38
+ url?: string;
39
+ label?: string;
40
+ labelArray?: Record<string, string[]>;
41
+ labelAuthorObject?: string;
42
+ repeat?: boolean;
43
+ [k: string]: unknown;
44
+ }
45
+
46
+ /** Un élément du tableau `notif` (forme transformée). created/updated : Date instance OU {sec,usec}. */
47
+ export interface NotificationItemData {
48
+ id: string; // injecté depuis la clé de la map notif (= oid hex)
49
+ _id: NotificationId;
50
+ type: string;
51
+ verb: string;
52
+ author: NotificationAuthor;
53
+ created: Date | DateValue;
54
+ updated: Date | DateValue;
55
+ target: NotificationTarget;
56
+ notify: NotificationNotify;
57
+ timestamp?: number; // ajouté serveur (= updated.sec)
58
+ timeAgo?: string; // présent en brut, retiré au transform
59
+ [k: string]: unknown;
60
+ }
61
+
62
+ /**
63
+ * Réponse de GET_NOTIFICATIONS (mode liste, body indexMin) APRÈS transform :
64
+ * `notif` est un tableau (la map oid->item est convertie). Vide => [].
65
+ */
66
+ export interface GetNotificationsResult {
67
+ notif: NotificationItemData[];
68
+ [k: string]: unknown;
69
+ }
70
+
71
+ /**
72
+ * Réponse de GET_NOTIFICATIONS_COUNT (mode badge, body refreshTimestamp non-nul) :
73
+ * `notif` = notifications mises à jour APRÈS le timestamp (souvent [] si timestamp = maintenant),
74
+ * `countNotif` = nombre TOTAL de notifications NON VUES (isUnseen) — indépendant du timestamp.
75
+ * countNotif n'est présent QUE si refreshTimestamp est fourni et non-nul (sinon mode liste).
76
+ */
77
+ export interface GetNotificationsCountResult {
78
+ notif: NotificationItemData[];
79
+ countNotif?: number;
80
+ [k: string]: unknown;
81
+ }