import { type FirebaseOptions } from "@firebase/app"; import { type Firestore } from "@firebase/firestore/lite"; import { ManagerEvents } from "./ManagerEvents"; type FirebaseDBOptions = FirebaseOptions & { tables?: string[]; }; /** * Represents a generic Firebase database manager. * @typeparam V The type of values stored in the database. */ declare class FirebaseDB extends ManagerEvents> { #private; readonly url: string; readonly options?: FirebaseDBOptions | undefined; readonly tables: string[]; firebase: Firestore; /** * Constructs a new FirebaseDB instance. * @param url The URL of the Firebase database. * @param options Additional options for Firebase initialization, including tables. */ constructor(url: string, options?: FirebaseDBOptions | undefined); /** * Checks if the specified table exists. * @param tableName The name of the table to check. * @throws Error if the database is not ready or the table does not exist. */ private hasTable; /** * Retrieves a value from the specified table with the given key. * @param table The name of the table. * @param key The key of the value to retrieve. * @returns The value associated with the key, if found. */ get(table: string, key: string): Promise; /** * Sets a value in the specified table with the given key. * Emits "create" event if the key does not exist, and "update" event if the key already exists and value changes. * @param table The name of the table. * @param key The key of the value to set. * @param value The value to set. * @returns This instance for chaining. */ set(table: string, key: string, value: V): Promise; /** * Checks if a value with the specified key exists in the 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 database to check responsiveness. * @returns The time taken in milliseconds to retrieve data from all tables. */ ping(): Promise; /** * Connects to the Firebase database. * Initializes Firebase app and Firestore instance. * Emits "ready" event upon successful connection. * @returns This instance for chaining. */ connect(): Promise; } export { FirebaseDB, FirebaseDBOptions };