uni-manager 0.0.7 → 0.0.9
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/fesm2022/uni-manager.mjs +60 -47
- package/fesm2022/uni-manager.mjs.map +1 -1
- package/lib/error/manager.d.ts +4 -4
- package/lib/http/manager.d.ts +6 -10
- package/lib/http/ref.d.ts +8 -4
- package/package.json +1 -1
package/fesm2022/uni-manager.mjs
CHANGED
|
@@ -8,20 +8,22 @@ class UniErrorManager {
|
|
|
8
8
|
/** Store pubblico (Observable) */
|
|
9
9
|
static { this.store$ = UniErrorManager.store.asObservable(); }
|
|
10
10
|
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
11
|
-
static get
|
|
11
|
+
static get currentValue() {
|
|
12
12
|
return UniErrorManager.store.getValue();
|
|
13
13
|
}
|
|
14
|
-
/*
|
|
14
|
+
/* ------------------------------------------------------------------------------- */
|
|
15
|
+
/* -------------------------------- Metodi: store -------------------------------- */
|
|
16
|
+
/* ------------------------------------------------------------------------------- */
|
|
15
17
|
/**
|
|
16
18
|
* Aggiunge o aggiorna un errore nello store.
|
|
17
19
|
* Se l'errore esiste già (stesso ID), incrementa il contatore 'count'.
|
|
18
20
|
*/
|
|
19
|
-
static
|
|
21
|
+
static add(id, error) {
|
|
20
22
|
// Recupera l'ultimo stato (Map)
|
|
21
|
-
const oldMap = UniErrorManager.
|
|
23
|
+
const oldMap = UniErrorManager.currentValue;
|
|
22
24
|
// Tenta di recuperare l'oggetto corrente
|
|
23
25
|
const oldItem = oldMap.get(id);
|
|
24
|
-
// Crea il nuovo oggetto
|
|
26
|
+
// Crea il nuovo oggetto
|
|
25
27
|
const newItemMap = {
|
|
26
28
|
...error,
|
|
27
29
|
count: oldItem ? oldItem.count + 1 : 1,
|
|
@@ -35,22 +37,26 @@ class UniErrorManager {
|
|
|
35
37
|
/**
|
|
36
38
|
* Rimuove un errore tramite ID
|
|
37
39
|
*/
|
|
38
|
-
static
|
|
40
|
+
static remove(id) {
|
|
39
41
|
// Recupera l'ultimo stato (Map)
|
|
40
|
-
const oldMap = UniErrorManager.
|
|
42
|
+
const oldMap = UniErrorManager.currentValue;
|
|
41
43
|
// Controllo: se non è presente l'item allora termina
|
|
42
44
|
if (!oldMap.has(id))
|
|
43
45
|
return;
|
|
44
|
-
//
|
|
46
|
+
// Crea una nuova istanza della Map
|
|
45
47
|
const newMap = new Map(oldMap);
|
|
46
48
|
newMap.delete(id);
|
|
49
|
+
// Aggiorna il nuovo stato notificando l'observer
|
|
47
50
|
UniErrorManager.store.next(newMap);
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* Svuota completamente la lista degli errori
|
|
51
54
|
*/
|
|
52
|
-
static
|
|
53
|
-
|
|
55
|
+
static removeAll() {
|
|
56
|
+
// Crea una nuova istanza della Map
|
|
57
|
+
const newMap = new Map();
|
|
58
|
+
// Aggiorna il nuovo stato notificando l'observer
|
|
59
|
+
UniErrorManager.store.next(newMap);
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -170,14 +176,20 @@ async function executeImage(url, init) {
|
|
|
170
176
|
* Aggiunge una nuova ref nello store solo se non è già presente.
|
|
171
177
|
* Se l'ID esiste già, l'operazione viene interrotta per preservare il dato originale.
|
|
172
178
|
*/
|
|
173
|
-
function
|
|
179
|
+
function add(id, lineId, url, type) {
|
|
174
180
|
// Recupera l'ultimo stato (Map)
|
|
175
|
-
const oldMap = UniHttpManager.
|
|
181
|
+
const oldMap = UniHttpManager.currentValue;
|
|
176
182
|
// Controllo: se è presente l'item allora termina
|
|
177
183
|
if (oldMap.get(id))
|
|
178
184
|
return;
|
|
179
|
-
// Crea il nuovo oggetto
|
|
180
|
-
const newItemMap = {
|
|
185
|
+
// Crea il nuovo oggetto
|
|
186
|
+
const newItemMap = {
|
|
187
|
+
type,
|
|
188
|
+
lineId,
|
|
189
|
+
url,
|
|
190
|
+
hasError: false,
|
|
191
|
+
pendingCount: 0,
|
|
192
|
+
};
|
|
181
193
|
// Crea una nuova istanza della Map
|
|
182
194
|
const newMap = new Map(oldMap);
|
|
183
195
|
newMap.set(id, newItemMap);
|
|
@@ -187,9 +199,9 @@ function addRef(id, lineId, url, type) {
|
|
|
187
199
|
/**
|
|
188
200
|
* Rimuove un http ref tramite ID
|
|
189
201
|
*/
|
|
190
|
-
function
|
|
202
|
+
function remove(id) {
|
|
191
203
|
// Recupera l'ultimo stato (Map)
|
|
192
|
-
const oldMap = UniHttpManager.
|
|
204
|
+
const oldMap = UniHttpManager.currentValue;
|
|
193
205
|
// Controllo: se non è presente l'item allora termina
|
|
194
206
|
if (!oldMap.has(id))
|
|
195
207
|
return;
|
|
@@ -203,12 +215,11 @@ function removeRef(id) {
|
|
|
203
215
|
* Incrementa o decrementa 'pendingCount' garantendo che non scenda mai sotto lo zero.
|
|
204
216
|
* Se la ref non esiste, l'operazione viene ignorata.
|
|
205
217
|
*/
|
|
206
|
-
function
|
|
218
|
+
function updateIsLoading(id, delta) {
|
|
207
219
|
// Recupera l'ultimo stato (Map)
|
|
208
|
-
const oldMap = UniHttpManager.
|
|
209
|
-
// Tenta di recuperare l'oggetto corrente
|
|
210
|
-
const oldItem = oldMap.get(id);
|
|
220
|
+
const oldMap = UniHttpManager.currentValue;
|
|
211
221
|
// Controllo: se non è presente l'item allora termina
|
|
222
|
+
const oldItem = oldMap.get(id);
|
|
212
223
|
if (!oldItem)
|
|
213
224
|
return;
|
|
214
225
|
// Aggiorna l'oggetto
|
|
@@ -227,12 +238,11 @@ function updateRefIsLoading(id, delta) {
|
|
|
227
238
|
* Se il valore di 'hasError' è identico a quello attuale o se la ref non esiste,
|
|
228
239
|
* l'operazione viene interrotta per evitare aggiornamenti inutili.
|
|
229
240
|
*/
|
|
230
|
-
function
|
|
241
|
+
function updateHasError(id, hasError) {
|
|
231
242
|
// Recupera l'ultimo stato (Map)
|
|
232
|
-
const oldMap = UniHttpManager.
|
|
233
|
-
// Tenta di recuperare l'oggetto corrente
|
|
234
|
-
const oldItem = oldMap.get(id);
|
|
243
|
+
const oldMap = UniHttpManager.currentValue;
|
|
235
244
|
// Controllo: se non è presente l'item allora termina
|
|
245
|
+
const oldItem = oldMap.get(id);
|
|
236
246
|
if (!oldItem)
|
|
237
247
|
return;
|
|
238
248
|
// Controllo: se con lo stesso valore, salta
|
|
@@ -246,6 +256,15 @@ function updateRefHasError(id, hasError) {
|
|
|
246
256
|
// Aggiorna il nuovo stato notificando l'observer
|
|
247
257
|
UniHttpManager.store.next(newMap);
|
|
248
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Svuota completamente la lista delle refs
|
|
261
|
+
*/
|
|
262
|
+
function removeAll() {
|
|
263
|
+
// Crea una nuova istanza della Map
|
|
264
|
+
const newMap = new Map();
|
|
265
|
+
// Aggiorna il nuovo stato notificando l'observer
|
|
266
|
+
UniHttpManager.store.next(newMap);
|
|
267
|
+
}
|
|
249
268
|
|
|
250
269
|
function operatorHandler(operator) {
|
|
251
270
|
// Gestione della concorrenza in base al parametro
|
|
@@ -267,7 +286,7 @@ function errorHandler(err, errorMode, ref) {
|
|
|
267
286
|
return throwError(() => err);
|
|
268
287
|
}
|
|
269
288
|
// Aggiorna la ref nella map
|
|
270
|
-
|
|
289
|
+
updateHasError(ref, true);
|
|
271
290
|
// Gestione dell'errore in base al parametro
|
|
272
291
|
switch (errorMode) {
|
|
273
292
|
case PollingErrorMode.IGNORE:
|
|
@@ -275,12 +294,12 @@ function errorHandler(err, errorMode, ref) {
|
|
|
275
294
|
case PollingErrorMode.SKIP:
|
|
276
295
|
return EMPTY;
|
|
277
296
|
case PollingErrorMode.IGNORE_WITH_ERROR: {
|
|
278
|
-
UniErrorManager.
|
|
297
|
+
UniErrorManager.add(ref, err);
|
|
279
298
|
return of(undefined);
|
|
280
299
|
}
|
|
281
300
|
case PollingErrorMode.STOP:
|
|
282
301
|
default: {
|
|
283
|
-
UniErrorManager.
|
|
302
|
+
UniErrorManager.add(ref, err);
|
|
284
303
|
return throwError(() => err);
|
|
285
304
|
}
|
|
286
305
|
}
|
|
@@ -294,15 +313,15 @@ function http$(url, refType, config, promiseFactory) {
|
|
|
294
313
|
return http$.pipe(tap({
|
|
295
314
|
subscribe: () => {
|
|
296
315
|
/* Creazione reference */
|
|
297
|
-
|
|
316
|
+
add(ref, null, url, refType);
|
|
298
317
|
/* Incrementa per il loader */
|
|
299
318
|
if (hasLoader !== false) {
|
|
300
|
-
|
|
319
|
+
updateIsLoading(ref, 1);
|
|
301
320
|
}
|
|
302
321
|
},
|
|
303
322
|
unsubscribe: () => {
|
|
304
323
|
/* Rimozione reference */
|
|
305
|
-
|
|
324
|
+
remove(ref);
|
|
306
325
|
},
|
|
307
326
|
// TODO: toast
|
|
308
327
|
// next: (res) => {
|
|
@@ -317,7 +336,7 @@ function http$(url, refType, config, promiseFactory) {
|
|
|
317
336
|
}), finalize(() => {
|
|
318
337
|
/* Decrementa per il loader */
|
|
319
338
|
if (hasLoader !== false) {
|
|
320
|
-
|
|
339
|
+
updateIsLoading(ref, -1);
|
|
321
340
|
}
|
|
322
341
|
}));
|
|
323
342
|
});
|
|
@@ -329,24 +348,24 @@ function httpPolling$(url, config, promiseFactory) {
|
|
|
329
348
|
const source$ = timer$.pipe(tap({
|
|
330
349
|
subscribe: () => {
|
|
331
350
|
/* Creazione reference */
|
|
332
|
-
|
|
351
|
+
add(ref, null, url, 'polling');
|
|
333
352
|
},
|
|
334
353
|
unsubscribe: () => {
|
|
335
354
|
/* Rimozione reference */
|
|
336
|
-
|
|
355
|
+
remove(ref);
|
|
337
356
|
},
|
|
338
357
|
}), operatorHandler(operator)((index) => {
|
|
339
358
|
/* Incrementa per il loader */
|
|
340
359
|
if (index === 0 && firstIteration?.hasLoader !== false) {
|
|
341
|
-
|
|
360
|
+
updateIsLoading(ref, 1);
|
|
342
361
|
}
|
|
343
362
|
return defer(() => {
|
|
344
363
|
const http$ = from(promiseFactory());
|
|
345
364
|
return http$.pipe(tap(() => {
|
|
346
365
|
/* Rimozione popup di errore nel caso di errorMode = 'IGNORE_WITH_ERROR' */
|
|
347
366
|
if (errorMode === PollingErrorMode.IGNORE_WITH_ERROR) {
|
|
348
|
-
|
|
349
|
-
UniErrorManager.
|
|
367
|
+
updateHasError(ref, false);
|
|
368
|
+
UniErrorManager.remove(ref);
|
|
350
369
|
}
|
|
351
370
|
// /* Prima risposta */
|
|
352
371
|
// if (index === 0 && firstIteration) {
|
|
@@ -358,7 +377,7 @@ function httpPolling$(url, config, promiseFactory) {
|
|
|
358
377
|
}), finalize(() => {
|
|
359
378
|
/* Decrementa per il loader */
|
|
360
379
|
if (index === 0 && firstIteration?.hasLoader !== false) {
|
|
361
|
-
|
|
380
|
+
updateIsLoading(ref, -1);
|
|
362
381
|
}
|
|
363
382
|
}));
|
|
364
383
|
});
|
|
@@ -380,7 +399,7 @@ class UniHttpManager {
|
|
|
380
399
|
/** Store pubblico (Observable) */
|
|
381
400
|
static { this.store$ = this.store.asObservable(); }
|
|
382
401
|
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
383
|
-
static get
|
|
402
|
+
static get currentValue() {
|
|
384
403
|
return this.store.getValue();
|
|
385
404
|
}
|
|
386
405
|
/* ------------------------------------------------------------------------------- */
|
|
@@ -478,19 +497,13 @@ class UniHttpManager {
|
|
|
478
497
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
479
498
|
}
|
|
480
499
|
/* ------------------------------------------------------------------------------- */
|
|
481
|
-
/*
|
|
500
|
+
/* -------------------------------- Metodi: store -------------------------------- */
|
|
482
501
|
/* ------------------------------------------------------------------------------- */
|
|
483
|
-
/**
|
|
484
|
-
* Aggiorna lo stato di caricamento per una specifica reference.
|
|
485
|
-
*/
|
|
486
|
-
static updateRefIsLoading(id, delta) {
|
|
487
|
-
updateRefIsLoading(id, delta);
|
|
488
|
-
}
|
|
489
502
|
/**
|
|
490
503
|
* Imposta o resetta lo stato di errore per una specifica reference.
|
|
491
504
|
*/
|
|
492
|
-
static
|
|
493
|
-
|
|
505
|
+
static updateHasError(id, hasError) {
|
|
506
|
+
updateHasError(id, hasError);
|
|
494
507
|
}
|
|
495
508
|
}
|
|
496
509
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uni-manager.mjs","sources":["../../../projects/uni-manager/src/lib/error/manager.ts","../../../projects/uni-manager/src/lib/http/enum.ts","../../../projects/uni-manager/src/lib/http/execute.ts","../../../projects/uni-manager/src/lib/http/ref.ts","../../../projects/uni-manager/src/lib/http/handler.ts","../../../projects/uni-manager/src/lib/http/http.ts","../../../projects/uni-manager/src/lib/http/util.ts","../../../projects/uni-manager/src/lib/http/manager.ts","../../../projects/uni-manager/src/public-api.ts","../../../projects/uni-manager/src/uni-manager.ts"],"sourcesContent":["import { BehaviorSubject, type Observable } from 'rxjs';\r\nimport type { IUniFeError, IUniHttpError } from 'uni-error';\r\n\r\nexport class UniErrorManager {\r\n /** Store privato (Subject) */\r\n private static store = new BehaviorSubject<Map<string, IUniFeError | IUniHttpError>>(new Map());\r\n\r\n /** Store pubblico (Observable) */\r\n public static store$: Observable<Map<string, IUniFeError | IUniHttpError>> =\r\n UniErrorManager.store.asObservable();\r\n\r\n /** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */\r\n public static get currentErrors(): Map<string, IUniFeError | IUniHttpError> {\r\n return UniErrorManager.store.getValue();\r\n }\r\n\r\n /* ------------------------------ Methods ------------------------------ */\r\n /**\r\n * Aggiunge o aggiorna un errore nello store.\r\n * Se l'errore esiste già (stesso ID), incrementa il contatore 'count'.\r\n */\r\n public static addError(id: string, error: IUniHttpError | IUniFeError): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniErrorManager.currentErrors;\r\n\r\n // Tenta di recuperare l'oggetto corrente\r\n const oldItem = oldMap.get(id);\r\n\r\n // Crea il nuovo oggetto aggiornato (in base al recupero o meno di uno con lo stesso id)\r\n const newItemMap: IUniFeError | IUniHttpError = {\r\n ...error,\r\n count: oldItem ? oldItem.count + 1 : 1,\r\n };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniErrorManager.store.next(newMap);\r\n }\r\n\r\n /**\r\n * Rimuove un errore tramite ID\r\n */\r\n public static removeError(id: string): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniErrorManager.currentErrors;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldMap.has(id)) return;\r\n\r\n // Aggiorna store\r\n const newMap = new Map(oldMap);\r\n newMap.delete(id);\r\n UniErrorManager.store.next(newMap);\r\n }\r\n\r\n /**\r\n * Svuota completamente la lista degli errori\r\n */\r\n public static clearAll(): void {\r\n UniErrorManager.store.next(new Map());\r\n }\r\n}\r\n","export enum MapOperator {\r\n\t/** Cancella la precedente richiesta, mantiene solo l’ultima */\r\n\tSWITCH_MAP,\r\n\r\n\t/** Ignora nuovi valori finché la corrente non finisce */\r\n\tEXHAUST_MAP,\r\n\r\n\t/** Mette le richieste in coda, le esegue una alla volta */\r\n\tCONCAT_MAP,\r\n\r\n\t/** Esegue tutte le richieste in parallelo, ordine non garantito */\r\n\tMERGE_MAP\r\n}\r\n\r\nexport enum PollingErrorMode {\r\n\t/** Salta questa iterazione emettendo un undefined. Il polling continua al tick successivo. */\r\n\tIGNORE,\r\n\r\n\t/** Salta questa iterazione senza emettere valori. Il polling continua al tick successivo. */\r\n\tSKIP,\r\n\r\n\t/** Interrompe il polling propagando l'errore. */\r\n\tSTOP,\r\n\r\n\t/** Ignora l'errore, lo salva (es. per UI), e continua il polling. Emette `undefined`. */\r\n\tIGNORE_WITH_ERROR\r\n}\r\n\r\nexport enum EmitValueMode {\r\n\t/** Aggiorna lo stato solo se arrivano dati nuovi (distinct) */\r\n\tON_NEW_DATA,\r\n\r\n\t/** Aggiorna lo stato ad ogni chiamata, anche se i dati sono uguali */\r\n\tEVERY_TIME\r\n}\r\n","import { isHttpErrorBody, UniHttpError } from 'uni-error';\r\n\r\nasync function execute(\r\n url: URL,\r\n init?: RequestInit,\r\n): Promise<{ res: Response; type: 'json' | 'image' | null } | undefined> {\r\n try {\r\n /* Esegue chiamata http */\r\n const res = await fetch(url, init);\r\n\r\n /* Nessun contenuto */\r\n if (res.status === 204) {\r\n return undefined;\r\n }\r\n\r\n /* Recupero se è un json */\r\n const contentType = res.headers.get('content-type') ?? '';\r\n const isJson = contentType.startsWith('application/json');\r\n const isImage = contentType.startsWith('image/');\r\n\r\n /* Errore HTTP (quindi risposta ricevuta ma non ok) */\r\n if (!res.ok) {\r\n let errorBody: unknown;\r\n\r\n try {\r\n const resClone = res.clone();\r\n errorBody = isJson ? await resClone.json() : await resClone.text();\r\n } catch {\r\n errorBody = await res.text();\r\n }\r\n\r\n if (isHttpErrorBody(errorBody)) {\r\n const type = errorBody.exceptionType.includes('HttpRequestException') ? 'be' : 'ice';\r\n throw new UniHttpError(type, res.status, url, errorBody);\r\n } else {\r\n const error = new Error(`HTTP ${res.statusText}`);\r\n throw new UniHttpError('base', res.status, url, {\r\n exceptionMessage: error.message,\r\n exceptionType: 'ErrorBase',\r\n message: error.message,\r\n stackTrace: error.stack ?? '',\r\n });\r\n }\r\n }\r\n\r\n return { res, type: isJson ? 'json' : isImage ? 'image' : null };\r\n } catch (error: unknown) {\r\n if (error instanceof TypeError) {\r\n throw new UniHttpError('network', -1, url, {\r\n exceptionMessage: `${error.name}: ${error.message}\\n${error.stack}`,\r\n exceptionType: error.name,\r\n message: error.message,\r\n stackTrace: error.stack ?? '',\r\n });\r\n }\r\n\r\n // Fallback\r\n throw error;\r\n }\r\n}\r\n\r\nexport async function executeHttp<T>(url: URL, init?: RequestInit): Promise<T | undefined> {\r\n /* Esegue chiamata http e vari controlli */\r\n const executeRes = await execute(url, init);\r\n if (!executeRes) return undefined;\r\n\r\n /* Recupero risposta */\r\n const { res, type } = executeRes;\r\n\r\n /* Successo JSON */\r\n if (type === 'json') {\r\n return (await res.json()) as T;\r\n }\r\n\r\n /* Successo testo */\r\n const text = await res.text();\r\n return text ? (text as unknown as T) : undefined;\r\n}\r\n\r\nexport async function executeImage(url: URL, init?: RequestInit): Promise<string | undefined> {\r\n /* Esegue chiamata http e vari controlli */\r\n const executeRes = await execute(url, init);\r\n if (!executeRes) return undefined;\r\n\r\n /* Recupero risposta */\r\n const { res, type } = executeRes;\r\n\r\n /* Successo immagine */\r\n if (type !== 'image') {\r\n throw new Error(`Not image found`);\r\n }\r\n\r\n /* Successo immagine */\r\n const blob = await res.blob();\r\n return URL.createObjectURL(blob);\r\n}\r\n","import { UniHttpManager } from './manager';\r\nimport type { HttpRef } from './model';\r\n\r\n/**\r\n * Aggiunge una nuova ref nello store solo se non è già presente.\r\n * Se l'ID esiste già, l'operazione viene interrotta per preservare il dato originale.\r\n */\r\nexport function addRef(id: string, lineId: null, url: URL, type: HttpRef['type']): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentRefs;\r\n\r\n // Controllo: se è presente l'item allora termina\r\n if (oldMap.get(id)) return;\r\n\r\n // Crea il nuovo oggetto (essendo un nuovo inserimento, i valori sono quelli di default)\r\n const newItemMap: HttpRef = { type, lineId, url, hasError: false, pendingCount: 0 };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Rimuove un http ref tramite ID\r\n */\r\nexport function removeRef(id: string): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentRefs;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldMap.has(id)) return;\r\n\r\n // Aggiorna store\r\n const newMap = new Map(oldMap);\r\n newMap.delete(id);\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Aggiorna il contatore delle chiamate pendenti per una specifica ref.\r\n * Incrementa o decrementa 'pendingCount' garantendo che non scenda mai sotto lo zero.\r\n * Se la ref non esiste, l'operazione viene ignorata.\r\n */\r\nexport function updateRefIsLoading(id: string, delta: -1 | 1): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentRefs;\r\n\r\n // Tenta di recuperare l'oggetto corrente\r\n const oldItem = oldMap.get(id);\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldItem) return;\r\n\r\n // Aggiorna l'oggetto\r\n const newItemMap: HttpRef = {\r\n ...oldItem,\r\n pendingCount: Math.max(0, oldItem.pendingCount + delta),\r\n };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Aggiorna lo stato di errore per una specifica ref.\r\n * Se il valore di 'hasError' è identico a quello attuale o se la ref non esiste,\r\n * l'operazione viene interrotta per evitare aggiornamenti inutili.\r\n */\r\nexport function updateRefHasError(id: string, hasError: boolean): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentRefs;\r\n\r\n // Tenta di recuperare l'oggetto corrente\r\n const oldItem = oldMap.get(id);\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldItem) return;\r\n\r\n // Controllo: se con lo stesso valore, salta\r\n if (oldItem.hasError === hasError) return;\r\n\r\n // Aggiorna l'oggetto\r\n const newItemMap: HttpRef = { ...oldItem, hasError };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n","import {\r\n concatMap,\r\n EMPTY,\r\n exhaustMap,\r\n mergeMap,\r\n Observable,\r\n of,\r\n type OperatorFunction,\r\n switchMap,\r\n throwError,\r\n} from 'rxjs';\r\nimport { UniHttpError } from 'uni-error';\r\n\r\nimport { UniErrorManager } from '../error';\r\nimport { MapOperator, PollingErrorMode } from './enum';\r\nimport { updateRefHasError } from './ref';\r\n\r\nexport function operatorHandler<T>(\r\n operator: MapOperator,\r\n): (\r\n project: (value: number) => Observable<T | undefined>,\r\n) => OperatorFunction<number, T | undefined> {\r\n // Gestione della concorrenza in base al parametro\r\n switch (operator) {\r\n case MapOperator.EXHAUST_MAP:\r\n return (project) => exhaustMap(project);\r\n case MapOperator.CONCAT_MAP:\r\n return (project) => concatMap(project);\r\n case MapOperator.MERGE_MAP:\r\n return (project) => mergeMap(project);\r\n case MapOperator.SWITCH_MAP:\r\n default:\r\n return (project) => switchMap(project);\r\n }\r\n}\r\n\r\nexport function errorHandler(\r\n err: unknown,\r\n errorMode: PollingErrorMode,\r\n ref: string,\r\n): Observable<undefined> {\r\n // Controllo: sia effettivamente un errore di tipo 'UniHttpError'\r\n if (!(err instanceof UniHttpError)) {\r\n return throwError(() => err);\r\n }\r\n\r\n // Aggiorna la ref nella map\r\n updateRefHasError(ref, true);\r\n\r\n // Gestione dell'errore in base al parametro\r\n switch (errorMode) {\r\n case PollingErrorMode.IGNORE:\r\n return of(undefined);\r\n case PollingErrorMode.SKIP:\r\n return EMPTY;\r\n case PollingErrorMode.IGNORE_WITH_ERROR: {\r\n UniErrorManager.addError(ref, err);\r\n return of(undefined);\r\n }\r\n case PollingErrorMode.STOP:\r\n default: {\r\n UniErrorManager.addError(ref, err);\r\n return throwError(() => err);\r\n }\r\n }\r\n}\r\n","import { isEqual } from 'lodash-es';\r\nimport {\r\n catchError,\r\n defer,\r\n distinctUntilChanged,\r\n finalize,\r\n from,\r\n Observable,\r\n tap,\r\n timer,\r\n} from 'rxjs';\r\n\r\nimport { UniErrorManager } from '../error';\r\nimport { EmitValueMode, MapOperator, PollingErrorMode } from './enum';\r\nimport { errorHandler, operatorHandler } from './handler';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { addRef, removeRef, updateRefHasError, updateRefIsLoading } from './ref';\r\n\r\nexport function http$<T>(\r\n url: URL,\r\n refType: HttpRef['type'],\r\n config: HttpConfig<T>,\r\n promiseFactory: () => Promise<T | undefined>,\r\n): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { ref, hasLoader } = config;\r\n\r\n return defer(() => {\r\n const http$ = from(promiseFactory());\r\n return http$.pipe(\r\n tap({\r\n subscribe: () => {\r\n /* Creazione reference */\r\n addRef(ref, null, url, refType);\r\n\r\n /* Incrementa per il loader */\r\n if (hasLoader !== false) {\r\n updateRefIsLoading(ref, 1);\r\n }\r\n },\r\n unsubscribe: () => {\r\n /* Rimozione reference */\r\n removeRef(ref);\r\n },\r\n // TODO: toast\r\n // next: (res) => {\r\n // /* Mostra toast (se presente) */\r\n // if (toast) {\r\n // showToast(res, toast);\r\n // }\r\n // },\r\n }),\r\n catchError((err) => {\r\n /* Gestione errore */\r\n return errorHandler(err, PollingErrorMode.STOP, ref);\r\n }),\r\n finalize(() => {\r\n /* Decrementa per il loader */\r\n if (hasLoader !== false) {\r\n updateRefIsLoading(ref, -1);\r\n }\r\n }),\r\n );\r\n });\r\n}\r\n\r\nexport function httpPolling$<T>(\r\n url: URL,\r\n config: HttpConfigPolling<T>,\r\n promiseFactory: () => Promise<T | undefined>,\r\n): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const {\r\n interval,\r\n ref,\r\n operator = MapOperator.SWITCH_MAP,\r\n errorMode = PollingErrorMode.STOP,\r\n emitValueMode = EmitValueMode.EVERY_TIME,\r\n firstIteration,\r\n } = config;\r\n\r\n const timer$ = timer(0, interval);\r\n const source$ = timer$.pipe(\r\n tap({\r\n subscribe: () => {\r\n /* Creazione reference */\r\n addRef(ref, null, url, 'polling');\r\n },\r\n unsubscribe: () => {\r\n /* Rimozione reference */\r\n removeRef(ref);\r\n },\r\n }),\r\n operatorHandler<T>(operator)((index) => {\r\n /* Incrementa per il loader */\r\n if (index === 0 && firstIteration?.hasLoader !== false) {\r\n updateRefIsLoading(ref, 1);\r\n }\r\n\r\n return defer(() => {\r\n const http$ = from(promiseFactory());\r\n return http$.pipe(\r\n tap(() => {\r\n /* Rimozione popup di errore nel caso di errorMode = 'IGNORE_WITH_ERROR' */\r\n if (errorMode === PollingErrorMode.IGNORE_WITH_ERROR) {\r\n updateRefHasError(ref, false);\r\n UniErrorManager.removeError(ref);\r\n }\r\n\r\n // /* Prima risposta */\r\n // if (index === 0 && firstIteration) {\r\n // showToast(res, firstIteration.toast);\r\n // }\r\n }),\r\n catchError((err) => {\r\n /* Gestione errore */\r\n return errorHandler(err, errorMode, ref);\r\n }),\r\n finalize(() => {\r\n /* Decrementa per il loader */\r\n if (index === 0 && firstIteration?.hasLoader !== false) {\r\n updateRefIsLoading(ref, -1);\r\n }\r\n }),\r\n );\r\n });\r\n }),\r\n );\r\n\r\n return emitValueMode === EmitValueMode.EVERY_TIME\r\n ? source$\r\n : source$.pipe(distinctUntilChanged((prev, cur) => isEqual(prev, cur)));\r\n}\r\n","export function getUrl(hostname: string, port: number, path: string): URL {\r\n const base = `http://${hostname}:${port}`;\r\n return new URL(`/api${path}`, base);\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { BehaviorSubject, Observable } from 'rxjs';\r\n\r\nimport { executeHttp, executeImage } from './execute';\r\nimport { http$, httpPolling$ } from './http';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { updateRefHasError, updateRefIsLoading } from './ref';\r\nimport { getUrl } from './util';\r\n\r\nexport class UniHttpManager {\r\n /** Store privato (Subject) */\r\n public static store = new BehaviorSubject<Map<string, HttpRef>>(new Map());\r\n\r\n /** Store pubblico (Observable) */\r\n public static store$: Observable<Map<string, HttpRef>> = this.store.asObservable();\r\n\r\n /** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */\r\n public static get currentRefs(): Map<string, HttpRef> {\r\n return this.store.getValue();\r\n }\r\n\r\n /** Hostname del server (es. 'api.example.com' o 'localhost') */\r\n private static hostname: string;\r\n\r\n /** Porta del server su cui effettuare le chiamate (es. 80, 443 o 3000) */\r\n private static port: number;\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------------- Metodi: setup -------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Inizializza la configurazione di rete del manager.\r\n * Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.\r\n */\r\n public static setup(hostname: string, port: number): void {\r\n this.hostname = hostname;\r\n this.port = port;\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------ Metodi: http one ------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /** Esegue una singola richiesta HTTP GET.\r\n * Utilizza il path configurato per costruire l'URL completo e restituisce un Observable del risultato.\r\n */\r\n public static get$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Recupera un'immagine tramite una richiesta GET e la trasforma in un formato gestibile (es. Blob o Base64).\r\n * Delega la logica di conversione alla funzione executeImage.\r\n */\r\n public static getImage$(config: HttpConfig<string>): Observable<string | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeImage(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una singola richiesta HTTP PUT per aggiornare una risorsa esistente.\r\n */\r\n public static put$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'PUT' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una richiesta HTTP POST inviando un payload JSON nel corpo della richiesta.\r\n * Imposta automaticamente l'header 'Content-Type' come 'application/json'.\r\n */\r\n public static post$<T>(\r\n config: HttpConfig<T>,\r\n body: Record<string, any>,\r\n ): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = {\r\n ...init,\r\n method: 'POST',\r\n headers: {\r\n ...init?.headers,\r\n 'Content-Type': 'application/json',\r\n },\r\n body: JSON.stringify(body),\r\n };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ---------------------------- Metodi: http polling ----------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Avvia un ciclo di polling basato su richieste GET.\r\n * Continua a emettere valori in base alla configurazione di intervallo definita in HttpConfigPolling.\r\n */\r\n public static getHttpPolling$<T>(config: HttpConfigPolling<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Avvia un ciclo di polling basato su richieste POST.\r\n * Invia il body specificato a ogni iterazione del ciclo.\r\n */\r\n public static postHttpPolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body: Record<any, any>,\r\n ): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = {\r\n ...init,\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify(body),\r\n };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* --------------------------------- Metodi: ref --------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Aggiorna lo stato di caricamento per una specifica reference.\r\n */\r\n public static updateRefIsLoading(id: string, delta: -1 | 1): void {\r\n updateRefIsLoading(id, delta);\r\n }\r\n\r\n /**\r\n * Imposta o resetta lo stato di errore per una specifica reference.\r\n */\r\n public static updateRefHasError(id: string, hasError: boolean): void {\r\n updateRefHasError(id, hasError);\r\n }\r\n}\r\n","/*\r\n * Public API Surface of uni-manager\r\n */\r\n\r\nexport * from './lib/error';\r\nexport * from './lib/http';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAGa,eAAe,CAAA;;aAEX,IAAK,CAAA,KAAA,GAAG,IAAI,eAAe,CAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;;AAGlF,IAAA,SAAA,IAAA,CAAA,MAAM,GAClB,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;;AAGhC,IAAA,WAAW,aAAa,GAAA;AAC7B,QAAA,OAAO,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE;;;AAIzC;;;AAGG;AACI,IAAA,OAAO,QAAQ,CAAC,EAAU,EAAE,KAAkC,EAAA;;AAEnE,QAAA,MAAM,MAAM,GAAG,eAAe,CAAC,aAAa;;QAG5C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;;AAG9B,QAAA,MAAM,UAAU,GAAgC;AAC9C,YAAA,GAAG,KAAK;AACR,YAAA,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC;SACvC;;AAGD,QAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;AAC9B,QAAA,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC;;AAG1B,QAAA,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;;AAGpC;;AAEG;IACI,OAAO,WAAW,CAAC,EAAU,EAAA;;A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;AAC3D,QAAA,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC;;;;AC1JnC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"uni-manager.mjs","sources":["../../../projects/uni-manager/src/lib/error/manager.ts","../../../projects/uni-manager/src/lib/http/enum.ts","../../../projects/uni-manager/src/lib/http/execute.ts","../../../projects/uni-manager/src/lib/http/ref.ts","../../../projects/uni-manager/src/lib/http/handler.ts","../../../projects/uni-manager/src/lib/http/http.ts","../../../projects/uni-manager/src/lib/http/util.ts","../../../projects/uni-manager/src/lib/http/manager.ts","../../../projects/uni-manager/src/public-api.ts","../../../projects/uni-manager/src/uni-manager.ts"],"sourcesContent":["import { BehaviorSubject, type Observable } from 'rxjs';\r\nimport type { IUniFeError, IUniHttpError } from 'uni-error';\r\n\r\nexport class UniErrorManager {\r\n /** Store privato (Subject) */\r\n private static store = new BehaviorSubject<Map<string, IUniFeError | IUniHttpError>>(new Map());\r\n\r\n /** Store pubblico (Observable) */\r\n public static store$: Observable<Map<string, IUniFeError | IUniHttpError>> =\r\n UniErrorManager.store.asObservable();\r\n\r\n /** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */\r\n public static get currentValue(): Map<string, IUniFeError | IUniHttpError> {\r\n return UniErrorManager.store.getValue();\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------------- Metodi: store -------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Aggiunge o aggiorna un errore nello store.\r\n * Se l'errore esiste già (stesso ID), incrementa il contatore 'count'.\r\n */\r\n public static add(id: string, error: IUniHttpError | IUniFeError): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniErrorManager.currentValue;\r\n\r\n // Tenta di recuperare l'oggetto corrente\r\n const oldItem = oldMap.get(id);\r\n\r\n // Crea il nuovo oggetto\r\n const newItemMap: IUniFeError | IUniHttpError = {\r\n ...error,\r\n count: oldItem ? oldItem.count + 1 : 1,\r\n };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniErrorManager.store.next(newMap);\r\n }\r\n\r\n /**\r\n * Rimuove un errore tramite ID\r\n */\r\n public static remove(id: string): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniErrorManager.currentValue;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldMap.has(id)) return;\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.delete(id);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniErrorManager.store.next(newMap);\r\n }\r\n\r\n /**\r\n * Svuota completamente la lista degli errori\r\n */\r\n public static removeAll(): void {\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map();\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniErrorManager.store.next(newMap);\r\n }\r\n}\r\n","export enum MapOperator {\r\n\t/** Cancella la precedente richiesta, mantiene solo l’ultima */\r\n\tSWITCH_MAP,\r\n\r\n\t/** Ignora nuovi valori finché la corrente non finisce */\r\n\tEXHAUST_MAP,\r\n\r\n\t/** Mette le richieste in coda, le esegue una alla volta */\r\n\tCONCAT_MAP,\r\n\r\n\t/** Esegue tutte le richieste in parallelo, ordine non garantito */\r\n\tMERGE_MAP\r\n}\r\n\r\nexport enum PollingErrorMode {\r\n\t/** Salta questa iterazione emettendo un undefined. Il polling continua al tick successivo. */\r\n\tIGNORE,\r\n\r\n\t/** Salta questa iterazione senza emettere valori. Il polling continua al tick successivo. */\r\n\tSKIP,\r\n\r\n\t/** Interrompe il polling propagando l'errore. */\r\n\tSTOP,\r\n\r\n\t/** Ignora l'errore, lo salva (es. per UI), e continua il polling. Emette `undefined`. */\r\n\tIGNORE_WITH_ERROR\r\n}\r\n\r\nexport enum EmitValueMode {\r\n\t/** Aggiorna lo stato solo se arrivano dati nuovi (distinct) */\r\n\tON_NEW_DATA,\r\n\r\n\t/** Aggiorna lo stato ad ogni chiamata, anche se i dati sono uguali */\r\n\tEVERY_TIME\r\n}\r\n","import { isHttpErrorBody, UniHttpError } from 'uni-error';\r\n\r\nasync function execute(\r\n url: URL,\r\n init?: RequestInit,\r\n): Promise<{ res: Response; type: 'json' | 'image' | null } | undefined> {\r\n try {\r\n /* Esegue chiamata http */\r\n const res = await fetch(url, init);\r\n\r\n /* Nessun contenuto */\r\n if (res.status === 204) {\r\n return undefined;\r\n }\r\n\r\n /* Recupero se è un json */\r\n const contentType = res.headers.get('content-type') ?? '';\r\n const isJson = contentType.startsWith('application/json');\r\n const isImage = contentType.startsWith('image/');\r\n\r\n /* Errore HTTP (quindi risposta ricevuta ma non ok) */\r\n if (!res.ok) {\r\n let errorBody: unknown;\r\n\r\n try {\r\n const resClone = res.clone();\r\n errorBody = isJson ? await resClone.json() : await resClone.text();\r\n } catch {\r\n errorBody = await res.text();\r\n }\r\n\r\n if (isHttpErrorBody(errorBody)) {\r\n const type = errorBody.exceptionType.includes('HttpRequestException') ? 'be' : 'ice';\r\n throw new UniHttpError(type, res.status, url, errorBody);\r\n } else {\r\n const error = new Error(`HTTP ${res.statusText}`);\r\n throw new UniHttpError('base', res.status, url, {\r\n exceptionMessage: error.message,\r\n exceptionType: 'ErrorBase',\r\n message: error.message,\r\n stackTrace: error.stack ?? '',\r\n });\r\n }\r\n }\r\n\r\n return { res, type: isJson ? 'json' : isImage ? 'image' : null };\r\n } catch (error: unknown) {\r\n if (error instanceof TypeError) {\r\n throw new UniHttpError('network', -1, url, {\r\n exceptionMessage: `${error.name}: ${error.message}\\n${error.stack}`,\r\n exceptionType: error.name,\r\n message: error.message,\r\n stackTrace: error.stack ?? '',\r\n });\r\n }\r\n\r\n // Fallback\r\n throw error;\r\n }\r\n}\r\n\r\nexport async function executeHttp<T>(url: URL, init?: RequestInit): Promise<T | undefined> {\r\n /* Esegue chiamata http e vari controlli */\r\n const executeRes = await execute(url, init);\r\n if (!executeRes) return undefined;\r\n\r\n /* Recupero risposta */\r\n const { res, type } = executeRes;\r\n\r\n /* Successo JSON */\r\n if (type === 'json') {\r\n return (await res.json()) as T;\r\n }\r\n\r\n /* Successo testo */\r\n const text = await res.text();\r\n return text ? (text as unknown as T) : undefined;\r\n}\r\n\r\nexport async function executeImage(url: URL, init?: RequestInit): Promise<string | undefined> {\r\n /* Esegue chiamata http e vari controlli */\r\n const executeRes = await execute(url, init);\r\n if (!executeRes) return undefined;\r\n\r\n /* Recupero risposta */\r\n const { res, type } = executeRes;\r\n\r\n /* Successo immagine */\r\n if (type !== 'image') {\r\n throw new Error(`Not image found`);\r\n }\r\n\r\n /* Successo immagine */\r\n const blob = await res.blob();\r\n return URL.createObjectURL(blob);\r\n}\r\n","import { UniHttpManager } from './manager';\r\nimport type { HttpRef } from './model';\r\n\r\n/**\r\n * Aggiunge una nuova ref nello store solo se non è già presente.\r\n * Se l'ID esiste già, l'operazione viene interrotta per preservare il dato originale.\r\n */\r\nexport function add(id: string, lineId: null, url: URL, type: HttpRef['type']): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentValue;\r\n\r\n // Controllo: se è presente l'item allora termina\r\n if (oldMap.get(id)) return;\r\n\r\n // Crea il nuovo oggetto\r\n const newItemMap: HttpRef = {\r\n type,\r\n lineId,\r\n url,\r\n hasError: false,\r\n pendingCount: 0,\r\n };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Rimuove un http ref tramite ID\r\n */\r\nexport function remove(id: string): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentValue;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n if (!oldMap.has(id)) return;\r\n\r\n // Aggiorna store\r\n const newMap = new Map(oldMap);\r\n newMap.delete(id);\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Aggiorna il contatore delle chiamate pendenti per una specifica ref.\r\n * Incrementa o decrementa 'pendingCount' garantendo che non scenda mai sotto lo zero.\r\n * Se la ref non esiste, l'operazione viene ignorata.\r\n */\r\nexport function updateIsLoading(id: string, delta: -1 | 1): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentValue;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n const oldItem = oldMap.get(id);\r\n if (!oldItem) return;\r\n\r\n // Aggiorna l'oggetto\r\n const newItemMap: HttpRef = {\r\n ...oldItem,\r\n pendingCount: Math.max(0, oldItem.pendingCount + delta),\r\n };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Aggiorna lo stato di errore per una specifica ref.\r\n * Se il valore di 'hasError' è identico a quello attuale o se la ref non esiste,\r\n * l'operazione viene interrotta per evitare aggiornamenti inutili.\r\n */\r\nexport function updateHasError(id: string, hasError: boolean): void {\r\n // Recupera l'ultimo stato (Map)\r\n const oldMap = UniHttpManager.currentValue;\r\n\r\n // Controllo: se non è presente l'item allora termina\r\n const oldItem = oldMap.get(id);\r\n if (!oldItem) return;\r\n\r\n // Controllo: se con lo stesso valore, salta\r\n if (oldItem.hasError === hasError) return;\r\n\r\n // Aggiorna l'oggetto\r\n const newItemMap: HttpRef = { ...oldItem, hasError };\r\n\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map(oldMap);\r\n newMap.set(id, newItemMap);\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n\r\n/**\r\n * Svuota completamente la lista delle refs\r\n */\r\nexport function removeAll(): void {\r\n // Crea una nuova istanza della Map\r\n const newMap = new Map();\r\n\r\n // Aggiorna il nuovo stato notificando l'observer\r\n UniHttpManager.store.next(newMap);\r\n}\r\n","import {\r\n concatMap,\r\n EMPTY,\r\n exhaustMap,\r\n mergeMap,\r\n Observable,\r\n of,\r\n type OperatorFunction,\r\n switchMap,\r\n throwError,\r\n} from 'rxjs';\r\nimport { UniHttpError } from 'uni-error';\r\n\r\nimport { UniErrorManager } from '../error';\r\nimport { MapOperator, PollingErrorMode } from './enum';\r\nimport { updateHasError } from './ref';\r\n\r\nexport function operatorHandler<T>(\r\n operator: MapOperator,\r\n): (\r\n project: (value: number) => Observable<T | undefined>,\r\n) => OperatorFunction<number, T | undefined> {\r\n // Gestione della concorrenza in base al parametro\r\n switch (operator) {\r\n case MapOperator.EXHAUST_MAP:\r\n return (project) => exhaustMap(project);\r\n case MapOperator.CONCAT_MAP:\r\n return (project) => concatMap(project);\r\n case MapOperator.MERGE_MAP:\r\n return (project) => mergeMap(project);\r\n case MapOperator.SWITCH_MAP:\r\n default:\r\n return (project) => switchMap(project);\r\n }\r\n}\r\n\r\nexport function errorHandler(\r\n err: unknown,\r\n errorMode: PollingErrorMode,\r\n ref: string,\r\n): Observable<undefined> {\r\n // Controllo: sia effettivamente un errore di tipo 'UniHttpError'\r\n if (!(err instanceof UniHttpError)) {\r\n return throwError(() => err);\r\n }\r\n\r\n // Aggiorna la ref nella map\r\n updateHasError(ref, true);\r\n\r\n // Gestione dell'errore in base al parametro\r\n switch (errorMode) {\r\n case PollingErrorMode.IGNORE:\r\n return of(undefined);\r\n case PollingErrorMode.SKIP:\r\n return EMPTY;\r\n case PollingErrorMode.IGNORE_WITH_ERROR: {\r\n UniErrorManager.add(ref, err);\r\n return of(undefined);\r\n }\r\n case PollingErrorMode.STOP:\r\n default: {\r\n UniErrorManager.add(ref, err);\r\n return throwError(() => err);\r\n }\r\n }\r\n}\r\n","import { isEqual } from 'lodash-es';\r\nimport {\r\n catchError,\r\n defer,\r\n distinctUntilChanged,\r\n finalize,\r\n from,\r\n Observable,\r\n tap,\r\n timer,\r\n} from 'rxjs';\r\n\r\nimport { UniErrorManager } from '../error';\r\nimport { EmitValueMode, MapOperator, PollingErrorMode } from './enum';\r\nimport { errorHandler, operatorHandler } from './handler';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { add, remove, updateHasError, updateIsLoading } from './ref';\r\n\r\nexport function http$<T>(\r\n url: URL,\r\n refType: HttpRef['type'],\r\n config: HttpConfig<T>,\r\n promiseFactory: () => Promise<T | undefined>,\r\n): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { ref, hasLoader } = config;\r\n\r\n return defer(() => {\r\n const http$ = from(promiseFactory());\r\n return http$.pipe(\r\n tap({\r\n subscribe: () => {\r\n /* Creazione reference */\r\n add(ref, null, url, refType);\r\n\r\n /* Incrementa per il loader */\r\n if (hasLoader !== false) {\r\n updateIsLoading(ref, 1);\r\n }\r\n },\r\n unsubscribe: () => {\r\n /* Rimozione reference */\r\n remove(ref);\r\n },\r\n // TODO: toast\r\n // next: (res) => {\r\n // /* Mostra toast (se presente) */\r\n // if (toast) {\r\n // showToast(res, toast);\r\n // }\r\n // },\r\n }),\r\n catchError((err) => {\r\n /* Gestione errore */\r\n return errorHandler(err, PollingErrorMode.STOP, ref);\r\n }),\r\n finalize(() => {\r\n /* Decrementa per il loader */\r\n if (hasLoader !== false) {\r\n updateIsLoading(ref, -1);\r\n }\r\n }),\r\n );\r\n });\r\n}\r\n\r\nexport function httpPolling$<T>(\r\n url: URL,\r\n config: HttpConfigPolling<T>,\r\n promiseFactory: () => Promise<T | undefined>,\r\n): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const {\r\n interval,\r\n ref,\r\n operator = MapOperator.SWITCH_MAP,\r\n errorMode = PollingErrorMode.STOP,\r\n emitValueMode = EmitValueMode.EVERY_TIME,\r\n firstIteration,\r\n } = config;\r\n\r\n const timer$ = timer(0, interval);\r\n const source$ = timer$.pipe(\r\n tap({\r\n subscribe: () => {\r\n /* Creazione reference */\r\n add(ref, null, url, 'polling');\r\n },\r\n unsubscribe: () => {\r\n /* Rimozione reference */\r\n remove(ref);\r\n },\r\n }),\r\n operatorHandler<T>(operator)((index) => {\r\n /* Incrementa per il loader */\r\n if (index === 0 && firstIteration?.hasLoader !== false) {\r\n updateIsLoading(ref, 1);\r\n }\r\n\r\n return defer(() => {\r\n const http$ = from(promiseFactory());\r\n return http$.pipe(\r\n tap(() => {\r\n /* Rimozione popup di errore nel caso di errorMode = 'IGNORE_WITH_ERROR' */\r\n if (errorMode === PollingErrorMode.IGNORE_WITH_ERROR) {\r\n updateHasError(ref, false);\r\n UniErrorManager.remove(ref);\r\n }\r\n\r\n // /* Prima risposta */\r\n // if (index === 0 && firstIteration) {\r\n // showToast(res, firstIteration.toast);\r\n // }\r\n }),\r\n catchError((err) => {\r\n /* Gestione errore */\r\n return errorHandler(err, errorMode, ref);\r\n }),\r\n finalize(() => {\r\n /* Decrementa per il loader */\r\n if (index === 0 && firstIteration?.hasLoader !== false) {\r\n updateIsLoading(ref, -1);\r\n }\r\n }),\r\n );\r\n });\r\n }),\r\n );\r\n\r\n return emitValueMode === EmitValueMode.EVERY_TIME\r\n ? source$\r\n : source$.pipe(distinctUntilChanged((prev, cur) => isEqual(prev, cur)));\r\n}\r\n","export function getUrl(hostname: string, port: number, path: string): URL {\r\n const base = `http://${hostname}:${port}`;\r\n return new URL(`/api${path}`, base);\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { BehaviorSubject, Observable } from 'rxjs';\r\n\r\nimport { executeHttp, executeImage } from './execute';\r\nimport { http$, httpPolling$ } from './http';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { updateHasError } from './ref';\r\nimport { getUrl } from './util';\r\n\r\nexport class UniHttpManager {\r\n /** Hostname del server (es. 'api.example.com' o 'localhost') */\r\n private static hostname: string;\r\n\r\n /** Porta del server su cui effettuare le chiamate (es. 80, 443 o 3000) */\r\n private static port: number;\r\n\r\n /** Store privato (Subject) */\r\n public static store = new BehaviorSubject<Map<string, HttpRef>>(new Map());\r\n\r\n /** Store pubblico (Observable) */\r\n public static store$: Observable<Map<string, HttpRef>> = this.store.asObservable();\r\n\r\n /** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */\r\n public static get currentValue(): Map<string, HttpRef> {\r\n return this.store.getValue();\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------------- Metodi: setup -------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Inizializza la configurazione di rete del manager.\r\n * Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.\r\n */\r\n public static setup(hostname: string, port: number): void {\r\n this.hostname = hostname;\r\n this.port = port;\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------ Metodi: http one ------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /** Esegue una singola richiesta HTTP GET.\r\n * Utilizza il path configurato per costruire l'URL completo e restituisce un Observable del risultato.\r\n */\r\n public static get$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Recupera un'immagine tramite una richiesta GET e la trasforma in un formato gestibile (es. Blob o Base64).\r\n * Delega la logica di conversione alla funzione executeImage.\r\n */\r\n public static getImage$(config: HttpConfig<string>): Observable<string | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeImage(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una singola richiesta HTTP PUT per aggiornare una risorsa esistente.\r\n */\r\n public static put$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'PUT' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una richiesta HTTP POST inviando un payload JSON nel corpo della richiesta.\r\n * Imposta automaticamente l'header 'Content-Type' come 'application/json'.\r\n */\r\n public static post$<T>(\r\n config: HttpConfig<T>,\r\n body: Record<string, any>,\r\n ): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = {\r\n ...init,\r\n method: 'POST',\r\n headers: {\r\n ...init?.headers,\r\n 'Content-Type': 'application/json',\r\n },\r\n body: JSON.stringify(body),\r\n };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ---------------------------- Metodi: http polling ----------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Avvia un ciclo di polling basato su richieste GET.\r\n * Continua a emettere valori in base alla configurazione di intervallo definita in HttpConfigPolling.\r\n */\r\n public static getHttpPolling$<T>(config: HttpConfigPolling<T>): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = { ...init, method: 'GET' };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Avvia un ciclo di polling basato su richieste POST.\r\n * Invia il body specificato a ogni iterazione del ciclo.\r\n */\r\n public static postHttpPolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body: Record<any, any>,\r\n ): Observable<T | undefined> {\r\n /* Recupero configurazione */\r\n const { path, init } = config;\r\n\r\n const initCustom: RequestInit = {\r\n ...init,\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify(body),\r\n };\r\n const url = getUrl(this.hostname, this.port, path);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------------- Metodi: store -------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Imposta o resetta lo stato di errore per una specifica reference.\r\n */\r\n public static updateHasError(id: string, hasError: boolean): void {\r\n updateHasError(id, hasError);\r\n }\r\n}\r\n","/*\r\n * Public API Surface of uni-manager\r\n */\r\n\r\nexport * from './lib/error';\r\nexport * from './lib/http';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAGa,eAAe,CAAA;;aAEX,IAAK,CAAA,KAAA,GAAG,IAAI,eAAe,CAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;;AAGlF,IAAA,SAAA,IAAA,CAAA,MAAM,GAClB,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;;AAGhC,IAAA,WAAW,YAAY,GAAA;AAC5B,QAAA,OAAO,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE;;;;;AAMzC;;;AAGG;AACI,IAAA,OAAO,GAAG,CAAC,EAAU,EAAE,KAAkC,EAAA;;AAE9D,QAAA,MAAM,MAAM,GAAG,eAAe,CAAC,YAAY;;QAG3C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;;AAG9B,QAAA,MAAM,UAAU,GAAgC;AAC9C,YAAA,GAAG,KAAK;AACR,YAAA,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC;SACvC;;AAGD,QAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;AAC9B,QAAA,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC;;AAG1B,QAAA,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;;AAGpC;;AAEG;IACI,OAAO,MAAM,CAAC,EAAU,EAAA;;AAE7B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;;AAEG;AACI,IAAA,OAAO,cAAc,CAAC,EAAU,EAAE,QAAiB,EAAA;AACxD,QAAA,cAAc,CAAC,EAAE,EAAE,QAAQ,CAAC;;;;ACnJhC;;AAEG;;ACFH;;AAEG;;;;"}
|
package/lib/error/manager.d.ts
CHANGED
|
@@ -6,18 +6,18 @@ export declare class UniErrorManager {
|
|
|
6
6
|
/** Store pubblico (Observable) */
|
|
7
7
|
static store$: Observable<Map<string, IUniFeError | IUniHttpError>>;
|
|
8
8
|
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
9
|
-
static get
|
|
9
|
+
static get currentValue(): Map<string, IUniFeError | IUniHttpError>;
|
|
10
10
|
/**
|
|
11
11
|
* Aggiunge o aggiorna un errore nello store.
|
|
12
12
|
* Se l'errore esiste già (stesso ID), incrementa il contatore 'count'.
|
|
13
13
|
*/
|
|
14
|
-
static
|
|
14
|
+
static add(id: string, error: IUniHttpError | IUniFeError): void;
|
|
15
15
|
/**
|
|
16
16
|
* Rimuove un errore tramite ID
|
|
17
17
|
*/
|
|
18
|
-
static
|
|
18
|
+
static remove(id: string): void;
|
|
19
19
|
/**
|
|
20
20
|
* Svuota completamente la lista degli errori
|
|
21
21
|
*/
|
|
22
|
-
static
|
|
22
|
+
static removeAll(): void;
|
|
23
23
|
}
|
package/lib/http/manager.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
2
2
|
import type { HttpConfig, HttpConfigPolling, HttpRef } from './model';
|
|
3
3
|
export declare class UniHttpManager {
|
|
4
|
+
/** Hostname del server (es. 'api.example.com' o 'localhost') */
|
|
5
|
+
private static hostname;
|
|
6
|
+
/** Porta del server su cui effettuare le chiamate (es. 80, 443 o 3000) */
|
|
7
|
+
private static port;
|
|
4
8
|
/** Store privato (Subject) */
|
|
5
9
|
static store: BehaviorSubject<Map<string, HttpRef>>;
|
|
6
10
|
/** Store pubblico (Observable) */
|
|
7
11
|
static store$: Observable<Map<string, HttpRef>>;
|
|
8
12
|
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
9
|
-
static get
|
|
10
|
-
/** Hostname del server (es. 'api.example.com' o 'localhost') */
|
|
11
|
-
private static hostname;
|
|
12
|
-
/** Porta del server su cui effettuare le chiamate (es. 80, 443 o 3000) */
|
|
13
|
-
private static port;
|
|
13
|
+
static get currentValue(): Map<string, HttpRef>;
|
|
14
14
|
/**
|
|
15
15
|
* Inizializza la configurazione di rete del manager.
|
|
16
16
|
* Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.
|
|
@@ -44,12 +44,8 @@ export declare class UniHttpManager {
|
|
|
44
44
|
* Invia il body specificato a ogni iterazione del ciclo.
|
|
45
45
|
*/
|
|
46
46
|
static postHttpPolling$<T>(config: HttpConfigPolling<T>, body: Record<any, any>): Observable<T | undefined>;
|
|
47
|
-
/**
|
|
48
|
-
* Aggiorna lo stato di caricamento per una specifica reference.
|
|
49
|
-
*/
|
|
50
|
-
static updateRefIsLoading(id: string, delta: -1 | 1): void;
|
|
51
47
|
/**
|
|
52
48
|
* Imposta o resetta lo stato di errore per una specifica reference.
|
|
53
49
|
*/
|
|
54
|
-
static
|
|
50
|
+
static updateHasError(id: string, hasError: boolean): void;
|
|
55
51
|
}
|
package/lib/http/ref.d.ts
CHANGED
|
@@ -3,20 +3,24 @@ import type { HttpRef } from './model';
|
|
|
3
3
|
* Aggiunge una nuova ref nello store solo se non è già presente.
|
|
4
4
|
* Se l'ID esiste già, l'operazione viene interrotta per preservare il dato originale.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function add(id: string, lineId: null, url: URL, type: HttpRef['type']): void;
|
|
7
7
|
/**
|
|
8
8
|
* Rimuove un http ref tramite ID
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function remove(id: string): void;
|
|
11
11
|
/**
|
|
12
12
|
* Aggiorna il contatore delle chiamate pendenti per una specifica ref.
|
|
13
13
|
* Incrementa o decrementa 'pendingCount' garantendo che non scenda mai sotto lo zero.
|
|
14
14
|
* Se la ref non esiste, l'operazione viene ignorata.
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function updateIsLoading(id: string, delta: -1 | 1): void;
|
|
17
17
|
/**
|
|
18
18
|
* Aggiorna lo stato di errore per una specifica ref.
|
|
19
19
|
* Se il valore di 'hasError' è identico a quello attuale o se la ref non esiste,
|
|
20
20
|
* l'operazione viene interrotta per evitare aggiornamenti inutili.
|
|
21
21
|
*/
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function updateHasError(id: string, hasError: boolean): void;
|
|
23
|
+
/**
|
|
24
|
+
* Svuota completamente la lista delle refs
|
|
25
|
+
*/
|
|
26
|
+
export declare function removeAll(): void;
|