react-sqlite-hook
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -0,1 +1,12 @@ | ||
## 3.0.2 (2022-09-23) | ||
### Added Features | ||
- add getFromHTTPRequest | ||
### Bug Fixes | ||
- Fix FeatureNotAvailableError after upgrading from Capacitor 3 to Capacitor 4 issue#324 of @capacitor-community/sqlite as suggested by | ||
Alexander Kristiansen (axkristiansen) | ||
## 3.0.1 (2022-09-18) | ||
@@ -2,0 +13,0 @@ |
{ | ||
"name": "react-sqlite-hook", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "React Hook for @Capacitor-community/sqlite plugin", | ||
@@ -49,3 +49,3 @@ "repository": { | ||
"devDependencies": { | ||
"@capacitor-community/sqlite": "^4.1.0", | ||
"@capacitor-community/sqlite": "^4.1.1", | ||
"@capacitor/core": "^4.1.0", | ||
@@ -52,0 +52,0 @@ "@capacitor/docgen": "0.0.17", |
@@ -201,2 +201,3 @@ import { AvailableResult } from './util/models'; | ||
* Copy databases from assets to application database folder | ||
* @param overwrite boolean | ||
* @returns Promise<void> | ||
@@ -207,8 +208,16 @@ * @since 2.0.0 | ||
/** | ||
* Check the consistency between Js Connections | ||
* and Native Connections | ||
* if inconsistency all connections are removed | ||
* @returns Promise<Result> | ||
* @since 2.0.1 | ||
* Get databases from HTTP request to application database folder | ||
* @param url string | ||
* @param overwrite boolean | ||
* @returns Promise<void> | ||
* @since 3.0.2 | ||
*/ | ||
getFromHTTPRequest(url: string, overwrite?: boolean): Promise<void>; | ||
/** | ||
* Check the consistency between Js Connections | ||
* and Native Connections | ||
* if inconsistency all connections are removed | ||
* @returns Promise<Result> | ||
* @since 2.0.1 | ||
*/ | ||
checkConnectionsConsistency(): Promise<Result>; | ||
@@ -215,0 +224,0 @@ /** |
@@ -380,3 +380,3 @@ import { useCallback, useMemo, useEffect } from 'react'; | ||
let msg = "Must provide an upgrade statement with "; | ||
msg += "fromVersion & toVersion & statement"; | ||
msg += "toVersion & statements"; | ||
return Promise.reject(msg); | ||
@@ -412,2 +412,15 @@ } | ||
/** | ||
* Get databases from HTTP request to application database folder | ||
*/ | ||
const getFromHTTPRequest = useCallback(async (url, overwrite) => { | ||
const mOverwrite = overwrite != null ? overwrite : true; | ||
try { | ||
await mSQLite.getFromHTTPRequest(url, overwrite); | ||
return Promise.resolve(); | ||
} | ||
catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}, [mSQLite]); | ||
/** | ||
* Check the consistency between Js Connections | ||
@@ -653,3 +666,3 @@ * and Native Connections | ||
if (!availableFeaturesN.useSQLite) { | ||
return Object.assign({ initWebStore: featureNotAvailableError, saveToStore: featureNotAvailableError, echo: featureNotAvailableError, getPlatform: featureNotAvailableError, getCapacitorSQLite: featureNotAvailableError, createConnection: featureNotAvailableError, closeConnection: featureNotAvailableError, retrieveConnection: featureNotAvailableError, retrieveAllConnections: featureNotAvailableError, closeAllConnections: featureNotAvailableError, addUpgradeStatement: featureNotAvailableError, importFromJson: featureNotAvailableError, isJsonValid: featureNotAvailableError, copyFromAssets: featureNotAvailableError, isConnection: featureNotAvailableError, isDatabase: featureNotAvailableError, getNCDatabasePath: featureNotAvailableError, createNCConnection: featureNotAvailableError, closeNCConnection: featureNotAvailableError, retrieveNCConnection: featureNotAvailableError, isNCConnection: featureNotAvailableError, isNCDatabase: featureNotAvailableError, getDatabaseList: featureNotAvailableError, getMigratableDbList: featureNotAvailableError, addSQLiteSuffix: featureNotAvailableError, deleteOldDatabases: featureNotAvailableError, checkConnectionsConsistency: featureNotAvailableError, isSecretStored: featureNotAvailableError, setEncryptionSecret: featureNotAvailableError, changeEncryptionSecret: featureNotAvailableError, clearEncryptionSecret: featureNotAvailableError }, notAvailable); | ||
return Object.assign({ initWebStore: featureNotAvailableError, saveToStore: featureNotAvailableError, echo: featureNotAvailableError, getPlatform: featureNotAvailableError, getCapacitorSQLite: featureNotAvailableError, createConnection: featureNotAvailableError, closeConnection: featureNotAvailableError, retrieveConnection: featureNotAvailableError, retrieveAllConnections: featureNotAvailableError, closeAllConnections: featureNotAvailableError, addUpgradeStatement: featureNotAvailableError, importFromJson: featureNotAvailableError, isJsonValid: featureNotAvailableError, copyFromAssets: featureNotAvailableError, getFromHTTPRequest: featureNotAvailableError, isConnection: featureNotAvailableError, isDatabase: featureNotAvailableError, getNCDatabasePath: featureNotAvailableError, createNCConnection: featureNotAvailableError, closeNCConnection: featureNotAvailableError, retrieveNCConnection: featureNotAvailableError, isNCConnection: featureNotAvailableError, isNCDatabase: featureNotAvailableError, getDatabaseList: featureNotAvailableError, getMigratableDbList: featureNotAvailableError, addSQLiteSuffix: featureNotAvailableError, deleteOldDatabases: featureNotAvailableError, checkConnectionsConsistency: featureNotAvailableError, isSecretStored: featureNotAvailableError, setEncryptionSecret: featureNotAvailableError, changeEncryptionSecret: featureNotAvailableError, clearEncryptionSecret: featureNotAvailableError }, notAvailable); | ||
} | ||
@@ -659,3 +672,3 @@ else { | ||
retrieveConnection, retrieveAllConnections, closeAllConnections, | ||
addUpgradeStatement, importFromJson, isJsonValid, copyFromAssets, | ||
addUpgradeStatement, importFromJson, isJsonValid, copyFromAssets, getFromHTTPRequest, | ||
isConnection, isDatabase, getDatabaseList, getMigratableDbList, addSQLiteSuffix, | ||
@@ -662,0 +675,0 @@ deleteOldDatabases, checkConnectionsConsistency, |
{ | ||
"name": "react-sqlite-hook", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "React Hook for @Capacitor-community/sqlite plugin", | ||
@@ -49,3 +49,3 @@ "repository": { | ||
"devDependencies": { | ||
"@capacitor-community/sqlite": "^4.1.0", | ||
"@capacitor-community/sqlite": "^4.1.1", | ||
"@capacitor/core": "^4.1.0", | ||
@@ -52,0 +52,0 @@ "@capacitor/docgen": "0.0.17", |
@@ -91,2 +91,3 @@ <p align="center"><br><img src="https://avatars3.githubusercontent.com/u/16580653?v=4" width="128" height="128" /></p> | ||
| isNCDatabase | ✅ | ✅ | ❌ | ❌ | | ||
| getFromHTTPRequest | ✅ | ✅ | ✅ | ✅ | | ||
@@ -93,0 +94,0 @@ |
@@ -66,4 +66,5 @@ | ||
readonly?: boolean): Promise<any> => { | ||
const mReadonly = readonly ? readonly : false; | ||
let dbConn: SQLiteDBConnection = new | ||
SQLiteDBConnection(dbName,false,CapacitorSQLite) | ||
SQLiteDBConnection(dbName,mReadonly,CapacitorSQLite) | ||
if(dbConn != null) { | ||
@@ -188,3 +189,3 @@ connDict.set(dbName,dbConn) | ||
await act(async () => { | ||
capacitorMock.init(false, 'web'); | ||
capacitorMock.init(true, 'web'); | ||
}); | ||
@@ -198,3 +199,3 @@ const r = renderHook(() => useSQLite({})); | ||
const { isAvailable } = result; | ||
expect(isAvailable).toBe(false); | ||
expect(isAvailable).toBe(true); | ||
}); | ||
@@ -201,0 +202,0 @@ }); |
@@ -211,2 +211,3 @@ import { useCallback, useMemo, useEffect } from 'react'; | ||
* Copy databases from assets to application database folder | ||
* @param overwrite boolean | ||
* @returns Promise<void> | ||
@@ -217,2 +218,10 @@ * @since 2.0.0 | ||
/** | ||
* Get databases from HTTP request to application database folder | ||
* @param url string | ||
* @param overwrite boolean | ||
* @returns Promise<void> | ||
* @since 3.0.2 | ||
*/ | ||
getFromHTTPRequest(url: string, overwrite?: boolean): Promise<void>; | ||
/** | ||
* Check the consistency between Js Connections | ||
@@ -642,3 +651,3 @@ * and Native Connections | ||
let msg = "Must provide an upgrade statement with "; | ||
msg += "fromVersion & toVersion & statement" | ||
msg += "toVersion & statements" | ||
return Promise.reject(msg); | ||
@@ -673,2 +682,14 @@ } | ||
/** | ||
* Get databases from HTTP request to application database folder | ||
*/ | ||
const getFromHTTPRequest = useCallback(async (url: string, overwrite?: boolean) : Promise<void> => { | ||
const mOverwrite = overwrite!= null ? overwrite : true; | ||
try { | ||
await mSQLite.getFromHTTPRequest(url, overwrite); | ||
return Promise.resolve(); | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}, [mSQLite]); | ||
/** | ||
* Check the consistency between Js Connections | ||
@@ -921,2 +942,3 @@ * and Native Connections | ||
copyFromAssets: featureNotAvailableError, | ||
getFromHTTPRequest: featureNotAvailableError, | ||
isConnection: featureNotAvailableError, | ||
@@ -944,3 +966,3 @@ isDatabase: featureNotAvailableError, | ||
retrieveConnection, retrieveAllConnections, closeAllConnections, | ||
addUpgradeStatement, importFromJson, isJsonValid, copyFromAssets, | ||
addUpgradeStatement, importFromJson, isJsonValid, copyFromAssets, getFromHTTPRequest, | ||
isConnection, isDatabase, getDatabaseList, getMigratableDbList, addSQLiteSuffix, | ||
@@ -947,0 +969,0 @@ deleteOldDatabases, checkConnectionsConsistency, |
Sorry, the diff of this file is not supported yet
132436
2330
142