@iobroker/socket-classes 0.5.0 → 0.5.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 CHANGED
@@ -69,6 +69,12 @@ io.close();
69
69
  -->
70
70
 
71
71
  ## Changelog
72
+ ### 0.5.3 (2022-08-24)
73
+ * (bluefox) Caught error by subscribe
74
+
75
+ ### 0.5.2 (2022-08-19)
76
+ * (bluefox) Added command `getCompactSystemRepositories`
77
+
72
78
  ### 0.5.0 (2022-07-20)
73
79
  * (bluefox) Buffer conversion errors caught and handled
74
80
 
@@ -262,6 +262,10 @@ class SocketCommands {
262
262
  }
263
263
 
264
264
  subscribe(socket, type, pattern, patternFile) {
265
+ if (!pattern) {
266
+ return this.adapter.log.warn('Empty pattern on subscribe!');
267
+ }
268
+
265
269
  this.subscribes[type] = this.subscribes[type] || {};
266
270
 
267
271
  let p;
@@ -269,7 +273,7 @@ class SocketCommands {
269
273
  pattern = pattern.toString();
270
274
  if (patternFile && type === 'fileChange') {
271
275
  patternFile = patternFile.toString();
272
- key = pattern + '####' + patternFile;
276
+ key = `${pattern}####${patternFile}`;
273
277
  } else {
274
278
  key = pattern;
275
279
  }
@@ -310,7 +314,10 @@ class SocketCommands {
310
314
  };
311
315
 
312
316
  unsubscribe(socket, type, pattern, patternFile) {
313
- //console.log((socket._name || socket.id) + ' unsubscribe ' + pattern);
317
+ if (!pattern) {
318
+ return this.adapter.log.warn('Empty pattern on subscribe!');
319
+ }
320
+ // console.log((socket._name || socket.id) + ' unsubscribe ' + pattern);
314
321
  if (!this.subscribes[type]) {
315
322
  return;
316
323
  }
@@ -319,7 +326,7 @@ class SocketCommands {
319
326
  pattern = pattern.toString();
320
327
  if (patternFile && type === 'fileChange') {
321
328
  patternFile = patternFile.toString();
322
- key = pattern + '####' + patternFile;
329
+ key = `${pattern}####${patternFile}`;
323
330
  } else {
324
331
  key = pattern;
325
332
  }
@@ -996,12 +996,28 @@ class SocketCommandsAdmin extends SocketCommands {
996
996
  if (this._checkPermissions(socket, 'getObject', callback)) {
997
997
  this.adapter.getForeignObject('system.config', (error, obj) => {
998
998
  obj = obj || {};
999
- const secret = obj.native && obj.native.secret;
999
+ const secret = obj && obj.native && obj.native.secret;
1000
1000
  delete obj.native;
1001
1001
  if (secret) {
1002
1002
  obj.native = {secret};
1003
1003
  }
1004
- callback(error, obj);
1004
+ callback(error, obj);
1005
+ });
1006
+ }
1007
+ };
1008
+
1009
+ this.commands['getCompactSystemRepositories'] = (socket, callback) => {
1010
+ if (this._checkPermissions(socket, 'getObject', callback)) {
1011
+ this.adapter.getForeignObject('system.repositories', (error, obj) => {
1012
+ obj && obj.native && obj.native.repositories && Object.keys(obj.native.repositories).forEach(name => {
1013
+ if (obj.native.repositories[name].json) {
1014
+ // limit information to _repoInfo
1015
+ obj.native.repositories[name].json = {
1016
+ _repoInfo: obj.native.repositories[name].json._repoInfo
1017
+ };
1018
+ }
1019
+ });
1020
+ callback(error, obj);
1005
1021
  });
1006
1022
  }
1007
1023
  };
@@ -1013,7 +1029,7 @@ class SocketCommandsAdmin extends SocketCommands {
1013
1029
  const result = {};
1014
1030
  data && Object.keys(data).forEach(name => result[name] = {
1015
1031
  version: data[name].version,
1016
- icon: data[name].extIcon
1032
+ icon: data[name].extIcon,
1017
1033
  });
1018
1034
  callback(result);
1019
1035
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",