@communecter/cocolight-api-client 1.0.76 → 1.0.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.76",
3
+ "version": "1.0.77",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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, 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, UpdatePathValueData } 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, UpdatePathValueData, DeleteDocumentByContextData } from "./EndpointApi.types.js";
6
6
 
7
7
  /**
8
8
  * Classe EndpointApi générée automatiquement depuis endpoints-copie.json
@@ -1688,6 +1688,22 @@ export class EndpointApi {
1688
1688
  return this.callIsConnected("UPDATE_PATH_VALUE", data);
1689
1689
  }
1690
1690
 
1691
+ /**
1692
+ * Supprimer une image/document par contexte d’entité : Supprimer des documents associés à une entité dans un contexte spécifique
1693
+ * Constant : DELETE_DOCUMENT_BY_CONTEXT
1694
+ * @param data - Données envoyées à l'API
1695
+ * @returns Les données de réponse.
1696
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1697
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1698
+ * @throws {Error} - En cas d'erreur inattendue.
1699
+ */
1700
+ async deleteDocumentByContext(data: DeleteDocumentByContextData): Promise<any> {
1701
+ if (!data || typeof data !== "object") {
1702
+ throw new TypeError("Le paramètre data doit être un objet.");
1703
+ }
1704
+ return this.callIsConnected("DELETE_DOCUMENT_BY_CONTEXT", data);
1705
+ }
1706
+
1691
1707
  }
1692
1708
 
1693
1709
  export default EndpointApi;
@@ -4870,3 +4870,32 @@ export interface UpdatePathValueData {
4870
4870
  };
4871
4871
  [k: string]: unknown;
4872
4872
  }
4873
+
4874
+
4875
+ export interface DeleteDocumentByContextData {
4876
+ /**
4877
+ * ID de l’utilisateur
4878
+ */
4879
+ parentId?: string;
4880
+ /**
4881
+ * Type de contexte de l’entité
4882
+ */
4883
+ parentType?: "citoyens" | "organizations" | "projects" | "events" | "poi";
4884
+ path: "communecter";
4885
+ /**
4886
+ * ID image/document à supprimer
4887
+ */
4888
+ ids?: string;
4889
+ pathParams?: {
4890
+ /**
4891
+ * ID du contexte de l’entité
4892
+ */
4893
+ contextId: string;
4894
+ /**
4895
+ * Type de contexte de l’entité
4896
+ */
4897
+ contextType: "citoyens" | "organizations" | "projects" | "events" | "poi";
4898
+ [k: string]: unknown;
4899
+ };
4900
+ [k: string]: unknown;
4901
+ }
package/src/api/News.ts CHANGED
@@ -163,12 +163,26 @@ export class News extends BaseEntity<NewsItemNormalized> {
163
163
  payload.idNews = this.id;
164
164
 
165
165
  let hasChanged = false;
166
- await this.callIsConnected(() => this.endpointApi.updateNews(payload as UpdateNewsData)) as any;
167
- // TODO : voir si j'ai ce qui faut dans data de UPDATE_NEWS pour mettre à jour #serverData
168
- // c'est dans data.object
169
- // if(data?.object){
170
- // this._serverData = { ...data.object };
166
+
167
+
168
+ // il faut que j'ai les ids des images et fichiers avant la mise à jour venant de serverData
169
+ // if (this._serverData?.mediaImg?.images && this._serverData?.mediaImg?.images.length > 0) {
170
+ // imagesIds = this._serverData.mediaImg.images.map((img: any) => img.id);
171
171
  // }
172
+
173
+ // if (this._serverData?.mediaFile?.files && this._serverData?.mediaFile?.files.length > 0) {
174
+ // filesIds = this._serverData.mediaFile.files.map((f: any) => f.id);
175
+ // }
176
+
177
+ // comparer avec this._draftData.mediaImg.images pour voir si des images ont été supprimées
178
+ // comparer avec this._draftData.mediaFile.files pour voir si des fichiers ont été supprimés
179
+
180
+
181
+ await this.callIsConnected(() => this.endpointApi.updateNews(payload as UpdateNewsData)) as any;
182
+
183
+ // TODO : je voudrais pouvoir comparer les images et fichiers pour supprimer ceux qui ont été enlevés
184
+ // avec deleteDocumentByContext() mais il faut que j'ai les ids des images et fichiers avant la mise à jour
185
+
172
186
  hasChanged = true;
173
187
  return hasChanged;
174
188
  };
@@ -262,6 +276,8 @@ export class News extends BaseEntity<NewsItemNormalized> {
262
276
  return dataFile;
263
277
  }
264
278
 
279
+
280
+
265
281
  /**
266
282
  * Supprimer une actualité : Supprime une actualité existante.
267
283
  * Constant : DELETE_NEWS
@@ -335,7 +335,7 @@ export class Organization extends BaseEntity<OrganizationItemNormalized> {
335
335
  const { toBeValidated, isAdmin, isAdminPending, isInviting, roles = [] } = options;
336
336
 
337
337
  if(this.isMe){
338
- finalData.pathParams = { type: this.getEntityType(), id: this.id };
338
+ finalData.pathParams = { id: this.id };
339
339
  // finalData.filters = {
340
340
  // [`links.memberOf.${this.id}`]: { "$exists": true },
341
341
  // [`links.memberOf.${this.id}.toBeValidated`]: { "$exists": false },