import { EventEmitter } from "events"; import { IQueryColumnDef } from "./query/query-builder/types"; export interface IDbConn extends EventEmitter { config: TDbConnConf; isConnected: boolean; isOnTransaction: boolean; on(event: "close", listener: () => void): this; connectAsync(): Promise; closeAsync(): Promise; beginTransactionAsync(isolationLevel?: ISOLATION_LEVEL): Promise; commitTransactionAsync(): Promise; rollbackTransactionAsync(): Promise; executeAsync(queries: string[]): Promise; executeParametrizedAsync(query: string, params?: any[]): Promise; bulkInsertAsync( tableName: string, columnDefs: IQueryColumnDef[], records: Record[], ): Promise; bulkUpsertAsync( tableName: string, columnDefs: IQueryColumnDef[], records: Record[], ): Promise; } export type TDbConnConf = IDefaultDbConnConf | ISqliteDbConnConf; export interface IDefaultDbConnConf { dialect: "mysql" | "mssql" | "mssql-azure"; host: string; port?: number; username: string; password: string; database?: string; schema?: string; defaultIsolationLevel?: ISOLATION_LEVEL; } export interface ISqliteDbConnConf { dialect: "sqlite"; filePath: string; } export type ISOLATION_LEVEL = | "READ_UNCOMMITTED" | "READ_COMMITTED" | "REPEATABLE_READ" | "SERIALIZABLE";