@webority-technologies/mobile-core 0.0.5 → 0.0.7
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/android/build.gradle +65 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/AppSignatureHelper.kt +57 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModule.kt +20 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModuleImpl.kt +146 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverPackage.kt +33 -0
- package/lib/commonjs/formatters/dateMath.js +19 -1
- package/lib/commonjs/formatters/index.js +6 -0
- package/lib/commonjs/formatters/windowsToIanaTable.js +164 -0
- package/lib/commonjs/geolocation/index.js +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/permissions/index.js +128 -129
- package/lib/commonjs/smsRetriever/index.js +91 -0
- package/lib/commonjs/specs/NativeSmsRetriever.js +15 -0
- package/lib/commonjs/sqlite/index.js +12 -30
- package/lib/module/formatters/dateMath.js +17 -0
- package/lib/module/formatters/index.js +1 -1
- package/lib/module/formatters/windowsToIanaTable.js +160 -0
- package/lib/module/geolocation/index.js +1 -1
- package/lib/module/index.js +4 -3
- package/lib/module/permissions/index.js +129 -130
- package/lib/module/smsRetriever/index.js +86 -0
- package/lib/module/specs/NativeSmsRetriever.js +13 -0
- package/lib/module/sqlite/index.js +12 -30
- package/lib/typescript/commonjs/formatters/dateMath.d.ts +9 -0
- package/lib/typescript/commonjs/formatters/index.d.ts +1 -1
- package/lib/typescript/commonjs/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/commonjs/index.d.ts +4 -3
- package/lib/typescript/commonjs/permissions/index.d.ts +14 -36
- package/lib/typescript/commonjs/smsRetriever/index.d.ts +30 -0
- package/lib/typescript/commonjs/specs/NativeSmsRetriever.d.ts +15 -0
- package/lib/typescript/commonjs/sqlite/index.d.ts +10 -18
- package/lib/typescript/module/formatters/dateMath.d.ts +9 -0
- package/lib/typescript/module/formatters/index.d.ts +1 -1
- package/lib/typescript/module/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/module/index.d.ts +4 -3
- package/lib/typescript/module/permissions/index.d.ts +14 -36
- package/lib/typescript/module/smsRetriever/index.d.ts +30 -0
- package/lib/typescript/module/specs/NativeSmsRetriever.d.ts +15 -0
- package/lib/typescript/module/sqlite/index.d.ts +10 -18
- package/package.json +30 -47
- package/lib/commonjs/sqlite/adapters/op.js +0 -43
- package/lib/commonjs/sqlite/adapters/rows.js +0 -33
- package/lib/commonjs/sqlite/adapters/storage.js +0 -50
- package/lib/commonjs/sqlite/adapters/sync.js +0 -45
- package/lib/commonjs/sqlite/nitro.js +0 -17
- package/lib/commonjs/sqlite/op.js +0 -18
- package/lib/commonjs/sqlite/quick.js +0 -14
- package/lib/commonjs/sqlite/storage.js +0 -14
- package/lib/module/sqlite/adapters/op.js +0 -38
- package/lib/module/sqlite/adapters/rows.js +0 -28
- package/lib/module/sqlite/adapters/storage.js +0 -46
- package/lib/module/sqlite/adapters/sync.js +0 -41
- package/lib/module/sqlite/nitro.js +0 -12
- package/lib/module/sqlite/op.js +0 -13
- package/lib/module/sqlite/quick.js +0 -9
- package/lib/module/sqlite/storage.js +0 -9
- package/lib/typescript/commonjs/sqlite/adapters/op.d.ts +0 -27
- package/lib/typescript/commonjs/sqlite/adapters/rows.d.ts +0 -7
- package/lib/typescript/commonjs/sqlite/adapters/storage.d.ts +0 -30
- package/lib/typescript/commonjs/sqlite/adapters/sync.d.ts +0 -31
- package/lib/typescript/commonjs/sqlite/nitro.d.ts +0 -7
- package/lib/typescript/commonjs/sqlite/op.d.ts +0 -8
- package/lib/typescript/commonjs/sqlite/quick.d.ts +0 -4
- package/lib/typescript/commonjs/sqlite/storage.d.ts +0 -4
- package/lib/typescript/module/sqlite/adapters/op.d.ts +0 -27
- package/lib/typescript/module/sqlite/adapters/rows.d.ts +0 -7
- package/lib/typescript/module/sqlite/adapters/storage.d.ts +0 -30
- package/lib/typescript/module/sqlite/adapters/sync.d.ts +0 -31
- package/lib/typescript/module/sqlite/nitro.d.ts +0 -7
- package/lib/typescript/module/sqlite/op.d.ts +0 -8
- package/lib/typescript/module/sqlite/quick.d.ts +0 -4
- package/lib/typescript/module/sqlite/storage.d.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority-technologies/mobile-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -71,44 +71,14 @@
|
|
|
71
71
|
"default": "./lib/commonjs/download/index.js"
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"./
|
|
74
|
+
"./smsRetriever": {
|
|
75
75
|
"import": {
|
|
76
|
-
"types": "./lib/typescript/module/
|
|
77
|
-
"default": "./lib/module/
|
|
76
|
+
"types": "./lib/typescript/module/smsRetriever/index.d.ts",
|
|
77
|
+
"default": "./lib/module/smsRetriever/index.js"
|
|
78
78
|
},
|
|
79
79
|
"require": {
|
|
80
|
-
"types": "./lib/typescript/commonjs/
|
|
81
|
-
"default": "./lib/commonjs/
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"./sqlite/nitro": {
|
|
85
|
-
"import": {
|
|
86
|
-
"types": "./lib/typescript/module/sqlite/nitro.d.ts",
|
|
87
|
-
"default": "./lib/module/sqlite/nitro.js"
|
|
88
|
-
},
|
|
89
|
-
"require": {
|
|
90
|
-
"types": "./lib/typescript/commonjs/sqlite/nitro.d.ts",
|
|
91
|
-
"default": "./lib/commonjs/sqlite/nitro.js"
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
"./sqlite/quick": {
|
|
95
|
-
"import": {
|
|
96
|
-
"types": "./lib/typescript/module/sqlite/quick.d.ts",
|
|
97
|
-
"default": "./lib/module/sqlite/quick.js"
|
|
98
|
-
},
|
|
99
|
-
"require": {
|
|
100
|
-
"types": "./lib/typescript/commonjs/sqlite/quick.d.ts",
|
|
101
|
-
"default": "./lib/commonjs/sqlite/quick.js"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"./sqlite/storage": {
|
|
105
|
-
"import": {
|
|
106
|
-
"types": "./lib/typescript/module/sqlite/storage.d.ts",
|
|
107
|
-
"default": "./lib/module/sqlite/storage.js"
|
|
108
|
-
},
|
|
109
|
-
"require": {
|
|
110
|
-
"types": "./lib/typescript/commonjs/sqlite/storage.d.ts",
|
|
111
|
-
"default": "./lib/commonjs/sqlite/storage.js"
|
|
80
|
+
"types": "./lib/typescript/commonjs/smsRetriever/index.d.ts",
|
|
81
|
+
"default": "./lib/commonjs/smsRetriever/index.js"
|
|
112
82
|
}
|
|
113
83
|
},
|
|
114
84
|
"./package.json": "./package.json"
|
|
@@ -119,11 +89,20 @@
|
|
|
119
89
|
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
120
90
|
"files": [
|
|
121
91
|
"lib",
|
|
92
|
+
"android",
|
|
122
93
|
"!**/__tests__",
|
|
123
94
|
"!**/*.test.*",
|
|
124
95
|
"!**/*.spec.*",
|
|
125
96
|
"!**/*.map"
|
|
126
97
|
],
|
|
98
|
+
"codegenConfig": {
|
|
99
|
+
"name": "RNMobileCoreSmsRetrieverSpec",
|
|
100
|
+
"type": "modules",
|
|
101
|
+
"jsSrcsDir": "./src/specs",
|
|
102
|
+
"android": {
|
|
103
|
+
"javaPackageName": "com.webority.mobilecore.smsretriever"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
127
106
|
"scripts": {
|
|
128
107
|
"build": "bob build",
|
|
129
108
|
"clean": "rimraf lib",
|
|
@@ -137,36 +116,40 @@
|
|
|
137
116
|
"libphonenumber-js": "^1.12.41"
|
|
138
117
|
},
|
|
139
118
|
"peerDependencies": {
|
|
140
|
-
"@op-engineering/op-sqlite": "*",
|
|
141
119
|
"expo": ">=57.0.0",
|
|
142
120
|
"expo-application": ">=57.0.0",
|
|
121
|
+
"expo-calendar": ">=57.0.0",
|
|
122
|
+
"expo-camera": ">=57.0.0",
|
|
123
|
+
"expo-contacts": ">=57.0.0",
|
|
143
124
|
"expo-file-system": ">=57.0.0",
|
|
144
125
|
"expo-image-manipulator": ">=57.0.0",
|
|
126
|
+
"expo-image-picker": ">=57.0.0",
|
|
145
127
|
"expo-location": ">=57.0.0",
|
|
128
|
+
"expo-media-library": ">=57.0.0",
|
|
146
129
|
"expo-network": ">=57.0.0",
|
|
130
|
+
"expo-notifications": ">=57.0.0",
|
|
147
131
|
"expo-secure-store": ">=57.0.0",
|
|
148
132
|
"expo-sqlite": ">=57.0.0",
|
|
149
133
|
"react": "^19.1.0",
|
|
150
|
-
"react-native": ">=0.81.0"
|
|
151
|
-
"react-native-nitro-sqlite": "*",
|
|
152
|
-
"react-native-permissions": ">=4.0.0",
|
|
153
|
-
"react-native-quick-sqlite": "*",
|
|
154
|
-
"react-native-sqlite-storage": "*"
|
|
134
|
+
"react-native": ">=0.81.0"
|
|
155
135
|
},
|
|
156
136
|
"peerDependenciesMeta": {
|
|
157
|
-
"
|
|
137
|
+
"expo-calendar": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"expo-camera": {
|
|
158
141
|
"optional": true
|
|
159
142
|
},
|
|
160
|
-
"
|
|
143
|
+
"expo-contacts": {
|
|
161
144
|
"optional": true
|
|
162
145
|
},
|
|
163
|
-
"
|
|
146
|
+
"expo-image-picker": {
|
|
164
147
|
"optional": true
|
|
165
148
|
},
|
|
166
|
-
"
|
|
149
|
+
"expo-media-library": {
|
|
167
150
|
"optional": true
|
|
168
151
|
},
|
|
169
|
-
"
|
|
152
|
+
"expo-notifications": {
|
|
170
153
|
"optional": true
|
|
171
154
|
}
|
|
172
155
|
},
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.adaptOpSqlite = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @op-engineering/op-sqlite. Shape verified against 18.1.4 rather than assumed:
|
|
9
|
-
* `open({ name, location })` is synchronous and returns a DB whose `execute` is
|
|
10
|
-
* ASYNC, and whose `rows` is already a plain array of objects rather than the
|
|
11
|
-
* `{ _array, item() }` shape the older drivers use. Both differences are why it
|
|
12
|
-
* cannot share the sync adapter.
|
|
13
|
-
*
|
|
14
|
-
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const adaptOpSqlite = mod => ({
|
|
18
|
-
open: async (name, options) => {
|
|
19
|
-
const db = mod.open({
|
|
20
|
-
name,
|
|
21
|
-
location: options?.location
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
execute: async (sql, params) => {
|
|
25
|
-
const result = await db.execute(sql, params ? [...params] : undefined);
|
|
26
|
-
return {
|
|
27
|
-
rows: result.rows ?? [],
|
|
28
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
29
|
-
insertId: result.insertId
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
close: async () => {
|
|
33
|
-
if (db.closeAsync) {
|
|
34
|
-
await db.closeAsync();
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
db.close();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
exports.adaptOpSqlite = adaptOpSqlite;
|
|
43
|
-
//# sourceMappingURL=op.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.rowsToArray = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Row shapes differ per driver: a plain array, `{ _array, length, item() }`, or
|
|
9
|
-
* `{ length, item() }` alone. Every adapter normalises to a plain array here so
|
|
10
|
-
* nothing driver-specific escapes into the Db layer.
|
|
11
|
-
*/
|
|
12
|
-
const rowsToArray = rows => {
|
|
13
|
-
if (Array.isArray(rows)) {
|
|
14
|
-
return rows;
|
|
15
|
-
}
|
|
16
|
-
const shaped = rows;
|
|
17
|
-
if (!shaped) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(shaped._array)) {
|
|
21
|
-
return shaped._array;
|
|
22
|
-
}
|
|
23
|
-
if (typeof shaped.item === 'function' && typeof shaped.length === 'number') {
|
|
24
|
-
const out = [];
|
|
25
|
-
for (let i = 0; i < shaped.length; i += 1) {
|
|
26
|
-
out.push(shaped.item(i));
|
|
27
|
-
}
|
|
28
|
-
return out;
|
|
29
|
-
}
|
|
30
|
-
return [];
|
|
31
|
-
};
|
|
32
|
-
exports.rowsToArray = rowsToArray;
|
|
33
|
-
//# sourceMappingURL=rows.js.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.adaptSqliteStorage = void 0;
|
|
7
|
-
var _rows = require("./rows.js");
|
|
8
|
-
/** react-native-sqlite-storage: callback-based by default, promise-based once
|
|
9
|
-
* `enablePromise(true)` is called; `executeSql` resolves an array whose first
|
|
10
|
-
* element is the result set. */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Adapt an already-required `react-native-sqlite-storage` module. Exported for
|
|
14
|
-
* the same reason as the filesystem adapters: the library cannot name a package
|
|
15
|
-
* the app did not install without breaking the app's bundle.
|
|
16
|
-
*/
|
|
17
|
-
const adaptSqliteStorage = mod => ({
|
|
18
|
-
open: async (name, options) => {
|
|
19
|
-
// This is a GLOBAL side effect, not a per-connection setting: the vendor
|
|
20
|
-
// implements it by rewriting SQLitePlugin and SQLiteFactory prototype
|
|
21
|
-
// methods. An app that also uses react-native-sqlite-storage directly in
|
|
22
|
-
// callback mode will find its own callbacks converted to promises from the
|
|
23
|
-
// moment this adapter opens a database. Unavoidable, since the adapter
|
|
24
|
-
// cannot work otherwise, and worth knowing before mixing the two.
|
|
25
|
-
mod.enablePromise(true);
|
|
26
|
-
const db = await mod.openDatabase({
|
|
27
|
-
name,
|
|
28
|
-
location: options?.location ?? 'default'
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
execute: async (sql, params) => {
|
|
32
|
-
const [result] = await db.executeSql(sql, params ? [...params] : undefined);
|
|
33
|
-
return {
|
|
34
|
-
rows: (0, _rows.rowsToArray)(result.rows),
|
|
35
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
36
|
-
insertId: result.insertId
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
// Not `() => db.close()`: in promise mode this driver resolves the
|
|
40
|
-
// success-callback ARGUMENTS array rather than void, so returning it
|
|
41
|
-
// directly would make SqliteDatabase.close() resolve an array while
|
|
42
|
-
// typed as void. Awaiting and discarding makes the type honest.
|
|
43
|
-
close: async () => {
|
|
44
|
-
await db.close();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
exports.adaptSqliteStorage = adaptSqliteStorage;
|
|
50
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.adaptSyncSqlite = void 0;
|
|
7
|
-
var _rows = require("./rows.js");
|
|
8
|
-
/**
|
|
9
|
-
* nitro-sqlite and quick-sqlite share one synchronous shape, so one adapter
|
|
10
|
-
* serves both. The REQUIRE lives in the driver entry points beside this file,
|
|
11
|
-
* never here and never in the core: Metro resolves requires statically, so a
|
|
12
|
-
* package named anywhere reachable becomes mandatory for every consumer.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** Shape shared by react-native-nitro-sqlite and react-native-quick-sqlite: a
|
|
16
|
-
* synchronous `open({ name, location })` whose `db.execute()` and `db.close()`
|
|
17
|
-
* are also synchronous. Both are wrapped in Promise.resolve to fit SqliteDriver. */
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Adapt an already-required nitro-sqlite or quick-sqlite module. Both expose the
|
|
21
|
-
* same synchronous shape. Exported so an app on quick-sqlite can inject it.
|
|
22
|
-
*/
|
|
23
|
-
const adaptSyncSqlite = mod => ({
|
|
24
|
-
open: async (name, options) => {
|
|
25
|
-
const db = mod.open({
|
|
26
|
-
name,
|
|
27
|
-
location: options?.location
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
execute: async (sql, params) => {
|
|
31
|
-
const result = db.execute(sql, params ? [...params] : undefined);
|
|
32
|
-
return {
|
|
33
|
-
rows: (0, _rows.rowsToArray)(result.rows),
|
|
34
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
35
|
-
insertId: result.insertId
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
close: async () => {
|
|
39
|
-
db.close();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
exports.adaptSyncSqlite = adaptSyncSqlite;
|
|
45
|
-
//# sourceMappingURL=sync.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.nitroSqliteDriver = void 0;
|
|
7
|
-
var _sync = require("./adapters/sync.js");
|
|
8
|
-
/**
|
|
9
|
-
* The one place `react-native-nitro-sqlite` is named. Import this module only if
|
|
10
|
-
* you installed it; nothing else in the library reaches it.
|
|
11
|
-
*/
|
|
12
|
-
const nitroSqliteDriver = () => {
|
|
13
|
-
const mod = require('react-native-nitro-sqlite');
|
|
14
|
-
return (0, _sync.adaptSyncSqlite)(mod.default ?? mod);
|
|
15
|
-
};
|
|
16
|
-
exports.nitroSqliteDriver = nitroSqliteDriver;
|
|
17
|
-
//# sourceMappingURL=nitro.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.opSqliteDriver = void 0;
|
|
7
|
-
var _op = require("./adapters/op.js");
|
|
8
|
-
/**
|
|
9
|
-
* The one place `@op-engineering/op-sqlite` is named. It is the driver we
|
|
10
|
-
* recommend: the most actively maintained of the four, and the only one already
|
|
11
|
-
* proven in one of our apps. Import this module only if you installed it.
|
|
12
|
-
*/
|
|
13
|
-
const opSqliteDriver = () => {
|
|
14
|
-
const mod = require('@op-engineering/op-sqlite');
|
|
15
|
-
return (0, _op.adaptOpSqlite)(mod.default ?? mod);
|
|
16
|
-
};
|
|
17
|
-
exports.opSqliteDriver = opSqliteDriver;
|
|
18
|
-
//# sourceMappingURL=op.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.quickSqliteDriver = void 0;
|
|
7
|
-
var _sync = require("./adapters/sync.js");
|
|
8
|
-
/** The one place `react-native-quick-sqlite` is named. */
|
|
9
|
-
const quickSqliteDriver = () => {
|
|
10
|
-
const mod = require('react-native-quick-sqlite');
|
|
11
|
-
return (0, _sync.adaptSyncSqlite)(mod.default ?? mod);
|
|
12
|
-
};
|
|
13
|
-
exports.quickSqliteDriver = quickSqliteDriver;
|
|
14
|
-
//# sourceMappingURL=quick.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sqliteStorageDriver = void 0;
|
|
7
|
-
var _storage = require("./adapters/storage.js");
|
|
8
|
-
/** The one place `react-native-sqlite-storage` is named. */
|
|
9
|
-
const sqliteStorageDriver = () => {
|
|
10
|
-
const mod = require('react-native-sqlite-storage');
|
|
11
|
-
return (0, _storage.adaptSqliteStorage)(mod.default ?? mod);
|
|
12
|
-
};
|
|
13
|
-
exports.sqliteStorageDriver = sqliteStorageDriver;
|
|
14
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @op-engineering/op-sqlite. Shape verified against 18.1.4 rather than assumed:
|
|
5
|
-
* `open({ name, location })` is synchronous and returns a DB whose `execute` is
|
|
6
|
-
* ASYNC, and whose `rows` is already a plain array of objects rather than the
|
|
7
|
-
* `{ _array, item() }` shape the older drivers use. Both differences are why it
|
|
8
|
-
* cannot share the sync adapter.
|
|
9
|
-
*
|
|
10
|
-
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export const adaptOpSqlite = mod => ({
|
|
14
|
-
open: async (name, options) => {
|
|
15
|
-
const db = mod.open({
|
|
16
|
-
name,
|
|
17
|
-
location: options?.location
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
execute: async (sql, params) => {
|
|
21
|
-
const result = await db.execute(sql, params ? [...params] : undefined);
|
|
22
|
-
return {
|
|
23
|
-
rows: result.rows ?? [],
|
|
24
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
25
|
-
insertId: result.insertId
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
close: async () => {
|
|
29
|
-
if (db.closeAsync) {
|
|
30
|
-
await db.closeAsync();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
db.close();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=op.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Row shapes differ per driver: a plain array, `{ _array, length, item() }`, or
|
|
5
|
-
* `{ length, item() }` alone. Every adapter normalises to a plain array here so
|
|
6
|
-
* nothing driver-specific escapes into the Db layer.
|
|
7
|
-
*/
|
|
8
|
-
export const rowsToArray = rows => {
|
|
9
|
-
if (Array.isArray(rows)) {
|
|
10
|
-
return rows;
|
|
11
|
-
}
|
|
12
|
-
const shaped = rows;
|
|
13
|
-
if (!shaped) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(shaped._array)) {
|
|
17
|
-
return shaped._array;
|
|
18
|
-
}
|
|
19
|
-
if (typeof shaped.item === 'function' && typeof shaped.length === 'number') {
|
|
20
|
-
const out = [];
|
|
21
|
-
for (let i = 0; i < shaped.length; i += 1) {
|
|
22
|
-
out.push(shaped.item(i));
|
|
23
|
-
}
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
return [];
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=rows.js.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { rowsToArray } from "./rows.js";
|
|
4
|
-
|
|
5
|
-
/** react-native-sqlite-storage: callback-based by default, promise-based once
|
|
6
|
-
* `enablePromise(true)` is called; `executeSql` resolves an array whose first
|
|
7
|
-
* element is the result set. */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Adapt an already-required `react-native-sqlite-storage` module. Exported for
|
|
11
|
-
* the same reason as the filesystem adapters: the library cannot name a package
|
|
12
|
-
* the app did not install without breaking the app's bundle.
|
|
13
|
-
*/
|
|
14
|
-
export const adaptSqliteStorage = mod => ({
|
|
15
|
-
open: async (name, options) => {
|
|
16
|
-
// This is a GLOBAL side effect, not a per-connection setting: the vendor
|
|
17
|
-
// implements it by rewriting SQLitePlugin and SQLiteFactory prototype
|
|
18
|
-
// methods. An app that also uses react-native-sqlite-storage directly in
|
|
19
|
-
// callback mode will find its own callbacks converted to promises from the
|
|
20
|
-
// moment this adapter opens a database. Unavoidable, since the adapter
|
|
21
|
-
// cannot work otherwise, and worth knowing before mixing the two.
|
|
22
|
-
mod.enablePromise(true);
|
|
23
|
-
const db = await mod.openDatabase({
|
|
24
|
-
name,
|
|
25
|
-
location: options?.location ?? 'default'
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
execute: async (sql, params) => {
|
|
29
|
-
const [result] = await db.executeSql(sql, params ? [...params] : undefined);
|
|
30
|
-
return {
|
|
31
|
-
rows: rowsToArray(result.rows),
|
|
32
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
33
|
-
insertId: result.insertId
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
// Not `() => db.close()`: in promise mode this driver resolves the
|
|
37
|
-
// success-callback ARGUMENTS array rather than void, so returning it
|
|
38
|
-
// directly would make SqliteDatabase.close() resolve an array while
|
|
39
|
-
// typed as void. Awaiting and discarding makes the type honest.
|
|
40
|
-
close: async () => {
|
|
41
|
-
await db.close();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { rowsToArray } from "./rows.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* nitro-sqlite and quick-sqlite share one synchronous shape, so one adapter
|
|
7
|
-
* serves both. The REQUIRE lives in the driver entry points beside this file,
|
|
8
|
-
* never here and never in the core: Metro resolves requires statically, so a
|
|
9
|
-
* package named anywhere reachable becomes mandatory for every consumer.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** Shape shared by react-native-nitro-sqlite and react-native-quick-sqlite: a
|
|
13
|
-
* synchronous `open({ name, location })` whose `db.execute()` and `db.close()`
|
|
14
|
-
* are also synchronous. Both are wrapped in Promise.resolve to fit SqliteDriver. */
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Adapt an already-required nitro-sqlite or quick-sqlite module. Both expose the
|
|
18
|
-
* same synchronous shape. Exported so an app on quick-sqlite can inject it.
|
|
19
|
-
*/
|
|
20
|
-
export const adaptSyncSqlite = mod => ({
|
|
21
|
-
open: async (name, options) => {
|
|
22
|
-
const db = mod.open({
|
|
23
|
-
name,
|
|
24
|
-
location: options?.location
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
execute: async (sql, params) => {
|
|
28
|
-
const result = db.execute(sql, params ? [...params] : undefined);
|
|
29
|
-
return {
|
|
30
|
-
rows: rowsToArray(result.rows),
|
|
31
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
32
|
-
insertId: result.insertId
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
close: async () => {
|
|
36
|
-
db.close();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=sync.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { adaptSyncSqlite } from "./adapters/sync.js";
|
|
4
|
-
/**
|
|
5
|
-
* The one place `react-native-nitro-sqlite` is named. Import this module only if
|
|
6
|
-
* you installed it; nothing else in the library reaches it.
|
|
7
|
-
*/
|
|
8
|
-
export const nitroSqliteDriver = () => {
|
|
9
|
-
const mod = require('react-native-nitro-sqlite');
|
|
10
|
-
return adaptSyncSqlite(mod.default ?? mod);
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=nitro.js.map
|
package/lib/module/sqlite/op.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { adaptOpSqlite } from "./adapters/op.js";
|
|
4
|
-
/**
|
|
5
|
-
* The one place `@op-engineering/op-sqlite` is named. It is the driver we
|
|
6
|
-
* recommend: the most actively maintained of the four, and the only one already
|
|
7
|
-
* proven in one of our apps. Import this module only if you installed it.
|
|
8
|
-
*/
|
|
9
|
-
export const opSqliteDriver = () => {
|
|
10
|
-
const mod = require('@op-engineering/op-sqlite');
|
|
11
|
-
return adaptOpSqlite(mod.default ?? mod);
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=op.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { adaptSyncSqlite } from "./adapters/sync.js";
|
|
4
|
-
/** The one place `react-native-quick-sqlite` is named. */
|
|
5
|
-
export const quickSqliteDriver = () => {
|
|
6
|
-
const mod = require('react-native-quick-sqlite');
|
|
7
|
-
return adaptSyncSqlite(mod.default ?? mod);
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=quick.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { adaptSqliteStorage } from "./adapters/storage.js";
|
|
4
|
-
/** The one place `react-native-sqlite-storage` is named. */
|
|
5
|
-
export const sqliteStorageDriver = () => {
|
|
6
|
-
const mod = require('react-native-sqlite-storage');
|
|
7
|
-
return adaptSqliteStorage(mod.default ?? mod);
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { SqliteDriver } from '../index';
|
|
2
|
-
/**
|
|
3
|
-
* @op-engineering/op-sqlite. Shape verified against 18.1.4 rather than assumed:
|
|
4
|
-
* `open({ name, location })` is synchronous and returns a DB whose `execute` is
|
|
5
|
-
* ASYNC, and whose `rows` is already a plain array of objects rather than the
|
|
6
|
-
* `{ _array, item() }` shape the older drivers use. Both differences are why it
|
|
7
|
-
* cannot share the sync adapter.
|
|
8
|
-
*
|
|
9
|
-
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
10
|
-
*/
|
|
11
|
-
export interface OpSqliteQueryResult {
|
|
12
|
-
rows?: Record<string, unknown>[];
|
|
13
|
-
rowsAffected?: number;
|
|
14
|
-
insertId?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface OpSqliteModuleLike {
|
|
17
|
-
open: (options: {
|
|
18
|
-
name: string;
|
|
19
|
-
location?: string;
|
|
20
|
-
}) => {
|
|
21
|
-
execute: (sql: string, params?: unknown[]) => Promise<OpSqliteQueryResult>;
|
|
22
|
-
close: () => void;
|
|
23
|
-
closeAsync?: () => Promise<void>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export declare const adaptOpSqlite: (mod: OpSqliteModuleLike) => SqliteDriver;
|
|
27
|
-
//# sourceMappingURL=op.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Row shapes differ per driver: a plain array, `{ _array, length, item() }`, or
|
|
3
|
-
* `{ length, item() }` alone. Every adapter normalises to a plain array here so
|
|
4
|
-
* nothing driver-specific escapes into the Db layer.
|
|
5
|
-
*/
|
|
6
|
-
export declare const rowsToArray: (rows: unknown) => Record<string, unknown>[];
|
|
7
|
-
//# sourceMappingURL=rows.d.ts.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { SqliteDriver } from '../index';
|
|
2
|
-
interface SqliteStorageResultSet {
|
|
3
|
-
rows: {
|
|
4
|
-
length: number;
|
|
5
|
-
item: (i: number) => Record<string, unknown>;
|
|
6
|
-
};
|
|
7
|
-
rowsAffected: number;
|
|
8
|
-
insertId?: number;
|
|
9
|
-
}
|
|
10
|
-
/** react-native-sqlite-storage: callback-based by default, promise-based once
|
|
11
|
-
* `enablePromise(true)` is called; `executeSql` resolves an array whose first
|
|
12
|
-
* element is the result set. */
|
|
13
|
-
interface SqliteStorageModuleLike {
|
|
14
|
-
enablePromise: (enabled: boolean) => void;
|
|
15
|
-
openDatabase: (options: {
|
|
16
|
-
name: string;
|
|
17
|
-
location?: string;
|
|
18
|
-
}) => Promise<{
|
|
19
|
-
executeSql: (sql: string, params?: unknown[]) => Promise<[SqliteStorageResultSet]>;
|
|
20
|
-
close: () => Promise<void>;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Adapt an already-required `react-native-sqlite-storage` module. Exported for
|
|
25
|
-
* the same reason as the filesystem adapters: the library cannot name a package
|
|
26
|
-
* the app did not install without breaking the app's bundle.
|
|
27
|
-
*/
|
|
28
|
-
export declare const adaptSqliteStorage: (mod: SqliteStorageModuleLike) => SqliteDriver;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=storage.d.ts.map
|