ngx-sp-auth 4.3.6 → 4.3.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/fesm2022/ngx-sp-auth.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { RouterLink, NavigationEnd, RouterOutlet } from '@angular/router';
|
|
|
11
11
|
import { BehaviorSubject, take, tap, Subject, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, map as map$1, of, lastValueFrom, from } from 'rxjs';
|
|
12
12
|
import * as i3 from 'ngx-sp-infra';
|
|
13
13
|
import { Utils, SearchInputComponent, InfraModule, FormUtils, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
|
|
14
|
+
import { openDB, deleteDB } from 'idb';
|
|
14
15
|
import * as i3$2 from '@angular/common';
|
|
15
16
|
import { NgIf, CommonModule } from '@angular/common';
|
|
16
17
|
import * as i3$1 from '@angular/forms';
|
|
@@ -1643,6 +1644,131 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
1643
1644
|
args: [LIB_CUSTOM_MENU_SERVICE]
|
|
1644
1645
|
}] }, { type: LibMenuConfigService }, { type: AuthStorageService }] });
|
|
1645
1646
|
|
|
1647
|
+
class IndexedDBService {
|
|
1648
|
+
// #endregion ==========> PROPERTIES <==========
|
|
1649
|
+
constructor(_customEnvironment) {
|
|
1650
|
+
this._customEnvironment = _customEnvironment;
|
|
1651
|
+
this._dbName = "Sp_Filtros_";
|
|
1652
|
+
if (!window.indexedDB) {
|
|
1653
|
+
alert("Seu navegador não suporta uma versão estável do IndexedDB. Salvamento de filtros em sessão não estará disponível.");
|
|
1654
|
+
}
|
|
1655
|
+
this._dbName = `Sp_${_customEnvironment.product}_Filtros`;
|
|
1656
|
+
}
|
|
1657
|
+
// #region ==========> ACTIONS <==========
|
|
1658
|
+
// #region ADD
|
|
1659
|
+
/**
|
|
1660
|
+
* Cria um registro dentro de um objectStore.
|
|
1661
|
+
* O valor a ser inserido precisa ser um objeto com pelo **menos a propriedade `key`**, ela é a nossa *chave-primária* dos registros
|
|
1662
|
+
*
|
|
1663
|
+
* @param value Valor a ser inserido
|
|
1664
|
+
*/
|
|
1665
|
+
async add(value) {
|
|
1666
|
+
const db = await openDB(this._dbName, 1);
|
|
1667
|
+
await db.add('filters', value);
|
|
1668
|
+
}
|
|
1669
|
+
// #endregion ADD
|
|
1670
|
+
// #region GET
|
|
1671
|
+
/**
|
|
1672
|
+
* Busca um valor na base dentro de um objectStore.
|
|
1673
|
+
*
|
|
1674
|
+
* @param storeName Nome do objectStore
|
|
1675
|
+
* @param key Valor da chave única
|
|
1676
|
+
* @returns Promise<> com o valor encontrado ou undefined se não encontrar
|
|
1677
|
+
*/
|
|
1678
|
+
async get(key) {
|
|
1679
|
+
const db = await openDB(this._dbName, 1);
|
|
1680
|
+
return await db.get('filters', key);
|
|
1681
|
+
}
|
|
1682
|
+
// #endregion GET
|
|
1683
|
+
// #region UPDATE
|
|
1684
|
+
/**
|
|
1685
|
+
* Atualiza o valor de um registro dentro de um objectStore.
|
|
1686
|
+
*
|
|
1687
|
+
* @param value Valor atualizado
|
|
1688
|
+
*/
|
|
1689
|
+
async update(value) {
|
|
1690
|
+
const db = await openDB(this._dbName, 1);
|
|
1691
|
+
await db.put('filters', value);
|
|
1692
|
+
}
|
|
1693
|
+
// #endregion UPDATE
|
|
1694
|
+
// #region DELETE
|
|
1695
|
+
/**
|
|
1696
|
+
* Exclui um registro na base dentro de um objectStore.
|
|
1697
|
+
*
|
|
1698
|
+
* @param key Valor da chave única
|
|
1699
|
+
*/
|
|
1700
|
+
async delete(key) {
|
|
1701
|
+
const db = await openDB(this._dbName, 1);
|
|
1702
|
+
await db.delete('filters', key);
|
|
1703
|
+
}
|
|
1704
|
+
// #endregion DELETE
|
|
1705
|
+
// #endregion ==========> ACTIONS <==========
|
|
1706
|
+
// #region ==========> UTILS <==========
|
|
1707
|
+
/**
|
|
1708
|
+
* Inicializa as configurações iniciais do IndexedDB e já cria o objectStore que será utilizado caso não exista.
|
|
1709
|
+
*
|
|
1710
|
+
* O object store que será criado terá sua chave inline na propriedade `key` e o índice será a propriedade `context`, portanto todos os valores que forem inseridos **DEVEM** ser um objeto com pelo menos a propriedade `key` e `context`.
|
|
1711
|
+
* Deve ser chamado no constructor do seu componente para garantir inicialização correta pelo componente
|
|
1712
|
+
*
|
|
1713
|
+
* @param dbName Nome da base de dados que será usada
|
|
1714
|
+
*/
|
|
1715
|
+
async initializeDatabase(dbName = this._dbName) {
|
|
1716
|
+
this.request = await openDB(dbName, 1, {
|
|
1717
|
+
upgrade(db) {
|
|
1718
|
+
// Criar objectStore se não houver um mesmo com este nome
|
|
1719
|
+
if (!db.objectStoreNames.contains('filters')) {
|
|
1720
|
+
const store = db.createObjectStore('filters', { keyPath: 'key' });
|
|
1721
|
+
store.createIndex('context', 'context');
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1724
|
+
blocked() {
|
|
1725
|
+
// notify user / log: another tab has old version open
|
|
1726
|
+
console.warn('IndexedDB blocked — feche outras abas');
|
|
1727
|
+
},
|
|
1728
|
+
blocking() {
|
|
1729
|
+
// this instance is blocking a future version request
|
|
1730
|
+
console.warn('IndexedDB blocking — considere fechar esta conexão');
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Exclui uma database do IndexedDB com base no nome.
|
|
1736
|
+
*
|
|
1737
|
+
* @param name Nome da database
|
|
1738
|
+
*/
|
|
1739
|
+
async deleteDatabase(name) {
|
|
1740
|
+
return await deleteDB(name);
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Valida se já existe um valor cadastrado na base com a chave-única que foi informada, se houver retorna ele, caso contrário cria um registro placeholder para poder atualizar depois.
|
|
1744
|
+
*
|
|
1745
|
+
* @param key Valor da chave única
|
|
1746
|
+
* @param value (opcional) Valor placeholder caso não exista um valor previamente criado
|
|
1747
|
+
*
|
|
1748
|
+
* @returns Estrutura encontrada no objectStore com a chave-única informada
|
|
1749
|
+
*/
|
|
1750
|
+
async validate(key, value) {
|
|
1751
|
+
// Valida se já existe registro no DB local
|
|
1752
|
+
this._restored = await this.get(key);
|
|
1753
|
+
if (!this._restored && value) {
|
|
1754
|
+
// Se não existir nada, inicializa um registro placeholder dentro do objectStore existente
|
|
1755
|
+
await this.add(value);
|
|
1756
|
+
}
|
|
1757
|
+
else {
|
|
1758
|
+
// Se encontrar valor retorna apenas o payload com os dados que serão usados na tela
|
|
1759
|
+
return this._restored?.payload;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IndexedDBService, deps: [{ token: LibCustomEnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1763
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IndexedDBService, providedIn: 'root' }); }
|
|
1764
|
+
}
|
|
1765
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IndexedDBService, decorators: [{
|
|
1766
|
+
type: Injectable,
|
|
1767
|
+
args: [{
|
|
1768
|
+
providedIn: 'root'
|
|
1769
|
+
}]
|
|
1770
|
+
}], ctorParameters: () => [{ type: LibCustomEnvironmentService }] });
|
|
1771
|
+
|
|
1646
1772
|
/**
|
|
1647
1773
|
* Serviço responsável por criar e gerenciar uma instância global do componente SearchInput.
|
|
1648
1774
|
*
|
|
@@ -4214,5 +4340,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
4214
4340
|
* Generated bundle index. Do not edit.
|
|
4215
4341
|
*/
|
|
4216
4342
|
|
|
4217
|
-
export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, DynamicMenuComponent, ErrorMenuNotAllowed, ExternaLoginlGuard, IMenu, InfraUsuarioImg, IsMenuAllowedlGuard, LIB_CUSTOM_ENVIRONMENT_SERVICE, LIB_CUSTOM_LOGIN_SERVICE, LIB_CUSTOM_MENU_SERVICE, LIB_CUSTOM_STORAGE_SERVICE, LIB_MENU_CONFIG, LibCustomEnvironmentService, LibCustomLoginService, LibCustomMenuService, LibCustomStorageService, LibMenuConfigService, ListComponent, LoginComponent, LoginGuard, LoginOSComponent, LoginOSGuard, LoginProgress, MenuLateralComponent, MenuServicesService, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PesquisaTelasGlobalService, PrimaryDropdownComponent, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
|
|
4343
|
+
export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, DynamicMenuComponent, ErrorMenuNotAllowed, ExternaLoginlGuard, IMenu, IndexedDBService, InfraUsuarioImg, IsMenuAllowedlGuard, LIB_CUSTOM_ENVIRONMENT_SERVICE, LIB_CUSTOM_LOGIN_SERVICE, LIB_CUSTOM_MENU_SERVICE, LIB_CUSTOM_STORAGE_SERVICE, LIB_MENU_CONFIG, LibCustomEnvironmentService, LibCustomLoginService, LibCustomMenuService, LibCustomStorageService, LibMenuConfigService, ListComponent, LoginComponent, LoginGuard, LoginOSComponent, LoginOSGuard, LoginProgress, MenuLateralComponent, MenuServicesService, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PesquisaTelasGlobalService, PrimaryDropdownComponent, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
|
|
4218
4344
|
//# sourceMappingURL=ngx-sp-auth.mjs.map
|