@communecter/cocolight-api-client 1.0.30 → 1.0.32

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.
@@ -971,25 +971,6 @@ export interface GlobalAutocompleteData {
971
971
  * Balises (tags) à utiliser pour filtrer la recherche
972
972
  */
973
973
  searchTags?: string[];
974
- /**
975
- * Configuration des plages de résultats pour chaque type de recherche
976
- */
977
- ranges?: {
978
- /**
979
- * This interface was referenced by `undefined`'s JSON-Schema definition
980
- * via the `patternProperty` "^[^\s]+$".
981
- */
982
- [k: string]: {
983
- /**
984
- * Index de départ pour la pagination
985
- */
986
- indexMin: number;
987
- /**
988
- * Index de fin pour la pagination
989
- */
990
- indexMax: number;
991
- };
992
- };
993
974
  /**
994
975
  * Liste fixe des types à compter dans les résultats
995
976
  */
@@ -1004,13 +985,40 @@ export interface GlobalAutocompleteData {
1004
985
  | "poi"
1005
986
  )[];
1006
987
  /**
1007
- * Index de départ global pour la pagination
988
+ * Critère de recherche (actuellement vide)
1008
989
  */
1009
- indexMin: 0;
990
+ searchBy?: "ALL";
991
+ /**
992
+ * Index de départ global pour la pagination (toujours 0)
993
+ */
994
+ indexMin: number;
995
+ /**
996
+ * Index de fin global pour la pagination
997
+ */
998
+ indexMax?: number;
1010
999
  /**
1011
1000
  * Nombre d’éléments à récupérer (limite de pagination)
1012
1001
  */
1013
1002
  indexStep: number;
1003
+ /**
1004
+ * Configuration des plages de résultats pour chaque type de recherche
1005
+ */
1006
+ ranges?: {
1007
+ /**
1008
+ * This interface was referenced by `undefined`'s JSON-Schema definition
1009
+ * via the `patternProperty` "^[^\s]+$".
1010
+ */
1011
+ [k: string]: {
1012
+ /**
1013
+ * Index de départ pour la pagination
1014
+ */
1015
+ indexMin: number;
1016
+ /**
1017
+ * Index de fin pour la pagination
1018
+ */
1019
+ indexMax: number;
1020
+ };
1021
+ };
1014
1022
  /**
1015
1023
  * Type initial de la recherche, vide par défaut
1016
1024
  */
package/src/api/Event.js CHANGED
@@ -4,6 +4,8 @@ import BaseEntity from "./BaseEntity.js";
4
4
  export class Event extends BaseEntity {
5
5
  static entityType = "events";
6
6
 
7
+ static entityTag = "Event";
8
+
7
9
  static SCHEMA_CONSTANTS = [
8
10
  "ADD_EVENT",
9
11
  // "UPDATE_BLOCK_DESCRIPTION",
package/src/api/News.js CHANGED
@@ -4,6 +4,8 @@ import BaseEntity from "./BaseEntity.js";
4
4
  export class News extends BaseEntity {
5
5
  static entityType = "news";
6
6
 
7
+ static entityTag = "News";
8
+
7
9
  static SCHEMA_CONSTANTS = [
8
10
  "ADD_NEWS"
9
11
  ];
@@ -4,6 +4,8 @@ import BaseEntity from "./BaseEntity.js";
4
4
  export class Organization extends BaseEntity {
5
5
  static entityType = "organizations";
6
6
 
7
+ static entityTag = "Organization";
8
+
7
9
  static SCHEMA_CONSTANTS = [
8
10
  "ADD_ORGANIZATION",
9
11
  "UPDATE_BLOCK_DESCRIPTION",
@@ -178,32 +180,60 @@ export class Organization extends BaseEntity {
178
180
  *
179
181
  *
180
182
  */
181
- async getMembers(data = {}, options = {}, isNext = false) {
183
+ async getMembers(data = {}, options = {}) {
182
184
  data.searchType = this._getDefaultFromEndpoint("GET_MEMBERS_ADMIN", "searchType");
183
185
  // data.searchBy = "ALL";
184
- return this._paginateWith(data, isNext, async (finalData) => {
185
-
186
- const { toBeValidated, isAdmin, isAdminPending, isInviting, roles = [] } = options;
187
-
188
- if(this.isMe){
189
- finalData.pathParams = { type: this.getEntityType(), id: this.id };
190
- // finalData.filters = {
191
- // [`links.memberOf.${this.id}`]: { "$exists": true },
192
- // [`links.memberOf.${this.id}.toBeValidated`]: { "$exists": false },
193
- // [`links.memberOf.${this.id}.isInviting`]: { "$exists": false }
194
- // };
195
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
196
- } else {
197
- delete finalData?.pathParams;
198
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated: false, isAdmin, isInviting, roles });
199
- }
186
+ // return this._paginateWith(data, isNext, async (finalData) => {
187
+
188
+ // const { toBeValidated, isAdmin, isAdminPending, isInviting, roles = [] } = options;
189
+
190
+ // if(this.isMe){
191
+ // finalData.pathParams = { type: this.getEntityType(), id: this.id };
192
+ // // finalData.filters = {
193
+ // // [`links.memberOf.${this.id}`]: { "$exists": true },
194
+ // // [`links.memberOf.${this.id}.toBeValidated`]: { "$exists": false },
195
+ // // [`links.memberOf.${this.id}.isInviting`]: { "$exists": false }
196
+ // // };
197
+ // finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
198
+ // } else {
199
+ // delete finalData?.pathParams;
200
+ // finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated: false, isAdmin, isInviting, roles });
201
+ // }
202
+
203
+ // const fetchFn = this.isMe
204
+ // ? () => this.callIsMe(() => this.endpointApi.getMembersAdmin(finalData))
205
+ // : () => this.endpointApi.getMembersNoAdmin(finalData);
206
+
207
+ // return fetchFn();
208
+ // });
209
+ const paginator = this._createPaginatorEngine({
210
+ initialData: data,
211
+ finalizer: async (finalData) => {
212
+
213
+ const { toBeValidated, isAdmin, isAdminPending, isInviting, roles = [] } = options;
214
+
215
+ if(this.isMe){
216
+ finalData.pathParams = { type: this.getEntityType(), id: this.id };
217
+ // finalData.filters = {
218
+ // [`links.memberOf.${this.id}`]: { "$exists": true },
219
+ // [`links.memberOf.${this.id}.toBeValidated`]: { "$exists": false },
220
+ // [`links.memberOf.${this.id}.isInviting`]: { "$exists": false }
221
+ // };
222
+ finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
223
+ } else {
224
+ delete finalData?.pathParams;
225
+ finalData.filters = this._buildLinkFilters(this.id, { linkType: "memberOf", toBeValidated: false, isAdmin, isInviting, roles });
226
+ }
200
227
 
201
- const fetchFn = this.isMe
202
- ? () => this.callIsMe(() => this.endpointApi.getMembersAdmin(finalData))
203
- : () => this.endpointApi.getMembersNoAdmin(finalData);
228
+ const fetchFn = this.isMe
229
+ ? () => this.callIsMe(() => this.endpointApi.getMembersAdmin(finalData))
230
+ : () => this.endpointApi.getMembersNoAdmin(finalData);
204
231
 
205
- return fetchFn();
232
+ return fetchFn();
233
+ }
206
234
  });
235
+
236
+ return paginator.next();
207
237
  }
208
238
 
209
239
  /**
@@ -370,8 +400,8 @@ export class Organization extends BaseEntity {
370
400
  * @returns {Promise<Object>} - Résultat de la recherche.
371
401
  * @throws {ApiError} - Si le slug ou l'id de l'organisation n'est pas défini.
372
402
  */
373
- async searchCostum(data = {}, isNext = false) {
374
- return super.searchCostum(data, isNext);
403
+ async searchCostum(data = {}) {
404
+ return super.searchCostum(data);
375
405
  }
376
406
 
377
407
  }
package/src/api/Poi.js CHANGED
@@ -4,6 +4,8 @@ import BaseEntity from "./BaseEntity.js";
4
4
  export class Poi extends BaseEntity {
5
5
  static entityType = "poi";
6
6
 
7
+ static entityTag = "Poi";
8
+
7
9
  static SCHEMA_CONSTANTS = [
8
10
  "ADD_POI",
9
11
  "UPDATE_BLOCK_DESCRIPTION",
@@ -4,6 +4,8 @@ import BaseEntity from "./BaseEntity.js";
4
4
  export class Project extends BaseEntity {
5
5
  static entityType = "projects";
6
6
 
7
+ static entityTag = "Project";
8
+
7
9
  static SCHEMA_CONSTANTS = [
8
10
  "ADD_PROJECT",
9
11
  "UPDATE_BLOCK_DESCRIPTION",
@@ -188,33 +190,62 @@ export class Project extends BaseEntity {
188
190
  * const invitingContributors = await project.getContributors({}, { isInviting: true });
189
191
  *
190
192
  */
191
- async getContributors(data = {}, options = {}, isNext = false) {
193
+ async getContributors(data = {}, options = {}) {
192
194
  data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType");
193
195
  // data.searchBy = "ALL";
194
- return this._paginateWith(data, isNext, async (finalData) => {
195
-
196
- const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
197
-
198
- if(this.isMe){
199
- finalData.pathParams = { type: this.getEntityType(), id: this.id };
200
- // NOTE : dans le schema je crois que si pas de finalData.filters alors le default ce fait avec finalData.pathParams
201
- // finalData.filters = {
202
- // [`links.projects.${this.id}`]: { "$exists": true },
203
- // [`links.projects.${this.id}.toBeValidated`]: { "$exists": false },
204
- // [`links.projects.${this.id}.isInviting`]: { "$exists": false }
205
- // };
206
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
207
- } else {
208
- delete finalData?.pathParams;
209
- finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated: false, isAdmin, isInviting, roles });
210
- }
196
+ // return this._paginateWith(data, isNext, async (finalData) => {
197
+
198
+ // const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
199
+
200
+ // if(this.isMe){
201
+ // finalData.pathParams = { type: this.getEntityType(), id: this.id };
202
+ // // NOTE : dans le schema je crois que si pas de finalData.filters alors le default ce fait avec finalData.pathParams
203
+ // // finalData.filters = {
204
+ // // [`links.projects.${this.id}`]: { "$exists": true },
205
+ // // [`links.projects.${this.id}.toBeValidated`]: { "$exists": false },
206
+ // // [`links.projects.${this.id}.isInviting`]: { "$exists": false }
207
+ // // };
208
+ // finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
209
+ // } else {
210
+ // delete finalData?.pathParams;
211
+ // finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated: false, isAdmin, isInviting, roles });
212
+ // }
213
+
214
+ // const fetchFn = this.isMe
215
+ // ? () => this.callIsMe(() => this.endpointApi.getContributorsAdmin(finalData))
216
+ // : () => this.endpointApi.getContributorsNoAdmin(finalData);
217
+
218
+ // return fetchFn();
219
+ // });
220
+ const paginator = this._createPaginatorEngine({
221
+ initialData: data,
222
+ finalizer: async (finalData) => {
223
+
224
+ const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
225
+
226
+ if(this.isMe){
227
+ finalData.pathParams = { type: this.getEntityType(), id: this.id };
228
+ // NOTE : dans le schema je crois que si pas de finalData.filters alors le default ce fait avec finalData.pathParams
229
+ // finalData.filters = {
230
+ // [`links.projects.${this.id}`]: { "$exists": true },
231
+ // [`links.projects.${this.id}.toBeValidated`]: { "$exists": false },
232
+ // [`links.projects.${this.id}.isInviting`]: { "$exists": false }
233
+ // };
234
+ finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
235
+ } else {
236
+ delete finalData?.pathParams;
237
+ finalData.filters = this._buildLinkFilters(this.id, { linkType: "projects", toBeValidated: false, isAdmin, isInviting, roles });
238
+ }
211
239
 
212
- const fetchFn = this.isMe
213
- ? () => this.callIsMe(() => this.endpointApi.getContributorsAdmin(finalData))
214
- : () => this.endpointApi.getContributorsNoAdmin(finalData);
240
+ const fetchFn = this.isMe
241
+ ? () => this.callIsMe(() => this.endpointApi.getContributorsAdmin(finalData))
242
+ : () => this.endpointApi.getContributorsNoAdmin(finalData);
215
243
 
216
- return fetchFn();
244
+ return fetchFn();
245
+ }
217
246
  });
247
+
248
+ return paginator.next();
218
249
  }
219
250
 
220
251
  /**
package/src/api/User.js CHANGED
@@ -7,6 +7,8 @@ export class User extends BaseEntity {
7
7
 
8
8
  static entityType = "citoyens";
9
9
 
10
+ static entityTag = "User";
11
+
10
12
  static SCHEMA_CONSTANTS = [
11
13
  "UPDATE_BLOCK_DESCRIPTION",
12
14
  "UPDATE_BLOCK_INFO",
@@ -282,26 +284,48 @@ export class User extends BaseEntity {
282
284
  * Récupérer les organisations d'un utilisateur : Récupère la liste des organisations auxquelles l'utilisateur appartient.
283
285
  * Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
284
286
  */
285
- async getOrganizations(data = {}, isNext = false) {
287
+ async getOrganizations(data = {}) {
286
288
  data.searchType = this._getDefaultFromEndpoint("GET_ORGANIZATIONS_NO_ADMIN", "searchType");
287
289
  // data.searchBy = "ALL";
288
- return this._paginateWith(data, isNext, async (finalData) => {
289
- delete finalData?.pathParams;
290
+ // return this._paginateWith(data, isNext, async (finalData) => {
291
+ // delete finalData?.pathParams;
290
292
 
291
- const fetchFn = this.isMe
292
- ? () => this.callIsMe(() => this.endpointApi.getOrganizationsAdmin(finalData))
293
- : () => this.endpointApi.getOrganizationsNoAdmin(finalData);
293
+ // const fetchFn = this.isMe
294
+ // ? () => this.callIsMe(() => this.endpointApi.getOrganizationsAdmin(finalData))
295
+ // : () => this.endpointApi.getOrganizationsNoAdmin(finalData);
296
+
297
+ // if (!this.isMe && !finalData.filters) {
298
+ // finalData.filters = {
299
+ // [`links.members.${this.id}`]: { "$exists": true },
300
+ // [`links.members.${this.id}.toBeValidated`]: { "$exists": false },
301
+ // [`links.members.${this.id}.isInviting`]: { "$exists": false }
302
+ // };
303
+ // }
304
+
305
+ // return fetchFn();
306
+ // });
307
+ const paginator = this._createPaginatorEngine({
308
+ initialData: data,
309
+ finalizer: async (finalData) => {
310
+ delete finalData?.pathParams;
311
+
312
+ const fetchFn = this.isMe
313
+ ? () => this.callIsMe(() => this.endpointApi.getOrganizationsAdmin(finalData))
314
+ : () => this.endpointApi.getOrganizationsNoAdmin(finalData);
294
315
 
295
- if (!this.isMe && !finalData.filters) {
296
- finalData.filters = {
297
- [`links.members.${this.id}`]: { "$exists": true },
298
- [`links.members.${this.id}.toBeValidated`]: { "$exists": false },
299
- [`links.members.${this.id}.isInviting`]: { "$exists": false }
300
- };
316
+ if (!this.isMe && !finalData.filters) {
317
+ finalData.filters = {
318
+ [`links.members.${this.id}`]: { "$exists": true },
319
+ [`links.members.${this.id}.toBeValidated`]: { "$exists": false },
320
+ [`links.members.${this.id}.isInviting`]: { "$exists": false }
321
+ };
322
+ }
323
+
324
+ return fetchFn();
301
325
  }
302
-
303
- return fetchFn();
304
326
  });
327
+
328
+ return paginator.next();
305
329
  }
306
330
 
307
331
  /**
@@ -360,25 +384,46 @@ export class User extends BaseEntity {
360
384
  * Récupérer les suivis
361
385
  * Constant : GET_SUBSCRIPTIONS / GET_SUBSCRIPTIONS_ADMIN
362
386
  */
363
- async getSubscriptions(data = {}, isNext = false) {
387
+ async getSubscriptions(data = {}) {
364
388
  data.searchType = this._getDefaultFromEndpoint("GET_SUBSCRIPTIONS", "searchType");
365
389
  // data.searchBy = "ALL";
366
- return this._paginateWith(data, isNext, async (finalData) => {
390
+ // return this._paginateWith(data, isNext, async (finalData) => {
367
391
 
368
- delete finalData?.pathParams;
392
+ // delete finalData?.pathParams;
369
393
 
370
- const fetchFn = this.isMe
371
- ? () => this.callIsMe(() => this.endpointApi.getSubscriptionsAdmin(finalData))
372
- : () => this.endpointApi.getSubscriptions(finalData);
394
+ // const fetchFn = this.isMe
395
+ // ? () => this.callIsMe(() => this.endpointApi.getSubscriptionsAdmin(finalData))
396
+ // : () => this.endpointApi.getSubscriptions(finalData);
373
397
 
374
- if (!this.isMe && !finalData.filters) {
375
- finalData.filters = {
376
- [`links.followers.${this.id}`]: { "$exists": true },
377
- };
378
- }
398
+ // if (!this.isMe && !finalData.filters) {
399
+ // finalData.filters = {
400
+ // [`links.followers.${this.id}`]: { "$exists": true },
401
+ // };
402
+ // }
403
+
404
+ // return fetchFn();
405
+ // });
406
+ const paginator = this._createPaginatorEngine({
407
+ initialData: data,
408
+ finalizer: async (finalData) => {
409
+
410
+ delete finalData?.pathParams;
411
+
412
+ const fetchFn = this.isMe
413
+ ? () => this.callIsMe(() => this.endpointApi.getSubscriptionsAdmin(finalData))
414
+ : () => this.endpointApi.getSubscriptions(finalData);
415
+
416
+ if (!this.isMe && !finalData.filters) {
417
+ finalData.filters = {
418
+ [`links.followers.${this.id}`]: { "$exists": true },
419
+ };
420
+ }
379
421
 
380
- return fetchFn();
422
+ return fetchFn();
423
+ }
381
424
  });
425
+
426
+ return paginator.next();
382
427
  }
383
428
 
384
429
  /**