@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
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
// types/error-guards.ts - Type guards et utilitaires pour la gestion d'erreurs
|
|
2
|
-
|
|
3
|
-
import { ApiError, ApiClientError, ApiResponseError, ApiValidationError, ApiAuthenticationError, CircuitBreakerError } from "../error.js";
|
|
4
|
-
|
|
5
|
-
import type { ApiErrorDetails, HttpStatusCode } from "./api-responses.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Type guard pour vérifier si une valeur est une Error
|
|
9
|
-
*/
|
|
10
|
-
export function isError(value: unknown): value is Error {
|
|
11
|
-
return value instanceof Error;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Type guard pour vérifier si une valeur est une ApiError
|
|
16
|
-
*/
|
|
17
|
-
export function isApiError(value: unknown): value is ApiError {
|
|
18
|
-
return value instanceof ApiError;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Type guard pour vérifier si une valeur est une ApiClientError
|
|
23
|
-
*/
|
|
24
|
-
export function isApiClientError(value: unknown): value is ApiClientError {
|
|
25
|
-
return value instanceof ApiClientError;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Type guard pour vérifier si une valeur est une ApiResponseError
|
|
30
|
-
*/
|
|
31
|
-
export function isApiResponseError(value: unknown): value is ApiResponseError {
|
|
32
|
-
return value instanceof ApiResponseError;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Type guard pour vérifier si une valeur est une ApiValidationError
|
|
37
|
-
*/
|
|
38
|
-
export function isApiValidationError(value: unknown): value is ApiValidationError {
|
|
39
|
-
return value instanceof ApiValidationError;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Type guard pour vérifier si une valeur est une ApiAuthenticationError
|
|
44
|
-
*/
|
|
45
|
-
export function isApiAuthenticationError(value: unknown): value is ApiAuthenticationError {
|
|
46
|
-
return value instanceof ApiAuthenticationError;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Type guard pour vérifier si une valeur est une CircuitBreakerError
|
|
51
|
-
*/
|
|
52
|
-
export function isCircuitBreakerError(value: unknown): value is CircuitBreakerError {
|
|
53
|
-
return value instanceof CircuitBreakerError;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Type guard pour vérifier si une erreur a une propriété response (erreurs axios)
|
|
58
|
-
*/
|
|
59
|
-
export function hasResponse(error: unknown): error is Error & { response: { status: number; data: any } } {
|
|
60
|
-
return isError(error) && "response" in error &&
|
|
61
|
-
typeof (error as any).response === "object" &&
|
|
62
|
-
typeof (error as any).response.status === "number";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Type guard pour vérifier si une erreur a un code de statut HTTP
|
|
67
|
-
*/
|
|
68
|
-
export function hasStatusCode(error: unknown): error is Error & { status: HttpStatusCode } {
|
|
69
|
-
return isError(error) && "status" in error &&
|
|
70
|
-
typeof (error as any).status === "number";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Utilitaire pour extraire le message d'erreur de façon type-safe
|
|
75
|
-
*/
|
|
76
|
-
export function getErrorMessage(error: unknown): string {
|
|
77
|
-
if (isError(error)) {
|
|
78
|
-
return error.message;
|
|
79
|
-
}
|
|
80
|
-
if (typeof error === "string") {
|
|
81
|
-
return error;
|
|
82
|
-
}
|
|
83
|
-
if (error && typeof error === "object" && "message" in error) {
|
|
84
|
-
return String((error as any).message);
|
|
85
|
-
}
|
|
86
|
-
return "Unknown error";
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Utilitaire pour extraire le code de statut d'une erreur
|
|
91
|
-
*/
|
|
92
|
-
export function getErrorStatusCode(error: unknown): HttpStatusCode | undefined {
|
|
93
|
-
if (hasStatusCode(error)) {
|
|
94
|
-
return error.status as HttpStatusCode;
|
|
95
|
-
}
|
|
96
|
-
if (hasResponse(error)) {
|
|
97
|
-
return error.response.status as HttpStatusCode;
|
|
98
|
-
}
|
|
99
|
-
if (isApiError(error)) {
|
|
100
|
-
return error.status as HttpStatusCode;
|
|
101
|
-
}
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Utilitaire pour extraire les détails d'erreur de façon type-safe
|
|
107
|
-
*/
|
|
108
|
-
export function getErrorDetails(error: unknown): ApiErrorDetails | undefined {
|
|
109
|
-
if (isApiError(error)) {
|
|
110
|
-
return {
|
|
111
|
-
code: error.status as HttpStatusCode,
|
|
112
|
-
message: error.message,
|
|
113
|
-
details: (error as any).responseData
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (hasResponse(error)) {
|
|
118
|
-
return {
|
|
119
|
-
code: error.response.status as HttpStatusCode,
|
|
120
|
-
message: getErrorMessage(error),
|
|
121
|
-
details: error.response.data
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const status = getErrorStatusCode(error);
|
|
126
|
-
if (status) {
|
|
127
|
-
return {
|
|
128
|
-
code: status,
|
|
129
|
-
message: getErrorMessage(error)
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Utilitaire pour créer une erreur typée
|
|
138
|
-
*/
|
|
139
|
-
export function createTypedError(message: string, status: HttpStatusCode = 500, details?: any): ApiError {
|
|
140
|
-
return new ApiError(message, status, details);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Wrapper pour les fonctions qui peuvent lever des erreurs
|
|
145
|
-
*/
|
|
146
|
-
export async function safeCall<T>(
|
|
147
|
-
fn: () => Promise<T>,
|
|
148
|
-
fallback?: T
|
|
149
|
-
): Promise<{ data: T; error: null } | { data: T | undefined; error: ApiErrorDetails }> {
|
|
150
|
-
try {
|
|
151
|
-
const data = await fn();
|
|
152
|
-
return { data, error: null };
|
|
153
|
-
} catch (error) {
|
|
154
|
-
const errorDetails = getErrorDetails(error);
|
|
155
|
-
return {
|
|
156
|
-
data: fallback,
|
|
157
|
-
error: errorDetails || {
|
|
158
|
-
code: 500,
|
|
159
|
-
message: getErrorMessage(error)
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Type pour les résultats d'opérations sécurisées
|
|
167
|
-
*/
|
|
168
|
-
export type SafeResult<T> =
|
|
169
|
-
| { success: true; data: T; error: null }
|
|
170
|
-
| { success: false; data: undefined; error: ApiErrorDetails };
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Version améliorée de safeCall avec indicateur de succès
|
|
174
|
-
*/
|
|
175
|
-
export async function trySafe<T>(fn: () => Promise<T>): Promise<SafeResult<T>> {
|
|
176
|
-
try {
|
|
177
|
-
const data = await fn();
|
|
178
|
-
return { success: true, data, error: null };
|
|
179
|
-
} catch (error) {
|
|
180
|
-
const errorDetails = getErrorDetails(error);
|
|
181
|
-
return {
|
|
182
|
-
success: false,
|
|
183
|
-
data: undefined,
|
|
184
|
-
error: errorDetails || {
|
|
185
|
-
code: 500,
|
|
186
|
-
message: getErrorMessage(error)
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Utilitaire pour valider et normaliser les erreurs
|
|
194
|
-
*/
|
|
195
|
-
export function normalizeError(error: unknown): ApiError {
|
|
196
|
-
if (isApiError(error)) {
|
|
197
|
-
return error;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const message = getErrorMessage(error);
|
|
201
|
-
const status = getErrorStatusCode(error) || 500;
|
|
202
|
-
const details = hasResponse(error) ? error.response.data : undefined;
|
|
203
|
-
|
|
204
|
-
return new ApiError(message, status, details);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Type helper pour les fonctions qui peuvent lever des erreurs typées
|
|
209
|
-
*/
|
|
210
|
-
export type ErrorProne<T> = () => Promise<T> | T;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Décorateur de méthode pour capturer et normaliser les erreurs
|
|
214
|
-
*/
|
|
215
|
-
export function catchErrors<T extends any[], R>(
|
|
216
|
-
target: any,
|
|
217
|
-
propertyName: string,
|
|
218
|
-
descriptor: TypedPropertyDescriptor<(...args: T) => Promise<R>>
|
|
219
|
-
) {
|
|
220
|
-
const method = descriptor.value;
|
|
221
|
-
if (!method) return;
|
|
222
|
-
|
|
223
|
-
descriptor.value = async function (...args: T): Promise<R> {
|
|
224
|
-
try {
|
|
225
|
-
return await method.apply(this, args);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
throw normalizeError(error);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// types/index.ts - Point d'entrée central pour tous les types partagés
|
|
2
|
-
|
|
3
|
-
// Entity types
|
|
4
|
-
export type {
|
|
5
|
-
CollectionKey,
|
|
6
|
-
EntityTag
|
|
7
|
-
} from "../api/EntityRegistry.js";
|
|
8
|
-
|
|
9
|
-
export type {
|
|
10
|
-
EntityTypes,
|
|
11
|
-
SearchEntity,
|
|
12
|
-
TransformsMap,
|
|
13
|
-
TransformFunction,
|
|
14
|
-
} from "./entities.js";
|
|
15
|
-
|
|
16
|
-
// Payload types
|
|
17
|
-
export type {
|
|
18
|
-
SocialNetworkPayload,
|
|
19
|
-
} from "./payloads.js";
|
|
20
|
-
|
|
21
|
-
// Transform types
|
|
22
|
-
export type {
|
|
23
|
-
UserTransforms,
|
|
24
|
-
OrganizationTransforms,
|
|
25
|
-
ProjectTransforms,
|
|
26
|
-
EventTransforms
|
|
27
|
-
} from "./transforms.js";
|
|
28
|
-
|
|
29
|
-
// API Response types
|
|
30
|
-
export type {
|
|
31
|
-
BaseApiResponse,
|
|
32
|
-
ApiDataResponse,
|
|
33
|
-
ApiErrorResponse,
|
|
34
|
-
PaginatedApiResponse,
|
|
35
|
-
GetElementsKeyResponse,
|
|
36
|
-
ApiResponse
|
|
37
|
-
} from "./api-responses.js";
|
|
38
|
-
|
|
39
|
-
// API Error types
|
|
40
|
-
export type { ApiErrorDetails } from "./api-responses.js";
|
|
41
|
-
export type { GenericErrorDetails } from "../error.js";
|
package/src/types/payloads.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// types/payloads.ts - Types pour les payloads des méthodes _add et _update
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Types pour les réseaux sociaux
|
|
6
|
-
*/
|
|
7
|
-
export interface SocialNetworkPayload {
|
|
8
|
-
github?: string;
|
|
9
|
-
gitlab?: string;
|
|
10
|
-
facebook?: string;
|
|
11
|
-
twitter?: string;
|
|
12
|
-
instagram?: string;
|
|
13
|
-
linkedIn?: string;
|
|
14
|
-
youtube?: string;
|
|
15
|
-
website?: string;
|
|
16
|
-
diaspora?: string;
|
|
17
|
-
mastodon?: string;
|
|
18
|
-
telegram?: string;
|
|
19
|
-
signal?: string;
|
|
20
|
-
}
|
|
21
|
-
|
package/src/types/transforms.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// types/transforms.ts - Types spécialisés pour les transformations par entité
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
3
|
-
|
|
4
|
-
import type { TransformFunction, EntityRefsMap } from "./entities.js";
|
|
5
|
-
import type { SocialNetworkPayload } from "./payloads.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Types pour les données d'entrée des transforms
|
|
9
|
-
*/
|
|
10
|
-
export interface ParentData {
|
|
11
|
-
[key: string]: {
|
|
12
|
-
type?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
id?: string;
|
|
15
|
-
slug?: string;
|
|
16
|
-
_id?: any;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface OrganizerData {
|
|
21
|
-
[key: string]: {
|
|
22
|
-
type?: string;
|
|
23
|
-
name?: string;
|
|
24
|
-
id?: string;
|
|
25
|
-
slug?: string;
|
|
26
|
-
_id?: any;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Alias pour SocialNetworkPayload depuis payloads.ts (évite la duplication)
|
|
31
|
-
export type SocialNetworkData = SocialNetworkPayload;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Types pour les transforms spécifiques aux événements
|
|
35
|
-
*/
|
|
36
|
-
export interface EventTransforms {
|
|
37
|
-
parent: TransformFunction<ParentData | null, EntityRefsMap>;
|
|
38
|
-
organizer: TransformFunction<OrganizerData | null, EntityRefsMap>;
|
|
39
|
-
[key: string]: TransformFunction<any, any> | undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Types pour les transforms spécifiques aux utilisateurs/organisations/projets (réseaux sociaux)
|
|
44
|
-
*/
|
|
45
|
-
export interface SocialTransforms {
|
|
46
|
-
github: TransformFunction<any, string | undefined>;
|
|
47
|
-
gitlab: TransformFunction<any, string | undefined>;
|
|
48
|
-
facebook: TransformFunction<any, string | undefined>;
|
|
49
|
-
twitter: TransformFunction<any, string | undefined>;
|
|
50
|
-
instagram: TransformFunction<any, string | undefined>;
|
|
51
|
-
linkedIn?: TransformFunction<any, string | undefined>;
|
|
52
|
-
youtube?: TransformFunction<any, string | undefined>;
|
|
53
|
-
website?: TransformFunction<any, string | undefined>;
|
|
54
|
-
diaspora?: TransformFunction<any, string | undefined>;
|
|
55
|
-
mastodon?: TransformFunction<any, string | undefined>;
|
|
56
|
-
telegram?: TransformFunction<any, string | undefined>;
|
|
57
|
-
signal?: TransformFunction<any, string | undefined>;
|
|
58
|
-
[key: string]: TransformFunction<any, any> | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Types pour les transforms des utilisateurs
|
|
63
|
-
*/
|
|
64
|
-
export interface UserTransforms extends SocialTransforms {
|
|
65
|
-
// Ajouter d'autres transforms spécifiques aux utilisateurs si nécessaire
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Types pour les transforms des organisations
|
|
70
|
-
*/
|
|
71
|
-
export interface OrganizationTransforms extends SocialTransforms {
|
|
72
|
-
// Ajouter d'autres transforms spécifiques aux organisations si nécessaire
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Types pour les transforms des projets
|
|
77
|
-
*/
|
|
78
|
-
export interface ProjectTransforms extends SocialTransforms {
|
|
79
|
-
parent: TransformFunction<ParentData | null, EntityRefsMap>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Union de tous les types de transforms
|
|
84
|
-
*/
|
|
85
|
-
export type EntityTransforms = EventTransforms | UserTransforms | OrganizationTransforms | ProjectTransforms;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Fonction helper pour créer des transforms d'entité avec type safety
|
|
89
|
-
*/
|
|
90
|
-
export function createEntityRef(type: string, name?: string, id?: string, slug?: string, _id?: any) {
|
|
91
|
-
return { type, name, id, slug, _id };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Fonction helper pour transformer les données parent/organizer
|
|
96
|
-
*/
|
|
97
|
-
export function transformEntityRefs(val: ParentData | OrganizerData | null): EntityRefsMap {
|
|
98
|
-
if (!val || typeof val !== "object") return {};
|
|
99
|
-
|
|
100
|
-
return Object.fromEntries(
|
|
101
|
-
Object.entries(val).map(([key, obj]) => [
|
|
102
|
-
key,
|
|
103
|
-
{
|
|
104
|
-
type: obj?.type ?? "",
|
|
105
|
-
name: obj?.name,
|
|
106
|
-
// id: obj?.id,
|
|
107
|
-
// slug: obj?.slug
|
|
108
|
-
// _id exclu volontairement
|
|
109
|
-
}
|
|
110
|
-
])
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Fonction helper pour extraire les données de réseaux sociaux
|
|
116
|
-
*/
|
|
117
|
-
export function createSocialTransform(field: keyof SocialNetworkData): TransformFunction<any, string | undefined> {
|
|
118
|
-
return (_val: any, full?: any) => full?.socialNetwork?.[field];
|
|
119
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
import { OfflineQueueStorageStrategy } from "./OfflineQueueStorageStrategy.js";
|
|
6
|
-
|
|
7
|
-
export class FileOfflineStorage<T = any> extends OfflineQueueStorageStrategy<T> {
|
|
8
|
-
public readonly dir: string;
|
|
9
|
-
public readonly filePath: string;
|
|
10
|
-
|
|
11
|
-
constructor(filename: string = "offline-queue.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
|
|
12
|
-
super();
|
|
13
|
-
this.dir = dir;
|
|
14
|
-
this.filePath = path.join(dir, filename);
|
|
15
|
-
this._ensureDirectoryExists();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private _ensureDirectoryExists(): void {
|
|
19
|
-
if (!fs.existsSync(this.dir)) {
|
|
20
|
-
fs.mkdirSync(this.dir, { recursive: true });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private _readFile(): T[] {
|
|
25
|
-
if (!fs.existsSync(this.filePath)) return [];
|
|
26
|
-
try {
|
|
27
|
-
const json: T[] = JSON.parse(fs.readFileSync(this.filePath, "utf8"));
|
|
28
|
-
return json;
|
|
29
|
-
} catch (e) {
|
|
30
|
-
console.error("Erreur lecture offline queue :", e);
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private _writeFile(queue: T[]): void {
|
|
36
|
-
try {
|
|
37
|
-
fs.writeFileSync(this.filePath, JSON.stringify(queue, null, 2), "utf8");
|
|
38
|
-
} catch (e) {
|
|
39
|
-
console.warn("[OfflineQueue] Erreur d'écriture:", e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async loadQueue(): Promise<T[]> {
|
|
44
|
-
return this._readFile();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async saveQueue(queue: T[]): Promise<void> {
|
|
48
|
-
this._writeFile(queue);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as os from "os";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
|
|
6
|
-
import { TokenStorageStrategy } from "./TokenStorage.js";
|
|
7
|
-
|
|
8
|
-
export class FileStorageStrategy extends TokenStorageStrategy {
|
|
9
|
-
public readonly dir: string;
|
|
10
|
-
public readonly filePath: string;
|
|
11
|
-
|
|
12
|
-
constructor(filename: string = "tokens.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
|
|
13
|
-
super();
|
|
14
|
-
this.dir = dir;
|
|
15
|
-
this.filePath = path.join(dir, filename);
|
|
16
|
-
this._ensureDirectoryExists();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private _ensureDirectoryExists(): void {
|
|
20
|
-
if (!fs.existsSync(this.dir)) {
|
|
21
|
-
fs.mkdirSync(this.dir, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _readFile(): any {
|
|
26
|
-
if (!fs.existsSync(this.filePath)) return {};
|
|
27
|
-
try {
|
|
28
|
-
return JSON.parse(fs.readFileSync(this.filePath, "utf8"));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
|
|
31
|
-
console.error("Error reading token file:", e);
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private _writeFile(data: Record<string, any>): void {
|
|
37
|
-
fs.writeFileSync(this.filePath, JSON.stringify(data, null, 2), "utf8");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getAccessToken(): string | null {
|
|
41
|
-
return this._readFile().accessToken || null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
setAccessToken(token: string | null): void {
|
|
45
|
-
const data = this._readFile();
|
|
46
|
-
data.accessToken = token;
|
|
47
|
-
this._writeFile(data);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getRefreshToken(): string | null {
|
|
51
|
-
return this._readFile().refreshToken || null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setRefreshToken(token: string | null): void {
|
|
55
|
-
const data = this._readFile();
|
|
56
|
-
data.refreshToken = token;
|
|
57
|
-
this._writeFile(data);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
clear(): void {
|
|
61
|
-
this._writeFile({});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
import { MultiServerTokenStorageStrategy } from "./MultiServerTokenStorageStrategy.js";
|
|
6
|
-
|
|
7
|
-
export class MultiServerFileStorageStrategy extends MultiServerTokenStorageStrategy {
|
|
8
|
-
public readonly filePath: string;
|
|
9
|
-
|
|
10
|
-
constructor(filename: string = "tokens.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
|
|
11
|
-
super();
|
|
12
|
-
this.filePath = path.join(dir, filename);
|
|
13
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private _readFile(): any {
|
|
17
|
-
if (!fs.existsSync(this.filePath)) return {};
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(fs.readFileSync(this.filePath, "utf8"));
|
|
20
|
-
} catch {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _writeFile(data: Record<string, { accessToken?: string | null; refreshToken?: string | null }>): void {
|
|
26
|
-
fs.writeFileSync(this.filePath, JSON.stringify(data, null, 2), "utf8");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getAccessToken(): string | null {
|
|
30
|
-
const base = this._requireBaseURL();
|
|
31
|
-
return this._readFile()[base]?.accessToken ?? null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setAccessToken(token: string | null): void {
|
|
35
|
-
const base = this._requireBaseURL();
|
|
36
|
-
const all = this._readFile();
|
|
37
|
-
all[base] = { ...(all[base] || {}), accessToken: token };
|
|
38
|
-
this._writeFile(all);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getRefreshToken(): string | null {
|
|
42
|
-
const base = this._requireBaseURL();
|
|
43
|
-
return this._readFile()[base]?.refreshToken ?? null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setRefreshToken(token: string | null): void {
|
|
47
|
-
const base = this._requireBaseURL();
|
|
48
|
-
const all = this._readFile();
|
|
49
|
-
all[base] = { ...(all[base] || {}), refreshToken: token };
|
|
50
|
-
this._writeFile(all);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
clear(): void {
|
|
54
|
-
const base = this._requireBaseURL();
|
|
55
|
-
const all = this._readFile();
|
|
56
|
-
delete all[base];
|
|
57
|
-
this._writeFile(all);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getServers(): string[] {
|
|
61
|
-
return Object.keys(this._readFile());
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exportAll(): Record<string, { accessToken?: string | null; refreshToken?: string | null }> {
|
|
65
|
-
return this._readFile();
|
|
66
|
-
}
|
|
67
|
-
}
|