@communecter/cocolight-api-client 1.0.134 → 1.0.136

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.
@@ -5639,6 +5639,18 @@ export interface UpdatePathValueData {
5639
5639
  }
5640
5640
  | unknown[]
5641
5641
  | null;
5642
+ /**
5643
+ * Mode multi-field merge : `value` doit être un objet, chaque clé devient un sub-path et est mise à jour individuellement (vs `$set` qui écrase l'objet entier). Les sous-clés à `null`/`""` sont supprimées (`$unset`). Combinable avec `setType: Array` pour coercion par sous-clé.
5644
+ */
5645
+ updatePartial?: boolean;
5646
+ /**
5647
+ * ID du Form parent. Utilisé côté backend pour : (1) authorisation hiérarchique sur sub-forms (admin du Form parent autorisé à modifier les sub-inputs), (2) invalidation du cache de traduction du Form parent après modification.
5648
+ */
5649
+ formParentId?: string;
5650
+ /**
5651
+ * Avec `arrayForm`, désactive le mode `$push` et force `$set` (écrase l'array entier). Cas legacy — préférer omettre `arrayForm` pour écraser un array.
5652
+ */
5653
+ edit?: boolean;
5642
5654
  [k: string]: unknown;
5643
5655
  }
5644
5656
 
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, AddVoteData, AddReportAbuseData, ShareNewsData } from "./EndpointApi.types.js";
5
+ import type { AddNewsData, UpdateNewsData, DeleteNewsData, AddImageNewsData, AddFileNewsData, GetCommentsData, AddVoteData, AddReportAbuseData, ShareNewsData, ShowVoteData } from "./EndpointApi.types.js";
6
6
  import type { NewsItemNormalized } from "./serverDataType/News.js";
7
7
 
8
8
  export class News extends BaseEntity<NewsItemNormalized> {
@@ -366,6 +366,31 @@ export class News extends BaseEntity<NewsItemNormalized> {
366
366
  return await this.callIsConnected(() => this.endpointApi.addVote(payload));
367
367
  }
368
368
 
369
+ /**
370
+ * Récupère la liste des votes (like, love, etc.) sur cette news.
371
+ *
372
+ * Wrap de `SHOW_VOTE` avec auto-injection du `type` (`"news"`) et de
373
+ * `this.id` dans `pathParams`. Le retour contient `vote` (votes individuels
374
+ * indexés par userId) et `voteCount` (compteurs par statut).
375
+ *
376
+ * @returns Réponse API : `{ _id, vote, voteCount }` ou variante d'erreur.
377
+ * @throws {ApiError} 404 si la news n'a pas d'id (non enregistrée).
378
+ *
379
+ * @example
380
+ * const votes = await news.getVotes();
381
+ * votes.voteCount?.like; // nombre de likes
382
+ * votes.vote?.[userId]; // vote détaillé d'un user
383
+ */
384
+ async getVotes(): Promise<unknown> {
385
+ if (!this.id) {
386
+ throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
387
+ }
388
+ const payload: ShowVoteData = {
389
+ pathParams: { type: "news", id: this.id },
390
+ };
391
+ return this.endpointApi.showVote(payload);
392
+ }
393
+
369
394
  /**
370
395
  * Signale un abus sur cette news
371
396
  *
@@ -513,16 +513,7 @@ export class Organization extends BaseEntity<OrganizationItemNormalized> {
513
513
  * await org.updateOpeningHours(openingHours);
514
514
  */
515
515
  async updateOpeningHours(hours: OpeningHoursEntry[]): Promise<unknown> {
516
- if (!this.id) {
517
- throw new ApiError("L'organisation n'a pas d'ID, impossible de mettre à jour les horaires d'ouverture.", 400);
518
- }
519
-
520
- const result = await this.endpointApi.updatePathValue({
521
- id: this.id,
522
- collection: "organizations",
523
- path: "openingHours",
524
- value: hours as unknown as { [k: string]: unknown }
525
- });
516
+ const result = await this.updateField("openingHours", hours);
526
517
  await this._refreshIfDirect();
527
518
  return result;
528
519
  }