@esfaenza/extensions 13.1.4 → 13.1.7
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/esm2020/lib/models/ExtensionsModuleConfig.mjs +1 -1
- package/esm2020/lib/models/InboundMessageTypes.mjs +7 -0
- package/esm2020/lib/models/InterComMessage.mjs +14 -0
- package/esm2020/lib/modules/extensions.full.module.mjs +6 -13
- package/esm2020/lib/services/extensions.dates.service.mjs +2 -2
- package/esm2020/lib/services/extensions.intercom.service.mjs +53 -0
- package/esm2020/public-api.mjs +5 -4
- package/fesm2015/esfaenza-extensions.mjs +57 -222
- package/fesm2015/esfaenza-extensions.mjs.map +1 -1
- package/fesm2020/esfaenza-extensions.mjs +57 -220
- package/fesm2020/esfaenza-extensions.mjs.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 +28 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -3
- package/esm2020/lib/models/providers/base/BaseStorageProvider.mjs +0 -25
- package/esm2020/lib/models/providers/implementation/DefaultStorageProvider.mjs +0 -79
- package/esm2020/lib/models/session/base/BaseSessionRetriever.mjs +0 -6
- package/esm2020/lib/models/session/implementation/DefaultSessionRetriever.mjs +0 -28
- package/esm2020/lib/services/extensions.storage.service.mjs +0 -105
- package/lib/models/providers/base/BaseStorageProvider.d.ts +0 -65
- package/lib/models/providers/implementation/DefaultStorageProvider.d.ts +0 -23
- package/lib/models/session/base/BaseSessionRetriever.d.ts +0 -11
- package/lib/models/session/implementation/DefaultSessionRetriever.d.ts +0 -21
- package/lib/services/extensions.storage.service.d.ts +0 -61
|
@@ -3,8 +3,7 @@ import { InjectionToken, NgModule, Injectable, Optional, Inject } from '@angular
|
|
|
3
3
|
import swal from 'sweetalert2';
|
|
4
4
|
import * as i1 from 'ngx-toastr';
|
|
5
5
|
import { Deserialize } from 'cerialize';
|
|
6
|
-
import {
|
|
7
|
-
import { of } from 'rxjs';
|
|
6
|
+
import { Subject } from 'rxjs';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Token che identifica il locale da utilizzare per questa libreria, sono supportati i locali 'it-IT' ed 'en-US'
|
|
@@ -695,7 +694,7 @@ class DateService {
|
|
|
695
694
|
tryThis = toCall(date, this.cfg.smallDate);
|
|
696
695
|
else if (length == this.cfg.fulldateNoSS.length)
|
|
697
696
|
tryThis = toCall(date, this.cfg.fulldateNoSS);
|
|
698
|
-
if (tryThis.isValid())
|
|
697
|
+
if (tryThis && tryThis.isValid())
|
|
699
698
|
return tryThis;
|
|
700
699
|
// Se niente funziona, null.
|
|
701
700
|
// Ricondurre l'Input ad una data non è possibile.
|
|
@@ -1757,233 +1756,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1757
1756
|
type: Injectable
|
|
1758
1757
|
}] });
|
|
1759
1758
|
|
|
1760
|
-
/**
|
|
1761
|
-
|
|
1762
|
-
*/
|
|
1763
|
-
class BaseSessionRetriever {
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
/**
|
|
1767
|
-
* Classe che gestisce la scrittura delle informazioni nello store locale.
|
|
1768
|
-
* Questo store locale potrebbe essere il localStorage (implementazione di default data dal **DefaultStorageProvider**),
|
|
1769
|
-
* oppure un'implementazione custom facente capo a un DB esterno.
|
|
1770
|
-
*
|
|
1771
|
-
* In questo ultimo caso però sarà necessario implementarsi un proprio **BaseSessionRetriever**
|
|
1772
|
-
* che generi una chiave univoca di sessione su cui tutte le operazioni di questa classe saranno eseguite
|
|
1773
|
-
*/
|
|
1774
|
-
class BaseStorageProvider {
|
|
1775
|
-
/** @ignore Costruttore */
|
|
1776
|
-
constructor(session) {
|
|
1777
|
-
this.session = session;
|
|
1778
|
-
}
|
|
1759
|
+
/** Classe che rappresenta un generico messaggio scambiato fra applicazione e moduli */
|
|
1760
|
+
class InterComMessage {
|
|
1779
1761
|
/**
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1762
|
+
* Costruttore
|
|
1763
|
+
*
|
|
1764
|
+
* @param type Tipo di messaggio
|
|
1765
|
+
* @param message Contenuto del messaggio
|
|
1766
|
+
*/
|
|
1767
|
+
constructor(type, message) {
|
|
1768
|
+
this.type = type;
|
|
1769
|
+
this.message = message;
|
|
1788
1770
|
}
|
|
1789
1771
|
}
|
|
1790
1772
|
|
|
1791
1773
|
// Angular
|
|
1792
|
-
/**
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
*/
|
|
1800
|
-
class StorageService {
|
|
1801
|
-
/**
|
|
1802
|
-
* Costruttore
|
|
1803
|
-
*
|
|
1804
|
-
* @ignore
|
|
1805
|
-
*/
|
|
1806
|
-
constructor(APPSEARCH_PREFIX, _session, _storage) {
|
|
1807
|
-
this.APPSEARCH_PREFIX = APPSEARCH_PREFIX;
|
|
1808
|
-
this._session = _session;
|
|
1809
|
-
this._storage = _storage;
|
|
1774
|
+
/** Service che si occupa di gestire la comunicazione fra i moduli interni ed esterni dell'applicativo */
|
|
1775
|
+
class InterComService {
|
|
1776
|
+
constructor() {
|
|
1777
|
+
/** Messaggi in uscita, uno per ogni recipient registratosi dall'entrypoint **register** */
|
|
1778
|
+
this.outbounds = {};
|
|
1779
|
+
/** Messaggi in entrata, unico per applicazione principale */
|
|
1780
|
+
this.inbounds = new Subject();
|
|
1810
1781
|
}
|
|
1811
1782
|
/**
|
|
1812
|
-
*
|
|
1813
|
-
* 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
|
|
1783
|
+
* Metodo che permette di inviare un messaggio dall'applicazione ad un modulo esterno o viceversa
|
|
1814
1784
|
*
|
|
1815
|
-
* @param {
|
|
1816
|
-
* @param {
|
|
1785
|
+
* @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)
|
|
1786
|
+
* @param {any} message Messaggio da inviare che può essere un dto in casi complessi ma dovrà essere gestito a dovere lato implementativo
|
|
1787
|
+
* @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
|
|
1817
1788
|
*/
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
//Se
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1789
|
+
send(messageType, message, recipient) {
|
|
1790
|
+
let msg = new InterComMessage(messageType, message);
|
|
1791
|
+
// Se non c'è un recipient significa che è un modulo esterno che invia messaggi al modulo main (quindi messaggio in entrata - inbound)
|
|
1792
|
+
// Altrimenti significa che è il modulo main ad inviare messaggi ai moduli esterni (messaggio in uscita - outbound)
|
|
1793
|
+
if (!recipient) {
|
|
1794
|
+
this.inbounds.next(msg);
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
if (!this.outbounds[recipient])
|
|
1798
|
+
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'");
|
|
1799
|
+
else
|
|
1800
|
+
this.outbounds[recipient].next(msg);
|
|
1826
1801
|
}
|
|
1827
|
-
else
|
|
1828
|
-
finalItem = item;
|
|
1829
|
-
return this._storage.setItem(storeName, finalItem).pipe(first(), tap(res => {
|
|
1830
|
-
if (res == false)
|
|
1831
|
-
console.error("Impossibile effettuare il salvataggio dell'oggetto all'interno dello Storage Locale per la chiave " + storeName);
|
|
1832
|
-
}));
|
|
1833
|
-
}
|
|
1834
|
-
/**
|
|
1835
|
-
* Recupera un oggetto dallo Storage Locale
|
|
1836
|
-
*
|
|
1837
|
-
* @param {string} storeName Chiave del localStorage da cui recuperare l'oggetto
|
|
1838
|
-
*
|
|
1839
|
-
* @returns {any} Oggetto recuperato e deserializzato
|
|
1840
|
-
*/
|
|
1841
|
-
getItem(storeName) {
|
|
1842
|
-
return this._storage.getItem(storeName).pipe(first(), tap(res => {
|
|
1843
|
-
if (res == null)
|
|
1844
|
-
console.warn("Impossibile ottenere l'oggetto salvato con chiave " + storeName);
|
|
1845
|
-
}));
|
|
1846
|
-
}
|
|
1847
|
-
/**
|
|
1848
|
-
* Ripulisce lo Storage Locale
|
|
1849
|
-
*
|
|
1850
|
-
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1851
|
-
*/
|
|
1852
|
-
removeItem(storeName) {
|
|
1853
|
-
return this._storage.removeItem(storeName).pipe(first(), tap(res => {
|
|
1854
|
-
if (res == false)
|
|
1855
|
-
console.warn("Impossibile rimuovere l'oggetto salvato con chiave " + storeName);
|
|
1856
|
-
}));
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
* Ripulisce lo Storage Locale di ogni cosa salvata
|
|
1860
|
-
*
|
|
1861
|
-
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1862
|
-
*/
|
|
1863
|
-
clear() {
|
|
1864
|
-
return this._storage.clear().pipe(first(), tap(res => {
|
|
1865
|
-
if (res == false)
|
|
1866
|
-
console.warn("Impossibile ripulire lo Storage Locale");
|
|
1867
|
-
}));
|
|
1868
|
-
}
|
|
1869
|
-
/**
|
|
1870
|
-
* Restituisce tutte le chiavi-valore associate alla sessione corrente
|
|
1871
|
-
*
|
|
1872
|
-
* @returns {Observable<{ [index: string]: string; }>} Risultato della query
|
|
1873
|
-
*/
|
|
1874
|
-
getAll() {
|
|
1875
|
-
return this._storage.getAll().pipe(first());
|
|
1876
1802
|
}
|
|
1877
|
-
}
|
|
1878
|
-
StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: StorageService, deps: [{ token: APPSEARCH_PREFIX, optional: true }, { token: BaseSessionRetriever }, { token: BaseStorageProvider }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1879
|
-
StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: StorageService });
|
|
1880
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: StorageService, decorators: [{
|
|
1881
|
-
type: Injectable
|
|
1882
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1883
|
-
type: Optional
|
|
1884
|
-
}, {
|
|
1885
|
-
type: Inject,
|
|
1886
|
-
args: [APPSEARCH_PREFIX]
|
|
1887
|
-
}] }, { type: BaseSessionRetriever }, { type: BaseStorageProvider }]; } });
|
|
1888
|
-
|
|
1889
|
-
/**
|
|
1890
|
-
* Implementazione di default per la classe **BaseSessionRetriever**
|
|
1891
|
-
*/
|
|
1892
|
-
class DefaultSessionRetriever extends BaseSessionRetriever {
|
|
1893
1803
|
/**
|
|
1894
|
-
*
|
|
1804
|
+
* Permette di registrare un modulo esterno alla lista dei moduli in listening sulla coda di messaggi
|
|
1895
1805
|
*
|
|
1896
|
-
* @
|
|
1806
|
+
* @param {string} key Chiave del modulo da registrare. Tutti i messaggi inbound saranno inviati dall'applicazione principale su questa chiave
|
|
1897
1807
|
*/
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
* @returns {string} ID sessione
|
|
1903
|
-
*/
|
|
1904
|
-
getSessionKey() {
|
|
1905
|
-
return "DUMMY_SESSION";
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
DefaultSessionRetriever.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DefaultSessionRetriever, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1909
|
-
DefaultSessionRetriever.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DefaultSessionRetriever });
|
|
1910
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DefaultSessionRetriever, decorators: [{
|
|
1911
|
-
type: Injectable
|
|
1912
|
-
}], ctorParameters: function () { return []; } });
|
|
1913
|
-
|
|
1914
|
-
/** Implementazione di default per la classe **BaseStorageProvider** */
|
|
1915
|
-
class DefaultStorageProvider extends BaseStorageProvider {
|
|
1916
|
-
/** @ignore Costruttore */
|
|
1917
|
-
constructor(session) { super(session); }
|
|
1918
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1919
|
-
setItem(key, value) {
|
|
1920
|
-
try {
|
|
1921
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
1922
|
-
return of(true);
|
|
1923
|
-
}
|
|
1924
|
-
catch {
|
|
1925
|
-
// 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
|
|
1926
|
-
if (value.savedprefix) {
|
|
1927
|
-
console.warn("Spazio del local Storage insufficiente, prova a ripulirlo e risalvare");
|
|
1928
|
-
//Pulisco tutte le view con nome che parta per "Hot"
|
|
1929
|
-
for (let key in localStorage) {
|
|
1930
|
-
if (localStorage.hasOwnProperty(key) && key.startsWith(value.savedprefix))
|
|
1931
|
-
delete localStorage[key];
|
|
1932
|
-
}
|
|
1933
|
-
try {
|
|
1934
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
1935
|
-
}
|
|
1936
|
-
catch (e) {
|
|
1937
|
-
console.error("Spazio del local Storage insufficiente per salvare i risultati di ricerca con solo filtri. Non salvo nulla");
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
return of(false);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1944
|
-
getItem(key) {
|
|
1945
|
-
try {
|
|
1946
|
-
var ret = JSON.parse(localStorage.getItem(key));
|
|
1947
|
-
return of(ret);
|
|
1948
|
-
}
|
|
1949
|
-
catch {
|
|
1950
|
-
return of(null);
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1954
|
-
removeItem(key) {
|
|
1955
|
-
try {
|
|
1956
|
-
localStorage.removeItem(key);
|
|
1957
|
-
return of(true);
|
|
1958
|
-
}
|
|
1959
|
-
catch {
|
|
1960
|
-
return of(false);
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1964
|
-
clear() {
|
|
1965
|
-
try {
|
|
1966
|
-
localStorage.clear();
|
|
1967
|
-
return of(true);
|
|
1968
|
-
}
|
|
1969
|
-
catch {
|
|
1970
|
-
return of(false);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1974
|
-
getAll() {
|
|
1975
|
-
var ret = {};
|
|
1976
|
-
for (let key in localStorage) {
|
|
1977
|
-
ret[key] = localStorage[key];
|
|
1978
|
-
}
|
|
1979
|
-
return of(ret);
|
|
1808
|
+
register(key) {
|
|
1809
|
+
if (this.outbounds[key])
|
|
1810
|
+
throw "@esfaenza/extensions - InterComService: Impossibile registrare più volte lo stesso modulo";
|
|
1811
|
+
this.outbounds[key] = new Subject();
|
|
1980
1812
|
}
|
|
1981
1813
|
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
1814
|
+
InterComService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1815
|
+
InterComService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: InterComService });
|
|
1816
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: InterComService, decorators: [{
|
|
1985
1817
|
type: Injectable
|
|
1986
|
-
}]
|
|
1818
|
+
}] });
|
|
1987
1819
|
|
|
1988
1820
|
// Angular
|
|
1989
1821
|
/**
|
|
@@ -1993,8 +1825,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1993
1825
|
* ExportService,
|
|
1994
1826
|
* HashingService,
|
|
1995
1827
|
* MessageService,
|
|
1996
|
-
* UtilityService
|
|
1997
|
-
*
|
|
1828
|
+
* UtilityService
|
|
1829
|
+
* InterComService
|
|
1998
1830
|
*
|
|
1999
1831
|
* con eventuali provider che utilizzano
|
|
2000
1832
|
*/
|
|
@@ -2009,13 +1841,11 @@ class FullExtensionsModule {
|
|
|
2009
1841
|
HashingService,
|
|
2010
1842
|
MessageService,
|
|
2011
1843
|
UtilityService,
|
|
2012
|
-
|
|
1844
|
+
InterComService,
|
|
2013
1845
|
{ provide: EXT_LOCALE, useValue: config?.locale || 'it-IT' },
|
|
2014
1846
|
{ provide: EXT_FANCY_ALERTS, useValue: config?.fancy_alerts || true },
|
|
2015
1847
|
{ provide: APPSEARCH_PREFIX, useValue: config?.appsearch_prefix || 'Hot' },
|
|
2016
|
-
{ provide: EXT_ALLOW_UTC, useValue: config?.allow_utc == null ? false : config?.allow_utc }
|
|
2017
|
-
{ provide: BaseSessionRetriever, useClass: config?.sessionRetriever || DefaultSessionRetriever },
|
|
2018
|
-
{ provide: BaseStorageProvider, useClass: config?.storageProvider || DefaultStorageProvider },
|
|
1848
|
+
{ provide: EXT_ALLOW_UTC, useValue: config?.allow_utc == null ? false : config?.allow_utc }
|
|
2019
1849
|
]
|
|
2020
1850
|
};
|
|
2021
1851
|
}
|
|
@@ -2045,6 +1875,13 @@ class CsvHeaders {
|
|
|
2045
1875
|
class GenericItem {
|
|
2046
1876
|
}
|
|
2047
1877
|
|
|
1878
|
+
/** Enumeratore dei tipi di messaggio che i moduli esterni possono contattare sull'applicazione principale */
|
|
1879
|
+
var InboundMessageTypes;
|
|
1880
|
+
(function (InboundMessageTypes) {
|
|
1881
|
+
/** Evento di navigazione */
|
|
1882
|
+
InboundMessageTypes[InboundMessageTypes["Navigation"] = 0] = "Navigation";
|
|
1883
|
+
})(InboundMessageTypes || (InboundMessageTypes = {}));
|
|
1884
|
+
|
|
2048
1885
|
/*
|
|
2049
1886
|
* Public API Surface of extensions
|
|
2050
1887
|
*/
|
|
@@ -2053,5 +1890,5 @@ class GenericItem {
|
|
|
2053
1890
|
* Generated bundle index. Do not edit.
|
|
2054
1891
|
*/
|
|
2055
1892
|
|
|
2056
|
-
export { APPSEARCH_PREFIX,
|
|
1893
|
+
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 };
|
|
2057
1894
|
//# sourceMappingURL=esfaenza-extensions.mjs.map
|