@communecter/cocolight-api-client 1.0.62 → 1.0.63
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/Comment.ts +52 -1
- package/src/api/EndpointApi.ts +33 -1
- package/src/api/EndpointApi.types.ts +50 -0
- package/src/api/News.ts +52 -1
- package/src/endpoints.module.ts +8 -1
- package/types/api/Comment.d.ts +21 -0
- package/types/api/EndpointApi.d.ts +21 -1
- package/types/api/EndpointApi.types.d.ts +46 -0
- package/types/api/News.d.ts +21 -0
- package/types/endpoints.module.d.ts +460 -0
package/package.json
CHANGED
package/src/api/Comment.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiError } from "../error.js";
|
|
2
2
|
import { BaseEntity } from "./BaseEntity.js";
|
|
3
3
|
|
|
4
|
-
import type { AddCommentsData, DeleteCommentsData, UpdateCommentsData } from "./EndpointApi.types.js";
|
|
4
|
+
import type { AddCommentsData, AddReportAbuseData, AddVoteData, DeleteCommentsData, UpdateCommentsData } from "./EndpointApi.types.js";
|
|
5
5
|
import type { CommentItemNormalized } from "./serverDataType/Comment.js";
|
|
6
6
|
|
|
7
7
|
export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
@@ -197,4 +197,55 @@ export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
|
197
197
|
return entity as Comment;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Ajoute un vote sur ce commentaire
|
|
202
|
+
*
|
|
203
|
+
* @param status - Statut du vote (ex: 'like', 'dislike', 'love', etc.)
|
|
204
|
+
* @returns Promise contenant la réponse de l'API après l'ajout du vote
|
|
205
|
+
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
206
|
+
*/
|
|
207
|
+
async addVote(status: string){
|
|
208
|
+
if (!this.id) {
|
|
209
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const payload: AddVoteData = {
|
|
213
|
+
collection: "comments",
|
|
214
|
+
id: this.id,
|
|
215
|
+
action: "vote",
|
|
216
|
+
details: {
|
|
217
|
+
status
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
return await this.callIsConnected(() => this.endpointApi.addVote(payload));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Signale un abus sur ce commentaire
|
|
226
|
+
*
|
|
227
|
+
* @param params - Paramètres du signalement
|
|
228
|
+
* @param params.reason - Raison du signalement
|
|
229
|
+
* @param params.comment - Commentaire expliquant le signalement (optionnel)
|
|
230
|
+
* @returns Promise contenant la réponse de l'API après le signalement
|
|
231
|
+
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
232
|
+
*/
|
|
233
|
+
async addReportAbuse({ reason, comment }: { reason: string, comment?: string}){
|
|
234
|
+
if (!this.id) {
|
|
235
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const payload: AddReportAbuseData = {
|
|
239
|
+
collection: "comments",
|
|
240
|
+
id: this.id,
|
|
241
|
+
action: "reportAbuse",
|
|
242
|
+
details: {
|
|
243
|
+
reason,
|
|
244
|
+
comment
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
return await this.callIsConnected(() => this.endpointApi.addReportAbuse(payload));;
|
|
249
|
+
}
|
|
250
|
+
|
|
200
251
|
}
|
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 } from "./EndpointApi.types.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";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
@@ -1624,6 +1624,38 @@ export class EndpointApi {
|
|
|
1624
1624
|
return this.call("COFORM_ANSWERS_BY_ID", data);
|
|
1625
1625
|
}
|
|
1626
1626
|
|
|
1627
|
+
/**
|
|
1628
|
+
* Voter sur un élément (commentaire ou news) : Permet de voter sur un commentaire ou une news en spécifiant un statut de vote
|
|
1629
|
+
* Constant : ADD_VOTE
|
|
1630
|
+
* @param data - Données envoyées à l'API
|
|
1631
|
+
* @returns Les données de réponse.
|
|
1632
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1633
|
+
* @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
|
|
1634
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1635
|
+
*/
|
|
1636
|
+
async addVote(data: AddVoteData): Promise<any> {
|
|
1637
|
+
if (!data || typeof data !== "object") {
|
|
1638
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1639
|
+
}
|
|
1640
|
+
return this.callIsConnected("ADD_VOTE", data);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Signaler un abus sur un élément (commentaire ou news) : Permet de signaler un abus sur un commentaire ou une news en spécifiant une raison et un commentaire
|
|
1645
|
+
* Constant : ADD_REPORT_ABUSE
|
|
1646
|
+
* @param data - Données envoyées à l'API
|
|
1647
|
+
* @returns Les données de réponse.
|
|
1648
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1649
|
+
* @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
|
|
1650
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1651
|
+
*/
|
|
1652
|
+
async addReportAbuse(data: AddReportAbuseData): Promise<any> {
|
|
1653
|
+
if (!data || typeof data !== "object") {
|
|
1654
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1655
|
+
}
|
|
1656
|
+
return this.callIsConnected("ADD_REPORT_ABUSE", data);
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1627
1659
|
}
|
|
1628
1660
|
|
|
1629
1661
|
export default EndpointApi;
|
|
@@ -4767,3 +4767,53 @@ export interface CoformAnswersByIdData {
|
|
|
4767
4767
|
fields?: string[];
|
|
4768
4768
|
[k: string]: unknown;
|
|
4769
4769
|
}
|
|
4770
|
+
|
|
4771
|
+
|
|
4772
|
+
export interface AddVoteData {
|
|
4773
|
+
/**
|
|
4774
|
+
* ID de l'élément (commentaire ou news) sur lequel voter
|
|
4775
|
+
*/
|
|
4776
|
+
id: string;
|
|
4777
|
+
/**
|
|
4778
|
+
* Type de collection concernée
|
|
4779
|
+
*/
|
|
4780
|
+
collection: "comments" | "news";
|
|
4781
|
+
/**
|
|
4782
|
+
* Type d'action à effectuer (vote)
|
|
4783
|
+
*/
|
|
4784
|
+
action: "vote";
|
|
4785
|
+
details: {
|
|
4786
|
+
/**
|
|
4787
|
+
* Statut du vote (ex: 'like', 'dislike', etc.)
|
|
4788
|
+
*/
|
|
4789
|
+
status: string;
|
|
4790
|
+
};
|
|
4791
|
+
[k: string]: unknown;
|
|
4792
|
+
}
|
|
4793
|
+
|
|
4794
|
+
|
|
4795
|
+
export interface AddReportAbuseData {
|
|
4796
|
+
/**
|
|
4797
|
+
* ID de l'élément (commentaire ou news) à signaler
|
|
4798
|
+
*/
|
|
4799
|
+
id: string;
|
|
4800
|
+
/**
|
|
4801
|
+
* Type de collection concernée
|
|
4802
|
+
*/
|
|
4803
|
+
collection: "comments" | "news";
|
|
4804
|
+
/**
|
|
4805
|
+
* Type d'action à effectuer (signalement d'abus)
|
|
4806
|
+
*/
|
|
4807
|
+
action: "reportAbuse";
|
|
4808
|
+
details: {
|
|
4809
|
+
/**
|
|
4810
|
+
* Raison du signalement (requis)
|
|
4811
|
+
*/
|
|
4812
|
+
reason: string;
|
|
4813
|
+
/**
|
|
4814
|
+
* Commentaire expliquant le signalement (optionelle)
|
|
4815
|
+
*/
|
|
4816
|
+
comment?: string;
|
|
4817
|
+
};
|
|
4818
|
+
[k: string]: unknown;
|
|
4819
|
+
}
|
package/src/api/News.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ApiError, ApiResponseError } from "../error.js";
|
|
|
2
2
|
import { BaseEntity } from "./BaseEntity.js";
|
|
3
3
|
|
|
4
4
|
import type { Comment } from "./Comment.js";
|
|
5
|
-
import type { AddNewsData, UpdateNewsData, DeleteNewsData, AddImageNewsData, AddFileNewsData, GetCommentsData } from "./EndpointApi.types.js";
|
|
5
|
+
import type { AddNewsData, UpdateNewsData, DeleteNewsData, AddImageNewsData, AddFileNewsData, GetCommentsData, AddVoteData, AddReportAbuseData } from "./EndpointApi.types.js";
|
|
6
6
|
import type { NewsItemNormalized } from "./serverDataType/News.js";
|
|
7
7
|
|
|
8
8
|
export class News extends BaseEntity<NewsItemNormalized> {
|
|
@@ -326,4 +326,55 @@ export class News extends BaseEntity<NewsItemNormalized> {
|
|
|
326
326
|
return this._createFilteredProxy(rawList);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Ajoute un vote sur cette news
|
|
331
|
+
*
|
|
332
|
+
* @param status - Statut du vote (ex: 'like', 'dislike', 'love', etc.)
|
|
333
|
+
* @returns Promise contenant la réponse de l'API après l'ajout du vote
|
|
334
|
+
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
335
|
+
*/
|
|
336
|
+
async addVote(status: string){
|
|
337
|
+
if (!this.id) {
|
|
338
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const payload: AddVoteData = {
|
|
342
|
+
collection: "news",
|
|
343
|
+
id: this.id,
|
|
344
|
+
action: "vote",
|
|
345
|
+
details: {
|
|
346
|
+
status
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
return await this.callIsConnected(() => this.endpointApi.addVote(payload));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Signale un abus sur cette news
|
|
355
|
+
*
|
|
356
|
+
* @param params - Paramètres du signalement
|
|
357
|
+
* @param params.reason - Raison du signalement
|
|
358
|
+
* @param params.comment - Commentaire expliquant le signalement (optionnel)
|
|
359
|
+
* @returns Promise contenant la réponse de l'API après le signalement
|
|
360
|
+
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
361
|
+
*/
|
|
362
|
+
async addReportAbuse({ reason, comment }: { reason: string, comment?: string}){
|
|
363
|
+
if (!this.id) {
|
|
364
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const payload: AddReportAbuseData = {
|
|
368
|
+
collection: "news",
|
|
369
|
+
id: this.id,
|
|
370
|
+
action: "reportAbuse",
|
|
371
|
+
details: {
|
|
372
|
+
reason,
|
|
373
|
+
comment
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
return await this.callIsConnected(() =>this.endpointApi.addReportAbuse(payload));
|
|
378
|
+
}
|
|
379
|
+
|
|
329
380
|
}
|