@iobroker/db-objects-jsonl 7.2.3-alpha.8-20260709-8d8c9c5ed → 7.2.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/build/cjs/index.js +3 -5
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/objects/objectsInMemJsonlDB.d.ts +7 -38
- package/build/cjs/lib/objects/objectsInMemJsonlDB.js +31 -67
- package/build/cjs/lib/objects/objectsInMemJsonlDB.js.map +3 -3
- package/build/cjs/lib/objects/objectsInMemServerClass.d.ts +8 -41
- package/build/cjs/lib/objects/objectsInMemServerClass.js +2 -27
- package/build/cjs/lib/objects/objectsInMemServerClass.js.map +3 -3
- package/build/cjs/lib/objects/objectsInMemServerRedis.d.ts +30 -50
- package/build/cjs/lib/objects/objectsInMemServerRedis.js +34 -69
- package/build/cjs/lib/objects/objectsInMemServerRedis.js.map +4 -4
- package/build/esm/lib/objects/objectsInMemJsonlDB.d.ts +7 -38
- package/build/esm/lib/objects/objectsInMemJsonlDB.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemJsonlDB.js +36 -67
- package/build/esm/lib/objects/objectsInMemJsonlDB.js.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerClass.d.ts +8 -41
- package/build/esm/lib/objects/objectsInMemServerClass.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerClass.js +1 -25
- package/build/esm/lib/objects/objectsInMemServerClass.js.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerRedis.d.ts +30 -50
- package/build/esm/lib/objects/objectsInMemServerRedis.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInMemServerRedis.js +68 -87
- package/build/esm/lib/objects/objectsInMemServerRedis.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
|
@@ -1,45 +1,27 @@
|
|
|
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
|
-
};
|
|
18
1
|
/**
|
|
19
2
|
* This class inherits statesInMemoryJsonlDB class and adds redis communication layer
|
|
20
3
|
* to access the methods via redis protocol
|
|
21
4
|
*/
|
|
22
|
-
export
|
|
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;
|
|
5
|
+
export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
|
|
37
6
|
/**
|
|
38
7
|
* Constructor
|
|
39
8
|
*
|
|
40
9
|
* @param settings State and InMem-DB settings
|
|
41
10
|
*/
|
|
42
|
-
constructor(settings:
|
|
11
|
+
constructor(settings: any);
|
|
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;
|
|
43
25
|
/**
|
|
44
26
|
* Separate Namespace from ID and return both
|
|
45
27
|
*
|
|
@@ -47,8 +29,8 @@ export declare class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB<RedisH
|
|
|
47
29
|
* @returns Object with namespace and the
|
|
48
30
|
* ID/Array of IDs without the namespace
|
|
49
31
|
*/
|
|
50
|
-
_normalizeId(idWithNamespace:
|
|
51
|
-
id: string | null;
|
|
32
|
+
_normalizeId(idWithNamespace: any): {
|
|
33
|
+
id: string | any[] | null;
|
|
52
34
|
namespace: string;
|
|
53
35
|
name: string;
|
|
54
36
|
isMeta: boolean | undefined;
|
|
@@ -62,7 +44,7 @@ export declare class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB<RedisH
|
|
|
62
44
|
* @param obj Object to publish
|
|
63
45
|
* @returns Publish counter 0 or 1 depending on if send out or not
|
|
64
46
|
*/
|
|
65
|
-
publishToClients(client:
|
|
47
|
+
publishToClients(client: any, type: any, id: any, obj: any): 1 | 0;
|
|
66
48
|
/**
|
|
67
49
|
* Generate ID for a File
|
|
68
50
|
*
|
|
@@ -71,45 +53,43 @@ export declare class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB<RedisH
|
|
|
71
53
|
* @param isMeta generate a META ID or a Data ID?
|
|
72
54
|
* @returns File-ID
|
|
73
55
|
*/
|
|
74
|
-
getFileId(id:
|
|
56
|
+
getFileId(id: any, name: any, isMeta: any): string;
|
|
75
57
|
/**
|
|
76
58
|
* Register all event listeners for Handler and implement the relevant logic
|
|
77
59
|
*
|
|
78
60
|
* @param handler RedisHandler instance
|
|
79
61
|
*/
|
|
80
|
-
_socketEvents(handler:
|
|
62
|
+
_socketEvents(handler: any): void;
|
|
81
63
|
/**
|
|
82
64
|
* Return connected RedisHandlers/Connections
|
|
83
65
|
*
|
|
84
|
-
* @returns
|
|
66
|
+
* @returns
|
|
85
67
|
*/
|
|
86
|
-
getClients():
|
|
87
|
-
/**
|
|
88
|
-
* Destructor of the class. Called by shutting down.
|
|
89
|
-
*/
|
|
90
|
-
destroy(): Promise<void>;
|
|
68
|
+
getClients(): {};
|
|
91
69
|
/**
|
|
92
70
|
* Get keys matching pattern and send it to given responseId, for "SCAN" and "KEYS" - Objects and files supported
|
|
93
71
|
*
|
|
94
72
|
* @param handler RedisHandler instance
|
|
95
73
|
* @param pattern - pattern without namespace prefix
|
|
96
|
-
* @param responseId -
|
|
74
|
+
* @param responseId - Id where response will be sent to
|
|
97
75
|
* @param isScan - if used by "SCAN" this flag should be true
|
|
98
76
|
*/
|
|
99
|
-
_handleScanOrKeys(handler:
|
|
77
|
+
_handleScanOrKeys(handler: any, pattern: any, responseId: any, isScan?: boolean): any;
|
|
100
78
|
/**
|
|
101
79
|
* Initialize RedisHandler for a new network connection
|
|
102
80
|
*
|
|
103
81
|
* @param socket Network socket
|
|
104
82
|
*/
|
|
105
|
-
_initSocket(socket:
|
|
83
|
+
_initSocket(socket: any): void;
|
|
106
84
|
/**
|
|
107
85
|
* Initialize Redis Server
|
|
108
86
|
*
|
|
109
87
|
* @param settings Settings object
|
|
110
|
-
* @returns
|
|
88
|
+
* @returns
|
|
111
89
|
*/
|
|
112
|
-
_initRedisServer(settings:
|
|
90
|
+
_initRedisServer(settings: any): Promise<any>;
|
|
91
|
+
server: net.Server | undefined;
|
|
113
92
|
}
|
|
114
|
-
|
|
93
|
+
import { ObjectsInMemoryJsonlDB } from './objectsInMemJsonlDB.js';
|
|
94
|
+
import net from 'node:net';
|
|
115
95
|
//# sourceMappingURL=objectsInMemServerRedis.d.ts.map
|
|
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
8
|
var __export = (target, all) => {
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -37,28 +36,12 @@ var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
|
37
36
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
38
37
|
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
39
38
|
var import_db_objects_redis = require("@iobroker/db-objects-redis");
|
|
40
|
-
var import_tools = require("@iobroker/js-controller-common-db/tools");
|
|
41
39
|
var import_db_base = require("@iobroker/db-base");
|
|
42
|
-
var
|
|
40
|
+
var import_tools = require("@iobroker/js-controller-common-db/tools");
|
|
41
|
+
var import_db_base2 = require("@iobroker/db-base");
|
|
43
42
|
var import_objectsInMemJsonlDB = require("./objectsInMemJsonlDB.js");
|
|
43
|
+
var import_js_controller_common_db = require("@iobroker/js-controller-common-db");
|
|
44
44
|
class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJsonlDB {
|
|
45
|
-
static {
|
|
46
|
-
__name(this, "ObjectsInMemoryServer");
|
|
47
|
-
}
|
|
48
|
-
serverConnections = {};
|
|
49
|
-
namespaceObjects;
|
|
50
|
-
namespaceFile;
|
|
51
|
-
namespaceObj;
|
|
52
|
-
namespaceSet;
|
|
53
|
-
namespaceSetLen;
|
|
54
|
-
namespaceFileLen;
|
|
55
|
-
namespaceObjLen;
|
|
56
|
-
namespaceMeta;
|
|
57
|
-
namespaceMetaLen;
|
|
58
|
-
knownScripts = {};
|
|
59
|
-
normalizeFileRegex1;
|
|
60
|
-
normalizeFileRegex2;
|
|
61
|
-
server;
|
|
62
45
|
/**
|
|
63
46
|
* Constructor
|
|
64
47
|
*
|
|
@@ -66,6 +49,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
66
49
|
*/
|
|
67
50
|
constructor(settings) {
|
|
68
51
|
super(settings);
|
|
52
|
+
this.serverConnections = {};
|
|
69
53
|
this.namespaceObjects = `${this.settings.redisNamespace || settings.connection && settings.connection.redisNamespace || "cfg"}.`;
|
|
70
54
|
this.namespaceFile = `${this.namespaceObjects}f.`;
|
|
71
55
|
this.namespaceObj = `${this.namespaceObjects}o.`;
|
|
@@ -75,6 +59,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
75
59
|
this.namespaceObjLen = this.namespaceObj.length;
|
|
76
60
|
this.namespaceMeta = `${this.settings.namespaceMeta || "meta"}.`;
|
|
77
61
|
this.namespaceMetaLen = this.namespaceMeta.length;
|
|
62
|
+
this.knownScripts = {};
|
|
78
63
|
this.normalizeFileRegex1 = new RegExp("^(.*)\\$%\\$(.*)\\$%\\$(meta|data)$");
|
|
79
64
|
this.normalizeFileRegex2 = new RegExp("^(.*)\\$%\\$(.*)\\/?\\*$");
|
|
80
65
|
this.open().then(() => {
|
|
@@ -101,7 +86,15 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
101
86
|
let id = null;
|
|
102
87
|
let name = "";
|
|
103
88
|
let isMeta;
|
|
104
|
-
if (
|
|
89
|
+
if (Array.isArray(idWithNamespace)) {
|
|
90
|
+
const ids = [];
|
|
91
|
+
idWithNamespace.forEach((el) => {
|
|
92
|
+
const { id: id2, namespace } = this._normalizeId(el);
|
|
93
|
+
ids.push(id2);
|
|
94
|
+
ns = namespace;
|
|
95
|
+
});
|
|
96
|
+
id = ids;
|
|
97
|
+
} else if (typeof idWithNamespace === "string") {
|
|
105
98
|
id = idWithNamespace;
|
|
106
99
|
if (idWithNamespace.startsWith(this.namespaceObjects)) {
|
|
107
100
|
let idx = -1;
|
|
@@ -154,14 +147,14 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
154
147
|
* @returns Publish counter 0 or 1 depending on if send out or not
|
|
155
148
|
*/
|
|
156
149
|
publishToClients(client, type, id, obj) {
|
|
157
|
-
if (!client._subscribe
|
|
150
|
+
if (!client._subscribe || !client._subscribe[type]) {
|
|
158
151
|
return 0;
|
|
159
152
|
}
|
|
160
153
|
const s = client._subscribe[type];
|
|
161
154
|
const found = s.find((sub) => sub.regex.test(id));
|
|
162
155
|
if (found) {
|
|
163
156
|
if (type === "meta") {
|
|
164
|
-
this.log.silly(`${this.namespace} Redis Publish Meta ${id}=${
|
|
157
|
+
this.log.silly(`${this.namespace} Redis Publish Meta ${id}=${obj}`);
|
|
165
158
|
const sendPattern = this.namespaceMeta + found.pattern;
|
|
166
159
|
const sendId = this.namespaceMeta + id;
|
|
167
160
|
client.sendArray(null, ["pmessage", sendPattern, sendId, obj]);
|
|
@@ -241,11 +234,11 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
241
234
|
const scriptChecksum = shasum.digest("hex");
|
|
242
235
|
const scriptDesign = data[1].match(/^-- design: ([a-z0-9A-Z-.]+)\s/m);
|
|
243
236
|
const scriptFunc = data[1].match(/^-- func: (.+)$/m);
|
|
244
|
-
if (scriptDesign
|
|
237
|
+
if (scriptDesign && scriptDesign[1]) {
|
|
245
238
|
const design = scriptDesign[1];
|
|
246
239
|
let search = null;
|
|
247
240
|
const scriptSearch = data[1].match(/^-- search: ([a-z0-9A-Z-.]*)\s/m);
|
|
248
|
-
if (scriptSearch
|
|
241
|
+
if (scriptSearch && scriptSearch[1]) {
|
|
249
242
|
search = scriptSearch[1];
|
|
250
243
|
}
|
|
251
244
|
this.knownScripts[scriptChecksum] = { design, search };
|
|
@@ -253,7 +246,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
253
246
|
this.log.silly(`${namespaceLog} Register View LUA Script: ${scriptChecksum} = ${JSON.stringify(this.knownScripts[scriptChecksum])}`);
|
|
254
247
|
}
|
|
255
248
|
handler.sendBulk(responseId, scriptChecksum);
|
|
256
|
-
} else if (scriptFunc
|
|
249
|
+
} else if (scriptFunc && scriptFunc[1]) {
|
|
257
250
|
this.knownScripts[scriptChecksum] = { func: scriptFunc[1] };
|
|
258
251
|
if (this.settings.connection.enhancedLogging) {
|
|
259
252
|
this.log.silly(`${namespaceLog} Register Func LUA Script: ${scriptChecksum} = ${JSON.stringify(this.knownScripts[scriptChecksum])}`);
|
|
@@ -322,14 +315,14 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
322
315
|
});
|
|
323
316
|
handler.on("publish", (data, responseId) => {
|
|
324
317
|
const { id, namespace } = this._normalizeId(data[0]);
|
|
325
|
-
if (namespace === this.namespaceObj || namespace === this.namespaceMeta || namespace === this.namespaceFile
|
|
318
|
+
if (namespace === this.namespaceObj || namespace === this.namespaceMeta || namespace === this.namespaceFile) {
|
|
326
319
|
return void handler.sendInteger(responseId, 0);
|
|
327
320
|
}
|
|
328
321
|
const publishCount = this.publishAll(namespace.substr(0, namespace.length - 1), id, JSON.parse(data[1]));
|
|
329
322
|
handler.sendInteger(responseId, publishCount);
|
|
330
323
|
});
|
|
331
324
|
handler.on("mget", (data, responseId) => {
|
|
332
|
-
if (!data
|
|
325
|
+
if (!data || !data.length) {
|
|
333
326
|
return void handler.sendArray(responseId, []);
|
|
334
327
|
}
|
|
335
328
|
const { namespace, isMeta } = this._normalizeId(data[0]);
|
|
@@ -350,20 +343,20 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
350
343
|
} catch (err) {
|
|
351
344
|
return void handler.sendError(responseId, new Error(`ERROR _getObjects: ${err.message}`));
|
|
352
345
|
}
|
|
353
|
-
|
|
354
|
-
handler.sendArray(responseId,
|
|
346
|
+
result = result.map((el) => el ? JSON.stringify(el) : null);
|
|
347
|
+
handler.sendArray(responseId, result);
|
|
355
348
|
} else if (namespace === this.namespaceFile) {
|
|
356
349
|
if (isMeta) {
|
|
357
350
|
const response = [];
|
|
358
351
|
data.forEach((dataId) => {
|
|
359
352
|
const { id, namespace: namespace2, name } = this._normalizeId(dataId);
|
|
360
|
-
if (namespace2 !== this.namespaceFile
|
|
353
|
+
if (namespace2 !== this.namespaceFile) {
|
|
361
354
|
response.push(null);
|
|
362
355
|
this.log.warn(`${namespaceLog} Got MGET request for non File ID in File-ID chunk for ${dataId}`);
|
|
363
356
|
return;
|
|
364
357
|
}
|
|
365
358
|
this._loadFileSettings(id);
|
|
366
|
-
if (!this.fileOptions[id]
|
|
359
|
+
if (!this.fileOptions[id] || !this.fileOptions[id][name]) {
|
|
367
360
|
response.push(null);
|
|
368
361
|
return;
|
|
369
362
|
}
|
|
@@ -389,10 +382,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
389
382
|
});
|
|
390
383
|
handler.on("get", (data, responseId) => {
|
|
391
384
|
const { id, namespace, name, isMeta } = this._normalizeId(data[0]);
|
|
392
|
-
if (!id) {
|
|
393
|
-
handler.sendNull(responseId);
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
385
|
if (namespace === this.namespaceObj) {
|
|
397
386
|
const result = this._getObject(id);
|
|
398
387
|
if (!result) {
|
|
@@ -416,7 +405,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
416
405
|
}));
|
|
417
406
|
}
|
|
418
407
|
this._loadFileSettings(id);
|
|
419
|
-
if (!this.fileOptions[id]
|
|
408
|
+
if (!this.fileOptions[id] || !this.fileOptions[id][name]) {
|
|
420
409
|
return void handler.sendNull(responseId);
|
|
421
410
|
}
|
|
422
411
|
let obj = this._clone(this.fileOptions[id][name]);
|
|
@@ -424,9 +413,9 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
424
413
|
obj = {
|
|
425
414
|
mimeType: obj,
|
|
426
415
|
acl: {
|
|
427
|
-
owner: this.defaultNewAcl
|
|
428
|
-
ownerGroup: this.defaultNewAcl
|
|
429
|
-
permissions: this.defaultNewAcl
|
|
416
|
+
owner: this.defaultNewAcl && this.defaultNewAcl.owner || import_db_objects_redis.objectsUtils.CONSTS.SYSTEM_ADMIN_USER,
|
|
417
|
+
ownerGroup: this.defaultNewAcl && this.defaultNewAcl.ownerGroup || import_db_objects_redis.objectsUtils.CONSTS.SYSTEM_ADMIN_GROUP,
|
|
418
|
+
permissions: this.defaultNewAcl && this.defaultNewAcl.file.permissions || import_db_objects_redis.objectsUtils.CONSTS.ACCESS_USER_ALL | import_db_objects_redis.objectsUtils.CONSTS.ACCESS_GROUP_ALL | import_db_objects_redis.objectsUtils.CONSTS.ACCESS_EVERY_ALL
|
|
430
419
|
// 777
|
|
431
420
|
}
|
|
432
421
|
};
|
|
@@ -452,7 +441,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
452
441
|
}
|
|
453
442
|
} else if (namespace === this.namespaceMeta) {
|
|
454
443
|
if (id === "objects.primaryHost") {
|
|
455
|
-
handler.sendString(
|
|
444
|
+
handler.sendString(this.settings.hostname);
|
|
456
445
|
} else {
|
|
457
446
|
const result = this.getMeta(id);
|
|
458
447
|
if (result === void 0 || result === null) {
|
|
@@ -467,10 +456,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
467
456
|
});
|
|
468
457
|
handler.on("set", (data, responseId) => {
|
|
469
458
|
const { id, namespace, name, isMeta } = this._normalizeId(data[0]);
|
|
470
|
-
if (!id) {
|
|
471
|
-
handler.sendNull(responseId);
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
459
|
if (namespace === this.namespaceObj) {
|
|
475
460
|
try {
|
|
476
461
|
const obj = JSON.parse(data[1].toString("utf-8"));
|
|
@@ -514,9 +499,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
514
499
|
if (oldDetails.id !== newDetails.id) {
|
|
515
500
|
return void handler.sendError(responseId, new Error("ERROR renameObject: id needs to stay the same"));
|
|
516
501
|
}
|
|
517
|
-
if (oldDetails.id === null) {
|
|
518
|
-
return void handler.sendError(responseId, new Error(`ERROR renameObject: invalid ID ${data[0]}`));
|
|
519
|
-
}
|
|
520
502
|
if (oldDetails.isMeta) {
|
|
521
503
|
handler.sendString(responseId, "OK");
|
|
522
504
|
} else {
|
|
@@ -533,9 +515,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
533
515
|
});
|
|
534
516
|
handler.on("del", (data, responseId) => {
|
|
535
517
|
const { id, namespace, name, isMeta } = this._normalizeId(data[0]);
|
|
536
|
-
if (!id) {
|
|
537
|
-
return void handler.sendError(responseId, new Error(`ID is null: ${data[0]}`));
|
|
538
|
-
}
|
|
539
518
|
if (namespace === this.namespaceObj) {
|
|
540
519
|
try {
|
|
541
520
|
this._delObject(id);
|
|
@@ -563,9 +542,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
563
542
|
return void handler.sendInteger(responseId, 0);
|
|
564
543
|
}
|
|
565
544
|
const { id, namespace, name } = this._normalizeId(data[0]);
|
|
566
|
-
if (!id) {
|
|
567
|
-
return void handler.sendError(responseId, new Error(`ID is null: ${data[0]}`));
|
|
568
|
-
}
|
|
569
545
|
if (namespace === this.namespaceObj) {
|
|
570
546
|
let exists;
|
|
571
547
|
try {
|
|
@@ -617,9 +593,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
617
593
|
});
|
|
618
594
|
handler.on("psubscribe", (data, responseId) => {
|
|
619
595
|
const { id, namespace, name } = this._normalizeId(data[0]);
|
|
620
|
-
if (!id) {
|
|
621
|
-
return void handler.sendError(responseId, new Error(`ID is null: ${data[0]}`));
|
|
622
|
-
}
|
|
623
596
|
if (namespace === this.namespaceObj) {
|
|
624
597
|
this._subscribeConfigForClient(handler, id);
|
|
625
598
|
handler.sendArray(responseId, ["psubscribe", data[0], 1]);
|
|
@@ -635,9 +608,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
635
608
|
});
|
|
636
609
|
handler.on("punsubscribe", (data, responseId) => {
|
|
637
610
|
const { id, namespace, name } = this._normalizeId(data[0]);
|
|
638
|
-
if (!id) {
|
|
639
|
-
return void handler.sendError(responseId, new Error(`ID is null: ${data[0]}`));
|
|
640
|
-
}
|
|
641
611
|
if (namespace === this.namespaceObj) {
|
|
642
612
|
this._unsubscribeConfigForClient(handler, id);
|
|
643
613
|
handler.sendArray(responseId, ["punsubscribe", data[0], 1]);
|
|
@@ -680,8 +650,6 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
680
650
|
} else {
|
|
681
651
|
handler.sendNull(responseId);
|
|
682
652
|
}
|
|
683
|
-
} else if (typeof data[0] === "string" && data[0].toLowerCase() === "setinfo") {
|
|
684
|
-
handler.sendString(responseId, "OK");
|
|
685
653
|
} else {
|
|
686
654
|
handler.sendError(responseId, new Error(`CLIENT-UNSUPPORTED for ${JSON.stringify(data)}`));
|
|
687
655
|
}
|
|
@@ -691,7 +659,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
691
659
|
/**
|
|
692
660
|
* Return connected RedisHandlers/Connections
|
|
693
661
|
*
|
|
694
|
-
* @returns
|
|
662
|
+
* @returns
|
|
695
663
|
*/
|
|
696
664
|
getClients() {
|
|
697
665
|
return this.serverConnections;
|
|
@@ -724,14 +692,11 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
724
692
|
*
|
|
725
693
|
* @param handler RedisHandler instance
|
|
726
694
|
* @param pattern - pattern without namespace prefix
|
|
727
|
-
* @param responseId -
|
|
695
|
+
* @param responseId - Id where response will be sent to
|
|
728
696
|
* @param isScan - if used by "SCAN" this flag should be true
|
|
729
697
|
*/
|
|
730
698
|
_handleScanOrKeys(handler, pattern, responseId, isScan = false) {
|
|
731
699
|
const { id, namespace, name, isMeta } = this._normalizeId(pattern);
|
|
732
|
-
if (id === null) {
|
|
733
|
-
return void handler.sendError(responseId, new Error(`ID is null in ${pattern}`));
|
|
734
|
-
}
|
|
735
700
|
let response = [];
|
|
736
701
|
if (namespace === this.namespaceObj || namespace === this.namespaceObjects) {
|
|
737
702
|
try {
|
|
@@ -806,7 +771,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
806
771
|
handleAsBuffers: true,
|
|
807
772
|
enhancedLogging: this.settings.connection.enhancedLogging
|
|
808
773
|
};
|
|
809
|
-
const handler = new
|
|
774
|
+
const handler = new import_db_base2.RedisHandler(socket, options);
|
|
810
775
|
this._socketEvents(handler);
|
|
811
776
|
this.serverConnections[`${socket.remoteAddress}:${socket.remotePort}`] = handler;
|
|
812
777
|
socket.on("close", () => {
|
|
@@ -819,7 +784,7 @@ class ObjectsInMemoryServer extends import_objectsInMemJsonlDB.ObjectsInMemoryJs
|
|
|
819
784
|
* Initialize Redis Server
|
|
820
785
|
*
|
|
821
786
|
* @param settings Settings object
|
|
822
|
-
* @returns
|
|
787
|
+
* @returns
|
|
823
788
|
*/
|
|
824
789
|
_initRedisServer(settings) {
|
|
825
790
|
return new Promise((resolve, reject) => {
|