import { BSPlugin } from '@bs-core/shell';
import * as mssql from 'mssql';

type SqlServerConfig = {
    database: string;
    user: string;
    password: string;
    server?: string;
    port?: number;
    appName?: string;
};
type CNMSSqlConvertValuesOptions = {
    nullCurrencyValue?: number;
    dateFormat?: string;
};
type CNMSSqlCreateOptions = {
    convertValuesOpts?: CNMSSqlConvertValuesOptions;
};
type CNMSSqlUpdateOptions = {
    convertValuesOpts?: CNMSSqlConvertValuesOptions;
};
type CNMSSqlReadOptions = {
    orderBy?: string[];
    orderByDesc?: string[];
    groupBy?: string[];
    format?: "json" | "array";
    distinct?: boolean;
};
type CNMSSqlCreateParams = {
    collection: string;
    fields: {
        [key: string]: any;
    };
    id?: string;
    opts?: CNMSSqlCreateOptions;
    transaction?: mssql.Transaction;
};
type CNMSSqlReadParams = {
    collection: string;
    fields?: string[];
    criteria?: {
        [key: string]: any;
    };
    opts?: CNMSSqlReadOptions;
    transaction?: mssql.Transaction;
};
type CNMSSqlUpdateParams = {
    collection: string;
    fields: {
        [key: string]: any;
    };
    criteria: {
        [key: string]: any;
    };
    opts?: CNMSSqlUpdateOptions;
    transaction?: mssql.Transaction;
};
type CNMSSqlDeleteParams = {
    collection: string;
    criteria: {
        [key: string]: any;
    };
    transaction?: mssql.Transaction;
};
type ColumnDetails = {
    index: number;
    name: string;
    length: number;
    type: (() => mssql.ISqlType) | mssql.ISqlType;
    udt?: any;
    scale?: number | undefined;
    precision?: number | undefined;
    nullable: boolean;
    caseSensitive: boolean;
    identity: boolean;
    readOnly: boolean;
};
declare class SqlServer extends BSPlugin {
    private _pool;
    private _user;
    private _password;
    private _database;
    private _dbSever;
    private _port;
    private _appName;
    constructor(name: string, sqlServerConfig: SqlServerConfig);
    private isServerReady;
    protected stop(): Promise<void>;
    start(): Promise<boolean>;
    healthCheck(): Promise<boolean>;
    convertValueToSqlType(type: (() => mssql.ISqlType) | mssql.ISqlType, value: string, opts?: CNMSSqlConvertValuesOptions): any;
    getTableColumns(collection: string): Promise<mssql.IColumnMetadata>;
    create(params: CNMSSqlCreateParams): Promise<any>;
    read(params: CNMSSqlReadParams): Promise<any[]>;
    update(params: CNMSSqlUpdateParams): Promise<number>;
    delete(params: CNMSSqlDeleteParams): Promise<number>;
    query(query: string, transaction?: mssql.Transaction): Promise<any>;
    exec(query: string, transaction?: mssql.Transaction): Promise<number>;
    begin(): Promise<mssql.Transaction>;
    commit(transaction: mssql.Transaction): Promise<void>;
    rollback(transaction: mssql.Transaction): Promise<void>;
}

export { type CNMSSqlConvertValuesOptions, type CNMSSqlCreateOptions, type CNMSSqlCreateParams, type CNMSSqlDeleteParams, type CNMSSqlReadOptions, type CNMSSqlReadParams, type CNMSSqlUpdateOptions, type CNMSSqlUpdateParams, type ColumnDetails, SqlServer, type SqlServerConfig };
