@iobroker/db-objects-jsonl 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a
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/build/cjs/index.js +5 -3
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/objects/objectsInMemJsonlDB.d.ts +38 -7
- package/build/cjs/lib/objects/objectsInMemJsonlDB.js +67 -31
- package/build/cjs/lib/objects/objectsInMemJsonlDB.js.map +3 -3
- package/build/cjs/lib/objects/objectsInMemServerClass.d.ts +41 -8
- package/build/cjs/lib/objects/objectsInMemServerClass.js +27 -2
- package/build/cjs/lib/objects/objectsInMemServerClass.js.map +3 -3
- package/build/cjs/lib/objects/objectsInMemServerRedis.d.ts +50 -30
- package/build/cjs/lib/objects/objectsInMemServerRedis.js +69 -34
- package/build/cjs/lib/objects/objectsInMemServerRedis.js.map +4 -4
- package/build/esm/lib/objects/objectsInMemJsonlDB.d.ts +38 -7
- package/build/esm/lib/objects/objectsInMemJsonlDB.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemJsonlDB.js +67 -36
- package/build/esm/lib/objects/objectsInMemJsonlDB.js.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerClass.d.ts +41 -8
- package/build/esm/lib/objects/objectsInMemServerClass.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerClass.js +25 -1
- package/build/esm/lib/objects/objectsInMemServerClass.js.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerRedis.d.ts +50 -30
- package/build/esm/lib/objects/objectsInMemServerRedis.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerRedis.js +87 -68
- package/build/esm/lib/objects/objectsInMemServerRedis.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Object DB in memory - Server
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2013-
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
5
|
*
|
|
6
6
|
* MIT License
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
import { JsonlDB } from '@alcalzone/jsonl-db';
|
|
9
|
+
/// <reference types="@iobroker/types-dev" />
|
|
11
10
|
import path from 'node:path';
|
|
12
11
|
import fs from 'node:fs';
|
|
13
12
|
import os from 'node:os';
|
|
13
|
+
import { ObjectsInMemoryFileDB } from '@iobroker/db-objects-file';
|
|
14
|
+
import { JsonlDB } from '@alcalzone/jsonl-db';
|
|
14
15
|
import { tools } from '@iobroker/js-controller-common-db';
|
|
15
16
|
/**
|
|
16
17
|
* Normalizes options for the JsonlDB
|
|
17
18
|
*
|
|
18
19
|
* @param conf The jsonlOptions options from iobroker.json
|
|
19
|
-
* @returns
|
|
20
|
+
* @returns the normalized and validated JsonlDB options
|
|
20
21
|
*/
|
|
21
22
|
function normalizeJsonlOptions(conf = {}) {
|
|
22
23
|
const ret = {
|
|
@@ -43,21 +44,26 @@ function normalizeJsonlOptions(conf = {}) {
|
|
|
43
44
|
},
|
|
44
45
|
};
|
|
45
46
|
// Be really careful what we allow here. Incorrect settings may cause problems in production.
|
|
46
|
-
if (
|
|
47
|
+
if (conf.autoCompress && typeof conf.autoCompress === 'object') {
|
|
47
48
|
const ac = conf.autoCompress;
|
|
48
|
-
|
|
49
|
+
if (!ret.autoCompress) {
|
|
50
|
+
throw new Error('Unexpected autoCompress');
|
|
51
|
+
} // Letting the DB grow more than 100x is risky
|
|
49
52
|
if (typeof ac.sizeFactor === 'number' && ac.sizeFactor >= 2 && ac.sizeFactor <= 100) {
|
|
50
53
|
ret.autoCompress.sizeFactor = ac.sizeFactor;
|
|
51
54
|
}
|
|
52
|
-
// Also we should definitely compress once the DB has reached 100k lines or it might grow too big
|
|
55
|
+
// Also we should definitely compress once the DB has reached 100k lines, or it might grow too big
|
|
53
56
|
if (typeof ac.sizeFactorMinimumSize === 'number' &&
|
|
54
57
|
ac.sizeFactorMinimumSize >= 0 &&
|
|
55
58
|
ac.sizeFactorMinimumSize <= 100000) {
|
|
56
59
|
ret.autoCompress.sizeFactorMinimumSize = ac.sizeFactorMinimumSize;
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
if (
|
|
62
|
+
if (conf.throttleFS && typeof conf.throttleFS === 'object') {
|
|
60
63
|
const thr = conf.throttleFS;
|
|
64
|
+
if (!ret.throttleFS) {
|
|
65
|
+
throw new Error('Unexpected throttle fs');
|
|
66
|
+
}
|
|
61
67
|
// Don't write more often than every second and write at least once every hour
|
|
62
68
|
if (typeof thr.intervalMs === 'number' && thr.intervalMs >= 1000 && thr.intervalMs <= 3600000) {
|
|
63
69
|
ret.throttleFS.intervalMs = thr.intervalMs;
|
|
@@ -72,23 +78,31 @@ function normalizeJsonlOptions(conf = {}) {
|
|
|
72
78
|
return ret;
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
75
|
-
* This class inherits InMemoryFileDB class and adds all relevant logic for objects
|
|
81
|
+
* This class inherits InMemoryFileDB class and adds all relevant logic for objects,
|
|
76
82
|
* including the available methods for use by js-controller directly
|
|
77
83
|
*/
|
|
78
84
|
export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
85
|
+
_db;
|
|
86
|
+
_backupInterval;
|
|
87
|
+
/**
|
|
88
|
+
* @param settings Settings for the objects database
|
|
89
|
+
*/
|
|
79
90
|
constructor(settings) {
|
|
80
|
-
settings = settings || {};
|
|
81
91
|
settings.fileDB = {
|
|
82
92
|
fileName: 'objects.json',
|
|
83
93
|
backupDirName: 'backup-objects',
|
|
84
94
|
};
|
|
85
95
|
const jsonlOptions = normalizeJsonlOptions(settings.connection.jsonlOptions);
|
|
96
|
+
const jsonlFileName = 'objects.jsonl';
|
|
86
97
|
settings.jsonlDB = {
|
|
87
|
-
fileName:
|
|
98
|
+
fileName: jsonlFileName,
|
|
88
99
|
};
|
|
89
100
|
super(settings);
|
|
90
|
-
this._db = new JsonlDB(path.join(this.dataDir,
|
|
101
|
+
this._db = new JsonlDB(path.join(this.dataDir, jsonlFileName), jsonlOptions);
|
|
91
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Open the JSONL database, migrating from the legacy file DB if necessary
|
|
105
|
+
*/
|
|
92
106
|
async open() {
|
|
93
107
|
if (!(await this._maybeMigrateFileDB())) {
|
|
94
108
|
await this._db.open();
|
|
@@ -96,31 +110,31 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
96
110
|
// Create an object-like wrapper around the internal Map
|
|
97
111
|
this.dataset = new Proxy(this._db, {
|
|
98
112
|
/**
|
|
99
|
-
* @param target
|
|
100
|
-
* @param prop
|
|
113
|
+
* @param target The proxied JsonlDB instance
|
|
114
|
+
* @param prop The property key being read
|
|
101
115
|
*/
|
|
102
116
|
get(target, prop) {
|
|
103
117
|
return target.get(prop);
|
|
104
118
|
},
|
|
105
119
|
/**
|
|
106
|
-
* @param target
|
|
107
|
-
* @param prop
|
|
120
|
+
* @param target The proxied JsonlDB instance
|
|
121
|
+
* @param prop The property key being checked
|
|
108
122
|
*/
|
|
109
123
|
has(target, prop) {
|
|
110
124
|
return target.has(prop);
|
|
111
125
|
},
|
|
112
126
|
/**
|
|
113
|
-
* @param target
|
|
114
|
-
* @param prop
|
|
115
|
-
* @param value
|
|
127
|
+
* @param target The proxied JsonlDB instance
|
|
128
|
+
* @param prop The property key being written
|
|
129
|
+
* @param value The value to store
|
|
116
130
|
*/
|
|
117
131
|
set(target, prop, value) {
|
|
118
132
|
target.set(prop, value);
|
|
119
133
|
return true;
|
|
120
134
|
},
|
|
121
135
|
/**
|
|
122
|
-
* @param target
|
|
123
|
-
* @param prop
|
|
136
|
+
* @param target The proxied JsonlDB instance
|
|
137
|
+
* @param prop The property key being deleted
|
|
124
138
|
*/
|
|
125
139
|
deleteProperty(target, prop) {
|
|
126
140
|
return target.delete(prop);
|
|
@@ -129,8 +143,8 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
129
143
|
return [...target.keys()];
|
|
130
144
|
},
|
|
131
145
|
/**
|
|
132
|
-
* @param target
|
|
133
|
-
* @param prop
|
|
146
|
+
* @param target The proxied JsonlDB instance
|
|
147
|
+
* @param prop The property key to describe
|
|
134
148
|
*/
|
|
135
149
|
getOwnPropertyDescriptor(target, prop) {
|
|
136
150
|
if (!target.has(prop)) {
|
|
@@ -144,9 +158,9 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
144
158
|
};
|
|
145
159
|
},
|
|
146
160
|
});
|
|
147
|
-
if (this.settings.backup
|
|
161
|
+
if (this.settings.backup?.period && !this.settings.backup.disabled) {
|
|
148
162
|
this._backupInterval = setInterval(() => {
|
|
149
|
-
this.saveBackup();
|
|
163
|
+
this.saveBackup().catch(e => this.log.error(`${this.namespace} Cannot save backup: ${e.message}`));
|
|
150
164
|
}, this.settings.backup.period);
|
|
151
165
|
}
|
|
152
166
|
}
|
|
@@ -157,9 +171,14 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
157
171
|
* If this returns true, the jsonl DB was opened and doesn't need to be opened again.
|
|
158
172
|
*/
|
|
159
173
|
async _maybeMigrateFileDB() {
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
|
|
174
|
+
const jsonlName = this.settings.jsonlDB?.fileName;
|
|
175
|
+
const jsonName = this.settings.fileDB?.fileName;
|
|
176
|
+
if (!jsonlName || !jsonName) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const jsonlFileName = path.join(this.dataDir, jsonlName);
|
|
180
|
+
const jsonFileName = path.join(this.dataDir, jsonName);
|
|
181
|
+
const bakFileName = path.join(this.dataDir, `${jsonName}.bak`);
|
|
163
182
|
// Check the timestamps of each file, defaulting to 0 if they don't exist
|
|
164
183
|
let jsonlTimeStamp = 0;
|
|
165
184
|
let jsonTimeStamp = 0;
|
|
@@ -167,7 +186,7 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
167
186
|
try {
|
|
168
187
|
const stat = fs.statSync(jsonlFileName);
|
|
169
188
|
if (stat.isFile()) {
|
|
170
|
-
jsonlTimeStamp = stat.
|
|
189
|
+
jsonlTimeStamp = stat.mtimeMs;
|
|
171
190
|
}
|
|
172
191
|
}
|
|
173
192
|
catch {
|
|
@@ -176,7 +195,7 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
176
195
|
try {
|
|
177
196
|
const stat = fs.statSync(jsonFileName);
|
|
178
197
|
if (stat.isFile()) {
|
|
179
|
-
jsonTimeStamp = stat.
|
|
198
|
+
jsonTimeStamp = stat.mtimeMs;
|
|
180
199
|
}
|
|
181
200
|
}
|
|
182
201
|
catch {
|
|
@@ -185,7 +204,7 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
185
204
|
try {
|
|
186
205
|
const stat = fs.statSync(bakFileName);
|
|
187
206
|
if (stat.isFile()) {
|
|
188
|
-
bakTimeStamp = stat.
|
|
207
|
+
bakTimeStamp = stat.mtimeMs;
|
|
189
208
|
}
|
|
190
209
|
}
|
|
191
210
|
catch {
|
|
@@ -206,7 +225,7 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
206
225
|
}
|
|
207
226
|
await this._db.open();
|
|
208
227
|
this._db.clear();
|
|
209
|
-
|
|
228
|
+
this._db.importJSON(JSON.parse(fs.readFileSync(importFilename, 'utf8')));
|
|
210
229
|
// And rename the existing files to avoid redoing the work next time
|
|
211
230
|
if (fs.existsSync(jsonFileName)) {
|
|
212
231
|
try {
|
|
@@ -227,14 +246,23 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
227
246
|
// Signal to the caller that the DB is already open
|
|
228
247
|
return true;
|
|
229
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Persist the state. Nothing to do here as the JSONL DB saves behind the scenes.
|
|
251
|
+
*/
|
|
230
252
|
async saveState() {
|
|
231
253
|
// Nothing to do, the DB saves behind the scenes
|
|
232
254
|
}
|
|
233
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Regularly called to store a compressed backup of the DB
|
|
257
|
+
*/
|
|
234
258
|
async saveBackup() {
|
|
259
|
+
const jsonlFileName = this.settings.jsonlDB?.fileName;
|
|
260
|
+
if (!jsonlFileName) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
235
263
|
const now = Date.now();
|
|
236
|
-
const tmpBackupFileName = path.join(os.tmpdir(), `${this.getTimeStr(now)}_${
|
|
237
|
-
const backupFileName = path.join(this.backupDir, `${this.getTimeStr(now)}_${
|
|
264
|
+
const tmpBackupFileName = path.join(os.tmpdir(), `${this.getTimeStr(now)}_${jsonlFileName}`);
|
|
265
|
+
const backupFileName = path.join(this.backupDir, `${this.getTimeStr(now)}_${jsonlFileName}.gz`);
|
|
238
266
|
if (!this._db.isOpen) {
|
|
239
267
|
this.log.warn(`${this.namespace} Cannot save backup ${backupFileName}: DB is closed`);
|
|
240
268
|
return;
|
|
@@ -248,12 +276,15 @@ export class ObjectsInMemoryJsonlDB extends ObjectsInMemoryFileDB {
|
|
|
248
276
|
// and zip it
|
|
249
277
|
await tools.compressFileGZip(tmpBackupFileName, backupFileName, { deleteInput: true });
|
|
250
278
|
// figure out if older files need to be deleted
|
|
251
|
-
this.deleteOldBackupFiles(
|
|
279
|
+
this.deleteOldBackupFiles(jsonlFileName);
|
|
252
280
|
}
|
|
253
281
|
catch (e) {
|
|
254
282
|
this.log.error(`${this.namespace} Cannot save backup ${backupFileName}: ${e.message}`);
|
|
255
283
|
}
|
|
256
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Stop the backup interval, close the DB and clean up
|
|
287
|
+
*/
|
|
257
288
|
async destroy() {
|
|
258
289
|
await super.destroy();
|
|
259
290
|
if (this._backupInterval) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectsInMemJsonlDB.js","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemJsonlDB.
|
|
1
|
+
{"version":3,"file":"objectsInMemJsonlDB.js","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemJsonlDB.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,6CAA6C;AAE7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D;;;;;GAKG;AACH,SAAS,qBAAqB,CAC1B,OAA4E,EAAE;IAE9E,MAAM,GAAG,GAA+D;QACpE,YAAY,EAAE;YACV,mEAAmE;YACnE,UAAU,EAAE,CAAC;YACb,qBAAqB,EAAE,KAAK;YAC5B,yEAAyE;YACzE,gEAAgE;YAChE,UAAU,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;SAClC;QACD,gBAAgB,EAAE,IAAI;QACtB,UAAU,EAAE;YACR,UAAU,EAAE,KAAK;YACjB,mBAAmB,EAAE,IAAI;SAC5B;QACD,QAAQ,EAAE;YACN,uDAAuD;YACvD,oGAAoG;YACpG,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,GAAG;YACtB,iFAAiF;YACjF,OAAO,EAAE,IAAI;SAChB;KACJ,CAAC;IAEF,6FAA6F;IAC7F,IAAI,IAAI,CAAC,YAAY,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC7D,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,yB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KAAK,CAAC,OAAO;QACT,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,12 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* States DB in memory - Server with Redis protocol
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { Client as ObjectsInRedisClient, type ObjectsSettings } from '@iobroker/db-objects-redis';
|
|
10
|
+
import { type DbStatus } from '@iobroker/db-base';
|
|
11
|
+
/**
|
|
12
|
+
* Objects database client that also starts an in-memory server speaking the Redis protocol
|
|
13
|
+
*/
|
|
14
|
+
export declare class ObjectsInMemoryServerClass extends ObjectsInRedisClient {
|
|
15
|
+
private readonly objectsServer;
|
|
16
|
+
/**
|
|
17
|
+
* @param settings Settings for the objects client and the in-memory server
|
|
18
|
+
*/
|
|
19
|
+
constructor(settings: ObjectsSettings);
|
|
20
|
+
/**
|
|
21
|
+
* Destroy the client first and the in-memory server afterwards
|
|
22
|
+
*/
|
|
23
|
+
destroy(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the status as reported by the in-memory server
|
|
26
|
+
*/
|
|
27
|
+
getStatus(): DbStatus;
|
|
28
|
+
/**
|
|
29
|
+
* Synchronize the file directory of the in-memory server
|
|
30
|
+
*
|
|
31
|
+
* @param limitId Optional object ID to limit the synchronization to
|
|
32
|
+
*/
|
|
33
|
+
syncFileDirectory(limitId?: string): {
|
|
5
34
|
numberSuccess: number;
|
|
6
|
-
notifications:
|
|
35
|
+
notifications: string[];
|
|
7
36
|
};
|
|
8
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Check whether a directory exists in the in-memory server's file storage
|
|
39
|
+
*
|
|
40
|
+
* @param id The object ID owning the files
|
|
41
|
+
* @param name The directory path to check
|
|
42
|
+
*/
|
|
43
|
+
dirExists(id: string, name: string): boolean;
|
|
9
44
|
}
|
|
10
|
-
import { Client as ObjectsInRedisClient } from '@iobroker/db-objects-redis';
|
|
11
|
-
import { ObjectsInMemoryServer } from './objectsInMemServerRedis.js';
|
|
12
45
|
//# sourceMappingURL=objectsInMemServerClass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectsInMemServerClass.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerClass.
|
|
1
|
+
{"version":3,"file":"objectsInMemServerClass.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerClass.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;IAEtD;;OAEG;gBACS,QAAQ,EAAE,eAAe;IAgBrC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;OAEG;IACH,SAAS,IAAI,QAAQ;IAIrB;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAA;KAAE;IAIvF;;;;;OAKG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;CAG/C"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* States DB in memory - Server with Redis protocol
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2013-
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
5
|
*
|
|
6
6
|
* MIT License
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import { Client as ObjectsInRedisClient } from '@iobroker/db-objects-redis';
|
|
10
10
|
import { ObjectsInMemoryServer } from './objectsInMemServerRedis.js';
|
|
11
|
+
/**
|
|
12
|
+
* Objects database client that also starts an in-memory server speaking the Redis protocol
|
|
13
|
+
*/
|
|
11
14
|
export class ObjectsInMemoryServerClass extends ObjectsInRedisClient {
|
|
15
|
+
objectsServer;
|
|
16
|
+
/**
|
|
17
|
+
* @param settings Settings for the objects client and the in-memory server
|
|
18
|
+
*/
|
|
12
19
|
constructor(settings) {
|
|
13
20
|
settings.autoConnect = false; // delay Client connection to when we need it
|
|
14
21
|
super(settings);
|
|
@@ -23,16 +30,33 @@ export class ObjectsInMemoryServerClass extends ObjectsInRedisClient {
|
|
|
23
30
|
};
|
|
24
31
|
this.objectsServer = new ObjectsInMemoryServer(serverSettings);
|
|
25
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Destroy the client first and the in-memory server afterwards
|
|
35
|
+
*/
|
|
26
36
|
async destroy() {
|
|
27
37
|
await super.destroy(); // destroy client first
|
|
28
38
|
await this.objectsServer.destroy(); // server afterwards too
|
|
29
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the status as reported by the in-memory server
|
|
42
|
+
*/
|
|
30
43
|
getStatus() {
|
|
31
44
|
return this.objectsServer.getStatus(); // return Status as Server
|
|
32
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Synchronize the file directory of the in-memory server
|
|
48
|
+
*
|
|
49
|
+
* @param limitId Optional object ID to limit the synchronization to
|
|
50
|
+
*/
|
|
33
51
|
syncFileDirectory(limitId) {
|
|
34
52
|
return this.objectsServer.syncFileDirectory(limitId);
|
|
35
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Check whether a directory exists in the in-memory server's file storage
|
|
56
|
+
*
|
|
57
|
+
* @param id The object ID owning the files
|
|
58
|
+
* @param name The directory path to check
|
|
59
|
+
*/
|
|
36
60
|
dirExists(id, name) {
|
|
37
61
|
return this.objectsServer.dirExists(id, name);
|
|
38
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectsInMemServerClass.js","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerClass.
|
|
1
|
+
{"version":3,"file":"objectsInMemServerClass.js","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerClass.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,oBAAoB,EAAwB,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,oBAAoB;IAC/C,aAAa,CAAwB;IAEtD;;OAEG;IACH,YAAY,QAAyB;QACjC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,6CAA6C;QAC3E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,cAAc,GAAG;YACnB,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,QAAQ;YACzE,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,SAAS,EAAE,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,mDAAmD;YACzE,CAAC;SACJ,CAAC;QACF,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACT,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,uBAAuB;QAC9C,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,wBAAwB;IAChE,CAAC;IAED;;OAEG;IACH,SAAS;QACL,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,0BAA0B;IACrE,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,OAAgB;QAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,EAAU,EAAE,IAAY;QAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACJ"}
|
|
@@ -1,27 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objects DB in memory - Server with Redis protocol
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import net from 'node:net';
|
|
10
|
+
import { RedisHandler, type ConnectionOptions, type FileDbSettings } from '@iobroker/db-base';
|
|
11
|
+
import { ObjectsInMemoryJsonlDB } from './objectsInMemJsonlDB.js';
|
|
12
|
+
type RedisHandlerInternal = RedisHandler & {
|
|
13
|
+
_subscribe?: Record<string, {
|
|
14
|
+
pattern: string;
|
|
15
|
+
regex: RegExp;
|
|
16
|
+
}[]>;
|
|
17
|
+
};
|
|
1
18
|
/**
|
|
2
19
|
* This class inherits statesInMemoryJsonlDB class and adds redis communication layer
|
|
3
20
|
* to access the methods via redis protocol
|
|
4
21
|
*/
|
|
5
|
-
export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
|
|
22
|
+
export declare class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB<RedisHandlerInternal> {
|
|
23
|
+
private readonly serverConnections;
|
|
24
|
+
private readonly namespaceObjects;
|
|
25
|
+
private readonly namespaceFile;
|
|
26
|
+
private readonly namespaceObj;
|
|
27
|
+
private readonly namespaceSet;
|
|
28
|
+
private readonly namespaceSetLen;
|
|
29
|
+
private readonly namespaceFileLen;
|
|
30
|
+
private readonly namespaceObjLen;
|
|
31
|
+
private readonly namespaceMeta;
|
|
32
|
+
private readonly namespaceMetaLen;
|
|
33
|
+
private readonly knownScripts;
|
|
34
|
+
private readonly normalizeFileRegex1;
|
|
35
|
+
private readonly normalizeFileRegex2;
|
|
36
|
+
private server;
|
|
6
37
|
/**
|
|
7
38
|
* Constructor
|
|
8
39
|
*
|
|
9
40
|
* @param settings State and InMem-DB settings
|
|
10
41
|
*/
|
|
11
|
-
constructor(settings:
|
|
12
|
-
serverConnections: {};
|
|
13
|
-
namespaceObjects: string;
|
|
14
|
-
namespaceFile: string;
|
|
15
|
-
namespaceObj: string;
|
|
16
|
-
namespaceSet: string;
|
|
17
|
-
namespaceSetLen: number;
|
|
18
|
-
namespaceFileLen: number;
|
|
19
|
-
namespaceObjLen: number;
|
|
20
|
-
namespaceMeta: string;
|
|
21
|
-
namespaceMetaLen: number;
|
|
22
|
-
knownScripts: {};
|
|
23
|
-
normalizeFileRegex1: RegExp;
|
|
24
|
-
normalizeFileRegex2: RegExp;
|
|
42
|
+
constructor(settings: FileDbSettings<ioBroker.AnyObject | ioBroker.DesignObject>);
|
|
25
43
|
/**
|
|
26
44
|
* Separate Namespace from ID and return both
|
|
27
45
|
*
|
|
@@ -29,8 +47,8 @@ export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
|
|
|
29
47
|
* @returns Object with namespace and the
|
|
30
48
|
* ID/Array of IDs without the namespace
|
|
31
49
|
*/
|
|
32
|
-
_normalizeId(idWithNamespace:
|
|
33
|
-
id: string |
|
|
50
|
+
_normalizeId(idWithNamespace: string): {
|
|
51
|
+
id: string | null;
|
|
34
52
|
namespace: string;
|
|
35
53
|
name: string;
|
|
36
54
|
isMeta: boolean | undefined;
|
|
@@ -44,7 +62,7 @@ export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
|
|
|
44
62
|
* @param obj Object to publish
|
|
45
63
|
* @returns Publish counter 0 or 1 depending on if send out or not
|
|
46
64
|
*/
|
|
47
|
-
publishToClients(client:
|
|
65
|
+
publishToClients(client: RedisHandlerInternal, type: string, id: string, obj: ioBroker.AnyObject | ioBroker.DesignObject): number;
|
|
48
66
|
/**
|
|
49
67
|
* Generate ID for a File
|
|
50
68
|
*
|
|
@@ -53,43 +71,45 @@ export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
|
|
|
53
71
|
* @param isMeta generate a META ID or a Data ID?
|
|
54
72
|
* @returns File-ID
|
|
55
73
|
*/
|
|
56
|
-
getFileId(id:
|
|
74
|
+
getFileId(id: string, name: string, isMeta?: boolean): string;
|
|
57
75
|
/**
|
|
58
76
|
* Register all event listeners for Handler and implement the relevant logic
|
|
59
77
|
*
|
|
60
78
|
* @param handler RedisHandler instance
|
|
61
79
|
*/
|
|
62
|
-
_socketEvents(handler:
|
|
80
|
+
_socketEvents(handler: RedisHandler): void;
|
|
63
81
|
/**
|
|
64
82
|
* Return connected RedisHandlers/Connections
|
|
65
83
|
*
|
|
66
|
-
* @returns
|
|
84
|
+
* @returns the currently connected RedisHandlers/Connections
|
|
67
85
|
*/
|
|
68
|
-
getClients():
|
|
86
|
+
getClients(): Record<string, RedisHandler>;
|
|
87
|
+
/**
|
|
88
|
+
* Destructor of the class. Called by shutting down.
|
|
89
|
+
*/
|
|
90
|
+
destroy(): Promise<void>;
|
|
69
91
|
/**
|
|
70
92
|
* Get keys matching pattern and send it to given responseId, for "SCAN" and "KEYS" - Objects and files supported
|
|
71
93
|
*
|
|
72
94
|
* @param handler RedisHandler instance
|
|
73
95
|
* @param pattern - pattern without namespace prefix
|
|
74
|
-
* @param responseId -
|
|
96
|
+
* @param responseId - ID where response will be sent to
|
|
75
97
|
* @param isScan - if used by "SCAN" this flag should be true
|
|
76
98
|
*/
|
|
77
|
-
_handleScanOrKeys(handler:
|
|
99
|
+
_handleScanOrKeys(handler: RedisHandler, pattern: string, responseId: number, isScan?: boolean): void;
|
|
78
100
|
/**
|
|
79
101
|
* Initialize RedisHandler for a new network connection
|
|
80
102
|
*
|
|
81
103
|
* @param socket Network socket
|
|
82
104
|
*/
|
|
83
|
-
_initSocket(socket:
|
|
105
|
+
_initSocket(socket: net.Socket): void;
|
|
84
106
|
/**
|
|
85
107
|
* Initialize Redis Server
|
|
86
108
|
*
|
|
87
109
|
* @param settings Settings object
|
|
88
|
-
* @returns
|
|
110
|
+
* @returns a promise that resolves once the Redis server is listening
|
|
89
111
|
*/
|
|
90
|
-
_initRedisServer(settings:
|
|
91
|
-
server: net.Server | undefined;
|
|
112
|
+
_initRedisServer(settings: ConnectionOptions): Promise<void>;
|
|
92
113
|
}
|
|
93
|
-
|
|
94
|
-
import net from 'node:net';
|
|
114
|
+
export {};
|
|
95
115
|
//# sourceMappingURL=objectsInMemServerRedis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectsInMemServerRedis.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerRedis.
|
|
1
|
+
{"version":3,"file":"objectsInMemServerRedis.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsInMemServerRedis.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,GAAG,MAAM,UAAU,CAAC;AAO3B,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAA0B,MAAM,mBAAmB,CAAC;AAGtH,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAsBlE,KAAK,oBAAoB,GAAG,YAAY,GAAG;IACvC,UAAU,CAAC,EAAE,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