@iobroker/adapter-react-v5 4.4.4 → 4.4.6

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.
@@ -571,23 +571,57 @@ var Connection = /*#__PURE__*/function () {
571
571
  return console.error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(e)));
572
572
  });
573
573
  } else {
574
- if (Connection.isWeb()) {
575
- this._socket.emit('getStates', id, function (err, states) {
576
- err && console.error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(err)));
577
- states && Object.keys(states).forEach(function (id) {
578
- return cb(id, states[id]);
579
- });
580
- });
581
- } else {
582
- this._socket.emit('getForeignStates', id, function (err, states) {
583
- err && console.error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(err)));
584
- states && Object.keys(states).forEach(function (id) {
585
- return cb(id, states[id]);
586
- });
574
+ this._socket.emit(Connection.isWeb() ? 'getStates' : 'getForeignStates', id, function (err, states) {
575
+ err && console.error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(err)));
576
+ states && Object.keys(states).forEach(function (id) {
577
+ return cb(id, states[id]);
587
578
  });
579
+ });
580
+ }
581
+ }
582
+ }
583
+
584
+ /**
585
+ * Subscribe to changes of the given state.
586
+ * @param {string} id The ioBroker state ID.
587
+ * @param {ioBroker.StateChangeHandler} cb The callback.
588
+ */
589
+ }, {
590
+ key: "subscribeStateAsync",
591
+ value: function subscribeStateAsync(id, cb) {
592
+ var _this5 = this;
593
+ if (!this.statesSubscribes[id]) {
594
+ var reg = id.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/\+/g, '\\+').replace(/\[/g, '\\[');
595
+ if (!reg.includes('*')) {
596
+ reg += '$';
597
+ }
598
+ this.statesSubscribes[id] = {
599
+ reg: new RegExp(reg),
600
+ cbs: []
601
+ };
602
+ this.statesSubscribes[id].cbs.push(cb);
603
+ if (this.connected) {
604
+ if (this.connected && id !== this.ignoreState) {
605
+ // no answer from server required
606
+ this._socket.emit('subscribe', id);
588
607
  }
589
608
  }
609
+ } else {
610
+ !this.statesSubscribes[id].cbs.includes(cb) && this.statesSubscribes[id].cbs.push(cb);
590
611
  }
612
+ return new Promise(function (resolve, reject) {
613
+ if (typeof cb === 'function' && _this5.connected) {
614
+ _this5._socket.emit(Connection.isWeb() ? 'getStates' : 'getForeignStates', id, function (err, states) {
615
+ err && console.error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(err)));
616
+ states && Object.keys(states).forEach(function (id) {
617
+ return cb(id, states[id]);
618
+ });
619
+ states ? resolve(null) : reject(new Error("Cannot getForeignStates \"".concat(id, "\": ").concat(JSON.stringify(err))));
620
+ });
621
+ } else {
622
+ _this5.connected ? reject(new Error('callback is not a function')) : reject(new Error('not connected'));
623
+ }
624
+ });
591
625
  }
592
626
 
