import { Readable } from 'stream';

/**
 * Set of operators in SQL.
 * [📘](https://github.com/nodef/extra-sql/wiki/OPERATORS)
 */
declare const OPERATORS: Set<string>;
/**
 * Number of operands used with an SQL operator.
 * [📘](https://github.com/nodef/extra-sql/wiki/OPERAND_COUNT)
 */
declare const OPERAND_COUNT: Map<string, number>;
/** Types for columns in a table. */
type ColumnTypes = {
    [key: string]: string;
};
/** Weights for columns in a table (for a tsvector). */
type ColumnWeights = {
    [key: string]: string;
};
/** Data for a row in a table. */
type RowData = {
    [key: string]: any;
};
/** Options for creating a table. */
interface CreateTableOptions {
    /** Column name for the primary key. */
    pk?: string;
}
/** Options for creating an index. */
interface CreateIndexOptions {
    /** Indexing method (e.g., GIN, BTREE). */
    method?: string;
}
/** Options for inserting into a table. */
interface InsertIntoOptions {
    /** Column name for the primary key. */
    pk?: string;
}
/** Options for setting up table indexes. */
interface SetupTableIndexOptions {
    /** Column name for the primary key. */
    pk?: string;
    /** Whether to create an index. */
    index?: boolean;
    /** Columns, with their weights, for full-text search. */
    tsvector?: ColumnWeights;
}
/** Options for setting up a table. */
interface SetupTableOptions {
    /** Column name for the primary key. */
    pk?: string;
    /** Whether to create an index. */
    index?: boolean;
    /** Columns, with their weights, for full-text search. */
    tsvector?: ColumnWeights;
}
/** Options for selecting with tsquery. */
interface SelectTsqueryOptions {
    /** Columns to select. */
    columns?: string;
    /** Whether to order the results. */
    order?: boolean;
    /** Limit the number of results. */
    limit?: number;
    /** Normalization weight used during ranking (in ts_rank). */
    normalization?: number;
}
/** Options for matching with tsquery. */
interface MatchTsqueryOptions {
    /** Columns to select. */
    columns?: string;
    /** Whether to order the results. */
    order?: boolean;
    /** Limit the number of results. */
    limit?: number;
    /** Normalization weight used during ranking (in ts_rank). */
    normalization?: number;
}
/** Query data with SQL and parameters. */
interface QueryData {
    /** SQL query string. */
    query: string;
    /** Parameters for the query. */
    data: any[];
}
/**
 * Generate SQL command for CREATE TABLE.
 * [📘](https://github.com/nodef/extra-sql/wiki/createTable)
 * @param name table name
 * @param cols columns `{name: type}`
 * @param opt options `{pk}`
 * @param acc string to accumulate to (internal use)
 * @returns SQL command for creating the table
 */
declare function createTable(name: string, cols: ColumnTypes, opt?: CreateTableOptions, acc?: string): string;
/**
 * Generate SQL command for CREATE INDEX.
 * [📘](https://github.com/nodef/extra-sql/wiki/createIndex)
 * @param name index name
 * @param table table name
 * @param expr index expression
 * @param opt options `{method}`
 * @param acc string to accumulate to (internal use)
 * @returns SQL command for creating the index
 */
declare function createIndex(name: string, table: string, expr: string, opt?: CreateIndexOptions, acc?: string): string;
/**
 * Generate SQL command for CREATE VIEW.
 * [📘](https://github.com/nodef/extra-sql/wiki/createView)
 * @param name view name
 * @param query view query
 * @param opt options (currently unused)
 * @param acc string to accumulate to (internal use)
 * @returns SQL command for creating the view
 */
declare function createView(name: string, query: string, opt?: object, acc?: string): string;
/**
 * Generates SQL command for INSERT INTO using an array of values.
 * [📘](https://github.com/nodef/extra-sql/wiki/insertInto)
 * @param table table name
 * @param rows row objects `{column: value}`
 * @param opt options `{pk}`
 * @param acc string to accumulate to (internal use)
 * @returns SQL command to insert into the table
 */
declare function insertInto(table: string, rows: RowData[], opt?: InsertIntoOptions, acc?: string): string;
declare namespace insertInto {
    var stream: typeof insertIntoStream;
}
/**
 * Generate SQL command for INSERT INTO using a stream of values.
 * [📘](https://github.com/nodef/extra-sql/wiki/insertIntoStream)
 * @param table table name
 * @param stream readable stream of row objects `{column: value}`
 * @param opt options `{pk}`
 * @param acc string to accumulate to (internal use)
 * @returns SQL command to insert into the table (promise)
 */
