uni-manager 0.1.0 → 0.1.2
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-http.mjs +91 -89
- package/fesm2022/uni-manager-http.mjs.map +1 -1
- package/fesm2022/uni-manager-locale.mjs +3 -3
- package/fesm2022/uni-manager-locale.mjs.map +1 -1
- package/fesm2022/uni-manager-toast.mjs +16 -14
- package/fesm2022/uni-manager-toast.mjs.map +1 -1
- package/fesm2022/uni-manager.mjs +110 -106
- package/fesm2022/uni-manager.mjs.map +1 -1
- package/package.json +2 -2
- package/types/uni-manager-http.d.ts +6 -11
- package/types/uni-manager-locale.d.ts +1 -1
- package/types/uni-manager-toast.d.ts +2 -4
- package/types/uni-manager.d.ts +9 -16
|
@@ -17,7 +17,7 @@ import { concatMap } from 'rxjs/internal/operators/concatMap';
|
|
|
17
17
|
import { exhaustMap } from 'rxjs/internal/operators/exhaustMap';
|
|
18
18
|
import { mergeMap } from 'rxjs/internal/operators/mergeMap';
|
|
19
19
|
import { switchMap } from 'rxjs/internal/operators/switchMap';
|
|
20
|
-
import { UniHttpError,
|
|
20
|
+
import { UniHttpError, isHttpException } from 'uni-error/http';
|
|
21
21
|
import { UniTypeDateManager } from 'uni-manager/type';
|
|
22
22
|
|
|
23
23
|
var MapOperator;
|
|
@@ -69,28 +69,27 @@ function operatorHandler(operator) {
|
|
|
69
69
|
}
|
|
70
70
|
function errorHandler(err, errorMode, ref) {
|
|
71
71
|
// Controllo: sia effettivamente un errore di tipo 'UniHttpError'
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
case PollingErrorMode.STOP: {
|
|
90
|
-
UniErrorManager.add(ref, err);
|
|
91
|
-
return throwError(() => err);
|
|
72
|
+
if (err instanceof UniHttpError) {
|
|
73
|
+
switch (errorMode) {
|
|
74
|
+
case PollingErrorMode.IGNORE: {
|
|
75
|
+
return of();
|
|
76
|
+
}
|
|
77
|
+
case PollingErrorMode.SKIP: {
|
|
78
|
+
return EMPTY;
|
|
79
|
+
}
|
|
80
|
+
case PollingErrorMode.IGNORE_WITH_ERROR: {
|
|
81
|
+
UniErrorManager.add(ref, err);
|
|
82
|
+
return of();
|
|
83
|
+
}
|
|
84
|
+
case PollingErrorMode.STOP: {
|
|
85
|
+
UniErrorManager.add(ref, err);
|
|
86
|
+
return throwError(() => err);
|
|
87
|
+
}
|
|
92
88
|
}
|
|
93
89
|
}
|
|
90
|
+
else {
|
|
91
|
+
return throwError(() => err);
|
|
92
|
+
}
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
/* ------------------------------------------------------------------------------- */
|
|
@@ -125,6 +124,8 @@ function http$(url, refType, config, promiseFactory) {
|
|
|
125
124
|
}
|
|
126
125
|
},
|
|
127
126
|
}), catchError((err) => {
|
|
127
|
+
// Aggiorna la ref nella map
|
|
128
|
+
updateHasError(ref, true);
|
|
128
129
|
/* Gestione errore */
|
|
129
130
|
return errorHandler(err, PollingErrorMode.STOP, ref);
|
|
130
131
|
}), finalize(() => {
|
|
@@ -170,6 +171,8 @@ function httpPolling$(url, config, promiseFactory) {
|
|
|
170
171
|
UniToastManager.showHttp(firstIteration.toast, res);
|
|
171
172
|
}
|
|
172
173
|
}), catchError((err) => {
|
|
174
|
+
// Aggiorna la ref nella map
|
|
175
|
+
updateHasError(ref, true);
|
|
173
176
|
/* Gestione errore */
|
|
174
177
|
return errorHandler(err, errorMode, ref);
|
|
175
178
|
}), finalize(() => {
|
|
@@ -271,66 +274,65 @@ function updateHasError(id, hasError) {
|
|
|
271
274
|
// Aggiorna il nuovo stato notificando l'observer
|
|
272
275
|
UniHttpManager.store.next(newMap);
|
|
273
276
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Svuota completamente la lista delle refs
|
|
276
|
-
*/
|
|
277
|
-
function removeAll() {
|
|
278
|
-
// Crea una nuova istanza della Map
|
|
279
|
-
const newMap = new Map();
|
|
280
|
-
// Aggiorna il nuovo stato notificando l'observer
|
|
281
|
-
UniHttpManager.store.next(newMap);
|
|
282
|
-
}
|
|
283
277
|
|
|
284
278
|
async function execute(url, init) {
|
|
285
279
|
try {
|
|
286
|
-
/*
|
|
280
|
+
/* Esecuzione della richiesta HTTP nativa */
|
|
287
281
|
const res = await fetch(url, init);
|
|
288
|
-
/*
|
|
282
|
+
/* Gestione dello stato 204: assenza di contenuto legittima */
|
|
289
283
|
if (res.status === 204) {
|
|
290
284
|
return undefined;
|
|
291
285
|
}
|
|
292
|
-
/*
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
286
|
+
/*Gestione ok HTTP: risposta ricevuta dal server con stato valido */
|
|
287
|
+
if (res.ok) {
|
|
288
|
+
return res;
|
|
289
|
+
}
|
|
290
|
+
/* Gestione Errore HTTP: risposta ricevuta dal server ma con stato non valido */
|
|
291
|
+
let httpErrorPayload;
|
|
292
|
+
try {
|
|
293
|
+
/* Clonazione della risposta per l'ispezione del payload senza consumare lo stream originale */
|
|
294
|
+
const resClone = res.clone();
|
|
295
|
+
/* Recupero se è un json */
|
|
296
|
+
const contentType = res.headers.get('content-type') ?? '';
|
|
297
|
+
const isJson = contentType.startsWith('application/json');
|
|
298
|
+
/* Estrazione del corpo dell'errore in base al formato rilevato */
|
|
299
|
+
httpErrorPayload = isJson ? await resClone.json() : await resClone.text();
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
/* Fallback in caso di fallimento della clonazione o del parsing del testo */
|
|
303
|
+
httpErrorPayload = `Failed to parse error response body (Status: ${res.status})`;
|
|
304
|
+
}
|
|
305
|
+
// Controllo: se il payload estratto rispetta è di tipo HttpException
|
|
306
|
+
if (isHttpException(httpErrorPayload)) {
|
|
307
|
+
// const type = httpErrorPayload.isBe ? 'be' : 'ice';
|
|
308
|
+
throw new UniHttpError('be', res.status, url, httpErrorPayload);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
// Fallback per errori non di tipo HttpException (es. pagine HTML di errore di IIS/Nginx o stringhe piane)
|
|
312
|
+
const error = new Error(res.statusText || `HTTP Error ${res.status}`);
|
|
313
|
+
const fallbackException = {
|
|
314
|
+
message: typeof httpErrorPayload === 'string' && httpErrorPayload
|
|
315
|
+
? httpErrorPayload
|
|
316
|
+
: error.message,
|
|
317
|
+
type: 'ErrorBase',
|
|
318
|
+
stackTrace: error.stack ?? '',
|
|
319
|
+
isBe: true,
|
|
320
|
+
};
|
|
321
|
+
throw new UniHttpError('base', res.status, url, fallbackException);
|
|
320
322
|
}
|
|
321
|
-
/* Risposta ok */
|
|
322
|
-
return res;
|
|
323
323
|
}
|
|
324
324
|
catch (error) {
|
|
325
|
+
// Fallback per errori di rete locale (es. assenza di linea, DNS fallito, timeout di fetch)
|
|
325
326
|
if (error instanceof TypeError) {
|
|
326
|
-
|
|
327
|
-
exceptionMessage: `${error.name}: ${error.message}\n${error.stack}`,
|
|
328
|
-
exceptionType: error.name,
|
|
327
|
+
const fallbackNetworkException = {
|
|
329
328
|
message: error.message,
|
|
329
|
+
type: error.name || 'TypeError',
|
|
330
330
|
stackTrace: error.stack ?? '',
|
|
331
|
-
|
|
331
|
+
isBe: true,
|
|
332
|
+
};
|
|
333
|
+
throw new UniHttpError('network', -1, url, fallbackNetworkException);
|
|
332
334
|
}
|
|
333
|
-
//
|
|
335
|
+
// Rilancio diretto senza alterazioni per istanze di UniHttpError o eccezioni non identificate
|
|
334
336
|
throw error;
|
|
335
337
|
}
|
|
336
338
|
}
|
|
@@ -377,16 +379,16 @@ async function executeBlob(url, init) {
|
|
|
377
379
|
* Costruisce un URL completo per l'API partendo dai parametri di configurazione.
|
|
378
380
|
*/
|
|
379
381
|
function getUrl(hostname, port, config) {
|
|
380
|
-
const {
|
|
382
|
+
const { pathParams, path, hasApiPrefix } = config;
|
|
381
383
|
// Costruzione url
|
|
382
|
-
const prefix = hasApiPrefix ? '
|
|
384
|
+
const prefix = hasApiPrefix === false ? '' : 'api';
|
|
383
385
|
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
|
|
384
386
|
const pathFixed = prefix ? `${prefix}/${cleanPath}` : cleanPath;
|
|
385
387
|
const url = new URL(pathFixed, `http://${hostname}:${port}`);
|
|
386
|
-
if (
|
|
388
|
+
if (pathParams) {
|
|
387
389
|
// Regex per intercettare stringhe in formato ISO string
|
|
388
390
|
const isoDateRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/;
|
|
389
|
-
for (const [key, rawValue] of Object.entries(
|
|
391
|
+
for (const [key, rawValue] of Object.entries(pathParams)) {
|
|
390
392
|
if (rawValue === undefined || rawValue === null) {
|
|
391
393
|
continue;
|
|
392
394
|
}
|
|
@@ -503,7 +505,7 @@ class UniHttpManager {
|
|
|
503
505
|
...config.init,
|
|
504
506
|
method: 'GET',
|
|
505
507
|
};
|
|
506
|
-
/*
|
|
508
|
+
/* API */
|
|
507
509
|
const url = getUrl(this.hostname, this.port, config);
|
|
508
510
|
return http$(url, 'one', config, () => executeHttp(url, initCustom)).pipe(tap((res) => {
|
|
509
511
|
if (Array.isArray(res) && config.toast === undefined) {
|
|
@@ -529,12 +531,12 @@ class UniHttpManager {
|
|
|
529
531
|
},
|
|
530
532
|
body: JSON.stringify(normalizeHttpBody(body)),
|
|
531
533
|
};
|
|
532
|
-
/*
|
|
534
|
+
/* Config custom (toast di default) */
|
|
533
535
|
const configCustom = {
|
|
534
536
|
...config,
|
|
535
|
-
toast: config.
|
|
537
|
+
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
536
538
|
};
|
|
537
|
-
/*
|
|
539
|
+
/* API */
|
|
538
540
|
const url = getUrl(this.hostname, this.port, config);
|
|
539
541
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
540
542
|
}
|
|
@@ -551,12 +553,12 @@ class UniHttpManager {
|
|
|
551
553
|
};
|
|
552
554
|
initCustom.body = JSON.stringify(normalizeHttpBody(body));
|
|
553
555
|
}
|
|
554
|
-
/*
|
|
556
|
+
/* Config custom (toast di default) */
|
|
555
557
|
const configCustom = {
|
|
556
558
|
...config,
|
|
557
|
-
toast: config.
|
|
559
|
+
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
558
560
|
};
|
|
559
|
-
/*
|
|
561
|
+
/* API */
|
|
560
562
|
const url = getUrl(this.hostname, this.port, config);
|
|
561
563
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
562
564
|
}
|
|
@@ -570,12 +572,12 @@ class UniHttpManager {
|
|
|
570
572
|
...config.init,
|
|
571
573
|
method: 'DELETE',
|
|
572
574
|
};
|
|
573
|
-
/*
|
|
575
|
+
/* Config custom (toast di default) */
|
|
574
576
|
const configCustom = {
|
|
575
577
|
...config,
|
|
576
|
-
toast: config.
|
|
578
|
+
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
577
579
|
};
|
|
578
|
-
/*
|
|
580
|
+
/* API */
|
|
579
581
|
const url = getUrl(this.hostname, this.port, config);
|
|
580
582
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
581
583
|
}
|
|
@@ -592,9 +594,9 @@ class UniHttpManager {
|
|
|
592
594
|
...config.init,
|
|
593
595
|
method: 'GET',
|
|
594
596
|
};
|
|
595
|
-
/*
|
|
597
|
+
/* API */
|
|
596
598
|
const url = getUrl(this.hostname, this.port, config);
|
|
597
|
-
return http$(url, '
|
|
599
|
+
return http$(url, 'image', config, () => executeBlob(url, initCustom));
|
|
598
600
|
}
|
|
599
601
|
/**
|
|
600
602
|
* Recupera un file (es. PDF) tramite una richiesta GET e restituisce un Object URL temporaneo.
|
|
@@ -606,12 +608,12 @@ class UniHttpManager {
|
|
|
606
608
|
...config.init,
|
|
607
609
|
method: 'GET',
|
|
608
610
|
};
|
|
609
|
-
/*
|
|
611
|
+
/* Config custom (toast di default) */
|
|
610
612
|
const configCustom = {
|
|
611
613
|
...config,
|
|
612
|
-
toast: config.
|
|
614
|
+
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
613
615
|
};
|
|
614
|
-
/*
|
|
616
|
+
/* API */
|
|
615
617
|
const url = getUrl(this.hostname, this.port, config);
|
|
616
618
|
return http$(url, 'file', configCustom, () => executeBlob(url, initCustom));
|
|
617
619
|
}
|
|
@@ -628,7 +630,7 @@ class UniHttpManager {
|
|
|
628
630
|
...config.init,
|
|
629
631
|
method: 'GET',
|
|
630
632
|
};
|
|
631
|
-
/*
|
|
633
|
+
/* API */
|
|
632
634
|
const url = getUrl(this.hostname, this.port, config);
|
|
633
635
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
634
636
|
}
|
|
@@ -644,7 +646,7 @@ class UniHttpManager {
|
|
|
644
646
|
headers: { 'Content-Type': 'application/json' },
|
|
645
647
|
body: JSON.stringify(body),
|
|
646
648
|
};
|
|
647
|
-
/*
|
|
649
|
+
/* API */
|
|
648
650
|
const url = getUrl(this.hostname, this.port, config);
|
|
649
651
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
650
652
|
}
|
|
@@ -664,7 +666,7 @@ class UniHttpManager {
|
|
|
664
666
|
};
|
|
665
667
|
initCustom.body = JSON.stringify(body);
|
|
666
668
|
}
|
|
667
|
-
/*
|
|
669
|
+
/* API */
|
|
668
670
|
const url = getUrl(this.hostname, this.port, config);
|
|
669
671
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
670
672
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uni-manager-http.mjs","sources":["../../../projects/uni-manager/http/enum.ts","../../../projects/uni-manager/http/handler.ts","../../../projects/uni-manager/http/core.ts","../../../projects/uni-manager/http/execute.ts","../../../projects/uni-manager/http/util.ts","../../../projects/uni-manager/http/manager.ts","../../../projects/uni-manager/http/uni-manager-http.ts"],"sourcesContent":["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 { Observable } from 'rxjs/internal/Observable';\r\nimport { EMPTY } from 'rxjs/internal/observable/empty';\r\nimport { of } from 'rxjs/internal/observable/of';\r\nimport { throwError } from 'rxjs/internal/observable/throwError';\r\nimport { concatMap } from 'rxjs/internal/operators/concatMap';\r\nimport { exhaustMap } from 'rxjs/internal/operators/exhaustMap';\r\nimport { mergeMap } from 'rxjs/internal/operators/mergeMap';\r\nimport { switchMap } from 'rxjs/internal/operators/switchMap';\r\nimport { OperatorFunction } from 'rxjs/internal/types';\r\nimport { UniHttpError } from 'uni-error/http';\r\nimport { UniErrorManager } from 'uni-manager/error';\r\n\r\nimport { updateHasError } from './core';\r\nimport { MapOperator, PollingErrorMode } from './enum';\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 }\r\n case MapOperator.CONCAT_MAP: {\r\n return (project) => concatMap(project);\r\n }\r\n case MapOperator.MERGE_MAP: {\r\n return (project) => mergeMap(project);\r\n }\r\n case MapOperator.SWITCH_MAP: {\r\n return (project) => switchMap(project);\r\n }\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();\r\n }\r\n case PollingErrorMode.SKIP: {\r\n return EMPTY;\r\n }\r\n case PollingErrorMode.IGNORE_WITH_ERROR: {\r\n UniErrorManager.add(ref, err);\r\n return of();\r\n }\r\n case PollingErrorMode.STOP: {\r\n UniErrorManager.add(ref, err);\r\n return throwError(() => err);\r\n }\r\n }\r\n}\r\n","import isEqual from 'lodash-es/isEqual';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { defer } from 'rxjs/internal/observable/defer';\r\nimport { from } from 'rxjs/internal/observable/from';\r\nimport { timer } from 'rxjs/internal/observable/timer';\r\nimport { catchError } from 'rxjs/internal/operators/catchError';\r\nimport { distinctUntilChanged } from 'rxjs/internal/operators/distinctUntilChanged';\r\nimport { finalize } from 'rxjs/internal/operators/finalize';\r\nimport { tap } from 'rxjs/internal/operators/tap';\r\nimport { UniErrorManager } from 'uni-manager/error';\r\nimport { UniToastManager } from 'uni-manager/toast';\r\n\r\nimport { EmitValueMode, MapOperator, PollingErrorMode } from './enum';\r\nimport { errorHandler, operatorHandler } from './handler';\r\nimport { UniHttpManager } from './manager';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\n\r\n/* ------------------------------------------------------------------------------- */\r\n/* -------------------------------- Funzioni Core RxJS -------------------------- */\r\n/* ------------------------------------------------------------------------------- */\r\n/**\r\n * Gestisce l'esecuzione e il ciclo di vita di una singola richiesta HTTP.\r\n * Si occupa della registrazione della reference, della gestione dei loader, dei toast di successo e dell'intercettazione degli errori.\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, toast, 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, 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 next: (res) => {\r\n /* Mostra toast (se presente) */\r\n if (toast) {\r\n UniToastManager.showHttp(toast, res);\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\n/**\r\n * Avvia e coordina un ciclo di polling a intervalli regolari.\r\n * Gestisce la concorrenza tramite operatori RxJS configurabili, la rimozione dei popup, di errore nelle iterazioni successive e i comportamenti custom al primo avvio.\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.ON_NEW_DATA,\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, 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((res) => {\r\n /* Meccanismo di ripristino automatico: se il polling torna in salute, cancella l'errore dallo store e nasconde i relativi messaggi a schermo */\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?.toast) {\r\n UniToastManager.showHttp(firstIteration.toast, res);\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.ON_NEW_DATA\r\n ? source$.pipe(distinctUntilChanged((prev, cur) => isEqual(prev, cur)))\r\n : source$;\r\n}\r\n\r\n/* ------------------------------------------------------------------------------- */\r\n/* ------------------------------------ Utils ------------------------------------ */\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\nfunction add(id: string, 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: undefined,\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\nfunction 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\nfunction 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 { isHttpErrorBody, UniHttpError } from 'uni-error/http';\r\n\r\nasync function execute(url: URL, init?: RequestInit): Promise<Response | undefined> {\r\n try {\r\n /* Esegue chiamata http */\r\n const res = await fetch(url, init);\r\n\r\n /* Nessun contenuto cons status 204 */\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\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 /* Clona risposta solo se c'è errore, per leggerla senza consumare la originale */\r\n const resClone = res.clone();\r\n\r\n /* Aggiorna body con struttura errore */\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 /* Risposta ok */\r\n return res;\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 la chiamata HTTP e restituisce il corpo decodificato come JSON */\r\n const res = await execute(url, init);\r\n if (!res) return undefined;\r\n\r\n /* Estrae il contenuto come testo */\r\n const text = await res.text();\r\n\r\n /* Controllo: se il testo è vuoto (''), ritorna undefined */\r\n if (!text || text.trim().length === 0) {\r\n return undefined;\r\n }\r\n\r\n /* Parsa manualmente il testo, dato che lo stream è stato già letto */\r\n return JSON.parse(text) as T;\r\n}\r\n\r\nexport async function executeBlob(\r\n url: URL,\r\n init?: RequestInit,\r\n): Promise<{ url: string; name: string } | undefined> {\r\n /* Esegue la chiamata HTTP */\r\n const res = await execute(url, init);\r\n if (!res) return undefined;\r\n\r\n /* Estrae il contenuto come Blob direttamente */\r\n const blob = await res.blob();\r\n\r\n /* Controllo: se il blob è vuoto (0 byte), ritorna undefined */\r\n if (blob.size === 0) {\r\n return undefined;\r\n }\r\n\r\n /* Estrae il nome del file dall'header */\r\n const disposition = res.headers.get('Content-Disposition');\r\n let fileName = 'download.pdf'; // Fallback di default\r\n if (disposition) {\r\n const matches = /filename[^;=\\n]*=((['\"]).*?\\2|[^;\\n]*)/.exec(disposition);\r\n if (!!matches && matches[1]) {\r\n fileName = matches[1].replaceAll(/['\"]/g, '');\r\n }\r\n }\r\n\r\n /* Genera l'URL temporaneo dal blob */\r\n const fileUrl = URL.createObjectURL(blob);\r\n\r\n return { url: fileUrl, name: fileName };\r\n}\r\n","import { UniTypeDateManager } from 'uni-manager/type';\r\nimport type { HttpBody, HttpConfig } from './model';\r\n\r\n/**\r\n * Costruisce un URL completo per l'API partendo dai parametri di configurazione.\r\n */\r\nexport function getUrl<T>(hostname: string, port: number, config: HttpConfig<T>): URL {\r\n const { params, path, hasApiPrefix = true } = config;\r\n\r\n // Costruzione url\r\n const prefix = hasApiPrefix ? 'api' : '';\r\n const cleanPath = path.startsWith('/') ? path.slice(1) : path;\r\n const pathFixed = prefix ? `${prefix}/${cleanPath}` : cleanPath;\r\n const url = new URL(pathFixed, `http://${hostname}:${port}`);\r\n\r\n if (params) {\r\n // Regex per intercettare stringhe in formato ISO string\r\n const isoDateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})?)?$/;\r\n\r\n for (const [key, rawValue] of Object.entries(params)) {\r\n if (rawValue === undefined || rawValue === null) {\r\n continue;\r\n }\r\n\r\n // Conversione in array per usare un solo ciclo\r\n const valuesArray = Array.isArray(rawValue) ? rawValue : [rawValue];\r\n\r\n for (const item of valuesArray) {\r\n if (item === undefined || item === null) {\r\n continue;\r\n }\r\n\r\n let formattedValue: string;\r\n\r\n // Caso: Date nativo\r\n if (item instanceof Date) {\r\n formattedValue = UniTypeDateManager.toYYYYMMDD(item);\r\n }\r\n // Caso: Date formato ISO string\r\n else if (typeof item === 'string' && isoDateRegex.test(item)) {\r\n const parsedDate = new Date(item);\r\n formattedValue = Number.isNaN(parsedDate.getTime())\r\n ? item\r\n : UniTypeDateManager.toYYYYMMDD(parsedDate);\r\n }\r\n // Default\r\n else {\r\n formattedValue = String(item);\r\n }\r\n\r\n url.searchParams.append(key, formattedValue);\r\n }\r\n }\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/**\r\n * Normalizza i valori del body cosi da sistemare le incongruenze tra ui e db\r\n */\r\nexport function normalizeHttpBody<T extends HttpBody>(body: T, isRoot = true): T {\r\n // PRIMITIVI GENERICI\r\n // Tipi gestiti: null, undefined, number, boolean, symbol, bigint, string\r\n if (body === null || typeof body !== 'object') {\r\n // Sotto-gestione specifica per il tipo: string\r\n if (typeof body === 'string') {\r\n return body.trim() as T;\r\n }\r\n return body;\r\n }\r\n\r\n // DATE\r\n // Tipi gestiti: Date\r\n // Formattazione esplicita manuale in YYYY-MM-DD\r\n if (body instanceof Date) {\r\n const year = body.getFullYear();\r\n const month = String(body.getMonth() + 1).padStart(2, '0');\r\n const day = String(body.getDate()).padStart(2, '0');\r\n return `${year}-${month}-${day}` as unknown as T;\r\n }\r\n\r\n // STRUTTURE DATI ITERABILI\r\n // Tipi gestiti: Array (qualsiasi array, es. string[], number[], Object[])\r\n // Se è un array, viene mappato ricorsivamente ogni singolo elemento al suo interno (passando isRoot = false perché gli elementi dell'array non sono l'oggetto root principale)\r\n if (Array.isArray(body)) {\r\n return body.map((item) => normalizeHttpBody(item, false)) as unknown as T;\r\n }\r\n\r\n // OGGETTI\r\n // Tipi gestiti: Record<string, any>, generici oggetti JavaScript ({ })\r\n // Rimuove chiave 'id' al primo livello e prosegue ricorsivamente\r\n const entries = Object.entries(body)\r\n .filter(([key]) => !(isRoot && key.toLowerCase() === 'id'))\r\n .map(([key, value]) => [key, normalizeHttpBody(value, false)]);\r\n\r\n // Ricostruisce l'oggetto normalizzato\r\n return Object.fromEntries(entries) as T;\r\n}\r\n","import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { map } from 'rxjs/internal/operators/map';\r\nimport { tap } from 'rxjs/internal/operators/tap';\r\nimport { FileDatasource } from 'uni-manager/file';\r\nimport { ToastConfig, UniToastManager } from 'uni-manager/toast';\r\n\r\nimport { http$, httpPolling$ } from './core';\r\nimport { executeBlob, executeHttp } from './execute';\r\nimport type { HttpBody, HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { getUrl, normalizeHttpBody } from './util';\r\n\r\nconst CONFIG_TOAST_DEFAULT: ToastConfig = {\r\n type: 'success',\r\n label: 'OperationCompleted',\r\n};\r\n\r\nexport class UniHttpManager {\r\n /* ------------------------------------------------------------------------------- */\r\n /* ----------------------------------- Config ------------------------------------ */\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: get --------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /** Restituisce se lo store ha chiamate in attesa di risposta o meno */\r\n public static get hasWaitingRequests$(): Observable<boolean> {\r\n return this.store$.pipe(map((x) => [...x.values()].some((y) => y.pendingCount > 0)));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------------ Store ------------------------------------ */\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: CRUD --------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\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 read$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom)).pipe(\r\n tap((res) => {\r\n if (Array.isArray(res) && config.toast === undefined) {\r\n UniToastManager.show({\r\n label: 'ItemsFound',\r\n params: { count: res.length },\r\n });\r\n }\r\n }),\r\n );\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 create$<T>(config: HttpConfig<T>, body: HttpBody): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...config.init?.headers,\r\n },\r\n body: JSON.stringify(normalizeHttpBody(body)),\r\n };\r\n\r\n /* Toast di default */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.toast === null ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(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 update$<T>(config: HttpConfig<T>, body?: HttpBody): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = { ...config.init, method: 'PUT' };\r\n if (body !== undefined) {\r\n initCustom.headers = {\r\n 'Content-Type': 'application/json',\r\n ...config.init?.headers,\r\n };\r\n initCustom.body = JSON.stringify(normalizeHttpBody(body));\r\n }\r\n\r\n /* Toast di default */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.toast === null ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una richiesta HTTP DELETE per rimuovere una risorsa.\r\n * Utilizza il path configurato per costruire l'URL completo e restituisce un Observable del risultato.\r\n */\r\n public static delete$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'DELETE',\r\n };\r\n\r\n /* Toast di default */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.toast === null ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------- Metodi: CRUD file/image ---------------------------- */\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 readImage$(\r\n config: HttpConfig<{ url: string; name: string }>,\r\n ): Observable<{ url: string; name: string } | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', config, () => executeBlob(url, initCustom));\r\n }\r\n\r\n /**\r\n * Recupera un file (es. PDF) tramite una richiesta GET e restituisce un Object URL temporaneo.\r\n * Delega la logica di conversione alla funzione executeFile.\r\n */\r\n public static readFile$(\r\n config: HttpConfig<FileDatasource>,\r\n ): Observable<FileDatasource | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* Toast di default */\r\n const configCustom: HttpConfig<FileDatasource> = {\r\n ...config,\r\n toast: config.toast === null ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'file', configCustom, () => executeBlob(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ---------------------------- Metodi: CRUD 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 readPolling$<T>(config: HttpConfigPolling<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\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 createPolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body: HttpBody,\r\n ): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify(body),\r\n };\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\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 PUT.\r\n */\r\n public static updatePolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body?: HttpBody,\r\n ): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'PUT',\r\n };\r\n if (body !== undefined) {\r\n initCustom.headers = {\r\n ...initCustom.headers,\r\n 'Content-Type': 'application/json',\r\n };\r\n initCustom.body = JSON.stringify(body);\r\n }\r\n\r\n /* Chiama API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAAY;AAAZ,CAAA,UAAY,WAAW,EAAA;;AAEtB,IAAA,WAAA,CAAA,WAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAU;;AAGV,IAAA,WAAA,CAAA,WAAA,CAAA,aAAA,CAAA,GAAA,CAAA,CAAA,GAAA,aAAW;;AAGX,IAAA,WAAA,CAAA,WAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAU;;AAGV,IAAA,WAAA,CAAA,WAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAS;AACV,CAAC,EAZW,WAAW,KAAX,WAAW,GAAA,EAAA,CAAA,CAAA;IAcX;AAAZ,CAAA,UAAY,gBAAgB,EAAA;;AAE3B,IAAA,gBAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,C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C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QACxC;;AAGA,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;AACpD,QAAA,OAAO,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAI,GAAG,EAAE,UAAU,CAAC,CAAC;IACzE;;;AC/QF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"uni-manager-http.mjs","sources":["../../../projects/uni-manager/http/enum.ts","../../../projects/uni-manager/http/handler.ts","../../../projects/uni-manager/http/core.ts","../../../projects/uni-manager/http/execute.ts","../../../projects/uni-manager/http/util.ts","../../../projects/uni-manager/http/manager.ts","../../../projects/uni-manager/http/uni-manager-http.ts"],"sourcesContent":["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 { Observable } from 'rxjs/internal/Observable';\r\nimport { EMPTY } from 'rxjs/internal/observable/empty';\r\nimport { of } from 'rxjs/internal/observable/of';\r\nimport { throwError } from 'rxjs/internal/observable/throwError';\r\nimport { concatMap } from 'rxjs/internal/operators/concatMap';\r\nimport { exhaustMap } from 'rxjs/internal/operators/exhaustMap';\r\nimport { mergeMap } from 'rxjs/internal/operators/mergeMap';\r\nimport { switchMap } from 'rxjs/internal/operators/switchMap';\r\nimport { OperatorFunction } from 'rxjs/internal/types';\r\nimport { UniHttpError } from 'uni-error/http';\r\nimport { UniErrorManager } from 'uni-manager/error';\r\n\r\nimport { MapOperator, PollingErrorMode } from './enum';\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 }\r\n case MapOperator.CONCAT_MAP: {\r\n return (project) => concatMap(project);\r\n }\r\n case MapOperator.MERGE_MAP: {\r\n return (project) => mergeMap(project);\r\n }\r\n case MapOperator.SWITCH_MAP: {\r\n return (project) => switchMap(project);\r\n }\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<never> {\r\n // Controllo: sia effettivamente un errore di tipo 'UniHttpError'\r\n if (err instanceof UniHttpError) {\r\n switch (errorMode) {\r\n case PollingErrorMode.IGNORE: {\r\n return of();\r\n }\r\n case PollingErrorMode.SKIP: {\r\n return EMPTY;\r\n }\r\n case PollingErrorMode.IGNORE_WITH_ERROR: {\r\n UniErrorManager.add(ref, err);\r\n return of();\r\n }\r\n case PollingErrorMode.STOP: {\r\n UniErrorManager.add(ref, err);\r\n return throwError(() => err);\r\n }\r\n }\r\n } else {\r\n return throwError(() => err);\r\n }\r\n}\r\n","import isEqual from 'lodash-es/isEqual';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { defer } from 'rxjs/internal/observable/defer';\r\nimport { from } from 'rxjs/internal/observable/from';\r\nimport { timer } from 'rxjs/internal/observable/timer';\r\nimport { catchError } from 'rxjs/internal/operators/catchError';\r\nimport { distinctUntilChanged } from 'rxjs/internal/operators/distinctUntilChanged';\r\nimport { finalize } from 'rxjs/internal/operators/finalize';\r\nimport { tap } from 'rxjs/internal/operators/tap';\r\nimport { UniErrorManager } from 'uni-manager/error';\r\nimport { UniToastManager } from 'uni-manager/toast';\r\n\r\nimport { EmitValueMode, MapOperator, PollingErrorMode } from './enum';\r\nimport { errorHandler, operatorHandler } from './handler';\r\nimport { UniHttpManager } from './manager';\r\nimport type { HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\n\r\n/* ------------------------------------------------------------------------------- */\r\n/* -------------------------------- Funzioni Core RxJS -------------------------- */\r\n/* ------------------------------------------------------------------------------- */\r\n/**\r\n * Gestisce l'esecuzione e il ciclo di vita di una singola richiesta HTTP.\r\n * Si occupa della registrazione della reference, della gestione dei loader, dei toast di successo e dell'intercettazione degli errori.\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, toast, 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, 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 next: (res) => {\r\n /* Mostra toast (se presente) */\r\n if (toast) {\r\n UniToastManager.showHttp(toast, res);\r\n }\r\n },\r\n }),\r\n catchError((err) => {\r\n // Aggiorna la ref nella map\r\n updateHasError(ref, true);\r\n\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\n/**\r\n * Avvia e coordina un ciclo di polling a intervalli regolari.\r\n * Gestisce la concorrenza tramite operatori RxJS configurabili, la rimozione dei popup, di errore nelle iterazioni successive e i comportamenti custom al primo avvio.\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.ON_NEW_DATA,\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, 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((res) => {\r\n /* Meccanismo di ripristino automatico: se il polling torna in salute, cancella l'errore dallo store e nasconde i relativi messaggi a schermo */\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?.toast) {\r\n UniToastManager.showHttp(firstIteration.toast, res);\r\n }\r\n }),\r\n catchError((err) => {\r\n // Aggiorna la ref nella map\r\n updateHasError(ref, true);\r\n\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.ON_NEW_DATA\r\n ? source$.pipe(distinctUntilChanged((prev, cur) => isEqual(prev, cur)))\r\n : source$;\r\n}\r\n\r\n/* ------------------------------------------------------------------------------- */\r\n/* ------------------------------------ Utils ------------------------------------ */\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\nfunction add(id: string, 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: undefined,\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\nfunction 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\nfunction 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\nfunction 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","import { HttpException, isHttpException, UniHttpError } from 'uni-error/http';\r\nimport { FileDatasource } from 'uni-manager/file';\r\n\r\nasync function execute(url: URL, init?: RequestInit): Promise<Response | undefined> {\r\n try {\r\n /* Esecuzione della richiesta HTTP nativa */\r\n const res = await fetch(url, init);\r\n\r\n /* Gestione dello stato 204: assenza di contenuto legittima */\r\n if (res.status === 204) {\r\n return undefined;\r\n }\r\n\r\n /*Gestione ok HTTP: risposta ricevuta dal server con stato valido */\r\n if (res.ok) {\r\n return res;\r\n }\r\n\r\n /* Gestione Errore HTTP: risposta ricevuta dal server ma con stato non valido */\r\n let httpErrorPayload: unknown;\r\n try {\r\n /* Clonazione della risposta per l'ispezione del payload senza consumare lo stream originale */\r\n const resClone = res.clone();\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\r\n /* Estrazione del corpo dell'errore in base al formato rilevato */\r\n httpErrorPayload = isJson ? await resClone.json() : await resClone.text();\r\n } catch {\r\n /* Fallback in caso di fallimento della clonazione o del parsing del testo */\r\n httpErrorPayload = `Failed to parse error response body (Status: ${res.status})`;\r\n }\r\n\r\n // Controllo: se il payload estratto rispetta è di tipo HttpException\r\n if (isHttpException(httpErrorPayload)) {\r\n // const type = httpErrorPayload.isBe ? 'be' : 'ice';\r\n throw new UniHttpError('be', res.status, url, httpErrorPayload);\r\n } else {\r\n // Fallback per errori non di tipo HttpException (es. pagine HTML di errore di IIS/Nginx o stringhe piane)\r\n const error = new Error(res.statusText || `HTTP Error ${res.status}`);\r\n const fallbackException: HttpException = {\r\n message:\r\n typeof httpErrorPayload === 'string' && httpErrorPayload\r\n ? httpErrorPayload\r\n : error.message,\r\n type: 'ErrorBase',\r\n stackTrace: error.stack ?? '',\r\n isBe: true,\r\n };\r\n throw new UniHttpError('base', res.status, url, fallbackException);\r\n }\r\n } catch (error: unknown) {\r\n // Fallback per errori di rete locale (es. assenza di linea, DNS fallito, timeout di fetch)\r\n if (error instanceof TypeError) {\r\n const fallbackNetworkException: HttpException = {\r\n message: error.message,\r\n type: error.name || 'TypeError',\r\n stackTrace: error.stack ?? '',\r\n isBe: true,\r\n };\r\n throw new UniHttpError('network', -1, url, fallbackNetworkException);\r\n }\r\n\r\n // Rilancio diretto senza alterazioni per istanze di UniHttpError o eccezioni non identificate\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 la chiamata HTTP e restituisce il corpo decodificato come JSON */\r\n const res = await execute(url, init);\r\n if (!res) return undefined;\r\n\r\n /* Estrae il contenuto come testo */\r\n const text = await res.text();\r\n\r\n /* Controllo: se il testo è vuoto (''), ritorna undefined */\r\n if (!text || text.trim().length === 0) {\r\n return undefined;\r\n }\r\n\r\n /* Parsa manualmente il testo, dato che lo stream è stato già letto */\r\n return JSON.parse(text) as T;\r\n}\r\n\r\nexport async function executeBlob(\r\n url: URL,\r\n init?: RequestInit,\r\n): Promise<FileDatasource | undefined> {\r\n /* Esegue la chiamata HTTP */\r\n const res = await execute(url, init);\r\n if (!res) return undefined;\r\n\r\n /* Estrae il contenuto come Blob direttamente */\r\n const blob = await res.blob();\r\n\r\n /* Controllo: se il blob è vuoto (0 byte), ritorna undefined */\r\n if (blob.size === 0) {\r\n return undefined;\r\n }\r\n\r\n /* Estrae il nome del file dall'header */\r\n const disposition = res.headers.get('Content-Disposition');\r\n let fileName = 'download.pdf'; // Fallback di default\r\n if (disposition) {\r\n const matches = /filename[^;=\\n]*=((['\"]).*?\\2|[^;\\n]*)/.exec(disposition);\r\n if (!!matches && matches[1]) {\r\n fileName = matches[1].replaceAll(/['\"]/g, '');\r\n }\r\n }\r\n\r\n /* Genera l'URL temporaneo dal blob */\r\n const fileUrl = URL.createObjectURL(blob);\r\n\r\n return { url: fileUrl, name: fileName };\r\n}\r\n","import { UniTypeDateManager } from 'uni-manager/type';\r\nimport type { HttpBody, HttpConfig } from './model';\r\n\r\n/**\r\n * Costruisce un URL completo per l'API partendo dai parametri di configurazione.\r\n */\r\nexport function getUrl<T>(hostname: string, port: number, config: HttpConfig<T>): URL {\r\n const { pathParams, path, hasApiPrefix } = config;\r\n\r\n // Costruzione url\r\n const prefix = hasApiPrefix === false ? '' : 'api';\r\n const cleanPath = path.startsWith('/') ? path.slice(1) : path;\r\n const pathFixed = prefix ? `${prefix}/${cleanPath}` : cleanPath;\r\n const url = new URL(pathFixed, `http://${hostname}:${port}`);\r\n\r\n if (pathParams) {\r\n // Regex per intercettare stringhe in formato ISO string\r\n const isoDateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})?)?$/;\r\n\r\n for (const [key, rawValue] of Object.entries(pathParams)) {\r\n if (rawValue === undefined || rawValue === null) {\r\n continue;\r\n }\r\n\r\n // Conversione in array per usare un solo ciclo\r\n const valuesArray = Array.isArray(rawValue) ? rawValue : [rawValue];\r\n\r\n for (const item of valuesArray) {\r\n if (item === undefined || item === null) {\r\n continue;\r\n }\r\n\r\n let formattedValue: string;\r\n\r\n // Caso: Date nativo\r\n if (item instanceof Date) {\r\n formattedValue = UniTypeDateManager.toYYYYMMDD(item);\r\n }\r\n // Caso: Date formato ISO string\r\n else if (typeof item === 'string' && isoDateRegex.test(item)) {\r\n const parsedDate = new Date(item);\r\n formattedValue = Number.isNaN(parsedDate.getTime())\r\n ? item\r\n : UniTypeDateManager.toYYYYMMDD(parsedDate);\r\n }\r\n // Default\r\n else {\r\n formattedValue = String(item);\r\n }\r\n\r\n url.searchParams.append(key, formattedValue);\r\n }\r\n }\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/**\r\n * Normalizza i valori del body cosi da sistemare le incongruenze tra ui e db\r\n */\r\nexport function normalizeHttpBody<T extends HttpBody>(body: T, isRoot = true): T {\r\n // PRIMITIVI GENERICI\r\n // Tipi gestiti: null, undefined, number, boolean, symbol, bigint, string\r\n if (body === null || typeof body !== 'object') {\r\n // Sotto-gestione specifica per il tipo: string\r\n if (typeof body === 'string') {\r\n return body.trim() as T;\r\n }\r\n return body;\r\n }\r\n\r\n // DATE\r\n // Tipi gestiti: Date\r\n // Formattazione esplicita manuale in YYYY-MM-DD\r\n if (body instanceof Date) {\r\n const year = body.getFullYear();\r\n const month = String(body.getMonth() + 1).padStart(2, '0');\r\n const day = String(body.getDate()).padStart(2, '0');\r\n return `${year}-${month}-${day}` as unknown as T;\r\n }\r\n\r\n // STRUTTURE DATI ITERABILI\r\n // Tipi gestiti: Array (qualsiasi array, es. string[], number[], Object[])\r\n // Se è un array, viene mappato ricorsivamente ogni singolo elemento al suo interno (passando isRoot = false perché gli elementi dell'array non sono l'oggetto root principale)\r\n if (Array.isArray(body)) {\r\n return body.map((item) => normalizeHttpBody(item, false)) as unknown as T;\r\n }\r\n\r\n // OGGETTI\r\n // Tipi gestiti: Record<string, any>, generici oggetti JavaScript ({ })\r\n // Rimuove chiave 'id' al primo livello e prosegue ricorsivamente\r\n const entries = Object.entries(body)\r\n .filter(([key]) => !(isRoot && key.toLowerCase() === 'id'))\r\n .map(([key, value]) => [key, normalizeHttpBody(value, false)]);\r\n\r\n // Ricostruisce l'oggetto normalizzato\r\n return Object.fromEntries(entries) as T;\r\n}\r\n","import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { map } from 'rxjs/internal/operators/map';\r\nimport { tap } from 'rxjs/internal/operators/tap';\r\nimport type { FileDatasource } from 'uni-manager/file';\r\nimport { ToastConfig, UniToastManager } from 'uni-manager/toast';\r\n\r\nimport { http$, httpPolling$ } from './core';\r\nimport { executeBlob, executeHttp } from './execute';\r\nimport type { HttpBody, HttpConfig, HttpConfigPolling, HttpRef } from './model';\r\nimport { getUrl, normalizeHttpBody } from './util';\r\n\r\nconst CONFIG_TOAST_DEFAULT: ToastConfig = {\r\n type: 'success',\r\n label: 'OperationCompleted',\r\n};\r\n\r\nexport class UniHttpManager {\r\n /* ------------------------------------------------------------------------------- */\r\n /* ----------------------------------- Config ------------------------------------ */\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: get --------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /** Restituisce se lo store ha chiamate in attesa di risposta o meno */\r\n public static get hasWaitingRequests$(): Observable<boolean> {\r\n return this.store$.pipe(map((x) => [...x.values()].some((y) => y.pendingCount > 0)));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------------ Store ------------------------------------ */\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: CRUD --------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\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 read$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', config, () => executeHttp<T>(url, initCustom)).pipe(\r\n tap((res) => {\r\n if (Array.isArray(res) && config.toast === undefined) {\r\n UniToastManager.show({\r\n label: 'ItemsFound',\r\n params: { count: res.length },\r\n });\r\n }\r\n }),\r\n );\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 create$<T>(config: HttpConfig<T>, body: HttpBody): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...config.init?.headers,\r\n },\r\n body: JSON.stringify(normalizeHttpBody(body)),\r\n };\r\n\r\n /* Config custom (toast di default) */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(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 update$<T>(config: HttpConfig<T>, body?: HttpBody): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = { ...config.init, method: 'PUT' };\r\n if (body !== undefined) {\r\n initCustom.headers = {\r\n 'Content-Type': 'application/json',\r\n ...config.init?.headers,\r\n };\r\n initCustom.body = JSON.stringify(normalizeHttpBody(body));\r\n }\r\n\r\n /* Config custom (toast di default) */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /**\r\n * Esegue una richiesta HTTP DELETE per rimuovere una risorsa.\r\n * Utilizza il path configurato per costruire l'URL completo e restituisce un Observable del risultato.\r\n */\r\n public static delete$<T>(config: HttpConfig<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'DELETE',\r\n };\r\n\r\n /* Config custom (toast di default) */\r\n const configCustom: HttpConfig<T> = {\r\n ...config,\r\n toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'one', configCustom, () => executeHttp<T>(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* -------------------------- Metodi: CRUD file/image ---------------------------- */\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 readImage$(\r\n config: HttpConfig<FileDatasource>,\r\n ): Observable<FileDatasource | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'image', config, () => executeBlob(url, initCustom));\r\n }\r\n\r\n /**\r\n * Recupera un file (es. PDF) tramite una richiesta GET e restituisce un Object URL temporaneo.\r\n * Delega la logica di conversione alla funzione executeFile.\r\n */\r\n public static readFile$(\r\n config: HttpConfig<FileDatasource>,\r\n ): Observable<FileDatasource | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* Config custom (toast di default) */\r\n const configCustom: HttpConfig<FileDatasource> = {\r\n ...config,\r\n toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return http$(url, 'file', configCustom, () => executeBlob(url, initCustom));\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ---------------------------- Metodi: CRUD 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 readPolling$<T>(config: HttpConfigPolling<T>): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'GET',\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\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 createPolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body: HttpBody,\r\n ): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify(body),\r\n };\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\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 PUT.\r\n */\r\n public static updatePolling$<T>(\r\n config: HttpConfigPolling<T>,\r\n body?: HttpBody,\r\n ): Observable<T | undefined> {\r\n /* Config */\r\n const initCustom: RequestInit = {\r\n ...config.init,\r\n method: 'PUT',\r\n };\r\n if (body !== undefined) {\r\n initCustom.headers = {\r\n ...initCustom.headers,\r\n 'Content-Type': 'application/json',\r\n };\r\n initCustom.body = JSON.stringify(body);\r\n }\r\n\r\n /* API */\r\n const url = getUrl(this.hostname, this.port, config);\r\n return httpPolling$(url, config, () => executeHttp<T>(url, initCustom));\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAAY;AAAZ,CAAA,UAAY,WAAW,EAAA;;AAEtB,IAAA,WAAA,CAAA,WAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAU;;AAGV,IAAA,WAAA,CAAA,WAAA,CAAA,aAAA,CAAA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UAAU,GAAgB;YAC9B,GAAG,MAAM,CAAC,IAAI;AACd,YAAA,MAAM,EAAE,KAAK;SACd;AACD,QAAA,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,UAAU,CAAC,OAAO,GAAG;gBACnB,GAAG,UAAU,CAAC,OAAO;AACrB,gBAAA,cAAc,EAAE,kBAAkB;aACnC;YACD,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QACxC;;AAGA,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;AACpD,QAAA,OAAO,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAI,GAAG,EAAE,UAAU,CAAC,CAAC;IACzE;;;AC/QF;;AAEG;;;;"}
|
|
@@ -70,7 +70,7 @@ class UniLocaleManager {
|
|
|
70
70
|
* Traduce una label in base al dizionario caricato.
|
|
71
71
|
* Gestisce la composizione della chiave, i parametri dinamici (interpolazione) e il fallback.
|
|
72
72
|
*/
|
|
73
|
-
static translate(key, prefix = 'lbl',
|
|
73
|
+
static translate(key, prefix = 'lbl', params) {
|
|
74
74
|
if (!key)
|
|
75
75
|
return '-';
|
|
76
76
|
// Costruzione chiave: prefissoGlobale + prefissoLocale + LabelConInizialeMaiuscola
|
|
@@ -87,8 +87,8 @@ class UniLocaleManager {
|
|
|
87
87
|
return `🔑 ${finalKey}`;
|
|
88
88
|
}
|
|
89
89
|
// Interpolazione variabili
|
|
90
|
-
if (
|
|
91
|
-
for (const [key, value] of Object.entries(
|
|
90
|
+
if (params) {
|
|
91
|
+
for (const [key, value] of Object.entries(params)) {
|
|
92
92
|
const displayValue = value instanceof Date ? value.toLocaleDateString(this._locale) : String(value);
|
|
93
93
|
translation = translation.replaceAll(`{{${key}}}`, displayValue);
|
|
94
94
|
}
|