@communecter/cocolight-api-client 1.0.67 → 1.0.69
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/Comment.ts +5 -4
- package/src/api/News.ts +4 -2
- package/types/api/News.d.ts +3 -1
package/package.json
CHANGED
package/src/api/Comment.ts
CHANGED
|
@@ -37,13 +37,14 @@ export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
|
37
37
|
data.author = this._linkNestedEntity(data.author);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// Transformer les replies récursivement si présentes
|
|
41
40
|
if (Array.isArray(data.replies)) {
|
|
42
41
|
data.replies = data.replies.map(reply => {
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// Ajouter les propriétés nécessaires pour _linkNestedEntity
|
|
43
|
+
if (reply && typeof reply === "object" && !reply.type) {
|
|
44
|
+
reply.type = "comments";
|
|
45
|
+
reply.collection = "comments";
|
|
45
46
|
}
|
|
46
|
-
return reply;
|
|
47
|
+
return this._linkNestedEntity(reply);
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
|
package/src/api/News.ts
CHANGED
|
@@ -383,6 +383,7 @@ export class News extends BaseEntity<NewsItemNormalized> {
|
|
|
383
383
|
* @param params - Paramètres de partage
|
|
384
384
|
* @param params.childId - ID de l'entité cible (par défaut: utilisateur connecté)
|
|
385
385
|
* @param params.childType - Type de l'entité cible (par défaut: "citoyens")
|
|
386
|
+
* @param params.comment - Commentaire optionnel accompagnant le partage
|
|
386
387
|
* @returns Promise contenant la réponse de l'API après le partage
|
|
387
388
|
* @throws {ApiError} Si la news n'a pas d'ID (404)
|
|
388
389
|
* @throws {ApiError} Si l'utilisateur n'est pas connecté (400)
|
|
@@ -390,7 +391,7 @@ export class News extends BaseEntity<NewsItemNormalized> {
|
|
|
390
391
|
* @throws {ApiError} Si on tente de partager sa propre news à soi-même (400)
|
|
391
392
|
* @throws {ApiError} Si le type cible n'est pas valide (400)
|
|
392
393
|
*/
|
|
393
|
-
async shareNews({ childId, childType }: { childId?: string, childType?: string } = {}){
|
|
394
|
+
async shareNews({ childId, childType, comment }: { childId?: string, childType?: string, comment?: string } = {}){
|
|
394
395
|
// Validations préalables
|
|
395
396
|
if (!this.id) {
|
|
396
397
|
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
@@ -427,7 +428,8 @@ export class News extends BaseEntity<NewsItemNormalized> {
|
|
|
427
428
|
parentType: "news",
|
|
428
429
|
connectType: "share",
|
|
429
430
|
childType: targetType as "citoyens" | "projects" | "organizations",
|
|
430
|
-
childId: targetId
|
|
431
|
+
childId: targetId,
|
|
432
|
+
comment
|
|
431
433
|
};
|
|
432
434
|
|
|
433
435
|
return await this.callIsConnected(() => this.endpointApi.shareNews(payload));
|
package/types/api/News.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export declare class News extends BaseEntity<NewsItemNormalized> {
|
|
|
101
101
|
* @param params - Paramètres de partage
|
|
102
102
|
* @param params.childId - ID de l'entité cible (par défaut: utilisateur connecté)
|
|
103
103
|
* @param params.childType - Type de l'entité cible (par défaut: "citoyens")
|
|
104
|
+
* @param params.comment - Commentaire optionnel accompagnant le partage
|
|
104
105
|
* @returns Promise contenant la réponse de l'API après le partage
|
|
105
106
|
* @throws {ApiError} Si la news n'a pas d'ID (404)
|
|
106
107
|
* @throws {ApiError} Si l'utilisateur n'est pas connecté (400)
|
|
@@ -108,8 +109,9 @@ export declare class News extends BaseEntity<NewsItemNormalized> {
|
|
|
108
109
|
* @throws {ApiError} Si on tente de partager sa propre news à soi-même (400)
|
|
109
110
|
* @throws {ApiError} Si le type cible n'est pas valide (400)
|
|
110
111
|
*/
|
|
111
|
-
shareNews({ childId, childType }?: {
|
|
112
|
+
shareNews({ childId, childType, comment }?: {
|
|
112
113
|
childId?: string;
|
|
113
114
|
childType?: string;
|
|
115
|
+
comment?: string;
|
|
114
116
|
}): Promise<unknown>;
|
|
115
117
|
}
|