New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

firestorm-db

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestorm-db - npm Package Compare versions

Comparing version 1.11.0 to 1.11.1

11

package.json
{
"name": "firestorm-db",
"version": "1.11.0",
"version": "1.11.1",
"description": "Self hosted Firestore-like database with API endpoints based on micro bulk operations",

@@ -13,3 +13,3 @@ "main": "src/index.js",

"local_tests": "sudo act -P ubuntu-latest=shivammathur/node:latest -j js-wrapper-test",
"jsdoc": "jsdoc -a all -c jsdoc.json -R README.md src/index.js -d docs/jsdoc",
"jsdoc": "jsdoc src/index.js -c jsdoc.json -R README.md -t ./node_modules/docdash -d out",
"nodemon_jsdoc": "nodemon -x npm run jsdoc --watch src/index.js --watch jsdoc.json",

@@ -43,3 +43,3 @@ "types": "npx tsc",

"dependencies": {
"axios": "^1.6.2"
"axios": "^1.6.7"
},

@@ -52,10 +52,9 @@ "devDependencies": {

"jsdoc": "^4.0.2",
"jsdoc-to-markdown": "^8.0.0",
"jsdoc-to-markdown": "^8.0.1",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^3.1.1",
"prettier": "^3.2.4",
"recursive-copy": "^2.0.14",
"type-fest": "^4.8.3",
"typescript": "^5.3.3"
}
}

@@ -9,4 +9,3 @@ <div align="center">

<a href="https://github.com/TheRolfFR/firestorm-db/blob/main/CHANGELOG.md"> <img alt="Static Badge" src="https://img.shields.io/badge/Changelog-Read_here-blue?style=flat-square"></a>
<a href="https://github.com/TheRolfFR/firestorm-db/actions/workflows/testjs.yml"> <img src="https://img.shields.io/github/actions/workflow/status/TheRolfFR/firestorm-db/testjs.yml?style=flat-square
" alt="Tests" /></a>
<a href="https://github.com/TheRolfFR/firestorm-db/actions/workflows/testjs.yml"> <img src="https://img.shields.io/github/actions/workflow/status/TheRolfFR/firestorm-db/testjs.yml?style=flat-square" alt="Tests" /></a>

@@ -86,13 +85,13 @@ </div>

| Name | Parameters | Description |
| ----------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| sha1() | none | Returns the file sha1 hash. May vary from read_raw because read_raw adds ID fields to the entries. Compare with stringify version of your file. |
| read_raw() | none | Reads the entire collection |
| get(id) | id: `String\|Name` | Tries to get one element by its key |
| search(searchOptions, random) | searchOptions: `SearchOption[]` random?:`false\|true\|Number` | Searches collections and returns matching results. <br>You can randomize the output order with random as true or a given seed. |
| searchKeys(keys) | keys: `String[] \| Number[]` | Searches collections with given keys and returns matching results |
| select(selectOption) | selectOption: `{ field: String[] }` | Improved read_raw with field selection |
| random(max, seed, offset) | max?: `Integer >= -1` seed?: `Integer` offset?:`Integer >= 0` | Reads random entries of collection |
| Name | Parameters | Description |
| ----------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| sha1() | none | Get the sha1 hash of the file. Can be used to see if same file content without downloading the file. |
| readRaw() | none | Returns the whole content of the JSON. ID values are injected for easier iteration, so this may be different to sha1(). |
| get(id) | id: `string \| number` | Get an element from the collection. |
| search(searchOptions, random) | searchOptions: `SearchOption[]` random?:`boolean \| number` | Search through the collection You can randomize the output order with random as true or a given seed. |
| searchKeys(keys) | keys: `string[] \| number[]` | Search specific keys through the collection. |
| select(selectOption) | selectOption: `{ field: string[] }` | Get only selected fields from the collection Essentially an upgraded version of readRaw. |
| random(max, seed, offset) | max?: `integer >= -1` seed?: `integer` offset?:`integer >= 0` | Reads random entries of collection. |
The search method can take one or more options to filter entries in a collection. A search option studies a `field` with a `criteria` and compares it to a `value`. You can also use the boolean `ignoreCase` option for string values.
The search method can take one or more options to filter entries in a collection. A search option takes a `field` with a `criteria` and compares it to a `value`. You can also use the boolean `ignoreCase` option for string values.

@@ -103,36 +102,36 @@ Not all criteria are available depending the field type. There are more options available than the firestore `where` command, allowing you to get better and faster search results.

