@communecter/cocolight-api-client 1.0.78 → 1.0.80

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.78",
3
+ "version": "1.0.80",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
package/src/ApiClient.ts CHANGED
@@ -1383,6 +1383,13 @@ export default class ApiClient extends EventEmitter {
1383
1383
  if(item?.author?.typeSig === "people"){
1384
1384
  item.author.type = "citoyens";
1385
1385
  }
1386
+
1387
+ if(item?.typeSig === "people"){
1388
+ item.collection = "citoyens";
1389
+ }
1390
+ if(item?.typeSig === "organizations"){
1391
+ item.collection = "organizations";
1392
+ }
1386
1393
 
1387
1394
  // Convertit en EJSON si besoin
1388
1395
  return this._fromJSONValue ? EJSON.fromJSONValue(item) : item;
@@ -42,7 +42,8 @@ import type {
42
42
  GetSubscribersData,
43
43
  GetBadgesData,
44
44
  CoformAnswersSearchData,
45
- ProfilBannerData
45
+ ProfilBannerData,
46
+ SearchMemberAutocompleteData
46
47
  } from "./EndpointApi.types.js";
47
48
  import type { GetElementsKeyResponse } from "../types/api-responses.js";
48
49
  import type { TransformsMap } from "../types/entities.js";
@@ -230,6 +231,8 @@ type LinkFilters = Record<string, FilterValue>;
230
231
  interface MinimalUserLink {
231
232
  toBeValidated?: boolean;
232
233
  isInviting?: boolean;
234
+ isAdminInviting?: boolean;
235
+ isAdminPending?: boolean;
233
236
  }
234
237
 
235
238
  // Types pour linkEntitiesFromServerData
@@ -2406,7 +2409,7 @@ export class BaseEntity<TServerData = any> {
2406
2409
  }
2407
2410
 
2408
2411
  // Invitation reçue → accepte automatiquement
2409
- if (userLink.isInviting) {
2412
+ if (userLink.isInviting || userLink.isAdminInviting) {
2410
2413
  return this._acceptLinkRequest();
2411
2414
  }
2412
2415
 
@@ -2443,7 +2446,7 @@ export class BaseEntity<TServerData = any> {
2443
2446
 
2444
2447
  const userLink = this._getLinkFromConnectedUser();
2445
2448
 
2446
- if (userLink && userLink.isInviting) {
2449
+ if (userLink && (userLink.isInviting || userLink.isAdminInviting)) {
2447
2450
  const t = this.getEntityType();
2448
2451
 
2449
2452
  // 1) Garde runtime pour exclure les types non pris en charge par LinkValidateData
@@ -3382,8 +3385,8 @@ export class BaseEntity<TServerData = any> {
3382
3385
  */
3383
3386
  protected _validateUserLink(userLink: MinimalUserLink | null | undefined): boolean {
3384
3387
  if (!userLink) return false;
3385
- const { toBeValidated, isInviting } = userLink;
3386
- return !toBeValidated && !isInviting;
3388
+ const { toBeValidated, isInviting, isAdminInviting, isAdminPending } = userLink;
3389
+ return !toBeValidated && !isInviting && !isAdminInviting && !isAdminPending;
3387
3390
  }
3388
3391
 
3389
3392
  /**
@@ -4085,6 +4088,30 @@ export class BaseEntity<TServerData = any> {
4085
4088
  return paginator.next() as Promise<PaginatorPage<any>>;
4086
4089
  }
4087
4090
 
4091
+ async searchMembers(data: SearchMemberAutocompleteData) {
4092
+ // TODO: j'ai l'impression que searchMode : "organizationOnly" ne renvois pas que des organisations
4093
+ const result = await this.endpointApi.searchMemberAutocomplete(data);
4094
+ if (!result || !Array.isArray(result)) {
4095
+ return [];
4096
+ }
4097
+
4098
+ const t = this.getEntityType();
4099
+ if (t === "badges" || t === "news" || t === "poi" || t === "comments") {
4100
+ throw new ApiError(`Le type d'entité "${t}" n'est pas supporté par searchMemberAutocomplete.`, 400);
4101
+ }
4102
+
4103
+ result.forEach(item => {
4104
+ for (const key of Object.keys(item)) {
4105
+ if (!["id", "name", "slug", "profilThumbImageUrl", "profilMarkerImageUrl", "type", "collection"].includes(key)) {
4106
+ delete item[key];
4107
+ }
4108
+ }
4109
+ });
4110
+
4111
+ const rawList = this._linkEntities(result);
4112
+ return rawList;
4113
+ }
4114
+
4088
4115
  }
4089
4116
 
4090
4117
  export default BaseEntity;
@@ -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, DeleteDocumentByContextData } 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, DemoteAdminData } from "./EndpointApi.types.js";
6
6
 
7
7
  /**
8
8
  * Classe EndpointApi générée automatiquement depuis endpoints-copie.json
@@ -1704,6 +1704,22 @@ export class EndpointApi {
1704
1704
  return this.callIsConnected("DELETE_DOCUMENT_BY_CONTEXT", data);
1705
1705
  }
1706
1706
 
1707
+ /**
1708
+ * Rétirer les droits d’administrateur d’un membre : Rétirer les droits d’administrateur d’un membre d’une organisation ou d’un projet
1709
+ * Constant : DEMOTE_ADMIN
1710
+ * @param data - Données envoyées à l'API
1711
+ * @returns Les données de réponse.
1712
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1713
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1714
+ * @throws {Error} - En cas d'erreur inattendue.
1715
+ */
1716
+ async demoteAdmin(data: DemoteAdminData): Promise<any> {
1717
+ if (!data || typeof data !== "object") {
1718
+ throw new TypeError("Le paramètre data doit être un objet.");
1719
+ }
1720
+ return this.callIsConnected("DEMOTE_ADMIN", data);
1721
+ }
1722
+
1707
1723
  }
1708
1724
 
1709
1725
  export default EndpointApi;
@@ -4899,3 +4899,17 @@ export interface DeleteDocumentByContextData {
4899
4899
  };
4900
4900
  [k: string]: unknown;
4901
4901
  }
4902
+
4903
+
4904
+ export interface DemoteAdminData {
4905
+ parentId: string;
4906
+ /**
4907
+ * Type de contexte de l’entité
4908
+ */
4909
+ parentType: "organizations" | "projects";
4910
+ childId: string;
4911
+ childType: "citoyens";
4912
+ connect: "members" | "contributors";
4913
+ isAdmin: false;
4914
+ [k: string]: unknown;
4915
+ }