@communecter/cocolight-api-client 1.0.47 → 1.0.48
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 +1 -1
- 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/ApiClient.js +4 -2
- package/src/api/BaseEntity.js +18 -0
- package/src/api/EndpointApi.js +15 -0
- package/src/api/EndpointApi.types.d.ts +28 -0
- package/src/api/Event.js +8 -0
- package/src/api/Organization.js +12 -0
- package/src/api/Project.js +12 -0
- package/src/api/User.js +8 -0
- package/src/endpoints.module.js +2 -2
package/package.json
CHANGED
package/src/ApiClient.js
CHANGED
|
@@ -1074,7 +1074,7 @@ export default class ApiClient extends EventEmitter {
|
|
|
1074
1074
|
data.results = Object.keys(data.results).map((key) => {
|
|
1075
1075
|
return this._normalizeJsonData({ id: key, ...data.results[key] });
|
|
1076
1076
|
});
|
|
1077
|
-
} else if (Array.isArray(data.results)) {
|
|
1077
|
+
} else if (Array.isArray(data.results) && data.results.length > 0) {
|
|
1078
1078
|
data.results = data.results.map((item) => this._normalizeJsonData(item));
|
|
1079
1079
|
} else if (data.news && Array.isArray(data.news) && data.news.length === 0) {
|
|
1080
1080
|
data = data.news;
|
|
@@ -1441,7 +1441,9 @@ export default class ApiClient extends EventEmitter {
|
|
|
1441
1441
|
"profilRealBannerUrl",
|
|
1442
1442
|
"imagePath",
|
|
1443
1443
|
"imageThumbPath",
|
|
1444
|
-
"docPath"
|
|
1444
|
+
"docPath",
|
|
1445
|
+
"imageThumb",
|
|
1446
|
+
"imageMediumPath"
|
|
1445
1447
|
];
|
|
1446
1448
|
|
|
1447
1449
|
/**
|
package/src/api/BaseEntity.js
CHANGED
|
@@ -2171,6 +2171,24 @@ export class BaseEntity {
|
|
|
2171
2171
|
return this._createFilteredProxy(rawList);
|
|
2172
2172
|
}
|
|
2173
2173
|
|
|
2174
|
+
/**
|
|
2175
|
+
* Récupérer la galerie d'une entité.
|
|
2176
|
+
* Constant : GET_GALLERY
|
|
2177
|
+
* @param {Object} data - Les données à envoyer.
|
|
2178
|
+
* @param {string} data.pathParams.docType - Type de document (default: "image")
|
|
2179
|
+
* @param {string} data.contentKey - Clé de contenu pour la galerie (default: "null")
|
|
2180
|
+
* @param {string} data.folderId - ID du dossier pour la galerie (default: "null")
|
|
2181
|
+
* @returns {Promise<Object>} - Les données de réponse.
|
|
2182
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
2183
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
2184
|
+
*/
|
|
2185
|
+
async getGallery(data = {}) {
|
|
2186
|
+
data.pathParams = { type: this.getEntityType(), id: this.id, docType: data.pathParams?.docType || "image" };
|
|
2187
|
+
const arrayObjet = await this.endpointApi.getGallery(data);
|
|
2188
|
+
|
|
2189
|
+
return arrayObjet;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2174
2192
|
/**
|
|
2175
2193
|
* Soumet une demande pour rejoindre l'entité courante (ex. organisation, projet, événement...).
|
|
2176
2194
|
* Si une invitation est en attente, elle est automatiquement acceptée.
|
package/src/api/EndpointApi.js
CHANGED
|
@@ -1513,6 +1513,21 @@ class EndpointApi {
|
|
|
1513
1513
|
return this.call("COSTUM_EVENT_REQUEST_LOAD_CONTEXT_TAG", data);
|
|
1514
1514
|
}
|
|
1515
1515
|
|
|
1516
|
+
/**
|
|
1517
|
+
* Récupération de la galerie : Renvoie soit la liste d’albums associés à une entité, soit les images d’un album spécifique.
|
|
1518
|
+
* Constant : GET_GALLERY
|
|
1519
|
+
* @param {import("./EndpointApi.types").GetGalleryData} data - Données envoyées à l'API
|
|
1520
|
+
* @returns {Promise<Object>} - Les données de réponse.
|
|
1521
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1522
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1523
|
+
*/
|
|
1524
|
+
async getGallery(data) {
|
|
1525
|
+
if (!data || typeof data !== "object") {
|
|
1526
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1527
|
+
}
|
|
1528
|
+
return this.call("GET_GALLERY", data);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1516
1531
|
}
|
|
1517
1532
|
|
|
1518
1533
|
export default EndpointApi;
|
|
@@ -4412,3 +4412,31 @@ export interface CostumEventRequestLoadContextTagData {
|
|
|
4412
4412
|
};
|
|
4413
4413
|
[k: string]: unknown;
|
|
4414
4414
|
}
|
|
4415
|
+
|
|
4416
|
+
|
|
4417
|
+
export interface GetGalleryData {
|
|
4418
|
+
/**
|
|
4419
|
+
* Clé de contenu pour correspondre à l'album ou aux images
|
|
4420
|
+
*/
|
|
4421
|
+
contentKey?: string;
|
|
4422
|
+
/**
|
|
4423
|
+
* ID du dossier à récupérer (pour les images d'un album)
|
|
4424
|
+
*/
|
|
4425
|
+
folderId?: string;
|
|
4426
|
+
pathParams?: {
|
|
4427
|
+
/**
|
|
4428
|
+
* ID de l'entité
|
|
4429
|
+
*/
|
|
4430
|
+
id: string;
|
|
4431
|
+
/**
|
|
4432
|
+
* Type d'entité
|
|
4433
|
+
*/
|
|
4434
|
+
type: "citoyens" | "organizations" | "projects";
|
|
4435
|
+
/**
|
|
4436
|
+
* Type de document
|
|
4437
|
+
*/
|
|
4438
|
+
docType: "image" | "file" | "bookmarks";
|
|
4439
|
+
[k: string]: unknown;
|
|
4440
|
+
};
|
|
4441
|
+
[k: string]: unknown;
|
|
4442
|
+
}
|
package/src/api/Event.js
CHANGED
|
@@ -8,6 +8,10 @@ export class Event extends BaseEntity {
|
|
|
8
8
|
|
|
9
9
|
static SCHEMA_CONSTANTS = [
|
|
10
10
|
"ADD_EVENT",
|
|
11
|
+
// "UPDATE_BLOCK_DESCRIPTION",
|
|
12
|
+
// "UPDATE_BLOCK_INFO",
|
|
13
|
+
// "UPDATE_BLOCK_SOCIAL",
|
|
14
|
+
// "UPDATE_BLOCK_LOCALITY",
|
|
11
15
|
"UPDATE_BLOCK_SLUG",
|
|
12
16
|
"PROFIL_IMAGE"
|
|
13
17
|
];
|
|
@@ -18,6 +22,10 @@ export class Event extends BaseEntity {
|
|
|
18
22
|
]);
|
|
19
23
|
|
|
20
24
|
static UPDATE_BLOCKS = new Map([
|
|
25
|
+
// ["UPDATE_BLOCK_DESCRIPTION", "updateDescription"],
|
|
26
|
+
// ["UPDATE_BLOCK_SOCIAL", "updateSocial"],
|
|
27
|
+
// ["UPDATE_BLOCK_LOCALITY", "updateLocality"],
|
|
28
|
+
// ["UPDATE_BLOCK_INFO", "updateInfo"],
|
|
21
29
|
["UPDATE_BLOCK_SLUG", "updateSlug"],
|
|
22
30
|
["PROFIL_IMAGE", "updateImageProfil"]
|
|
23
31
|
]);
|
package/src/api/Organization.js
CHANGED
|
@@ -214,6 +214,18 @@ export class Organization extends BaseEntity {
|
|
|
214
214
|
return paginator.next();
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* 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
|
+
*/
|
|
225
|
+
async getGallery(data = {}) {
|
|
226
|
+
return super.getGallery(data);
|
|
227
|
+
}
|
|
228
|
+
|
|
217
229
|
/**
|
|
218
230
|
* Crée une instance de projet et récupère son profil si nécessaire.
|
|
219
231
|
*
|
package/src/api/Project.js
CHANGED
|
@@ -225,6 +225,18 @@ export class Project extends BaseEntity {
|
|
|
225
225
|
return paginator.next();
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* 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
|
+
*/
|
|
236
|
+
async getGallery(data = {}) {
|
|
237
|
+
return super.getGallery(data);
|
|
238
|
+
}
|
|
239
|
+
|
|
228
240
|
/**
|
|
229
241
|
* Crée une instance de projet et récupère son profil si nécessaire.
|
|
230
242
|
*
|
package/src/api/User.js
CHANGED
|
@@ -441,6 +441,14 @@ export class User extends BaseEntity {
|
|
|
441
441
|
return filteredBadges;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Récupérer la galerie de l'utilisateur
|
|
446
|
+
* Constant : GET_GALLERY
|
|
447
|
+
*/
|
|
448
|
+
async getGallery(data = {}) {
|
|
449
|
+
return super.getGallery(data);
|
|
450
|
+
}
|
|
451
|
+
|
|
444
452
|
async user(userData) {
|
|
445
453
|
if(!this.isMe){
|
|
446
454
|
throw new ApiError("Vous devez être connecté et être l'utilisateur");
|