@communecter/cocolight-api-client 1.0.51 → 1.0.55
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/401.cocolight-api-client.browser.js +1 -0
- package/dist/401.cocolight-api-client.cjs +1 -0
- package/dist/401.cocolight-api-client.mjs.js +1 -0
- package/dist/588.cocolight-api-client.browser.js +1 -0
- package/dist/588.cocolight-api-client.cjs +1 -0
- package/dist/588.cocolight-api-client.mjs.js +1 -0
- package/dist/593.cocolight-api-client.browser.js +1 -0
- package/dist/593.cocolight-api-client.cjs +1 -0
- package/dist/593.cocolight-api-client.mjs.js +1 -0
- package/dist/839.cocolight-api-client.browser.js +1 -0
- package/dist/839.cocolight-api-client.cjs +1 -0
- package/dist/839.cocolight-api-client.mjs.js +1 -0
- package/dist/cocolight-api-client.browser.js +3 -3
- 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 +28 -10
- package/src/{Api.js → Api.ts} +99 -91
- package/src/{ApiClient.js → ApiClient.ts} +444 -240
- package/src/EJSONType.ts +103 -0
- package/src/api/{Badge.js → Badge.ts} +56 -45
- package/src/api/BaseEntity.ts +3897 -0
- package/src/api/Comment.ts +200 -0
- package/src/api/{EndpointApi.js → EndpointApi.ts} +365 -299
- package/src/api/{EndpointApi.types.d.ts → EndpointApi.types.ts} +166 -9
- package/src/api/EntityRegistry.ts +208 -0
- package/src/api/Event.ts +332 -0
- package/src/api/News.ts +331 -0
- package/src/api/{Organization.js → Organization.ts} +155 -119
- package/src/api/{Poi.js → Poi.ts} +68 -60
- package/src/api/{Project.js → Project.ts} +150 -127
- package/src/api/{User.js → User.ts} +321 -256
- package/src/api/UserApi.ts +148 -0
- package/src/api/serverDataType/Comment.ts +88 -0
- package/src/api/serverDataType/Event.ts +80 -0
- package/src/api/serverDataType/News.ts +138 -0
- package/src/api/serverDataType/Organization.ts +80 -0
- package/src/api/serverDataType/Project.ts +71 -0
- package/src/api/serverDataType/User.ts +103 -0
- package/src/api/serverDataType/common.ts +80 -0
- package/src/endpoints.module.ts +2621 -0
- package/src/error.ts +86 -0
- package/src/index.ts +86 -0
- package/src/mixin/UserMixin.ts +4 -0
- package/src/types/api-responses.ts +217 -0
- package/src/types/entities.ts +22 -0
- package/src/types/error-guards.ts +230 -0
- package/src/types/index.ts +39 -0
- package/src/types/payloads.ts +21 -0
- package/src/types/transforms.ts +110 -0
- package/src/utils/{FileOfflineStorageStrategy.node.js → FileOfflineStorageStrategy.node.ts} +15 -12
- package/src/utils/{FileStorageStrategy.node.js → FileStorageStrategy.node.ts} +17 -14
- package/src/utils/MultiServerFileStorageStrategy.node.ts +67 -0
- package/src/utils/MultiServerTokenStorageStrategy.ts +139 -0
- package/src/utils/{OfflineClientManager.js → OfflineClientManager.ts} +82 -86
- package/src/utils/OfflineQueueStorageStrategy.ts +47 -0
- package/src/utils/TokenStorage.ts +77 -0
- package/src/utils/compat.ts +12 -0
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +35 -0
- package/src/utils/{createDefaultOfflineStrategy.js → createDefaultOfflineStrategy.ts} +8 -3
- package/src/utils/createDefaultTokenStorageStrategy.ts +33 -0
- package/src/utils/{reactive.js → reactive.ts} +49 -40
- package/src/utils/stream-utils.node.ts +12 -0
- package/types/Api.d.ts +87 -0
- package/types/Api.d.ts.map +1 -0
- package/types/ApiClient.d.ts +437 -0
- package/types/ApiClient.d.ts.map +1 -0
- package/types/EJSONType.d.ts +53 -0
- package/types/EJSONType.d.ts.map +1 -0
- package/types/api/Badge.d.ts +24 -0
- package/types/api/Badge.d.ts.map +1 -0
- package/types/api/BaseEntity.d.ts +1322 -0
- package/types/api/BaseEntity.d.ts.map +1 -0
- package/types/api/Comment.d.ts +36 -0
- package/types/api/EndpointApi.d.ts +985 -0
- package/types/api/EndpointApi.d.ts.map +1 -0
- package/types/api/EndpointApi.types.d.ts +4233 -0
- package/types/api/EntityRegistry.d.ts +24 -0
- package/types/api/EntityRegistry.d.ts.map +1 -0
- package/types/api/Event.d.ts +122 -0
- package/types/api/Event.d.ts.map +1 -0
- package/types/api/News.d.ts +77 -0
- package/types/api/News.d.ts.map +1 -0
- package/types/api/Organization.d.ts +203 -0
- package/types/api/Organization.d.ts.map +1 -0
- package/types/api/Poi.d.ts +54 -0
- package/types/api/Poi.d.ts.map +1 -0
- package/types/api/Project.d.ts +180 -0
- package/types/api/Project.d.ts.map +1 -0
- package/types/api/User.d.ts +332 -0
- package/types/api/User.d.ts.map +1 -0
- package/types/api/UserApi.d.ts +64 -0
- package/types/api/UserApi.d.ts.map +1 -0
- package/types/api/serverDataType/Comment.d.ts +83 -0
- package/types/api/serverDataType/Event.d.ts +67 -0
- package/types/api/serverDataType/News.d.ts +130 -0
- package/types/api/serverDataType/Organization.d.ts +65 -0
- package/types/api/serverDataType/Organization.d.ts.map +1 -0
- package/types/api/serverDataType/Project.d.ts +58 -0
- package/types/api/serverDataType/Project.d.ts.map +1 -0
- package/types/api/serverDataType/User.d.ts +86 -0
- package/types/api/serverDataType/User.d.ts.map +1 -0
- package/types/api/serverDataType/common.d.ts +71 -0
- package/types/api/serverDataType/common.d.ts.map +1 -0
- package/types/endpoints.module.d.ts +20559 -0
- package/types/endpoints.module.d.ts.map +1 -0
- package/types/error.d.ts +54 -0
- package/types/error.d.ts.map +1 -0
- package/types/index.d.ts +59 -0
- package/types/index.d.ts.map +1 -0
- package/types/mixin/UserMixin.d.ts +1 -0
- package/types/mixin/UserMixin.d.ts.map +1 -0
- package/types/types/api-responses.d.ts +190 -0
- package/types/types/api-responses.d.ts.map +1 -0
- package/types/types/entities.d.ts +17 -0
- package/types/types/entities.d.ts.map +1 -0
- package/types/types/error-guards.d.ts +99 -0
- package/types/types/error-guards.d.ts.map +1 -0
- package/types/types/index.d.ts +7 -0
- package/types/types/payloads.d.ts +17 -0
- package/types/types/payloads.d.ts.map +1 -0
- package/types/types/transforms.d.ts +79 -0
- package/types/types/transforms.d.ts.map +1 -0
- package/types/utils/FileOfflineStorageStrategy.node.d.ts +11 -0
- package/types/utils/FileOfflineStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/FileStorageStrategy.node.d.ts +14 -0
- package/types/utils/FileStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/MultiServerFileStorageStrategy.node.d.ts +17 -0
- package/types/utils/MultiServerFileStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/MultiServerTokenStorageStrategy.d.ts +44 -0
- package/types/utils/MultiServerTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/OfflineClientManager.d.ts +58 -0
- package/types/utils/OfflineClientManager.d.ts.map +1 -0
- package/types/utils/OfflineQueueStorageStrategy.d.ts +16 -0
- package/types/utils/OfflineQueueStorageStrategy.d.ts.map +1 -0
- package/types/utils/TokenStorage.d.ts +26 -0
- package/types/utils/TokenStorage.d.ts.map +1 -0
- package/types/utils/compat.d.ts +4 -0
- package/types/utils/compat.d.ts.map +1 -0
- package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts +2 -0
- package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/createDefaultOfflineStrategy.d.ts +2 -0
- package/types/utils/createDefaultOfflineStrategy.d.ts.map +1 -0
- package/types/utils/createDefaultTokenStorageStrategy.d.ts +2 -0
- package/types/utils/createDefaultTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/reactive.d.ts +54 -0
- package/types/utils/reactive.d.ts.map +1 -0
- package/types/utils/stream-utils.node.d.ts +3 -0
- package/types/utils/stream-utils.node.d.ts.map +1 -0
- package/dist/123.cocolight-api-client.browser.js +0 -1
- package/dist/123.cocolight-api-client.cjs +0 -1
- package/dist/22.cocolight-api-client.mjs.js +0 -1
- package/dist/339.cocolight-api-client.mjs.js +0 -1
- package/dist/394.cocolight-api-client.browser.js +0 -1
- package/dist/394.cocolight-api-client.cjs +0 -1
- package/dist/405.cocolight-api-client.browser.js +0 -1
- package/dist/405.cocolight-api-client.cjs +0 -1
- package/dist/774.cocolight-api-client.mjs.js +0 -1
- package/dist/790.cocolight-api-client.mjs.js +0 -1
- package/dist/931.cocolight-api-client.browser.js +0 -1
- package/dist/931.cocolight-api-client.cjs +0 -1
- package/src/EJSONType.js +0 -53
- package/src/api/BaseEntity.js +0 -2828
- package/src/api/EntityRegistry.js +0 -152
- package/src/api/Event.js +0 -226
- package/src/api/News.js +0 -244
- package/src/api/UserApi.js +0 -81
- package/src/endpoints.module.js +0 -5
- package/src/error.js +0 -68
- package/src/index.js +0 -34
- package/src/mixin/UserMixin.js +0 -8
- package/src/utils/MultiServerFileStorageStrategy.node.js +0 -65
- package/src/utils/MultiServerTokenStorageStrategy.js +0 -131
- package/src/utils/OfflineQueueStorageStrategy.js +0 -51
- package/src/utils/TokenStorage.js +0 -93
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.js +0 -45
- package/src/utils/createDefaultTokenStorageStrategy.js +0 -43
- package/src/utils/stream-utils.node.js +0 -10
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { type TokenStorageStrategy } from "./utils/TokenStorage.js";
|
|
3
|
+
/**
|
|
4
|
+
* Résultat retourné quand une requête est **mise en file** (offline ou breaker).
|
|
5
|
+
* Permet de typer précisément les chemins « non-réseau » de `callEndpoint`.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiClientOfflineEnqueueResult {
|
|
8
|
+
data: null;
|
|
9
|
+
offline?: true;
|
|
10
|
+
breaker?: true;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options de configuration pour ApiClient
|
|
14
|
+
*/
|
|
15
|
+
export interface ApiClientOptions {
|
|
16
|
+
baseURL: string;
|
|
17
|
+
accessToken?: string | null;
|
|
18
|
+
refreshToken?: string | null;
|
|
19
|
+
refreshUrl?: string;
|
|
20
|
+
endpoints?: any[];
|
|
21
|
+
timeout?: number;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
circuitBreakerThreshold?: number;
|
|
25
|
+
circuitBreakerResetTime?: number;
|
|
26
|
+
fromJSONValue?: boolean;
|
|
27
|
+
tokenStorageStrategy?: TokenStorageStrategy | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Structure des données pour les appels d'endpoint
|
|
31
|
+
*/
|
|
32
|
+
export interface CallEndpointData {
|
|
33
|
+
pathParams?: Record<string, any>;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Résultat d'un appel d'endpoint réussi
|
|
38
|
+
*/
|
|
39
|
+
export interface CallEndpointResult<T = any> {
|
|
40
|
+
data: T;
|
|
41
|
+
offline?: never;
|
|
42
|
+
breaker?: never;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Union type pour tous les résultats possibles de callEndpoint
|
|
46
|
+
*/
|
|
47
|
+
export type CallEndpointResponse<T = any> = CallEndpointResult<T> | ApiClientOfflineEnqueueResult;
|
|
48
|
+
/**
|
|
49
|
+
* Client générique pour consommer une API REST avec validation AJV, gestion des tokens,
|
|
50
|
+
* circuit breaker, retry automatique, et support offline.
|
|
51
|
+
*
|
|
52
|
+
* @fires ApiClient#retryAttempt
|
|
53
|
+
* @fires ApiClient#queuedOffline
|
|
54
|
+
* @fires ApiClient#circuitBreakerOpen
|
|
55
|
+
* @fires ApiClient#circuitBreakerReset
|
|
56
|
+
* @fires ApiClient#refreshSuccess
|
|
57
|
+
* @fires ApiClient#refreshFailed
|
|
58
|
+
* @fires ApiClient#sessionReset
|
|
59
|
+
* @fires ApiClient#validationError
|
|
60
|
+
* @fires ApiClient#offlineModeChanged
|
|
61
|
+
* @fires ApiClient#userLoggedIn
|
|
62
|
+
*/
|
|
63
|
+
export default class ApiClient extends EventEmitter {
|
|
64
|
+
readonly __entityTag: string;
|
|
65
|
+
readonly userId: string | null;
|
|
66
|
+
private readonly _baseURL;
|
|
67
|
+
private readonly _refreshUrl;
|
|
68
|
+
private readonly _endpoints;
|
|
69
|
+
private readonly _debug;
|
|
70
|
+
private readonly _fromJSONValue;
|
|
71
|
+
private readonly _tokenStorage;
|
|
72
|
+
private _offlineClientManager;
|
|
73
|
+
private _ajv;
|
|
74
|
+
_logger: any;
|
|
75
|
+
private _client;
|
|
76
|
+
private readonly _breakerThreshold;
|
|
77
|
+
private readonly _breakerResetTime;
|
|
78
|
+
private _breakerErrorCount;
|
|
79
|
+
private _breakerOpen;
|
|
80
|
+
private _lastBreakerOpenTime;
|
|
81
|
+
private _accessToken;
|
|
82
|
+
private _refreshToken;
|
|
83
|
+
private _setUserId;
|
|
84
|
+
constructor({ baseURL, accessToken, refreshToken, refreshUrl, endpoints, timeout, debug, maxRetries, circuitBreakerThreshold, circuitBreakerResetTime, fromJSONValue, tokenStorageStrategy }: ApiClientOptions);
|
|
85
|
+
/**
|
|
86
|
+
* Sets the access token for the API client and updates the authorization header.
|
|
87
|
+
*/
|
|
88
|
+
setToken(token: string | null): void;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves the current access token.
|
|
91
|
+
*/
|
|
92
|
+
getToken(): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the refresh token for the API client.
|
|
95
|
+
*/
|
|
96
|
+
setRefreshToken(token: string | null): void;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves the current refresh token.
|
|
99
|
+
*/
|
|
100
|
+
getRefreshToken(): string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Indique si le client est connecté.
|
|
103
|
+
* On considère que le client est connecté si un token d'accès (_accessToken) est défini.
|
|
104
|
+
*/
|
|
105
|
+
get isConnected(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Extrait l'identifiant depuis un JWT.
|
|
108
|
+
*/
|
|
109
|
+
private _getIdFromToken;
|
|
110
|
+
/**
|
|
111
|
+
* Méthode simplifiée de refresh (en JSON).
|
|
112
|
+
* Emet un event refreshSuccess si ça marche
|
|
113
|
+
*/
|
|
114
|
+
private _refreshAccessToken;
|
|
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
|
+
private _checkCircuitBreaker;
|
|
120
|
+
/**
|
|
121
|
+
* updateCircuitBreaker : incremente le compteur d'erreurs
|
|
122
|
+
* si on dépasse le threshold, on "open" le breaker.
|
|
123
|
+
*/
|
|
124
|
+
private _updateCircuitBreakerError;
|
|
125
|
+
/**
|
|
126
|
+
* resetCircuitBreaker : en cas de succès on reset le compteur
|
|
127
|
+
*/
|
|
128
|
+
private _resetCircuitBreakerSuccess;
|
|
129
|
+
static stripNullsInPlace(obj: any): any;
|
|
130
|
+
private _resolveSpecialValuesInPlace;
|
|
131
|
+
private _cleanSchemaLeftoverAlias;
|
|
132
|
+
/**
|
|
133
|
+
* Safely calls an asynchronous function and handles any errors that occur.
|
|
134
|
+
* Logs the error message using the instance's logger before re-throwing the error.
|
|
135
|
+
*
|
|
136
|
+
* @param fn - The asynchronous function to be called.
|
|
137
|
+
* @param args - The arguments to pass to the function.
|
|
138
|
+
* @returns The result of the asynchronous function.
|
|
139
|
+
* @throws {Error} Re-throws any error that occurs during the function execution.
|
|
140
|
+
*/
|
|
141
|
+
safeCall(fn: (...args: any[]) => Promise<any>, ...args: any[]): Promise<any>;
|
|
142
|
+
/**
|
|
143
|
+
* Appelle un endpoint avec validations AJV, auth et circuit breaker.
|
|
144
|
+
* En cas d’indisponibilité (offline ou breaker), **met en file** l’action via
|
|
145
|
+
* `_offlineClientManager` si présent.
|
|
146
|
+
*
|
|
147
|
+
* @param constant - The constant representing the endpoint to call.
|
|
148
|
+
* @param data - Données envoyées (incluant éventuellement `pathParams`).
|
|
149
|
+
* @param transformResponseData - `true` (transforme via `_transformData`), `false`, ou une fonction `(data) => any`.
|
|
150
|
+
* @param validateResponseSchema - Whether to validate the response schema.
|
|
151
|
+
* @returns The response from the endpoint call, or an enqueue result if offline or breaker is active.
|
|
152
|
+
* @throws {CircuitBreakerError} If the circuit breaker is activated.
|
|
153
|
+
* @throws {ApiClientError} If the endpoint is not found, token is required but not provided, or validation fails.
|
|
154
|
+
*/
|
|
155
|
+
callEndpoint<T = any>(constant: string, data?: CallEndpointData, transformResponseData?: boolean | ((data: any) => any), validateResponseSchema?: boolean): Promise<CallEndpointResponse<T>>;
|
|
156
|
+
/**
|
|
157
|
+
* Converts AJV (Another JSON Schema Validator) errors into human-readable messages.
|
|
158
|
+
*
|
|
159
|
+
* @param errors - An array of AJV validation error objects.
|
|
160
|
+
* @returns An array of human-readable error messages extracted from the AJV errors.
|
|
161
|
+
*/
|
|
162
|
+
private _ajvErrorHuman;
|
|
163
|
+
/**
|
|
164
|
+
* Checks the API response for errors and throws an `ApiResponseError` if any are found.
|
|
165
|
+
*
|
|
166
|
+
* This method examines the `response.data` object to determine if it contains
|
|
167
|
+
* error information. It handles both standard and nested error cases:
|
|
168
|
+
*
|
|
169
|
+
* - Standard case: If `data.result` is a boolean and is `false`, an error is thrown.
|
|
170
|
+
* - Nested case: If `data.resultErrors` exists and contains a `result` property
|
|
171
|
+
* that is a boolean and is `false`, an error is thrown.
|
|
172
|
+
*
|
|
173
|
+
* If no errors are found, the original `response` is returned.
|
|
174
|
+
*
|
|
175
|
+
* @param {import("axios").AxiosResponse | { data: any } } response
|
|
176
|
+
* @returns {import("axios").AxiosResponse | { data: any }}
|
|
177
|
+
* @throws {ApiResponseError} If an error is detected in the response data.
|
|
178
|
+
*/
|
|
179
|
+
checkAndThrowApiResponseError(response: any): any;
|
|
180
|
+
/**
|
|
181
|
+
* Réinitialise complètement la session de l'utilisateur :
|
|
182
|
+
* - Token d'accès
|
|
183
|
+
* - Token de rafraîchissement
|
|
184
|
+
* - userId
|
|
185
|
+
* - En-têtes Axios
|
|
186
|
+
*/
|
|
187
|
+
resetSession(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves the value from an object based on a dot-separated path.
|
|
190
|
+
*/
|
|
191
|
+
private _getValueByPath;
|
|
192
|
+
/**
|
|
193
|
+
* Normalizes Date objects to ISO strings for AJV validation.
|
|
194
|
+
* This preserves the object structure while converting only Dates.
|
|
195
|
+
* Handles reactive Proxies by unwrapping them first.
|
|
196
|
+
*
|
|
197
|
+
* @param obj - The object to normalize
|
|
198
|
+
* @returns The normalized object with Dates as ISO strings
|
|
199
|
+
*/
|
|
200
|
+
static normalizeDatesForValidation(obj: any): any;
|
|
201
|
+
/**
|
|
202
|
+
* Normalizes fields with format:"date" in schema to YYYY-MM-DD format.
|
|
203
|
+
* Extracts only the date part from ISO datetime strings.
|
|
204
|
+
*
|
|
205
|
+
* @param data - The data object to normalize
|
|
206
|
+
* @param schema - The JSON schema containing field definitions
|
|
207
|
+
* @returns The normalized data with date-only strings for format:"date" fields
|
|
208
|
+
*/
|
|
209
|
+
static normalizeSchemaDateFields(data: any, schema: any): any;
|
|
210
|
+
/**
|
|
211
|
+
* Converts an object to URL search parameters.
|
|
212
|
+
*
|
|
213
|
+
* @param obj - The object to be converted to URL search parameters.
|
|
214
|
+
* @param [options={}] - Optional settings for the conversion.
|
|
215
|
+
* @returns The URL search parameters generated from the object.
|
|
216
|
+
*/
|
|
217
|
+
static toURLSearchParams(obj: any, options?: any): URLSearchParams;
|
|
218
|
+
/**
|
|
219
|
+
* Builds parameters for an API request from a given object.
|
|
220
|
+
*/
|
|
221
|
+
static _buildParams(obj: any, paramsInstance: FormData | URLSearchParams, options?: {
|
|
222
|
+
dots?: boolean;
|
|
223
|
+
indexes?: boolean;
|
|
224
|
+
metaTokens?: boolean;
|
|
225
|
+
}): FormData | URLSearchParams;
|
|
226
|
+
/**
|
|
227
|
+
* Transforms the given data based on its structure.
|
|
228
|
+
*
|
|
229
|
+
* This method normalizes various structures of data into a consistent format.
|
|
230
|
+
* It handles different types of data including objects, arrays, and specific
|
|
231
|
+
* nested structures like `resultGoods`, `resultErrors`, `results`, `news`,
|
|
232
|
+
* `notif`, `citoyens`, `organizations`, `cities`, `newComment`, `map`, and `object`.
|
|
233
|
+
*
|
|
234
|
+
* @param data - The data to be transformed.
|
|
235
|
+
* @returns - The transformed data.
|
|
236
|
+
*
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
private _transformData;
|
|
240
|
+
/**
|
|
241
|
+
* Normalizes JSON data by transforming specific fields and ensuring URLs are complete.
|
|
242
|
+
*
|
|
243
|
+
* @param item - The JSON object to be normalized.
|
|
244
|
+
* @returns - The normalized JSON object.
|
|
245
|
+
*
|
|
246
|
+
* The function performs the following transformations:
|
|
247
|
+
* - Normalizes the ID field if it matches a specific pattern.
|
|
248
|
+
* - Converts date fields from seconds to milliseconds.
|
|
249
|
+
* - Ensures URLs in specific fields are complete.
|
|
250
|
+
* - Filters and normalizes nested objects and arrays.
|
|
251
|
+
* - Removes the `timeAgo` field if it exists.
|
|
252
|
+
* - Converts the object to EJSON format if necessary.
|
|
253
|
+
*/
|
|
254
|
+
private _normalizeJsonData;
|
|
255
|
+
/**
|
|
256
|
+
* Ensures that the given image path is a full URL. If the image path is already a full URL
|
|
257
|
+
* (i.e., it starts with "http://" or "https://"), it is returned as is. Otherwise, the image path
|
|
258
|
+
* is concatenated with the base URL of the ApiClient instance.
|
|
259
|
+
*
|
|
260
|
+
* @param imagePath - The image path to ensure as a full URL.
|
|
261
|
+
* @returns - The full URL of the image path.
|
|
262
|
+
*/
|
|
263
|
+
private _ensureFullURL;
|
|
264
|
+
/**
|
|
265
|
+
* Parcourt récursivement un objet pour normaliser les champs de date.
|
|
266
|
+
* Pour chaque clé présente dans dateFields, si la valeur est un nombre ou un objet
|
|
267
|
+
* contenant une propriété sec (nombre), la transforme en { $date: valeurEnMs }.
|
|
268
|
+
*
|
|
269
|
+
* @param obj - L’objet à normaliser.
|
|
270
|
+
* @returns L’objet normalisé.
|
|
271
|
+
*/
|
|
272
|
+
/**
|
|
273
|
+
* Parcourt récursivement un objet pour normaliser les chemins d'images.
|
|
274
|
+
* Pour chaque propriété correspondant à un champ d'image (dans imageFields),
|
|
275
|
+
* vérifie et convertit le chemin en URL complète à l’aide de _ensureFullURL.
|
|
276
|
+
* Les cas particuliers (comme mediaImg.images ou mediaFile.files) sont également gérés.
|
|
277
|
+
*
|
|
278
|
+
* @param obj - L’objet à normaliser.
|
|
279
|
+
* @returns L’objet normalisé.
|
|
280
|
+
*/
|
|
281
|
+
/**
|
|
282
|
+
* Parcourt récursivement un objet ou un tableau pour normaliser les identifiants (ID).
|
|
283
|
+
* Si un objet possède une propriété "_id" ou "id" contenant un sous-objet "$id" valide,
|
|
284
|
+
* l'ID est normalisé et la propriété _id est convertie au format EJSON attendu.
|
|
285
|
+
*
|
|
286
|
+
* @param obj - L'objet ou le tableau à normaliser.
|
|
287
|
+
* @returns L'objet ou le tableau normalisé.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Normalise récursivement les valeurs booléennes.
|
|
291
|
+
* Si une valeur est une chaîne "true" ou "false", elle est convertie en booléen.
|
|
292
|
+
*
|
|
293
|
+
* @param data - L'objet, le tableau ou la valeur à normaliser.
|
|
294
|
+
* @returns La donnée normalisée.
|
|
295
|
+
*/
|
|
296
|
+
/**
|
|
297
|
+
* Transforme une chaîne "true" ou "false" en booléen.
|
|
298
|
+
*
|
|
299
|
+
* @param str - La chaîne à normaliser.
|
|
300
|
+
* @returns La valeur booléenne ou la chaîne originale.
|
|
301
|
+
*/
|
|
302
|
+
private _normalizeString;
|
|
303
|
+
/**
|
|
304
|
+
* Normalise les identifiants dans un objet.
|
|
305
|
+
* Si l'objet possède une propriété "_id" ou "id" contenant un sous-objet "$id" valide,
|
|
306
|
+
* il met à jour l'objet en assignant la valeur de l'ID et en formattant _id en EJSON.
|
|
307
|
+
*
|
|
308
|
+
* @param obj - L'objet à normaliser.
|
|
309
|
+
* @returns L'objet avec l'ID normalisé.
|
|
310
|
+
*/
|
|
311
|
+
private _normalizeId;
|
|
312
|
+
/**
|
|
313
|
+
* Normalise une valeur de date.
|
|
314
|
+
* Si la valeur est un objet contenant "sec" (nombre) ou un nombre,
|
|
315
|
+
* elle est convertie en { $date: valeurEnMs }.
|
|
316
|
+
*
|
|
317
|
+
* @param value - La valeur à normaliser.
|
|
318
|
+
* @returns La valeur normalisée.
|
|
319
|
+
*/
|
|
320
|
+
private _normalizeDate;
|
|
321
|
+
/**
|
|
322
|
+
* Normalise une URL d'image.
|
|
323
|
+
* Si la valeur est une chaîne non vide, retourne l'URL complète via _ensureFullURL.
|
|
324
|
+
*
|
|
325
|
+
* @param value - La valeur à normaliser.
|
|
326
|
+
* @returns La valeur normalisée.
|
|
327
|
+
*/
|
|
328
|
+
private _normalizeImage;
|
|
329
|
+
/**
|
|
330
|
+
* Liste des champs d'image à normaliser.
|
|
331
|
+
*/
|
|
332
|
+
private _imageFields;
|
|
333
|
+
/**
|
|
334
|
+
* Liste des champs de date à normaliser.
|
|
335
|
+
*/
|
|
336
|
+
private _dateFields;
|
|
337
|
+
/**
|
|
338
|
+
* Normalise récursivement un objet, un tableau ou une valeur simple.
|
|
339
|
+
* Cette fonction réalise en une seule passe les opérations suivantes :
|
|
340
|
+
* - Conversion des chaînes "true"/"false" en booléens.
|
|
341
|
+
* - Normalisation des dates (pour les champs spécifiés).
|
|
342
|
+
* - Normalisation des images (pour les champs spécifiés).
|
|
343
|
+
* - Transformation récursive des objets et tableaux.
|
|
344
|
+
* - Normalisation des identifiants.
|
|
345
|
+
*
|
|
346
|
+
* @param data - La donnée à normaliser.
|
|
347
|
+
* @returns La donnée normalisée.
|
|
348
|
+
*/
|
|
349
|
+
private _normalizeRecursively;
|
|
350
|
+
private _startBeforeEndValidate;
|
|
351
|
+
/**
|
|
352
|
+
* Récupère le schéma de requête pour un endpoint donné.
|
|
353
|
+
* @param constant - Le nom de l'endpoint.
|
|
354
|
+
* @returns Le schéma de requête ou null si non trouvé.
|
|
355
|
+
*/
|
|
356
|
+
getRequestSchema(constant: string): any;
|
|
357
|
+
/**
|
|
358
|
+
* Récupère le schéma de chemin pour un endpoint donné.
|
|
359
|
+
* @param constant - Le nom de l'endpoint.
|
|
360
|
+
* @returns Le schéma de chemin ou null si non trouvé.
|
|
361
|
+
*/
|
|
362
|
+
getPathSchema(constant: string): any;
|
|
363
|
+
/**
|
|
364
|
+
* Permet d'écouter facilement un ensemble d'événements importants émis par l'ApiClient.
|
|
365
|
+
*
|
|
366
|
+
* @param handlers - Un objet avec des fonctions à appeler selon l'événement.
|
|
367
|
+
* @param [handlers.retryAttempt] - Lors d'une tentative de retry axios.
|
|
368
|
+
* @param [handlers.queuedOffline] - Lorsqu'une requête est mise en file.
|
|
369
|
+
* @param [handlers.circuitBreakerOpen] - Quand le breaker s'ouvre.
|
|
370
|
+
* @param [handlers.circuitBreakerReset] - Quand le breaker se referme.
|
|
371
|
+
* @param [handlers.refreshSuccess] - Quand le token est rafraîchi.
|
|
372
|
+
* @param [handlers.refreshFailed] - Quand le refresh échoue.
|
|
373
|
+
* @param [handlers.sessionReset] - Quand la session est réinitialisée.
|
|
374
|
+
* @param [handlers.validationError] - Quand une validation échoue.
|
|
375
|
+
* @param [handlers.offlineModeChanged] - Quand le mode offline change.
|
|
376
|
+
* @param [handlers.userLoggedIn] - Quand un utilisateur se connecte.
|
|
377
|
+
*/
|
|
378
|
+
onEvent(handlers?: Record<string, (...args: any[]) => void>): void;
|
|
379
|
+
/**
|
|
380
|
+
* Retourne la liste des noms d'événements personnalisés déclarés dans les endpoints.
|
|
381
|
+
* Utile pour introspection ou documentation.
|
|
382
|
+
*
|
|
383
|
+
* @returns Liste des événements émis dynamiquement via postActions.
|
|
384
|
+
*/
|
|
385
|
+
getDeclaredEvents(): unknown[];
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* @event ApiClient#retryAttempt
|
|
389
|
+
* @type {Object}
|
|
390
|
+
* @property {number} retryCount - Le numéro de tentative.
|
|
391
|
+
* @property {string} url - L'URL de la requête ayant échoué.
|
|
392
|
+
*/
|
|
393
|
+
/**
|
|
394
|
+
* @event ApiClient#queuedOffline
|
|
395
|
+
* @type {Object}
|
|
396
|
+
* @property {string} constant - Le nom de l'endpoint.
|
|
397
|
+
* @property {Object} data - Les données envoyées.
|
|
398
|
+
* @property {"offlineMode"|"circuitBreaker"} reason - La raison de la mise en file.
|
|
399
|
+
*/
|
|
400
|
+
/**
|
|
401
|
+
* @event ApiClient#circuitBreakerOpen
|
|
402
|
+
* @type {Object}
|
|
403
|
+
* @property {number} timestamp - Date (ms) à laquelle le breaker s'est ouvert.
|
|
404
|
+
*/
|
|
405
|
+
/**
|
|
406
|
+
* @event ApiClient#circuitBreakerReset
|
|
407
|
+
* @type {void}
|
|
408
|
+
*/
|
|
409
|
+
/**
|
|
410
|
+
* @event ApiClient#refreshSuccess
|
|
411
|
+
* @type {Object}
|
|
412
|
+
* @property {string} token - Le nouveau token d'accès.
|
|
413
|
+
* @property {string} [refreshToken] - Le nouveau refreshToken (optionnel).
|
|
414
|
+
*/
|
|
415
|
+
/**
|
|
416
|
+
* @event ApiClient#refreshFailed
|
|
417
|
+
* @type {Object}
|
|
418
|
+
* @property {string} error - Le message d’erreur de refresh.
|
|
419
|
+
*/
|
|
420
|
+
/**
|
|
421
|
+
* @event ApiClient#sessionReset
|
|
422
|
+
* @type {void}
|
|
423
|
+
*/
|
|
424
|
+
/**
|
|
425
|
+
* @event ApiClient#validationError
|
|
426
|
+
* @type {Object}
|
|
427
|
+
* @property {"pathParams"|"request"|"response"} stage - Étape de validation échouée.
|
|
428
|
+
* @property {Array<Object>} errors - Erreurs AJV brutes.
|
|
429
|
+
*/
|
|
430
|
+
/**
|
|
431
|
+
* @event ApiClient#offlineModeChanged
|
|
432
|
+
* @type {boolean} - true si le client est offline, false sinon.
|
|
433
|
+
*/
|
|
434
|
+
/**
|
|
435
|
+
* @event ApiClient#userLoggedIn
|
|
436
|
+
* @param user - Les données utilisateur extraites de la réponse.
|
|
437
|
+
*/
|
|
@@ -0,0 +1 @@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
_looksLikeObjectID: (str: string) => boolean;
|
|
6
|
+
ObjectID: typeof ObjectID;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Représentation minimaliste d'un ObjectID Mongo (stocke l'hex en interne).
|
|
10
|
+
*/
|
|
11
|
+
declare class ObjectID {
|
|
12
|
+
private _str?;
|
|
13
|
+
/**
|
|
14
|
+
* @param hexString - Chaîne hexadécimale (24 chars). Si omise, l'instance est vide.
|
|
15
|
+
* @throws {Error} Si `hexString` est fournie mais invalide.
|
|
16
|
+
*/
|
|
17
|
+
constructor(hexString?: string);
|
|
18
|
+
/**
|
|
19
|
+
* Compare à un autre ObjectID.
|
|
20
|
+
*/
|
|
21
|
+
equals(other: unknown): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Représentation lisible (style Mongo shell).
|
|
24
|
+
*/
|
|
25
|
+
toString(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Clone l'ObjectID.
|
|
28
|
+
*/
|
|
29
|
+
clone(): ObjectID;
|
|
30
|
+
/**
|
|
31
|
+
* Nom de type EJSON.
|
|
32
|
+
*/
|
|
33
|
+
typeName(): "oid";
|
|
34
|
+
/**
|
|
35
|
+
* Timestamp (secondes) extrait des 4 premiers octets.
|
|
36
|
+
* @returns Nombre de secondes depuis l'époque Unix.
|
|
37
|
+
*/
|
|
38
|
+
getTimestamp(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Valeur primitive (hex).
|
|
41
|
+
*/
|
|
42
|
+
valueOf(): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Valeur JSON (hex).
|
|
45
|
+
*/
|
|
46
|
+
toJSONValue(): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Chaîne hexadécimale (24 chars).
|
|
49
|
+
*/
|
|
50
|
+
toHexString(): string | undefined;
|
|
51
|
+
}
|
|
52
|
+
declare const MongoID: MongoIDModule;
|
|
53
|
+
export default MongoID;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EJSONType.d.ts","sourceRoot":"","sources":["../src/EJSONType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,QAAQ,EAAE,OAAO,QAAQ,CAAC;CAC3B;AAOD;;GAEG;AACH,cAAM,QAAQ;IACZ,OAAO,CAAC,IAAI,CAAC,CAAS;IAEtB;;;OAGG;gBACS,SAAS,CAAC,EAAE,MAAM;IAc9B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAI/B;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,KAAK,IAAI,QAAQ;IAIjB;;OAEG;IACH,QAAQ,IAAI,KAAK;IAIjB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAMtB;;OAEG;IACH,OAAO,IAAI,MAAM,GAAG,SAAS;IAI7B;;OAEG;IACH,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC;;OAEG;IACH,WAAW,IAAI,MAAM,GAAG,SAAS;CAGlC;AAED,QAAA,MAAM,OAAO,EAAE,aAGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseEntity } from "./BaseEntity.js";
|
|
2
|
+
export declare class Badge extends BaseEntity<any> {
|
|
3
|
+
static entityType: string;
|
|
4
|
+
static entityTag: string;
|
|
5
|
+
static SCHEMA_CONSTANTS: string[];
|
|
6
|
+
static ADD_BLOCKS: Map<string, string>;
|
|
7
|
+
static UPDATE_BLOCKS: Map<string, string>;
|
|
8
|
+
defaultFields: Record<string, any>;
|
|
9
|
+
removeFields: string[];
|
|
10
|
+
_add: (payload: Record<string, any>) => Promise<void>;
|
|
11
|
+
_update: (payload: Record<string, any>) => Promise<boolean>;
|
|
12
|
+
getOrganizations(): Promise<never>;
|
|
13
|
+
getProjects(): Promise<never>;
|
|
14
|
+
getEvents(): Promise<never>;
|
|
15
|
+
getPois(): Promise<never>;
|
|
16
|
+
getBadgesIssuer(): Promise<never>;
|
|
17
|
+
getNews(): Promise<never>;
|
|
18
|
+
getSubscribers(): Promise<never>;
|
|
19
|
+
project(): Promise<never>;
|
|
20
|
+
poi(): Promise<never>;
|
|
21
|
+
event(): Promise<never>;
|
|
22
|
+
badge(): Promise<never>;
|
|
23
|
+
news(): Promise<never>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/api/Badge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5D,qBAAa,KAAM,SAAQ,UAAU,CAAC,GAAG,CAAC;IACxC,MAAM,CAAC,UAAU,SAAY;IAE7B,MAAM,CAAC,SAAS,SAAW;IAE3B,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAE/B;IAEF,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnC;IAEH,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CACtC;IAEH,aAAa,EAAE,GAAG,CAEhB;IAEF,YAAY,EAAE,MAAM,EAAE,CAAM;IAM5B,IAAI,GAAU,SAAS,GAAG,KAAG,OAAO,CAAC,IAAI,CAAC,CAsBxC;IAEF,OAAO,GAAU,SAAS,GAAG,KAAG,OAAO,CAAC,OAAO,CAAC,CAuB9C;IACF,gBAAgB;IACV,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAIrD,gBAAgB;IACV,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAIhD,gBAAgB;IACV,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAI9C,gBAAgB;IACV,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC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