@communecter/cocolight-api-client 1.0.154 → 1.0.155

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.154",
3
+ "version": "1.0.155",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4617,6 +4617,52 @@ export class BaseEntity<TServerData = any> {
4617
4617
  throw new ApiError("Vous n'êtes pas abonné à cette entité.", 404);
4618
4618
  }
4619
4619
 
4620
+ /**
4621
+ * Invite des personnes PAR EMAIL à rejoindre CETTE entité (organisation, projet ou événement).
4622
+ *
4623
+ * Méthode de haut niveau à PRÉFÉRER à un appel direct `endpointApi.inviteMembers`.
4624
+ * Wrappe INVITE_MEMBERS (POST /co2/link/multiconnect, `listInvite.invites`) : le backend
4625
+ * crée un citoyen « pending » par email puis envoie un mail d'invitation. Les clés des
4626
+ * invités sont des UUID v4 générés ici (le contrat l'exige).
4627
+ *
4628
+ * @param invites - Liste d'invités `{ name, mail, msg?, isAdmin?, roles? }` (clé `mail`,
4629
+ * comme le legacy `Link::invite` ; `isAdmin:"admin"` pour inviter en admin).
4630
+ * @returns Réponse de l'API (par invité : citoyens/invites/organizations).
4631
+ * @throws {ApiError} Si l'entité n'a pas d'id, n'est pas une orga/projet/événement, ou liste vide.
4632
+ */
4633
+ async inviteByEmail(
4634
+ invites: Array<{ name: string; mail: string; msg?: string; isAdmin?: "" | "admin"; roles?: string[] }>,
4635
+ ): Promise<unknown> {
4636
+ if (!this.id) {
4637
+ throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
4638
+ }
4639
+ const parentType = this.getEntityType();
4640
+ if (parentType !== "organizations" && parentType !== "projects" && parentType !== "events") {
4641
+ throw new ApiError(`L'invitation par email n'est pas supportée pour le type "${parentType}".`, 400);
4642
+ }
4643
+ if (!Array.isArray(invites) || invites.length === 0) {
4644
+ throw new ApiError("Aucun invité fourni.", 400);
4645
+ }
4646
+ const listInvite = {
4647
+ invites: Object.fromEntries(invites.map((inv) => [this._uuidV4(), inv])),
4648
+ };
4649
+ return this.callIsConnected(() =>
4650
+ this.endpointApi.inviteMembers({ parentId: this.id as string, parentType, listInvite }),
4651
+ );
4652
+ }
4653
+
4654
+ /** UUID v4 compatible browser + Node (`crypto.randomUUID()` si dispo, sinon fallback). @private */
4655
+ private _uuidV4(): string {
4656
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
4657
+ return crypto.randomUUID();
4658
+ }
4659
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4660
+ const r = (Math.random() * 16) | 0;
4661
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
4662
+ return v.toString(16);
4663
+ });
4664
+ }
4665
+
4620
4666
 
4621
4667
  /**
4622
4668
  * Vérifie si l'utilisateur est connecté et a accès à l'entité.
@@ -2,7 +2,7 @@
2
2
  import { ApiAuthenticationError } from "../error.js";
3
3
 
4
4
  import type ApiClient from "../ApiClient.js";
5
- import type { DocumentListData, 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, GetUserEligiblePlacesData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, SearchEventsCostumData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, CoformGetAnswerFilesData, GetCoformCatalogsData, SaveCoformAnswerData, GetCoformAnswerHistoryData, GetCoformMultievalDataData, GetCoformCommontableContributorsData, 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, PersonActivateData } from "./EndpointApi.types.js";
5
+ import type { DocumentListData, 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, GetUserEligiblePlacesData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, SearchEventsCostumData, ShareEventsData, InviteMembersData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, CoformGetAnswerFilesData, GetCoformCatalogsData, SaveCoformAnswerData, GetCoformAnswerHistoryData, GetCoformMultievalDataData, GetCoformCommontableContributorsData, 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, PersonActivateData } from "./EndpointApi.types.js";
6
6
 
7
7
  /**
8
8
  * Classe EndpointApi générée automatiquement depuis endpoints-copie.json
@@ -1398,19 +1398,19 @@ export class EndpointApi {
1398
1398
  }
1399
1399
 
1400
1400
  /**
1401
- * Inviter des participants à un événement : Invite plusieurs utilisateurs ou entités à participer à un événement.
1402
- * Constant : INVITE_EVENT
1401
+ * Inviter des personnes (organisation / projet / événement) : Invite des personnes à rejoindre une organisation, un projet ou un événement : nouvelles par email (`listInvite.invites` → crée des comptes citoyens « pending » + mail d'invitation) ou existantes par id (`listInvite.citoyens`/`organizations`). Membre / contributeur / participant selon le parent ; `isAdmin:"admin"` pour inviter en admin. Port de Link::invite (multiconnect).
1402
+ * Constant : INVITE_MEMBERS
1403
1403
  * @param data - Données envoyées à l'API
1404
1404
  * @returns Les données de réponse.
1405
1405
  * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1406
1406
  * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1407
1407
  * @throws {Error} - En cas d'erreur inattendue.
1408
1408
  */
1409
- async inviteEvent(data: InviteEventData): Promise<any> {
1409
+ async inviteMembers(data: InviteMembersData): Promise<any> {
1410
1410
  if (!data || typeof data !== "object") {
1411
1411
  throw new TypeError("Le paramètre data doit être un objet.");
1412
1412
  }
1413
- return this.callIsConnected("INVITE_EVENT", data);
1413
+ return this.callIsConnected("INVITE_MEMBERS", data);
1414
1414
  }
1415
1415
 
1416
1416
  /**
@@ -487,7 +487,7 @@ export interface MulticonnectData {
487
487
  /**
488
488
  * Type de l'entité parente
489
489
  */
490
- parentType: "citoyens" | "projects" | "organizations";
490
+ parentType: "citoyens" | "projects" | "organizations" | "events";
491
491
  /**
492
492
  * Liste des citoyens invités
493
493
  */
@@ -4229,7 +4229,7 @@ export interface ShareEventsData {
4229
4229
  }
4230
4230
 
4231
4231
 
4232
- export interface InviteEventData {
4232
+ export interface InviteMembersData {
4233
4233
  /**
4234
4234
  * ID de l'entité parente
4235
4235
  */
@@ -4237,7 +4237,7 @@ export interface InviteEventData {
4237
4237
  /**
4238
4238
  * Type de l'entité parente
4239
4239
  */
4240
- parentType: "citoyens" | "projects" | "organizations";
4240
+ parentType: "citoyens" | "projects" | "organizations" | "events";
4241
4241
  /**
4242
4242
  * Liste des citoyens invités
4243
4243
  */