uni-manager 0.1.8 → 0.1.10
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 +1 -7
- 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 +21 -35
- package/fesm2022/uni-manager-http.mjs.map +1 -1
- package/fesm2022/uni-manager-locale.mjs +22 -18
- 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 +52 -66
- package/fesm2022/uni-manager.mjs.map +1 -1
- package/package.json +2 -2
- package/types/uni-manager-error.d.ts +1 -1
- package/types/uni-manager-http.d.ts +1 -2
- package/types/uni-manager-locale.d.ts +3 -3
- package/types/uni-manager.d.ts +3 -4
package/fesm2022/uni-manager.mjs
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { BehaviorSubject } from 'rxjs
|
|
2
|
-
import { distinctUntilChanged } from 'rxjs/internal/operators/distinctUntilChanged';
|
|
3
|
-
import { map } from 'rxjs/internal/operators/map';
|
|
4
|
-
import { tap } from 'rxjs/internal/operators/tap';
|
|
1
|
+
import { map, distinctUntilChanged, BehaviorSubject, switchMap, mergeMap, concatMap, exhaustMap, throwError, of, EMPTY, defer, from, tap, catchError, finalize, timer } from 'rxjs';
|
|
5
2
|
import { UniToastManager as UniToastManager$1 } from 'uni-manager/toast';
|
|
6
3
|
import isEqual from 'lodash-es/isEqual';
|
|
7
|
-
import { defer } from 'rxjs/internal/observable/defer';
|
|
8
|
-
import { from } from 'rxjs/internal/observable/from';
|
|
9
|
-
import { timer } from 'rxjs/internal/observable/timer';
|
|
10
|
-
import { catchError } from 'rxjs/internal/operators/catchError';
|
|
11
|
-
import { finalize } from 'rxjs/internal/operators/finalize';
|
|
12
4
|
import { UniErrorManager as UniErrorManager$1 } from 'uni-manager/error';
|
|
13
|
-
import { EMPTY } from 'rxjs/internal/observable/empty';
|
|
14
|
-
import { of } from 'rxjs/internal/observable/of';
|
|
15
|
-
import { throwError } from 'rxjs/internal/observable/throwError';
|
|
16
|
-
import { concatMap } from 'rxjs/internal/operators/concatMap';
|
|
17
|
-
import { exhaustMap } from 'rxjs/internal/operators/exhaustMap';
|
|
18
|
-
import { mergeMap } from 'rxjs/internal/operators/mergeMap';
|
|
19
|
-
import { switchMap } from 'rxjs/internal/operators/switchMap';
|
|
20
5
|
import { UniHttpError, isHttpException } from 'uni-error/http';
|
|
21
6
|
import { UniTypeDateManager as UniTypeDateManager$1 } from 'uni-manager/type';
|
|
22
7
|
import { UniLocaleManager as UniLocaleManager$1 } from 'uni-manager/locale';
|
|
@@ -54,7 +39,6 @@ class UniErrorManager {
|
|
|
54
39
|
static add(id, error) {
|
|
55
40
|
// Recupera l'ultimo stato (Map)
|
|
56
41
|
const oldMap = UniErrorManager.currentValue;
|
|
57
|
-
console.log(oldMap);
|
|
58
42
|
// Tenta di recuperare l'oggetto corrente
|
|
59
43
|
const oldItem = oldMap.get(id);
|
|
60
44
|
// Crea il nuovo oggetto aggiornando contatore e portando il timestamp al momento attuale
|
|
@@ -68,7 +52,6 @@ class UniErrorManager {
|
|
|
68
52
|
newMap.set(id, newItemMap);
|
|
69
53
|
// Aggiorna il nuovo stato notificando l'observer
|
|
70
54
|
UniErrorManager.store.next(newMap);
|
|
71
|
-
console.log(newMap);
|
|
72
55
|
}
|
|
73
56
|
/**
|
|
74
57
|
* Rimuove un errore tramite ID
|
|
@@ -76,7 +59,6 @@ class UniErrorManager {
|
|
|
76
59
|
static remove(id) {
|
|
77
60
|
// Recupera l'ultimo stato (Map)
|
|
78
61
|
const oldMap = UniErrorManager.currentValue;
|
|
79
|
-
console.log(oldMap);
|
|
80
62
|
// Controllo: se non è presente l'item allora termina
|
|
81
63
|
if (!oldMap.has(id))
|
|
82
64
|
return;
|
|
@@ -85,7 +67,6 @@ class UniErrorManager {
|
|
|
85
67
|
newMap.delete(id);
|
|
86
68
|
// Aggiorna il nuovo stato notificando l'observer
|
|
87
69
|
UniErrorManager.store.next(newMap);
|
|
88
|
-
console.log(newMap);
|
|
89
70
|
}
|
|
90
71
|
/**
|
|
91
72
|
* Svuota completamente la lista degli errori
|
|
@@ -111,7 +92,7 @@ class UniFileManager {
|
|
|
111
92
|
return;
|
|
112
93
|
newWindow.document.title = data.name;
|
|
113
94
|
// Crea l'iframe e lo aggiunge al body della nuova finestra
|
|
114
|
-
const iframe =
|
|
95
|
+
const iframe = UniFileManager.createIframe(newWindow.document, data.url, '100%', '100%');
|
|
115
96
|
newWindow.document.body.style.margin = '0';
|
|
116
97
|
newWindow.document.body.append(iframe);
|
|
117
98
|
// Rimuove l'oggetto URL dalla memoria dopo un tempo congruo per il caricamento
|
|
@@ -125,7 +106,7 @@ class UniFileManager {
|
|
|
125
106
|
if (!data || !data.url)
|
|
126
107
|
return;
|
|
127
108
|
// Crea l'iframe come elemento fisso e nascosto (dimensioni zero)
|
|
128
|
-
const iframe =
|
|
109
|
+
const iframe = UniFileManager.createIframe(document, data.url, '0', '0');
|
|
129
110
|
iframe.style.position = 'fixed';
|
|
130
111
|
iframe.style.bottom = '0';
|
|
131
112
|
document.body.append(iframe);
|
|
@@ -224,8 +205,6 @@ function operatorHandler(operator) {
|
|
|
224
205
|
function errorHandler(ref, err, errorMode) {
|
|
225
206
|
// Controllo: sia effettivamente un errore di tipo 'UniHttpError'
|
|
226
207
|
if (err instanceof UniHttpError) {
|
|
227
|
-
// Aggiunge errore al manager
|
|
228
|
-
UniErrorManager$1.add(ref, err);
|
|
229
208
|
switch (errorMode) {
|
|
230
209
|
case PollingErrorMode.IGNORE: {
|
|
231
210
|
return of();
|
|
@@ -535,9 +514,9 @@ async function executeBlob(url, init) {
|
|
|
535
514
|
function getUrl(hostname, port, config) {
|
|
536
515
|
const { pathParams, path, hasApiPrefix } = config;
|
|
537
516
|
// Costruzione url
|
|
538
|
-
const
|
|
539
|
-
const
|
|
540
|
-
const pathFixed =
|
|
517
|
+
const cleanPath = path.replaceAll(/^\/+|\/+$/g, '');
|
|
518
|
+
const segments = [hasApiPrefix === false ? '' : 'api', cleanPath].filter(Boolean);
|
|
519
|
+
const pathFixed = '/' + segments.join('/');
|
|
541
520
|
const url = new URL(pathFixed, `http://${hostname}:${port}`);
|
|
542
521
|
if (pathParams) {
|
|
543
522
|
// Regex per intercettare stringhe in formato ISO string
|
|
@@ -622,7 +601,7 @@ class UniHttpManager {
|
|
|
622
601
|
/* ------------------------------------------------------------------------------- */
|
|
623
602
|
/** Restituisce se lo store ha chiamate in attesa di risposta o meno */
|
|
624
603
|
static get hasWaitingRequests$() {
|
|
625
|
-
return
|
|
604
|
+
return UniHttpManager.store$.pipe(map((requestMap) => {
|
|
626
605
|
for (const request of requestMap.values()) {
|
|
627
606
|
if (request.pendingCount > 0)
|
|
628
607
|
return true;
|
|
@@ -636,10 +615,10 @@ class UniHttpManager {
|
|
|
636
615
|
/** Store privato (Subject) */
|
|
637
616
|
static { this.store = new BehaviorSubject(new Map()); }
|
|
638
617
|
/** Store pubblico (Observable) */
|
|
639
|
-
static { this.store$ =
|
|
618
|
+
static { this.store$ = UniHttpManager.store.asObservable(); }
|
|
640
619
|
/** Ottiene lo stato attuale della Map senza dover sottoscrivere l'observable */
|
|
641
620
|
static get currentValue() {
|
|
642
|
-
return
|
|
621
|
+
return UniHttpManager.store.getValue();
|
|
643
622
|
}
|
|
644
623
|
/* ------------------------------------------------------------------------------- */
|
|
645
624
|
/* -------------------------------- Metodi: setup -------------------------------- */
|
|
@@ -649,8 +628,9 @@ class UniHttpManager {
|
|
|
649
628
|
* Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.
|
|
650
629
|
*/
|
|
651
630
|
static setup(hostname, port) {
|
|
652
|
-
|
|
653
|
-
|
|
631
|
+
UniHttpManager.hostname = hostname;
|
|
632
|
+
UniHttpManager.port = port;
|
|
633
|
+
console.log(UniHttpManager.hostname, UniHttpManager.port);
|
|
654
634
|
}
|
|
655
635
|
/* ------------------------------------------------------------------------------- */
|
|
656
636
|
/* -------------------------------- Metodi: CRUD --------------------------------- */
|
|
@@ -666,7 +646,8 @@ class UniHttpManager {
|
|
|
666
646
|
method: 'GET',
|
|
667
647
|
};
|
|
668
648
|
/* API */
|
|
669
|
-
|
|
649
|
+
console.log('read$', UniHttpManager.hostname, UniHttpManager.port);
|
|
650
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
670
651
|
return http$(url, 'one', config, () => executeHttp(url, initCustom)).pipe(tap((res) => {
|
|
671
652
|
if (Array.isArray(res) && config.toast === undefined) {
|
|
672
653
|
UniToastManager$1.show({
|
|
@@ -697,7 +678,8 @@ class UniHttpManager {
|
|
|
697
678
|
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
698
679
|
};
|
|
699
680
|
/* API */
|
|
700
|
-
|
|
681
|
+
console.log('create$', UniHttpManager.hostname, UniHttpManager.port);
|
|
682
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
701
683
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
702
684
|
}
|
|
703
685
|
/**
|
|
@@ -719,7 +701,7 @@ class UniHttpManager {
|
|
|
719
701
|
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
720
702
|
};
|
|
721
703
|
/* API */
|
|
722
|
-
const url = getUrl(
|
|
704
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
723
705
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
724
706
|
}
|
|
725
707
|
/**
|
|
@@ -738,7 +720,7 @@ class UniHttpManager {
|
|
|
738
720
|
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
739
721
|
};
|
|
740
722
|
/* API */
|
|
741
|
-
const url = getUrl(
|
|
723
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
742
724
|
return http$(url, 'one', configCustom, () => executeHttp(url, initCustom));
|
|
743
725
|
}
|
|
744
726
|
/* ------------------------------------------------------------------------------- */
|
|
@@ -755,7 +737,7 @@ class UniHttpManager {
|
|
|
755
737
|
method: 'GET',
|
|
756
738
|
};
|
|
757
739
|
/* API */
|
|
758
|
-
const url = getUrl(
|
|
740
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
759
741
|
return http$(url, 'image', config, () => executeBlob(url, initCustom));
|
|
760
742
|
}
|
|
761
743
|
/**
|
|
@@ -774,7 +756,7 @@ class UniHttpManager {
|
|
|
774
756
|
toast: config.hasToast === false ? undefined : (config.toast ?? CONFIG_TOAST_DEFAULT),
|
|
775
757
|
};
|
|
776
758
|
/* API */
|
|
777
|
-
const url = getUrl(
|
|
759
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
778
760
|
return http$(url, 'file', configCustom, () => executeBlob(url, initCustom));
|
|
779
761
|
}
|
|
780
762
|
/* ------------------------------------------------------------------------------- */
|
|
@@ -791,7 +773,7 @@ class UniHttpManager {
|
|
|
791
773
|
method: 'GET',
|
|
792
774
|
};
|
|
793
775
|
/* API */
|
|
794
|
-
const url = getUrl(
|
|
776
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
795
777
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
796
778
|
}
|
|
797
779
|
/**
|
|
@@ -807,7 +789,7 @@ class UniHttpManager {
|
|
|
807
789
|
body: JSON.stringify(body),
|
|
808
790
|
};
|
|
809
791
|
/* API */
|
|
810
|
-
const url = getUrl(
|
|
792
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
811
793
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
812
794
|
}
|
|
813
795
|
/**
|
|
@@ -827,7 +809,7 @@ class UniHttpManager {
|
|
|
827
809
|
initCustom.body = JSON.stringify(body);
|
|
828
810
|
}
|
|
829
811
|
/* API */
|
|
830
|
-
const url = getUrl(
|
|
812
|
+
const url = getUrl(UniHttpManager.hostname, UniHttpManager.port, config);
|
|
831
813
|
return httpPolling$(url, config, () => executeHttp(url, initCustom));
|
|
832
814
|
}
|
|
833
815
|
}
|
|
@@ -847,19 +829,19 @@ class UniLocaleManager {
|
|
|
847
829
|
/* ------------------------------------------------------------------------------- */
|
|
848
830
|
/** Restituisce il codice lingua corrente */
|
|
849
831
|
static get locale() {
|
|
850
|
-
return
|
|
832
|
+
return UniLocaleManager._locale;
|
|
851
833
|
}
|
|
852
834
|
/** Restituisce l'array contenente tutti i codici locale supportati.*/
|
|
853
835
|
static get localesSupported() {
|
|
854
|
-
return
|
|
836
|
+
return UniLocaleManager._localesSupported;
|
|
855
837
|
}
|
|
856
838
|
/** Restituisce solo la lingua (es. 'it') */
|
|
857
839
|
static get language() {
|
|
858
|
-
return
|
|
840
|
+
return UniLocaleManager._locale.split('-')[0];
|
|
859
841
|
}
|
|
860
842
|
/** Restituisce solo il paese (es. 'IT') */
|
|
861
843
|
static get region() {
|
|
862
|
-
const parts =
|
|
844
|
+
const parts = UniLocaleManager._locale.split('-');
|
|
863
845
|
return parts.length > 1 ? parts[1] : '';
|
|
864
846
|
}
|
|
865
847
|
/* ------------------------------------------------------------------------------- */
|
|
@@ -868,10 +850,10 @@ class UniLocaleManager {
|
|
|
868
850
|
/** Store privato (Subject) */
|
|
869
851
|
static { this.store = new BehaviorSubject({}); }
|
|
870
852
|
/** Store pubblico (Observable) */
|
|
871
|
-
static { this.store$ =
|
|
853
|
+
static { this.store$ = UniLocaleManager.store.asObservable(); }
|
|
872
854
|
/** Ottiene il dizionario attuale senza sottoscrizione */
|
|
873
855
|
static get currentValue() {
|
|
874
|
-
return
|
|
856
|
+
return UniLocaleManager.store.getValue();
|
|
875
857
|
}
|
|
876
858
|
/* ------------------------------------------------------------------------------- */
|
|
877
859
|
/* -------------------------------- Metodi: setup -------------------------------- */
|
|
@@ -881,19 +863,19 @@ class UniLocaleManager {
|
|
|
881
863
|
* Deve essere chiamato prima di effettuare qualsiasi richiesta HTTP.
|
|
882
864
|
*/
|
|
883
865
|
static setup(locale, prefix) {
|
|
884
|
-
|
|
885
|
-
|
|
866
|
+
UniLocaleManager._locale = locale ?? 'en-US';
|
|
867
|
+
UniLocaleManager._prefix = prefix;
|
|
886
868
|
}
|
|
887
869
|
/** Imposta l'elenco dei codici lingua supportati dall'applicazione */
|
|
888
870
|
static setLocalesSupported(locales) {
|
|
889
|
-
|
|
871
|
+
UniLocaleManager._localesSupported = locales ?? [];
|
|
890
872
|
}
|
|
891
873
|
/**
|
|
892
874
|
* Aggiorna lo store locale con il dizionario delle traduzioni fornito.
|
|
893
875
|
* Se viene passato undefined, lo store viene inizializzato come oggetto vuoto.
|
|
894
876
|
*/
|
|
895
877
|
static setTranslations(translations) {
|
|
896
|
-
|
|
878
|
+
UniLocaleManager.store.next(translations ?? {});
|
|
897
879
|
}
|
|
898
880
|
/* ------------------------------------------------------------------------------- */
|
|
899
881
|
/* ----------------------------- Metodi: traduzioni ------------------------------ */
|
|
@@ -910,9 +892,9 @@ class UniLocaleManager {
|
|
|
910
892
|
const rootKeyParts = keyParts.filter((p) => p.toLowerCase() !== prefix.toLowerCase());
|
|
911
893
|
const cleanKey = rootKeyParts.length > 0 ? rootKeyParts.join('') : undefined;
|
|
912
894
|
const capitalizedKey = cleanKey ? cleanKey.charAt(0).toUpperCase() + cleanKey.slice(1) : '';
|
|
913
|
-
const finalKey = `${
|
|
895
|
+
const finalKey = `${UniLocaleManager._prefix ?? ''}${prefix}${capitalizedKey}`;
|
|
914
896
|
// Cerca la chiave in minuscolo (standardizzazione)
|
|
915
|
-
let translation =
|
|
897
|
+
let translation = UniLocaleManager.currentValue?.[finalKey.toLowerCase()];
|
|
916
898
|
// Log e fallback se la traduzione manca
|
|
917
899
|
if (!translation) {
|
|
918
900
|
console.warn(`Translation missing for key: ${finalKey}`);
|
|
@@ -921,7 +903,9 @@ class UniLocaleManager {
|
|
|
921
903
|
// Interpolazione variabili
|
|
922
904
|
if (params) {
|
|
923
905
|
for (const [key, value] of Object.entries(params)) {
|
|
924
|
-
const displayValue = value instanceof Date
|
|
906
|
+
const displayValue = value instanceof Date
|
|
907
|
+
? value.toLocaleDateString(UniLocaleManager._locale)
|
|
908
|
+
: String(value);
|
|
925
909
|
translation = translation.replaceAll(`{{${key}}}`, displayValue);
|
|
926
910
|
}
|
|
927
911
|
}
|
|
@@ -938,14 +922,14 @@ class UniLocaleManager {
|
|
|
938
922
|
const [label, ...params] = keyWithParams.split(splitChar);
|
|
939
923
|
// Se non ci sono parametri, esegui una traduzione semplice
|
|
940
924
|
if (params.length === 0) {
|
|
941
|
-
return
|
|
925
|
+
return UniLocaleManager.translate(label);
|
|
942
926
|
}
|
|
943
927
|
// Mappa i parametri in un oggetto di interpolazione: { inlineParam0: val, inlineParam1: val, ... }
|
|
944
928
|
const interpolationParameters = {};
|
|
945
929
|
for (const [index, val] of params.entries()) {
|
|
946
930
|
interpolationParameters[`param${index}`] = val;
|
|
947
931
|
}
|
|
948
|
-
return
|
|
932
|
+
return UniLocaleManager.translate(label, 'lbl', interpolationParameters);
|
|
949
933
|
}
|
|
950
934
|
/* ------------------------------------------------------------------------------- */
|
|
951
935
|
/* ------------------------------- Metodi: numeri -------------------------------- */
|
|
@@ -955,7 +939,7 @@ class UniLocaleManager {
|
|
|
955
939
|
* Disabilita i separatori delle migliaia e forza un numero fisso di decimali.
|
|
956
940
|
*/
|
|
957
941
|
static toStringNumber(value, decimal) {
|
|
958
|
-
return new Intl.NumberFormat(
|
|
942
|
+
return new Intl.NumberFormat(UniLocaleManager._locale, {
|
|
959
943
|
useGrouping: true,
|
|
960
944
|
minimumFractionDigits: decimal,
|
|
961
945
|
maximumFractionDigits: decimal,
|
|
@@ -977,7 +961,9 @@ class UniLocaleManager {
|
|
|
977
961
|
return '';
|
|
978
962
|
}
|
|
979
963
|
// Controllo: locale da forzare
|
|
980
|
-
const locale = force &&
|
|
964
|
+
const locale = force && UniLocaleManager._locale.startsWith(force.oldLang)
|
|
965
|
+
? force.newLocale
|
|
966
|
+
: UniLocaleManager._locale;
|
|
981
967
|
switch (mode) {
|
|
982
968
|
case 'date': {
|
|
983
969
|
return dt.toLocaleDateString(locale);
|
|
@@ -1001,7 +987,7 @@ class UniToastManager {
|
|
|
1001
987
|
* Inizializza il manager con una serie di operazioni
|
|
1002
988
|
*/
|
|
1003
989
|
static setup(operations) {
|
|
1004
|
-
|
|
990
|
+
UniToastManager.manager = operations;
|
|
1005
991
|
}
|
|
1006
992
|
/* ------------------------------------------------------------------------------- */
|
|
1007
993
|
/* -------------------------------- Metodi: show --------------------------------- */
|
|
@@ -1013,7 +999,7 @@ class UniToastManager {
|
|
|
1013
999
|
/* Messaggio tradotto */
|
|
1014
1000
|
const msg = UniLocaleManager$1.translate(config.label, 'toast', config.params);
|
|
1015
1001
|
const msgFixed = `${config.prefix ?? ''}${msg}${config.suffix ?? ''}`;
|
|
1016
|
-
|
|
1002
|
+
UniToastManager.manager[config.type ?? 'info'](msgFixed, config);
|
|
1017
1003
|
}
|
|
1018
1004
|
/**
|
|
1019
1005
|
* Mostra un toast di successo basato su una risposta HTTP e una label di traduzione.
|
|
@@ -1039,7 +1025,7 @@ class UniToastManager {
|
|
|
1039
1025
|
}
|
|
1040
1026
|
}
|
|
1041
1027
|
/* Messaggio tradotto */
|
|
1042
|
-
|
|
1028
|
+
UniToastManager.show({ ...config, params: allParams });
|
|
1043
1029
|
}
|
|
1044
1030
|
}
|
|
1045
1031
|
|
|
@@ -1113,7 +1099,7 @@ class UniTypeStringManager {
|
|
|
1113
1099
|
// Pulizia chiave
|
|
1114
1100
|
const fixedKey = key.trim();
|
|
1115
1101
|
// Unisce il prefisso
|
|
1116
|
-
return prefix +
|
|
1102
|
+
return prefix + UniTypeStringManager.toPascalCase(fixedKey);
|
|
1117
1103
|
}
|
|
1118
1104
|
/** Converte una stringa in PascalCase (es. "user_id" -> "UserId") */
|
|
1119
1105
|
static toPascalCase(key) {
|
|
@@ -1123,11 +1109,11 @@ class UniTypeStringManager {
|
|
|
1123
1109
|
// Pulizia chiave
|
|
1124
1110
|
const fixedKey = key.trim();
|
|
1125
1111
|
// Normalizza e pulisce
|
|
1126
|
-
const parts =
|
|
1112
|
+
const parts = UniTypeStringManager.splitString(fixedKey);
|
|
1127
1113
|
if (parts.length === 0)
|
|
1128
1114
|
return '';
|
|
1129
1115
|
// Converte in PascalCase
|
|
1130
|
-
const pascalCased =
|
|
1116
|
+
const pascalCased = UniTypeStringManager.toPascalCaseParts(parts);
|
|
1131
1117
|
return pascalCased;
|
|
1132
1118
|
}
|
|
1133
1119
|
/** Converte una stringa in camelCase (es. "user_id" -> "userId") */
|
|
@@ -1138,13 +1124,13 @@ class UniTypeStringManager {
|
|
|
1138
1124
|
// Pulizia chiave
|
|
1139
1125
|
const fixedKey = key.trim();
|
|
1140
1126
|
// Normalizza e pulisce
|
|
1141
|
-
const parts =
|
|
1127
|
+
const parts = UniTypeStringManager.splitString(fixedKey);
|
|
1142
1128
|
if (parts.length === 0)
|
|
1143
1129
|
return '';
|
|
1144
1130
|
// La prima parola resta minuscola, le successive PascalCase
|
|
1145
1131
|
const first = parts[0].toLowerCase();
|
|
1146
1132
|
const rest = parts.slice(1);
|
|
1147
|
-
return first +
|
|
1133
|
+
return first + UniTypeStringManager.toPascalCaseParts(rest);
|
|
1148
1134
|
}
|
|
1149
1135
|
/** Capitalizza solo la prima lettera della stringa */
|
|
1150
1136
|
static toCapitalize(key) {
|