/** * CacheStorageRepository - Cache API-based persistent storage (Browser Bundle Version) * Implements IAsyncRepository for asynchronous access to Cache API * * This provides Layer 3 caching in the handler chain: * 1. Memory (sync) → 2. LocalStorage (sync) → 3. CacheStorage (async) → 4. Network (async) */ import type { IAsyncRepository } from '../../interfaces/repository.interface.js'; import type { StorageRepositoryConfig } from '../../config/repository.config.js'; import type { TranslationData } from '../../types/translation-data.types.js'; /** * Configuration options for CacheStorageRepository */ export interface CacheStorageRepositoryConfig extends StorageRepositoryConfig { options?: StorageRepositoryConfig['options'] & { /** Cache name for the Cache API (default: 'lionrapid-v1') */ cacheName?: string; /** TTL in milliseconds (default: 7 days) */ ttl?: number; }; } /** * Cache API-based repository for persistent translation caching * * Features: * - Asynchronous access (Cache API is async) * - TTL-based expiration * - Larger storage capacity than localStorage * - Graceful fallback when Cache API unavailable (SSR, old browsers) * - Works alongside Service Worker for offline support * * @example * ```typescript * import { CacheStorageRepository } from '@lionrapid/storage'; * * const cacheRepo = new CacheStorageRepository({ * enabled: true, * options: { * cacheName: 'my-app-translations', * ttl: 7 * 24 * 60 * 60 * 1000, // 7 days * }, * }); * ``` */ export declare class CacheStorageRepository implements IAsyncRepository { readonly name = "CacheStorageRepository"; readonly type: "storage"; readonly config: CacheStorageRepositoryConfig; private cacheName; private defaultTTL; private available; constructor(config?: CacheStorageRepositoryConfig); /** * Check if Cache API is available * Returns false in SSR, old browsers, or insecure contexts */ private checkAvailability; /** * Get a translation value by key * @throws {TranslationNotFoundError} When translation doesn't exist or is expired */ get(key: string): Promise; /** * Set a translation value */ set(key: string, value: string): Promise; /** * Remove a translation by key */ remove(key: string): Promise; /** * Clear all LionRapid entries from the cache */ clear(): Promise; /** * Clear all entries for a specific namespace */ clearNamespace(locale: string, namespace: string): Promise; /** * Get namespace translations * @throws {TranslationNotFoundError} When namespace doesn't exist */ getNamespace(locale: string, namespace: string): Promise; /** * Set namespace translations */ setNamespace(locale: string, namespace: string, translations: TranslationData): Promise; /** * Get repository configuration */ getConfig(): CacheStorageRepositoryConfig; /** * Check if Cache API is available */ isAvailable(): boolean; /** * Get all cached entries (for debugging) * Returns an object mapping keys to values */ getEntries(): Promise>; /** * Get cache statistics */ getCacheStats(): Promise<{ size: number; cacheName: string; }>; } //# sourceMappingURL=cache-storage-repository.d.ts.map