import type { Agile } from '../agile'; import { Persistent } from './persistent'; import { Storage, StorageItemKey, StorageKey } from './storage'; export declare class Storages { agileInstance: () => Agile; config: StoragesConfigInterface; storages: { [key: string]: Storage; }; persistentInstances: { [key: string]: Persistent; }; /** * The Storages Class manages all external Storages for an Agile Instance * and provides an interface to easily store, * load and remove values from multiple Storages at once. * * @internal * @param agileInstance - Instance of Agile the Storages belongs to. * @param config - Configuration object */ constructor(agileInstance: Agile, config?: CreateStoragesConfigInterface); /** * Instantiates and registers the * [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localStorage). * * Note that the Local Storage is only available in a web environment. * * @internal */ instantiateLocalStorage(): boolean; /** * Registers the specified Storage with AgileTs * and updates the Persistent Instances that have already attempted * to use the previously unregistered Storage. * * @public * @param storage - Storage to be registered with AgileTs. * @param config - Configuration object */ register(storage: Storage, config?: RegisterConfigInterface): boolean; /** * Retrieves a single Storage with the specified key/name identifier * from the Storages Class. * * If the to retrieve Storage doesn't exist, `undefined` is returned. * * @public * @param storageKey - Key/Name identifier of the Storage. */ getStorage(storageKey: StorageKey | undefined | null): Storage | undefined; /** * Retrieves the stored value at the specified Storage Item key * from the defined external Storage (`storageKey`). * * When no Storage has been specified, * the value is retrieved from the default Storage. * * @public * @param storageItemKey - Key/Name identifier of the value to be retrieved. * @param storageKey - Key/Name identifier of the external Storage * from which the value is to be retrieved. */ get(storageItemKey: StorageItemKey, storageKey?: StorageKey): Promise; /** * Stores or updates the value at the specified Storage Item key * in the defined external Storages (`storageKeys`). * * When no Storage has been specified, * the value is stored/updated in the default Storage. * * @public * @param storageItemKey - Key/Name identifier of the value to be stored. * @param value - Value to be stored in an external Storage. * @param storageKeys - Key/Name identifier of the external Storage * where the value is to be stored. */ set(storageItemKey: StorageItemKey, value: any, storageKeys?: StorageKey[]): void; /** * Removes the value at the specified Storage Item key * from the defined external Storages (`storageKeys`). * * When no Storage has been specified, * the value is removed from the default Storage. * * @public * @param storageItemKey - Key/Name identifier of the value to be removed. * @param storageKeys - Key/Name identifier of the external Storage * from which the value is to be removed. */ remove(storageItemKey: StorageItemKey, storageKeys?: StorageKey[]): void; /** * Returns a boolean indicating whether any Storage * has been registered with the Agile Instance or not. * * @public */ hasStorage(): boolean; /** * Returns a boolean indication whether the * [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localStorage) * is available in the current environment. * * @public */ static localStorageAvailable(): boolean; } export interface CreateStoragesConfigInterface { /** * Whether to register the Local Storage by default. * Note that the Local Storage is only available in a web environment. * @default false */ localStorage?: boolean; /** * Key/Name identifier of the default Storage. * * The default Storage represents the default Storage of the Storages Class, * on which executed actions are performed if no specific Storage was specified. * * Also, the persisted value is loaded from the default Storage by default, * since only one persisted value can be applied. * If the loading of the value from the default Storage failed, * an attempt is made to load the value from the remaining Storages. * * @default undefined */ defaultStorageKey?: StorageKey; } export interface StoragesConfigInterface { /** * Key/Name identifier of the default Storage. * * The default Storage represents the default Storage of the Storages Class, * on which executed actions are performed if no specific Storage was specified. * * Also, the persisted value is loaded from the default Storage by default, * since only one persisted value can be applied. * If the loading of the value from the default Storage failed, * an attempt is made to load the value from the remaining Storages. * * @default undefined */ defaultStorageKey: StorageKey | null; } export interface RegisterConfigInterface { /** * Whether the to register Storage should become the default Storage. * * The default Storage represents the default Storage of the Storages Class, * on which executed actions are performed if no specific Storage was specified. * * Also, the persisted value is loaded from the default Storage by default, * since only one persisted value can be applied. * If the loading of the value from the default Storage failed, * an attempt is made to load the value from the remaining Storages. * * @default false */ default?: boolean; }