@iobroker/socket-classes 0.5.3 → 1.0.1

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,9 @@ class SocketCommandsAdmin extends SocketCommands {
1082
1162
  super.__initCommandsStates();
1083
1163
 
1084
1164
  this.commands['getForeignStates'] = (socket, pattern, callback) => {
1165
+ // Read all states (which might not belong to this adapter) which match the given pattern
1166
+ // @param {string} pattern - pattern like
1167
+ // @param {function} callback - `function (error)`
1085
1168
  if (this._checkPermissions(socket, 'getStates', callback)) {
1086
1169
  if (typeof callback === 'function') {
1087
1170
  try {
@@ -1096,46 +1179,18 @@ class SocketCommandsAdmin extends SocketCommands {
1096
1179
  }
1097
1180
  }
1098
1181
  };
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
1182
  }
1134
1183
 
1135
1184
  __initCommandsFiles() {
1136
1185
  super.__initCommandsFiles();
1137
1186
 
1138
1187
  this.commands['writeFile'] = (socket, _adapter, fileName, data64, options, callback) => {
1188
+ // Write file into ioBroker DB as base64 string
1189
+ // @param {string} _adapter - instance name, e.g. `vis.0`
1190
+ // @param {string} fileName - file name, e.g `main/vis-views.json`
1191
+ // @param {string} data64 - file content as base64 string
1192
+ // @param {object} options - optional `{mode: 0x0644}`
1193
+ // @param {function} callback - `function (error)`
1139
1194
  if (this._checkPermissions(socket, 'writeFile', callback, fileName)) {
1140
1195
  if (typeof options === 'function') {
1141
1196
  callback = options;
@@ -1159,12 +1214,24 @@ class SocketCommandsAdmin extends SocketCommands {
1159
1214
  __initCommandsObjects() {
1160
1215
  super.__initCommandsObjects();
1161
1216
 
1162
- this.commands['getAllObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
1217
+ this.commands['getAllObjects'] = (socket, callback) => {
1218
+ // Read absolutely all objects
1219
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1220
+ return this._getAllObjects(socket, callback);
1221
+ }
1163
1222
 
1164
1223
  // Identical to getAllObjects
1165
- this.commands['getObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
1224
+ this.commands['getObjects'] = (socket, callback) => {
1225
+ // Read absolutely all objects. Same as `getAllObjects`.
1226
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1227
+ return this._getAllObjects(socket, callback);
1228
+ }
1166
1229
 
1167
1230
  this.commands['extendObject'] = (socket, id, obj, callback) => {
1231
+ // Extend existing object
1232
+ // @param {string} id - object ID
1233
+ // @param {object} obj - new parts of the object, like `{common: {name: 'new name'}}`
1234
+ // @param {function} callback - `function (error)`
1168
1235
  if (this._checkPermissions(socket, 'extendObject', callback, id)) {
1169
1236
  try {
1170
1237
  this.adapter.extendForeignObject(id, obj, {user: socket._acl.user}, (error, ...args) =>
@@ -1177,6 +1244,10 @@ class SocketCommandsAdmin extends SocketCommands {
1177
1244
  };
1178
1245
 
1179
1246
  this.commands['getForeignObjects'] = (socket, pattern, type, callback) => {
1247
+ // Read objects by pattern
1248
+ // @param {string} pattern - pattern like `system.adapter.admin.0.*`
1249
+ // @param {string} type - type of objects to delete, like `state`, `channel`, `device`, `host`, `adapter`. Default - `state`
1250
+ // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1180
1251
  if (this._checkPermissions(socket, 'getObjects', callback)) {
1181
1252
  if (typeof type === 'function') {
1182
1253
  callback = type;
@@ -1198,6 +1269,10 @@ class SocketCommandsAdmin extends SocketCommands {
1198
1269
  };
1199
1270
 
1200
1271
  this.commands['delObject'] = (socket, id, options, callback) => {
1272
+ // Delete object or objects recursively. Objects with `dontDelete` cannot be deleted.
1273
+ // @param {string} id - Object ID like, 'adapterName.0.channel'
1274
+ // @param {string} options - `{recursive: true}`
1275
+ // @param {function} callback - `function (error)`
1201
1276
  if (this._checkPermissions(socket, 'delObject', callback, id)) {
1202
1277
  if (typeof options === 'function') {
1203
1278
  callback = options;
@@ -1208,6 +1283,7 @@ class SocketCommandsAdmin extends SocketCommands {
1208
1283
  }
1209
1284
  options.user = socket._acl.user;
1210
1285
  try {
1286
+ // options.recursive = true; // the only difference between delObject and delObjects is this line
1211
1287
  this.adapter.delForeignObject(id, options, (error, ...args) =>
1212
1288
  SocketCommands._fixCallback(callback, error, ...args));
1213
1289
  } catch (error) {
@@ -1216,6 +1292,27 @@ class SocketCommandsAdmin extends SocketCommands {
1216
1292
  }
1217
1293
  }
1218
1294
  };
1295
+
1296
+ this.commands['delObjects'] = (socket, id, options, callback) => {
1297
+ // Delete objects recursively. Objects with `dontDelete` cannot be deleted. Same as `delObject` but with `recursive: true`.
1298
+ // @param {string} id - Object ID like, 'adapterName.0.channel'
1299
+ // @param {string} options - optional
1300
+ // @param {function} callback - `function (error)`
1301
+ if (this._checkPermissions(socket, 'delObject', callback, id)) {
1302
+ if (!options || typeof options !== 'object') {
1303
+ options = {};
1304
+ }
1305
+ options.user = socket._acl.user;
1306
+ options.recursive = true; // the only difference between delObject and delObjects is this line
1307
+ try {
1308
+ this.adapter.delForeignObject(id, options, (error, ...args) =>
1309
+ SocketCommands._fixCallback(callback, error, ...args));
1310
+ } catch (error) {
1311
+ this.adapter.log.error(`[delObjects] ERROR: ${error}`);
1312
+ SocketCommands._fixCallback(callback, error);
1313
+ }
1314
+ }
1315
+ };
1219
1316
  }
1220
1317
 
1221
1318
  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": "1.0.1",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",
@@ -21,6 +21,7 @@
21
21
  "url": "https://github.com/ioBroker/ioBroker.socket-classes"
22
22
  },
23
23
  "dependencies": {
24
+ "@iobroker/adapter-core": "^2.6.7",
24
25
  "passport": "^0.6.0",
25
26
  "cookie-parser": "^1.4.6",
26
27
  "axios": "^0.27.2"
@@ -28,8 +29,10 @@
28
29
  "devDependencies": {
29
30
  "@alcalzone/release-script": "^3.5.9",
30
31
  "@alcalzone/release-script-plugin-license": "^3.5.9",
32
+ "iobroker.js-controller": "dev",
33
+ "gulp": "^4.0.2",
31
34
  "chai": "^4.3.6",
32
- "mocha": "^9.2.2"
35
+ "mocha": "^10.0.0"
33
36
  },
34
37
  "bugs": {
35
38
  "url": "https://github.com/ioBroker/ioBroker.web/issues"
@@ -47,7 +50,8 @@
47
50
  "release": "release-script",
48
51
  "release-patch": "release-script patch --yes",
49
52
  "release-minor": "release-script minor --yes",
50
- "release-major": "release-script major --yes"
53
+ "release-major": "release-script major --yes",
54
+ "docs": "gulp"
51
55
  },
52
56
  "license": "MIT",
53
57
  "maintainers": [