@esfaenza/extensions 11.2.14 → 11.2.18

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.
@@ -1790,8 +1790,20 @@
1790
1790
  * che generi una chiave univoca di sessione su cui tutte le operazioni di questa classe saranno eseguite
1791
1791
  */
1792
1792
  var BaseStorageProvider = /** @class */ (function () {
1793
- function BaseStorageProvider() {
1793
+ /** @ignore Costruttore */
1794
+ function BaseStorageProvider(session) {
1795
+ this.session = session;
1794
1796
  }
1797
+ /**
1798
+ * Ottiene la chiave "Reale" da utilizzare per la persistenza di una chiave generica
1799
+ *
1800
+ * @param {string} key Chiave da storicizzare
1801
+ *
1802
+ * @returns {string} Unione fra l'identificativo della sessione e la chiave specificata
1803
+ */
1804
+ BaseStorageProvider.prototype.getKey = function (key) {
1805
+ return this.session.getSessionKey() + "§" + key + "§";
1806
+ };
1795
1807
  return BaseStorageProvider;
1796
1808
  }());
1797
1809
 
@@ -1807,6 +1819,9 @@
1807
1819
  // Angular
1808
1820
  /**
1809
1821
  * Service che fornisce funzionalità di base per storicizzazione e recupero oggetti dallo Storage Locale
1822
+ *
1823
+ * N.B: In ogni chiamata è presente l'operatore rxjs **first()** per far sì che a prescindere dall'implementazione utente/default gli
1824
+ * observable effettuino l'unsubscribe automaticamente terminata la prima operazine
1810
1825
  */
1811
1826
  var StorageService = /** @class */ (function () {
1812
1827
  /**
@@ -1826,25 +1841,20 @@
1826
1841
  * @param {string} storeName Chiave del localStorage in cui storicizzare l'oggetto **itemsContainer**
1827
1842
  * @param {{ items: any[] }} itemsContainer Oggetto da storicizzare
1828
1843
  */
1829
- StorageService.prototype.setItem = function (storeName, itemsContainer) {
1830
- //Prima di salvare elimino gli oggetti per non fillare il localStorage di spazzatura
1831
- var item = JSON.parse(JSON.stringify(itemsContainer));
1832
- item.items = [];
1833
- item.savedstate = true;
1834
- item.savedprefix = this.APPSEARCH_PREFIX || 'Hot';
1835
- return this.setAny(storeName, item);
1836
- };
1837
- /**
1838
- * Inserisce un oggetto nello Storage Locale dopo averlo serializzato
1839
- *
1840
- * @param {string} storeName Chiave del localStorage in cui storicizzare l'oggetto **item**
1841
- * @param {any} item Oggetto da storicizzare
1842
- */
1843
- StorageService.prototype.setAny = function (storeName, item) {
1844
- return this._storage.setItem(this._session.getSessionKey(), storeName, item).pipe(operators.tap(function (res) {
1845
- if (res == false) {
1844
+ StorageService.prototype.setItem = function (storeName, item) {
1845
+ var finalItem;
1846
+ //Se sto salvando un oggetto con "items" e "page" vuol dire che è un appsearch, la ripulisco
1847
+ if (item.items && item.page) {
1848
+ finalItem = JSON.parse(JSON.stringify(item));
1849
+ finalItem.items = [];
1850
+ finalItem.savedstate = true;
1851
+ finalItem.savedprefix = this.APPSEARCH_PREFIX || 'Hot';
1852
+ }
1853
+ else
1854
+ finalItem = item;
1855
+ return this._storage.setItem(storeName, finalItem).pipe(operators.first(), operators.tap(function (res) {
1856
+ if (res == false)
1846
1857
  console.error("Impossibile effettuare il salvataggio dell'oggetto all'interno dello Storage Locale per la chiave " + storeName);
1847
- }
1848
1858
  }));
1849
1859
  };
1850
1860
  /**
@@ -1855,7 +1865,7 @@
1855
1865
  * @returns {any} Oggetto recuperato e deserializzato
1856
1866
  */
1857
1867
  StorageService.prototype.getItem = function (storeName) {
1858
- return this._storage.getItem(this._session.getSessionKey(), storeName).pipe(operators.tap(function (res) {
1868
+ return this._storage.getItem(storeName).pipe(operators.first(), operators.tap(function (res) {
1859
1869
  if (res == null)
1860
1870
  console.warn("Impossibile ottenere l'oggetto salvato con chiave " + storeName);
1861
1871
  }));
@@ -1866,7 +1876,7 @@
1866
1876
  * @param {string} storeName Chiave del localStorage da ripulire
1867
1877
  */
1868
1878
  StorageService.prototype.removeItem = function (storeName) {
1869
- return this._storage.removeItem(this._session.getSessionKey(), storeName).pipe(operators.tap(function (res) {
1879
+ return this._storage.removeItem(storeName).pipe(operators.first(), operators.tap(function (res) {
1870
1880
  if (res == false)
1871
1881
  console.warn("Impossibile rimuovere l'oggetto salvato con chiave " + storeName);
1872
1882
  }));
@@ -1877,11 +1887,19 @@
1877
1887
  * @param {string} storeName Chiave del localStorage da ripulire
1878
1888
  */
1879
1889
  StorageService.prototype.clear = function () {
1880
- return this._storage.clear(this._session.getSessionKey()).pipe(operators.tap(function (res) {
1890
+ return this._storage.clear().pipe(operators.first(), operators.tap(function (res) {
1881
1891
  if (res == false)
1882
1892
  console.warn("Impossibile ripulire lo Storage Locale");
1883
1893
  }));
1884
1894
  };
1895
+ /**
1896
+ * Restituisce tutte le chiavi-valore associate alla sessione corrente
1897
+ *
1898
+ * @returns {Observable<{ [index: string]: string; }>} Risultato della query
1899
+ */
1900
+ StorageService.prototype.getAll = function () {
1901
+ return this._storage.getAll().pipe(operators.first());
1902
+ };
1885
1903
  return StorageService;
1886
1904
  }());
1887
1905
  StorageService.decorators = [
@@ -2233,12 +2251,12 @@
2233
2251
  /** Implementazione di default per la classe **BaseStorageProvider** */
2234
2252
  var DefaultStorageProvider = /** @class */ (function (_super) {
2235
2253
  __extends(DefaultStorageProvider, _super);
2236
- /** @ignore Costruttore */
2237
- function DefaultStorageProvider() {
2238
- return _super.call(this) || this;
2254
+ /** @ignore Costruttore */
2255
+ function DefaultStorageProvider(session) {
2256
+ return _super.call(this, session) || this;
2239
2257
  }
2240
2258
  /** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
2241
- DefaultStorageProvider.prototype.setItem = function (identity, key, value) {
2259
+ DefaultStorageProvider.prototype.setItem = function (key, value) {
2242
2260
  try {
2243
2261
  localStorage.setItem(key, JSON.stringify(value));
2244
2262
  return rxjs.of(true);
@@ -2263,7 +2281,7 @@
2263
2281
  }
2264
2282
  };
2265
2283
  /** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
2266
- DefaultStorageProvider.prototype.getItem = function (identity, key) {
2284
+ DefaultStorageProvider.prototype.getItem = function (key) {
2267
2285
  try {
2268
2286
  var ret = JSON.parse(localStorage.getItem(key));
2269
2287
  return rxjs.of(ret);
@@ -2273,7 +2291,7 @@
2273
2291
  }
2274
2292
  };
2275
2293
  /** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
2276
- DefaultStorageProvider.prototype.removeItem = function (identity, key) {
2294
+ DefaultStorageProvider.prototype.removeItem = function (key) {
2277
2295
  try {
2278
2296
  localStorage.removeItem(key);
2279
2297
  return rxjs.of(true);
@@ -2283,7 +2301,7 @@
2283
2301
  }
2284
2302
  };
2285
2303
  /** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
2286
- DefaultStorageProvider.prototype.clear = function (identity) {
2304
+ DefaultStorageProvider.prototype.clear = function () {
2287
2305
  try {
2288
2306
  localStorage.clear();
2289
2307
  return rxjs.of(true);
@@ -2292,12 +2310,22 @@
2292
2310
  return rxjs.of(false);
2293
2311
  }
2294
2312
  };
2313
+ /** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
2314
+ DefaultStorageProvider.prototype.getAll = function () {
2315
+ var ret = {};
2316
+ for (var key in localStorage) {
2317
+ ret[key] = localStorage[key];
2318
+ }
2319
+ return rxjs.of(ret);
2320
+ };
2295
2321
  return DefaultStorageProvider;
2296
2322
  }(BaseStorageProvider));
2297
2323
  DefaultStorageProvider.decorators = [
2298
2324
  { type: core.Injectable }
2299
2325
  ];
2300
- DefaultStorageProvider.ctorParameters = function () { return []; };
2326
+ DefaultStorageProvider.ctorParameters = function () { return [
2327
+ { type: BaseSessionRetriever }
2328
+ ]; };
2301
2329
 
2302
2330
  // Angular
2303
2331
  /**