@communecter/cocolight-api-client 1.0.31 → 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.
- package/dist/cocolight-api-client.browser.js +3 -3
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
- package/package.json +1 -1
- package/src/api/BaseEntity.js +439 -176
- package/src/api/Organization.js +51 -23
- package/src/api/Project.js +51 -22
- package/src/api/User.js +69 -26
package/src/api/Organization.js
CHANGED
|
@@ -180,32 +180,60 @@ export class Organization extends BaseEntity {
|
|
|
180
180
|
*
|
|
181
181
|
*
|
|
182
182
|
*/
|
|
183
|
-
async getMembers(data = {}, options = {}
|
|
183
|
+
async getMembers(data = {}, options = {}) {
|
|
184
184
|
data.searchType = this._getDefaultFromEndpoint("GET_MEMBERS_ADMIN", "searchType");
|
|
185
185
|
// data.searchBy = "ALL";
|
|
186
|
-
return this._paginateWith(data, isNext, async (finalData) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
+
}
|
|
202
227
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
228
|
+
const fetchFn = this.isMe
|
|
229
|
+
? () => this.callIsMe(() => this.endpointApi.getMembersAdmin(finalData))
|
|
230
|
+
: () => this.endpointApi.getMembersNoAdmin(finalData);
|
|
206
231
|
|
|
207
|
-
|
|
232
|
+
return fetchFn();
|
|
233
|
+
}
|
|
208
234
|
});
|
|
235
|
+
|
|
236
|
+
return paginator.next();
|
|
209
237
|
}
|
|
210
238
|
|
|
211
239
|
/**
|
|
@@ -372,8 +400,8 @@ export class Organization extends BaseEntity {
|
|
|
372
400
|
* @returns {Promise<Object>} - Résultat de la recherche.
|
|
373
401
|
* @throws {ApiError} - Si le slug ou l'id de l'organisation n'est pas défini.
|
|
374
402
|
*/
|
|
375
|
-
async searchCostum(data = {}
|
|
376
|
-
return super.searchCostum(data
|
|
403
|
+
async searchCostum(data = {}) {
|
|
404
|
+
return super.searchCostum(data);
|
|
377
405
|
}
|
|
378
406
|
|
|
379
407
|
}
|
package/src/api/Project.js
CHANGED
|
@@ -190,33 +190,62 @@ export class Project extends BaseEntity {
|
|
|
190
190
|
* const invitingContributors = await project.getContributors({}, { isInviting: true });
|
|
191
191
|
*
|
|
192
192
|
*/
|
|
193
|
-
async getContributors(data = {}, options = {}
|
|
193
|
+
async getContributors(data = {}, options = {}) {
|
|
194
194
|
data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType");
|
|
195
195
|
// data.searchBy = "ALL";
|
|
196
|
-
return this._paginateWith(data, isNext, async (finalData) => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
}
|
|
213
239
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
240
|
+
const fetchFn = this.isMe
|
|
241
|
+
? () => this.callIsMe(() => this.endpointApi.getContributorsAdmin(finalData))
|
|
242
|
+
: () => this.endpointApi.getContributorsNoAdmin(finalData);
|
|
217
243
|
|
|
218
|
-
|
|
244
|
+
return fetchFn();
|
|
245
|
+
}
|
|
219
246
|
});
|
|
247
|
+
|
|
248
|
+
return paginator.next();
|
|
220
249
|
}
|
|
221
250
|
|
|
222
251
|
/**
|
package/src/api/User.js
CHANGED
|
@@ -284,26 +284,48 @@ export class User extends BaseEntity {
|
|
|
284
284
|
* Récupérer les organisations d'un utilisateur : Récupère la liste des organisations auxquelles l'utilisateur appartient.
|
|
285
285
|
* Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
|
|
286
286
|
*/
|
|
287
|
-
async getOrganizations(data = {}
|
|
287
|
+
async getOrganizations(data = {}) {
|
|
288
288
|
data.searchType = this._getDefaultFromEndpoint("GET_ORGANIZATIONS_NO_ADMIN", "searchType");
|
|
289
289
|
// data.searchBy = "ALL";
|
|
290
|
-
return this._paginateWith(data, isNext, async (finalData) => {
|
|
291
|
-
|
|
290
|
+
// return this._paginateWith(data, isNext, async (finalData) => {
|
|
291
|
+
// delete finalData?.pathParams;
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
// const fetchFn = this.isMe
|
|
294
|
+
// ? () => this.callIsMe(() => this.endpointApi.getOrganizationsAdmin(finalData))
|
|
295
|
+
// : () => this.endpointApi.getOrganizationsNoAdmin(finalData);
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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);
|
|
315
|
+
|
|
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();
|
|
303
325
|
}
|
|
304
|
-
|
|
305
|
-
return fetchFn();
|
|
306
326
|
});
|
|
327
|
+
|
|
328
|
+
return paginator.next();
|
|
307
329
|
}
|
|
308
330
|
|
|
309
331
|
/**
|
|
@@ -362,25 +384,46 @@ export class User extends BaseEntity {
|
|
|
362
384
|
* Récupérer les suivis
|
|
363
385
|
* Constant : GET_SUBSCRIPTIONS / GET_SUBSCRIPTIONS_ADMIN
|
|
364
386
|
*/
|
|
365
|
-
async getSubscriptions(data = {}
|
|
387
|
+
async getSubscriptions(data = {}) {
|
|
366
388
|
data.searchType = this._getDefaultFromEndpoint("GET_SUBSCRIPTIONS", "searchType");
|
|
367
389
|
// data.searchBy = "ALL";
|
|
368
|
-
return this._paginateWith(data, isNext, async (finalData) => {
|
|
390
|
+
// return this._paginateWith(data, isNext, async (finalData) => {
|
|
369
391
|
|
|
370
|
-
|
|
392
|
+
// delete finalData?.pathParams;
|
|
371
393
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
394
|
+
// const fetchFn = this.isMe
|
|
395
|
+
// ? () => this.callIsMe(() => this.endpointApi.getSubscriptionsAdmin(finalData))
|
|
396
|
+
// : () => this.endpointApi.getSubscriptions(finalData);
|
|
375
397
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
+
}
|
|
381
421
|
|
|
382
|
-
|
|
422
|
+
return fetchFn();
|
|
423
|
+
}
|
|
383
424
|
});
|
|
425
|
+
|
|
426
|
+
return paginator.next();
|
|
384
427
|
}
|
|
385
428
|
|
|
386
429
|
/**
|