UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

35 lines (34 loc) 1.13 kB
import { Duration } from '@salesforce/kit'; import { JsonMap, Nullable } from '@salesforce/ts-types'; import { ConfigFile } from './configFile'; /** * A Time To Live configuration file where each entry is timestamped and removed once the TTL has expired. * * @example * ``` * import { Duration } from '@salesforce/kit'; * const config = await TTLConfig.create({ * isGlobal: false, * ttl: Duration.days(1) * }); * ``` */ export declare class TTLConfig<T extends TTLConfig.Options, P extends JsonMap> extends ConfigFile<T, TTLConfig.Contents<P>> { set(key: string, value: Partial<TTLConfig.Entry<P>>): void; getLatestEntry(): Nullable<[string, TTLConfig.Entry<P>]>; getLatestKey(): Nullable<string>; isExpired(dateTime: number, value: P & { timestamp: string; }): boolean; protected init(): Promise<void>; private timestamp; } export declare namespace TTLConfig { type Options = ConfigFile.Options & { ttl: Duration; }; type Entry<T extends JsonMap> = T & { timestamp: string; }; type Contents<T extends JsonMap> = Record<string, Entry<T>>; }