1// Definitions copied from `@types/websql` as we want 2// to expose a custom version of the API that: 3// - uses primitive `string` instead of `String` 4// - excludes some methods that are not exposed by our API. 5// 6// Original definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2> 7 8export interface Window { 9 openDatabase?: ( 10 name: string, 11 version: string, 12 displayName: string, 13 estimatedSize: number, 14 creationCallback?: DatabaseCallback 15 ) => Database; 16} 17 18export interface DatabaseCallback { 19 (database: Database): void; 20} 21 22export interface Database { 23 version: string; 24 25 transaction( 26 callback: SQLTransactionCallback, 27 errorCallback?: SQLTransactionErrorCallback, 28 successCallback?: SQLVoidCallback 29 ): void; 30 31 readTransaction( 32 callback: SQLTransactionCallback, 33 errorCallback?: SQLTransactionErrorCallback, 34 successCallback?: SQLVoidCallback 35 ): void; 36} 37 38export interface SQLVoidCallback { 39 (): void; 40} 41 42export interface SQLTransactionCallback { 43 (transaction: SQLTransaction): void; 44} 45 46export interface SQLTransactionErrorCallback { 47 (error: SQLError): void; 48} 49 50export interface SQLTransaction { 51 executeSql( 52 sqlStatement: string, 53 args?: any[], 54 callback?: SQLStatementCallback, 55 errorCallback?: SQLStatementErrorCallback 56 ): void; 57} 58 59export interface SQLStatementCallback { 60 (transaction: SQLTransaction, resultSet: SQLResultSet): void; 61} 62 63export interface SQLStatementErrorCallback { 64 (transaction: SQLTransaction, error: SQLError): boolean; 65} 66 67export interface SQLResultSet { 68 insertId: number; 69 rowsAffected: number; 70 rows: SQLResultSetRowList; 71} 72 73export interface SQLResultSetRowList { 74 length: number; 75 item(index: number): any; 76 _array: any[]; 77} 78 79export declare class SQLError { 80 static UNKNOWN_ERR: number; 81 static DATABASE_ERR: number; 82 static VERSION_ERR: number; 83 static TOO_LARGE_ERR: number; 84 static QUOTA_ERR: number; 85 static SYNTAX_ERR: number; 86 static CONSTRAINT_ERR: number; 87 static TIMEOUT_ERR: number; 88 89 code: number; 90 message: string; 91} 92 93export interface WebSQLDatabase extends Database { 94 exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void; 95} 96 97export type Query = { sql: string; args: unknown[] }; 98 99export interface ResultSetError { 100 error: Error; 101} 102export interface ResultSet { 103 insertId?: number; 104 rowsAffected: number; 105 rows: { [column: string]: any }[]; 106} 107 108export type SQLiteCallback = ( 109 error?: Error | null, 110 resultSet?: (ResultSetError | ResultSet)[] 111) => void; 112