import { type IEventDataMap } from "../typing"; import { Collection } from "@telegram.ts/collection"; import { MySqlDB, type MySqlDBOptions } from "./MySqlDB"; import { MongoDB, type MongoDBOptions } from "./MongoDB"; import { StorageDB, type StorageDBOptions } from "./StorageDB"; import { FirebaseDB, type FirebaseDBOptions } from "./FirebaseDB"; type AoiManagerOptions = { logging?: boolean; } & ({ type: "storage"; options?: StorageDBOptions; } | { type: "mongo"; url: string; options?: MongoDBOptions; } | { type: "firebase"; url: string; options?: FirebaseDBOptions; } | { type: "mysql"; options: MySqlDBOptions & { tables?: string[]; }; }); declare class AoiManager { #private; readonly tables: string[]; readonly database: StorageDB | MongoDB | FirebaseDB | MySqlDB; readonly collection: Collection; /** * Creates an instance of AoiManager. * @param options - The options for configuring the AoiManager. */ constructor(options?: AoiManagerOptions); /** * Adds an event listener. * @param eventName - The name of the event. * @param listener - The callback function for the event. */ on>(eventName: T, listener: (args: IEventDataMap[T]) => void): StorageDB | MongoDB | FirebaseDB | MySqlDB; /** * Adds a one-time event listener. * @param eventName - The name of the event. * @param listener - The callback function for the event. */ once>(eventName: T, listener: (args: IEventDataMap[T]) => void): StorageDB | MongoDB | FirebaseDB | MySqlDB; /** * Removes an event listener. * @param eventName - The name of the event. * @param listener - The callback function for the event. */ off>(eventName: T, listener: (args: IEventDataMap[T]) => void): StorageDB | MongoDB | FirebaseDB | MySqlDB; /** * Emits an event. * @param eventName - The name of the event. * @param eventData - The data for the event. */ emit>(eventName: T, eventData: IEventDataMap[T]): boolean; /** * Gets a value from the database. * @param table - The table name. * @param key - The key. * @returns The value. */ get(table: string, key: string): Promise; /** * Sets a value in the database. * @param table - The table name. * @param key - The key. * @param value - The value. * @returns The instance of AoiManager. */ set(table: string, key: string, value: Value): Promise; /** * Checks if a key exists in the database. * @param table - The table name. * @param key - The key. * @returns A boolean indicating if the key exists. */ has(table: string, key: string): Promise; /** * Gets all values from a table. * @param table - The table name. * @returns An object containing all key-value pairs. */ all(table: string): Promise<{ [key: string]: Value; }>; /** * Finds one entry in a table that matches the callback criteria. * @param table - The table name. * @param callback - The callback function to match entries. * @returns The matching entry or null. */ findOne(table: string, callback: (entry: { key: string; value: Value; }, index: number) => boolean | Promise): Promise<{ key: string; value: Value; index: number; } | null>; /** * Finds multiple entries in a table that match the callback criteria. * @param table - The table name. * @param callback - The callback function to match entries. * @returns An array of matching entries. */ findMany(table: string, callback: (entry: { key: string; value: Value; }, index: number) => boolean | Promise): Promise<{ key: string; value: Value; index: number; }[]>; /** * Deletes multiple entries in a table that match the callback criteria. * @param table - The table name. * @param callback - The callback function to match entries. */ deleteMany(table: string, callback: (entry: { key: string; value: Value; }, index: number) => boolean | Promise): Promise; /** * Deletes an entry or entries in a table. * @param table - The table name. * @param key - The key or keys to delete. */ delete(table: string, key: string | string[]): Promise; /** * Clears all entries in a table. * @param table - The table name. */ clear(table: string): Promise; /** * Converts a file to a table in the database. * @param table - The table name. * @param filePath - The file path. */ convertFileToTable(table: string, filePath: string): Promise; /** * Converts a table to a file. * @param table - The table name. * @param filePath - The file path. */ convertTableToFile(table: string, filePath: string): Promise; /** * Pings the database. * @returns The ping time in milliseconds. */ ping(): Promise; /** * Connects to the database. */ connect(): Promise; /** * Checks if a table exists. * @param table - The table name. * @returns A boolean indicating if the table exists. */ hasTable(table: string): boolean; /** * Gets the default value for a variable. * @param vars - The variable name. * @param table - The table name. * @returns The default value of the variable. */ defaulValue(vars: string, table: string): any; /** * Sets variables in the specified tables. * @param options - The variables to set. * @param tables - The table or tables to set the variables in. */ variables(options: { [key: string]: any; }, tables?: string | string[]): Promise; } export { AoiManager, AoiManagerOptions };