@communecter/cocolight-api-client 1.0.17 → 1.0.19

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.17",
3
+ "version": "1.0.19",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "build:browser": "webpack --config webpack.config.standalone.js",
24
24
  "build:node": "webpack --config webpack.config.node.js",
25
25
  "build:esm": "webpack --config webpack.config.esm.mjs",
26
- "build": "npm run generate:module:publish && npm run generate:doc && npm run lint:fix && npm run build:browser && npm run build:node && npm run build:esm",
26
+ "build": "npm run generate:module:publish && npm run generate:methodeapi && npm run generate:doc && npm run lint:fix && npm run build:browser && npm run build:node && npm run build:esm",
27
27
  "build:publish": "npm run build && npm publish --access public",
28
28
  "generate:module": "node ./scripts/transform-json-module.js",
29
29
  "generate:module:publish": "node ./scripts/transform-json-module.publish.js",
package/src/Api.js CHANGED
@@ -1,7 +1,10 @@
1
1
  // Api.js
2
+ import { Badge } from "./api/Badge.js";
2
3
  import EndpointApi from "./api/EndpointApi.js";
4
+ import { Event } from "./api/Event.js";
3
5
  import { News } from "./api/News.js";
4
6
  import { Organization } from "./api/Organization.js";
7
+ import { Poi } from "./api/Poi.js";
5
8
  import { Project } from "./api/Project.js";
6
9
  import { User } from "./api/User.js";
7
10
  import { UserApi } from "./api/UserApi.js";
@@ -117,9 +120,9 @@ export default class Api {
117
120
  async user(userData) {
118
121
  try {
119
122
  if (!userData.id && !userData.slug) {
120
- return new User(this._client, userData, { EndpointApi, Organization, Project, News });
123
+ return new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News });
121
124
  } else {
122
- const user = new User(this._client, userData, { EndpointApi, Organization, Project, News });
125
+ const user = new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News });
123
126
  await user.get();
124
127
  return user;
125
128
  }
