import { DataSource, QueryRunner } from 'typeorm';
import { CacheModule } from '../cache';
import { BoundSql } from './BoundSql';
import { Dialect } from './dialect';
import { NamedTableInterceptor, SQLInterceptor } from './interceptor';
import { Page } from './model';
import { PageResult } from './model';
import { NamedTable } from './table';
import { Context } from '@midwayjs/core';
export declare class SQLModule {
    private static sqlInterceptors;
    private static namedTableInterceptors;
    private magicDataSource;
    sqlCache: CacheModule;
    ctx: Context;
    private magicConfig;
    /**
     * 数据源key 仅根节点
     */
    dataSourceNames: string[];
    /**
     * 当前数据源
     */
    dataSourceNode: DataSource;
    /**
     * 查询创建器
     */
    queryRunner: QueryRunner;
    /**
     * 缓存过期时间
     */
    ttl: number;
    /**
     * 缓存名称
     */
    cacheName: string;
    /**
     * 逻辑删除列
     */
    logicDeleteColumn: string;
    /**
     * 逻辑删除值
     */
    logicDeleteValue: string;
    /**
     * 添加SQL拦截器
     * @param sqlInterceptor
     */
    static addSqlInterceptor(sqlInterceptor: SQLInterceptor): void;
    /**
     * 添加单表crud拦截器
     * @param namedTableInterceptor
     */
    static addNamedTableInterceptor(namedTableInterceptor: NamedTableInterceptor): void;
    /**
     * 初始化
     */
    init(): Promise<void>;
    /**
     * 克隆
     * @param dataSourceNode 数据源
     * @protected
     */
    protected cloneSQLModule(dataSourceNode: DataSource): SQLModule;
    /**
     * 数据源名称
     */
    getDataSourceName(): any;
    /**
     * 创建查询创建器
     */
    createQueryRunner(): void;
    /**
     * 销毁查询创建器
     */
    release(): Promise<void>;
    /**
     * 开启事务
     * @param _function
     */
    transaction(_function?: () => Promise<any>): Promise<any | void>;
    /**
     * 配置缓存
     * @param cacheName 缓存名称
     * @param ttl 缓存失效时间 单位为秒
     */
    cache(cacheName: string, ttl?: number): this;
    /**
     * 删除缓存
     * @param cacheName 缓存名称
     * @param matchStart 是否匹配开头为缓存名称的所有key
     */
    deleteCache(cacheName: string, matchStart?: boolean): Promise<void>;
    /**
     * 查询List，并传入变量信息
     */
    select(sqlOrXml: string, params?: Record<string, any>): Promise<any[]>;
    /**
     * 查询int值，适合单行单列int的结果
     */
    selectInt(sqlOrXml: string, params?: Record<string, any>): Promise<number>;
    /**
     * 查询单条结果，查不到返回null
     */
    selectOne(sqlOrXml: string, params?: Record<string, any>): Promise<Record<string, any>>;
    /**
     * 查询单行单列的值
     */
    selectValue(sqlOrXml: string, params?: Record<string, any>): Promise<unknown>;
    _select(boundSql: BoundSql): Promise<any[]>;
    _selectInt(boundSql: BoundSql): Promise<number>;
    _selectOne(boundSql: BoundSql): Promise<Record<string, any>>;
    _selectValue(boundSql: BoundSql): Promise<unknown>;
    /**
     * 分页查询（手动传入limit和offset参数）
     * @param countSqlOrXml count语句
     * @param sqlOrXml `SQL`语句或`xml`
     * @param limit 限制条数
     * @param offset 跳过条数
     * @param params 变量信息
     */
    page(countSqlOrXml: string, sqlOrXml: string | number, limit: number, offset?: number | Record<string, any>, params?: Record<string, any>): Promise<PageResult<Record<string, any>[]>>;
    __page(count: number, boundSql: BoundSql, page: Page, dialect: Dialect): Promise<PageResult<Record<string, any>[]>>;
    _page(boundSql: BoundSql, page: Page): Promise<PageResult<Record<string, any>[]>>;
    private queryForList;
    private assertDatasourceNotNull;
    /**
     * 执行update，并传入变量信息
     */
    update(sqlOrXml: string, params?: Record<string, any>): Promise<number>;
    _update(boundSql: BoundSql): Promise<number>;
    /**
     * 执行update，并传入变量信息
     */
    insert(sqlOrXml: string, params?: Record<string, any>): Promise<string | number>;
    _insert(boundSql: BoundSql): Promise<string | number | null>;
    /**
     * 批量执行操作，返回受影响的行数
     * @param sql `SQL`语句 或者多条sql
     * @param args 变量信息
     * @param batchSize 每次多少条
     */
    batchUpdate(sql: string[] | string, args?: any[][], batchSize?: number): Promise<number>;
    /**
     * 指定table，进行单表操作
     * @param tableName
     */
    table(tableName: string): NamedTable;
    buildPageBoundSql(dialect: Dialect, boundSql: BoundSql, offset: number, limit: number): BoundSql;
}
