@communecter/cocolight-api-client 1.0.153 → 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/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/api/BaseEntity.ts +53 -1
- package/src/api/EndpointApi.ts +5 -5
- package/src/api/EndpointApi.types.ts +12 -4
- package/src/endpoints.module.ts +1 -1
- package/types/api/BaseEntity.d.ts +23 -1
- package/types/api/EndpointApi.d.ts +4 -4
- package/types/api/EndpointApi.types.d.ts +12 -4
- package/types/endpoints.module.d.ts +274 -1
package/package.json
CHANGED
package/src/api/BaseEntity.ts
CHANGED
|
@@ -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é.
|
|
@@ -5486,6 +5532,11 @@ export class BaseEntity<TServerData = any> {
|
|
|
5486
5532
|
id: this.id,
|
|
5487
5533
|
type: this.getEntityType()
|
|
5488
5534
|
},
|
|
5535
|
+
// `element_event` lit son id/type dans le BODY (EventAction::run ignore le $id du path et lit
|
|
5536
|
+
// $_POST["id"]/$_POST["type"]). Bug corrigé : avant, seuls les pathParams partaient -> body vide
|
|
5537
|
+
// -> get_events([]) -> []. On injecte id/type en body (surchargeables via `data` pour cibler un autre élément).
|
|
5538
|
+
id: this.id,
|
|
5539
|
+
type: this.getEntityType(),
|
|
5489
5540
|
...data
|
|
5490
5541
|
};
|
|
5491
5542
|
|
|
@@ -5606,7 +5657,8 @@ export class BaseEntity<TServerData = any> {
|
|
|
5606
5657
|
* @throws {ApiResponseError}
|
|
5607
5658
|
* @throws {Error}
|
|
5608
5659
|
*/
|
|
5609
|
-
|
|
5660
|
+
// `event` est REQUIS : le legacy fait `new MongoId($_POST['event'])` (EventAction:64-68) qui throw si absent.
|
|
5661
|
+
async costumEventRequestLoadContextTag(data: Partial<Omit<CostumEventRequestLoadContextTagData, "pathParams" | "event">> & Pick<CostumEventRequestLoadContextTagData, "event">): Promise<unknown> {
|
|
5610
5662
|
|
|
5611
5663
|
if (!this.id) {
|
|
5612
5664
|
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
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 { 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,
|
|
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
|
|
1402
|
-
* Constant :
|
|
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
|
|
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("
|
|
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
|
|
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
|
*/
|
|
@@ -4886,6 +4886,14 @@ export interface CostumEventRequestSubeventsData {
|
|
|
4886
4886
|
|
|
4887
4887
|
|
|
4888
4888
|
export interface CostumEventRequestElementEventData {
|
|
4889
|
+
/**
|
|
4890
|
+
* ID de l’élément dont on récupère les événements liés (lu dans le BODY — EventAction::run element_event lit $_POST["id"], ignore le path)
|
|
4891
|
+
*/
|
|
4892
|
+
id?: string;
|
|
4893
|
+
/**
|
|
4894
|
+
* Type/collection de l’élément (lu dans le BODY — $_POST["type"])
|
|
4895
|
+
*/
|
|
4896
|
+
type?: string;
|
|
4889
4897
|
/**
|
|
4890
4898
|
* ID du contexte de recherche (actuellement vide)
|
|
4891
4899
|
*/
|
|
@@ -5155,7 +5163,7 @@ export interface CostumEventRequestLoadContextTagData {
|
|
|
5155
5163
|
/**
|
|
5156
5164
|
* ID de l’événement
|
|
5157
5165
|
*/
|
|
5158
|
-
event
|
|
5166
|
+
event: string;
|
|
5159
5167
|
/**
|
|
5160
5168
|
* Recherche textuelle dans les tags
|
|
5161
5169
|
*/
|