node-persist-manager 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Luligu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # NodeStorage
2
+
3
+ NodeStorage is a lightweight, file-based storage management system for Node.js, built on top of `node-persist`. It allows for easy and intuitive handling of persistent key-value storage directly within your Node.js applications. This system is ideal for small to medium-sized projects requiring simple data persistence without the overhead of a database system.
4
+
5
+ ## Features
6
+
7
+ - Simple and intuitive API for data storage and retrieval.
8
+ - Asynchronous data handling.
9
+ - Customizable storage directories for isolated storage contexts.
10
+ - Built-in logging capabilities for monitoring storage initialization and operations.
11
+ - Comprehensive test suite using Jest to ensure reliability and performance.
12
+ - Detailed documentation with JSDoc for better developer experience.
13
+
14
+ ## Getting Started
15
+
16
+ ### Prerequisites
17
+
18
+ - Node.js installed on your machine.
19
+ - Basic knowledge of TypeScript and Node.js.
20
+
21
+ ### Installation
22
+
23
+ To get started with NodeStorage in your package
24
+
25
+ ```bash
26
+ npm install node-persist-manager
27
+ ```
28
+
29
+ # Usage
30
+
31
+ ## Initializing NodeStorageManager:
32
+
33
+ Create an instance of NodeStorageManager to manage your storage instances.
34
+
35
+ ```
36
+ import { NodeStorageManager, NodeStorage } from 'node-persist-manager';
37
+ ```
38
+
39
+ ```
40
+ const storageManager = new NodeStorageManager({
41
+ dir: 'path/to/storage/directory', // Optional: Customize the storage directory.
42
+ logging: true, // Optional: Enable logging.
43
+ });
44
+ ```
45
+
46
+ ## Creating a Storage Instance:
47
+
48
+ Use the manager to create a new storage context.
49
+
50
+ ```
51
+ const myStorage = await storageManager.createStorage('myStorageName');
52
+ ```
53
+
54
+ Using the Storage:
55
+
56
+ ## Set a value:
57
+
58
+ ```
59
+ await myStorage.set('myKey', 'myValue');
60
+ ```
61
+
62
+ ## Get a value:
63
+
64
+ ```
65
+ const value = await myStorage.get('myKey');
66
+ console.log(value); // Outputs: 'myValue'
67
+ ```
68
+
69
+ ## Remove a value:
70
+
71
+ ```
72
+ await myStorage.remove('myKey');
73
+ ```
74
+
75
+ ## Clear the storage:
76
+
77
+ ```
78
+ await myStorage.clear();
79
+ ```
80
+
81
+ # API Reference
82
+
83
+ ## NodeStorageManager methods:
84
+
85
+ - createStorage(storageName: string): Promise<NodeStorage>
86
+
87
+ - removeStorage(storageName: string): Promise<boolean>
88
+
89
+ - logStorage(): Promise<void>
90
+
91
+
92
+ ## NodeStorage methods:
93
+
94
+ - set<T = any>(key: NodeStorageKey, value: T): Promise&lt;void&gt;
95
+
96
+ - get<T = any>(key: NodeStorageKey, defaultValue?: T): Promise&lt;T&gt;
97
+
98
+ - remove(key: NodeStorageKey): Promise&lt;void&gt;
99
+
100
+ - clear(): Promise&lt;void&gt;
101
+
102
+ - logStorage(): Promise&lt;void&gt;
103
+
104
+ # Contributing
105
+
106
+ Contributions to NodeStorage are welcome.
107
+
108
+ # License
109
+
110
+ This project is licensed under the MIT License - see the LICENSE file for details.
111
+
112
+ # Acknowledgments
113
+
114
+ Thanks to node-persist for providing the underlying storage mechanism.
@@ -0,0 +1,100 @@
1
+ /**
2
+ * This file contains the classes NodeStorageManager and NodeStorage
3
+ *
4
+ * @file nodeStorage.ts
5
+ * @author Luca Liguori
6
+ * @date 2024-02-02
7
+ * @version 1.0.1
8
+ *
9
+ * All rights reserved.
10
+ *
11
+ */
12
+ import NodePersist, { LocalStorage, InitOptions } from 'node-persist';
13
+ export type NodeStorageKey = string;
14
+ export type NodeStorageName = string;
15
+ /**
16
+ * Class responsible for managing multiple node storages.
17
+ */
18
+ export declare class NodeStorageManager {
19
+ private readonly storage;
20
+ private readonly initOptions;
21
+ private storageNames;
22
+ /**
23
+ * Initializes a new instance of NodeStorageManager with optional initialization options.
24
+ * @param {InitOptions} [initOptions] - Optional initialization options to customize the storage.
25
+ */
26
+ constructor(initOptions?: InitOptions);
27
+ /**
28
+ * Creates and initializes a new storage with a given name.
29
+ * @param {string} storageName - The name of the new storage to create.
30
+ * @returns {Promise<NodeStorage>} A promise that resolves to the newly created NodeStorage instance.
31
+ */
32
+ createStorage(storageName: string): Promise<NodeStorage>;
33
+ /**
34
+ * Removes a storage by its name.
35
+ * @param {string} storageName - The name of the storage to remove.
36
+ * @returns {Promise<boolean>} A promise that resolves to true if the storage was successfully removed, otherwise false.
37
+ */
38
+ removeStorage(storageName: string): Promise<boolean>;
39
+ /**
40
+ * Retrieves the names of all available storages.
41
+ * @returns {Promise<NodeStorageName[]>} A promise that resolves to an array of storage names.
42
+ */
43
+ getStorageNames(): Promise<NodeStorageName[]>;
44
+ /**
45
+ * Logs the names of all managed storages to the console.
46
+ */
47
+ logStorage(): Promise<void>;
48
+ }
49
+ /**
50
+ * Class representing a storage for nodes.
51
+ */
52
+ export declare class NodeStorage {
53
+ private readonly storage;
54
+ private readonly initOptions;
55
+ /**
56
+ * Creates an instance of NodeStorage.
57
+ * @param {LocalStorage} storage - The local storage instance.
58
+ * @param {InitOptions} initOptions - The initialization options.
59
+ */
60
+ constructor(storage: LocalStorage, initOptions: InitOptions);
61
+ /**
62
+ * Sets a value for a given key in the storage.
63
+ * @template T - The type of the value to be stored.
64
+ * @param {NodeStorageKey} key - The key under which the value is stored.
65
+ * @param {T} value - The value to store.
66
+ * @returns {Promise<NodePersist.WriteFileResult>} A promise that resolves with the result of writing the file.
67
+ */
68
+ set<T = any>(key: NodeStorageKey, value: T): Promise<NodePersist.WriteFileResult>;
69
+ /**
70
+ * Retrieves a value for a given key from the storage.
71
+ * If the key does not exist, returns a default value if provided.
72
+ * @template T - The type of the value to retrieve.
73
+ * @param {NodeStorageKey} key - The key of the value to retrieve.
74
+ * @param {T} [defaultValue] - The default value to return if the key is not found.
75
+ * @returns {Promise<T>} A promise that resolves with the value.
76
+ */
77
+ get<T = any>(key: NodeStorageKey, defaultValue?: T): Promise<T>;
78
+ /**
79
+ * Checks if the storage includes a given key.
80
+ * @param {NodeStorageKey} key - The key to check.
81
+ * @returns {Promise<boolean>} A promise that resolves with true if the key exists, otherwise false.
82
+ */
83
+ includes(key: NodeStorageKey): Promise<boolean>;
84
+ /**
85
+ * Removes a value for a given key from the storage.
86
+ * @param {NodeStorageKey} key - The key of the value to remove.
87
+ * @returns {Promise<NodePersist.DeleteFileResult>} A promise that resolves with the result of deleting the file.
88
+ */
89
+ remove(key: NodeStorageKey): Promise<NodePersist.DeleteFileResult>;
90
+ /**
91
+ * Clears all entries from the storage.
92
+ * @returns {Promise<void>} A promise that resolves when the storage is cleared.
93
+ */
94
+ clear(): Promise<void>;
95
+ /**
96
+ * Logs the current storage state to the console.
97
+ */
98
+ logStorage(): Promise<void>;
99
+ }
100
+ //# sourceMappingURL=nodeStorage.d.ts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Q,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrD;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC;IAIxE;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACG,UAAU;CAOjB"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * This file contains the classes NodeStorageManager and NodeStorage
3
+ *
4
+ * @file nodeStorage.ts
5
+ * @author Luca Liguori
6
+ * @date 2024-02-02
7
+ * @version 1.0.1
8
+ *
9
+ * All rights reserved.
10
+ *
11
+ */
12
+ import NodePersist from 'node-persist';
13
+ import { rm } from 'fs/promises';
14
+ import path from 'path';
15
+ /**
16
+ * Class responsible for managing multiple node storages.
17
+ */
18
+ export class NodeStorageManager {
19
+ storage;
20
+ initOptions;
21
+ storageNames = [];
22
+ /**
23
+ * Initializes a new instance of NodeStorageManager with optional initialization options.
24
+ * @param {InitOptions} [initOptions] - Optional initialization options to customize the storage.
25
+ */
26
+ constructor(initOptions) {
27
+ // Merge initOptions with default initOptions
28
+ this.initOptions = Object.assign({
29
+ dir: path.join(process.cwd(), 'node_storage'),
30
+ logging: false,
31
+ }, initOptions);
32
+ // Create and initialize a new instace of LocalStorage
33
+ this.storage = NodePersist.create(this.initOptions);
34
+ this.storage.initSync(this.initOptions);
35
+ console.log(`Storage manager initialized with options ${JSON.stringify(this.initOptions)}`);
36
+ /*
37
+ this.get<Array<NodeStorageName>>('storageNames').then(storageNames => {
38
+ this.storageNames = storageNames;
39
+ });
40
+ */
41
+ }
42
+ /**
43
+ * Creates and initializes a new storage with a given name.
44
+ * @param {string} storageName - The name of the new storage to create.
45
+ * @returns {Promise<NodeStorage>} A promise that resolves to the newly created NodeStorage instance.
46
+ */
47
+ async createStorage(storageName) {
48
+ const initOptions = {};
49
+ Object.assign(initOptions, this.initOptions, { dir: path.join(this.initOptions.dir, '.' + storageName) });
50
+ const storage = NodePersist.create(initOptions);
51
+ await storage.init(initOptions);
52
+ //console.log(`Created storage ${storageName} with options ${JSON.stringify(initOptions)}`);
53
+ // Update storageNames
54
+ this.storageNames = await this.storage.get('storageNames') ?? [];
55
+ //console.log('Storage list(1):', this.storageNames);
56
+ if (!this.storageNames.includes(storageName)) {
57
+ this.storageNames.push(storageName);
58
+ }
59
+ //console.log('Storage list(2):', this.storageNames);
60
+ await this.storage.set('storageNames', this.storageNames);
61
+ //console.log('Storage list(3):', await this.storage.get('storageNames') );
62
+ return new NodeStorage(storage, initOptions);
63
+ }
64
+ /**
65
+ * Removes a storage by its name.
66
+ * @param {string} storageName - The name of the storage to remove.
67
+ * @returns {Promise<boolean>} A promise that resolves to true if the storage was successfully removed, otherwise false.
68
+ */
69
+ async removeStorage(storageName) {
70
+ const dir = path.join(this.initOptions.dir, '.' + storageName);
71
+ try {
72
+ await rm(dir, { recursive: true });
73
+ //console.log('Storage removed');
74
+ // Update storageNames
75
+ this.storageNames = await this.storage.get('storageNames') ?? [];
76
+ const index = this.storageNames.indexOf(storageName);
77
+ if (index > -1) {
78
+ this.storageNames.splice(index, 1);
79
+ }
80
+ await this.storage.set('storageNames', this.storageNames);
81
+ //console.log('Storage list:', await this.storage.get('storageNames') );
82
+ return true;
83
+ }
84
+ catch (err) {
85
+ //console.error('Error removing storage:', err);
86
+ return false;
87
+ }
88
+ }
89
+ /**
90
+ * Retrieves the names of all available storages.
91
+ * @returns {Promise<NodeStorageName[]>} A promise that resolves to an array of storage names.
92
+ */
93
+ async getStorageNames() {
94
+ this.storageNames = await this.storage.get('storageNames') ?? [];
95
+ return this.storageNames;
96
+ }
97
+ /**
98
+ * Logs the names of all managed storages to the console.
99
+ */
100
+ async logStorage() {
101
+ console.log('This NodeStorageManager has these storages:');
102
+ const storageNames = await this.storage.get('storageNames') ?? [];
103
+ storageNames.forEach(name => {
104
+ console.log(`- ${name}`);
105
+ });
106
+ }
107
+ }
108
+ /**
109
+ * Class representing a storage for nodes.
110
+ */
111
+ export class NodeStorage {
112
+ storage;
113
+ initOptions;
114
+ /**
115
+ * Creates an instance of NodeStorage.
116
+ * @param {LocalStorage} storage - The local storage instance.
117
+ * @param {InitOptions} initOptions - The initialization options.
118
+ */
119
+ constructor(storage, initOptions) {
120
+ this.storage = storage;
121
+ this.initOptions = initOptions;
122
+ }
123
+ /**
124
+ * Sets a value for a given key in the storage.
125
+ * @template T - The type of the value to be stored.
126
+ * @param {NodeStorageKey} key - The key under which the value is stored.
127
+ * @param {T} value - The value to store.
128
+ * @returns {Promise<NodePersist.WriteFileResult>} A promise that resolves with the result of writing the file.
129
+ */
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ async set(key, value) {
132
+ return await this.storage.setItem(key, value);
133
+ }
134
+ /**
135
+ * Retrieves a value for a given key from the storage.
136
+ * If the key does not exist, returns a default value if provided.
137
+ * @template T - The type of the value to retrieve.
138
+ * @param {NodeStorageKey} key - The key of the value to retrieve.
139
+ * @param {T} [defaultValue] - The default value to return if the key is not found.
140
+ * @returns {Promise<T>} A promise that resolves with the value.
141
+ */
142
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
+ async get(key, defaultValue) {
144
+ const value = await this.storage.getItem(key);
145
+ return value !== undefined ? value : defaultValue;
146
+ }
147
+ /**
148
+ * Checks if the storage includes a given key.
149
+ * @param {NodeStorageKey} key - The key to check.
150
+ * @returns {Promise<boolean>} A promise that resolves with true if the key exists, otherwise false.
151
+ */
152
+ async includes(key) {
153
+ const keys = await this.storage.keys();
154
+ return keys.includes(key);
155
+ }
156
+ /**
157
+ * Removes a value for a given key from the storage.
158
+ * @param {NodeStorageKey} key - The key of the value to remove.
159
+ * @returns {Promise<NodePersist.DeleteFileResult>} A promise that resolves with the result of deleting the file.
160
+ */
161
+ async remove(key) {
162
+ return await this.storage.removeItem(key);
163
+ }
164
+ /**
165
+ * Clears all entries from the storage.
166
+ * @returns {Promise<void>} A promise that resolves when the storage is cleared.
167
+ */
168
+ async clear() {
169
+ return await this.storage.clear();
170
+ }
171
+ /**
172
+ * Logs the current storage state to the console.
173
+ */
174
+ async logStorage() {
175
+ console.log(`This NodeStorage has ${await this.storage.length()} keys:`);
176
+ const keys = await this.storage.keys();
177
+ keys.forEach(async (key) => {
178
+ console.log(`- ${key}: ${await this.storage.get(key)}`);
179
+ });
180
+ }
181
+ }
182
+ //# sourceMappingURL=nodeStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeStorage.js","sourceRoot":"","sources":["../src/nodeStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,WAA0C,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACZ,OAAO,CAAe;IACtB,WAAW,CAAc;IAClC,YAAY,GAAoB,EAAE,CAAC;IAE3C;;;OAGG;IACH,YAAY,WAAyB;QACnC,6CAA6C;QAC7C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;YAC/B,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;YAC7C,OAAO,EAAE,KAAK;SACA,EAAE,WAAW,CAAC,CAAC;QAE/B,sDAAsD;QACtD,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC5F;;;;cAIA;IACF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,MAAM,WAAW,GAA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}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "node-persist-manager",
3
+ "version": "1.0.3",
4
+ "description": "Asyncronous Node.js storage manager in type script",
5
+ "author": "https://github.com/Luligu",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Luligu/node-persist-manager"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Luligu/node-persist-manager/issues"
13
+ },
14
+ "engines": {
15
+ "node": ">=18.0.0"
16
+ },
17
+ "type": "module",
18
+ "main": "dist/nodeStorage.js",
19
+ "types": "dist/nodeStorage.d.js",
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "watch": "tsc --watch",
23
+ "test": "jest",
24
+ "test:verbose": "jest --verbose",
25
+ "test:watch": "jest --watch",
26
+ "lint": "eslint src/**.ts",
27
+ "lint:fix": "eslint src/**.ts --fix",
28
+ "clean": "rimraf tsconfig.tsbuildinfo ./dist",
29
+ "cleanBuild": "npm run clean && tsc",
30
+ "deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modules ./node_storage",
31
+ "prepublishOnly": "npm run lint && npm run cleanBuild",
32
+ "checkDependencies": "npx npm-check-updates",
33
+ "updateDependencies": "npx npm-check-updates -u"
34
+ },
35
+ "keywords": [
36
+ "node-persist",
37
+ "persist",
38
+ "storage",
39
+ "context",
40
+ "NodeStorageManager",
41
+ "NodeStorage"
42
+ ],
43
+ "devDependencies": {
44
+ "@types/jest": "^29.5.12",
45
+ "@types/node": "^20.11.19",
46
+ "@types/node-persist": "^3.1.8",
47
+ "@typescript-eslint/eslint-plugin": "^7.0.2",
48
+ "@typescript-eslint/parser": "^7.0.2",
49
+ "eslint": "^8.56.0",
50
+ "jest": "^29.7.0",
51
+ "ts-jest": "^29.1.2",
52
+ "typescript": "^5.3.3"
53
+ },
54
+ "dependencies": {
55
+ "node-persist": "^4.0.1"
56
+ }
57
+ }