@iobroker/adapter-react-v5 7.4.2 → 7.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/Components/FileBrowser.js +1 -1
- package/build/Components/FileBrowser.js.map +1 -1
- package/build/Components/IconPicker.js +0 -1
- package/build/Components/IconPicker.js.map +1 -1
- package/build/Components/Image.js.map +1 -1
- package/build/Components/Logo.js +4 -4
- package/build/Components/Logo.js.map +1 -1
- package/build/Components/ObjectBrowser.d.ts +8 -6
- package/build/Components/ObjectBrowser.js +1 -1
- package/build/Components/ObjectBrowser.js.map +1 -1
- package/build/Components/TextWithIcon.js +0 -1
- package/build/Components/TextWithIcon.js.map +1 -1
- package/build/Components/Utils.js +1 -3
- package/build/Components/Utils.js.map +1 -1
- package/build/Dialogs/SelectID.d.ts +2 -2
- package/build/Dialogs/SelectID.js +1 -1
- package/build/Dialogs/SelectID.js.map +1 -1
- package/build/GenericApp.js +1 -1
- package/build/GenericApp.js.map +1 -1
- package/build/LegacyConnection.d.ts +4 -7
- package/build/LegacyConnection.js +84 -159
- package/build/LegacyConnection.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/types.d.ts +80 -0
- package/package.json +13 -13
|
@@ -13,73 +13,10 @@ export const PROGRESS = {
|
|
|
13
13
|
};
|
|
14
14
|
const PERMISSION_ERROR = 'permissionError';
|
|
15
15
|
const NOT_CONNECTED = 'notConnectedError';
|
|
16
|
-
const TIMEOUT_FOR_ADMIN4 = 1300;
|
|
17
16
|
export const ERRORS = {
|
|
18
17
|
PERMISSION_ERROR,
|
|
19
18
|
NOT_CONNECTED,
|
|
20
19
|
};
|
|
21
|
-
function fixAdminUI(obj) {
|
|
22
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
23
|
-
if (obj?.common && !obj.common.adminUI) {
|
|
24
|
-
if (obj.common.noConfig) {
|
|
25
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
26
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
27
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
28
|
-
obj.common.adminUI.config = 'none';
|
|
29
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
30
|
-
}
|
|
31
|
-
else if (obj.common.jsonConfig) {
|
|
32
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
33
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
34
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
35
|
-
obj.common.adminUI.config = 'json';
|
|
36
|
-
}
|
|
37
|
-
else if (obj.common.materialize) {
|
|
38
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
39
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
40
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
41
|
-
obj.common.adminUI.config = 'materialize';
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
45
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
46
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
47
|
-
obj.common.adminUI.config = 'html';
|
|
48
|
-
}
|
|
49
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
50
|
-
if (obj.common.jsonCustom) {
|
|
51
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
52
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
53
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
54
|
-
obj.common.adminUI.custom = 'json';
|
|
55
|
-
}
|
|
56
|
-
else if (obj.common.supportCustoms) {
|
|
57
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
58
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
59
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
60
|
-
obj.common.adminUI.custom = 'json';
|
|
61
|
-
}
|
|
62
|
-
if (obj.common.materializeTab && obj.common.adminTab) {
|
|
63
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
64
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
65
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
66
|
-
obj.common.adminUI.tab = 'materialize';
|
|
67
|
-
}
|
|
68
|
-
else if (obj.common.adminTab) {
|
|
69
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
70
|
-
obj.common.adminUI = obj.common.adminUI || {};
|
|
71
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
72
|
-
obj.common.adminUI.tab = 'html';
|
|
73
|
-
}
|
|
74
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
75
|
-
if (obj.common.adminUI) {
|
|
76
|
-
console.debug(
|
|
77
|
-
// @ts-expect-error it is deprecated, but still could appear
|
|
78
|
-
`Please add to "${obj._id.replace(/\.\d+$/, '')}" common.adminUI=${JSON.stringify(obj.common.adminUI)}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return obj;
|
|
82
|
-
}
|
|
83
20
|
/** Converts ioB pattern into regex */
|
|
84
21
|
export function pattern2RegEx(pattern) {
|
|
85
22
|
pattern = (pattern || '').toString();
|
|
@@ -117,7 +54,6 @@ export class LegacyConnection {
|
|
|
117
54
|
loaded = false;
|
|
118
55
|
loadTimer = null;
|
|
119
56
|
loadCounter = 0;
|
|
120
|
-
admin5only;
|
|
121
57
|
ignoreState = '';
|
|
122
58
|
simStates = {};
|
|
123
59
|
autoSubscribes;
|
|
@@ -152,7 +88,6 @@ export class LegacyConnection {
|
|
|
152
88
|
this.onError =
|
|
153
89
|
this.props.onError ||
|
|
154
90
|
((err) => console.error(err));
|
|
155
|
-
this.admin5only = this.props.admin5only || false;
|
|
156
91
|
this.startSocket();
|
|
157
92
|
}
|
|
158
93
|
/**
|
|
@@ -412,14 +347,9 @@ export class LegacyConnection {
|
|
|
412
347
|
this.acl = acl;
|
|
413
348
|
}
|
|
414
349
|
// Read system configuration
|
|
415
|
-
let
|
|
350
|
+
let systemConfig;
|
|
416
351
|
try {
|
|
417
|
-
|
|
418
|
-
data = await this.getCompactSystemConfig();
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
data = await this.getSystemConfig();
|
|
422
|
-
}
|
|
352
|
+
systemConfig = await this.getSystemConfig();
|
|
423
353
|
if (this.doNotLoadACL) {
|
|
424
354
|
if (this.loaded) {
|
|
425
355
|
return;
|
|
@@ -430,7 +360,7 @@ export class LegacyConnection {
|
|
|
430
360
|
this.onProgress(PROGRESS.CONNECTED);
|
|
431
361
|
this.firstConnect = false;
|
|
432
362
|
}
|
|
433
|
-
this.systemConfig =
|
|
363
|
+
this.systemConfig = systemConfig;
|
|
434
364
|
if (this.systemConfig && this.systemConfig.common) {
|
|
435
365
|
this.systemLang = this.systemConfig.common.language;
|
|
436
366
|
}
|
|
@@ -451,7 +381,7 @@ export class LegacyConnection {
|
|
|
451
381
|
this.props.onReady && this.objects && this.props.onReady(this.objects);
|
|
452
382
|
}
|
|
453
383
|
else {
|
|
454
|
-
this.objects =
|
|
384
|
+
this.objects = { 'system.config': systemConfig };
|
|
455
385
|
this.onProgress(PROGRESS.READY);
|
|
456
386
|
this.props.onReady && this.props.onReady(this.objects);
|
|
457
387
|
}
|
|
@@ -478,7 +408,7 @@ export class LegacyConnection {
|
|
|
478
408
|
* @param binary Set to true if the given state is binary and requires Base64 decoding
|
|
479
409
|
* @param cb The callback
|
|
480
410
|
*/
|
|
481
|
-
subscribeState(id, binary, cb) {
|
|
411
|
+
async subscribeState(id, binary, cb) {
|
|
482
412
|
if (typeof binary === 'function') {
|
|
483
413
|
cb = binary;
|
|
484
414
|
binary = false;
|
|
@@ -492,7 +422,7 @@ export class LegacyConnection {
|
|
|
492
422
|
}
|
|
493
423
|
if (!cb) {
|
|
494
424
|
console.error('No callback found for subscribeState');
|
|
495
|
-
return;
|
|
425
|
+
return Promise.reject(new Error('No callback found for subscribeState'));
|
|
496
426
|
}
|
|
497
427
|
const toSubscribe = [];
|
|
498
428
|
for (let i = 0; i < ids.length; i++) {
|
|
@@ -525,16 +455,35 @@ export class LegacyConnection {
|
|
|
525
455
|
this._socket.emit('subscribe', toSubscribe);
|
|
526
456
|
}
|
|
527
457
|
if (binary) {
|
|
458
|
+
let base64;
|
|
528
459
|
for (let i = 0; i < ids.length; i++) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
460
|
+
try {
|
|
461
|
+
// deprecated, but we still support it
|
|
462
|
+
base64 = await this.getBinaryState(ids[i]);
|
|
463
|
+
}
|
|
464
|
+
catch (e) {
|
|
465
|
+
console.error(`Cannot getBinaryState "${ids[i]}": ${JSON.stringify(e)}`);
|
|
466
|
+
base64 = undefined;
|
|
467
|
+
}
|
|
468
|
+
if (base64 !== undefined && cb) {
|
|
469
|
+
cb(ids[i], base64);
|
|
470
|
+
}
|
|
532
471
|
}
|
|
533
472
|
}
|
|
534
473
|
else {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
474
|
+
return new Promise((resolve, reject) => {
|
|
475
|
+
this._socket.emit(LegacyConnection.isWeb() ? 'getStates' : 'getForeignStates', ids, (err, states) => {
|
|
476
|
+
if (err) {
|
|
477
|
+
console.error(`Cannot getForeignStates "${id}": ${JSON.stringify(err)}`);
|
|
478
|
+
reject(new Error(err));
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
if (states) {
|
|
482
|
+
Object.keys(states).forEach(_id => cb(_id, states[_id]));
|
|
483
|
+
}
|
|
484
|
+
resolve();
|
|
485
|
+
}
|
|
486
|
+
});
|
|
538
487
|
});
|
|
539
488
|
}
|
|
540
489
|
}
|
|
@@ -1169,26 +1118,14 @@ export class LegacyConnection {
|
|
|
1169
1118
|
adapter = '';
|
|
1170
1119
|
}
|
|
1171
1120
|
adapter = adapter || '';
|
|
1172
|
-
if (!update && this._promises[`instances_${adapter}`]) {
|
|
1121
|
+
if (!update && this._promises[`instances_${adapter}`] instanceof Promise) {
|
|
1173
1122
|
return this._promises[`instances_${adapter}`];
|
|
1174
1123
|
}
|
|
1175
1124
|
if (!this.connected) {
|
|
1176
1125
|
return Promise.reject(new Error(NOT_CONNECTED));
|
|
1177
1126
|
}
|
|
1178
1127
|
this._promises[`instances_${adapter}`] = new Promise((resolve, reject) => {
|
|
1179
|
-
|
|
1180
|
-
timeout = null;
|
|
1181
|
-
this.getObjectView(`system.adapter.${adapter ? `${adapter}.` : ''}`, `system.adapter.${adapter ? `${adapter}.` : ''}\u9999`, 'instance')
|
|
1182
|
-
.then(items => resolve(Object.keys(items).map(id => fixAdminUI(items[id]))))
|
|
1183
|
-
.catch(e => reject(new Error(e)));
|
|
1184
|
-
}, TIMEOUT_FOR_ADMIN4);
|
|
1185
|
-
this._socket.emit('getAdapterInstances', adapter, (err, instances) => {
|
|
1186
|
-
if (timeout) {
|
|
1187
|
-
clearTimeout(timeout);
|
|
1188
|
-
timeout = null;
|
|
1189
|
-
err ? reject(new Error(err)) : resolve(instances);
|
|
1190
|
-
}
|
|
1191
|
-
});
|
|
1128
|
+
this._socket.emit('getAdapterInstances', adapter, (err, instances) => err ? reject(new Error(err)) : resolve(instances));
|
|
1192
1129
|
});
|
|
1193
1130
|
return this._promises[`instances_${adapter}`];
|
|
1194
1131
|
}
|
|
@@ -1207,27 +1144,15 @@ export class LegacyConnection {
|
|
|
1207
1144
|
adapter = '';
|
|
1208
1145
|
}
|
|
1209
1146
|
adapter = adapter || '';
|
|
1210
|
-
if (!update && this._promises[`adapter_${adapter}`]) {
|
|
1147
|
+
if (!update && this._promises[`adapter_${adapter}`] instanceof Promise) {
|
|
1211
1148
|
return this._promises[`adapter_${adapter}`];
|
|
1212
1149
|
}
|
|
1213
1150
|
if (!this.connected) {
|
|
1214
1151
|
return Promise.reject(new Error(NOT_CONNECTED));
|
|
1215
1152
|
}
|
|
1216
1153
|
this._promises[`adapter_${adapter}`] = new Promise((resolve, reject) => {
|
|
1217
|
-
let timeout = setTimeout(() => {
|
|
1218
|
-
timeout = null;
|
|
1219
|
-
this.getObjectView(`system.adapter.${adapter}.`, `system.adapter.${adapter}.\u9999`, 'adapter')
|
|
1220
|
-
.then(items => {
|
|
1221
|
-
resolve(Object.keys(items).map(id => fixAdminUI(items[id])));
|
|
1222
|
-
})
|
|
1223
|
-
.catch(e => reject(new Error(e)));
|
|
1224
|
-
}, TIMEOUT_FOR_ADMIN4);
|
|
1225
1154
|
this._socket.emit('getAdapters', adapter, (err, adapters) => {
|
|
1226
|
-
|
|
1227
|
-
clearTimeout(timeout);
|
|
1228
|
-
timeout = null;
|
|
1229
|
-
err ? reject(new Error(err)) : resolve(adapters);
|
|
1230
|
-
}
|
|
1155
|
+
err ? reject(new Error(err)) : resolve(adapters);
|
|
1231
1156
|
});
|
|
1232
1157
|
});
|
|
1233
1158
|
return this._promises[`adapter_${adapter}`];
|
|
@@ -1401,7 +1326,7 @@ export class LegacyConnection {
|
|
|
1401
1326
|
_enum,
|
|
1402
1327
|
/** Force update. */
|
|
1403
1328
|
update) {
|
|
1404
|
-
if (!update && this._promises[`enums_${_enum || 'all'}`]) {
|
|
1329
|
+
if (!update && this._promises[`enums_${_enum || 'all'}`] instanceof Promise) {
|
|
1405
1330
|
return this._promises[`enums_${_enum || 'all'}`];
|
|
1406
1331
|
}
|
|
1407
1332
|
if (!this.connected) {
|
|
@@ -1498,7 +1423,7 @@ export class LegacyConnection {
|
|
|
1498
1423
|
if (LegacyConnection.isWeb()) {
|
|
1499
1424
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
1500
1425
|
}
|
|
1501
|
-
if (this._promises.cert && !update) {
|
|
1426
|
+
if (this._promises.cert instanceof Promise && !update) {
|
|
1502
1427
|
return this._promises.cert;
|
|
1503
1428
|
}
|
|
1504
1429
|
if (!this.connected) {
|
|
@@ -1703,7 +1628,7 @@ export class LegacyConnection {
|
|
|
1703
1628
|
if (LegacyConnection.isWeb()) {
|
|
1704
1629
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
1705
1630
|
}
|
|
1706
|
-
if (!update && this._promises.hosts) {
|
|
1631
|
+
if (!update && this._promises.hosts instanceof Promise) {
|
|
1707
1632
|
return this._promises.hosts;
|
|
1708
1633
|
}
|
|
1709
1634
|
if (!this.connected) {
|
|
@@ -1730,7 +1655,7 @@ export class LegacyConnection {
|
|
|
1730
1655
|
if (LegacyConnection.isWeb()) {
|
|
1731
1656
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
1732
1657
|
}
|
|
1733
|
-
if (!update && this._promises.users) {
|
|
1658
|
+
if (!update && this._promises.users instanceof Promise) {
|
|
1734
1659
|
return this._promises.users;
|
|
1735
1660
|
}
|
|
1736
1661
|
if (!this.connected) {
|
|
@@ -1754,7 +1679,7 @@ export class LegacyConnection {
|
|
|
1754
1679
|
* @param update Force update.
|
|
1755
1680
|
*/
|
|
1756
1681
|
getGroups(update) {
|
|
1757
|
-
if (!update && this._promises.groups) {
|
|
1682
|
+
if (!update && this._promises.groups instanceof Promise) {
|
|
1758
1683
|
return this._promises.groups;
|
|
1759
1684
|
}
|
|
1760
1685
|
if (!this.connected) {
|
|
@@ -1786,7 +1711,7 @@ export class LegacyConnection {
|
|
|
1786
1711
|
if (!host.startsWith('system.host.')) {
|
|
1787
1712
|
host += `system.host.${host}`;
|
|
1788
1713
|
}
|
|
1789
|
-
if (!update && this._promises[`hostInfo_${host}`]) {
|
|
1714
|
+
if (!update && this._promises[`hostInfo_${host}`] instanceof Promise) {
|
|
1790
1715
|
return this._promises[`hostInfo_${host}`];
|
|
1791
1716
|
}
|
|
1792
1717
|
if (!this.connected) {
|
|
@@ -1831,7 +1756,7 @@ export class LegacyConnection {
|
|
|
1831
1756
|
if (!host.startsWith('system.host.')) {
|
|
1832
1757
|
host += `system.host.${host}`;
|
|
1833
1758
|
}
|
|
1834
|
-
if (!update && this._promises[`hostInfoShort_${host}`]) {
|
|
1759
|
+
if (!update && this._promises[`hostInfoShort_${host}`] instanceof Promise) {
|
|
1835
1760
|
return this._promises[`hostInfoShort_${host}`];
|
|
1836
1761
|
}
|
|
1837
1762
|
if (!this.connected) {
|
|
@@ -1874,7 +1799,7 @@ export class LegacyConnection {
|
|
|
1874
1799
|
if (LegacyConnection.isWeb()) {
|
|
1875
1800
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
1876
1801
|
}
|
|
1877
|
-
if (!update && this._promises.repo) {
|
|
1802
|
+
if (!update && this._promises.repo instanceof Promise) {
|
|
1878
1803
|
return this._promises.repo;
|
|
1879
1804
|
}
|
|
1880
1805
|
if (!this.connected) {
|
|
@@ -1920,7 +1845,7 @@ export class LegacyConnection {
|
|
|
1920
1845
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
1921
1846
|
}
|
|
1922
1847
|
this._promises.installed = this._promises.installed || {};
|
|
1923
|
-
if (!update && this._promises.installed[host]) {
|
|
1848
|
+
if (!update && this._promises.installed[host] instanceof Promise) {
|
|
1924
1849
|
return this._promises.installed[host];
|
|
1925
1850
|
}
|
|
1926
1851
|
if (!this.connected) {
|
|
@@ -2038,7 +1963,7 @@ export class LegacyConnection {
|
|
|
2038
1963
|
feature,
|
|
2039
1964
|
/** Force update. */
|
|
2040
1965
|
update) {
|
|
2041
|
-
if (!update && this._promises[`supportedFeatures_${feature}`]) {
|
|
1966
|
+
if (!update && this._promises[`supportedFeatures_${feature}`] instanceof Promise) {
|
|
2042
1967
|
return this._promises[`supportedFeatures_${feature}`];
|
|
2043
1968
|
}
|
|
2044
1969
|
if (!this.connected) {
|
|
@@ -2195,7 +2120,7 @@ export class LegacyConnection {
|
|
|
2195
2120
|
* @param update Force update.
|
|
2196
2121
|
*/
|
|
2197
2122
|
getSystemConfig(update) {
|
|
2198
|
-
if (!update && this._promises.systemConfig) {
|
|
2123
|
+
if (!update && this._promises.systemConfig instanceof Promise) {
|
|
2199
2124
|
return this._promises.systemConfig;
|
|
2200
2125
|
}
|
|
2201
2126
|
if (!this.connected) {
|
|
@@ -2266,7 +2191,7 @@ export class LegacyConnection {
|
|
|
2266
2191
|
if (!host.startsWith('system.host.')) {
|
|
2267
2192
|
host = `system.host.${host}`;
|
|
2268
2193
|
}
|
|
2269
|
-
if (!update && this._promises[`IPs_${host}`]) {
|
|
2194
|
+
if (!update && this._promises[`IPs_${host}`] instanceof Promise) {
|
|
2270
2195
|
return this._promises[`IPs_${host}`];
|
|
2271
2196
|
}
|
|
2272
2197
|
this._promises[`IPs_${host}`] = this.getObject(host).then(obj => (obj?.common ? obj.common.address || [] : []));
|
|
@@ -2284,11 +2209,11 @@ export class LegacyConnection {
|
|
|
2284
2209
|
if (ipOrHostName.startsWith('system.host.')) {
|
|
2285
2210
|
ipOrHostName = ipOrHostName.replace(/^system\.host\./, '');
|
|
2286
2211
|
}
|
|
2287
|
-
if (!update && this._promises[`rIPs_${ipOrHostName}`]) {
|
|
2212
|
+
if (!update && this._promises[`rIPs_${ipOrHostName}`] instanceof Promise) {
|
|
2288
2213
|
return this._promises[`rIPs_${ipOrHostName}`];
|
|
2289
2214
|
}
|
|
2290
2215
|
this._promises[`rIPs_${ipOrHostName}`] = new Promise(resolve => {
|
|
2291
|
-
this._socket.emit('getHostByIp', ipOrHostName, (
|
|
2216
|
+
this._socket.emit('getHostByIp', ipOrHostName, (_ip, host) => {
|
|
2292
2217
|
const IPs4 = [{ name: '[IPv4] 0.0.0.0 - Listen on all IPs', address: '0.0.0.0', family: 'ipv4' }];
|
|
2293
2218
|
const IPs6 = [{ name: '[IPv6] :: - Listen on all IPs', address: '::', family: 'ipv6' }];
|
|
2294
2219
|
if (host?.native?.hardware?.networkInterfaces) {
|
|
@@ -2348,33 +2273,32 @@ export class LegacyConnection {
|
|
|
2348
2273
|
* Gets the version.
|
|
2349
2274
|
*/
|
|
2350
2275
|
getVersion(update) {
|
|
2351
|
-
if (update && this._promises.version) {
|
|
2352
|
-
|
|
2353
|
-
}
|
|
2354
|
-
this._promises.version =
|
|
2355
|
-
this.
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
});
|
|
2366
|
-
});
|
|
2276
|
+
if (!update && this._promises.version instanceof Promise) {
|
|
2277
|
+
return this._promises.version;
|
|
2278
|
+
}
|
|
2279
|
+
this._promises.version = new Promise((resolve, reject) => {
|
|
2280
|
+
this._socket.emit('getVersion', (err, version, serverName) => {
|
|
2281
|
+
// support of old socket.io
|
|
2282
|
+
if (err && !version && typeof err === 'string' && err.match(/\d+\.\d+\.\d+/)) {
|
|
2283
|
+
resolve({ version: err, serverName: 'socketio' });
|
|
2284
|
+
}
|
|
2285
|
+
else {
|
|
2286
|
+
err ? reject(new Error(err)) : resolve({ version, serverName });
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
});
|
|
2367
2290
|
return this._promises.version;
|
|
2368
2291
|
}
|
|
2369
2292
|
/**
|
|
2370
2293
|
* Gets the web server name.
|
|
2371
2294
|
*/
|
|
2372
2295
|
getWebServerName() {
|
|
2373
|
-
this._promises.webName
|
|
2374
|
-
this._promises.webName
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2296
|
+
if (this._promises.webName instanceof Promise) {
|
|
2297
|
+
return this._promises.webName;
|
|
2298
|
+
}
|
|
2299
|
+
this._promises.webName = new Promise((resolve, reject) => {
|
|
2300
|
+
this._socket.emit('getAdapterName', (err, name) => err ? reject(new Error(err)) : resolve(name));
|
|
2301
|
+
});
|
|
2378
2302
|
return this._promises.webName;
|
|
2379
2303
|
}
|
|
2380
2304
|
/**
|
|
@@ -2506,7 +2430,7 @@ export class LegacyConnection {
|
|
|
2506
2430
|
return Promise.reject(new Error(NOT_CONNECTED));
|
|
2507
2431
|
}
|
|
2508
2432
|
return new Promise(resolve => {
|
|
2509
|
-
this._socket.emit('authEnabled', (
|
|
2433
|
+
this._socket.emit('authEnabled', (_isSecure, user) => resolve(user));
|
|
2510
2434
|
});
|
|
2511
2435
|
}
|
|
2512
2436
|
getCurrentSession(cmdTimeout) {
|
|
@@ -2555,11 +2479,12 @@ export class LegacyConnection {
|
|
|
2555
2479
|
if (!this.connected) {
|
|
2556
2480
|
return Promise.reject(new Error(NOT_CONNECTED));
|
|
2557
2481
|
}
|
|
2558
|
-
this._promises.currentInstance
|
|
2559
|
-
this._promises.currentInstance
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2482
|
+
if (this._promises.currentInstance instanceof Promise) {
|
|
2483
|
+
return this._promises.currentInstance;
|
|
2484
|
+
}
|
|
2485
|
+
this._promises.currentInstance = new Promise((resolve, reject) => {
|
|
2486
|
+
this._socket.emit('getCurrentInstance', (err, namespace) => err ? reject(new Error(err)) : resolve(namespace));
|
|
2487
|
+
});
|
|
2563
2488
|
return this._promises.currentInstance;
|
|
2564
2489
|
}
|
|
2565
2490
|
// returns very optimized information for adapters to minimize a connection load
|
|
@@ -2567,7 +2492,7 @@ export class LegacyConnection {
|
|
|
2567
2492
|
if (LegacyConnection.isWeb()) {
|
|
2568
2493
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2569
2494
|
}
|
|
2570
|
-
if (!update && this._promises.compactAdapters) {
|
|
2495
|
+
if (!update && this._promises.compactAdapters instanceof Promise) {
|
|
2571
2496
|
return this._promises.compactAdapters;
|
|
2572
2497
|
}
|
|
2573
2498
|
if (!this.connected) {
|
|
@@ -2588,7 +2513,7 @@ export class LegacyConnection {
|
|
|
2588
2513
|
if (LegacyConnection.isWeb()) {
|
|
2589
2514
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2590
2515
|
}
|
|
2591
|
-
if (!update && this._promises.compactInstances) {
|
|
2516
|
+
if (!update && this._promises.compactInstances instanceof Promise) {
|
|
2592
2517
|
return this._promises.compactInstances;
|
|
2593
2518
|
}
|
|
2594
2519
|
if (!this.connected) {
|
|
@@ -2613,7 +2538,7 @@ export class LegacyConnection {
|
|
|
2613
2538
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2614
2539
|
}
|
|
2615
2540
|
this._promises.installedCompact = this._promises.installedCompact || {};
|
|
2616
|
-
if (!update && this._promises.installedCompact[host]) {
|
|
2541
|
+
if (!update && this._promises.installedCompact[host] instanceof Promise) {
|
|
2617
2542
|
return this._promises.installedCompact[host];
|
|
2618
2543
|
}
|
|
2619
2544
|
if (!this.connected) {
|
|
@@ -2653,7 +2578,7 @@ export class LegacyConnection {
|
|
|
2653
2578
|
if (LegacyConnection.isWeb()) {
|
|
2654
2579
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2655
2580
|
}
|
|
2656
|
-
if (!update && this._promises.getCompactSystemRepositories) {
|
|
2581
|
+
if (!update && this._promises.getCompactSystemRepositories instanceof Promise) {
|
|
2657
2582
|
return this._promises.getCompactSystemRepositories;
|
|
2658
2583
|
}
|
|
2659
2584
|
if (!this.connected) {
|
|
@@ -2686,7 +2611,7 @@ export class LegacyConnection {
|
|
|
2686
2611
|
}
|
|
2687
2612
|
// returns very optimized information for adapters to minimize a connection load
|
|
2688
2613
|
getCompactSystemConfig(update) {
|
|
2689
|
-
if (!update && this._promises.systemConfigPromise) {
|
|
2614
|
+
if (!update && this._promises.systemConfigPromise instanceof Promise) {
|
|
2690
2615
|
return this._promises.systemConfigPromise;
|
|
2691
2616
|
}
|
|
2692
2617
|
if (!this.connected) {
|
|
@@ -2708,7 +2633,7 @@ export class LegacyConnection {
|
|
|
2708
2633
|
if (LegacyConnection.isWeb()) {
|
|
2709
2634
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2710
2635
|
}
|
|
2711
|
-
if (!update && this._promises.repoCompact) {
|
|
2636
|
+
if (!update && this._promises.repoCompact instanceof Promise) {
|
|
2712
2637
|
return this._promises.repoCompact;
|
|
2713
2638
|
}
|
|
2714
2639
|
if (!this.connected) {
|
|
@@ -2753,7 +2678,7 @@ export class LegacyConnection {
|
|
|
2753
2678
|
if (LegacyConnection.isWeb()) {
|
|
2754
2679
|
return Promise.reject(new Error('Allowed only in admin'));
|
|
2755
2680
|
}
|
|
2756
|
-
if (!update && this._promises.hostsCompact) {
|
|
2681
|
+
if (!update && this._promises.hostsCompact instanceof Promise) {
|
|
2757
2682
|
return this._promises.hostsCompact;
|
|
2758
2683
|
}
|
|
2759
2684
|
if (!this.connected) {
|
|
@@ -2768,7 +2693,7 @@ export class LegacyConnection {
|
|
|
2768
2693
|
* Get uuid
|
|
2769
2694
|
*/
|
|
2770
2695
|
getUuid() {
|
|
2771
|
-
if (this._promises.uuid) {
|
|
2696
|
+
if (this._promises.uuid instanceof Promise) {
|
|
2772
2697
|
return this._promises.uuid;
|
|
2773
2698
|
}
|
|
2774
2699
|
if (!this.connected) {
|