| Criteria | Types allowed | Description |
| ---------------------- | ----------------------- | ------------------------------------------------------------------------------------------------- |
| `'!='` | Boolean, Number, String | Searches if the entry field's value is different from yours |
| `'=='` | Boolean, Number, String | Searches if the entry field's value is equal to yours |
| `'>='` | Number, String | Searches if the entry field's value is greater or equal than yours |
| `'<='` | Number, String | Searches if the entry field's value is equal to than yours |
| `'>'` | Number, String | Searches if the entry field's value is greater than yours |
| `'<'` | Number, String | Searches if the entry field's value is lower than yours |
| `'in'` | Number, String | Searches if the entry field's value is in the array of values you gave |
| `'includes'` | String | Searches if the entry field's value includes your substring |
| `'startsWith'` | String | Searches if the entry field's value starts with your substring |
| `'endsWith'` | String | Searches if the entry field's value ends with your substring |
| `'array-contains'` | Array | Searches if the entry field's array contains your value |
| `'array-contains-any'` | Array | Searches if the entry field's array ends contains your one value of more inside your values array |
| `'array-length-eq'` | Number | Searches if the entry field's array size is equal to your value |
| `'array-length-df'` | Number | Searches if the entry field's array size is different from your value |
| `'array-length-lt'` | Number | Searches if the entry field's array size is lower than your value |
| `'array-length-gt'` | Number | Searches if the entry field's array size is lower greater than your value |
| `'array-length-le'` | Number | Searches if the entry field's array size is lower or equal to your value |
| `'array-length-ge'` | Number | Searches if the entry field's array size is greater or equal to your value |
| Criteria | Types allowed | Description |
| ---------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------- |
| `'!='` | `boolean`, `number`, `string` | Searches if the entry field's value is different from yours |
| `'=='` | `boolean`, `number`, `string` | Searches if the entry field's value is equal to yours |
| `'>='` | `number`, `string` | Searches if the entry field's value is greater or equal than yours |
| `'<='` | `number`, `string` | Searches if the entry field's value is equal to than yours |
| `'>'` | `number`, `string` | Searches if the entry field's value is greater than yours |
| `'<'` | `number`, `string` | Searches if the entry field's value is lower than yours |
| `'in'` | `number`, `string` | Searches if the entry field's value is in the array of values you gave |
| `'includes'` | `string` | Searches if the entry field's value includes your substring |
| `'startsWith'` | `string` | Searches if the entry field's value starts with your substring |
| `'endsWith'` | `string` | Searches if the entry field's value ends with your substring |
| `'array-contains'` | `Array` | Searches if the entry field's array contains your value |
| `'array-contains-any'` | `Array` | Searches if the entry field's array ends contains your one value of more inside your values array |
| `'array-length-eq'` | `number` | Searches if the entry field's array size is equal to your value |
| `'array-length-df'` | `number` | Searches if the entry field's array size is different from your value |
| `'array-length-lt'` | `number` | Searches if the entry field's array size is lower than your value |
| `'array-length-gt'` | `number` | Searches if the entry field's array size is lower greater than your value |
| `'array-length-le'` | `number` | Searches if the entry field's array size is lower or equal to your value |
| `'array-length-ge'` | `number` | Searches if the entry field's array size is greater or equal to your value |
### Write operations
| Name | Parameters | Description |
| ----------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------- |
| writes_raw() | none | Writes the entire collection **/!\\ Very dangerous /!\\** |
| add(value) | value: `Object` | Adds one element with autoKey into the collection |
| addBulk(values) | value: `Object[]` | Adds multiple elements with autoKey into the collection |
| remove(key) | key: `String\|Name` | Remove one element from the collection with the corresponding key |
| removeBulk(keys) | keys: `String[]\|Name[]` | Remove multiple elements from the collection with the corresponding keys |
| set(key, value) | key: `String\|Name`, value: `Object` | Sets one element with its key and value into the collection |
| setBulk(keys, values) | keys: `String[]\|Name[]`, values: `Object[]` | Sets multiple elements with their corresponding keys and values into the collection |
| editField(obj) | obj: `EditObject` | Changes one field of a given element in a collection |
| editFieldBulk(objArray) | objArray: `EditObject[]` | Changes one field per element in a collection |
| Name | Parameters | Description |
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------- |
| writeRaw() | none | Set the entire JSON file contents **/!\\ Very dangerous /!\\** |
| add(value) | value: `Object` | Adds one element with autoKey into the collection |
| addBulk(values) | value: `Object[]` | Adds multiple elements with autoKey into the collection |
| remove(key) | key: `string \| number` | Remove one element from the collection with the corresponding key |
| removeBulk(keys) | keys: `string[] \| number[]` | Remove multiple elements from the collection with the corresponding keys |
| set(key, value) | key: `string \| number`, value: `Object` | Sets one element with its key and value into the collection |
| setBulk(keys, values) | keys: `string[] \| number[]`, values: `Object[]` | Sets multiple elements with their corresponding keys and values into the collection |
| editField(obj) | obj: `EditObject` | Changes one field of a given element in a collection |
| editFieldBulk(objArray) | objArray: `EditObject[]` | Changes one field per element in a collection |

