// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from "rxjs"; import { PartiumConfig } from "../models/partium-config"; import { Organization } from './organization/models/organization'; import { BaseLoginInitService } from "./base-login-init.service"; export type KeyPrefixParams = { userEmail: boolean; organizationName: boolean; }; /** * Class that defines structure of a localStorage-service implementation. * It contains functions that are required for reading and writing data * to the devices localStorage. * * An implementation of this service is required and has to be configured during * the initialization phase of Partium. * * This class file is called interface, even though it is not an interface, * but we need it to be a concrete class for the serviceProvider. */ export declare class LocalStorageService extends BaseLoginInitService { private organizationName; /** * Initializes the LocalStorageService: Configures the service based on the passed Partium configuration. * * Note: Should be called at the start of a session * to ensure the correct recent parts are loaded */ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable): Observable; /** * Sets the value of the pair identified by key to value, creating a new * key/value pair if none existed for key previously. * * Method should be overridden by child-class * * @param key the key to identify the pair * @param value the value as string * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns promise that resolves as soon as the value is stored */ setItem(_key: string, _value: string, _keyPrefixParams?: KeyPrefixParams): Promise; /** * Sets the value of the pair identified by key to value, creating a new * key/value pair if none existed for key previously. * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child-class * * @param key the key to identify the pair * @param value the value as string * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ setItemSync(_key: string, _value: string, _keyPrefixParams?: KeyPrefixParams): void; /** * Sets a series of key-value pairs * * Method should be overridden by child class * * @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']] * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns promise that resolves as soon as all pairs are stored */ setItems(_keyValuePairs: [string, string][], _keyPrefixParams?: KeyPrefixParams): Promise; /** * Sets a series of key-value pairs * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child class * * @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']] * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ setItemsSync(_keyValuePairs: [string, string][], _keyPrefixParams?: KeyPrefixParams): void; /** * Returns the current value associated with the given key, or null if the given * key does not exist in the list associated with the object. * * Method should be overridden by child-class * * @param key the key to identify the pair * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns string-value of the item stored by the given key, or null if not found */ getItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise; /** * Returns the current value associated with the given key, or null if the given * key does not exist in the list associated with the object. * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child-class * * @param key the key to identify the pair * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns string-value of the item stored by the given key, or null if not found */ getItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): string | undefined; /** * Returns the current value for each of the given keys, or null if the given * keys does not exist in the list associated with the object. * * Method should be overridden by child-class * * @param keys array of keys to retrieve * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns array of string-values of the items stored by the given keys, or null if not found */ getItems(_keys: string[], _keyPrefixParams?: KeyPrefixParams): Promise; /** * Returns the current value for each of the given keys, or null if the given * keys does not exist in the list associated with the object. * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child-class * * @param keys array of keys to retrieve * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns array of string-values of the items stored by the given keys, or null if not found */ getItemsSync(_keys: string[], _keyPrefixParams?: KeyPrefixParams): string[] | undefined; /** * Returns all key-value pairs * * Method should be overridden by child class * * @returns array of string-value of all the stored items */ getAll(): Promise<[string, string][]>; /** * Returns all key-value pairs * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child class * * @returns array of string-value of all the stored items */ getAllSync(): [string, string][]; /** * Delete a key-value pair * * Method should be overridden by child class * * @param key the key to identify the pair * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ deleteItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise; /** * Delete a key-value pair * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child class * * @param key the key to identify the pair * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ deleteItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): void; /** * Delete a series of key-value pairs * * Method should be overridden by child class * * @param keys the keys to identify the pairs * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ deleteItems(_keys: string[], _keyPrefixParams?: KeyPrefixParams): Promise; /** * Delete a series of key-value pairs * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child class * * @param keys the keys to identify the pairs * @param keyPrefixParams optional parameters to prefix the key with different prefix-options */ deleteItemsSync(_keys: string[], _keyPrefixParams?: KeyPrefixParams): void; /** * Returns true if an item with the given key exists, false otherwise. * * Method should be overridden by child-class * * @param key the key to identify the item * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns true if the item exists, false otherwise */ hasItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise; /** * Returns true if an item with the given key exists, false otherwise. * * This method should not be used inside the SDK. It's purpose is only for integrators from outside. * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous * interaction with the local storage. * * Method should be overridden by child-class * * @param key the key to identify the item * @param keyPrefixParams optional parameters to prefix the key with different prefix-options * @returns true if the item exists, false otherwise */ hasItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): boolean; protected getPrefixedKey(key: string, keyPrefixParams?: KeyPrefixParams): string; }