@esfaenza/extensions 11.2.21 → 11.2.24
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/bundles/esfaenza-extensions.umd.js +61 -546
- package/bundles/esfaenza-extensions.umd.js.map +1 -1
- package/bundles/esfaenza-extensions.umd.min.js +1 -16
- package/bundles/esfaenza-extensions.umd.min.js.map +1 -1
- package/esfaenza-extensions.d.ts +0 -2
- package/esfaenza-extensions.metadata.json +1 -1
- package/esm2015/esfaenza-extensions.js +1 -3
- package/esm2015/lib/models/ExtensionsModuleConfig.js +1 -1
- package/esm2015/lib/models/InboundMessageTypes.js +7 -0
- package/esm2015/lib/models/InterComMessage.js +14 -0
- package/esm2015/lib/modules/extensions.full.module.js +6 -13
- package/esm2015/lib/services/extensions.dates.service.js +2 -2
- package/esm2015/lib/services/extensions.intercom.service.js +50 -0
- package/esm2015/public-api.js +5 -4
- package/fesm2015/esfaenza-extensions.js +54 -217
- package/fesm2015/esfaenza-extensions.js.map +1 -1
- package/lib/models/ExtensionsModuleConfig.d.ts +0 -11
- package/lib/models/InboundMessageTypes.d.ts +5 -0
- package/lib/models/InterComMessage.d.ts +12 -0
- package/lib/modules/extensions.full.module.d.ts +2 -2
- package/lib/services/extensions.intercom.service.d.ts +25 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -3
- package/esm2015/lib/models/providers/base/BaseStorageProvider.js +0 -25
- package/esm2015/lib/models/providers/implementation/DefaultStorageProvider.js +0 -79
- package/esm2015/lib/models/session/base/BaseSessionRetriever.js +0 -6
- package/esm2015/lib/models/session/implementation/DefaultSessionRetriever.js +0 -26
- package/esm2015/lib/services/extensions.storage.service.js +0 -102
- package/lib/models/providers/base/BaseStorageProvider.d.ts +0 -65
- package/lib/models/providers/implementation/DefaultStorageProvider.d.ts +0 -20
- package/lib/models/session/base/BaseSessionRetriever.d.ts +0 -11
- package/lib/models/session/implementation/DefaultSessionRetriever.d.ts +0 -18
- package/lib/services/extensions.storage.service.d.ts +0 -58
|
@@ -2,8 +2,7 @@ import { InjectionToken, NgModule, Injectable, Optional, Inject } from '@angular
|
|
|
2
2
|
import { ToastrService } from 'ngx-toastr';
|
|
3
3
|
import swal from 'sweetalert2';
|
|
4
4
|
import { Deserialize } from 'cerialize';
|
|
5
|
-
import {
|
|
6
|
-
import { of } from 'rxjs';
|
|
5
|
+
import { Subject } from 'rxjs';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Token che identifica il locale da utilizzare per questa libreria, sono supportati i locali 'it-IT' ed 'en-US'
|
|
@@ -686,7 +685,7 @@ class DateService {
|
|
|
686
685
|
tryThis = toCall(date, this.cfg.smallDate);
|
|
687
686
|
else if (length == this.cfg.fulldateNoSS.length)
|
|
688
687
|
tryThis = toCall(date, this.cfg.fulldateNoSS);
|
|
689
|
-
if (tryThis.isValid())
|
|
688
|
+
if (tryThis && tryThis.isValid())
|
|
690
689
|
return tryThis;
|
|
691
690
|
// Se niente funziona, null.
|
|
692
691
|
// Ricondurre l'Input ad una data non è possibile.
|
|
@@ -1737,230 +1736,63 @@ UtilityService.decorators = [
|
|
|
1737
1736
|
{ type: Injectable }
|
|
1738
1737
|
];
|
|
1739
1738
|
|
|
1740
|
-
/**
|
|
1741
|
-
|
|
1742
|
-
* Questo store locale potrebbe essere il localStorage (implementazione di default data dal **DefaultStorageProvider**),
|
|
1743
|
-
* oppure un'implementazione custom facente capo a un DB esterno.
|
|
1744
|
-
*
|
|
1745
|
-
* In questo ultimo caso però sarà necessario implementarsi un proprio **BaseSessionRetriever**
|
|
1746
|
-
* che generi una chiave univoca di sessione su cui tutte le operazioni di questa classe saranno eseguite
|
|
1747
|
-
*/
|
|
1748
|
-
class BaseStorageProvider {
|
|
1749
|
-
/** @ignore Costruttore */
|
|
1750
|
-
constructor(session) {
|
|
1751
|
-
this.session = session;
|
|
1752
|
-
}
|
|
1739
|
+
/** Classe che rappresenta un generico messaggio scambiato fra applicazione e moduli */
|
|
1740
|
+
class InterComMessage {
|
|
1753
1741
|
/**
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1742
|
+
* Costruttore
|
|
1743
|
+
*
|
|
1744
|
+
* @param type Tipo di messaggio
|
|
1745
|
+
* @param message Contenuto del messaggio
|
|
1746
|
+
*/
|
|
1747
|
+
constructor(type, message) {
|
|
1748
|
+
this.type = type;
|
|
1749
|
+
this.message = message;
|
|
1762
1750
|
}
|
|
1763
1751
|
}
|
|
1764
1752
|
|
|
1765
|
-
/**
|
|
1766
|
-
* Classe astratta che si occupa di recuperare l'Id sessione univoco per applicazione ed utente collegato
|
|
1767
|
-
*/
|
|
1768
|
-
class BaseSessionRetriever {
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
1753
|
// Angular
|
|
1772
|
-
/**
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
*/
|
|
1780
|
-
class StorageService {
|
|
1781
|
-
/**
|
|
1782
|
-
* Costruttore
|
|
1783
|
-
*
|
|
1784
|
-
* @ignore
|
|
1785
|
-
*/
|
|
1786
|
-
constructor(APPSEARCH_PREFIX, _session, _storage) {
|
|
1787
|
-
this.APPSEARCH_PREFIX = APPSEARCH_PREFIX;
|
|
1788
|
-
this._session = _session;
|
|
1789
|
-
this._storage = _storage;
|
|
1754
|
+
/** Service che si occupa di gestire la comunicazione fra i moduli interni ed esterni dell'applicativo */
|
|
1755
|
+
class InterComService {
|
|
1756
|
+
constructor() {
|
|
1757
|
+
/** Messaggi in uscita, uno per ogni recipient registratosi dall'entrypoint **register** */
|
|
1758
|
+
this.outbounds = {};
|
|
1759
|
+
/** Messaggi in entrata, unico per applicazione principale */
|
|
1760
|
+
this.inbounds = new Subject();
|
|
1790
1761
|
}
|
|
1791
1762
|
/**
|
|
1792
|
-
*
|
|
1793
|
-
* salvato, in modo che quando viene recuperato il sistema non pensi che sia un oggetto vuoto ma che sappia che gli oggetti son stati ripuliti per risparmiare spazio
|
|
1763
|
+
* Metodo che permette di inviare un messaggio dall'applicazione ad un modulo esterno o viceversa
|
|
1794
1764
|
*
|
|
1795
|
-
* @param {
|
|
1796
|
-
* @param {
|
|
1765
|
+
* @param {any} messageType Tipologia di messaggio. Sarà di tipo **InboundMessageTypes** per tutti i messaggi inbound, dinamico per tutti i mesaggi outbound (il tipo dipenderà dagli enum dei messaggi dei moduli esterni)
|
|
1766
|
+
* @param {any} message Messaggio da inviare che può essere un dto in casi complessi ma dovrà essere gestito a dovere lato implementativo
|
|
1767
|
+
* @param {string} recipient Destinatario del messaggio. Per i messaggi inbound dev'essere lasciato vuoto, per i messaggi outbound sarà valorizzato alla chiave del modulo a cui si vuole inviare il messaggio
|
|
1797
1768
|
*/
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
//Se
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1769
|
+
send(messageType, message, recipient) {
|
|
1770
|
+
let msg = new InterComMessage(messageType, message);
|
|
1771
|
+
// Se non c'è un recipient significa che è un modulo esterno che invia messaggi al modulo main (quindi messaggio in entrata - inbound)
|
|
1772
|
+
// Altrimenti significa che è il modulo main ad inviare messaggi ai moduli esterni (messaggio in uscita - outbound)
|
|
1773
|
+
if (!recipient) {
|
|
1774
|
+
this.inbounds.next(msg);
|
|
1775
|
+
}
|
|
1776
|
+
else {
|
|
1777
|
+
if (!this.outbounds[recipient])
|
|
1778
|
+
console.warn("@esfaenza/extensions - InterComService: Impossibile inviare il messaggio al recipient " + recipient + " assicurarsi che il modulo sia caricato e che effettui la chiamata al metodo 'regisster'");
|
|
1779
|
+
else
|
|
1780
|
+
this.outbounds[recipient].next(msg);
|
|
1806
1781
|
}
|
|
1807
|
-
else
|
|
1808
|
-
finalItem = item;
|
|
1809
|
-
return this._storage.setItem(storeName, finalItem).pipe(first(), tap(res => {
|
|
1810
|
-
if (res == false)
|
|
1811
|
-
console.error("Impossibile effettuare il salvataggio dell'oggetto all'interno dello Storage Locale per la chiave " + storeName);
|
|
1812
|
-
}));
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* Recupera un oggetto dallo Storage Locale
|
|
1816
|
-
*
|
|
1817
|
-
* @param {string} storeName Chiave del localStorage da cui recuperare l'oggetto
|
|
1818
|
-
*
|
|
1819
|
-
* @returns {any} Oggetto recuperato e deserializzato
|
|
1820
|
-
*/
|
|
1821
|
-
getItem(storeName) {
|
|
1822
|
-
return this._storage.getItem(storeName).pipe(first(), tap(res => {
|
|
1823
|
-
if (res == null)
|
|
1824
|
-
console.warn("Impossibile ottenere l'oggetto salvato con chiave " + storeName);
|
|
1825
|
-
}));
|
|
1826
|
-
}
|
|
1827
|
-
/**
|
|
1828
|
-
* Ripulisce lo Storage Locale
|
|
1829
|
-
*
|
|
1830
|
-
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1831
|
-
*/
|
|
1832
|
-
removeItem(storeName) {
|
|
1833
|
-
return this._storage.removeItem(storeName).pipe(first(), tap(res => {
|
|
1834
|
-
if (res == false)
|
|
1835
|
-
console.warn("Impossibile rimuovere l'oggetto salvato con chiave " + storeName);
|
|
1836
|
-
}));
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
|
-
* Ripulisce lo Storage Locale di ogni cosa salvata
|
|
1840
|
-
*
|
|
1841
|
-
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1842
|
-
*/
|
|
1843
|
-
clear() {
|
|
1844
|
-
return this._storage.clear().pipe(first(), tap(res => {
|
|
1845
|
-
if (res == false)
|
|
1846
|
-
console.warn("Impossibile ripulire lo Storage Locale");
|
|
1847
|
-
}));
|
|
1848
1782
|
}
|
|
1849
1783
|
/**
|
|
1850
|
-
*
|
|
1784
|
+
* Permette di registrare un modulo esterno alla lista dei moduli in listening sulla coda di messaggi
|
|
1851
1785
|
*
|
|
1852
|
-
* @
|
|
1786
|
+
* @param {string} key Chiave del modulo da registrare. Tutti i messaggi inbound saranno inviati dall'applicazione principale su questa chiave
|
|
1853
1787
|
*/
|
|
1854
|
-
|
|
1855
|
-
|
|
1788
|
+
register(key) {
|
|
1789
|
+
if (this.outbounds[key])
|
|
1790
|
+
throw "@esfaenza/extensions - InterComService: Impossibile registrare più volte lo stesso modulo";
|
|
1791
|
+
this.outbounds[key] = new Subject();
|
|
1856
1792
|
}
|
|
1857
1793
|
}
|
|
1858
|
-
|
|
1794
|
+
InterComService.decorators = [
|
|
1859
1795
|
{ type: Injectable }
|
|
1860
|
-
];
|
|
1861
|
-
StorageService.ctorParameters = () => [
|
|
1862
|
-
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [APPSEARCH_PREFIX,] }] },
|
|
1863
|
-
{ type: BaseSessionRetriever },
|
|
1864
|
-
{ type: BaseStorageProvider }
|
|
1865
|
-
];
|
|
1866
|
-
|
|
1867
|
-
/**
|
|
1868
|
-
* Implementazione di default per la classe **BaseSessionRetriever**
|
|
1869
|
-
*/
|
|
1870
|
-
class DefaultSessionRetriever extends BaseSessionRetriever {
|
|
1871
|
-
/**
|
|
1872
|
-
* Costruttore
|
|
1873
|
-
*
|
|
1874
|
-
* @ignore
|
|
1875
|
-
*/
|
|
1876
|
-
constructor() { super(); }
|
|
1877
|
-
/**
|
|
1878
|
-
* Ottiene un ID sessione
|
|
1879
|
-
*
|
|
1880
|
-
* @returns {string} ID sessione
|
|
1881
|
-
*/
|
|
1882
|
-
getSessionKey() {
|
|
1883
|
-
return "DUMMY_SESSION";
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
DefaultSessionRetriever.decorators = [
|
|
1887
|
-
{ type: Injectable }
|
|
1888
|
-
];
|
|
1889
|
-
DefaultSessionRetriever.ctorParameters = () => [];
|
|
1890
|
-
|
|
1891
|
-
/** Implementazione di default per la classe **BaseStorageProvider** */
|
|
1892
|
-
class DefaultStorageProvider extends BaseStorageProvider {
|
|
1893
|
-
/** @ignore Costruttore */
|
|
1894
|
-
constructor(session) { super(session); }
|
|
1895
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1896
|
-
setItem(key, value) {
|
|
1897
|
-
try {
|
|
1898
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
1899
|
-
return of(true);
|
|
1900
|
-
}
|
|
1901
|
-
catch (_a) {
|
|
1902
|
-
// Potrebbe arrivarmi un prefisso di salvataggio nella modalità di default. Questo serve per ripulire le stesse cose con quel prefisso e sperare di liberare spazio
|
|
1903
|
-
if (value.savedprefix) {
|
|
1904
|
-
console.warn("Spazio del local Storage insufficiente, prova a ripulirlo e risalvare");
|
|
1905
|
-
//Pulisco tutte le view con nome che parta per "Hot"
|
|
1906
|
-
for (let key in localStorage) {
|
|
1907
|
-
if (localStorage.hasOwnProperty(key) && key.startsWith(value.savedprefix))
|
|
1908
|
-
delete localStorage[key];
|
|
1909
|
-
}
|
|
1910
|
-
try {
|
|
1911
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
1912
|
-
}
|
|
1913
|
-
catch (e) {
|
|
1914
|
-
console.error("Spazio del local Storage insufficiente per salvare i risultati di ricerca con solo filtri. Non salvo nulla");
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
return of(false);
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1921
|
-
getItem(key) {
|
|
1922
|
-
try {
|
|
1923
|
-
var ret = JSON.parse(localStorage.getItem(key));
|
|
1924
|
-
return of(ret);
|
|
1925
|
-
}
|
|
1926
|
-
catch (_a) {
|
|
1927
|
-
return of(null);
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1931
|
-
removeItem(key) {
|
|
1932
|
-
try {
|
|
1933
|
-
localStorage.removeItem(key);
|
|
1934
|
-
return of(true);
|
|
1935
|
-
}
|
|
1936
|
-
catch (_a) {
|
|
1937
|
-
return of(false);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1941
|
-
clear() {
|
|
1942
|
-
try {
|
|
1943
|
-
localStorage.clear();
|
|
1944
|
-
return of(true);
|
|
1945
|
-
}
|
|
1946
|
-
catch (_a) {
|
|
1947
|
-
return of(false);
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1951
|
-
getAll() {
|
|
1952
|
-
var ret = {};
|
|
1953
|
-
for (let key in localStorage) {
|
|
1954
|
-
ret[key] = localStorage[key];
|
|
1955
|
-
}
|
|
1956
|
-
return of(ret);
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
DefaultStorageProvider.decorators = [
|
|
1960
|
-
{ type: Injectable }
|
|
1961
|
-
];
|
|
1962
|
-
DefaultStorageProvider.ctorParameters = () => [
|
|
1963
|
-
{ type: BaseSessionRetriever }
|
|
1964
1796
|
];
|
|
1965
1797
|
|
|
1966
1798
|
// Angular
|
|
@@ -1971,8 +1803,8 @@ DefaultStorageProvider.ctorParameters = () => [
|
|
|
1971
1803
|
* ExportService,
|
|
1972
1804
|
* HashingService,
|
|
1973
1805
|
* MessageService,
|
|
1974
|
-
* UtilityService
|
|
1975
|
-
*
|
|
1806
|
+
* UtilityService
|
|
1807
|
+
* InterComService
|
|
1976
1808
|
*
|
|
1977
1809
|
* con eventuali provider che utilizzano
|
|
1978
1810
|
*/
|
|
@@ -1987,13 +1819,11 @@ class FullExtensionsModule {
|
|
|
1987
1819
|
HashingService,
|
|
1988
1820
|
MessageService,
|
|
1989
1821
|
UtilityService,
|
|
1990
|
-
|
|
1822
|
+
InterComService,
|
|
1991
1823
|
{ provide: EXT_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
|
|
1992
1824
|
{ provide: EXT_FANCY_ALERTS, useValue: (config === null || config === void 0 ? void 0 : config.fancy_alerts) || true },
|
|
1993
1825
|
{ provide: APPSEARCH_PREFIX, useValue: (config === null || config === void 0 ? void 0 : config.appsearch_prefix) || 'Hot' },
|
|
1994
|
-
{ provide: EXT_ALLOW_UTC, useValue: (config === null || config === void 0 ? void 0 : config.allow_utc) == null ? false : config === null || config === void 0 ? void 0 : config.allow_utc }
|
|
1995
|
-
{ provide: BaseSessionRetriever, useClass: (config === null || config === void 0 ? void 0 : config.sessionRetriever) || DefaultSessionRetriever },
|
|
1996
|
-
{ provide: BaseStorageProvider, useClass: (config === null || config === void 0 ? void 0 : config.storageProvider) || DefaultStorageProvider },
|
|
1826
|
+
{ provide: EXT_ALLOW_UTC, useValue: (config === null || config === void 0 ? void 0 : config.allow_utc) == null ? false : config === null || config === void 0 ? void 0 : config.allow_utc }
|
|
1997
1827
|
]
|
|
1998
1828
|
};
|
|
1999
1829
|
}
|
|
@@ -2020,6 +1850,13 @@ class CsvHeaders {
|
|
|
2020
1850
|
class GenericItem {
|
|
2021
1851
|
}
|
|
2022
1852
|
|
|
1853
|
+
/** Enumeratore dei tipi di messaggio che i moduli esterni possono contattare sull'applicazione principale */
|
|
1854
|
+
var InboundMessageTypes;
|
|
1855
|
+
(function (InboundMessageTypes) {
|
|
1856
|
+
/** Evento di navigazione */
|
|
1857
|
+
InboundMessageTypes[InboundMessageTypes["Navigation"] = 0] = "Navigation";
|
|
1858
|
+
})(InboundMessageTypes || (InboundMessageTypes = {}));
|
|
1859
|
+
|
|
2023
1860
|
/*
|
|
2024
1861
|
* Public API Surface of extensions
|
|
2025
1862
|
*/
|
|
@@ -2028,5 +1865,5 @@ class GenericItem {
|
|
|
2028
1865
|
* Generated bundle index. Do not edit.
|
|
2029
1866
|
*/
|
|
2030
1867
|
|
|
2031
|
-
export { APPSEARCH_PREFIX,
|
|
1868
|
+
export { APPSEARCH_PREFIX, CallResult, ClipboardService, CsvHeaders, DateService, EXT_ALLOW_UTC, EXT_FANCY_ALERTS, EXT_LOCALE, Export, ExportAs, ExportDictionary, ExportList, ExportService, ExtensionsModule, FullExtensionsModule, GenericItem, HashingService, InboundMessageTypes, InterComMessage, InterComService, MessageService, UtilityService };
|
|
2032
1869
|
//# sourceMappingURL=esfaenza-extensions.js.map
|