@iobroker/js-controller-adapter 5.0.13 → 5.0.14-alpha.0-20231017-1cfd77e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/_Types.d.ts +5 -5
- package/build/lib/_Types.d.ts.map +1 -1
- package/build/lib/adapter/adapter.d.ts +5 -0
- package/build/lib/adapter/adapter.d.ts.map +1 -1
- package/build/lib/adapter/adapter.js +334 -313
- package/build/lib/adapter/adapter.js.map +1 -1
- package/build/lib/adapter/constants.d.ts +1 -1
- package/build/lib/adapter/constants.js +2 -2
- package/build/lib/adapter/constants.js.map +1 -1
- package/build/lib/adapter/validator.d.ts +21 -21
- package/build/lib/adapter/validator.d.ts.map +1 -1
- package/build/lib/adapter/validator.js +27 -27
- package/build/lib/adapter/validator.js.map +1 -1
- package/package.json +10 -10
|
@@ -22,9 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
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
|
+
};
|
|
25
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
38
|
};
|
|
39
|
+
var _AdapterClass_states, _AdapterClass_objects;
|
|
28
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
41
|
exports.Adapter = exports.AdapterClass = void 0;
|
|
30
42
|
const net_1 = __importDefault(require("net"));
|
|
@@ -51,11 +63,6 @@ const constants_1 = require("./constants");
|
|
|
51
63
|
const userInterfaceMessagingController_1 = require("./userInterfaceMessagingController");
|
|
52
64
|
const constants_2 = require("@iobroker/js-controller-common/constants");
|
|
53
65
|
js_controller_common_1.tools.ensureDNSOrder();
|
|
54
|
-
// keep them outside until we have migrated to TS, else devs can access them
|
|
55
|
-
let adapterStates;
|
|
56
|
-
let adapterObjects;
|
|
57
|
-
let States;
|
|
58
|
-
let Objects;
|
|
59
66
|
/**
|
|
60
67
|
* Adapter class
|
|
61
68
|
*
|
|
@@ -66,6 +73,10 @@ let Objects;
|
|
|
66
73
|
class AdapterClass extends events_1.EventEmitter {
|
|
67
74
|
constructor(options) {
|
|
68
75
|
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);
|
|
69
80
|
/** List of instances which want our logs */
|
|
70
81
|
this.logList = new Set();
|
|
71
82
|
this.aliases = new Map();
|
|
@@ -572,12 +583,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
572
583
|
}
|
|
573
584
|
// actual implementation
|
|
574
585
|
_getSession(options) {
|
|
575
|
-
if (!
|
|
586
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
576
587
|
// if states is no longer existing, we do not need to unsubscribe
|
|
577
588
|
this._logger.info(`${this.namespaceLog} getSession not processed because States database not connected`);
|
|
578
589
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
579
590
|
}
|
|
580
|
-
|
|
591
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getSession(options.id, options.callback);
|
|
581
592
|
}
|
|
582
593
|
// unknown implementation guards
|
|
583
594
|
setSession(id, ttl, data, callback) {
|
|
@@ -589,12 +600,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
589
600
|
}
|
|
590
601
|
// actual implementation
|
|
591
602
|
_setSession(options) {
|
|
592
|
-
if (!
|
|
603
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
593
604
|
// if states is no longer existing, we do not need to unsubscribe
|
|
594
605
|
this._logger.info(`${this.namespaceLog} setSession not processed because States database not connected`);
|
|
595
606
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
596
607
|
}
|
|
597
|
-
|
|
608
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setSession(options.id, options.ttl, options.data, options.callback);
|
|
598
609
|
}
|
|
599
610
|
destroySession(id, callback) {
|
|
600
611
|
validator_1.Validator.assertString(id, 'id');
|
|
@@ -602,19 +613,19 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
602
613
|
return this._destroySession({ id, callback });
|
|
603
614
|
}
|
|
604
615
|
_destroySession(options) {
|
|
605
|
-
if (!
|
|
616
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
606
617
|
// if states is no longer existing, we do not need to unsubscribe
|
|
607
618
|
this._logger.info(`${this.namespaceLog} destroySession not processed because States database not connected`);
|
|
608
619
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
609
620
|
}
|
|
610
|
-
|
|
621
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").destroySession(options.id, options.callback);
|
|
611
622
|
}
|
|
612
623
|
async _getObjectsByArray(keys, objects, options) {
|
|
613
624
|
if (objects) {
|
|
614
625
|
return objects;
|
|
615
626
|
}
|
|
616
627
|
try {
|
|
617
|
-
const res = await
|
|
628
|
+
const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjects(keys, options);
|
|
618
629
|
return res;
|
|
619
630
|
}
|
|
620
631
|
catch (e) {
|
|
@@ -673,17 +684,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
673
684
|
}
|
|
674
685
|
setTimeout(async () => {
|
|
675
686
|
// give last states some time to get handled
|
|
676
|
-
if (
|
|
687
|
+
if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
677
688
|
try {
|
|
678
|
-
await
|
|
689
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").destroy();
|
|
679
690
|
}
|
|
680
691
|
catch {
|
|
681
692
|
// ignore
|
|
682
693
|
}
|
|
683
694
|
}
|
|
684
|
-
if (
|
|
695
|
+
if (__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
685
696
|
try {
|
|
686
|
-
await
|
|
697
|
+
await __classPrivateFieldGet(this, _AdapterClass_objects, "f").destroy();
|
|
687
698
|
}
|
|
688
699
|
catch {
|
|
689
700
|
//ignore
|
|
@@ -691,8 +702,8 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
691
702
|
}
|
|
692
703
|
if (this.startedInCompactMode) {
|
|
693
704
|
this.emit('exit', _exitCode, reason);
|
|
694
|
-
|
|
695
|
-
|
|
705
|
+
__classPrivateFieldSet(this, _AdapterClass_states, null, "f");
|
|
706
|
+
__classPrivateFieldSet(this, _AdapterClass_objects, null, "f");
|
|
696
707
|
}
|
|
697
708
|
else {
|
|
698
709
|
process.exit(_exitCode);
|
|
@@ -1328,9 +1339,9 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1328
1339
|
this.messageCallbacks.forEach(callbackObj => clearTimeout(callbackObj.timer));
|
|
1329
1340
|
this.messageCallbacks.clear();
|
|
1330
1341
|
}
|
|
1331
|
-
if (
|
|
1342
|
+
if (__classPrivateFieldGet(this, _AdapterClass_states, "f") && updateAliveState) {
|
|
1332
1343
|
this.outputCount++;
|
|
1333
|
-
|
|
1344
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, { val: false, ack: true, from: id }, () => {
|
|
1334
1345
|
if (!isPause) {
|
|
1335
1346
|
this._logger.info(`${this.namespaceLog} terminating`);
|
|
1336
1347
|
}
|
|
@@ -1378,7 +1389,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1378
1389
|
// Even if the developer forgets to call the unload callback, we need to stop the process
|
|
1379
1390
|
// Therefore wait a short while and then force the unload
|
|
1380
1391
|
setTimeout(() => {
|
|
1381
|
-
if (
|
|
1392
|
+
if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
1382
1393
|
finishUnload();
|
|
1383
1394
|
// Give 1 seconds to write the value
|
|
1384
1395
|
setTimeout(() => {
|
|
@@ -1473,13 +1484,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1473
1484
|
async _getCertificates(options) {
|
|
1474
1485
|
const { publicName, chainedName, privateName, callback } = options;
|
|
1475
1486
|
let obj;
|
|
1476
|
-
if (!
|
|
1487
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
1477
1488
|
this._logger.info(`${this.namespaceLog} getCertificates not processed because Objects database not connected`);
|
|
1478
1489
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
1479
1490
|
}
|
|
1480
1491
|
try {
|
|
1481
1492
|
// Load certificates
|
|
1482
|
-
obj = await
|
|
1493
|
+
obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject('system.certificates');
|
|
1483
1494
|
}
|
|
1484
1495
|
catch {
|
|
1485
1496
|
// ignore
|
|
@@ -1869,7 +1880,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1869
1880
|
* @param [callback]
|
|
1870
1881
|
*/
|
|
1871
1882
|
async _setObjectWithDefaultValue(id, obj, options, callback) {
|
|
1872
|
-
if (!
|
|
1883
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
1873
1884
|
this._logger.info(`${this.namespaceLog} setObject not processed because Objects database not connected`);
|
|
1874
1885
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
1875
1886
|
}
|
|
@@ -1888,7 +1899,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1888
1899
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
1889
1900
|
}
|
|
1890
1901
|
try {
|
|
1891
|
-
const result = await
|
|
1902
|
+
const result = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(id, obj, options);
|
|
1892
1903
|
if (obj.type === 'state' && obj.common && obj.common.def !== undefined && obj.common.def !== null) {
|
|
1893
1904
|
const state = await this.getForeignStateAsync(id);
|
|
1894
1905
|
// only set the def state, if state is non-existent
|
|
@@ -1932,7 +1943,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1932
1943
|
}
|
|
1933
1944
|
}
|
|
1934
1945
|
};
|
|
1935
|
-
if (!
|
|
1946
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
1936
1947
|
return js_controller_common_1.tools.maybeCallback(options.callback, ret);
|
|
1937
1948
|
}
|
|
1938
1949
|
const params = {
|
|
@@ -1941,7 +1952,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1941
1952
|
include_docs: true
|
|
1942
1953
|
};
|
|
1943
1954
|
try {
|
|
1944
|
-
const folders = await
|
|
1955
|
+
const folders = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'folder', params);
|
|
1945
1956
|
if (folders) {
|
|
1946
1957
|
addRows(folders.rows);
|
|
1947
1958
|
}
|
|
@@ -1950,7 +1961,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1950
1961
|
/* ignore, we'll return what we get till now */
|
|
1951
1962
|
}
|
|
1952
1963
|
try {
|
|
1953
|
-
const devices = await
|
|
1964
|
+
const devices = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'device', params);
|
|
1954
1965
|
if (devices) {
|
|
1955
1966
|
addRows(devices.rows);
|
|
1956
1967
|
}
|
|
@@ -1959,7 +1970,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1959
1970
|
/* ignore, we'll return what we get till now */
|
|
1960
1971
|
}
|
|
1961
1972
|
try {
|
|
1962
|
-
const channels = await
|
|
1973
|
+
const channels = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'channel', params);
|
|
1963
1974
|
if (channels) {
|
|
1964
1975
|
addRows(channels.rows);
|
|
1965
1976
|
}
|
|
@@ -1968,7 +1979,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
1968
1979
|
/* ignore, we'll return what we get till now */
|
|
1969
1980
|
}
|
|
1970
1981
|
try {
|
|
1971
|
-
const states = await
|
|
1982
|
+
const states = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'state', params);
|
|
1972
1983
|
if (states) {
|
|
1973
1984
|
addRows(states.rows);
|
|
1974
1985
|
}
|
|
@@ -2058,7 +2069,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2058
2069
|
}
|
|
2059
2070
|
// TODO: the public return type needs to be defined correctly, probably needs to be discussed
|
|
2060
2071
|
async _extendObject(options) {
|
|
2061
|
-
if (!
|
|
2072
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2062
2073
|
this._logger.info(`${this.namespaceLog} extendObject not processed because Objects database not connected`);
|
|
2063
2074
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2064
2075
|
}
|
|
@@ -2084,12 +2095,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2084
2095
|
// Read whole object
|
|
2085
2096
|
let oldObj;
|
|
2086
2097
|
try {
|
|
2087
|
-
oldObj = await
|
|
2098
|
+
oldObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(options.id, options.options);
|
|
2088
2099
|
}
|
|
2089
2100
|
catch (e) {
|
|
2090
2101
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, e);
|
|
2091
2102
|
}
|
|
2092
|
-
if (!
|
|
2103
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2093
2104
|
this._logger.info(`${this.namespaceLog} extendObject not processed because Objects database not connected`);
|
|
2094
2105
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2095
2106
|
}
|
|
@@ -2130,7 +2141,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2130
2141
|
options.obj.ts = options.obj.ts || Date.now();
|
|
2131
2142
|
options.obj = extend(true, oldObj, options.obj);
|
|
2132
2143
|
// @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
|
|
2133
|
-
return
|
|
2144
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(options.id, options.obj, options.options, options.callback);
|
|
2134
2145
|
}
|
|
2135
2146
|
else {
|
|
2136
2147
|
options.obj.from = options.obj.from || `system.adapter.${this.namespace}`;
|
|
@@ -2157,7 +2168,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2157
2168
|
return this.setForeignObject(options.id, options.obj, options.options, options.callback);
|
|
2158
2169
|
}
|
|
2159
2170
|
try {
|
|
2160
|
-
const cbObj = await
|
|
2171
|
+
const cbObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").extendObjectAsync(options.id, options.obj, options.options || {});
|
|
2161
2172
|
let defState;
|
|
2162
2173
|
if (options.obj.type === 'state' || oldObj.type === 'state') {
|
|
2163
2174
|
if (options.obj.common && 'def' in options.obj.common && options.obj.common.def !== undefined) {
|
|
@@ -2316,14 +2327,14 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2316
2327
|
async _extendForeignObjectAsync(_options) {
|
|
2317
2328
|
const { id, callback, options } = _options;
|
|
2318
2329
|
let { obj } = _options;
|
|
2319
|
-
if (!
|
|
2330
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2320
2331
|
this._logger.info(`${this.namespaceLog} extendForeignObject not processed because Objects database not connected`);
|
|
2321
2332
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2322
2333
|
}
|
|
2323
2334
|
// Read whole object
|
|
2324
2335
|
let oldObj;
|
|
2325
2336
|
try {
|
|
2326
|
-
oldObj = await
|
|
2337
|
+
oldObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(id, options);
|
|
2327
2338
|
}
|
|
2328
2339
|
catch (e) {
|
|
2329
2340
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
@@ -2359,7 +2370,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2359
2370
|
obj.ts = obj.ts || Date.now();
|
|
2360
2371
|
obj = extend(true, oldObj, obj);
|
|
2361
2372
|
// @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
|
|
2362
|
-
return
|
|
2373
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, options, callback);
|
|
2363
2374
|
}
|
|
2364
2375
|
else {
|
|
2365
2376
|
obj.from = obj.from || `system.adapter.${this.namespace}`;
|
|
@@ -2385,7 +2396,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2385
2396
|
return this.setForeignObject(id, obj, options, callback);
|
|
2386
2397
|
}
|
|
2387
2398
|
try {
|
|
2388
|
-
const cbObj = await
|
|
2399
|
+
const cbObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").extendObjectAsync(id, obj, options || {});
|
|
2389
2400
|
if ((cbObj === null || cbObj === void 0 ? void 0 : cbObj.value.type) === 'state') {
|
|
2390
2401
|
let defState;
|
|
2391
2402
|
if (obj.common && 'def' in obj.common && obj.common.def !== undefined) {
|
|
@@ -2430,7 +2441,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2430
2441
|
* @param options optional user context
|
|
2431
2442
|
*/
|
|
2432
2443
|
objectExists(id, options) {
|
|
2433
|
-
if (!
|
|
2444
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2434
2445
|
this._logger.info(`${this.namespaceLog} objectExists not processed because Objects database not connected`);
|
|
2435
2446
|
return Promise.resolve();
|
|
2436
2447
|
}
|
|
@@ -2440,7 +2451,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2440
2451
|
}
|
|
2441
2452
|
id = this._utils.fixId(id);
|
|
2442
2453
|
this._utils.validateId(id, false, null);
|
|
2443
|
-
return
|
|
2454
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options);
|
|
2444
2455
|
}
|
|
2445
2456
|
/**
|
|
2446
2457
|
* Checks if an object exists to the given id
|
|
@@ -2449,7 +2460,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2449
2460
|
* @param options optional user context
|
|
2450
2461
|
*/
|
|
2451
2462
|
foreignObjectExists(id, options) {
|
|
2452
|
-
if (!
|
|
2463
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2453
2464
|
this._logger.info(`${this.namespaceLog} foreignObjectExists not processed because Objects database not connected`);
|
|
2454
2465
|
return Promise.resolve();
|
|
2455
2466
|
}
|
|
@@ -2458,7 +2469,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2458
2469
|
validator_1.Validator.assertObject(options, 'options');
|
|
2459
2470
|
}
|
|
2460
2471
|
this._utils.validateId(id, true, null);
|
|
2461
|
-
return
|
|
2472
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options);
|
|
2462
2473
|
}
|
|
2463
2474
|
/**
|
|
2464
2475
|
* Get object of this instance.
|
|
@@ -2484,7 +2495,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2484
2495
|
if (options !== null && options !== undefined) {
|
|
2485
2496
|
validator_1.Validator.assertObject(options, 'options');
|
|
2486
2497
|
}
|
|
2487
|
-
if (!
|
|
2498
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2488
2499
|
this._logger.info(`${this.namespaceLog} getObject not processed because Objects database not connected`);
|
|
2489
2500
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2490
2501
|
}
|
|
@@ -2494,7 +2505,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2494
2505
|
catch (err) {
|
|
2495
2506
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
2496
2507
|
}
|
|
2497
|
-
|
|
2508
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(this._utils.fixId(id), options, callback);
|
|
2498
2509
|
}
|
|
2499
2510
|
/**
|
|
2500
2511
|
* Read object view from DB.
|
|
@@ -2539,7 +2550,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2539
2550
|
}
|
|
2540
2551
|
_getObjectView(_options) {
|
|
2541
2552
|
const { design, search, params, options, callback } = _options;
|
|
2542
|
-
if (!
|
|
2553
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2543
2554
|
this._logger.info(`${this.namespaceLog} getObjectView not processed because Objects database not connected`);
|
|
2544
2555
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2545
2556
|
}
|
|
@@ -2580,7 +2591,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2580
2591
|
}
|
|
2581
2592
|
}
|
|
2582
2593
|
// @ts-expect-error fix it
|
|
2583
|
-
return
|
|
2594
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView(design, search, params, options, callback);
|
|
2584
2595
|
}
|
|
2585
2596
|
/**
|
|
2586
2597
|
* Read object list from DB.
|
|
@@ -2617,11 +2628,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2617
2628
|
}
|
|
2618
2629
|
validator_1.Validator.assertObject(params, 'params');
|
|
2619
2630
|
validator_1.Validator.assertOptionalCallback(callback, 'callback');
|
|
2620
|
-
if (!
|
|
2631
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2621
2632
|
this._logger.info(`${this.namespaceLog} getObjectList not processed because Objects database not connected`);
|
|
2622
2633
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2623
2634
|
}
|
|
2624
|
-
|
|
2635
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList(params, options, callback);
|
|
2625
2636
|
}
|
|
2626
2637
|
/**
|
|
2627
2638
|
* Get the enum tree.
|
|
@@ -2671,7 +2682,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2671
2682
|
_getEnum(_options) {
|
|
2672
2683
|
const { options, callback } = _options;
|
|
2673
2684
|
let { _enum } = _options;
|
|
2674
|
-
if (!
|
|
2685
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2675
2686
|
this._logger.info(`${this.namespaceLog} getEnum not processed because Objects database not connected`);
|
|
2676
2687
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2677
2688
|
}
|
|
@@ -2679,7 +2690,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2679
2690
|
_enum = `enum.${_enum}`;
|
|
2680
2691
|
}
|
|
2681
2692
|
const result = {};
|
|
2682
|
-
|
|
2693
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
|
|
2683
2694
|
startkey: `${_enum}.`,
|
|
2684
2695
|
endkey: `${_enum}.\u9999`
|
|
2685
2696
|
}, options, (err, res) => {
|
|
@@ -2754,7 +2765,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2754
2765
|
async _getEnums(_options) {
|
|
2755
2766
|
const { options, callback } = _options;
|
|
2756
2767
|
let { _enumList } = _options;
|
|
2757
|
-
if (!
|
|
2768
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2758
2769
|
this._logger.info(`${this.namespaceLog} getEnums not processed because Objects database not connected`);
|
|
2759
2770
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2760
2771
|
}
|
|
@@ -2785,7 +2796,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2785
2796
|
}
|
|
2786
2797
|
else {
|
|
2787
2798
|
// Read all enums
|
|
2788
|
-
|
|
2799
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
|
|
2789
2800
|
startkey: 'enum.',
|
|
2790
2801
|
endkey: 'enum.\u9999'
|
|
2791
2802
|
}, options, (err, res) => {
|
|
@@ -2893,14 +2904,14 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2893
2904
|
async _getForeignObjects(_options) {
|
|
2894
2905
|
var _a;
|
|
2895
2906
|
const { options, callback, type, pattern, enums } = _options;
|
|
2896
|
-
if (!
|
|
2907
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
2897
2908
|
this._logger.info(`${this.namespaceLog} getForeignObjects not processed because Objects database not connected`);
|
|
2898
2909
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
2899
2910
|
}
|
|
2900
2911
|
let objs;
|
|
2901
2912
|
if (Array.isArray(pattern)) {
|
|
2902
2913
|
try {
|
|
2903
|
-
objs = await
|
|
2914
|
+
objs = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjects(pattern, options);
|
|
2904
2915
|
}
|
|
2905
2916
|
catch (e) {
|
|
2906
2917
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
@@ -2915,7 +2926,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
2915
2926
|
};
|
|
2916
2927
|
}
|
|
2917
2928
|
try {
|
|
2918
|
-
const res = await
|
|
2929
|
+
const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', type || 'state', params, options);
|
|
2919
2930
|
objs = res.rows.map(row => row.value);
|
|
2920
2931
|
}
|
|
2921
2932
|
catch (e) {
|
|
@@ -3009,7 +3020,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3009
3020
|
if (options !== null && options !== undefined) {
|
|
3010
3021
|
validator_1.Validator.assertObject(options, 'options');
|
|
3011
3022
|
}
|
|
3012
|
-
if (!
|
|
3023
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3013
3024
|
this._logger.info(`${this.namespaceLog} findForeignObject not processed because Objects database not connected`);
|
|
3014
3025
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3015
3026
|
}
|
|
@@ -3019,7 +3030,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3019
3030
|
catch (err) {
|
|
3020
3031
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
3021
3032
|
}
|
|
3022
|
-
|
|
3033
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").findObject(id, type, options || {}, callback);
|
|
3023
3034
|
}
|
|
3024
3035
|
/**
|
|
3025
3036
|
* Get any object.
|
|
@@ -3053,12 +3064,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3053
3064
|
return this._getForeignObject({ id, options, callback });
|
|
3054
3065
|
}
|
|
3055
3066
|
async _getForeignObject(options) {
|
|
3056
|
-
if (!
|
|
3067
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3057
3068
|
this._logger.info(`${this.namespaceLog} getForeignObject not processed because Objects database not connected`);
|
|
3058
3069
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3059
3070
|
}
|
|
3060
3071
|
try {
|
|
3061
|
-
const obj = await
|
|
3072
|
+
const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(options.id, options);
|
|
3062
3073
|
// remove protectedNative if not admin, not cloud or not own adapter
|
|
3063
3074
|
if (obj &&
|
|
3064
3075
|
'protectedNative' in obj &&
|
|
@@ -3108,7 +3119,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3108
3119
|
}
|
|
3109
3120
|
else {
|
|
3110
3121
|
const task = tasks.shift();
|
|
3111
|
-
|
|
3122
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").delObject(task.id, options, async (err) => {
|
|
3112
3123
|
if (err) {
|
|
3113
3124
|
return js_controller_common_1.tools.maybeCallbackWithError(cb, err);
|
|
3114
3125
|
}
|
|
@@ -3121,7 +3132,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3121
3132
|
}
|
|
3122
3133
|
}
|
|
3123
3134
|
try {
|
|
3124
|
-
await js_controller_common_1.tools.removeIdFromAllEnums(
|
|
3135
|
+
await js_controller_common_1.tools.removeIdFromAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), task.id, this.enums);
|
|
3125
3136
|
}
|
|
3126
3137
|
catch (e) {
|
|
3127
3138
|
this._logger.warn(`${this.namespaceLog} Could not remove ${task.id} from enums: ${e.message}`);
|
|
@@ -3154,7 +3165,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3154
3165
|
if (options !== undefined && options !== null) {
|
|
3155
3166
|
validator_1.Validator.assertObject(options, 'options');
|
|
3156
3167
|
}
|
|
3157
|
-
if (!
|
|
3168
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3158
3169
|
this._logger.info(`${this.namespaceLog} delForeignObject not processed because Objects database not connected`);
|
|
3159
3170
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3160
3171
|
}
|
|
@@ -3175,11 +3186,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3175
3186
|
// If recursive deletion of all underlying objects, including id
|
|
3176
3187
|
if (options && options.recursive) {
|
|
3177
3188
|
// read object itself
|
|
3178
|
-
|
|
3189
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options, (err, obj) => {
|
|
3179
3190
|
const tasks = obj && (!obj.common || !obj.common.dontDelete) ? [{ id, state: obj.type === 'state' }] : [];
|
|
3180
3191
|
const selector = { startkey: `${id}.`, endkey: `${id}.\u9999` };
|
|
3181
3192
|
// read all underlying states
|
|
3182
|
-
|
|
3193
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList(selector, options, (err, res) => {
|
|
3183
3194
|
res &&
|
|
3184
3195
|
res.rows.forEach((item) => !tasks.find(task => task.id === item.id) &&
|
|
3185
3196
|
(!item.value || !item.value.common || !item.value.common.dontDelete) && // exclude objects with dontDelete flag
|
|
@@ -3189,7 +3200,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3189
3200
|
});
|
|
3190
3201
|
}
|
|
3191
3202
|
else {
|
|
3192
|
-
|
|
3203
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options, async (err, obj) => {
|
|
3193
3204
|
var _a;
|
|
3194
3205
|
if (err) {
|
|
3195
3206
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
@@ -3200,7 +3211,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3200
3211
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, new Error('not deletable'));
|
|
3201
3212
|
}
|
|
3202
3213
|
try {
|
|
3203
|
-
await
|
|
3214
|
+
await __classPrivateFieldGet(this, _AdapterClass_objects, "f").delObject(obj._id, options);
|
|
3204
3215
|
}
|
|
3205
3216
|
catch (err) {
|
|
3206
3217
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
@@ -3219,7 +3230,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3219
3230
|
}
|
|
3220
3231
|
}
|
|
3221
3232
|
try {
|
|
3222
|
-
await js_controller_common_1.tools.removeIdFromAllEnums(
|
|
3233
|
+
await js_controller_common_1.tools.removeIdFromAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), id, this.enums);
|
|
3223
3234
|
}
|
|
3224
3235
|
catch (e) {
|
|
3225
3236
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
@@ -3251,16 +3262,16 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3251
3262
|
if (options !== null && options !== undefined) {
|
|
3252
3263
|
validator_1.Validator.assertObject(options, 'options');
|
|
3253
3264
|
}
|
|
3254
|
-
if (!
|
|
3265
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3255
3266
|
this._logger.info(`${this.namespaceLog} subscribeObjects not processed because Objects database not connected`);
|
|
3256
3267
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3257
3268
|
}
|
|
3258
3269
|
if (pattern === '*') {
|
|
3259
|
-
|
|
3270
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(`${this.namespace}.*`, options, callback);
|
|
3260
3271
|
}
|
|
3261
3272
|
else {
|
|
3262
3273
|
const fixedPattern = Array.isArray(pattern) ? pattern : this._utils.fixId(pattern, true);
|
|
3263
|
-
|
|
3274
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(fixedPattern, options, callback);
|
|
3264
3275
|
}
|
|
3265
3276
|
}
|
|
3266
3277
|
/**
|
|
@@ -3285,16 +3296,16 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3285
3296
|
if (options !== null && options !== undefined) {
|
|
3286
3297
|
validator_1.Validator.assertObject(options, 'options');
|
|
3287
3298
|
}
|
|
3288
|
-
if (!
|
|
3299
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3289
3300
|
this._logger.info(`${this.namespaceLog} unsubscribeObjects not processed because Objects database not connected`);
|
|
3290
3301
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3291
3302
|
}
|
|
3292
3303
|
if (pattern === '*') {
|
|
3293
|
-
|
|
3304
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(`${this.namespace}.*`, options, callback);
|
|
3294
3305
|
}
|
|
3295
3306
|
else {
|
|
3296
3307
|
const fixedPattern = Array.isArray(pattern) ? pattern : this._utils.fixId(pattern, true);
|
|
3297
|
-
|
|
3308
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(fixedPattern, options, callback);
|
|
3298
3309
|
}
|
|
3299
3310
|
}
|
|
3300
3311
|
/**
|
|
@@ -3319,11 +3330,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3319
3330
|
if (options !== null && options !== undefined) {
|
|
3320
3331
|
validator_1.Validator.assertObject(options, 'options');
|
|
3321
3332
|
}
|
|
3322
|
-
if (!
|
|
3333
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3323
3334
|
this._logger.info(`${this.namespaceLog} subscribeForeignObjects not processed because Objects database not connected`);
|
|
3324
3335
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3325
3336
|
}
|
|
3326
|
-
|
|
3337
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUser(pattern, options, callback);
|
|
3327
3338
|
}
|
|
3328
3339
|
/**
|
|
3329
3340
|
* Unsubscribe for the patterns on all objects.
|
|
@@ -3350,11 +3361,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3350
3361
|
if (options !== null && options !== undefined) {
|
|
3351
3362
|
validator_1.Validator.assertObject(options, 'options');
|
|
3352
3363
|
}
|
|
3353
|
-
if (!
|
|
3364
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3354
3365
|
this._logger.info(`${this.namespaceLog} unsubscribeForeignObjects not processed because Objects database not connected`);
|
|
3355
3366
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3356
3367
|
}
|
|
3357
|
-
|
|
3368
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUser(pattern, options, callback);
|
|
3358
3369
|
}
|
|
3359
3370
|
/**
|
|
3360
3371
|
* Subscribe for the changes of files in specific instance.
|
|
@@ -3364,7 +3375,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3364
3375
|
* @param options optional user context
|
|
3365
3376
|
*/
|
|
3366
3377
|
subscribeForeignFiles(id, pattern, options) {
|
|
3367
|
-
if (!
|
|
3378
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3368
3379
|
this._logger.info(`${this.namespaceLog} subscribeForeignFiles not processed because Objects database not connected`);
|
|
3369
3380
|
return Promise.reject(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3370
3381
|
}
|
|
@@ -3373,7 +3384,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3373
3384
|
if (options !== null && options !== undefined) {
|
|
3374
3385
|
validator_1.Validator.assertObject(options, 'options');
|
|
3375
3386
|
}
|
|
3376
|
-
return
|
|
3387
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeUserFile(id, pattern, options);
|
|
3377
3388
|
}
|
|
3378
3389
|
/**
|
|
3379
3390
|
* Unsubscribe for the changes of files on specific instance.
|
|
@@ -3386,7 +3397,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3386
3397
|
if (!pattern) {
|
|
3387
3398
|
pattern = '*';
|
|
3388
3399
|
}
|
|
3389
|
-
if (!
|
|
3400
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3390
3401
|
this._logger.info(`${this.namespaceLog} unsubscribeForeignFiles not processed because Objects database not connected`);
|
|
3391
3402
|
return Promise.reject(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3392
3403
|
}
|
|
@@ -3395,7 +3406,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3395
3406
|
if (options !== null && options !== undefined) {
|
|
3396
3407
|
validator_1.Validator.assertObject(options, 'options');
|
|
3397
3408
|
}
|
|
3398
|
-
return
|
|
3409
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribeUserFile(id, pattern, options);
|
|
3399
3410
|
}
|
|
3400
3411
|
/**
|
|
3401
3412
|
* Same as {@link AdapterClass.setObject}, but with check if the object exists.
|
|
@@ -3438,7 +3449,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3438
3449
|
});
|
|
3439
3450
|
}
|
|
3440
3451
|
async _setObjectNotExists(options) {
|
|
3441
|
-
if (!
|
|
3452
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3442
3453
|
this._logger.info(`${this.namespaceLog} setObjectNotExists not processed because Objects database not connected`);
|
|
3443
3454
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3444
3455
|
}
|
|
@@ -3448,7 +3459,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3448
3459
|
// check if object already exists
|
|
3449
3460
|
let objExists;
|
|
3450
3461
|
try {
|
|
3451
|
-
objExists = await
|
|
3462
|
+
objExists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(options.id, options.options);
|
|
3452
3463
|
}
|
|
3453
3464
|
catch (e) {
|
|
3454
3465
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, `Could not check object existence of ${options.id}: ${e.message}`);
|
|
@@ -3501,7 +3512,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3501
3512
|
}
|
|
3502
3513
|
async _setForeignObjectNotExists(_options) {
|
|
3503
3514
|
const { id, obj, options, callback } = _options;
|
|
3504
|
-
if (!
|
|
3515
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3505
3516
|
this._logger.info(`${this.namespaceLog} setForeignObjectNotExists not processed because Objects database not connected`);
|
|
3506
3517
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3507
3518
|
}
|
|
@@ -3514,7 +3525,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3514
3525
|
// check if object exists
|
|
3515
3526
|
let objExists;
|
|
3516
3527
|
try {
|
|
3517
|
-
objExists = await
|
|
3528
|
+
objExists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(id, options || {});
|
|
3518
3529
|
}
|
|
3519
3530
|
catch (e) {
|
|
3520
3531
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, `Could not check object existence of ${id}: ${e.message}`);
|
|
@@ -3822,7 +3833,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3822
3833
|
async _deleteDevice(_options) {
|
|
3823
3834
|
const { callback } = _options;
|
|
3824
3835
|
let { deviceName } = _options;
|
|
3825
|
-
if (!
|
|
3836
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3826
3837
|
this._logger.info(`${this.namespaceLog} deleteDevice not processed because Objects database not connected`);
|
|
3827
3838
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3828
3839
|
}
|
|
@@ -3870,7 +3881,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3870
3881
|
_addChannelToEnum(_options) {
|
|
3871
3882
|
const { addTo, options, callback } = _options;
|
|
3872
3883
|
let { enumName, parentDevice, channelName } = _options;
|
|
3873
|
-
if (!
|
|
3884
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3874
3885
|
this._logger.info(`${this.namespaceLog} addChannelToEnum not processed because Objects database not connected`);
|
|
3875
3886
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3876
3887
|
}
|
|
@@ -3889,7 +3900,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3889
3900
|
channelName = channelName.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
|
|
3890
3901
|
const objId = `${this.namespace}.${this._DCS2ID(parentDevice, channelName)}`;
|
|
3891
3902
|
if (addTo.startsWith('enum.')) {
|
|
3892
|
-
|
|
3903
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(addTo, options, (err, obj) => {
|
|
3893
3904
|
if (err) {
|
|
3894
3905
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
3895
3906
|
}
|
|
@@ -3899,7 +3910,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3899
3910
|
obj.from = `system.adapter.${this.namespace}`;
|
|
3900
3911
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
3901
3912
|
obj.ts = Date.now();
|
|
3902
|
-
|
|
3913
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
|
|
3903
3914
|
}
|
|
3904
3915
|
else {
|
|
3905
3916
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
@@ -3911,7 +3922,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3911
3922
|
if (enumName.startsWith('enum.')) {
|
|
3912
3923
|
enumName = enumName.substring(5);
|
|
3913
3924
|
}
|
|
3914
|
-
|
|
3925
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
|
|
3915
3926
|
if (err) {
|
|
3916
3927
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
3917
3928
|
}
|
|
@@ -3923,7 +3934,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3923
3934
|
obj.from = `system.adapter.${this.namespace}`;
|
|
3924
3935
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
3925
3936
|
obj.ts = Date.now();
|
|
3926
|
-
|
|
3937
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
|
|
3927
3938
|
}
|
|
3928
3939
|
else {
|
|
3929
3940
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
@@ -3931,7 +3942,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3931
3942
|
}
|
|
3932
3943
|
else {
|
|
3933
3944
|
// Create enum
|
|
3934
|
-
|
|
3945
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(`enum.${enumName}.${addTo}`, {
|
|
3935
3946
|
common: {
|
|
3936
3947
|
name: addTo,
|
|
3937
3948
|
members: [objId]
|
|
@@ -3962,7 +3973,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3962
3973
|
_deleteChannelFromEnum(_options) {
|
|
3963
3974
|
const { options, callback } = _options;
|
|
3964
3975
|
let { enumName, channelName, parentDevice } = _options;
|
|
3965
|
-
if (!
|
|
3976
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
3966
3977
|
this._logger.info(`${this.namespaceLog} deleteChannelFromEnum not processed because Objects database not connected`);
|
|
3967
3978
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
3968
3979
|
}
|
|
@@ -3987,7 +3998,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3987
3998
|
else {
|
|
3988
3999
|
enumName = 'enum.';
|
|
3989
4000
|
}
|
|
3990
|
-
|
|
4001
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
|
|
3991
4002
|
startkey: enumName,
|
|
3992
4003
|
endkey: `${enumName}\u9999`
|
|
3993
4004
|
}, options, async (err, res) => {
|
|
@@ -3998,7 +4009,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
3998
4009
|
if (res) {
|
|
3999
4010
|
for (const row of res.rows) {
|
|
4000
4011
|
try {
|
|
4001
|
-
const obj = (await
|
|
4012
|
+
const obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(row.id, options));
|
|
4002
4013
|
if ((_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.members) {
|
|
4003
4014
|
const pos = obj.common.members.indexOf(objId);
|
|
4004
4015
|
if (pos !== -1) {
|
|
@@ -4006,7 +4017,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4006
4017
|
obj.from = `system.adapter.${this.namespace}`;
|
|
4007
4018
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
4008
4019
|
obj.ts = Date.now();
|
|
4009
|
-
await
|
|
4020
|
+
await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(obj._id, obj, options);
|
|
4010
4021
|
}
|
|
4011
4022
|
}
|
|
4012
4023
|
}
|
|
@@ -4059,7 +4070,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4059
4070
|
async _deleteChannel(_options) {
|
|
4060
4071
|
const { callback } = _options;
|
|
4061
4072
|
let { channelName, parentDevice } = _options;
|
|
4062
|
-
if (!
|
|
4073
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4063
4074
|
this._logger.info(`${this.namespaceLog} deleteChannel not processed because Objects database not connected`);
|
|
4064
4075
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4065
4076
|
}
|
|
@@ -4201,11 +4212,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4201
4212
|
}
|
|
4202
4213
|
_getDevices(_options) {
|
|
4203
4214
|
const { options, callback } = _options;
|
|
4204
|
-
if (!
|
|
4215
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4205
4216
|
this._logger.info(`${this.namespaceLog} getDevices not processed because Objects database not connected`);
|
|
4206
4217
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4207
4218
|
}
|
|
4208
|
-
|
|
4219
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'device', {
|
|
4209
4220
|
startkey: `${this.namespace}.`,
|
|
4210
4221
|
endkey: `${this.namespace}.\u9999`
|
|
4211
4222
|
}, options, (err, obj) => {
|
|
@@ -4240,7 +4251,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4240
4251
|
return this._getChannelsOf({ parentDevice, options, callback });
|
|
4241
4252
|
}
|
|
4242
4253
|
_getChannelsOf(options) {
|
|
4243
|
-
if (!
|
|
4254
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4244
4255
|
this._logger.info(`${this.namespaceLog} getChannelsOf not processed because Objects database not connected`);
|
|
4245
4256
|
return js_controller_common_1.tools.maybeCallbackWithError(options.callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4246
4257
|
}
|
|
@@ -4252,7 +4263,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4252
4263
|
}
|
|
4253
4264
|
options.parentDevice = options.parentDevice.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
|
|
4254
4265
|
options.parentDevice = this.namespace + (options.parentDevice ? `.${options.parentDevice}` : '');
|
|
4255
|
-
|
|
4266
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'channel', {
|
|
4256
4267
|
startkey: `${options.parentDevice}.`,
|
|
4257
4268
|
endkey: `${options.parentDevice}.\u9999`
|
|
4258
4269
|
}, options.options || {}, (err, obj) => {
|
|
@@ -4300,7 +4311,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4300
4311
|
_getStatesOf(_options) {
|
|
4301
4312
|
const { options, callback } = _options;
|
|
4302
4313
|
let { parentDevice, parentChannel } = _options;
|
|
4303
|
-
if (!
|
|
4314
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4304
4315
|
this._logger.info(`${this.namespaceLog} getStatesOf not processed because Objects database not connected`);
|
|
4305
4316
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4306
4317
|
}
|
|
@@ -4324,7 +4335,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4324
4335
|
}
|
|
4325
4336
|
parentChannel = parentChannel.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
|
|
4326
4337
|
const id = `${this.namespace}.${this._DCS2ID(parentDevice, parentChannel, true)}`;
|
|
4327
|
-
|
|
4338
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'state', {
|
|
4328
4339
|
startkey: id,
|
|
4329
4340
|
endkey: `${id}\u9999`
|
|
4330
4341
|
}, options, (err, obj) => {
|
|
@@ -4335,7 +4346,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4335
4346
|
let read = 0;
|
|
4336
4347
|
for (const row of obj.rows) {
|
|
4337
4348
|
read++;
|
|
4338
|
-
|
|
4349
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(row.id, (err, subObj) => {
|
|
4339
4350
|
if (subObj) {
|
|
4340
4351
|
res.push(subObj);
|
|
4341
4352
|
}
|
|
@@ -4365,7 +4376,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4365
4376
|
_addStateToEnum(_options) {
|
|
4366
4377
|
const { addTo, options, callback } = _options;
|
|
4367
4378
|
let { enumName, parentDevice, parentChannel, stateName } = _options;
|
|
4368
|
-
if (!
|
|
4379
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4369
4380
|
this._logger.info(`${this.namespaceLog} addStateToEnum not processed because Objects database not connected`);
|
|
4370
4381
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4371
4382
|
}
|
|
@@ -4396,7 +4407,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4396
4407
|
stateName = stateName.replace(FORBIDDEN_CHARS, '_').replace(/\./g, '_');
|
|
4397
4408
|
const objId = this._utils.fixId({ device: parentDevice, channel: parentChannel, state: stateName });
|
|
4398
4409
|
if (addTo.startsWith('enum.')) {
|
|
4399
|
-
|
|
4410
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(addTo, options, (err, obj) => {
|
|
4400
4411
|
if (err || !obj) {
|
|
4401
4412
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err || js_controller_common_1.tools.ERRORS.ERROR_NOT_FOUND);
|
|
4402
4413
|
}
|
|
@@ -4405,7 +4416,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4405
4416
|
obj.from = `system.adapter.${this.namespace}`;
|
|
4406
4417
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
4407
4418
|
obj.ts = Date.now();
|
|
4408
|
-
|
|
4419
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, options, callback);
|
|
4409
4420
|
}
|
|
4410
4421
|
else {
|
|
4411
4422
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
@@ -4416,7 +4427,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4416
4427
|
if (enumName.startsWith('enum.')) {
|
|
4417
4428
|
enumName = enumName.substring(5);
|
|
4418
4429
|
}
|
|
4419
|
-
|
|
4430
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`enum.${enumName}.${addTo}`, options, (err, obj) => {
|
|
4420
4431
|
if (!err && obj) {
|
|
4421
4432
|
// @ts-expect-error cast to enum object
|
|
4422
4433
|
if (!obj.common.members.includes(objId)) {
|
|
@@ -4424,7 +4435,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4424
4435
|
obj.from = `system.adapter.${this.namespace}`;
|
|
4425
4436
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
4426
4437
|
obj.ts = Date.now();
|
|
4427
|
-
|
|
4438
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(obj._id, obj, callback);
|
|
4428
4439
|
}
|
|
4429
4440
|
else {
|
|
4430
4441
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
@@ -4435,7 +4446,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4435
4446
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
4436
4447
|
}
|
|
4437
4448
|
// Create enum
|
|
4438
|
-
|
|
4449
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(`enum.${enumName}.${addTo}`, {
|
|
4439
4450
|
common: {
|
|
4440
4451
|
name: addTo,
|
|
4441
4452
|
members: [objId]
|
|
@@ -4467,7 +4478,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4467
4478
|
_deleteStateFromEnum(_options) {
|
|
4468
4479
|
const { options, callback } = _options;
|
|
4469
4480
|
let { enumName, parentDevice, parentChannel, stateName } = _options;
|
|
4470
|
-
if (!
|
|
4481
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4471
4482
|
this._logger.info(`${this.namespaceLog} deleteStateFromEnum not processed because Objects database not connected`);
|
|
4472
4483
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4473
4484
|
}
|
|
@@ -4507,7 +4518,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4507
4518
|
else {
|
|
4508
4519
|
enumName = 'enum.';
|
|
4509
4520
|
}
|
|
4510
|
-
|
|
4521
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'enum', {
|
|
4511
4522
|
startkey: enumName,
|
|
4512
4523
|
endkey: `${enumName}\u9999`
|
|
4513
4524
|
}, options, async (err, res) => {
|
|
@@ -4516,7 +4527,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4516
4527
|
}
|
|
4517
4528
|
for (const row of res.rows) {
|
|
4518
4529
|
try {
|
|
4519
|
-
const obj = await
|
|
4530
|
+
const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(row.id);
|
|
4520
4531
|
if (obj && obj.common && obj.common.members) {
|
|
4521
4532
|
const pos = obj.common.members.indexOf(objId);
|
|
4522
4533
|
if (pos !== -1) {
|
|
@@ -4524,7 +4535,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4524
4535
|
obj.from = `system.adapter.${this.namespace}`;
|
|
4525
4536
|
obj.user = (options === null || options === void 0 ? void 0 : options.user) || constants_1.SYSTEM_ADMIN_USER;
|
|
4526
4537
|
obj.ts = Date.now();
|
|
4527
|
-
await
|
|
4538
|
+
await __classPrivateFieldGet(this, _AdapterClass_objects, "f").setObjectAsync(obj._id, obj);
|
|
4528
4539
|
}
|
|
4529
4540
|
}
|
|
4530
4541
|
}
|
|
@@ -4564,11 +4575,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4564
4575
|
callback = options;
|
|
4565
4576
|
options = null;
|
|
4566
4577
|
}
|
|
4567
|
-
if (!
|
|
4578
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4568
4579
|
this._logger.info(`${this.namespaceLog} chmodFile not processed because Objects database not connected`);
|
|
4569
4580
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4570
4581
|
}
|
|
4571
|
-
|
|
4582
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").chmodFile(_adapter, path, options, callback);
|
|
4572
4583
|
}
|
|
4573
4584
|
/**
|
|
4574
4585
|
* Change a file owner
|
|
@@ -4599,11 +4610,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4599
4610
|
callback = options;
|
|
4600
4611
|
options = null;
|
|
4601
4612
|
}
|
|
4602
|
-
if (!
|
|
4613
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4603
4614
|
this._logger.info(`${this.namespaceLog} chownFile not processed because Objects database not connected`);
|
|
4604
4615
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4605
4616
|
}
|
|
4606
|
-
|
|
4617
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").chownFile(_adapter, path, options, callback);
|
|
4607
4618
|
}
|
|
4608
4619
|
/**
|
|
4609
4620
|
* Read directory from DB.
|
|
@@ -4654,11 +4665,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4654
4665
|
if (options !== null && options !== undefined) {
|
|
4655
4666
|
validator_1.Validator.assertObject(options, 'options');
|
|
4656
4667
|
}
|
|
4657
|
-
if (!
|
|
4668
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4658
4669
|
this._logger.info(`${this.namespaceLog} readDir not processed because Objects database not connected`);
|
|
4659
4670
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4660
4671
|
}
|
|
4661
|
-
|
|
4672
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").readDir(_adapter, path, options, callback);
|
|
4662
4673
|
}
|
|
4663
4674
|
unlink(_adapter, name, options, callback) {
|
|
4664
4675
|
if (_adapter === null) {
|
|
@@ -4674,11 +4685,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4674
4685
|
if (options !== undefined && options !== null) {
|
|
4675
4686
|
validator_1.Validator.assertObject(options, 'options');
|
|
4676
4687
|
}
|
|
4677
|
-
if (!
|
|
4688
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4678
4689
|
this._logger.info(`${this.namespaceLog} unlink not processed because Objects database not connected`);
|
|
4679
4690
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4680
4691
|
}
|
|
4681
|
-
|
|
4692
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").unlink(_adapter, name, options, callback);
|
|
4682
4693
|
}
|
|
4683
4694
|
rename(_adapter, oldName, newName, options, callback) {
|
|
4684
4695
|
if (_adapter === null) {
|
|
@@ -4695,11 +4706,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4695
4706
|
if (options !== null && options !== undefined) {
|
|
4696
4707
|
validator_1.Validator.assertObject(options, 'options');
|
|
4697
4708
|
}
|
|
4698
|
-
if (!
|
|
4709
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4699
4710
|
this._logger.info(`${this.namespaceLog} rename not processed because Objects database not connected`);
|
|
4700
4711
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4701
4712
|
}
|
|
4702
|
-
|
|
4713
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").rename(_adapter, oldName, newName, options, callback);
|
|
4703
4714
|
}
|
|
4704
4715
|
mkdir(_adapter, dirname, options, callback) {
|
|
4705
4716
|
if (_adapter === null) {
|
|
@@ -4715,11 +4726,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4715
4726
|
if (options !== undefined && options !== null) {
|
|
4716
4727
|
validator_1.Validator.assertObject(options, 'options');
|
|
4717
4728
|
}
|
|
4718
|
-
if (!
|
|
4729
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4719
4730
|
this._logger.info(`${this.namespaceLog} mkdir not processed because Objects database not connected`);
|
|
4720
4731
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4721
4732
|
}
|
|
4722
|
-
|
|
4733
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").mkdir(_adapter, dirname, options, callback);
|
|
4723
4734
|
}
|
|
4724
4735
|
/**
|
|
4725
4736
|
* Read file from DB.
|
|
@@ -4757,11 +4768,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4757
4768
|
validator_1.Validator.assertObject(options, 'options');
|
|
4758
4769
|
}
|
|
4759
4770
|
validator_1.Validator.assertCallback(callback, 'callback');
|
|
4760
|
-
if (!
|
|
4771
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4761
4772
|
this._logger.info(`${this.namespaceLog} readFile not processed because Objects database not connected`);
|
|
4762
4773
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4763
4774
|
}
|
|
4764
|
-
|
|
4775
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").readFile(_adapter, filename, options, callback);
|
|
4765
4776
|
}
|
|
4766
4777
|
/**
|
|
4767
4778
|
* Write file to DB.
|
|
@@ -4801,11 +4812,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4801
4812
|
if (typeof data !== 'string') {
|
|
4802
4813
|
validator_1.Validator.assertBuffer(data, 'data');
|
|
4803
4814
|
}
|
|
4804
|
-
if (!
|
|
4815
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4805
4816
|
this._logger.info(`${this.namespaceLog} writeFile not processed because Objects database not connected`);
|
|
4806
4817
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4807
4818
|
}
|
|
4808
|
-
return
|
|
4819
|
+
return __classPrivateFieldGet(this, _AdapterClass_objects, "f").writeFile(_adapter, filename, data, options, callback);
|
|
4809
4820
|
}
|
|
4810
4821
|
/**
|
|
4811
4822
|
* Checks if file exists in DB.
|
|
@@ -4826,12 +4837,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
4826
4837
|
if (options !== null && options !== undefined) {
|
|
4827
4838
|
validator_1.Validator.assertObject(options, 'options');
|
|
4828
4839
|
}
|
|
4829
|
-
if (!
|
|
4840
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
4830
4841
|
this._logger.info(`${this.namespaceLog} fileExists not processed because Objects database not connected`);
|
|
4831
4842
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
4832
4843
|
}
|
|
4833
4844
|
try {
|
|
4834
|
-
const exists = await
|
|
4845
|
+
const exists = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").fileExists(_adapter, filename, options);
|
|
4835
4846
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, null, exists);
|
|
4836
4847
|
}
|
|
4837
4848
|
catch (e) {
|
|
@@ -5085,7 +5096,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5085
5096
|
if (!instanceName.startsWith('system.adapter.')) {
|
|
5086
5097
|
instanceName = `system.adapter.${instanceName}`;
|
|
5087
5098
|
}
|
|
5088
|
-
if (!
|
|
5099
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5089
5100
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5090
5101
|
this._logger.info(`${this.namespaceLog} sendTo not processed because States database not connected`);
|
|
5091
5102
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5099,21 +5110,21 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5099
5110
|
}
|
|
5100
5111
|
// If not specific instance
|
|
5101
5112
|
if (!instanceName.match(/\.[0-9]+$/)) {
|
|
5102
|
-
if (!
|
|
5113
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5103
5114
|
this._logger.info(`${this.namespaceLog} sendTo not processed because Objects database not connected`);
|
|
5104
5115
|
// @ts-expect-error TODO it could also be the cb object
|
|
5105
5116
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5106
5117
|
}
|
|
5107
5118
|
try {
|
|
5108
5119
|
// Send to all instances of adapter
|
|
5109
|
-
const res = await
|
|
5120
|
+
const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'instance', {
|
|
5110
5121
|
startkey: `${instanceName}.`,
|
|
5111
5122
|
endkey: `${instanceName}.\u9999`
|
|
5112
5123
|
});
|
|
5113
5124
|
if (res) {
|
|
5114
5125
|
for (const row of res.rows) {
|
|
5115
5126
|
try {
|
|
5116
|
-
await
|
|
5127
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(row.id, obj);
|
|
5117
5128
|
}
|
|
5118
5129
|
catch (e) {
|
|
5119
5130
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5132,7 +5143,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5132
5143
|
// force subscribe even no messagebox enabled
|
|
5133
5144
|
if (!(0, utils_1.isMessageboxSupported)(this.common) && !this.mboxSubscribed) {
|
|
5134
5145
|
this.mboxSubscribed = true;
|
|
5135
|
-
|
|
5146
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
|
|
5136
5147
|
}
|
|
5137
5148
|
obj.callback = {
|
|
5138
5149
|
message: message,
|
|
@@ -5169,7 +5180,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5169
5180
|
}
|
|
5170
5181
|
}
|
|
5171
5182
|
try {
|
|
5172
|
-
await
|
|
5183
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(instanceName, obj);
|
|
5173
5184
|
}
|
|
5174
5185
|
catch (e) {
|
|
5175
5186
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5217,7 +5228,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5217
5228
|
const { command, message, callback } = _options;
|
|
5218
5229
|
let { hostName } = _options;
|
|
5219
5230
|
const obj = { command, message, from: `system.adapter.${this.namespace}` };
|
|
5220
|
-
if (!
|
|
5231
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5221
5232
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5222
5233
|
this._logger.info(`${this.namespaceLog} sendToHost not processed because States database not connected`);
|
|
5223
5234
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5227,17 +5238,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5227
5238
|
hostName = `system.host.${hostName}`;
|
|
5228
5239
|
}
|
|
5229
5240
|
if (!hostName) {
|
|
5230
|
-
if (!
|
|
5241
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5231
5242
|
this._logger.info(`${this.namespaceLog} sendToHost not processed because Objects database not connected`);
|
|
5232
5243
|
// @ts-expect-error TODO it could also be the cb object
|
|
5233
5244
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5234
5245
|
}
|
|
5235
5246
|
// Send to all hosts
|
|
5236
|
-
|
|
5247
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectList({
|
|
5237
5248
|
startkey: 'system.host.',
|
|
5238
5249
|
endkey: `system.host.\u9999`
|
|
5239
5250
|
}, null, async (err, res) => {
|
|
5240
|
-
if (!
|
|
5251
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5241
5252
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5242
5253
|
return;
|
|
5243
5254
|
}
|
|
@@ -5247,7 +5258,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5247
5258
|
// ignore system.host.name.alive and so on
|
|
5248
5259
|
if (parts.length === 3) {
|
|
5249
5260
|
try {
|
|
5250
|
-
await
|
|
5261
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(row.id, obj);
|
|
5251
5262
|
}
|
|
5252
5263
|
catch (e) {
|
|
5253
5264
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5264,7 +5275,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5264
5275
|
// force subscribe even no messagebox enabled
|
|
5265
5276
|
if (!(0, utils_1.isMessageboxSupported)(this.common) && !this.mboxSubscribed) {
|
|
5266
5277
|
this.mboxSubscribed = true;
|
|
5267
|
-
|
|
5278
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
|
|
5268
5279
|
}
|
|
5269
5280
|
obj.callback = {
|
|
5270
5281
|
message,
|
|
@@ -5283,7 +5294,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5283
5294
|
}
|
|
5284
5295
|
}
|
|
5285
5296
|
try {
|
|
5286
|
-
await
|
|
5297
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(hostName, obj);
|
|
5287
5298
|
}
|
|
5288
5299
|
catch (e) {
|
|
5289
5300
|
// @ts-expect-error TODO it could also be the cb object
|
|
@@ -5297,21 +5308,21 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5297
5308
|
* @param options clientId and data options
|
|
5298
5309
|
*/
|
|
5299
5310
|
sendToUI(options) {
|
|
5300
|
-
if (!
|
|
5311
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5301
5312
|
throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5302
5313
|
}
|
|
5303
5314
|
const { clientId, data } = options;
|
|
5304
5315
|
if (clientId === undefined) {
|
|
5305
5316
|
return this.uiMessagingController.sendToAllClients({
|
|
5306
5317
|
data,
|
|
5307
|
-
states:
|
|
5318
|
+
states: __classPrivateFieldGet(this, _AdapterClass_states, "f")
|
|
5308
5319
|
});
|
|
5309
5320
|
}
|
|
5310
5321
|
validator_1.Validator.assertString(clientId, 'clientId');
|
|
5311
5322
|
return this.uiMessagingController.sendToClient({
|
|
5312
5323
|
clientId,
|
|
5313
5324
|
data,
|
|
5314
|
-
states:
|
|
5325
|
+
states: __classPrivateFieldGet(this, _AdapterClass_states, "f")
|
|
5315
5326
|
});
|
|
5316
5327
|
}
|
|
5317
5328
|
/**
|
|
@@ -5322,7 +5333,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5322
5333
|
* @param message - message to be stored/checked
|
|
5323
5334
|
*/
|
|
5324
5335
|
async registerNotification(scope, category, message) {
|
|
5325
|
-
if (!
|
|
5336
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5326
5337
|
// if states is no longer existing, we do not need to set
|
|
5327
5338
|
this._logger.info(`${this.namespaceLog} registerNotification not processed because States database not connected`);
|
|
5328
5339
|
throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -5337,7 +5348,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5337
5348
|
message: { scope, category, message, instance: this.namespace },
|
|
5338
5349
|
from: `system.adapter.${this.namespace}`
|
|
5339
5350
|
};
|
|
5340
|
-
await
|
|
5351
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").pushMessage(`system.host.${this.host}`, obj);
|
|
5341
5352
|
}
|
|
5342
5353
|
/**
|
|
5343
5354
|
* Writes value into states DB.
|
|
@@ -5400,12 +5411,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5400
5411
|
async _setState(_options) {
|
|
5401
5412
|
const { state, ack, options, callback } = _options;
|
|
5402
5413
|
const { id } = _options;
|
|
5403
|
-
if (!
|
|
5414
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5404
5415
|
// if states is no longer existing, we do not need to set
|
|
5405
5416
|
this._logger.info(`${this.namespaceLog} setState not processed because States database not connected`);
|
|
5406
5417
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5407
5418
|
}
|
|
5408
|
-
if (!
|
|
5419
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5409
5420
|
this._logger.info(`${this.namespaceLog} setState not processed because Objects database not connected`);
|
|
5410
5421
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5411
5422
|
}
|
|
@@ -5455,13 +5466,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5455
5466
|
obj = (await this._checkStates(fixedId, options || {}, 'setState')).objs[0];
|
|
5456
5467
|
}
|
|
5457
5468
|
else {
|
|
5458
|
-
obj = (await
|
|
5469
|
+
obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(fixedId, options));
|
|
5459
5470
|
}
|
|
5460
5471
|
}
|
|
5461
5472
|
catch (e) {
|
|
5462
5473
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
5463
5474
|
}
|
|
5464
|
-
if (!
|
|
5475
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5465
5476
|
// if objects is no longer existing, we do not need to unsubscribe
|
|
5466
5477
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
|
|
5467
5478
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -5495,20 +5506,20 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5495
5506
|
targetObj = (await this._checkStates(aliasId, options || {}, 'setState')).objs[0];
|
|
5496
5507
|
}
|
|
5497
5508
|
else {
|
|
5498
|
-
targetObj = (await
|
|
5509
|
+
targetObj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options));
|
|
5499
5510
|
}
|
|
5500
5511
|
}
|
|
5501
5512
|
catch (e) {
|
|
5502
5513
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
5503
5514
|
}
|
|
5504
|
-
if (!
|
|
5515
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5505
5516
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5506
5517
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
5507
5518
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5508
5519
|
}
|
|
5509
5520
|
// write target state
|
|
5510
5521
|
this.outputCount++;
|
|
5511
|
-
return
|
|
5522
|
+
return __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
|
|
5512
5523
|
sourceCommon: obj === null || obj === void 0 ? void 0 : obj.common,
|
|
5513
5524
|
targetCommon: targetObj === null || targetObj === void 0 ? void 0 : targetObj.common,
|
|
5514
5525
|
state: stateObj,
|
|
@@ -5524,13 +5535,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5524
5535
|
}
|
|
5525
5536
|
}
|
|
5526
5537
|
else {
|
|
5527
|
-
if (!
|
|
5538
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5528
5539
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5529
5540
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
5530
5541
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5531
5542
|
}
|
|
5532
5543
|
this.outputCount++;
|
|
5533
|
-
return
|
|
5544
|
+
return __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(fixedId, stateObj, callback);
|
|
5534
5545
|
}
|
|
5535
5546
|
}
|
|
5536
5547
|
// Cache will be cleared if user or group changes. Important! only if subscribed.
|
|
@@ -5786,11 +5797,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5786
5797
|
originalChecked = options.checked;
|
|
5787
5798
|
}
|
|
5788
5799
|
options.checked = true;
|
|
5789
|
-
if (!
|
|
5800
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5790
5801
|
this._logger.info(`${this.namespaceLog} checkStates not processed because Objects database not connected`);
|
|
5791
5802
|
throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5792
5803
|
}
|
|
5793
|
-
const obj = (await
|
|
5804
|
+
const obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options));
|
|
5794
5805
|
objs.push(obj);
|
|
5795
5806
|
if (originalChecked !== undefined) {
|
|
5796
5807
|
options.checked = originalChecked;
|
|
@@ -5820,7 +5831,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5820
5831
|
}
|
|
5821
5832
|
}
|
|
5822
5833
|
async _setStateChangedHelper(id, state) {
|
|
5823
|
-
if (!
|
|
5834
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
5824
5835
|
this._logger.info(`${this.namespaceLog} setStateChanged not processed because Objects database not connected`);
|
|
5825
5836
|
throw new Error(js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
5826
5837
|
}
|
|
@@ -5828,7 +5839,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5828
5839
|
let obj;
|
|
5829
5840
|
let err;
|
|
5830
5841
|
try {
|
|
5831
|
-
obj = await
|
|
5842
|
+
obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id);
|
|
5832
5843
|
}
|
|
5833
5844
|
catch (e) {
|
|
5834
5845
|
err = e;
|
|
@@ -5880,7 +5891,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5880
5891
|
await this._utils.performStrictObjectCheck(id, state);
|
|
5881
5892
|
}
|
|
5882
5893
|
this.outputCount++;
|
|
5883
|
-
await
|
|
5894
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state);
|
|
5884
5895
|
return { id, notChanged: false };
|
|
5885
5896
|
}
|
|
5886
5897
|
else {
|
|
@@ -5936,7 +5947,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
5936
5947
|
}
|
|
5937
5948
|
async _setStateChanged(_options) {
|
|
5938
5949
|
const { id, ack, options, callback, state } = _options;
|
|
5939
|
-
if (!
|
|
5950
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
5940
5951
|
// if states is no longer existing, we do not need to unsubscribe
|
|
5941
5952
|
this._logger.info(`${this.namespaceLog} setStateChanged not processed because States database not connected`);
|
|
5942
5953
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6037,7 +6048,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6037
6048
|
callback = ack;
|
|
6038
6049
|
ack = undefined;
|
|
6039
6050
|
}
|
|
6040
|
-
if (!
|
|
6051
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6041
6052
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6042
6053
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6043
6054
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6088,7 +6099,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6088
6099
|
catch (e) {
|
|
6089
6100
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
6090
6101
|
}
|
|
6091
|
-
if (!
|
|
6102
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6092
6103
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6093
6104
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6094
6105
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6123,13 +6134,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6123
6134
|
catch (e) {
|
|
6124
6135
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
6125
6136
|
}
|
|
6126
|
-
if (!
|
|
6137
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6127
6138
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6128
6139
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6129
6140
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6130
6141
|
}
|
|
6131
6142
|
this.outputCount++;
|
|
6132
|
-
|
|
6143
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
|
|
6133
6144
|
sourceCommon: obj === null || obj === void 0 ? void 0 : obj.common,
|
|
6134
6145
|
targetCommon: targetObj && targetObj.common,
|
|
6135
6146
|
state,
|
|
@@ -6145,24 +6156,24 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6145
6156
|
}
|
|
6146
6157
|
}
|
|
6147
6158
|
else {
|
|
6148
|
-
if (!
|
|
6159
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6149
6160
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6150
6161
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6151
6162
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6152
6163
|
}
|
|
6153
6164
|
this.outputCount++;
|
|
6154
|
-
|
|
6165
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state, callback);
|
|
6155
6166
|
}
|
|
6156
6167
|
}
|
|
6157
6168
|
else {
|
|
6158
6169
|
// write alias
|
|
6159
6170
|
if (id.startsWith(constants_1.ALIAS_STARTS_WITH)) {
|
|
6160
|
-
if (!
|
|
6171
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
6161
6172
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
|
|
6162
6173
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6163
6174
|
}
|
|
6164
6175
|
// read alias id
|
|
6165
|
-
|
|
6176
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options, (err, obj) => {
|
|
6166
6177
|
var _a, _b;
|
|
6167
6178
|
// @ts-expect-error
|
|
6168
6179
|
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) {
|
|
@@ -6181,20 +6192,20 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6181
6192
|
this._logger.warn(`${this.namespaceLog} Error validating alias id of ${id}: ${e.message}`);
|
|
6182
6193
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, `Error validating alias id of ${id}: ${e.message}`);
|
|
6183
6194
|
}
|
|
6184
|
-
if (!
|
|
6195
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
6185
6196
|
// if objects is no longer existing, we do not need to unsubscribe
|
|
6186
6197
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
|
|
6187
6198
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6188
6199
|
}
|
|
6189
6200
|
// read object for formatting
|
|
6190
|
-
|
|
6191
|
-
if (!
|
|
6201
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options, (err, targetObj) => {
|
|
6202
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6192
6203
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6193
6204
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6194
6205
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6195
6206
|
}
|
|
6196
6207
|
this.outputCount++;
|
|
6197
|
-
|
|
6208
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(aliasId, js_controller_common_1.tools.formatAliasValue({
|
|
6198
6209
|
sourceCommon: obj.common,
|
|
6199
6210
|
targetCommon: targetObj === null || targetObj === void 0 ? void 0 : targetObj.common,
|
|
6200
6211
|
state,
|
|
@@ -6213,7 +6224,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6213
6224
|
}
|
|
6214
6225
|
else {
|
|
6215
6226
|
if (this.performStrictObjectChecks) {
|
|
6216
|
-
if (!
|
|
6227
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
6217
6228
|
// if objects is no longer existing, we do not need to unsubscribe
|
|
6218
6229
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because Objects database not connected`);
|
|
6219
6230
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6221,13 +6232,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6221
6232
|
// validate that object exists, read-only logic ok, type ok, etc. won't throw now
|
|
6222
6233
|
await this._utils.performStrictObjectCheck(id, state);
|
|
6223
6234
|
}
|
|
6224
|
-
if (!
|
|
6235
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6225
6236
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6226
6237
|
this._logger.info(`${this.namespaceLog} setForeignState not processed because States database not connected`);
|
|
6227
6238
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6228
6239
|
}
|
|
6229
6240
|
this.outputCount++;
|
|
6230
|
-
|
|
6241
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(id, state, callback);
|
|
6231
6242
|
}
|
|
6232
6243
|
}
|
|
6233
6244
|
}
|
|
@@ -6275,7 +6286,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6275
6286
|
callback = ack;
|
|
6276
6287
|
ack = undefined;
|
|
6277
6288
|
}
|
|
6278
|
-
if (!
|
|
6289
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6279
6290
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6280
6291
|
this._logger.info(`${this.namespaceLog} setForeignStateChanged not processed because States database not connected`);
|
|
6281
6292
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6384,12 +6395,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6384
6395
|
}
|
|
6385
6396
|
async _getForeignState(_options) {
|
|
6386
6397
|
const { id, options, callback } = _options;
|
|
6387
|
-
if (!
|
|
6398
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6388
6399
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6389
6400
|
this._logger.info(`${this.namespaceLog} getForeignState not processed because States database not connected`);
|
|
6390
6401
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6391
6402
|
}
|
|
6392
|
-
if (!
|
|
6403
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
6393
6404
|
this._logger.info(`${this.namespaceLog} getForeignState not processed because Objects database not connected`);
|
|
6394
6405
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6395
6406
|
}
|
|
@@ -6409,7 +6420,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6409
6420
|
obj = (await this._checkStates(id, options || {}, 'getState')).objs[0];
|
|
6410
6421
|
}
|
|
6411
6422
|
else {
|
|
6412
|
-
obj = (await
|
|
6423
|
+
obj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(id, options));
|
|
6413
6424
|
}
|
|
6414
6425
|
}
|
|
6415
6426
|
catch (e) {
|
|
@@ -6440,7 +6451,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6440
6451
|
sourceObj = (await this._checkStates(aliasId, options || {}, 'getState')).objs[0];
|
|
6441
6452
|
}
|
|
6442
6453
|
else {
|
|
6443
|
-
sourceObj = (await
|
|
6454
|
+
sourceObj = (await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(aliasId, options));
|
|
6444
6455
|
}
|
|
6445
6456
|
}
|
|
6446
6457
|
catch (e) {
|
|
@@ -6454,7 +6465,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6454
6465
|
this.inputCount++;
|
|
6455
6466
|
try {
|
|
6456
6467
|
// @ts-expect-error void return possible fix it
|
|
6457
|
-
state = await
|
|
6468
|
+
state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(aliasId);
|
|
6458
6469
|
}
|
|
6459
6470
|
catch (e) {
|
|
6460
6471
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
@@ -6481,7 +6492,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6481
6492
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, null, this.oStates[id]);
|
|
6482
6493
|
}
|
|
6483
6494
|
else {
|
|
6484
|
-
return
|
|
6495
|
+
return __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(id, callback);
|
|
6485
6496
|
}
|
|
6486
6497
|
}
|
|
6487
6498
|
}
|
|
@@ -6508,7 +6519,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6508
6519
|
let _obj;
|
|
6509
6520
|
// read all adapters
|
|
6510
6521
|
try {
|
|
6511
|
-
_obj = await
|
|
6522
|
+
_obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'instance', {
|
|
6512
6523
|
startkey: 'system.adapter.',
|
|
6513
6524
|
endkey: 'system.adapter.\u9999'
|
|
6514
6525
|
});
|
|
@@ -6704,7 +6715,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6704
6715
|
}
|
|
6705
6716
|
async _delForeignState(_options) {
|
|
6706
6717
|
const { id, options, callback } = _options;
|
|
6707
|
-
if (!
|
|
6718
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6708
6719
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6709
6720
|
this._logger.info(`${this.namespaceLog} delForeignState not processed because States database not connected`);
|
|
6710
6721
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6723,7 +6734,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6723
6734
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
6724
6735
|
}
|
|
6725
6736
|
}
|
|
6726
|
-
|
|
6737
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").delState(id, callback);
|
|
6727
6738
|
}
|
|
6728
6739
|
/**
|
|
6729
6740
|
* Read all states of this adapter, that pass the pattern
|
|
@@ -6756,7 +6767,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6756
6767
|
}
|
|
6757
6768
|
async _processStatesSecondary(keys, targetObjs, srcObjs) {
|
|
6758
6769
|
var _a;
|
|
6759
|
-
const arr = await
|
|
6770
|
+
const arr = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys);
|
|
6760
6771
|
const result = {};
|
|
6761
6772
|
for (let i = 0; i < keys.length; i++) {
|
|
6762
6773
|
const obj = targetObjs && targetObjs[i];
|
|
@@ -6872,12 +6883,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6872
6883
|
}
|
|
6873
6884
|
async _getForeignStates(_options) {
|
|
6874
6885
|
const { options, pattern, callback } = _options;
|
|
6875
|
-
if (!
|
|
6886
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
6876
6887
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6877
6888
|
this._logger.info(`${this.namespaceLog} getForeignStates not processed because States database not connected`);
|
|
6878
6889
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
6879
6890
|
}
|
|
6880
|
-
if (!
|
|
6891
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
6881
6892
|
// if states is no longer existing, we do not need to unsubscribe
|
|
6882
6893
|
this._logger.info(`${this.namespaceLog} getForeignStates not processed because Objects database not connected`);
|
|
6883
6894
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -6916,7 +6927,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6916
6927
|
// in special maintenance mode, just returns all states. Aliases are not supported in this mode
|
|
6917
6928
|
if (options.user === constants_1.SYSTEM_ADMIN_USER && options.maintenance) {
|
|
6918
6929
|
try {
|
|
6919
|
-
const keys = await
|
|
6930
|
+
const keys = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(pattern);
|
|
6920
6931
|
const res = await this._processStatesSecondary(keys || [], null, null);
|
|
6921
6932
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, null, res);
|
|
6922
6933
|
}
|
|
@@ -6925,7 +6936,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
6925
6936
|
}
|
|
6926
6937
|
}
|
|
6927
6938
|
try {
|
|
6928
|
-
const res = await
|
|
6939
|
+
const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectView('system', 'state', params, options);
|
|
6929
6940
|
if (originalChecked !== undefined) {
|
|
6930
6941
|
options.checked = originalChecked;
|
|
6931
6942
|
}
|
|
@@ -7009,8 +7020,8 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7009
7020
|
if (!aliasDetails.source) {
|
|
7010
7021
|
let sourceObj;
|
|
7011
7022
|
try {
|
|
7012
|
-
await
|
|
7013
|
-
sourceObj = await
|
|
7023
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(sourceId);
|
|
7024
|
+
sourceObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(sourceId, this._options);
|
|
7014
7025
|
}
|
|
7015
7026
|
catch (e) {
|
|
7016
7027
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
@@ -7058,7 +7069,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7058
7069
|
// @ts-expect-error
|
|
7059
7070
|
if (!this.aliases.get(sourceId).targets.length) {
|
|
7060
7071
|
this.aliases.delete(sourceId);
|
|
7061
|
-
await
|
|
7072
|
+
await __classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribe(sourceId);
|
|
7062
7073
|
}
|
|
7063
7074
|
}
|
|
7064
7075
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
@@ -7095,12 +7106,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7095
7106
|
const { pattern, options, callback } = _options;
|
|
7096
7107
|
// Todo check rights for options
|
|
7097
7108
|
await this._autoSubscribeOn();
|
|
7098
|
-
if (!
|
|
7109
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7099
7110
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7100
7111
|
this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because States database not connected`);
|
|
7101
7112
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7102
7113
|
}
|
|
7103
|
-
if (!
|
|
7114
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
7104
7115
|
this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because Objects database not connected`);
|
|
7105
7116
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7106
7117
|
}
|
|
@@ -7110,7 +7121,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7110
7121
|
// put this pattern into adapter list
|
|
7111
7122
|
let state;
|
|
7112
7123
|
try {
|
|
7113
|
-
state = await
|
|
7124
|
+
state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${autoSubEntry}.subscribes`);
|
|
7114
7125
|
}
|
|
7115
7126
|
catch {
|
|
7116
7127
|
// ignore
|
|
@@ -7136,7 +7147,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7136
7147
|
}
|
|
7137
7148
|
subs[pattern][this.namespace]++;
|
|
7138
7149
|
this.outputCount++;
|
|
7139
|
-
|
|
7150
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${autoSubEntry}.subscribes`, JSON.stringify(subs));
|
|
7140
7151
|
}
|
|
7141
7152
|
}
|
|
7142
7153
|
if (Array.isArray(pattern)) {
|
|
@@ -7159,7 +7170,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7159
7170
|
if (aliasesIds.length) {
|
|
7160
7171
|
if (!this._aliasObjectsSubscribed) {
|
|
7161
7172
|
this._aliasObjectsSubscribed = true;
|
|
7162
|
-
|
|
7173
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
|
|
7163
7174
|
}
|
|
7164
7175
|
const aliasObjs = await this._getObjectsByArray(aliasesIds, null, options);
|
|
7165
7176
|
for (const aliasObj of aliasObjs) {
|
|
@@ -7171,7 +7182,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7171
7182
|
}
|
|
7172
7183
|
if (nonAliasesIds.length) {
|
|
7173
7184
|
for (const id of nonAliasesIds) {
|
|
7174
|
-
promises.push(new Promise(resolve =>
|
|
7185
|
+
promises.push(new Promise(resolve => __classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(id, resolve)));
|
|
7175
7186
|
}
|
|
7176
7187
|
}
|
|
7177
7188
|
try {
|
|
@@ -7186,7 +7197,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7186
7197
|
if (pattern === '*' || pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
|
|
7187
7198
|
if (!this._aliasObjectsSubscribed) {
|
|
7188
7199
|
this._aliasObjectsSubscribed = true;
|
|
7189
|
-
|
|
7200
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
|
|
7190
7201
|
}
|
|
7191
7202
|
// read all aliases
|
|
7192
7203
|
try {
|
|
@@ -7211,7 +7222,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7211
7222
|
catch (e) {
|
|
7212
7223
|
this._logger.error(`${this.namespaceLog} Error on "subscribeForeignStates": ${e.message}`);
|
|
7213
7224
|
}
|
|
7214
|
-
if (!
|
|
7225
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7215
7226
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7216
7227
|
this._logger.info(`${this.namespaceLog} subscribeForeignStates not processed because States database not connected`);
|
|
7217
7228
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -7221,7 +7232,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7221
7232
|
}
|
|
7222
7233
|
else {
|
|
7223
7234
|
// no alias objects found or pattern *
|
|
7224
|
-
|
|
7235
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
|
|
7225
7236
|
}
|
|
7226
7237
|
}
|
|
7227
7238
|
catch (e) {
|
|
@@ -7230,13 +7241,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7230
7241
|
}
|
|
7231
7242
|
}
|
|
7232
7243
|
else {
|
|
7233
|
-
|
|
7244
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
|
|
7234
7245
|
}
|
|
7235
7246
|
}
|
|
7236
7247
|
else if (pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
|
|
7237
7248
|
if (!this._aliasObjectsSubscribed) {
|
|
7238
7249
|
this._aliasObjectsSubscribed = true;
|
|
7239
|
-
|
|
7250
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
|
|
7240
7251
|
}
|
|
7241
7252
|
// aliases['sourceId'] = {
|
|
7242
7253
|
// source: {common attributes},
|
|
@@ -7253,7 +7264,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7253
7264
|
// };
|
|
7254
7265
|
// just read one alias Object
|
|
7255
7266
|
try {
|
|
7256
|
-
const aliasObj = await
|
|
7267
|
+
const aliasObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(pattern, options);
|
|
7257
7268
|
if (aliasObj) {
|
|
7258
7269
|
// cb will be called, but await for catching promisified part
|
|
7259
7270
|
await this._addAliasSubscribe(aliasObj, pattern, callback);
|
|
@@ -7267,7 +7278,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7267
7278
|
}
|
|
7268
7279
|
}
|
|
7269
7280
|
else {
|
|
7270
|
-
|
|
7281
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeUser(pattern, callback);
|
|
7271
7282
|
}
|
|
7272
7283
|
}
|
|
7273
7284
|
/**
|
|
@@ -7306,7 +7317,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7306
7317
|
}
|
|
7307
7318
|
async _unsubscribeForeignStates(_options) {
|
|
7308
7319
|
const { pattern, callback } = _options;
|
|
7309
|
-
if (!
|
|
7320
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7310
7321
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7311
7322
|
this._logger.info(`${this.namespaceLog} unsubscrubeForeignStates not processed because States database not connected`);
|
|
7312
7323
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -7317,7 +7328,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7317
7328
|
// remove this pattern from adapter list
|
|
7318
7329
|
let state;
|
|
7319
7330
|
try {
|
|
7320
|
-
state = await
|
|
7331
|
+
state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${autoSub}.subscribes`);
|
|
7321
7332
|
}
|
|
7322
7333
|
catch {
|
|
7323
7334
|
// ignore
|
|
@@ -7354,7 +7365,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7354
7365
|
delete subs[pattern];
|
|
7355
7366
|
}
|
|
7356
7367
|
this.outputCount++;
|
|
7357
|
-
|
|
7368
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${autoSub}.subscribes`, JSON.stringify(subs));
|
|
7358
7369
|
}
|
|
7359
7370
|
}
|
|
7360
7371
|
}
|
|
@@ -7370,15 +7381,15 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7370
7381
|
if (pattern === '*' || pattern.startsWith(constants_1.ALIAS_STARTS_WITH)) {
|
|
7371
7382
|
aliasPattern = pattern; // check all aliases
|
|
7372
7383
|
if (pattern === '*') {
|
|
7373
|
-
promises.push(
|
|
7384
|
+
promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
|
|
7374
7385
|
}
|
|
7375
7386
|
}
|
|
7376
7387
|
else {
|
|
7377
|
-
promises.push(
|
|
7388
|
+
promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
|
|
7378
7389
|
}
|
|
7379
7390
|
}
|
|
7380
7391
|
else {
|
|
7381
|
-
promises.push(
|
|
7392
|
+
promises.push(__classPrivateFieldGet(this, _AdapterClass_states, "f").unsubscribeUser(pattern));
|
|
7382
7393
|
}
|
|
7383
7394
|
if (aliasPattern) {
|
|
7384
7395
|
// if pattern known, remove it from alias patterns to not subscribe to further matching aliases
|
|
@@ -7395,7 +7406,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7395
7406
|
// if no alias subscribed any longer, remove subscription
|
|
7396
7407
|
if (!this.aliases.size && this._aliasObjectsSubscribed) {
|
|
7397
7408
|
this._aliasObjectsSubscribed = false;
|
|
7398
|
-
|
|
7409
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").unsubscribe(`${constants_1.ALIAS_STARTS_WITH}*`);
|
|
7399
7410
|
}
|
|
7400
7411
|
return js_controller_common_1.tools.maybeCallback(callback);
|
|
7401
7412
|
}
|
|
@@ -7494,11 +7505,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7494
7505
|
if (this.performStrictObjectChecks) {
|
|
7495
7506
|
// obj needs to exist and has to be of type "file" - custom check for binary state
|
|
7496
7507
|
try {
|
|
7497
|
-
if (!
|
|
7508
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
7498
7509
|
this._logger.info(`${this.namespaceLog} setBinaryState not processed because Objects database not connected`);
|
|
7499
7510
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7500
7511
|
}
|
|
7501
|
-
const obj = await
|
|
7512
|
+
const obj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectAsync(id);
|
|
7502
7513
|
// at first check object existence
|
|
7503
7514
|
if (!obj) {
|
|
7504
7515
|
this._logger.warn(`${this.namespaceLog} Binary state "${id}" has no existing object, this might lead to an error in future versions`);
|
|
@@ -7515,7 +7526,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7515
7526
|
this._logger.warn(`${this.namespaceLog} Could not perform strict object check of binary state ${id}: ${e.message}`);
|
|
7516
7527
|
}
|
|
7517
7528
|
}
|
|
7518
|
-
if (!
|
|
7529
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7519
7530
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7520
7531
|
this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
|
|
7521
7532
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -7537,38 +7548,38 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7537
7548
|
if (obj && !('binary' in obj)) {
|
|
7538
7549
|
// @ts-expect-error probably need to adjust types
|
|
7539
7550
|
obj.binary = true;
|
|
7540
|
-
if (!
|
|
7551
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
7541
7552
|
this._logger.info(`${this.namespaceLog} setBinaryState not processed because Objects database not connected`);
|
|
7542
7553
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7543
7554
|
}
|
|
7544
|
-
|
|
7555
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, err => {
|
|
7545
7556
|
if (err) {
|
|
7546
7557
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
7547
7558
|
}
|
|
7548
7559
|
else {
|
|
7549
|
-
if (!
|
|
7560
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7550
7561
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7551
7562
|
this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
|
|
7552
7563
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7553
7564
|
}
|
|
7554
7565
|
this.outputCount++;
|
|
7555
|
-
|
|
7566
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
|
|
7556
7567
|
}
|
|
7557
7568
|
});
|
|
7558
7569
|
}
|
|
7559
7570
|
else {
|
|
7560
|
-
if (!
|
|
7571
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7561
7572
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7562
7573
|
this._logger.info(`${this.namespaceLog} setBinaryState not processed because States database not connected`);
|
|
7563
7574
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
7564
7575
|
}
|
|
7565
7576
|
this.outputCount++;
|
|
7566
|
-
|
|
7577
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
|
|
7567
7578
|
}
|
|
7568
7579
|
}
|
|
7569
7580
|
else {
|
|
7570
7581
|
this.outputCount++;
|
|
7571
|
-
|
|
7582
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setBinaryState(id, binary, callback);
|
|
7572
7583
|
}
|
|
7573
7584
|
}
|
|
7574
7585
|
/**
|
|
@@ -7611,7 +7622,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7611
7622
|
}
|
|
7612
7623
|
async _getForeignBinaryState(_options) {
|
|
7613
7624
|
const { id, options, callback } = _options;
|
|
7614
|
-
if (!
|
|
7625
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7615
7626
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7616
7627
|
this._logger.info(`${this.namespaceLog} getBinaryState not processed because States database not connected`);
|
|
7617
7628
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -7634,11 +7645,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7634
7645
|
catch (e) {
|
|
7635
7646
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
7636
7647
|
}
|
|
7637
|
-
|
|
7648
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getBinaryState(id, (err, data) => {
|
|
7638
7649
|
if (!err && data && obj && !('binary' in obj)) {
|
|
7639
7650
|
// @ts-expect-error type adjustment needed?
|
|
7640
7651
|
obj.binary = true;
|
|
7641
|
-
|
|
7652
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").setObject(id, obj, err => {
|
|
7642
7653
|
if (err) {
|
|
7643
7654
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, err);
|
|
7644
7655
|
}
|
|
@@ -7697,7 +7708,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7697
7708
|
}
|
|
7698
7709
|
async _delForeignBinaryState(_options) {
|
|
7699
7710
|
const { id, options, callback } = _options;
|
|
7700
|
-
if (!
|
|
7711
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7701
7712
|
// if states is no longer existing, we do not need to unsubscribe
|
|
7702
7713
|
this._logger.info(`${this.namespaceLog} delBinaryState not processed because States database not connected`);
|
|
7703
7714
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
@@ -7715,10 +7726,10 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7715
7726
|
catch (e) {
|
|
7716
7727
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, e);
|
|
7717
7728
|
}
|
|
7718
|
-
|
|
7729
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").delBinaryState(id, callback);
|
|
7719
7730
|
}
|
|
7720
7731
|
else {
|
|
7721
|
-
|
|
7732
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").delBinaryState(id, callback);
|
|
7722
7733
|
}
|
|
7723
7734
|
}
|
|
7724
7735
|
/**
|
|
@@ -7764,10 +7775,10 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7764
7775
|
}
|
|
7765
7776
|
async _autoSubscribeOn() {
|
|
7766
7777
|
var _a;
|
|
7767
|
-
if (!this.autoSubscribe &&
|
|
7778
|
+
if (!this.autoSubscribe && __classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
7768
7779
|
try {
|
|
7769
7780
|
// collect all
|
|
7770
|
-
const res = await
|
|
7781
|
+
const res = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").getObjectViewAsync('system', 'instance', {
|
|
7771
7782
|
startkey: 'system.adapter.',
|
|
7772
7783
|
endkey: 'system.adapter.\u9999'
|
|
7773
7784
|
});
|
|
@@ -7781,7 +7792,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7781
7792
|
}
|
|
7782
7793
|
}
|
|
7783
7794
|
// because of autoSubscribe
|
|
7784
|
-
await
|
|
7795
|
+
await __classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribeAsync('system.adapter.*');
|
|
7785
7796
|
}
|
|
7786
7797
|
catch {
|
|
7787
7798
|
// ignore
|
|
@@ -7881,11 +7892,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7881
7892
|
return licenses;
|
|
7882
7893
|
}
|
|
7883
7894
|
_reportStatus() {
|
|
7884
|
-
if (!
|
|
7895
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7885
7896
|
return;
|
|
7886
7897
|
}
|
|
7887
7898
|
const id = `system.adapter.${this.namespace}`;
|
|
7888
|
-
|
|
7899
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, {
|
|
7889
7900
|
val: true,
|
|
7890
7901
|
ack: true,
|
|
7891
7902
|
expire: Math.floor(this._config.system.statisticsInterval / 1000) + 10,
|
|
@@ -7893,7 +7904,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7893
7904
|
});
|
|
7894
7905
|
this.outputCount++;
|
|
7895
7906
|
if (this.connected) {
|
|
7896
|
-
|
|
7907
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.connected`, { val: true, ack: true, expire: 30, from: id });
|
|
7897
7908
|
this.outputCount++;
|
|
7898
7909
|
}
|
|
7899
7910
|
if (!this.startedInCompactMode) {
|
|
@@ -7909,32 +7920,32 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7909
7920
|
// }
|
|
7910
7921
|
(0, pidusage_1.default)(process.pid, (err, stats) => {
|
|
7911
7922
|
// sometimes adapter is stopped, but this is still running
|
|
7912
|
-
if (!err && this &&
|
|
7913
|
-
|
|
7923
|
+
if (!err && this && __classPrivateFieldGet(this, _AdapterClass_states, "f") && __classPrivateFieldGet(this, _AdapterClass_states, "f").setState && stats) {
|
|
7924
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cpu`, {
|
|
7914
7925
|
ack: true,
|
|
7915
7926
|
from: id,
|
|
7916
7927
|
val: Math.round(100 * stats.cpu) / 100
|
|
7917
7928
|
});
|
|
7918
|
-
|
|
7929
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cputime`, { ack: true, from: id, val: stats.ctime / 1000 });
|
|
7919
7930
|
this.outputCount += 2;
|
|
7920
7931
|
}
|
|
7921
7932
|
});
|
|
7922
7933
|
try {
|
|
7923
7934
|
//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).
|
|
7924
7935
|
const mem = process.memoryUsage();
|
|
7925
|
-
|
|
7936
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memRss`, {
|
|
7926
7937
|
val: parseFloat((mem.rss / 1048576) /* 1MB */
|
|
7927
7938
|
.toFixed(2)),
|
|
7928
7939
|
ack: true,
|
|
7929
7940
|
from: id
|
|
7930
7941
|
});
|
|
7931
|
-
|
|
7942
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapTotal`, {
|
|
7932
7943
|
val: parseFloat((mem.heapTotal / 1048576) /* 1MB */
|
|
7933
7944
|
.toFixed(2)),
|
|
7934
7945
|
ack: true,
|
|
7935
7946
|
from: id
|
|
7936
7947
|
});
|
|
7937
|
-
|
|
7948
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapUsed`, {
|
|
7938
7949
|
val: parseFloat((mem.heapUsed / 1048576) /* 1MB */
|
|
7939
7950
|
.toFixed(2)),
|
|
7940
7951
|
ack: true,
|
|
@@ -7947,19 +7958,19 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7947
7958
|
this.outputCount += 3;
|
|
7948
7959
|
if (this.eventLoopLags.length) {
|
|
7949
7960
|
const eventLoopLag = Math.ceil(this.eventLoopLags.reduce((a, b) => a + b) / this.eventLoopLags.length);
|
|
7950
|
-
|
|
7961
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.eventLoopLag`, { val: eventLoopLag, ack: true, from: id }); // average of measured values
|
|
7951
7962
|
this.eventLoopLags = [];
|
|
7952
7963
|
this.outputCount++;
|
|
7953
7964
|
}
|
|
7954
7965
|
}
|
|
7955
7966
|
this.outputCount += 3;
|
|
7956
|
-
|
|
7967
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.uptime`, {
|
|
7957
7968
|
val: parseInt(process.uptime().toFixed(), 10),
|
|
7958
7969
|
ack: true,
|
|
7959
7970
|
from: id
|
|
7960
7971
|
});
|
|
7961
|
-
|
|
7962
|
-
|
|
7972
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.inputCount`, { val: this.inputCount, ack: true, from: id });
|
|
7973
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.outputCount`, { val: this.outputCount, ack: true, from: id });
|
|
7963
7974
|
this.inputCount = 0;
|
|
7964
7975
|
this.outputCount = 0;
|
|
7965
7976
|
}
|
|
@@ -7968,18 +7979,18 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
7968
7979
|
let logs = [];
|
|
7969
7980
|
// LogList
|
|
7970
7981
|
logs.push(`Actual Loglist - ${JSON.stringify(Array.from(this.logList))}`);
|
|
7971
|
-
if (!
|
|
7982
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7972
7983
|
// if adapterState was destroyed, we can not continue
|
|
7973
7984
|
return;
|
|
7974
7985
|
}
|
|
7975
7986
|
// Read current state of all log subscribers
|
|
7976
|
-
|
|
7987
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
|
|
7977
7988
|
if (keys === null || keys === void 0 ? void 0 : keys.length) {
|
|
7978
|
-
if (!
|
|
7989
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
7979
7990
|
// if adapterState was destroyed, we can not continue
|
|
7980
7991
|
return;
|
|
7981
7992
|
}
|
|
7982
|
-
|
|
7993
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys, (err, obj) => {
|
|
7983
7994
|
if (obj) {
|
|
7984
7995
|
for (let i = 0; i < keys.length; i++) {
|
|
7985
7996
|
const objPart = obj[i];
|
|
@@ -8017,17 +8028,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8017
8028
|
// temporary log buffer
|
|
8018
8029
|
let messages = [];
|
|
8019
8030
|
// Read current state of all log subscriber
|
|
8020
|
-
if (!
|
|
8031
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8021
8032
|
// if adapterState was destroyed, we can not continue
|
|
8022
8033
|
return;
|
|
8023
8034
|
}
|
|
8024
|
-
|
|
8035
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getKeys(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`, (err, keys) => {
|
|
8025
8036
|
if (keys === null || keys === void 0 ? void 0 : keys.length) {
|
|
8026
|
-
if (!
|
|
8037
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8027
8038
|
// if adapterState was destroyed, we can not continue
|
|
8028
8039
|
return;
|
|
8029
8040
|
}
|
|
8030
|
-
|
|
8041
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getStates(keys, (err, obj) => {
|
|
8031
8042
|
if (obj) {
|
|
8032
8043
|
for (let i = 0; i < keys.length; i++) {
|
|
8033
8044
|
const objPart = obj[i];
|
|
@@ -8046,10 +8057,10 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8046
8057
|
this.logRedirect(true, id);
|
|
8047
8058
|
}
|
|
8048
8059
|
}
|
|
8049
|
-
if (this.logList.size && (messages === null || messages === void 0 ? void 0 : messages.length) &&
|
|
8060
|
+
if (this.logList.size && (messages === null || messages === void 0 ? void 0 : messages.length) && __classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8050
8061
|
for (const message of messages) {
|
|
8051
8062
|
for (const instanceId of this.logList) {
|
|
8052
|
-
|
|
8063
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").pushLog(instanceId, message);
|
|
8053
8064
|
}
|
|
8054
8065
|
}
|
|
8055
8066
|
}
|
|
@@ -8084,6 +8095,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8084
8095
|
const ts = this._logger.transports.find(t => t.name === 'NT');
|
|
8085
8096
|
// @ts-expect-error
|
|
8086
8097
|
ts.on('logged', info => {
|
|
8098
|
+
var _a;
|
|
8087
8099
|
info.from = this.namespace;
|
|
8088
8100
|
// emit to itself
|
|
8089
8101
|
if (this._options.logTransporter && this.logRequired && !this._stopInProgress) {
|
|
@@ -8099,17 +8111,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8099
8111
|
}
|
|
8100
8112
|
}
|
|
8101
8113
|
}
|
|
8102
|
-
else if (
|
|
8114
|
+
else if ((_a = __classPrivateFieldGet(this, _AdapterClass_states, "f")) === null || _a === void 0 ? void 0 : _a.pushLog) {
|
|
8103
8115
|
// Send to all adapter, that required logs
|
|
8104
8116
|
for (const instanceId of this.logList) {
|
|
8105
|
-
|
|
8117
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").pushLog(instanceId, info);
|
|
8106
8118
|
}
|
|
8107
8119
|
}
|
|
8108
8120
|
});
|
|
8109
8121
|
this._options.logTransporter = this._options.logTransporter || this.ioPack.common.logTransporter;
|
|
8110
8122
|
if (this._options.logTransporter) {
|
|
8111
8123
|
this.requireLog = async (isActive, options) => {
|
|
8112
|
-
if (!
|
|
8124
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8113
8125
|
return;
|
|
8114
8126
|
}
|
|
8115
8127
|
if (this.logRequired !== isActive) {
|
|
@@ -8123,7 +8135,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8123
8135
|
this.logOffTimer = null;
|
|
8124
8136
|
this._logger.silly(`${this.namespaceLog} Change log subscriber state: FALSE`);
|
|
8125
8137
|
this.outputCount++;
|
|
8126
|
-
if (
|
|
8138
|
+
if (__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8127
8139
|
try {
|
|
8128
8140
|
await this.setForeignStateAsync(`system.adapter.${this.namespace}.logging`, {
|
|
8129
8141
|
val: false,
|
|
@@ -8164,7 +8176,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8164
8176
|
this.emit('log', msg);
|
|
8165
8177
|
}
|
|
8166
8178
|
};
|
|
8167
|
-
|
|
8179
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeLog(`system.adapter.${this.namespace}`);
|
|
8168
8180
|
}
|
|
8169
8181
|
else {
|
|
8170
8182
|
this.requireLog = isActive => {
|
|
@@ -8188,12 +8200,16 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8188
8200
|
this._logger.warn(`${this.namespaceLog} slow connection to states DB. Still waiting ...`);
|
|
8189
8201
|
}
|
|
8190
8202
|
}, this._config.states.connectTimeout || 2000);
|
|
8203
|
+
if (!this.States) {
|
|
8204
|
+
this._logger.warn(`${this.namespaceLog} States DB constructor has not been initialized`);
|
|
8205
|
+
this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
|
|
8206
|
+
}
|
|
8191
8207
|
// Internal object, but some special adapters want to access it anyway.
|
|
8192
|
-
|
|
8208
|
+
__classPrivateFieldSet(this, _AdapterClass_states, new this.States({
|
|
8193
8209
|
namespace: this.namespaceLog,
|
|
8194
8210
|
connection: this._config.states,
|
|
8195
8211
|
connected: async () => {
|
|
8196
|
-
if (!
|
|
8212
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8197
8213
|
return;
|
|
8198
8214
|
}
|
|
8199
8215
|
this._logger.silly(`${this.namespaceLog} statesDB connected`);
|
|
@@ -8204,17 +8220,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8204
8220
|
}
|
|
8205
8221
|
if (!this._config.isInstall) {
|
|
8206
8222
|
// Subscribe for process exit signal
|
|
8207
|
-
|
|
8223
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.sigKill`);
|
|
8208
8224
|
// Subscribe for loglevel
|
|
8209
|
-
|
|
8225
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.logLevel`);
|
|
8210
8226
|
}
|
|
8211
8227
|
if (this._options.subscribable) {
|
|
8212
8228
|
// subscribe on if other instance wants to have states of this adapter
|
|
8213
|
-
|
|
8229
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.subscribes`);
|
|
8214
8230
|
// read actual autosubscribe requests
|
|
8215
8231
|
let state;
|
|
8216
8232
|
try {
|
|
8217
|
-
state = await
|
|
8233
|
+
state = await __classPrivateFieldGet(this, _AdapterClass_states, "f").getStateAsync(`system.adapter.${this.namespace}.subscribes`);
|
|
8218
8234
|
}
|
|
8219
8235
|
catch {
|
|
8220
8236
|
// ignore
|
|
@@ -8292,8 +8308,8 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8292
8308
|
this._logger.info(`${this.namespaceLog} Got invalid loglevel "${state.val}", ignoring`);
|
|
8293
8309
|
}
|
|
8294
8310
|
this.outputCount++;
|
|
8295
|
-
|
|
8296
|
-
|
|
8311
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f") &&
|
|
8312
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
8297
8313
|
val: currentLevel,
|
|
8298
8314
|
ack: true,
|
|
8299
8315
|
from: `system.adapter.${this.namespace}`
|
|
@@ -8393,7 +8409,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8393
8409
|
if (state.val) {
|
|
8394
8410
|
if (!this.pluginHandler.isPluginInstanciated(pluginName)) {
|
|
8395
8411
|
this.pluginHandler.instanciatePlugin(pluginName, this.pluginHandler.getPluginConfig(pluginName) || {}, __dirname);
|
|
8396
|
-
this.pluginHandler.setDatabaseForPlugin(pluginName,
|
|
8412
|
+
this.pluginHandler.setDatabaseForPlugin(pluginName, __classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"));
|
|
8397
8413
|
this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
|
|
8398
8414
|
}
|
|
8399
8415
|
}
|
|
@@ -8471,7 +8487,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8471
8487
|
this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
|
|
8472
8488
|
}, 5000);
|
|
8473
8489
|
}
|
|
8474
|
-
});
|
|
8490
|
+
}), "f");
|
|
8475
8491
|
}
|
|
8476
8492
|
_initObjects(cb) {
|
|
8477
8493
|
this._initializeTimeout = setTimeout(() => {
|
|
@@ -8484,7 +8500,11 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8484
8500
|
this._logger.warn(`${this.namespaceLog} slow connection to objects DB. Still waiting ...`);
|
|
8485
8501
|
}
|
|
8486
8502
|
}, this._config.objects.connectTimeout * 2); // Because we do not connect only anymore, give it a bit more time
|
|
8487
|
-
|
|
8503
|
+
if (!this.Objects) {
|
|
8504
|
+
this._logger.warn(`${this.namespaceLog} Objects DB constructor has not been initialized`);
|
|
8505
|
+
this.terminate(js_controller_common_1.EXIT_CODES.NO_ERROR);
|
|
8506
|
+
}
|
|
8507
|
+
__classPrivateFieldSet(this, _AdapterClass_objects, new this.Objects({
|
|
8488
8508
|
namespace: this.namespaceLog,
|
|
8489
8509
|
connection: this._config.objects,
|
|
8490
8510
|
logger: this._logger,
|
|
@@ -8494,17 +8514,17 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8494
8514
|
clearTimeout(this._initializeTimeout);
|
|
8495
8515
|
this._initializeTimeout = null;
|
|
8496
8516
|
}
|
|
8497
|
-
if (!
|
|
8517
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
8498
8518
|
return;
|
|
8499
8519
|
}
|
|
8500
8520
|
// subscribe to user changes
|
|
8501
|
-
|
|
8521
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe('system.user.*');
|
|
8502
8522
|
// get all enums and register for enum changes
|
|
8503
|
-
this.enums = await js_controller_common_1.tools.getAllEnums(
|
|
8504
|
-
|
|
8523
|
+
this.enums = await js_controller_common_1.tools.getAllEnums(__classPrivateFieldGet(this, _AdapterClass_objects, "f"));
|
|
8524
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").subscribe('enum.*');
|
|
8505
8525
|
// Read dateformat if using of formatDate is announced
|
|
8506
8526
|
if (this._options.useFormatDate) {
|
|
8507
|
-
|
|
8527
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject('system.config', (err, data) => {
|
|
8508
8528
|
if (data === null || data === void 0 ? void 0 : data.common) {
|
|
8509
8529
|
this.dateFormat = data.common.dateFormat;
|
|
8510
8530
|
this.isFloatComma = data.common.isFloatComma;
|
|
@@ -8703,21 +8723,21 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8703
8723
|
setImmediate(() => this.emit('fileChange', id, fileName, size));
|
|
8704
8724
|
}
|
|
8705
8725
|
}
|
|
8706
|
-
});
|
|
8726
|
+
}), "f");
|
|
8707
8727
|
}
|
|
8708
8728
|
/**
|
|
8709
8729
|
* Called if states and objects successfully initialized
|
|
8710
8730
|
*/
|
|
8711
8731
|
_prepareInitAdapter() {
|
|
8712
|
-
if (this.terminated || !
|
|
8732
|
+
if (this.terminated || !__classPrivateFieldGet(this, _AdapterClass_objects, "f") || !__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8713
8733
|
return;
|
|
8714
8734
|
}
|
|
8715
8735
|
if (this._options.instance !== undefined) {
|
|
8716
8736
|
this._initAdapter(this._options);
|
|
8717
8737
|
}
|
|
8718
8738
|
else {
|
|
8719
|
-
|
|
8720
|
-
|
|
8739
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${this.namespace}.alive`, (err, resAlive) => {
|
|
8740
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").getState(`system.adapter.${this.namespace}.sigKill`, (err, killRes) => {
|
|
8721
8741
|
if ((killRes === null || killRes === void 0 ? void 0 : killRes.val) !== undefined) {
|
|
8722
8742
|
killRes.val = parseInt(killRes.val, 10);
|
|
8723
8743
|
}
|
|
@@ -8750,7 +8770,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8750
8770
|
this.terminate(js_controller_common_1.EXIT_CODES.ADAPTER_ALREADY_RUNNING);
|
|
8751
8771
|
}
|
|
8752
8772
|
else {
|
|
8753
|
-
|
|
8773
|
+
__classPrivateFieldGet(this, _AdapterClass_objects, "f").getObject(`system.adapter.${this.namespace}`, (err, res) => {
|
|
8754
8774
|
// TODO: ts infers AdapterObject instead of InstanceObject
|
|
8755
8775
|
if ((err || !res) && !this._config.isInstall) {
|
|
8756
8776
|
this._logger.error(`${this.namespaceLog} ${this.namespace} invalid config`);
|
|
@@ -8770,14 +8790,14 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8770
8790
|
if (!this.pluginHandler) {
|
|
8771
8791
|
return;
|
|
8772
8792
|
}
|
|
8773
|
-
this.pluginHandler.setDatabaseForPlugins(
|
|
8793
|
+
this.pluginHandler.setDatabaseForPlugins(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"));
|
|
8774
8794
|
this.pluginHandler.initPlugins(adapterConfig || {}, async () => {
|
|
8775
8795
|
var _a, _b, _c;
|
|
8776
|
-
if (!
|
|
8796
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f") || !__classPrivateFieldGet(this, _AdapterClass_objects, "f") || this.terminated) {
|
|
8777
8797
|
// if adapterState was destroyed,we should not continue
|
|
8778
8798
|
return;
|
|
8779
8799
|
}
|
|
8780
|
-
|
|
8800
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`system.adapter.${this.namespace}.plugins.*`);
|
|
8781
8801
|
if (this._options.instance === undefined) {
|
|
8782
8802
|
if (!adapterConfig || !('common' in adapterConfig) || !adapterConfig.common.enabled) {
|
|
8783
8803
|
if (adapterConfig && 'common' in adapterConfig && adapterConfig.common.enabled !== undefined) {
|
|
@@ -8790,9 +8810,9 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8790
8810
|
if (!this._config.isInstall && (!process.argv || !this._config.forceIfDisabled)) {
|
|
8791
8811
|
const id = `system.adapter.${this.namespace}`;
|
|
8792
8812
|
this.outputCount += 2;
|
|
8793
|
-
|
|
8813
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
|
|
8794
8814
|
let done = false;
|
|
8795
|
-
|
|
8815
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.connected`, {
|
|
8796
8816
|
val: true,
|
|
8797
8817
|
ack: true,
|
|
8798
8818
|
expire: 30,
|
|
@@ -8885,7 +8905,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8885
8905
|
this.stop = () => this._stop(false);
|
|
8886
8906
|
}
|
|
8887
8907
|
// Monitor logging state
|
|
8888
|
-
|
|
8908
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribe(`${constants_2.SYSTEM_ADAPTER_PREFIX}*.logging`);
|
|
8889
8909
|
if (typeof this._options.message === 'function' &&
|
|
8890
8910
|
// @ts-expect-error, we should infer correctly that this is an InstanceObject in this case
|
|
8891
8911
|
!(0, utils_1.isMessageboxSupported)(adapterConfig.common)) {
|
|
@@ -8894,7 +8914,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8894
8914
|
}
|
|
8895
8915
|
else if ((0, utils_1.isMessageboxSupported)(adapterConfig.common)) {
|
|
8896
8916
|
this.mboxSubscribed = true;
|
|
8897
|
-
|
|
8917
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").subscribeMessage(`system.adapter.${this.namespace}`);
|
|
8898
8918
|
}
|
|
8899
8919
|
}
|
|
8900
8920
|
else {
|
|
@@ -8912,7 +8932,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8912
8932
|
this.host = ((_a = this.common) === null || _a === void 0 ? void 0 : _a.host) || js_controller_common_1.tools.getHostName() || os_1.default.hostname();
|
|
8913
8933
|
}
|
|
8914
8934
|
this.adapterConfig = adapterConfig;
|
|
8915
|
-
this._utils = new validator_1.Validator(
|
|
8935
|
+
this._utils = new validator_1.Validator(__classPrivateFieldGet(this, _AdapterClass_objects, "f"), __classPrivateFieldGet(this, _AdapterClass_states, "f"), this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
|
|
8916
8936
|
this.log = new log_1.Log(this.namespaceLog, this._config.log.level, this._logger);
|
|
8917
8937
|
await this._createInstancesObjects(adapterConfig);
|
|
8918
8938
|
// auto oObjects
|
|
@@ -8947,13 +8967,13 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8947
8967
|
}
|
|
8948
8968
|
// Wait till all attributes decrypted
|
|
8949
8969
|
await Promise.all(promises);
|
|
8950
|
-
if (!
|
|
8951
|
-
// if adapterStates was destroyed, we should not continue
|
|
8970
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
8971
|
+
// if this.adapterStates was destroyed, we should not continue
|
|
8952
8972
|
return;
|
|
8953
8973
|
}
|
|
8954
8974
|
this.outputCount++;
|
|
8955
8975
|
// set current loglevel
|
|
8956
|
-
|
|
8976
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
8957
8977
|
val: this._config.log.level,
|
|
8958
8978
|
ack: true,
|
|
8959
8979
|
from: `system.adapter.${this.namespace}`
|
|
@@ -8977,19 +8997,19 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
8977
8997
|
this._reportInterval = setInterval(() => this._reportStatus(), this._config.system.statisticsInterval);
|
|
8978
8998
|
this._reportStatus();
|
|
8979
8999
|
const id = `system.adapter.${this.namespace}`;
|
|
8980
|
-
|
|
9000
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.compactMode`, {
|
|
8981
9001
|
ack: true,
|
|
8982
9002
|
from: id,
|
|
8983
9003
|
val: !!this.startedInCompactMode
|
|
8984
9004
|
});
|
|
8985
9005
|
this.outputCount++;
|
|
8986
9006
|
if (this.startedInCompactMode) {
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
9007
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cpu`, { ack: true, from: id, val: 0 });
|
|
9008
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.cputime`, { ack: true, from: id, val: 0 });
|
|
9009
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memRss`, { val: 0, ack: true, from: id });
|
|
9010
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapTotal`, { val: 0, ack: true, from: id });
|
|
9011
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.memHeapUsed`, { val: 0, ack: true, from: id });
|
|
9012
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(`${id}.eventLoopLag`, { val: 0, ack: true, from: id });
|
|
8993
9013
|
this.outputCount += 6;
|
|
8994
9014
|
}
|
|
8995
9015
|
else {
|
|
@@ -9155,7 +9175,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
9155
9175
|
if (obj.type === 'state' && obj.common.def !== undefined) {
|
|
9156
9176
|
// default value given - if obj non-existing we have to set it
|
|
9157
9177
|
try {
|
|
9158
|
-
const checkObj = await
|
|
9178
|
+
const checkObj = await __classPrivateFieldGet(this, _AdapterClass_objects, "f").objectExists(obj._id);
|
|
9159
9179
|
if (!checkObj) {
|
|
9160
9180
|
obj.state = obj.common.def;
|
|
9161
9181
|
}
|
|
@@ -9210,7 +9230,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
9210
9230
|
this._logger.warn(`${this.namespaceLog} Object ${task._id} is invalid: ${e.message}`);
|
|
9211
9231
|
this._logger.warn(`${this.namespaceLog} This object will not be created in future versions. Please report this to the developer.`);
|
|
9212
9232
|
}
|
|
9213
|
-
if (!
|
|
9233
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_objects, "f")) {
|
|
9214
9234
|
this._logger.info(`${this.namespaceLog} extendObjects not processed because Objects database not connected.`);
|
|
9215
9235
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
9216
9236
|
}
|
|
@@ -9223,12 +9243,12 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
9223
9243
|
// ignore
|
|
9224
9244
|
}
|
|
9225
9245
|
if (state !== undefined) {
|
|
9226
|
-
if (!
|
|
9246
|
+
if (!__classPrivateFieldGet(this, _AdapterClass_states, "f")) {
|
|
9227
9247
|
this._logger.info(`${this.namespaceLog} extendObjects not processed because States database not connected.`);
|
|
9228
9248
|
return js_controller_common_1.tools.maybeCallbackWithError(callback, js_controller_common_1.tools.ERRORS.ERROR_DB_CLOSED);
|
|
9229
9249
|
}
|
|
9230
9250
|
this.outputCount++;
|
|
9231
|
-
|
|
9251
|
+
__classPrivateFieldGet(this, _AdapterClass_states, "f").setState(task._id, {
|
|
9232
9252
|
val: state,
|
|
9233
9253
|
from: `system.adapter.${this.namespace}`,
|
|
9234
9254
|
ack: true
|
|
@@ -9283,25 +9303,25 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
9283
9303
|
}
|
|
9284
9304
|
if (this._config.states && this._config.states.type) {
|
|
9285
9305
|
try {
|
|
9286
|
-
States = (await (_a = `@iobroker/db-states-${this._config.states.type}`, Promise.resolve().then(() => __importStar(require(_a))))).Client;
|
|
9306
|
+
this.States = (await (_a = `@iobroker/db-states-${this._config.states.type}`, Promise.resolve().then(() => __importStar(require(_a))))).Client;
|
|
9287
9307
|
}
|
|
9288
9308
|
catch (err) {
|
|
9289
9309
|
throw new Error(`Unknown states type: ${this._config.states.type}: ${err.message}`);
|
|
9290
9310
|
}
|
|
9291
9311
|
}
|
|
9292
9312
|
else {
|
|
9293
|
-
States = (0, js_controller_common_db_1.getStatesConstructor)();
|
|
9313
|
+
this.States = (0, js_controller_common_db_1.getStatesConstructor)();
|
|
9294
9314
|
}
|
|
9295
9315
|
if (this._config.objects && this._config.objects.type) {
|
|
9296
9316
|
try {
|
|
9297
|
-
Objects = (await (_b = `@iobroker/db-objects-${this._config.objects.type}`, Promise.resolve().then(() => __importStar(require(_b))))).Client;
|
|
9317
|
+
this.Objects = (await (_b = `@iobroker/db-objects-${this._config.objects.type}`, Promise.resolve().then(() => __importStar(require(_b))))).Client;
|
|
9298
9318
|
}
|
|
9299
9319
|
catch (err) {
|
|
9300
9320
|
throw new Error(`Unknown objects type: ${this._config.objects.type}: ${err.message}`);
|
|
9301
9321
|
}
|
|
9302
9322
|
}
|
|
9303
9323
|
else {
|
|
9304
|
-
Objects = (0, js_controller_common_db_1.getObjectsConstructor)();
|
|
9324
|
+
this.Objects = (0, js_controller_common_db_1.getObjectsConstructor)();
|
|
9305
9325
|
}
|
|
9306
9326
|
const ifaces = os_1.default.networkInterfaces();
|
|
9307
9327
|
const ipArr = [];
|
|
@@ -9342,6 +9362,7 @@ class AdapterClass extends events_1.EventEmitter {
|
|
|
9342
9362
|
}
|
|
9343
9363
|
}
|
|
9344
9364
|
exports.AdapterClass = AdapterClass;
|
|
9365
|
+
_AdapterClass_states = new WeakMap(), _AdapterClass_objects = new WeakMap();
|
|
9345
9366
|
/**
|
|
9346
9367
|
* Polyfill to allow calling without `new`
|
|
9347
9368
|
* @type {AdapterClass}
|