expo-sqlite 12.0.0 → 12.2.0
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 +23 -0
- package/android/build.gradle +4 -4
- package/android/src/main/cpp/NativeStatementBinding.cpp +19 -8
- package/android/src/main/cpp/NativeStatementBinding.h +2 -14
- package/android/src/main/java/expo/modules/sqlite/NativeStatementBinding.kt +4 -3
- package/android/src/main/java/expo/modules/sqlite/SQLiteModuleNext.kt +19 -12
- package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86_64/libcrsqlite.so +0 -0
- package/build/SQLite.d.ts +2 -2
- package/build/SQLite.d.ts.map +1 -1
- package/build/SQLite.js.map +1 -1
- package/build/SQLite.types.d.ts +3 -2
- package/build/SQLite.types.d.ts.map +1 -1
- package/build/SQLite.types.js.map +1 -1
- package/build/next/Database.d.ts +91 -73
- package/build/next/Database.d.ts.map +1 -1
- package/build/next/Database.js +24 -25
- package/build/next/Database.js.map +1 -1
- package/build/next/NativeDatabase.d.ts +1 -1
- package/build/next/NativeDatabase.js.map +1 -1
- package/build/next/NativeStatement.d.ts +17 -14
- package/build/next/NativeStatement.d.ts.map +1 -1
- package/build/next/NativeStatement.js.map +1 -1
- package/build/next/Statement.d.ts +65 -43
- package/build/next/Statement.d.ts.map +1 -1
- package/build/next/Statement.js +76 -27
- package/build/next/Statement.js.map +1 -1
- package/build/next/hooks.d.ts +25 -0
- package/build/next/hooks.d.ts.map +1 -1
- package/build/next/hooks.js +39 -11
- package/build/next/hooks.js.map +1 -1
- package/ios/SQLiteModuleNext.swift +52 -35
- package/package.json +2 -2
- package/src/SQLite.ts +2 -1
- package/src/SQLite.types.ts +5 -2
- package/src/next/Database.ts +111 -92
- package/src/next/NativeDatabase.ts +1 -1
- package/src/next/NativeStatement.ts +25 -14
- package/src/next/Statement.ts +133 -66
- package/src/next/hooks.tsx +40 -12
- package/android/src/main/jniLibs/arm64/libcrsqlite.so +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,12 +10,35 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.2.0 — 2023-11-14
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed the `transactionExclusiveAsync` does not support CRSQLite. ([#25370](https://github.com/expo/expo/pull/25370) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- Build `crsqlite` from source using the correct architectures. ([#25363](https://github.com/expo/expo/pull/25363) by [@alanjhughes](https://github.com/alanjhughes))
|
|
22
|
+
|
|
23
|
+
## 12.1.0 — 2023-11-10
|
|
24
|
+
|
|
25
|
+
### 🎉 New features
|
|
26
|
+
|
|
27
|
+
- Improved performance on the `expo-sqlite/next` API. ([#25314](https://github.com/expo/expo/pull/25314) by [@kudo](https://github.com/kudo))
|
|
28
|
+
|
|
29
|
+
### 🐛 Bug fixes
|
|
30
|
+
|
|
31
|
+
- Fix crash issues in `sqlite/next`. ([#25295](https://github.com/expo/expo/pull/25295) by [@kudo](https://github.com/kudo))
|
|
32
|
+
- Fix `executeSqlAsync` to accept null properly as arguments. ([#24761](https://github.com/expo/expo/pull/24761) by [@spencerc99](https://github.com/spencerc99))
|
|
33
|
+
- Fixed `useSQLiteContext()` and `finalizeUnusedStatementsBeforeClosing` issues in `expo-sqlite/next` API. ([#25328](https://github.com/expo/expo/pull/25328) by [@kudo](https://github.com/kudo))
|
|
34
|
+
|
|
13
35
|
## 12.0.0 — 2023-11-06
|
|
14
36
|
|
|
15
37
|
### 🛠 Breaking changes
|
|
16
38
|
|
|
17
39
|
- Bumped iOS deployment target to 13.4. ([#25063](https://github.com/expo/expo/pull/25063) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
|
18
40
|
- Remove CRSQLite support on legacy API. ([#25092](https://github.com/expo/expo/pull/25092) by [@kudo](https://github.com/kudo))
|
|
41
|
+
- On `Android` bump `compileSdkVersion` and `targetSdkVersion` to `34`. ([#24708](https://github.com/expo/expo/pull/24708) by [@alanjhughes](https://github.com/alanjhughes))
|
|
19
42
|
|
|
20
43
|
### 🎉 New features
|
|
21
44
|
|
package/android/build.gradle
CHANGED
|
@@ -4,7 +4,7 @@ apply plugin: 'maven-publish'
|
|
|
4
4
|
apply plugin: 'de.undercouch.download'
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '12.
|
|
7
|
+
version = '12.2.0'
|
|
8
8
|
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
10
|
if (expoModulesCorePlugin.exists()) {
|
|
@@ -73,11 +73,11 @@ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
|
|
|
73
73
|
android {
|
|
74
74
|
// Remove this if and it's contents, when support for SDK49 is dropped
|
|
75
75
|
if (!safeExtGet("expoProvidesDefaultConfig", false)) {
|
|
76
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
76
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
77
77
|
|
|
78
78
|
defaultConfig {
|
|
79
79
|
minSdkVersion safeExtGet("minSdkVersion", 23)
|
|
80
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
80
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
publishing {
|
|
@@ -106,7 +106,7 @@ android {
|
|
|
106
106
|
namespace "expo.modules.sqlite"
|
|
107
107
|
defaultConfig {
|
|
108
108
|
versionCode 18
|
|
109
|
-
versionName "12.
|
|
109
|
+
versionName "12.2.0"
|
|
110
110
|
|
|
111
111
|
externalNativeBuild {
|
|
112
112
|
cmake {
|
|
@@ -30,7 +30,10 @@ void NativeStatementBinding::registerNatives() {
|
|
|
30
30
|
makeNativeMethod("sqlite3_step", NativeStatementBinding::sqlite3_step),
|
|
31
31
|
makeNativeMethod("bindStatementParam",
|
|
32
32
|
NativeStatementBinding::bindStatementParam),
|
|
33
|
-
makeNativeMethod("
|
|
33
|
+
makeNativeMethod("getColumnNames",
|
|
34
|
+
NativeStatementBinding::getColumnNames),
|
|
35
|
+
makeNativeMethod("getColumnValues",
|
|
36
|
+
NativeStatementBinding::getColumnValues),
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -92,16 +95,24 @@ int NativeStatementBinding::bindStatementParam(
|
|
|
92
95
|
return ret;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
jni::local_ref<
|
|
96
|
-
NativeStatementBinding::
|
|
98
|
+
jni::local_ref<jni::JArrayList<jni::JString>>
|
|
99
|
+
NativeStatementBinding::getColumnNames() {
|
|
97
100
|
int columnCount = sqlite3_column_count();
|
|
98
|
-
auto
|
|
101
|
+
auto columnNames = jni::JArrayList<jni::JString>::create(columnCount);
|
|
99
102
|
for (int i = 0; i < columnCount; ++i) {
|
|
100
|
-
|
|
101
|
-
auto value = getColumnValue(i);
|
|
102
|
-
row->put(jni::make_jstring(name), value);
|
|
103
|
+
columnNames->add(jni::make_jstring(sqlite3_column_name(i)));
|
|
103
104
|
}
|
|
104
|
-
return
|
|
105
|
+
return columnNames;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
jni::local_ref<jni::JArrayList<jni::JObject>>
|
|
109
|
+
NativeStatementBinding::getColumnValues() {
|
|
110
|
+
int columnCount = sqlite3_column_count();
|
|
111
|
+
auto columnValues = jni::JArrayList<jni::JObject>::create(columnCount);
|
|
112
|
+
for (int i = 0; i < columnCount; ++i) {
|
|
113
|
+
columnValues->add(getColumnValue(i));
|
|
114
|
+
}
|
|
115
|
+
return columnValues;
|
|
105
116
|
}
|
|
106
117
|
|
|
107
118
|
// static
|
|
@@ -13,19 +13,6 @@ namespace expo {
|
|
|
13
13
|
|
|
14
14
|
class NativeDatabaseBinding;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* A convenient wrapper for the ArrayMap
|
|
18
|
-
*/
|
|
19
|
-
template <typename K = jobject, typename V = jobject>
|
|
20
|
-
struct ArrayMap : public jni::JavaClass<ArrayMap<K, V>, jni::JMap<K, V>> {
|
|
21
|
-
static auto constexpr kJavaDescriptor = "Landroid/util/ArrayMap;";
|
|
22
|
-
|
|
23
|
-
static jni::local_ref<typename ArrayMap<K, V>::javaobject>
|
|
24
|
-
create(int capacity) {
|
|
25
|
-
return ArrayMap<K, V>::newInstance(capacity);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
16
|
class NativeStatementBinding : public jni::HybridClass<NativeStatementBinding> {
|
|
30
17
|
public:
|
|
31
18
|
static constexpr auto kJavaDescriptor =
|
|
@@ -43,7 +30,8 @@ public:
|
|
|
43
30
|
|
|
44
31
|
// helpers
|
|
45
32
|
int bindStatementParam(int index, jni::alias_ref<jni::JObject> param);
|
|
46
|
-
jni::local_ref<
|
|
33
|
+
jni::local_ref<jni::JArrayList<jni::JString>> getColumnNames();
|
|
34
|
+
jni::local_ref<jni::JArrayList<jni::JObject>> getColumnValues();
|
|
47
35
|
|
|
48
36
|
private:
|
|
49
37
|
explicit NativeStatementBinding(
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
package expo.modules.sqlite
|
|
4
4
|
|
|
5
|
-
import android.util.ArrayMap
|
|
6
5
|
import com.facebook.jni.HybridData
|
|
7
6
|
import expo.modules.core.interfaces.DoNotStrip
|
|
8
7
|
|
|
9
|
-
internal typealias
|
|
8
|
+
internal typealias ColumnNames = ArrayList<String>
|
|
9
|
+
internal typealias ColumnValues = ArrayList<Any>
|
|
10
10
|
|
|
11
11
|
@Suppress("KotlinJniMissingFunction")
|
|
12
12
|
@DoNotStrip
|
|
@@ -28,7 +28,8 @@ internal class NativeStatementBinding {
|
|
|
28
28
|
external fun sqlite3_step(): Int
|
|
29
29
|
|
|
30
30
|
external fun bindStatementParam(index: Int, param: Any): Int
|
|
31
|
-
external fun
|
|
31
|
+
external fun getColumnNames(): ColumnNames
|
|
32
|
+
external fun getColumnValues(): ColumnValues
|
|
32
33
|
|
|
33
34
|
// endregion
|
|
34
35
|
|
|
@@ -150,6 +150,13 @@ class SQLiteModuleNext : Module() {
|
|
|
150
150
|
return@Function objectGetAll(statement, database, bindParams)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
AsyncFunction("getColumnNamesAsync") { statement: NativeStatement ->
|
|
154
|
+
return@AsyncFunction statement.ref.getColumnNames()
|
|
155
|
+
}
|
|
156
|
+
Function("getColumnNamesSync") { statement: NativeStatement ->
|
|
157
|
+
return@Function statement.ref.getColumnNames()
|
|
158
|
+
}
|
|
159
|
+
|
|
153
160
|
AsyncFunction("resetAsync") { statement: NativeStatement, database: NativeDatabase ->
|
|
154
161
|
return@AsyncFunction reset(statement, database)
|
|
155
162
|
}
|
|
@@ -231,13 +238,13 @@ class SQLiteModuleNext : Module() {
|
|
|
231
238
|
}
|
|
232
239
|
|
|
233
240
|
@Throws(InvalidConvertibleException::class, SQLiteErrorException::class)
|
|
234
|
-
private fun arrayGet(statement: NativeStatement, database: NativeDatabase, bindParams: List<Any>):
|
|
241
|
+
private fun arrayGet(statement: NativeStatement, database: NativeDatabase, bindParams: List<Any>): ColumnValues? {
|
|
235
242
|
for ((index, param) in bindParams.withIndex()) {
|
|
236
243
|
statement.ref.bindStatementParam(index + 1, param)
|
|
237
244
|
}
|
|
238
245
|
val ret = statement.ref.sqlite3_step()
|
|
239
246
|
if (ret == NativeDatabaseBinding.SQLITE_ROW) {
|
|
240
|
-
return statement.ref.
|
|
247
|
+
return statement.ref.getColumnValues()
|
|
241
248
|
}
|
|
242
249
|
if (ret != NativeDatabaseBinding.SQLITE_DONE) {
|
|
243
250
|
throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
|
|
@@ -246,7 +253,7 @@ class SQLiteModuleNext : Module() {
|
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
@Throws(InvalidConvertibleException::class, SQLiteErrorException::class)
|
|
249
|
-
private fun objectGet(statement: NativeStatement, database: NativeDatabase, bindParams: Map<String, Any>):
|
|
256
|
+
private fun objectGet(statement: NativeStatement, database: NativeDatabase, bindParams: Map<String, Any>): ColumnValues? {
|
|
250
257
|
for ((name, param) in bindParams) {
|
|
251
258
|
val index = statement.ref.sqlite3_bind_parameter_index(name)
|
|
252
259
|
if (index > 0) {
|
|
@@ -255,7 +262,7 @@ class SQLiteModuleNext : Module() {
|
|
|
255
262
|
}
|
|
256
263
|
val ret = statement.ref.sqlite3_step()
|
|
257
264
|
if (ret == NativeDatabaseBinding.SQLITE_ROW) {
|
|
258
|
-
return statement.ref.
|
|
265
|
+
return statement.ref.getColumnValues()
|
|
259
266
|
}
|
|
260
267
|
if (ret != NativeDatabaseBinding.SQLITE_DONE) {
|
|
261
268
|
throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
|
|
@@ -264,44 +271,44 @@ class SQLiteModuleNext : Module() {
|
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
@Throws(InvalidConvertibleException::class, SQLiteErrorException::class)
|
|
267
|
-
private fun arrayGetAll(statement: NativeStatement, database: NativeDatabase, bindParams: List<Any>): List<
|
|
274
|
+
private fun arrayGetAll(statement: NativeStatement, database: NativeDatabase, bindParams: List<Any>): List<ColumnValues> {
|
|
268
275
|
for ((index, param) in bindParams.withIndex()) {
|
|
269
276
|
statement.ref.bindStatementParam(index + 1, param)
|
|
270
277
|
}
|
|
271
|
-
val
|
|
278
|
+
val columnValuesList = mutableListOf<ColumnValues>()
|
|
272
279
|
while (true) {
|
|
273
280
|
val ret = statement.ref.sqlite3_step()
|
|
274
281
|
if (ret == NativeDatabaseBinding.SQLITE_ROW) {
|
|
275
|
-
|
|
282
|
+
columnValuesList.add(statement.ref.getColumnValues())
|
|
276
283
|
continue
|
|
277
284
|
} else if (ret == NativeDatabaseBinding.SQLITE_DONE) {
|
|
278
285
|
break
|
|
279
286
|
}
|
|
280
287
|
throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
|
|
281
288
|
}
|
|
282
|
-
return
|
|
289
|
+
return columnValuesList
|
|
283
290
|
}
|
|
284
291
|
|
|
285
292
|
@Throws(InvalidConvertibleException::class, SQLiteErrorException::class)
|
|
286
|
-
private fun objectGetAll(statement: NativeStatement, database: NativeDatabase, bindParams: Map<String, Any>): List<
|
|
293
|
+
private fun objectGetAll(statement: NativeStatement, database: NativeDatabase, bindParams: Map<String, Any>): List<ColumnValues> {
|
|
287
294
|
for ((name, param) in bindParams) {
|
|
288
295
|
val index = statement.ref.sqlite3_bind_parameter_index(name)
|
|
289
296
|
if (index > 0) {
|
|
290
297
|
statement.ref.bindStatementParam(index, param)
|
|
291
298
|
}
|
|
292
299
|
}
|
|
293
|
-
val
|
|
300
|
+
val columnValuesList = mutableListOf<ColumnValues>()
|
|
294
301
|
while (true) {
|
|
295
302
|
val ret = statement.ref.sqlite3_step()
|
|
296
303
|
if (ret == NativeDatabaseBinding.SQLITE_ROW) {
|
|
297
|
-
|
|
304
|
+
columnValuesList.add(statement.ref.getColumnValues())
|
|
298
305
|
continue
|
|
299
306
|
} else if (ret == NativeDatabaseBinding.SQLITE_DONE) {
|
|
300
307
|
break
|
|
301
308
|
}
|
|
302
309
|
throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
|
|
303
310
|
}
|
|
304
|
-
return
|
|
311
|
+
return columnValuesList
|
|
305
312
|
}
|
|
306
313
|
|
|
307
314
|
@Throws(SQLiteErrorException::class)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/SQLite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './polyfillNextTick';
|
|
2
|
-
import type { Query, ResultSet, ResultSetError, SQLiteCallback, SQLTransactionAsyncCallback, SQLTransactionAsync, SQLTransactionCallback, SQLTransactionErrorCallback } from './SQLite.types';
|
|
2
|
+
import type { Query, ResultSet, ResultSetError, SQLiteCallback, SQLStatementArg, SQLTransactionAsyncCallback, SQLTransactionAsync, SQLTransactionCallback, SQLTransactionErrorCallback } from './SQLite.types';
|
|
3
3
|
/** The database returned by `openDatabase()` */
|
|
4
4
|
export declare class SQLiteDatabase {
|
|
5
5
|
_name: string;
|
|
@@ -84,6 +84,6 @@ export declare class ExpoSQLTransactionAsync implements SQLTransactionAsync {
|
|
|
84
84
|
private readonly db;
|
|
85
85
|
private readonly readOnly;
|
|
86
86
|
constructor(db: SQLiteDatabase, readOnly: boolean);
|
|
87
|
-
executeSqlAsync(sqlStatement: string, args?:
|
|
87
|
+
executeSqlAsync(sqlStatement: string, args?: SQLStatementArg[]): Promise<ResultSet>;
|
|
88
88
|
}
|
|
89
89
|
//# sourceMappingURL=SQLite.d.ts.map
|
package/build/SQLite.d.ts.map
CHANGED
|
@@ -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,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAaxB,gDAAgD;AAChD,qBAAa,cAAc;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAS;gBAEb,IAAI,EAAE,MAAM;IAIxB;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;IAgBzE;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EA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A0B;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,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,MAAkC;IAC1D,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule, EventEmitter } 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');\nconst emitter = new EventEmitter(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 * Due to limitations on `Android` this function is provided to allow raw SQL queries to be\n * executed on the database. This will be less efficient than using the `exec` function, please use\n * only when necessary.\n */\n execRawQuery(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (Platform.OS === 'ios') {\n return this.exec(queries, readOnly, callback);\n }\n\n ExpoSQLite.execRawQuery(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\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(): Promise<void> {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Synchronously closes the database.\n */\n closeSync(): void {\n this._closed = true;\n return ExpoSQLite.closeSync(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 * Used to listen to changes in the database.\n * @param callback A function that receives the `tableName` and `rowId` of the modified data.\n */\n onDatabaseChange(cb: (result: { tableName: string; rowId: number }) => void) {\n return emitter.addListener('onDatabaseChange', cb);\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.execRawQuery = db._db.execRawQuery.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.closeSync = db._db.closeSync.bind(db._db);\n db.onDatabaseChange = db._db.onDatabaseChange.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(\n private readonly db: SQLiteDatabase,\n private readonly readOnly: boolean\n ) {}\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 const result = resultSets[0];\n if (isResultSetError(result)) {\n throw result.error;\n }\n return result;\n }\n}\n\nfunction isResultSetError(result: ResultSet | ResultSetError): result is ResultSetError {\n return 'error' in result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,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QAAiB;QADjB,OAAE,GAAF,EAAE,CAAgB;QAClB,aAAQ,GAAR,QAAQ,CAAS;IACjC,CAAC;IAEJ,KAAK,CAAC,eAAe,CAAC,YAAoB,EAAE,IAAwB;QAClE,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,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,MAAkC;IAC1D,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule, EventEmitter } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport type {\n Query,\n ResultSet,\n ResultSetError,\n SQLiteCallback,\n SQLStatementArg,\n SQLTransactionAsyncCallback,\n SQLTransactionAsync,\n SQLTransactionCallback,\n SQLTransactionErrorCallback,\n} from './SQLite.types';\n\nconst ExpoSQLite = requireNativeModule('ExpoSQLite');\nconst emitter = new EventEmitter(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 * Due to limitations on `Android` this function is provided to allow raw SQL queries to be\n * executed on the database. This will be less efficient than using the `exec` function, please use\n * only when necessary.\n */\n execRawQuery(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (Platform.OS === 'ios') {\n return this.exec(queries, readOnly, callback);\n }\n\n ExpoSQLite.execRawQuery(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\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(): Promise<void> {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Synchronously closes the database.\n */\n closeSync(): void {\n this._closed = true;\n return ExpoSQLite.closeSync(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 * Used to listen to changes in the database.\n * @param callback A function that receives the `tableName` and `rowId` of the modified data.\n */\n onDatabaseChange(cb: (result: { tableName: string; rowId: number }) => void) {\n return emitter.addListener('onDatabaseChange', cb);\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.execRawQuery = db._db.execRawQuery.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.closeSync = db._db.closeSync.bind(db._db);\n db.onDatabaseChange = db._db.onDatabaseChange.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(\n private readonly db: SQLiteDatabase,\n private readonly readOnly: boolean\n ) {}\n\n async executeSqlAsync(sqlStatement: string, args?: SQLStatementArg[]): Promise<ResultSet> {\n const resultSets = await this.db.execAsync(\n [{ sql: sqlStatement, args: args ?? [] }],\n this.readOnly\n );\n const result = resultSets[0];\n if (isResultSetError(result)) {\n throw result.error;\n }\n return result;\n }\n}\n\nfunction isResultSetError(result: ResultSet | ResultSetError): result is ResultSetError {\n return 'error' in result;\n}\n"]}
|
package/build/SQLite.types.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface Database {
|
|
|
21
21
|
}
|
|
22
22
|
export type SQLTransactionCallback = (transaction: SQLTransaction) => void;
|
|
23
23
|
export type SQLTransactionErrorCallback = (error: SQLError) => void;
|
|
24
|
+
export type SQLStatementArg = string | number | null;
|
|
24
25
|
/**
|
|
25
26
|
* A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the
|
|
26
27
|
* `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to
|
|
@@ -41,7 +42,7 @@ export interface SQLTransaction {
|
|
|
41
42
|
* @param errorCallback Called if an error occurred executing this particular query in the
|
|
42
43
|
* transaction. Takes two parameters: the transaction itself, and the error object.
|
|
43
44
|
*/
|
|
44
|
-
executeSql(sqlStatement: string, args?:
|
|
45
|
+
executeSql(sqlStatement: string, args?: SQLStatementArg[], callback?: SQLStatementCallback, errorCallback?: SQLStatementErrorCallback): void;
|
|
45
46
|
}
|
|
46
47
|
export type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;
|
|
47
48
|
export type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;
|
|
@@ -125,7 +126,7 @@ export type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError
|
|
|
125
126
|
/** A transaction object to perform SQL statements in async mode. */
|
|
126
127
|
export interface SQLTransactionAsync {
|
|
127
128
|
/** Executes a SQL statement in async mode. */
|
|
128
|
-
executeSqlAsync(sqlStatement: string, args?:
|
|
129
|
+
executeSqlAsync(sqlStatement: string, args?: SQLStatementArg[]): Promise<ResultSet>;
|
|
129
130
|
}
|
|
130
131
|
/** A transaction callback with given `SQLTransactionAsync` object to perform SQL statements in async mode. */
|
|
131
132
|
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,
|
|
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;C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AI,EAAE;QAAE,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,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACrF;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?:
|
|
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// @docsMissing\nexport type SQLStatementArg = string | number | null;\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?: SQLStatementArg[],\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(sqlStatement: string, args?: SQLStatementArg[]): 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"]}
|