stream-chat-react-native-core 5.14.0-beta.1 → 5.14.0-beta.3

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.
@@ -3,7 +3,6 @@ import type { PreparedQueries } from './types';
3
3
  * QuickSqliteClient takes care of any direct interaction with sqlite.
4
4
  * This way usage react-native-quick-sqlite package is scoped to a single class/file.
5
5
  *
6
- * TODO: Drop the support for v4 of react-native-quick-sqlite in the next major release.
7
6
  */
8
7
  export declare class QuickSqliteClient {
9
8
  static dbVersion: number;
@@ -11,11 +10,10 @@ export declare class QuickSqliteClient {
11
10
  static dbLocation: string;
12
11
  static getDbVersion: () => number;
13
12
  static setDbVersion: (version: number) => number;
14
- static isQuickSqliteV4: boolean;
15
13
  static openDB: () => void;
16
14
  static closeDB: () => void;
17
15
  static executeSqlBatch: (queries: PreparedQueries[]) => void;
18
- static executeSql: (query: string, params?: string[] | undefined) => any;
16
+ static executeSql: (query: string, params?: string[] | undefined) => any[];
19
17
  static dropTables: () => void;
20
18
  static deleteDatabase: () => boolean;
21
19
  static initializeDatabase: () => void;
@@ -1,3 +1,3 @@
1
1
  export declare const getPendingTasks: (conditions?: {
2
2
  messageId?: string;
3
- }) => any;
3
+ }) => import("../types").PendingTask[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.14.0-beta.1",
4
+ "version": "5.14.0-beta.3",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -82,7 +82,13 @@
82
82
  "stream-chat": "8.2.1"
83
83
  },
84
84
  "peerDependencies": {
85
- "react-native-svg": ">=12.1.0"
85
+ "react-native-svg": ">=12.1.0",
86
+ "react-native-quick-sqlite": ">=5.1.0"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "react-native-quick-sqlite": {
90
+ "optional": true
91
+ }
86
92
  },
87
93
  "devDependencies": {
88
94
  "@babel/cli": "^7.12.17",
@@ -487,6 +487,8 @@ export const MessageInputProvider = <
487
487
  }
488
488
 
489
489
  const imagesAndFiles = [...imageUploads, ...fileUploads];
