added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Antoine Aflalo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+278
View File
@@ -0,0 +1,278 @@
[![NodeJs](https://github.com/Belphemur/node-json-db/actions/workflows/nodejs.yml/badge.svg)](https://github.com/Belphemur/node-json-db/actions/workflows/nodejs.yml)[![codecov](https://codecov.io/gh/Belphemur/node-json-db/branch/master/graph/badge.svg?token=J3Ppt4UCbY)](https://codecov.io/gh/Belphemur/node-json-db)[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FBelphemur%2Fnode-json-db.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FBelphemur%2Fnode-json-db?ref=badge_shield)
[![NPM](https://nodei.co/npm/node-json-db.png?downloads=true&stars=true)](https://nodei.co/npm/node-json-db/)
> A simple "database" that use JSON file for Node.JS.
## Installation
Add `node-json-db` to your existing Node.js project.
```bash
yarn add node-json-db
```
## Documentation
[Auto Generated](https://belphemur.github.io/node-json-db)
## Inner Working
### Data
The module stores the data using JavaScript Object directly into a JSON file. You can easily traverse the data to reach
directly the interesting property using the DataPath. The principle of DataPath is the same as XMLPath.
### Example
```javascript
{
test: {
data1 : {
array : ['test','array']
},
data2 : 5
}
}
```
If you want to fetch the value of array, the DataPath is **/test/data1/array**
To reach the value of data2 : **/test/data2**
You can of course get also the full object **test** : **/test**
Or even the root : **/**
## Usage
See [test](https://github.com/Belphemur/node-json-db/tree/master/test) for more usage details.
```javascript
import { JsonDB } from 'node-json-db';
import { Config } from 'node-json-db/dist/lib/JsonDBConfig'
// The first argument is the database filename. If no extension, '.json' is assumed and automatically added.
// The second argument is used to tell the DB to save after each push
// If you put false, you'll have to call the save() method.
// The third argument is to ask JsonDB to save the database in an human readable format. (default false)
// The last argument is the separator. By default it's slash (/)
var db = new JsonDB(new Config("myDataBase", true, false, '/'));
// Pushing the data into the database
// With the wanted DataPath
// By default the push will override the old value
db.push("/test1","super test");
// It also create automatically the hierarchy when pushing new data for a DataPath that doesn't exists
db.push("/test2/my/test",5);
// You can also push directly objects
db.push("/test3", {test:"test", json: {test:["test"]}});
// If you don't want to override the data but to merge them
// The merge is recursive and work with Object and Array.
db.push("/test3", {
new:"cool",
json: {
important : 5
}
}, false);
/*
This give you this results :
{
"test":"test",
"json":{
"test":[
"test"
],
"important":5
},
"new":"cool"
}
*/
// You can't merge primitive.
// If you do this:
db.push("/test2/my/test/",10,false);
// The data will be overriden
// Get the data from the root
var data = db.getData("/");
// From a particular DataPath
var data = db.getData("/test1");
// If you try to get some data from a DataPath that doesn't exists
// You'll get an Error
try {
var data = db.getData("/test1/test/dont/work");
} catch(error) {
// The error will tell you where the DataPath stopped. In this case test1
// Since /test1/test does't exist.
console.error(error);
};
// Deleting data
db.delete("/test1");
// Save the data (useful if you disable the saveOnPush)
db.save();
// In case you have a exterior change to the databse file and want to reload it
// use this method
db.reload();
```
### TypeScript Support
#### v0.8.0
As of v0.8.0, [TypeScript](https://www.typescriptlang.org) types are
included in this package, so using `@types/node-json-db` is no longer required.
#### v1.0.0
JsonDB isn't exported as default any more. You'll need to change how you load the library.
This change is done to follow the right way to import module.
```javascript
import { JsonDB } from 'node-json-db';
import { Config } from 'node-json-db/dist/lib/JsonDBConfig'
const db = new JsonDB(new Config("myDataBase", true, false, '/'));
```
#### Typing
With TypeScript, you have access to a new method: getObject<T> that will take care of typing your return object.
```typescript
import { JsonDB } from 'node-json-db';
import { Config } from 'node-json-db/dist/lib/JsonDBConfig'
const db = new JsonDB(new Config("myDataBase", true, false, '/'));
interface FooBar {
Hello: string
World: number
}
const object = {Hello: "World", World: 5} as FooBar;
db.push("/test", object);
//Will be typed as FooBar in your IDE
const result = db.getObject<FooBar>("/test");
```
### Array Support
You can also access the information stored into arrays and manipulate them.
```typescript
import { JsonDB } from 'node-json-db';
import { Config } from 'node-json-db/dist/lib/JsonDBConfig'
// The first argument is the database filename. If no extension, '.json' is assumed and automatically added.
// The second argument is used to tell the DB to save after each push
// If you put false, you'll have to call the save() method.
// The third argument is to ask JsonDB to save the database in an human readable format. (default false)
const db = new JsonDB(new Config("myDataBase", true, false, '/'));
// This will create an array 'myarray' with the object '{obj:'test'}' at index 0
db.push("/arraytest/myarray[0]", {
obj:'test'
}, true);
// You can retrieve a property of an object included in an array
// testString = 'test';
var testString = db.getData("/arraytest/myarray[0]/obj");
// Doing this will delete the object stored at the index 0 of the array.
// Keep in mind this won't delete the array even if it's empty.
db.delete("/arraytest/myarray[0]");
```
#### Appending in Array
```javascript
// You can also easily append new item to an existing array
// This set the next index with {obj: 'test'}
db.push("/arraytest/myarray[]", {
obj:'test'
}, true);
// The append feature can be used in conjuction with properties
// This will set the next index as an object {myTest: 'test'}
db.push("/arraytest/myarray[]/myTest", 'test', true);
```
#### Last Item in Array
```javascript
// Add basic array
db.push("/arraytest/lastItemArray", [1, 2, 3], true);
// You can easily get the last item of the array with the index -1
// This will return 3
db.getData("/arraytest/lastItemArray[-1]");
// You can delete the last item of an array with -1
// This will remove the integer "3" from the array
db.delete("/arraytest/lastItemArray[-1]");
// This will return 2 since 3 just got removed
db.getData("/arraytest/lastItemArray[-1]");
```
#### Count for Array
```javascript
//
db.push("/arraytest/list", [{id: 65464646155, name: "test"}], true);
// You can have the number of element, in this case = 1
let numberOfElement = db.count("/arraytest/list");
```
#### Get Index in Array
```javascript
// You can have the current index of an object
db.push("/arraytest/myarray", {id: 65464646155, name: "test"}, true);
db.getIndex("/arraytest/myarray", 65464646155);
// By default, the property is 'id'
// You can add another property instead
db.getIndex("/arraytest/myarray", "test", "name");
// It's useful if you want to delete some object
db.delete("/arraytest/myarray[" + db.getIndex("/arraytest/myarray", 65464646155) + "]");
```
### Exception/Error
#### Type
| Type | Explanation |
| ------------- |:----------------------------------------------------------------:|
| DataError | When the error is linked to the Data Given |
| DatabaseError | Linked to a problem with the loading or saving of the Database. |
#### Errors
| Error | Type | Explanation |
| ------------------------------------------------------|:-------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|The Data Path can't be empty |DataError |The Database expect to minimum receive the root **separator** as DataPath. |
|Can't find dataPath: /XXX. Stopped at YYY |DataError |When the full hierarchy of the DataPath given is not present in the Database. It tells you until where it's valid. This error can happen when using *getData* and *delete* |
|Can't merge another type of data with an Array |DataError |If you chose to not override the data (merging) when pushing and the new data is an array but the current data isn't an array (an Object by example). |
|Can't merge an Array with an Object |DataError |Same idea as the previous message. You have an array as current data and ask to merge it with an Object. |
|DataPath: /XXX. YYY is not an array. |DataError |When trying to access an object as an array. |
|DataPath: /XXX. Can't find index INDEX in array YYY |DataError |When trying to access a non-existent index in the array. |
|Only numerical values accepted for array index |DataError |An array can only use number for its indexes. For this use the normal object. |
|The entry at the path (/XXX) needs to be either an Object or an Array |DataError |When using the find method, the rootPath need to point to an object or an array to search into it for the wanted value. |
|Can't Load Database: XXXX |DatabaseError |JsonDB can't load the database for "err" reason. You can find the nested error in **error.inner** |
|Can't save the database: XXX |DatabaseError |JsonDB can't save the database for "err" reason. You can find the nested error in **error.inner** |
|DataBase not loaded. Can't write |DatabaseError |Since the database hasn't been loaded correctly, the module won't let you save the data to avoid erasing your database. |
# Limitations
## Object with `separator` in key
Object pushed with key containing the `separator` character won't be reachable. See [#75](https://github.com/Belphemur/node-json-db/issues/75).
Please consider the `separator` as a reserved character by node-json-db.
# Thanks
[James Davis](https://github.com/davisjam) for helping to fix a regular expression vulnerable to [catastrophic backtracking](https://docs.microsoft.com/en-us/dotnet/standard/base-types/backtracking-in-regular-expressions).
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FBelphemur%2Fnode-json-db.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FBelphemur%2Fnode-json-db?ref=badge_large)
+101
View File
@@ -0,0 +1,101 @@
import { Config } from "./lib/JsonDBConfig";
export declare type FindCallback = (entry: any, index: number | string) => boolean;
export declare class JsonDB {
private loaded;
private data;
private readonly config;
/**
* JSONDB Constructor
* @param filename where to save the "DB". Can also be used to give the whole configuration
* @param saveOnPush save the database at each push command into the json file
* @param humanReadable the JSON file will be readable easily by a human
* @param separator what to use as separator
*/
constructor(filename: string | Config, saveOnPush?: boolean, humanReadable?: boolean, separator?: string);
/**
* Process datapath into different parts
* @param dataPath
*/
private processDataPath;
private retrieveData;
private getParentData;
/**
* Get the wanted data
* @param dataPath path of the data to retrieve
*/
getData(dataPath: string): any;
/**
* Same as getData only here it's directly typed to your object
* @param dataPath path of the data to retrieve
*/
getObject<T>(dataPath: string): T;
/**
* Check for existing datapath
* @param dataPath
*/
exists(dataPath: string): boolean;
/**
* Returns the number of element which constitutes the array
* @param dataPath
*/
count(dataPath: string): number;
/**
* Returns the index of the object that meets the criteria submitted. Returns -1, if no match is found.
* @param dataPath base dataPath from where to start searching
* @param searchValue value to look for in the dataPath
* @param propertyName name of the property to look for searchValue
*/
getIndex(dataPath: string, searchValue: (string | number), propertyName?: string): number;
/**
* Return the index of the value inside the array. Returns -1, if no match is found.
* @param dataPath base dataPath from where to start searching
* @param searchValue value to look for in the dataPath
*/
getIndexValue(dataPath: string, searchValue: (string | number)): number;
private getArrayData;
/**
* Find all specific entry in an array/object
* @param rootPath base dataPath from where to start searching
* @param callback method to filter the result and find the wanted entry. Receive the entry and it's index.
*/
filter<T>(rootPath: string, callback: FindCallback): T[] | undefined;
/**
* Find a specific entry in an array/object
* @param rootPath base dataPath from where to start searching
* @param callback method to filter the result and find the wanted entry. Receive the entry and it's index.
*/
find<T>(rootPath: string, callback: FindCallback): T | undefined;
/**
* Pushing data into the database
* @param dataPath path leading to the data
* @param data data to push
* @param override overriding or not the data, if not, it will merge them
*/
push(dataPath: string, data: any, override?: boolean): void;
/**
* Delete the data
* @param dataPath path leading to the data
*/
delete(dataPath: string): void;
/**
* Only use this if you know what you're doing.
* It reset the full data of the database.
* @param data
*/
resetData(data: any): void;
/**
* Reload the database from the file
*/
reload(): void;
/**
* Manually load the database
* It is automatically called when the first getData is done
*/
load(): void;
/**
* Manually save the database
* By default you can't save the database if it's not loaded
* @param force force the save of the database
*/
save(force?: boolean): void;
}
+347
View File
@@ -0,0 +1,347 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonDB = void 0;
const Utils_1 = require("./lib/Utils");
const FS = require("fs");
const path = require("path");
const mkdirp = require("mkdirp");
const Errors_1 = require("./lib/Errors");
const DBParentData_1 = require("./lib/DBParentData");
const ArrayInfo_1 = require("./lib/ArrayInfo");
const JsonDBConfig_1 = require("./lib/JsonDBConfig");
class JsonDB {
loaded = false;
data = {};
config;
/**
* JSONDB Constructor
* @param filename where to save the "DB". Can also be used to give the whole configuration
* @param saveOnPush save the database at each push command into the json file
* @param humanReadable the JSON file will be readable easily by a human
* @param separator what to use as separator
*/
constructor(filename, saveOnPush = true, humanReadable = false, separator = '/') {
if (filename instanceof JsonDBConfig_1.Config) {
this.config = filename;
}
else {
this.config = new JsonDBConfig_1.Config(filename, saveOnPush, humanReadable, separator);
}
if (!FS.existsSync(this.config.filename)) {
const dirname = path.dirname(this.config.filename);
mkdirp.sync(dirname);
this.save(true);
this.loaded = true;
}
}
/**
* Process datapath into different parts
* @param dataPath
*/
processDataPath(dataPath) {
if (dataPath === undefined || !dataPath.trim()) {
throw new Errors_1.DataError("The Data Path can't be empty", 6);
}
if (dataPath == this.config.separator) {
return [];
}
dataPath = (0, Utils_1.removeTrailingChar)(dataPath, this.config.separator);
const path = dataPath.split(this.config.separator);
path.shift();
return path;
}
retrieveData(dataPath, create = false) {
this.load();
const thisDb = this;
const recursiveProcessDataPath = (data, index) => {
let property = dataPath[index];
/**
* Find the wanted Data or create it.
*/
function findData(isArray = false) {
if (data.hasOwnProperty(property)) {
data = data[property];
}
else if (create) {
if (isArray) {
data[property] = [];
}
else {
data[property] = {};
}
data = data[property];
}
else {
throw new Errors_1.DataError(`Can't find dataPath: ${thisDb.config.separator}${dataPath.join(thisDb.config.separator)}. Stopped at ${property}`, 5);
}
}
const arrayInfo = ArrayInfo_1.ArrayInfo.processArray(property);
if (arrayInfo) {
property = arrayInfo.property;
findData(true);
if (!Array.isArray(data)) {
throw new Errors_1.DataError(`DataPath: ${thisDb.config.separator}${dataPath.join(thisDb.config.separator)}. ${property} is not an array.`, 11);
}
const arrayIndex = arrayInfo.getIndex(data, true);
if (!arrayInfo.append && data.hasOwnProperty(arrayIndex)) {
data = data[arrayIndex];
}
else if (create) {
if (arrayInfo.append) {
data.push({});
data = data[data.length - 1];
}
else {
data[arrayIndex] = {};
data = data[arrayIndex];
}
}
else {
throw new Errors_1.DataError(`DataPath: ${thisDb.config.separator}${dataPath.join(thisDb.config.separator)}. . Can't find index ${arrayInfo.index} in array ${property}`, 10);
}
}
else {
findData();
}
if (dataPath.length == ++index) {
return data;
}
return recursiveProcessDataPath(data, index);
};
if (dataPath.length === 0) {
return this.data;
}
return recursiveProcessDataPath(this.data, 0);
}
getParentData(dataPath, create) {
const path = this.processDataPath(dataPath);
const last = path.pop();
return new DBParentData_1.DBParentData(this.retrieveData(path, create), this, dataPath, last);
}
/**
* Get the wanted data
* @param dataPath path of the data to retrieve
*/
getData(dataPath) {
const path = this.processDataPath(dataPath);
return this.retrieveData(path, false);
}
/**
* Same as getData only here it's directly typed to your object
* @param dataPath path of the data to retrieve
*/
getObject(dataPath) {
return this.getData(dataPath);
}
/**
* Check for existing datapath
* @param dataPath
*/
exists(dataPath) {
try {
this.getData(dataPath);
return true;
}
catch (e) {
if (e instanceof Errors_1.DataError) {
return false;
}
throw e;
}
}
/**
* Returns the number of element which constitutes the array
* @param dataPath
*/
count(dataPath) {
const result = this.getData(dataPath);
if (!Array.isArray(result)) {
throw new Errors_1.DataError(`DataPath: ${dataPath} is not an array.`, 11);
}
const path = this.processDataPath(dataPath);
const data = this.retrieveData(path, false);
return data.length;
}
/**
* Returns the index of the object that meets the criteria submitted. Returns -1, if no match is found.
* @param dataPath base dataPath from where to start searching
* @param searchValue value to look for in the dataPath
* @param propertyName name of the property to look for searchValue
*/
getIndex(dataPath, searchValue, propertyName = 'id') {
const data = this.getArrayData(dataPath);
return data.map(function (element) { return element[propertyName]; }).indexOf(searchValue);
}
/**
* Return the index of the value inside the array. Returns -1, if no match is found.
* @param dataPath base dataPath from where to start searching
* @param searchValue value to look for in the dataPath
*/
getIndexValue(dataPath, searchValue) {
return this.getArrayData(dataPath).indexOf(searchValue);
}
getArrayData(dataPath) {
const result = this.getData(dataPath);
if (!Array.isArray(result)) {
throw new Errors_1.DataError(`DataPath: ${dataPath} is not an array.`, 11);
}
const path = this.processDataPath(dataPath);
return this.retrieveData(path, false);
}
/**
* Find all specific entry in an array/object
* @param rootPath base dataPath from where to start searching
* @param callback method to filter the result and find the wanted entry. Receive the entry and it's index.
*/
filter(rootPath, callback) {
const result = this.getData(rootPath);
if (Array.isArray(result)) {
return result.filter(callback);
}
if (result instanceof Object) {
const entries = Object.entries(result);
const found = entries.filter((entry) => {
return callback(entry[1], entry[0]);
});
if (!found || found.length < 1) {
return undefined;
}
return found.map((entry) => {
return entry[1];
});
}
throw new Errors_1.DataError("The entry at the path (" + rootPath + ") needs to be either an Object or an Array", 12);
}
/**
* Find a specific entry in an array/object
* @param rootPath base dataPath from where to start searching
* @param callback method to filter the result and find the wanted entry. Receive the entry and it's index.
*/
find(rootPath, callback) {
const result = this.getData(rootPath);
if (Array.isArray(result)) {
return result.find(callback);
}
if (result instanceof Object) {
const entries = Object.entries(result);
const found = entries.find((entry) => {
return callback(entry[1], entry[0]);
});
if (!found || found.length < 2) {
return undefined;
}
return found[1];
}
throw new Errors_1.DataError("The entry at the path (" + rootPath + ") needs to be either an Object or an Array", 12);
}
/**
* Pushing data into the database
* @param dataPath path leading to the data
* @param data data to push
* @param override overriding or not the data, if not, it will merge them
*/
push(dataPath, data, override = true) {
const dbData = this.getParentData(dataPath, true);
if (!dbData) {
throw new Error("Data not found");
}
let toSet = data;
if (!override) {
if (Array.isArray(data)) {
let storedData = dbData.getData();
if (storedData === undefined) {
storedData = [];
}
else if (!Array.isArray(storedData)) {
throw new Errors_1.DataError("Can't merge another type of data with an Array", 3);
}
toSet = storedData.concat(data);
}
else if (data === Object(data)) {
if (Array.isArray(dbData.getData())) {
throw new Errors_1.DataError("Can't merge an Array with an Object", 4);
}
toSet = (0, Utils_1.merge)(dbData.getData(), data);
}
}
dbData.setData(toSet);
if (this.config.saveOnPush) {
this.save();
}
}
/**
* Delete the data
* @param dataPath path leading to the data
*/
delete(dataPath) {
const dbData = this.getParentData(dataPath, true);
if (!dbData) {
return;
}
dbData.delete();
if (this.config.saveOnPush) {
this.save();
}
}
/**
* Only use this if you know what you're doing.
* It reset the full data of the database.
* @param data
*/
resetData(data) {
this.data = data;
}
/**
* Reload the database from the file
*/
reload() {
this.loaded = false;
this.load();
}
;
/**
* Manually load the database
* It is automatically called when the first getData is done
*/
load() {
if (this.loaded) {
return;
}
try {
const data = FS.readFileSync(this.config.filename, 'utf8');
this.data = JSON.parse(data);
this.loaded = true;
}
catch (err) {
const error = new Errors_1.DatabaseError("Can't Load Database", 1, err);
throw error;
}
}
/**
* Manually save the database
* By default you can't save the database if it's not loaded
* @param force force the save of the database
*/
save(force) {
force = force || false;
if (!force && !this.loaded) {
throw new Errors_1.DatabaseError("DataBase not loaded. Can't write", 7);
}
let data = "";
try {
if (this.config.humanReadable) {
data = JSON.stringify(this.data, null, 4);
}
else {
data = JSON.stringify(this.data);
}
FS.writeFileSync(this.config.filename, data, 'utf8');
}
catch (err) {
const error = new Errors_1.DatabaseError("Can't save the database", 2, err);
throw error;
}
}
}
exports.JsonDB = JsonDB;
//# sourceMappingURL=JsonDB.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,40 @@
import { KeyValue } from "./Utils";
export declare const arrayRegex: () => RegExp;
export declare class ArrayInfo {
readonly property: string;
readonly index: number;
readonly append: boolean;
constructor(property: string, index: any);
/**
* Check if the property want to access an Array
* @param property
*/
static processArray(property?: string): ArrayInfo | null;
/**
* Get the index for the array
* @param data
* @param avoidProperty
*/
getIndex(data: KeyValue, avoidProperty?: boolean): number;
/**
* Get the Data
* @param data
*/
getData(data: KeyValue): any;
/**
* Set the data for the array
* @param data
* @param value
*/
setData(data: KeyValue, value: any): void;
/**
* Delete the index from the array
* @param data
*/
delete(data: KeyValue): void;
/**
* Check if the ArrayInfo is valid for the given data
* @param data
*/
isValid(data: KeyValue): boolean;
}
@@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayInfo = exports.arrayRegex = void 0;
const Errors_1 = require("./Errors");
function isInt(value) {
return !isNaN(value) &&
Number(value) == value && !isNaN(parseInt(value, 10));
}
const arrayRegex = () => /^([\.0-9a-zA-Z_$\-][0-9a-zA-Z_\-$\.]*)\[((?!(\]|\[)).*|)\]$/gm;
exports.arrayRegex = arrayRegex;
const regexCache = {};
class ArrayInfo {
property;
index = 0;
append = false;
constructor(property, index) {
this.property = property;
this.append = index === "";
if (isInt(index)) {
this.index = parseInt(index);
}
else if (!this.append) {
throw new Errors_1.DataError("Only numerical values accepted for array index", 200);
}
}
/**
* Check if the property want to access an Array
* @param property
*/
static processArray(property) {
if (typeof property === 'undefined') {
return null;
}
if (regexCache[property]) {
return regexCache[property];
}
const arrayIndexRegex = (0, exports.arrayRegex)();
const match = arrayIndexRegex.exec(property.trim());
if (match != null) {
return (regexCache[property] = new ArrayInfo(match[1], match[2]));
}
return null;
}
/**
* Get the index for the array
* @param data
* @param avoidProperty
*/
getIndex(data, avoidProperty) {
if (avoidProperty === undefined) {
avoidProperty = false;
}
if (this.append) {
return -1;
}
const index = this.index;
if (index == -1) {
const dataIterable = avoidProperty ? data : data[this.property];
if (dataIterable.length === 0) {
return 0;
}
return dataIterable.length - 1;
}
return index;
}
/**
* Get the Data
* @param data
*/
getData(data) {
if (this.append) {
throw new Errors_1.DataError("Can't get data when appending", 100);
}
const index = this.getIndex(data);
return data[this.property][index];
}
/**
* Set the data for the array
* @param data
* @param value
*/
setData(data, value) {
if (this.append) {
data[this.property].push(value);
}
else {
const index = this.getIndex(data);
data[this.property][index] = value;
}
}
/**
* Delete the index from the array
* @param data
*/
delete(data) {
if (this.append) {
throw new Errors_1.DataError("Can't delete an appended data", 10);
}
const index = this.getIndex(data);
data[this.property].splice(index, 1);
}
/**
* Check if the ArrayInfo is valid for the given data
* @param data
*/
isValid(data) {
const index = this.getIndex(data);
return data[this.property].hasOwnProperty(index);
}
}
exports.ArrayInfo = ArrayInfo;
//# sourceMappingURL=ArrayInfo.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayInfo.js","sourceRoot":"","sources":["../../src/lib/ArrayInfo.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAGlC,SAAS,KAAK,CAAC,KAAU;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAA;AAC7D,CAAC;AAEM,MAAM,UAAU,GAAG,GAAG,EAAE,CAA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GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACxC,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,IAAc;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACpD,CAAC;CACJ;AA7GD,8BA6GC"}
@@ -0,0 +1,27 @@
import { KeyValue } from "./Utils";
import { JsonDB } from "../JsonDB";
export declare class DBParentData {
readonly parent?: string;
readonly data: KeyValue;
readonly db: JsonDB;
readonly dataPath: string;
constructor(data: any, db: JsonDB, dataPath: string, parent?: string);
/**
* Check if it's an array
* @param deletion
*/
private checkArray;
/**
* Get the data linked to this path
*/
getData(): any;
/**
* Set the data to the wanted path
* @param toSet
*/
setData(toSet: any): void;
/**
* Delete the data of the current path
*/
delete(): void;
}
@@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DBParentData = void 0;
const ArrayInfo_1 = require("./ArrayInfo");
const Errors_1 = require("./Errors");
class DBParentData {
parent;
data;
db;
dataPath;
constructor(data, db, dataPath, parent) {
this.parent = parent;
this.data = data;
this.db = db;
this.dataPath = dataPath;
}
/**
* Check if it's an array
* @param deletion
*/
checkArray(deletion = false) {
const arrayInfo = ArrayInfo_1.ArrayInfo.processArray(this.parent);
if (arrayInfo && (!arrayInfo.append || deletion) && !arrayInfo.isValid(this.data)) {
throw new Errors_1.DataError("DataPath: /" + this.dataPath + ". Can't find index " + arrayInfo.index + " in array " + arrayInfo.property, 10);
}
return arrayInfo;
}
/**
* Get the data linked to this path
*/
getData() {
if (this.parent === undefined) {
return this.data;
}
const arrayInfo = this.checkArray();
if (arrayInfo) {
return arrayInfo.getData(this.data);
}
else {
return this.data[this.parent];
}
}
/**
* Set the data to the wanted path
* @param toSet
*/
setData(toSet) {
if (this.parent === undefined) {
this.db.resetData(toSet);
return;
}
const arrayInfo = ArrayInfo_1.ArrayInfo.processArray(this.parent);
if (arrayInfo) {
if (!this.data.hasOwnProperty(arrayInfo.property)) {
this.data[arrayInfo.property] = [];
}
else if (!Array.isArray(this.data[arrayInfo.property])) {
throw new Errors_1.DataError("DataPath: /" + this.dataPath + ". " + arrayInfo.property + " is not an array.", 11);
}
arrayInfo.setData(this.data, toSet);
}
else {
this.data[this.parent] = toSet;
}
}
/**
* Delete the data of the current path
*/
delete() {
if (this.parent === undefined) {
this.db.resetData({});
return;
}
const arrayInfo = this.checkArray(true);
if (arrayInfo) {
arrayInfo.delete(this.data);
}
else {
delete this.data[this.parent];
}
}
}
exports.DBParentData = DBParentData;
//# sourceMappingURL=DBParentData.js.map
@@ -0,0 +1 @@
{"version":3,"file":"DBParentData.js","sourceRoot":"","sources":["../../src/lib/DBParentData.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AACrC,qCAAkC;AAIlC,MAAa,YAAY;IACZ,MAAM,CAAS;IACf,IAAI,CAAU;IACd,EAAE,CAAQ;IACV,QAAQ,CAAQ;IAGzB,YAAY,IAAS,EAAE,EAAU,EAAE,QAAgB,EAAE,MAAe;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACK,UAAU,CAAC,WAAoB,KAAK;QACxC,MAAM,SAAS,GAAG,qBAAS,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACrD,IAAI,SAAS,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC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mB,EAAE,EAAE,CAAC,CAAA;aAC3G;YACD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;SACtC;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAA;SACjC;IAEL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC3B,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;YACrB,OAAM;SACT;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,SAAS,EAAE;YACX,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SAC9B;aAAM;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAChC;IACL,CAAC;CACJ;AAjFD,oCAiFC"}
@@ -0,0 +1,10 @@
export declare abstract class NestedError extends Error {
readonly inner?: Error;
readonly id: Number;
constructor(message: string, id: Number, inner?: Error);
toString(): string;
}
export declare class DatabaseError extends NestedError {
}
export declare class DataError extends NestedError {
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataError = exports.DatabaseError = exports.NestedError = void 0;
class NestedError extends Error {
inner;
id;
constructor(message, id, inner) {
super(message);
this.inner = inner;
this.id = id;
this.name = this.constructor.name;
}
toString() {
const string = this.name + ": " + this.message;
if (this.inner) {
return string + ':\n' + this.inner;
}
return string;
}
}
exports.NestedError = NestedError;
class DatabaseError extends NestedError {
}
exports.DatabaseError = DatabaseError;
class DataError extends NestedError {
}
exports.DataError = DataError;
//# sourceMappingURL=Errors.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../src/lib/Errors.ts"],"names":[],"mappings":";;;AAAA,MAAsB,WAAY,SAAQ,KAAK;IAClC,KAAK,CAAQ;IACb,EAAE,CAAQ;IAGnB,YAAmB,OAAe,EAAE,EAAU,EAAE,KAAa;QACzD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACrC,CAAC;IAGD,QAAQ;QACJ,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;QAC9C,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,OAAO,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;SACrC;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ;AApBD,kCAoBC;AAED,MAAa,aAAc,SAAQ,WAAW;CAC7C;AADD,sCACC;AAED,MAAa,SAAU,SAAQ,WAAW;CACzC;AADD,8BACC"}
@@ -0,0 +1,13 @@
export interface JsonDBConfig {
filename: string;
saveOnPush: boolean;
humanReadable: boolean;
separator: string;
}
export declare class Config implements JsonDBConfig {
filename: string;
humanReadable: boolean;
saveOnPush: boolean;
separator: string;
constructor(filename: string, saveOnPush?: boolean, humanReadable?: boolean, separator?: string);
}
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const path = require("path");
class Config {
filename;
humanReadable;
saveOnPush;
separator;
constructor(filename, saveOnPush = true, humanReadable = false, separator = '/') {
this.filename = filename;
// Force json if no extension
if (path.extname(filename) === "") {
this.filename += ".json";
}
this.humanReadable = humanReadable;
this.saveOnPush = saveOnPush;
this.separator = separator;
}
}
exports.Config = Config;
//# sourceMappingURL=JsonDBConfig.js.map
@@ -0,0 +1 @@
{"version":3,"file":"JsonDBConfig.js","sourceRoot":"","sources":["../../src/lib/JsonDBConfig.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAS7B,MAAa,MAAM;IACjB,QAAQ,CAAQ;IAChB,aAAa,CAAS;IACtB,UAAU,CAAS;IACnB,SAAS,CAAQ;IAGjB,YAAY,QAAgB,EAAE,aAAsB,IAAI,EAAE,gBAAyB,KAAK,EAAE,YAAoB,GAAG;QAC/G,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAExB,6BAA6B;QAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE;YACjC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAA;SACzB;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAnBD,wBAmBC"}
@@ -0,0 +1,5 @@
export interface KeyValue {
[key: string]: any;
}
export declare const merge: (...arrays: KeyValue[]) => KeyValue;
export declare const removeTrailingChar: (dataPath: string, trailing: string) => string;
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeTrailingChar = exports.merge = void 0;
const merge = (...arrays) => {
const destination = {};
arrays.forEach(function (source) {
var prop;
for (prop in source) {
if (prop in destination && destination[prop] === null) {
destination[prop] = source[prop];
}
else if (prop in destination && Array.isArray(destination[prop])) {
// Concat Arrays
destination[prop] = destination[prop].concat(source[prop]);
}
else if (prop in destination && typeof destination[prop] === "object") {
// Merge Objects
destination[prop] = (0, exports.merge)(destination[prop], source[prop]);
}
else {
// Set new values
destination[prop] = source[prop];
}
}
});
return destination;
};
exports.merge = merge;
const removeTrailingChar = (dataPath, trailing) => {
if (dataPath.length > 1 && dataPath.endsWith(trailing)) {
return dataPath.substring(0, dataPath.length - 1);
}
return dataPath;
};
exports.removeTrailingChar = removeTrailingChar;
//# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Utils.js","sourceR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,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;KACpD;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AALY,QAAA,kBAAkB,sBAK9B"}
+113
View File
@@ -0,0 +1,113 @@
{
"_from": "node-json-db@^1.1.0",
"_id": "node-json-db@1.4.1",
"_inBundle": false,
"_integrity": "sha512-hyfnBtuN3kb88SMmDgVil53Frygx+yYkVi6t10VjpEsPseuMI8+gT+FF37DOcyGCr/1wq6qNIr5PnFimCDlzfA==",
"_location": "/node-json-db",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "node-json-db@^1.1.0",
"name": "node-json-db",
"escapedName": "node-json-db",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/node-json-db/-/node-json-db-1.4.1.tgz",
"_shasum": "d5d0898b97902d7ffa6e082c3fe414582fcb363e",
"_spec": "node-json-db@^1.1.0",
"_where": "/home/pi/MagicMirror/modules/MMM-COVID19-AMPEL",
"author": {
"name": "Antoine Aflalo",
"email": "antoineaf+npm@admincmd.com"
},
"bugs": {
"url": "https://github.com/Belphemur/node-json-db/issues"
},
"bundleDependencies": false,
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"mkdirp": "~1.0.4"
},
"deprecated": false,
"description": "Database using JSON file as storage for Node.JS",
"devDependencies": {
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/git": "^10.0.0",
"@types/jest": "^27.0.0",
"@types/mkdirp": "^1.0.1",
"@types/node": "^16.0.0",
"@types/safe-regex": "^1.1.2",
"cz-conventional-changelog": "^3.3.0",
"husky": "^7.0.0",
"jest": "^27.2.0",
"last-release-git": "^0.0.3",
"safe-regex": "~2.1.1",
"semantic-release": "^18.0.0",
"travis-deploy-once": "^5.0.11",
"ts-jest": "^27.0.5",
"typedoc": "^0.22.3",
"typescript": "^4.4.3",
"validate-commit-msg": "^2.14.0"
},
"files": [
"dist/",
"README.md",
"LICENSE"
],
"homepage": "https://github.com/Belphemur/node-json-db",
"husky": {
"hooks": {
"commit-msg": "validate-commit-msg"
}
},
"keywords": [
"database",
"json",
"db",
"typescript"
],
"license": "MIT",
"main": "dist/JsonDB.js",
"name": "node-json-db",
"release": {
"getLastRelease": "last-release-git",
"verifyConditions": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github"
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [
"@semantic-release/github",
"@semantic-release/npm"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/Belphemur/node-json-db.git"
},
"scripts": {
"build": "tsc",
"build:doc": "typedoc --entryPointStrategy expand ./src",
"prepare": "husky install",
"semantic-release": "semantic-release",
"test": "jest --coverage",
"travis-deploy-once": "travis-deploy-once"
},
"types": "dist/JsonDB.d.ts",
"version": "1.4.1"
}