@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
3
 
4
- export class Organization extends BaseEntity {
5
- static entityType = "organizations";
4
+ import type { PaginatorPage } from "./BaseEntity.js";
5
+ import type {
6
+ AddOrganizationData,
7
+ GetMembersAdminData,
8
+ GetMembersNoAdminData
9
+ } from "./EndpointApi.types.js";
10
+ import type { User } from "./User.js";
6
11
 
7
- static entityTag = "Organization";
12
+ type OrganizationItemNormalized = import("./serverDataType/Organization.js").OrganizationItemNormalized;
8
13
 
9
- static SCHEMA_CONSTANTS = [
14
+ export class Organization extends BaseEntity<OrganizationItemNormalized> {
15
+ static override entityType = "organizations";
16
+
17
+ static override entityTag = "Organization";
18
+
19
+ static override SCHEMA_CONSTANTS: string[] = [
10
20
  "ADD_ORGANIZATION",
11
21
  "UPDATE_BLOCK_DESCRIPTION",
12
22
  "UPDATE_BLOCK_INFO",
@@ -19,7 +29,7 @@ export class Organization extends BaseEntity {
19
29
  static ADD_BLOCKS = new Map([
20
30
  ["ADD_ORGANIZATION", "addOrganization"],
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,39 +38,39 @@ export class Organization 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
  // role = admin c'est bizarre car en faite c'est gérer dans links sur user et l'orga
42
52
  // links.members.${this.userId}.isAdmin === true
43
- transforms = {
44
- github: (val, full) => full?.socialNetwork?.github,
45
- gitlab: (val, full) => full?.socialNetwork?.gitlab,
46
- facebook: (val, full) => full?.socialNetwork?.facebook,
47
- twitter: (val, full) => full?.socialNetwork?.twitter,
48
- instagram: (val, full) => full?.socialNetwork?.instagram,
49
- diaspora: (val, full) => full?.socialNetwork?.diaspora,
50
- mastodon: (val, full) => full?.socialNetwork?.mastodon,
51
- telegram: (val, full) => full?.socialNetwork?.telegram,
52
- signal: (val, full) => full?.socialNetwork?.signal
53
+ override transforms: Record<string, (val: any, full: any) => any> = {
54
+ github: (val: any, full: any) => full?.socialNetwork?.github,
55
+ gitlab: (val: any, full: any) => full?.socialNetwork?.gitlab,
56
+ facebook: (val: any, full: any) => full?.socialNetwork?.facebook,
57
+ twitter: (val: any, full: any) => full?.socialNetwork?.twitter,
58
+ instagram: (val: any, full: any) => full?.socialNetwork?.instagram,
59
+ diaspora: (val: any, full: any) => full?.socialNetwork?.diaspora,
60
+ mastodon: (val: any, full: any) => full?.socialNetwork?.mastodon,
61
+ telegram: (val: any, full: any) => full?.socialNetwork?.telegram,
62
+ signal: (val: any, full: any) => full?.socialNetwork?.signal
53
63
  };
54
64
 
55
- async _add(payload) {
65
+ override _add = async (payload: Record<string, any>): Promise<void> => {
56
66
  if (!this._calledFromSave) {
57
- throw new ApiError("utilisation invalide de _add, utilisez save");
67
+ throw new ApiError("utilisation invalide de _add, utilisez save", 400);
58
68
  }
59
69
 
60
70
  payload.id = this._newId?.();
61
71
  if (payload.slug) delete payload.slug;
62
72
 
63
- for (const [constant, methodName] of Organization.ADD_BLOCKS) {
73
+ for (const [constant, methodName] of Array.from(Organization.ADD_BLOCKS)) {
64
74
  const blockData = this._extractChangedFieldsFromSchema(
65
75
  this.apiClient,
66
76
  constant,
@@ -68,28 +78,28 @@ export class Organization extends BaseEntity {
68
78
  () => {}
69
79
  );
70
80
  if (blockData && Object.keys(blockData).length > 0) {
71
- const data = await this[methodName](blockData);
81
+ const data = await this._invokeBlockMethod(Organization.ADD_BLOCKS, methodName, blockData);
72
82
  if (!this.id && data?.map?.id) {
73
83
  this._draftData.id = data.map.id;
74
84
  this._draftData.slug = data.map.slug;
75
85
  }
76
86
  }
77
87
  }
78
- }
88
+ };
79
89
 
80
- async _update(payload) {
90
+ override _update = async (payload: Record<string, any>): Promise<boolean> => {
81
91
  if(!this.isAdmin()){
82
92
  throw new ApiError("Vous n'avez pas les droits pour modifier cette organisation", 403);
83
93
  }
84
94
 
85
95
  if (!this._calledFromSave) {
86
- throw new ApiError("utilisation invalide de _update, utilisez save");
96
+ throw new ApiError("utilisation invalide de _update, utilisez save", 400);
87
97
  }
88
98
 
89
99
  if (payload.id) delete payload.id;
90
100
  let hasChanged = false;
91
101
 
92
- for (const [constant, methodName] of Organization.UPDATE_BLOCKS) {
102
+ for (const [constant, methodName] of Array.from(Organization.UPDATE_BLOCKS)) {
93
103
  const blockData = this._extractChangedFieldsFromSchema(
94
104
  this.apiClient,
95
105
  constant,
@@ -98,59 +108,90 @@ export class Organization extends BaseEntity {
98
108
  this.removeFields
99
109
  );
100
110
  if (blockData && Object.keys(blockData).length > 0) {
101
- await this[methodName](blockData);
111
+ await this._invokeBlockMethod(Organization.UPDATE_BLOCKS, methodName, blockData);
102
112
  hasChanged = true;
103
113
  }
104
114
  }
105
115
 
106
116
  return hasChanged;
107
- }
117
+ };
108
118
 
109
- async addOrganization(data = {}) {
119
+ /**
120
+ * Ajoute une organisation.
121
+ *
122
+ * @param data - Données de l'organisation à ajouter.
123
+ * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
124
+ */
125
+ async addOrganization(data: AddOrganizationData): Promise<unknown> {
110
126
  return this.callIsConnected(() => this.endpointApi.addOrganization(data));
111
127
  }
112
128
 
113
-
114
- async getOrganizations() {
115
- throw new ApiError("getOrganizations n'existe pas dans Organization");
129
+ override async getOrganizations(): Promise<never> {
130
+ throw new ApiError("getOrganizations n'existe pas dans Organization", 404);
116
131
  }
117
132
 
118
- async getProjects(data = {}) {
133
+ /**
134
+ * {@inheritDoc BaseEntity#getProjects}
135
+ *
136
+ * Récupère les projets de l'organisation.
137
+ */
138
+ override async getProjects(data: Parameters<BaseEntity<OrganizationItemNormalized>["getProjects"]>[0] = {}) {
119
139
  return super.getProjects(data);
120
140
  }
121
141
 
122
- async getEvents() {
123
- throw new ApiError("getEvents pas encore implémenté dans Organization");
124
- }
142
+ // /** @override @returns {Promise<never>} */
143
+ // async getEvents() {
144
+ // throw new ApiError("getEvents pas encore implémenté dans Organization", 404);
145
+ // }
125
146
 
126
- async getPois(data = {}) {
147
+ /**
148
+ * {@inheritDoc BaseEntity#getPois}
149
+ *
150
+ * Récupère les points d'intérêt de l'organisation.
151
+ */
152
+ override async getPois(data: Parameters<BaseEntity<OrganizationItemNormalized>["getPois"]>[0] = {}) {
127
153
  return super.getPois(data);
128
154
  }
129
155
 
130
- async getBadgesIssuer(data = {}) {
156
+ /**
157
+ * {@inheritDoc BaseEntity#getBadgesIssuer}
158
+ *
159
+ * Récupère les émetteurs de badges de l'organisation.
160
+ */
161
+ override async getBadgesIssuer(data: Parameters<BaseEntity<OrganizationItemNormalized>["getBadgesIssuer"]>[0] = {}) {
131
162
  return super.getBadgesIssuer(data);
132
163
  }
133
164
 
134
- async getNews(data = {}) {
165
+ /**
166
+ * {@inheritDoc BaseEntity#getNews}
167
+ *
168
+ * Récupère les actualités de l'organisation.
169
+ */
170
+ override async getNews(data: Parameters<BaseEntity<OrganizationItemNormalized>["getNews"]>[0] = {}) {
135
171
  return super.getNews(data);
136
172
  }
137
173
 
138
- async getSubscribers(data = {}) {
174
+ /**
175
+ * {@inheritDoc BaseEntity#getSubscribers}
176
+ *
177
+ * Récupère les abonnés de l'organisation.
178
+ */
179
+ override async getSubscribers(data: Parameters<BaseEntity<OrganizationItemNormalized>["getSubscribers"]>[0] = {}) {
139
180
  return super.getSubscribers(data);
140
181
  }
141
182
 
183
+
142
184
  /**
143
185
  * Récupérer les membres de l'organisation.
144
186
  * Constant : GET_MEMBERS_ADMIN / GET_MEMBERS_NO_ADMIN
145
- * @param {Object} data - Les données de requête.
146
- * @param {Object} options - Options supplémentaires.
147
- * @param {boolean} options.toBeValidated - Indique si les membres doivent être validés.
148
- * @param {boolean} options.isAdmin - Indique si l'utilisateur est admin.
149
- * @param {boolean} options.isAdminPending - Indique si l'utilisateur est en attente de validation pour être admin.
150
- * @param {boolean} options.isInviting - Indique si l'utilisateur est en attente d'invitation.
151
- * @param {Array} options.roles - Liste des rôles à filtrer.
152
- * @param {boolean} isNext - Indique si c'est une recherche suivante (pagination).
153
- * @returns {Promise<Object>} - Un objet contenant le nombre de membres et la liste des membres.
187
+ * @param data - Paramètres (partiels) de recherche/pagination.
188
+ * @param options - Options supplémentaires.
189
+ * @param options.toBeValidated - Indique si les membres doivent être validés.
190
+ * @param options.isAdmin - Indique si l'utilisateur est admin.
191
+ * @param options.isAdminPending - Indique si l'utilisateur est en attente de validation pour être admin.
192
+ * @param options.isInviting - Indique si l'utilisateur est en attente d'invitation.
193
+ * @param options.roles - Liste des rôles à filtrer.
194
+ * @returns - Un objet contenant le nombre de membres et la liste des membres.
154
195
  * @throws {ApiResponseError} - Si une erreur se produit lors de la récupération des contributeurs.
155
196
  *
156
197
  * @example
@@ -180,8 +221,25 @@ export class Organization extends BaseEntity {
180
221
  *
181
222
  *
182
223
  */
183
- async getMembers(data = {}, options = {}) {
184
- data.searchType = this._getDefaultFromEndpoint("GET_MEMBERS_ADMIN", "searchType");
224
+ async getMembers(
225
+ data: Partial<GetMembersAdminData | GetMembersNoAdminData> = {},
226
+ options: {
227
+ toBeValidated?: boolean;
228
+ isAdmin?: boolean;
229
+ isAdminPending?: boolean;
230
+ isInviting?: boolean;
231
+ roles?: any[];
232
+ } = {}
233
+ ): Promise<PaginatorPage<User | Organization>> {
234
+
235
+ if(!this.id) {
236
+ throw new ApiError("L'organisation n'est pas définie, impossible de récupérer les membres", 400);
237
+ }
238
+
239
+ /** « Snapshot » local, typé string */
240
+ const orgId = this.id as string;
241
+
242
+ data.searchType = this._getDefaultFromEndpoint("GET_MEMBERS_ADMIN", "searchType") as GetMembersAdminData["searchType"];
185
243
  // data.searchBy = "ALL";
186
244
 
187
245
  const paginator = this._createPaginatorEngine({
@@ -197,10 +255,10 @@ export class Organization extends BaseEntity {
197
255
  // [`links.memberOf.${this.id}.toBeValidated`]: { "$exists": false },
198
256
  // [`links.memberOf.${this.id}.isInviting`]: { "$exists": false }
199
257
  // };
200
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
258
+ finalData.filters = this._buildLinkFilters(orgId, { linkType: "memberOf", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
201
259
  } else {
202
260
  delete finalData?.pathParams;
203
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated: false, isAdmin, isInviting, roles });
261
+ finalData.filters = this._buildLinkFilters(orgId, { linkType: "memberOf", toBeValidated: false, isAdmin, isInviting, roles });
204
262
  }
205
263
 
206
264
  const fetchFn = this.isMe
@@ -211,29 +269,24 @@ export class Organization extends BaseEntity {
211
269
  }
212
270
  });
213
271
 
214
- return paginator.next();
272
+ return paginator.next() as Promise<PaginatorPage<User | Organization>>;
215
273
  }
216
274
 
217
275
  /**
276
+ * {@inheritDoc BaseEntity#getGallery}
277
+ *
218
278
  * Récupère la galerie de l'organisation.
219
- *
220
- * @param {Object} data - Les données de requête.
221
- * @returns {Promise<Object>} - Un objet contenant les éléments de la galerie.
222
- * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
223
- * @throws {Error} - En cas d'erreur inattendue.
224
279
  */
225
- async getGallery(data = {}) {
280
+ override async getGallery(data: Parameters<BaseEntity<OrganizationItemNormalized>["getGallery"]>[0] = {}) {
226
281
  return super.getGallery(data);
227
282
  }
228
283
 
229
284
  /**
230
- * Crée une instance de projet et récupère son profil si nécessaire.
285
+ * {@inheritDoc BaseEntity#project}
231
286
  *
232
- * @param {Object} projectData - Les données nécessaires pour initialiser le projet.
233
- * @returns {Promise<Project>} Une promesse qui résout l'objet Projet créé.
234
- * @throws {Error} Si une erreur se produit lors de la création du projet.
287
+ * Crée une instance de projet et récupère son profil si nécessaire.
235
288
  */
236
- async project(projectData = {}) {
289
+ override async project(projectData: Parameters<BaseEntity<OrganizationItemNormalized>["project"]>[0] = {}) {
237
290
  if(!this.isAdmin()){
238
291
  throw new ApiError("Vous n'avez pas les droits pour créer un projet dans cette organisation", 403);
239
292
  }
@@ -241,13 +294,11 @@ export class Organization extends BaseEntity {
241
294
  }
242
295
 
243
296
  /**
297
+ * {@inheritDoc BaseEntity#poi}
298
+ *
244
299
  * Crée une instance de POI et la récupère si nécessaire.
245
- *
246
- * @param {Object} poiData - Les données nécessaires pour initialiser le POI.
247
- * @returns {Promise<Poi>} Une promesse qui résout l'objet POI créé.
248
- * @throws {Error} Si une erreur se produit lors de la création du POI.
249
300
  */
250
- async poi(poiData = {}) {
301
+ override async poi(poiData: Parameters<BaseEntity<OrganizationItemNormalized>["poi"]>[0] = {}) {
251
302
  if(!this.isAdmin()){
252
303
  throw new ApiError("Vous n'avez pas les droits pour créer un poi dans cette organisation", 403);
253
304
  }
@@ -255,13 +306,11 @@ export class Organization extends BaseEntity {
255
306
  }
256
307
 
257
308
  /**
309
+ * {@inheritDoc BaseEntity#event}
310
+ *
258
311
  * Crée une instance d'événement et la récupère si nécessaire.
259
- *
260
- * @param {Object} eventData - Les données nécessaires pour initialiser l'événement.
261
- * @returns {Promise<Event>} Une promesse qui résout l'objet Événement créé.
262
- * @throws {Error} Si une erreur se produit lors de la création de l'événement.
263
312
  */
264
- async event(eventData = {}) {
313
+ override async event(eventData: Parameters<BaseEntity<OrganizationItemNormalized>["event"]>[0] = {}) {
265
314
  if(!this.isAdmin()){
266
315
  throw new ApiError("Vous n'avez pas les droits pour créer un event dans cette organisation", 403);
267
316
  }
@@ -269,13 +318,11 @@ export class Organization extends BaseEntity {
269
318
  }
270
319
 
271
320
  /**
321
+ * {@inheritDoc BaseEntity#badge}
322
+ *
272
323
  * Crée une instance de badge et la récupère si nécessaire.
273
- *
274
- * @param {Object} badgeData - Les données nécessaires pour initialiser le badge.
275
- * @returns {Promise<Badge>} Une promesse qui résout l'objet Badge créé.
276
- * @throws {Error} Si une erreur se produit lors de la création du badge.
277
324
  */
278
- async badge(badgeData = {}) {
325
+ override async badge(badgeData: Parameters<BaseEntity<OrganizationItemNormalized>["badge"]>[0] = {}) {
279
326
  if(!this.isAdmin()){
280
327
  throw new ApiError("Vous n'avez pas les droits pour créer un badge dans cette organisation", 403);
281
328
  }
@@ -283,13 +330,11 @@ export class Organization extends BaseEntity {
283
330
  }
284
331
 
285
332
  /**
333
+ * {@inheritDoc BaseEntity#news}
334
+ *
286
335
  * Crée une instance de news et la récupère si nécessaire.
287
- *
288
- * @param {Object} newsData - Les données nécessaires pour initialiser la news.
289
- * @returns {Promise<News>} Une promesse qui résout l'objet News créé.
290
- * @throws {Error} Si une erreur se produit lors de la création de la news.
291
336
  */
292
- async news(newsData = {}) {
337
+ override async news(newsData: Parameters<BaseEntity<OrganizationItemNormalized>["news"]>[0] = {}) {
293
338
  // TODO: qui peut créer une news sur l'organisation ?
294
339
  return super.news(newsData);
295
340
  }
@@ -303,67 +348,61 @@ export class Organization extends BaseEntity {
303
348
 
304
349
 
305
350
  /**
351
+ * {@inheritDoc BaseEntity#requestToJoin}
352
+ *
306
353
  * Envoie une demande pour rejoindre l'organisation en tant que membre.
307
354
  * L'action est soumise à validation par un administrateur de l'organisation.
308
- *
309
- * @returns {Promise<Object>} - Résultat de la requête d'adhésion.
310
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité ne supporte pas l'action.
311
355
  */
312
- async requestToJoin(){
356
+ override async requestToJoin() {
313
357
  return super.requestToJoin();
314
358
  }
315
359
 
316
360
  /**
361
+ * {@inheritDoc BaseEntity#requestToJoinAdmin}
362
+ *
317
363
  * Envoie une demande pour rejoindre l'organisation en tant qu'administrateur.
318
364
  * L'action est soumise à validation par un administrateur existant.
319
- *
320
- * @returns {Promise<Object>} - Résultat de la requête d'administration.
321
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité ne supporte pas l'action.
322
365
  */
323
- async requestToJoinAdmin(){
366
+ override async requestToJoinAdmin() {
324
367
  return super.requestToJoinAdmin();
325
368
  }
326
369
 
327
370
  /**
371
+ * {@inheritDoc BaseEntity#acceptInvitation}
372
+ *
328
373
  * Accepte une invitation à rejoindre l'organisation.
329
374
  * Cette action valide un lien en attente avec l'option `isInviting`.
330
- *
331
- * @returns {Promise<Object>} - Résultat de la validation du lien.
332
- * @throws {ApiError} - Si aucune invitation n'est en attente ou si l'entité ne supporte pas l'action.
333
375
  */
334
- async acceptInvitation(){
376
+ override async acceptInvitation() {
335
377
  return super.acceptInvitation();
336
378
  }
337
379
 
338
380
  /**
381
+ * {@inheritDoc BaseEntity#leave}
382
+ *
339
383
  * Quitte l'organisation, que ce soit en tant que membre ou administrateur.
340
384
  * Cette action supprime le lien entre l'utilisateur et l'organisation.
341
- *
342
- * @returns {Promise<Object>} - Résultat de la déconnexion.
343
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou non membre.
344
385
  */
345
- async leave() {
386
+ override async leave() {
346
387
  return super.leave();
347
388
  }
348
389
 
349
390
  /**
391
+ * {@inheritDoc BaseEntity#follow}
392
+ *
350
393
  * Suivre une organisation.
351
394
  * Cette action permet à l'utilisateur de suivre l'organisation.
352
- *
353
- * @returns {Promise<Object>} - Résultat de l'action de suivi.
354
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité ne supporte pas l'action.
355
395
  */
356
- async follow() {
396
+ override async follow() {
357
397
  return super.follow();
358
398
  }
359
399
 
360
400
  /**
401
+ * {@inheritDoc BaseEntity#unfollow}
402
+ *
361
403
  * Se désabonne d'une organisation.
362
- *
363
- * @returns {Promise<Object>} - Résultat de la désinscription.
364
- * @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
365
404
  */
366
- async unfollow() {
405
+ override async unfollow() {
367
406
  return super.unfollow();
368
407
  }
369
408
 
@@ -374,23 +413,20 @@ export class Organization extends BaseEntity {
374
413
  */
375
414
 
376
415
  /**
416
+ * {@inheritDoc BaseEntity#getCostumJson}
417
+ *
377
418
  * Récupère le JSON personnalisé de l'organisation.
378
- *
379
- * @returns {Promise<Object>} - Le JSON personnalisé de l'organisation.
380
- * @throws {ApiError} - Si le slug de l'organisation n'est pas défini.
381
419
  */
382
- async getCostumJson() {
420
+ override async getCostumJson() {
383
421
  return super.getCostumJson();
384
422
  }
385
423
 
386
424
  /**
387
- * recherche lié à l'organisation
425
+ * {@inheritDoc BaseEntity#searchCostum}
388
426
  *
389
- * @param {Object} data - Les données de recherche.
390
- * @returns {Promise<Object>} - Résultat de la recherche.
391
- * @throws {ApiError} - Si le slug ou l'id de l'organisation n'est pas défini.
427
+ * Cette surcharge précise que la recherche est faite dans le contexte de l'organisation.
392
428
  */
393
- async searchCostum(data = {}) {
429
+ override async searchCostum(data: Parameters<BaseEntity<OrganizationItemNormalized>["searchCostum"]>[0]) {
394
430
  return super.searchCostum(data);
395
431
  }
396
432