uni-manager 0.1.10 → 0.1.11
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-error.mjs +8 -8
- package/fesm2022/uni-manager-error.mjs.map +1 -1
- package/fesm2022/uni-manager-file.mjs +2 -2
- package/fesm2022/uni-manager-file.mjs.map +1 -1
- package/fesm2022/uni-manager-http.mjs +17 -49
- package/fesm2022/uni-manager-http.mjs.map +1 -1
- package/fesm2022/uni-manager-locale.mjs +17 -21
- package/fesm2022/uni-manager-locale.mjs.map +1 -1
- package/fesm2022/uni-manager-toast.mjs +3 -3
- package/fesm2022/uni-manager-toast.mjs.map +1 -1
- package/fesm2022/uni-manager-type.mjs +5 -5
- package/fesm2022/uni-manager-type.mjs.map +1 -1
- package/fesm2022/uni-manager.mjs +2 -1175
- package/fesm2022/uni-manager.mjs.map +1 -1
- package/package.json +3 -2
- package/types/uni-manager-error.d.ts +1 -2
- package/types/uni-manager-file.d.ts +1 -5
- package/types/uni-manager-http.d.ts +2 -64
- package/types/uni-manager-toast.d.ts +1 -17
- package/types/uni-manager.d.ts +2 -311
package/types/uni-manager.d.ts
CHANGED
|
@@ -1,312 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { Observable, BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { IUniFeError } from 'uni-error/fe';
|
|
4
|
-
import { IUniHttpError } from 'uni-error/http';
|
|
5
|
-
import { FileDatasource as FileDatasource$1 } from 'uni-manager/file';
|
|
6
|
-
import { ToastConfig as ToastConfig$1, ToastHttpConfig as ToastHttpConfig$1 } from 'uni-manager/toast';
|
|
1
|
+
declare const libraryName = "uni-manager";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
/** Restituisce se lo store ha chiamate in attesa di risposta o meno */
|
|
10
|
-
static get errors$(): Observable<({
|
|
11
|
-
id: string;
|
|
12
|
-
} & (IUniFeError | IUniHttpError))[]>;
|
|
13
|
-
/** Store privato (Subject) */
|
|
14
|
-
private static store;
|
|
15
|
-
/** Store pubblico (Observable) */
|
|
16
|
-
static store$: Observable<Map<string, IUniFeError | IUniHttpError>>;
|
|
17
|
-
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
18
|
-
static get currentValue(): Map<string, IUniFeError | IUniHttpError>;
|
|
19
|
-
/**
|
|
20
|
-
* Aggiunge o aggiorna un errore nello store.
|
|
21
|
-
* Se l'errore esiste già (stesso ID), incrementa il contatore 'count' e aggiorna il timestamp.
|
|
22
|
-
*/
|
|
23
|
-
static add(id: string, error: IUniHttpError | IUniFeError): void;
|
|
24
|
-
/**
|
|
25
|
-
* Rimuove un errore tramite ID
|
|
26
|
-
*/
|
|
27
|
-
static remove(id: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Svuota completamente la lista degli errori
|
|
30
|
-
*/
|
|
31
|
-
static removeAll(): void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface FileDatasource {
|
|
35
|
-
url: string;
|
|
36
|
-
name: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare class UniFileManager {
|
|
40
|
-
/**
|
|
41
|
-
* Apre un file (es. PDF, immagine) in una nuova scheda del browser
|
|
42
|
-
* Il contenuto viene caricato all'interno di un iframe per garantire compatibilità di visualizzazione
|
|
43
|
-
*/
|
|
44
|
-
static openInNewTab(data: FileDatasource | undefined): void;
|
|
45
|
-
/**
|
|
46
|
-
* Stampa un file aprendo il dialogo di stampa nativo del sistema
|
|
47
|
-
* Utilizza un iframe invisibile per non interrompere la navigazione
|
|
48
|
-
*/
|
|
49
|
-
static openInPrintPreview(data: FileDatasource | undefined): void;
|
|
50
|
-
/**
|
|
51
|
-
* Scarica un file localmente sul dispositivo dell'utente
|
|
52
|
-
*/
|
|
53
|
-
static download(data: FileDatasource | undefined): void;
|
|
54
|
-
private static createIframe;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
declare enum MapOperator {
|
|
58
|
-
/** Cancella la precedente richiesta, mantiene solo l’ultima */
|
|
59
|
-
SWITCH_MAP = 0,
|
|
60
|
-
/** Ignora nuovi valori finché la corrente non finisce */
|
|
61
|
-
EXHAUST_MAP = 1,
|
|
62
|
-
/** Mette le richieste in coda, le esegue una alla volta */
|
|
63
|
-
CONCAT_MAP = 2,
|
|
64
|
-
/** Esegue tutte le richieste in parallelo, ordine non garantito */
|
|
65
|
-
MERGE_MAP = 3
|
|
66
|
-
}
|
|
67
|
-
declare enum PollingErrorMode {
|
|
68
|
-
/** Salta questa iterazione emettendo un undefined. Il polling continua al tick successivo. */
|
|
69
|
-
IGNORE = 0,
|
|
70
|
-
/** Salta questa iterazione senza emettere valori. Il polling continua al tick successivo. */
|
|
71
|
-
SKIP = 1,
|
|
72
|
-
/** Interrompe il polling propagando l'errore. */
|
|
73
|
-
STOP = 2,
|
|
74
|
-
/** Ignora l'errore, lo salva (es. per UI), e continua il polling. Emette `undefined`. */
|
|
75
|
-
IGNORE_WITH_ERROR = 3
|
|
76
|
-
}
|
|
77
|
-
declare enum EmitValueMode {
|
|
78
|
-
/** Aggiorna lo stato solo se arrivano dati nuovi (distinct) */
|
|
79
|
-
ON_NEW_DATA = 0,
|
|
80
|
-
/** Aggiorna lo stato ad ogni chiamata, anche se i dati sono uguali */
|
|
81
|
-
EVERY_TIME = 1
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface HttpRef {
|
|
85
|
-
type: 'one' | 'polling' | 'image' | 'file';
|
|
86
|
-
lineId: number | null | undefined;
|
|
87
|
-
url: URL;
|
|
88
|
-
pendingCount: number;
|
|
89
|
-
hasError: boolean;
|
|
90
|
-
}
|
|
91
|
-
interface HttpConfig<T> {
|
|
92
|
-
ref: string;
|
|
93
|
-
path: string;
|
|
94
|
-
pathParams?: Record<string, any>;
|
|
95
|
-
init?: RequestInit;
|
|
96
|
-
toast?: ToastConfig$1 & ToastHttpConfig$1<T>;
|
|
97
|
-
hasToast?: boolean;
|
|
98
|
-
hasLoader?: boolean;
|
|
99
|
-
hasApiPrefix?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface HttpConfigPolling<T> {
|
|
102
|
-
interval: number;
|
|
103
|
-
ref: string;
|
|
104
|
-
path: string;
|
|
105
|
-
pathParams?: Record<string, any>;
|
|
106
|
-
init?: RequestInit;
|
|
107
|
-
operator?: MapOperator;
|
|
108
|
-
errorMode?: PollingErrorMode;
|
|
109
|
-
emitValueMode?: EmitValueMode;
|
|
110
|
-
firstIteration?: {
|
|
111
|
-
toast: NonNullable<HttpConfig<T>['toast']>;
|
|
112
|
-
hasLoader?: boolean;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
type HttpBody = Record<string, any> | any[] | string | number | boolean | Date;
|
|
116
|
-
|
|
117
|
-
declare class UniHttpManager {
|
|
118
|
-
/** Hostname del server (es. 'api.example.com' o 'localhost') */
|
|
119
|
-
private static hostname;
|
|
120
|
-
/** Porta del server su cui effettuare le chiamate (es. 80, 443 o 3000) */
|
|
121
|
-
private static port;
|
|
122
|
-
/** Restituisce se lo store ha chiamate in attesa di risposta o meno */
|
|
123
|
-
static get hasWaitingRequests$(): Observable<boolean>;
|
|
124
|
-
/** Store privato (Subject) */
|
|
125
|
-
static store: BehaviorSubject<Map<string, HttpRef>>;
|
|
126
|
-
/** Store pubblico (Observable) */
|
|
127
|
-
static store$: Observable<Map<string, HttpRef>>;
|
|
128
|
-
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
129
|
-
static get currentValue(): Map<string, HttpRef>;
|
|
130
|
-
/**
|
|
131
|
-
* Inizializza la configurazione di rete del manager.
|
|
132
|
-
* Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.
|
|
133
|
-
*/
|
|
134
|
-
static setup(hostname: string, port: number): void;
|
|
135
|
-
static read$<T>(config: HttpConfig<T>): Observable<T | undefined>;
|
|
136
|
-
/**
|
|
137
|
-
* Esegue una richiesta HTTP POST inviando un payload JSON nel corpo della richiesta.
|
|
138
|
-
* Imposta automaticamente l'header 'Content-Type' come 'application/json'.
|
|
139
|
-
*/
|
|
140
|
-
static create$<T>(config: HttpConfig<T>, body: HttpBody): Observable<T | undefined>;
|
|
141
|
-
/**
|
|
142
|
-
* Esegue una singola richiesta HTTP PUT per aggiornare una risorsa esistente.
|
|
143
|
-
*/
|
|
144
|
-
static update$<T>(config: HttpConfig<T>, body?: HttpBody): Observable<T | undefined>;
|
|
145
|
-
/**
|
|
146
|
-
* Esegue una richiesta HTTP DELETE per rimuovere una risorsa.
|
|
147
|
-
* Utilizza il path configurato per costruire l'URL completo e restituisce un Observable del risultato.
|
|
148
|
-
*/
|
|
149
|
-
static delete$<T>(config: HttpConfig<T>): Observable<T | undefined>;
|
|
150
|
-
/**
|
|
151
|
-
* Recupera un'immagine tramite una richiesta GET e la trasforma in un formato gestibile (es. Blob o Base64).
|
|
152
|
-
* Delega la logica di conversione alla funzione executeImage.
|
|
153
|
-
*/
|
|
154
|
-
static readImage$(config: HttpConfig<FileDatasource$1>): Observable<FileDatasource$1 | undefined>;
|
|
155
|
-
/**
|
|
156
|
-
* Recupera un file (es. PDF) tramite una richiesta GET e restituisce un Object URL temporaneo.
|
|
157
|
-
* Delega la logica di conversione alla funzione executeFile.
|
|
158
|
-
*/
|
|
159
|
-
static readFile$(config: HttpConfig<FileDatasource$1>): Observable<FileDatasource$1 | undefined>;
|
|
160
|
-
/**
|
|
161
|
-
* Avvia un ciclo di polling basato su richieste GET.
|
|
162
|
-
* Continua a emettere valori in base alla configurazione di intervallo definita in HttpConfigPolling.
|
|
163
|
-
*/
|
|
164
|
-
static readPolling$<T>(config: HttpConfigPolling<T>): Observable<T | undefined>;
|
|
165
|
-
/**
|
|
166
|
-
* Avvia un ciclo di polling basato su richieste POST.
|
|
167
|
-
* Invia il body specificato a ogni iterazione del ciclo.
|
|
168
|
-
*/
|
|
169
|
-
static createPolling$<T>(config: HttpConfigPolling<T>, body: HttpBody): Observable<T | undefined>;
|
|
170
|
-
/**
|
|
171
|
-
* Avvia un ciclo di polling basato su richieste PUT.
|
|
172
|
-
*/
|
|
173
|
-
static updatePolling$<T>(config: HttpConfigPolling<T>, body?: HttpBody): Observable<T | undefined>;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
declare class UniLocaleManager {
|
|
177
|
-
/** Codice lingua corrente (es. 'it-IT', 'en-US') usato per formattare date e numeri */
|
|
178
|
-
private static _locale;
|
|
179
|
-
/** Elenco dei codici lingua supportati dall'applicazione (es. ['it-IT', 'en-US']) */
|
|
180
|
-
private static _localesSupported;
|
|
181
|
-
/** Prefisso globale applicato a tutte le chiavi di traduzione (es. 'APP_') */
|
|
182
|
-
private static _prefix;
|
|
183
|
-
/** Restituisce il codice lingua corrente */
|
|
184
|
-
static get locale(): string;
|
|
185
|
-
/** Restituisce l'array contenente tutti i codici locale supportati.*/
|
|
186
|
-
static get localesSupported(): string[];
|
|
187
|
-
/** Restituisce solo la lingua (es. 'it') */
|
|
188
|
-
static get language(): string;
|
|
189
|
-
/** Restituisce solo il paese (es. 'IT') */
|
|
190
|
-
static get region(): string;
|
|
191
|
-
/** Store privato (Subject) */
|
|
192
|
-
static store: BehaviorSubject<Record<string, string>>;
|
|
193
|
-
/** Store pubblico (Observable) */
|
|
194
|
-
static store$: rxjs.Observable<Record<string, string>>;
|
|
195
|
-
/** Ottiene il dizionario attuale senza sottoscrizione */
|
|
196
|
-
static get currentValue(): Record<string, string>;
|
|
197
|
-
/**
|
|
198
|
-
* Inizializza la configurazione di rete del manager.
|
|
199
|
-
* Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.
|
|
200
|
-
*/
|
|
201
|
-
static setup(locale: string | null | undefined, prefix?: string): void;
|
|
202
|
-
/** Imposta l'elenco dei codici lingua supportati dall'applicazione */
|
|
203
|
-
static setLocalesSupported(locales: string[] | undefined): void;
|
|
204
|
-
/**
|
|
205
|
-
* Aggiorna lo store locale con il dizionario delle traduzioni fornito.
|
|
206
|
-
* Se viene passato undefined, lo store viene inizializzato come oggetto vuoto.
|
|
207
|
-
*/
|
|
208
|
-
static setTranslations(translations: Record<string, string> | undefined): void;
|
|
209
|
-
/**
|
|
210
|
-
* Traduce una label in base al dizionario caricato.
|
|
211
|
-
* Gestisce la composizione della chiave, i parametri dinamici (interpolazione) e il fallback.
|
|
212
|
-
*/
|
|
213
|
-
static translate(key: string, prefix?: string, params?: Record<string, string | number | Date>): string;
|
|
214
|
-
/**
|
|
215
|
-
* Traduce una stringa che contiene parametri separati da un carattere specifico.
|
|
216
|
-
* Supporta ora un numero arbitrario di parametri in formato "label/param1/param2"
|
|
217
|
-
* o semplicemente "label".
|
|
218
|
-
*/
|
|
219
|
-
static translateInlineParams(keyWithParams: string, splitChar: string): string;
|
|
220
|
-
/**
|
|
221
|
-
* Converte un valore numerico in una stringa formattata secondo il locale impostato.
|
|
222
|
-
* Disabilita i separatori delle migliaia e forza un numero fisso di decimali.
|
|
223
|
-
*/
|
|
224
|
-
static toStringNumber(value: number, decimal: number): string;
|
|
225
|
-
/**
|
|
226
|
-
* Formatta una data o una stringa in base al locale corrente.
|
|
227
|
-
* Gestisce tre modalità predefinite (date, time, full) e accetta opzioni personalizzate Intl.
|
|
228
|
-
*/
|
|
229
|
-
static toDate(date: string | Date, mode?: 'date' | 'time' | 'full', force?: {
|
|
230
|
-
oldLang: string;
|
|
231
|
-
newLocale: string;
|
|
232
|
-
}): string;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
interface IToastManager {
|
|
236
|
-
success: (message: string, config?: ToastConfig) => void;
|
|
237
|
-
info: (message: string, config?: ToastConfig) => void;
|
|
238
|
-
warning: (message: string, config?: ToastConfig) => void;
|
|
239
|
-
error: (message: string, config?: ToastConfig) => void;
|
|
240
|
-
}
|
|
241
|
-
interface ToastConfig {
|
|
242
|
-
label: string;
|
|
243
|
-
params?: Record<string, any>;
|
|
244
|
-
type?: keyof IToastManager;
|
|
245
|
-
duration?: number;
|
|
246
|
-
}
|
|
247
|
-
interface ToastHttpConfig<T> {
|
|
248
|
-
resParams?: (keyof T & string)[];
|
|
249
|
-
formatters?: Partial<Record<keyof T & string, (val: any) => any>>;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
declare class UniToastManager {
|
|
253
|
-
/** Riferimento interno all'istanza */
|
|
254
|
-
private static manager;
|
|
255
|
-
/**
|
|
256
|
-
* Inizializza il manager con una serie di operazioni
|
|
257
|
-
*/
|
|
258
|
-
static setup(operations: IToastManager): void;
|
|
259
|
-
/**
|
|
260
|
-
* Mostra un toast di successo basato su una risposta HTTP e una label di traduzione.
|
|
261
|
-
*/
|
|
262
|
-
static show(config: ToastConfig & {
|
|
263
|
-
prefix?: string;
|
|
264
|
-
suffix?: string;
|
|
265
|
-
}): void;
|
|
266
|
-
/**
|
|
267
|
-
* Mostra un toast di successo basato su una risposta HTTP e una label di traduzione.
|
|
268
|
-
*/
|
|
269
|
-
static showHttp<T>(config: ToastConfig & ToastHttpConfig<T>, res: T | undefined): void;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Classe di utilità per la gestione e formattazione delle date.
|
|
274
|
-
* Fornisce metodi per convertire in modo sicuro valori di tipo Date, stringa o null in formati standardizzati.
|
|
275
|
-
*/
|
|
276
|
-
declare class UniTypeDateManager {
|
|
277
|
-
static toYYYYMMDD(date: Date | string | null | undefined): string;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Utility per la gestione e formattazione di valori numerici.
|
|
282
|
-
*/
|
|
283
|
-
declare class UniTypeNumberManager {
|
|
284
|
-
/** Applica il padding a un numero o una stringa */
|
|
285
|
-
static toPad(value: number | string | null | undefined, count: number, character?: string): string;
|
|
286
|
-
/** Formatta un numero in una versione leggibile (es: 1000 -> 1K, 1000000 -> 1M) */
|
|
287
|
-
static toTruncateAndAdUdm(value: number, decimalDigits?: number, maxIntegerDigits?: number): string;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Utility per la manipolazione di stringhe
|
|
292
|
-
*/
|
|
293
|
-
declare class UniTypeStringManager {
|
|
294
|
-
/** Converte una stringa in formato lblPascalCase (es. "user_id" -> "lblUserId") */
|
|
295
|
-
static toLabelize(key: string | null | undefined, prefix?: string): string;
|
|
296
|
-
/** Converte una stringa in PascalCase (es. "user_id" -> "UserId") */
|
|
297
|
-
static toPascalCase(key: string | null | undefined): string;
|
|
298
|
-
/** Converte una stringa in camelCase (es. "user_id" -> "userId") */
|
|
299
|
-
static toCamelCase(key: string | null | undefined): string;
|
|
300
|
-
/** Capitalizza solo la prima lettera della stringa */
|
|
301
|
-
static toCapitalize(key: string | null | undefined): string;
|
|
302
|
-
/** Sostituisce sotto-stringhe all'interno della stringa */
|
|
303
|
-
static toReplace(key: string | null | undefined, values: {
|
|
304
|
-
searchValue: string;
|
|
305
|
-
replaceValue: string;
|
|
306
|
-
}[]): string;
|
|
307
|
-
private static splitString;
|
|
308
|
-
private static toPascalCaseParts;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export { EmitValueMode, MapOperator, PollingErrorMode, UniErrorManager, UniFileManager, UniHttpManager, UniLocaleManager, UniToastManager, UniTypeDateManager, UniTypeNumberManager, UniTypeStringManager };
|
|
312
|
-
export type { FileDatasource, HttpBody, HttpConfig, HttpConfigPolling, HttpRef, IToastManager, ToastConfig, ToastHttpConfig };
|
|
3
|
+
export { libraryName };
|