UNPKG

@shopify/cli-kit

Version:

A set of utilities, interfaces, and models that are common across all the platform features

60 lines (59 loc) 1.9 kB
/** * A wrapper around the `conf` package that provides a strongly-typed interface * for accessing the local storage. */ export declare class LocalStorage<T extends { [key: string]: any; }> { private readonly config; constructor(options: { projectName?: string; cwd?: string; }); /** * Get a value from the local storage. * * @param key - The key to get. * @returns The value. * @throws AbortError if a permission error occurs. * @throws BugError if an unexpected error occurs. */ get<TKey extends keyof T>(key: TKey): T[TKey] | undefined; /** * Set a value in the local storage. * * @param key - The key to set. * @param value - The value to set. * @throws AbortError if a permission error occurs. * @throws BugError if an unexpected error occurs. */ set<TKey extends keyof T>(key: TKey, value?: T[TKey]): void; /** * Delete a value from the local storage. * * @param key - The key to delete. * @throws AbortError if a permission error occurs. * @throws BugError if an unexpected error occurs. */ delete<TKey extends keyof T>(key: TKey): void; /** * Clear the local storage (delete all values). * * @throws AbortError if a permission error occurs. * @throws BugError if an unexpected error occurs. */ clear(): void; /** * Handle errors from config operations. * If the error is permission-related, throw an AbortError with helpful hints. * Otherwise, throw a BugError. * * @param error - The error that occurred. * @param operation - The operation that failed. * @throws AbortError if the error is permission-related. * @throws BugError if the error is not permission-related. */ private handleError; private isPermissionError; private tryMessage; }