import type { DataSource, DbDataSource } from './squared'; import type { CacheOptions, IdentifierAction } from './core'; import type { DB_TYPE } from '../index.d'; export interface ExecuteAction { params?: T; } export interface CascadeAction { cascade?: string; cacheObjectKey?: string; fallback?: unknown; } export interface ExecuteQueryOptions { checkObject?: CheckObjectCallback | string; checkObjectKey?: string; errorQuery?: ErrorQueryCallback; sessionKey?: string; outCacheMiss?: string[]; } export interface ExecuteBatchQueryOptions extends ExecuteQueryOptions { parallel?: boolean; connectOnce?: boolean; } export interface ProcessRowsOptions { disconnect?: () => void; parallel?: boolean; } export interface DbConnection { hostname: string; password: string; pathname: string; port: string; protocol: string; search: string; username: string; database: string; } export interface HandleFailOptions { commandType?: number; errorQuery?: ErrorQueryCallback; } export interface ServerAuth extends AuthValue, IdentifierAction { protocol?: string; server?: string; hostname?: string; port?: T; database?: string; } export interface IDbPool { client: U; lastAccessed: number; success: number; failed: number; poolKey: string; uuidKey: Null; add(item: T, uuidKey?: string): this; has(item: T): boolean; getConnection(): Promise; remove(): void; detach(force?: boolean): Promise; close(): Promise; isIdle(timeout: number): boolean; isEmpty(): boolean; set connected(value: boolean); get persist(): boolean; get closed(): boolean; get closeable(): boolean; set parent(value: ObjectMap>); } export interface DbPoolConstructor { findKey(pools: ObjectMap, uuidKey: unknown, poolKey: Undef, ...items: X[]): Null; validateKey(pools: ObjectMap, username: string, uuidKey: unknown): [string, Null]; checkTimeout(pools: ObjectMap, value: number, limit?: number): Promise; readonly prototype: IDbPool; new(pool: U, poolKey: string, uuidKey?: Null): IDbPool; } export interface PoolConfig extends MinMax { idle?: T; queue_max?: number; queue_idle?: T; purge?: T; timeout?: number; socket_timeout?: number; } export interface TimeoutAction { timeout?: NumString; } export type DbSource = "mariadb" | "mongodb" | "mssql" | "mysql" | "oracle" | "postgres" | "redis"; export type QueryResult = unknown[]; export type BatchQueryResult = Null[]; export type CheckObjectCallback = (item: DataSource, data: unknown) => Null; export type ErrorQueryCallback = (err: unknown, item: DbDataSource, commandType?: number) => boolean; export interface SQL_COMMAND { SELECT: 1; INSERT: 2; UPDATE: 3; DELETE: 4; } export type { DB_TYPE, CacheOptions, IdentifierAction };