@communecter/cocolight-api-client 1.0.54 → 1.0.56

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.
Files changed (179) hide show
  1. package/dist/401.cocolight-api-client.browser.js +1 -0
  2. package/dist/401.cocolight-api-client.cjs +1 -0
  3. package/dist/401.cocolight-api-client.mjs.js +1 -0
  4. package/dist/588.cocolight-api-client.browser.js +1 -0
  5. package/dist/588.cocolight-api-client.cjs +1 -0
  6. package/dist/588.cocolight-api-client.mjs.js +1 -0
  7. package/dist/593.cocolight-api-client.browser.js +1 -0
  8. package/dist/593.cocolight-api-client.cjs +1 -0
  9. package/dist/593.cocolight-api-client.mjs.js +1 -0
  10. package/dist/839.cocolight-api-client.browser.js +1 -0
  11. package/dist/839.cocolight-api-client.cjs +1 -0
  12. package/dist/839.cocolight-api-client.mjs.js +1 -0
  13. package/dist/cocolight-api-client.browser.js +3 -3
  14. package/dist/cocolight-api-client.cjs +1 -1
  15. package/dist/cocolight-api-client.mjs.js +1 -1
  16. package/dist/cocolight-api-client.vite.mjs.js +1 -1
  17. package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
  18. package/package.json +29 -17
  19. package/src/{Api.js → Api.ts} +85 -95
  20. package/src/{ApiClient.js → ApiClient.ts} +436 -247
  21. package/src/EJSONType.ts +103 -0
  22. package/src/api/{Badge.js → Badge.ts} +56 -45
  23. package/src/api/BaseEntity.ts +3890 -0
  24. package/src/api/Comment.ts +200 -0
  25. package/src/api/{EndpointApi.js → EndpointApi.ts} +363 -297
  26. package/src/api/EndpointApi.types.ts +4609 -0
  27. package/src/api/EntityRegistry.ts +203 -0
  28. package/src/api/Event.ts +332 -0
  29. package/src/api/News.ts +331 -0
  30. package/src/api/{Organization.js → Organization.ts} +155 -119
  31. package/src/api/{Poi.js → Poi.ts} +68 -60
  32. package/src/api/{Project.js → Project.ts} +150 -127
  33. package/src/api/{User.js → User.ts} +321 -256
  34. package/src/api/UserApi.ts +148 -0
  35. package/src/api/serverDataType/Comment.ts +88 -0
  36. package/src/api/serverDataType/Event.ts +80 -0
  37. package/src/api/serverDataType/News.ts +138 -0
  38. package/src/api/serverDataType/Organization.ts +80 -0
  39. package/src/api/serverDataType/Project.ts +71 -0
  40. package/src/api/serverDataType/User.ts +103 -0
  41. package/src/api/serverDataType/common.ts +80 -0
  42. package/src/endpoints.module.ts +2621 -0
  43. package/src/error.ts +86 -0
  44. package/src/index.ts +86 -0
  45. package/src/mixin/UserMixin.ts +4 -0
  46. package/src/types/api-responses.ts +217 -0
  47. package/src/types/entities.ts +22 -0
  48. package/src/types/error-guards.ts +230 -0
  49. package/src/types/index.ts +39 -0
  50. package/src/types/payloads.ts +21 -0
  51. package/src/types/transforms.ts +110 -0
  52. package/src/utils/{FileOfflineStorageStrategy.node.js → FileOfflineStorageStrategy.node.ts} +15 -12
  53. package/src/utils/{FileStorageStrategy.node.js → FileStorageStrategy.node.ts} +16 -39
  54. package/src/utils/MultiServerFileStorageStrategy.node.ts +67 -0
  55. package/src/utils/MultiServerTokenStorageStrategy.ts +139 -0
  56. package/src/utils/{OfflineClientManager.js → OfflineClientManager.ts} +82 -86
  57. package/src/utils/OfflineQueueStorageStrategy.ts +47 -0
  58. package/src/utils/TokenStorage.ts +77 -0
  59. package/src/utils/compat.ts +12 -0
  60. package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +35 -0
  61. package/src/utils/{createDefaultOfflineStrategy.js → createDefaultOfflineStrategy.ts} +8 -3
  62. package/src/utils/createDefaultTokenStorageStrategy.ts +33 -0
  63. package/src/utils/{reactive.js → reactive.ts} +49 -40
  64. package/src/utils/stream-utils.node.ts +12 -0
  65. package/types/Api.d.ts +38 -82
  66. package/types/Api.d.ts.map +1 -0
  67. package/types/ApiClient.d.ts +244 -184
  68. package/types/ApiClient.d.ts.map +1 -0
  69. package/types/EJSONType.d.ts +48 -22
  70. package/types/EJSONType.d.ts.map +1 -0
  71. package/types/api/Badge.d.ts +20 -20
  72. package/types/api/Badge.d.ts.map +1 -0
  73. package/types/api/BaseEntity.d.ts +751 -446
  74. package/types/api/BaseEntity.d.ts.map +1 -0
  75. package/types/api/Comment.d.ts +36 -0
  76. package/types/api/EndpointApi.d.ts +347 -295
  77. package/types/api/EndpointApi.d.ts.map +1 -0
  78. package/types/api/EndpointApi.types.d.ts +3914 -4133
  79. package/types/api/EntityRegistry.d.ts +18 -16
  80. package/types/api/EntityRegistry.d.ts.map +1 -0
  81. package/types/api/Event.d.ts +119 -35
  82. package/types/api/Event.d.ts.map +1 -0
  83. package/types/api/News.d.ts +52 -20
  84. package/types/api/News.d.ts.map +1 -0
  85. package/types/api/Organization.d.ts +165 -49
  86. package/types/api/Organization.d.ts.map +1 -0
  87. package/types/api/Poi.d.ts +51 -22
  88. package/types/api/Poi.d.ts.map +1 -0
  89. package/types/api/Project.d.ts +151 -52
  90. package/types/api/Project.d.ts.map +1 -0
  91. package/types/api/User.d.ts +222 -93
  92. package/types/api/User.d.ts.map +1 -0
  93. package/types/api/UserApi.d.ts +60 -9
  94. package/types/api/UserApi.d.ts.map +1 -0
  95. package/types/api/serverDataType/Comment.d.ts +83 -0
  96. package/types/api/serverDataType/Event.d.ts +67 -0
  97. package/types/api/serverDataType/News.d.ts +130 -0
  98. package/types/api/serverDataType/Organization.d.ts +65 -0
  99. package/types/api/serverDataType/Organization.d.ts.map +1 -0
  100. package/types/api/serverDataType/Project.d.ts +58 -0
  101. package/types/api/serverDataType/Project.d.ts.map +1 -0
  102. package/types/api/serverDataType/User.d.ts +86 -0
  103. package/types/api/serverDataType/User.d.ts.map +1 -0
  104. package/types/api/serverDataType/common.d.ts +71 -0
  105. package/types/api/serverDataType/common.d.ts.map +1 -0
  106. package/types/endpoints.module.d.ts +6922 -1215
  107. package/types/endpoints.module.d.ts.map +1 -0
  108. package/types/error.d.ts +25 -51
  109. package/types/error.d.ts.map +1 -0
  110. package/types/index.d.ts +55 -48
  111. package/types/index.d.ts.map +1 -0
  112. package/types/mixin/UserMixin.d.ts +1 -1
  113. package/types/mixin/UserMixin.d.ts.map +1 -0
  114. package/types/types/api-responses.d.ts +190 -0
  115. package/types/types/api-responses.d.ts.map +1 -0
  116. package/types/types/entities.d.ts +17 -0
  117. package/types/types/entities.d.ts.map +1 -0
  118. package/types/types/error-guards.d.ts +99 -0
  119. package/types/types/error-guards.d.ts.map +1 -0
  120. package/types/types/index.d.ts +7 -0
  121. package/types/types/payloads.d.ts +17 -0
  122. package/types/types/payloads.d.ts.map +1 -0
  123. package/types/types/transforms.d.ts +79 -0
  124. package/types/types/transforms.d.ts.map +1 -0
  125. package/types/utils/FileOfflineStorageStrategy.node.d.ts +10 -9
  126. package/types/utils/FileOfflineStorageStrategy.node.d.ts.map +1 -0
  127. package/types/utils/FileStorageStrategy.node.d.ts +9 -20
  128. package/types/utils/FileStorageStrategy.node.d.ts.map +1 -0
  129. package/types/utils/MultiServerFileStorageStrategy.node.d.ts +13 -18
  130. package/types/utils/MultiServerFileStorageStrategy.node.d.ts.map +1 -0
  131. package/types/utils/MultiServerTokenStorageStrategy.d.ts +30 -51
  132. package/types/utils/MultiServerTokenStorageStrategy.d.ts.map +1 -0
  133. package/types/utils/OfflineClientManager.d.ts +52 -88
  134. package/types/utils/OfflineClientManager.d.ts.map +1 -0
  135. package/types/utils/OfflineQueueStorageStrategy.d.ts +12 -9
  136. package/types/utils/OfflineQueueStorageStrategy.d.ts.map +1 -0
  137. package/types/utils/TokenStorage.d.ts +20 -70
  138. package/types/utils/TokenStorage.d.ts.map +1 -0
  139. package/types/utils/compat.d.ts +4 -0
  140. package/types/utils/compat.d.ts.map +1 -0
  141. package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts +2 -11
  142. package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts.map +1 -0
  143. package/types/utils/createDefaultOfflineStrategy.d.ts +2 -3
  144. package/types/utils/createDefaultOfflineStrategy.d.ts.map +1 -0
  145. package/types/utils/createDefaultTokenStorageStrategy.d.ts +2 -12
  146. package/types/utils/createDefaultTokenStorageStrategy.d.ts.map +1 -0
  147. package/types/utils/reactive.d.ts +10 -16
  148. package/types/utils/reactive.d.ts.map +1 -0
  149. package/types/utils/stream-utils.node.d.ts +3 -2
  150. package/types/utils/stream-utils.node.d.ts.map +1 -0
  151. package/dist/123.cocolight-api-client.browser.js +0 -1
  152. package/dist/123.cocolight-api-client.cjs +0 -1
  153. package/dist/22.cocolight-api-client.mjs.js +0 -1
  154. package/dist/339.cocolight-api-client.mjs.js +0 -1
  155. package/dist/394.cocolight-api-client.browser.js +0 -1
  156. package/dist/394.cocolight-api-client.cjs +0 -1
  157. package/dist/405.cocolight-api-client.browser.js +0 -1
  158. package/dist/405.cocolight-api-client.cjs +0 -1
  159. package/dist/774.cocolight-api-client.mjs.js +0 -1
  160. package/dist/790.cocolight-api-client.mjs.js +0 -1
  161. package/dist/931.cocolight-api-client.browser.js +0 -1
  162. package/dist/931.cocolight-api-client.cjs +0 -1
  163. package/src/EJSONType.js +0 -53
  164. package/src/api/BaseEntity.js +0 -2828
  165. package/src/api/EntityRegistry.js +0 -152
  166. package/src/api/Event.js +0 -226
  167. package/src/api/News.js +0 -244
  168. package/src/api/UserApi.js +0 -81
  169. package/src/endpoints.module.js +0 -5
  170. package/src/error.js +0 -121
  171. package/src/index.js +0 -97
  172. package/src/mixin/UserMixin.js +0 -8
  173. package/src/utils/MultiServerFileStorageStrategy.node.js +0 -87
  174. package/src/utils/MultiServerTokenStorageStrategy.js +0 -188
  175. package/src/utils/OfflineQueueStorageStrategy.js +0 -51
  176. package/src/utils/TokenStorage.js +0 -153
  177. package/src/utils/createDefaultMultiServerTokenStorageStrategy.js +0 -51
  178. package/src/utils/createDefaultTokenStorageStrategy.js +0 -49
  179. package/src/utils/stream-utils.node.js +0 -10