@@ -143,13 +142,13 @@ ### Edit field operations

| Operation | Value required | Types allowed | Description |
| -------------- | -------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `set` | Yes | any | Sets a field to a given value |
| `remove` | No | any | Removes a field from the element |
| `append` | Yes | String | Appends string at the end of the string field |
| `invert` | No | any | Inverts tate of boolean field |
| `increment` | No | Number | Adds a number to the field, default is 1 |
| `decrement` | No | Number | Retrieves a number to the field, default is -1 |
| `array-push ` | Yes | any | Push an element to the end of an array field |
| `array-delete` | Yes | Integer | Removes and element at a certain index in an array field, check [array_splice documentation](https://www.php.net/manual/function.array-splice) offset for more infos |
| `array-splice` | Yes | [Integer, Integer] | Removes certain elements, check [array_splice documentation](https://www.php.net/manual/function.array-splice) offset and length for more infos |
| Operation | Value required | Types allowed | Description |
| -------------- | -------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `set` | Yes | `any` | Sets a field to a given value |
| `remove` | No | `any` | Removes a field from the element |
| `append` | Yes | `string` | Appends string at the end of the string field |
| `invert` | No | `any` | Inverts tate of boolean field |
| `increment` | No | `number` | Adds a number to the field, default is 1 |
| `decrement` | No | `number` | Retrieves a number to the field, default is -1 |
| `array-push ` | Yes | `any` | Push an element to the end of an array field |
| `array-delete` | Yes | `integer` | Removes and element at a certain index in an array field, check [array_splice documentation](https://www.php.net/manual/function.array-splice) offset for more infos |
| `array-splice` | Yes | `[integer, integer]` | Removes certain elements, check [array_splice documentation](https://www.php.net/manual/function.array-splice) offset and length for more infos |

@@ -164,3 +163,3 @@ <br>

The developer has to create 2 files at the root of this folder: `tokens.php` and `config.php`
The developer has to create two main files at the root of their Firestorm setup: `tokens.php` and `config.php`.

@@ -307,3 +306,3 @@ `tokens.php` will contain the tokens inside a `$db_tokens` value array with the tokens to use. You will use these tokens to write data or read private tables.

All Firestorm methods correspond to an equivalent Axios request. Read requests are GET request and write requests are POST requests with provided JSON data.
All Firestorm methods correspond to an equivalent Axios request to the relevant PHP file. Read requests are GET requests and write requests are POST requests with provided JSON data.

@@ -310,0 +309,0 @@ You always have the same first keys and the one key per method:

@@ -7,6 +7,6 @@ try {

* @typedef {Object} SearchOption
* @property {string} field The field you want to search in
* @property {"!=" | "==" | ">=" | "<=" | "<" | ">" | "in" | "includes" | "startsWith" | "endsWith" | "array-contains" | "array-contains-any" | "array-length-(eq|df|gt|lt|ge|le)" } criteria filter criteria
* @property {string | number | boolean | Array } value the value you want to compare
* @property {boolean} ignoreCase Ignore case on search string
* @property {string} field - The field you want to search in
* @property {"!=" | "==" | ">=" | "<=" | "<" | ">" | "in" | "includes" | "startsWith" | "endsWith" | "array-contains" | "array-contains-any" | "array-length-(eq|df|gt|lt|ge|le)" } criteria - Filter criteria
* @property {string | number | boolean | Array } value - The value you want to compare
* @property {boolean} ignoreCase - Ignore case on search string
*/

@@ -16,6 +16,6 @@

* @typedef {Object} EditObject
* @property {string | number } id the affected element
* @property {string} field The field you want to edit
* @property {"set" | "remove" | "append" | "increment" | "decrement" | "array-push" | "array-delete" | "array-splice"} operation Wanted operation on field
* @property {string | number | boolean | Array } [value] // the value you want to compare
* @property {string | number } id - The affected element
* @property {string} field - The field you want to edit
* @property {"set" | "remove" | "append" | "increment" | "decrement" | "array-push" | "array-delete" | "array-splice"} operation - Wanted operation on field
* @property {string | number | boolean | Array} [value] - The value you want to compare
*/

@@ -25,13 +25,14 @@

* @typedef {Object} SelectOption
* @property {Array<string>} fields Chosen fields to eventually return
* @property {Array<string>} fields - Chosen fields to eventually return
*/
/**
* @ignore
* @typedef {WriteConfirmation}
* @property {string} message - Write status
*/
/** @ignore */
let _address = undefined;
/**
* @ignore
*/
/** @ignore */
let _token = undefined;

@@ -64,5 +65,11 @@

/**
* Axios Promise typedef to avoid documentation generation problems
* @ignore
* @typedef {require("axios").AxiosPromise} AxiosPromise
*/
/**
* Auto-extracts data from Axios request
* @ignore
* @param {Promise<import("axios").AxiosPromise>} request The Axios concerned request
* @param {Promise<AxiosPromise>} request The Axios concerned request
*/

@@ -88,4 +95,5 @@ const __extract_data = (request) => {

/**
* @param {string} name The name of the Collection
* @param {Function} [addMethods] Additional methods and data to add to the objects
* Create a new Firestorm collection instance
* @param {string} name - The name of the collection
* @param {Function} [addMethods] - Additional methods and data to add to the objects
*/

@@ -104,4 +112,4 @@ constructor(name, addMethods = (el) => el) {

* @ignore
* @param {import("axios").AxiosPromise} req Incoming request
* @returns {Object|Object[]}
* @param {AxiosPromise} req - Incoming request
* @returns {Object | Object[]}
*/

@@ -130,3 +138,3 @@ __add_methods(req) {

* @ignore
* @param {AxiosPromise} request The Axios concerned request
* @param {AxiosPromise} request - The Axios concerned request
*/

@@ -141,3 +149,3 @@ __extract_data(request) {

* @ignore
* @param {Object} data Body data
* @param {Object} data - Body data
* @returns {Promise<Object|Object[]>} data out

@@ -157,4 +165,4 @@ */

* Get an element from the collection
* @param {string | number} id The entry ID
* @returns {Promise<T>} Result entry you may be looking for
* @param {string | number} id - The ID of the element you want to get
* @returns {Promise<T>} Corresponding value
*/

@@ -172,3 +180,5 @@ get(id) {

/**
* @returns {string} returns sha1 hash of the file. can be used to see if same file content without downloading the file for example
* Get the sha1 hash of the file
* - Can be used to see if same file content without downloading the file
* @returns {string} The sha1 hash of the file
*/

@@ -184,5 +194,5 @@ sha1() {

* Search through collection
* @param {SearchOption[]} searchOptions Array of search options
* @param {(number | false | true)} [random] Random result seed, disabled by default, but can activated with true or a given seed
* @returns {Promise<T[]>}
* @param {SearchOption[]} searchOptions - Array of search options
* @param {boolean | number} [random] - Random result seed, disabled by default, but can activated with true or a given seed
* @returns {Promise<T[]>} The found elements
*/

@@ -257,4 +267,4 @@ search(searchOptions, random = false) {

* Search specific keys through collection
* @param {string[] | number[]} keys Wanted keys
* @returns {Promise<T[]>} Search results
* @param {string[] | number[]} keys - Array of keys to search
* @returns {Promise<T[]>} The found elements
*/

@@ -285,12 +295,5 @@ searchKeys(keys) {

/**
* @deprecated use readRaw instead
* Returns the whole content of the JSON
* @returns {Promise<Record<string, T>>} The entire collection
*/
read_raw() {
return this.readRaw();
}
/**
* Returns the whole content of the file
* @returns {Promise} // the get promise of the collection raw file content
*/
readRaw() {

@@ -315,5 +318,16 @@ return new Promise((resolve, reject) => {

/**
* Upgraded read raw with field selection
* @param {SelectOption} selectOption Select options
* Returns the whole content of the JSON
* @deprecated Use readRaw instead
* @returns {Promise<Record<string, T>>} The entire collection
*/
read_raw() {
return this.readRaw();
}
/**
* Get only selected fields from the collection
* - Essentially an upgraded version of readRaw
* @param {SelectOption} selectOption - Select options
* @returns {Promise<Record<string, Partial<T>>>} Selected fields
*/
select(selectOption) {

@@ -341,6 +355,6 @@ if (!selectOption) selectOption = {};

* Returns random max entries offsets with a given seed
* @param {number} max integer
* @param {number} seed integer
* @param {number} offset integer
* @returns {Promise} entries
* @param {number} max - The maximum number of entries
* @param {number} seed - The seed to use
* @param {number} offset - The offset to use
* @returns {Promise<T[]>} The found elements
*/

@@ -427,5 +441,5 @@ random(max, seed, offset) {

/**
* Writes the raw JSON file
* @param {Object} value The whole JSON to write
* @returns {Promise<any>}
* Set the entire JSON file contents
* @param {Record<string, T>} value - The value to write
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -440,6 +454,6 @@ writeRaw(value) {

/**
* Writes the raw JSON file
* @param {Object} value
* @deprecated use writeRaw instead
* @returns {Promise<any>}
* Set the entire JSON file contents
* @param {Record<string, T>} value - The value to write
* @deprecated Use writeRaw instead
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -451,5 +465,5 @@ write_raw(value) {

/**
* Add automatically a value to the JSON
* @param {Object} value The value to add
* @returns {Promise<any>}
* Automatically add a value to the JSON file
* @param {T} value - The value (without methods) to add
* @returns {Promise<string>} The generated ID of the added element
*/

@@ -475,5 +489,5 @@ add(value) {

/**
* Add automatically multiple values to the JSON
* @param {Object[]} values The values to add
* @returns {Promise<any>}
* Automatically add multiple values to the JSON file
* @param {Object[]} values - The values (without methods) to add
* @returns {Promise<string[]>} The generated IDs of the added elements
*/

@@ -491,5 +505,5 @@ addBulk(values) {

/**
* Remove entry with its key from the JSON
* Remove an element from the collection by its ID
* @param {string | number} key The key from the entry to remove
* @returns {Promise<any>}
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -501,5 +515,5 @@ remove(key) {

/**
* Remove entry with their keys from the JSON
* Remove multiple elements from the collection by their IDs
* @param {string[] | number[]} keys The key from the entries to remove
* @returns {Promise<any>}
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -511,6 +525,6 @@ removeBulk(keys) {

/**
* Sets an entry in the JSON
* @param {string} key The key of the value you want to set
* @param {Object} value The value you want for this key
* @returns {Promise<any>}
* Set a value in the collection by ID
* @param {string} key - The ID of the element you want to edit
* @param {T} value - The value (without methods) you want to edit
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -524,6 +538,6 @@ set(key, value) {

/**
* Sets multiple entries in the JSON
* @param {string[]} keys The array of keys of the values you want to set
* @param {Object[]} values The values you want for these keys
* @returns {Promise<any>}
* Set multiple values in the collection by their IDs
* @param {string[]} keys - The IDs of the elements you want to edit
* @param {T[]} values - The values (without methods) you want to edit
* @returns {Promise<WriteConfirmation>} Write confirmation
*/

@@ -537,5 +551,5 @@ setBulk(keys, values) {

/**
* Changes one field from an element in this collection
* @param {EditObject} obj The edit object
* @returns {Promise<any>}
* Edit one field of the collection
* @param {EditObject} obj - The edit object
* @returns {Promise<T>} The edited element
*/

@@ -550,3 +564,3 @@ editField(obj) {

* @param {EditObject[]} objArray The edit object array with operations
* @returns {Promise<any>}
* @returns {Promise<T[]>} The edited elements
*/

@@ -564,5 +578,5 @@ editFieldBulk(objArray) {

/**
* @param {string} newValue The new address value
* @returns {string} The stored address value
* @memberof firestorm
* Change the current Firestorm address
* @param {string} [newValue] - The new Firestorm address
* @returns {string} The stored Firestorm address
*/

@@ -577,4 +591,5 @@ address(newValue = undefined) {

/**
* @param {string} newValue The new write token
* @returns {string} The stored write token
* Change the current Firestorm token
* @param {string} [newValue] - The new Firestorm write token
* @returns {string} The stored Firestorm write token
*/

@@ -587,6 +602,9 @@ token(newValue = undefined) {

},
/**
* @param {string} name Collection name to get
* @param {Function} addMethods Additional methods and data to add to the objects
* @returns {Collection}
* Create a new Firestorm collection instance
* @template T
* @param {string} name - The name of the collection
* @param {Function} [addMethods] - Additional methods and data to add to the objects
* @returns {Collection<T>} The collection
*/

@@ -598,4 +616,6 @@ collection(name, addMethods = (el) => el) {

/**
*
* @param {string} name Table name to get
* Create a temporary Firestorm collection with no methods
* @template T
* @param {string} name - The table name to get
* @returns {Collection<T>} The collection
*/

@@ -606,5 +626,3 @@ table(name) {

/**
* Value for the id field when researching content
*/
/** Value for the id field when researching content */
ID_FIELD: ID_FIELD_NAME,

@@ -620,5 +638,5 @@

/**
* gets file back
* Get file back
* @memberof firestorm.files
* @param {string} path File path wanted
* @param {string} path - The file path wanted
*/

@@ -638,4 +656,4 @@ get(path) {

* @memberof firestorm.files
* @param {FormData} form formData with path, filename and file
* @returns {Promise} http response
* @param {FormData} form - The form data with path, filename, and file
* @returns {Promise<any>} HTTP response
*/

@@ -654,4 +672,4 @@ upload(form) {

* @memberof firestorm.files
* @param {string} path File path to delete
* @returns {Promise} http response
* @param {string} path - The file path to delete
* @returns {Promise<any>} HTTP response
*/

@@ -658,0 +676,0 @@ delete(path) {

@@ -137,2 +137,5 @@ export type NumberCriteria =

/** Write status */
export type WriteConfirmation = { message: string };
export type SearchOption<T> = {

@@ -146,3 +149,3 @@ [K in keyof T]: {

value?: any;
/** is it case sensitive? (default: true) */
/** is it case sensitive? (default true) */
ignoreCase?: boolean;

@@ -167,4 +170,5 @@ };

/**
* Create a new Firestorm collection instance
* @param name - The name of the collection
* @param addMethods - The methods you want to add to the collection
* @param addMethods - Additional methods and data to add to the objects
*/

@@ -175,3 +179,4 @@ public constructor(name: string, addMethods?: CollectionMethods<T>);

* Get an element from the collection
* @param id - The id of the element you want to get
* @param id - The ID of the element you want to get
* @returns Corresponding value
*/

@@ -181,4 +186,4 @@ public get(id: string | number): Promise<T>;

/**
* Get the sha1 hash of the file.
* - Can be used to see if same file content without downloading the file for example
* Get the sha1 hash of the file
* - Can be used to see if same file content without downloading the file
* @returns The sha1 hash of the file

@@ -207,3 +212,3 @@ */

/**
* Returns the whole content of the file
* Returns the whole content of the JSON
* @returns The entire collection

@@ -214,3 +219,3 @@ */

/**
* Returns the whole content of the file
* Returns the whole content of the JSON
* @deprecated Use readRaw instead

@@ -222,7 +227,8 @@ * @returns The entire collection

/**
* Get only selected elements from the collection
* Get only selected fields from the collection
* - Essentially an upgraded version of readRaw
* @param option - The option you want to select
* @returns Only selected elements from T
* @returns Selected fields
*/
public select(option: SelectOption<T>): Promise<any[]>;
public select(option: SelectOption<T>): Promise<Record<string, Partial<T>>>;

@@ -239,20 +245,20 @@ /**

/**
* Write the whole content in the JSON file
* Set the entire JSON file contents
* @param value - The value to write
* @returns The written elements
* @returns Write confirmation
*/
public writeRaw(value: Record<string, T>): Promise<string>;
public writeRaw(value: Record<string, T>): Promise<WriteConfirmation>;
/**
* Write the whole content in the JSON file
* Set the entire JSON file contents
* @deprecated Use writeRaw instead
* @param value - The value to write
* @deprecated Use writeRaw instead
* @returns The written elements
* @returns Write confirmation
*/
public write_raw(value: Record<string, T>): Promise<string>;
public write_raw(value: Record<string, T>): Promise<WriteConfirmation>;
/**
* Add automatically a value to the JSON file
* @param value - The value, without methods, to add
* @returns The id of the added element
* Automatically add a value to the JSON file
* @param value - The value (without methods) to add
* @returns The generated ID of the added element
*/

@@ -262,5 +268,5 @@ public add(value: Writable<T>): Promise<string>;

/**
* Add automatically multiple values to the JSON file
* @param values - The values, without methods, to add
* @returns The ids of the added elements
* Automatically add multiple values to the JSON file
* @param values - The values (without methods) to add
* @returns The generated IDs of the added elements
*/

@@ -270,30 +276,30 @@ public addBulk(values: Writable<T>[]): Promise<string[]>;

/**
* Remove an element from the collection by its id
* @param id - The id of the element you want to remove
* @returns The id of the removed element
* Remove an element from the collection by its ID
* @param id - The ID of the element you want to remove
* @returns Write confirmation
*/
public remove(id: string | number): Promise<string>;
public remove(id: string | number): Promise<WriteConfirmation>;
/**
* Remove multiple elements from the collection by their ids
* @param ids - The ids of the elements you want to remove
* @returns The ids of the removed elements
* Remove multiple elements from the collection by their IDs
* @param ids - The IDs of the elements you want to remove
* @returns Write confirmation
*/
public removeBulk(ids: string[] | number[]): Promise<string>;
public removeBulk(ids: string[] | number[]): Promise<WriteConfirmation>;
/**
* Set a value in the collection by its id
* @param id - The id of the element you want to edit
* @param value - The value, without methods, you want to edit
* @returns The edited element
* Set a value in the collection by ID
* @param id - The ID of the element you want to edit
* @param value - The value (without methods) you want to edit
* @returns Write confirmation
*/
public set(id: string | number, value: Writable<T>): Promise<string>;
public set(id: string | number, value: Writable<T>): Promise<WriteConfirmation>;
/**
* Set multiple values in the collection by their ids
* @param ids - The ids of the elements you want to edit
* @param values - The values, without methods, you want to edit
* @returns The edited elements
* Set multiple values in the collection by their IDs
* @param ids - The IDs of the elements you want to edit
* @param values - The values (without methods) you want to edit
* @returns Write confirmation
*/
public setBulk(ids: string[] | number[], values: Writable<T>[]): Promise<string>;
public setBulk(ids: string[] | number[], values: Writable<T>[]): Promise<WriteConfirmation>;

@@ -318,9 +324,9 @@ /**

// don't need ID field when adding keys, and settings keys has a separate id argument
// don't need ID field when adding keys, and setting keys has a separate ID argument
type Writable<T> = Omit<Omit<T, NoMethods<T>>, "id">;
/**
* Change the current firestorm address
* @param value - The new firestorm address
* @returns The stored firestorm address
* Change the current Firestorm address
* @param value - The new Firestorm address
* @returns The stored Firestorm address
*/

@@ -330,10 +336,12 @@ export function address(value?: string): string;

/**
* @param value - The new firestorm write token
* @returns The stored firestorm write token
* Change the current Firestorm token
* @param value - The new Firestorm write token
* @returns The stored Firestorm write token
*/
export function token(value: string): string;
export function token(value?: string): string;
/**
* @param value - The new firestorm read token
* @param addMethods - Additional methods you want to add to the collection
* Create a new Firestorm collection instance
* @param value - The name of the collection
* @param addMethods - Additional methods and data to add to the objects
* @returns The collection

@@ -344,8 +352,12 @@ */

/**
* Create a temporary Firestorm collection with no methods
* @param table - The table name to get
* @returns The collection
*/
export function table(table: string): Promise<any>;
export function table<T>(table: string): Promise<Collection<T>>;
/** we need to use an abstract class here because `delete` is reserved otherwise */
export abstract class files {
/**
* Firestorm file handler
*/
export declare const files: {
/**

@@ -355,10 +367,10 @@ * Get file back

*/
static get: (path: string) => any;
get(path: string): Promise<any>;
/**
* Upload file
* @param form - The form data with path, filename & file
* @returns http response
* @param form - The form data with path, filename, and file
* @returns HTTP response
*/
static upload: (form: FormData) => Promise<any>;
upload(form: FormData): Promise<any>;

@@ -368,6 +380,6 @@ /**

* @param path - The file path to delete
* @returns http response
* @returns HTTP response
*/
static delete: (path: string) => Promise<any>;
}
delete(path: string): Promise<any>;
};

@@ -374,0 +386,0 @@ /**

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