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