@communecter/cocolight-api-client 1.0.50 → 1.0.54
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/123.cocolight-api-client.browser.js +1 -1
- package/dist/123.cocolight-api-client.cjs +1 -1
- package/dist/774.cocolight-api-client.mjs.js +1 -1
- 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 +15 -9
- package/src/Api.js +41 -23
- package/src/ApiClient.js +33 -18
- package/src/api/EndpointApi.js +95 -95
- package/src/endpoints.module.js +1 -1
- package/src/error.js +63 -10
- package/src/index.js +65 -2
- package/src/utils/FileStorageStrategy.node.js +28 -2
- package/src/utils/MultiServerFileStorageStrategy.node.js +24 -2
- package/src/utils/MultiServerTokenStorageStrategy.js +84 -27
- package/src/utils/TokenStorage.js +79 -19
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.js +33 -27
- package/src/utils/createDefaultTokenStorageStrategy.js +29 -23
- package/types/Api.d.ts +131 -0
- package/types/ApiClient.d.ts +377 -0
- package/types/EJSONType.d.ts +27 -0
- package/types/api/Badge.d.ts +24 -0
- package/types/api/BaseEntity.d.ts +1017 -0
- package/types/api/EndpointApi.d.ts +933 -0
- package/{src → types}/api/EndpointApi.types.d.ts +3 -3
- package/types/api/EntityRegistry.d.ts +22 -0
- package/types/api/Event.d.ts +38 -0
- package/types/api/News.d.ts +45 -0
- package/types/api/Organization.d.ts +87 -0
- package/types/api/Poi.d.ts +25 -0
- package/types/api/Project.d.ts +81 -0
- package/types/api/User.d.ts +203 -0
- package/types/api/UserApi.d.ts +13 -0
- package/types/endpoints.module.d.ts +14852 -0
- package/types/error.d.ts +80 -0
- package/types/index.d.ts +52 -0
- package/types/mixin/UserMixin.d.ts +1 -0
- package/types/utils/FileOfflineStorageStrategy.node.d.ts +10 -0
- package/types/utils/FileStorageStrategy.node.d.ts +25 -0
- package/types/utils/MultiServerFileStorageStrategy.node.d.ts +22 -0
- package/types/utils/MultiServerTokenStorageStrategy.d.ts +65 -0
- package/types/utils/OfflineClientManager.d.ts +94 -0
- package/types/utils/OfflineQueueStorageStrategy.d.ts +13 -0
- package/types/utils/TokenStorage.d.ts +76 -0
- package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts +11 -0
- package/types/utils/createDefaultOfflineStrategy.d.ts +3 -0
- package/types/utils/createDefaultTokenStorageStrategy.d.ts +12 -0
- package/types/utils/reactive.d.ts +60 -0
- package/types/utils/stream-utils.node.d.ts +2 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client générique pour consommer une API REST avec validation AJV, gestion des tokens,
|
|
3
|
+
* circuit breaker, retry automatique, et support offline.
|
|
4
|
+
*
|
|
5
|
+
* @extends EventEmitter
|
|
6
|
+
*
|
|
7
|
+
* @fires ApiClient#retryAttempt
|
|
8
|
+
* @fires ApiClient#queuedOffline
|
|
9
|
+
* @fires ApiClient#circuitBreakerOpen
|
|
10
|
+
* @fires ApiClient#circuitBreakerReset
|
|
11
|
+
* @fires ApiClient#refreshSuccess
|
|
12
|
+
* @fires ApiClient#refreshFailed
|
|
13
|
+
* @fires ApiClient#sessionReset
|
|
14
|
+
* @fires ApiClient#validationError
|
|
15
|
+
* @fires ApiClient#offlineModeChanged
|
|
16
|
+
* @fires ApiClient#userLoggedIn
|
|
17
|
+
*/
|
|
18
|
+
export default class ApiClient extends EventEmitter<[never]> {
|
|
19
|
+
static stripNullsInPlace(obj: any): any;
|
|
20
|
+
/**
|
|
21
|
+
* Converts an object to URL search parameters.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} obj - The object to be converted to URL search parameters.
|
|
24
|
+
* @param {Object} [options={}] - Optional settings for the conversion.
|
|
25
|
+
* @returns {URLSearchParams} The URL search parameters generated from the object.
|
|
26
|
+
*/
|
|
27
|
+
static toURLSearchParams(obj: any, options?: any): URLSearchParams;
|
|
28
|
+
/**
|
|
29
|
+
* Builds parameters for an API request from a given object.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} obj - The object to be converted into parameters.
|
|
32
|
+
* @param {FormData|URLSearchParams} paramsInstance - The instance to which the parameters will be appended.
|
|
33
|
+
* @param {Object} [options={}] - Optional settings.
|
|
34
|
+
* @param {boolean} [options.dots=false] - Whether to use dots in the parameter keys.
|
|
35
|
+
* @param {boolean} [options.indexes=false] - Whether to include array indexes in the parameter keys.
|
|
36
|
+
* @param {boolean} [options.metaTokens=true] - Whether to include meta tokens in the parameter keys.
|
|
37
|
+
* @throws {TypeError} If the provided obj is not an object or is null.
|
|
38
|
+
* @returns {FormData|URLSearchParams} The instance with the appended parameters.
|
|
39
|
+
*/
|
|
40
|
+
static _buildParams(obj: any, paramsInstance: FormData | URLSearchParams, options?: {
|
|
41
|
+
dots?: boolean;
|
|
42
|
+
indexes?: boolean;
|
|
43
|
+
metaTokens?: boolean;
|
|
44
|
+
}): FormData | URLSearchParams;
|
|
45
|
+
/**
|
|
46
|
+
* @param {ApiClientOptions} [options]
|
|
47
|
+
*/
|
|
48
|
+
constructor({ baseURL, accessToken, refreshToken, refreshUrl, endpoints, timeout, debug, maxRetries, circuitBreakerThreshold, circuitBreakerResetTime, fromJSONValue, tokenStorageStrategy }?: ApiClientOptions);
|
|
49
|
+
__entityTag: string;
|
|
50
|
+
_baseURL: string;
|
|
51
|
+
_refreshUrl: string;
|
|
52
|
+
_endpoints: any[];
|
|
53
|
+
_debug: boolean;
|
|
54
|
+
_offlineClientManager: any;
|
|
55
|
+
_fromJSONValue: boolean;
|
|
56
|
+
_setUserId: (id: any) => void;
|
|
57
|
+
_ajv: any;
|
|
58
|
+
_logger: any;
|
|
59
|
+
_client: any;
|
|
60
|
+
_breakerThreshold: number;
|
|
61
|
+
_breakerResetTime: number;
|
|
62
|
+
_breakerErrorCount: number;
|
|
63
|
+
_breakerOpen: boolean;
|
|
64
|
+
/** @type {string|null} */
|
|
65
|
+
_lastBreakerOpenTime: string | null;
|
|
66
|
+
/** @type {string|null} */
|
|
67
|
+
_accessToken: string | null;
|
|
68
|
+
/** @type {string|null} */
|
|
69
|
+
_refreshToken: string | null;
|
|
70
|
+
/** @type {TokenStorageStrategy} */
|
|
71
|
+
_tokenStorage: TokenStorageStrategy;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the access token for the API client and updates the authorization header.
|
|
74
|
+
*
|
|
75
|
+
* @param {string|null} token - The access token to be set.
|
|
76
|
+
*/
|
|
77
|
+
setToken(token: string | null): void;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the current access token.
|
|
80
|
+
*
|
|
81
|
+
* @returns {string|null} The access token.
|
|
82
|
+
*/
|
|
83
|
+
getToken(): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the refresh token for the API client.
|
|
86
|
+
*
|
|
87
|
+
* @param {string|null} token - The refresh token to be set.
|
|
88
|
+
*/
|
|
89
|
+
setRefreshToken(token: string | null): void;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves the current refresh token.
|
|
92
|
+
*
|
|
93
|
+
* @returns {string|null} The refresh token.
|
|
94
|
+
*/
|
|
95
|
+
getRefreshToken(): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Indique si le client est connecté.
|
|
98
|
+
* On considère que le client est connecté si un token d'accès (_accessToken) est défini.
|
|
99
|
+
*
|
|
100
|
+
* @returns {boolean} True si connecté, false sinon.
|
|
101
|
+
*/
|
|
102
|
+
get isConnected(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Extrait l'identifiant depuis un JWT.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} token - Le token JWT (accessToken ou refreshToken).
|
|
107
|
+
* @returns {string|null} L'identifiant extrait ou null si non trouvé.
|
|
108
|
+
*/
|
|
109
|
+
_getIdFromToken(token: string): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Méthode simplifiée de refresh (en JSON).
|
|
112
|
+
* Emet un event refreshSuccess si ça marche
|
|
113
|
+
*/
|
|
114
|
+
_refreshAccessToken(): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* checkCircuitBreaker : vérifie si on peut appeler l'API ou non
|
|
117
|
+
* si le breaker est \"open\", on regarde si on peut \"reset\"
|
|
118
|
+
*/
|
|
119
|
+
_checkCircuitBreaker(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* updateCircuitBreaker : incremente le compteur d'erreurs
|
|
122
|
+
* si on dépasse le threshold, on \"open\" le breaker.
|
|
123
|
+
*/
|
|
124
|
+
_updateCircuitBreakerError(): void;
|
|
125
|
+
/**
|
|
126
|
+
* resetCircuitBreaker : en cas de succès on reset le compteur
|
|
127
|
+
*/
|
|
128
|
+
_resetCircuitBreakerSuccess(): void;
|
|
129
|
+
_resolveSpecialValuesInPlace(obj: any, pathParams?: {}): any;
|
|
130
|
+
_cleanSchemaLeftoverAlias(obj: any): any;
|
|
131
|
+
/**
|
|
132
|
+
* Safely calls an asynchronous function and handles any errors that occur.
|
|
133
|
+
* Logs the error message using the instance's logger before re-throwing the error.
|
|
134
|
+
*
|
|
135
|
+
* @param {Function} fn - The asynchronous function to be called.
|
|
136
|
+
* @param {...any} args - The arguments to pass to the function.
|
|
137
|
+
* @returns {Promise<any>} The result of the asynchronous function.
|
|
138
|
+
* @throws {Error} Re-throws any error that occurs during the function execution.
|
|
139
|
+
*/
|
|
140
|
+
safeCall(fn: Function, ...args: any[]): Promise<any>;
|
|
141
|
+
/**
|
|
142
|
+
* Calls an API endpoint with the specified parameters.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} constant - The constant representing the endpoint to call.
|
|
145
|
+
* @param {Object} [data={}] - The data to send with the request.
|
|
146
|
+
* @param {boolean|function} [transformResponseData=true] - Whether to transform the response data or a function to transform it.
|
|
147
|
+
* @param {boolean} [validateResponseSchema=true] - Whether to validate the response schema.
|
|
148
|
+
* @returns {Promise<Object>} The response from the API.
|
|
149
|
+
* @throws {CircuitBreakerError} If the circuit breaker is activated.
|
|
150
|
+
* @throws {ApiClientError} If the endpoint is not found, token is required but not provided, or validation fails.
|
|
151
|
+
*/
|
|
152
|
+
callEndpoint(constant: string, data?: any, transformResponseData?: boolean | Function, validateResponseSchema?: boolean): Promise<any>;
|
|
153
|
+
/**
|
|
154
|
+
* Converts AJV (Another JSON Schema Validator) errors into human-readable messages.
|
|
155
|
+
*
|
|
156
|
+
* @param {Array} errors - An array of AJV validation error objects.
|
|
157
|
+
* @returns {Array<string>} An array of human-readable error messages extracted from the AJV errors.
|
|
158
|
+
*/
|
|
159
|
+
_ajvErrorHuman(errors: any[]): Array<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Checks the API response for errors and throws an `ApiResponseError` if any are found.
|
|
162
|
+
*
|
|
163
|
+
* This method examines the `response.data` object to determine if it contains
|
|
164
|
+
* error information. It handles both standard and nested error cases:
|
|
165
|
+
*
|
|
166
|
+
* - Standard case: If `data.result` is a boolean and is `false`, an error is thrown.
|
|
167
|
+
* - Nested case: If `data.resultErrors` exists and contains a `result` property
|
|
168
|
+
* that is a boolean and is `false`, an error is thrown.
|
|
169
|
+
*
|
|
170
|
+
* If no errors are found, the original `response` is returned.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} response - The API response object to check.
|
|
173
|
+
* @param {Object} response.data - The data payload of the response.
|
|
174
|
+
* @param {number} response.status - The HTTP status code of the response.
|
|
175
|
+
* @throws {ApiResponseError} If an error is detected in the response data.
|
|
176
|
+
* @returns {Object} The original `response` object if no errors are found.
|
|
177
|
+
*/
|
|
178
|
+
checkAndThrowApiResponseError(response: {
|
|
179
|
+
data: any;
|
|
180
|
+
status: number;
|
|
181
|
+
}): any;
|
|
182
|
+
/**
|
|
183
|
+
* Réinitialise complètement la session de l'utilisateur :
|
|
184
|
+
* - Token d'accès
|
|
185
|
+
* - Token de rafraîchissement
|
|
186
|
+
* - userId
|
|
187
|
+
* - En-têtes Axios
|
|
188
|
+
*/
|
|
189
|
+
resetSession(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves the value from an object based on a dot-separated path.
|
|
192
|
+
*
|
|
193
|
+
* @param {Object} obj - The object from which to retrieve the value.
|
|
194
|
+
* @param {string} path - The dot-separated path string indicating the value to retrieve.
|
|
195
|
+
* @returns {*} - The value found at the specified path, or undefined if the path is invalid.
|
|
196
|
+
*/
|
|
197
|
+
_getValueByPath(obj: any, path: string): any;
|
|
198
|
+
/**
|
|
199
|
+
* Transforms the given data based on its structure.
|
|
200
|
+
*
|
|
201
|
+
* This method normalizes various structures of data into a consistent format.
|
|
202
|
+
* It handles different types of data including objects, arrays, and specific
|
|
203
|
+
* nested structures like `resultGoods`, `resultErrors`, `results`, `news`,
|
|
204
|
+
* `notif`, `citoyens`, `organizations`, `cities`, `newComment`, `map`, and `object`.
|
|
205
|
+
*
|
|
206
|
+
* @param {Object|Array} data - The data to be transformed.
|
|
207
|
+
* @returns {Object|Array} - The transformed data.
|
|
208
|
+
*
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
private _transformData;
|
|
212
|
+
/**
|
|
213
|
+
* Normalizes JSON data by transforming specific fields and ensuring URLs are complete.
|
|
214
|
+
*
|
|
215
|
+
* @param {Object} item - The JSON object to be normalized.
|
|
216
|
+
* @returns {Object} - The normalized JSON object.
|
|
217
|
+
*
|
|
218
|
+
* The function performs the following transformations:
|
|
219
|
+
* - Normalizes the ID field if it matches a specific pattern.
|
|
220
|
+
* - Converts date fields from seconds to milliseconds.
|
|
221
|
+
* - Ensures URLs in specific fields are complete.
|
|
222
|
+
* - Filters and normalizes nested objects and arrays.
|
|
223
|
+
* - Removes the `timeAgo` field if it exists.
|
|
224
|
+
* - Converts the object to EJSON format if necessary.
|
|
225
|
+
*/
|
|
226
|
+
_normalizeJsonData(item: any): any;
|
|
227
|
+
/**
|
|
228
|
+
* Ensures that the given image path is a full URL. If the image path is already a full URL
|
|
229
|
+
* (i.e., it starts with "http://" or "https://"), it is returned as is. Otherwise, the image path
|
|
230
|
+
* is concatenated with the base URL of the ApiClient instance.
|
|
231
|
+
*
|
|
232
|
+
* @param {string} imagePath - The image path to ensure as a full URL.
|
|
233
|
+
* @returns {string} - The full URL of the image path.
|
|
234
|
+
*/
|
|
235
|
+
_ensureFullURL(imagePath: string): string;
|
|
236
|
+
/**
|
|
237
|
+
* Parcourt récursivement un objet pour normaliser les champs de date.
|
|
238
|
+
* Pour chaque clé présente dans dateFields, si la valeur est un nombre ou un objet
|
|
239
|
+
* contenant une propriété sec (nombre), la transforme en { $date: valeurEnMs }.
|
|
240
|
+
*
|
|
241
|
+
* @param {Object} obj - L’objet à normaliser.
|
|
242
|
+
* @returns {Object} L’objet normalisé.
|
|
243
|
+
*/
|
|
244
|
+
/**
|
|
245
|
+
* Parcourt récursivement un objet pour normaliser les chemins d'images.
|
|
246
|
+
* Pour chaque propriété correspondant à un champ d'image (dans imageFields),
|
|
247
|
+
* vérifie et convertit le chemin en URL complète à l’aide de _ensureFullURL.
|
|
248
|
+
* Les cas particuliers (comme mediaImg.images ou mediaFile.files) sont également gérés.
|
|
249
|
+
*
|
|
250
|
+
* @param {Object} obj - L’objet à normaliser.
|
|
251
|
+
* @returns {Object} L’objet normalisé.
|
|
252
|
+
*/
|
|
253
|
+
/**
|
|
254
|
+
* Parcourt récursivement un objet ou un tableau pour normaliser les identifiants (ID).
|
|
255
|
+
* Si un objet possède une propriété "_id" ou "id" contenant un sous-objet "$id" valide,
|
|
256
|
+
* l'ID est normalisé et la propriété _id est convertie au format EJSON attendu.
|
|
257
|
+
*
|
|
258
|
+
* @param {Object|Array} obj - L'objet ou le tableau à normaliser.
|
|
259
|
+
* @returns {Object|Array} L'objet ou le tableau normalisé.
|
|
260
|
+
*/
|
|
261
|
+
/**
|
|
262
|
+
* Normalise récursivement les valeurs booléennes.
|
|
263
|
+
* Si une valeur est une chaîne "true" ou "false", elle est convertie en booléen.
|
|
264
|
+
*
|
|
265
|
+
* @param {any} data - L'objet, le tableau ou la valeur à normaliser.
|
|
266
|
+
* @returns {any} La donnée normalisée.
|
|
267
|
+
*/
|
|
268
|
+
/**
|
|
269
|
+
* Transforme une chaîne "true" ou "false" en booléen.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} str - La chaîne à normaliser.
|
|
272
|
+
* @returns {boolean|string} La valeur booléenne ou la chaîne originale.
|
|
273
|
+
*/
|
|
274
|
+
_normalizeString(str: string): boolean | string;
|
|
275
|
+
/**
|
|
276
|
+
* Normalise les identifiants dans un objet.
|
|
277
|
+
* Si l'objet possède une propriété "_id" ou "id" contenant un sous-objet "$id" valide,
|
|
278
|
+
* il met à jour l'objet en assignant la valeur de l'ID et en formattant _id en EJSON.
|
|
279
|
+
*
|
|
280
|
+
* @param {Object} obj - L'objet à normaliser.
|
|
281
|
+
* @returns {Object} L'objet avec l'ID normalisé.
|
|
282
|
+
*/
|
|
283
|
+
_normalizeId(obj: any): any;
|
|
284
|
+
/**
|
|
285
|
+
* Normalise une valeur de date.
|
|
286
|
+
* Si la valeur est un objet contenant "sec" (nombre) ou un nombre,
|
|
287
|
+
* elle est convertie en { $date: valeurEnMs }.
|
|
288
|
+
*
|
|
289
|
+
* @param {any} value - La valeur à normaliser.
|
|
290
|
+
* @returns {any} La valeur normalisée.
|
|
291
|
+
*/
|
|
292
|
+
_normalizeDate(value: any): any;
|
|
293
|
+
/**
|
|
294
|
+
* Normalise une URL d'image.
|
|
295
|
+
* Si la valeur est une chaîne non vide, retourne l'URL complète via _ensureFullURL.
|
|
296
|
+
*
|
|
297
|
+
* @param {any} value - La valeur à normaliser.
|
|
298
|
+
* @returns {any} La valeur normalisée.
|
|
299
|
+
*/
|
|
300
|
+
_normalizeImage(value: any): any;
|
|
301
|
+
/**
|
|
302
|
+
* Liste des champs d'image à normaliser.
|
|
303
|
+
*/
|
|
304
|
+
_imageFields: string[];
|
|
305
|
+
/**
|
|
306
|
+
* Liste des champs de date à normaliser.
|
|
307
|
+
*/
|
|
308
|
+
_dateFields: string[];
|
|
309
|
+
/**
|
|
310
|
+
* Normalise récursivement un objet, un tableau ou une valeur simple.
|
|
311
|
+
* Cette fonction réalise en une seule passe les opérations suivantes :
|
|
312
|
+
* - Conversion des chaînes "true"/"false" en booléens.
|
|
313
|
+
* - Normalisation des dates (pour les champs spécifiés).
|
|
314
|
+
* - Normalisation des images (pour les champs spécifiés).
|
|
315
|
+
* - Transformation récursive des objets et tableaux.
|
|
316
|
+
* - Normalisation des identifiants.
|
|
317
|
+
*
|
|
318
|
+
* @param {any} data - La donnée à normaliser.
|
|
319
|
+
* @returns {any} La donnée normalisée.
|
|
320
|
+
*/
|
|
321
|
+
_normalizeRecursively(data: any): any;
|
|
322
|
+
_startBeforeEndValidate: (schema: any, data: any) => boolean;
|
|
323
|
+
getRequestSchema(constant: any): any;
|
|
324
|
+
getPathSchema(constant: any): any;
|
|
325
|
+
/**
|
|
326
|
+
* Permet d'écouter facilement un ensemble d'événements importants émis par l'ApiClient.
|
|
327
|
+
*
|
|
328
|
+
* @param {Object} handlers - Un objet avec des fonctions à appeler selon l'événement.
|
|
329
|
+
* @param {Function} [handlers.retryAttempt] - Lors d'une tentative de retry axios.
|
|
330
|
+
* @param {Function} [handlers.queuedOffline] - Lorsqu'une requête est mise en file.
|
|
331
|
+
* @param {Function} [handlers.circuitBreakerOpen] - Quand le breaker s'ouvre.
|
|
332
|
+
* @param {Function} [handlers.circuitBreakerReset] - Quand le breaker se referme.
|
|
333
|
+
* @param {Function} [handlers.refreshSuccess] - Quand le token est rafraîchi.
|
|
334
|
+
* @param {Function} [handlers.refreshFailed] - Quand le refresh échoue.
|
|
335
|
+
* @param {Function} [handlers.sessionReset] - Quand la session est réinitialisée.
|
|
336
|
+
* @param {Function} [handlers.validationError] - Quand une validation échoue.
|
|
337
|
+
* @param {Function} [handlers.offlineModeChanged] - Quand le mode offline change.
|
|
338
|
+
* @param {Function} [handlers.userLoggedIn] - Quand un utilisateur se connecte.
|
|
339
|
+
*/
|
|
340
|
+
onEvent(handlers?: {
|
|
341
|
+
retryAttempt?: Function;
|
|
342
|
+
queuedOffline?: Function;
|
|
343
|
+
circuitBreakerOpen?: Function;
|
|
344
|
+
circuitBreakerReset?: Function;
|
|
345
|
+
refreshSuccess?: Function;
|
|
346
|
+
refreshFailed?: Function;
|
|
347
|
+
sessionReset?: Function;
|
|
348
|
+
validationError?: Function;
|
|
349
|
+
offlineModeChanged?: Function;
|
|
350
|
+
userLoggedIn?: Function;
|
|
351
|
+
}): void;
|
|
352
|
+
/**
|
|
353
|
+
* Retourne la liste des noms d'événements personnalisés déclarés dans les endpoints.
|
|
354
|
+
* Utile pour introspection ou documentation.
|
|
355
|
+
*
|
|
356
|
+
* @returns {string[]} Liste des événements émis dynamiquement via postActions.
|
|
357
|
+
*/
|
|
358
|
+
getDeclaredEvents(): string[];
|
|
359
|
+
}
|
|
360
|
+
export type TokenStorageStrategy = import("./utils/TokenStorage.js").TokenStorageStrategy;
|
|
361
|
+
export type MemoryStorageStrategy = import("./utils/TokenStorage.js").MemoryStorageStrategy;
|
|
362
|
+
export type MultiServerTokenStorageStrategy = import("./utils/MultiServerTokenStorageStrategy.js").MultiServerTokenStorageStrategy;
|
|
363
|
+
export type ApiClientOptions = {
|
|
364
|
+
baseURL: string;
|
|
365
|
+
accessToken?: string;
|
|
366
|
+
refreshToken?: string;
|
|
367
|
+
refreshUrl?: string;
|
|
368
|
+
endpoints?: any[];
|
|
369
|
+
timeout?: number;
|
|
370
|
+
debug?: boolean;
|
|
371
|
+
maxRetries?: number;
|
|
372
|
+
circuitBreakerThreshold?: number;
|
|
373
|
+
circuitBreakerResetTime?: number;
|
|
374
|
+
fromJSONValue?: boolean;
|
|
375
|
+
tokenStorageStrategy?: TokenStorageStrategy | null;
|
|
376
|
+
};
|
|
377
|
+
import { EventEmitter } from "events";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default MongoID;
|
|
2
|
+
declare namespace MongoID {
|
|
3
|
+
export function _looksLikeObjectID(str: any): boolean;
|
|
4
|
+
export { ObjectID };
|
|
5
|
+
}
|
|
6
|
+
declare class ObjectID {
|
|
7
|
+
constructor(hexString: any);
|
|
8
|
+
_str: any;
|
|
9
|
+
equals(other: any): boolean;
|
|
10
|
+
toString(): string;
|
|
11
|
+
clone(): {
|
|
12
|
+
_str: any;
|
|
13
|
+
equals(other: any): boolean;
|
|
14
|
+
toString(): string;
|
|
15
|
+
clone(): /*elided*/ any;
|
|
16
|
+
typeName(): string;
|
|
17
|
+
getTimestamp(): number;
|
|
18
|
+
valueOf(): any;
|
|
19
|
+
toJSONValue(): any;
|
|
20
|
+
toHexString(): any;
|
|
21
|
+
};
|
|
22
|
+
typeName(): string;
|
|
23
|
+
getTimestamp(): number;
|
|
24
|
+
valueOf(): any;
|
|
25
|
+
toJSONValue(): any;
|
|
26
|
+
toHexString(): any;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class Badge extends BaseEntity {
|
|
2
|
+
static entityType: string;
|
|
3
|
+
static SCHEMA_CONSTANTS: string[];
|
|
4
|
+
static ADD_BLOCKS: Map<string, string>;
|
|
5
|
+
static UPDATE_BLOCKS: Map<any, any>;
|
|
6
|
+
defaultFields: {};
|
|
7
|
+
removeFields: any[];
|
|
8
|
+
transforms: {};
|
|
9
|
+
_add(payload: any): Promise<void>;
|
|
10
|
+
_update(payload: any): Promise<boolean>;
|
|
11
|
+
getOrganizations(): Promise<void>;
|
|
12
|
+
getProjects(): Promise<void>;
|
|
13
|
+
getEvents(): Promise<void>;
|
|
14
|
+
getPois(): Promise<void>;
|
|
15
|
+
getBadgesIssuer(): Promise<void>;
|
|
16
|
+
getNews(): Promise<void>;
|
|
17
|
+
getSubscribers(): Promise<void>;
|
|
18
|
+
project(): Promise<void>;
|
|
19
|
+
poi(): Promise<void>;
|
|
20
|
+
event(): Promise<void>;
|
|
21
|
+
badge(): Promise<void>;
|
|
22
|
+
news(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
import BaseEntity from "./BaseEntity.js";
|