@communecter/cocolight-api-client 1.0.72 → 1.0.74
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 +2 -2
- 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/api/BaseEntity.ts +32 -1
- package/src/api/EndpointApi.ts +17 -1
- package/src/api/EndpointApi.types.ts +29 -0
- package/src/api/User.ts +14 -0
- package/src/endpoints.module.ts +234 -161
- package/types/api/BaseEntity.d.ts +18 -0
- package/types/api/EndpointApi.d.ts +11 -1
- package/types/api/EndpointApi.types.d.ts +27 -0
- package/types/api/User.d.ts +6 -0
- package/types/endpoints.module.d.ts +856 -173
package/package.json
CHANGED
package/src/api/BaseEntity.ts
CHANGED
|
@@ -41,7 +41,8 @@ import type {
|
|
|
41
41
|
GetPoisNoAdminData,
|
|
42
42
|
GetSubscribersData,
|
|
43
43
|
GetBadgesData,
|
|
44
|
-
CoformAnswersSearchData
|
|
44
|
+
CoformAnswersSearchData,
|
|
45
|
+
ProfilBannerData
|
|
45
46
|
} from "./EndpointApi.types.js";
|
|
46
47
|
import type { GetElementsKeyResponse } from "../types/api-responses.js";
|
|
47
48
|
import type { TransformsMap } from "../types/entities.js";
|
|
@@ -2752,6 +2753,36 @@ export class BaseEntity<TServerData = any> {
|
|
|
2752
2753
|
return this.callIsConnected(() => this.endpointApi.profilImage(data));
|
|
2753
2754
|
}
|
|
2754
2755
|
|
|
2756
|
+
/**
|
|
2757
|
+
* Mettre à jour l'image de bannière : Permet de mettre à jour l'image de bannière d'un utilisateur ou d'une entité.
|
|
2758
|
+
* Constant : PROFIL_BANNER
|
|
2759
|
+
* @param data - Les données à envoyer.
|
|
2760
|
+
* @param data.banner - L'image de bannière à mettre à jour.
|
|
2761
|
+
* @param data.cropW - Largeur du recadrage.
|
|
2762
|
+
* @param data.cropH - Hauteur du recadrage.
|
|
2763
|
+
* @param data.cropX - Position X du recadrage.
|
|
2764
|
+
* @param data.cropY - Position Y du recadrage.
|
|
2765
|
+
* @returns - Les données de réponse.
|
|
2766
|
+
*/
|
|
2767
|
+
async updateImageBanner({ banner: image, cropW, cropH, cropX, cropY }: { banner: UploadInput, cropW: number, cropH: number, cropX: number, cropY: number }): Promise<unknown> {
|
|
2768
|
+
|
|
2769
|
+
if (!this.id) {
|
|
2770
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
const t = this.getEntityType();
|
|
2774
|
+
if (t === "badges" || t === "news" || t === "comments" || t === "answers") {
|
|
2775
|
+
throw new ApiError(`Le type d'entité "${t}" n'est pas supporté par UPDATE_BLOCK_LOCALITY.`, 400);
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
const folder: NonNullable<ProfilBannerData["pathParams"]>["folder"] = t;
|
|
2779
|
+
|
|
2780
|
+
image = await this._validateImage(image);
|
|
2781
|
+
|
|
2782
|
+
const data: ProfilBannerData = { pathParams: { folder, ownerId: this.id }, parentType: folder, parentId: this.id, formOrigin: "banner", cropW, cropH, cropX, cropY, banner: image as unknown as Record<string, unknown>, };
|
|
2783
|
+
return this.callIsConnected(() => this.endpointApi.profilBanner(data));
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2755
2786
|
/**
|
|
2756
2787
|
* Crée une instance d'organisation et récupère son profil si nécessaire.
|
|
2757
2788
|
*
|
package/src/api/EndpointApi.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ApiAuthenticationError } from "../error.js";
|
|
3
3
|
|
|
4
4
|
import type ApiClient from "../ApiClient.js";
|
|
5
|
-
import type { PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, 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, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, AddVoteData, AddReportAbuseData } from "./EndpointApi.types.js";
|
|
5
|
+
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, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, AddVoteData, AddReportAbuseData } from "./EndpointApi.types.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
@@ -328,6 +328,22 @@ export class EndpointApi {
|
|
|
328
328
|
return this.callIsConnected("PROFIL_IMAGE", data);
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Mettre à jour l'image de bannière : Permet de mettre à jour l'image de la bannière d'un utilisateur ou d'une entité.
|
|
333
|
+
* Constant : PROFIL_BANNER
|
|
334
|
+
* @param data - Données envoyées à l'API
|
|
335
|
+
* @returns Les données de réponse.
|
|
336
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
337
|
+
* @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
|
|
338
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
339
|
+
*/
|
|
340
|
+
async profilBanner(data: ProfilBannerData): Promise<any> {
|
|
341
|
+
if (!data || typeof data !== "object") {
|
|
342
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
343
|
+
}
|
|
344
|
+
return this.callIsConnected("PROFIL_BANNER", data);
|
|
345
|
+
}
|
|
346
|
+
|
|
331
347
|
/**
|
|
332
348
|
* Obtenir les éléments liés : Récupère les informations détaillées d'un élément et de ses éléments liés.
|
|
333
349
|
* Constant : GET_ELEMENTS_ABOUT
|
|
@@ -404,6 +404,35 @@ export interface ProfilImageData {
|
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
|
|
407
|
+
export interface ProfilBannerData {
|
|
408
|
+
/**
|
|
409
|
+
* Fichier image de profil au format binaire
|
|
410
|
+
*/
|
|
411
|
+
banner: {
|
|
412
|
+
[k: string]: unknown;
|
|
413
|
+
};
|
|
414
|
+
parentId: string;
|
|
415
|
+
parentType: "citoyens" | "projects" | "organizations" | "events" | "poi";
|
|
416
|
+
formOrigin: "banner";
|
|
417
|
+
cropW: number;
|
|
418
|
+
cropH: number;
|
|
419
|
+
cropX: number;
|
|
420
|
+
cropY: number;
|
|
421
|
+
pathParams?: {
|
|
422
|
+
/**
|
|
423
|
+
* Type d'entité
|
|
424
|
+
*/
|
|
425
|
+
folder: "citoyens" | "projects" | "organizations" | "events" | "poi";
|
|
426
|
+
/**
|
|
427
|
+
* ID de l'utilisateur ou de l'entité
|
|
428
|
+
*/
|
|
429
|
+
ownerId: string;
|
|
430
|
+
[k: string]: unknown;
|
|
431
|
+
};
|
|
432
|
+
[k: string]: unknown;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
|
|
407
436
|
export interface GetElementsAboutData {
|
|
408
437
|
/**
|
|
409
438
|
* Template utilisé (ex: ficheInfoElement)
|
package/src/api/User.ts
CHANGED
|
@@ -340,7 +340,21 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
340
340
|
}
|
|
341
341
|
return super.updateImageProfil(data);
|
|
342
342
|
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* {@inheritDoc BaseEntity#updateImageBanner}
|
|
347
|
+
*
|
|
348
|
+
* Mettre à jour l'image de bannière : Permet de mettre à jour l'image de bannière d'un utilisateur ou d'une entité.
|
|
349
|
+
*/
|
|
350
|
+
override async updateImageBanner(data: Parameters<BaseEntity<UserItemNormalized>["updateImageBanner"]>[0]) {
|
|
351
|
+
if(!this.isMe){
|
|
352
|
+
throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour l'image de bannière.", 401);
|
|
353
|
+
}
|
|
354
|
+
return super.updateImageBanner(data);
|
|
355
|
+
}
|
|
343
356
|
|
|
357
|
+
|
|
344
358
|
/**
|
|
345
359
|
* {@inheritDoc BaseEntity#getOrganizations}
|
|
346
360
|
* @param [data]
|