uni-manager 0.0.79 → 0.1.1

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