import { ManagerEvents } from "./ManagerEvents"; type StorageDBOptions = { path: string; tables: string[]; extname?: string; }; /** * Represents a generic storage manager using JSON files. * @typeparam V The type of values stored in the database. */ declare class StorageDB extends ManagerEvents> { #private; readonly options: { path: string; tables: string[]; extname: string; }; /** * Constructs a new StorageDB instance. * @param options Configuration options for the storage manager. */ constructor(options?: { path?: string; tables?: string[]; extname?: string; }); private getData; private setData; /** * Retrieves a value associated with the specified key from the specified table. * @param table The name of the table. * @param key The key to retrieve the value for. * @returns The value associated with the key, if found; otherwise, undefined. */ get(table: string, key: string): Promise; /** * Sets a value associated with the specified key in the specified table. * Emits "create" event if the key does not exist, and "update" event if the value changes. * @param table The name of the table. * @param key The key to associate the value with. * @param value The value to set. * @returns This instance for chaining. */ set(table: string, key: string, value: V): Promise; /** * Checks if a key exists in the specified table. * @param table The name of the table. * @param key The key to check for existence. * @returns True if the key exists, false otherwise. */ has(table: string, key: string): Promise; /** * Retrieves all key-value pairs from the specified table. * @param table The name of the table. * @returns An object containing all key-value pairs in the table. */ all(table: string): Promise<{ [key: string]: V; }>; /** * Finds the first key-value pair in the specified table that satisfies the provided condition. * @param table The name of the table. * @param callback A function that defines the condition. * @returns An object containing the key-value pair that satisfies the condition, or null if no such pair is found. */ findOne(table: string, callback: (entry: { key: string; value: V; }, index: number) => boolean | Promise): Promise<{ key: string; value: V; index: number; } | null>; /** * Finds all key-value pairs in the specified table that satisfy the provided condition. * @param table The name of the table. * @param callback A function that defines the condition. * @returns An array of objects containing the key-value pairs that satisfy the condition. */ findMany(table: string, callback: (entry: { key: string; value: V; }, index: number) => boolean | Promise): Promise<{ key: string; value: V; index: number; }[]>; /** * Deletes all key-value pairs in the specified table that satisfy the provided condition. * @param table The name of the table. * @param callback A function that defines the condition. */ deleteMany(table: string, callback: (entry: { key: string; value: V; }, index: number) => boolean | Promise): Promise; /** * Deletes key-value pairs from the specified table with the given key(s). * @param table The name of the table. * @param key The key or array of keys to delete. */ delete(table: string, key: string | string[]): Promise; /** * Deletes all key-value pairs from the specified table. * @param table The name of the table. */ clear(table: string): Promise; /** * Reads data from a file, parses it into JSON format, and writes it to a specified table in the database. * @param table - The name of the table to populate with data. * @param filePath - The file path to read the JSON data from. */ convertFileToTable(table: string, filePath: string): Promise; /** * Converts data from a specified table in the database to JSON format and writes it to a file. * @param table - The name of the table to convert to JSON. * @param filePath - The file path to write the JSON data to. */ convertTableToFile(table: string, filePath: string): Promise; /** * Pings the storage database to check responsiveness. * @returns The time taken in milliseconds to retrieve data from all tables. */ ping(): Promise; /** * Connects to the storage database. * Initializes data files for tables and emits "ready" event upon successful connection. * @returns This instance for chaining. */ connect(): Promise; } export { StorageDB, StorageDBOptions };