@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.
@@ -1,8 +1,10 @@
1
1
  import { BaseEntity } from "./BaseEntity.js";
2
+ import { Notifications } from "./Notifications.js";
2
3
  import type { Badge } from "./Badge.js";
3
4
  import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
4
- import type { ChangePasswordData, DeleteAccountData, GetSubscriptionsAdminData, GetSubscriptionsData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetFriendsAdminData } from "./EndpointApi.types.js";
5
+ import type { ChangePasswordData, DeleteAccountData, GetSubscriptionsAdminData, GetSubscriptionsData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetUserEligiblePlacesData, GetFriendsAdminData } from "./EndpointApi.types.js";
5
6
  import type { Organization } from "./Organization.js";
7
+ import type { NotificationItemData } from "./serverDataType/Notification.js";
6
8
  import type { EntityTypes } from "@/types/entities.js";
7
9
  type ApiClient = import("../ApiClient.js").default;
8
10
  type UserItemNormalized = import("./serverDataType/User.js").UserItemNormalized;
@@ -159,6 +161,20 @@ export declare class User extends BaseEntity<UserItemNormalized> {
159
161
  getOrganizations(data?: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData>, options?: {
160
162
  restoredState?: PaginatorState;
161
163
  }): Promise<PaginatorPage<Organization>>;
164
+ /**
165
+ * Récupère les lieux (organizations) memberOf de l'utilisateur, filtrés
166
+ * côté serveur par des filters arbitraires (tags, source.key, etc.) et
167
+ * un flag `notSourceKey` configurables.
168
+ *
169
+ * Mirroir de `getOrganizations` mais permet de passer dynamiquement les
170
+ * filtres du finder du formulaire (vue collaborative coform/place), pour
171
+ * que la pagination soit correcte (filtrage côté serveur, pas côté client).
172
+ *
173
+ * Constant : GET_USER_ELIGIBLE_PLACES
174
+ */
175
+ getEligiblePlaces(data?: Partial<GetUserEligiblePlacesData>, options?: {
176
+ restoredState?: PaginatorState;
177
+ }): Promise<PaginatorPage<Organization>>;
162
178
  /**
163
179
  * {@inheritDoc BaseEntity#getProjects}
164
180
  *
@@ -786,5 +802,33 @@ export declare class User extends BaseEntity<UserItemNormalized> {
786
802
  * ```
787
803
  */
788
804
  demoteFromAdmin(): Promise<unknown>;
805
+ /** Gestionnaire de notifications, créé paresseusement et mis en cache. */
806
+ private _notifications?;
807
+ /**
808
+ * Point d'entrée `me.notifications` (composition, PAS une entité BaseEntity).
809
+ * Sûr : endpointApi/apiClient sont initialisés dans le constructeur avant tout accès getter.
810
+ */
811
+ get notifications(): Notifications;
812
+ /**
813
+ * Récupère les notifications (mode liste). STATELESS + plat (`NotificationItemData[]`),
814
+ * idéal comme `queryFn` React Query / prefetch SSR — ne touche PAS le manager réactif
815
+ * (`me.notifications`). `ApiClient._transformData` garantit `notif` = tableau (map -> array
816
+ * + `id` injecté), donc on fait confiance à la normalisation amont.
817
+ * pathParams.id est OBLIGATOIRE : le défaut "@userId" ne matche pas le pattern de l'endpoint.
818
+ */
819
+ fetchNotifications({ indexMin }?: {
820
+ indexMin?: number;
821
+ }): Promise<NotificationItemData[]>;
822
+ /**
823
+ * Compte les notifications NON VUES (badge). STATELESS. refreshTimestamp = maintenant ->
824
+ * le serveur renvoie `countNotif` (total non-vus) + une liste vide.
825
+ */
826
+ fetchNotificationsCount(): Promise<number>;
827
+ /** Marque une notification comme lue (MARK_NOTIFICATION_AS_READ). */
828
+ markNotificationAsRead(id: string): Promise<unknown>;
829
+ /** Marque toutes les notifications comme vues/lues (NOTIFICATION_UPDATE). */
830
+ markAllNotifications(action: "seen" | "read"): Promise<unknown>;
831
+ /** Supprime toutes les notifications de l'utilisateur (REMOVE_ALL_NOTIFICATIONS). */
832
+ removeAllNotifications(): Promise<unknown>;
789
833
  }
