expo-sqlite 11.3.1 → 11.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 11.3.2 — 2023-07-29
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed missing `transaction()` and `readTransaction()` function types from `SQLiteDatabase`. ([#23751](https://github.com/expo/expo/pull/23751) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 11.3.1 — 2023-06-28
14
20
 
15
21
  ### 🎉 New features
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '11.3.1'
6
+ version = '11.3.2'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -67,7 +67,7 @@ android {
67
67
  minSdkVersion safeExtGet("minSdkVersion", 21)
68
68
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
69
  versionCode 18
70
- versionName "11.3.1"
70
+ versionName "11.3.2"
71
71
  }
72
72
  lintOptions {
73
73
  abortOnError false
package/build/SQLite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import './polyfillNextTick';
2
- import type { Query, ResultSet, SQLiteCallback, SQLTransactionAsyncCallback, SQLTransactionAsync } from './SQLite.types';
2
+ import type { Query, ResultSet, ResultSetError, SQLiteCallback, SQLTransactionAsyncCallback, SQLTransactionAsync, SQLTransactionCallback, SQLTransactionErrorCallback } from './SQLite.types';
3
3
  /** The database returned by `openDatabase()` */
4
4
  export declare class SQLiteDatabase {
5
5
  _name: string;
@@ -12,7 +12,7 @@ export declare class SQLiteDatabase {
12
12
  /**
13
13
  * Executes the SQL statement and returns a Promise resolving with the result.
14
14
  */
15
- execAsync(queries: Query[], readOnly: boolean): Promise<ResultSet[]>;
15
+ execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]>;
16
16
  /**
17
17
  * @deprecated Use `closeAsync()` instead.
18
18
  */
@@ -32,6 +32,17 @@ export declare class SQLiteDatabase {
32
32
  * @param readOnly true if all the SQL statements in the callback are read only.
33
33
  */
34
34
  transactionAsync(asyncCallback: SQLTransactionAsyncCallback, readOnly?: boolean): Promise<void>;
35
+ version: string;
36
+ /**
37
+ * Execute a database transaction.
38
+ * @param callback A function representing the transaction to perform. Takes a Transaction
39
+ * (see below) as its only parameter, on which it can add SQL statements to execute.
40
+ * @param errorCallback Called if an error occurred processing this transaction. Takes a single
41
+ * parameter describing the error.
42
+ * @param successCallback Called when the transaction has completed executing on the database.
43
+ */
44
+ transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
45
+ readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
35
46
  }
36
47
  /**
37
48
  * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
@@ -55,6 +66,6 @@ export declare class ExpoSQLTransactionAsync implements SQLTransactionAsync {
55
66
  private readonly db;
56
67
  private readonly readOnly;
57
68
  constructor(db: SQLiteDatabase, readOnly: boolean);
58
- executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;
69
+ executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSetError | ResultSet>;
59
70
  }
60
71
  //# sourceMappingURL=SQLite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.d.ts","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAM5B,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EAET,cAAc,EACd,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAYxB,gDAAgD;AAChD,qBAAa,cAAc;IACzB,KAAK,EAA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,KAAK,IAAI,GACtC,cAAc,CAWhB;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,EAAE;IAAkB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAA7C,EAAE,EAAE,cAAc,EAAmB,QAAQ,EAAE,OAAO;IAE7E,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACzB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;CAOvC"}
package/build/SQLite.js CHANGED
@@ -79,6 +79,8 @@ export class SQLiteDatabase {
79
79
  throw e;
80
80
  }
81
81
  }
82
+ // @ts-expect-error: properties that are added from websql
83
+ version;
82
84
  }
83
85
  function _serializeQuery(query) {
84
86
  return Platform.OS === 'android'
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAWxC,MAAM,UAAU,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAErD,SAAS,SAAS,CAAC,IAAc,EAAE,MAAa;IAC9C,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KAC7B;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gDAAgD;AAChD,MAAM,OAAO,cAAc;IACzB,KAAK,CAAS;IACd,OAAO,GAAY,KAAK,CAAC;IAEz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AAS,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC7C,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/C,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjD,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACL;IAAqC;IAAlE,YAA6B,EAAkB,EAAmB,QAAiB;QAAtD,OAAE,GAAF,EAAE,CAAgB;QAAmB,aAAQ,GAAR,QAAQ,CAAS;IAAG,CAAC;IAEvF,KAAK,CAAC,eAAe,CAAC,YAAoB,EAAE,IAA0B;QACpE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CACxC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,EACzC,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport type {\n Query,\n ResultSet,\n ResultSetError,\n SQLiteCallback,\n SQLTransactionAsyncCallback,\n SQLTransactionAsync,\n} from './SQLite.types';\n\nconst ExpoSQLite = requireNativeModule('ExpoSQLite');\n\nfunction zipObject(keys: string[], values: any[]) {\n const result = {};\n for (let i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n return result;\n}\n\n/** The database returned by `openDatabase()` */\nexport class SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Executes the SQL statement and returns a callback resolving with the result.\n */\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExpoSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Executes the SQL statement and returns a Promise resolving with the result.\n */\n async execAsync(queries: Query[], readOnly: boolean): Promise<ResultSet[]> {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n const nativeResultSets = await ExpoSQLite.exec(\n this._name,\n queries.map(_serializeQuery),\n readOnly\n );\n return nativeResultSets.map(_deserializeResultSet);\n }\n\n /**\n * @deprecated Use `closeAsync()` instead.\n */\n close = this.closeAsync;\n\n /**\n * Close the database.\n */\n closeAsync(): void {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void> {\n if (!this._closed) {\n throw new Error(\n `Unable to delete '${this._name}' database that is currently open. Close it prior to deletion.`\n );\n }\n\n return ExpoSQLite.deleteAsync(this._name);\n }\n\n /**\n * Creates a new transaction with Promise support.\n * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.\n * @param readOnly true if all the SQL statements in the callback are read only.\n */\n async transactionAsync(\n asyncCallback: SQLTransactionAsyncCallback,\n readOnly: boolean = false\n ): Promise<void> {\n await this.execAsync([{ sql: 'BEGIN;', args: [] }], false);\n try {\n const transaction = new ExpoSQLTransactionAsync(this, readOnly);\n await asyncCallback(transaction);\n await this.execAsync([{ sql: 'END;', args: [] }], false);\n } catch (e: unknown) {\n await this.execAsync([{ sql: 'ROLLBACK;', args: [] }], false);\n throw e;\n }\n }\n}\n\nfunction _serializeQuery(query: Query): Query | [string, any[]] {\n return Platform.OS === 'android'\n ? {\n sql: query.sql,\n args: query.args.map(_escapeBlob),\n }\n : [query.sql, query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](./filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: SQLiteDatabase) => void\n): SQLiteDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n db.exec = db._db.exec.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.deleteAsync = db._db.deleteAsync.bind(db._db);\n db.transactionAsync = db._db.transactionAsync.bind(db._db);\n return db;\n}\n\n/**\n * Internal data structure for the async transaction API.\n * @internal\n */\nexport class ExpoSQLTransactionAsync implements SQLTransactionAsync {\n constructor(private readonly db: SQLiteDatabase, private readonly readOnly: boolean) {}\n\n async executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet> {\n const resultSets = await this.db.execAsync(\n [{ sql: sqlStatement, args: args ?? [] }],\n this.readOnly\n );\n return resultSets[0];\n }\n}\n"]}
1
+ {"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAaxC,MAAM,UAAU,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAErD,SAAS,SAAS,CAAC,IAAc,EAAE,MAAa;IAC9C,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KAC7B;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gDAAgD;AAChD,MAAM,OAAO,cAAc;IACzB,KAAK,CAAS;IACd,OAAO,GAAY,KAAK,CAAC;IAEzB,YAAY,IAAY;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAgB,EAAE,QAAiB,EAAE,QAAwB;QAChE,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;SACl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,CAAC,CAAC;IAC/C,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjD,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACL;IAAqC;IAAlE,YAA6B,EAAkB,EAAmB,QAAiB;QAAtD,OAAE,GAAF,EAAE,CAAgB;QAAmB,aAAQ,GAAR,QAAQ,CAAS;IAAG,CAAC;IAEvF,KAAK,CAAC,eAAe,CACnB,YAAoB,EACpB,IAA0B;QAE1B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CACxC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,EACzC,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport type {\n Query,\n ResultSet,\n ResultSetError,\n SQLiteCallback,\n SQLTransactionAsyncCallback,\n SQLTransactionAsync,\n SQLTransactionCallback,\n SQLTransactionErrorCallback,\n} from './SQLite.types';\n\nconst ExpoSQLite = requireNativeModule('ExpoSQLite');\n\nfunction zipObject(keys: string[], values: any[]) {\n const result = {};\n for (let i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n return result;\n}\n\n/** The database returned by `openDatabase()` */\nexport class SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Executes the SQL statement and returns a callback resolving with the result.\n */\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExpoSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Executes the SQL statement and returns a Promise resolving with the result.\n */\n async execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]> {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n const nativeResultSets = await ExpoSQLite.exec(\n this._name,\n queries.map(_serializeQuery),\n readOnly\n );\n return nativeResultSets.map(_deserializeResultSet);\n }\n\n /**\n * @deprecated Use `closeAsync()` instead.\n */\n close = this.closeAsync;\n\n /**\n * Close the database.\n */\n closeAsync(): void {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void> {\n if (!this._closed) {\n throw new Error(\n `Unable to delete '${this._name}' database that is currently open. Close it prior to deletion.`\n );\n }\n\n return ExpoSQLite.deleteAsync(this._name);\n }\n\n /**\n * Creates a new transaction with Promise support.\n * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.\n * @param readOnly true if all the SQL statements in the callback are read only.\n */\n async transactionAsync(\n asyncCallback: SQLTransactionAsyncCallback,\n readOnly: boolean = false\n ): Promise<void> {\n await this.execAsync([{ sql: 'BEGIN;', args: [] }], false);\n try {\n const transaction = new ExpoSQLTransactionAsync(this, readOnly);\n await asyncCallback(transaction);\n await this.execAsync([{ sql: 'END;', args: [] }], false);\n } catch (e: unknown) {\n await this.execAsync([{ sql: 'ROLLBACK;', args: [] }], false);\n throw e;\n }\n }\n\n // @ts-expect-error: properties that are added from websql\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n // @ts-expect-error: properties that are added from websql\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n // @ts-expect-error: properties that are added from websql\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\nfunction _serializeQuery(query: Query): Query | [string, any[]] {\n return Platform.OS === 'android'\n ? {\n sql: query.sql,\n args: query.args.map(_escapeBlob),\n }\n : [query.sql, query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](./filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: SQLiteDatabase) => void\n): SQLiteDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n db.exec = db._db.exec.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.deleteAsync = db._db.deleteAsync.bind(db._db);\n db.transactionAsync = db._db.transactionAsync.bind(db._db);\n return db;\n}\n\n/**\n * Internal data structure for the async transaction API.\n * @internal\n */\nexport class ExpoSQLTransactionAsync implements SQLTransactionAsync {\n constructor(private readonly db: SQLiteDatabase, private readonly readOnly: boolean) {}\n\n async executeSqlAsync(\n sqlStatement: string,\n args?: (number | string)[]\n ): Promise<ResultSetError | ResultSet> {\n const resultSets = await this.db.execAsync(\n [{ sql: sqlStatement, args: args ?? [] }],\n this.readOnly\n );\n return resultSets[0];\n }\n}\n"]}
@@ -101,14 +101,14 @@ export type Query = {
101
101
  sql: string;
102
102
  args: unknown[];
103
103
  };
104
- export type ResultSetError = {
104
+ export interface ResultSetError {
105
105
  error: Error;
106
- };
106
+ }
107
107
  /**
108
108
  * `ResultSet` objects are returned through second parameter of the `success` callback for the
109
109
  * `tx.executeSql()` method on a `SQLTransaction` (see above).
110
110
  */
111
- export type ResultSet = {
111
+ export interface ResultSet {
112
112
  /**
113
113
  * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
114
114
  */
@@ -120,12 +120,12 @@ export type ResultSet = {
120
120
  rows: {
121
121
  [column: string]: any;
122
122
  }[];
123
- };
123
+ }
124
124
  export type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError | ResultSet)[]) => void;
125
125
  /** A transaction object to perform SQL statements in async mode. */
126
126
  export interface SQLTransactionAsync {
127
127
  /** Executes a SQL statement in async mode. */
128
- executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;
128
+ executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSetError | ResultSet>;
129
129
  }
130
130
  /** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */
131
131
  export type SQLTransactionAsyncCallback = (transaction: SQLTransactionAsync) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.types.d.ts","sourceRoot":"","sources":["../src/SQLite.types.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,MAAM;IACrB,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,gBAAgB,CAAC,EAAE,gBAAgB,KAChC,QAAQ,CAAC;CACf;AAGD,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAG5D;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;OAOG;IACH,WAAW,CACT,QAAQ,EAAE,sBAAsB,EAChC,aAAa,CAAC,EAAE,2BAA2B,EAC3C,eAAe,CAAC,EAAE,MAAM,IAAI,GAC3B,IAAI,CAAC;IAER,eAAe,CACb,QAAQ,EAAE,sBAAsB,EAChC,aAAa,CAAC,EAAE,2BAA2B,EAC3C,eAAe,CAAC,EAAE,MAAM,IAAI,GAC3B,IAAI,CAAC;CACT;AAGD,MAAM,MAAM,sBAAsB,GAAG,CAAC,WAAW,EAAE,cAAc,KAAK,IAAI,CAAC;AAG3E,MAAM,MAAM,2BAA2B,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAGpE;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;OAaG;IACH,UAAU,CACR,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,EACjC,QAAQ,CAAC,EAAE,oBAAoB,E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AE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;CACnC;AAGD,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,EACpB,SAAS,CAAC,EAAE,CAAC,cAAc,GAAG,SAAS,CAAC,EAAE,KACvC,IAAI,CAAC;AAEV,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,eAAe,CACb,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACzB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CACxC;AAED,8GAA8G;AAC9G,MAAM,MAAM,2BAA2B,GAAG,CAAC,WAAW,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.types.js","sourceRoot":"","sources":["../src/SQLite.types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,8CAA8C;AAC9C,gDAAgD;AAChD,2DAA2D;AAC3D,EAAE;AACF,0EAA0E","sourcesContent":["// Definitions copied from `@types/websql` as we want\n// to expose a custom version of the API that:\n// - uses primitive `string` instead of `String`\n// - excludes some methods that are not exposed by our API.\n//\n// Original definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>\n\n// @docsMissing\nexport interface Window {\n openDatabase?: (\n name: string,\n version: string,\n displayName: string,\n estimatedSize: number,\n creationCallback?: DatabaseCallback\n ) => Database;\n}\n\n// @docsMissing\nexport type DatabaseCallback = (database: Database) => void;\n\n// @needsAudit @docsMissing\n/**\n * `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a\n * connection to a database on your device.\n */\nexport interface Database {\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\n// @docsMissing\nexport type SQLTransactionCallback = (transaction: SQLTransaction) => void;\n\n// @docsMissing\nexport type SQLTransactionErrorCallback = (error: SQLError) => void;\n\n// @needsAudit\n/**\n * A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the\n * `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to\n * perform in a database transaction.\n */\nexport interface SQLTransaction {\n /**\n * Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make\n * use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to\n * never construct SQL statements on the fly.\n * @param sqlStatement A string containing a database query to execute expressed as SQL. The string\n * may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter.\n * @param args An array of values (numbers, strings or nulls) to substitute for `?` placeholders in the\n * SQL statement.\n * @param callback Called when the query is successfully completed during the transaction. Takes\n * two parameters: the transaction itself, and a `ResultSet` object (see below) with the results\n * of the query.\n * @param errorCallback Called if an error occurred executing this particular query in the\n * transaction. Takes two parameters: the transaction itself, and the error object.\n */\n executeSql(\n sqlStatement: string,\n args?: (number | string | null)[],\n callback?: SQLStatementCallback,\n errorCallback?: SQLStatementErrorCallback\n ): void;\n}\n\n// @docsMissing\nexport type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;\n\n// @docsMissing\nexport type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;\n\n// @needsAudit\nexport type SQLResultSet = {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: SQLResultSetRowList;\n};\n\n// @needsAudit\nexport interface SQLResultSetRowList {\n /**\n * The number of rows returned by the query.\n */\n length: number;\n /**\n * Returns the row with the given `index`. If there is no such row, returns `null`.\n * @param index Index of row to get.\n */\n item(index: number): any;\n /**\n * The actual array of rows returned by the query. Can be used directly instead of\n * getting rows through rows.item().\n */\n _array: any[];\n}\n\n// @docsMissing\nexport declare class SQLError {\n static UNKNOWN_ERR: number;\n static DATABASE_ERR: number;\n static VERSION_ERR: number;\n static TOO_LARGE_ERR: number;\n static QUOTA_ERR: number;\n static SYNTAX_ERR: number;\n static CONSTRAINT_ERR: number;\n static TIMEOUT_ERR: number;\n\n code: number;\n message: string;\n}\n\n/** @deprecated Use `SQLiteDatabase` instead. */\nexport interface WebSQLDatabase extends Database {\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;\n\n /**\n * Close the database.\n */\n closeAsync(): void;\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void>;\n}\n\n// @docsMissing\nexport type Query = { sql: string; args: unknown[] };\n\n// @docsMissing\nexport type ResultSetError = {\n error: Error;\n};\n\n// @needsAudit\n/**\n * `ResultSet` objects are returned through second parameter of the `success` callback for the\n * `tx.executeSql()` method on a `SQLTransaction` (see above).\n */\nexport type ResultSet = {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: { [column: string]: any }[];\n};\n\n// @docsMissing\nexport type SQLiteCallback = (\n error?: Error | null,\n resultSet?: (ResultSetError | ResultSet)[]\n) => void;\n\n/** A transaction object to perform SQL statements in async mode. */\nexport interface SQLTransactionAsync {\n /** Executes a SQL statement in async mode. */\n executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;\n}\n\n/** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */\nexport type SQLTransactionAsyncCallback = (transaction: SQLTransactionAsync) => Promise<void>;\n"]}
1
+ {"version":3,"file":"SQLite.types.js","sourceRoot":"","sources":["../src/SQLite.types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,8CAA8C;AAC9C,gDAAgD;AAChD,2DAA2D;AAC3D,EAAE;AACF,0EAA0E","sourcesContent":["// Definitions copied from `@types/websql` as we want\n// to expose a custom version of the API that:\n// - uses primitive `string` instead of `String`\n// - excludes some methods that are not exposed by our API.\n//\n// Original definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>\n\n// @docsMissing\nexport interface Window {\n openDatabase?: (\n name: string,\n version: string,\n displayName: string,\n estimatedSize: number,\n creationCallback?: DatabaseCallback\n ) => Database;\n}\n\n// @docsMissing\nexport type DatabaseCallback = (database: Database) => void;\n\n// @needsAudit @docsMissing\n/**\n * `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a\n * connection to a database on your device.\n */\nexport interface Database {\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\n// @docsMissing\nexport type SQLTransactionCallback = (transaction: SQLTransaction) => void;\n\n// @docsMissing\nexport type SQLTransactionErrorCallback = (error: SQLError) => void;\n\n// @needsAudit\n/**\n * A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the\n * `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to\n * perform in a database transaction.\n */\nexport interface SQLTransaction {\n /**\n * Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make\n * use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to\n * never construct SQL statements on the fly.\n * @param sqlStatement A string containing a database query to execute expressed as SQL. The string\n * may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter.\n * @param args An array of values (numbers, strings or nulls) to substitute for `?` placeholders in the\n * SQL statement.\n * @param callback Called when the query is successfully completed during the transaction. Takes\n * two parameters: the transaction itself, and a `ResultSet` object (see below) with the results\n * of the query.\n * @param errorCallback Called if an error occurred executing this particular query in the\n * transaction. Takes two parameters: the transaction itself, and the error object.\n */\n executeSql(\n sqlStatement: string,\n args?: (number | string | null)[],\n callback?: SQLStatementCallback,\n errorCallback?: SQLStatementErrorCallback\n ): void;\n}\n\n// @docsMissing\nexport type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;\n\n// @docsMissing\nexport type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;\n\n// @needsAudit\nexport type SQLResultSet = {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: SQLResultSetRowList;\n};\n\n// @needsAudit\nexport interface SQLResultSetRowList {\n /**\n * The number of rows returned by the query.\n */\n length: number;\n /**\n * Returns the row with the given `index`. If there is no such row, returns `null`.\n * @param index Index of row to get.\n */\n item(index: number): any;\n /**\n * The actual array of rows returned by the query. Can be used directly instead of\n * getting rows through rows.item().\n */\n _array: any[];\n}\n\n// @docsMissing\nexport declare class SQLError {\n static UNKNOWN_ERR: number;\n static DATABASE_ERR: number;\n static VERSION_ERR: number;\n static TOO_LARGE_ERR: number;\n static QUOTA_ERR: number;\n static SYNTAX_ERR: number;\n static CONSTRAINT_ERR: number;\n static TIMEOUT_ERR: number;\n\n code: number;\n message: string;\n}\n\n/** @deprecated Use `SQLiteDatabase` instead. */\nexport interface WebSQLDatabase extends Database {\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;\n\n /**\n * Close the database.\n */\n closeAsync(): void;\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void>;\n}\n\n// @docsMissing\nexport type Query = { sql: string; args: unknown[] };\n\n// @docsMissing\nexport interface ResultSetError {\n error: Error;\n}\n\n// @needsAudit\n/**\n * `ResultSet` objects are returned through second parameter of the `success` callback for the\n * `tx.executeSql()` method on a `SQLTransaction` (see above).\n */\nexport interface ResultSet {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: { [column: string]: any }[];\n}\n\n// @docsMissing\nexport type SQLiteCallback = (\n error?: Error | null,\n resultSet?: (ResultSetError | ResultSet)[]\n) => void;\n\n/** A transaction object to perform SQL statements in async mode. */\nexport interface SQLTransactionAsync {\n /** Executes a SQL statement in async mode. */\n executeSqlAsync(\n sqlStatement: string,\n args?: (number | string)[]\n ): Promise<ResultSetError | ResultSet>;\n}\n\n/** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */\nexport type SQLTransactionAsyncCallback = (transaction: SQLTransactionAsync) => Promise<void>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-sqlite",
3
- "version": "11.3.1",
3
+ "version": "11.3.2",
4
4
  "description": "Provides access to a database that can be queried through a WebSQL-like API (https://www.w3.org/TR/webdatabase/). The database is persisted across restarts of your app.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "expo": "*"
46
46
  },
47
- "gitHead": "4a38f32842594bb0ef39228dacde53042f12a47b"
47
+ "gitHead": "0d774d352ca6d11f83a3223199c8e5f6ba4c8e09"
48
48
  }
package/src/SQLite.ts CHANGED
@@ -11,6 +11,8 @@ import type {
11
11
  SQLiteCallback,
12
12
  SQLTransactionAsyncCallback,
13
13
  SQLTransactionAsync,
14
+ SQLTransactionCallback,
15
+ SQLTransactionErrorCallback,
14
16
  } from './SQLite.types';
15
17
 
16
18
  const ExpoSQLite = requireNativeModule('ExpoSQLite');
@@ -54,7 +56,7 @@ export class SQLiteDatabase {
54
56
  /**
55
57
  * Executes the SQL statement and returns a Promise resolving with the result.
56
58
  */
57
- async execAsync(queries: Query[], readOnly: boolean): Promise<ResultSet[]> {
59
+ async execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]> {
58
60
  if (this._closed) {
59
61
  throw new Error(`The SQLite database is closed`);
60
62
  }
@@ -113,6 +115,31 @@ export class SQLiteDatabase {
113
115
  throw e;
114
116
  }
115
117
  }
118
+
119
+ // @ts-expect-error: properties that are added from websql
120
+ version: string;
121
+
122
+ /**
123
+ * Execute a database transaction.
124
+ * @param callback A function representing the transaction to perform. Takes a Transaction
125
+ * (see below) as its only parameter, on which it can add SQL statements to execute.
126
+ * @param errorCallback Called if an error occurred processing this transaction. Takes a single
127
+ * parameter describing the error.
128
+ * @param successCallback Called when the transaction has completed executing on the database.
129
+ */
130
+ // @ts-expect-error: properties that are added from websql
131
+ transaction(
132
+ callback: SQLTransactionCallback,
133
+ errorCallback?: SQLTransactionErrorCallback,
134
+ successCallback?: () => void
135
+ ): void;
136
+
137
+ // @ts-expect-error: properties that are added from websql
138
+ readTransaction(
139
+ callback: SQLTransactionCallback,
140
+ errorCallback?: SQLTransactionErrorCallback,
141
+ successCallback?: () => void
142
+ ): void;
116
143
  }
117
144
 
118
145
  function _serializeQuery(query: Query): Query | [string, any[]] {
@@ -194,7 +221,10 @@ export function openDatabase(
194
221
  export class ExpoSQLTransactionAsync implements SQLTransactionAsync {
195
222
  constructor(private readonly db: SQLiteDatabase, private readonly readOnly: boolean) {}
196
223
 
197
- async executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet> {
224
+ async executeSqlAsync(
225
+ sqlStatement: string,
226
+ args?: (number | string)[]
227
+ ): Promise<ResultSetError | ResultSet> {
198
228
  const resultSets = await this.db.execAsync(
199
229
  [{ sql: sqlStatement, args: args ?? [] }],
200
230
  this.readOnly
@@ -155,16 +155,16 @@ export interface WebSQLDatabase extends Database {
155
155
  export type Query = { sql: string; args: unknown[] };
156
156
 
157
157
  // @docsMissing
158
- export type ResultSetError = {
158
+ export interface ResultSetError {
159
159
  error: Error;
160
- };
160
+ }
161
161
 
162
162
  // @needsAudit
163
163
  /**
164
164
  * `ResultSet` objects are returned through second parameter of the `success` callback for the
165
165
  * `tx.executeSql()` method on a `SQLTransaction` (see above).
166
166
  */
167
- export type ResultSet = {
167
+ export interface ResultSet {
168
168
  /**
169
169
  * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
170
170
  */
@@ -174,7 +174,7 @@ export type ResultSet = {
174
174
  */
175
175
  rowsAffected: number;
176
176
  rows: { [column: string]: any }[];
177
- };
177
+ }
178
178
 
179
179
  // @docsMissing
180
180
  export type SQLiteCallback = (
@@ -185,7 +185,10 @@ export type SQLiteCallback = (
185
185
  /** A transaction object to perform SQL statements in async mode. */
186
186
  export interface SQLTransactionAsync {
187
187
  /** Executes a SQL statement in async mode. */
188
- executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;
188
+ executeSqlAsync(
189
+ sqlStatement: string,
190
+ args?: (number | string)[]
191
+ ): Promise<ResultSetError | ResultSet>;
189
192
  }
190
193
 
191
194
  /** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */