@communecter/cocolight-api-client 1.0.109 → 1.0.111

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.109",
3
+ "version": "1.0.111",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3891,6 +3891,62 @@ export class BaseEntity<TServerData = any> {
3891
3891
  return this._isLinked("follows");
3892
3892
  }
3893
3893
 
3894
+ /**
3895
+ * Vérifie si le lien de l'utilisateur connecté est en attente de validation.
3896
+ *
3897
+ * @returns - `true` si le lien est à valider, `false` sinon.
3898
+ * @throws {ApiError}
3899
+ */
3900
+ isToBeValidated(): boolean {
3901
+ this._checkAccess("vérifier si il est à validé.");
3902
+ this._assertEntityType("citoyens","organizations", "projects", "events");
3903
+ const userLink = this._getLinkFromConnectedUser();
3904
+ if (!userLink) return false;
3905
+ return userLink?.toBeValidated === true;
3906
+ }
3907
+
3908
+ /**
3909
+ * Vérifie si l'utilisateur connecté a été invité à rejoindre l'entité.
3910
+ *
3911
+ * @returns - `true` si l'utilisateur est invité, `false` sinon.
3912
+ * @throws {ApiError}
3913
+ */
3914
+ isInviting(): boolean {
3915
+ this._checkAccess("vérifier si il est invité.");
3916
+ this._assertEntityType("citoyens","organizations", "projects", "events");
3917
+ const userLink = this._getLinkFromConnectedUser();
3918
+ if (!userLink) return false;
3919
+ return userLink?.isInviting === true;
3920
+ }
3921
+
3922
+ /**
3923
+ * Vérifie si l'utilisateur connecté a été invité en tant qu'administrateur.
3924
+ *
3925
+ * @returns - `true` si l'utilisateur est invité admin, `false` sinon.
3926
+ * @throws {ApiError}
3927
+ */
3928
+ isInvitingAdmin(): boolean {
3929
+ this._checkAccess("vérifier si il est invité admin.");
3930
+ this._assertEntityType("organizations", "projects", "events");
3931
+ const userLink = this._getLinkFromConnectedUser();
3932
+ if (!userLink) return false;
3933
+ return (userLink?.isAdminInviting === true || userLink?.isInviting === true) && userLink?.isAdmin === true;
3934
+ }
3935
+
3936
+ /**
3937
+ * Vérifie si l'utilisateur connecté est administrateur en attente de confirmation.
3938
+ *
3939
+ * @returns - `true` si l'utilisateur est admin en attente, `false` sinon.
3940
+ * @throws {ApiError}
3941
+ */
3942
+ isAdminPending(): boolean {
3943
+ this._checkAccess("vérifier si il est en attente admin.");
3944
+ this._assertEntityType("organizations", "projects", "events");
3945
+ const userLink = this._getLinkFromConnectedUser();
3946
+ if (!userLink) return false;
3947
+ return userLink?.isAdmin === true && userLink?.isAdminPending === true;
3948
+ }
3949
+
3894
3950
  /**
3895
3951
  * Récupère le JSON personnalisé de l'entité
3896
3952
  *
package/src/api/User.ts CHANGED
@@ -1067,7 +1067,11 @@ export class User extends BaseEntity<UserItemNormalized> {
1067
1067
  * }
1068
1068
  */
1069
1069
  override isAdmin(): boolean {
1070
- this._validateMemberPreconditions("isAdmin", ["organizations", "projects"]);
1070
+ try {
1071
+ this._validateMemberPreconditions("isAdmin", ["organizations", "projects"]);
1072
+ } catch{
1073
+ return false;
1074
+ }
1071
1075
  const parentLink = this._getParentLinkForUser();
1072
1076
  return this._validateUserLink(parentLink) && parentLink?.isAdmin === true;
1073
1077
  }
@@ -1098,7 +1102,11 @@ export class User extends BaseEntity<UserItemNormalized> {
1098
1102
  * }
1099
1103
  */
1100
1104
  override isMember(): boolean {
1101
- this._validateMemberPreconditions("isMember", ["organizations"]);
1105
+ try {
1106
+ this._validateMemberPreconditions("isMember", ["organizations"]);
1107
+ } catch{
1108
+ return false;
1109
+ }
1102
1110
  const parentLink = this._getParentLinkForUser();
1103
1111
  return this._validateUserLink(parentLink);
1104
1112
  }
@@ -1129,7 +1137,11 @@ export class User extends BaseEntity<UserItemNormalized> {
1129
1137
  * }
1130
1138
  */
1131
1139
  override isContributor(): boolean {
1132
- this._validateMemberPreconditions("isContributor", ["projects"]);
1140
+ try {
1141
+ this._validateMemberPreconditions("isContributor", ["projects"]);
1142
+ } catch{
1143
+ return false;
1144
+ }
1133
1145
  const parentLink = this._getParentLinkForUser();
1134
1146
  return this._validateUserLink(parentLink);
1135
1147
  }
@@ -1160,7 +1172,11 @@ export class User extends BaseEntity<UserItemNormalized> {
1160
1172
  * }
1161
1173
  */
