@communecter/cocolight-api-client 1.0.154 → 1.0.156
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/1035.cocolight-api-client.browser.js +1 -1
- package/dist/1035.cocolight-api-client.cjs +1 -1
- package/dist/1483.cocolight-api-client.browser.js +1 -1
- package/dist/1483.cocolight-api-client.cjs +1 -1
- package/dist/1491.cocolight-api-client.browser.js +1 -1
- package/dist/1491.cocolight-api-client.cjs +1 -1
- package/dist/1494.cocolight-api-client.browser.js +1 -1
- package/dist/1494.cocolight-api-client.cjs +1 -1
- package/dist/1641.cocolight-api-client.browser.js +1 -1
- package/dist/1641.cocolight-api-client.cjs +1 -1
- package/dist/1678.cocolight-api-client.browser.js +1 -1
- package/dist/1678.cocolight-api-client.cjs +1 -1
- package/dist/2041.cocolight-api-client.browser.js +1 -1
- package/dist/2041.cocolight-api-client.cjs +1 -1
- package/dist/2302.cocolight-api-client.browser.js +1 -1
- package/dist/2302.cocolight-api-client.cjs +1 -1
- package/dist/2313.cocolight-api-client.browser.js +1 -1
- package/dist/2313.cocolight-api-client.cjs +1 -1
- package/dist/2379.cocolight-api-client.browser.js +1 -1
- package/dist/2379.cocolight-api-client.cjs +1 -1
- package/dist/2439.cocolight-api-client.browser.js +1 -1
- package/dist/2439.cocolight-api-client.cjs +1 -1
- package/dist/2594.cocolight-api-client.browser.js +1 -1
- package/dist/2594.cocolight-api-client.cjs +1 -1
- package/dist/2766.cocolight-api-client.browser.js +1 -1
- package/dist/2766.cocolight-api-client.cjs +1 -1
- package/dist/2812.cocolight-api-client.browser.js +1 -1
- package/dist/2812.cocolight-api-client.cjs +1 -1
- package/dist/2918.cocolight-api-client.browser.js +1 -1
- package/dist/2918.cocolight-api-client.cjs +1 -1
- package/dist/3028.cocolight-api-client.browser.js +1 -1
- package/dist/3028.cocolight-api-client.cjs +1 -1
- package/dist/3330.cocolight-api-client.browser.js +1 -1
- package/dist/3330.cocolight-api-client.cjs +1 -1
- package/dist/3371.cocolight-api-client.browser.js +1 -1
- package/dist/3371.cocolight-api-client.cjs +1 -1
- package/dist/3401.cocolight-api-client.browser.js +1 -1
- package/dist/3401.cocolight-api-client.cjs +1 -1
- package/dist/3516.cocolight-api-client.browser.js +1 -1
- package/dist/3516.cocolight-api-client.cjs +1 -1
- package/dist/3593.cocolight-api-client.browser.js +1 -1
- package/dist/3593.cocolight-api-client.cjs +1 -1
- package/dist/3764.cocolight-api-client.browser.js +1 -1
- package/dist/3764.cocolight-api-client.cjs +1 -1
- package/dist/3873.cocolight-api-client.browser.js +1 -1
- package/dist/3873.cocolight-api-client.cjs +1 -1
- package/dist/3911.cocolight-api-client.browser.js +1 -1
- package/dist/3911.cocolight-api-client.cjs +1 -1
- package/dist/4031.cocolight-api-client.browser.js +1 -1
- package/dist/4031.cocolight-api-client.cjs +1 -1
- package/dist/4152.cocolight-api-client.browser.js +1 -1
- package/dist/4152.cocolight-api-client.cjs +1 -1
- package/dist/4203.cocolight-api-client.browser.js +1 -1
- package/dist/4203.cocolight-api-client.cjs +1 -1
- package/dist/424.cocolight-api-client.browser.js +1 -1
- package/dist/424.cocolight-api-client.cjs +1 -1
- package/dist/435.cocolight-api-client.browser.js +1 -1
- package/dist/435.cocolight-api-client.cjs +1 -1
- package/dist/4402.cocolight-api-client.browser.js +1 -1
- package/dist/4402.cocolight-api-client.cjs +1 -1
- package/dist/4425.cocolight-api-client.browser.js +1 -1
- package/dist/4425.cocolight-api-client.cjs +1 -1
- package/dist/4472.cocolight-api-client.browser.js +1 -1
- package/dist/4472.cocolight-api-client.cjs +1 -1
- package/dist/4914.cocolight-api-client.browser.js +1 -1
- package/dist/4914.cocolight-api-client.cjs +1 -1
- package/dist/4959.cocolight-api-client.browser.js +1 -1
- package/dist/4959.cocolight-api-client.cjs +1 -1
- package/dist/5100.cocolight-api-client.browser.js +1 -1
- package/dist/5100.cocolight-api-client.cjs +1 -1
- package/dist/5111.cocolight-api-client.browser.js +1 -1
- package/dist/5111.cocolight-api-client.cjs +1 -1
- package/dist/5286.cocolight-api-client.browser.js +1 -1
- package/dist/5286.cocolight-api-client.cjs +1 -1
- package/dist/5380.cocolight-api-client.browser.js +1 -1
- package/dist/5380.cocolight-api-client.cjs +1 -1
- package/dist/5383.cocolight-api-client.browser.js +1 -1
- package/dist/5383.cocolight-api-client.cjs +1 -1
- package/dist/5480.cocolight-api-client.browser.js +1 -1
- package/dist/5480.cocolight-api-client.cjs +1 -1
- package/dist/5541.cocolight-api-client.browser.js +1 -1
- package/dist/5541.cocolight-api-client.cjs +1 -1
- package/dist/5839.cocolight-api-client.browser.js +1 -1
- package/dist/5839.cocolight-api-client.cjs +1 -1
- package/dist/5862.cocolight-api-client.browser.js +1 -1
- package/dist/5862.cocolight-api-client.cjs +1 -1
- package/dist/5869.cocolight-api-client.browser.js +1 -1
- package/dist/5869.cocolight-api-client.cjs +1 -1
- package/dist/588.cocolight-api-client.browser.js +1 -1
- package/dist/588.cocolight-api-client.cjs +1 -1
- package/dist/601.cocolight-api-client.browser.js +1 -1
- package/dist/601.cocolight-api-client.cjs +1 -1
- package/dist/6012.cocolight-api-client.browser.js +1 -1
- package/dist/6012.cocolight-api-client.cjs +1 -1
- package/dist/6200.cocolight-api-client.browser.js +1 -1
- package/dist/6200.cocolight-api-client.cjs +1 -1
- package/dist/6369.cocolight-api-client.browser.js +1 -1
- package/dist/6369.cocolight-api-client.cjs +1 -1
- package/dist/7009.cocolight-api-client.browser.js +1 -1
- package/dist/7009.cocolight-api-client.cjs +1 -1
- package/dist/725.cocolight-api-client.browser.js +1 -1
- package/dist/725.cocolight-api-client.cjs +1 -1
- package/dist/7320.cocolight-api-client.browser.js +1 -1
- package/dist/7339.cocolight-api-client.browser.js +1 -1
- package/dist/7339.cocolight-api-client.cjs +1 -1
- package/dist/7398.cocolight-api-client.browser.js +1 -1
- package/dist/7398.cocolight-api-client.cjs +1 -1
- package/dist/7888.cocolight-api-client.browser.js +1 -1
- package/dist/7888.cocolight-api-client.cjs +1 -1
- package/dist/7975.cocolight-api-client.browser.js +1 -1
- package/dist/7975.cocolight-api-client.cjs +1 -1
- package/dist/809.cocolight-api-client.browser.js +1 -1
- package/dist/809.cocolight-api-client.cjs +1 -1
- package/dist/8300.cocolight-api-client.browser.js +1 -1
- package/dist/8300.cocolight-api-client.cjs +1 -1
- package/dist/8317.cocolight-api-client.browser.js +1 -1
- package/dist/8317.cocolight-api-client.cjs +1 -1
- package/dist/8525.cocolight-api-client.browser.js +1 -1
- package/dist/8525.cocolight-api-client.cjs +1 -1
- package/dist/8894.cocolight-api-client.browser.js +1 -1
- package/dist/8894.cocolight-api-client.cjs +1 -1
- package/dist/9301.cocolight-api-client.browser.js +1 -1
- package/dist/9301.cocolight-api-client.cjs +1 -1
- package/dist/9438.cocolight-api-client.browser.js +1 -1
- package/dist/9438.cocolight-api-client.cjs +1 -1
- package/dist/9478.cocolight-api-client.browser.js +1 -1
- package/dist/9478.cocolight-api-client.cjs +1 -1
- package/dist/9568.cocolight-api-client.browser.js +1 -1
- package/dist/9568.cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.browser.js +6 -6
- package/dist/cocolight-api-client.cjs +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 +7 -17
- package/types/Api.d.ts +1 -0
- package/types/ApiClient.d.ts +10 -1
- package/types/api/BaseEntity.d.ts +24 -0
- package/types/api/EndpointApi.d.ts +4 -4
- package/types/api/EndpointApi.types.d.ts +3 -3
- package/types/utils/OfflineClientManager.d.ts +8 -0
- package/dist/1035.cocolight-api-client.mjs.js +0 -1
- package/dist/1483.cocolight-api-client.mjs.js +0 -1
- package/dist/1491.cocolight-api-client.mjs.js +0 -1
- package/dist/1494.cocolight-api-client.mjs.js +0 -1
- package/dist/1641.cocolight-api-client.mjs.js +0 -1
- package/dist/1678.cocolight-api-client.mjs.js +0 -1
- package/dist/2041.cocolight-api-client.mjs.js +0 -1
- package/dist/2302.cocolight-api-client.mjs.js +0 -1
- package/dist/2313.cocolight-api-client.mjs.js +0 -1
- package/dist/2379.cocolight-api-client.mjs.js +0 -1
- package/dist/2439.cocolight-api-client.mjs.js +0 -1
- package/dist/2594.cocolight-api-client.mjs.js +0 -1
- package/dist/2766.cocolight-api-client.mjs.js +0 -1
- package/dist/2812.cocolight-api-client.mjs.js +0 -1
- package/dist/2918.cocolight-api-client.mjs.js +0 -1
- package/dist/3028.cocolight-api-client.mjs.js +0 -1
- package/dist/3330.cocolight-api-client.mjs.js +0 -1
- package/dist/3371.cocolight-api-client.mjs.js +0 -1
- package/dist/3401.cocolight-api-client.mjs.js +0 -1
- package/dist/3516.cocolight-api-client.mjs.js +0 -1
- package/dist/3593.cocolight-api-client.mjs.js +0 -1
- package/dist/3764.cocolight-api-client.mjs.js +0 -1
- package/dist/3873.cocolight-api-client.mjs.js +0 -1
- package/dist/3911.cocolight-api-client.mjs.js +0 -1
- package/dist/4031.cocolight-api-client.mjs.js +0 -1
- package/dist/4152.cocolight-api-client.mjs.js +0 -1
- package/dist/4203.cocolight-api-client.mjs.js +0 -1
- package/dist/424.cocolight-api-client.mjs.js +0 -1
- package/dist/435.cocolight-api-client.mjs.js +0 -1
- package/dist/4402.cocolight-api-client.mjs.js +0 -1
- package/dist/4425.cocolight-api-client.mjs.js +0 -1
- package/dist/4472.cocolight-api-client.mjs.js +0 -1
- package/dist/4914.cocolight-api-client.mjs.js +0 -1
- package/dist/4959.cocolight-api-client.mjs.js +0 -1
- package/dist/5100.cocolight-api-client.mjs.js +0 -1
- package/dist/5111.cocolight-api-client.mjs.js +0 -1
- package/dist/5286.cocolight-api-client.mjs.js +0 -1
- package/dist/5380.cocolight-api-client.mjs.js +0 -1
- package/dist/5383.cocolight-api-client.mjs.js +0 -1
- package/dist/5480.cocolight-api-client.mjs.js +0 -1
- package/dist/5541.cocolight-api-client.mjs.js +0 -1
- package/dist/5839.cocolight-api-client.mjs.js +0 -1
- package/dist/5862.cocolight-api-client.mjs.js +0 -1
- package/dist/5869.cocolight-api-client.mjs.js +0 -1
- package/dist/588.cocolight-api-client.mjs.js +0 -1
- package/dist/601.cocolight-api-client.mjs.js +0 -1
- package/dist/6012.cocolight-api-client.mjs.js +0 -1
- package/dist/6200.cocolight-api-client.mjs.js +0 -1
- package/dist/6369.cocolight-api-client.mjs.js +0 -1
- package/dist/7009.cocolight-api-client.mjs.js +0 -1
- package/dist/725.cocolight-api-client.mjs.js +0 -1
- package/dist/7339.cocolight-api-client.mjs.js +0 -1
- package/dist/7398.cocolight-api-client.mjs.js +0 -1
- package/dist/7888.cocolight-api-client.mjs.js +0 -1
- package/dist/7975.cocolight-api-client.mjs.js +0 -1
- package/dist/809.cocolight-api-client.mjs.js +0 -1
- package/dist/8300.cocolight-api-client.mjs.js +0 -1
- package/dist/8317.cocolight-api-client.mjs.js +0 -1
- package/dist/8525.cocolight-api-client.mjs.js +0 -1
- package/dist/8894.cocolight-api-client.mjs.js +0 -1
- package/dist/9301.cocolight-api-client.mjs.js +0 -1
- package/dist/9438.cocolight-api-client.mjs.js +0 -1
- package/dist/9478.cocolight-api-client.mjs.js +0 -1
- package/dist/9568.cocolight-api-client.mjs.js +0 -1
- package/dist/cocolight-api-client.mjs.js +0 -1
- package/src/Api.ts +0 -348
- package/src/ApiClient.ts +0 -1994
- package/src/EJSONType.ts +0 -103
- package/src/api/Action.ts +0 -665
- package/src/api/Answer.ts +0 -1392
- package/src/api/Badge.ts +0 -143
- package/src/api/BaseEntity.ts +0 -6338
- package/src/api/Classified.ts +0 -175
- package/src/api/Comment.ts +0 -280
- package/src/api/EndpointApi.ts +0 -2270
- package/src/api/EndpointApi.types.ts +0 -6566
- package/src/api/EntityRegistry.ts +0 -324
- package/src/api/Event.ts +0 -360
- package/src/api/Form.ts +0 -282
- package/src/api/News.ts +0 -547
- package/src/api/Notifications.ts +0 -196
- package/src/api/Organization.ts +0 -771
- package/src/api/Poi.ts +0 -242
- package/src/api/Project.ts +0 -545
- package/src/api/User.ts +0 -1889
- package/src/api/UserApi.ts +0 -192
- package/src/api/serverDataType/Action.ts +0 -177
- package/src/api/serverDataType/Answer.ts +0 -106
- package/src/api/serverDataType/Classified.ts +0 -152
- package/src/api/serverDataType/Comment.ts +0 -88
- package/src/api/serverDataType/Country.ts +0 -1
- package/src/api/serverDataType/Event.ts +0 -112
- package/src/api/serverDataType/Form.ts +0 -157
- package/src/api/serverDataType/News.ts +0 -138
- package/src/api/serverDataType/Notification.ts +0 -81
- package/src/api/serverDataType/Organization.ts +0 -111
- package/src/api/serverDataType/Poi.ts +0 -75
- package/src/api/serverDataType/Project.ts +0 -115
- package/src/api/serverDataType/User.ts +0 -112
- package/src/api/serverDataType/Zone.ts +0 -33
- package/src/api/serverDataType/common.ts +0 -84
- package/src/costum/normalize.ts +0 -7
- package/src/costum/registry.ts +0 -138
- package/src/costum/runtime-map.ts +0 -221
- package/src/costum/runtime.ts +0 -274
- package/src/costum/schemas/CercleTravailleursSociauxLiberauxLaPlumeSociale.ts +0 -19
- package/src/costum/schemas/FabEn.ts +0 -19
- package/src/costum/schemas/LivingLabInnovationSocialeBraspanon.ts +0 -19
- package/src/costum/schemas/alfph.ts +0 -27
- package/src/costum/schemas/campagne.ts +0 -19
- package/src/costum/schemas/chtitube.ts +0 -19
- package/src/costum/schemas/circuitCourt.ts +0 -19
- package/src/costum/schemas/cmcasHauteBretagne.ts +0 -19
- package/src/costum/schemas/coFinancementTierslieux.ts +0 -27
- package/src/costum/schemas/coeurNumerique.ts +0 -19
- package/src/costum/schemas/communLundi.ts +0 -19
- package/src/costum/schemas/cressReunion.ts +0 -35
- package/src/costum/schemas/cressReunionNetwork.ts +0 -35
- package/src/costum/schemas/ctenat.ts +0 -43
- package/src/costum/schemas/cyberReunion.ts +0 -19
- package/src/costum/schemas/ekisphere.ts +0 -35
- package/src/costum/schemas/equipementsSportifs974.ts +0 -19
- package/src/costum/schemas/federationDesCae.ts +0 -19
- package/src/costum/schemas/formationGenerique.ts +0 -35
- package/src/costum/schemas/franceTierslieux.ts +0 -19
- package/src/costum/schemas/hinaura.ts +0 -27
- package/src/costum/schemas/hubmayotte.ts +0 -19
- package/src/costum/schemas/hubnouvellecaledonie.ts +0 -19
- package/src/costum/schemas/hubpolynesiefrancaise.ts +0 -19
- package/src/costum/schemas/hubreunion.ts +0 -19
- package/src/costum/schemas/hubterritoires.ts +0 -19
- package/src/costum/schemas/hubwallisetfutuna.ts +0 -19
- package/src/costum/schemas/hva.ts +0 -27
- package/src/costum/schemas/ibv2.ts +0 -19
- package/src/costum/schemas/institutBleu.ts +0 -19
- package/src/costum/schemas/journalInsoumisChambery.ts +0 -27
- package/src/costum/schemas/kpacite.ts +0 -19
- package/src/costum/schemas/laCompagnieDesTierslieux.ts +0 -43
- package/src/costum/schemas/laMaisonDesFaiseurs.ts +0 -19
- package/src/costum/schemas/laReunionPourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/laSemaineDesTierslieux.ts +0 -19
- package/src/costum/schemas/labEnCommuns.ts +0 -19
- package/src/costum/schemas/lakou.ts +0 -27
- package/src/costum/schemas/lesCommunsDesTierslieux.ts +0 -19
- package/src/costum/schemas/mayottePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/meir.ts +0 -27
- package/src/costum/schemas/navigatorDesTierslieux.ts +0 -19
- package/src/costum/schemas/notragora.ts +0 -27
- package/src/costum/schemas/nouvellecaledoniePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/openAtlas.ts +0 -19
- package/src/costum/schemas/polynesieFrancaisePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/prdr.ts +0 -19
- package/src/costum/schemas/reseauTierslieux.ts +0 -19
- package/src/costum/schemas/rfflabs.ts +0 -19
- package/src/costum/schemas/ries.ts +0 -19
- package/src/costum/schemas/siteDuPactePourLaTransition.ts +0 -27
- package/src/costum/schemas/sportSanteBienetre.ts +0 -43
- package/src/costum/schemas/suppa.ts +0 -19
- package/src/costum/schemas/terramies.ts +0 -19
- package/src/costum/schemas/testeTplFormation.ts +0 -35
- package/src/costum/schemas/tierslieuxbelgique.ts +0 -19
- package/src/costum/schemas/tierslieuxorg1.ts +0 -35
- package/src/costum/schemas/transiter.ts +0 -35
- package/src/costum/schemas/vhelioPeiTour2025.ts +0 -19
- package/src/costum/schemas/wallisetfutunaPourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/symbol.ts +0 -26
- package/src/costum/types.ts +0 -895
- package/src/endpoints.module.ts +0 -4253
- package/src/error.ts +0 -86
- package/src/forms/entityForm.ts +0 -142
- package/src/index.ts +0 -161
- package/src/mixin/UserMixin.ts +0 -4
- package/src/types/api-responses.ts +0 -217
- package/src/types/entities.ts +0 -58
- package/src/types/error-guards.ts +0 -230
- package/src/types/index.ts +0 -41
- package/src/types/payloads.ts +0 -21
- package/src/types/transforms.ts +0 -119
- package/src/utils/FileOfflineStorageStrategy.node.ts +0 -50
- package/src/utils/FileStorageStrategy.node.ts +0 -63
- package/src/utils/MultiServerFileStorageStrategy.node.ts +0 -67
- package/src/utils/MultiServerTokenStorageStrategy.ts +0 -139
- package/src/utils/OfflineClientManager.ts +0 -216
- package/src/utils/OfflineQueueStorageStrategy.ts +0 -47
- package/src/utils/TokenStorage.ts +0 -77
- package/src/utils/compat.ts +0 -12
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +0 -35
- package/src/utils/createDefaultOfflineStrategy.ts +0 -34
- package/src/utils/createDefaultTokenStorageStrategy.ts +0 -33
- package/src/utils/reactive.ts +0 -243
- package/src/utils/stream-utils.node.ts +0 -12
package/src/Api.ts
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
// Api.ts
|
|
2
|
-
import { Action } from "./api/Action.js";
|
|
3
|
-
import { Answer } from "./api/Answer.js";
|
|
4
|
-
import { Badge } from "./api/Badge.js";
|
|
5
|
-
import { Classified } from "./api/Classified.js";
|
|
6
|
-
import { Comment } from "./api/Comment.js";
|
|
7
|
-
import EndpointApi from "./api/EndpointApi.js";
|
|
8
|
-
import { createFromCollection, registerEntity } from "./api/EntityRegistry.js";
|
|
9
|
-
import { Event } from "./api/Event.js";
|
|
10
|
-
import { Form } from "./api/Form.js";
|
|
11
|
-
import { News } from "./api/News.js";
|
|
12
|
-
import { Organization } from "./api/Organization.js";
|
|
13
|
-
import { Poi } from "./api/Poi.js";
|
|
14
|
-
import { Project } from "./api/Project.js";
|
|
15
|
-
import { User } from "./api/User.js";
|
|
16
|
-
import { UserApi } from "./api/UserApi.js";
|
|
17
|
-
import { ApiAuthenticationError, ApiClientError, ApiError, ApiResponseError } from "./error.js";
|
|
18
|
-
|
|
19
|
-
import type { SearchTagsData } from "./api/EndpointApi.types.js";
|
|
20
|
-
import type ApiClient from "./ApiClient.js";
|
|
21
|
-
import type { ApiClientOptions } from "./ApiClient.js";
|
|
22
|
-
import type { GetElementsKeyResponse } from "./types/api-responses.js";
|
|
23
|
-
import type { EntityData, EntityTypes } from "./types/entities.js";
|
|
24
|
-
|
|
25
|
-
registerEntity("User", User);
|
|
26
|
-
registerEntity("Organization", Organization);
|
|
27
|
-
registerEntity("Project", Project);
|
|
28
|
-
registerEntity("Event", Event);
|
|
29
|
-
registerEntity("Poi", Poi);
|
|
30
|
-
registerEntity("Badge", Badge);
|
|
31
|
-
registerEntity("EndpointApi", EndpointApi);
|
|
32
|
-
// registerEntity("UserApi", UserApi);
|
|
33
|
-
registerEntity("News", News);
|
|
34
|
-
registerEntity("Comment", Comment);
|
|
35
|
-
registerEntity("Answer", Answer);
|
|
36
|
-
registerEntity("Form", Form);
|
|
37
|
-
registerEntity("Classified", Classified);
|
|
38
|
-
registerEntity("Action", Action);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export default class Api {
|
|
43
|
-
private _loggedUser: User | null;
|
|
44
|
-
private _client: ApiClient;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Authentifie l'utilisateur et retourne une instance d'Api.
|
|
48
|
-
*/
|
|
49
|
-
static async userLogin(
|
|
50
|
-
email: string,
|
|
51
|
-
password: string,
|
|
52
|
-
options: ApiClientOptions | ApiClient
|
|
53
|
-
): Promise<Api> {
|
|
54
|
-
const userApi = Api.userApi(options);
|
|
55
|
-
return await Api.userApiLogin(userApi, email, password);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Crée une instance de UserApi avec les options fournies.
|
|
60
|
-
*/
|
|
61
|
-
static userApi(options: ApiClientOptions | ApiClient): UserApi {
|
|
62
|
-
try {
|
|
63
|
-
const userApi = new UserApi(options);
|
|
64
|
-
return userApi;
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :", (error as Error).message);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Connecte un utilisateur avec un UserApi existant.
|
|
73
|
-
*/
|
|
74
|
-
static async userApiLogin(
|
|
75
|
-
userApi: UserApi,
|
|
76
|
-
email: string,
|
|
77
|
-
password: string
|
|
78
|
-
): Promise<Api> {
|
|
79
|
-
try {
|
|
80
|
-
|
|
81
|
-
if (!userApi) {
|
|
82
|
-
throw new ApiError("userApi is not defined", 500);
|
|
83
|
-
}
|
|
84
|
-
if(!userApi.client) {
|
|
85
|
-
throw new ApiError("userApi.client is not defined", 500);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if(userApi.client.isConnected) {
|
|
89
|
-
// Si l'utilisateur est déjà connecté, on le récupère
|
|
90
|
-
// et on ne fait pas de login
|
|
91
|
-
const loggedUser = await userApi.meIsconnected();
|
|
92
|
-
return new Api(loggedUser, userApi.client);
|
|
93
|
-
} else {
|
|
94
|
-
if (!email || !password) {
|
|
95
|
-
throw new ApiError("email and password are required", 400);
|
|
96
|
-
}
|
|
97
|
-
const loggedUser = await userApi.login(email, password);
|
|
98
|
-
return new Api(loggedUser, userApi.client);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
} catch (error) {
|
|
102
|
-
if(error instanceof ApiClientError) {
|
|
103
|
-
if(error?.details?.error) {
|
|
104
|
-
throw new ApiAuthenticationError(error.details.error, error.status, error.details);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Construit une instance d'Api.
|
|
113
|
-
*/
|
|
114
|
-
constructor(loggedUser: User | null, client: ApiClient) {
|
|
115
|
-
this._loggedUser = loggedUser;
|
|
116
|
-
this._client = client;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Retourne l'utilisateur connecté.
|
|
121
|
-
*/
|
|
122
|
-
async me(): Promise<User> {
|
|
123
|
-
if (!this._loggedUser) {
|
|
124
|
-
throw new ApiAuthenticationError("Accès refusé : utilisateur non authentifié.", 401);
|
|
125
|
-
}
|
|
126
|
-
await this._loggedUser.get();
|
|
127
|
-
return this._loggedUser;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Crée une instance User (autre que le connecté).
|
|
132
|
-
*/
|
|
133
|
-
async user(userData: EntityData): Promise<User> {
|
|
134
|
-
try {
|
|
135
|
-
if (!userData.id && !userData.slug) {
|
|
136
|
-
return new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
137
|
-
} else {
|
|
138
|
-
const user = new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
139
|
-
await user.get();
|
|
140
|
-
return user;
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :", (error as Error).message);
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Creates an Organization object and optionally retrieves its profile.
|
|
151
|
-
*/
|
|
152
|
-
async organization(organizationData: EntityData): Promise<Organization> {
|
|
153
|
-
try {
|
|
154
|
-
const organization = new Organization(this._client, organizationData, { EndpointApi, User, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
155
|
-
if (!organizationData.id && !organizationData.slug) {
|
|
156
|
-
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");
|
|
157
|
-
}
|
|
158
|
-
await organization.get();
|
|
159
|
-
return organization;
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.error("[Api.organization] Erreur lors de la création d'un objet organisation :", (error as Error).message);
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Creates a new Project instance and optionally retrieves its profile.
|
|
168
|
-
*/
|
|
169
|
-
async project(projectData: EntityData): Promise<Project> {
|
|
170
|
-
try {
|
|
171
|
-
const project = new Project(this._client, projectData, { EndpointApi, User, Organization, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
172
|
-
if (!projectData.id && !projectData.slug) {
|
|
173
|
-
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");
|
|
174
|
-
}
|
|
175
|
-
await project.get();
|
|
176
|
-
return project;
|
|
177
|
-
} catch (error) {
|
|
178
|
-
console.error("[Api.project] Erreur lors de la création d'un objet projet :", (error as Error).message);
|
|
179
|
-
throw error;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Creates a new Event instance and optionally retrieves its profile.
|
|
185
|
-
*/
|
|
186
|
-
async event(eventData: EntityData): Promise<Event> {
|
|
187
|
-
try {
|
|
188
|
-
const event = new Event(this._client, eventData, { EndpointApi, User, Organization, Project, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
189
|
-
if (!eventData.id && !eventData.slug) {
|
|
190
|
-
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Event.");
|
|
191
|
-
}
|
|
192
|
-
await event.get();
|
|
193
|
-
return event;
|
|
194
|
-
} catch (error) {
|
|
195
|
-
console.error("[Api.event] Erreur lors de la création d'un objet événement :", (error as Error).message);
|
|
196
|
-
throw error;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Creates a new Poi instance and optionally retrieves its profile.
|
|
202
|
-
*/
|
|
203
|
-
async poi(poiData: EntityData): Promise<Poi> {
|
|
204
|
-
try {
|
|
205
|
-
const poi = new Poi(this._client, poiData, { EndpointApi, User, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
206
|
-
if (!poiData.id && !poiData.slug) {
|
|
207
|
-
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Poi.");
|
|
208
|
-
}
|
|
209
|
-
await poi.get();
|
|
210
|
-
return poi;
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error("[Api.poi] Erreur lors de la création d'un objet poi :", (error as Error).message);
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Creates a new Answer instance and optionally retrieves answer data.
|
|
219
|
-
*/
|
|
220
|
-
async answer(answerData: { id: string }): Promise<Answer> {
|
|
221
|
-
try {
|
|
222
|
-
const answer = new Answer(this._client, answerData, { EndpointApi, User, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
223
|
-
if (!answerData.id) {
|
|
224
|
-
throw new Error("Vous devez fournir un id pour créer une instance Answer.");
|
|
225
|
-
}
|
|
226
|
-
await answer.get();
|
|
227
|
-
return answer;
|
|
228
|
-
} catch (error) {
|
|
229
|
-
console.error("[Api.answer] Erreur lors de la création d'un objet Answer :", (error as Error).message);
|
|
230
|
-
throw error;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Creates a new Form instance and optionally retrieves form data.
|
|
236
|
-
*/
|
|
237
|
-
async form(formData: { id: string }): Promise<Form> {
|
|
238
|
-
try {
|
|
239
|
-
const form = new Form(this._client, formData, { EndpointApi, User, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
240
|
-
if (!formData.id) {
|
|
241
|
-
throw new Error("Vous devez fournir un id pour créer une instance Form.");
|
|
242
|
-
}
|
|
243
|
-
await form.get();
|
|
244
|
-
return form;
|
|
245
|
-
} catch (error) {
|
|
246
|
-
console.error("[Api.form] Erreur lors de la création d'un objet Form :", (error as Error).message);
|
|
247
|
-
throw error;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async classified(classifiedData: EntityData): Promise<Classified> {
|
|
252
|
-
try {
|
|
253
|
-
const classified = new Classified(this._client, classifiedData, { EndpointApi, User, Organization, Project, Event, Poi, Badge, News, Comment, Answer, Form, Classified, Action });
|
|
254
|
-
if (!classifiedData.id && !classifiedData.slug) {
|
|
255
|
-
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Classified.");
|
|
256
|
-
}
|
|
257
|
-
await classified.get();
|
|
258
|
-
return classified;
|
|
259
|
-
} catch (error) {
|
|
260
|
-
console.error("[Api.classified] Erreur lors de la création d'un objet Classified :", (error as Error).message);
|
|
261
|
-
throw error;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Retourne une entité à partir d'un slug.
|
|
267
|
-
*/
|
|
268
|
-
async entitySlug(slug: string): Promise<EntityTypes> {
|
|
269
|
-
if (!slug) {
|
|
270
|
-
throw new ApiError("slug requis", 400);
|
|
271
|
-
}
|
|
272
|
-
try {
|
|
273
|
-
const data = await this.endpointApi.getElementsKey({
|
|
274
|
-
pathParams:{
|
|
275
|
-
slug: slug
|
|
276
|
-
}
|
|
277
|
-
}) as GetElementsKeyResponse;
|
|
278
|
-
|
|
279
|
-
if(data.contextId && data.contextType) {
|
|
280
|
-
const entity = createFromCollection(data.contextType, this._client, { id: data.contextId });
|
|
281
|
-
if (!entity) {
|
|
282
|
-
throw new ApiResponseError(`Le type d'entité pour le slug ${slug} n'est pas reconnu`, 200, data as object);
|
|
283
|
-
}
|
|
284
|
-
await entity.get();
|
|
285
|
-
// On sait que c'est l'un des types concrets → on caste
|
|
286
|
-
return entity as EntityTypes;
|
|
287
|
-
} else {
|
|
288
|
-
throw new ApiResponseError(`Le slug ${slug} n'est pas valide`, 200, data as object);
|
|
289
|
-
}
|
|
290
|
-
} catch (error) {
|
|
291
|
-
if(error instanceof ApiResponseError) {
|
|
292
|
-
throw new ApiResponseError(`Impossible de récupérer l'identifiant pour le slug ${slug}`, error.status, error.responseData);
|
|
293
|
-
} else {
|
|
294
|
-
throw error;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Retourne l'instance d'ApiClient.
|
|
302
|
-
*/
|
|
303
|
-
get client(): ApiClient {
|
|
304
|
-
return this._client;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Retourne l'instance d'EndpointApi.
|
|
309
|
-
*/
|
|
310
|
-
get endpointApi(): EndpointApi {
|
|
311
|
-
return new EndpointApi(this._client);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Recherche des tags correspondant à un mot-clé.
|
|
316
|
-
*
|
|
317
|
-
* Wrap de `SEARCH_TAGS` (auth=none) — accessible même non connecté.
|
|
318
|
-
* Méthode exposée sur la facade `Api` (pas d'entité hôte naturelle pour
|
|
319
|
-
* un index global de tags).
|
|
320
|
-
*
|
|
321
|
-
* @param q - Mot-clé de recherche (au moins 1 caractère).
|
|
322
|
-
* @returns Tableau de résultats : soit `[{tag}]` si aucun match (echo du
|
|
323
|
-
* terme), soit `[{_id, tag, field_length}, ...]` avec les tags
|
|
324
|
-
* existants triés par `field_length`.
|
|
325
|
-
* @throws {ApiError} 400 si `q` vide.
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* const results = await api.searchTags("permac");
|
|
329
|
-
* results.forEach(t => console.log(t.tag, t.field_length));
|
|
330
|
-
*/
|
|
331
|
-
async searchTags(q: string): Promise<unknown> {
|
|
332
|
-
if (typeof q !== "string" || q.length === 0) {
|
|
333
|
-
throw new ApiError("Le mot-clé `q` est requis pour searchTags.", 400);
|
|
334
|
-
}
|
|
335
|
-
const payload: SearchTagsData = { pathParams: { q } };
|
|
336
|
-
return this.endpointApi.searchTags(payload);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Déconnecte l'utilisateur et réinitialise la session.
|
|
341
|
-
*/
|
|
342
|
-
logout(): void {
|
|
343
|
-
this._loggedUser = null;
|
|
344
|
-
this._client.resetSession();
|
|
345
|
-
this._client._logger.info("UserApi: User logged out");
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
}
|