@iobroker/js-controller-adapter 5.0.18 → 5.0.20-alpha.0-20240131-ea40ee4f

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.
@@ -1,42 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
- };
30
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
31
- if (kind === "m") throw new TypeError("Private method is not writable");
32
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
33
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
34
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
35
- };
36
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
4
  };
39
- var _AdapterClass_states, _AdapterClass_objects;
40
5
  Object.defineProperty(exports, "__esModule", { value: true });
41
6
  exports.Adapter = exports.AdapterClass = void 0;
42
7
  const node_net_1 = __importDefault(require("node:net"));
@@ -59,7 +24,7 @@ const package_json_1 = require("@iobroker/js-controller-adapter/package.json");
59
24
  const log_1 = require("../../lib/adapter/log");
60
25
  const validator_1 = require("./validator");
61
26
  const { FORBIDDEN_CHARS } = js_controller_common_1.tools;
62
- const constants_1 = require("./constants");
27
+ const constants_1 = require("../../lib/adapter/constants");
63
28
  const userInterfaceMessagingController_1 = require("../../lib/adapter/userInterfaceMessagingController");
64
29
  const constants_2 = require("@iobroker/js-controller-common/constants");
65
30
  js_controller_common_1.tools.ensureDNSOrder();
@@ -71,51 +36,134 @@ js_controller_common_1.tools.ensureDNSOrder();
71
36
  *
72
37
  */
