1export interface Window {
2    openDatabase?: (name: string, version: string, displayName: string, estimatedSize: number, creationCallback?: DatabaseCallback) => Database;
3}
4export type DatabaseCallback = (database: Database) => void;
5/**
6 * `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a
7 * connection to a database on your device.
8 */
9export interface Database {
10    version: string;
11    /**
12     * Execute a database transaction.
13     * @param callback A function representing the transaction to perform. Takes a Transaction
14     * (see below) as its only parameter, on which it can add SQL statements to execute.
15     * @param errorCallback Called if an error occurred processing this transaction. Takes a single
16     * parameter describing the error.
17     * @param successCallback Called when the transaction has completed executing on the database.
18     */
19    transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
20    readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
21}
22export type SQLTransactionCallback = (transaction: SQLTransaction) => void;
23export type SQLTransactionErrorCallback = (error: SQLError) => void;
24/**
25 * A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the
26 * `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to
27 * perform in a database transaction.
28 */
29export interface SQLTransaction {
30    /**
31     * Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make
32     * use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to
33     * never construct SQL statements on the fly.
34     * @param sqlStatement A string containing a database query to execute expressed as SQL. The string
35     * may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter.
36     * @param args An array of values (numbers, strings or nulls) to substitute for `?` placeholders in the
37     * SQL statement.
38     * @param callback Called when the query is successfully completed during the transaction. Takes
39     * two parameters: the transaction itself, and a `ResultSet` object (see below) with the results
40     * of the query.
41     * @param errorCallback Called if an error occurred executing this particular query in the
42     * transaction. Takes two parameters: the transaction itself, and the error object.
43     */
44    executeSql(sqlStatement: string, args?: (number | string | null)[], callback?: SQLStatementCallback, errorCallback?: SQLStatementErrorCallback): void;
45}
46export type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;
47export type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;
48export type SQLResultSet = {
49    /**
50     * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
51     */
52    insertId?: number;
53    /**
54     * The number of rows that were changed by the SQL statement.
55     */
56    rowsAffected: number;
57    rows: SQLResultSetRowList;
58};
59export interface SQLResultSetRowList {
60    /**
61     * The number of rows returned by the query.
62     */
63    length: number;
64    /**
65     * Returns the row with the given `index`. If there is no such row, returns `null`.
66     * @param index Index of row to get.
67     */
68    item(index: number): any;
69    /**
70     * The actual array of rows returned by the query. Can be used directly instead of
71     * getting rows through rows.item().
72     */
73    _array: any[];
74}
75export declare class SQLError {
76    static UNKNOWN_ERR: number;
77    static DATABASE_ERR: number;
78    static VERSION_ERR: number;
79    static TOO_LARGE_ERR: number;
80    static QUOTA_ERR: number;
81    static SYNTAX_ERR: number;
82    static CONSTRAINT_ERR: number;
83    static TIMEOUT_ERR: number;
84    code: number;
85    message: string;
86}
87/** @deprecated Use `SQLiteDatabase` instead. */
88export interface WebSQLDatabase extends Database {
89    exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;
90    /**
91     * Close the database.
92     */
93    closeAsync(): void;
94    /**
95     * Delete the database file.
96     * > The database has to be closed prior to deletion.
97     */
98    deleteAsync(): Promise<void>;
99}
100export type Query = {
101    sql: string;
102    args: unknown[];
103};
104export interface ResultSetError {
105    error: Error;
106}
107/**
108 * `ResultSet` objects are returned through second parameter of the `success` callback for the
109 * `tx.executeSql()` method on a `SQLTransaction` (see above).
110 */
111export interface ResultSet {
112    /**
113     * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
114     */
115    insertId?: number;
116    /**
117     * The number of rows that were changed by the SQL statement.
118     */
119    rowsAffected: number;
120    rows: {
121        [column: string]: any;
122    }[];
123}
124export type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError | ResultSet)[]) => void;
125/** A transaction object to perform SQL statements in async mode. */
126export interface SQLTransactionAsync {
127    /** Executes a SQL statement in async mode. */
128    executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;
129}
130/** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */
131export type SQLTransactionAsyncCallback = (transaction: SQLTransactionAsync) => Promise<void>;
132//# sourceMappingURL=SQLite.types.d.ts.map