1162
1174
  override isAttendee(): boolean {
1163
- this._validateMemberPreconditions("isAttendee", ["events"]);
1175
+ try {
1176
+ this._validateMemberPreconditions("isAttendee", ["events"]);
1177
+ } catch{
1178
+ return false;
1179
+ }
1164
1180
  const parentLink = this._getParentLinkForUser();
1165
1181
  return this._validateUserLink(parentLink);
1166
1182
  }
@@ -1182,8 +1198,12 @@ export class User extends BaseEntity<UserItemNormalized> {
1182
1198
  * console.log("Invitation en attente:", invitedUser?.data.name);
1183
1199
  * ```
1184
1200
  */
1185
- isInviting(): boolean {
1186
- this._validateMemberPreconditions("isInviting", ["organizations", "projects", "events"]);
1201
+ override isInviting(): boolean {
1202
+ try {
1203
+ this._validateMemberPreconditions("isInviting", ["organizations", "projects", "events"]);
1204
+ } catch{
1205
+ return false;
1206
+ }
1187
1207
  const parentLink = this._getParentLinkForUser();
1188
1208
  if (!parentLink) return false;
1189
1209
  return parentLink?.isInviting === true;
@@ -1206,8 +1226,12 @@ export class User extends BaseEntity<UserItemNormalized> {
1206
1226
  * console.log("Invitation admin en attente:", invitedAdmin?.data.name);
1207
1227
  * ```
1208
1228
  */
1209
- isInvitingAdmin(): boolean {
1210
- this._validateMemberPreconditions("isInvitingAdmin", ["organizations", "projects"]);
1229
+ override isInvitingAdmin(): boolean {
1230
+ try {
1231
+ this._validateMemberPreconditions("isInvitingAdmin", ["organizations", "projects"]);
1232
+ } catch{
1233
+ return false;
1234
+ }
1211
1235
  const parentLink = this._getParentLinkForUser();
1212
1236
  if (!parentLink) return false;
1213
1237
  return (parentLink?.isAdminInviting === true || parentLink?.isInviting === true) && parentLink?.isAdmin === true;
@@ -1232,8 +1256,12 @@ export class User extends BaseEntity<UserItemNormalized> {
1232
1256
  * }
1233
1257
  * ```
1234
1258
  */
1235
- isAdminPending(): boolean {
1236
- this._validateMemberPreconditions("isAdminPending", ["organizations", "projects"]);
1259
+ override isAdminPending(): boolean {
1260
+ try {
1261
+ this._validateMemberPreconditions("isAdminPending", ["organizations", "projects"]);
1262
+ } catch{
1263
+ return false;
1264
+ }
1237
1265
  const parentLink = this._getParentLinkForUser();
1238
1266
  return parentLink?.isAdmin === true && parentLink?.isAdminPending === true;
1239
1267
  }
@@ -1257,8 +1285,12 @@ export class User extends BaseEntity<UserItemNormalized> {
1257
1285
  * }
1258
1286
  * ```
1259
1287
  */
1260
- isToBeValidated(): boolean {
1261
- this._validateMemberPreconditions("isToBeValidated", ["organizations", "projects", "events"]);
1288
+ override isToBeValidated(): boolean {
1289
+ try {
1290
+ this._validateMemberPreconditions("isToBeValidated", ["organizations", "projects", "events"]);
1291
+ } catch{
1292
+ return false;
1293
+ }
1262
1294
  const parentLink = this._getParentLinkForUser();
1263
1295
  return parentLink?.toBeValidated === true;
1264
1296
  }
@@ -1326,6 +1326,34 @@ export declare class BaseEntity<TServerData = any> {
1326
1326
  * @throws {ApiError}
1327
1327
  */
1328
1328
  isFollowing(): boolean;
1329
+ /**
1330
+ * Vérifie si le lien de l'utilisateur connecté est en attente de validation.
1331
+ *
1332
+ * @returns - `true` si le lien est à valider, `false` sinon.
1333
+ * @throws {ApiError}
1334
+ */
1335
+ isToBeValidated(): boolean;
1336
+ /**
1337
+ * Vérifie si l'utilisateur connecté a été invité à rejoindre l'entité.
1338
+ *
1339
+ * @returns - `true` si l'utilisateur est invité, `false` sinon.
1340
+ * @throws {ApiError}
1341
+ */
1342
+ isInviting(): boolean;
1343
+ /**
1344
+ * Vérifie si l'utilisateur connecté a été invité en tant qu'administrateur.
1345
+ *
1346
+ * @returns - `true` si l'utilisateur est invité admin, `false` sinon.
1347
+ * @throws {ApiError}
1348
+ */
1349
+ isInvitingAdmin(): boolean;
1350
+ /**
1351
+ * Vérifie si l'utilisateur connecté est administrateur en attente de confirmation.
1352
+ *
1353
+ * @returns - `true` si l'utilisateur est admin en attente, `false` sinon.
1354
+ * @throws {ApiError}
1355
+ */
1356
+ isAdminPending(): boolean;
1329
1357
  /**
1330
1358
  * Récupère le JSON personnalisé de l'entité
1331
1359
  *