Socket
Socket
Sign inDemoInstall

@capacitor-community/sqlite

Package Overview
Dependencies
Maintainers
20
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/sqlite - npm Package Compare versions

Comparing version 2.9.0-beta.1 to 2.9.0-beta.2

16

CHANGELOG.md

@@ -0,1 +1,17 @@

## 2.9.0-beta.2 (2020-12-25) REFACTOR
### Chore
- update to @capacitor/core@2.4.5
### Added Features
- Ionic-React-Usage.md documentation
- Ionic-Vue-Usage.md documentation
- copyFromAssets
### Bug Fixes
- update README and CHANGELOG
## 2.9.0-beta.1 (2020-12-25) REFACTOR

@@ -2,0 +18,0 @@

@@ -137,2 +137,9 @@ declare module '@capacitor/core' {

addUpgradeStatement(options: capSQLiteUpgradeOptions): Promise<capSQLiteResult>;
/**
* Copy databases from public/assets/databases folder to application databases folder
*
* @returns Promise<capSQLiteResult>
* @since 2.9.0 refactor
*/
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -478,2 +485,8 @@ export interface capEchoOptions {

isJsonValid(jsonstring: string): Promise<capSQLiteResult>;
/**
* Copy databases from public/assets/databases folder to application databases folder
* @returns Promise<capSQLiteResult>
* @since 2.9.0 refactor
*/
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -496,2 +509,3 @@ /**

isJsonValid(jsonstring: string): Promise<capSQLiteResult>;
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -498,0 +512,0 @@ /**

@@ -104,2 +104,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
copyFromAssets() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.sqlite.copyFromAssets();
});
}
}

@@ -106,0 +111,0 @@ /**

1

dist/esm/web.d.ts

@@ -23,4 +23,5 @@ import { WebPlugin } from '@capacitor/core';

addUpgradeStatement(options: capSQLiteUpgradeOptions): Promise<capSQLiteResult>;
copyFromAssets(): Promise<capSQLiteResult>;
}
declare const CapacitorSQLite: CapacitorSQLiteWeb;
export { CapacitorSQLite };

@@ -177,2 +177,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
copyFromAssets() {
return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});
}
}

@@ -179,0 +187,0 @@ const CapacitorSQLite = new CapacitorSQLiteWeb();

@@ -107,2 +107,7 @@ var capacitorPlugin = (function (exports, core) {

}
copyFromAssets() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.sqlite.copyFromAssets();
});
}
}

@@ -419,2 +424,10 @@ /**

}
copyFromAssets() {
return __awaiter$1(this, void 0, void 0, function* () {
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});
}
}

@@ -429,2 +442,4 @@ const CapacitorSQLite = new CapacitorSQLiteWeb();

Object.defineProperty(exports, '__esModule', { value: true });
return exports;

@@ -431,0 +446,0 @@

@@ -26,2 +26,29 @@ export declare class UtilsFile {

/**
* GetDatabasesPath
* get the database folder path
*/
getDatabasesPath(): string;
/**
* GetAssetsDatabasesPath
* get the assets databases folder path
*/
getAssetsDatabasesPath(): string;
/**
* SetPathSuffix
* @param db
*/
setPathSuffix(db: string): string;
/**
* GetFileList
* get the file list for a given folder
* @param path
*/
getFileList(path: string): Promise<string[]>;
/**
* CopyFromAssetToDatabase
* @param db
* @param toDb
*/
copyFromAssetToDatabase(db: string, toDb: string): Promise<void>;
/**
* CopyFileName

@@ -28,0 +55,0 @@ * Copy file name

@@ -51,2 +51,9 @@ import { __awaiter } from "tslib";

getFilePath(fileName) {
return this.Path.join(this.getDatabasesPath(), fileName);
}
/**
* GetDatabasesPath
* get the database folder path
*/
getDatabasesPath() {
let retPath = '';

@@ -60,3 +67,3 @@ const dbFolder = this.pathDB;

const dir = __dirname.substring(0, __dirname.lastIndexOf(sep) + 1);
retPath = this.Path.join(dir, dbFolder, fileName);
retPath = this.Path.join(dir, dbFolder);
const retB = this._createFolderIfNotExists(this.Path.join(dir, dbFolder));

@@ -67,3 +74,3 @@ if (!retB)

else {
retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName, fileName);
retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName);
let retB = this._createFolderIfNotExists(this.Path.join(this.HomeDir, dbFolder));

@@ -82,2 +89,63 @@ if (retB) {

/**
* GetAssetsDatabasesPath
* get the assets databases folder path
*/
getAssetsDatabasesPath() {
let retPath = '';
let sep = '/';
const idx = __dirname.indexOf('\\');
if (idx != -1)
sep = '\\';
const dir = __dirname.substring(0, __dirname.lastIndexOf(sep) + 1);
retPath = this.Path.join(dir, 'app', 'assets', this.pathDB.toLowerCase());
console.log(`$$$ AssetsDatabases ${retPath}`);
return retPath;
}
/**
* SetPathSuffix
* @param db
*/
setPathSuffix(db) {
let toDb = db;
if (db.length > 9) {
const last9 = db.slice(-9);
if (last9 != 'SQLite.db') {
toDb = this.Path.parse(db).name + 'SQLite.db';
}
}
else {
toDb = toDb + 'SQLite.db';
}
return toDb;
}
/**
* GetFileList
* get the file list for a given folder
* @param path
*/
getFileList(path) {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const filenames = this.NodeFs.readdirSync(path);
let dbs = [];
filenames.forEach((file) => {
if (this.Path.extname(file) == '.db')
dbs.push(file);
});
resolve(dbs);
}));
}
/**
* CopyFromAssetToDatabase
* @param db
* @param toDb
*/
copyFromAssetToDatabase(db, toDb) {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const pAsset = this.Path.join(this.getAssetsDatabasesPath(), db);
const pDb = this.Path.join(this.getDatabasesPath(), toDb);
yield this.copyFilePath(pAsset, pDb);
resolve();
}));
}
/**
* CopyFileName

@@ -120,2 +188,3 @@ * Copy file name

try {
yield this.deleteFilePath(toFilePath);
this.NodeFs.copyFileSync(filePath, toFilePath);

@@ -122,0 +191,0 @@ resolve();

@@ -28,4 +28,5 @@ import { WebPlugin } from '@capacitor/core';

addUpgradeStatement(options: capSQLiteUpgradeOptions): Promise<capSQLiteResult>;
copyFromAssets(): Promise<capSQLiteResult>;
}
declare const CapacitorSQLite: CapacitorSQLiteElectronWeb;
export { CapacitorSQLite };

@@ -625,2 +625,30 @@ import { __awaiter } from "tslib";

}
copyFromAssets() {
return __awaiter(this, void 0, void 0, function* () {
// check if the assets/database folder exists
const assetsDbPath = this._uFile.getAssetsDatabasesPath();
const res = this._uFile.isPathExists(assetsDbPath);
if (res) {
// get the database files
const dbList = yield this._uFile.getFileList(assetsDbPath);
// loop through the database files
const toDbList = [];
dbList.forEach((db) => __awaiter(this, void 0, void 0, function* () {
console.log(`>>> ${db}`);
// for each check if the suffix SQLite.db is there or add it
let toDb = this._uFile.setPathSuffix(db);
toDbList.push(toDb);
// for each copy the file to the Application database folder
yield this._uFile.copyFromAssetToDatabase(db, toDb);
}));
return Promise.resolve({ result: true });
}
else {
return Promise.resolve({
result: false,
message: 'CopyFromAssets: assets/databases folder does not exist',
});
}
});
}
}

@@ -627,0 +655,0 @@ const CapacitorSQLite = new CapacitorSQLiteElectronWeb();

@@ -137,2 +137,9 @@ declare module '@capacitor/core' {

addUpgradeStatement(options: capSQLiteUpgradeOptions): Promise<capSQLiteResult>;
/**
* Copy databases from public/assets/databases folder to application databases folder
*
* @returns Promise<capSQLiteResult>
* @since 2.9.0 refactor
*/
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -244,3 +251,3 @@ export interface capEchoOptions {

* Set the synchronization date
*
* Format yyyy-MM-dd'T'HH:mm:ss.SSSZ
*/

@@ -479,2 +486,8 @@ syncdate?: string;

isJsonValid(jsonstring: string): Promise<capSQLiteResult>;
/**
* Copy databases from public/assets/databases folder to application databases folder
* @returns Promise<capSQLiteResult>
* @since 2.9.0 refactor
*/
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -497,2 +510,3 @@ /**

isJsonValid(jsonstring: string): Promise<capSQLiteResult>;
copyFromAssets(): Promise<capSQLiteResult>;
}

@@ -499,0 +513,0 @@ /**

@@ -96,2 +96,7 @@ import { __awaiter } from "tslib";

}
copyFromAssets() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.sqlite.copyFromAssets();
});
}
}

@@ -98,0 +103,0 @@ /**

@@ -51,2 +51,9 @@ export class UtilsFile {

public getFilePath(fileName: string): string {
return this.Path.join(this.getDatabasesPath(), fileName);
}
/**
* GetDatabasesPath
* get the database folder path
*/
public getDatabasesPath(): string {
let retPath: string = '';

@@ -62,3 +69,3 @@ const dbFolder: string = this.pathDB;

);
retPath = this.Path.join(dir, dbFolder, fileName);
retPath = this.Path.join(dir, dbFolder);
const retB: boolean = this._createFolderIfNotExists(

@@ -69,3 +76,3 @@ this.Path.join(dir, dbFolder),

} else {
retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName, fileName);
retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName);
let retB: boolean = this._createFolderIfNotExists(

@@ -83,5 +90,64 @@ this.Path.join(this.HomeDir, dbFolder),

}
return retPath;
}
/**
* GetAssetsDatabasesPath
* get the assets databases folder path
*/
public getAssetsDatabasesPath(): string {
let retPath: string = '';
let sep: string = '/';
const idx: number = __dirname.indexOf('\\');
if (idx != -1) sep = '\\';
const dir: string = __dirname.substring(0, __dirname.lastIndexOf(sep) + 1);
retPath = this.Path.join(dir, 'app', 'assets', this.pathDB.toLowerCase());
console.log(`$$$ AssetsDatabases ${retPath}`);
return retPath;
}
/**
* SetPathSuffix
* @param db
*/
public setPathSuffix(db: string): string {
let toDb: string = db;
if (db.length > 9) {
const last9: string = db.slice(-9);
if (last9 != 'SQLite.db') {
toDb = this.Path.parse(db).name + 'SQLite.db';
}
} else {
toDb = toDb + 'SQLite.db';
}
return toDb;
}
/**
* GetFileList
* get the file list for a given folder
* @param path
*/
public getFileList(path: string): Promise<string[]> {
return new Promise(async resolve => {
const filenames = this.NodeFs.readdirSync(path);
let dbs: string[] = [];
filenames.forEach((file: string) => {
if (this.Path.extname(file) == '.db') dbs.push(file);
});
resolve(dbs);
});
}
/**
* CopyFromAssetToDatabase
* @param db
* @param toDb
*/
public copyFromAssetToDatabase(db: string, toDb: string): Promise<void> {
return new Promise(async resolve => {
const pAsset: string = this.Path.join(this.getAssetsDatabasesPath(), db);
const pDb: string = this.Path.join(this.getDatabasesPath(), toDb);
await this.copyFilePath(pAsset, pDb);
resolve();
});
}
/**
* CopyFileName

@@ -122,2 +188,3 @@ * Copy file name

try {
await this.deleteFilePath(toFilePath);
this.NodeFs.copyFileSync(filePath, toFilePath);

@@ -124,0 +191,0 @@ resolve();

@@ -638,2 +638,27 @@ import { WebPlugin } from '@capacitor/core';

}
async copyFromAssets(): Promise<capSQLiteResult> {
// check if the assets/database folder exists
const assetsDbPath = this._uFile.getAssetsDatabasesPath();
const res: boolean = this._uFile.isPathExists(assetsDbPath);
if (res) {
// get the database files
const dbList: string[] = await this._uFile.getFileList(assetsDbPath);
// loop through the database files
const toDbList: string[] = [];
dbList.forEach(async (db: string) => {
console.log(`>>> ${db}`);
// for each check if the suffix SQLite.db is there or add it
let toDb: string = this._uFile.setPathSuffix(db);
toDbList.push(toDb);
// for each copy the file to the Application database folder
await this._uFile.copyFromAssetToDatabase(db, toDb);
});
return Promise.resolve({ result: true });
} else {
return Promise.resolve({
result: false,
message: 'CopyFromAssets: assets/databases folder does not exist',
});
}
}
}

@@ -640,0 +665,0 @@ const CapacitorSQLite = new CapacitorSQLiteElectronWeb();

38

package.json
{
"name": "@capacitor-community/sqlite",
"version": "2.9.0-beta.1",
"version": "2.9.0-beta.2",
"description": "Capacitor SQLite Plugin",

@@ -26,22 +26,22 @@ "homepage": "https://github.com/capacitor-community/sqlite",

"devDependencies": {
"@capacitor/android": "^2.4.4",
"@capacitor/core": "^2.4.4",
"@capacitor/docgen": "0.0.10",
"@capacitor/ios": "^2.4.4",
"@ionic/prettier-config": "^1.0.0",
"@ionic/swiftlint-config": "^1.1.1",
"@rollup/plugin-node-resolve": "^9.0.0",
"@types/node": "^12.12.62",
"@capacitor/android": "^2.4.5",
"@capacitor/core": "^2.4.5",
"@capacitor/docgen": "0.0.14",
"@capacitor/ios": "^2.4.5",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^11.0.1",
"@types/node": "^14.14.19",
"electron": "^11.1.0",
"husky": "^4.2.5",
"np": "^6.5.0",
"prettier": "^2.0.5",
"prettier-plugin-java": "^0.8.1",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.0",
"rollup": "^2.28.1",
"husky": "^4.3.6",
"np": "^7.2.0",
"prettier": "^2.2.1",
"prettier-plugin-java": "^1.0.1",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.2",
"rollup": "^2.35.1",
"rollup-plugin-node-resolve": "^5.2.0",
"swiftlint": "^1.0.1",
"tslib": "^1.13.0",
"typescript": "^3.9.6"
"tslib": "^2.0.3",
"typescript": "^4.0.5"
},

@@ -54,3 +54,3 @@ "husky": {

"peerDependencies": {
"@capacitor/core": "^2.4.4"
"@capacitor/core": "^2.4.5"
},

@@ -57,0 +57,0 @@ "files": [

@@ -50,5 +50,6 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>

- a [Ionic/Vue app](#ionic/vue)
Other frameworks will be tested later
- Ionic/Vue will require an update of the `vue-sqlite-hook`.
- Stencil

@@ -96,3 +97,2 @@

new ArrayList<Class<? extends Plugin>>() {
{

@@ -170,2 +170,3 @@ // Additional plugins you've installed go here

| addUpgradeStatement | ✅ | ✅ | ✅ | ❌ |
| copyFromAssets | ✅ | ✅ | ✅ | ❌ |

@@ -184,2 +185,8 @@ ## Documentation

[Ionic/Angular_Usage_Documentation](https://github.com/capacitor-community/sqlite/blob/refactor/docs/Ionic-Angular-Usage.md)
[Ionic/React_Usage_Documentation](https://github.com/capacitor-community/sqlite/blob/refactor/docs/Ionic-React-Usage.md)
[Ionic/Vue_Usage_Documentation](https://github.com/capacitor-community/sqlite/blob/refactor/docs/Ionic-Vue-Usage.md)
## Applications demonstrating the use of the plugin

@@ -195,4 +202,6 @@

### Ionic/Vue (to come later)
### Ionic/Vue
- [vue-sqlite-app-refactor](https://github.com/jepiqueau/vue-sqlite-app-starter/tree/refactor)
### Vue (to come later)

@@ -206,5 +215,5 @@

- [In your Ionic/React App] (to come later)
- [In your Ionic/React App](https://github.com/capacitor-community/sqlite/blob/refactor/docs/Ionic-React-Usage.md)
- [In your Ionic/Vue App] (to come later)
- [In your Ionic/Vue App](https://github.com/capacitor-community/sqlite/blob/refactor/docs/Ionic-Vue-Usage.md)

@@ -227,3 +236,4 @@ ## Dependencies

<td align="center"><a href="https://github.com/paulantoine2"><img src="https://avatars0.githubusercontent.com/u/22882943?s=64&v=4" width="100px;" alt=""/><br /><sub><b>Paul Antoine</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/paulantoine2"><img src="https://avatars2.githubusercontent.com/u/303016?s=60&u=1ce232ae3c22eac7b0b4778e46fe079939c39b40&v=4" width="100px;" alt=""/><br /><sub><b>Karyfars</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/karyfars"><img src="https://avatars2.githubusercontent.com/u/303016?s=60&u=1ce232ae3c22eac7b0b4778e46fe079939c39b40&v=4" width="100px;" alt=""/><br /><sub><b>Karyfars</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/https://github.com/chriswep"><img src="https://avatars2.githubusercontent.com/u/1055809?s=400&u=e555940f143da8be255743028d6838cb5c020b44&v=4" width="100px;" alt=""/><br /><sub><b>Karyfars</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Documentation">📖</a></td>
</tr>

@@ -230,0 +240,0 @@ </table>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc