Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "cordova-sqlite-storage",
"version": "1.5.2",
"description": "Native interface to SQLite for PhoneGap/Cordova",
"types": "./types/index.d.ts",
"cordova": {
"id": "cordova-sqlite-storage",
"platforms": [
Expand Down
67 changes: 67 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Type definitions for cordova-sqlite-storage 1.5
// Project: https://github.com/litehelpers/Cordova-sqlite-storage
// Definitions by: rafw87 <https://github.com/rafw87/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

interface Window {
sqlitePlugin: SQLitePlugin.SQLite;
}

declare var sqlitePlugin: SQLitePlugin.SQLite;

declare namespace SQLitePlugin {
type TransactionFunction = (tx: Transaction) => void;

type SuccessCallback = () => void;
type DatabaseSuccessCallback = (db: Database) => void;
type StatementSuccessCallback = (results: Results) => void;
type TransactionStatementSuccessCallback = (tx: Transaction, results: Results) => void;

type ErrorCallback = (err: Error) => void;
type TransactionStatementErrorCallback = (tx: Transaction, err: Error) => boolean | void;

interface OpenArgs {
name: string;
location?: string;
iosDatabaseLocation?: string;
androidDatabaseImplementation?: number;
androidLockWorkaround?: number;
createFromLocation?: number;
[key: string]: any;
}
interface DeleteArgs {
name: string;
location?: string;
iosDatabaseLocation?: string;
}

interface Results {
rowsAffected: number;
insertId?: number;
rows: {
length: number;
item(i: number): any;
};
}

interface Transaction {
executeSql(statement: string, params?: any[], success?: TransactionStatementSuccessCallback, error?: TransactionStatementErrorCallback): void;
}

interface Database {
transaction(fn: TransactionFunction, error?: ErrorCallback, success?: SuccessCallback): void;
readTransaction(fn: TransactionFunction, error?: ErrorCallback, success?: SuccessCallback): void;

executeSql(statement: string, params?: any[], success?: StatementSuccessCallback, error?: ErrorCallback): void;
sqlBatch(sqlStatements: Array<string|[string, any[]]>, success?: SuccessCallback, error?: ErrorCallback): void;

close(success?: SuccessCallback, error?: ErrorCallback): void;
}

interface SQLite {
openDatabase(args: OpenArgs, success?: DatabaseSuccessCallback, error?: ErrorCallback): Database;
deleteDatabase(args: DeleteArgs, success?: SuccessCallback, error?: ErrorCallback): void;
selfTest(success?: SuccessCallback, error?: ErrorCallback): void;
echoTest(ok?: (value: string) => void, error?: (msg: string) => void): void;
}
}