UNPKG

@fluid-app/storage-manager

Version:

Storage management utilities for Fluid Commerce applications

90 lines (85 loc) 2.26 kB
/** * Storage keys */ declare const STORAGE_KEYS: { CART: string; EVENT_QUEUE: string; SESSION: string; FINGERPRINT: string; COUNTRY: string; LOCALE: string; SERVER_SETTINGS: string; SETTINGS_OVERRIDE: string; ATTRIBUTION: string; ATTRIBUTION_CACHE: string; }; /** * Manages storage operations */ declare class StorageManager { private storage; /** * Set an item in storage * @param key Storage key * @param value Storage value */ setItem(key: string, value: string): void; /** * Get an item from storage * @param key Storage key * @returns The stored value or null if not found */ getItem(key: string): string | null; /** * Remove an item from storage * @param key Storage key */ removeItem(key: string): void; /** * Set an object in storage (serialized as JSON) * @param key Storage key * @param value Object to store */ setObject<T>(key: string, value: T): void; /** * Get an object from storage (deserialized from JSON) * @param key Storage key * @returns The stored object or null if not found or invalid */ getObject<T>(key: string): T | null; /** * Gets country code from storage or cookies * @returns The country code or null if not found */ getCountryCode(): string | null; /** * Sets the country code in storage * @param countryCode The country code to store */ setCountryCode(countryCode: string): void; /** * Gets locale from storage or cookies * @returns The locale or null if not found */ getLocale(): string | null; /** * Sets the locale in storage * @param locale The locale to store */ setLocale(locale: string): void; } /** * Check if the code is running in a browser environment */ declare const isBrowser: boolean; /** * Get a cookie value by name * @param name The name of the cookie to retrieve * @returns The cookie value or null if not found */ declare const getCookie: (name: string) => string | null; declare const COOKIE_KEYS: { COUNTRY: string; LOCALE: string; }; export { COOKIE_KEYS, STORAGE_KEYS, StorageManager, getCookie, isBrowser };