@@ -1,12 +1,22 @@
1
1
  import { ApiError } from "../error.js";
2
- import BaseEntity from "./BaseEntity.js";
2
+ import { BaseEntity } from "./BaseEntity.js";
3
+ import { createSocialTransform, transformEntityRefs } from "../types/transforms.js";
3
4
 
4
- export class Project extends BaseEntity {
5
- static entityType = "projects";
6
5
 
7
- static entityTag = "Project";
6
+ import type { PaginatorPage } from "./BaseEntity.js";
7
+ import type { AddProjectData, GetContributorsAdminData, GetContributorsNoAdminData } from "./EndpointApi.types.js";
8
+ import type { Organization } from "./Organization.js";
9
+ import type { User } from "./User.js";
10
+ import type { ProjectTransforms } from "../types/transforms.js";
8
11
 
9
- static SCHEMA_CONSTANTS = [
12
+ type ProjectItemNormalized = import("./serverDataType/Project.js").ProjectItemNormalized;
13
+
14
+ export class Project extends BaseEntity<ProjectItemNormalized> {
15
+ static override entityType = "projects";
16
+
17
+ static override entityTag = "Project";
18
+
19
+ static override SCHEMA_CONSTANTS: string[] = [
10
20
  "ADD_PROJECT",
11
21
  "UPDATE_BLOCK_DESCRIPTION",
12
22
  "UPDATE_BLOCK_INFO",
@@ -19,7 +29,7 @@ export class Project extends BaseEntity {
19
29
  static ADD_BLOCKS = new Map([
20
30
  ["ADD_PROJECT", "addProject"],
21
31
  ["PROFIL_IMAGE", "updateImageProfil"]
22
- ]);
32
+ ] as const);
23
33
 
24
34
  static UPDATE_BLOCKS = new Map([
25
35
  ["UPDATE_BLOCK_DESCRIPTION", "updateDescription"],
@@ -28,51 +38,39 @@ export class Project extends BaseEntity {
28
38
  ["UPDATE_BLOCK_INFO", "updateInfo"],
29
39
  ["UPDATE_BLOCK_SLUG", "updateSlug"],
30
40
  ["PROFIL_IMAGE", "updateImageProfil"]
31
- ]);
41
+ ] as const);
32
42
 
33
- defaultFields = {
43
+ override defaultFields: Record<string, any> = {
34
44
  typeElement: this.getEntityType()
35
45
  };
36
46
 
37
- removeFields = [
47
+ override removeFields: string[] = [
38
48
  "typeElement"
39
49
  ];
40
50
 
41
51
  // links.contributors.${this.userId}.isAdmin === true
42
- transforms = {
43
- github: (val, full) => full?.socialNetwork?.github,
44
- gitlab: (val, full) => full?.socialNetwork?.gitlab,
45
- facebook: (val, full) => full?.socialNetwork?.facebook,
46
- twitter: (val, full) => full?.socialNetwork?.twitter,
47
- instagram: (val, full) => full?.socialNetwork?.instagram,
48
- diaspora: (val, full) => full?.socialNetwork?.diaspora,
49
- mastodon: (val, full) => full?.socialNetwork?.mastodon,
50
- telegram: (val, full) => full?.socialNetwork?.telegram,
51
- signal: (val, full) => full?.socialNetwork?.signal,
52
- parent: (val) => {
53
- if (!val || typeof val !== "object") return null;
54
-
55
- return Object.fromEntries(
56
- Object.entries(val).map(([key, obj]) => [
57
- key,
58
- {
59
- type: obj?.type ?? null,
60
- name: obj?.name ?? null
61
- }
62
- ])
63
- );
64
- }
52
+ override transforms: ProjectTransforms = {
53
+ github: createSocialTransform("github"),
54
+ gitlab: createSocialTransform("gitlab"),
55
+ facebook: createSocialTransform("facebook"),
56
+ twitter: createSocialTransform("twitter"),
57
+ instagram: createSocialTransform("instagram"),
58
+ diaspora: createSocialTransform("diaspora"),
59
+ mastodon: createSocialTransform("mastodon"),
60
+ telegram: createSocialTransform("telegram"),
61
+ signal: createSocialTransform("signal"),
62
+ parent: transformEntityRefs
65
63
  };
66
64
 
67
- async _add(payload) {
65
+ override _add = async (payload: Record<string, any>): Promise<void> => {
68
66
  if (!this._calledFromSave) {
69
- throw new ApiError("utilisation invalide de _add, utilisez save");
67
+ throw new ApiError("utilisation invalide de _add, utilisez save", 400);
70
68
  }
71
69
 
72
70
  payload.id = this._newId?.();
73
71
  if (payload.slug) delete payload.slug;
74
72
 
75
- for (const [constant, methodName] of Project.ADD_BLOCKS) {
73
+ for (const [constant, methodName] of Array.from(Project.ADD_BLOCKS)) {
76
74
  const blockData = this._extractChangedFieldsFromSchema(
77
75
  this.apiClient,
78
76
  constant,
@@ -80,28 +78,28 @@ export class Project extends BaseEntity {
80
78
  () => {}
81
79
  );
82
80
  if (blockData && Object.keys(blockData).length > 0) {
83
- const data = await this[methodName](blockData);
81
+ const data = await this._invokeBlockMethod(Project.ADD_BLOCKS, methodName, blockData);
84
82
  if (!this.id && data?.map?.id) {
85
83
  this._draftData.id = data.map.id;
86
84
  this._draftData.slug = data.map.slug;
87
85
  }
88
86
  }
89
87
  }
90
- }
88
+ };
91
89
 
92
- async _update(payload) {
90
+ override _update = async (payload: Record<string, any>): Promise<boolean> => {
93
91
  if(!this.isAdmin()){
94
92
  throw new ApiError("Vous n'avez pas les droits pour modifier ce projet", 403);
95
93
  }
96
94
 
97
95
  if (!this._calledFromSave) {
98
- throw new ApiError("utilisation invalide de _update, utilisez save");
96
+ throw new ApiError("utilisation invalide de _update, utilisez save", 400);
99
97
  }
100
98
 
101
99
  if (payload.id) delete payload.id;
102
100
  let hasChanged = false;
103
101
 
104
- for (const [constant, methodName] of Project.UPDATE_BLOCKS) {
102
+ for (const [constant, methodName] of Array.from(Project.UPDATE_BLOCKS)) {
105
103
  const blockData = this._extractChangedFieldsFromSchema(
106
104
  this.apiClient,
107
105
  constant,
@@ -110,88 +108,132 @@ export class Project extends BaseEntity {
110
108
  this.removeFields
111
109
  );
112
110
  if (blockData && Object.keys(blockData).length > 0) {
113
- await this[methodName](blockData);
111
+ await this._invokeBlockMethod(Project.UPDATE_BLOCKS, methodName, blockData);
114
112
  hasChanged = true;
115
113
  }
116
114
  }
117
115
 
118
116
  return hasChanged;
119
- }
117
+ };
120
118
 
121
- async addProject(data = {}) {
119
+ /**
120
+ * Ajoute un projet.
121
+ *
122
+ * @param data - Données du projet à ajouter.
123
+ * @returns - Résultat de l'ajout du projet.
124
+ * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
125
+ */
126
+ async addProject(data: Partial<AddProjectData> = {}): Promise<unknown> {
122
127
 
123
128
  // le parent n'est pas me donc on doit ajouter le parent
124
- if (!this.isMe) {
129
+ if (!this.isMe && this.parent) {
125
130
  data.parent = {};
126
131
  data.parent[`${this.parent.id}`] = {
127
132
  type: this.parent.getEntityType(),
128
- name: this.parent.name
133
+ name: (this.parent as any).name
129
134
  };
130
135
  }
131
136
 
132
- return this.callIsConnected(() => this.endpointApi.addProject(data));
137
+ return this.callIsConnected(() => this.endpointApi.addProject(data as AddProjectData));
133
138
  }
134
139
 
135
- async getOrganizations() {
136
- throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`);
140
+
141
+ override async getOrganizations(): Promise<never> {
142
+ throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`, 501);
137
143
  }
138
144
 
139
- async getProjects(data = {}) {
145
+ /**
146
+ * {@inheritDoc BaseEntity#getProjects}
147
+ *
148
+ * Récupère les projets du projet.
149
+ */
150
+ override async getProjects(data: Parameters<BaseEntity<ProjectItemNormalized>["getProjects"]>[0] = {}) {
140
151
  return super.getProjects(data);
141
152
  }
153
+
142
154
 
143
- async getEvents() {
144
- throw new ApiError(`getEvents pas encore implémenté dans ${this.constructor.name}`);
155
+
156
+ async getEvents(): Promise<never> {
157
+ throw new ApiError(`getEvents pas encore implémenté dans ${this.constructor.name}`, 501);
145
158
  }
146
159
 
147
- async getPois(data = {}) {
160
+ /**
161
+ * {@inheritDoc BaseEntity#getPois}
162
+ *
163
+ * Récupère les points d'intérêt d'un projet.
164
+ */
165
+ override async getPois(data: Parameters<BaseEntity<ProjectItemNormalized>["getPois"]>[0] = {}) {
148
166
  return super.getPois(data);
149
167
  }
150
168
 
151
- async getBadgesIssuer(data = {}) {
169
+ /**
170
+ * {@inheritDoc BaseEntity#getBadgesIssuer}
171
+ *
172
+ * Récupère les émetteurs de badges d'un projet.
173
+ */
174
+ override async getBadgesIssuer(data: Parameters<BaseEntity<ProjectItemNormalized>["getBadgesIssuer"]>[0] = {}) {
152
175
  return super.getBadgesIssuer(data);
153
176
  }
154
177
 
155
- async getNews(data = {}) {
178
+ /**
179
+ * {@inheritDoc BaseEntity#getNews}
180
+ *
181
+ * Récupère les actualités d'un projet.
182
+ */
183
+ override async getNews(data: Parameters<BaseEntity<ProjectItemNormalized>["getNews"]>[0] = {}) {
156
184
  return super.getNews(data);
157
185
  }
158
186
 
159
- async getSubscribers(data = {}) {
187
+ /**
188
+ * {@inheritDoc BaseEntity#getSubscribers}
189
+ *
190
+ * Récupère les abonnés d'un projet.
191
+ */
192
+ override async getSubscribers(data: Parameters<BaseEntity<ProjectItemNormalized>["getSubscribers"]>[0] = {}) {
160
193
  return super.getSubscribers(data);
161
194
  }
162
195
 
163
196
  /**
164
197
  * Récupérer les contributeurs d'un projet.
165
198
  * Constant : GET_CONTRIBUTORS_ADMIN / GET_CONTRIBUTORS_NO_ADMIN
166
- * @param {Object} data - Les données de requête.
167
- * @param {Object} options - Options supplémentaires.
168
- * @param {boolean} options.toBeValidated - Indique si les contributeurs doivent être validés.
169
- * @param {boolean} options.isAdmin - Indique si l'utilisateur est admin.
170
- * @param {boolean} options.isInviting - Indique si l'utilisateur est en attente d'invitation.
171
- * @param {Array} options.roles - Liste des rôles à filtrer.
172
- * @param {boolean} isNext - Indique si c'est une recherche suivante (pagination).
173
- * @returns {Promise<Object>} - Un objet contenant le nombre de contributeurs et la liste des contributeurs.
199
+ * @param data - Paramètres (partiels) de recherche/pagination.
200
+ * @param options - Options supplémentaires.
201
+ * @param options.toBeValidated - Indique si les contributeurs doivent être validés.
202
+ * @param options.isAdmin - Indique si l'utilisateur est admin.
203
+ * @param options.isInviting - Indique si l'utilisateur est en attente d'invitation.
204
+ * @param options.roles - Liste des rôles à filtrer.
205
+ * @param isNext - Indique si c'est une recherche suivante (pagination).
206
+ * @returns - Un objet contenant le nombre de contributeurs et la liste des contributeurs.
174
207
  * @throws {ApiResponseError} - Si une erreur se produit lors de la récupération des contributeurs.
175
- *
208
+ *
176
209
  * @example
177
210
  * // Récupérer tous les contributeurs
178
211
  * const contributors = await project.getContributors();
179
- *
212
+ *
180
213
  * // Récupérer les contributeurs avec validation en attente
181
214
  * const contributorsToBeValidated = await project.getContributors({}, { toBeValidated: true });
182
- *
215
+ *
183
216
  * // Récupérer les contributeurs avec un rôle spécifique
184
217
  * const contributorsWithRole = await project.getContributors({}, { roles: ["admin"] });
185
- *
218
+ *
186
219
  * // Récupérer les contributeurs administrateurs
187
220
  * const adminContributors = await project.getContributors({}, { isAdmin: true });
188
- *
221
+ *
189
222
  * // Récupérer les contributeurs en attente d'invitation
190
223
  * const invitingContributors = await project.getContributors({}, { isInviting: true });
191
- *
224
+ *
192
225
  */
193
- async getContributors(data = {}, options = {}) {
194
- data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType");
226
+ async getContributors(
227
+ data: Partial<GetContributorsAdminData | GetContributorsNoAdminData> = {},
228
+ options: {
229
+ toBeValidated?: boolean;
230
+ isAdmin?: boolean;
231
+ isAdminPending?: boolean;
232
+ isInviting?: boolean;
233
+ roles?: any[];
234
+ } = {}
235
+ ): Promise<PaginatorPage<User | Organization>> {
236
+ data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType") as GetContributorsAdminData["searchType"];
195
237
  // data.searchBy = "ALL";
196
238
 
197
239
  const paginator = this._createPaginatorEngine({
@@ -222,29 +264,24 @@ export class Project extends BaseEntity {
222
264
  }
223
265
  });
224
266
 
225
- return paginator.next();
267
+ return paginator.next() as Promise<PaginatorPage<User | Organization>>;
226
268
  }
227
269
 
228
270
  /**
271
+ * {@inheritDoc BaseEntity#getGallery}
272
+ *
229
273
  * Récupère la galerie d'un projet.
230
- *
231
- * @param {Object} data - Les données de requête pour la galerie.
232
- * @returns {Promise<Object>} - Un objet contenant les images de la galerie.
233
- * @throws {ApiResponseError} - Si une erreur se produit lors de la récupération de la galerie.
234
- * @throws {Error} - En cas d'erreur inattendue.
235
274
  */
236
- async getGallery(data = {}) {
275
+ override async getGallery(data: Parameters<BaseEntity<ProjectItemNormalized>["getGallery"]>[0] = {}) {
237
276
  return super.getGallery(data);
238
277
  }
239
278
 
240
279
  /**
241
- * Crée une instance de projet et récupère son profil si nécessaire.
280
+ * {@inheritDoc BaseEntity#project}
242
281
  *
243
- * @param {Object} projectData - Les données nécessaires pour initialiser le projet.
244
- * @returns {Promise<Project>} Une promesse qui résout l'objet Projet créé.
245
- * @throws {Error} Si une erreur se produit lors de la création du projet.
282
+ * Crée une instance de projet et récupère son profil si nécessaire.
246
283
  */
247
- async project(projectData = {}) {
284
+ override async project(projectData: Parameters<BaseEntity<ProjectItemNormalized>["project"]>[0] = {}) {
248
285
  if(!this.isAdmin()){
249
286
  throw new ApiError("Vous n'avez pas les droits pour créer un projet dans ce projet", 403);
250
287
  }
@@ -252,13 +289,11 @@ export class Project extends BaseEntity {
252
289
  }
253
290
 
254
291
  /**
292
+ * {@inheritDoc BaseEntity#poi}
293
+ *
255
294
  * Crée une instance de POI et la récupère si nécessaire.
256
- *
257
- * @param {Object} poiData - Les données nécessaires pour initialiser le POI.
258
- * @returns {Promise<Poi>} Une promesse qui résout l'objet POI créé.
259
- * @throws {Error} Si une erreur se produit lors de la création du POI.
260
295
  */
261
- async poi(poiData = {}) {
296
+ override async poi(poiData: Parameters<BaseEntity<ProjectItemNormalized>["poi"]>[0] = {}) {
262
297
  if(!this.isAdmin()){
263
298
  throw new ApiError("Vous n'avez pas les droits pour créer un POI dans ce projet", 403);
264
299
  }
@@ -266,13 +301,11 @@ export class Project extends BaseEntity {
266
301
  }
267
302
 
268
303
  /**
304
+ * {@inheritDoc BaseEntity#event}
305
+ *
269
306
  * Crée une instance d'événement et la récupère si nécessaire.
270
- *
271
- * @param {Object} eventData - Les données nécessaires pour initialiser l'événement.
272
- * @returns {Promise<Event>} Une promesse qui résout l'objet Événement créé.
273
- * @throws {Error} Si une erreur se produit lors de la création de l'événement.
274
307
  */
275
- async event(eventData = {}) {
308
+ override async event(eventData: Parameters<BaseEntity<ProjectItemNormalized>["event"]>[0] = {}) {
276
309
  if(!this.isAdmin()){
277
310
  throw new ApiError("Vous n'avez pas les droits pour créer un événement dans ce projet", 403);
278
311
  }
@@ -280,13 +313,11 @@ export class Project extends BaseEntity {
280
313
  }
281
314
 
282
315
  /**
316
+ * {@inheritDoc BaseEntity#badge}
317
+ *
283
318
  * Crée une instance de badge et la récupère si nécessaire.
284
- *
285
- * @param {Object} badgeData - Les données nécessaires pour initialiser le badge.
286
- * @returns {Promise<Badge>} Une promesse qui résout l'objet Badge créé.
287
- * @throws {Error} Si une erreur se produit lors de la création du badge.
288
319
  */
289
- async badge(badgeData = {}) {
320
+ override async badge(badgeData: Parameters<BaseEntity<ProjectItemNormalized>["badge"]>[0] = {}) {
290
321
  if(!this.isAdmin()){
291
322
  throw new ApiError("Vous n'avez pas les droits pour créer un badge dans ce projet", 403);
292
323
  }
@@ -294,13 +325,11 @@ export class Project extends BaseEntity {
294
325
  }
295
326
 
296
327
  /**
328
+ * {@inheritDoc BaseEntity#news}
329
+ *
297
330
  * Crée une instance de news et la récupère si nécessaire.
298
- *
299
- * @param {Object} newsData - Les données nécessaires pour initialiser la news.
300
- * @returns {Promise<News>} Une promesse qui résout l'objet News créé.
301
- * @throws {Error} Si une erreur se produit lors de la création de la news.
302
331
  */
303
- async news(newsData = {}) {
332
+ override async news(newsData: Parameters<BaseEntity<ProjectItemNormalized>["news"]>[0] = {}) {
304
333
  // TODO: qui peut créer une news sur le projet ?
305
334
  return super.news(newsData);
306
335
  }
@@ -313,67 +342,61 @@ export class Project extends BaseEntity {
313
342
  */
314
343
 
315
344
  /**
345
+ * {@inheritDoc BaseEntity#requestToJoin}
346
+ *
316
347
  * Envoie une demande pour rejoindre le projet en tant que contributeur.
317
348
  * L'action est soumise à validation par un administrateur du projet.
318
- *
319
- * @returns {Promise<Object>} - Résultat de la requête d'adhésion.
320
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si le projet ne supporte pas l'action.
321
349
  */
322
- async requestToJoin(){
350
+ override async requestToJoin() {
323
351
  return super.requestToJoin();
324
352
  }
325
353
 
326
354
  /**
355
+ * {@inheritDoc BaseEntity#requestToJoinAdmin}
356
+ *
327
357
  * Envoie une demande pour devenir administrateur du projet.
328
358
  * L'action est soumise à validation par un administrateur existant.
329
- *
330
- * @returns {Promise<Object>} - Résultat de la requête d'administration.
331
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si le projet ne supporte pas l'action.
332
359
  */
333
- async requestToJoinAdmin(){
360
+ override async requestToJoinAdmin() {
334
361
  return super.requestToJoinAdmin();
335
362
  }
336
363
 
337
364
  /**
365
+ * {@inheritDoc BaseEntity#acceptInvitation}
366
+ *
338
367
  * Accepte une invitation à rejoindre le projet.
339
368
  * Cette action valide un lien en attente avec l'option `isInviting`.
340
- *
341
- * @returns {Promise<Object>} - Résultat de la validation du lien.
342
- * @throws {ApiError} - Si aucune invitation n'est en attente ou si le projet ne supporte pas l'action.
343
369
  */
344
- async acceptInvitation(){
370
+ override async acceptInvitation() {
345
371
  return super.acceptInvitation();
346
372
  }
347
373
 
348
374
  /**
375
+ * {@inheritDoc BaseEntity#leave}
376
+ *
349
377
  * Quitte le projet, que ce soit en tant que contributeur ou administrateur.
350
378
  * Cette action supprime le lien entre l'utilisateur et le projet.
351
- *
352
- * @returns {Promise<Object>} - Résultat de la déconnexion.
353
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou non contributeur.
354
379
  */
355
- async leave() {
380
+ override async leave() {
356
381
  return super.leave();
357
382
  }
358
383
 
359
384
  /**
385
+ * {@inheritDoc BaseEntity#follow}
386
+ *
360
387
  * Suivre un projet.
361
388
  * Cette action permet à l'utilisateur de suivre le projet.
362
- *
363
- * @returns {Promise<Object>} - Résultat de l'action de suivi.
364
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité ne supporte pas l'action.
365
389
  */
366
- async follow() {
390
+ override async follow() {
367
391
  return super.follow();
368
392
  }
369
393
 
370
394
  /**
395
+ * {@inheritDoc BaseEntity#unfollow}
396
+ *
371
397
  * Se désabonne d'un projet.
372
- *
373
- * @returns {Promise<Object>} - Résultat de la désinscription.
374
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
375
398
  */
376
- async unfollow() {
399
+ override async unfollow() {
377
400
  return super.unfollow();
378
401
  }
379
402