593
627
  /**
@@ -781,7 +815,7 @@ var Connection = /*#__PURE__*/function () {
781
815
  }, {
782
816
  key: "objectChange",
783
817
  value: function objectChange(id, obj) {
784
- var _this5 = this;
818
+ var _this6 = this;
785
819
  // update main.objects cache
786
820
  if (!this.objects) {
787
821
  return;
@@ -813,9 +847,9 @@ var Connection = /*#__PURE__*/function () {
813
847
  changed = true;
814
848
  }
815
849
  Object.keys(this.objectsSubscribes).forEach(function (_id) {
816
- if (_id === id || _this5.objectsSubscribes[_id].reg.test(id)) {
850
+ if (_id === id || _this6.objectsSubscribes[_id].reg.test(id)) {
817
851
  // @ts-ignore
818
- _this5.objectsSubscribes[_id].cbs.forEach(function (cb) {
852
+ _this6.objectsSubscribes[_id].cbs.forEach(function (cb) {
819
853
  try {
820
854
  cb(id, obj, oldObj);
821
855
  } catch (e) {
@@ -877,16 +911,16 @@ var Connection = /*#__PURE__*/function () {
877
911
  }, {
878
912
  key: "getStates",
879
913
  value: function getStates(disableProgressUpdate) {
880
- var _this6 = this;
914
+ var _this7 = this;
881
915
  if (!this.connected) {
882
916
  return Promise.reject(NOT_CONNECTED);
883
917
  }
884
918
  return new Promise(function (resolve, reject) {
885
- return _this6._socket.emit('getStates', function (err, res) {
886
- _this6.states = res;
919
+ return _this7._socket.emit('getStates', function (err, res) {
920
+ _this7.states = res;
887
921
  // @ts-ignore
888
- !disableProgressUpdate && _this6.onProgress(PROGRESS.STATES_LOADED);
889
- return err ? reject(err) : resolve(_this6.states);
922
+ !disableProgressUpdate && _this7.onProgress(PROGRESS.STATES_LOADED);
923
+ return err ? reject(err) : resolve(_this7.states);
890
924
  });
891
925
  });
892
926
  }
@@ -899,7 +933,7 @@ var Connection = /*#__PURE__*/function () {
899
933
  }, {
900
934
  key: "getState",
901
935
  value: function getState(id) {
902
- var _this7 = this;
936
+ var _this8 = this;
903
937
  if (!this.connected) {
904
938
  return Promise.reject(NOT_CONNECTED);
905
939
  }
@@ -910,7 +944,7 @@ var Connection = /*#__PURE__*/function () {
910
944
  });
911
945
  }
912
946
  return new Promise(function (resolve, reject) {
913
- return _this7._socket.emit('getState', id, function (err, state) {
947
+ return _this8._socket.emit('getState', id, function (err, state) {
914
948
  return err ? reject(err) : resolve(state);
915
949
  });
916
950
  });
@@ -925,14 +959,14 @@ var Connection = /*#__PURE__*/function () {
925
959
  }, {
926
960
  key: "getBinaryState",
927
961
  value: function getBinaryState(id) {
928
- var _this8 = this;
962
+ var _this9 = this;
929
963
  if (!this.connected) {
930
964
  return Promise.reject(NOT_CONNECTED);
931
965
  }
932
966
 
933
967
  // the data will come in base64
934
968
  return new Promise(function (resolve, reject) {
935
- return _this8._socket.emit('getBinaryState', id, function (err, state) {
969
+ return _this9._socket.emit('getBinaryState', id, function (err, state) {
936
970
  return err ? reject(err) : resolve(state);
937
971
  });
938
972
  });
@@ -948,14 +982,14 @@ var Connection = /*#__PURE__*/function () {
948
982
  }, {
949
983
  key: "setBinaryState",
950
984
  value: function setBinaryState(id, base64) {
951
- var _this9 = this;
985
+ var _this10 = this;
952
986
  if (!this.connected) {
953
987
  return Promise.reject(NOT_CONNECTED);
954
988
  }
955
989
 
956
990
  // the data will come in base64
957
991
  return new Promise(function (resolve, reject) {
958
- return _this9._socket.emit('setBinaryState', id, base64, function (err) {
992
+ return _this10._socket.emit('setBinaryState', id, base64, function (err) {
959
993
  return err ? reject(err) : resolve();
960
994
  });
961
995
  });
@@ -971,7 +1005,7 @@ var Connection = /*#__PURE__*/function () {
971
1005
  }, {
972
1006
  key: "setState",
973
1007
  value: function setState(id, val, ack) {
974
- var _this10 = this;
1008
+ var _this11 = this;
975
1009
  if (!this.connected) {
976
1010
  return Promise.reject(NOT_CONNECTED);
977
1011
  }
@@ -1022,7 +1056,7 @@ var Connection = /*#__PURE__*/function () {
1022
1056
  return Promise.resolve();
1023
1057
  }
1024
1058
  return new Promise(function (resolve, reject) {
1025
- return _this10._socket.emit('setState', id, val, function (err) {
1059
+ return _this11._socket.emit('setState', id, val, function (err) {
1026
1060
  return err ? reject(err) : resolve();
1027
1061
  });
1028
1062
  });
@@ -1042,18 +1076,18 @@ var Connection = /*#__PURE__*/function () {
1042
1076
  }, {
1043
1077
  key: "getObjects",
1044
1078
  value: function getObjects(update, disableProgressUpdate) {
1045
- var _this11 = this;
1079
+ var _this12 = this;
1046
1080
  if (!this.connected) {
1047
1081
  return Promise.reject(NOT_CONNECTED);
1048
1082
  }
1049
1083
  return new Promise(function (resolve, reject) {
1050
- if (!update && _this11.objects) {
1051
- return resolve(_this11.objects);
1084
+ if (!update && _this12.objects) {
1085
+ return resolve(_this12.objects);
1052
1086
  }
1053
- _this11._socket.emit(Connection.isWeb() ? 'getObjects' : 'getAllObjects', function (err, res) {
1054
- _this11.objects = res;
1055
- disableProgressUpdate && _this11.onProgress(PROGRESS.OBJECTS_LOADED);
1056
- err ? reject(err) : resolve(_this11.objects);
1087
+ _this12._socket.emit(Connection.isWeb() ? 'getObjects' : 'getAllObjects', function (err, res) {
1088
+ _this12.objects = res;
1089
+ disableProgressUpdate && _this12.onProgress(PROGRESS.OBJECTS_LOADED);
1090
+ err ? reject(err) : resolve(_this12.objects);
1057
1091
  });
1058
1092
  });
1059
1093
  }
@@ -1066,12 +1100,12 @@ var Connection = /*#__PURE__*/function () {
1066
1100
  }, {
1067
1101
  key: "getObjectsById",
1068
1102
  value: function getObjectsById(list) {
1069
- var _this12 = this;
1103
+ var _this13 = this;
1070
1104
  if (!this.connected) {
1071
1105
  return Promise.reject(NOT_CONNECTED);
1072
1106
  }
1073
1107
  return new Promise(function (resolve, reject) {
1074
- return _this12._socket.emit('getObjects', list, function (err, res) {
1108
+ return _this13._socket.emit('getObjects', list, function (err, res) {
1075
1109
  return err ? reject(err) : resolve(res);
1076
1110
  });
1077
1111
  });
@@ -1085,37 +1119,37 @@ var Connection = /*#__PURE__*/function () {
1085
1119
  }, {
1086
1120
  key: "_subscribe",
1087
1121
  value: function _subscribe(isEnable) {
1088
- var _this13 = this;
1122
+ var _this14 = this;
1089
1123
  if (isEnable && !this.subscribed) {
1090
1124
  this.subscribed = true;
1091
1125
  this.autoSubscribes.forEach(function (id) {
1092
- return _this13._socket.emit('subscribeObjects', id);
1126
+ return _this14._socket.emit('subscribeObjects', id);
1093
1127
  });
1094
1128
  // re subscribe objects
1095
1129
  Object.keys(this.objectsSubscribes).forEach(function (id) {
1096
- return _this13._socket.emit('subscribeObjects', id);
1130
+ return _this14._socket.emit('subscribeObjects', id);
1097
1131
  });
1098
1132
  // re-subscribe logs
1099
1133
  this.autoSubscribeLog && this._socket.emit('requireLog', true);
1100
1134
  // re subscribe states
1101
1135
  Object.keys(this.statesSubscribes).forEach(function (id) {
1102
- return _this13._socket.emit('subscribe', id);
1136
+ return _this14._socket.emit('subscribe', id);
1103
1137
  });
1104
1138
  } else if (!isEnable && this.subscribed) {
1105
1139
  this.subscribed = false;
1106
1140
  // un-subscribe objects
1107
1141
  this.autoSubscribes.forEach(function (id) {
1108
- return _this13._socket.emit('unsubscribeObjects', id);
1142
+ return _this14._socket.emit('unsubscribeObjects', id);
1109
1143
  });
1110
1144
  Object.keys(this.objectsSubscribes).forEach(function (id) {
1111
- return _this13._socket.emit('unsubscribeObjects', id);
1145
+ return _this14._socket.emit('unsubscribeObjects', id);
1112
1146
  });
1113
1147
  // un-subscribe logs
1114
1148
  this.autoSubscribeLog && this._socket.emit('requireLog', false);
1115
1149
 
1116
1150
  // un-subscribe states
1117
1151
  Object.keys(this.statesSubscribes).forEach(function (id) {
1118
- return _this13._socket.emit('unsubscribe', id);
1152
+ return _this14._socket.emit('unsubscribe', id);
1119
1153
  });
1120
1154
  }
1121
1155
  }
@@ -1128,12 +1162,12 @@ var Connection = /*#__PURE__*/function () {
1128
1162
  }, {
1129
1163
  key: "requireLog",
1130
1164
  value: function requireLog(isEnabled) {
1131
- var _this14 = this;
1165
+ var _this15 = this;
1132
1166
  if (!this.connected) {
1133
1167
  return Promise.reject(NOT_CONNECTED);
1134
1168
  }
1135
1169
  return new Promise(function (resolve, reject) {
1136
- return _this14._socket.emit('requireLog', isEnabled, function (err) {
1170
+ return _this15._socket.emit('requireLog', isEnabled, function (err) {
1137
1171
  return err ? reject(err) : resolve();
1138
1172
  });
1139
1173
  });
@@ -1148,12 +1182,12 @@ var Connection = /*#__PURE__*/function () {
1148
1182
  }, {
1149
1183
  key: "delObject",
1150
1184
  value: function delObject(id, maintenance) {
1151
- var _this15 = this;
1185
+ var _this16 = this;
1152
1186
  if (!this.connected) {
1153
1187
  return Promise.reject(NOT_CONNECTED);
1154
1188
  }
1155
1189
  return new Promise(function (resolve, reject) {
1156
- return _this15._socket.emit('delObject', id, {
1190
+ return _this16._socket.emit('delObject', id, {
1157
1191
  maintenance: !!maintenance
1158
1192
  }, function (err) {
1159
1193
  return err ? reject(err) : resolve();
@@ -1170,12 +1204,12 @@ var Connection = /*#__PURE__*/function () {
1170
1204
  }, {
1171
1205
  key: "delObjects",
1172
1206
  value: function delObjects(id, maintenance) {
1173
- var _this16 = this;
1207
+ var _this17 = this;
1174
1208
  if (!this.connected) {
1175
1209
  return Promise.reject(NOT_CONNECTED);
1176
1210
  }
1177
1211
  return new Promise(function (resolve, reject) {
1178
- return _this16._socket.emit('delObjects', id, {
1212
+ return _this17._socket.emit('delObjects', id, {
1179
1213
  maintenance: !!maintenance
1180
1214
  }, function (err) {
1181
1215
  return err ? reject(err) : resolve();
@@ -1192,7 +1226,7 @@ var Connection = /*#__PURE__*/function () {
1192
1226
  }, {
1193
1227
  key: "setObject",
1194
1228
  value: function setObject(id, obj) {
1195
- var _this17 = this;
1229
+ var _this18 = this;
1196
1230
  if (!this.connected) {
1197
1231
  return Promise.reject(NOT_CONNECTED);
1198
1232
  }
@@ -1210,7 +1244,7 @@ var Connection = /*#__PURE__*/function () {
1210
1244
  delete obj.ts;
1211
1245
  }
1212
1246
  return new Promise(function (resolve, reject) {
1213
- return _this17._socket.emit('setObject', id, obj, function (err) {
1247
+ return _this18._socket.emit('setObject', id, obj, function (err) {
1214
1248
  return err ? reject(err) : resolve();
1215
1249
  });
1216
1250
  });
@@ -1224,7 +1258,7 @@ var Connection = /*#__PURE__*/function () {
1224
1258
  }, {
1225
1259
  key: "getObject",
1226
1260
  value: function getObject(id) {
1227
- var _this18 = this;
1261
+ var _this19 = this;
1228
1262
  if (!this.connected) {
1229
1263
  return Promise.reject(NOT_CONNECTED);
1230
1264
  }
@@ -1239,7 +1273,7 @@ var Connection = /*#__PURE__*/function () {
1239
1273
  });
1240
1274
  }
1241
1275
  return new Promise(function (resolve, reject) {
1242
- return _this18._socket.emit('getObject', id, function (err, obj) {
1276
+ return _this19._socket.emit('getObject', id, function (err, obj) {
1243
1277
  return err ? reject(err) : resolve(obj);
1244
1278
  });
1245
1279
  });
@@ -1259,7 +1293,7 @@ var Connection = /*#__PURE__*/function () {
1259
1293
  }, {
1260
1294
  key: "getAdapterInstances",
1261
1295
  value: function getAdapterInstances(adapter, update) {
1262
- var _this19 = this;
1296
+ var _this20 = this;
1263
1297
  if (typeof adapter === 'boolean') {
1264
1298
  update = adapter;
1265
1299
  adapter = '';
@@ -1274,7 +1308,7 @@ var Connection = /*#__PURE__*/function () {
1274
1308
  this._promises["instances_".concat(adapter)] = new Promise(function (resolve, reject) {
1275
1309
  var timeout = setTimeout(function () {
1276
1310
  timeout = null;
1277
- _this19.getObjectView("system.adapter.".concat(adapter ? "".concat(adapter, ".") : ''), "system.adapter.".concat(adapter ? "".concat(adapter, ".") : '', "\u9999"), 'instance').then(function (items) {
1311
+ _this20.getObjectView("system.adapter.".concat(adapter ? "".concat(adapter, ".") : ''), "system.adapter.".concat(adapter ? "".concat(adapter, ".") : '', "\u9999"), 'instance').then(function (items) {
1278
1312
  return resolve(Object.keys(items).map(function (id) {
1279
1313
  return fixAdminUI(items[id]);
1280
1314
  }));
@@ -1282,7 +1316,7 @@ var Connection = /*#__PURE__*/function () {
1282
1316
  return reject(e);
1283
1317
  });
1284
1318
  }, TIMEOUT_FOR_ADMIN4);
1285
- _this19._socket.emit('getAdapterInstances', adapter, function (err, instances) {
1319
+ _this20._socket.emit('getAdapterInstances', adapter, function (err, instances) {
1286
1320
  if (timeout) {
1287
1321
  clearTimeout(timeout);
1288
1322
  timeout = null;
@@ -1307,7 +1341,7 @@ var Connection = /*#__PURE__*/function () {
1307
1341
  }, {
1308
1342
  key: "getAdapters",
1309
1343
  value: function getAdapters(adapter, update) {
1310
- var _this20 = this;
1344
+ var _this21 = this;
1311
1345
  if (Connection.isWeb()) {
1312
1346
  return Promise.reject('Allowed only in admin');
1313
1347
  }
@@ -1325,7 +1359,7 @@ var Connection = /*#__PURE__*/function () {
1325
1359
  this._promises["adapter_".concat(adapter)] = new Promise(function (resolve, reject) {
1326
1360
  var timeout = setTimeout(function () {
1327
1361
  timeout = null;
1328
- _this20.getObjectView("system.adapter.".concat(adapter, "."), "system.adapter.".concat(adapter, ".\u9999"), 'adapter').then(function (items) {
1362
+ _this21.getObjectView("system.adapter.".concat(adapter, "."), "system.adapter.".concat(adapter, ".\u9999"), 'adapter').then(function (items) {
1329
1363
  return resolve(Object.keys(items).map(function (id) {
1330
1364
  return fixAdminUI(items[id]);
1331
1365
  }));
@@ -1333,7 +1367,7 @@ var Connection = /*#__PURE__*/function () {
1333
1367
  return reject(e);
1334
1368
  });
1335
1369
  }, TIMEOUT_FOR_ADMIN4);
1336
- _this20._socket.emit('getAdapters', adapter, function (err, adapters) {
1370
+ _this21._socket.emit('getAdapters', adapter, function (err, adapters) {
1337
1371
  if (timeout) {
1338
1372
  clearTimeout(timeout);
1339
1373
  timeout = null;
@@ -1353,7 +1387,7 @@ var Connection = /*#__PURE__*/function () {
1353
1387
  }, {
1354
1388
  key: "_renameGroups",
1355
1389
  value: function _renameGroups(objs, cb) {
1356
- var _this21 = this;
1390
+ var _this22 = this;
1357
1391
  if (!objs || !objs.length) {
1358
1392
  cb && cb();
1359
1393
  } else {
@@ -1362,10 +1396,10 @@ var Connection = /*#__PURE__*/function () {
1362
1396
  obj._id = obj.newId;
1363
1397
  delete obj.newId;
1364
1398
  this.setObject(obj._id, obj).then(function () {
1365
- return _this21.delObject(oldId);
1399
+ return _this22.delObject(oldId);
1366
1400
  }).then(function () {
1367
1401
  return setTimeout(function () {
1368
- return _this21._renameGroups(objs, cb);
1402
+ return _this22._renameGroups(objs, cb);
1369
1403
  }, 0);
1370
1404
  })["catch"](function (err) {
1371
1405
  return cb && cb(err);
@@ -1382,7 +1416,7 @@ var Connection = /*#__PURE__*/function () {
1382
1416
  }, {
1383
1417
  key: "renameGroup",
1384
1418
  value: function renameGroup(id, newId, newName) {
1385
- var _this22 = this;
1419
+ var _this23 = this;
1386
1420
  if (Connection.isWeb()) {
1387
1421
  return Promise.reject('Allowed only in admin');
1388
1422
  }
@@ -1396,7 +1430,7 @@ var Connection = /*#__PURE__*/function () {
1396
1430
  return group.newId = newId + group._id.substring(id.length);
1397
1431
  });
1398
1432
  return new Promise(function (resolve, reject) {
1399
- return _this22._renameGroups(groupsToRename, function (err) {
1433
+ return _this23._renameGroups(groupsToRename, function (err) {
1400
1434
  return err ? reject(err) : resolve();
1401
1435
  });
1402
1436
  }).then(function () {
@@ -1409,8 +1443,8 @@ var Connection = /*#__PURE__*/function () {
1409
1443
  obj.common = obj.common || {};
1410
1444
  obj.common.name = newName;
1411
1445
  }
1412
- return _this22.setObject(obj._id, obj).then(function () {
1413
- return _this22.delObject(id);
1446
+ return _this23.setObject(obj._id, obj).then(function () {
1447
+ return _this23.delObject(id);
1414
1448
  });
1415
1449
  }
1416
1450
  });
@@ -1428,12 +1462,12 @@ var Connection = /*#__PURE__*/function () {
1428
1462
  }, {
1429
1463
  key: "sendTo",
1430
1464
  value: function sendTo(instance, command, data) {
1431
- var _this23 = this;
1465
+ var _this24 = this;
1432
1466
  if (!this.connected) {
1433
1467
  return Promise.reject(NOT_CONNECTED);
1434
1468
  }
1435
1469
  return new Promise(function (resolve) {
1436
- return _this23._socket.emit('sendTo', instance, command, data, function (result) {
1470
+ return _this24._socket.emit('sendTo', instance, command, data, function (result) {
1437
1471
  return resolve(result);
1438
1472
  });
1439
1473
  });
@@ -1447,7 +1481,7 @@ var Connection = /*#__PURE__*/function () {
1447
1481
  }, {
1448
1482
  key: "extendObject",
1449
1483
  value: function extendObject(id, obj) {
1450
- var _this24 = this;
1484
+ var _this25 = this;
1451
1485
  if (!this.connected) {
1452
1486
  return Promise.reject(NOT_CONNECTED);
1453
1487
  }
@@ -1462,7 +1496,7 @@ var Connection = /*#__PURE__*/function () {
1462
1496
  delete obj.ts;
1463
1497
  }
1464
1498
  return new Promise(function (resolve, reject) {
1465
- return _this24._socket.emit('extendObject', id, obj, function (err) {
1499
+ return _this25._socket.emit('extendObject', id, obj, function (err) {
1466
1500
  return err ? reject(err) : resolve();
1467
1501
  });
1468
1502
  });
@@ -1582,7 +1616,7 @@ var Connection = /*#__PURE__*/function () {
1582
1616
  }, {
1583
1617
  key: "getEnums",
1584
1618
  value: function getEnums(_enum, update) {
1585
- var _this25 = this;
1619
+ var _this26 = this;
1586
1620
  if (!update && this._promises["enums_".concat(_enum || 'all')]) {
1587
1621
  return this._promises["enums_".concat(_enum || 'all')];
1588
1622
  }
@@ -1590,7 +1624,7 @@ var Connection = /*#__PURE__*/function () {
1590
1624
  return Promise.reject(NOT_CONNECTED);
1591
1625
  }
1592
1626
  this._promises["enums_".concat(_enum || 'all')] = new Promise(function (resolve, reject) {
1593
- _this25._socket.emit('getObjectView', 'system', 'enum', {
1627
+ _this26._socket.emit('getObjectView', 'system', 'enum', {
1594
1628
  startkey: "enum.".concat(_enum || ''),
1595
1629
  endkey: "enum.".concat(_enum ? "".concat(_enum, ".") : '', "\u9999")
1596
1630
  }, function (err, res) {
@@ -1621,9 +1655,9 @@ var Connection = /*#__PURE__*/function () {
1621
1655
  }, {
1622
1656
  key: "getObjectViewCustom",
1623
1657
  value: function getObjectViewCustom(design, type, start, end) {
1624
- var _this26 = this;
1658
+ var _this27 = this;
1625
1659
  return new Promise(function (resolve, reject) {
1626
- _this26._socket.emit('getObjectView', design, type, {
1660
+ _this27._socket.emit('getObjectView', design, type, {
1627
1661
  startkey: start,
1628
1662
  endkey: end
1629
1663
  }, function (err, res) {
@@ -1742,7 +1776,7 @@ var Connection = /*#__PURE__*/function () {
1742
1776
  }, {
1743
1777
  key: "getLogs",
1744
1778
  value: function getLogs(host, linesNumber) {
1745
- var _this27 = this;
1779
+ var _this28 = this;
1746
1780
  if (Connection.isWeb()) {
1747
1781
  return Promise.reject('Allowed only in admin');
1748
1782
  }
@@ -1750,7 +1784,7 @@ var Connection = /*#__PURE__*/function () {
1750
1784
  return Promise.reject(NOT_CONNECTED);
1751
1785
  }
1752
1786
  return new Promise(function (resolve) {
1753
- return _this27._socket.emit('sendToHost', host, 'getLogs', linesNumber || 200, function (lines) {
1787
+ return _this28._socket.emit('sendToHost', host, 'getLogs', linesNumber || 200, function (lines) {
1754
1788
  return resolve(lines);
1755
1789
  });
1756
1790
  });
@@ -1763,7 +1797,7 @@ var Connection = /*#__PURE__*/function () {
1763
1797
  }, {
1764
1798
  key: "getLogsFiles",
1765
1799
  value: function getLogsFiles(host) {
1766
- var _this28 = this;
1800
+ var _this29 = this;
1767
1801
  if (Connection.isWeb()) {
1768
1802
  return Promise.reject('Allowed only in admin');
1769
1803
  }
@@ -1771,7 +1805,7 @@ var Connection = /*#__PURE__*/function () {
1771
1805
  return Promise.reject(NOT_CONNECTED);
1772
1806
  }
1773
1807
  return new Promise(function (resolve, reject) {
1774
- return _this28._socket.emit('readLogs', host, function (err, files) {
1808
+ return _this29._socket.emit('readLogs', host, function (err, files) {
1775
1809
  return err ? reject(err) : resolve(files);
1776
1810
  });
1777
1811
  });
@@ -1785,7 +1819,7 @@ var Connection = /*#__PURE__*/function () {
1785
1819
  }, {
1786
1820
  key: "delLogs",
1787
1821
  value: function delLogs(host) {
1788
- var _this29 = this;
1822
+ var _this30 = this;
1789
1823
  if (Connection.isWeb()) {
1790
1824
  return Promise.reject('Allowed only in admin');
1791
1825
  }
@@ -1793,7 +1827,7 @@ var Connection = /*#__PURE__*/function () {
1793
1827
  return Promise.reject(NOT_CONNECTED);
1794
1828
  }
1795
1829
  return new Promise(function (resolve, reject) {
1796
- return _this29._socket.emit('sendToHost', host, 'delLogs', null, function (error) {
1830
+ return _this30._socket.emit('sendToHost', host, 'delLogs', null, function (error) {
1797
1831
  return error ? reject(error) : resolve();
1798
1832
  });
1799
1833
  });
@@ -1806,12 +1840,12 @@ var Connection = /*#__PURE__*/function () {
1806
1840
  }, {
1807
1841
  key: "readMetaItems",
1808
1842
  value: function readMetaItems() {
1809
- var _this30 = this;
1843
+ var _this31 = this;
1810
1844
  if (!this.connected) {
1811
1845
  return Promise.reject(NOT_CONNECTED);
1812
1846
  }
1813
1847
  return new Promise(function (resolve, reject) {
1814
- return _this30._socket.emit('getObjectView', 'system', 'meta', {
1848
+ return _this31._socket.emit('getObjectView', 'system', 'meta', {
1815
1849
  startkey: '',
1816
1850
  endkey: "\u9999"
1817
1851
  }, function (err, objs) {
@@ -1831,12 +1865,12 @@ var Connection = /*#__PURE__*/function () {
1831
1865
  }, {
1832
1866
  key: "readDir",
1833
1867
  value: function readDir(adapter, fileName) {
1834
- var _this31 = this;
1868
+ var _this32 = this;
1835
1869
  if (!this.connected) {
1836
1870
  return Promise.reject(NOT_CONNECTED);
1837
1871
  }
1838
1872
  return new Promise(function (resolve, reject) {
1839
- return _this31._socket.emit('readDir', adapter, fileName, function (err, files) {
1873
+ return _this32._socket.emit('readDir', adapter, fileName, function (err, files) {
1840
1874
  return err ? reject(err) : resolve(files);
1841
1875
  });
1842
1876
  });
@@ -1852,13 +1886,13 @@ var Connection = /*#__PURE__*/function () {
1852
1886
  }, {
1853
1887
  key: "readFile",
1854
1888
  value: function readFile(adapter, fileName, base64) {
1855
- var _this32 = this;
1889
+ var _this33 = this;
1856
1890
  if (!this.connected) {
1857
1891
  return Promise.reject(NOT_CONNECTED);
1858
1892
  }
1859
1893
  return new Promise(function (resolve, reject) {
1860
1894
  if (!base64) {
1861
- _this32._socket.emit('readFile', adapter, fileName, function (err, data, type) {
1895
+ _this33._socket.emit('readFile', adapter, fileName, function (err, data, type) {
1862
1896
  //@ts-ignore
1863
1897
  err ? reject(err) : resolve({
1864
1898
  data: data,
@@ -1866,7 +1900,7 @@ var Connection = /*#__PURE__*/function () {
1866
1900
  });
1867
1901
  });
1868
1902
  } else {
1869
- _this32._socket.emit('readFile64', adapter, fileName, base64, function (err, data) {
1903
+ _this33._socket.emit('readFile64', adapter, fileName, base64, function (err, data) {
1870
1904
  return err ? reject(err) : resolve(data);
1871
1905
  });
1872
1906
  }
@@ -1883,20 +1917,20 @@ var Connection = /*#__PURE__*/function () {
1883
1917
  }, {
1884
1918
  key: "writeFile64",
1885
1919
  value: function writeFile64(adapter, fileName, data) {
1886
- var _this33 = this;
1920
+ var _this34 = this;
1887
1921
  if (!this.connected) {
1888
1922
  return Promise.reject(NOT_CONNECTED);
1889
1923
  }
1890
1924
  return new Promise(function (resolve, reject) {
1891
1925
  if (typeof data === 'string') {
1892
- _this33._socket.emit('writeFile', adapter, fileName, data, function (err) {
1926
+ _this34._socket.emit('writeFile', adapter, fileName, data, function (err) {
1893
1927
  return err ? reject(err) : resolve();
1894
1928
  });
1895
1929
  } else {
1896
1930
  var base64 = btoa(new Uint8Array(data).reduce(function (data, _byte) {
1897
1931
  return data + String.fromCharCode(_byte);
1898
1932
  }, ''));
1899
- _this33._socket.emit('writeFile64', adapter, fileName, base64, function (err) {
1933
+ _this34._socket.emit('writeFile64', adapter, fileName, base64, function (err) {
1900
1934
  return err ? reject(err) : resolve();
1901
1935
  });
1902
1936
  }
@@ -1912,12 +1946,12 @@ var Connection = /*#__PURE__*/function () {
1912
1946
  }, {
1913
1947
  key: "deleteFile",
1914
1948
  value: function deleteFile(adapter, fileName) {
1915
- var _this34 = this;
1949
+ var _this35 = this;
1916
1950
  if (!this.connected) {
1917
1951
  return Promise.reject(NOT_CONNECTED);
1918
1952
  }
1919
1953
  return new Promise(function (resolve, reject) {
1920
- return _this34._socket.emit('unlink', adapter, fileName, function (err) {
1954
+ return _this35._socket.emit('unlink', adapter, fileName, function (err) {
1921
1955
  return err ? reject(err) : resolve();
1922
1956
  });
1923
1957
  });
@@ -1933,12 +1967,12 @@ var Connection = /*#__PURE__*/function () {
1933
1967
  }, {
1934
1968
  key: "deleteFolder",
1935
1969
  value: function deleteFolder(adapter, folderName) {
1936
- var _this35 = this;
1970
+ var _this36 = this;
1937
1971
  if (!this.connected) {
1938
1972
  return Promise.reject(NOT_CONNECTED);
1939
1973
  }
1940
1974
  return new Promise(function (resolve, reject) {
1941
- return _this35._socket.emit('deleteFolder', adapter, folderName, function (err) {
1975
+ return _this36._socket.emit('deleteFolder', adapter, folderName, function (err) {
1942
1976
  return err ? reject(err) : resolve();
1943
1977
  });
1944
1978
  });
@@ -1952,7 +1986,7 @@ var Connection = /*#__PURE__*/function () {
1952
1986
  }, {
1953
1987
  key: "getHosts",
1954
1988
  value: function getHosts(update) {
1955
- var _this36 = this;
1989
+ var _this37 = this;
1956
1990
  if (Connection.isWeb()) {
1957
1991
  return Promise.reject('Allowed only in admin');
1958
1992
  }
@@ -1963,7 +1997,7 @@ var Connection = /*#__PURE__*/function () {
1963
1997
  return Promise.reject(NOT_CONNECTED);
1964
1998
  }
1965
1999
  this._promises.hosts = new Promise(function (resolve, reject) {
1966
- return _this36._socket.emit('getObjectView', 'system', 'host', {
2000
+ return _this37._socket.emit('getObjectView', 'system', 'host', {
1967
2001
  startkey: 'system.host.',
1968
2002
  endkey: "system.host.\u9999"
1969
2003
  }, function (err, doc) {
@@ -1987,7 +2021,7 @@ var Connection = /*#__PURE__*/function () {
1987
2021
  }, {
1988
2022
  key: "getUsers",
1989
2023
  value: function getUsers(update) {
1990
- var _this37 = this;
2024
+ var _this38 = this;
1991
2025
  if (Connection.isWeb()) {
1992
2026
  return Promise.reject('Allowed only in admin');
1993
2027
  }
@@ -1998,7 +2032,7 @@ var Connection = /*#__PURE__*/function () {
1998
2032
  return Promise.reject(NOT_CONNECTED);
1999
2033
  }
2000
2034
  this._promises.users = new Promise(function (resolve, reject) {
2001
- return _this37._socket.emit('getObjectView', 'system', 'user', {
2035
+ return _this38._socket.emit('getObjectView', 'system', 'user', {
2002
2036
  startkey: 'system.user.',
2003
2037
  endkey: "system.user.\u9999"
2004
2038
  }, function (err, doc) {
@@ -2022,7 +2056,7 @@ var Connection = /*#__PURE__*/function () {
2022
2056
  }, {
2023
2057
  key: "getGroups",
2024
2058
  value: function getGroups(update) {
2025
- var _this38 = this;
2059
+ var _this39 = this;
2026
2060
  if (!update && this._promises.groups) {
2027
2061
  return this._promises.groups;
2028
2062
  }
@@ -2030,7 +2064,7 @@ var Connection = /*#__PURE__*/function () {
2030
2064
  return Promise.reject(NOT_CONNECTED);
2031
2065
  }
2032
2066
  this._promises.groups = new Promise(function (resolve, reject) {
2033
- return _this38._socket.emit('getObjectView', 'system', 'group', {
2067
+ return _this39._socket.emit('getObjectView', 'system', 'group', {
2034
2068
  startkey: 'system.group.',
2035
2069
  endkey: "system.group.\u9999"
2036
2070
  }, function (err, doc) {
@@ -2056,7 +2090,7 @@ var Connection = /*#__PURE__*/function () {
2056
2090
  }, {
2057
2091
  key: "getHostInfo",
2058
2092
  value: function getHostInfo(host, update, timeoutMs) {
2059
- var _this39 = this;
2093
+ var _this40 = this;
2060
2094
  if (Connection.isWeb()) {
2061
2095
  return Promise.reject('Allowed only in admin');
2062
2096
  }
@@ -2076,8 +2110,8 @@ var Connection = /*#__PURE__*/function () {
2076
2110
  timeout = null;
2077
2111
  reject('getHostInfo timeout');
2078
2112
  }
2079
- }, timeoutMs || _this39.props.cmdTimeout);
2080
- _this39._socket.emit('sendToHost', host, 'getHostInfo', null, function (data) {
2113
+ }, timeoutMs || _this40.props.cmdTimeout);
2114
+ _this40._socket.emit('sendToHost', host, 'getHostInfo', null, function (data) {
2081
2115
  if (timeout) {
2082
2116
  clearTimeout(timeout);
2083
2117
  timeout = null;
@@ -2104,7 +2138,7 @@ var Connection = /*#__PURE__*/function () {
2104
2138
  }, {
2105
2139
  key: "getHostInfoShort",
2106
2140
  value: function getHostInfoShort(host, update, timeoutMs) {
2107
- var _this40 = this;
2141
+ var _this41 = this;
2108
2142
  if (Connection.isWeb()) {
2109
2143
  return Promise.reject('Allowed only in admin');
2110
2144
  }
@@ -2124,8 +2158,8 @@ var Connection = /*#__PURE__*/function () {
2124
2158
  timeout = null;
2125
2159
  reject('hostInfoShort timeout');
2126
2160
  }
2127
- }, timeoutMs || _this40.props.cmdTimeout);
2128
- _this40._socket.emit('sendToHost', host, 'getHostInfoShort', null, function (data) {
2161
+ }, timeoutMs || _this41.props.cmdTimeout);
2162
+ _this41._socket.emit('sendToHost', host, 'getHostInfoShort', null, function (data) {
2129
2163
  if (timeout) {
2130
2164
  clearTimeout(timeout);
2131
2165
  timeout = null;
@@ -2153,7 +2187,7 @@ var Connection = /*#__PURE__*/function () {
2153
2187
  }, {
2154
2188
  key: "getRepository",
2155
2189
  value: function getRepository(host, args, update, timeoutMs) {
2156
- var _this41 = this;
2190
+ var _this42 = this;
2157
2191
  if (Connection.isWeb()) {
2158
2192
  return Promise.reject('Allowed only in admin');
2159
2193
  }
@@ -2172,8 +2206,8 @@ var Connection = /*#__PURE__*/function () {
2172
2206
  timeout = null;
2173
2207
  reject('getRepository timeout');
2174
2208
  }
2175
- }, timeoutMs || _this41.props.cmdTimeout);
2176
- _this41._socket.emit('sendToHost', host, 'getRepository', args, function (data) {
2209
+ }, timeoutMs || _this42.props.cmdTimeout);
2210
+ _this42._socket.emit('sendToHost', host, 'getRepository', args, function (data) {
2177
2211
  if (timeout) {
2178
2212
  clearTimeout(timeout);
2179
2213
  timeout = null;
@@ -2200,7 +2234,7 @@ var Connection = /*#__PURE__*/function () {
2200
2234
  }, {
2201
2235
  key: "getInstalled",
2202
2236
  value: function getInstalled(host, update, cmdTimeout) {
2203
- var _this42 = this;
2237
+ var _this43 = this;
2204
2238
  if (Connection.isWeb()) {
2205
2239
  return Promise.reject('Allowed only in admin');
2206
2240
  }
@@ -2220,8 +2254,8 @@ var Connection = /*#__PURE__*/function () {
2220
2254
  timeout = null;
2221
2255
  reject('getInstalled timeout');
2222
2256
  }
2223
- }, cmdTimeout || _this42.props.cmdTimeout);
2224
- _this42._socket.emit('sendToHost', host, 'getInstalled', null, function (data) {
2257
+ }, cmdTimeout || _this43.props.cmdTimeout);
2258
+ _this43._socket.emit('sendToHost', host, 'getInstalled', null, function (data) {
2225
2259
  if (timeout) {
2226
2260
  clearTimeout(timeout);
2227
2261
  timeout = null;
@@ -2247,12 +2281,12 @@ var Connection = /*#__PURE__*/function () {
2247
2281
  }, {
2248
2282
  key: "rename",
2249
2283
  value: function rename(adapter, oldName, newName) {
2250
- var _this43 = this;
2284
+ var _this44 = this;
2251
2285
  if (!this.connected) {
2252
2286
  return Promise.reject(NOT_CONNECTED);
2253
2287
  }
2254
2288
  return new Promise(function (resolve, reject) {
2255
- return _this43._socket.emit('rename', adapter, oldName, newName, function (err) {
2289
+ return _this44._socket.emit('rename', adapter, oldName, newName, function (err) {
2256
2290
  return err ? reject(err) : resolve();
2257
2291
  });
2258
2292
  });
@@ -2267,12 +2301,12 @@ var Connection = /*#__PURE__*/function () {
2267
2301
  }, {
2268
2302
  key: "renameFile",
2269
2303
  value: function renameFile(adapter, oldName, newName) {
2270
- var _this44 = this;
2304
+ var _this45 = this;
2271
2305
  if (!this.connected) {
2272
2306
  return Promise.reject(NOT_CONNECTED);
2273
2307
  }
2274
2308
  return new Promise(function (resolve, reject) {
2275
- return _this44._socket.emit('renameFile', adapter, oldName, newName, function (err) {
2309
+ return _this45._socket.emit('renameFile', adapter, oldName, newName, function (err) {
2276
2310
  return err ? reject(err) : resolve();
2277
2311
  });
2278
2312
  });
@@ -2289,7 +2323,7 @@ var Connection = /*#__PURE__*/function () {
2289
2323
  }, {
2290
2324
  key: "cmdExec",
2291
2325
  value: function cmdExec(host, cmd, cmdId, cmdTimeout) {
2292
- var _this45 = this;
2326
+ var _this46 = this;
2293
2327
  if (Connection.isWeb()) {
2294
2328
  return Promise.reject('Allowed only in admin');
2295
2329
  }
@@ -2306,7 +2340,7 @@ var Connection = /*#__PURE__*/function () {
2306
2340
  reject('cmdExec timeout');
2307
2341
  }
2308
2342
  }, cmdTimeout);
2309
- _this45._socket.emit('cmdExec', host, cmdId, cmd, null, function (err) {
2343
+ _this46._socket.emit('cmdExec', host, cmdId, cmd, null, function (err) {
2310
2344
  if (!cmdTimeout || timeout) {
2311
2345
  timeout && clearTimeout(timeout);
2312
2346
  timeout = null;
@@ -2329,7 +2363,7 @@ var Connection = /*#__PURE__*/function () {
2329
2363
  }, {
2330
2364
  key: "checkFeatureSupported",
2331
2365
  value: function checkFeatureSupported(feature, update) {
2332
- var _this46 = this;
2366
+ var _this47 = this;
2333
2367
  var cache = "supportedFeatures_".concat(feature);
2334
2368
  if (!update && this._promises[cache]) {
2335
2369
  return this._promises[cache];
@@ -2338,7 +2372,7 @@ var Connection = /*#__PURE__*/function () {
2338
2372
  return Promise.reject(NOT_CONNECTED);
2339
2373
  }
2340
2374
  this._promises[cache] = new Promise(function (resolve, reject) {
2341
- return _this46._socket.emit('checkFeatureSupported', feature, function (err, features) {
2375
+ return _this47._socket.emit('checkFeatureSupported', feature, function (err, features) {
2342
2376
  err ? reject(err) : resolve(features);
2343
2377
  });
2344
2378
  });
@@ -2353,13 +2387,13 @@ var Connection = /*#__PURE__*/function () {
2353
2387
  }, {
2354
2388
  key: "readBaseSettings",
2355
2389
  value: function readBaseSettings(host) {
2356
- var _this47 = this;
2390
+ var _this48 = this;
2357
2391
  if (Connection.isWeb()) {
2358
2392
  return Promise.reject('Allowed only in admin');
2359
2393
  }
2360
2394
  return this.checkFeatureSupported('CONTROLLER_READWRITE_BASE_SETTINGS').then(function (result) {
2361
2395
  if (result) {
2362
- if (!_this47.connected) {
2396
+ if (!_this48.connected) {
2363
2397
  return Promise.reject(NOT_CONNECTED);
2364
2398
  }
2365
2399
  return new Promise(function (resolve, reject) {
@@ -2368,11 +2402,11 @@ var Connection = /*#__PURE__*/function () {
2368
2402
  timeout = null;
2369
2403
  reject('readBaseSettings timeout');
2370
2404
  }
2371
- }, _this47.props.cmdTimeout);
2405
+ }, _this48.props.cmdTimeout);
2372
2406
  if (host.startsWith('system.host.')) {
2373
2407
  host = host.replace(/^system\.host\./, '');
2374
2408
  }
2375
- _this47._socket.emit('sendToHost', host, 'readBaseSettings', null, function (data) {
2409
+ _this48._socket.emit('sendToHost', host, 'readBaseSettings', null, function (data) {
2376
2410
  if (timeout) {
2377
2411
  clearTimeout(timeout);
2378
2412
  timeout = null;
@@ -2400,13 +2434,13 @@ var Connection = /*#__PURE__*/function () {
2400
2434
  }, {
2401
2435
  key: "writeBaseSettings",
2402
2436
  value: function writeBaseSettings(host, config) {
2403
- var _this48 = this;
2437
+ var _this49 = this;
2404
2438
  if (Connection.isWeb()) {
2405
2439
  return Promise.reject('Allowed only in admin');
2406
2440
  }
2407
2441
  return this.checkFeatureSupported('CONTROLLER_READWRITE_BASE_SETTINGS').then(function (result) {
2408
2442
  if (result) {
2409
- if (!_this48.connected) {
2443
+ if (!_this49.connected) {
2410
2444
  return Promise.reject(NOT_CONNECTED);
2411
2445
  }
2412
2446
  return new Promise(function (resolve, reject) {
@@ -2415,8 +2449,8 @@ var Connection = /*#__PURE__*/function () {
2415
2449
  timeout = null;
2416
2450
  reject('writeBaseSettings timeout');
2417
2451
  }
2418
- }, _this48.props.cmdTimeout);
2419
- _this48._socket.emit('sendToHost', host, 'writeBaseSettings', config, function (data) {
2452
+ }, _this49.props.cmdTimeout);
2453
+ _this49._socket.emit('sendToHost', host, 'writeBaseSettings', config, function (data) {
2420
2454
  if (timeout) {
2421
2455
  clearTimeout(timeout);
2422
2456
  timeout = null;
@@ -2443,12 +2477,12 @@ var Connection = /*#__PURE__*/function () {
2443
2477
  }, {
2444
2478
  key: "restartController",
2445
2479
  value: function restartController(host) {
2446
- var _this49 = this;
2480
+ var _this50 = this;
2447
2481
  if (Connection.isWeb()) {
2448
2482
  return Promise.reject('Allowed only in admin');
2449
2483
  }
2450
2484
  return new Promise(function (resolve, reject) {
2451
- _this49._socket.emit('sendToHost', host, 'restartController', null, function (error) {
2485
+ _this50._socket.emit('sendToHost', host, 'restartController', null, function (error) {
2452
2486
  error ? reject(error) : resolve(true);
2453
2487
  });
2454
2488
  });
@@ -2463,12 +2497,12 @@ var Connection = /*#__PURE__*/function () {
2463
2497
  }, {
2464
2498
  key: "getDiagData",
2465
2499
  value: function getDiagData(host, typeOfDiag) {
2466
- var _this50 = this;
2500
+ var _this51 = this;
2467
2501
  if (Connection.isWeb()) {
2468
2502
  return Promise.reject('Allowed only in admin');
2469
2503
  }
2470
2504
  return new Promise(function (resolve) {
2471
- _this50._socket.emit('sendToHost', host, 'getDiagData', typeOfDiag, function (result) {
2505
+ _this51._socket.emit('sendToHost', host, 'getDiagData', typeOfDiag, function (result) {
2472
2506
  return resolve(result);
2473
2507
  });
2474
2508
  });
@@ -2482,19 +2516,19 @@ var Connection = /*#__PURE__*/function () {
2482
2516
  }, {
2483
2517
  key: "getForeignStates",
2484
2518
  value: function getForeignStates(pattern) {
2485
- var _this51 = this;
2519
+ var _this52 = this;
2486
2520
  if (!this.connected) {
2487
2521
  return Promise.reject(NOT_CONNECTED);
2488
2522
  }
2489
2523
  if (Connection.isWeb()) {
2490
2524
  return new Promise(function (resolve, reject) {
2491
- return _this51._socket.emit('getStates', pattern || '*', function (err, states) {
2525
+ return _this52._socket.emit('getStates', pattern || '*', function (err, states) {
2492
2526
  return err ? reject(err) : resolve(states);
2493
2527
  });
2494
2528
  });
2495
2529
  }
2496
2530
  return new Promise(function (resolve, reject) {
2497
- return _this51._socket.emit('getForeignStates', pattern || '*', function (err, states) {
2531
+ return _this52._socket.emit('getForeignStates', pattern || '*', function (err, states) {
2498
2532
  return err ? reject(err) : resolve(states);
2499
2533
  });
2500
2534
  });
@@ -2509,12 +2543,12 @@ var Connection = /*#__PURE__*/function () {
2509
2543
  }, {
2510
2544
  key: "getForeignObjects",
2511
2545
  value: function getForeignObjects(pattern, type) {
2512
- var _this52 = this;
2546
+ var _this53 = this;
2513
2547
  if (!this.connected) {
2514
2548
  return Promise.reject(NOT_CONNECTED);
2515
2549
  }
2516
2550
  return new Promise(function (resolve, reject) {
2517
- return _this52._socket.emit('getForeignObjects', pattern || '*', type, function (err, states) {
2551
+ return _this53._socket.emit('getForeignObjects', pattern || '*', type, function (err, states) {
2518
2552
  return err ? reject(err) : resolve(states);
2519
2553
  });
2520
2554
  });
@@ -2554,9 +2588,9 @@ var Connection = /*#__PURE__*/function () {
2554
2588
  }, {
2555
2589
  key: "setSystemConfig",
2556
2590
  value: function setSystemConfig(obj) {
2557
- var _this53 = this;
2591
+ var _this54 = this;
2558
2592
  return this.setObject('system.config', obj).then(function () {
2559
- return _this53._promises.systemConfig = Promise.resolve(obj);
2593
+ return _this54._promises.systemConfig = Promise.resolve(obj);
2560
2594
  });
2561
2595
  }
2562
2596
 
@@ -2579,12 +2613,12 @@ var Connection = /*#__PURE__*/function () {
2579
2613
  }, {
2580
2614
  key: "getHistory",
2581
2615
  value: function getHistory(id, options) {
2582
- var _this54 = this;
2616
+ var _this55 = this;
2583
2617
  if (!this.connected) {
2584
2618
  return Promise.reject(NOT_CONNECTED);
2585
2619
  }
2586
2620
  return new Promise(function (resolve, reject) {
2587
- return _this54._socket.emit('getHistory', id, options, function (err, values) {
2621
+ return _this55._socket.emit('getHistory', id, options, function (err, values) {
2588
2622
  return err ? reject(err) : resolve(values);
2589
2623
  });
2590
2624
  });
@@ -2599,12 +2633,12 @@ var Connection = /*#__PURE__*/function () {
2599
2633
  }, {
2600
2634
  key: "getHistoryEx",
2601
2635
  value: function getHistoryEx(id, options) {
2602
- var _this55 = this;
2636
+ var _this56 = this;
2603
2637
  if (!this.connected) {
2604
2638
  return Promise.reject(NOT_CONNECTED);
2605
2639
  }
2606
2640
  return new Promise(function (resolve, reject) {
2607
- return _this55._socket.emit('getHistory', id, options, function (err, values, stepIgnore, sessionId) {
2641
+ return _this56._socket.emit('getHistory', id, options, function (err, values, stepIgnore, sessionId) {
2608
2642
  return err ? reject(err) : resolve({
2609
2643
  values: values,
2610
2644
  sessionId: sessionId,
@@ -2623,12 +2657,12 @@ var Connection = /*#__PURE__*/function () {
2623
2657
  }, {
2624
2658
  key: "changePassword",
2625
2659
  value: function changePassword(user, password) {
2626
- var _this56 = this;
2660
+ var _this57 = this;
2627
2661
  if (Connection.isWeb()) {
2628
2662
  return Promise.reject('Allowed only in admin');
2629
2663
  }
2630
2664
  return new Promise(function (resolve, reject) {
2631
- return _this56._socket.emit('changePassword', user, password, function (err) {
2665
+ return _this57._socket.emit('changePassword', user, password, function (err) {
2632
2666
  return err ? reject(err) : resolve();
2633
2667
  });
2634
2668
  });
@@ -2667,7 +2701,7 @@ var Connection = /*#__PURE__*/function () {
2667
2701
  }, {
2668
2702
  key: "getHostByIp",
2669
2703
  value: function getHostByIp(ipOrHostName, update) {
2670
- var _this57 = this;
2704
+ var _this58 = this;
2671
2705
  if (Connection.isWeb()) {
2672
2706
  return Promise.reject('Allowed only in admin');
2673
2707
  }
@@ -2679,7 +2713,7 @@ var Connection = /*#__PURE__*/function () {
2679
2713
  return this._promises[cache];
2680
2714
  }
2681
2715
  this._promises[cache] = new Promise(function (resolve) {
2682
- return _this57._socket.emit('getHostByIp', ipOrHostName, function (ip, host) {
2716
+ return _this58._socket.emit('getHostByIp', ipOrHostName, function (ip, host) {
2683
2717
  var _host$native;
2684
2718
  var IPs4 = [{
2685
2719
  name: '[IPv4] 0.0.0.0 - Listen on all IPs',
@@ -2730,12 +2764,12 @@ var Connection = /*#__PURE__*/function () {
2730
2764
  }, {
2731
2765
  key: "encrypt",
2732
2766
  value: function encrypt(text) {
2733
- var _this58 = this;
2767
+ var _this59 = this;
2734
2768
  if (Connection.isWeb()) {
2735
2769
  return Promise.reject('Allowed only in admin');
2736
2770
  }
2737
2771
  return new Promise(function (resolve, reject) {
2738
- return _this58._socket.emit('encrypt', text, function (err, text) {
2772
+ return _this59._socket.emit('encrypt', text, function (err, text) {
2739
2773
  return err ? reject(err) : resolve(text);
2740
2774
  });
2741
2775
  });
@@ -2749,12 +2783,12 @@ var Connection = /*#__PURE__*/function () {
2749
2783
  }, {
2750
2784
  key: "decrypt",
2751
2785
  value: function decrypt(encryptedText) {
2752
- var _this59 = this;
2786
+ var _this60 = this;
2753
2787
  if (Connection.isWeb()) {
2754
2788
  return Promise.reject('Allowed only in admin');
2755
2789
  }
2756
2790
  return new Promise(function (resolve, reject) {
2757
- return _this59._socket.emit('decrypt', encryptedText, function (err, text) {
2791
+ return _this60._socket.emit('decrypt', encryptedText, function (err, text) {
2758
2792
  return err ? reject(err) : resolve(text);
2759
2793
  });
2760
2794
  });
@@ -2767,12 +2801,12 @@ var Connection = /*#__PURE__*/function () {
2767
2801
  }, {
2768
2802
  key: "getVersion",
2769
2803
  value: function getVersion(update) {
2770
- var _this60 = this;
2804
+ var _this61 = this;
2771
2805
  if (update && this._promises.version) {
2772
2806
  this._promises.version = null;
2773
2807
  }
2774
2808
  this._promises.version = this._promises.version || new Promise(function (resolve, reject) {
2775
- return _this60._socket.emit('getVersion', function (err, version, serverName) {
2809
+ return _this61._socket.emit('getVersion', function (err, version, serverName) {
2776
2810
  // support of old socket.io
2777
2811
  if (err && !version && typeof err === 'string' && err.match(/\d+\.\d+\.\d+/)) {
2778
2812
  resolve({
@@ -2797,9 +2831,9 @@ var Connection = /*#__PURE__*/function () {
2797
2831
  }, {
2798
2832
  key: "getWebServerName",
2799
2833
  value: function getWebServerName() {
2800
- var _this61 = this;
2834
+ var _this62 = this;
2801
2835
  this._promises.webName = this._promises.webName || new Promise(function (resolve, reject) {
2802
- return _this61._socket.emit('getAdapterName', function (err, name) {
2836
+ return _this62._socket.emit('getAdapterName', function (err, name) {
2803
2837
  return err ? reject(err) : resolve(name);
2804
2838
  });
2805
2839
  });
@@ -2828,7 +2862,7 @@ var Connection = /*#__PURE__*/function () {
2828
2862
  }, {
2829
2863
  key: "chmodFile",
2830
2864
  value: function chmodFile(adapter, filename, options) {
2831
- var _this62 = this;
2865
+ var _this63 = this;
2832
2866
  if (Connection.isWeb()) {
2833
2867
  return Promise.reject('Allowed only in admin');
2834
2868
  }
@@ -2836,7 +2870,7 @@ var Connection = /*#__PURE__*/function () {
2836
2870
  return Promise.reject(NOT_CONNECTED);
2837
2871
  }
2838
2872
  return new Promise(function (resolve, reject) {
2839
- return _this62._socket.emit('chmodFile', adapter, filename, options, function (err, entries, id) {
2873
+ return _this63._socket.emit('chmodFile', adapter, filename, options, function (err, entries, id) {
2840
2874
  return err ? reject(err) : resolve({
2841
2875
  entries: entries,
2842
2876
  id: id
@@ -2855,7 +2889,7 @@ var Connection = /*#__PURE__*/function () {
2855
2889
  }, {
2856
2890
  key: "chownFile",
2857
2891
  value: function chownFile(adapter, filename, options) {
2858
- var _this63 = this;
2892
+ var _this64 = this;
2859
2893
  if (Connection.isWeb()) {
2860
2894
  return Promise.reject('Allowed only in admin');
2861
2895
  }
@@ -2863,7 +2897,7 @@ var Connection = /*#__PURE__*/function () {
2863
2897
  return Promise.reject(NOT_CONNECTED);
2864
2898
  }
2865
2899
  return new Promise(function (resolve, reject) {
2866
- return _this63._socket.emit('chownFile', adapter, filename, options, function (err, entries, id) {
2900
+ return _this64._socket.emit('chownFile', adapter, filename, options, function (err, entries, id) {
2867
2901
  return err ? reject(err) : resolve({
2868
2902
  entries: entries,
2869
2903
  id: id
@@ -2881,12 +2915,12 @@ var Connection = /*#__PURE__*/function () {
2881
2915
  }, {
2882
2916
  key: "fileExists",
2883
2917
  value: function fileExists(adapter, filename) {
2884
- var _this64 = this;
2918
+ var _this65 = this;
2885
2919
  if (!this.connected) {
2886
2920
  return Promise.reject(NOT_CONNECTED);
2887
2921
  }
2888
2922
  return new Promise(function (resolve, reject) {
2889
- return _this64._socket.emit('fileExists', adapter, filename, function (err, exists) {
2923
+ return _this65._socket.emit('fileExists', adapter, filename, function (err, exists) {
2890
2924
  return err ? reject(err) : resolve(exists);
2891
2925
  });
2892
2926
  });
@@ -2901,7 +2935,7 @@ var Connection = /*#__PURE__*/function () {
2901
2935
  }, {
2902
2936
  key: "getNotifications",
2903
2937
  value: function getNotifications(host, category) {
2904
- var _this65 = this;
2938
+ var _this66 = this;
2905
2939
  if (Connection.isWeb()) {
2906
2940
  return Promise.reject('Allowed only in admin');
2907
2941
  }
@@ -2909,7 +2943,7 @@ var Connection = /*#__PURE__*/function () {
2909
2943
  return Promise.reject(NOT_CONNECTED);
2910
2944
  }
2911
2945
  return new Promise(function (resolve) {
2912
- return _this65._socket.emit('sendToHost', host, 'getNotifications', {
2946
+ return _this66._socket.emit('sendToHost', host, 'getNotifications', {
2913
2947
  category: category
2914
2948
  }, function (notifications) {
2915
2949
  return resolve(notifications);
@@ -2926,7 +2960,7 @@ var Connection = /*#__PURE__*/function () {
2926
2960
  }, {
2927
2961
  key: "clearNotifications",
2928
2962
  value: function clearNotifications(host, category) {
2929
- var _this66 = this;
2963
+ var _this67 = this;
2930
2964
  if (Connection.isWeb()) {
2931
2965
  return Promise.reject('Allowed only in admin');
2932
2966
  }
@@ -2934,7 +2968,7 @@ var Connection = /*#__PURE__*/function () {
2934
2968
  return Promise.reject(NOT_CONNECTED);
2935
2969
  }
2936
2970
  return new Promise(function (resolve) {
2937
- return _this66._socket.emit('sendToHost', host, 'clearNotifications', {
2971
+ return _this67._socket.emit('sendToHost', host, 'clearNotifications', {
2938
2972
  category: category
2939
2973
  }, function (notifications) {
2940
2974
  return resolve(notifications);
@@ -2949,7 +2983,7 @@ var Connection = /*#__PURE__*/function () {
2949
2983
  }, {
2950
2984
  key: "getIsEasyModeStrict",
2951
2985
  value: function getIsEasyModeStrict() {
2952
- var _this67 = this;
2986
+ var _this68 = this;
2953
2987
  if (Connection.isWeb()) {
2954
2988
  return Promise.reject('Allowed only in admin');
2955
2989
  }
@@ -2957,7 +2991,7 @@ var Connection = /*#__PURE__*/function () {
2957
2991
  return Promise.reject(NOT_CONNECTED);
2958
2992
  }
2959
2993
  return new Promise(function (resolve, reject) {
2960
- return _this67._socket.emit('getIsEasyModeStrict', function (error, isStrict) {
2994
+ return _this68._socket.emit('getIsEasyModeStrict', function (error, isStrict) {
2961
2995
  return error ? reject(error) : resolve(isStrict);
2962
2996
  });
2963
2997
  });
@@ -2970,7 +3004,7 @@ var Connection = /*#__PURE__*/function () {
2970
3004
  }, {
2971
3005
  key: "getEasyMode",
2972
3006
  value: function getEasyMode() {
2973
- var _this68 = this;
3007
+ var _this69 = this;
2974
3008
  if (Connection.isWeb()) {
2975
3009
  return Promise.reject('Allowed only in admin');
2976
3010
  }
@@ -2978,7 +3012,7 @@ var Connection = /*#__PURE__*/function () {
2978
3012
  return Promise.reject(NOT_CONNECTED);
2979
3013
  }
2980
3014
  return new Promise(function (resolve, reject) {
2981
- return _this68._socket.emit('getEasyMode', function (error, config) {
3015
+ return _this69._socket.emit('getEasyMode', function (error, config) {
2982
3016
  return error ? reject(error) : resolve(config);
2983
3017
  });
2984
3018
  });
@@ -2991,12 +3025,12 @@ var Connection = /*#__PURE__*/function () {
2991
3025
  }, {
2992
3026
  key: "getCurrentUser",
2993
3027
  value: function getCurrentUser() {
2994
- var _this69 = this;
3028
+ var _this70 = this;
2995
3029
  if (!this.connected) {
2996
3030
  return Promise.reject(NOT_CONNECTED);
2997
3031
  }
2998
3032
  return new Promise(function (resolve) {
2999
- return _this69._socket.emit('authEnabled', function (isSecure, user) {
3033
+ return _this70._socket.emit('authEnabled', function (isSecure, user) {
3000
3034
  return resolve(user);
3001
3035
  });
3002
3036
  });
@@ -3039,7 +3073,7 @@ var Connection = /*#__PURE__*/function () {
3039
3073
  }, {
3040
3074
  key: "getRatings",
3041
3075
  value: function getRatings(update) {
3042
- var _this70 = this;
3076
+ var _this71 = this;
3043
3077
  if (Connection.isWeb()) {
3044
3078
  return Promise.reject('Allowed only in admin');
3045
3079
  }
@@ -3047,7 +3081,7 @@ var Connection = /*#__PURE__*/function () {
3047
3081
  return Promise.reject(NOT_CONNECTED);
3048
3082
  }
3049
3083
  return new Promise(function (resolve, reject) {
3050
- return _this70._socket.emit('getRatings', update, function (err, ratings) {
3084
+ return _this71._socket.emit('getRatings', update, function (err, ratings) {
3051
3085
  return err ? reject(err) : resolve(ratings);
3052
3086
  });
3053
3087
  });
@@ -3060,12 +3094,12 @@ var Connection = /*#__PURE__*/function () {
3060
3094
  }, {
3061
3095
  key: "getCurrentInstance",
3062
3096
  value: function getCurrentInstance() {
3063
- var _this71 = this;
3097
+ var _this72 = this;
3064
3098
  if (!this.connected) {
3065
3099
  return Promise.reject(NOT_CONNECTED);
3066
3100
  }
3067
3101
  this._promises.currentInstance = this._promises.currentInstance || new Promise(function (resolve, reject) {
3068
- return _this71._socket.emit('getCurrentInstance', function (err, namespace) {
3102
+ return _this72._socket.emit('getCurrentInstance', function (err, namespace) {
3069
3103
  return err ? reject(err) : resolve(namespace);
3070
3104
  });
3071
3105
  });
@@ -3076,7 +3110,7 @@ var Connection = /*#__PURE__*/function () {
3076
3110
  }, {
3077
3111
  key: "getCompactAdapters",
3078
3112
  value: function getCompactAdapters(update) {
3079
- var _this72 = this;
3113
+ var _this73 = this;
3080
3114
  if (Connection.isWeb()) {
3081
3115
  return Promise.reject('Allowed only in admin');
3082
3116
  }
@@ -3087,7 +3121,7 @@ var Connection = /*#__PURE__*/function () {
3087
3121
  return Promise.reject(NOT_CONNECTED);
3088
3122
  }
3089
3123
  this._promises.compactAdapters = new Promise(function (resolve, reject) {
3090
- return _this72._socket.emit('getCompactAdapters', function (err, adapters) {
3124
+ return _this73._socket.emit('getCompactAdapters', function (err, adapters) {
3091
3125
  return err ? reject(err) : resolve(adapters);
3092
3126
  });
3093
3127
  });
@@ -3105,7 +3139,7 @@ var Connection = /*#__PURE__*/function () {
3105
3139
  }, {
3106
3140
  key: "getCompactInstances",
3107
3141
  value: function getCompactInstances(update) {
3108
- var _this73 = this;
3142
+ var _this74 = this;
3109
3143
  if (Connection.isWeb()) {
3110
3144
  return Promise.reject('Allowed only in admin');
3111
3145
  }
@@ -3116,7 +3150,7 @@ var Connection = /*#__PURE__*/function () {
3116
3150
  return Promise.reject(NOT_CONNECTED);
3117
3151
  }
3118
3152
  this._promises.compactInstances = new Promise(function (resolve, reject) {
3119
- return _this73._socket.emit('getCompactInstances', function (err, instances) {
3153
+ return _this74._socket.emit('getCompactInstances', function (err, instances) {
3120
3154
  return err ? reject(err) : resolve(instances);
3121
3155
  });
3122
3156
  });
@@ -3135,7 +3169,7 @@ var Connection = /*#__PURE__*/function () {
3135
3169
  }, {
3136
3170
  key: "getCompactInstalled",
3137
3171
  value: function getCompactInstalled(host, update, cmdTimeout) {
3138
- var _this74 = this;
3172
+ var _this75 = this;
3139
3173
  if (Connection.isWeb()) {
3140
3174
  return Promise.reject('Allowed only in admin');
3141
3175
  }
@@ -3155,8 +3189,8 @@ var Connection = /*#__PURE__*/function () {
3155
3189
  timeout = null;
3156
3190
  reject('getCompactInstalled timeout');
3157
3191
  }
3158
- }, cmdTimeout || _this74.props.cmdTimeout);
3159
- _this74._socket.emit('getCompactInstalled', host, function (data) {
3192
+ }, cmdTimeout || _this75.props.cmdTimeout);
3193
+ _this75._socket.emit('getCompactInstalled', host, function (data) {
3160
3194
  if (timeout) {
3161
3195
  clearTimeout(timeout);
3162
3196
  timeout = null;
@@ -3178,7 +3212,7 @@ var Connection = /*#__PURE__*/function () {
3178
3212
  }, {
3179
3213
  key: "getCompactSystemRepositories",
3180
3214
  value: function getCompactSystemRepositories(update, cmdTimeout) {
3181
- var _this75 = this;
3215
+ var _this76 = this;
3182
3216
  if (Connection.isWeb()) {
3183
3217
  return Promise.reject('Allowed only in admin');
3184
3218
  }
@@ -3192,8 +3226,8 @@ var Connection = /*#__PURE__*/function () {
3192
3226
  timeout = null;
3193
3227
  reject('getCompactSystemRepositories timeout');
3194
3228
  }
3195
- }, cmdTimeout || _this75.props.cmdTimeout);
3196
- _this75._socket.emit('getCompactSystemRepositories', function (data) {
3229
+ }, cmdTimeout || _this76.props.cmdTimeout);
3230
+ _this76._socket.emit('getCompactSystemRepositories', function (data) {
3197
3231
  if (timeout) {
3198
3232
  clearTimeout(timeout);
3199
3233
  timeout = null;
@@ -3227,7 +3261,7 @@ var Connection = /*#__PURE__*/function () {
3227
3261
  value:
3228
3262
  // returns very optimized information for adapters to minimize connection load
3229
3263
  function getCompactSystemConfig(update) {
3230
- var _this76 = this;
3264
+ var _this77 = this;
3231
3265
  if (!update && this._promises.systemConfigCommon) {
3232
3266
  return this._promises.systemConfigCommon;
3233
3267
  }
@@ -3235,7 +3269,7 @@ var Connection = /*#__PURE__*/function () {
3235
3269
  return Promise.reject(NOT_CONNECTED);
3236
3270
  }
3237
3271
  this._promises.systemConfigCommon = new Promise(function (resolve, reject) {
3238
- return _this76._socket.emit('getCompactSystemConfig', function (err, systemConfig) {
3272
+ return _this77._socket.emit('getCompactSystemConfig', function (err, systemConfig) {
3239
3273
  return err ? reject(err) : resolve(systemConfig);
3240
3274
  });
3241
3275
  });
@@ -3252,7 +3286,7 @@ var Connection = /*#__PURE__*/function () {
3252
3286
  }, {
3253
3287
  key: "getCompactRepository",
3254
3288
  value: function getCompactRepository(host, update, timeoutMs) {
3255
- var _this77 = this;
3289
+ var _this78 = this;
3256
3290
  if (Connection.isWeb()) {
3257
3291
  return Promise.reject('Allowed only in admin');
3258
3292
  }
@@ -3271,8 +3305,8 @@ var Connection = /*#__PURE__*/function () {
3271
3305
  timeout = null;
3272
3306
  reject('getCompactRepository timeout');
3273
3307
  }
3274
- }, timeoutMs || _this77.props.cmdTimeout);
3275
- _this77._socket.emit('getCompactRepository', host, function (data) {
3308
+ }, timeoutMs || _this78.props.cmdTimeout);
3309
+ _this78._socket.emit('getCompactRepository', host, function (data) {
3276
3310
  if (timeout) {
3277
3311
  clearTimeout(timeout);
3278
3312
  timeout = null;
@@ -3291,7 +3325,7 @@ var Connection = /*#__PURE__*/function () {
3291
3325
  }, {
3292
3326
  key: "getCompactHosts",
3293
3327
  value: function getCompactHosts(update) {
3294
- var _this78 = this;
3328
+ var _this79 = this;
3295
3329
  if (Connection.isWeb()) {
3296
3330
  return Promise.reject('Allowed only in admin');
3297
3331
  }
@@ -3302,7 +3336,7 @@ var Connection = /*#__PURE__*/function () {
3302
3336
  return Promise.reject(NOT_CONNECTED);
3303
3337
  }
3304
3338
  this._promises.hostsCompact = new Promise(function (resolve, reject) {
3305
- return _this78._socket.emit('getCompactHosts', function (err, hosts) {
3339
+ return _this79._socket.emit('getCompactHosts', function (err, hosts) {
3306
3340
  return err ? reject(err) : resolve(hosts);
3307
3341
  });
3308
3342
  });
@@ -3342,12 +3376,12 @@ var Connection = /*#__PURE__*/function () {
3342
3376
  }, {
3343
3377
  key: "subscribeOnInstance",
3344
3378
  value: function subscribeOnInstance(targetInstance, messageType, data, callback) {
3345
- var _this79 = this;
3379
+ var _this80 = this;
3346
3380
  if (!this.connected) {
3347
3381
  return Promise.reject(NOT_CONNECTED);
3348
3382
  }
3349
3383
  return new Promise(function (resolve, reject) {
3350
- return _this79._socket.emit('clientSubscribe', targetInstance, messageType, data, function (err, result) {
3384
+ return _this80._socket.emit('clientSubscribe', targetInstance, messageType, data, function (err, result) {
3351
3385
  if (err) {
3352
3386
  reject(err);
3353
3387
  } else if (result && result.error) {
@@ -3357,11 +3391,11 @@ var Connection = /*#__PURE__*/function () {
3357
3391
  targetInstance = "system.adapter.".concat(targetInstance);
3358
3392
  }
3359
3393
  // save callback
3360
- _this79._instanceSubscriptions[targetInstance] = _this79._instanceSubscriptions[targetInstance] || [];
3361
- if (!_this79._instanceSubscriptions[targetInstance].find(function (sub) {
3394
+ _this80._instanceSubscriptions[targetInstance] = _this80._instanceSubscriptions[targetInstance] || [];
3395
+ if (!_this80._instanceSubscriptions[targetInstance].find(function (sub) {
3362
3396
  return sub.messageType === messageType && sub.callback === callback;
3363
3397
  })) {
3364
- _this79._instanceSubscriptions[targetInstance].push({
3398
+ _this80._instanceSubscriptions[targetInstance].push({
3365
3399
  messageType: messageType,
3366
3400
  callback: callback
3367
3401
  });
@@ -3376,43 +3410,59 @@ var Connection = /*#__PURE__*/function () {
3376
3410
  * Unsubscribe from instance message
3377
3411
  * @param {string} [targetInstance] instance, like 'cameras.0'
3378
3412
  * @param {string} [messageType] message type like 'startCamera/cam3'
3379
- * @param {function} [callback] message handler
3413
+ * @param {function} [callback] message handler. Could be null if all callbacks for this messageType should be unsubscribed
3380
3414
  * @returns {Promise<boolean>}
3381
3415
  */
3382
3416
  }, {
3383
3417
  key: "unsubscribeFromInstance",
3384
3418
  value: function unsubscribeFromInstance(targetInstance, messageType, callback) {
3385
- var _this$_instanceSubscr,
3386
- _this80 = this;
3419
+ var _this81 = this;
3387
3420
  if (!targetInstance.startsWith('system.adapter.')) {
3388
3421
  targetInstance = "system.adapter.".concat(targetInstance);
3389
3422
  }
3390
- var index = (_this$_instanceSubscr = this._instanceSubscriptions[targetInstance]) === null || _this$_instanceSubscr === void 0 ? void 0 : _this$_instanceSubscr.findIndex(function (sub) {
3391
- return sub.messageType === messageType && sub.callback === callback;
3392
- });
3393
- if (index !== undefined && index !== null && index !== -1) {
3394
- // remember messageType
3395
- var _messageType = this._instanceSubscriptions[targetInstance][index].messageType;
3396
- this._instanceSubscriptions[targetInstance].splice(index, 1);
3397
- if (!this._instanceSubscriptions[targetInstance].length) {
3398
- delete this._instanceSubscriptions[targetInstance];
3399
- }
3423
+ var deleted;
3424
+ var promiseResults = [];
3425
+ var _loop = function _loop() {
3426
+ var _this81$_instanceSubs;
3427
+ deleted = false;
3428
+ var index = (_this81$_instanceSubs = _this81._instanceSubscriptions[targetInstance]) === null || _this81$_instanceSubs === void 0 ? void 0 : _this81$_instanceSubs.findIndex(function (sub) {
3429
+ return (!messageType || sub.messageType === messageType) && (!callback || sub.callback === callback);
3430
+ });
3431
+ if (index !== undefined && index !== null && index !== -1) {
3432
+ deleted = true;
3433
+ // remember messageType
3434
+ var _messageType = _this81._instanceSubscriptions[targetInstance][index].messageType;
3435
+ _this81._instanceSubscriptions[targetInstance].splice(index, 1);
3436
+ if (!_this81._instanceSubscriptions[targetInstance].length) {
3437
+ delete _this81._instanceSubscriptions[targetInstance];
3438
+ }
3400
3439
 
3401
- // try to find another subscription for this instance and messageType
3402
- var found = this._instanceSubscriptions[targetInstance] && this._instanceSubscriptions[targetInstance].find(function (sub) {
3403
- return sub.messageType === _messageType;
3404
- });
3405
- if (!found) {
3406
- return new Promise(function (resolve, reject) {
3407
- return _this80._socket.emit('clientUnsubscribe', targetInstance, messageType, function (err, wasSubscribed) {
3408
- if (err) {
3409
- reject(err);
3410
- } else {
3411
- resolve(wasSubscribed);
3412
- }
3413
- });
3440
+ // try to find another subscription for this instance and messageType
3441
+ var found = _this81._instanceSubscriptions[targetInstance] && _this81._instanceSubscriptions[targetInstance].find(function (sub) {
3442
+ return sub.messageType === _messageType;
3414
3443
  });
3444
+ if (!found) {
3445
+ promiseResults.push(new Promise(function (resolve, reject) {
3446
+ return _this81._socket.emit('clientUnsubscribe', targetInstance, messageType, function (err, wasSubscribed) {
3447
+ if (err) {
3448
+ reject(err);
3449
+ } else {
3450
+ resolve(wasSubscribed);
3451
+ }
3452
+ });
3453
+ }));
3454
+ }
3415
3455
  }
3456
+ };
3457
+ do {
3458
+ _loop();
3459
+ } while (deleted && (!callback || !messageType));
3460
+ if (promiseResults.length) {
3461
+ return Promise.all(promiseResults).then(function (results) {
3462
+ return results.find(function (result) {
3463
+ return result;
3464
+ }) || false;
3465
+ });
3416
3466
  }
3417
3467
  return Promise.resolve(false);
3418
3468
  }
@@ -3436,12 +3486,12 @@ var Connection = /*#__PURE__*/function () {
3436
3486
  }, {
3437
3487
  key: "logout",
3438
3488
  value: function logout() {
3439
- var _this81 = this;
3489
+ var _this82 = this;
3440
3490
  if (!this.connected) {
3441
3491
  return Promise.reject(NOT_CONNECTED);
3442
3492
  }
3443
3493
  return new Promise(function (resolve, reject) {
3444
- return _this81._socket.emit('logout', function (err) {
3494
+ return _this82._socket.emit('logout', function (err) {
3445
3495
  return err ? reject(err) : resolve(null);
3446
3496
  });
3447
3497
  });