490
+ if (imagesAndFiles.length === 0) return false;
491
+
490
492
  if (enableOfflineSupport) {
491
493
  // Allow only if none of the attachments have unsupported status
492
494
  for (const file of imagesAndFiles) {
@@ -5,13 +5,19 @@ let sqlite: typeof QuickSQLite;
5
5
  try {
6
6
  sqlite = require('react-native-quick-sqlite').QuickSQLite;
7
7
  } catch (e) {
8
- // Failed for one of the reason
9
- // 1. Running on expo, where we don't support offline storage yet.
8
+ // We want to throw the original error when remote debugger (e.g. Chrome) is enabled.
9
+ // QuickSQLite can only be used when synchronous method invocations (JSI) are possible.
10
+ // e.g on-device debugger (e.g. Flipper).
11
+ const isRemoteDebuggerError = e instanceof Error && e.message.includes('Failed to install');
12
+ if (isRemoteDebuggerError) {
13
+ throw e;
14
+ }
15
+ // Reaching here will mean that QuickSQLite is not installed for one of the reasons
16
+ // 1. Running on regular expo, where we don't support offline storage yet.
10
17
  // 2. Offline support is disabled, in which case this library is not installed.
11
18
  }
12
19
 
13
20
  import { DB_LOCATION, DB_NAME } from './constants';
14
- import { QuickSqliteClient_v4 } from './QuickSqliteClient_v4';
15
21
  import { tables } from './schema';
16
22
  import { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';
17
23
  import type { PreparedQueries, Table } from './types';
@@ -20,7 +26,6 @@ import type { PreparedQueries, Table } from './types';
20
26
  * QuickSqliteClient takes care of any direct interaction with sqlite.
21
27
  * This way usage react-native-quick-sqlite package is scoped to a single class/file.
22
28
  *
23
- * TODO: Drop the support for v4 of react-native-quick-sqlite in the next major release.
24
29
  */
25
30
  export class QuickSqliteClient {
26
31
  static dbVersion = 3;
@@ -28,73 +33,50 @@ export class QuickSqliteClient {
28
33
  static dbName = DB_NAME;
29
34
  static dbLocation = DB_LOCATION;
30
35
 
31
- static getDbVersion = () => this.dbVersion;
36
+ static getDbVersion = () => QuickSqliteClient.dbVersion;
32
37
  // Force a specific db version. This is mainly useful for testsuit.
33
- static setDbVersion = (version: number) => (this.dbVersion = version);
38
+ static setDbVersion = (version: number) => (QuickSqliteClient.dbVersion = version);
34
39
 
35
- // @ts-ignore
36
- static isQuickSqliteV4 = sqlite?.executeSql ? true : false;
37
-
38
- // print if legacy version
39
40
  static openDB = () => {
40
- if (this.isQuickSqliteV4) {
41
- QuickSqliteClient_v4.openDB();
42
- return;
43
- }
44
-
45
41
  try {
46
- sqlite.open(this.dbName, this.dbLocation);
47
- sqlite.execute(this.dbName, `PRAGMA foreign_keys = ON`, []);
42
+ sqlite.open(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
43
+ sqlite.execute(QuickSqliteClient.dbName, `PRAGMA foreign_keys = ON`, []);
48
44
  } catch (e) {
49
- console.error(`Error opening database ${this.dbName}: ${e}`);
45
+ console.error(`Error opening database ${QuickSqliteClient.dbName}: ${e}`);
50
46
  }
51
47
  };
52
48
 
53
49
  static closeDB = () => {
54
- if (this.isQuickSqliteV4) {
55
- QuickSqliteClient_v4.closeDB();
56
- return;
57
- }
58
-
59
50
  try {
60
- sqlite.close(this.dbName);
51
+ sqlite.close(QuickSqliteClient.dbName);
61
52
  } catch (e) {
62
- console.error(`Error closing database ${this.dbName}: ${e}`);
53
+ console.error(`Error closing database ${QuickSqliteClient.dbName}: ${e}`);
63
54
  }
64
55
  };
65
56
 
66
57
  static executeSqlBatch = (queries: PreparedQueries[]) => {
67
58
  if (!queries || !queries.length) return;
68
59
 
69
- if (this.isQuickSqliteV4) {
70
- QuickSqliteClient_v4.executeSqlBatch(queries);
71
- return;
72
- }
73
-
74
- this.openDB();
60
+ QuickSqliteClient.openDB();
75
61
  try {
76
62
  sqlite.executeBatch(DB_NAME, queries);
77
63
 
78
- this.closeDB();
64
+ QuickSqliteClient.closeDB();
79
65
  } catch (e) {
80
- this.closeDB();
66
+ QuickSqliteClient.closeDB();
81
67
  throw new Error(`Query/queries failed: ${e}`);
82
68
  }
83
69
  };
84
70
 
85
71
  static executeSql = (query: string, params?: string[]) => {
86
- if (this.isQuickSqliteV4) {
87
- return QuickSqliteClient_v4.executeSql(query, params);
88
- }
89
-
90
72
  try {
91
- this.openDB();
73
+ QuickSqliteClient.openDB();
92
74
  const { rows } = sqlite.execute(DB_NAME, query, params);
93
- this.closeDB();
75
+ QuickSqliteClient.closeDB();
94
76
 
95
77
  return rows ? rows._array : [];
96
78
  } catch (e) {
97
- this.closeDB();
79
+ QuickSqliteClient.closeDB();
98
80
  throw new Error(`Query/queries failed: ${e}: `);
99
81
  }
100
82
  };
@@ -105,16 +87,12 @@ export class QuickSqliteClient {
105
87
  [],
106
88
  ]);
107
89
 
108
- this.executeSqlBatch(queries);
90
+ QuickSqliteClient.executeSqlBatch(queries);
109
91
  };
110
92
 
111
93
  static deleteDatabase = () => {
112
- if (this.isQuickSqliteV4) {
113
- return QuickSqliteClient_v4.deleteDatabase();
114
- }
115
-
116
94
  try {
117
- sqlite.delete(this.dbName, this.dbLocation);
95
+ sqlite.delete(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
118
96
  } catch (e) {
119
97
  throw new Error(`Error deleting DB: ${e}`);
120
98
  }
@@ -123,26 +101,17 @@ export class QuickSqliteClient {
123
101
  };
124
102
 
125
103
  static initializeDatabase = () => {
126
- // @ts-ignore
127
104
  if (sqlite === undefined) {
128
105
  throw new Error(
129
106
  'Please install "react-native-quick-sqlite" package to enable offline support',
130
107
  );
131
108
  }
132
109
 
133
- if (this.isQuickSqliteV4) {
134
- console.warn(
135
- 'You seem to be using an older version of "react-native-quick-sqlite" dependency,',
136
- 'and we are going to drop support for it in the next major release.',
137
- 'Please upgrade to the version v5 of "react-native-quick-sqlite" to avoid any issues.',
138
- );
139
- }
140
-
141
- const version = this.getUserPragmaVersion();
110
+ const version = QuickSqliteClient.getUserPragmaVersion();
142
111
 
143
- if (version !== this.dbVersion) {
144
- this.dropTables();
145
- this.updateUserPragmaVersion(this.dbVersion);
112
+ if (version !== QuickSqliteClient.dbVersion) {
113
+ QuickSqliteClient.dropTables();
114
+ QuickSqliteClient.updateUserPragmaVersion(QuickSqliteClient.dbVersion);
146
115
  }
147
116
  const q = (Object.keys(tables) as Table[]).reduce<PreparedQueries[]>(
148
117
  (queriesSoFar, tableName) => {
@@ -152,39 +121,30 @@ export class QuickSqliteClient {
152
121
  [],
153
122
  );
154
123
 
155
- this.executeSqlBatch(q);
124
+ QuickSqliteClient.executeSqlBatch(q);
156
125
  };
157
126
 
158
127
  static updateUserPragmaVersion = (version: number) => {
159
- if (this.isQuickSqliteV4) {
160
- QuickSqliteClient_v4.updateUserPragmaVersion(version);
161
- return;
162
- }
163
-
164
- this.openDB();
128
+ QuickSqliteClient.openDB();
165
129
  sqlite.execute(DB_NAME, `PRAGMA user_version = ${version}`, []);
166
- this.closeDB();
130
+ QuickSqliteClient.closeDB();
167
131
  };
168
132
 
169
133
  static getUserPragmaVersion = () => {
170
- if (this.isQuickSqliteV4) {
171
- return QuickSqliteClient_v4.getUserPragmaVersion();
172
- }
173
-
174
- this.openDB();
134
+ QuickSqliteClient.openDB();
175
135
  try {
176
136
  const { rows } = sqlite.execute(DB_NAME, `PRAGMA user_version`, []);
177
137
  const result = rows ? rows._array : [];
178
- this.closeDB();
138
+ QuickSqliteClient.closeDB();
179
139
  return result[0].user_version as number;
180
140
  } catch (e) {
181
- this.closeDB();
141
+ QuickSqliteClient.closeDB();
182
142
  throw new Error(`Querying for user_version failed: ${e}`);
183
143
  }
184
144
  };
185
145
 
186
146
  static resetDB = () => {
187
- this.dropTables();
188
- this.initializeDatabase();
147
+ QuickSqliteClient.dropTables();
148
+ QuickSqliteClient.initializeDatabase();
189
149
  };
190
150
  }
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.14.0-beta.1"
2
+ "version": "5.14.0-beta.3"
3
3
  }
@@ -1,83 +0,0 @@
1
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.QuickSqliteClient_v4 = void 0;
6
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
7
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
- var _constants = require("./constants");
9
- var sqlite;
10
- try {
11
- sqlite = require('react-native-quick-sqlite').QuickSQLite;
12
- } catch (e) {}
13
- var QuickSqliteClient_v4 = (0, _createClass2["default"])(function QuickSqliteClient_v4() {
14
- (0, _classCallCheck2["default"])(this, QuickSqliteClient_v4);
15
- });
16
- exports.QuickSqliteClient_v4 = QuickSqliteClient_v4;
17
- QuickSqliteClient_v4.dbName = _constants.DB_NAME;
18
- QuickSqliteClient_v4.dbLocation = _constants.DB_LOCATION;
19
- QuickSqliteClient_v4.openDB = function () {
20
- var _sqlite$open = sqlite.open(QuickSqliteClient_v4.dbName, QuickSqliteClient_v4.dbLocation),
21
- message = _sqlite$open.message,
22
- status = _sqlite$open.status;
23
- sqlite.executeSql(QuickSqliteClient_v4.dbName, "PRAGMA foreign_keys = ON", []);
24
- if (status === _constants.DB_STATUS_ERROR) {
25
- console.error("Error opening database " + QuickSqliteClient_v4.dbName + ": " + message);
26
- }
27
- };
28
- QuickSqliteClient_v4.closeDB = function () {
29
- var _sqlite$close = sqlite.close(QuickSqliteClient_v4.dbName),
30
- message = _sqlite$close.message,
31
- status = _sqlite$close.status;
32
- if (status === _constants.DB_STATUS_ERROR) {
33
- console.error("Error closing database " + QuickSqliteClient_v4.dbName + ": " + message);
34
- }
35
- };
36
- QuickSqliteClient_v4.executeSqlBatch = function (queries) {
37
- QuickSqliteClient_v4.openDB();
38
- var res = sqlite.executeSqlBatch(_constants.DB_NAME, queries);
39
- if (res.status === 1) {
40
- console.error("Query/queries failed: " + res.message + " " + JSON.stringify(res));
41
- }
42
- QuickSqliteClient_v4.closeDB();
43
- };
44
- QuickSqliteClient_v4.executeSql = function (query, params) {
45
- QuickSqliteClient_v4.openDB();
46
- var _sqlite$executeSql = sqlite.executeSql(_constants.DB_NAME, query, params),
47
- message = _sqlite$executeSql.message,
48
- rows = _sqlite$executeSql.rows,
49
- status = _sqlite$executeSql.status;
50
- QuickSqliteClient_v4.closeDB();
51
- if (status === 1) {
52
- console.error("Query/queries failed: " + message + ": ", query);
53
- }
54
- return rows ? rows._array : [];
55
- };
56
- QuickSqliteClient_v4.deleteDatabase = function () {
57
- var _sqlite$delete = sqlite["delete"](QuickSqliteClient_v4.dbName, QuickSqliteClient_v4.dbLocation),
58
- message = _sqlite$delete.message,
59
- status = _sqlite$delete.status;
60
- if (status === _constants.DB_STATUS_ERROR) {
61
- throw new Error("Error deleting DB: " + message);
62
- }
63
- return true;
64
- };
65
- QuickSqliteClient_v4.updateUserPragmaVersion = function (version) {
66
- QuickSqliteClient_v4.openDB();
67
- sqlite.executeSql(_constants.DB_NAME, "PRAGMA user_version = " + version, []);
68
- QuickSqliteClient_v4.closeDB();
69
- };
70
- QuickSqliteClient_v4.getUserPragmaVersion = function () {
71
- QuickSqliteClient_v4.openDB();
72
- var _sqlite$executeSql2 = sqlite.executeSql(_constants.DB_NAME, "PRAGMA user_version", []),
73
- message = _sqlite$executeSql2.message,
74
- rows = _sqlite$executeSql2.rows,
75
- status = _sqlite$executeSql2.status;
76
- QuickSqliteClient_v4.closeDB();
77
- if (status === 1) {
78
- console.error("Querying for user_version failed: " + message);
79
- }
80
- var result = rows ? rows._array : [];
81
- return result[0].user_version;
82
- };
83
- //# sourceMappingURL=QuickSqliteClient_v4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_constants","require","sqlite","QuickSQLite","e","QuickSqliteClient_v4","_createClass2","_classCallCheck2","exports","dbName","DB_NAME","dbLocation","DB_LOCATION","openDB","_sqlite$open","open","message","status","executeSql","DB_STATUS_ERROR","console","error","closeDB","_sqlite$close","close","executeSqlBatch","queries","res","JSON","stringify","query","params","_sqlite$executeSql","rows","_array","deleteDatabase","_sqlite$delete","Error","updateUserPragmaVersion","version","getUserPragmaVersion","_sqlite$executeSql2","result","user_version"],"sources":["QuickSqliteClient_v4.ts"],"sourcesContent":["// We are going to disable type checks for this file, since this QuickSqliteClient is for legacy version of sqlite but\n// dev-dependency \"react-native-quick-sqlite\" is not available for legacy version of sqlite.\n/* eslint-disable no-underscore-dangle */\n// @ts-nocheck\n\nimport type { QuickSQLite } from 'react-native-quick-sqlite';\nlet sqlite: typeof QuickSQLite;\n\ntry {\n sqlite = require('react-native-quick-sqlite').QuickSQLite;\n} catch (e) {\n // Failed for one of the reason\n // 1. Running on expo, where we don't support offline storage yet.\n // 2. Offline support is disabled, in which case this library is not installed.\n}\nimport { DB_LOCATION, DB_NAME, DB_STATUS_ERROR } from './constants';\nimport type { PreparedQueries } from './types';\n\n// QuickSqliteClient takes care of any direct interaction with sqlite for v4 of react-native-quick-sqlite.\n// This is to avoid any breaking changes for users using v4 of react-native-quick-sqlite.\nexport class QuickSqliteClient_v4 {\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static openDB = () => {\n const { message, status } = sqlite.open(this.dbName, this.dbLocation);\n sqlite.executeSql(this.dbName, `PRAGMA foreign_keys = ON`, []);\n\n if (status === DB_STATUS_ERROR) {\n console.error(`Error opening database ${this.dbName}: ${message}`);\n }\n };\n\n static closeDB = () => {\n const { message, status } = sqlite.close(this.dbName);\n\n if (status === DB_STATUS_ERROR) {\n console.error(`Error closing database ${this.dbName}: ${message}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n this.openDB();\n\n const res = sqlite.executeSqlBatch(DB_NAME, queries);\n\n if (res.status === 1) {\n console.error(`Query/queries failed: ${res.message} ${JSON.stringify(res)}`);\n }\n\n this.closeDB();\n };\n\n static executeSql = (query: string, params?: string[]) => {\n this.openDB();\n\n const { message, rows, status } = sqlite.executeSql(DB_NAME, query, params);\n\n this.closeDB();\n\n if (status === 1) {\n console.error(`Query/queries failed: ${message}: `, query);\n }\n\n return rows ? rows._array : [];\n };\n\n static deleteDatabase = () => {\n const { message, status } = sqlite.delete(this.dbName, this.dbLocation);\n if (status === DB_STATUS_ERROR) {\n throw new Error(`Error deleting DB: ${message}`);\n }\n\n return true;\n };\n\n static updateUserPragmaVersion = (version: number) => {\n this.openDB();\n\n sqlite.executeSql(DB_NAME, `PRAGMA user_version = ${version}`, []);\n\n this.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n this.openDB();\n\n const { message, rows, status } = sqlite.executeSql(DB_NAME, `PRAGMA user_version`, []);\n\n this.closeDB();\n if (status === 1) {\n console.error(`Querying for user_version failed: ${message}`);\n }\n\n const result = rows ? rows._array : [];\n return result[0].user_version as number;\n };\n}\n"],"mappings":";;;;;;;AAeA,IAAAA,UAAA,GAAAC,OAAA;AATA,IAAIC,MAA0B;AAE9B,IAAI;EACFA,MAAM,GAAGD,OAAO,CAAC,2BAA2B,CAAC,CAACE,WAAW;AAC3D,CAAC,CAAC,OAAOC,CAAC,EAAE,CAIZ;AAAC,IAMYC,oBAAoB,OAAAC,aAAA,sBAAAD,qBAAA;EAAA,IAAAE,gBAAA,mBAAAF,oBAAA;AAAA;AAAAG,OAAA,CAAAH,oBAAA,GAAAA,oBAAA;AAApBA,oBAAoB,CACxBI,MAAM,GAAGC,kBAAO;AADZL,oBAAoB,CAExBM,UAAU,GAAGC,sBAAW;AAFpBP,oBAAoB,CAIxBQ,MAAM,GAAG,YAAM;EACpB,IAAAC,YAAA,GAA4BZ,MAAM,CAACa,IAAI,CAL9BV,oBAAoB,CAKgBI,MAAM,EAL1CJ,oBAAoB,CAK6BM,UAAU,CAAC;IAA7DK,OAAO,GAAAF,YAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,YAAA,CAANG,MAAM;EACvBf,MAAM,CAACgB,UAAU,CANRb,oBAAoB,CAMNI,MAAM,8BAA8B,EAAE,CAAC;EAE9D,IAAIQ,MAAM,KAAKE,0BAAe,EAAE;IAC9BC,OAAO,CAACC,KAAK,6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AE;EACtC,OAAOQ,MAAM,CAAC,CAAC,CAAC,CAACC,YAAY;AAC/B,CAAC"}
@@ -1,83 +0,0 @@
1
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.QuickSqliteClient_v4 = void 0;
6
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
7
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
- var _constants = require("./constants");
9
- var sqlite;
10
- try {
11
- sqlite = require('react-native-quick-sqlite').QuickSQLite;
12
- } catch (e) {}
13
- var QuickSqliteClient_v4 = (0, _createClass2["default"])(function QuickSqliteClient_v4() {
14
- (0, _classCallCheck2["default"])(this, QuickSqliteClient_v4);
15
- });
16
- exports.QuickSqliteClient_v4 = QuickSqliteClient_v4;
17
- QuickSqliteClient_v4.dbName = _constants.DB_NAME;
18
- QuickSqliteClient_v4.dbLocation = _constants.DB_LOCATION;
19
- QuickSqliteClient_v4.openDB = function () {
20
- var _sqlite$open = sqlite.open(QuickSqliteClient_v4.dbName, QuickSqliteClient_v4.dbLocation),
21
- message = _sqlite$open.message,
22
- status = _sqlite$open.status;
23
- sqlite.executeSql(QuickSqliteClient_v4.dbName, "PRAGMA foreign_keys = ON", []);
24
- if (status === _constants.DB_STATUS_ERROR) {
25
- console.error("Error opening database " + QuickSqliteClient_v4.dbName + ": " + message);
26
- }
27
- };
28
- QuickSqliteClient_v4.closeDB = function () {
29
- var _sqlite$close = sqlite.close(QuickSqliteClient_v4.dbName),
30
- message = _sqlite$close.message,
31
- status = _sqlite$close.status;
32
- if (status === _constants.DB_STATUS_ERROR) {
33
- console.error("Error closing database " + QuickSqliteClient_v4.dbName + ": " + message);
34
- }
35
- };
36
- QuickSqliteClient_v4.executeSqlBatch = function (queries) {
37
- QuickSqliteClient_v4.openDB();
38
- var res = sqlite.executeSqlBatch(_constants.DB_NAME, queries);
39
- if (res.status === 1) {
40
- console.error("Query/queries failed: " + res.message + " " + JSON.stringify(res));
41
- }
42
- QuickSqliteClient_v4.closeDB();
43
- };
44
- QuickSqliteClient_v4.executeSql = function (query, params) {
45
- QuickSqliteClient_v4.openDB();
46
- var _sqlite$executeSql = sqlite.executeSql(_constants.DB_NAME, query, params),
47
- message = _sqlite$executeSql.message,
48
- rows = _sqlite$executeSql.rows,
49
- status = _sqlite$executeSql.status;
50
- QuickSqliteClient_v4.closeDB();
51
- if (status === 1) {
52
- console.error("Query/queries failed: " + message + ": ", query);
53
- }
54
- return rows ? rows._array : [];
55
- };
56
- QuickSqliteClient_v4.deleteDatabase = function () {
57
- var _sqlite$delete = sqlite["delete"](QuickSqliteClient_v4.dbName, QuickSqliteClient_v4.dbLocation),
58
- message = _sqlite$delete.message,
59
- status = _sqlite$delete.status;
60
- if (status === _constants.DB_STATUS_ERROR) {
61
- throw new Error("Error deleting DB: " + message);
62
- }
63
- return true;
64
- };
65
- QuickSqliteClient_v4.updateUserPragmaVersion = function (version) {
66
- QuickSqliteClient_v4.openDB();
67
- sqlite.executeSql(_constants.DB_NAME, "PRAGMA user_version = " + version, []);
68
- QuickSqliteClient_v4.closeDB();
69
- };
70
- QuickSqliteClient_v4.getUserPragmaVersion = function () {
71
- QuickSqliteClient_v4.openDB();
72
- var _sqlite$executeSql2 = sqlite.executeSql(_constants.DB_NAME, "PRAGMA user_version", []),
73
- message = _sqlite$executeSql2.message,
74
- rows = _sqlite$executeSql2.rows,
75
- status = _sqlite$executeSql2.status;
76
- QuickSqliteClient_v4.closeDB();
77
- if (status === 1) {
78
- console.error("Querying for user_version failed: " + message);
79
- }
80
- var result = rows ? rows._array : [];
81
- return result[0].user_version;
82
- };
83
- //# sourceMappingURL=QuickSqliteClient_v4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_constants","require","sqlite","QuickSQLite","e","QuickSqliteClient_v4","_createClass2","_classCallCheck2","exports","dbName","DB_NAME","dbLocation","DB_LOCATION","openDB","_sqlite$open","open","message","status","executeSql","DB_STATUS_ERROR","console","error","closeDB","_sqlite$close","close","executeSqlBatch","queries","res","JSON","stringify","query","params","_sqlite$executeSql","rows","_array","deleteDatabase","_sqlite$delete","Error","updateUserPragmaVersion","version","getUserPragmaVersion","_sqlite$executeSql2","result","user_version"],"sources":["QuickSqliteClient_v4.ts"],"sourcesContent":["// We are going to disable type checks for this file, since this QuickSqliteClient is for legacy version of sqlite but\n// dev-dependency \"react-native-quick-sqlite\" is not available for legacy version of sqlite.\n/* eslint-disable no-underscore-dangle */\n// @ts-nocheck\n\nimport type { QuickSQLite } from 'react-native-quick-sqlite';\nlet sqlite: typeof QuickSQLite;\n\ntry {\n sqlite = require('react-native-quick-sqlite').QuickSQLite;\n} catch (e) {\n // Failed for one of the reason\n // 1. Running on expo, where we don't support offline storage yet.\n // 2. Offline support is disabled, in which case this library is not installed.\n}\nimport { DB_LOCATION, DB_NAME, DB_STATUS_ERROR } from './constants';\nimport type { PreparedQueries } from './types';\n\n// QuickSqliteClient takes care of any direct interaction with sqlite for v4 of react-native-quick-sqlite.\n// This is to avoid any breaking changes for users using v4 of react-native-quick-sqlite.\nexport class QuickSqliteClient_v4 {\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static openDB = () => {\n const { message, status } = sqlite.open(this.dbName, this.dbLocation);\n sqlite.executeSql(this.dbName, `PRAGMA foreign_keys = ON`, []);\n\n if (status === DB_STATUS_ERROR) {\n console.error(`Error opening database ${this.dbName}: ${message}`);\n }\n };\n\n static closeDB = () => {\n const { message, status } = sqlite.close(this.dbName);\n\n if (status === DB_STATUS_ERROR) {\n console.error(`Error closing database ${this.dbName}: ${message}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n this.openDB();\n\n const res = sqlite.executeSqlBatch(DB_NAME, queries);\n\n if (res.status === 1) {\n console.error(`Query/queries failed: ${res.message} ${JSON.stringify(res)}`);\n }\n\n this.closeDB();\n };\n\n static executeSql = (query: string, params?: string[]) => {\n this.openDB();\n\n const { message, rows, status } = sqlite.executeSql(DB_NAME, query, params);\n\n this.closeDB();\n\n if (status === 1) {\n console.error(`Query/queries failed: ${message}: `, query);\n }\n\n return rows ? rows._array : [];\n };\n\n static deleteDatabase = () => {\n const { message, status } = sqlite.delete(this.dbName, this.dbLocation);\n if (status === DB_STATUS_ERROR) {\n throw new Error(`Error deleting DB: ${message}`);\n }\n\n return true;\n };\n\n static updateUserPragmaVersion = (version: number) => {\n this.openDB();\n\n sqlite.executeSql(DB_NAME, `PRAGMA user_version = ${version}`, []);\n\n this.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n this.openDB();\n\n const { message, rows, status } = sqlite.executeSql(DB_NAME, `PRAGMA user_version`, []);\n\n this.closeDB();\n if (status === 1) {\n console.error(`Querying for user_version failed: ${message}`);\n }\n\n const result = rows ? rows._array : [];\n return result[0].user_version as number;\n };\n}\n"],"mappings":";;;;;;;AAeA,IAAAA,UAAA,GAAAC,OAAA;AATA,IAAIC,MAA0B;AAE9B,IAAI;EACFA,MAAM,GAAGD,OAAO,CAAC,2BAA2B,CAAC,CAACE,WAAW;AAC3D,CAAC,CAAC,OAAOC,CAAC,EAAE,CAIZ;AAAC,IAMYC,oBAAoB,OAAAC,aAAA,sBAAAD,qBAAA;EAAA,IAAAE,gBAAA,mBAAAF,oBAAA;AAAA;AAAAG,OAAA,CAAAH,oBAAA,GAAAA,oBAAA;AAApBA,oBAAoB,CACxBI,MAAM,GAAGC,kBAAO;AADZL,oBAAoB,CAExBM,UAAU,GAAGC,sBAAW;AAFpBP,oBAAoB,CAIxBQ,MAAM,GAAG,YAAM;EACpB,IAAAC,YAAA,GAA4BZ,MAAM,CAACa,IAAI,CAL9BV,oBAAoB,CAKgBI,MAAM,EAL1CJ,oBAAoB,CAK6BM,UAAU,CAAC;IAA7DK,OAAO,GAAAF,YAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,YAAA,CAANG,MAAM;EACvBf,MAAM,CAACgB,UAAU,CANRb,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AO,CAACC,KAAK,wCAAsCL,OAAO,CAAG;EAC/D;EAEA,IAAM0B,MAAM,GAAGT,IAAI,GAAGA,IAAI,CAACC,MAAM,GAAG,EAAE;EACtC,OAAOQ,MAAM,CAAC,CAAC,CAAC,CAACC,YAAY;AAC/B,CAAC"}
@@ -1,12 +0,0 @@
1
- import type { PreparedQueries } from './types';
2
- export declare class QuickSqliteClient_v4 {
3
- static dbName: string;
4
- static dbLocation: string;
5
- static openDB: () => void;
6
- static closeDB: () => void;
7
- static executeSqlBatch: (queries: PreparedQueries[]) => void;
8
- static executeSql: (query: string, params?: string[] | undefined) => any;
9
- static deleteDatabase: () => boolean;
10
- static updateUserPragmaVersion: (version: number) => void;
11
- static getUserPragmaVersion: () => number;
12
- }
@@ -1,98 +0,0 @@
1
- // We are going to disable type checks for this file, since this QuickSqliteClient is for legacy version of sqlite but
2
- // dev-dependency "react-native-quick-sqlite" is not available for legacy version of sqlite.
3
- /* eslint-disable no-underscore-dangle */
4
- // @ts-nocheck
5
-
6
- import type { QuickSQLite } from 'react-native-quick-sqlite';
7
- let sqlite: typeof QuickSQLite;
8
-
9
- try {
10
- sqlite = require('react-native-quick-sqlite').QuickSQLite;
11
- } catch (e) {
12
- // Failed for one of the reason
13
- // 1. Running on expo, where we don't support offline storage yet.
14
- // 2. Offline support is disabled, in which case this library is not installed.
15
- }
16
- import { DB_LOCATION, DB_NAME, DB_STATUS_ERROR } from './constants';
17
- import type { PreparedQueries } from './types';
18
-
19
- // QuickSqliteClient takes care of any direct interaction with sqlite for v4 of react-native-quick-sqlite.
20
- // This is to avoid any breaking changes for users using v4 of react-native-quick-sqlite.
21
- export class QuickSqliteClient_v4 {
22
- static dbName = DB_NAME;
23
- static dbLocation = DB_LOCATION;
24
-
25
- static openDB = () => {
26
- const { message, status } = sqlite.open(this.dbName, this.dbLocation);
27
- sqlite.executeSql(this.dbName, `PRAGMA foreign_keys = ON`, []);
28
-
29
- if (status === DB_STATUS_ERROR) {
30
- console.error(`Error opening database ${this.dbName}: ${message}`);
31
- }
32
- };
33
-
34
- static closeDB = () => {
35
- const { message, status } = sqlite.close(this.dbName);
36
-
37
- if (status === DB_STATUS_ERROR) {
38
- console.error(`Error closing database ${this.dbName}: ${message}`);
39
- }
40
- };
41
-
42
- static executeSqlBatch = (queries: PreparedQueries[]) => {
43
- this.openDB();
44
-
45
- const res = sqlite.executeSqlBatch(DB_NAME, queries);
46
-
47
- if (res.status === 1) {
48
- console.error(`Query/queries failed: ${res.message} ${JSON.stringify(res)}`);
49
- }
50
-
51
- this.closeDB();
52
- };
53
-
54
- static executeSql = (query: string, params?: string[]) => {
55
- this.openDB();
56
-
57
- const { message, rows, status } = sqlite.executeSql(DB_NAME, query, params);
58
-
59
- this.closeDB();
60
-
61
- if (status === 1) {
62
- console.error(`Query/queries failed: ${message}: `, query);
63
- }
64
-
65
- return rows ? rows._array : [];
66
- };
67
-
68
- static deleteDatabase = () => {
69
- const { message, status } = sqlite.delete(this.dbName, this.dbLocation);
70
- if (status === DB_STATUS_ERROR) {
71
- throw new Error(`Error deleting DB: ${message}`);
72
- }
73
-
74
- return true;
75
- };
76
-
77
- static updateUserPragmaVersion = (version: number) => {
78
- this.openDB();
79
-
80
- sqlite.executeSql(DB_NAME, `PRAGMA user_version = ${version}`, []);
81
-
82
- this.closeDB();
83
- };
84
-
85
- static getUserPragmaVersion = () => {
86
- this.openDB();
87
-
88
- const { message, rows, status } = sqlite.executeSql(DB_NAME, `PRAGMA user_version`, []);
89
-
90
- this.closeDB();
91
- if (status === 1) {
92
- console.error(`Querying for user_version failed: ${message}`);
93
- }
94
-
95
- const result = rows ? rows._array : [];
96
- return result[0].user_version as number;
97
- };
98
- }