UNPKG

@twilio/flex-ui

Version:

Twilio Flex UI

89 lines (88 loc) 2.84 kB
import { LogEntry } from "../spies"; import { Storage } from "./Storage"; /** * @typedef {object} Log.MemoryStorageSpecificOptions * @property {string} [identifier] Unique identifier * @property {boolean} [extendedLogs] Set to true to get, uncut, unprocessed logs from spy * @property {number} [maxLineLength] If extendedLogs is enabled, customise the maxLength of the stringified logs */ type MemoryStorageSpecificOptions = { identifier?: string; extendedLogs?: boolean; maxLineLength?: number; }; /** * @typedef {object} Log.MemoryStorageOptions * @mixes Log.MemoryStorageSpecificOptions * @property {string} [identifier] Unique identifier * @property {boolean} [extendedLogs] Set to true to get, uncut, unprocessed logs from spy * @property {number} [maxLineLength] If extendedLogs is enabled, customise the maxLength of the stringified logs */ export type MemoryStorageOptions = MemoryStorageSpecificOptions; export type MemoryStorageConstructorOptions = MemoryStorageSpecificOptions; type MemoryStorageLogEntry = LogEntry & { size: number; }; type Cache = MemoryStorageLogEntry[]; /** * An implementations that stores information in the local storage * @category Log Manager / Storages * @extends Log.Storage * @hideconstructor * @private */ export declare class MemoryStorage extends Storage { static calculateUsedSpace(data: string): number; private maxMemoryStorageSize; private cache; private memorisedLogs; private cacheSize; private extendedLogs; private maxLineLength; private set; /** * @private * @param options * @function Object() { [native code] } */ constructor(options: MemoryStorageOptions); /** * Set a maximum local storage content size * @param newSizeLimit New content size limit in Kbs * @returns {void} * @private */ setMaxMemoryStorageSize(newSizeLimit: number): void; /** * Get a maximum local storage size * @returns {number} Maximum size of the local storage in Kbs * @private */ getMaxMemoryStorageSize(): number; /** * Add a LogEntry to the storage * @param {LogEntry} diff A new LogEntry to add to the storage * @returns {Promise} A promise that resolves with data from the store * @private */ add(diff: LogEntry): Promise<Cache>; /** * Get the current array of LogEntries stored in the local storage * @returns {LogEntry[]} Array of LogEntries * @private */ get(): Cache; /** * Clear all records in the local storage * @returns {Promise} A new (empty) list of LogEntries in the store * @private */ clear(): void; /** * @param {Cache} cache * @private * @return {number} size of the cache in kb */ private getCacheSize; } export {};