@communecter/cocolight-api-client 1.0.140 → 1.0.142
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.
- package/dist/cocolight-api-client.browser.js +1 -1
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
- package/package.json +1 -1
- package/src/ApiClient.ts +5 -1
- package/src/api/BaseEntity.ts +113 -0
- package/src/api/EndpointApi.ts +16 -1
- package/src/api/EndpointApi.types.ts +103 -0
- package/src/api/Notifications.ts +196 -0
- package/src/api/User.ts +72 -1
- package/src/api/serverDataType/Notification.ts +81 -0
- package/src/endpoints.module.ts +1 -1
- package/src/index.ts +9 -0
- package/types/api/BaseEntity.d.ts +68 -1
- package/types/api/EndpointApi.d.ts +10 -1
- package/types/api/EndpointApi.types.d.ts +96 -0
- package/types/api/Notifications.d.ts +79 -0
- package/types/api/User.d.ts +30 -0
- package/types/api/serverDataType/Notification.d.ts +73 -0
- package/types/endpoints.module.d.ts +338 -0
- package/types/index.d.ts +4 -1
package/src/index.ts
CHANGED
|
@@ -41,6 +41,9 @@ const cocolightApiClient = {
|
|
|
41
41
|
|
|
42
42
|
export default cocolightApiClient;
|
|
43
43
|
|
|
44
|
+
// Helpers réactifs en exports nommés (permet `import { effect, subscribeTo } from "..."`)
|
|
45
|
+
export { batch, computed, effect, getSignals, isReactive, isSignal, reactive, subscribeTo, watch } from "./utils/reactive.js";
|
|
46
|
+
|
|
44
47
|
// Export des types pour faciliter l'utilisation
|
|
45
48
|
|
|
46
49
|
// Classes principales
|
|
@@ -101,6 +104,10 @@ export type * from "./api/serverDataType/Action.js";
|
|
|
101
104
|
export type * from "./api/serverDataType/common.js";
|
|
102
105
|
export type * from "./api/serverDataType/Country.js";
|
|
103
106
|
export type * from "./api/serverDataType/Zone.js";
|
|
107
|
+
export type * from "./api/serverDataType/Notification.js";
|
|
108
|
+
|
|
109
|
+
// Classes notifications (type-only, comme les entités) — instances obtenues via me.notifications
|
|
110
|
+
export type { Notification, Notifications } from "./api/Notifications.js";
|
|
104
111
|
|
|
105
112
|
// Types utilitaires BaseEntity
|
|
106
113
|
export type {
|
|
@@ -113,6 +120,8 @@ export type {
|
|
|
113
120
|
CostumContextFields,
|
|
114
121
|
WithCostumContext,
|
|
115
122
|
EntityType,
|
|
123
|
+
CoformThematicValue,
|
|
124
|
+
CoformFilterByPathResult,
|
|
116
125
|
} from "./api/BaseEntity.js";
|
|
117
126
|
|
|
118
127
|
// Constantes BaseEntity
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, GetNewsData, GetGalleryData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestDatesData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetOrganizationsAdminData, GetOrganizationsNoAdminData, GetProjectsAdminData, GetProjectsNoAdminData, GetPoisAdminData, GetPoisNoAdminData, GetSubscribersData, GetBadgesData, CoformAnswersSearchData, SearchMemberAutocompleteData, GetEventsData, CostumFilterCoformData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, FundingEnvelopeData, CoremuOperationData, UpdatePathValueData } from "./EndpointApi.types.js";
|
|
1
|
+
import type { UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, GetNewsData, GetGalleryData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestDatesData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetOrganizationsAdminData, GetOrganizationsNoAdminData, GetProjectsAdminData, GetProjectsNoAdminData, GetPoisAdminData, GetPoisNoAdminData, GetSubscribersData, GetBadgesData, CoformAnswersSearchData, SearchMemberAutocompleteData, GetEventsData, CostumFilterCoformData, CostumFilterCoformByPathData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, FundingEnvelopeData, CoremuOperationData, UpdatePathValueData } from "./EndpointApi.types.js";
|
|
2
2
|
import type { TransformsMap } from "../types/entities.js";
|
|
3
3
|
import type { CountryItem } from "./serverDataType/Country.js";
|
|
4
4
|
import type { ZoneItemNormalized } from "./serverDataType/Zone.js";
|
|
@@ -176,6 +176,29 @@ export type CostumContextFields = {
|
|
|
176
176
|
sourceKey: string[];
|
|
177
177
|
};
|
|
178
178
|
export type WithCostumContext<T> = T & CostumContextFields;
|
|
179
|
+
/**
|
|
180
|
+
* Une valeur distincte d'une thématique CoForm (retournée par `coformFilterByPath`).
|
|
181
|
+
*/
|
|
182
|
+
export interface CoformThematicValue {
|
|
183
|
+
/** Nom de la valeur de thématique (ex: "Cafés cantines solidaires"). */
|
|
184
|
+
name: string;
|
|
185
|
+
/** URL de l'image associée (chaîne vide si aucune). */
|
|
186
|
+
image: string;
|
|
187
|
+
/** Identifiants des éléments liés via le finder (orgas/projets/poi selon finderPath). */
|
|
188
|
+
orgaNameArray: string[];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Résultat normalisé de `coformFilterByPath` (endpoint COSTUM_FILTER_COFORM_BY_PATH).
|
|
192
|
+
* Reconstruit proprement la réponse backend que le normalizer générique aplatit.
|
|
193
|
+
*/
|
|
194
|
+
export interface CoformFilterByPathResult {
|
|
195
|
+
/** _id des answers concernées par la thématique (dédupliqués). */
|
|
196
|
+
distinctElements: string[];
|
|
197
|
+
/** Valeurs distinctes de la thématique, chacune avec image/name/éléments liés. */
|
|
198
|
+
values: CoformThematicValue[];
|
|
199
|
+
/** Compteurs renvoyés par le backend (ex: `{ answers: 14 }`). */
|
|
200
|
+
count: Record<string, number>;
|
|
201
|
+
}
|
|
179
202
|
type PaginationCursor = {
|
|
180
203
|
searchType?: string[];
|
|
181
204
|
searchBy?: string;
|
|
@@ -2044,6 +2067,50 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
2044
2067
|
* filters["activités"].count; // { "Atelier": 12, "Coworking": 8 }
|
|
2045
2068
|
*/
|
|
2046
2069
|
coformFiltersSearch(data?: Partial<CostumFilterCoformData>): Promise<any>;
|
|
2070
|
+
/**
|
|
2071
|
+
* Récupère les valeurs distinctes d'**une seule** thématique CoForm, query pilotée
|
|
2072
|
+
* côté client via `params.thematicPath` (+ `params.finderPath` optionnel).
|
|
2073
|
+
*
|
|
2074
|
+
* Distinct de {@link coformFiltersSearch} (qui passe `searchedData` et fait le batch
|
|
2075
|
+
* multi-filtres piloté serveur) : ici on cible UN filtre précis et on construit
|
|
2076
|
+
* soi-même la projection (`fields`) et les `filters`. Côté backend, c'est la branche
|
|
2077
|
+
* `isset($_POST["params"])` du controller AutoGlobalThematicNtwrkAction.
|
|
2078
|
+
*
|
|
2079
|
+
* Utile pour un **filtre par réseau régional/thématique** : on combine `params` avec
|
|
2080
|
+
* `notSourceKey: true` (cherche dans tout le réseau) ou `sourceKey: ["<réseau>"]`
|
|
2081
|
+
* (scope un réseau précis — cf. `_withCostumContext`).
|
|
2082
|
+
*
|
|
2083
|
+
* @param data - `params.thematicPath` est requis ; le reste (fields/filters/searchType/
|
|
2084
|
+
* sortBy/indexMin/indexStep/notSourceKey/locality) est optionnel.
|
|
2085
|
+
* @returns {@link CoformFilterByPathResult} : `{ distinctElements, values, count }`.
|
|
2086
|
+
* Reconstruit proprement la map backend que le normalizer générique aplatit
|
|
2087
|
+
* (la clé `results` est traitée comme wrapper de liste par `_transformData`).
|
|
2088
|
+
* @throws {ApiError} 400 si `params.thematicPath` est absent.
|
|
2089
|
+
*
|
|
2090
|
+
* @example
|
|
2091
|
+
* const res = await project.coformFilterByPath({
|
|
2092
|
+
* params: {
|
|
2093
|
+
* thematicPath: "lesCommunsDesTierslieux17102023_108_0.multiCheckboxPlus...",
|
|
2094
|
+
* finderPath: "answers.lesCommunsDesTierslieux17102023_108_0.finder...",
|
|
2095
|
+
* },
|
|
2096
|
+
* fields: [
|
|
2097
|
+
* "answers.lesCommunsDesTierslieux17102023_108_0.multiCheckboxPlus...",
|
|
2098
|
+
* "answers.lesCommunsDesTierslieux17102023_108_0.finder...",
|
|
2099
|
+
* ],
|
|
2100
|
+
* filters: {
|
|
2101
|
+
* "answers.lesCommunsDesTierslieux17102023_108_0.multiCheckboxPlus...": { $exists: true },
|
|
2102
|
+
* },
|
|
2103
|
+
* searchType: ["answers"],
|
|
2104
|
+
* notSourceKey: true,
|
|
2105
|
+
* });
|
|
2106
|
+
* res.count.answers; // 14
|
|
2107
|
+
* res.values[0].name; // "Cafés cantines solidaires"
|
|
2108
|
+
* res.values[0].orgaNameArray; // ["5b740..."]
|
|
2109
|
+
* res.distinctElements; // string[] des _id concernés
|
|
2110
|
+
*/
|
|
2111
|
+
coformFilterByPath(data: Partial<CostumFilterCoformByPathData> & {
|
|
2112
|
+
params: CostumFilterCoformByPathData["params"];
|
|
2113
|
+
}): Promise<CoformFilterByPathResult>;
|
|
2047
2114
|
/**
|
|
2048
2115
|
* Recherche des zones géographiques selon un pays et un niveau administratif.
|
|
2049
2116
|
* Utilise le contexte Communecter de l'entité courante.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ApiClient from "../ApiClient.js";
|
|
2
|
-
import type { PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, CoformGetAnswerFilesData, SaveCoformAnswerData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DeleteDocumentByIdData, DemoteAdminData, CostumFilterCoformData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, GenerateAnswerFromFormData, FundingEnvelopeData, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData } from "./EndpointApi.types.js";
|
|
2
|
+
import type { PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, CoformGetAnswerFilesData, SaveCoformAnswerData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DeleteDocumentByIdData, DemoteAdminData, CostumFilterCoformData, CostumFilterCoformByPathData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, GenerateAnswerFromFormData, FundingEnvelopeData, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData } from "./EndpointApi.types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
5
5
|
*/
|
|
@@ -1126,6 +1126,15 @@ export declare class EndpointApi {
|
|
|
1126
1126
|
* @throws {Error} - En cas d'erreur inattendue.
|
|
1127
1127
|
*/
|
|
1128
1128
|
costumFilterCoform(data: CostumFilterCoformData): Promise<any>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Filtre CoForm par path (thématique unique) : Récupère les valeurs distinctes d'UNE thématique CoForm (branche `isset($_POST['params'])` du controller AutoGlobalThematicNtwrkAction). La query est construite côté client via `params.thematicPath` (+ `params.finderPath` optionnel) ; le serveur fait un seul globalAutoComplete + tri. Distinct de COSTUM_FILTER_COFORM (branche `searchedData`, multi-filtres pilotés serveur).
|
|
1131
|
+
* Constant : COSTUM_FILTER_COFORM_BY_PATH
|
|
1132
|
+
* @param data - Données envoyées à l'API
|
|
1133
|
+
* @returns Les données de réponse.
|
|
1134
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1135
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1136
|
+
*/
|
|
1137
|
+
costumFilterCoformByPath(data: CostumFilterCoformByPathData): Promise<any>;
|
|
1129
1138
|
/**
|
|
1130
1139
|
* Récupérer la liste des pays : Récupérer la liste de tous les pays
|
|
1131
1140
|
* Constant : GET_COUNTRIES
|
|
@@ -5234,6 +5234,102 @@ export interface CostumFilterCoformData {
|
|
|
5234
5234
|
costumType?: string;
|
|
5235
5235
|
[k: string]: unknown;
|
|
5236
5236
|
}
|
|
5237
|
+
export interface CostumFilterCoformByPathData {
|
|
5238
|
+
/**
|
|
5239
|
+
* Discriminant de la branche B : chemins de la thématique et du finder. Sa présence aiguille le controller vers le mode single-filtre client-driven.
|
|
5240
|
+
*/
|
|
5241
|
+
params: {
|
|
5242
|
+
/**
|
|
5243
|
+
* Chemin de la thématique dans answers (ex: `formKey.multiCheckboxPlus...`). Devient `path` côté backend.
|
|
5244
|
+
*/
|
|
5245
|
+
thematicPath: string;
|
|
5246
|
+
/**
|
|
5247
|
+
* Chemin du finder (ex: `answers.formKey.finder...`). Optionnel : défaut backend `links.organizations`.
|
|
5248
|
+
*/
|
|
5249
|
+
finderPath?: string;
|
|
5250
|
+
};
|
|
5251
|
+
/**
|
|
5252
|
+
* Types d'entités à inclure (typiquement `["answers"]`).
|
|
5253
|
+
*/
|
|
5254
|
+
searchType?: string[];
|
|
5255
|
+
/**
|
|
5256
|
+
* Projection : champs à retourner (incluant thematicPath et finderPath).
|
|
5257
|
+
*/
|
|
5258
|
+
fields?: string[];
|
|
5259
|
+
/**
|
|
5260
|
+
* Filtres MongoDB additionnels (objet) ou chaîne vide.
|
|
5261
|
+
*/
|
|
5262
|
+
filters?: {
|
|
5263
|
+
[k: string]: unknown;
|
|
5264
|
+
} | "";
|
|
5265
|
+
/**
|
|
5266
|
+
* Champ de tri (clé = champ, valeur = 1 ou -1).
|
|
5267
|
+
*/
|
|
5268
|
+
sortBy?: {
|
|
5269
|
+
[k: string]: 1 | -1;
|
|
5270
|
+
};
|
|
5271
|
+
/**
|
|
5272
|
+
* Index de départ pour la pagination.
|
|
5273
|
+
*/
|
|
5274
|
+
indexMin?: number;
|
|
5275
|
+
/**
|
|
5276
|
+
* Nombre d'éléments à récupérer (haut par défaut : agrégation des valeurs distinctes).
|
|
5277
|
+
*/
|
|
5278
|
+
indexStep?: number;
|
|
5279
|
+
/**
|
|
5280
|
+
* Comptage des types dans la réponse.
|
|
5281
|
+
*/
|
|
5282
|
+
count?: boolean;
|
|
5283
|
+
/**
|
|
5284
|
+
* Extension Fediverse (toujours désactivée).
|
|
5285
|
+
*/
|
|
5286
|
+
fediverse?: boolean;
|
|
5287
|
+
/**
|
|
5288
|
+
* Si true, ignore le filtre sourceKey côté backend (recherche dans tout le réseau, pas seulement le costum courant).
|
|
5289
|
+
*/
|
|
5290
|
+
notSourceKey?: boolean;
|
|
5291
|
+
/**
|
|
5292
|
+
* Type initial de la recherche (vide par défaut).
|
|
5293
|
+
*/
|
|
5294
|
+
initType?: string;
|
|
5295
|
+
/**
|
|
5296
|
+
* Localités ciblées (object keyé, array d'objets, ou chaîne vide).
|
|
5297
|
+
*/
|
|
5298
|
+
locality?: {
|
|
5299
|
+
[k: string]: unknown;
|
|
5300
|
+
} | {
|
|
5301
|
+
[k: string]: unknown;
|
|
5302
|
+
}[] | "";
|
|
5303
|
+
/**
|
|
5304
|
+
* ID du contexte costum (auto-injecté par _withCostumContext).
|
|
5305
|
+
*/
|
|
5306
|
+
contextId?: string;
|
|
5307
|
+
/**
|
|
5308
|
+
* Type du contexte costum (auto-injecté).
|
|
5309
|
+
*/
|
|
5310
|
+
contextType?: "projects" | "organizations";
|
|
5311
|
+
/**
|
|
5312
|
+
* Slug du costum (auto-injecté par _withCostumContext).
|
|
5313
|
+
*/
|
|
5314
|
+
costumSlug?: string;
|
|
5315
|
+
/**
|
|
5316
|
+
* Alias historique de contextId (auto-injecté).
|
|
5317
|
+
*/
|
|
5318
|
+
costumId?: string;
|
|
5319
|
+
/**
|
|
5320
|
+
* Alias historique de contextType (auto-injecté).
|
|
5321
|
+
*/
|
|
5322
|
+
costumType?: "projects" | "organizations";
|
|
5323
|
+
/**
|
|
5324
|
+
* Mode édition costum (toujours désactivé).
|
|
5325
|
+
*/
|
|
5326
|
+
costumEditMode?: boolean;
|
|
5327
|
+
/**
|
|
5328
|
+
* Clés de source pour filtrer (ignoré si notSourceKey=true).
|
|
5329
|
+
*/
|
|
5330
|
+
sourceKey?: string[];
|
|
5331
|
+
[k: string]: unknown;
|
|
5332
|
+
}
|
|
5237
5333
|
export interface GetCountriesData {
|
|
5238
5334
|
/**
|
|
5239
5335
|
* Slug personnalisé
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { NotificationAuthor, NotificationItemData } from "./serverDataType/Notification.js";
|
|
2
|
+
type User = import("./User.js").User;
|
|
3
|
+
/**
|
|
4
|
+
* Item de notification fin. N'étend PAS BaseEntity : il garde la donnée brute, un backref
|
|
5
|
+
* User (pour router les appels via callIsMe + endpointApi) et un backref manager (pour le recount).
|
|
6
|
+
* Les drapeaux lu/vu sont réactifs (objet reactive({...}) — surface scalaire fiable).
|
|
7
|
+
*/
|
|
8
|
+
export declare class Notification {
|
|
9
|
+
private readonly _data;
|
|
10
|
+
private readonly _owner;
|
|
11
|
+
private _manager;
|
|
12
|
+
private readonly _state;
|
|
13
|
+
constructor(data: NotificationItemData, owner: User, manager?: Notifications | null);
|
|
14
|
+
static fromData(data: NotificationItemData, owner: User, manager?: Notifications | null): Notification;
|
|
15
|
+
/** Lie l'item à son manager (appelé par le manager au wrap). */
|
|
16
|
+
_attach(manager: Notifications): this;
|
|
17
|
+
get id(): string;
|
|
18
|
+
get isUnread(): boolean;
|
|
19
|
+
get isUnseen(): boolean;
|
|
20
|
+
get data(): NotificationItemData;
|
|
21
|
+
get author(): NotificationAuthor;
|
|
22
|
+
get createdAt(): Date;
|
|
23
|
+
_setReadLocal(): void;
|
|
24
|
+
_setSeenLocal(): void;
|
|
25
|
+
_restoreLocal(unread: boolean, unseen: boolean): void;
|
|
26
|
+
/** Marque CET item comme lu : optimiste + rollback + recount manager. */
|
|
27
|
+
markRead(): Promise<void>;
|
|
28
|
+
/** Pas d'endpoint "seen" par item : flip local uniquement. */
|
|
29
|
+
markSeen(): void;
|
|
30
|
+
toJSON(): NotificationItemData;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gestionnaire de notifications de l'utilisateur connecté. Accroché à User via `me.notifications`.
|
|
34
|
+
* N'étend PAS BaseEntity. Items dans un tableau SIMPLE (jamais proxifié) ; seuls les scalaires
|
|
35
|
+
* vivent dans un reactive({...}) (loadedUnreadCount, unseenTotal, cursor, hasMore, version).
|
|
36
|
+
* Aucun effect/computed créé ici (pas d'API de dispose -> pas de fuite).
|
|
37
|
+
*/
|
|
38
|
+
export declare class Notifications {
|
|
39
|
+
private readonly _owner;
|
|
40
|
+
private readonly _pageSize;
|
|
41
|
+
private _items;
|
|
42
|
+
private readonly _state;
|
|
43
|
+
constructor(owner: User, pageSize?: number);
|
|
44
|
+
get items(): Notification[];
|
|
45
|
+
get loadedUnreadCount(): number;
|
|
46
|
+
get unseenTotal(): number;
|
|
47
|
+
get hasMore(): boolean;
|
|
48
|
+
_recount(): void;
|
|
49
|
+
private _wrap;
|
|
50
|
+
private _commit;
|
|
51
|
+
/** Première page (reset le curseur). Tri serveur : updated desc, 15/page. */
|
|
52
|
+
list({ indexMin }?: {
|
|
53
|
+
indexMin?: number;
|
|
54
|
+
}): Promise<Notification[]>;
|
|
55
|
+
/** Page suivante (curseur indexMin = nb d'items déjà chargés). Concatène par réassignation. */
|
|
56
|
+
loadMore(): Promise<Notification[]>;
|
|
57
|
+
/** Recharge depuis le début. */
|
|
58
|
+
refresh(): Promise<Notification[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Badge : total des NON-VUS via GET_NOTIFICATIONS_COUNT (refreshTimestamp = maintenant ->
|
|
61
|
+
* liste vide + countNotif). Met à jour unseenTotal et le retourne.
|
|
62
|
+
*/
|
|
63
|
+
count(): Promise<number>;
|
|
64
|
+
/**
|
|
65
|
+
* PUR : convertit des `NotificationItemData[]` plats (ex. cache React Query après
|
|
66
|
+
* hydratation SSR) en `Notification[]` liées à l'utilisateur, SANS modifier l'état du
|
|
67
|
+
* manager. À utiliser dans un `select` React Query (cache plat -> instances vivantes).
|
|
68
|
+
*/
|
|
69
|
+
toItems(data: NotificationItemData[]): Notification[];
|
|
70
|
+
markAllRead(): Promise<void>;
|
|
71
|
+
markAllSeen(): Promise<void>;
|
|
72
|
+
private _bulk;
|
|
73
|
+
/** Supprime toutes les notifications de l'utilisateur + vide l'état local. */
|
|
74
|
+
clear(): Promise<void>;
|
|
75
|
+
toJSON(): NotificationItemData[];
|
|
76
|
+
restore(rawItems: NotificationItemData[]): this;
|
|
77
|
+
static restore(rawItems: NotificationItemData[], owner: User): Notifications;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
package/types/api/User.d.ts
CHANGED
|
@@ -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
5
|
import type { ChangePasswordData, DeleteAccountData, GetSubscriptionsAdminData, GetSubscriptionsData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, 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;
|
|
@@ -786,5 +788,33 @@ export declare class User extends BaseEntity<UserItemNormalized> {
|
|
|
786
788
|
* ```
|
|
787
789
|
*/
|
|
788
790
|
demoteFromAdmin(): Promise<unknown>;
|
|
791
|
+
/** Gestionnaire de notifications, créé paresseusement et mis en cache. */
|
|
792
|
+
private _notifications?;
|
|
793
|
+
/**
|
|
794
|
+
* Point d'entrée `me.notifications` (composition, PAS une entité BaseEntity).
|
|
795
|
+
* Sûr : endpointApi/apiClient sont initialisés dans le constructeur avant tout accès getter.
|
|
796
|
+
*/
|
|
797
|
+
get notifications(): Notifications;
|
|
798
|
+
/**
|
|
799
|
+
* Récupère les notifications (mode liste). STATELESS + plat (`NotificationItemData[]`),
|
|
800
|
+
* idéal comme `queryFn` React Query / prefetch SSR — ne touche PAS le manager réactif
|
|
801
|
+
* (`me.notifications`). `ApiClient._transformData` garantit `notif` = tableau (map -> array
|
|
802
|
+
* + `id` injecté), donc on fait confiance à la normalisation amont.
|
|
803
|
+
* pathParams.id est OBLIGATOIRE : le défaut "@userId" ne matche pas le pattern de l'endpoint.
|
|
804
|
+
*/
|
|
805
|
+
fetchNotifications({ indexMin }?: {
|
|
806
|
+
indexMin?: number;
|
|
807
|
+
}): Promise<NotificationItemData[]>;
|
|
808
|
+
/**
|
|
809
|
+
* Compte les notifications NON VUES (badge). STATELESS. refreshTimestamp = maintenant ->
|
|
810
|
+
* le serveur renvoie `countNotif` (total non-vus) + une liste vide.
|
|
811
|
+
*/
|
|
812
|
+
fetchNotificationsCount(): Promise<number>;
|
|
813
|
+
/** Marque une notification comme lue (MARK_NOTIFICATION_AS_READ). */
|
|
814
|
+
markNotificationAsRead(id: string): Promise<unknown>;
|
|
815
|
+
/** Marque toutes les notifications comme vues/lues (NOTIFICATION_UPDATE). */
|
|
816
|
+
markAllNotifications(action: "seen" | "read"): Promise<unknown>;
|
|
817
|
+
/** Supprime toutes les notifications de l'utilisateur (REMOVE_ALL_NOTIFICATIONS). */
|
|
818
|
+
removeAllNotifications(): Promise<unknown>;
|
|
789
819
|
}
|
|
790
820
|
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 {};
|