73
38
  class AdapterClass extends node_events_1.EventEmitter {
39
+ /** Instance to access states DB */
40
+ #states;
41
+ /** Instance to access objects DB */
42
+ #objects;
43
+ /** States DB constructor */
44
+ States;
45
+ /** Objects DB constructor */
46
+ Objects;
47
+ /** Contents of iobroker.json */
48
+ _config;
49
+ _options;
50
+ startedInCompactMode;
51
+ /** List of instances which want our logs */
52
+ logList = new Set();
53
+ aliases = new Map();
54
+ aliasPatterns = new Set();
55
+ enums = {};
56
+ eventLoopLags = [];
57
+ overwriteLogLevel = false;
58
+ adapterReady = false;
59
+ /** Callbacks from sendTo */
60
+ messageCallbacks = new Map();
61
+ /**
62
+ * Contains a live cache of the adapter's states.
63
+ * NOTE: This is only defined if the adapter was initialized with the option states: true.
64
+ */
65
+ oStates;
66
+ /**
67
+ * Contains a live cache of the adapter's objects.
68
+ * NOTE: This is only defined if the adapter was initialized with the option objects: true.
69
+ */
70
+ oObjects;
71
+ _stopInProgress = false;
72
+ _callbackId = 1;
73
+ _firstConnection = true;
74
+ _timers = new Set();
75
+ _intervals = new Set();
76
+ _delays = new Set();
77
+ /** For ease of use the log property is always defined, however it is only available after `ready` has been called. */
78
+ log;
79
+ performStrictObjectChecks;
80
+ _logger;
81
+ _restartScheduleJob;
82
+ _schedule;
83
+ namespaceLog;
84
+ namespace;
85
+ name;
86
+ _systemSecret;
87
+ /** Whether the adapter has already terminated */
88
+ terminated = false;
89
+ /** The cache of usernames */
90
+ usernames = {};
91
+ /** A RegExp to test for forbidden chars in object IDs */
92
+ FORBIDDEN_CHARS = FORBIDDEN_CHARS;
93
+ inputCount = 0;
94
+ outputCount = 0;
95
+ /** The cache of users */
96
+ users = {}; // todo
97
+ /** The cache of user groups */
98
+ groups = {};
99
+ /** An array of instances, that support auto subscribe */
100
+ autoSubscribe = [];
101
+ defaultHistory = null;
102
+ pluginHandler;
103
+ _reportInterval;
104
+ getPortRunning = null;
105
+ _namespaceRegExp;
106
+ instance;
107
+ // @ts-expect-error decide how to handle it
108
+ _utils;
109
+ /** contents of io-package.json */
110
+ adapterConfig;
111
+ connected;
112
+ adapterDir;
113
+ /** contents of package.json */
114
+ pack;
115
+ /** contents of io-package.json */
116
+ ioPack; // contents of io-package.json TODO difference to adapterConfig?
117
+ _initializeTimeout;
118
+ inited;
119
+ /** contents of iobroker.json if required via AdapterOptions */
120
+ systemConfig;
121
+ /** the configured date format of system.config, only available if requested via AdapterOptions `useFormatDate` */
122
+ dateFormat;
123
+ /** if float comma instead of dot is used, only available if requested via AdapterOptions `useFormatDate` */
124
+ isFloatComma;
125
+ /** configured language of system.config, only available if requested via AdapterOptions `useFormatDate` */
126
+ language;
127
+ /** longitude configured in system.config, only available if requested via AdapterOptions `useFormatDate`*/
128
+ longitude;
129
+ /** latitude configured in system.config, only available if requested via AdapterOptions `useFormatDate`*/
130
+ latitude;
131
+ _defaultObjs;
132
+ _aliasObjectsSubscribed;
133
+ config = {};
134
+ host;
135
+ common;
136
+ mboxSubscribed;
137
+ /** Stop the adapter */
138
+ stop;
139
+ version;
140
+ /** Stop the adapter only defined in compact, not for external usage */
141
+ kill;
142
+ processLog;
143
+ /**
144
+ * Start or stop subscribing to log messages
145
+ * The method is only available if logTransporter is active via io-pack or adapter options
146
+ * Note, that stopping will stop after 10 seconds, not immediately
147
+ *
148
+ * @param isActive - if log subscription should be activated or deactivated
149
+ * @param options - options passed to setState e.g. user permissions
150
+ */
151
+ requireLog;
152
+ logOffTimer;
153
+ logRedirect;
154
+ logRequired;
155
+ patterns;
156
+ statesConnectedTime;
157
+ /** Constants for frequent use in adapters */
158
+ constants = {
159
+ STATE_QUALITY: constants_1.STATE_QUALITY
160
+ };
161
+ /** Features supported by the running instance */
162
+ SUPPORTED_FEATURES = (0, utils_1.getSupportedFeatures)();
163
+ /** Controller for messaging related functionality */
164
+ uiMessagingController;
74
165
  constructor(options) {
75
166
  super();
76
- /** Instance to access states DB */
77
- _AdapterClass_states.set(this, void 0);
78
- /** Instance to access objects DB */
79
- _AdapterClass_objects.set(this, void 0);
80
- /** List of instances which want our logs */
81
- this.logList = new Set();
82
- this.aliases = new Map();
83
- this.aliasPatterns = new Set();
84
- this.enums = {};
85
- this.eventLoopLags = [];
86
- this.overwriteLogLevel = false;
87
- this.adapterReady = false;
88
- /** Callbacks from sendTo */
89
- this.messageCallbacks = new Map();
90
- this._stopInProgress = false;
91
- this._callbackId = 1;
92
- this._firstConnection = true;
93
- this._timers = new Set();
94
- this._intervals = new Set();
95
- this._delays = new Set();
96
- /** Whether the adapter has already terminated */
97
- this.terminated = false;
98
- /** The cache of usernames */
99
- this.usernames = {};
100
- /** A RegExp to test for forbidden chars in object IDs */
101
- this.FORBIDDEN_CHARS = FORBIDDEN_CHARS;
102
- this.inputCount = 0;
103
- this.outputCount = 0;
104
- /** The cache of users */
105
- this.users = {}; // todo
106
- /** The cache of user groups */
107
- this.groups = {};
108
- /** An array of instances, that support auto subscribe */
109
- this.autoSubscribe = [];
110
- this.defaultHistory = null;
111
- this.getPortRunning = null;
112
- this.config = {};
113
- /** Constants for frequent use in adapters */
114
- this.constants = {
115
- STATE_QUALITY: constants_1.STATE_QUALITY
116
- };
117
- /** Features supported by the running instance */
118
- this.SUPPORTED_FEATURES = (0, utils_1.getSupportedFeatures)();
119
167
  // enable "const adapter = require(__dirname + '/../../lib/adapter.js')('adapterName');" call
120
168
  if (typeof options === 'string') {
121
169
  this._options = { name: options };
@@ -583,12 +631,12 @@ class AdapterClass extends node_events_1.EventEmitter {
583
631
  }
584
632
  // actual implementation
585
633
  _getSession(options) {
586
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
634
+ if (!this.#states) {
587
635
  // if states is no longer existing, we do not need to unsubscribe
588
636
  this._logger.info(`${this.namespaceLog} getSession not processed because States database not connected`);
589
637
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
590
638
  }
591
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getSession(options.id, options.callback);
639
+ this.#states.getSession(options.id, options.callback);
592
640
  }
593
641
  // unknown implementation guards
594
642
  setSession(id, ttl, data, callback) {
@@ -600,12 +648,12 @@ class AdapterClass extends node_events_1.EventEmitter {
600
648
  }
601
649
  // actual implementation
602
650
  _setSession(options) {
603
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
651
+ if (!this.#states) {
604
652
  // if states is no longer existing, we do not need to unsubscribe
605
653
  this._logger.info(`${this.namespaceLog} setSession not processed because States database not connected`);
606
654
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
607
655
  }
608
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setSession(options.id, options.ttl, options.data, options.callback);
656
+ this.#states.setSession(options.id, options.ttl, options.data, options.callback);
609
657
  }
610
658
  destroySession(id, callback) {
611
659
  validator_1.Validator.assertString(id, 'id');
@@ -613,16 +661,16 @@ class AdapterClass extends node_events_1.EventEmitter {
613
661
  return this._destroySession({ id, callback });
614
662
  }
615
663
  _destroySession(options) {
616
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
664
+ if (!this.#states) {
617
665
  // if states is no longer existing, we do not need to unsubscribe
618
666
  this._logger.info(`${this.namespaceLog} destroySession not processed because States database not connected`);
619
667
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
620
668
  }
621
- __classPrivateFieldGet(this, _AdapterClass_states, "f").destroySession(options.id, options.callback);
669
+ this.#states.destroySession(options.id, options.callback);
622
670
  }
623
671
  async _getObjectsByArray(keys, options) {
624
672
  try {
625
- const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjects(keys, options);
673
+ const res = await this.#objects.getObjects(keys, options);
626
674
  return res;
627
675
  }
628
676
  catch (e) {
@@ -681,17 +729,17 @@ class AdapterClass extends node_events_1.EventEmitter {
681
729
  }
682
730
  setTimeout(async () => {
683
731
  // give last states some time to get handled
684
- if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
732
+ if (this.#states) {
685
733
  try {
686
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").destroy();
734
+ await this.#states.destroy();
687
735
  }
688
736
  catch {
689
737
  // ignore
690
738
  }
691
739
  }
692
- if (__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
740
+ if (this.#objects) {
693
741
  try {
694
- await __classPrivateFieldGet(this, _AdapterClass_objects, "f").destroy();
742
+ await this.#objects.destroy();
695
743
  }
696
744
  catch {
697
745
  //ignore
@@ -699,8 +747,8 @@ class AdapterClass extends node_events_1.EventEmitter {
699
747
  }
700
748
  if (this.startedInCompactMode) {
701
749
  this.emit('exit', _exitCode, reason);
702
- __classPrivateFieldSet(this, _AdapterClass_states, null, "f");
703
- __classPrivateFieldSet(this, _AdapterClass_objects, null, "f");
750
+ this.#states = null;
751
+ this.#objects = null;
704
752
  }
705
753
  else {
706
754
  process.exit(_exitCode);
@@ -1223,12 +1271,11 @@ class AdapterClass extends node_events_1.EventEmitter {
1223
1271
  return js_controller_common_1.tools.maybeCallback(options.callback, acl);
1224
1272
  }
1225
1273
  this.getForeignObjects('*', 'group', null, options, (err, groups) => {
1226
- var _a, _b;
1227
1274
  acl.groups = [];
1228
1275
  // aggregate all groups permissions, where this user is
1229
1276
  if (groups) {
1230
1277
  for (const g of Object.keys(groups)) {
1231
- if (((_b = (_a = groups[g]) === null || _a === void 0 ? void 0 : _a.common) === null || _b === void 0 ? void 0 : _b.members) && groups[g].common.members.includes(userId)) {
1278
+ if (groups[g]?.common?.members && groups[g].common.members.includes(userId)) {
1232
1279
  acl.groups.push(groups[g]._id);
1233
1280
  if (groups[g]._id === constants_1.SYSTEM_ADMIN_GROUP) {
1234
1281
  acl = {
@@ -1308,7 +1355,6 @@ class AdapterClass extends node_events_1.EventEmitter {
1308
1355
  });
1309
1356
  }
1310
1357
  async _stop(isPause, isScheduled, exitCode, updateAliveState) {
1311
- var _a;
1312
1358
  exitCode = exitCode || (isScheduled ? js_controller_common_1.EXIT_CODES.START_IMMEDIATELY_AFTER_STOP : 0);
1313
1359
  if (updateAliveState === undefined) {
1314
1360
  updateAliveState = true;
@@ -1336,9 +1382,9 @@ class AdapterClass extends node_events_1.EventEmitter {
1336
1382
  this.messageCallbacks.forEach(callbackObj => clearTimeout(callbackObj.timer));
1337
1383
  this.messageCallbacks.clear();
1338
1384
  }
1339
- if (__classPrivateFieldGet(this, _AdapterClass_states, "f") && updateAliveState) {
1385
+ if (this.#states && updateAliveState) {
1340
1386
  this.outputCount++;
1341
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, { val: false, ack: true, from: id }, () => {
1387
+ this.#states.setState(`${id}.alive`, { val: false, ack: true, from: id }, () => {
1342
1388
  if (!isPause) {
1343
1389
  this._logger.info(`${this.namespaceLog} terminating`);
1344
1390
  }
@@ -1386,7 +1432,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1386
1432
  // Even if the developer forgets to call the unload callback, we need to stop the process.
1387
1433
  // Therefore, wait a short while and then force the unload procedure
1388
1434
  setTimeout(() => {
1389
- if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
1435
+ if (this.#states) {
1390
1436
  finishUnload();
1391
1437
  // Give 1 second to write the value
1392
1438
  setTimeout(() => {
@@ -1402,7 +1448,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1402
1448
  }
1403
1449
  this.terminate(exitCode);
1404
1450
  }
1405
- }, ((_a = this.common) === null || _a === void 0 ? void 0 : _a.stopTimeout) || 500);
1451
+ }, this.common?.stopTimeout || 500);
1406
1452
  }
1407
1453
  }
1408
1454
  /**
@@ -1481,13 +1527,13 @@ class AdapterClass extends node_events_1.EventEmitter {
1481
1527
  async _getCertificates(options) {
1482
1528
  const { publicName, chainedName, privateName, callback } = options;
1483
1529
  let obj;
1484
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
1530
+ if (!this.#objects) {
1485
1531
  this._logger.info(`${this.namespaceLog} getCertificates not processed because Objects database not connected`);
1486
1532
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
1487
1533
  }
1488
1534
  try {
1489
1535
  // Load certificates
1490
- obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject('system.certificates');
1536
+ obj = await this.#objects.getObject('system.certificates');
1491
1537
  }
1492
1538
  catch {
1493
1539
  // ignore
@@ -1636,7 +1682,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1636
1682
  }
1637
1683
  try {
1638
1684
  const data = await this.getForeignObjectAsync('system.config');
1639
- if (data === null || data === void 0 ? void 0 : data.native) {
1685
+ if (data?.native) {
1640
1686
  this._systemSecret = data.native.secret;
1641
1687
  }
1642
1688
  }
@@ -1794,7 +1840,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1794
1840
  }
1795
1841
  async _setObject(options) {
1796
1842
  if (!this._defaultObjs) {
1797
- this._defaultObjs = (await Promise.resolve().then(() => __importStar(require('./defaultObjs.js')))).createDefaults();
1843
+ this._defaultObjs = (await import('./defaultObjs.js')).createDefaults();
1798
1844
  }
1799
1845
  if (!options.obj) {
1800
1846
  this._logger.error(`${this.namespaceLog} setObject: try to set null object for ${options.id}`);
@@ -1877,7 +1923,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1877
1923
  * @param [callback]
1878
1924
  */
1879
1925
  async _setObjectWithDefaultValue(id, obj, options, callback) {
1880
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
1926
+ if (!this.#objects) {
1881
1927
  this._logger.info(`${this.namespaceLog} setObject not processed because Objects database not connected`);
1882
1928
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
1883
1929
  }
@@ -1896,7 +1942,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1896
1942
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
1897
1943
  }
1898
1944
  try {
1899
- const result = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(id, obj, options);
1945
+ const result = await this.#objects.setObjectAsync(id, obj, options);
1900
1946
  if (obj.type === 'state' && obj.common && obj.common.def !== undefined && obj.common.def !== null) {
1901
1947
  const state = await this.getForeignStateAsync(id);
1902
1948
  // only set the def state, if state is non-existent
@@ -1940,7 +1986,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1940
1986
  }
1941
1987
  }
1942
1988
  };
1943
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
1989
+ if (!this.#objects) {
1944
1990
  return js_controller_common_1.tools.maybeCallback(options.callback, ret);
1945
1991
  }
1946
1992
  const params = {
@@ -1949,7 +1995,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1949
1995
  include_docs: true
1950
1996
  };
1951
1997
  try {
1952
- const folders = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'folder', params);
1998
+ const folders = await this.#objects.getObjectViewAsync('system', 'folder', params);
1953
1999
  if (folders) {
1954
2000
  addRows(folders.rows);
1955
2001
  }
@@ -1958,7 +2004,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1958
2004
  /* ignore, we'll return what we get till now */
1959
2005
  }
1960
2006
  try {
1961
- const devices = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'device', params);
2007
+ const devices = await this.#objects.getObjectViewAsync('system', 'device', params);
1962
2008
  if (devices) {
1963
2009
  addRows(devices.rows);
1964
2010
  }
@@ -1967,7 +2013,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1967
2013
  /* ignore, we'll return what we get till now */
1968
2014
  }
1969
2015
  try {
1970
- const channels = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'channel', params);
2016
+ const channels = await this.#objects.getObjectViewAsync('system', 'channel', params);
1971
2017
  if (channels) {
1972
2018
  addRows(channels.rows);
1973
2019
  }
@@ -1976,7 +2022,7 @@ class AdapterClass extends node_events_1.EventEmitter {
1976
2022
  /* ignore, we'll return what we get till now */
1977
2023
  }
1978
2024
  try {
1979
- const states = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'state', params);
2025
+ const states = await this.#objects.getObjectViewAsync('system', 'state', params);
1980
2026
  if (states) {
1981
2027
  addRows(states.rows);
1982
2028
  }
@@ -2066,7 +2112,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2066
2112
  }
2067
2113
  // TODO: the public return type needs to be defined correctly, probably needs to be discussed
2068
2114
  async _extendObject(options) {
2069
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2115
+ if (!this.#objects) {
2070
2116
  this._logger.info(`${this.namespaceLog} extendObject not processed because Objects database not connected`);
2071
2117
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2072
2118
  }
@@ -2092,12 +2138,12 @@ class AdapterClass extends node_events_1.EventEmitter {
2092
2138
  // Read whole object
2093
2139
  let oldObj;
2094
2140
  try {
2095
- oldObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(options.id, options.options);
2141
+ oldObj = await this.#objects.getObjectAsync(options.id, options.options);
2096
2142
  }
2097
2143
  catch (e) {
2098
2144
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, e);
2099
2145
  }
2100
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2146
+ if (!this.#objects) {
2101
2147
  this._logger.info(`${this.namespaceLog} extendObject not processed because Objects database not connected`);
2102
2148
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2103
2149
  }
@@ -2138,7 +2184,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2138
2184
  options.obj.ts = options.obj.ts || Date.now();
2139
2185
  options.obj = extend(true, oldObj, options.obj);
2140
2186
  // @ts-expect-error TODO we are returning type Object for ease of use to devs, but formally these are AnyObjects, e.g. not guaranteed to have common
2141
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(options.id, options.obj, options.options, options.callback);
2187
+ return this.#objects.setObject(options.id, options.obj, options.options, options.callback);
2142
2188
  }
2143
2189
  else {
2144
2190
  options.obj.from = options.obj.from || `system.adapter.${this.namespace}`;
@@ -2165,7 +2211,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2165
2211
  return this.setForeignObject(options.id, options.obj, options.options, options.callback);
2166
2212
  }
2167
2213
  try {
2168
- const cbObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").extendObjectAsync(options.id, options.obj, options.options || {});
2214
+ const cbObj = await this.#objects.extendObjectAsync(options.id, options.obj, options.options || {});
2169
2215
  let defState;
2170
2216
  if (options.obj.type === 'state' || oldObj.type === 'state') {
2171
2217
  if (options.obj.common && 'def' in options.obj.common && options.obj.common.def !== undefined) {
@@ -2243,7 +2289,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2243
2289
  const { options, callback, obj } = _options;
2244
2290
  let { id } = _options;
2245
2291
  obj.from = obj.from || `system.adapter.${this.namespace}`;
2246
- obj.user = obj.user || (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
2292
+ obj.user = obj.user || options?.user || constants_1.SYSTEM_ADMIN_USER;
2247
2293
  obj.ts = obj.ts || Date.now();
2248
2294
  id = this.fixForbiddenCharsInId(id);
2249
2295
  // check that alias is valid if given
@@ -2324,14 +2370,14 @@ class AdapterClass extends node_events_1.EventEmitter {
2324
2370
  async _extendForeignObjectAsync(_options) {
2325
2371
  const { id, callback, options } = _options;
2326
2372
  let { obj } = _options;
2327
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2373
+ if (!this.#objects) {
2328
2374
  this._logger.info(`${this.namespaceLog} extendForeignObject not processed because Objects database not connected`);
2329
2375
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2330
2376
  }
2331
2377
  // Read whole object
2332
2378
  let oldObj;
2333
2379
  try {
2334
- oldObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(id, options);
2380
+ oldObj = await this.#objects.getObjectAsync(id, options);
2335
2381
  }
2336
2382
  catch (e) {
2337
2383
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
@@ -2363,15 +2409,15 @@ class AdapterClass extends node_events_1.EventEmitter {
2363
2409
  oldObj.native.devices = [];
2364
2410
  }
2365
2411
  obj.from = obj.from || `system.adapter.${this.namespace}`;
2366
- obj.user = obj.user || (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
2412
+ obj.user = obj.user || options?.user || constants_1.SYSTEM_ADMIN_USER;
2367
2413
  obj.ts = obj.ts || Date.now();
2368
2414
  obj = extend(true, oldObj, obj);
2369
2415
  // @ts-expect-error TODO we are returning type Object for ease of use to devs, but formally these are AnyObjects, e.g. not guaranteed to have common
2370
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, options, callback);
2416
+ return this.#objects.setObject(id, obj, options, callback);
2371
2417
  }
2372
2418
  else {
2373
2419
  obj.from = obj.from || `system.adapter.${this.namespace}`;
2374
- obj.user = obj.user || (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
2420
+ obj.user = obj.user || options?.user || constants_1.SYSTEM_ADMIN_USER;
2375
2421
  obj.ts = obj.ts || Date.now();
2376
2422
  if ((obj.type && obj.type === 'state') || (!obj.type && oldObj && oldObj.type === 'state')) {
2377
2423
  if (obj.common &&
@@ -2393,8 +2439,8 @@ class AdapterClass extends node_events_1.EventEmitter {
2393
2439
  return this.setForeignObject(id, obj, options, callback);
2394
2440
  }
2395
2441
  try {
2396
- const cbObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").extendObjectAsync(id, obj, options || {});
2397
- if ((cbObj === null || cbObj === void 0 ? void 0 : cbObj.value.type) === 'state') {
2442
+ const cbObj = await this.#objects.extendObjectAsync(id, obj, options || {});
2443
+ if (cbObj?.value.type === 'state') {
2398
2444
  let defState;
2399
2445
  if (obj.common && 'def' in obj.common && obj.common.def !== undefined) {
2400
2446
  defState = obj.common.def;
@@ -2438,7 +2484,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2438
2484
  * @param options optional user context
2439
2485
  */
2440
2486
  objectExists(id, options) {
2441
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2487
+ if (!this.#objects) {
2442
2488
  this._logger.info(`${this.namespaceLog} objectExists not processed because Objects database not connected`);
2443
2489
  return Promise.resolve();
2444
2490
  }
@@ -2448,7 +2494,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2448
2494
  }
2449
2495
  id = this._utils.fixId(id);
2450
2496
  this._utils.validateId(id, false, null);
2451
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options);
2497
+ return this.#objects.objectExists(id, options);
2452
2498
  }
2453
2499
  /**
2454
2500
  * Checks if an object exists to the given id
@@ -2457,7 +2503,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2457
2503
  * @param options optional user context
2458
2504
  */
2459
2505
  foreignObjectExists(id, options) {
2460
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2506
+ if (!this.#objects) {
2461
2507
  this._logger.info(`${this.namespaceLog} foreignObjectExists not processed because Objects database not connected`);
2462
2508
  return Promise.resolve();
2463
2509
  }
@@ -2466,7 +2512,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2466
2512
  validator_1.Validator.assertObject(options, 'options');
2467
2513
  }
2468
2514
  this._utils.validateId(id, true, null);
2469
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options);
2515
+ return this.#objects.objectExists(id, options);
2470
2516
  }
2471
2517
  /**
2472
2518
  * Get object of this instance.
@@ -2492,7 +2538,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2492
2538
  if (options !== null && options !== undefined) {
2493
2539
  validator_1.Validator.assertObject(options, 'options');
2494
2540
  }
2495
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2541
+ if (!this.#objects) {
2496
2542
  this._logger.info(`${this.namespaceLog} getObject not processed because Objects database not connected`);
2497
2543
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2498
2544
  }
@@ -2502,7 +2548,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2502
2548
  catch (err) {
2503
2549
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
2504
2550
  }
2505
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(this._utils.fixId(id), options, callback);
2551
+ this.#objects.getObject(this._utils.fixId(id), options, callback);
2506
2552
  }
2507
2553
  /**
2508
2554
  * Read object view from DB.
@@ -2547,7 +2593,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2547
2593
  }
2548
2594
  _getObjectView(_options) {
2549
2595
  const { design, search, params, options, callback } = _options;
2550
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2596
+ if (!this.#objects) {
2551
2597
  this._logger.info(`${this.namespaceLog} getObjectView not processed because Objects database not connected`);
2552
2598
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2553
2599
  }
@@ -2588,7 +2634,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2588
2634
  }
2589
2635
  }
2590
2636
  // @ts-expect-error fix it
2591
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView(design, search, params, options, callback);
2637
+ return this.#objects.getObjectView(design, search, params, options, callback);
2592
2638
  }
2593
2639
  /**
2594
2640
  * Read object list from DB.
@@ -2625,11 +2671,11 @@ class AdapterClass extends node_events_1.EventEmitter {
2625
2671
  }
2626
2672
  validator_1.Validator.assertObject(params, 'params');
2627
2673
  validator_1.Validator.assertOptionalCallback(callback, 'callback');
2628
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2674
+ if (!this.#objects) {
2629
2675
  this._logger.info(`${this.namespaceLog} getObjectList not processed because Objects database not connected`);
2630
2676
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2631
2677
  }
2632
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList(params, options, callback);
2678
+ this.#objects.getObjectList(params, options, callback);
2633
2679
  }
2634
2680
  /**
2635
2681
  * Get the enum tree.
@@ -2679,7 +2725,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2679
2725
  _getEnum(_options) {
2680
2726
  const { options, callback } = _options;
2681
2727
  let { _enum } = _options;
2682
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2728
+ if (!this.#objects) {
2683
2729
  this._logger.info(`${this.namespaceLog} getEnum not processed because Objects database not connected`);
2684
2730
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2685
2731
  }
@@ -2687,14 +2733,14 @@ class AdapterClass extends node_events_1.EventEmitter {
2687
2733
  _enum = `enum.${_enum}`;
2688
2734
  }
2689
2735
  const result = {};
2690
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
2736
+ this.#objects.getObjectView('system', 'enum', {
2691
2737
  startkey: `${_enum}.`,
2692
2738
  endkey: `${_enum}.\u9999`
2693
2739
  }, options, (err, res) => {
2694
2740
  if (err) {
2695
2741
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
2696
2742
  }
2697
- if (res === null || res === void 0 ? void 0 : res.rows) {
2743
+ if (res?.rows) {
2698
2744
  for (const row of res.rows) {
2699
2745
  result[row.id] = row.value;
2700
2746
  }
@@ -2762,7 +2808,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2762
2808
  async _getEnums(_options) {
2763
2809
  const { options, callback } = _options;
2764
2810
  let { _enumList } = _options;
2765
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2811
+ if (!this.#objects) {
2766
2812
  this._logger.info(`${this.namespaceLog} getEnums not processed because Objects database not connected`);
2767
2813
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2768
2814
  }
@@ -2793,7 +2839,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2793
2839
  }
2794
2840
  else {
2795
2841
  // Read all enums
2796
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
2842
+ this.#objects.getObjectView('system', 'enum', {
2797
2843
  startkey: 'enum.',
2798
2844
  endkey: 'enum.\u9999'
2799
2845
  }, options, (err, res) => {
@@ -2802,7 +2848,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2802
2848
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
2803
2849
  }
2804
2850
  const result = {};
2805
- if (res === null || res === void 0 ? void 0 : res.rows) {
2851
+ if (res?.rows) {
2806
2852
  for (const row of res.rows) {
2807
2853
  const parts = row.id.split('.', 3);
2808
2854
  if (!parts[2]) {
@@ -2899,16 +2945,15 @@ class AdapterClass extends node_events_1.EventEmitter {
2899
2945
  });
2900
2946
  }
2901
2947
  async _getForeignObjects(_options) {
2902
- var _a;
2903
2948
  const { options, callback, type, pattern, enums } = _options;
2904
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
2949
+ if (!this.#objects) {
2905
2950
  this._logger.info(`${this.namespaceLog} getForeignObjects not processed because Objects database not connected`);
2906
2951
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
2907
2952
  }
2908
2953
  let objs;
2909
2954
  if (Array.isArray(pattern)) {
2910
2955
  try {
2911
- objs = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjects(pattern, options);
2956
+ objs = await this.#objects.getObjects(pattern, options);
2912
2957
  }
2913
2958
  catch (e) {
2914
2959
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
@@ -2923,7 +2968,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2923
2968
  };
2924
2969
  }
2925
2970
  try {
2926
- const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', type || 'state', params, options);
2971
+ const res = await this.#objects.getObjectView('system', type || 'state', params, options);
2927
2972
  objs = res.rows.map(row => row.value);
2928
2973
  }
2929
2974
  catch (e) {
@@ -2958,7 +3003,7 @@ class AdapterClass extends node_events_1.EventEmitter {
2958
3003
  list[id].enums = {};
2959
3004
  for (const _enum of Object.values(_enums)) {
2960
3005
  for (const [enumID, enumObj] of Object.entries(_enum)) {
2961
- if (!((_a = enumObj === null || enumObj === void 0 ? void 0 : enumObj.common) === null || _a === void 0 ? void 0 : _a.members)) {
3006
+ if (!enumObj?.common?.members) {
2962
3007
  continue;
2963
3008
  }
2964
3009
  if (enumObj.common.members.includes(id) ||
@@ -3017,7 +3062,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3017
3062
  if (options !== null && options !== undefined) {
3018
3063
  validator_1.Validator.assertObject(options, 'options');
3019
3064
  }
3020
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3065
+ if (!this.#objects) {
3021
3066
  this._logger.info(`${this.namespaceLog} findForeignObject not processed because Objects database not connected`);
3022
3067
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3023
3068
  }
@@ -3027,7 +3072,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3027
3072
  catch (err) {
3028
3073
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
3029
3074
  }
3030
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").findObject(id, type, options || {}, callback);
3075
+ this.#objects.findObject(id, type, options || {}, callback);
3031
3076
  }
3032
3077
  /**
3033
3078
  * Get any object.
@@ -3061,12 +3106,12 @@ class AdapterClass extends node_events_1.EventEmitter {
3061
3106
  return this._getForeignObject({ id, options, callback });
3062
3107
  }
3063
3108
  async _getForeignObject(options) {
3064
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3109
+ if (!this.#objects) {
3065
3110
  this._logger.info(`${this.namespaceLog} getForeignObject not processed because Objects database not connected`);
3066
3111
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3067
3112
  }
3068
3113
  try {
3069
- const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(options.id, options);
3114
+ const obj = await this.#objects.getObjectAsync(options.id, options);
3070
3115
  // remove protectedNative if not admin, not cloud or not own adapter
3071
3116
  if (obj &&
3072
3117
  'protectedNative' in obj &&
@@ -3116,7 +3161,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3116
3161
  }
3117
3162
  else {
3118
3163
  const task = tasks.shift();
3119
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").delObject(task.id, options, async (err) => {
3164
+ this.#objects.delObject(task.id, options, async (err) => {
3120
3165
  if (err) {
3121
3166
  return js_controller_common_1.tools.maybeCallbackWithError(cb, err);
3122
3167
  }
@@ -3129,7 +3174,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3129
3174
  }
3130
3175
  }
3131
3176
  try {
3132
- await js_controller_common_1.tools.removeIdFromAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), task.id, this.enums);
3177
+ await js_controller_common_1.tools.removeIdFromAllEnums(this.#objects, task.id, this.enums);
3133
3178
  }
3134
3179
  catch (e) {
3135
3180
  this._logger.warn(`${this.namespaceLog} Could not remove ${task.id} from enums: ${e.message}`);
@@ -3162,7 +3207,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3162
3207
  if (options !== undefined && options !== null) {
3163
3208
  validator_1.Validator.assertObject(options, 'options');
3164
3209
  }
3165
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3210
+ if (!this.#objects) {
3166
3211
  this._logger.info(`${this.namespaceLog} delForeignObject not processed because Objects database not connected`);
3167
3212
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3168
3213
  }
@@ -3181,13 +3226,13 @@ class AdapterClass extends node_events_1.EventEmitter {
3181
3226
  _delForeignObject(_options) {
3182
3227
  const { id, options, callback } = _options;
3183
3228
  // If recursive deletion of all underlying objects, including id
3184
- if (options === null || options === void 0 ? void 0 : options.recursive) {
3229
+ if (options?.recursive) {
3185
3230
  // read object itself
3186
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options, (err, obj) => {
3231
+ this.#objects.getObject(id, options, (err, obj) => {
3187
3232
  const tasks = obj && (!obj.common || !obj.common.dontDelete) ? [{ id, state: obj.type === 'state' }] : [];
3188
3233
  const selector = { startkey: `${id}.`, endkey: `${id}.\u9999` };
3189
3234
  // read all underlying states
3190
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList(selector, options, (err, res) => {
3235
+ this.#objects.getObjectList(selector, options, (err, res) => {
3191
3236
  res &&
3192
3237
  res.rows.forEach((item) => !tasks.find(task => task.id === item.id) &&
3193
3238
  (!item.value || !item.value.common || !item.value.common.dontDelete) && // exclude objects with dontDelete flag
@@ -3197,18 +3242,17 @@ class AdapterClass extends node_events_1.EventEmitter {
3197
3242
  });
3198
3243
  }
3199
3244
  else {
3200
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options, async (err, obj) => {
3201
- var _a;
3245
+ this.#objects.getObject(id, options, async (err, obj) => {
3202
3246
  if (err) {
3203
3247
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
3204
3248
  }
3205
3249
  else if (obj) {
3206
3250
  // do not allow deletion of objects with dontDelete flag
3207
- if ((_a = obj.common) === null || _a === void 0 ? void 0 : _a.dontDelete) {
3251
+ if (obj.common?.dontDelete) {
3208
3252
  return js_controller_common_1.tools.maybeCallbackWithError(callback, new Error('not deletable'));
3209
3253
  }
3210
3254
  try {
3211
- await __classPrivateFieldGet(this, _AdapterClass_objects, "f").delObject(obj._id, options);
3255
+ await this.#objects.delObject(obj._id, options);
3212
3256
  }
3213
3257
  catch (err) {
3214
3258
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
@@ -3227,7 +3271,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3227
3271
  }
3228
3272
  }
3229
3273
  try {
3230
- await js_controller_common_1.tools.removeIdFromAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), id, this.enums);
3274
+ await js_controller_common_1.tools.removeIdFromAllEnums(this.#objects, id, this.enums);
3231
3275
  }
3232
3276
  catch (e) {
3233
3277
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
@@ -3259,16 +3303,16 @@ class AdapterClass extends node_events_1.EventEmitter {
3259
3303
  if (options !== null && options !== undefined) {
3260
3304
  validator_1.Validator.assertObject(options, 'options');
3261
3305
  }
3262
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3306
+ if (!this.#objects) {
3263
3307
  this._logger.info(`${this.namespaceLog} subscribeObjects not processed because Objects database not connected`);
3264
3308
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3265
3309
  }
3266
3310
  if (pattern === '*') {
3267
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(`${this.namespace}.*`, options, callback);
3311
+ this.#objects.subscribeUser(`${this.namespace}.*`, options, callback);
3268
3312
  }
3269
3313
  else {
3270
3314
  const fixedPattern = Array.isArray(pattern) ? pattern : this._utils.fixId(pattern, true);
3271
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(fixedPattern, options, callback);
3315
+ this.#objects.subscribeUser(fixedPattern, options, callback);
3272
3316
  }
3273
3317
  }
3274
3318
  /**
@@ -3293,16 +3337,16 @@ class AdapterClass extends node_events_1.EventEmitter {
3293
3337
  if (options !== null && options !== undefined) {
3294
3338
  validator_1.Validator.assertObject(options, 'options');
3295
3339
  }
3296
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3340
+ if (!this.#objects) {
3297
3341
  this._logger.info(`${this.namespaceLog} unsubscribeObjects not processed because Objects database not connected`);
3298
3342
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3299
3343
  }
3300
3344
  if (pattern === '*') {
3301
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(`${this.namespace}.*`, options, callback);
3345
+ this.#objects.unsubscribeUser(`${this.namespace}.*`, options, callback);
3302
3346
  }
3303
3347
  else {
3304
3348
  const fixedPattern = Array.isArray(pattern) ? pattern : this._utils.fixId(pattern, true);
3305
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(fixedPattern, options, callback);
3349
+ this.#objects.unsubscribeUser(fixedPattern, options, callback);
3306
3350
  }
3307
3351
  }
3308
3352
  /**
@@ -3327,11 +3371,11 @@ class AdapterClass extends node_events_1.EventEmitter {
3327
3371
  if (options !== null && options !== undefined) {
3328
3372
  validator_1.Validator.assertObject(options, 'options');
3329
3373
  }
3330
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3374
+ if (!this.#objects) {
3331
3375
  this._logger.info(`${this.namespaceLog} subscribeForeignObjects not processed because Objects database not connected`);
3332
3376
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3333
3377
  }
3334
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(pattern, options, callback);
3378
+ this.#objects.subscribeUser(pattern, options, callback);
3335
3379
  }
3336
3380
  /**
3337
3381
  * Unsubscribe for the patterns on all objects.
@@ -3358,11 +3402,11 @@ class AdapterClass extends node_events_1.EventEmitter {
3358
3402
  if (options !== null && options !== undefined) {
3359
3403
  validator_1.Validator.assertObject(options, 'options');
3360
3404
  }
3361
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3405
+ if (!this.#objects) {
3362
3406
  this._logger.info(`${this.namespaceLog} unsubscribeForeignObjects not processed because Objects database not connected`);
3363
3407
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3364
3408
  }
3365
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(pattern, options, callback);
3409
+ this.#objects.unsubscribeUser(pattern, options, callback);
3366
3410
  }
3367
3411
  /**
3368
3412
  * Subscribe for the changes of files in specific instance.
@@ -3372,7 +3416,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3372
3416
  * @param options optional user context
3373
3417
  */
3374
3418
  subscribeForeignFiles(id, pattern, options) {
3375
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3419
+ if (!this.#objects) {
3376
3420
  this._logger.info(`${this.namespaceLog} subscribeForeignFiles not processed because Objects database not connected`);
3377
3421
  return Promise.reject(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3378
3422
  }
@@ -3381,7 +3425,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3381
3425
  if (options !== null && options !== undefined) {
3382
3426
  validator_1.Validator.assertObject(options, 'options');
3383
3427
  }
3384
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUserFile(id, pattern, options);
3428
+ return this.#objects.subscribeUserFile(id, pattern, options);
3385
3429
  }
3386
3430
  /**
3387
3431
  * Unsubscribe for the changes of files on specific instance.
@@ -3394,7 +3438,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3394
3438
  if (!pattern) {
3395
3439
  pattern = '*';
3396
3440
  }
3397
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3441
+ if (!this.#objects) {
3398
3442
  this._logger.info(`${this.namespaceLog} unsubscribeForeignFiles not processed because Objects database not connected`);
3399
3443
  return Promise.reject(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3400
3444
  }
@@ -3403,7 +3447,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3403
3447
  if (options !== null && options !== undefined) {
3404
3448
  validator_1.Validator.assertObject(options, 'options');
3405
3449
  }
3406
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUserFile(id, pattern, options);
3450
+ return this.#objects.unsubscribeUserFile(id, pattern, options);
3407
3451
  }
3408
3452
  /**
3409
3453
  * Same as {@link AdapterClass.setObject}, but with check if the object exists.
@@ -3446,7 +3490,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3446
3490
  });
3447
3491
  }
3448
3492
  async _setObjectNotExists(options) {
3449
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3493
+ if (!this.#objects) {
3450
3494
  this._logger.info(`${this.namespaceLog} setObjectNotExists not processed because Objects database not connected`);
3451
3495
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3452
3496
  }
@@ -3456,7 +3500,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3456
3500
  // check if object already exists
3457
3501
  let objExists;
3458
3502
  try {
3459
- objExists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(options.id, options.options);
3503
+ objExists = await this.#objects.objectExists(options.id, options.options);
3460
3504
  }
3461
3505
  catch (e) {
3462
3506
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, `Could not check object existence of ${options.id}: ${e.message}`);
@@ -3509,7 +3553,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3509
3553
  }
3510
3554
  async _setForeignObjectNotExists(_options) {
3511
3555
  const { id, obj, options, callback } = _options;
3512
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3556
+ if (!this.#objects) {
3513
3557
  this._logger.info(`${this.namespaceLog} setForeignObjectNotExists not processed because Objects database not connected`);
3514
3558
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3515
3559
  }
@@ -3522,7 +3566,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3522
3566
  // check if object exists
3523
3567
  let objExists;
3524
3568
  try {
3525
- objExists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options || {});
3569
+ objExists = await this.#objects.objectExists(id, options || {});
3526
3570
  }
3527
3571
  catch (e) {
3528
3572
  return js_controller_common_1.tools.maybeCallbackWithError(callback, `Could not check object existence of ${id}: ${e.message}`);
@@ -3532,7 +3576,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3532
3576
  obj.from = `system.adapter.${this.namespace}`;
3533
3577
  }
3534
3578
  if (!obj.user) {
3535
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
3579
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
3536
3580
  }
3537
3581
  if (!obj.ts) {
3538
3582
  obj.ts = Date.now();
@@ -3830,7 +3874,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3830
3874
  async _deleteDevice(_options) {
3831
3875
  const { callback } = _options;
3832
3876
  let { deviceName } = _options;
3833
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3877
+ if (!this.#objects) {
3834
3878
  this._logger.info(`${this.namespaceLog} deleteDevice not processed because Objects database not connected`);
3835
3879
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3836
3880
  }
@@ -3878,7 +3922,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3878
3922
  _addChannelToEnum(_options) {
3879
3923
  const { addTo, options, callback } = _options;
3880
3924
  let { enumName, parentDevice, channelName } = _options;
3881
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
3925
+ if (!this.#objects) {
3882
3926
  this._logger.info(`${this.namespaceLog} addChannelToEnum not processed because Objects database not connected`);
3883
3927
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3884
3928
  }
@@ -3897,7 +3941,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3897
3941
  channelName = channelName.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
3898
3942
  const objId = `${this.namespace}.${this._DCS2ID(parentDevice, channelName)}`;
3899
3943
  if (addTo.startsWith('enum.')) {
3900
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(addTo, options, (err, obj) => {
3944
+ this.#objects.getObject(addTo, options, (err, obj) => {
3901
3945
  if (err) {
3902
3946
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
3903
3947
  }
@@ -3905,9 +3949,9 @@ class AdapterClass extends node_events_1.EventEmitter {
3905
3949
  if (!obj.common.members.includes(objId)) {
3906
3950
  obj.common.members.push(objId);
3907
3951
  obj.from = `system.adapter.${this.namespace}`;
3908
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
3952
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
3909
3953
  obj.ts = Date.now();
3910
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
3954
+ this.#objects.setObject(obj._id, obj, options, callback);
3911
3955
  }
3912
3956
  else {
3913
3957
  return js_controller_common_1.tools.maybeCallback(callback);
@@ -3919,7 +3963,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3919
3963
  if (enumName.startsWith('enum.')) {
3920
3964
  enumName = enumName.substring(5);
3921
3965
  }
3922
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
3966
+ this.#objects.getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
3923
3967
  if (err) {
3924
3968
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
3925
3969
  }
@@ -3929,9 +3973,9 @@ class AdapterClass extends node_events_1.EventEmitter {
3929
3973
  // @ts-expect-error
3930
3974
  obj.common.members.push(objId);
3931
3975
  obj.from = `system.adapter.${this.namespace}`;
3932
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
3976
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
3933
3977
  obj.ts = Date.now();
3934
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
3978
+ this.#objects.setObject(obj._id, obj, options, callback);
3935
3979
  }
3936
3980
  else {
3937
3981
  return js_controller_common_1.tools.maybeCallback(callback);
@@ -3939,7 +3983,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3939
3983
  }
3940
3984
  else {
3941
3985
  // Create enum
3942
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(`enum.${enumName}.${addTo}`, {
3986
+ this.#objects.setObject(`enum.${enumName}.${addTo}`, {
3943
3987
  common: {
3944
3988
  name: addTo,
3945
3989
  members: [objId]
@@ -3970,7 +4014,7 @@ class AdapterClass extends node_events_1.EventEmitter {
3970
4014
  _deleteChannelFromEnum(_options) {
3971
4015
  const { options, callback } = _options;
3972
4016
  let { enumName, channelName, parentDevice } = _options;
3973
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4017
+ if (!this.#objects) {
3974
4018
  this._logger.info(`${this.namespaceLog} deleteChannelFromEnum not processed because Objects database not connected`);
3975
4019
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
3976
4020
  }
@@ -3995,26 +4039,25 @@ class AdapterClass extends node_events_1.EventEmitter {
3995
4039
  else {
3996
4040
  enumName = 'enum.';
3997
4041
  }
3998
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
4042
+ this.#objects.getObjectView('system', 'enum', {
3999
4043
  startkey: enumName,
4000
4044
  endkey: `${enumName}\u9999`
4001
4045
  }, options, async (err, res) => {
4002
- var _a;
4003
4046
  if (err) {
4004
4047
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
4005
4048
  }
4006
4049
  if (res) {
4007
4050
  for (const row of res.rows) {
4008
4051
  try {
4009
- const obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(row.id, options));
4010
- if ((_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.members) {
4052
+ const obj = (await this.#objects.getObject(row.id, options));
4053
+ if (obj?.common?.members) {
4011
4054
  const pos = obj.common.members.indexOf(objId);
4012
4055
  if (pos !== -1) {
4013
4056
  obj.common.members.splice(pos, 1);
4014
4057
  obj.from = `system.adapter.${this.namespace}`;
4015
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
4058
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
4016
4059
  obj.ts = Date.now();
4017
- await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(obj._id, obj, options);
4060
+ await this.#objects.setObjectAsync(obj._id, obj, options);
4018
4061
  }
4019
4062
  }
4020
4063
  }
@@ -4067,7 +4110,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4067
4110
  async _deleteChannel(_options) {
4068
4111
  const { callback } = _options;
4069
4112
  let { channelName, parentDevice } = _options;
4070
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4113
+ if (!this.#objects) {
4071
4114
  this._logger.info(`${this.namespaceLog} deleteChannel not processed because Objects database not connected`);
4072
4115
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4073
4116
  }
@@ -4147,9 +4190,9 @@ class AdapterClass extends node_events_1.EventEmitter {
4147
4190
  parentDevice = '';
4148
4191
  }
4149
4192
  }
4150
- parentDevice = parentDevice !== null && parentDevice !== void 0 ? parentDevice : '';
4151
- parentChannel = parentChannel !== null && parentChannel !== void 0 ? parentChannel : '';
4152
- stateName = stateName !== null && stateName !== void 0 ? stateName : '';
4193
+ parentDevice = parentDevice ?? '';
4194
+ parentChannel = parentChannel ?? '';
4195
+ stateName = stateName ?? '';
4153
4196
  validator_1.Validator.assertString(parentDevice, 'parentDevice');
4154
4197
  validator_1.Validator.assertString(parentChannel, 'parentChannel');
4155
4198
  validator_1.Validator.assertString(stateName, 'stateName');
@@ -4209,11 +4252,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4209
4252
  }
4210
4253
  _getDevices(_options) {
4211
4254
  const { options, callback } = _options;
4212
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4255
+ if (!this.#objects) {
4213
4256
  this._logger.info(`${this.namespaceLog} getDevices not processed because Objects database not connected`);
4214
4257
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4215
4258
  }
4216
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'device', {
4259
+ this.#objects.getObjectView('system', 'device', {
4217
4260
  startkey: `${this.namespace}.`,
4218
4261
  endkey: `${this.namespace}.\u9999`
4219
4262
  }, options, (err, obj) => {
@@ -4248,7 +4291,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4248
4291
  return this._getChannelsOf({ parentDevice, options, callback });
4249
4292
  }
4250
4293
  _getChannelsOf(options) {
4251
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4294
+ if (!this.#objects) {
4252
4295
  this._logger.info(`${this.namespaceLog} getChannelsOf not processed because Objects database not connected`);
4253
4296
  return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4254
4297
  }
@@ -4260,7 +4303,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4260
4303
  }
4261
4304
  options.parentDevice = options.parentDevice.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
4262
4305
  options.parentDevice = this.namespace + (options.parentDevice ? `.${options.parentDevice}` : '');
4263
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'channel', {
4306
+ this.#objects.getObjectView('system', 'channel', {
4264
4307
  startkey: `${options.parentDevice}.`,
4265
4308
  endkey: `${options.parentDevice}.\u9999`
4266
4309
  }, options.options || {}, (err, obj) => {
@@ -4308,7 +4351,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4308
4351
  _getStatesOf(_options) {
4309
4352
  const { options, callback } = _options;
4310
4353
  let { parentDevice, parentChannel } = _options;
4311
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4354
+ if (!this.#objects) {
4312
4355
  this._logger.info(`${this.namespaceLog} getStatesOf not processed because Objects database not connected`);
4313
4356
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4314
4357
  }
@@ -4332,7 +4375,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4332
4375
  }
4333
4376
  parentChannel = parentChannel.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
4334
4377
  const id = `${this.namespace}.${this._DCS2ID(parentDevice, parentChannel, true)}`;
4335
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'state', {
4378
+ this.#objects.getObjectView('system', 'state', {
4336
4379
  startkey: id,
4337
4380
  endkey: `${id}\u9999`
4338
4381
  }, options, (err, obj) => {
@@ -4343,7 +4386,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4343
4386
  let read = 0;
4344
4387
  for (const row of obj.rows) {
4345
4388
  read++;
4346
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(row.id, (err, subObj) => {
4389
+ this.#objects.getObject(row.id, (err, subObj) => {
4347
4390
  if (subObj) {
4348
4391
  res.push(subObj);
4349
4392
  }
@@ -4373,7 +4416,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4373
4416
  _addStateToEnum(_options) {
4374
4417
  const { addTo, options, callback } = _options;
4375
4418
  let { enumName, parentDevice, parentChannel, stateName } = _options;
4376
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4419
+ if (!this.#objects) {
4377
4420
  this._logger.info(`${this.namespaceLog} addStateToEnum not processed because Objects database not connected`);
4378
4421
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4379
4422
  }
@@ -4404,16 +4447,16 @@ class AdapterClass extends node_events_1.EventEmitter {
4404
4447
  stateName = stateName.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
4405
4448
  const objId = this._utils.fixId({ device: parentDevice, channel: parentChannel, state: stateName });
4406
4449
  if (addTo.startsWith('enum.')) {
4407
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(addTo, options, (err, obj) => {
4450
+ this.#objects.getObject(addTo, options, (err, obj) => {
4408
4451
  if (err || !obj) {
4409
4452
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err || js_controller_common_1.tools.ERRORS.ERROR_NOT_FOUND);
4410
4453
  }
4411
4454
  if (!obj.common.members.includes(objId)) {
4412
4455
  obj.common.members.push(objId);
4413
4456
  obj.from = `system.adapter.${this.namespace}`;
4414
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
4457
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
4415
4458
  obj.ts = Date.now();
4416
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
4459
+ this.#objects.setObject(obj._id, obj, options, callback);
4417
4460
  }
4418
4461
  else {
4419
4462
  return js_controller_common_1.tools.maybeCallback(callback);
@@ -4424,15 +4467,15 @@ class AdapterClass extends node_events_1.EventEmitter {
4424
4467
  if (enumName.startsWith('enum.')) {
4425
4468
  enumName = enumName.substring(5);
4426
4469
  }
4427
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
4470
+ this.#objects.getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
4428
4471
  if (!err && obj) {
4429
4472
  // @ts-expect-error cast to enum object
4430
4473
  if (!obj.common.members.includes(objId)) {
4431
4474
  obj.common.members.push(objId);
4432
4475
  obj.from = `system.adapter.${this.namespace}`;
4433
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
4476
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
4434
4477
  obj.ts = Date.now();
4435
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, callback);
4478
+ this.#objects.setObject(obj._id, obj, callback);
4436
4479
  }
4437
4480
  else {
4438
4481
  return js_controller_common_1.tools.maybeCallback(callback);
@@ -4443,7 +4486,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4443
4486
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
4444
4487
  }
4445
4488
  // Create enum
4446
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(`enum.${enumName}.${addTo}`, {
4489
+ this.#objects.setObject(`enum.${enumName}.${addTo}`, {
4447
4490
  common: {
4448
4491
  name: addTo,
4449
4492
  members: [objId]
@@ -4475,7 +4518,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4475
4518
  _deleteStateFromEnum(_options) {
4476
4519
  const { options, callback } = _options;
4477
4520
  let { enumName, parentDevice, parentChannel, stateName } = _options;
4478
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4521
+ if (!this.#objects) {
4479
4522
  this._logger.info(`${this.namespaceLog} deleteStateFromEnum not processed because Objects database not connected`);
4480
4523
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4481
4524
  }
@@ -4515,7 +4558,7 @@ class AdapterClass extends node_events_1.EventEmitter {
4515
4558
  else {
4516
4559
  enumName = 'enum.';
4517
4560
  }
4518
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
4561
+ this.#objects.getObjectView('system', 'enum', {
4519
4562
  startkey: enumName,
4520
4563
  endkey: `${enumName}\u9999`
4521
4564
  }, options, async (err, res) => {
@@ -4524,15 +4567,15 @@ class AdapterClass extends node_events_1.EventEmitter {
4524
4567
  }
4525
4568
  for (const row of res.rows) {
4526
4569
  try {
4527
- const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(row.id);
4570
+ const obj = await this.#objects.getObjectAsync(row.id);
4528
4571
  if (obj && obj.common && obj.common.members) {
4529
4572
  const pos = obj.common.members.indexOf(objId);
4530
4573
  if (pos !== -1) {
4531
4574
  obj.common.members.splice(pos, 1);
4532
4575
  obj.from = `system.adapter.${this.namespace}`;
4533
- obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
4576
+ obj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
4534
4577
  obj.ts = Date.now();
4535
- await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(obj._id, obj);
4578
+ await this.#objects.setObjectAsync(obj._id, obj);
4536
4579
  }
4537
4580
  }
4538
4581
  }
@@ -4572,11 +4615,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4572
4615
  callback = options;
4573
4616
  options = null;
4574
4617
  }
4575
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4618
+ if (!this.#objects) {
4576
4619
  this._logger.info(`${this.namespaceLog} chmodFile not processed because Objects database not connected`);
4577
4620
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4578
4621
  }
4579
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").chmodFile(_adapter, path, options, callback);
4622
+ this.#objects.chmodFile(_adapter, path, options, callback);
4580
4623
  }
4581
4624
  /**
4582
4625
  * Change a file owner
@@ -4607,11 +4650,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4607
4650
  callback = options;
4608
4651
  options = null;
4609
4652
  }
4610
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4653
+ if (!this.#objects) {
4611
4654
  this._logger.info(`${this.namespaceLog} chownFile not processed because Objects database not connected`);
4612
4655
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4613
4656
  }
4614
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").chownFile(_adapter, path, options, callback);
4657
+ this.#objects.chownFile(_adapter, path, options, callback);
4615
4658
  }
4616
4659
  /**
4617
4660
  * Read directory from DB.
@@ -4662,11 +4705,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4662
4705
  if (options !== null && options !== undefined) {
4663
4706
  validator_1.Validator.assertObject(options, 'options');
4664
4707
  }
4665
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4708
+ if (!this.#objects) {
4666
4709
  this._logger.info(`${this.namespaceLog} readDir not processed because Objects database not connected`);
4667
4710
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4668
4711
  }
4669
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").readDir(_adapter, path, options, callback);
4712
+ this.#objects.readDir(_adapter, path, options, callback);
4670
4713
  }
4671
4714
  unlink(_adapter, name, options, callback) {
4672
4715
  if (_adapter === null) {
@@ -4682,11 +4725,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4682
4725
  if (options !== undefined && options !== null) {
4683
4726
  validator_1.Validator.assertObject(options, 'options');
4684
4727
  }
4685
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4728
+ if (!this.#objects) {
4686
4729
  this._logger.info(`${this.namespaceLog} unlink not processed because Objects database not connected`);
4687
4730
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4688
4731
  }
4689
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").unlink(_adapter, name, options, callback);
4732
+ this.#objects.unlink(_adapter, name, options, callback);
4690
4733
  }
4691
4734
  rename(_adapter, oldName, newName, options, callback) {
4692
4735
  if (_adapter === null) {
@@ -4703,11 +4746,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4703
4746
  if (options !== null && options !== undefined) {
4704
4747
  validator_1.Validator.assertObject(options, 'options');
4705
4748
  }
4706
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4749
+ if (!this.#objects) {
4707
4750
  this._logger.info(`${this.namespaceLog} rename not processed because Objects database not connected`);
4708
4751
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4709
4752
  }
4710
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").rename(_adapter, oldName, newName, options, callback);
4753
+ this.#objects.rename(_adapter, oldName, newName, options, callback);
4711
4754
  }
4712
4755
  mkdir(_adapter, dirname, options, callback) {
4713
4756
  if (_adapter === null) {
@@ -4723,11 +4766,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4723
4766
  if (options !== undefined && options !== null) {
4724
4767
  validator_1.Validator.assertObject(options, 'options');
4725
4768
  }
4726
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4769
+ if (!this.#objects) {
4727
4770
  this._logger.info(`${this.namespaceLog} mkdir not processed because Objects database not connected`);
4728
4771
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4729
4772
  }
4730
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").mkdir(_adapter, dirname, options, callback);
4773
+ this.#objects.mkdir(_adapter, dirname, options, callback);
4731
4774
  }
4732
4775
  /**
4733
4776
  * Read file from DB.
@@ -4765,11 +4808,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4765
4808
  validator_1.Validator.assertObject(options, 'options');
4766
4809
  }
4767
4810
  validator_1.Validator.assertCallback(callback, 'callback');
4768
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4811
+ if (!this.#objects) {
4769
4812
  this._logger.info(`${this.namespaceLog} readFile not processed because Objects database not connected`);
4770
4813
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4771
4814
  }
4772
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").readFile(_adapter, filename, options, callback);
4815
+ this.#objects.readFile(_adapter, filename, options, callback);
4773
4816
  }
4774
4817
  /**
4775
4818
  * Write file to DB.
@@ -4809,11 +4852,11 @@ class AdapterClass extends node_events_1.EventEmitter {
4809
4852
  if (typeof data !== 'string') {
4810
4853
  validator_1.Validator.assertBuffer(data, 'data');
4811
4854
  }
4812
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4855
+ if (!this.#objects) {
4813
4856
  this._logger.info(`${this.namespaceLog} writeFile not processed because Objects database not connected`);
4814
4857
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4815
4858
  }
4816
- return __classPrivateFieldGet(this, _AdapterClass_objects, "f").writeFile(_adapter, filename, data, options, callback);
4859
+ return this.#objects.writeFile(_adapter, filename, data, options, callback);
4817
4860
  }
4818
4861
  /**
4819
4862
  * Checks if file exists in DB.
@@ -4834,12 +4877,12 @@ class AdapterClass extends node_events_1.EventEmitter {
4834
4877
  if (options !== null && options !== undefined) {
4835
4878
  validator_1.Validator.assertObject(options, 'options');
4836
4879
  }
4837
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
4880
+ if (!this.#objects) {
4838
4881
  this._logger.info(`${this.namespaceLog} fileExists not processed because Objects database not connected`);
4839
4882
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
4840
4883
  }
4841
4884
  try {
4842
- const exists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").fileExists(_adapter, filename, options);
4885
+ const exists = await this.#objects.fileExists(_adapter, filename, options);
4843
4886
  return js_controller_common_1.tools.maybeCallbackWithError(callback, null, exists);
4844
4887
  }
4845
4888
  catch (e) {
@@ -5093,7 +5136,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5093
5136
  if (!instanceName.startsWith('system.adapter.')) {
5094
5137
  instanceName = `system.adapter.${instanceName}`;
5095
5138
  }
5096
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5139
+ if (!this.#states) {
5097
5140
  // if states is no longer existing, we do not need to unsubscribe
5098
5141
  this._logger.info(`${this.namespaceLog} sendTo not processed because States database not connected`);
5099
5142
  // @ts-expect-error TODO it could also be the cb object
@@ -5107,21 +5150,21 @@ class AdapterClass extends node_events_1.EventEmitter {
5107
5150
  }
5108
5151
  // If not specific instance
5109
5152
  if (!instanceName.match(/\.[0-9]+$/)) {
5110
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5153
+ if (!this.#objects) {
5111
5154
  this._logger.info(`${this.namespaceLog} sendTo not processed because Objects database not connected`);
5112
5155
  // @ts-expect-error TODO it could also be the cb object
5113
5156
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5114
5157
  }
5115
5158
  try {
5116
5159
  // Send to all instances of adapter
5117
- const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'instance', {
5160
+ const res = await this.#objects.getObjectView('system', 'instance', {
5118
5161
  startkey: `${instanceName}.`,
5119
5162
  endkey: `${instanceName}.\u9999`
5120
5163
  });
5121
5164
  if (res) {
5122
5165
  for (const row of res.rows) {
5123
5166
  try {
5124
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(row.id, obj);
5167
+ await this.#states.pushMessage(row.id, obj);
5125
5168
  }
5126
5169
  catch (e) {
5127
5170
  // @ts-expect-error TODO it could also be the cb object
@@ -5140,7 +5183,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5140
5183
  // force subscribe even no messagebox enabled
5141
5184
  if (!(0, utils_1.isMessageboxSupported)(this.common) && !this.mboxSubscribed) {
5142
5185
  this.mboxSubscribed = true;
5143
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
5186
+ this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
5144
5187
  }
5145
5188
  obj.callback = {
5146
5189
  message: message,
@@ -5153,7 +5196,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5153
5196
  }
5154
5197
  const callbackId = obj.callback.id;
5155
5198
  let timer;
5156
- if (options === null || options === void 0 ? void 0 : options.timeout) {
5199
+ if (options?.timeout) {
5157
5200
  timer = setTimeout(() => {
5158
5201
  const callbackObj = this.messageCallbacks.get(callbackId);
5159
5202
  if (callbackObj) {
@@ -5177,7 +5220,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5177
5220
  }
5178
5221
  }
5179
5222
  try {
5180
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(instanceName, obj);
5223
+ await this.#states.pushMessage(instanceName, obj);
5181
5224
  }
5182
5225
  catch (e) {
5183
5226
  // @ts-expect-error TODO it could also be the cb object
@@ -5225,7 +5268,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5225
5268
  const { command, message, callback } = _options;
5226
5269
  let { hostName } = _options;
5227
5270
  const obj = { command, message, from: `system.adapter.${this.namespace}` };
5228
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5271
+ if (!this.#states) {
5229
5272
  // if states is no longer existing, we do not need to unsubscribe
5230
5273
  this._logger.info(`${this.namespaceLog} sendToHost not processed because States database not connected`);
5231
5274
  // @ts-expect-error TODO it could also be the cb object
@@ -5235,27 +5278,27 @@ class AdapterClass extends node_events_1.EventEmitter {
5235
5278
  hostName = `system.host.${hostName}`;
5236
5279
  }
5237
5280
  if (!hostName) {
5238
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5281
+ if (!this.#objects) {
5239
5282
  this._logger.info(`${this.namespaceLog} sendToHost not processed because Objects database not connected`);
5240
5283
  // @ts-expect-error TODO it could also be the cb object
5241
5284
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5242
5285
  }
5243
5286
  // Send to all hosts
5244
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList({
5287
+ this.#objects.getObjectList({
5245
5288
  startkey: 'system.host.',
5246
5289
  endkey: `system.host.\u9999`
5247
5290
  }, null, async (err, res) => {
5248
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5291
+ if (!this.#states) {
5249
5292
  // if states is no longer existing, we do not need to unsubscribe
5250
5293
  return;
5251
5294
  }
5252
- if (!err && (res === null || res === void 0 ? void 0 : res.rows.length)) {
5295
+ if (!err && res?.rows.length) {
5253
5296
  for (const row of res.rows) {
5254
5297
  const parts = row.id.split('.');
5255
5298
  // ignore system.host.name.alive and so on
5256
5299
  if (parts.length === 3) {
5257
5300
  try {
5258
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(row.id, obj);
5301
+ await this.#states.pushMessage(row.id, obj);
5259
5302
  }
5260
5303
  catch (e) {
5261
5304
  // @ts-expect-error TODO it could also be the cb object
@@ -5272,7 +5315,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5272
5315
  // force subscribe even no messagebox enabled
5273
5316
  if (!(0, utils_1.isMessageboxSupported)(this.common) && !this.mboxSubscribed) {
5274
5317
  this.mboxSubscribed = true;
5275
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
5318
+ this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
5276
5319
  }
5277
5320
  obj.callback = {
5278
5321
  message,
@@ -5291,7 +5334,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5291
5334
  }
5292
5335
  }
5293
5336
  try {
5294
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(hostName, obj);
5337
+ await this.#states.pushMessage(hostName, obj);
5295
5338
  }
5296
5339
  catch (e) {
5297
5340
  // @ts-expect-error TODO it could also be the cb object
@@ -5305,21 +5348,21 @@ class AdapterClass extends node_events_1.EventEmitter {
5305
5348
  * @param options clientId and data options
5306
5349
  */
5307
5350
  sendToUI(options) {
5308
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5351
+ if (!this.#states) {
5309
5352
  throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5310
5353
  }
5311
5354
  const { clientId, data } = options;
5312
5355
  if (clientId === undefined) {
5313
5356
  return this.uiMessagingController.sendToAllClients({
5314
5357
  data,
5315
- states: __classPrivateFieldGet(this, _AdapterClass_states, "f")
5358
+ states: this.#states
5316
5359
  });
5317
5360
  }
5318
5361
  validator_1.Validator.assertString(clientId, 'clientId');
5319
5362
  return this.uiMessagingController.sendToClient({
5320
5363
  clientId,
5321
5364
  data,
5322
- states: __classPrivateFieldGet(this, _AdapterClass_states, "f")
5365
+ states: this.#states
5323
5366
  });
5324
5367
  }
5325
5368
  /**
@@ -5330,7 +5373,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5330
5373
  * @param message - message to be stored/checked
5331
5374
  */
5332
5375
  async registerNotification(scope, category, message) {
5333
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5376
+ if (!this.#states) {
5334
5377
  // if states is no longer existing, we do not need to set
5335
5378
  this._logger.info(`${this.namespaceLog} registerNotification not processed because States database not connected`);
5336
5379
  throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -5345,7 +5388,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5345
5388
  message: { scope, category, message, instance: this.namespace },
5346
5389
  from: `system.adapter.${this.namespace}`
5347
5390
  };
5348
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(`system.host.${this.host}`, obj);
5391
+ await this.#states.pushMessage(`system.host.${this.host}`, obj);
5349
5392
  }
5350
5393
  /**
5351
5394
  * Writes value into states DB.
@@ -5406,15 +5449,14 @@ class AdapterClass extends node_events_1.EventEmitter {
5406
5449
  return this._setState({ id, state: state, ack, options, callback });
5407
5450
  }
5408
5451
  async _setState(_options) {
5409
- var _a, _b;
5410
5452
  const { state, ack, options, callback } = _options;
5411
5453
  const { id } = _options;
5412
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5454
+ if (!this.#states) {
5413
5455
  // if states is no longer existing, we do not need to set
5414
5456
  this._logger.info(`${this.namespaceLog} setState not processed because States database not connected`);
5415
5457
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5416
5458
  }
5417
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5459
+ if (!this.#objects) {
5418
5460
  this._logger.info(`${this.namespaceLog} setState not processed because Objects database not connected`);
5419
5461
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5420
5462
  }
@@ -5453,9 +5495,9 @@ class AdapterClass extends node_events_1.EventEmitter {
5453
5495
  typeof stateObj.from === 'string' && stateObj.from !== ''
5454
5496
  ? stateObj.from
5455
5497
  : `system.adapter.${this.namespace}`;
5456
- stateObj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
5498
+ stateObj.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
5457
5499
  let permCheckRequired = false;
5458
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
5500
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
5459
5501
  permCheckRequired = true;
5460
5502
  }
5461
5503
  let obj;
@@ -5464,13 +5506,13 @@ class AdapterClass extends node_events_1.EventEmitter {
5464
5506
  obj = (await this._checkStates(fixedId, options || {}, 'setState')).objs[0];
5465
5507
  }
5466
5508
  else {
5467
- obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(fixedId, options));
5509
+ obj = (await this.#objects.getObject(fixedId, options));
5468
5510
  }
5469
5511
  }
5470
5512
  catch (e) {
5471
5513
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
5472
5514
  }
5473
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5515
+ if (!this.#objects) {
5474
5516
  // if objects is no longer existing, we do not need to unsubscribe
5475
5517
  this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
5476
5518
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -5481,7 +5523,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5481
5523
  }
5482
5524
  if (fixedId.startsWith(constants_1.ALIAS_STARTS_WITH)) {
5483
5525
  // write alias
5484
- if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) === null || _b === void 0 ? void 0 : _b.id) {
5526
+ if (obj?.common?.alias?.id) {
5485
5527
  // id can be string or can have attribute write
5486
5528
  const aliasId = js_controller_common_1.tools.isObject(obj.common.alias.id) ? obj.common.alias.id.write : obj.common.alias.id;
5487
5529
  // validate here because we use objects/states db directly
@@ -5499,27 +5541,27 @@ class AdapterClass extends node_events_1.EventEmitter {
5499
5541
  targetObj = (await this._checkStates(aliasId, options || {}, 'setState')).objs[0];
5500
5542
  }
5501
5543
  else {
5502
- targetObj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options));
5544
+ targetObj = (await this.#objects.getObject(aliasId, options));
5503
5545
  }
5504
5546
  }
5505
5547
  catch (e) {
5506
5548
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
5507
5549
  }
5508
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5550
+ if (!this.#states) {
5509
5551
  // if states is no longer existing, we do not need to unsubscribe
5510
5552
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
5511
5553
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5512
5554
  }
5513
5555
  // write target state
5514
5556
  this.outputCount++;
5515
- return __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
5516
- sourceCommon: obj === null || obj === void 0 ? void 0 : obj.common,
5517
- targetCommon: targetObj === null || targetObj === void 0 ? void 0 : targetObj.common,
5557
+ return this.#states.setState(aliasId, js_controller_common_1.tools.formatAliasValue({
5558
+ sourceCommon: obj?.common,
5559
+ targetCommon: targetObj?.common,
5518
5560
  state: stateObj,
5519
5561
  logger: this._logger,
5520
5562
  logNamespace: this.namespaceLog,
5521
- sourceId: obj === null || obj === void 0 ? void 0 : obj._id,
5522
- targetId: targetObj === null || targetObj === void 0 ? void 0 : targetObj._id
5563
+ sourceId: obj?._id,
5564
+ targetId: targetObj?._id
5523
5565
  }), callback);
5524
5566
  }
5525
5567
  else {
@@ -5528,18 +5570,17 @@ class AdapterClass extends node_events_1.EventEmitter {
5528
5570
  }
5529
5571
  }
5530
5572
  else {
5531
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5573
+ if (!this.#states) {
5532
5574
  // if states is no longer existing, we do not need to unsubscribe
5533
5575
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
5534
5576
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5535
5577
  }
5536
5578
  this.outputCount++;
5537
- return __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(fixedId, stateObj, callback);
5579
+ return this.#states.setState(fixedId, stateObj, callback);
5538
5580
  }
5539
5581
  }
5540
5582
  // Cache will be cleared if user or group changes. Important! only if subscribed.
5541
5583
  async _getUserGroups(options) {
5542
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5543
5584
  if (this.users[options.user]) {
5544
5585
  options.groups = this.users[options.user].groups;
5545
5586
  options.acl = this.users[options.user].acl;
@@ -5578,17 +5619,17 @@ class AdapterClass extends node_events_1.EventEmitter {
5578
5619
  this.users[options.user] = {
5579
5620
  groups: options.groups,
5580
5621
  // @ts-expect-error TODO: UserCommon has no acl
5581
- acl: ((_a = userAcl.common) === null || _a === void 0 ? void 0 : _a.acl) || {}
5622
+ acl: userAcl.common?.acl || {}
5582
5623
  };
5583
5624
  await this._getGroups(options.groups);
5584
5625
  // combine all rights
5585
5626
  const user = this.users[options.user];
5586
5627
  for (const gName of options.groups) {
5587
- if (!((_b = this.groups[gName].common) === null || _b === void 0 ? void 0 : _b.acl)) {
5628
+ if (!this.groups[gName].common?.acl) {
5588
5629
  continue;
5589
5630
  }
5590
5631
  const group = this.groups[gName];
5591
- if ((_d = (_c = group.common) === null || _c === void 0 ? void 0 : _c.acl) === null || _d === void 0 ? void 0 : _d.file) {
5632
+ if (group.common?.acl?.file) {
5592
5633
  if (!user.acl || !user.acl.file) {
5593
5634
  user.acl = user.acl || {};
5594
5635
  user.acl.file = user.acl.file || {};
@@ -5606,7 +5647,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5606
5647
  user.acl.file.list = user.acl.file.list || group.common.acl.file.list;
5607
5648
  }
5608
5649
  }
5609
- if ((_f = (_e = group.common) === null || _e === void 0 ? void 0 : _e.acl) === null || _f === void 0 ? void 0 : _f.object) {
5650
+ if (group.common?.acl?.object) {
5610
5651
  if (!user.acl || !user.acl.object) {
5611
5652
  user.acl = user.acl || {};
5612
5653
  user.acl.object = user.acl.object || {};
@@ -5624,7 +5665,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5624
5665
  user.acl.object.list = user.acl.object.list || group.common.acl.object.list;
5625
5666
  }
5626
5667
  }
5627
- if ((_h = (_g = group.common) === null || _g === void 0 ? void 0 : _g.acl) === null || _h === void 0 ? void 0 : _h.users) {
5668
+ if (group.common?.acl?.users) {
5628
5669
  if (!user.acl || !user.acl.users) {
5629
5670
  user.acl = user.acl || {};
5630
5671
  user.acl.users = user.acl.users || {};
@@ -5642,7 +5683,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5642
5683
  user.acl.users.list = user.acl.users.list || group.common.acl.users.list;
5643
5684
  }
5644
5685
  }
5645
- if ((_k = (_j = group.common) === null || _j === void 0 ? void 0 : _j.acl) === null || _k === void 0 ? void 0 : _k.state) {
5686
+ if (group.common?.acl?.state) {
5646
5687
  if (!user.acl || !user.acl.state) {
5647
5688
  user.acl = user.acl || {};
5648
5689
  user.acl.state = user.acl.state || {};
@@ -5667,7 +5708,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5667
5708
  }
5668
5709
  _checkState(obj, options, command) {
5669
5710
  const limitToOwnerRights = options.limitToOwnerRights === true;
5670
- if (obj === null || obj === void 0 ? void 0 : obj.acl) {
5711
+ if (obj?.acl) {
5671
5712
  obj.acl.state = obj.acl.state || obj.acl.object;
5672
5713
  if (obj.acl.state) {
5673
5714
  // If user is owner
@@ -5790,11 +5831,11 @@ class AdapterClass extends node_events_1.EventEmitter {
5790
5831
  originalChecked = options.checked;
5791
5832
  }
5792
5833
  options.checked = true;
5793
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5834
+ if (!this.#objects) {
5794
5835
  this._logger.info(`${this.namespaceLog} checkStates not processed because Objects database not connected`);
5795
5836
  throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5796
5837
  }
5797
- const obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options));
5838
+ const obj = (await this.#objects.getObject(id, options));
5798
5839
  objs.push(obj);
5799
5840
  if (originalChecked !== undefined) {
5800
5841
  options.checked = originalChecked;
@@ -5824,8 +5865,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5824
5865
  }
5825
5866
  }
5826
5867
  async _setStateChangedHelper(id, state) {
5827
- var _a, _b;
5828
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
5868
+ if (!this.#objects) {
5829
5869
  this._logger.info(`${this.namespaceLog} setStateChanged not processed because Objects database not connected`);
5830
5870
  throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
5831
5871
  }
@@ -5833,12 +5873,12 @@ class AdapterClass extends node_events_1.EventEmitter {
5833
5873
  let obj;
5834
5874
  let err;
5835
5875
  try {
5836
- obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id);
5876
+ obj = await this.#objects.getObject(id);
5837
5877
  }
5838
5878
  catch (e) {
5839
5879
  err = e;
5840
5880
  }
5841
- if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) === null || _b === void 0 ? void 0 : _b.id) {
5881
+ if (obj?.common?.alias?.id) {
5842
5882
  // id can be string or can have attribute write
5843
5883
  const aliasId = js_controller_common_1.tools.isObject(obj.common.alias.id) ? obj.common.alias.id.write : obj.common.alias.id;
5844
5884
  return this._setStateChangedHelper(aliasId, state);
@@ -5885,7 +5925,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5885
5925
  await this._utils.performStrictObjectCheck(id, state);
5886
5926
  }
5887
5927
  this.outputCount++;
5888
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state);
5928
+ await this.#states.setState(id, state);
5889
5929
  return { id, notChanged: false };
5890
5930
  }
5891
5931
  else {
@@ -5941,7 +5981,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5941
5981
  }
5942
5982
  async _setStateChanged(_options) {
5943
5983
  const { id, ack, options, callback, state } = _options;
5944
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
5984
+ if (!this.#states) {
5945
5985
  // if states is no longer existing, we do not need to unsubscribe
5946
5986
  this._logger.info(`${this.namespaceLog} setStateChanged not processed because States database not connected`);
5947
5987
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -5981,7 +6021,7 @@ class AdapterClass extends node_events_1.EventEmitter {
5981
6021
  typeof stateObj.from === 'string' && stateObj.from !== ''
5982
6022
  ? stateObj.from
5983
6023
  : `system.adapter.${this.namespace}`;
5984
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6024
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
5985
6025
  try {
5986
6026
  await this._checkStates(fixedId, options, 'setState');
5987
6027
  }
@@ -6029,7 +6069,6 @@ class AdapterClass extends node_events_1.EventEmitter {
6029
6069
  * ```
6030
6070
  */
6031
6071
  async setForeignState(id, state, ack, options, callback) {
6032
- var _a, _b, _c, _d;
6033
6072
  if (typeof state === 'object' && typeof ack !== 'boolean') {
6034
6073
  callback = options;
6035
6074
  options = ack;
@@ -6043,7 +6082,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6043
6082
  callback = ack;
6044
6083
  ack = undefined;
6045
6084
  }
6046
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6085
+ if (!this.#states) {
6047
6086
  // if states is no longer existing, we do not need to unsubscribe
6048
6087
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6049
6088
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6079,14 +6118,14 @@ class AdapterClass extends node_events_1.EventEmitter {
6079
6118
  // if state.from provided, we use it else, we set default property
6080
6119
  state.from =
6081
6120
  typeof state.from === 'string' && state.from !== '' ? state.from : `system.adapter.${this.namespace}`;
6082
- state.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
6121
+ state.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
6083
6122
  if (!id || typeof id !== 'string') {
6084
6123
  const warn = id ? `ID can be only string and not "${typeof id}"` : `Empty ID: ${JSON.stringify(state)}`;
6085
6124
  this._logger.warn(`${this.namespaceLog} ${warn}`);
6086
6125
  return js_controller_common_1.tools.maybeCallbackWithError(callback, warn);
6087
6126
  }
6088
6127
  id = this.fixForbiddenCharsInId(id);
6089
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6128
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6090
6129
  let obj;
6091
6130
  try {
6092
6131
  obj = (await this._checkStates(id, options, 'setState')).objs[0];
@@ -6094,7 +6133,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6094
6133
  catch (e) {
6095
6134
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
6096
6135
  }
6097
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6136
+ if (!this.#states) {
6098
6137
  // if states is no longer existing, we do not need to unsubscribe
6099
6138
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6100
6139
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6105,7 +6144,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6105
6144
  }
6106
6145
  if (id.startsWith(constants_1.ALIAS_STARTS_WITH)) {
6107
6146
  // write alias
6108
- if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) === null || _b === void 0 ? void 0 : _b.id) {
6147
+ if (obj?.common?.alias?.id) {
6109
6148
  // id can be string or can have attribute write
6110
6149
  const aliasId = js_controller_common_1.tools.isObject(obj.common.alias.id)
6111
6150
  ? obj.common.alias.id.write
@@ -6126,20 +6165,20 @@ class AdapterClass extends node_events_1.EventEmitter {
6126
6165
  catch (e) {
6127
6166
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
6128
6167
  }
6129
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6168
+ if (!this.#states) {
6130
6169
  // if states is no longer existing, we do not need to unsubscribe
6131
6170
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6132
6171
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6133
6172
  }
6134
6173
  this.outputCount++;
6135
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
6136
- sourceCommon: obj === null || obj === void 0 ? void 0 : obj.common,
6174
+ this.#states.setState(aliasId, js_controller_common_1.tools.formatAliasValue({
6175
+ sourceCommon: obj?.common,
6137
6176
  targetCommon: targetObj && targetObj.common,
6138
6177
  state,
6139
6178
  logger: this._logger,
6140
6179
  logNamespace: this.namespaceLog,
6141
- sourceId: obj === null || obj === void 0 ? void 0 : obj._id,
6142
- targetId: targetObj === null || targetObj === void 0 ? void 0 : targetObj._id
6180
+ sourceId: obj?._id,
6181
+ targetId: targetObj?._id
6143
6182
  }), callback);
6144
6183
  }
6145
6184
  else {
@@ -6148,25 +6187,25 @@ class AdapterClass extends node_events_1.EventEmitter {
6148
6187
  }
6149
6188
  }
6150
6189
  else {
6151
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6190
+ if (!this.#states) {
6152
6191
  // if states is no longer existing, we do not need to unsubscribe
6153
6192
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6154
6193
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6155
6194
  }
6156
6195
  this.outputCount++;
6157
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state, callback);
6196
+ this.#states.setState(id, state, callback);
6158
6197
  }
6159
6198
  }
6160
6199
  else {
6161
6200
  // write alias
6162
6201
  if (id.startsWith(constants_1.ALIAS_STARTS_WITH)) {
6163
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
6202
+ if (!this.#objects) {
6164
6203
  this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
6165
6204
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6166
6205
  }
6167
6206
  // read alias id
6168
- const obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(id, options));
6169
- if ((_d = (_c = obj === null || obj === void 0 ? void 0 : obj.common) === null || _c === void 0 ? void 0 : _c.alias) === null || _d === void 0 ? void 0 : _d.id) {
6207
+ const obj = (await this.#objects.getObjectAsync(id, options));
6208
+ if (obj?.common?.alias?.id) {
6170
6209
  // alias id can be a string or can have id.write
6171
6210
  const aliasId = js_controller_common_1.tools.isObject(obj.common.alias.id)
6172
6211
  ? obj.common.alias.id.write
@@ -6179,27 +6218,27 @@ class AdapterClass extends node_events_1.EventEmitter {
6179
6218
  this._logger.warn(`${this.namespaceLog} Error validating alias id of ${id}: ${e.message}`);
6180
6219
  return js_controller_common_1.tools.maybeCallbackWithError(callback, `Error validating alias id of ${id}: ${e.message}`);
6181
6220
  }
6182
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
6221
+ if (!this.#objects) {
6183
6222
  // if objects is no longer existing, we do not need to unsubscribe
6184
6223
  this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
6185
6224
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6186
6225
  }
6187
6226
  // read object for formatting
6188
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options, (err, targetObj) => {
6189
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6227
+ this.#objects.getObject(aliasId, options, (err, targetObj) => {
6228
+ if (!this.#states) {
6190
6229
  // if states is no longer existing, we do not need to unsubscribe
6191
6230
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6192
6231
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6193
6232
  }
6194
6233
  this.outputCount++;
6195
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
6234
+ this.#states.setState(aliasId, js_controller_common_1.tools.formatAliasValue({
6196
6235
  sourceCommon: obj.common,
6197
- targetCommon: targetObj === null || targetObj === void 0 ? void 0 : targetObj.common,
6236
+ targetCommon: targetObj?.common,
6198
6237
  state,
6199
6238
  logger: this._logger,
6200
6239
  logNamespace: this.namespaceLog,
6201
6240
  sourceId: obj._id,
6202
- targetId: targetObj === null || targetObj === void 0 ? void 0 : targetObj._id
6241
+ targetId: targetObj?._id
6203
6242
  }), callback);
6204
6243
  });
6205
6244
  }
@@ -6210,7 +6249,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6210
6249
  }
6211
6250
  else {
6212
6251
  if (this.performStrictObjectChecks) {
6213
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
6252
+ if (!this.#objects) {
6214
6253
  // if objects is no longer existing, we do not need to unsubscribe
6215
6254
  this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
6216
6255
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6218,13 +6257,13 @@ class AdapterClass extends node_events_1.EventEmitter {
6218
6257
  // validate that object exists, read-only logic ok, type ok, etc. won't throw now
6219
6258
  await this._utils.performStrictObjectCheck(id, state);
6220
6259
  }
6221
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6260
+ if (!this.#states) {
6222
6261
  // if states is no longer existing, we do not need to unsubscribe
6223
6262
  this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
6224
6263
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6225
6264
  }
6226
6265
  this.outputCount++;
6227
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state, callback);
6266
+ this.#states.setState(id, state, callback);
6228
6267
  }
6229
6268
  }
6230
6269
  }
@@ -6272,7 +6311,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6272
6311
  callback = ack;
6273
6312
  ack = undefined;
6274
6313
  }
6275
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6314
+ if (!this.#states) {
6276
6315
  // if states is no longer existing, we do not need to unsubscribe
6277
6316
  this._logger.info(`${this.namespaceLog} setForeignStateChanged not processed because States database not connected`);
6278
6317
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6308,9 +6347,9 @@ class AdapterClass extends node_events_1.EventEmitter {
6308
6347
  // if state.from provided, we use it else, we set default property
6309
6348
  state.from =
6310
6349
  typeof state.from === 'string' && state.from !== '' ? state.from : `system.adapter.${this.namespace}`;
6311
- state.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
6350
+ state.user = options?.user || constants_1.SYSTEM_ADMIN_USER;
6312
6351
  id = this.fixForbiddenCharsInId(id);
6313
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6352
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6314
6353
  try {
6315
6354
  await this._checkStates(id, options, 'setState');
6316
6355
  }
@@ -6380,14 +6419,13 @@ class AdapterClass extends node_events_1.EventEmitter {
6380
6419
  return this._getForeignState({ id, options, callback });
6381
6420
  }
6382
6421
  async _getForeignState(_options) {
6383
- var _a, _b;
6384
6422
  const { id, options, callback } = _options;
6385
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6423
+ if (!this.#states) {
6386
6424
  // if states is no longer existing, we do not need to unsubscribe
6387
6425
  this._logger.info(`${this.namespaceLog} getForeignState not processed because States database not connected`);
6388
6426
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6389
6427
  }
6390
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
6428
+ if (!this.#objects) {
6391
6429
  this._logger.info(`${this.namespaceLog} getForeignState not processed because Objects database not connected`);
6392
6430
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6393
6431
  }
@@ -6398,7 +6436,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6398
6436
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
6399
6437
  }
6400
6438
  let permCheckRequired = false;
6401
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6439
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6402
6440
  permCheckRequired = true;
6403
6441
  }
6404
6442
  let obj;
@@ -6407,7 +6445,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6407
6445
  obj = (await this._checkStates(id, options || {}, 'getState')).objs[0];
6408
6446
  }
6409
6447
  else {
6410
- obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options));
6448
+ obj = (await this.#objects.getObject(id, options));
6411
6449
  }
6412
6450
  }
6413
6451
  catch (e) {
@@ -6415,7 +6453,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6415
6453
  }
6416
6454
  if (id.startsWith(constants_1.ALIAS_STARTS_WITH)) {
6417
6455
  // TODO: optimize alias GET performance
6418
- if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) === null || _b === void 0 ? void 0 : _b.id) {
6456
+ if (obj?.common?.alias?.id) {
6419
6457
  // id can be string or can have attribute id.read
6420
6458
  const aliasId = js_controller_common_1.tools.isObject(obj.common.alias.id) ? obj.common.alias.id.read : obj.common.alias.id;
6421
6459
  // validate here because we use objects/states db directly
@@ -6433,7 +6471,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6433
6471
  sourceObj = (await this._checkStates(aliasId, options || {}, 'getState')).objs[0];
6434
6472
  }
6435
6473
  else {
6436
- sourceObj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options));
6474
+ sourceObj = (await this.#objects.getObject(aliasId, options));
6437
6475
  }
6438
6476
  }
6439
6477
  catch (e) {
@@ -6447,19 +6485,19 @@ class AdapterClass extends node_events_1.EventEmitter {
6447
6485
  this.inputCount++;
6448
6486
  try {
6449
6487
  // @ts-expect-error void return possible fix it
6450
- state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(aliasId);
6488
+ state = await this.#states.getState(aliasId);
6451
6489
  }
6452
6490
  catch (e) {
6453
6491
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
6454
6492
  }
6455
6493
  }
6456
6494
  return js_controller_common_1.tools.maybeCallbackWithError(callback, null, js_controller_common_1.tools.formatAliasValue({
6457
- sourceCommon: sourceObj === null || sourceObj === void 0 ? void 0 : sourceObj.common,
6495
+ sourceCommon: sourceObj?.common,
6458
6496
  targetCommon: obj.common,
6459
6497
  state,
6460
6498
  logger: this._logger,
6461
6499
  logNamespace: this.namespaceLog,
6462
- sourceId: sourceObj === null || sourceObj === void 0 ? void 0 : sourceObj._id,
6500
+ sourceId: sourceObj?._id,
6463
6501
  targetId: obj._id
6464
6502
  }));
6465
6503
  }
@@ -6474,13 +6512,12 @@ class AdapterClass extends node_events_1.EventEmitter {
6474
6512
  return js_controller_common_1.tools.maybeCallbackWithError(callback, null, this.oStates[id]);
6475
6513
  }
6476
6514
  else {
6477
- return __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(id, callback);
6515
+ return this.#states.getState(id, callback);
6478
6516
  }
6479
6517
  }
6480
6518
  }
6481
6519
  // find out default history instance
6482
6520
  async _getDefaultHistory() {
6483
- var _a;
6484
6521
  if (!this.defaultHistory) {
6485
6522
  // read default history instance from system.config
6486
6523
  let data;
@@ -6490,10 +6527,10 @@ class AdapterClass extends node_events_1.EventEmitter {
6490
6527
  catch {
6491
6528
  // ignore
6492
6529
  }
6493
- if (data === null || data === void 0 ? void 0 : data.common) {
6530
+ if (data?.common) {
6494
6531
  this.defaultHistory = data.common.defaultHistory;
6495
6532
  }
6496
- if (data === null || data === void 0 ? void 0 : data.native) {
6533
+ if (data?.native) {
6497
6534
  this._systemSecret = data.native.secret;
6498
6535
  }
6499
6536
  // if no default history set
@@ -6501,7 +6538,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6501
6538
  let _obj;
6502
6539
  // read all adapters
6503
6540
  try {
6504
- _obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'instance', {
6541
+ _obj = await this.#objects.getObjectViewAsync('system', 'instance', {
6505
6542
  startkey: 'system.adapter.',
6506
6543
  endkey: 'system.adapter.\u9999'
6507
6544
  });
@@ -6509,9 +6546,9 @@ class AdapterClass extends node_events_1.EventEmitter {
6509
6546
  catch {
6510
6547
  // ignore
6511
6548
  }
6512
- if (_obj === null || _obj === void 0 ? void 0 : _obj.rows) {
6549
+ if (_obj?.rows) {
6513
6550
  for (const row of _obj.rows) {
6514
- if (((_a = row.value) === null || _a === void 0 ? void 0 : _a.common) && row.value.common.type === 'storage') {
6551
+ if (row.value?.common && row.value.common.type === 'storage') {
6515
6552
  this.defaultHistory = row.id.substring('system.adapter.'.length);
6516
6553
  break;
6517
6554
  }
@@ -6697,7 +6734,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6697
6734
  }
6698
6735
  async _delForeignState(_options) {
6699
6736
  const { id, options, callback } = _options;
6700
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6737
+ if (!this.#states) {
6701
6738
  // if states is no longer existing, we do not need to unsubscribe
6702
6739
  this._logger.info(`${this.namespaceLog} delForeignState not processed because States database not connected`);
6703
6740
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6708,7 +6745,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6708
6745
  catch (err) {
6709
6746
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
6710
6747
  }
6711
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6748
+ if (options?.user && options.user !== constants_1.SYSTEM_ADMIN_USER) {
6712
6749
  try {
6713
6750
  await this._checkStates(id, options, 'delState');
6714
6751
  }
@@ -6716,7 +6753,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6716
6753
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
6717
6754
  }
6718
6755
  }
6719
- __classPrivateFieldGet(this, _AdapterClass_states, "f").delState(id, callback);
6756
+ this.#states.delState(id, callback);
6720
6757
  }
6721
6758
  /**
6722
6759
  * Read all states of this adapter, that pass the pattern
@@ -6748,12 +6785,11 @@ class AdapterClass extends node_events_1.EventEmitter {
6748
6785
  this.getForeignStates(fixedPattern, options, callback);
6749
6786
  }
6750
6787
  async _processStatesSecondary(keys, targetObjs, srcObjs) {
6751
- var _a;
6752
- const arr = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys);
6788
+ const arr = await this.#states.getStates(keys);
6753
6789
  const result = {};
6754
6790
  for (let i = 0; i < keys.length; i++) {
6755
6791
  const obj = targetObjs && targetObjs[i];
6756
- if (((_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) && srcObjs) {
6792
+ if (obj?.common?.alias && srcObjs) {
6757
6793
  const srcObj = srcObjs[i];
6758
6794
  if (srcObj) {
6759
6795
  result[obj._id] =
@@ -6772,7 +6808,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6772
6808
  }
6773
6809
  }
6774
6810
  else {
6775
- result[(obj === null || obj === void 0 ? void 0 : obj._id) || keys[i]] = arr[i] || null;
6811
+ result[obj?._id || keys[i]] = arr[i] || null;
6776
6812
  }
6777
6813
  }
6778
6814
  // @ts-expect-error adapt the return type?
@@ -6786,11 +6822,10 @@ class AdapterClass extends node_events_1.EventEmitter {
6786
6822
  * @param targetObjs the target objects (e.g. alias objects or the actual objects)
6787
6823
  */
6788
6824
  async _processStates(keys, targetObjs) {
6789
- var _a;
6790
6825
  const aliasIndexes = [];
6791
6826
  const aliasIds = [];
6792
6827
  /** Target objects with null placeholders for non-alias keys */
6793
- const fullTargetObjs = [];
6828
+ const fullTargetObjs = new Array(keys.length).fill(null);
6794
6829
  keys.forEach((id, idx) => {
6795
6830
  if (id.startsWith(constants_1.ALIAS_STARTS_WITH)) {
6796
6831
  aliasIndexes.push(idx);
@@ -6805,24 +6840,25 @@ class AdapterClass extends node_events_1.EventEmitter {
6805
6840
  // read aliases objects to get information of source objects
6806
6841
  targetObjs = (await this._getObjectsByArray(aliasIds));
6807
6842
  }
6808
- // replace aliases ID with targets
6809
- for (let i = 0; i < keys.length; i++) {
6810
- if (!aliasIndexes.includes(i)) {
6811
- fullTargetObjs.push(null);
6812
- continue;
6813
- }
6843
+ else {
6844
+ // we are only interested in keeping alias target objects
6845
+ targetObjs = targetObjs.filter((_val, idx) => aliasIndexes.includes(idx));
6846
+ }
6847
+ // replace alias ids with targets
6848
+ for (let i = 0; i < aliasIds.length; i++) {
6814
6849
  const obj = targetObjs[i];
6815
- fullTargetObjs[i] = targetObjs[i];
6816
- if ((_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) {
6850
+ const aliasIdx = aliasIndexes[i];
6851
+ fullTargetObjs[aliasIdx] = obj;
6852
+ if (obj?.common?.alias) {
6817
6853
  // alias id can be string or can have attribute read (this is used by getStates -> so read is important)
6818
- keys[i] =
6854
+ keys[aliasIdx] =
6819
6855
  js_controller_common_1.tools.isObject(obj.common.alias.id) && 'read' in obj.common.alias.id
6820
6856
  ? obj.common.alias.id.read
6821
6857
  : obj.common.alias.id;
6822
6858
  }
6823
6859
  }
6824
6860
  // srcObjs and targetObjs could be merged
6825
- const srcObjs = (await this._getObjectsByArray(keys, this._options));
6861
+ const srcObjs = (await this._getObjectsByArray(keys));
6826
6862
  return this._processStatesSecondary(keys, fullTargetObjs, srcObjs);
6827
6863
  }
6828
6864
  else {
@@ -6866,12 +6902,12 @@ class AdapterClass extends node_events_1.EventEmitter {
6866
6902
  }
6867
6903
  async _getForeignStates(_options) {
6868
6904
  const { options, pattern, callback } = _options;
6869
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
6905
+ if (!this.#states) {
6870
6906
  // if states is no longer existing, we do not need to unsubscribe
6871
6907
  this._logger.info(`${this.namespaceLog} getForeignStates not processed because States database not connected`);
6872
6908
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
6873
6909
  }
6874
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
6910
+ if (!this.#objects) {
6875
6911
  // if states is no longer existing, we do not need to unsubscribe
6876
6912
  this._logger.info(`${this.namespaceLog} getForeignStates not processed because Objects database not connected`);
6877
6913
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -6889,7 +6925,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6889
6925
  }
6890
6926
  }
6891
6927
  else {
6892
- const res = await this._processStates(pattern, options === null || options === void 0 ? void 0 : options._objects);
6928
+ const res = await this._processStates(pattern, options?._objects);
6893
6929
  return js_controller_common_1.tools.maybeCallbackWithError(callback, null, res);
6894
6930
  }
6895
6931
  }
@@ -6910,7 +6946,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6910
6946
  // in special maintenance mode, just returns all states. Aliases are not supported in this mode
6911
6947
  if (options.user === constants_1.SYSTEM_ADMIN_USER && options.maintenance) {
6912
6948
  try {
6913
- const keys = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(pattern);
6949
+ const keys = await this.#states.getKeys(pattern);
6914
6950
  const res = await this._processStatesSecondary(keys || [], null, null);
6915
6951
  return js_controller_common_1.tools.maybeCallbackWithError(callback, null, res);
6916
6952
  }
@@ -6919,7 +6955,7 @@ class AdapterClass extends node_events_1.EventEmitter {
6919
6955
  }
6920
6956
  }
6921
6957
  try {
6922
- const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'state', params, options);
6958
+ const res = await this.#objects.getObjectView('system', 'state', params, options);
6923
6959
  if (originalChecked !== undefined) {
6924
6960
  options.checked = originalChecked;
6925
6961
  }
@@ -7000,13 +7036,13 @@ class AdapterClass extends node_events_1.EventEmitter {
7000
7036
  if (!aliasDetails.source) {
7001
7037
  let sourceObj;
7002
7038
  try {
7003
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(sourceId);
7004
- sourceObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(sourceId, this._options);
7039
+ await this.#states.subscribe(sourceId);
7040
+ sourceObj = await this.#objects.getObject(sourceId, this._options);
7005
7041
  }
7006
7042
  catch (e) {
7007
7043
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
7008
7044
  }
7009
- if (sourceObj === null || sourceObj === void 0 ? void 0 : sourceObj.common) {
7045
+ if (sourceObj?.common) {
7010
7046
  if (!this.aliases.has(sourceObj._id)) {
7011
7047
  // TODO what means this, we ensured alias existed, did some async stuff now it's gone -> alias has been deleted?
7012
7048
  this._logger.error(`${this.namespaceLog} Alias subscription error. Please check your alias definitions: sourceId=${sourceId}, sourceObj=${JSON.stringify(sourceObj)}`);
@@ -7046,7 +7082,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7046
7082
  // unsubscribe if no more aliases exists
7047
7083
  if (!this.aliases.get(sourceId).targets.length) {
7048
7084
  this.aliases.delete(sourceId);
7049
- await __classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribe(sourceId);
7085
+ await this.#states.unsubscribe(sourceId);
7050
7086
  }
7051
7087
  }
7052
7088
  return js_controller_common_1.tools.maybeCallback(callback);
@@ -7083,12 +7119,12 @@ class AdapterClass extends node_events_1.EventEmitter {
7083
7119
  const { pattern, options, callback } = _options;
7084
7120
  // Todo check rights for options
7085
7121
  await this._autoSubscribeOn();
7086
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7122
+ if (!this.#states) {
7087
7123
  // if states is no longer existing, we do not need to unsubscribe
7088
7124
  this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because States database not connected`);
7089
7125
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7090
7126
  }
7091
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
7127
+ if (!this.#objects) {
7092
7128
  this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because Objects database not connected`);
7093
7129
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7094
7130
  }
@@ -7098,7 +7134,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7098
7134
  // put this pattern into adapter list
7099
7135
  let state;
7100
7136
  try {
7101
- state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${autoSubEntry}.subscribes`);
7137
+ state = await this.#states.getState(`system.adapter.${autoSubEntry}.subscribes`);
7102
7138
  }
7103
7139
  catch {
7104
7140
  // ignore
@@ -7124,7 +7160,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7124
7160
  }
7125
7161
  subs[pattern][this.namespace]++;
7126
7162
  this.outputCount++;
7127
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${autoSubEntry}.subscribes`, JSON.stringify(subs));
7163
+ this.#states.setState(`system.adapter.${autoSubEntry}.subscribes`, JSON.stringify(subs));
7128
7164
  }
7129
7165
  }
7130
7166
  if (Array.isArray(pattern)) {
@@ -7147,7 +7183,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7147
7183
  if (aliasesIds.length) {
7148
7184
  if (!this._aliasObjectsSubscribed) {
7149
7185
  this._aliasObjectsSubscribed = true;
7150
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7186
+ this.#objects.subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7151
7187
  }
7152
7188
  const aliasObjs = await this._getObjectsByArray(aliasesIds, options);
7153
7189
  for (const aliasObj of aliasObjs) {
@@ -7159,7 +7195,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7159
7195
  }
7160
7196
  if (nonAliasesIds.length) {
7161
7197
  for (const id of nonAliasesIds) {
7162
- promises.push(new Promise(resolve => __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(id, resolve)));
7198
+ promises.push(new Promise(resolve => this.#states.subscribeUser(id, resolve)));
7163
7199
  }
7164
7200
  }
7165
7201
  try {
@@ -7174,7 +7210,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7174
7210
  if (pattern === '*' || pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
7175
7211
  if (!this._aliasObjectsSubscribed) {
7176
7212
  this._aliasObjectsSubscribed = true;
7177
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7213
+ this.#objects.subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7178
7214
  }
7179
7215
  // read all aliases
7180
7216
  try {
@@ -7199,7 +7235,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7199
7235
  catch (e) {
7200
7236
  this._logger.error(`${this.namespaceLog} Error on "subscribeForeignStates": ${e.message}`);
7201
7237
  }
7202
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7238
+ if (!this.#states) {
7203
7239
  // if states is no longer existing, we do not need to unsubscribe
7204
7240
  this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because States database not connected`);
7205
7241
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -7209,7 +7245,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7209
7245
  }
7210
7246
  else {
7211
7247
  // no alias objects found or pattern *
7212
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
7248
+ this.#states.subscribeUser(pattern, callback);
7213
7249
  }
7214
7250
  }
7215
7251
  catch (e) {
@@ -7218,13 +7254,13 @@ class AdapterClass extends node_events_1.EventEmitter {
7218
7254
  }
7219
7255
  }
7220
7256
  else {
7221
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
7257
+ this.#states.subscribeUser(pattern, callback);
7222
7258
  }
7223
7259
  }
7224
7260
  else if (pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
7225
7261
  if (!this._aliasObjectsSubscribed) {
7226
7262
  this._aliasObjectsSubscribed = true;
7227
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7263
+ this.#objects.subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7228
7264
  }
7229
7265
  // aliases['sourceId'] = {
7230
7266
  // source: {common attributes},
@@ -7241,7 +7277,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7241
7277
  // };
7242
7278
  // just read one alias Object
7243
7279
  try {
7244
- const aliasObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(pattern, options);
7280
+ const aliasObj = await this.#objects.getObjectAsync(pattern, options);
7245
7281
  if (aliasObj) {
7246
7282
  // cb will be called, but await for catching promisified part
7247
7283
  await this._addAliasSubscribe(aliasObj, pattern, callback);
@@ -7255,7 +7291,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7255
7291
  }
7256
7292
  }
7257
7293
  else {
7258
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
7294
+ this.#states.subscribeUser(pattern, callback);
7259
7295
  }
7260
7296
  }
7261
7297
  /**
@@ -7294,7 +7330,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7294
7330
  }
7295
7331
  async _unsubscribeForeignStates(_options) {
7296
7332
  const { pattern, callback } = _options;
7297
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7333
+ if (!this.#states) {
7298
7334
  // if states is no longer existing, we do not need to unsubscribe
7299
7335
  this._logger.info(`${this.namespaceLog} unsubscrubeForeignStates not processed because States database not connected`);
7300
7336
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -7305,7 +7341,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7305
7341
  // remove this pattern from adapter list
7306
7342
  let state;
7307
7343
  try {
7308
- state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${autoSub}.subscribes`);
7344
+ state = await this.#states.getState(`system.adapter.${autoSub}.subscribes`);
7309
7345
  }
7310
7346
  catch {
7311
7347
  // ignore
@@ -7342,7 +7378,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7342
7378
  delete subs[pattern];
7343
7379
  }
7344
7380
  this.outputCount++;
7345
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${autoSub}.subscribes`, JSON.stringify(subs));
7381
+ this.#states.setState(`system.adapter.${autoSub}.subscribes`, JSON.stringify(subs));
7346
7382
  }
7347
7383
  }
7348
7384
  }
@@ -7358,15 +7394,15 @@ class AdapterClass extends node_events_1.EventEmitter {
7358
7394
  if (pattern === '*' || pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
7359
7395
  aliasPattern = pattern; // check all aliases
7360
7396
  if (pattern === '*') {
7361
- promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
7397
+ promises.push(this.#states.unsubscribeUser(pattern));
7362
7398
  }
7363
7399
  }
7364
7400
  else {
7365
- promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
7401
+ promises.push(this.#states.unsubscribeUser(pattern));
7366
7402
  }
7367
7403
  }
7368
7404
  else {
7369
- promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
7405
+ promises.push(this.#states.unsubscribeUser(pattern));
7370
7406
  }
7371
7407
  if (aliasPattern) {
7372
7408
  // if pattern known, remove it from alias patterns to not subscribe to further matching aliases
@@ -7383,7 +7419,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7383
7419
  // if no alias subscribed any longer, remove subscription
7384
7420
  if (!this.aliases.size && this._aliasObjectsSubscribed) {
7385
7421
  this._aliasObjectsSubscribed = false;
7386
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7422
+ this.#objects.unsubscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
7387
7423
  }
7388
7424
  return js_controller_common_1.tools.maybeCallback(callback);
7389
7425
  }
@@ -7482,11 +7518,11 @@ class AdapterClass extends node_events_1.EventEmitter {
7482
7518
  if (this.performStrictObjectChecks) {
7483
7519
  // obj needs to exist and has to be of type "file" - custom check for binary state
7484
7520
  try {
7485
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
7521
+ if (!this.#objects) {
7486
7522
  this._logger.info(`${this.namespaceLog} setBinaryState not processed because Objects database not connected`);
7487
7523
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7488
7524
  }
7489
- const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(id);
7525
+ const obj = await this.#objects.getObjectAsync(id);
7490
7526
  // at first check object existence
7491
7527
  if (!obj) {
7492
7528
  this._logger.warn(`${this.namespaceLog} Binary state "${id}" has no existing object, this might lead to an error in future versions`);
@@ -7503,7 +7539,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7503
7539
  this._logger.warn(`${this.namespaceLog} Could not perform strict object check of binary state ${id}: ${e.message}`);
7504
7540
  }
7505
7541
  }
7506
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7542
+ if (!this.#states) {
7507
7543
  // if states is no longer existing, we do not need to unsubscribe
7508
7544
  this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
7509
7545
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -7525,38 +7561,38 @@ class AdapterClass extends node_events_1.EventEmitter {
7525
7561
  if (obj && !('binary' in obj)) {
7526
7562
  // @ts-expect-error probably need to adjust types
7527
7563
  obj.binary = true;
7528
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
7564
+ if (!this.#objects) {
7529
7565
  this._logger.info(`${this.namespaceLog} setBinaryState not processed because Objects database not connected`);
7530
7566
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7531
7567
  }
7532
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, err => {
7568
+ this.#objects.setObject(id, obj, err => {
7533
7569
  if (err) {
7534
7570
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
7535
7571
  }
7536
7572
  else {
7537
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7573
+ if (!this.#states) {
7538
7574
  // if states is no longer existing, we do not need to unsubscribe
7539
7575
  this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
7540
7576
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7541
7577
  }
7542
7578
  this.outputCount++;
7543
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
7579
+ this.#states.setBinaryState(id, binary, callback);
7544
7580
  }
7545
7581
  });
7546
7582
  }
7547
7583
  else {
7548
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7584
+ if (!this.#states) {
7549
7585
  // if states is no longer existing, we do not need to unsubscribe
7550
7586
  this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
7551
7587
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
7552
7588
  }
7553
7589
  this.outputCount++;
7554
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
7590
+ this.#states.setBinaryState(id, binary, callback);
7555
7591
  }
7556
7592
  }
7557
7593
  else {
7558
7594
  this.outputCount++;
7559
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
7595
+ this.#states.setBinaryState(id, binary, callback);
7560
7596
  }
7561
7597
  }
7562
7598
  /**
@@ -7599,7 +7635,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7599
7635
  }
7600
7636
  async _getForeignBinaryState(_options) {
7601
7637
  const { id, options, callback } = _options;
7602
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7638
+ if (!this.#states) {
7603
7639
  // if states is no longer existing, we do not need to unsubscribe
7604
7640
  this._logger.info(`${this.namespaceLog} getBinaryState not processed because States database not connected`);
7605
7641
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -7622,11 +7658,11 @@ class AdapterClass extends node_events_1.EventEmitter {
7622
7658
  catch (e) {
7623
7659
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
7624
7660
  }
7625
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getBinaryState(id, (err, data) => {
7661
+ this.#states.getBinaryState(id, (err, data) => {
7626
7662
  if (!err && data && obj && !('binary' in obj)) {
7627
7663
  // @ts-expect-error type adjustment needed?
7628
7664
  obj.binary = true;
7629
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, err => {
7665
+ this.#objects.setObject(id, obj, err => {
7630
7666
  if (err) {
7631
7667
  return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
7632
7668
  }
@@ -7685,7 +7721,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7685
7721
  }
7686
7722
  async _delForeignBinaryState(_options) {
7687
7723
  const { id, options, callback } = _options;
7688
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7724
+ if (!this.#states) {
7689
7725
  // if states is no longer existing, we do not need to unsubscribe
7690
7726
  this._logger.info(`${this.namespaceLog} delBinaryState not processed because States database not connected`);
7691
7727
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
@@ -7703,10 +7739,10 @@ class AdapterClass extends node_events_1.EventEmitter {
7703
7739
  catch (e) {
7704
7740
  return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
7705
7741
  }
7706
- __classPrivateFieldGet(this, _AdapterClass_states, "f").delBinaryState(id, callback);
7742
+ this.#states.delBinaryState(id, callback);
7707
7743
  }
7708
7744
  else {
7709
- __classPrivateFieldGet(this, _AdapterClass_states, "f").delBinaryState(id, callback);
7745
+ this.#states.delBinaryState(id, callback);
7710
7746
  }
7711
7747
  }
7712
7748
  /**
@@ -7751,17 +7787,16 @@ class AdapterClass extends node_events_1.EventEmitter {
7751
7787
  return this.pluginHandler.getPluginConfig(name);
7752
7788
  }
7753
7789
  async _autoSubscribeOn() {
7754
- var _a;
7755
- if (!this.autoSubscribe && __classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
7790
+ if (!this.autoSubscribe && this.#objects) {
7756
7791
  try {
7757
7792
  // collect all
7758
- const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'instance', {
7793
+ const res = await this.#objects.getObjectViewAsync('system', 'instance', {
7759
7794
  startkey: 'system.adapter.',
7760
7795
  endkey: 'system.adapter.\u9999'
7761
7796
  });
7762
7797
  this.autoSubscribe = [];
7763
7798
  for (const row of res.rows) {
7764
- if ((_a = row.value) === null || _a === void 0 ? void 0 : _a.common.subscribable) {
7799
+ if (row.value?.common.subscribable) {
7765
7800
  const _id = row.id.substring(15); // cut system.adapter.
7766
7801
  if (!this.autoSubscribe.includes(_id)) {
7767
7802
  this.autoSubscribe.push(_id);
@@ -7769,7 +7804,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7769
7804
  }
7770
7805
  }
7771
7806
  // because of autoSubscribe
7772
- await __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeAsync('system.adapter.*');
7807
+ await this.#objects.subscribeAsync('system.adapter.*');
7773
7808
  }
7774
7809
  catch {
7775
7810
  // ignore
@@ -7783,20 +7818,19 @@ class AdapterClass extends node_events_1.EventEmitter {
7783
7818
  * @returns list of suitable licenses
7784
7819
  */
7785
7820
  async getSuitableLicenses(all, adapterName) {
7786
- var _a, _b, _c, _d;
7787
7821
  const licenses = [];
7788
7822
  try {
7789
7823
  const obj = await this.getForeignObjectAsync('system.licenses');
7790
7824
  const uuidObj = await this.getForeignObjectAsync('system.meta.uuid');
7791
7825
  let uuid;
7792
- if (!((_a = uuidObj === null || uuidObj === void 0 ? void 0 : uuidObj.native) === null || _a === void 0 ? void 0 : _a.uuid)) {
7826
+ if (!uuidObj?.native?.uuid) {
7793
7827
  this._logger.warn(`${this.namespaceLog} No UUID found!`);
7794
7828
  return licenses;
7795
7829
  }
7796
7830
  else {
7797
7831
  uuid = uuidObj.native.uuid;
7798
7832
  }
7799
- if ((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.native) === null || _b === void 0 ? void 0 : _b.licenses) === null || _c === void 0 ? void 0 : _c.length) {
7833
+ if (obj?.native?.licenses?.length) {
7800
7834
  const now = Date.now();
7801
7835
  const cert = fs_extra_1.default.readFileSync(node_path_1.default.join(__dirname, '..', '..', 'cert', 'cloudCert.crt'));
7802
7836
  let adapterObj;
@@ -7808,7 +7842,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7808
7842
  // ignore
7809
7843
  }
7810
7844
  }
7811
- const version = semver_1.default.major(((_d = adapterObj === null || adapterObj === void 0 ? void 0 : adapterObj.common) === null || _d === void 0 ? void 0 : _d.version) || this.pack.version);
7845
+ const version = semver_1.default.major(adapterObj?.common?.version || this.pack.version);
7812
7846
  obj.native.licenses.forEach((license) => {
7813
7847
  try {
7814
7848
  const decoded = jsonwebtoken_1.default.verify(license.json, cert);
@@ -7879,13 +7913,13 @@ class AdapterClass extends node_events_1.EventEmitter {
7879
7913
  return licenses;
7880
7914
  }
7881
7915
  _reportStatus() {
7882
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
7916
+ if (!this.#states) {
7883
7917
  return;
7884
7918
  }
7885
7919
  /** Time after which states regularly set by the status report expire in seconds */
7886
7920
  const reportStatusExpirySec = Math.floor(this._config.system.statisticsInterval / 1000) + 10;
7887
7921
  const id = `system.adapter.${this.namespace}`;
7888
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, {
7922
+ this.#states.setState(`${id}.alive`, {
7889
7923
  val: true,
7890
7924
  ack: true,
7891
7925
  expire: reportStatusExpirySec,
@@ -7893,7 +7927,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7893
7927
  });
7894
7928
  this.outputCount++;
7895
7929
  if (this.connected) {
7896
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.connected`, {
7930
+ this.#states.setState(`${id}.connected`, {
7897
7931
  val: true,
7898
7932
  ack: true,
7899
7933
  expire: reportStatusExpirySec,
@@ -7914,14 +7948,14 @@ class AdapterClass extends node_events_1.EventEmitter {
7914
7948
  // }
7915
7949
  (0, pidusage_1.default)(process.pid, (err, stats) => {
7916
7950
  // sometimes adapter is stopped, but this is still running
7917
- if (!err && this && __classPrivateFieldGet(this, _AdapterClass_states, "f") && __classPrivateFieldGet(this, _AdapterClass_states, "f").setState && stats) {
7918
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cpu`, {
7951
+ if (!err && this && this.#states && this.#states.setState && stats) {
7952
+ this.#states.setState(`${id}.cpu`, {
7919
7953
  ack: true,
7920
7954
  from: id,
7921
7955
  val: Math.round(100 * stats.cpu) / 100,
7922
7956
  expire: reportStatusExpirySec
7923
7957
  });
7924
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cputime`, {
7958
+ this.#states.setState(`${id}.cputime`, {
7925
7959
  ack: true,
7926
7960
  from: id,
7927
7961
  val: stats.ctime / 1000,
@@ -7933,21 +7967,21 @@ class AdapterClass extends node_events_1.EventEmitter {
7933
7967
  try {
7934
7968
  //RSS is the resident set size, the portion of the process's memory held in RAM (as opposed to the swap space or the part held in the filesystem).
7935
7969
  const mem = process.memoryUsage();
7936
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memRss`, {
7970
+ this.#states.setState(`${id}.memRss`, {
7937
7971
  val: parseFloat((mem.rss / 1048576) /* 1MB */
7938
7972
  .toFixed(2)),
7939
7973
  ack: true,
7940
7974
  from: id,
7941
7975
  expire: reportStatusExpirySec
7942
7976
  });
7943
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapTotal`, {
7977
+ this.#states.setState(`${id}.memHeapTotal`, {
7944
7978
  val: parseFloat((mem.heapTotal / 1048576) /* 1MB */
7945
7979
  .toFixed(2)),
7946
7980
  ack: true,
7947
7981
  from: id,
7948
7982
  expire: reportStatusExpirySec
7949
7983
  });
7950
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapUsed`, {
7984
+ this.#states.setState(`${id}.memHeapUsed`, {
7951
7985
  val: parseFloat((mem.heapUsed / 1048576) /* 1MB */
7952
7986
  .toFixed(2)),
7953
7987
  ack: true,
@@ -7961,7 +7995,7 @@ class AdapterClass extends node_events_1.EventEmitter {
7961
7995
  this.outputCount += 3;
7962
7996
  if (this.eventLoopLags.length) {
7963
7997
  const eventLoopLag = Math.ceil(this.eventLoopLags.reduce((a, b) => a + b) / this.eventLoopLags.length);
7964
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.eventLoopLag`, {
7998
+ this.#states.setState(`${id}.eventLoopLag`, {
7965
7999
  val: eventLoopLag,
7966
8000
  ack: true,
7967
8001
  from: id,
@@ -7972,19 +8006,19 @@ class AdapterClass extends node_events_1.EventEmitter {
7972
8006
  }
7973
8007
  }
7974
8008
  this.outputCount += 3;
7975
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.uptime`, {
8009
+ this.#states.setState(`${id}.uptime`, {
7976
8010
  val: parseInt(process.uptime().toFixed(), 10),
7977
8011
  ack: true,
7978
8012
  from: id,
7979
8013
  expire: reportStatusExpirySec
7980
8014
  });
7981
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.inputCount`, {
8015
+ this.#states.setState(`${id}.inputCount`, {
7982
8016
  val: this.inputCount,
7983
8017
  ack: true,
7984
8018
  from: id,
7985
8019
  expire: reportStatusExpirySec
7986
8020
  });
7987
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.outputCount`, {
8021
+ this.#states.setState(`${id}.outputCount`, {
7988
8022
  val: this.outputCount,
7989
8023
  ack: true,
7990
8024
  from: id,
@@ -7998,18 +8032,18 @@ class AdapterClass extends node_events_1.EventEmitter {
7998
8032
  let logs = [];
7999
8033
  // LogList
8000
8034
  logs.push(`Actual Loglist - ${JSON.stringify(Array.from(this.logList))}`);
8001
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8035
+ if (!this.#states) {
8002
8036
  // if adapterState was destroyed, we can not continue
8003
8037
  return;
8004
8038
  }
8005
8039
  // Read current state of all log subscribers
8006
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
8007
- if (keys === null || keys === void 0 ? void 0 : keys.length) {
8008
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8040
+ this.#states.getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
8041
+ if (keys?.length) {
8042
+ if (!this.#states) {
8009
8043
  // if adapterState was destroyed, we can not continue
8010
8044
  return;
8011
8045
  }
8012
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys, (err, obj) => {
8046
+ this.#states.getStates(keys, (err, obj) => {
8013
8047
  if (obj) {
8014
8048
  for (let i = 0; i < keys.length; i++) {
8015
8049
  const objPart = obj[i];
@@ -8047,17 +8081,17 @@ class AdapterClass extends node_events_1.EventEmitter {
8047
8081
  // temporary log buffer
8048
8082
  let messages = [];
8049
8083
  // Read current state of all log subscriber
8050
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8084
+ if (!this.#states) {
8051
8085
  // if adapterState was destroyed, we can not continue
8052
8086
  return;
8053
8087
  }
8054
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
8055
- if (keys === null || keys === void 0 ? void 0 : keys.length) {
8056
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8088
+ this.#states.getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
8089
+ if (keys?.length) {
8090
+ if (!this.#states) {
8057
8091
  // if adapterState was destroyed, we can not continue
8058
8092
  return;
8059
8093
  }
8060
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys, (err, obj) => {
8094
+ this.#states.getStates(keys, (err, obj) => {
8061
8095
  if (obj) {
8062
8096
  for (let i = 0; i < keys.length; i++) {
8063
8097
  const objPart = obj[i];
@@ -8076,10 +8110,10 @@ class AdapterClass extends node_events_1.EventEmitter {
8076
8110
  this.logRedirect(true, id);
8077
8111
  }
8078
8112
  }
8079
- if (this.logList.size && (messages === null || messages === void 0 ? void 0 : messages.length) && __classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8113
+ if (this.logList.size && messages?.length && this.#states) {
8080
8114
  for (const message of messages) {
8081
8115
  for (const instanceId of this.logList) {
8082
- __classPrivateFieldGet(this, _AdapterClass_states, "f").pushLog(instanceId, message);
8116
+ this.#states.pushLog(instanceId, message);
8083
8117
  }
8084
8118
  }
8085
8119
  }
@@ -8114,7 +8148,6 @@ class AdapterClass extends node_events_1.EventEmitter {
8114
8148
  const ts = this._logger.transports.find(t => t.name === 'NT');
8115
8149
  // @ts-expect-error
8116
8150
  ts.on('logged', info => {
8117
- var _a;
8118
8151
  info.from = this.namespace;
8119
8152
  // emit to itself
8120
8153
  if (this._options.logTransporter && this.logRequired && !this._stopInProgress) {
@@ -8130,17 +8163,17 @@ class AdapterClass extends node_events_1.EventEmitter {
8130
8163
  }
8131
8164
  }
8132
8165
  }
8133
- else if ((_a = __classPrivateFieldGet(this, _AdapterClass_states, "f")) === null || _a === void 0 ? void 0 : _a.pushLog) {
8166
+ else if (this.#states?.pushLog) {
8134
8167
  // Send to all adapter, that required logs
8135
8168
  for (const instanceId of this.logList) {
8136
- __classPrivateFieldGet(this, _AdapterClass_states, "f").pushLog(instanceId, info);
8169
+ this.#states.pushLog(instanceId, info);
8137
8170
  }
8138
8171
  }
8139
8172
  });
8140
8173
  this._options.logTransporter = this._options.logTransporter || this.ioPack.common.logTransporter;
8141
8174
  if (this._options.logTransporter) {
8142
8175
  this.requireLog = async (isActive, options) => {
8143
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8176
+ if (!this.#states) {
8144
8177
  return;
8145
8178
  }
8146
8179
  if (this.logRequired !== isActive) {
@@ -8154,7 +8187,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8154
8187
  this.logOffTimer = null;
8155
8188
  this._logger.silly(`${this.namespaceLog} Change log subscriber state: FALSE`);
8156
8189
  this.outputCount++;
8157
- if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8190
+ if (this.#states) {
8158
8191
  try {
8159
8192
  await this.setForeignStateAsync(`system.adapter.${this.namespace}.logging`, {
8160
8193
  val: false,
@@ -8195,7 +8228,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8195
8228
  this.emit('log', msg);
8196
8229
  }
8197
8230
  };
8198
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeLog(`system.adapter.${this.namespace}`);
8231
+ this.#states.subscribeLog(`system.adapter.${this.namespace}`);
8199
8232
  }
8200
8233
  else {
8201
8234
  this.requireLog = isActive => {
@@ -8224,11 +8257,11 @@ class AdapterClass extends node_events_1.EventEmitter {
8224
8257
  this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
8225
8258
  }
8226
8259
  // Internal object, but some special adapters want to access it anyway.
8227
- __classPrivateFieldSet(this, _AdapterClass_states, new this.States({
8260
+ this.#states = new this.States({
8228
8261
  namespace: this.namespaceLog,
8229
8262
  connection: this._config.states,
8230
8263
  connected: async () => {
8231
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8264
+ if (!this.#states) {
8232
8265
  return;
8233
8266
  }
8234
8267
  this._logger.silly(`${this.namespaceLog} statesDB connected`);
@@ -8239,22 +8272,22 @@ class AdapterClass extends node_events_1.EventEmitter {
8239
8272
  }
8240
8273
  if (!this._config.isInstall) {
8241
8274
  // Subscribe for process exit signal
8242
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.sigKill`);
8275
+ this.#states.subscribe(`system.adapter.${this.namespace}.sigKill`);
8243
8276
  // Subscribe for loglevel
8244
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.logLevel`);
8277
+ this.#states.subscribe(`system.adapter.${this.namespace}.logLevel`);
8245
8278
  }
8246
8279
  if (this._options.subscribable) {
8247
8280
  // subscribe on if other instance wants to have states of this adapter
8248
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.subscribes`);
8281
+ this.#states.subscribe(`system.adapter.${this.namespace}.subscribes`);
8249
8282
  // read actual autosubscribe requests
8250
8283
  let state;
8251
8284
  try {
8252
- state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getStateAsync(`system.adapter.${this.namespace}.subscribes`);
8285
+ state = await this.#states.getStateAsync(`system.adapter.${this.namespace}.subscribes`);
8253
8286
  }
8254
8287
  catch {
8255
8288
  // ignore
8256
8289
  }
8257
- if (!(state === null || state === void 0 ? void 0 : state.val)) {
8290
+ if (!state?.val) {
8258
8291
  this.patterns = {};
8259
8292
  }
8260
8293
  else {
@@ -8274,7 +8307,6 @@ class AdapterClass extends node_events_1.EventEmitter {
8274
8307
  },
8275
8308
  logger: this._logger,
8276
8309
  change: async (id, stateOrMessage) => {
8277
- var _a, _b;
8278
8310
  this.inputCount++;
8279
8311
  // for simplicity reasons we exclude Message for now TODO
8280
8312
  const state = stateOrMessage;
@@ -8327,8 +8359,8 @@ class AdapterClass extends node_events_1.EventEmitter {
8327
8359
  this._logger.info(`${this.namespaceLog} Got invalid loglevel "${state.val}", ignoring`);
8328
8360
  }
8329
8361
  this.outputCount++;
8330
- __classPrivateFieldGet(this, _AdapterClass_states, "f") &&
8331
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${this.namespace}.logLevel`, {
8362
+ this.#states &&
8363
+ this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
8332
8364
  val: currentLevel,
8333
8365
  ack: true,
8334
8366
  from: `system.adapter.${this.namespace}`
@@ -8373,7 +8405,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8373
8405
  const obj = state;
8374
8406
  if (obj) {
8375
8407
  let callbackObj;
8376
- if ((_a = obj.callback) === null || _a === void 0 ? void 0 : _a.id) {
8408
+ if (obj.callback?.id) {
8377
8409
  callbackObj = this.messageCallbacks.get(obj.callback.id);
8378
8410
  }
8379
8411
  // If callback stored for this request
@@ -8421,14 +8453,14 @@ class AdapterClass extends node_events_1.EventEmitter {
8421
8453
  nameEndIndex = undefined;
8422
8454
  }
8423
8455
  const pluginName = id.substring(pluginStatesIndex, nameEndIndex);
8424
- if (!((_b = this.pluginHandler) === null || _b === void 0 ? void 0 : _b.pluginExists(pluginName))) {
8456
+ if (!this.pluginHandler?.pluginExists(pluginName)) {
8425
8457
  return;
8426
8458
  }
8427
8459
  if (this.pluginHandler.isPluginActive(pluginName) !== state.val) {
8428
8460
  if (state.val) {
8429
8461
  if (!this.pluginHandler.isPluginInstanciated(pluginName)) {
8430
8462
  this.pluginHandler.instanciatePlugin(pluginName, this.pluginHandler.getPluginConfig(pluginName) || {}, __dirname);
8431
- this.pluginHandler.setDatabaseForPlugin(pluginName, __classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"));
8463
+ this.pluginHandler.setDatabaseForPlugin(pluginName, this.#objects, this.#states);
8432
8464
  this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
8433
8465
  }
8434
8466
  }
@@ -8505,7 +8537,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8505
8537
  this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
8506
8538
  }, 5000);
8507
8539
  }
8508
- }), "f");
8540
+ });
8509
8541
  }
8510
8542
  _initObjects(cb) {
8511
8543
  this._initializeTimeout = setTimeout(() => {
@@ -8522,7 +8554,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8522
8554
  this._logger.warn(`${this.namespaceLog} Objects DB constructor has not been initialized`);
8523
8555
  this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
8524
8556
  }
8525
- __classPrivateFieldSet(this, _AdapterClass_objects, new this.Objects({
8557
+ this.#objects = new this.Objects({
8526
8558
  namespace: this.namespaceLog,
8527
8559
  connection: this._config.objects,
8528
8560
  logger: this._logger,
@@ -8532,18 +8564,18 @@ class AdapterClass extends node_events_1.EventEmitter {
8532
8564
  clearTimeout(this._initializeTimeout);
8533
8565
  this._initializeTimeout = null;
8534
8566
  }
8535
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
8567
+ if (!this.#objects) {
8536
8568
  return;
8537
8569
  }
8538
8570
  // subscribe to user changes
8539
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe('system.user.*');
8571
+ this.#objects.subscribe('system.user.*');
8540
8572
  // get all enums and register for enum changes
8541
- this.enums = await js_controller_common_1.tools.getAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"));
8542
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe('enum.*');
8573
+ this.enums = await js_controller_common_1.tools.getAllEnums(this.#objects);
8574
+ this.#objects.subscribe('enum.*');
8543
8575
  // Read dateformat if using of formatDate is announced
8544
8576
  if (this._options.useFormatDate) {
8545
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject('system.config', (err, data) => {
8546
- if (data === null || data === void 0 ? void 0 : data.common) {
8577
+ this.#objects.getObject('system.config', (err, data) => {
8578
+ if (data?.common) {
8547
8579
  this.dateFormat = data.common.dateFormat;
8548
8580
  this.isFloatComma = data.common.isFloatComma;
8549
8581
  this.language = data.common.language;
@@ -8551,7 +8583,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8551
8583
  this.latitude = data.common.latitude;
8552
8584
  this.defaultHistory = data.common.defaultHistory;
8553
8585
  }
8554
- if (data === null || data === void 0 ? void 0 : data.native) {
8586
+ if (data?.native) {
8555
8587
  this._systemSecret = data.native.secret;
8556
8588
  }
8557
8589
  return js_controller_common_1.tools.maybeCallback(cb);
@@ -8573,7 +8605,6 @@ class AdapterClass extends node_events_1.EventEmitter {
8573
8605
  }, 4000);
8574
8606
  },
8575
8607
  change: async (id, obj) => {
8576
- var _a, _b, _c;
8577
8608
  // System level object changes (and alias objects)
8578
8609
  if (!id) {
8579
8610
  this._logger.error(`${this.namespaceLog} change ID is empty: ${JSON.stringify(obj)}`);
@@ -8588,8 +8619,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8588
8619
  }
8589
8620
  // update language, dateFormat and comma
8590
8621
  if (id === 'system.config' &&
8591
- obj &&
8592
- obj.common &&
8622
+ obj?.common &&
8593
8623
  (this._options.useFormatDate || this.defaultHistory !== undefined)) {
8594
8624
  this.dateFormat = obj.common.dateFormat;
8595
8625
  this.isFloatComma = obj.common.isFloatComma;
@@ -8608,7 +8638,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8608
8638
  if (targetAlias) {
8609
8639
  isNewAlias = false;
8610
8640
  // new sourceId or same
8611
- if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.alias) === null || _b === void 0 ? void 0 : _b.id) {
8641
+ if (obj?.common?.alias?.id) {
8612
8642
  // check if id.read or id
8613
8643
  const newSourceId = typeof obj.common.alias.id.read === 'string'
8614
8644
  ? obj.common.alias.id.read
@@ -8661,7 +8691,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8661
8691
  }
8662
8692
  // process auto-subscribe adapters
8663
8693
  if (id.startsWith('system.adapter.')) {
8664
- if ((_c = obj === null || obj === void 0 ? void 0 : obj.common) === null || _c === void 0 ? void 0 : _c.subscribable) {
8694
+ if (obj?.common?.subscribable) {
8665
8695
  const _id = id.substring(15); // 'system.adapter.'.length
8666
8696
  if (obj.common.enabled) {
8667
8697
  if (!this.autoSubscribe.includes(_id)) {
@@ -8741,22 +8771,22 @@ class AdapterClass extends node_events_1.EventEmitter {
8741
8771
  setImmediate(() => this.emit('fileChange', id, fileName, size));
8742
8772
  }
8743
8773
  }
8744
- }), "f");
8774
+ });
8745
8775
  }
8746
8776
  /**
8747
8777
  * Called if states and objects successfully initialized
8748
8778
  */
8749
8779
  _prepareInitAdapter() {
8750
- if (this.terminated || !__classPrivateFieldGet(this, _AdapterClass_objects, "f") || !__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
8780
+ if (this.terminated || !this.#objects || !this.#states) {
8751
8781
  return;
8752
8782
  }
8753
8783
  if (this._options.instance !== undefined) {
8754
8784
  this._initAdapter(this._options);
8755
8785
  }
8756
8786
  else {
8757
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${this.namespace}.alive`, (err, resAlive) => {
8758
- __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${this.namespace}.sigKill`, (err, killRes) => {
8759
- if ((killRes === null || killRes === void 0 ? void 0 : killRes.val) !== undefined) {
8787
+ this.#states.getState(`system.adapter.${this.namespace}.alive`, (err, resAlive) => {
8788
+ this.#states.getState(`system.adapter.${this.namespace}.sigKill`, (err, killRes) => {
8789
+ if (killRes?.val !== undefined) {
8760
8790
  killRes.val = parseInt(killRes.val, 10);
8761
8791
  }
8762
8792
  if (!this._config.isInstall &&
@@ -8788,7 +8818,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8788
8818
  this.terminate(js_controller_common_1.EXIT_CODES.ADAPTER_ALREADY_RUNNING);
8789
8819
  }
8790
8820
  else {
8791
- __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`system.adapter.${this.namespace}`, (err, res) => {
8821
+ this.#objects.getObject(`system.adapter.${this.namespace}`, (err, res) => {
8792
8822
  // TODO: ts infers AdapterObject instead of InstanceObject
8793
8823
  if ((err || !res) && !this._config.isInstall) {
8794
8824
  this._logger.error(`${this.namespaceLog} ${this.namespace} invalid config`);
@@ -8808,14 +8838,13 @@ class AdapterClass extends node_events_1.EventEmitter {
8808
8838
  if (!this.pluginHandler) {
8809
8839
  return;
8810
8840
  }
8811
- this.pluginHandler.setDatabaseForPlugins(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"));
8841
+ this.pluginHandler.setDatabaseForPlugins(this.#objects, this.#states);
8812
8842
  this.pluginHandler.initPlugins(adapterConfig || {}, async () => {
8813
- var _a, _b, _c;
8814
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f") || !__classPrivateFieldGet(this, _AdapterClass_objects, "f") || this.terminated) {
8843
+ if (!this.#states || !this.#objects || this.terminated) {
8815
8844
  // if adapterState was destroyed,we should not continue
8816
8845
  return;
8817
8846
  }
8818
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.plugins.*`);
8847
+ this.#states.subscribe(`system.adapter.${this.namespace}.plugins.*`);
8819
8848
  if (this._options.instance === undefined) {
8820
8849
  if (!adapterConfig || !('common' in adapterConfig) || !adapterConfig.common.enabled) {
8821
8850
  if (adapterConfig && 'common' in adapterConfig && adapterConfig.common.enabled !== undefined) {
@@ -8828,9 +8857,9 @@ class AdapterClass extends node_events_1.EventEmitter {
8828
8857
  if (!this._config.isInstall && (!process.argv || !this._config.forceIfDisabled)) {
8829
8858
  const id = `system.adapter.${this.namespace}`;
8830
8859
  this.outputCount += 2;
8831
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
8860
+ this.#states.setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
8832
8861
  let done = false;
8833
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.connected`, {
8862
+ this.#states.setState(`${id}.connected`, {
8834
8863
  val: true,
8835
8864
  ack: true,
8836
8865
  expire: 30,
@@ -8923,7 +8952,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8923
8952
  this.stop = () => this._stop(false);
8924
8953
  }
8925
8954
  // Monitor logging state
8926
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`);
8955
+ this.#states.subscribe(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`);
8927
8956
  if (typeof this._options.message === 'function' &&
8928
8957
  // @ts-expect-error, we should infer correctly that this is an InstanceObject in this case
8929
8958
  !(0, utils_1.isMessageboxSupported)(adapterConfig.common)) {
@@ -8932,7 +8961,7 @@ class AdapterClass extends node_events_1.EventEmitter {
8932
8961
  }
8933
8962
  else if ((0, utils_1.isMessageboxSupported)(adapterConfig.common)) {
8934
8963
  this.mboxSubscribed = true;
8935
- __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
8964
+ this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
8936
8965
  }
8937
8966
  }
8938
8967
  else {
@@ -8947,10 +8976,10 @@ class AdapterClass extends node_events_1.EventEmitter {
8947
8976
  this.config = adapterConfig.native || {};
8948
8977
  // @ts-expect-error
8949
8978
  this.common = adapterConfig.common || {};
8950
- this.host = ((_a = this.common) === null || _a === void 0 ? void 0 : _a.host) || js_controller_common_1.tools.getHostName() || node_os_1.default.hostname();
8979
+ this.host = this.common?.host || js_controller_common_1.tools.getHostName() || node_os_1.default.hostname();
8951
8980
  }
8952
8981
  this.adapterConfig = adapterConfig;
8953
- this._utils = new validator_1.Validator(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"), this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
8982
+ this._utils = new validator_1.Validator(this.#objects, this.#states, this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
8954
8983
  this.log = new log_1.Log(this.namespaceLog, this._config.log.level, this._logger);
8955
8984
  await this._createInstancesObjects(adapterConfig);
8956
8985
  // auto oObjects
@@ -8985,21 +9014,21 @@ class AdapterClass extends node_events_1.EventEmitter {
8985
9014
  }
8986
9015
  // Wait till all attributes decrypted
8987
9016
  await Promise.all(promises);
8988
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
9017
+ if (!this.#states) {
8989
9018
  // if this.adapterStates was destroyed, we should not continue
8990
9019
  return;
8991
9020
  }
8992
9021
  this.outputCount++;
8993
9022
  // set current loglevel
8994
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${this.namespace}.logLevel`, {
9023
+ this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
8995
9024
  val: this._config.log.level,
8996
9025
  ack: true,
8997
9026
  from: `system.adapter.${this.namespace}`
8998
9027
  });
8999
9028
  if (this._options.instance === undefined) {
9000
- this.version = ((_b = this.pack) === null || _b === void 0 ? void 0 : _b.version)
9029
+ this.version = this.pack?.version
9001
9030
  ? this.pack.version
9002
- : ((_c = this.ioPack) === null || _c === void 0 ? void 0 : _c.common)
9031
+ : this.ioPack?.common
9003
9032
  ? this.ioPack.common.version
9004
9033
  : 'unknown';
9005
9034
  // display if it's a non-official version - only if installedFrom is explicitly given and differs it's not npm
@@ -9015,19 +9044,19 @@ class AdapterClass extends node_events_1.EventEmitter {
9015
9044
  this._reportInterval = setInterval(() => this._reportStatus(), this._config.system.statisticsInterval);
9016
9045
  this._reportStatus();
9017
9046
  const id = `system.adapter.${this.namespace}`;
9018
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.compactMode`, {
9047
+ this.#states.setState(`${id}.compactMode`, {
9019
9048
  ack: true,
9020
9049
  from: id,
9021
9050
  val: !!this.startedInCompactMode
9022
9051
  });
9023
9052
  this.outputCount++;
9024
9053
  if (this.startedInCompactMode) {
9025
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cpu`, { ack: true, from: id, val: 0 });
9026
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cputime`, { ack: true, from: id, val: 0 });
9027
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memRss`, { val: 0, ack: true, from: id });
9028
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapTotal`, { val: 0, ack: true, from: id });
9029
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapUsed`, { val: 0, ack: true, from: id });
9030
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.eventLoopLag`, { val: 0, ack: true, from: id });
9054
+ this.#states.setState(`${id}.cpu`, { ack: true, from: id, val: 0 });
9055
+ this.#states.setState(`${id}.cputime`, { ack: true, from: id, val: 0 });
9056
+ this.#states.setState(`${id}.memRss`, { val: 0, ack: true, from: id });
9057
+ this.#states.setState(`${id}.memHeapTotal`, { val: 0, ack: true, from: id });
9058
+ this.#states.setState(`${id}.memHeapUsed`, { val: 0, ack: true, from: id });
9059
+ this.#states.setState(`${id}.eventLoopLag`, { val: 0, ack: true, from: id });
9031
9060
  this.outputCount += 6;
9032
9061
  }
9033
9062
  else {
@@ -9041,7 +9070,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9041
9070
  }
9042
9071
  if (adapterConfig && 'common' in adapterConfig && adapterConfig.common.restartSchedule) {
9043
9072
  try {
9044
- this._schedule = await Promise.resolve().then(() => __importStar(require('node-schedule')));
9073
+ this._schedule = await import('node-schedule');
9045
9074
  }
9046
9075
  catch {
9047
9076
  this._logger.error(`${this.namespaceLog} Cannot load node-schedule. Scheduled restart is disabled`);
@@ -9111,7 +9140,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9111
9140
  }
9112
9141
  }
9113
9142
  // catch it on Windows
9114
- if (this.getPortRunning && (err === null || err === void 0 ? void 0 : err.message) === 'listen EADDRINUSE') {
9143
+ if (this.getPortRunning && err?.message === 'listen EADDRINUSE') {
9115
9144
  const { host, port, callback } = this.getPortRunning;
9116
9145
  this._logger.warn(`${this.namespaceLog} Port ${port}${host ? ` for host ${host}` : ''} is in use. Get next`);
9117
9146
  setImmediate(() => this.getPort(port + 1, host, callback));
@@ -9143,9 +9172,8 @@ class AdapterClass extends node_events_1.EventEmitter {
9143
9172
  }
9144
9173
  }
9145
9174
  async _createInstancesObjects(instanceObj) {
9146
- var _a;
9147
9175
  let objs;
9148
- if ((instanceObj === null || instanceObj === void 0 ? void 0 : instanceObj.common) && !('onlyWWW' in instanceObj.common) && instanceObj.common.mode !== 'once') {
9176
+ if (instanceObj?.common && !('onlyWWW' in instanceObj.common) && instanceObj.common.mode !== 'once') {
9149
9177
  // @ts-expect-error
9150
9178
  objs = js_controller_common_1.tools.getInstanceIndicatorObjects(this.namespace, instanceObj.common.wakeup);
9151
9179
  }
@@ -9160,35 +9188,33 @@ class AdapterClass extends node_events_1.EventEmitter {
9160
9188
  obj._id = obj._id === '' ? this.namespace : `${this.namespace}.${obj._id}`;
9161
9189
  }
9162
9190
  if (obj && (obj._id || obj.type === 'meta')) {
9163
- if (obj.common) {
9164
- if (obj.common.name) {
9165
- const commonName = obj.common.name;
9166
- // if name has many languages
9167
- if (js_controller_common_1.tools.isObject(commonName)) {
9168
- for (const [lang, value] of Object.entries(commonName)) {
9169
- commonName[lang] = value.replace('%INSTANCE%', this.instance.toString());
9170
- }
9171
- }
9172
- else {
9173
- obj.common.name = commonName.replace('%INSTANCE%', this.instance.toString());
9191
+ if (obj.common?.name) {
9192
+ const commonName = obj.common.name;
9193
+ // if name has many languages
9194
+ if (js_controller_common_1.tools.isObject(commonName)) {
9195
+ for (const [lang, value] of Object.entries(commonName)) {
9196
+ commonName[lang] = value.replace('%INSTANCE%', this.instance.toString());
9174
9197
  }
9175
9198
  }
9199
+ else {
9200
+ obj.common.name = commonName.replace('%INSTANCE%', this.instance.toString());
9201
+ }
9176
9202
  if ('desc' in obj.common) {
9177
9203
  const commonDesc = obj.common.desc;
9178
9204
  // if description has many languages
9179
9205
  if (js_controller_common_1.tools.isObject(commonDesc)) {
9180
9206
  for (const [lang, value] of Object.entries(commonDesc)) {
9181
- commonDesc[lang] = value.replace('%INSTANCE%', this.instance);
9207
+ commonDesc[lang] = value.replace('%INSTANCE%', this.instance.toString());
9182
9208
  }
9183
9209
  }
9184
- else {
9185
- obj.common.desc = commonDesc.replace('%INSTANCE%', this.instance);
9210
+ else if (commonDesc) {
9211
+ obj.common.desc = commonDesc.replace('%INSTANCE%', this.instance.toString());
9186
9212
  }
9187
9213
  }
9188
9214
  if (obj.type === 'state' && obj.common.def !== undefined) {
9189
9215
  // default value given - if obj non-existing we have to set it
9190
9216
  try {
9191
- const checkObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(obj._id);
9217
+ const checkObj = await this.#objects.objectExists(obj._id);
9192
9218
  if (!checkObj) {
9193
9219
  obj.state = obj.common.def;
9194
9220
  }
@@ -9206,7 +9232,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9206
9232
  }
9207
9233
  }
9208
9234
  // create logging object for log-transporter instances
9209
- if ((_a = instanceObj === null || instanceObj === void 0 ? void 0 : instanceObj.common) === null || _a === void 0 ? void 0 : _a.logTransporter) {
9235
+ if (instanceObj?.common?.logTransporter) {
9210
9236
  // create system.adapter.ADAPTERNAME.instance.logger
9211
9237
  objs.push({
9212
9238
  _id: `system.adapter.${this.namespace}.logging`,
@@ -9243,7 +9269,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9243
9269
  this._logger.warn(`${this.namespaceLog} Object ${task._id} is invalid: ${e.message}`);
9244
9270
  this._logger.warn(`${this.namespaceLog} This object will not be created in future versions. Please report this to the developer.`);
9245
9271
  }
9246
- if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
9272
+ if (!this.#objects) {
9247
9273
  this._logger.info(`${this.namespaceLog} extendObjects not processed because Objects database not connected.`);
9248
9274
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
9249
9275
  }
@@ -9256,12 +9282,12 @@ class AdapterClass extends node_events_1.EventEmitter {
9256
9282
  // ignore
9257
9283
  }
9258
9284
  if (state !== undefined) {
9259
- if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
9285
+ if (!this.#states) {
9260
9286
  this._logger.info(`${this.namespaceLog} extendObjects not processed because States database not connected.`);
9261
9287
  return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
9262
9288
  }
9263
9289
  this.outputCount++;
9264
- __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(task._id, {
9290
+ this.#states.setState(task._id, {
9265
9291
  val: state,
9266
9292
  from: `system.adapter.${this.namespace}`,
9267
9293
  ack: true
@@ -9285,7 +9311,6 @@ class AdapterClass extends node_events_1.EventEmitter {
9285
9311
  return mId;
9286
9312
  }
9287
9313
  async _init() {
9288
- var _a, _b;
9289
9314
  /**
9290
9315
  * Initiates the databases
9291
9316
  */
@@ -9316,7 +9341,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9316
9341
  }
9317
9342
  if (this._config.states && this._config.states.type) {
9318
9343
  try {
9319
- this.States = (await (_a = `@iobroker/db-states-${this._config.states.type}`, Promise.resolve().then(() => __importStar(require(_a))))).Client;
9344
+ this.States = (await import(`@iobroker/db-states-${this._config.states.type}`)).Client;
9320
9345
  }
9321
9346
  catch (err) {
9322
9347
  throw new Error(`Unknown states type: ${this._config.states.type}: ${err.message}`);
@@ -9327,7 +9352,7 @@ class AdapterClass extends node_events_1.EventEmitter {
9327
9352
  }
9328
9353
  if (this._config.objects && this._config.objects.type) {
9329
9354
  try {
9330
- this.Objects = (await (_b = `@iobroker/db-objects-${this._config.objects.type}`, Promise.resolve().then(() => __importStar(require(_b))))).Client;
9355
+ this.Objects = (await import(`@iobroker/db-objects-${this._config.objects.type}`)).Client;
9331
9356
  }
9332
9357
  catch (err) {
9333
9358
  throw new Error(`Unknown objects type: ${this._config.objects.type}: ${err.message}`);
@@ -9375,7 +9400,6 @@ class AdapterClass extends node_events_1.EventEmitter {
9375
9400
  }
9376
9401
  }
9377
9402
  exports.AdapterClass = AdapterClass;
9378
- _AdapterClass_states = new WeakMap(), _AdapterClass_objects = new WeakMap();
9379
9403
  /**
9380
9404
  * Polyfill to allow calling without `new`
9381
9405
  * @type {AdapterClass}