@sixbell-telco/sdk 1.6.0 → 2.0.1
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/CHANGELOG.md +196 -711
- package/README.md +307 -282
- package/_index.css +3 -3
- package/components/audio-player/audio-timeline/audio-timeline.component.d.ts +1 -1
- package/components/audio-player/services/audio.service.d.ts +14 -14
- package/components/countdown/src/countdown.component.d.ts +1 -1
- package/components/dropdown-menu/src/dropdown-menu-content/dropdown-menu-content.component.d.ts +2 -3
- package/components/dual-list/src/dual-list.component.d.ts +2 -1
- package/components/file-upload/file-dropzone/file-dropzone.component.d.ts +7 -7
- package/components/file-upload/file-uploader/file-uploader.component.d.ts +7 -7
- package/components/forms/input/src/input.component.d.ts +11 -1
- package/components/forms/textarea/src/textarea.component.d.ts +10 -10
- package/components/link/src/link.component.d.ts +0 -3
- package/components/tab/directives/tab-content/tab-content.directive.d.ts +3 -3
- package/components/tab/directives/tab-header/tab-header.directive.d.ts +2 -2
- package/components/wizard/services/wizard.service.d.ts +5 -5
- package/directives/auto-focus/public-api.d.ts +1 -1
- package/directives/auto-focus/src/{autofocus.directive.d.ts → auto-focus.directive.d.ts} +5 -7
- package/directives/only-numbers/public-api.d.ts +6 -1
- package/directives/only-numbers/src/only-numbers.directive.d.ts +37 -0
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +7 -5
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-countdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +0 -4
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +8 -7
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +6 -4
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +2 -0
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +15 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +19 -8
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-link.mjs +2 -7
- package/fesm2022/sixbell-telco-sdk-components-link.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-overlay.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-overlay.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs +14 -31
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs +42 -8
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-date.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-date.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs +339 -0
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-sync.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-sync.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +1053 -716
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +345 -257
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/package.json +67 -66
- package/utils/runtime-config/README.md +235 -0
- package/utils/{resource-loader → runtime-config}/index.d.ts +1 -1
- package/utils/runtime-config/public-api.d.ts +5 -0
- package/utils/runtime-config/src/http-client.d.ts +11 -0
- package/utils/runtime-config/src/runtime-config-loader.d.ts +23 -0
- package/utils/runtime-config/src/runtime-config-store.d.ts +11 -0
- package/utils/runtime-config/src/runtime-update-adapter.d.ts +15 -0
- package/utils/runtime-config/src/types.d.ts +66 -0
- package/utils/theme/README.md +324 -986
- package/utils/theme/public-api.d.ts +4 -4
- package/utils/theme/src/constants.d.ts +6 -12
- package/utils/theme/src/models/theme.d.ts +46 -173
- package/utils/theme/src/providers/theme.provider.d.ts +0 -10
- package/utils/theme/src/providers/theme.provider.types.d.ts +16 -15
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +16 -12
- package/utils/theme/src/theme-dom/theme-dom.service.d.ts +8 -0
- package/utils/theme/src/theme.service.d.ts +24 -27
- package/utils/theme/src/utils/utils.d.ts +2 -10
- package/utils/translation/README.md +170 -1390
- package/utils/translation/public-api.d.ts +3 -3
- package/utils/translation/src/constants.d.ts +7 -9
- package/utils/translation/src/models/translation.d.ts +9 -10
- package/utils/translation/src/providers/translation.provider.d.ts +17 -28
- package/utils/translation/src/providers/translation.provider.types.d.ts +13 -6
- package/utils/translation/src/translation.service.d.ts +37 -9
- package/directives/only-numbers/src/just-numbers.directive.d.ts +0 -9
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs +0 -1222
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs.map +0 -1
- package/utils/resource-loader/README.md +0 -460
- package/utils/resource-loader/public-api.d.ts +0 -1
- package/utils/resource-loader/src/cache/index.d.ts +0 -2
- package/utils/resource-loader/src/cache/layers/factory.d.ts +0 -38
- package/utils/resource-loader/src/cache/layers/index.d.ts +0 -3
- package/utils/resource-loader/src/cache/layers/indexed-db-cache.d.ts +0 -118
- package/utils/resource-loader/src/cache/layers/local-storage-cache.d.ts +0 -86
- package/utils/resource-loader/src/cache/layers/memory-cache.d.ts +0 -76
- package/utils/resource-loader/src/cache/types.d.ts +0 -107
- package/utils/resource-loader/src/config/index.d.ts +0 -1
- package/utils/resource-loader/src/config/load-config.d.ts +0 -32
- package/utils/resource-loader/src/constants.d.ts +0 -38
- package/utils/resource-loader/src/http/index.d.ts +0 -1
- package/utils/resource-loader/src/http/retryable-client.d.ts +0 -43
- package/utils/resource-loader/src/index.d.ts +0 -1
- package/utils/resource-loader/src/resource-loader.d.ts +0 -67
- package/utils/resource-loader/src/types.d.ts +0 -152
- package/utils/resource-loader/src/utils/cache-validator.d.ts +0 -72
- package/utils/resource-loader/src/utils/helpers.d.ts +0 -15
- package/utils/resource-loader/src/utils/index.d.ts +0 -2
- package/utils/theme/src/providers/constants.d.ts +0 -7
- package/utils/translation/src/providers/constants.d.ts +0 -11
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry, CacheLayer } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* IndexedDB-backed cache layer implementation.
|
|
4
|
-
* Most persistent and largest capacity (~50MB+ depending on browser).
|
|
5
|
-
* Survives page reload and browser session; user must explicitly clear.
|
|
6
|
-
* Async operations with transactions ensure data integrity.
|
|
7
|
-
*
|
|
8
|
-
* @template T The type of data stored
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const indexedDbCache = new IndexedDbCacheLayer<Config>('my-app', 'sixbell-theme-resources');
|
|
13
|
-
* await indexedDbCache.set('config', { theme: 'dark' }, 3600000);
|
|
14
|
-
* const entry = await indexedDbCache.get('config');
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare class IndexedDbCacheLayer<T = unknown> implements CacheLayer<T> {
|
|
18
|
-
private cacheName;
|
|
19
|
-
private databaseName;
|
|
20
|
-
private dbPromise;
|
|
21
|
-
constructor(cacheName: string, databaseName?: string);
|
|
22
|
-
/**
|
|
23
|
-
* Retrieve a cached entry from IndexedDB.
|
|
24
|
-
*
|
|
25
|
-
* @param key - The cache key
|
|
26
|
-
* @returns The cached entry if found and fresh, null otherwise
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const entry = await indexedDbCache.get('theme-config');
|
|
31
|
-
* if (entry) {
|
|
32
|
-
* console.log('Found in IndexedDB:', entry.value);
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
get(key: string): Promise<CacheEntry<T> | null>;
|
|
37
|
-
/**
|
|
38
|
-
* Store a value in IndexedDB.
|
|
39
|
-
*
|
|
40
|
-
* @param key - The cache key
|
|
41
|
-
* @param value - The data to cache
|
|
42
|
-
* @param ttl - Time-to-live in milliseconds
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* await indexedDbCache.set('theme', { mode: 'dark' }, 3600000);
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
set(key: string, value: T, ttl: number): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Remove a cached entry from IndexedDB.
|
|
52
|
-
*
|
|
53
|
-
* @param key - The cache key
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* await indexedDbCache.remove('theme-config');
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
remove(key: string): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Clear all entries from IndexedDB with this cache name prefix.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* await indexedDbCache.clear();
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
clear(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Remove all expired entries from IndexedDB.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* await indexedDbCache.cleanup();
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
cleanup(): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Get or create the IndexedDB database connection.
|
|
81
|
-
*
|
|
82
|
-
* @private
|
|
83
|
-
* @returns Promise that resolves to the IDBDatabase instance
|
|
84
|
-
*/
|
|
85
|
-
private getDatabase;
|
|
86
|
-
/**
|
|
87
|
-
* Get a value from an IndexedDB object store.
|
|
88
|
-
*
|
|
89
|
-
* @private
|
|
90
|
-
*/
|
|
91
|
-
private getFromStore;
|
|
92
|
-
/**
|
|
93
|
-
* Put a value into an IndexedDB object store.
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
private putInStore;
|
|
98
|
-
/**
|
|
99
|
-
* Delete a value from an IndexedDB object store.
|
|
100
|
-
*
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private deleteFromStore;
|
|
104
|
-
/**
|
|
105
|
-
* Get all keys from an IndexedDB object store.
|
|
106
|
-
*
|
|
107
|
-
* @private
|
|
108
|
-
*/
|
|
109
|
-
private getAllKeysFromStore;
|
|
110
|
-
/**
|
|
111
|
-
* Get the full storage key with namespace prefix.
|
|
112
|
-
*
|
|
113
|
-
* @private
|
|
114
|
-
* @param key - The logical cache key
|
|
115
|
-
* @returns The full storage key with prefix
|
|
116
|
-
*/
|
|
117
|
-
private getStorageKey;
|
|
118
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry, CacheLayer } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* localStorage-backed cache layer implementation.
|
|
4
|
-
* Persistent across page reloads and browser sessions (capacity ~5-10MB per domain).
|
|
5
|
-
* Falls back gracefully if localStorage is unavailable (private browsing, quota exceeded).
|
|
6
|
-
*
|
|
7
|
-
* Stores entries as JSON strings with a namespace prefix to avoid collisions.
|
|
8
|
-
*
|
|
9
|
-
* @template T The type of data stored
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const localCache = new LocalStorageCacheLayer<Config>('my-app');
|
|
14
|
-
* await localCache.set('config', { theme: 'dark' }, 3600000);
|
|
15
|
-
* const entry = await localCache.get('config');
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class LocalStorageCacheLayer<T = unknown> implements CacheLayer<T> {
|
|
19
|
-
private cacheName;
|
|
20
|
-
constructor(cacheName: string);
|
|
21
|
-
/**
|
|
22
|
-
* Retrieve a cached entry from localStorage.
|
|
23
|
-
*
|
|
24
|
-
* @param key - The cache key
|
|
25
|
-
* @returns The cached entry if found and fresh, null otherwise
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const entry = await localCache.get('theme-config');
|
|
30
|
-
* if (entry) {
|
|
31
|
-
* console.log('Found in localStorage:', entry.value);
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
get(key: string): Promise<CacheEntry<T> | null>;
|
|
36
|
-
/**
|
|
37
|
-
* Store a value in localStorage.
|
|
38
|
-
*
|
|
39
|
-
* @param key - The cache key
|
|
40
|
-
* @param value - The data to cache
|
|
41
|
-
* @param ttl - Time-to-live in milliseconds
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* await localCache.set('theme', { mode: 'dark' }, 3600000);
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
set(key: string, value: T, ttl: number): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Remove a cached entry from localStorage.
|
|
51
|
-
*
|
|
52
|
-
* @param key - The cache key
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* await localCache.remove('theme-config');
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
remove(key: string): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Clear all entries from localStorage with this cache name prefix.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* await localCache.clear();
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
clear(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Remove all expired entries from localStorage.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* await localCache.cleanup();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
cleanup(): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Get the full storage key with namespace prefix.
|
|
80
|
-
*
|
|
81
|
-
* @private
|
|
82
|
-
* @param key - The logical cache key
|
|
83
|
-
* @returns The full storage key with prefix
|
|
84
|
-
*/
|
|
85
|
-
private getStorageKey;
|
|
86
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry, CacheLayer } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* In-memory cache layer implementation.
|
|
4
|
-
* Fastest but volatile—cleared on page reload and browser session close.
|
|
5
|
-
*
|
|
6
|
-
* Uses a Map to store entries with O(1) lookup and retrieval.
|
|
7
|
-
*
|
|
8
|
-
* @template T The type of data stored
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const memoryCache = new MemoryCacheLayer<Config>();
|
|
13
|
-
* await memoryCache.set('config', { theme: 'dark' }, 3600000);
|
|
14
|
-
* const entry = await memoryCache.get('config');
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare class MemoryCacheLayer<T = unknown> implements CacheLayer<T> {
|
|
18
|
-
private store;
|
|
19
|
-
/**
|
|
20
|
-
* Retrieve a cached entry from memory.
|
|
21
|
-
*
|
|
22
|
-
* @param key - The cache key
|
|
23
|
-
* @returns The cached entry if found and fresh, null otherwise
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const entry = await memoryCache.get('theme-config');
|
|
28
|
-
* if (entry) {
|
|
29
|
-
* console.log('Found in memory:', entry.value);
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
get(key: string): Promise<CacheEntry<T> | null>;
|
|
34
|
-
/**
|
|
35
|
-
* Store a value in memory cache.
|
|
36
|
-
*
|
|
37
|
-
* @param key - The cache key
|
|
38
|
-
* @param value - The data to cache
|
|
39
|
-
* @param ttl - Time-to-live in milliseconds
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* await memoryCache.set('theme', { mode: 'dark' }, 3600000);
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
set(key: string, value: T, ttl: number): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Remove a cached entry from memory.
|
|
49
|
-
*
|
|
50
|
-
* @param key - The cache key
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* await memoryCache.remove('theme-config');
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
remove(key: string): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Clear all entries from memory cache.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* await memoryCache.clear();
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
clear(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Remove all expired entries from memory cache.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* await memoryCache.cleanup();
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
cleanup(): Promise<void>;
|
|
76
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { CacheLayerName } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a single cache entry with metadata.
|
|
4
|
-
*
|
|
5
|
-
* @template T The type of cached data
|
|
6
|
-
*
|
|
7
|
-
* @property value - The actual cached data
|
|
8
|
-
* @property timestamp - When the entry was created (milliseconds since epoch)
|
|
9
|
-
* @property ttl - Time-to-live in milliseconds from creation
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const entry: CacheEntry<Config> = {
|
|
14
|
-
* value: { theme: 'dark' },
|
|
15
|
-
* timestamp: Date.now(),
|
|
16
|
-
* ttl: 3600000, // 1 hour
|
|
17
|
-
* };
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export interface CacheEntry<T> {
|
|
21
|
-
value: T;
|
|
22
|
-
timestamp: number;
|
|
23
|
-
ttl: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Abstract interface for cache storage layers.
|
|
27
|
-
* Each layer (IndexedDB, localStorage, memory) implements this interface,
|
|
28
|
-
* allowing the loader to swap between storage backends seamlessly.
|
|
29
|
-
*
|
|
30
|
-
* @template T The type of data stored
|
|
31
|
-
*/
|
|
32
|
-
export interface CacheLayer<T = unknown> {
|
|
33
|
-
/**
|
|
34
|
-
* Retrieve a cached entry by key.
|
|
35
|
-
*
|
|
36
|
-
* @param key - The cache key
|
|
37
|
-
* @returns The cached entry, or null if not found or expired
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* const entry = await cacheLayer.get('theme-config');
|
|
42
|
-
* if (entry) {
|
|
43
|
-
* console.log('Found:', entry.value);
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
get(key: string): Promise<CacheEntry<T> | null>;
|
|
48
|
-
/**
|
|
49
|
-
* Store a value in the cache.
|
|
50
|
-
*
|
|
51
|
-
* @param key - The cache key
|
|
52
|
-
* @param value - The data to cache
|
|
53
|
-
* @param ttl - Time-to-live in milliseconds
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* await cacheLayer.set('theme-config', themeData, 3600000);
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
set(key: string, value: T, ttl: number): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Remove a cached entry by key.
|
|
63
|
-
*
|
|
64
|
-
* @param key - The cache key
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* await cacheLayer.remove('theme-config');
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
remove(key: string): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Clear all entries from this cache layer.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* await cacheLayer.clear();
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
clear(): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Cleanup expired entries (called during maintenance cycles).
|
|
83
|
-
* For in-memory caches, this might remove stale entries.
|
|
84
|
-
* For persistent layers (IndexedDB, localStorage), this removes entries past TTL.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* await cacheLayer.cleanup();
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
cleanup(): Promise<void>;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Configuration for creating cache layers.
|
|
95
|
-
*/
|
|
96
|
-
export interface CacheLayerConfig {
|
|
97
|
-
cacheName: string;
|
|
98
|
-
storageName?: string;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Factory options for creating cache layers.
|
|
102
|
-
*/
|
|
103
|
-
export interface CacheLayerFactoryOptions {
|
|
104
|
-
layerName: CacheLayerName;
|
|
105
|
-
cacheName: string;
|
|
106
|
-
indexedDBName?: string;
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LoadConfig } from './load-config';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ResourceLoaderDefaults, ResourceLoaderRequestOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Merges global defaults with per-request options into a single configuration object.
|
|
4
|
-
* Eliminates scattered config assignments throughout the codebase.
|
|
5
|
-
*
|
|
6
|
-
* @template T The expected data type
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const config = new LoadConfig<MyData>(defaults, requestOptions);
|
|
11
|
-
* console.log(config.cacheTTL); // Value from requestOptions or defaults
|
|
12
|
-
* console.log(config.retries); // Value from requestOptions or defaults
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare class LoadConfig<T = unknown> {
|
|
16
|
-
readonly cacheName: string;
|
|
17
|
-
readonly storageOrder: string[];
|
|
18
|
-
readonly cacheTTL: number;
|
|
19
|
-
readonly staleWhileRevalidate: boolean;
|
|
20
|
-
readonly useStaleOnError: boolean;
|
|
21
|
-
readonly revalidateOnFresh: boolean;
|
|
22
|
-
readonly retries: number;
|
|
23
|
-
readonly retryDelayMs: number;
|
|
24
|
-
readonly timeoutMs: number;
|
|
25
|
-
readonly parser: (response: Response) => Promise<unknown>;
|
|
26
|
-
readonly seedCacheWithFallback: boolean;
|
|
27
|
-
readonly logErrors: boolean;
|
|
28
|
-
readonly freshOnNavigation: boolean;
|
|
29
|
-
readonly cacheKey: string;
|
|
30
|
-
readonly fallbackData?: T;
|
|
31
|
-
constructor(defaults: ResourceLoaderDefaults | undefined, options: ResourceLoaderRequestOptions<T> | undefined, url: string);
|
|
32
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { CacheLayerName, ResourceLoaderDefaults } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Default storage layer order for cache lookups.
|
|
4
|
-
* IndexedDB is tried first (largest capacity), then localStorage, then memory (fastest but volatile).
|
|
5
|
-
*/
|
|
6
|
-
export declare const DEFAULT_STORAGE_ORDER: CacheLayerName[];
|
|
7
|
-
/**
|
|
8
|
-
* Default cache TTL: 24 hours (in milliseconds)
|
|
9
|
-
*/
|
|
10
|
-
export declare const DEFAULT_CACHE_TTL: number;
|
|
11
|
-
/**
|
|
12
|
-
* IndexedDB database and store names
|
|
13
|
-
*/
|
|
14
|
-
export declare const INDEXED_DB_NAME = "resilient-resources";
|
|
15
|
-
export declare const INDEXED_DB_STORE_NAME = "resources";
|
|
16
|
-
/**
|
|
17
|
-
* Default configuration for ResourceLoader instances.
|
|
18
|
-
* These values are applied to all load operations unless explicitly overridden.
|
|
19
|
-
*
|
|
20
|
-
* Note: freshOnNavigation defaults to true, which is the recommended pattern:
|
|
21
|
-
* - Skip cache on every load, always fetch fresh with network retry fallback to cache
|
|
22
|
-
* - Prevents stale data problems and layout shifts
|
|
23
|
-
* - Use fallbackData for offline scenarios
|
|
24
|
-
* - Disable it (set to false) only if you need aggressive caching (rare cases)
|
|
25
|
-
*/
|
|
26
|
-
export declare const RESOURCE_LOADER_DEFAULTS: ResourceLoaderDefaults;
|
|
27
|
-
/**
|
|
28
|
-
* Maximum number of retry attempts for failed requests
|
|
29
|
-
*/
|
|
30
|
-
export declare const MAX_RETRIES = 5;
|
|
31
|
-
/**
|
|
32
|
-
* Cleanup interval for cache maintenance (24 hours)
|
|
33
|
-
*/
|
|
34
|
-
export declare const CACHE_CLEANUP_INTERVAL: number;
|
|
35
|
-
/**
|
|
36
|
-
* Maximum cleanup task duration (5 minutes)
|
|
37
|
-
*/
|
|
38
|
-
export declare const MAX_CLEANUP_TASK_DURATION: number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RetryableHttpClient } from './retryable-client';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encapsulates HTTP request logic with built-in retry and timeout support.
|
|
3
|
-
* Centralizes fetch implementation to eliminate duplication across the codebase.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```typescript
|
|
7
|
-
* const client = new RetryableHttpClient(3, 250, 8000);
|
|
8
|
-
* const response = await client.fetch('https://example.com/data');
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export declare class RetryableHttpClient {
|
|
12
|
-
readonly retries: number;
|
|
13
|
-
readonly retryDelayMs: number;
|
|
14
|
-
readonly timeoutMs: number;
|
|
15
|
-
constructor(retries: number, retryDelayMs: number, timeoutMs: number);
|
|
16
|
-
/**
|
|
17
|
-
* Fetch a resource with automatic retry and timeout support.
|
|
18
|
-
*
|
|
19
|
-
* @param url - The resource URL
|
|
20
|
-
* @returns The Response object
|
|
21
|
-
* @throws Error if all retries are exhausted or fetch fails
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* try {
|
|
26
|
-
* const response = await client.fetch('https://api.example.com/config');
|
|
27
|
-
* const data = await response.json();
|
|
28
|
-
* } catch (error) {
|
|
29
|
-
* console.error('Failed to fetch:', error);
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
fetch(url: string): Promise<Response>;
|
|
34
|
-
/**
|
|
35
|
-
* Single fetch attempt with timeout.
|
|
36
|
-
*
|
|
37
|
-
* @private
|
|
38
|
-
* @param url - The resource URL
|
|
39
|
-
* @returns The Response object
|
|
40
|
-
* @throws Error if fetch times out or fails
|
|
41
|
-
*/
|
|
42
|
-
private attemptFetch;
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './resource-loader';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { LoggerService } from '@sixbell-telco/sdk/utils/logger';
|
|
2
|
-
export type { CacheLayerName, ResourceCacheStatus, ResourceLoadResult, ResourceLoaderDefaults, ResourceLoaderRequestOptions, ResourceSource, } from './types';
|
|
3
|
-
export type { CacheEntry, CacheLayer, CacheLayerConfig, CacheLayerFactoryOptions } from './cache';
|
|
4
|
-
export { IndexedDbCacheLayer, LocalStorageCacheLayer, MemoryCacheLayer } from './cache/layers';
|
|
5
|
-
export { CacheLayerFactory } from './cache/layers/factory';
|
|
6
|
-
export { CacheValidator, cloneValue } from './utils';
|
|
7
|
-
export { DEFAULT_CACHE_TTL, DEFAULT_STORAGE_ORDER, RESOURCE_LOADER_DEFAULTS } from './constants';
|
|
8
|
-
import type { ResourceLoadResult, ResourceLoaderDefaults, ResourceLoaderRequestOptions } from './types';
|
|
9
|
-
/**
|
|
10
|
-
* Provides intelligent resource loading with:
|
|
11
|
-
* - **Multi-layer caching**: IndexedDB (persistent) → localStorage → memory, with automatic fallback
|
|
12
|
-
* - **Retry logic**: Configurable retries with exponential backoff and request timeouts
|
|
13
|
-
* - **Stale-while-revalidate**: Serve cached data immediately, refresh in background
|
|
14
|
-
* - **Fallback support**: Gracefully degrade to fallback data when all else fails
|
|
15
|
-
* - **Request deduplication**: Multiple identical requests share a single network call
|
|
16
|
-
*
|
|
17
|
-
* @example Basic usage (theme configuration):
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const loader = new ResourceLoader({
|
|
20
|
-
* cacheName: 'theme-cache',
|
|
21
|
-
* cacheTTL: 1000 * 60 * 60 * 24, // 24 hours
|
|
22
|
-
* storageOrder: ['indexedDB', 'localStorage', 'memory'],
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* const result = await loader.load<ThemeConfig>('assets/themes/config.json', {
|
|
26
|
-
* fallbackData: DEFAULT_THEME_CONFIG,
|
|
27
|
-
* parser: async (response) => (await response.json()) as ThemeConfig,
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* console.log(result.data); // Theme configuration
|
|
31
|
-
* console.log(result.source); // 'cache', 'network', or 'fallback'
|
|
32
|
-
* console.log(result.cacheStatus); // 'fresh', 'stale', or 'miss'
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare class ResourceLoader {
|
|
36
|
-
private readonly defaults;
|
|
37
|
-
private readonly layerPool;
|
|
38
|
-
private readonly inFlightLoads;
|
|
39
|
-
private logger;
|
|
40
|
-
private indexedDBName;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new ResourceLoader instance.
|
|
43
|
-
*
|
|
44
|
-
* @param defaults Global default configuration applied to all load operations
|
|
45
|
-
* @param logger Optional logger instance for debug output
|
|
46
|
-
*/
|
|
47
|
-
constructor(defaults?: ResourceLoaderDefaults, logger?: LoggerService);
|
|
48
|
-
/**
|
|
49
|
-
* Loads a resource with intelligent caching, retry, and fallback support.
|
|
50
|
-
*
|
|
51
|
-
* @template T The expected data type to be loaded
|
|
52
|
-
* @param url The URL or path to fetch the resource from
|
|
53
|
-
* @param options Request-specific options (override defaults)
|
|
54
|
-
* @returns A promise resolving to a ResourceLoadResult containing data, source, and cache status
|
|
55
|
-
*/
|
|
56
|
-
load<T = unknown>(url: string, options?: ResourceLoaderRequestOptions<T>): Promise<ResourceLoadResult<T>>;
|
|
57
|
-
private loadInternal;
|
|
58
|
-
private lookupCache;
|
|
59
|
-
private logCacheStatus;
|
|
60
|
-
private returnCacheResult;
|
|
61
|
-
private returnCacheWithRevalidation;
|
|
62
|
-
private performBackgroundRefresh;
|
|
63
|
-
private fetchAndHandleError;
|
|
64
|
-
private performFetch;
|
|
65
|
-
private buildLayers;
|
|
66
|
-
private writeToLayers;
|
|
67
|
-
}
|