@@ -139,7 +142,7 @@ export default class Api {
139
142
  */
140
143
  async organization(organizationData) {
141
144
  try {
142
- const organization = new Organization(this._client, organizationData, { EndpointApi, User, Project, News });
145
+ const organization = new Organization(this._client, organizationData, { EndpointApi, User, Project, Event, Poi, Badge, News });
143
146
  if (!organizationData.id && !organizationData.slug) {
144
147
  throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");
145
148
  }
@@ -160,7 +163,7 @@ export default class Api {
160
163
  */
161
164
  async project(projectData) {
162
165
  try {
163
- const project = new Project(this._client, projectData, { User, News, EndpointApi });
166
+ const project = new Project(this._client, projectData, { EndpointApi, User, Event, Poi, Badge, News });
164
167
  if (!projectData.id && !projectData.slug) {
165
168
  throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");
166
169
  }
package/src/ApiClient.js CHANGED
@@ -12,6 +12,7 @@ import pino from "pino";
12
12
  import MongoID from "./EJSONType.js";
13
13
  import endpointsJson from "./endpoints.module.js";
14
14
  import { ApiClientError, ApiResponseError, ApiValidationError, CircuitBreakerError } from "./error.js";
15
+ import { MultiServerTokenStorageStrategy } from "./utils/MultiServerTokenStorageStrategy.js";
15
16
  import { MemoryStorageStrategy } from "./utils/TokenStorage.js";
16
17
 
17
18
 
@@ -150,6 +151,10 @@ export default class ApiClient extends EventEmitter {
150
151
  this._accessToken = null;
151
152
  this._refreshToken = null;
152
153
 
154
+ if (tokenStorageStrategy instanceof MultiServerTokenStorageStrategy) {
155
+ tokenStorageStrategy.use(this._baseURL);
156
+ }
157
+
153
158
  this._tokenStorage = tokenStorageStrategy || new MemoryStorageStrategy();
154
159
 
155
160
  if (
@@ -649,7 +654,7 @@ export default class ApiClient extends EventEmitter {
649
654
  if (!valid) {
650
655
  const errorMessages = this._ajvErrorHuman(validatePathParams.errors);
651
656
  this.emit("validationError", { stage: "pathParams", errors: validatePathParams.errors });
652
- throw new ApiValidationError("Path parameter validation failed.", 400, errorMessages, validatePathParams.errors);
657
+ throw new ApiValidationError(`callEndpoint: ${constant} - Path parameter validation failed.`, 400, errorMessages, validatePathParams.errors);
653
658
  }
654
659
 
655
660
  resolvedParams = this._resolveSpecialValuesInPlace(pathParams);
@@ -678,7 +683,7 @@ export default class ApiClient extends EventEmitter {
678
683
  if (!valid) {
679
684
  const errorMessages = validateRequest.errors ? this._ajvErrorHuman(validateRequest.errors) : [];
680
685
  this.emit("validationError", { stage: "request", errors: validateRequest.errors });
681
- throw new ApiValidationError("Request validation failed.", 400, errorMessages , validateRequest.errors);
686
+ throw new ApiValidationError(`callEndpoint: ${constant} - Request validation failed.`, 400, errorMessages , validateRequest.errors);
682
687
  }
683
688
 
684
689
  data = this._resolveSpecialValuesInPlace(cleanedData, resolvedParams);
@@ -1440,7 +1445,7 @@ export default class ApiClient extends EventEmitter {
1440
1445
  /**
1441
1446
  * Liste des champs de date à normaliser.
1442
1447
  */
1443
- _dateFields = ["modified", "created", "updated", "birthDate", "lastLoginDate", "startDate", "endDate", "date"];
1448
+ _dateFields = ["modified", "created", "updated", "birthDate", "lastLoginDate", "startDate", "endDate", "date", "issuedOn"];
1444
1449
 
1445
1450
  /**
1446
1451
  * Normalise récursivement un objet, un tableau ou une valeur simple.
@@ -0,0 +1,117 @@
1
+ import BaseEntity from "./BaseEntity.js";
2
+
3
+ export class Badge extends BaseEntity {
4
+ static entityType = "badges";
5
+
6
+ static SCHEMA_CONSTANTS = [
7
+ "ADD_BADGES",
8
+ ];
9
+
10
+ static ADD_BLOCKS = new Map([
11
+ ["ADD_BADGES", "addBadges"]
12
+ ]);
13
+
14
+ static UPDATE_BLOCKS = new Map([
15
+ ]);
16
+
17
+ defaultFields = {
18
+
19
+ };
20
+
21
+ removeFields = [];
22
+
23
+ transforms = {
24
+
25
+ };
26
+
27
+ async _add(payload) {
28
+ payload.id = this._newId?.();
29
+ if (payload.slug) delete payload.slug;
30
+
31
+ for (const [constant, methodName] of Badge.ADD_BLOCKS) {
32
+ const blockData = this._extractChangedFieldsFromSchema(
33
+ this.apiClient,
34
+ constant,
35
+ { ...payload, ...this.defaultFields },
36
+ () => {}
37
+ );
38
+ if (blockData && Object.keys(blockData).length > 0) {
39
+ const data = await this[methodName](blockData);
40
+ if (!this.id && data?.map?.id) {
41
+ this._draftData.id = data.map.id;
42
+ this._draftData.slug = data.map.slug;
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ async _update(payload) {
49
+ if (payload.id) delete payload.id;
50
+ let hasChanged = false;
51
+
52
+ for (const [constant, methodName] of Badge.UPDATE_BLOCKS) {
53
+ const blockData = this._extractChangedFieldsFromSchema(
54
+ this.apiClient,
55
+ constant,
56
+ { ...payload, ...this.defaultFields },
57
+ () => this.initialDraftData,
58
+ this.removeFields
59
+ );
60
+ if (blockData && Object.keys(blockData).length > 0) {
61
+ await this[methodName](blockData);
62
+ hasChanged = true;
63
+ }
64
+ }
65
+
66
+ return hasChanged;
67
+ }
68
+
69
+ async getOrganizations() {
70
+ throw new Error(`getOrganizations n'existe pas dans ${this.constructor.name}`);
71
+ }
72
+
73
+ async getProjects() {
74
+ throw new Error(`getProjects n'existe pas dans ${this.constructor.name}`);
75
+ }
76
+
77
+ async getEvents() {
78
+ throw new Error(`getEvents n'existe pas dans ${this.constructor.name}`);
79
+ }
80
+
81
+ async getPois() {
82
+ throw new Error(`getPois n'existe pas dans ${this.constructor.name}`);
83
+ }
84
+
85
+ async getBadgesIssuer() {
86
+ throw new Error(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`);
87
+ }
88
+
89
+ async getNews() {
90
+ throw new Error(`getNews n'existe pas dans ${this.constructor.name}`);
91
+ }
92
+
93
+ async getSubscribers() {
94
+ throw new Error(`getSubscribers n'existe pas dans ${this.constructor.name}`);
95
+ }
96
+
97
+ async project() {
98
+ throw new Error(`project n'existe pas dans ${this.constructor.name}`);
99
+ }
100
+
101
+ async poi() {
102
+ throw new Error(`poi n'existe pas dans ${this.constructor.name}`);
103
+ }
104
+
105
+ async event() {
106
+ throw new Error(`event n'existe pas dans ${this.constructor.name}`);
107
+ }
108
+
109
+ async badge() {
110
+ throw new Error(`badge n'existe pas dans ${this.constructor.name}`);
111
+ }
112
+
113
+ async news() {
114
+ throw new Error(`news n'existe pas dans ${this.constructor.name}`);
115
+ }
116
+
117
+ }
@@ -0,0 +1,162 @@
1
+ // BaseEntity.js
2
+ import { ApiError } from "../error.js";
3
+ import { DraftStateMixin } from "../mixin/DraftStateMixin.js";
4
+ import { EntityMixin } from "../mixin/EntityMixin.js";
5
+ import { MutualEntityMixin } from "../mixin/MutualEntityMixin.js";
6
+ import { UtilMixin } from "../mixin/UtilMixin.js";
7
+
8
+ export class BaseEntity {
9
+ _draftData = {};
10
+ _initialDraftData = {};
11
+ _serverData = null;
12
+ _calledFromSave = false;
13
+
14
+ constructor(parent, data = {}, deps = {}, config = {}) {
15
+ this.__entityTag = config.entityTag || this.constructor.name || "BaseEntity";
16
+ this.deps = deps;
17
+
18
+ this.EndpointApiClass = deps.EndpointApi;
19
+
20
+ if (parent?.__entityTag === "ApiClient") {
21
+ this.apiClient = parent;
22
+ this.parent = null;
23
+ } else if (parent?.apiClient) {
24
+ this.apiClient = parent.apiClient;
25
+ this.parent = parent;
26
+ } else {
27
+ throw new ApiError("Parent invalide ou ApiClient manquant.");
28
+ }
29
+
30
+ this.endpointApi = typeof deps.EndpointApi === "function"
31
+ ? new deps.EndpointApi(this.apiClient)
32
+ : deps.EndpointApi;
33
+
34
+ this._serverData = null;
35
+
36
+ const { draft, proxy } = this._buildDraftAndProxy({
37
+ data: { ...data, ...this.defaultFields },
38
+ serverData: this._serverData,
39
+ constant: this.constructor.SCHEMA_CONSTANTS,
40
+ apiClient: this.apiClient,
41
+ transforms: this.transforms,
42
+ removeFields: this.removeFields
43
+ });
44
+
45
+ this._initialDraftData = JSON.parse(JSON.stringify(draft));
46
+ this._draftData = draft;
47
+ this.data = proxy;
48
+ }
49
+
50
+ get id() {
51
+ return this._draftData.id || null;
52
+ }
53
+
54
+ _id(newId) {
55
+ this._draftData.id = newId;
56
+ }
57
+
58
+ get isConnected() {
59
+ return this.apiClient.isConnected;
60
+ }
61
+
62
+ get userId() {
63
+ return this.apiClient.userId;
64
+ }
65
+
66
+ get draftData() {
67
+ return this._draftData;
68
+ }
69
+
70
+ get initialDraftData() {
71
+ return this._initialDraftData;
72
+ }
73
+
74
+ get serverData() {
75
+ return this._serverData;
76
+ }
77
+
78
+ get isMe() {
79
+ return this.isConnected && this.userId === this.parent?.id;
80
+ }
81
+
82
+ getEntityType() {
83
+ return this.constructor.entityType;
84
+ }
85
+
86
+ _setData(newData) {
87
+ this._serverData = { ...newData };
88
+
89
+ const { draft, proxy } = this._buildDraftAndProxy({
90
+ data: { ...newData, ...this.defaultFields },
91
+ serverData: this._serverData,
92
+ constant: this.constructor.SCHEMA_CONSTANTS,
93
+ apiClient: this.apiClient,
94
+ transforms: this.transforms,
95
+ removeFields: this.removeFields
96
+ });
97
+ this._initialDraftData = JSON.parse(JSON.stringify(draft));
98
+ this._draftData = draft;
99
+ this.data = proxy;
100
+ }
101
+
102
+ async refresh() {
103
+ if (!this.id) throw new ApiError("Impossible de rafraîchir sans ID.");
104
+ return this.get();
105
+ }
106
+
107
+ async save() {
108
+ if (!this.isConnected) throw new ApiError("Non connecté.");
109
+ this._calledFromSave = true;
110
+ try {
111
+ const payload = { ...this._draftData };
112
+
113
+ if (!this.id && typeof this._add === "function") {
114
+ await this._add(payload);
115
+ return await this.refresh();
116
+ } else if (typeof this._update === "function") {
117
+ const hasChanged = await this._update(payload);
118
+ if (hasChanged) return await this.refresh();
119
+ }
120
+
121
+ return this._serverData;
122
+ } finally {
123
+ this._calledFromSave = false;
124
+ }
125
+ }
126
+
127
+ static fromServerData(data, parent, deps) {
128
+ const instance = new this(parent, {}, deps);
129
+ instance._serverData = { ...data };
130
+
131
+ const { draft, proxy } = instance._buildDraftAndProxy({
132
+ data: { ...data, ...instance.defaultFields },
133
+ serverData: instance._serverData,
134
+ constant: this.SCHEMA_CONSTANTS,
135
+ apiClient: instance.apiClient,
136
+ transforms: instance.transforms,
137
+ removeFields: instance.removeFields
138
+ });
139
+
140
+ instance._draftData = draft;
141
+ instance.data = proxy;
142
+ return instance;
143
+ }
144
+
145
+ hasChanges() {
146
+ return JSON.stringify(this._draftData) !== JSON.stringify(this._initialDraftData);
147
+ }
148
+
149
+ defaultFields = {};
150
+ removeFields = [];
151
+ transforms = {};
152
+ }
153
+
154
+ Object.assign(
155
+ BaseEntity.prototype,
156
+ DraftStateMixin,
157
+ EntityMixin,
158
+ MutualEntityMixin,
159
+ UtilMixin
160
+ );
161
+
162
+ export default BaseEntity;
@@ -210,7 +210,7 @@ class EndpointApi {
210
210
  * Constant : UPDATE_BLOCK_DESCRIPTION
211
211
  * @param {object} data - data
212
212
  * @param {"descriptions"} data.block - Nom du bloc à mettre à jour (doit être 'descriptions') (default: "descriptions")
213
- * @param {"citoyens" | "projects" | "organizations"} data.typeElement - Type d'élément (citoyens, projects, organizations) (default: "citoyens")
213
+ * @param {"citoyens" | "projects" | "organizations" | "poi"} data.typeElement - Type d'élément (citoyens, projects, organizations, poi) (default: "citoyens")
214
214
  * @param {string} data.id - ID de l'élément concerné
215
215
  * @param {string | null} data.scope - Périmètre de mise à jour (default: "")
216
216
  * @param {string} data.descMentions - Mentions dans la description (default: "")
@@ -230,7 +230,7 @@ class EndpointApi {
230
230
  * Constant : UPDATE_BLOCK_INFO
231
231
  * @param {object} data - data
232
232
  * @param {"info"} data.block - Nom du bloc à mettre à jour (doit être 'info') (default: "info")
233
- * @param {"citoyens" | "projects" | "organizations"} data.typeElement - Type d'élément (citoyens, projects, organizations) (default: "citoyens")
233
+ * @param {"citoyens" | "projects" | "organizations" | "poi"} data.typeElement - Type d'élément (citoyens, projects, organizations, poi) (default: "citoyens")
234
234
  * @param {string} data.id - ID de l'élément concerné
235
235
  * @param {string} data.scope - Périmètre de mise à jour (default: "")
236
236
  * @returns {Promise<Object>} - Les données de réponse.
@@ -273,7 +273,7 @@ class EndpointApi {
273
273
  * Constant : UPDATE_BLOCK_LOCALITY
274
274
  * @param {object} data - data
275
275
  * @param {"localities"} data.block - Nom du bloc à mettre à jour (doit être 'localities') (default: "localities")
276
- * @param {"citoyens" | "projects" | "organizations"} data.typeElement - Type d'élément (default: "citoyens")
276
+ * @param {"citoyens" | "projects" | "organizations" | "poi"} data.typeElement - Type d'élément (default: "citoyens")
277
277
  * @param {string} data.id - ID de l'élément concerné
278
278
  * @param {string} data.scope - Périmètre de mise à jour (default: "")
279
279
  * @param {object} data.geo - Coordonnées géographiques
@@ -312,7 +312,7 @@ class EndpointApi {
312
312
  * Constant : UPDATE_BLOCK_SLUG
313
313
  * @param {object} data - data
314
314
  * @param {"info"} data.block - Nom du bloc à mettre à jour (doit être 'info') (default: "info")
315
- * @param {"citoyens" | "projects" | "organizations"} data.typeElement - Type d'élément (citoyens, projects, organizations) (default: "citoyens")
315
+ * @param {"citoyens" | "projects" | "organizations" | "poi"} data.typeElement - Type d'élément (citoyens, projects, organizations, poi) (default: "citoyens")
316
316
  * @param {string} data.id - ID de l'élément concerné
317
317
  * @param {string} data.scope - data.scope (default: "")
318
318
  * @param {string} data.slug - Slug simplifié pour URL
@@ -348,7 +348,7 @@ class EndpointApi {
348
348
  * @param {object} data - data
349
349
  * @param {any} data.profil_avatar - Fichier image de profil au format binaire
350
350
  * @param {object} data.pathParams - data.pathParams
351
- * @param {"citoyens" | "projects" | "organizations"} data.pathParams.folder - Type d'entité (default: "citoyens")
351
+ * @param {"citoyens" | "projects" | "organizations" | "events" | "poi"} data.pathParams.folder - Type d'entité (default: "citoyens")
352
352
  * @param {string} data.pathParams.ownerId - ID de l'utilisateur ou de l'entité
353
353
  * @returns {Promise<Object>} - Les données de réponse.
354
354
  * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
@@ -365,7 +365,7 @@ class EndpointApi {
365
365
  * @param {object} data - data
366
366
  * @param {"ficheInfoElement"} data.tpl - Template utilisé (ex: ficheInfoElement) (default: "ficheInfoElement")
367
367
  * @param {object} data.pathParams - data.pathParams
368
- * @param {"citoyens" | "projects" | "organizations"} data.pathParams.type - Type d'entité (default: "citoyens")
368
+ * @param {"citoyens" | "projects" | "organizations" | "events" | "poi" | "badges"} data.pathParams.type - Type d'entité (default: "citoyens")
369
369
  * @param {string} data.pathParams.id - ID de l'utilisateur ou de l'entité
370
370
  * @returns {Promise<Object>} - Les données de réponse.
371
371
  * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
@@ -0,0 +1,144 @@
1
+ import BaseEntity from "./BaseEntity.js";
2
+
3
+ export class Event extends BaseEntity {
4
+ static entityType = "events";
5
+
6
+ static SCHEMA_CONSTANTS = [
7
+ "ADD_EVENT",
8
+ // "UPDATE_BLOCK_DESCRIPTION",
9
+ // "UPDATE_BLOCK_INFO",
10
+ // "UPDATE_BLOCK_SOCIAL",
11
+ // "UPDATE_BLOCK_LOCALITY",
12
+ // "UPDATE_BLOCK_SLUG",
13
+ // "PROFIL_IMAGE"
14
+ ];
15
+
16
+ static ADD_BLOCKS = new Map([
17
+ ["ADD_EVENT", "addEvent"]
18
+ ]);
19
+
20
+ static UPDATE_BLOCKS = new Map([
21
+ // ["UPDATE_BLOCK_DESCRIPTION", "updateDescription"],
22
+ // ["UPDATE_BLOCK_INFO", "updateInfo"],
23
+ // ["UPDATE_BLOCK_SOCIAL", "updateSocial"],
24
+ // ["UPDATE_BLOCK_LOCALITY", "updateLocality"],
25
+ // ["UPDATE_BLOCK_SLUG", "updateSlug"],
26
+ // ["PROFIL_IMAGE", "updateImageProfil"]
27
+ ]);
28
+
29
+ defaultFields = {
30
+
31
+ };
32
+
33
+ removeFields = ["typeElement"];
34
+
35
+ transforms = {
36
+
37
+ };
38
+
39
+ async _add(payload) {
40
+ if (!this._calledFromSave) {
41
+ throw new Error("utilisation invalide de _add, utilisez save");
42
+ }
43
+
44
+ payload.id = this._newId?.();
45
+ if (payload.slug) delete payload.slug;
46
+
47
+ for (const [constant, methodName] of Event.ADD_BLOCKS) {
48
+ const blockData = this._extractChangedFieldsFromSchema(
49
+ this.apiClient,
50
+ constant,
51
+ { ...payload, ...this.defaultFields },
52
+ () => {}
53
+ );
54
+ if (blockData && Object.keys(blockData).length > 0) {
55
+ const data = await this[methodName](blockData);
56
+ if (!this.id && data?.map?.id) {
57
+ this._draftData.id = data.map.id;
58
+ this._draftData.slug = data.map.slug;
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ async _update(payload) {
65
+ if (!this._calledFromSave) {
66
+ throw new Error("utilisation invalide de _update, utilisez save");
67
+ }
68
+
69
+ if (payload.id) delete payload.id;
70
+ let hasChanged = false;
71
+
72
+ for (const [constant, methodName] of Event.UPDATE_BLOCKS) {
73
+ const blockData = this._extractChangedFieldsFromSchema(
74
+ this.apiClient,
75
+ constant,
76
+ { ...payload, ...this.defaultFields },
77
+ () => this.initialDraftData,
78
+ this.removeFields
79
+ );
80
+ if (blockData && Object.keys(blockData).length > 0) {
81
+ await this[methodName](blockData);
82
+ hasChanged = true;
83
+ }
84
+ }
85
+
86
+ return hasChanged;
87
+ }
88
+
89
+ async getOrganizations() {
90
+ throw new Error(`getOrganizations n'existe pas dans ${this.constructor.name}`);
91
+ }
92
+
93
+ async getProjects() {
94
+ throw new Error(`getProjects n'existe pas dans ${this.constructor.name}`);
95
+ }
96
+
97
+ async getEvents() {
98
+ throw new Error(`getEvents - les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`);
99
+ }
100
+
101
+ async getPois() {
102
+ throw new Error(`getPois n'existe pas dans ${this.constructor.name}`);
103
+ }
104
+
105
+ async getBadgesIssuer() {
106
+ throw new Error(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`);
107
+ }
108
+
109
+ async getNews(data = {}) {
110
+ return super.getNews(data);
111
+ }
112
+
113
+ async getSubscribers(data = {}) {
114
+ return super.getSubscribers(data);
115
+ }
116
+
117
+ async project() {
118
+ throw new Error(`project n'existe pas dans ${this.constructor.name}`);
119
+ }
120
+
121
+ async poi() {
122
+ throw new Error(`poi n'existe pas dans ${this.constructor.name}`);
123
+ }
124
+
125
+ async event() {
126
+ throw new Error(`les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`);
127
+ }
128
+
129
+ async badge() {
130
+ throw new Error(`badge n'existe pas dans ${this.constructor.name}`);
131
+ }
132
+
133
+ /**
134
+ * Crée une instance de news et la récupère si nécessaire.
135
+ *
136
+ * @param {Object} newsData - Les données nécessaires pour initialiser la news.
137
+ * @returns {Promise<News>} Une promesse qui résout l'objet News créé.
138
+ * @throws {Error} Si une erreur se produit lors de la création de la news.
139
+ */
140
+ async news(newsData = {}) {
141
+ return super.news(newsData);
142
+ }
143
+
144
+ }