declare function insertIntoStream(table: string, stream: Readable, opt?: InsertIntoOptions, acc?: string): Promise<string>;
/**
 * Generate SQL commands for setting up table indexes and views.
 * [📘](https://github.com/nodef/extra-sql/wiki/setupTableIndex)
 * @param table table name
 * @param cols columns with their types `{name: type}`
 * @param opt options `{pk, index, tsvector}`
 * @param acc Accumulator for the SQL string (internal use).
 * @returns SQL commands for setting up the table indexes and views
 */
declare function setupTableIndex(table: string, cols: ColumnTypes, opt?: SetupTableIndexOptions, acc?: string): string;
/**
 * Generate SQL commands to set up a table (create, insert, index).
 * [📘](https://github.com/nodef/extra-sql/wiki/setupTable)
 * @param name table name
 * @param cols columns with their types `{name: type}`
 * @param rows rows to insert (optional)
 * @param opt options `{pk, index, tsvector}`
 * @param acc string to accumulate to (internal use)
 * @returns SQL commands for setting up the table
 */
declare function setupTable(name: string, cols: ColumnTypes, rows?: RowData[] | null, opt?: SetupTableOptions, acc?: string): string;
declare namespace setupTable {
    var index: typeof setupTableIndex;
}
/**
 * Generate SQL command to check if a table exists.
 * [📘](https://github.com/nodef/extra-sql/wiki/tableExists)
 * @param name table name
 * @returns SQL command to check if the table exists
 */
declare function tableExists(name: string): string;
/**
 * Generate SQL command for SELECT with tsquery.
 * [📘](https://github.com/nodef/extra-sql/wiki/selectTsquery)
 * @param table table name
 * @param query plain query words
 * @param tsv tsvector column name ["tsvector"]
 * @param opt options `{columns, order, limit, normalization}`
 * @returns SQL command for selecting with tsquery
 */
declare function selectTsquery(table: string, query: string, tsv?: string, opt?: SelectTsqueryOptions): string;
/**
 * Generate SQL query for matching words with tsquery.
 * [📘](https://github.com/nodef/extra-sql/wiki/matchTsquery)
 * @param table table name
 * @param words match words
 * @param tsv tsvector column name ["tsvector"]
 * @param opt options `{columns, order, limit, normalization}`
 * @returns SQL query for matching words with tsquery
 */
declare function matchTsquery(table: string, words: string[], tsv?: string, opt?: MatchTsqueryOptions): string;
/**
 * Generate SQL command for creating a table with data.
 * [📘](https://github.com/nodef/extra-sql/wiki/createTableData)
 * @param table table name
 * @param cols columns with their types `{name: type}`
 * @param pkeys primary key(s)
 * @returns query data for creating the table `{query, data}`
 */
declare function createTableData(table: string, cols: ColumnTypes, pkeys?: string | string[]): QueryData;
/**
 * Generate SQL command for updating data.
 * [📘](https://github.com/nodef/extra-sql/wiki/updateData)
 * @param table table name
 * @param set columns to set `{column: value}`
 * @param where where conditions `{column: value}`
 * @param op operator for conditions ['=']
 * @param sep separator for conditions ['AND']
 * @returns query data for updating the data `{query, data}`
 */
declare function updateData(table: string, set: RowData, where: RowData, op?: string, sep?: string): QueryData;
/**
 * Generate SQL command for selecting data.
 * [📘](https://github.com/nodef/extra-sql/wiki/selectData)
 * @param tab table name
 * @param whr where conditions `{column: value}`
 * @param op operator for conditions ['=']
 * @param sep separator for conditions ['AND']
 * @returns query data for selecting the data `{query, data}`
 */
declare function selectData(tab: string, whr: RowData, op?: string, sep?: string): QueryData;
/**
 * Generate SQL command for inserting data.
 * [📘](https://github.com/nodef/extra-sql/wiki/insertIntoData)
 * @param table table name
 * @param rows rows to insert
 * @returns query data for inserting the data `{query, data}`
 */
declare function insertIntoData(table: string, rows: RowData[]): QueryData;
/**
 * Generate SQL command for deleting data.
 * [📘](https://github.com/nodef/extra-sql/wiki/deleteData)
 * @param table table name
 * @param where where conditions `{column: value}`
 * @param op operator for conditions ['=']
 * @param sep separator for conditions ['AND']
 * @returns query data for deleting the data `{query, data}`
 */
declare function deleteData(table: string, where: RowData, op?: string, sep?: string): QueryData;

export { OPERAND_COUNT, OPERATORS, createIndex, createTable, createTableData, createView, deleteData, insertInto, insertIntoData, insertIntoStream, matchTsquery, selectData, selectTsquery, setupTable, setupTableIndex, tableExists, updateData };
