stream-chat-react-native-core 5.14.0-beta.2 → 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.
@@ -7,14 +7,17 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _constants = require("./constants");
10
- var _QuickSqliteClient_v = require("./QuickSqliteClient_v4");
11
10
  var _schema = require("./schema");
12
11
  var _createCreateTableQuery = require("./sqlite-utils/createCreateTableQuery");
13
- var _sqlite;
14
12
  var sqlite;
15
13
  try {
16
14
  sqlite = require('react-native-quick-sqlite').QuickSQLite;
17
- } catch (e) {}
15
+ } catch (e) {
16
+ var isRemoteDebuggerError = e instanceof Error && e.message.includes('Failed to install');
17
+ if (isRemoteDebuggerError) {
18
+ throw e;
19
+ }
20
+ }
18
21
  var QuickSqliteClient = (0, _createClass2["default"])(function QuickSqliteClient() {
19
22
  (0, _classCallCheck2["default"])(this, QuickSqliteClient);
20
23
  });
@@ -28,12 +31,7 @@ QuickSqliteClient.getDbVersion = function () {
28
31
  QuickSqliteClient.setDbVersion = function (version) {
29
32
  return QuickSqliteClient.dbVersion = version;
30
33
  };
31
- QuickSqliteClient.isQuickSqliteV4 = (_sqlite = sqlite) != null && _sqlite.executeSql ? true : false;
32
34
  QuickSqliteClient.openDB = function () {
33
- if (QuickSqliteClient.isQuickSqliteV4) {
34
- _QuickSqliteClient_v.QuickSqliteClient_v4.openDB();
35
- return;
36
- }
37
35
  try {
38
36
  sqlite.open(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
39
37
  sqlite.execute(QuickSqliteClient.dbName, "PRAGMA foreign_keys = ON", []);
@@ -42,10 +40,6 @@ QuickSqliteClient.openDB = function () {
42
40
  }
43
41
  };
44
42
  QuickSqliteClient.closeDB = function () {
45
- if (QuickSqliteClient.isQuickSqliteV4) {
46
- _QuickSqliteClient_v.QuickSqliteClient_v4.closeDB();
47
- return;
48
- }
49
43
  try {
50
44
  sqlite.close(QuickSqliteClient.dbName);
51
45
  } catch (e) {
@@ -54,10 +48,6 @@ QuickSqliteClient.closeDB = function () {
54
48
  };
55
49
  QuickSqliteClient.executeSqlBatch = function (queries) {
56
50
  if (!queries || !queries.length) return;
57
- if (QuickSqliteClient.isQuickSqliteV4) {
58
- _QuickSqliteClient_v.QuickSqliteClient_v4.executeSqlBatch(queries);
59
- return;
60
- }
61
51
  QuickSqliteClient.openDB();
62
52
  try {
63
53
  sqlite.executeBatch(_constants.DB_NAME, queries);
@@ -68,9 +58,6 @@ QuickSqliteClient.executeSqlBatch = function (queries) {
68
58
  }
69
59
  };
70
60
  QuickSqliteClient.executeSql = function (query, params) {
71
- if (QuickSqliteClient.isQuickSqliteV4) {
72
- return _QuickSqliteClient_v.QuickSqliteClient_v4.executeSql(query, params);
73
- }
74
61
  try {
75
62
  QuickSqliteClient.openDB();
76
63
  var _sqlite$execute = sqlite.execute(_constants.DB_NAME, query, params),
@@ -89,9 +76,6 @@ QuickSqliteClient.dropTables = function () {
89
76
  QuickSqliteClient.executeSqlBatch(queries);
90
77
  };
91
78
  QuickSqliteClient.deleteDatabase = function () {
92
- if (QuickSqliteClient.isQuickSqliteV4) {
93
- return _QuickSqliteClient_v.QuickSqliteClient_v4.deleteDatabase();
94
- }
95
79
  try {
96
80
  sqlite["delete"](QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
97
81
  } catch (e) {
@@ -103,9 +87,6 @@ QuickSqliteClient.initializeDatabase = function () {
103
87
  if (sqlite === undefined) {
104
88
  throw new Error('Please install "react-native-quick-sqlite" package to enable offline support');
105
89
  }
106
- if (QuickSqliteClient.isQuickSqliteV4) {
107
- console.warn('You seem to be using an older version of "react-native-quick-sqlite" dependency,', 'and we are going to drop support for it in the next major release.', 'Please upgrade to the version v5 of "react-native-quick-sqlite" to avoid any issues.');
108
- }
109
90
  var version = QuickSqliteClient.getUserPragmaVersion();
110
91
  if (version !== QuickSqliteClient.dbVersion) {
111
92
  QuickSqliteClient.dropTables();
@@ -118,18 +99,11 @@ QuickSqliteClient.initializeDatabase = function () {
118
99
  QuickSqliteClient.executeSqlBatch(q);
119
100
  };
120
101
  QuickSqliteClient.updateUserPragmaVersion = function (version) {
121
- if (QuickSqliteClient.isQuickSqliteV4) {
122
- _QuickSqliteClient_v.QuickSqliteClient_v4.updateUserPragmaVersion(version);
123
- return;
124
- }
125
102
  QuickSqliteClient.openDB();
126
103
  sqlite.execute(_constants.DB_NAME, "PRAGMA user_version = " + version, []);
127
104
  QuickSqliteClient.closeDB();
128
105
  };
129
106
  QuickSqliteClient.getUserPragmaVersion = function () {
130
- if (QuickSqliteClient.isQuickSqliteV4) {
131
- return _QuickSqliteClient_v.QuickSqliteClient_v4.getUserPragmaVersion();
132
- }
133
107
  QuickSqliteClient.openDB();
134
108
  try {
135
109
  var _sqlite$execute2 = sqlite.execute(_constants.DB_NAME, "PRAGMA user_version", []),
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","_QuickSqliteClient_v","_schema","_createCreateTableQuery","_sqlite","sqlite","QuickSQLite","e","QuickSqliteClient","_createClass2","_classCallCheck2","exports","dbVersion","dbName","DB_NAME","dbLocation","DB_LOCATION","getDbVersion","setDbVersion","version","isQuickSqliteV4","executeSql","openDB","QuickSqliteClient_v4","open","execute","console","error","closeDB","close","executeSqlBatch","queries","length","executeBatch","Error","query","params","_sqlite$execute","rows","_array","dropTables","Object","keys","tables","map","table","deleteDatabase","initializeDatabase","undefined","warn","getUserPragmaVersion","updateUserPragmaVersion","q","reduce","queriesSoFar","tableName","push","apply","_toConsumableArray2","createCreateTableQuery","_sqlite$execute2","result","user_version","resetDB"],"sources":["QuickSqliteClient.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\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}\n\nimport { DB_LOCATION, DB_NAME } from './constants';\nimport { QuickSqliteClient_v4 } from './QuickSqliteClient_v4';\nimport { tables } from './schema';\nimport { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';\nimport type { PreparedQueries, Table } from './types';\n\n/**\n * QuickSqliteClient takes care of any direct interaction with sqlite.\n * This way usage react-native-quick-sqlite package is scoped to a single class/file.\n *\n * TODO: Drop the support for v4 of react-native-quick-sqlite in the next major release.\n */\nexport class QuickSqliteClient {\n static dbVersion = 3;\n\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static getDbVersion = () => this.dbVersion;\n // Force a specific db version. This is mainly useful for testsuit.\n static setDbVersion = (version: number) => (this.dbVersion = version);\n\n // @ts-ignore\n static isQuickSqliteV4 = sqlite?.executeSql ? true : false;\n\n // print if legacy version\n static openDB = () => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.openDB();\n return;\n }\n\n try {\n sqlite.open(this.dbName, this.dbLocation);\n sqlite.execute(this.dbName, `PRAGMA foreign_keys = ON`, []);\n } catch (e) {\n console.error(`Error opening database ${this.dbName}: ${e}`);\n }\n };\n\n static closeDB = () => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.closeDB();\n return;\n }\n\n try {\n sqlite.close(this.dbName);\n } catch (e) {\n console.error(`Error closing database ${this.dbName}: ${e}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n if (!queries || !queries.length) return;\n\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.executeSqlBatch(queries);\n return;\n }\n\n this.openDB();\n try {\n sqlite.executeBatch(DB_NAME, queries);\n\n this.closeDB();\n } catch (e) {\n this.closeDB();\n throw new Error(`Query/queries failed: ${e}`);\n }\n };\n\n static executeSql = (query: string, params?: string[]) => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.executeSql(query, params);\n }\n\n try {\n this.openDB();\n const { rows } = sqlite.execute(DB_NAME, query, params);\n this.closeDB();\n\n return rows ? rows._array : [];\n } catch (e) {\n this.closeDB();\n throw new Error(`Query/queries failed: ${e}: `);\n }\n };\n\n static dropTables = () => {\n const queries: PreparedQueries[] = Object.keys(tables).map((table) => [\n `DROP TABLE IF EXISTS ${table}`,\n [],\n ]);\n\n this.executeSqlBatch(queries);\n };\n\n static deleteDatabase = () => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.deleteDatabase();\n }\n\n try {\n sqlite.delete(this.dbName, this.dbLocation);\n } catch (e) {\n throw new Error(`Error deleting DB: ${e}`);\n }\n\n return true;\n };\n\n static initializeDatabase = () => {\n // @ts-ignore\n if (sqlite === undefined) {\n throw new Error(\n 'Please install \"react-native-quick-sqlite\" package to enable offline support',\n );\n }\n\n if (this.isQuickSqliteV4) {\n console.warn(\n 'You seem to be using an older version of \"react-native-quick-sqlite\" dependency,',\n 'and we are going to drop support for it in the next major release.',\n 'Please upgrade to the version v5 of \"react-native-quick-sqlite\" to avoid any issues.',\n );\n }\n\n const version = this.getUserPragmaVersion();\n\n if (version !== this.dbVersion) {\n this.dropTables();\n this.updateUserPragmaVersion(this.dbVersion);\n }\n const q = (Object.keys(tables) as Table[]).reduce<PreparedQueries[]>(\n (queriesSoFar, tableName) => {\n queriesSoFar.push(...createCreateTableQuery(tableName));\n return queriesSoFar;\n },\n [],\n );\n\n this.executeSqlBatch(q);\n };\n\n static updateUserPragmaVersion = (version: number) => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.updateUserPragmaVersion(version);\n return;\n }\n\n this.openDB();\n sqlite.execute(DB_NAME, `PRAGMA user_version = ${version}`, []);\n this.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.getUserPragmaVersion();\n }\n\n this.openDB();\n try {\n const { rows } = sqlite.execute(DB_NAME, `PRAGMA user_version`, []);\n const result = rows ? rows._array : [];\n this.closeDB();\n return result[0].user_version as number;\n } catch (e) {\n this.closeDB();\n throw new Error(`Querying for user_version failed: ${e}`);\n }\n };\n\n static resetDB = () => {\n this.dropTables();\n this.initializeDatabase();\n };\n}\n"],"mappings":";;;;;;;;AAYA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAA+E,IAAAI,OAAA;AAb/E,IAAIC,MAA0B;AAE9B,IAAI;EACFA,MAAM,GAAGL,OAAO,CAAC,2BAA2B,CAAC,CAACM,WAAW;AAC3D,CAAC,CAAC,OAAOC,CAAC,EAAE,CAIZ;AAAC,IAcYC,iBAAiB,OAAAC,aAAA,sBAAAD,kBAAA;EAAA,IAAAE,gBAAA,mBAAAF,iBAAA;AAAA;AAAAG,OAAA,CAAAH,iBAAA,GAAAA,iBAAA;AAAjBA,iBAAiB,CACrBI,SAAS,GAAG,CAAC;AADTJ,iBAAiB,CAGrBK,MAAM,GAAGC,kBAAO;AAHZN,iBAAiB,CAIrBO,UAAU,GAAGC,sBAAW;AAJpBR,iBAAiB,CAMrBS,YAAY,GAAG;EAAA,OANXT,iBAAiB,CAMKI,SAAS;AAAA;AAN/BJ,iBAAiB,CAQrBU,YAAY,GAAG,UAACC,OAAe;EAAA,OAR3BX,iBAAiB,CAQqBI,SAAS,GAAGO,OAAO;AAAA,CAAC;AAR1DX,iBAAiB,CAWrBY,eAAe,GAAG,CAAAhB,OAAA,GAAAC,MAAM,aAAND,OAAA,CAAQiB,UAAU,GAAG,IAAI,GAAG,KAAK;AAX/Cb,iBAAiB,CAcrBc,MAAM,GAAG,YAAM;EACpB,IAfSd,iBAAiB,CAejBY,eAAe,EAAE;IACxBG,yCAAoB,CAACD,MAAM,EAAE;IAC7B;EACF;EAEA,IAAI;IAC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E;IACxB,OAAOG,yCAAoB,CAAC2B,oBAAoB,EAAE;EACpD;EAnJS1C,iBAAiB,CAqJrBc,MAAM,EAAE;EACb,IAAI;IACF,IAAAsC,gBAAA,GAAiBvD,MAAM,CAACoB,OAAO,CAACX,kBAAO,yBAAyB,EAAE,CAAC;MAA3DwB,IAAI,GAAAsB,gBAAA,CAAJtB,IAAI;IACZ,IAAMuB,MAAM,GAAGvB,IAAI,GAAGA,IAAI,CAACC,MAAM,GAAG,EAAE;IAxJ/B/B,iBAAiB,CAyJnBoB,OAAO,EAAE;IACd,OAAOiC,MAAM,CAAC,CAAC,CAAC,CAACC,YAAY;EAC/B,CAAC,CAAC,OAAOvD,CAAC,EAAE;IA3JHC,iBAAiB,CA4JnBoB,OAAO,EAAE;IACd,MAAM,IAAIM,KAAK,wCAAsC3B,CAAC,CAAG;EAC3D;AACF,CAAC;AA/JUC,iBAAiB,CAiKrBuD,OAAO,GAAG,YAAM;EAjKZvD,iBAAiB,CAkKrBgC,UAAU,EAAE;EAlKRhC,iBAAiB,CAmKrBuC,kBAAkB,EAAE;AAC3B,CAAC"}
1
+ {"version":3,"names":["_constants","require","_schema","_createCreateTableQuery","sqlite","QuickSQLite","e","isRemoteDebuggerError","Error","message","includes","QuickSqliteClient","_createClass2","_classCallCheck2","exports","dbVersion","dbName","DB_NAME","dbLocation","DB_LOCATION","getDbVersion","setDbVersion","version","openDB","open","execute","console","error","closeDB","close","executeSqlBatch","queries","length","executeBatch","executeSql","query","params","_sqlite$execute","rows","_array","dropTables","Object","keys","tables","map","table","deleteDatabase","initializeDatabase","undefined","getUserPragmaVersion","updateUserPragmaVersion","q","reduce","queriesSoFar","tableName","push","apply","_toConsumableArray2","createCreateTableQuery","_sqlite$execute2","result","user_version","resetDB"],"sources":["QuickSqliteClient.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\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 // We want to throw the original error when remote debugger (e.g. Chrome) is enabled.\n // QuickSQLite can only be used when synchronous method invocations (JSI) are possible.\n // e.g on-device debugger (e.g. Flipper).\n const isRemoteDebuggerError = e instanceof Error && e.message.includes('Failed to install');\n if (isRemoteDebuggerError) {\n throw e;\n }\n // Reaching here will mean that QuickSQLite is not installed for one of the reasons\n // 1. Running on regular expo, where we don't support offline storage yet.\n // 2. Offline support is disabled, in which case this library is not installed.\n}\n\nimport { DB_LOCATION, DB_NAME } from './constants';\nimport { tables } from './schema';\nimport { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';\nimport type { PreparedQueries, Table } from './types';\n\n/**\n * QuickSqliteClient takes care of any direct interaction with sqlite.\n * This way usage react-native-quick-sqlite package is scoped to a single class/file.\n *\n */\nexport class QuickSqliteClient {\n static dbVersion = 3;\n\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static getDbVersion = () => QuickSqliteClient.dbVersion;\n // Force a specific db version. This is mainly useful for testsuit.\n static setDbVersion = (version: number) => (QuickSqliteClient.dbVersion = version);\n\n static openDB = () => {\n try {\n sqlite.open(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);\n sqlite.execute(QuickSqliteClient.dbName, `PRAGMA foreign_keys = ON`, []);\n } catch (e) {\n console.error(`Error opening database ${QuickSqliteClient.dbName}: ${e}`);\n }\n };\n\n static closeDB = () => {\n try {\n sqlite.close(QuickSqliteClient.dbName);\n } catch (e) {\n console.error(`Error closing database ${QuickSqliteClient.dbName}: ${e}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n if (!queries || !queries.length) return;\n\n QuickSqliteClient.openDB();\n try {\n sqlite.executeBatch(DB_NAME, queries);\n\n QuickSqliteClient.closeDB();\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Query/queries failed: ${e}`);\n }\n };\n\n static executeSql = (query: string, params?: string[]) => {\n try {\n QuickSqliteClient.openDB();\n const { rows } = sqlite.execute(DB_NAME, query, params);\n QuickSqliteClient.closeDB();\n\n return rows ? rows._array : [];\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Query/queries failed: ${e}: `);\n }\n };\n\n static dropTables = () => {\n const queries: PreparedQueries[] = Object.keys(tables).map((table) => [\n `DROP TABLE IF EXISTS ${table}`,\n [],\n ]);\n\n QuickSqliteClient.executeSqlBatch(queries);\n };\n\n static deleteDatabase = () => {\n try {\n sqlite.delete(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);\n } catch (e) {\n throw new Error(`Error deleting DB: ${e}`);\n }\n\n return true;\n };\n\n static initializeDatabase = () => {\n if (sqlite === undefined) {\n throw new Error(\n 'Please install \"react-native-quick-sqlite\" package to enable offline support',\n );\n }\n\n const version = QuickSqliteClient.getUserPragmaVersion();\n\n if (version !== QuickSqliteClient.dbVersion) {\n QuickSqliteClient.dropTables();\n QuickSqliteClient.updateUserPragmaVersion(QuickSqliteClient.dbVersion);\n }\n const q = (Object.keys(tables) as Table[]).reduce<PreparedQueries[]>(\n (queriesSoFar, tableName) => {\n queriesSoFar.push(...createCreateTableQuery(tableName));\n return queriesSoFar;\n },\n [],\n );\n\n QuickSqliteClient.executeSqlBatch(q);\n };\n\n static updateUserPragmaVersion = (version: number) => {\n QuickSqliteClient.openDB();\n sqlite.execute(DB_NAME, `PRAGMA user_version = ${version}`, []);\n QuickSqliteClient.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n QuickSqliteClient.openDB();\n try {\n const { rows } = sqlite.execute(DB_NAME, `PRAGMA user_version`, []);\n const result = rows ? rows._array : [];\n QuickSqliteClient.closeDB();\n return result[0].user_version as number;\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Querying for user_version failed: ${e}`);\n }\n };\n\n static resetDB = () => {\n QuickSqliteClient.dropTables();\n QuickSqliteClient.initializeDatabase();\n };\n}\n"],"mappings":";;;;;;;;AAmBA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC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B,CAACiB,OAAO,EAAE;AAC7B,CAAC;AArGUjB,iBAAiB,CAuGrBsC,oBAAoB,GAAG,YAAM;EAClCtC,iBAAiB,CAACY,MAAM,EAAE;EAC1B,IAAI;IACF,IAAAoC,gBAAA,GAAiBvD,MAAM,CAACqB,OAAO,CAACR,kBAAO,yBAAyB,EAAE,CAAC;MAA3DqB,IAAI,GAAAqB,gBAAA,CAAJrB,IAAI;IACZ,IAAMsB,MAAM,GAAGtB,IAAI,GAAGA,IAAI,CAACC,MAAM,GAAG,EAAE;IACtC5B,iBAAiB,CAACiB,OAAO,EAAE;IAC3B,OAAOgC,MAAM,CAAC,CAAC,CAAC,CAACC,YAAY;EAC/B,CAAC,CAAC,OAAOvD,CAAC,EAAE;IACVK,iBAAiB,CAACiB,OAAO,EAAE;IAC3B,MAAM,IAAIpB,KAAK,wCAAsCF,CAAC,CAAG;EAC3D;AACF,CAAC;AAlHUK,iBAAiB,CAoHrBmD,OAAO,GAAG,YAAM;EACrBnD,iBAAiB,CAAC6B,UAAU,EAAE;EAC9B7B,iBAAiB,CAACoC,kBAAkB,EAAE;AACxC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.14.0-beta.2"
2
+ "version": "5.14.0-beta.3"
3
3
  }
@@ -7,14 +7,17 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _constants = require("./constants");
10
- var _QuickSqliteClient_v = require("./QuickSqliteClient_v4");
11
10
  var _schema = require("./schema");
12
11
  var _createCreateTableQuery = require("./sqlite-utils/createCreateTableQuery");
13
- var _sqlite;
14
12
  var sqlite;
15
13
  try {
16
14
  sqlite = require('react-native-quick-sqlite').QuickSQLite;
17
- } catch (e) {}
15
+ } catch (e) {
16
+ var isRemoteDebuggerError = e instanceof Error && e.message.includes('Failed to install');
17
+ if (isRemoteDebuggerError) {
18
+ throw e;
19
+ }
20
+ }
18
21
  var QuickSqliteClient = (0, _createClass2["default"])(function QuickSqliteClient() {
19
22
  (0, _classCallCheck2["default"])(this, QuickSqliteClient);
20
23
  });
@@ -28,12 +31,7 @@ QuickSqliteClient.getDbVersion = function () {
28
31
  QuickSqliteClient.setDbVersion = function (version) {
29
32
  return QuickSqliteClient.dbVersion = version;
30
33
  };
31
- QuickSqliteClient.isQuickSqliteV4 = (_sqlite = sqlite) != null && _sqlite.executeSql ? true : false;
32
34
  QuickSqliteClient.openDB = function () {
33
- if (QuickSqliteClient.isQuickSqliteV4) {
34
- _QuickSqliteClient_v.QuickSqliteClient_v4.openDB();
35
- return;
36
- }
37
35
  try {
38
36
  sqlite.open(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
39
37
  sqlite.execute(QuickSqliteClient.dbName, "PRAGMA foreign_keys = ON", []);
@@ -42,10 +40,6 @@ QuickSqliteClient.openDB = function () {
42
40
  }
43
41
  };
44
42
  QuickSqliteClient.closeDB = function () {
45
- if (QuickSqliteClient.isQuickSqliteV4) {
46
- _QuickSqliteClient_v.QuickSqliteClient_v4.closeDB();
47
- return;
48
- }
49
43
  try {
50
44
  sqlite.close(QuickSqliteClient.dbName);
51
45
  } catch (e) {
@@ -54,10 +48,6 @@ QuickSqliteClient.closeDB = function () {
54
48
  };
55
49
  QuickSqliteClient.executeSqlBatch = function (queries) {
56
50
  if (!queries || !queries.length) return;
57
- if (QuickSqliteClient.isQuickSqliteV4) {
58
- _QuickSqliteClient_v.QuickSqliteClient_v4.executeSqlBatch(queries);
59
- return;
60
- }
61
51
  QuickSqliteClient.openDB();
62
52
  try {
63
53
  sqlite.executeBatch(_constants.DB_NAME, queries);
@@ -68,9 +58,6 @@ QuickSqliteClient.executeSqlBatch = function (queries) {
68
58
  }
69
59
  };
70
60
  QuickSqliteClient.executeSql = function (query, params) {
71
- if (QuickSqliteClient.isQuickSqliteV4) {
72
- return _QuickSqliteClient_v.QuickSqliteClient_v4.executeSql(query, params);
73
- }
74
61
  try {
75
62
  QuickSqliteClient.openDB();
76
63
  var _sqlite$execute = sqlite.execute(_constants.DB_NAME, query, params),
@@ -89,9 +76,6 @@ QuickSqliteClient.dropTables = function () {
89
76
  QuickSqliteClient.executeSqlBatch(queries);
90
77
  };
91
78
  QuickSqliteClient.deleteDatabase = function () {
92
- if (QuickSqliteClient.isQuickSqliteV4) {
93
- return _QuickSqliteClient_v.QuickSqliteClient_v4.deleteDatabase();
94
- }
95
79
  try {
96
80
  sqlite["delete"](QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);
97
81
  } catch (e) {
@@ -103,9 +87,6 @@ QuickSqliteClient.initializeDatabase = function () {
103
87
  if (sqlite === undefined) {
104
88
  throw new Error('Please install "react-native-quick-sqlite" package to enable offline support');
105
89
  }
106
- if (QuickSqliteClient.isQuickSqliteV4) {
107
- console.warn('You seem to be using an older version of "react-native-quick-sqlite" dependency,', 'and we are going to drop support for it in the next major release.', 'Please upgrade to the version v5 of "react-native-quick-sqlite" to avoid any issues.');
108
- }
109
90
  var version = QuickSqliteClient.getUserPragmaVersion();
110
91
  if (version !== QuickSqliteClient.dbVersion) {
111
92
  QuickSqliteClient.dropTables();
@@ -118,18 +99,11 @@ QuickSqliteClient.initializeDatabase = function () {
118
99
  QuickSqliteClient.executeSqlBatch(q);
119
100
  };
120
101
  QuickSqliteClient.updateUserPragmaVersion = function (version) {
121
- if (QuickSqliteClient.isQuickSqliteV4) {
122
- _QuickSqliteClient_v.QuickSqliteClient_v4.updateUserPragmaVersion(version);
123
- return;
124
- }
125
102
  QuickSqliteClient.openDB();
126
103
  sqlite.execute(_constants.DB_NAME, "PRAGMA user_version = " + version, []);
127
104
  QuickSqliteClient.closeDB();
128
105
  };
129
106
  QuickSqliteClient.getUserPragmaVersion = function () {
130
- if (QuickSqliteClient.isQuickSqliteV4) {
131
- return _QuickSqliteClient_v.QuickSqliteClient_v4.getUserPragmaVersion();
132
- }
133
107
  QuickSqliteClient.openDB();
134
108
  try {
135
109
  var _sqlite$execute2 = sqlite.execute(_constants.DB_NAME, "PRAGMA user_version", []),
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","_QuickSqliteClient_v","_schema","_createCreateTableQuery","_sqlite","sqlite","QuickSQLite","e","QuickSqliteClient","_createClass2","_classCallCheck2","exports","dbVersion","dbName","DB_NAME","dbLocation","DB_LOCATION","getDbVersion","setDbVersion","version","isQuickSqliteV4","executeSql","openDB","QuickSqliteClient_v4","open","execute","console","error","closeDB","close","executeSqlBatch","queries","length","executeBatch","Error","query","params","_sqlite$execute","rows","_array","dropTables","Object","keys","tables","map","table","deleteDatabase","initializeDatabase","undefined","warn","getUserPragmaVersion","updateUserPragmaVersion","q","reduce","queriesSoFar","tableName","push","apply","_toConsumableArray2","createCreateTableQuery","_sqlite$execute2","result","user_version","resetDB"],"sources":["QuickSqliteClient.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\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}\n\nimport { DB_LOCATION, DB_NAME } from './constants';\nimport { QuickSqliteClient_v4 } from './QuickSqliteClient_v4';\nimport { tables } from './schema';\nimport { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';\nimport type { PreparedQueries, Table } from './types';\n\n/**\n * QuickSqliteClient takes care of any direct interaction with sqlite.\n * This way usage react-native-quick-sqlite package is scoped to a single class/file.\n *\n * TODO: Drop the support for v4 of react-native-quick-sqlite in the next major release.\n */\nexport class QuickSqliteClient {\n static dbVersion = 3;\n\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static getDbVersion = () => this.dbVersion;\n // Force a specific db version. This is mainly useful for testsuit.\n static setDbVersion = (version: number) => (this.dbVersion = version);\n\n // @ts-ignore\n static isQuickSqliteV4 = sqlite?.executeSql ? true : false;\n\n // print if legacy version\n static openDB = () => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.openDB();\n return;\n }\n\n try {\n sqlite.open(this.dbName, this.dbLocation);\n sqlite.execute(this.dbName, `PRAGMA foreign_keys = ON`, []);\n } catch (e) {\n console.error(`Error opening database ${this.dbName}: ${e}`);\n }\n };\n\n static closeDB = () => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.closeDB();\n return;\n }\n\n try {\n sqlite.close(this.dbName);\n } catch (e) {\n console.error(`Error closing database ${this.dbName}: ${e}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n if (!queries || !queries.length) return;\n\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.executeSqlBatch(queries);\n return;\n }\n\n this.openDB();\n try {\n sqlite.executeBatch(DB_NAME, queries);\n\n this.closeDB();\n } catch (e) {\n this.closeDB();\n throw new Error(`Query/queries failed: ${e}`);\n }\n };\n\n static executeSql = (query: string, params?: string[]) => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.executeSql(query, params);\n }\n\n try {\n this.openDB();\n const { rows } = sqlite.execute(DB_NAME, query, params);\n this.closeDB();\n\n return rows ? rows._array : [];\n } catch (e) {\n this.closeDB();\n throw new Error(`Query/queries failed: ${e}: `);\n }\n };\n\n static dropTables = () => {\n const queries: PreparedQueries[] = Object.keys(tables).map((table) => [\n `DROP TABLE IF EXISTS ${table}`,\n [],\n ]);\n\n this.executeSqlBatch(queries);\n };\n\n static deleteDatabase = () => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.deleteDatabase();\n }\n\n try {\n sqlite.delete(this.dbName, this.dbLocation);\n } catch (e) {\n throw new Error(`Error deleting DB: ${e}`);\n }\n\n return true;\n };\n\n static initializeDatabase = () => {\n // @ts-ignore\n if (sqlite === undefined) {\n throw new Error(\n 'Please install \"react-native-quick-sqlite\" package to enable offline support',\n );\n }\n\n if (this.isQuickSqliteV4) {\n console.warn(\n 'You seem to be using an older version of \"react-native-quick-sqlite\" dependency,',\n 'and we are going to drop support for it in the next major release.',\n 'Please upgrade to the version v5 of \"react-native-quick-sqlite\" to avoid any issues.',\n );\n }\n\n const version = this.getUserPragmaVersion();\n\n if (version !== this.dbVersion) {\n this.dropTables();\n this.updateUserPragmaVersion(this.dbVersion);\n }\n const q = (Object.keys(tables) as Table[]).reduce<PreparedQueries[]>(\n (queriesSoFar, tableName) => {\n queriesSoFar.push(...createCreateTableQuery(tableName));\n return queriesSoFar;\n },\n [],\n );\n\n this.executeSqlBatch(q);\n };\n\n static updateUserPragmaVersion = (version: number) => {\n if (this.isQuickSqliteV4) {\n QuickSqliteClient_v4.updateUserPragmaVersion(version);\n return;\n }\n\n this.openDB();\n sqlite.execute(DB_NAME, `PRAGMA user_version = ${version}`, []);\n this.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n if (this.isQuickSqliteV4) {\n return QuickSqliteClient_v4.getUserPragmaVersion();\n }\n\n this.openDB();\n try {\n const { rows } = sqlite.execute(DB_NAME, `PRAGMA user_version`, []);\n const result = rows ? rows._array : [];\n this.closeDB();\n return result[0].user_version as number;\n } catch (e) {\n this.closeDB();\n throw new Error(`Querying for user_version failed: ${e}`);\n }\n };\n\n static resetDB = () => {\n this.dropTables();\n this.initializeDatabase();\n };\n}\n"],"mappings":";;;;;;;;AAYA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAA+E,IAAAI,OAAA;AAb/E,IAAIC,MAA0B;AAE9B,IAAI;EACFA,MAAM,GAAGL,OAAO,CAAC,2BAA2B,CAAC,CAACM,WAAW;AAC3D,CAAC,CAAC,OAAOC,CAAC,EAAE,CAIZ;AAAC,IAcYC,iBAAiB,OAAAC,aAAA,sBAAAD,kBAAA;EAAA,IAAAE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AG,YAAM;EAjKZvD,iBAAiB,CAkKrBgC,UAAU,EAAE;EAlKRhC,iBAAiB,CAmKrBuC,kBAAkB,EAAE;AAC3B,CAAC"}
1
+ {"version":3,"names":["_constants","require","_schema","_createCreateTableQuery","sqlite","QuickSQLite","e","isRemoteDebuggerError","Error","message","includes","QuickSqliteClient","_createClass2","_classCallCheck2","exports","dbVersion","dbName","DB_NAME","dbLocation","DB_LOCATION","getDbVersion","setDbVersion","version","openDB","open","execute","console","error","closeDB","close","executeSqlBatch","queries","length","executeBatch","executeSql","query","params","_sqlite$execute","rows","_array","dropTables","Object","keys","tables","map","table","deleteDatabase","initializeDatabase","undefined","getUserPragmaVersion","updateUserPragmaVersion","q","reduce","queriesSoFar","tableName","push","apply","_toConsumableArray2","createCreateTableQuery","_sqlite$execute2","result","user_version","resetDB"],"sources":["QuickSqliteClient.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\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 // We want to throw the original error when remote debugger (e.g. Chrome) is enabled.\n // QuickSQLite can only be used when synchronous method invocations (JSI) are possible.\n // e.g on-device debugger (e.g. Flipper).\n const isRemoteDebuggerError = e instanceof Error && e.message.includes('Failed to install');\n if (isRemoteDebuggerError) {\n throw e;\n }\n // Reaching here will mean that QuickSQLite is not installed for one of the reasons\n // 1. Running on regular expo, where we don't support offline storage yet.\n // 2. Offline support is disabled, in which case this library is not installed.\n}\n\nimport { DB_LOCATION, DB_NAME } from './constants';\nimport { tables } from './schema';\nimport { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';\nimport type { PreparedQueries, Table } from './types';\n\n/**\n * QuickSqliteClient takes care of any direct interaction with sqlite.\n * This way usage react-native-quick-sqlite package is scoped to a single class/file.\n *\n */\nexport class QuickSqliteClient {\n static dbVersion = 3;\n\n static dbName = DB_NAME;\n static dbLocation = DB_LOCATION;\n\n static getDbVersion = () => QuickSqliteClient.dbVersion;\n // Force a specific db version. This is mainly useful for testsuit.\n static setDbVersion = (version: number) => (QuickSqliteClient.dbVersion = version);\n\n static openDB = () => {\n try {\n sqlite.open(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);\n sqlite.execute(QuickSqliteClient.dbName, `PRAGMA foreign_keys = ON`, []);\n } catch (e) {\n console.error(`Error opening database ${QuickSqliteClient.dbName}: ${e}`);\n }\n };\n\n static closeDB = () => {\n try {\n sqlite.close(QuickSqliteClient.dbName);\n } catch (e) {\n console.error(`Error closing database ${QuickSqliteClient.dbName}: ${e}`);\n }\n };\n\n static executeSqlBatch = (queries: PreparedQueries[]) => {\n if (!queries || !queries.length) return;\n\n QuickSqliteClient.openDB();\n try {\n sqlite.executeBatch(DB_NAME, queries);\n\n QuickSqliteClient.closeDB();\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Query/queries failed: ${e}`);\n }\n };\n\n static executeSql = (query: string, params?: string[]) => {\n try {\n QuickSqliteClient.openDB();\n const { rows } = sqlite.execute(DB_NAME, query, params);\n QuickSqliteClient.closeDB();\n\n return rows ? rows._array : [];\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Query/queries failed: ${e}: `);\n }\n };\n\n static dropTables = () => {\n const queries: PreparedQueries[] = Object.keys(tables).map((table) => [\n `DROP TABLE IF EXISTS ${table}`,\n [],\n ]);\n\n QuickSqliteClient.executeSqlBatch(queries);\n };\n\n static deleteDatabase = () => {\n try {\n sqlite.delete(QuickSqliteClient.dbName, QuickSqliteClient.dbLocation);\n } catch (e) {\n throw new Error(`Error deleting DB: ${e}`);\n }\n\n return true;\n };\n\n static initializeDatabase = () => {\n if (sqlite === undefined) {\n throw new Error(\n 'Please install \"react-native-quick-sqlite\" package to enable offline support',\n );\n }\n\n const version = QuickSqliteClient.getUserPragmaVersion();\n\n if (version !== QuickSqliteClient.dbVersion) {\n QuickSqliteClient.dropTables();\n QuickSqliteClient.updateUserPragmaVersion(QuickSqliteClient.dbVersion);\n }\n const q = (Object.keys(tables) as Table[]).reduce<PreparedQueries[]>(\n (queriesSoFar, tableName) => {\n queriesSoFar.push(...createCreateTableQuery(tableName));\n return queriesSoFar;\n },\n [],\n );\n\n QuickSqliteClient.executeSqlBatch(q);\n };\n\n static updateUserPragmaVersion = (version: number) => {\n QuickSqliteClient.openDB();\n sqlite.execute(DB_NAME, `PRAGMA user_version = ${version}`, []);\n QuickSqliteClient.closeDB();\n };\n\n static getUserPragmaVersion = () => {\n QuickSqliteClient.openDB();\n try {\n const { rows } = sqlite.execute(DB_NAME, `PRAGMA user_version`, []);\n const result = rows ? rows._array : [];\n QuickSqliteClient.closeDB();\n return result[0].user_version as number;\n } catch (e) {\n QuickSqliteClient.closeDB();\n throw new Error(`Querying for user_version failed: ${e}`);\n }\n };\n\n static resetDB = () => {\n QuickSqliteClient.dropTables();\n QuickSqliteClient.initializeDatabase();\n };\n}\n"],"mappings":";;;;;;;;AAmBA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AAnBA,IAAIG,MAA0B;AAE9B,IAAI;EACFA,MAAM,GAAGH,OAAO,CAAC,2BAA2B,CAAC,CAACI,WAAW;AAC3D,CAAC,CAAC,OAAOC,CAAC,EAAE;EAIV,IAAMC,qBAAqB,GAAGD,CAAC,YAAYE,KAAK,IAAIF,CAAC,CAACG,OAAO,CAACC,QAAQ,CAAC,mBAAmB,CAAC;EAC3F,IAAIH,qBAAqB,EAAE;IACzB,MAAMD,CAAC;EACT;AAIF;AAAC,IAYYK,iBAAiB,OAAAC,aAAA,sBAAAD,kBAAA;EAAA,IAAAE,gBAAA,mBAAAF,iBAAA;AAAA;AAAAG,OAAA,CAAAH,iBAAA,GAAAA,iBAAA;AAAjBA,iBAAiB,CACrBI,SAAS,GAAG,CAAC;AADTJ,iBAAiB,CAGrBK,MAAM,GAAGC,kBAAO;AAHZN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CAoHrBmD,OAAO,GAAG,YAAM;EACrBnD,iBAAiB,CAAC6B,UAAU,EAAE;EAC9B7B,iBAAiB,CAACoC,kBAAkB,EAAE;AACxC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.14.0-beta.2"
2
+ "version": "5.14.0-beta.3"
3
3
  }
@@ -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.2",
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",
@@ -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.2"
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,6BATNhB,oBAAoB,CASkBI,MAAM,UAAKO,OAAO,CAAG;EACpE;AACF,CAAC;AAXUX,oBAAoB,CAaxBiB,OAAO,GAAG,YAAM;EACrB,IAAAC,a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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,6BATNhB,oBA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AAOQ,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
- }