@sankhyalabs/core 5.20.0-dev.54 → 5.20.0-dev.55
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/.docs/classes/ServiceUtils.md +67 -0
- package/.docs/enumerations/StorageType.md +37 -0
- package/.docs/globals.md +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/CacheManager/index.d.ts +52 -0
- package/dist/utils/CacheManager/index.js +101 -0
- package/dist/utils/CacheManager/index.js.map +1 -0
- package/dist/utils/CacheManager/interfaces/index.d.ts +5 -0
- package/dist/utils/CacheManager/interfaces/index.js +7 -0
- package/dist/utils/CacheManager/interfaces/index.js.map +1 -0
- package/dist/utils/ServiceUtils.d.ts +24 -0
- package/dist/utils/ServiceUtils.js +40 -0
- package/dist/utils/ServiceUtils.js.map +1 -0
- package/package.json +1 -1
- package/reports/test-report.xml +103 -103
- package/src/index.ts +4 -0
- package/src/utils/CacheManager/index.ts +103 -0
- package/src/utils/CacheManager/interfaces/index.ts +5 -0
- package/src/utils/ServiceUtils.ts +36 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[**@sankhyalabs/core**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@sankhyalabs/core](../globals.md) / ServiceUtils
|
|
6
|
+
|
|
7
|
+
# Class: ServiceUtils
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new ServiceUtils()
|
|
12
|
+
|
|
13
|
+
> **new ServiceUtils**(): [`ServiceUtils`](ServiceUtils.md)
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
[`ServiceUtils`](ServiceUtils.md)
|
|
18
|
+
|
|
19
|
+
## Methods
|
|
20
|
+
|
|
21
|
+
### useCacheWithService()
|
|
22
|
+
|
|
23
|
+
> `static` **useCacheWithService**\<`T`\>(`identifier`, `fetchFunction`, `storageType`): `Promise`\<`T`\>
|
|
24
|
+
|
|
25
|
+
Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
|
|
26
|
+
|
|
27
|
+
#### Type parameters
|
|
28
|
+
|
|
29
|
+
• **T**
|
|
30
|
+
|
|
31
|
+
Tipo do dado a ser retornado.
|
|
32
|
+
|
|
33
|
+
#### Parameters
|
|
34
|
+
|
|
35
|
+
• **identifier**: `string`
|
|
36
|
+
|
|
37
|
+
Identificadores únicos usados para compor a chave de cache.
|
|
38
|
+
|
|
39
|
+
• **fetchFunction**
|
|
40
|
+
|
|
41
|
+
Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
42
|
+
|
|
43
|
+
• **storageType**: [`StorageType`](../enumerations/StorageType.md)= `StorageType.IN_MEMORY_CACHE`
|
|
44
|
+
|
|
45
|
+
Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
`Promise`\<`T`\>
|
|
50
|
+
|
|
51
|
+
Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
|
|
52
|
+
|
|
53
|
+
#### Example
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const actions = await useCacheWithService(
|
|
57
|
+
`${this.entityName} - ${this.resourceID}`,
|
|
58
|
+
async () => {
|
|
59
|
+
return await fetchActionsFromAPI();
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
console.log(actions);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Source
|
|
66
|
+
|
|
67
|
+
src/utils/ServiceUtils.ts:28
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@sankhyalabs/core**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@sankhyalabs/core](../globals.md) / StorageType
|
|
6
|
+
|
|
7
|
+
# Enumeration: StorageType
|
|
8
|
+
|
|
9
|
+
## Enumeration Members
|
|
10
|
+
|
|
11
|
+
### IN\_MEMORY\_CACHE
|
|
12
|
+
|
|
13
|
+
> **IN\_MEMORY\_CACHE**: `"inMemoryCache"`
|
|
14
|
+
|
|
15
|
+
#### Source
|
|
16
|
+
|
|
17
|
+
src/utils/CacheManager/interfaces/index.ts:2
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### LOCAL\_STORAGE
|
|
22
|
+
|
|
23
|
+
> **LOCAL\_STORAGE**: `"localStorage"`
|
|
24
|
+
|
|
25
|
+
#### Source
|
|
26
|
+
|
|
27
|
+
src/utils/CacheManager/interfaces/index.ts:4
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### SESSION\_STORAGE
|
|
32
|
+
|
|
33
|
+
> **SESSION\_STORAGE**: `"sessionStorage"`
|
|
34
|
+
|
|
35
|
+
#### Source
|
|
36
|
+
|
|
37
|
+
src/utils/CacheManager/interfaces/index.ts:3
|
package/.docs/globals.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- [OverflowDirection](enumerations/OverflowDirection.md)
|
|
18
18
|
- [SelectionMode](enumerations/SelectionMode.md)
|
|
19
19
|
- [SortMode](enumerations/SortMode.md)
|
|
20
|
+
- [StorageType](enumerations/StorageType.md)
|
|
20
21
|
- [UserInterface](enumerations/UserInterface.md)
|
|
21
22
|
|
|
22
23
|
## Classes
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
- [SearchUtils](classes/SearchUtils.md)
|
|
51
52
|
- [SelectionInfo](classes/SelectionInfo.md)
|
|
52
53
|
- [ServiceCanceledException](classes/ServiceCanceledException.md)
|
|
54
|
+
- [ServiceUtils](classes/ServiceUtils.md)
|
|
53
55
|
- [SkwHttpProvider](classes/SkwHttpProvider.md)
|
|
54
56
|
- [StringUtils](classes/StringUtils.md)
|
|
55
57
|
- [TimeFormatter](classes/TimeFormatter.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -40,5 +40,7 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js";
|
|
|
40
40
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
41
41
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
42
42
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
43
|
+
import { ServiceUtils } from "./utils/ServiceUtils.js";
|
|
44
|
+
import { StorageType } from "./utils/CacheManager/index.js";
|
|
43
45
|
import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
44
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DependencyType, ChildDescriptor, ChildLink, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, ExecutionContext, PaginationInfo, SortingProvider, SortMode, LoadDataRequest, LoadDataResponse, SelectionInfo, SelectionMode, ElementIDUtils, IElementIDInfo, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils, PromiseSync, PromiseSyncCallback, HTMLBuilder, IRepository, IDBRepository, ILoadResult, IRepositoryIndex, FieldComparator, defaultDataLoader, KeyboardManager, SearchUtils, OverflowWatcher, OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME, DataUnitEventOptions, ServiceCanceledException };
|
|
46
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DependencyType, ChildDescriptor, ChildLink, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, ExecutionContext, PaginationInfo, SortingProvider, SortMode, LoadDataRequest, LoadDataResponse, SelectionInfo, SelectionMode, ElementIDUtils, IElementIDInfo, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils, PromiseSync, PromiseSyncCallback, HTMLBuilder, IRepository, IDBRepository, ILoadResult, IRepositoryIndex, FieldComparator, defaultDataLoader, KeyboardManager, SearchUtils, ServiceUtils, StorageType, OverflowWatcher, OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME, DataUnitEventOptions, ServiceCanceledException };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ import { IDBRepository } from "./repository/indexeddb/IDBRepository.js";
|
|
|
34
34
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
35
35
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
36
36
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
37
|
+
import { ServiceUtils } from "./utils/ServiceUtils.js";
|
|
38
|
+
import { StorageType } from "./utils/CacheManager/index.js";
|
|
37
39
|
import OverflowWatcher, { OverflowDirection, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
38
40
|
/*Classes públicas no pacote*/
|
|
39
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, DataType, UserInterface, DependencyType, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, SortMode, SelectionInfo, SelectionMode, ElementIDUtils, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils, PromiseSync, HTMLBuilder, IDBRepository, FieldComparator, defaultDataLoader, KeyboardManager, SearchUtils, OverflowWatcher, OverflowDirection, OVERFLOWED_CLASS_NAME, ServiceCanceledException };
|
|
41
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, DataType, UserInterface, DependencyType, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, SortMode, SelectionInfo, SelectionMode, ElementIDUtils, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils, PromiseSync, HTMLBuilder, IDBRepository, FieldComparator, defaultDataLoader, KeyboardManager, SearchUtils, ServiceUtils, StorageType, OverflowWatcher, OverflowDirection, OVERFLOWED_CLASS_NAME, ServiceCanceledException };
|
|
40
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EA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CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAO,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,eAAe,EAAE,EAAsB,iBAAiB,EAAyB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAExJ,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,eAAe,EAGf,QAAQ,EAGR,aAAa,EACb,cAAc,EAGd,cAAc,EACd,MAAM,EACN,MAAM,EAGN,eAAe,EAEf,kBAAkB,EAIlB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,aAAa,EAIb,QAAQ,EAGR,aAAa,EACb,aAAa,EACb,cAAc,EAEd,cAAc,EACd,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EAEX,WAAW,EAEX,aAAa,EAGb,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EAEf,iBAAiB,EAEjB,qBAAqB,EAErB,wBAAwB,EAC3B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { StorageType } from './interfaces/index.js';
|
|
2
|
+
export * from "./interfaces/index.js";
|
|
3
|
+
export declare class CacheManager {
|
|
4
|
+
/**
|
|
5
|
+
* Nome da chave utilizada para armazenar o cache no armazenamento.
|
|
6
|
+
*/
|
|
7
|
+
private static readonly storageKey;
|
|
8
|
+
/**
|
|
9
|
+
* Estrutura de armazenamento em memória.
|
|
10
|
+
*/
|
|
11
|
+
private static inMemoryCache;
|
|
12
|
+
/**
|
|
13
|
+
* Recupera ou define o valor no cache.
|
|
14
|
+
*
|
|
15
|
+
* @param key Identificador único para armazenar e recuperar o valor.
|
|
16
|
+
* @param fetchCallback Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
17
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
18
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchCallback`.
|
|
19
|
+
*/
|
|
20
|
+
static getOrSet<T>(key: string, fetchCallback: () => Promise<T>, storageType?: StorageType): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Remove uma entrada específica do cache.
|
|
23
|
+
*
|
|
24
|
+
* @param key Identificador único da entrada a ser removida.
|
|
25
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
26
|
+
*/
|
|
27
|
+
static clear(key: string, storageType?: StorageType): void;
|
|
28
|
+
/**
|
|
29
|
+
* Remove todas as entradas do cache.
|
|
30
|
+
*
|
|
31
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
32
|
+
*/
|
|
33
|
+
static clearAll(storageType?: StorageType): void;
|
|
34
|
+
/**
|
|
35
|
+
* Obtém o cache armazenado no armazenamento especificado.
|
|
36
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
37
|
+
* @returns Um objeto representando o cache armazenado.
|
|
38
|
+
*/
|
|
39
|
+
private static getCache;
|
|
40
|
+
/**
|
|
41
|
+
* Salva o cache no armazenamento especificado.
|
|
42
|
+
* @param cache O objeto representando o cache a ser salvo.
|
|
43
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
44
|
+
*/
|
|
45
|
+
private static saveCache;
|
|
46
|
+
/**
|
|
47
|
+
* Retorna o armazenamento correspondente ao tipo especificado.
|
|
48
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`.
|
|
49
|
+
* @returns O objeto de armazenamento correspondente.
|
|
50
|
+
*/
|
|
51
|
+
private static getStorage;
|
|
52
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { StorageType } from './interfaces/index.js';
|
|
11
|
+
export * from "./interfaces/index.js";
|
|
12
|
+
export class CacheManager {
|
|
13
|
+
/**
|
|
14
|
+
* Recupera ou define o valor no cache.
|
|
15
|
+
*
|
|
16
|
+
* @param key Identificador único para armazenar e recuperar o valor.
|
|
17
|
+
* @param fetchCallback Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
18
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
19
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchCallback`.
|
|
20
|
+
*/
|
|
21
|
+
static getOrSet(key, fetchCallback, storageType = StorageType.IN_MEMORY_CACHE) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const cache = this.getCache(storageType);
|
|
24
|
+
if (cache[key]) {
|
|
25
|
+
return cache[key].data;
|
|
26
|
+
}
|
|
27
|
+
const data = yield fetchCallback();
|
|
28
|
+
cache[key] = { data };
|
|
29
|
+
this.saveCache(cache, storageType);
|
|
30
|
+
return data;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Remove uma entrada específica do cache.
|
|
35
|
+
*
|
|
36
|
+
* @param key Identificador único da entrada a ser removida.
|
|
37
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
38
|
+
*/
|
|
39
|
+
static clear(key, storageType = StorageType.IN_MEMORY_CACHE) {
|
|
40
|
+
const cache = this.getCache(storageType);
|
|
41
|
+
delete cache[key];
|
|
42
|
+
this.saveCache(cache, storageType);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Remove todas as entradas do cache.
|
|
46
|
+
*
|
|
47
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
48
|
+
*/
|
|
49
|
+
static clearAll(storageType = StorageType.IN_MEMORY_CACHE) {
|
|
50
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
51
|
+
this.inMemoryCache.clear();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.getStorage(storageType).removeItem(this.storageKey);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Obtém o cache armazenado no armazenamento especificado.
|
|
59
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
60
|
+
* @returns Um objeto representando o cache armazenado.
|
|
61
|
+
*/
|
|
62
|
+
static getCache(storageType) {
|
|
63
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
64
|
+
return Object.fromEntries(this.inMemoryCache);
|
|
65
|
+
}
|
|
66
|
+
const storage = this.getStorage(storageType);
|
|
67
|
+
const cache = storage.getItem(this.storageKey);
|
|
68
|
+
return cache ? JSON.parse(cache) : {};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Salva o cache no armazenamento especificado.
|
|
72
|
+
* @param cache O objeto representando o cache a ser salvo.
|
|
73
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
74
|
+
*/
|
|
75
|
+
static saveCache(cache, storageType) {
|
|
76
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
77
|
+
this.inMemoryCache = new Map(Object.entries(cache));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const storage = this.getStorage(storageType);
|
|
81
|
+
storage.setItem(this.storageKey, JSON.stringify(cache));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Retorna o armazenamento correspondente ao tipo especificado.
|
|
86
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`.
|
|
87
|
+
* @returns O objeto de armazenamento correspondente.
|
|
88
|
+
*/
|
|
89
|
+
static getStorage(storageType) {
|
|
90
|
+
return storageType === StorageType.LOCAL_STORAGE ? localStorage : sessionStorage;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Nome da chave utilizada para armazenar o cache no armazenamento.
|
|
95
|
+
*/
|
|
96
|
+
CacheManager.storageKey = 'cacheManager';
|
|
97
|
+
/**
|
|
98
|
+
* Estrutura de armazenamento em memória.
|
|
99
|
+
*/
|
|
100
|
+
CacheManager.inMemoryCache = new Map();
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/CacheManager/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uB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W,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SACjD;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,SAAS,CAAC,KAA0B,EAAE,WAAwB;QACzE,IAAI,WAAW,KAAK,WAAW,CAAC,eAAe,EAAE;YAC7C,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;SACvD;aAAM;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAC7C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3D;IACL,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,UAAU,CAAC,WAAwB;QAC9C,OAAO,WAAW,KAAK,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;IACrF,CAAC;;AAhGD;;GAEG;AACqB,uBAAU,GAAG,cAAc,CAAC;AAEpD;;GAEG;AACY,0BAAa,GAAG,IAAI,GAAG,EAAe,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var StorageType;
|
|
2
|
+
(function (StorageType) {
|
|
3
|
+
StorageType["IN_MEMORY_CACHE"] = "inMemoryCache";
|
|
4
|
+
StorageType["SESSION_STORAGE"] = "sessionStorage";
|
|
5
|
+
StorageType["LOCAL_STORAGE"] = "localStorage";
|
|
6
|
+
})(StorageType || (StorageType = {}));
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/CacheManager/interfaces/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,gDAAiC,CAAA;IACjC,iDAAkC,CAAA;IAClC,6CAA8B,CAAA;AAClC,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StorageType } from './CacheManager/interfaces/index.js';
|
|
2
|
+
export declare class ServiceUtils {
|
|
3
|
+
/**
|
|
4
|
+
* Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
|
|
5
|
+
*
|
|
6
|
+
* @template T Tipo do dado a ser retornado.
|
|
7
|
+
* @param identifier Identificadores únicos usados para compor a chave de cache.
|
|
8
|
+
* @param fetchFunction Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
9
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
|
|
10
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const actions = await useCacheWithService(
|
|
15
|
+
* `${this.entityName} - ${this.resourceID}`,
|
|
16
|
+
* async () => {
|
|
17
|
+
* return await fetchActionsFromAPI();
|
|
18
|
+
* }
|
|
19
|
+
* );
|
|
20
|
+
* console.log(actions);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
static useCacheWithService<T>(identifier: string, fetchFunction: () => Promise<T>, storageType?: StorageType): Promise<T>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { CacheManager } from './CacheManager/index.js';
|
|
11
|
+
import { StorageType } from './CacheManager/interfaces/index.js';
|
|
12
|
+
export class ServiceUtils {
|
|
13
|
+
/**
|
|
14
|
+
* Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
|
|
15
|
+
*
|
|
16
|
+
* @template T Tipo do dado a ser retornado.
|
|
17
|
+
* @param identifier Identificadores únicos usados para compor a chave de cache.
|
|
18
|
+
* @param fetchFunction Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
19
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
|
|
20
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const actions = await useCacheWithService(
|
|
25
|
+
* `${this.entityName} - ${this.resourceID}`,
|
|
26
|
+
* async () => {
|
|
27
|
+
* return await fetchActionsFromAPI();
|
|
28
|
+
* }
|
|
29
|
+
* );
|
|
30
|
+
* console.log(actions);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
static useCacheWithService(identifier, fetchFunction, storageType = StorageType.IN_MEMORY_CACHE) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const cacheKey = `${identifier}`;
|
|
36
|
+
return CacheManager.getOrSet(cacheKey, fetchFunction, storageType);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ServiceUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceUtils.js","sourceRoot":"","sources":["../../src/utils/ServiceUtils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,MAAM,OAAO,YAAY;IAGrB;;;;;;;;;;;;;;;;;;;OAmBG;IACI,MAAM,CAAO,mBAAmB,CACnC,UAAkB,EAClB,aAA+B,EAC/B,cAA2B,WAAW,CAAC,eAAe;;YAEtD,MAAM,QAAQ,GAAG,GAAG,UAAU,EAAE,CAAC;YACjC,OAAO,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;QACvE,CAAC;KAAA;CACJ"}
|
package/package.json
CHANGED
package/reports/test-report.xml
CHANGED
|
@@ -1,175 +1,175 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<unitTest version="1">
|
|
3
|
+
<file path="/builds/dti/design-system/sankhyacore/test/http/HttpProvider.spec.ts">
|
|
4
|
+
<testCase name="HttpProvider Metodo GET" duration="12"/>
|
|
5
|
+
</file>
|
|
6
|
+
<file path="/builds/dti/design-system/sankhyacore/test/http/SkwHttpProvider.ts.spec.ts">
|
|
7
|
+
<testCase name="HttpProvider Metodo POST" duration="16"/>
|
|
8
|
+
</file>
|
|
9
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
|
|
10
|
+
<testCase name="StringUtils it should return the correct values of "value" and "type" through the getters methods initial setted by the constructor" duration="3"/>
|
|
11
|
+
<testCase name="StringUtils it should return the correct values of "value" and "type" through the getters methods initial setted by the setters methods" duration="0"/>
|
|
12
|
+
<testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="1"/>
|
|
13
|
+
</file>
|
|
3
14
|
<file path="/builds/dti/design-system/sankhyacore/src/utils/test/objectUtils.spec.ts">
|
|
4
|
-
<testCase name="ObjectUtils hasEquivalentValues should return true if both objects have the same property value" duration="
|
|
15
|
+
<testCase name="ObjectUtils hasEquivalentValues should return true if both objects have the same property value" duration="6"/>
|
|
5
16
|
<testCase name="ObjectUtils hasEquivalentValues should return false if both objects have different property values" duration="1"/>
|
|
6
|
-
<testCase name="ObjectUtils hasEquivalentValues should return true if both objects are equivalent with custom property to compare" duration="
|
|
7
|
-
<testCase name="ObjectUtils hasEquivalentValues should return false if both objects are not equivalent with custom property to compare" duration="
|
|
17
|
+
<testCase name="ObjectUtils hasEquivalentValues should return true if both objects are equivalent with custom property to compare" duration="1"/>
|
|
18
|
+
<testCase name="ObjectUtils hasEquivalentValues should return false if both objects are not equivalent with custom property to compare" duration="190"/>
|
|
8
19
|
<testCase name="ObjectUtils hasEquivalentValues should return false if one object does not have the property" duration="1"/>
|
|
9
|
-
<testCase name="ObjectUtils hasEquivalentValues should return true if comparing primitive values directly" duration="
|
|
10
|
-
<testCase name="ObjectUtils hasEquivalentValues should return false if comparing different primitive values" duration="
|
|
20
|
+
<testCase name="ObjectUtils hasEquivalentValues should return true if comparing primitive values directly" duration="1"/>
|
|
21
|
+
<testCase name="ObjectUtils hasEquivalentValues should return false if comparing different primitive values" duration="0"/>
|
|
11
22
|
<testCase name="ObjectUtils hasEquivalentValues should return true when comparing object with a null value" duration="0"/>
|
|
12
|
-
<testCase name="ObjectUtils hasEquivalentValues should return false when comparing object with null and non-null value" duration="
|
|
13
|
-
<testCase name="ObjectUtils hasEquivalentValues should return true when comparing non-object values that are equal" duration="
|
|
14
|
-
<testCase name="ObjectUtils should get an object value based on its path" duration="
|
|
23
|
+
<testCase name="ObjectUtils hasEquivalentValues should return false when comparing object with null and non-null value" duration="1"/>
|
|
24
|
+
<testCase name="ObjectUtils hasEquivalentValues should return true when comparing non-object values that are equal" duration="1"/>
|
|
25
|
+
<testCase name="ObjectUtils should get an object value based on its path" duration="0"/>
|
|
15
26
|
<testCase name="ObjectUtils should get an object value based on its path" duration="0"/>
|
|
16
27
|
<testCase name="ObjectUtils should return undefined if the path doesn't exist in the object" duration="1"/>
|
|
17
28
|
</file>
|
|
18
29
|
<file path="/builds/dti/design-system/sankhyacore/test/util/MaskFormatter.spec.ts">
|
|
19
|
-
<testCase name="Mask Formatter mask:CPF complete valid" duration="
|
|
30
|
+
<testCase name="Mask Formatter mask:CPF complete valid" duration="84"/>
|
|
20
31
|
<testCase name="Mask Formatter mask:CPF complete valid literals" duration="1"/>
|
|
21
|
-
<testCase name="Mask Formatter mask:CPF incomplete valid" duration="
|
|
32
|
+
<testCase name="Mask Formatter mask:CPF incomplete valid" duration="0"/>
|
|
22
33
|
<testCase name="Mask Formatter mask:CPF incomplete valid placeholder" duration="1"/>
|
|
23
|
-
<testCase name="Mask Formatter mask:CPF too long valid" duration="
|
|
24
|
-
<testCase name="Mask Formatter mask:CPF invalid for string" duration="
|
|
25
|
-
<testCase name="Mask Formatter mask:CPF invalid for being too long" duration="
|
|
26
|
-
<testCase name="Mask Formatter mask:Licence plate valid uppercase" duration="
|
|
34
|
+
<testCase name="Mask Formatter mask:CPF too long valid" duration="0"/>
|
|
35
|
+
<testCase name="Mask Formatter mask:CPF invalid for string" duration="112"/>
|
|
36
|
+
<testCase name="Mask Formatter mask:CPF invalid for being too long" duration="0"/>
|
|
37
|
+
<testCase name="Mask Formatter mask:Licence plate valid uppercase" duration="1"/>
|
|
27
38
|
<testCase name="Mask Formatter mask:Licence plate valid lowercase" duration="1"/>
|
|
28
|
-
<testCase name="Mask Formatter mask:Licence plate invalid" duration="
|
|
29
|
-
<testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="
|
|
39
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="78"/>
|
|
40
|
+
<testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="1"/>
|
|
30
41
|
<testCase name="Mask Formatter mask:Licence plate invalid for being too short with placeholder" duration="1"/>
|
|
31
|
-
<testCase name="Mask Formatter mask:Licence plate invalid" duration="
|
|
32
|
-
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="
|
|
33
|
-
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="
|
|
42
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="3"/>
|
|
43
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
|
|
44
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
|
|
34
45
|
<testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
|
|
35
|
-
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="
|
|
46
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
|
|
36
47
|
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="1"/>
|
|
37
48
|
<testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
|
|
38
49
|
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
|
|
39
|
-
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="
|
|
50
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
|
|
40
51
|
<testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
|
|
41
52
|
</file>
|
|
42
53
|
<file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaModel.spec.ts">
|
|
43
|
-
<testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="
|
|
44
|
-
<testCase name="StringUtils it should modify "expressions" and "parameters" properties through Setters methods" duration="
|
|
45
|
-
<testCase name="StringUtils it should return "expression" and "parameters" setted through constructor method" duration="
|
|
46
|
-
<testCase name="StringUtils it should return a Criteria class with "expression" and "parameters" as needed setted through "append" method" duration="
|
|
54
|
+
<testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="14"/>
|
|
55
|
+
<testCase name="StringUtils it should modify "expressions" and "parameters" properties through Setters methods" duration="2"/>
|
|
56
|
+
<testCase name="StringUtils it should return "expression" and "parameters" setted through constructor method" duration="2"/>
|
|
57
|
+
<testCase name="StringUtils it should return a Criteria class with "expression" and "parameters" as needed setted through "append" method" duration="87"/>
|
|
47
58
|
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "append" method" duration="1"/>
|
|
48
|
-
<testCase name="StringUtils it should return undefined as "expression" and "[]" as parameters as we use an empty criteria as first entry in the constructor" duration="
|
|
59
|
+
<testCase name="StringUtils it should return undefined as "expression" and "[]" as parameters as we use an empty criteria as first entry in the constructor" duration="1"/>
|
|
49
60
|
<testCase name="StringUtils it should return a Criteria class with "Expression" and "parameters" concatenaded as needed setted through "OR" method" duration="1"/>
|
|
50
|
-
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="
|
|
51
|
-
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="
|
|
52
|
-
<testCase name="StringUtils it should return a Criteria class with "Expression" and "parameters" concatenaded as needed setted through "AND" method" duration="
|
|
53
|
-
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="1"/>
|
|
61
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="0"/>
|
|
62
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="0"/>
|
|
63
|
+
<testCase name="StringUtils it should return a Criteria class with "Expression" and "parameters" concatenaded as needed setted through "AND" method" duration="91"/>
|
|
54
64
|
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="1"/>
|
|
65
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="2"/>
|
|
55
66
|
<testCase name="StringUtils it should return a toJSON object with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="1"/>
|
|
56
67
|
<testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="1"/>
|
|
57
68
|
</file>
|
|
58
|
-
<file path="/builds/dti/design-system/sankhyacore/test/
|
|
59
|
-
<testCase name="
|
|
60
|
-
</file>
|
|
61
|
-
<file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
|
|
62
|
-
<testCase name="OverflowWatcher should initialize with provided parameters" duration="17"/>
|
|
63
|
-
<testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="3"/>
|
|
64
|
-
<testCase name="OverflowWatcher Should call callback on forceUpdate" duration="445"/>
|
|
65
|
-
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="66"/>
|
|
66
|
-
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="14"/>
|
|
67
|
-
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="9"/>
|
|
68
|
-
<testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="5"/>
|
|
69
|
-
<testCase name="OverflowWatcher should ignore elements that can not overflow" duration="72"/>
|
|
70
|
-
<testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="1"/>
|
|
71
|
-
</file>
|
|
72
|
-
<file path="/builds/dti/design-system/sankhyacore/test/http/SkwHttpProvider.ts.spec.ts">
|
|
73
|
-
<testCase name="HttpProvider Metodo POST" duration="1"/>
|
|
74
|
-
</file>
|
|
75
|
-
<file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
|
|
76
|
-
<testCase name="StringUtils stringToNumber" duration="104"/>
|
|
77
|
-
<testCase name="StringUtils format" duration="221"/>
|
|
78
|
-
<testCase name="StringUtils format without formatnumber parameter" duration="1"/>
|
|
79
|
-
<testCase name="StringUtils format without formatnumber parameter" duration="4"/>
|
|
80
|
-
<testCase name="StringUtils format round number" duration="2"/>
|
|
69
|
+
<file path="/builds/dti/design-system/sankhyacore/src/dataunit/state/slice/test/RecordsSlice.spec.ts">
|
|
70
|
+
<testCase name="RecordsSlice should return newlines at the end" duration="3"/>
|
|
81
71
|
</file>
|
|
82
72
|
<file path="/builds/dti/design-system/sankhyacore/test/util/StringUtils.spec.ts">
|
|
83
|
-
<testCase name="StringUtils valor vazio" duration="
|
|
73
|
+
<testCase name="StringUtils valor vazio" duration="24"/>
|
|
84
74
|
<testCase name="StringUtils valor em branco" duration="1"/>
|
|
85
75
|
<testCase name="StringUtils valor null" duration="0"/>
|
|
86
|
-
<testCase name="StringUtils valor undefined" duration="
|
|
87
|
-
<testCase name="StringUtils valor 0" duration="
|
|
88
|
-
<testCase name="StringUtils com valor" duration="
|
|
89
|
-
<testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="
|
|
90
|
-
<testCase name="StringUtils should return the original value when called with an object without a toString method" duration="
|
|
76
|
+
<testCase name="StringUtils valor undefined" duration="0"/>
|
|
77
|
+
<testCase name="StringUtils valor 0" duration="1"/>
|
|
78
|
+
<testCase name="StringUtils com valor" duration="0"/>
|
|
79
|
+
<testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="3"/>
|
|
80
|
+
<testCase name="StringUtils should return the original value when called with an object without a toString method" duration="70"/>
|
|
91
81
|
<testCase name="StringUtils should return the original value when called with undefined" duration="1"/>
|
|
92
82
|
</file>
|
|
93
|
-
<file path="/builds/dti/design-system/sankhyacore/test/util/
|
|
94
|
-
<testCase name="StringUtils
|
|
95
|
-
<testCase name="StringUtils
|
|
96
|
-
<testCase name="StringUtils
|
|
83
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
|
|
84
|
+
<testCase name="StringUtils stringToNumber" duration="102"/>
|
|
85
|
+
<testCase name="StringUtils format" duration="199"/>
|
|
86
|
+
<testCase name="StringUtils format without formatnumber parameter" duration="2"/>
|
|
87
|
+
<testCase name="StringUtils format without formatnumber parameter" duration="1"/>
|
|
88
|
+
<testCase name="StringUtils format round number" duration="3"/>
|
|
97
89
|
</file>
|
|
98
90
|
<file path="/builds/dti/design-system/sankhyacore/test/util/TimeFormatter.spec.ts">
|
|
99
|
-
<testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="
|
|
100
|
-
<testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="
|
|
91
|
+
<testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="1"/>
|
|
92
|
+
<testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="0"/>
|
|
101
93
|
<testCase name="TimeFormatter Case: validateTime" duration="1"/>
|
|
102
94
|
</file>
|
|
103
|
-
<file path="/builds/dti/design-system/sankhyacore/
|
|
104
|
-
<testCase name="
|
|
95
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
|
|
96
|
+
<testCase name="OverflowWatcher should initialize with provided parameters" duration="9"/>
|
|
97
|
+
<testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="2"/>
|
|
98
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate" duration="292"/>
|
|
99
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="26"/>
|
|
100
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="99"/>
|
|
101
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="78"/>
|
|
102
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="4"/>
|
|
103
|
+
<testCase name="OverflowWatcher should ignore elements that can not overflow" duration="97"/>
|
|
104
|
+
<testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="1"/>
|
|
105
105
|
</file>
|
|
106
106
|
<file path="/builds/dti/design-system/sankhyacore/test/util/DataUnitStorage.spec.ts">
|
|
107
|
-
<testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="
|
|
108
|
-
<testCase name="DataUnitStorage get should return the stored DataUnit instance from the DataUnitStorage" duration="
|
|
109
|
-
<testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="
|
|
110
|
-
<testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="
|
|
107
|
+
<testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="72"/>
|
|
108
|
+
<testCase name="DataUnitStorage get should return the stored DataUnit instance from the DataUnitStorage" duration="0"/>
|
|
109
|
+
<testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="0"/>
|
|
110
|
+
<testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="1"/>
|
|
111
111
|
<testCase name="DataUnitStorage remove should remove the DataUnit instance with the specified name from the DataUnitStorage" duration="1"/>
|
|
112
|
-
<testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="
|
|
112
|
+
<testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="0"/>
|
|
113
113
|
</file>
|
|
114
114
|
<file path="/builds/dti/design-system/sankhyacore/src/dataunit/test/DataUnit.spec.ts">
|
|
115
|
-
<testCase name="DataUnit should return false when not waiting to reload" duration="
|
|
116
|
-
<testCase name="DataUnit should set waitingToReload to true" duration="
|
|
115
|
+
<testCase name="DataUnit should return false when not waiting to reload" duration="4"/>
|
|
116
|
+
<testCase name="DataUnit should set waitingToReload to true" duration="0"/>
|
|
117
117
|
<testCase name="DataUnit should set waitingToReload to false" duration="1"/>
|
|
118
|
-
<testCase name="DataUnit should dispatch SAVING_CANCELED action with correct fields and recordId" duration="
|
|
118
|
+
<testCase name="DataUnit should dispatch SAVING_CANCELED action with correct fields and recordId" duration="4"/>
|
|
119
119
|
</file>
|
|
120
120
|
<file path="/builds/dti/design-system/sankhyacore/test/util/ElementIDUtils.spec.ts">
|
|
121
|
-
<testCase name="addIDInfo 1 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="
|
|
121
|
+
<testCase name="addIDInfo 1 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="13"/>
|
|
122
122
|
<testCase name="addIDInfo 2 - should add data-element-id with valid id "brComSankhyaFinCadMovimentacaofinanceira_snkApplication"" duration="2"/>
|
|
123
123
|
<testCase name="addIDInfo 3 - should add data-element-id with valid id "movFinanceira_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="2"/>
|
|
124
|
-
<testCase name="addIDInfo 4 - should add data-element-id with valid id "meuID2_snkApplication"" duration="
|
|
124
|
+
<testCase name="addIDInfo 4 - should add data-element-id with valid id "meuID2_snkApplication"" duration="1"/>
|
|
125
125
|
<testCase name="addIDInfo 5 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="1"/>
|
|
126
|
-
<testCase name="addIDInfo 6 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="
|
|
126
|
+
<testCase name="addIDInfo 6 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="2"/>
|
|
127
127
|
<testCase name="addIDInfo 7 - should add data-element-id with valid id "componenteNameTest_snkApplication"" duration="1"/>
|
|
128
128
|
<testCase name="addIDInfo 8 - should add data-element-id with valid id "componentLabel_snkApplication"" duration="1"/>
|
|
129
|
-
<testCase name="addIDInfo 9 - should add data-element-id with valid id "dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="
|
|
130
|
-
<testCase name="addIDInfo 10 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="
|
|
131
|
-
<testCase name="addIDInfo 11 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira"" duration="
|
|
132
|
-
<testCase name="addIDInfo 12 - should add data-element-id with valid id "dataunitFinanceiro_movFinanceira_movimentacaoFinanceira"" duration="
|
|
129
|
+
<testCase name="addIDInfo 9 - should add data-element-id with valid id "dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="2"/>
|
|
130
|
+
<testCase name="addIDInfo 10 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="62"/>
|
|
131
|
+
<testCase name="addIDInfo 11 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira"" duration="1"/>
|
|
132
|
+
<testCase name="addIDInfo 12 - should add data-element-id with valid id "dataunitFinanceiro_movFinanceira_movimentacaoFinanceira"" duration="2"/>
|
|
133
133
|
<testCase name="addIDInfo 13 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira"" duration="2"/>
|
|
134
|
-
<testCase name="addIDInfo 14 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira"" duration="
|
|
134
|
+
<testCase name="addIDInfo 14 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira"" duration="1"/>
|
|
135
135
|
<testCase name="addIDInfo 15 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_snkApplication"" duration="1"/>
|
|
136
|
-
<testCase name="addIDInfo 16 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_snkApplication"" duration="
|
|
136
|
+
<testCase name="addIDInfo 16 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_snkApplication"" duration="8"/>
|
|
137
137
|
<testCase name="addIDInfo 17 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
138
138
|
<testCase name="addIDInfo 18 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
139
|
-
<testCase name="addIDInfo 19 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="
|
|
140
|
-
<testCase name="addIDInfo 20 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="
|
|
141
|
-
<testCase name="addIDInfo 21 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="
|
|
142
|
-
<testCase name="addIDInfo 22 - should add data-element-id with valid id "bancoObrigatorio_movimentacaoFinanceira"" duration="
|
|
139
|
+
<testCase name="addIDInfo 19 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="0"/>
|
|
140
|
+
<testCase name="addIDInfo 20 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="0"/>
|
|
141
|
+
<testCase name="addIDInfo 21 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="2"/>
|
|
142
|
+
<testCase name="addIDInfo 22 - should add data-element-id with valid id "bancoObrigatorio_movimentacaoFinanceira"" duration="1"/>
|
|
143
143
|
</file>
|
|
144
144
|
<file path="/builds/dti/design-system/sankhyacore/test/util/ElementUtils.spec.ts">
|
|
145
|
-
<testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="
|
|
146
|
-
<testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="
|
|
147
|
-
<testCase name="calcMarginSize should threat values defined as zero" duration="
|
|
145
|
+
<testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="53"/>
|
|
146
|
+
<testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="2"/>
|
|
147
|
+
<testCase name="calcMarginSize should threat values defined as zero" duration="3"/>
|
|
148
148
|
</file>
|
|
149
149
|
<file path="/builds/dti/design-system/sankhyacore/test/dataunit/formatting/PrettyFormatter.spec.ts">
|
|
150
|
-
<testCase name="getFormattedValue should return empty string when value is null" duration="
|
|
150
|
+
<testCase name="getFormattedValue should return empty string when value is null" duration="5"/>
|
|
151
151
|
<testCase name="getFormattedValue should return empty string when value is not an array" duration="1"/>
|
|
152
|
-
<testCase name="getFormattedValue should return empty string when value is an empty array" duration="
|
|
153
|
-
<testCase name="getFormattedValue should return file name when value is an array with one file object" duration="
|
|
152
|
+
<testCase name="getFormattedValue should return empty string when value is an empty array" duration="0"/>
|
|
153
|
+
<testCase name="getFormattedValue should return file name when value is an array with one file object" duration="1"/>
|
|
154
154
|
<testCase name="getFormattedValue should return file count when value is an array with multiple file objects" duration="0"/>
|
|
155
|
-
<testCase name="getFormattedValue should return empty string for undefined file" duration="
|
|
156
|
-
<testCase name="getFormattedValue should handle OBJECT type with value field" duration="
|
|
155
|
+
<testCase name="getFormattedValue should return empty string for undefined file" duration="0"/>
|
|
156
|
+
<testCase name="getFormattedValue should handle OBJECT type with value field" duration="0"/>
|
|
157
157
|
<testCase name="getFormattedValue should return empty string when value is undefined" duration="0"/>
|
|
158
158
|
<testCase name="getFormattedValue should return value as string when value is not an object" duration="1"/>
|
|
159
159
|
<testCase name="getFormattedValue should return value.toString() when value is an object without value property" duration="0"/>
|
|
160
|
-
<testCase name="getFormattedValue should handle BOOLEAN type" duration="
|
|
161
|
-
<testCase name="getFormattedValue should format numbers correctly" duration="
|
|
162
|
-
<testCase name="getFormattedValue should format dates correctly" duration="
|
|
163
|
-
<testCase name="getFormattedValue should format times correctly" duration="
|
|
164
|
-
<testCase name="getFormattedValue should format datetime correctly" duration="
|
|
160
|
+
<testCase name="getFormattedValue should handle BOOLEAN type" duration="1"/>
|
|
161
|
+
<testCase name="getFormattedValue should format numbers correctly" duration="15"/>
|
|
162
|
+
<testCase name="getFormattedValue should format dates correctly" duration="4"/>
|
|
163
|
+
<testCase name="getFormattedValue should format times correctly" duration="0"/>
|
|
164
|
+
<testCase name="getFormattedValue should format datetime correctly" duration="0"/>
|
|
165
165
|
<testCase name="getFormattedValue should call toString with correct parameters" duration="1"/>
|
|
166
166
|
<testCase name="getFormattedValue should handle undefined descriptor gracefully" duration="1"/>
|
|
167
167
|
<testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and matching option" duration="0"/>
|
|
168
|
-
<testCase name="getFormattedValue should return value with OPTIONSELECTOR and no matching option" duration="
|
|
168
|
+
<testCase name="getFormattedValue should return value with OPTIONSELECTOR and no matching option" duration="0"/>
|
|
169
169
|
<testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and value as object" duration="0"/>
|
|
170
170
|
<testCase name="getFormattedValue should return empty string with OPTIONSELECTOR and value as null" duration="0"/>
|
|
171
171
|
<testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and options as JSON string" duration="0"/>
|
|
172
|
-
<testCase name="getFormattedValue should return value with OPTIONSELECTOR and options as empty array" duration="
|
|
172
|
+
<testCase name="getFormattedValue should return value with OPTIONSELECTOR and options as empty array" duration="0"/>
|
|
173
173
|
<testCase name="getFormattedValue should format masked values correctly" duration="1"/>
|
|
174
174
|
</file>
|
|
175
175
|
</unitTest>
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,8 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js"
|
|
|
40
40
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
41
41
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
42
42
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
43
|
+
import { ServiceUtils } from "./utils/ServiceUtils.js";
|
|
44
|
+
import { StorageType } from "./utils/CacheManager/index.js";
|
|
43
45
|
import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
44
46
|
|
|
45
47
|
/*Classes públicas no pacote*/
|
|
@@ -108,6 +110,8 @@ export {
|
|
|
108
110
|
defaultDataLoader,
|
|
109
111
|
KeyboardManager,
|
|
110
112
|
SearchUtils,
|
|
113
|
+
ServiceUtils,
|
|
114
|
+
StorageType,
|
|
111
115
|
OverflowWatcher,
|
|
112
116
|
OnOverflowCallBack,
|
|
113
117
|
OverflowDirection,
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { StorageType } from './interfaces/index.js';
|
|
2
|
+
|
|
3
|
+
export * from "./interfaces/index.js";
|
|
4
|
+
|
|
5
|
+
export class CacheManager {
|
|
6
|
+
/**
|
|
7
|
+
* Nome da chave utilizada para armazenar o cache no armazenamento.
|
|
8
|
+
*/
|
|
9
|
+
private static readonly storageKey = 'cacheManager';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Estrutura de armazenamento em memória.
|
|
13
|
+
*/
|
|
14
|
+
private static inMemoryCache = new Map<string, any>();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Recupera ou define o valor no cache.
|
|
18
|
+
*
|
|
19
|
+
* @param key Identificador único para armazenar e recuperar o valor.
|
|
20
|
+
* @param fetchCallback Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
21
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
22
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchCallback`.
|
|
23
|
+
*/
|
|
24
|
+
public static async getOrSet<T>(
|
|
25
|
+
key: string,
|
|
26
|
+
fetchCallback: () => Promise<T>,
|
|
27
|
+
storageType: StorageType = StorageType.IN_MEMORY_CACHE
|
|
28
|
+
): Promise<T> {
|
|
29
|
+
const cache = this.getCache(storageType);
|
|
30
|
+
|
|
31
|
+
if (cache[key]) {
|
|
32
|
+
return cache[key].data;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const data = await fetchCallback();
|
|
36
|
+
cache[key] = { data };
|
|
37
|
+
this.saveCache(cache, storageType);
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Remove uma entrada específica do cache.
|
|
43
|
+
*
|
|
44
|
+
* @param key Identificador único da entrada a ser removida.
|
|
45
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
46
|
+
*/
|
|
47
|
+
public static clear(key: string, storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
|
|
48
|
+
const cache = this.getCache(storageType);
|
|
49
|
+
delete cache[key];
|
|
50
|
+
this.saveCache(cache, storageType);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Remove todas as entradas do cache.
|
|
55
|
+
*
|
|
56
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
57
|
+
*/
|
|
58
|
+
public static clearAll(storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
|
|
59
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
60
|
+
this.inMemoryCache.clear();
|
|
61
|
+
} else {
|
|
62
|
+
this.getStorage(storageType).removeItem(this.storageKey);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Obtém o cache armazenado no armazenamento especificado.
|
|
68
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
69
|
+
* @returns Um objeto representando o cache armazenado.
|
|
70
|
+
*/
|
|
71
|
+
private static getCache(storageType: StorageType): Record<string, any> {
|
|
72
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
73
|
+
return Object.fromEntries(this.inMemoryCache);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const storage = this.getStorage(storageType);
|
|
77
|
+
const cache = storage.getItem(this.storageKey);
|
|
78
|
+
return cache ? JSON.parse(cache) : {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Salva o cache no armazenamento especificado.
|
|
83
|
+
* @param cache O objeto representando o cache a ser salvo.
|
|
84
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
85
|
+
*/
|
|
86
|
+
private static saveCache(cache: Record<string, any>, storageType: StorageType): void {
|
|
87
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
88
|
+
this.inMemoryCache = new Map(Object.entries(cache));
|
|
89
|
+
} else {
|
|
90
|
+
const storage = this.getStorage(storageType);
|
|
91
|
+
storage.setItem(this.storageKey, JSON.stringify(cache));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Retorna o armazenamento correspondente ao tipo especificado.
|
|
97
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`.
|
|
98
|
+
* @returns O objeto de armazenamento correspondente.
|
|
99
|
+
*/
|
|
100
|
+
private static getStorage(storageType: StorageType): Storage {
|
|
101
|
+
return storageType === StorageType.LOCAL_STORAGE ? localStorage : sessionStorage;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CacheManager } from './CacheManager/index.js';
|
|
2
|
+
import { StorageType } from './CacheManager/interfaces/index.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class ServiceUtils {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
|
|
10
|
+
*
|
|
11
|
+
* @template T Tipo do dado a ser retornado.
|
|
12
|
+
* @param identifier Identificadores únicos usados para compor a chave de cache.
|
|
13
|
+
* @param fetchFunction Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
14
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
|
|
15
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const actions = await useCacheWithService(
|
|
20
|
+
* `${this.entityName} - ${this.resourceID}`,
|
|
21
|
+
* async () => {
|
|
22
|
+
* return await fetchActionsFromAPI();
|
|
23
|
+
* }
|
|
24
|
+
* );
|
|
25
|
+
* console.log(actions);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
public static async useCacheWithService<T>(
|
|
29
|
+
identifier: string,
|
|
30
|
+
fetchFunction: () => Promise<T>,
|
|
31
|
+
storageType: StorageType = StorageType.IN_MEMORY_CACHE
|
|
32
|
+
): Promise<T> {
|
|
33
|
+
const cacheKey = `${identifier}`;
|
|
34
|
+
return CacheManager.getOrSet(cacheKey, fetchFunction, storageType);
|
|
35
|
+
}
|
|
36
|
+
}
|