@iobroker/socket-classes 0.5.3 → 0.5.4

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.
@@ -551,6 +551,10 @@ class SocketCommandsAdmin extends SocketCommands {
551
551
 
552
552
  _initCommandsUser() {
553
553
  this.commands['addUser'] = (socket, user, pass, callback) => {
554
+ // Add new user
555
+ // @param {string} user - user name, like `benjamin`
556
+ // @param {string} pass - user password
557
+ // @param {function} callback - `function (error)`
554
558
  if (this._checkPermissions(socket, 'addUser', callback, user)) {
555
559
  this._addUser(user, pass, {user: socket._acl.user}, (error, ...args) =>
556
560
  SocketCommands._fixCallback(callback, error, ...args));
@@ -558,6 +562,9 @@ class SocketCommandsAdmin extends SocketCommands {
558
562
  };
559
563
 
560
564
  this.commands['delUser'] = (socket, user, callback) => {
565
+ // Delete existing user. Admin cannot be deleted.
566
+ // @param {string} user - user name, like 'benjamin
567
+ // @param {function} callback - `function (error)`
561
568
  if (this._checkPermissions(socket, 'delUser', callback, user)) {
562
569
  this._delUser(user, {user: socket._acl.user}, (error, ...args) =>
563
570
  SocketCommands._fixCallback(callback, error, ...args));
@@ -565,6 +572,11 @@ class SocketCommandsAdmin extends SocketCommands {
565
572
  };
566
573
 
567
574
  this.commands['addGroup'] = (socket, group, desc, acl, callback) => {
575
+ // Add new group.
576
+ // @param {string} group - user name, like 'benjamin
577
+ // @param {string} desc - optional description
578
+ // @param {object} acl - optional access control list object, like `{"object":{"list":true,"read":true,"write":false,"delete":false},"state":{"list":true,"read":true,"write":true,"create":true,"delete":false},"users":{"list":true,"read":true,"write":false,"create":false,"delete":false},"other":{"execute":false,"http":true,"sendto":false},"file":{"list":true,"read":true,"write":false,"create":false,"delete":false}}`
579
+ // @param {function} callback - `function (error)`
568
580
  if (this._checkPermissions(socket, 'addGroup', callback, group)) {
569
581
  this._addGroup(group, desc, acl, {user: socket._acl.user}, (error, ...args) =>
570
582
  SocketCommands._fixCallback(callback, error, ...args));
@@ -572,12 +584,20 @@ class SocketCommandsAdmin extends SocketCommands {
572
584
  };
573
585
 
574
586
  this.commands['delGroup'] = (socket, group, callback) => {
587
+ // Delete existing group. Administrator group cannot be deleted.
588
+ // @param {string} group - group name, like 'users`
589
+ // @param {function} callback - `function (error)`
575
590
  if (this._checkPermissions(socket, 'delGroup', callback, group)) {
576
591
  this._delGroup(group, {user: socket._acl.user}, (error, ...args) =>
577
592
  SocketCommands._fixCallback(callback, error, ...args));
578
593
  }
579
594
  };
595
+
580
596
  this.commands['changePassword'] = (socket, user, pass, callback) => {
597
+ // Change user password
598
+ // @param {string} user - user name, like 'benjamin`
599
+ // @param {string} pass - new password
600
+ // @param {function} callback - `function (error)`
581
601
  if (user === socket._acl.user || this._checkPermissions(socket, 'changePassword', callback, user)) {
582
602
  try {
583
603
  this.adapter.setPassword(user, pass, {user: socket._acl.user}, (error, ...args) =>
@@ -592,6 +612,9 @@ class SocketCommandsAdmin extends SocketCommands {
592
612
 
593
613
  _initCommandsAdmin() {
594
614
  this.commands['getHostByIp'] = (socket, ip, callback) => {
615
+ // Read host object by IP address
616
+ // @param {string} ip - ip address. IPv4 or IPv6
617
+ // @param {function} callback - `function (ip, obj)`. If host not found, obj is null
595
618
  if (typeof callback !== 'function') {
596
619
  return this.adapter.log.warn('[getHostByIp] Invalid callback');
597
620
  }
@@ -632,6 +655,9 @@ class SocketCommandsAdmin extends SocketCommands {
632
655
  };
633
656
 
634
657
  this.commands['requireLog'] = (socket, isEnabled, callback) => {
658
+ // Activate or deactivate logging events. Events will be sent to the socket as `log` event. Adapter must have `common.logTransporter = true`
659
+ // @param {boolean} isEnabled - is logging enabled
660
+ // @param {function} callback - `function (error)`
635
661
  if (this._checkPermissions(socket, 'setObject', callback)) {
636
662
  if (isEnabled) {
637
663
  this.subscribe(socket, 'log', 'dummy');
@@ -646,6 +672,9 @@ class SocketCommandsAdmin extends SocketCommands {
646
672
  };
647
673
 
648
674
  this.commands['readLogs'] = (socket, host, callback) => {
675
+ // Get logs file from given host
676
+ // @param {string} host - host id, like 'system.host.raspberrypi'
677
+ // @param {function} callback - `function (error, files)`, where `files` is array of `{fileName: `log/hostname/transport/file`, size: 123}`
649
678
  if (this._checkPermissions(socket, 'readLogs', callback)) {
650
679
  let timeout = setTimeout(() => {
651
680
  if (timeout) {
@@ -713,6 +742,9 @@ class SocketCommandsAdmin extends SocketCommands {
713
742
  };
714
743
 
715
744
  this.commands['delState'] = (socket, id, callback) => {
745
+ // Delete state. Corresponding object will be deleted too.
746
+ // @param {string} id - state ID
747
+ // @param {function} callback - `function (error)`
716
748
  if (this._checkPermissions(socket, 'delState', callback, id)) {
717
749
  // clear cache
718
750
  if (this.states && this.states[id]) {
@@ -731,12 +763,18 @@ class SocketCommandsAdmin extends SocketCommands {
731
763
  // commands will be executed on host/controller
732
764
  // following response commands are expected: cmdStdout, cmdStderr, cmdExit
733
765
  this.commands['cmdExec'] = (socket, host, id, cmd, callback) => {
766
+ // Execute shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
767
+ // @param {string} host - host name, like 'system.host.raspberrypi'
768
+ // @param {string} id - session ID, like `Date.now()´. This session ID will come in events `cmdStdout, cmdStderr, cmdExit`
769
+ // @param {string} cmd - command
770
+ // @param {function} callback - `function (error)`
734
771
  if (this._checkPermissions(socket, 'cmdExec', callback, cmd)) {
735
772
  this.adapter.log.debug(`cmdExec on ${host}(${id}): ${cmd}`);
736
773
  // remember socket for this ID.
737
774
  this.cmdSessions[id] = {socket};
738
775
  try {
739
776
  this.adapter.sendToHost(host, 'cmdExec', {data: cmd, id});
777
+ SocketCommands._fixCallback(callback, null);
740
778
  } catch (error) {
741
779
  this.adapter.log.error('[cmdExec] ERROR: ' + error.toString());
742
780
  SocketCommands._fixCallback(callback, error);
@@ -745,6 +783,8 @@ class SocketCommandsAdmin extends SocketCommands {
745
783
  };
746
784
 
747
785
  this.commands['eventsThreshold'] = (socket, isActive) => {
786
+ // Used only for admin to limit number of events to front-end.
787
+ // @param {boolean} isActive - if true, then events will be limited
748
788
  if (!isActive) {
749
789
  this.disableEventThreshold(true);
750
790
  } else {
@@ -753,6 +793,9 @@ class SocketCommandsAdmin extends SocketCommands {
753
793
  };
754
794
 
755
795
  this.commands['getRatings'] = (socket, update, callback) => {
796
+ // Read ratings of adapters
797
+ // @param {boolean} update - if true, the ratings will be read from central server, if false from local cache
798
+ // @param {function} callback - `function (error, ratings)`, where `ratings` is object like `{accuweather: {rating: {r: 3.33, c: 3}, 1.2.1: {r: 3, c: 1}},…}`
756
799
  if (update || !this.adapter._ratings) {
757
800
  this.updateRatings()
758
801
  .then(() => SocketCommands._fixCallback(callback, null, this.adapter._ratings));
@@ -762,14 +805,22 @@ class SocketCommandsAdmin extends SocketCommands {
762
805
  };
763
806
 
764
807
  this.commands['getCurrentInstance'] = (socket, callback) => {
808
+ // Return current instance name like `admin.0`
809
+ // @param {function} callback - `function (error, namespace)`
765
810
  SocketCommands._fixCallback(callback, null, this.adapter.namespace);
766
811
  };
767
812
 
768
813
  this.commands['checkFeatureSupported'] = (socket, feature, callback) => {
814
+ // Checks if same feature is supported by current js-controller
815
+ // @param {string} feature - feature name like `CONTROLLER_LICENSE_MANAGER`
816
+ // @param {function} callback - `function (error, isSupported)`
769
817
  SocketCommands._fixCallback(callback, null, this.adapter.supportsFeature && this.adapter.supportsFeature(feature));
770
818
  };
771
819
 
772
820
  this.commands['decrypt'] = (socket, encryptedText, callback) => {
821
+ // Decrypts text with system secret key
822
+ // @param {string} encryptedText - encrypted text
823
+ // @param {function} callback - `function (error, decryptedText)`
773
824
  if (this.secret) {
774
825
  SocketCommands._fixCallback(callback, null, this.adapter.decrypt(this.secret, encryptedText));
775
826
  } else {
@@ -791,6 +842,9 @@ class SocketCommandsAdmin extends SocketCommands {
791
842
  };
792
843
 
793
844
  this.commands['encrypt'] = (socket, plainText, callback) => {
845
+ // Encrypts text with system secret key
846
+ // @param {string} plainText - normal text
847
+ // @param {function} callback - `function (error, encryptedText)`
794
848
  if (this.secret) {
795
849
  SocketCommands._fixCallback(callback, null, this.adapter.encrypt(this.secret, plainText));
796
850
  } else {
@@ -813,10 +867,15 @@ class SocketCommandsAdmin extends SocketCommands {
813
867
  };
814
868
 
815
869
  this.commands['getIsEasyModeStrict'] = (socket, callback) => {
870
+ // Returns if admin has easy mode enabled
871
+ // @param {function} callback - `function (error, isEasyModeStrict)`
816
872
  SocketCommands._fixCallback(callback, null, this.adapter.config.accessLimit);
817
873
  };
818
874
 
819
875
  this.commands['getEasyMode'] = (socket, callback) => {
876
+ // Get easy mode configuration
877
+ // @param {function} callback - `function (error, easyModeConfig)`, where `easyModeConfig` is object like `{strict: true, configs: [{_id: 'system.adapter.javascript.0', common: {...}}, {...}]}`
878
+ // }`
820
879
  if (this._checkPermissions(socket, 'getObject', callback)) {
821
880
  let user;
822
881
  if (this.adapter.config.auth) {
@@ -829,7 +888,7 @@ class SocketCommandsAdmin extends SocketCommands {
829
888
  }
830
889
 
831
890
  if (this.adapter.config.accessLimit) {
832
- const configs = [];
891
+ const configs = [];
833
892
  const promises = [];
834
893
  this.adapter.config.accessAllowedConfigs.forEach(id => promises.push(this._readInstanceConfig(id, user, false, configs)));
835
894
  this.adapter.config.accessAllowedTabs.forEach(id => promises.push(this._readInstanceConfig(id, user, true, configs)));
@@ -872,6 +931,9 @@ class SocketCommandsAdmin extends SocketCommands {
872
931
  };
873
932
 
874
933
  this.commands['getAdapters'] = (socket, adapterName, callback) => {
934
+ // Read all adapters objects
935
+ // @param {string} adapterName - optional adapter name
936
+ // @param {function} callback - `function (error, results)`, where `results` is array of objects like `{_id: 'system.adapter.javascript', common: {...}}`
875
937
  if (typeof callback === 'function' && this._checkPermissions(socket, 'getObject', callback)) {
876
938
  this.adapter.getObjectView('system', 'adapter',
877
939
  {startkey: `system.adapter.${adapterName || ''}`, endkey: `system.adapter.${adapterName || '\u9999'}`},
@@ -897,6 +959,10 @@ class SocketCommandsAdmin extends SocketCommands {
897
959
  };
898
960
 
899
961
  this.commands['updateLicenses'] = (socket, login, password, callback) => {
962
+ // Read software licenses (vis, knx, ...) from ioBroker.net cloud for given user
963
+ // @param {string} login - cloud login
964
+ // @param {string} password - cloud password
965
+ // @param {function} callback - `function (error, results)`, where `results` is array of objects like `[{"json":"xxx","id":"ab","email":"dogafox@gmail.com","product":"iobroker.knx.year","version":"2","invoice":"Pxx","uuid":"uuid","time":"2021-11-16T19:53:02.000Z","validTill":"2022-11-16T22:59:59.000Z","datapoints":1000}]`
900
966
  if (this._checkPermissions(socket, 'setObject', callback, login, password)) {
901
967
  if (this.adapter.supportsFeature('CONTROLLER_LICENSE_MANAGER')) {
902
968
  let timeout = setTimeout(() => {
@@ -923,6 +989,8 @@ class SocketCommandsAdmin extends SocketCommands {
923
989
  };
924
990
 
925
991
  this.commands['getCompactInstances'] = (socket, callback) => {
992
+ // Read all instances in short form to save bandwidth
993
+ // @param {function} callback - `function (error, results)`, where `results` is an object like `{'system.adapter.javascript.0': {adminTab, name, icon, enabled}}`
926
994
  if (typeof callback === 'function') {
927
995
  if (this._checkPermissions(socket, 'getObject', callback)) {
928
996
  this.adapter.getObjectView('system', 'instance',
@@ -952,6 +1020,8 @@ class SocketCommandsAdmin extends SocketCommands {
952
1020
  };
953
1021
 
954
1022
  this.commands['getCompactAdapters'] = (socket, callback) => {
1023
+ // Read all adapters in short for to save bandwidth
1024
+ // @param {function} callback - `function (error, results)`, where `results` is an object like `{'javascript': {icon, v: '1.0.1', iv: 'ignoredVersion}}`
955
1025
  if (typeof callback === 'function') {
956
1026
  if (this._checkPermissions(socket, 'getObject', callback)) {
957
1027
  this.adapter.getObjectView('system', 'adapter',
@@ -981,6 +1051,8 @@ class SocketCommandsAdmin extends SocketCommands {
981
1051
  };
982
1052
 
983
1053
  this.commands['getCompactInstalled'] = (socket, host, callback) => {
1054
+ // Read all installed adapters in short form to save bandwidth
1055
+ // @param {function} callback - `function (error, results)`, where `results` is an object like `{'javascript': {version: '1.0.1'}}``
984
1056
  if (typeof callback === 'function') {
985
1057
  if (this._checkPermissions(socket, 'sendToHost', callback)) {
986
1058
  this._sendToHost(host, 'getInstalled', null, data => {
@@ -993,6 +1065,8 @@ class SocketCommandsAdmin extends SocketCommands {
993
1065
  };
994
1066
 
995
1067
  this.commands['getCompactSystemConfig'] = (socket, callback) => {
1068
+ // Read system config in short form to save bandwidth
1069
+ // @param {function} callback - `function (error, systemConfig)`, where `systemConfig` is an object like `{common: {...}, native: {secret: 'aaa'}}`
996
1070
  if (this._checkPermissions(socket, 'getObject', callback)) {
997
1071
  this.adapter.getForeignObject('system.config', (error, obj) => {
998
1072
  obj = obj || {};
@@ -1007,6 +1081,8 @@ class SocketCommandsAdmin extends SocketCommands {
1007
1081
  };
1008
1082
 
1009
1083
  this.commands['getCompactSystemRepositories'] = (socket, callback) => {
1084
+ // Read repositories from cache in short form to save bandwidth
1085
+ // @param {function} callback - `function (error, repositories)`, where `repositories` is an object like `{_id: 'system.repositories', common: {...}, native: {repositories: {default: {json: {_repoInfo: {...}}}}}}`
1010
1086
  if (this._checkPermissions(socket, 'getObject', callback)) {
1011
1087
  this.adapter.getForeignObject('system.repositories', (error, obj) => {
1012
1088
  obj && obj.native && obj.native.repositories && Object.keys(obj.native.repositories).forEach(name => {
@@ -1023,6 +1099,8 @@ class SocketCommandsAdmin extends SocketCommands {
1023
1099
  };
1024
1100
 
1025
1101
  this.commands['getCompactRepository'] = (socket, host, callback) => {
1102
+ // Read current repository in short form to save bandwidth
1103
+ // @param {function} callback - `function (error, repository)`, where `repository` is an object like `{'javascript': {version: '1.0.1', icon}, 'admin': {version: '1.0.1', icon}}`
1026
1104
  if (this._checkPermissions(socket, 'sendToHost', callback)) {
1027
1105
  this._sendToHost(host, 'getRepository', null, data => {
1028
1106
  // Extract only version and icon
@@ -1037,6 +1115,8 @@ class SocketCommandsAdmin extends SocketCommands {
1037
1115
  };
1038
1116
 
1039
1117
  this.commands['getCompactHosts'] = (socket, callback) => {
1118
+ // Read all hosts in short form to save bandwidth
1119
+ // @param {function} callback - `function (error, hosts)`, where `hosts` is an array of objects like `[{_id:'system.host.raspi',common:{name:'raspi',icon:'icon',color:'blue',installedVersion:'2.1.0'},native:{hardware:{networkInterfaces:[...]}}}]`
1040
1120
  if (this._checkPermissions(socket, 'getObject', callback)) {
1041
1121
  this.adapter.getObjectView('system', 'host',
1042
1122
  {startkey: 'system.host.', endkey: 'system.host.\u9999'}, (error, doc) => {
@@ -1082,6 +1162,10 @@ class SocketCommandsAdmin extends SocketCommands {
1082
1162
  super.__initCommandsStates();
1083
1163
 
1084
1164
  this.commands['getForeignStates'] = (socket, pattern, callback) => {
1165
+ // Change user password
1166
+ // @param {string} user - user name, like 'benjamin`
1167
+ // @param {string} pass - new password
1168
+ // @param {function} callback - `function (error)`
1085
1169
  if (this._checkPermissions(socket, 'getStates', callback)) {
1086
1170
  if (typeof callback === 'function') {
1087
1171
  try {
@@ -1096,46 +1180,18 @@ class SocketCommandsAdmin extends SocketCommands {
1096
1180
  }
1097
1181
  }
1098
1182
  };
1099
-
1100
- this.commands['delObject'] = (socket, id, options, callback) => {
1101
- if (this._checkPermissions(socket, 'delObject', callback, id)) {
1102
- if (!options || typeof options !== 'object') {
1103
- options = {};
1104
- }
1105
- options.user = socket._acl.user;
1106
- try {
1107
- // options.recursive = true; // the only difference between delObject and delObjects is this line
1108
- this.adapter.delForeignObject(id, options, (error, ...args) =>
1109
- SocketCommands._fixCallback(callback, error, ...args));
1110
- } catch (error) {
1111
- this.adapter.log.error(`[delObject] ERROR: ${error}`);
1112
- SocketCommands._fixCallback(callback, error);
1113
- }
1114
- }
1115
- };
1116
-
1117
- this.commands['delObjects'] = (socket, id, options, callback) => {
1118
- if (this._checkPermissions(socket, 'delObject', callback, id)) {
1119
- if (!options || typeof options !== 'object') {
1120
- options = {};
1121
- }
1122
- options.user = socket._acl.user;
1123
- options.recursive = true; // the only difference between delObject and delObjects is this line
1124
- try {
1125
- this.adapter.delForeignObject(id, options, (error, ...args) =>
1126
- SocketCommands._fixCallback(callback, error, ...args));
1127
- } catch (error) {
1128
- this.adapter.log.error(`[delObjects] ERROR: ${error}`);
1129
- SocketCommands._fixCallback(callback, error);
1130
- }
1131
- }
1132
- };
1133
1183
  }
1134
1184
 
1135
1185
  __initCommandsFiles() {
1136
1186
  super.__initCommandsFiles();
1137
1187
 
1138
1188
  this.commands['writeFile'] = (socket, _adapter, fileName, data64, options, callback) => {
1189
+ // Write file into ioBroker DB as base64 string
1190
+ // @param {string} _adapter - instance name, e.g. `vis.0`
1191
+ // @param {string} fileName - file name, e.g `main/vis-views.json`
1192
+ // @param {string} data64 - file content as base64 string
1193
+ // @param {object} options - optional `{mode: 0x0644}`
1194
+ // @param {function} callback - `function (error)`
1139
1195
  if (this._checkPermissions(socket, 'writeFile', callback, fileName)) {
1140
1196
  if (typeof options === 'function') {
1141
1197
  callback = options;
@@ -1159,12 +1215,24 @@ class SocketCommandsAdmin extends SocketCommands {
1159
1215
  __initCommandsObjects() {
1160
1216
  super.__initCommandsObjects();
1161
1217
 
1162
- this.commands['getAllObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
1218
+ this.commands['getAllObjects'] = (socket, callback) => {
1219
+ // Read absolutely all objects
1220
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1221
+ return this._getAllObjects(socket, callback);
1222
+ }
1163
1223
 
1164
1224
  // Identical to getAllObjects
1165
- this.commands['getObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
1225
+ this.commands['getObjects'] = (socket, callback) => {
1226
+ // Read absolutely all objects. Same as `getAllObjects`.
1227
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1228
+ return this._getAllObjects(socket, callback);
1229
+ }
1166
1230
 
1167
1231
  this.commands['extendObject'] = (socket, id, obj, callback) => {
1232
+ // Extend existing object
1233
+ // @param {string} id - object ID
1234
+ // @param {object} obj - new parts of the object, like `{common: {name: 'new name'}}`
1235
+ // @param {function} callback - `function (error)`
1168
1236
  if (this._checkPermissions(socket, 'extendObject', callback, id)) {
1169
1237
  try {
1170
1238
  this.adapter.extendForeignObject(id, obj, {user: socket._acl.user}, (error, ...args) =>
@@ -1177,6 +1245,10 @@ class SocketCommandsAdmin extends SocketCommands {
1177
1245
  };
1178
1246
 
1179
1247
  this.commands['getForeignObjects'] = (socket, pattern, type, callback) => {
1248
+ // Read objects by pattern
1249
+ // @param {string} pattern - pattern like `system.adapter.admin.0.*`
1250
+ // @param {string} type - type of objects to delete, like `state`, `channel`, `device`, `host`, `adapter`. Default - `state`
1251
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1180
1252
  if (this._checkPermissions(socket, 'getObjects', callback)) {
1181
1253
  if (typeof type === 'function') {
1182
1254
  callback = type;
@@ -1198,6 +1270,10 @@ class SocketCommandsAdmin extends SocketCommands {
1198
1270
  };
1199
1271
 
1200
1272
  this.commands['delObject'] = (socket, id, options, callback) => {
1273
+ // Delete object or objects recursively. Objects with `dontDelete` cannot be deleted.
1274
+ // @param {string} id - Object ID like, 'adapterName.0.channel'
1275
+ // @param {string} options - `{recursive: true}`
1276
+ // @param {function} callback - `function (error)`
1201
1277
  if (this._checkPermissions(socket, 'delObject', callback, id)) {
1202
1278
  if (typeof options === 'function') {
1203
1279
  callback = options;
@@ -1208,6 +1284,7 @@ class SocketCommandsAdmin extends SocketCommands {
1208
1284
  }
1209
1285
  options.user = socket._acl.user;
1210
1286
  try {
1287
+ // options.recursive = true; // the only difference between delObject and delObjects is this line
1211
1288
  this.adapter.delForeignObject(id, options, (error, ...args) =>
1212
1289
  SocketCommands._fixCallback(callback, error, ...args));
1213
1290
  } catch (error) {
@@ -1216,6 +1293,27 @@ class SocketCommandsAdmin extends SocketCommands {
1216
1293
  }
1217
1294
  }
1218
1295
  };
1296
+
1297
+ this.commands['delObjects'] = (socket, id, options, callback) => {
1298
+ // Delete objects recursively. Objects with `dontDelete` cannot be deleted. Same as `delObject` but with `recursive: true`.
1299
+ // @param {string} id - Object ID like, 'adapterName.0.channel'
1300
+ // @param {string} options - optional
1301
+ // @param {function} callback - `function (error)`
1302
+ if (this._checkPermissions(socket, 'delObject', callback, id)) {
1303
+ if (!options || typeof options !== 'object') {
1304
+ options = {};
1305
+ }
1306
+ options.user = socket._acl.user;
1307
+ options.recursive = true; // the only difference between delObject and delObjects is this line
1308
+ try {
1309
+ this.adapter.delForeignObject(id, options, (error, ...args) =>
1310
+ SocketCommands._fixCallback(callback, error, ...args));
1311
+ } catch (error) {
1312
+ this.adapter.log.error(`[delObjects] ERROR: ${error}`);
1313
+ SocketCommands._fixCallback(callback, error);
1314
+ }
1315
+ }
1316
+ };
1219
1317
  }
1220
1318
 
1221
1319
  stateChange(id, state) {
@@ -109,7 +109,7 @@ class SocketCommon {
109
109
  // ignore "failed connection" as it already shown
110
110
  if (!error || !error.message || !error.message.includes('failed connection')) {
111
111
  if ((error && error.message && error.message.includes('authentication failed') ||
112
- (details && details.includes('authentication failed')))
112
+ (details && details.toString().includes('authentication failed')))
113
113
  ) {
114
114
  this.adapter.log.debug(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
115
115
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",
@@ -28,8 +28,9 @@
28
28
  "devDependencies": {
29
29
  "@alcalzone/release-script": "^3.5.9",
30
30
  "@alcalzone/release-script-plugin-license": "^3.5.9",
31
+ "gulp": "^4.0.2",
31
32
  "chai": "^4.3.6",
32
- "mocha": "^9.2.2"
33
+ "mocha": "^10.0.0"
33
34
  },
34
35
  "bugs": {
35
36
  "url": "https://github.com/ioBroker/ioBroker.web/issues"
@@ -47,7 +48,8 @@
47
48
  "release": "release-script",
48
49
  "release-patch": "release-script patch --yes",
49
50
  "release-minor": "release-script minor --yes",
50
- "release-major": "release-script major --yes"
51
+ "release-major": "release-script major --yes",
52
+ "docs": "gulp"
51
53
  },
52
54
  "license": "MIT",
53
55
  "maintainers": [