1// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2> 2 3export interface DatabaseCallback { 4 (database: Database): void; 5} 6 7export interface Database { 8 version: string; 9 10 transaction( 11 callback: SQLTransactionCallback, 12 errorCallback?: SQLTransactionErrorCallback, 13 successCallback?: SQLVoidCallback 14 ): void; 15 16 readTransaction( 17 callback: SQLTransactionCallback, 18 errorCallback?: SQLTransactionErrorCallback, 19 successCallback?: SQLVoidCallback 20 ): void; 21} 22 23export interface SQLVoidCallback { 24 (): void; 25} 26 27export interface SQLTransactionCallback { 28 (transaction: SQLTransaction): void; 29} 30 31export interface SQLTransactionErrorCallback { 32 (error: SQLError): void; 33} 34 35export interface SQLTransaction { 36 executeSql( 37 sqlStatement: string, 38 args?: any[], 39 callback?: SQLStatementCallback, 40 errorCallback?: SQLStatementErrorCallback 41 ): void; 42} 43 44export interface SQLStatementCallback { 45 (transaction: SQLTransaction, resultSet: SQLResultSet): void; 46} 47 48export interface SQLStatementErrorCallback { 49 (transaction: SQLTransaction, error: SQLError): boolean; 50} 51 52export interface SQLResultSet { 53 insertId: number; 54 rowsAffected: number; 55 rows: SQLResultSetRowList; 56} 57 58export interface SQLResultSetRowList { 59 length: number; 60 item(index: number): any; 61} 62 63export declare class SQLError { 64 static UNKNOWN_ERR: number; 65 static DATABASE_ERR: number; 66 static VERSION_ERR: number; 67 static TOO_LARGE_ERR: number; 68 static QUOTA_ERR: number; 69 static SYNTAX_ERR: number; 70 static CONSTRAINT_ERR: number; 71 static TIMEOUT_ERR: number; 72 73 code: number; 74 message: string; 75} 76 77export interface WebSQLDatabase extends Database { 78 exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void; 79} 80 81export type Query = { sql: string; args: unknown[] }; 82 83export interface ResultSetError { 84 error: Error; 85} 86export interface ResultSet { 87 insertId?: number; 88 rowsAffected: number; 89 rows: { [column: string]: any }[]; 90} 91 92export type SQLiteCallback = ( 93 error?: Error | null, 94 resultSet?: (ResultSetError | ResultSet)[] 95) => void; 96