@communecter/cocolight-api-client 1.0.118 → 1.0.120
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.ts +1 -2
- package/src/api/BaseEntity.ts +80 -13
- package/src/api/Comment.ts +1 -1
- package/src/api/EndpointApi.ts +31 -1
- package/src/api/EndpointApi.types.ts +57 -1
- package/src/api/User.ts +40 -18
- package/src/api/UserApi.ts +1 -1
- package/src/api/serverDataType/Zone.ts +33 -0
- package/src/endpoints.module.ts +4 -1
- package/src/index.ts +1 -0
- package/types/api/BaseEntity.d.ts +39 -1
- package/types/api/EndpointApi.d.ts +19 -1
- package/types/api/EndpointApi.types.d.ts +53 -1
- package/types/api/User.d.ts +15 -6
- package/types/api/serverDataType/Zone.d.ts +30 -0
- package/types/endpoints.module.d.ts +797 -0
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
package/src/ApiClient.ts
CHANGED
|
@@ -207,7 +207,6 @@ export default class ApiClient extends EventEmitter {
|
|
|
207
207
|
baseURL,
|
|
208
208
|
timeout
|
|
209
209
|
});
|
|
210
|
-
|
|
211
210
|
// axios-retry : pour retenter en cas de soucis réseau ou code 5xx
|
|
212
211
|
if (maxRetries > 0) {
|
|
213
212
|
axiosRetry(this._client, {
|
|
@@ -741,7 +740,7 @@ export default class ApiClient extends EventEmitter {
|
|
|
741
740
|
throw new ApiClientError(`Path param manquant ou non résolu : {${key}}`, 400);
|
|
742
741
|
});
|
|
743
742
|
}
|
|
744
|
-
|
|
743
|
+
|
|
745
744
|
// === 2. Validation données (request schema) ===
|
|
746
745
|
if (requestSchema) {
|
|
747
746
|
// Si auth est "none" et que userId n'est pas défini, on nettoie le schéma
|
package/src/api/BaseEntity.ts
CHANGED
|
@@ -44,10 +44,13 @@ import type {
|
|
|
44
44
|
CoformAnswersSearchData,
|
|
45
45
|
ProfilBannerData,
|
|
46
46
|
SearchMemberAutocompleteData,
|
|
47
|
-
GetEventsData
|
|
47
|
+
GetEventsData,
|
|
48
|
+
CostumFilterCoformData,
|
|
49
|
+
SearchZonesData
|
|
48
50
|
} from "./EndpointApi.types.js";
|
|
49
51
|
import type { GetElementsKeyResponse } from "../types/api-responses.js";
|
|
50
52
|
import type { TransformsMap } from "../types/entities.js";
|
|
53
|
+
import type { ZoneItemNormalized } from "./serverDataType/Zone.js";
|
|
51
54
|
const { fromBuffer } = pkg;
|
|
52
55
|
|
|
53
56
|
/**
|
|
@@ -3959,12 +3962,15 @@ export class BaseEntity<TServerData = any> {
|
|
|
3959
3962
|
* @throws {ApiError} - Si `silent` est `false` et que les préconditions ne sont pas remplies.
|
|
3960
3963
|
*/
|
|
3961
3964
|
isFollower(options?: { silent?: boolean }): boolean {
|
|
3962
|
-
const
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3965
|
+
const silent = options?.silent ?? true;
|
|
3966
|
+
const expectedTypes = ["citoyens", "organizations", "projects", "events", "poi"];
|
|
3967
|
+
try {
|
|
3968
|
+
this._checkAccess("vérifier si il vous suit");
|
|
3969
|
+
this._assertEntityType(...expectedTypes);
|
|
3970
|
+
} catch (e) {
|
|
3971
|
+
if (silent) return false;
|
|
3972
|
+
throw e;
|
|
3973
|
+
}
|
|
3968
3974
|
return this._isLinked("followers");
|
|
3969
3975
|
}
|
|
3970
3976
|
|
|
@@ -3977,12 +3983,15 @@ export class BaseEntity<TServerData = any> {
|
|
|
3977
3983
|
* @throws {ApiError} - Si `silent` est `false` et que les préconditions ne sont pas remplies.
|
|
3978
3984
|
*/
|
|
3979
3985
|
isFollowing(options?: { silent?: boolean }): boolean {
|
|
3980
|
-
const
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
+
const silent = options?.silent ?? true;
|
|
3987
|
+
const expectedTypes = ["citoyens", "organizations", "projects", "events", "poi"];
|
|
3988
|
+
try {
|
|
3989
|
+
this._checkAccess("vérifier si vous le suivez");
|
|
3990
|
+
this._assertEntityType(...expectedTypes);
|
|
3991
|
+
} catch (e) {
|
|
3992
|
+
if (silent) return false;
|
|
3993
|
+
throw e;
|
|
3994
|
+
}
|
|
3986
3995
|
return this._isLinked("follows");
|
|
3987
3996
|
}
|
|
3988
3997
|
|
|
@@ -4634,6 +4643,64 @@ export class BaseEntity<TServerData = any> {
|
|
|
4634
4643
|
return paginator.next() as Promise<PaginatorPage<any>>;
|
|
4635
4644
|
}
|
|
4636
4645
|
|
|
4646
|
+
|
|
4647
|
+
/**
|
|
4648
|
+
* Récupère les filtres disponibles basés sur les réponses CoForm de l'entité courante.
|
|
4649
|
+
* Utilise le contexte Communecter (costumSlug, contextId, contextType) de l'entité.
|
|
4650
|
+
*
|
|
4651
|
+
* La réponse est un objet indexé par nom de filtre, chaque entrée contenant :
|
|
4652
|
+
* - `count` : nombre de résultats par catégorie
|
|
4653
|
+
* - `results` : valeurs disponibles pour ce filtre (libellé, image, etc.)
|
|
4654
|
+
*
|
|
4655
|
+
* @param data - Paramètres optionnels de recherche
|
|
4656
|
+
* @param data.searchedData - Filtres actifs : clé → `{ label, forms, path, finderPath }`
|
|
4657
|
+
* @returns Objet `Record<filterName, { count, results }>` des filtres disponibles
|
|
4658
|
+
*
|
|
4659
|
+
* @example
|
|
4660
|
+
* const filters = await project.coformFiltersSearch({
|
|
4661
|
+
* searchedData: {
|
|
4662
|
+
* "activités": {
|
|
4663
|
+
* label: "Activités",
|
|
4664
|
+
* forms: "6486d24e9cad105cbf29a777",
|
|
4665
|
+
* path: "lesCommunsDesTierslieux...",
|
|
4666
|
+
* finderPath: "answers.lesCommunsDesTierslieux..."
|
|
4667
|
+
* }
|
|
4668
|
+
* }
|
|
4669
|
+
* });
|
|
4670
|
+
* filters["activités"].count; // { "Atelier": 12, "Coworking": 8 }
|
|
4671
|
+
*/
|
|
4672
|
+
async coformFiltersSearch(
|
|
4673
|
+
data: Partial<CostumFilterCoformData> = {},
|
|
4674
|
+
): Promise<any> {
|
|
4675
|
+
const wrappedFinalizer = this._withCostumContext(
|
|
4676
|
+
(finalData: CostumFilterCoformData) => this.endpointApi.costumFilterCoform(finalData)
|
|
4677
|
+
);
|
|
4678
|
+
return wrappedFinalizer(data);
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
|
|
4682
|
+
/**
|
|
4683
|
+
* Recherche des zones géographiques selon un pays et un niveau administratif.
|
|
4684
|
+
* Utilise le contexte Communecter de l'entité courante.
|
|
4685
|
+
*
|
|
4686
|
+
* @param data - Paramètres de recherche
|
|
4687
|
+
* @param data.countryCode - Code(s) pays ISO (ex: `["FR"]`)
|
|
4688
|
+
* @param data.level - Niveau(x) administratif(s) (ex: `["1"]`)
|
|
4689
|
+
* @returns Liste des zones correspondantes
|
|
4690
|
+
* @throws {ApiError} Si `countryCode` ou `level` sont absents
|
|
4691
|
+
*/
|
|
4692
|
+
async searchZone(
|
|
4693
|
+
data: SearchZonesData,
|
|
4694
|
+
): Promise<ZoneItemNormalized[]> {
|
|
4695
|
+
if(!data.countryCode?.length || !data.level?.length){
|
|
4696
|
+
throw new ApiError("countryCode et level sont requis.", 400);
|
|
4697
|
+
}
|
|
4698
|
+
const wrappedFinalizer = this._withCostumContext(
|
|
4699
|
+
(finalData: SearchZonesData) => this.endpointApi.searchZones(finalData)
|
|
4700
|
+
);
|
|
4701
|
+
return wrappedFinalizer(data) as Promise<ZoneItemNormalized[]>;
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4637
4704
|
/**
|
|
4638
4705
|
* ───────────────────────────────
|
|
4639
4706
|
* Pagination restoration methods
|
package/src/api/Comment.ts
CHANGED
|
@@ -246,7 +246,7 @@ export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
return await this.callIsConnected(() => this.endpointApi.addReportAbuse(payload))
|
|
249
|
+
return await this.callIsConnected(() => this.endpointApi.addReportAbuse(payload));
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
}
|
package/src/api/EndpointApi.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ApiAuthenticationError } from "../error.js";
|
|
3
3
|
|
|
4
4
|
import type ApiClient from "../ApiClient.js";
|
|
5
|
-
import type { PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DemoteAdminData } from "./EndpointApi.types.js";
|
|
5
|
+
import type { PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DemoteAdminData, CostumFilterCoformData, SearchZonesData } from "./EndpointApi.types.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
@@ -1720,6 +1720,36 @@ export class EndpointApi {
|
|
|
1720
1720
|
return this.callIsConnected("DEMOTE_ADMIN", data);
|
|
1721
1721
|
}
|
|
1722
1722
|
|
|
1723
|
+
/**
|
|
1724
|
+
* Filtre par reponses CoForm : Recuperer tous les filtres possibles via l'answers
|
|
1725
|
+
* Constant : COSTUM_FILTER_COFORM
|
|
1726
|
+
* @param data - Données envoyées à l'API
|
|
1727
|
+
* @returns Les données de réponse.
|
|
1728
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1729
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1730
|
+
*/
|
|
1731
|
+
async costumFilterCoform(data: CostumFilterCoformData): Promise<any> {
|
|
1732
|
+
if (!data || typeof data !== "object") {
|
|
1733
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1734
|
+
}
|
|
1735
|
+
return this.call("COSTUM_FILTER_COFORM", data);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Rechercher des zones géographiques : Rechercher des zones géographiques
|
|
1740
|
+
* Constant : SEARCH_ZONES
|
|
1741
|
+
* @param data - Données envoyées à l'API
|
|
1742
|
+
* @returns Les données de réponse.
|
|
1743
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1744
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1745
|
+
*/
|
|
1746
|
+
async searchZones(data: SearchZonesData): Promise<any> {
|
|
1747
|
+
if (!data || typeof data !== "object") {
|
|
1748
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1749
|
+
}
|
|
1750
|
+
return this.call("SEARCH_ZONES", data);
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1723
1753
|
}
|
|
1724
1754
|
|
|
1725
1755
|
export default EndpointApi;
|
|
@@ -3967,7 +3967,7 @@ export interface GlobalAutocompleteCostumData {
|
|
|
3967
3967
|
/**
|
|
3968
3968
|
* Type de la localité : 'cities' pour une ville ou 'level1' pour une région
|
|
3969
3969
|
*/
|
|
3970
|
-
type: "cities" | "level1";
|
|
3970
|
+
type: "cities" | "level1" | "level2" | "level3" | "level4" | "level5";
|
|
3971
3971
|
};
|
|
3972
3972
|
};
|
|
3973
3973
|
/**
|
|
@@ -4948,3 +4948,59 @@ export interface DemoteAdminData {
|
|
|
4948
4948
|
isAdmin: false;
|
|
4949
4949
|
[k: string]: unknown;
|
|
4950
4950
|
}
|
|
4951
|
+
|
|
4952
|
+
|
|
4953
|
+
export interface CostumFilterCoformData {
|
|
4954
|
+
/**
|
|
4955
|
+
* Données de recherche pour le filtre
|
|
4956
|
+
*/
|
|
4957
|
+
searchedData?: {
|
|
4958
|
+
[k: string]: unknown;
|
|
4959
|
+
};
|
|
4960
|
+
/**
|
|
4961
|
+
* Slug du costume
|
|
4962
|
+
*/
|
|
4963
|
+
costumSlug?: string;
|
|
4964
|
+
/**
|
|
4965
|
+
* ID du costume
|
|
4966
|
+
*/
|
|
4967
|
+
costumId?: string;
|
|
4968
|
+
/**
|
|
4969
|
+
* Type du costume
|
|
4970
|
+
*/
|
|
4971
|
+
costumType?: string;
|
|
4972
|
+
[k: string]: unknown;
|
|
4973
|
+
}
|
|
4974
|
+
|
|
4975
|
+
|
|
4976
|
+
export interface SearchZonesData {
|
|
4977
|
+
/**
|
|
4978
|
+
* Code du pays pour la recherche
|
|
4979
|
+
*/
|
|
4980
|
+
countryCode: unknown[];
|
|
4981
|
+
/**
|
|
4982
|
+
* Niveau de la zone géographique pour la recherche
|
|
4983
|
+
*/
|
|
4984
|
+
level: unknown[];
|
|
4985
|
+
/**
|
|
4986
|
+
* Critère de tri des résultats
|
|
4987
|
+
*/
|
|
4988
|
+
sortBy?: string;
|
|
4989
|
+
/**
|
|
4990
|
+
* ID du niveau supérieur pour la recherche
|
|
4991
|
+
*/
|
|
4992
|
+
upperLevelId?: string;
|
|
4993
|
+
/**
|
|
4994
|
+
* Slug du costume
|
|
4995
|
+
*/
|
|
4996
|
+
costumSlug?: string;
|
|
4997
|
+
/**
|
|
4998
|
+
* ID du costume
|
|
4999
|
+
*/
|
|
5000
|
+
costumId?: string;
|
|
5001
|
+
/**
|
|
5002
|
+
* Type du costume
|
|
5003
|
+
*/
|
|
5004
|
+
costumType?: string;
|
|
5005
|
+
[k: string]: unknown;
|
|
5006
|
+
}
|
package/src/api/User.ts
CHANGED
|
@@ -858,31 +858,46 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
858
858
|
|
|
859
859
|
/**
|
|
860
860
|
* Vérifie si l'utilisateur connecté est ami avec cet utilisateur.
|
|
861
|
-
*
|
|
861
|
+
* @param options - Options de vérification.
|
|
862
|
+
* @param options.silent - Si `true`, retourne `false` au lieu de lever une exception. Par défaut `true`.
|
|
862
863
|
* @returns - True si l'utilisateur connecté est ami, sinon false.
|
|
863
864
|
* @throws {ApiError} - Si l'utilisateur n'est pas connecté.
|
|
864
865
|
*/
|
|
865
|
-
isFriend(): boolean {
|
|
866
|
-
|
|
867
|
-
|
|
866
|
+
isFriend(options?: { silent?: boolean }): boolean {
|
|
867
|
+
const silent = options?.silent ?? true;
|
|
868
|
+
try {
|
|
869
|
+
if (!this.isActingUser) {
|
|
870
|
+
throw new ApiError("Vous devez être connecté pour vérifier si vous êtes ami.", 401);
|
|
871
|
+
}
|
|
872
|
+
} catch (e) {
|
|
873
|
+
if (silent) return false;
|
|
874
|
+
throw e;
|
|
868
875
|
}
|
|
869
876
|
this._assertEntityType("citoyens");
|
|
870
877
|
const userLink = this._getLinkFromConnectedUser();
|
|
878
|
+
if(!userLink) return false;
|
|
871
879
|
return this._validateUserLink(userLink);
|
|
872
880
|
}
|
|
873
881
|
|
|
874
882
|
/**
|
|
875
883
|
* Vérifie si l'utilisateur suit l'entité.
|
|
876
|
-
*
|
|
884
|
+
* @param options - Options de vérification.
|
|
885
|
+
* @param options.silent - Si `true`, retourne `false` au lieu de lever une exception. Par défaut `true`.
|
|
877
886
|
* @returns - `true` si l'utilisateur suit l'entité, `false` sinon.
|
|
878
887
|
* @throws {ApiError}
|
|
879
888
|
*/
|
|
880
|
-
override isFollower(): boolean {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
889
|
+
override isFollower(options?: { silent?: boolean }): boolean {
|
|
890
|
+
const silent = options?.silent ?? true;
|
|
891
|
+
try {
|
|
892
|
+
if (!this.isActingUser) {
|
|
893
|
+
throw new ApiError("Vous devez être connecté pour vérifier si il vous suit.", 401);
|
|
894
|
+
}
|
|
895
|
+
if (!this.id) {
|
|
896
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
897
|
+
}
|
|
898
|
+
} catch (e) {
|
|
899
|
+
if (silent) return false;
|
|
900
|
+
throw e;
|
|
886
901
|
}
|
|
887
902
|
this._assertEntityType("citoyens");
|
|
888
903
|
return this._isLinked("followers");
|
|
@@ -890,16 +905,23 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
890
905
|
|
|
891
906
|
/**
|
|
892
907
|
* Vérifie si l'utilisateur est abonné à l'entité.
|
|
893
|
-
*
|
|
908
|
+
* @param options - Options de vérification.
|
|
909
|
+
* @param options.silent - Si `true`, retourne `false` au lieu de lever une exception. Par défaut `true`.
|
|
894
910
|
* @returns - `true` si l'utilisateur est abonné, `false` sinon.
|
|
895
911
|
* @throws {ApiError}
|
|
896
912
|
*/
|
|
897
|
-
override isFollowing(): boolean {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
913
|
+
override isFollowing(options?: { silent?: boolean }): boolean {
|
|
914
|
+
const silent = options?.silent ?? true;
|
|
915
|
+
try {
|
|
916
|
+
if (!this.isActingUser) {
|
|
917
|
+
throw new ApiError("Vous devez être connecté pour vérifier si vous le suivez.", 401);
|
|
918
|
+
}
|
|
919
|
+
if (!this.id) {
|
|
920
|
+
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
921
|
+
}
|
|
922
|
+
} catch (e) {
|
|
923
|
+
if (silent) return false;
|
|
924
|
+
throw e;
|
|
903
925
|
}
|
|
904
926
|
this._assertEntityType("citoyens");
|
|
905
927
|
return this._isLinked("follows");
|
package/src/api/UserApi.ts
CHANGED
|
@@ -83,7 +83,7 @@ export class UserApi {
|
|
|
83
83
|
throw new ApiError("User not connected", 401);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
this.client._logger.
|
|
86
|
+
this.client._logger.debug("UserApi", "meIsconnected", this.client.userId);
|
|
87
87
|
|
|
88
88
|
this.loggedUser = new User(
|
|
89
89
|
this.client,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GeoCoordinates, GeoPosition, IdObject } from "./common.js";
|
|
2
|
+
|
|
3
|
+
import type EJSONType from "../../EJSONType.js";
|
|
4
|
+
|
|
5
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
6
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
7
|
+
|
|
8
|
+
export interface ZoneItemNormalized {
|
|
9
|
+
_id: IdObject;
|
|
10
|
+
countryCode: string;
|
|
11
|
+
geo: GeoCoordinates;
|
|
12
|
+
geoPosition: GeoPosition;
|
|
13
|
+
level: string[];
|
|
14
|
+
name: string;
|
|
15
|
+
osmID?: string;
|
|
16
|
+
wikidataID?: string;
|
|
17
|
+
translateId: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ZoneItemJson {
|
|
22
|
+
id: string;
|
|
23
|
+
_id: ObjectID;
|
|
24
|
+
countryCode: string;
|
|
25
|
+
geo: GeoCoordinates;
|
|
26
|
+
geoPosition: GeoPosition;
|
|
27
|
+
level: string[];
|
|
28
|
+
name: string;
|
|
29
|
+
osmID?: string;
|
|
30
|
+
wikidataID?: string;
|
|
31
|
+
translateId: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|