790
834
  export {};
@@ -133,4 +133,24 @@ export interface FormItemNormalized {
133
133
  useBannerImg?: boolean;
134
134
  [key: string]: unknown;
135
135
  }
136
+ /**
137
+ * Une contribution individuelle à une table commune (commonTable) d'un coform.
138
+ * Retournée par `Form.getCommonTableContributors()` (endpoint GET_COFORM_COMMONTABLE_CONTRIBUTORS).
139
+ * Plusieurs entrées possibles pour un même `userId` (plusieurs solutions au même usage).
140
+ */
141
+ export interface CoformCommonTableContributor {
142
+ userId: string;
143
+ userName?: string;
144
+ userSlug?: string;
145
+ criteriaId: string;
146
+ /** Nom de la solution saisie. */
147
+ criteria: string;
148
+ /** love | happySmile | neutral | sad | cry | "" */
149
+ happiness?: string;
150
+ /** Note de 0 à 5. */
151
+ note?: number;
152
+ comment?: string;
153
+ fromAnswerId?: string;
154
+ [k: string]: unknown;
155
+ }
136
156
  export {};
@@ -0,0 +1,73 @@
1
+ import type { DateValue, IdObject } from "./common.js";
2
+ import type EJSONType from "../../EJSONType.js";
3
+ type ObjectIDInstance = InstanceType<typeof EJSONType["ObjectID"]>;
4
+ export type NotificationId = ObjectIDInstance | IdObject | string;
5
+ /** Auteur APRÈS aplatissement par _transformData (la map oid->objet devient un objet). */
6
+ export interface NotificationAuthor {
7
+ id?: string;
8
+ type?: string;
9
+ name: string;
10
+ profilThumbImageUrl?: string;
11
+ [k: string]: unknown;
12
+ }
13
+ export interface NotificationTarget {
14
+ type: string;
15
+ id: string;
16
+ parent?: {
17
+ id: string;
18
+ type: string;
19
+ };
20
+ }
21
+ /** État lu/vu, par destinataire. Un champ ABSENT (clé unset côté serveur) = état "faux". */
22
+ export interface NotificationReadState {
23
+ isUnread?: boolean;
24
+ isUnseen?: boolean;
25
+ }
26
+ export interface NotificationNotify {
27
+ objectType?: string;
28
+ /** keyé par oid de destinataire -> état lu/vu de CE destinataire. */
29
+ id: Record<string, NotificationReadState>;
30
+ displayName?: string;
31
+ icon?: string;
32
+ url?: string;
33
+ label?: string;
34
+ labelArray?: Record<string, string[]>;
35
+ labelAuthorObject?: string;
36
+ repeat?: boolean;
37
+ [k: string]: unknown;
38
+ }
39
+ /** Un élément du tableau `notif` (forme transformée). created/updated : Date instance OU {sec,usec}. */
40
+ export interface NotificationItemData {
41
+ id: string;
42
+ _id: NotificationId;
43
+ type: string;
44
+ verb: string;
45
+ author: NotificationAuthor;
46
+ created: Date | DateValue;
47
+ updated: Date | DateValue;
48
+ target: NotificationTarget;
49
+ notify: NotificationNotify;
50
+ timestamp?: number;
51
+ timeAgo?: string;
52
+ [k: string]: unknown;
53
+ }
54
+ /**
55
+ * Réponse de GET_NOTIFICATIONS (mode liste, body indexMin) APRÈS transform :
56
+ * `notif` est un tableau (la map oid->item est convertie). Vide => [].
57
+ */
58
+ export interface GetNotificationsResult {
59
+ notif: NotificationItemData[];
60
+ [k: string]: unknown;
61
+ }
62
+ /**
63
+ * Réponse de GET_NOTIFICATIONS_COUNT (mode badge, body refreshTimestamp non-nul) :
64
+ * `notif` = notifications mises à jour APRÈS le timestamp (souvent [] si timestamp = maintenant),
65
+ * `countNotif` = nombre TOTAL de notifications NON VUES (isUnseen) — indépendant du timestamp.
66
+ * countNotif n'est présent QUE si refreshTimestamp est fourni et non-nul (sinon mode liste).
67
+ */
68
+ export interface GetNotificationsCountResult {
69
+ notif: NotificationItemData[];
70
+ countNotif?: number;
71
+ [k: string]: unknown;
72
+ }
73
+ export {};