@iobroker/socket-classes 1.4.6 → 1.5.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2023 bluefox <dogafox@gmail.com>
3
+ Copyright (c) 2020-2024 bluefox <dogafox@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -740,8 +740,9 @@ Get one object
740
740
  * id *(string)*: object ID.
741
741
  * callback *(function)*: `function (error, obj)`
742
742
 
743
- ### <a name="getobjects_a"></a>getObjects(callback)
743
+ ### <a name="getobjects_a"></a>getObjects(list, callback)
744
744
  Read absolutely all objects. Same as `getAllObjects`.
745
+ * list *(string[])*: optional list of IDs.
745
746
  * callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
746
747
 
747
748
  ### <a name="subscribeobjects_a"></a>subscribeObjects(pattern, callback)
@@ -978,6 +979,9 @@ Read all instances of the given adapter, or all instances of all adapters if ada
978
979
  -->
979
980
 
980
981
  ## Changelog
982
+ ### 1.5.0 (2024-02-22)
983
+ * (bluefox) Extended getObjects function with the possibility to read the list of IDs in admin
984
+
981
985
  ### 1.4.6 (2023-10-19)
982
986
  * (bluefox) Added `publishInstanceMessageAll` command
983
987
 
@@ -1116,7 +1120,7 @@ Read all instances of the given adapter, or all instances of all adapters if ada
1116
1120
  ## License
1117
1121
  The MIT License (MIT)
1118
1122
 
1119
- Copyright (c) 2020-2023 Bluefox <dogafox@gmail.com>
1123
+ Copyright (c) 2020-2024 Bluefox <dogafox@gmail.com>
1120
1124
 
1121
1125
  Permission is hereby granted, free of charge, to any person obtaining a copy
1122
1126
  of this software and associated documentation files (the "Software"), to deal
@@ -203,8 +203,8 @@ class SocketCommandsAdmin extends SocketCommands {
203
203
  if (error.response) {
204
204
  throw new Error(
205
205
  (error.response.data && error.response.data.error) ||
206
- error.response.data ||
207
- error.response.status
206
+ error.response.data ||
207
+ error.response.status
208
208
  );
209
209
  } else if (error.request) {
210
210
  throw new Error('no response');
@@ -1204,16 +1204,16 @@ class SocketCommandsAdmin extends SocketCommands {
1204
1204
  if (this._checkPermissions(socket, 'getObject', callback)) {
1205
1205
  this.adapter.getForeignObject('system.repositories', { user: socket._acl.user }, (error, obj) => {
1206
1206
  obj &&
1207
- obj.native &&
1208
- obj.native.repositories &&
1209
- Object.keys(obj.native.repositories).forEach(name => {
1210
- if (obj.native.repositories[name].json) {
1211
- // limit information to _repoInfo
1212
- obj.native.repositories[name].json = {
1213
- _repoInfo: obj.native.repositories[name].json._repoInfo
1214
- };
1215
- }
1216
- });
1207
+ obj.native &&
1208
+ obj.native.repositories &&
1209
+ Object.keys(obj.native.repositories).forEach(name => {
1210
+ if (obj.native.repositories[name].json) {
1211
+ // limit information to _repoInfo
1212
+ obj.native.repositories[name].json = {
1213
+ _repoInfo: obj.native.repositories[name].json._repoInfo
1214
+ };
1215
+ }
1216
+ });
1217
1217
  callback(error, obj);
1218
1218
  });
1219
1219
  }
@@ -1227,13 +1227,13 @@ class SocketCommandsAdmin extends SocketCommands {
1227
1227
  // Extract only the version and icon
1228
1228
  const result = {};
1229
1229
  data &&
1230
- Object.keys(data).forEach(
1231
- name =>
1232
- (result[name] = {
1233
- version: data[name].version,
1234
- icon: data[name].extIcon
1235
- })
1236
- );
1230
+ Object.keys(data).forEach(
1231
+ name =>
1232
+ (result[name] = {
1233
+ version: data[name].version,
1234
+ icon: data[name].extIcon
1235
+ })
1236
+ );
1237
1237
  callback(result);
1238
1238
  });
1239
1239
  }
@@ -1333,10 +1333,32 @@ class SocketCommandsAdmin extends SocketCommands {
1333
1333
  };
1334
1334
 
1335
1335
  // Identical to getAllObjects
1336
- this.commands['getObjects'] = (socket, callback) => {
1336
+ this.commands['getObjects'] = (socket, list, callback) => {
1337
1337
  // Read absolutely all objects. Same as `getAllObjects`.
1338
+ // @param {string[]} list - optional list of IDs.
1338
1339
  // @param {function} callback - `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
1339
- return this._getAllObjects(socket, callback);
1340
+ if (typeof list === 'function') {
1341
+ callback = list;
1342
+ list = null;
1343
+ }
1344
+ if (list && list.length) {
1345
+ if (this._checkPermissions(socket, 'getObject', callback)) {
1346
+ if (typeof callback === 'function') {
1347
+ try {
1348
+ this.adapter.getForeignObjects(list, { user: socket._acl.user }, (error, objs) =>
1349
+ SocketCommands._fixCallback(callback, error, objs)
1350
+ );
1351
+ } catch (error) {
1352
+ this.adapter.log.error(`[getObjects] ERROR: ${error.toString()}`);
1353
+ SocketCommands._fixCallback(callback, error);
1354
+ }
1355
+ } else {
1356
+ this.adapter.log.warn('[getObjects] Invalid callback');
1357
+ }
1358
+ }
1359
+ } else {
1360
+ return this._getAllObjects(socket, callback);
1361
+ }
1340
1362
  };
1341
1363
 
1342
1364
  this.commands['extendObject'] = (socket, id, obj, callback) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "1.4.6",
3
+ "version": "1.5.0",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",
@@ -22,18 +22,18 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@iobroker/adapter-core": "^3.0.4",
25
- "axios": "^1.5.1",
25
+ "axios": "^1.6.7",
26
26
  "cookie-parser": "^1.4.6",
27
- "passport": "^0.6.0"
27
+ "passport": "^0.7.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@alcalzone/release-script": "^3.6.0",
31
- "@alcalzone/release-script-plugin-license": "^3.5.9",
32
- "@foxriver76/eslint-config": "^1.0.1",
33
- "chai": "^4.3.10",
30
+ "@alcalzone/release-script": "^3.7.0",
31
+ "@alcalzone/release-script-plugin-license": "^3.7.0",
32
+ "@foxriver76/eslint-config": "^1.0.2",
33
+ "chai": "^4.4.1",
34
34
  "gulp": "^4.0.2",
35
35
  "iobroker.js-controller": "dev",
36
- "mocha": "^10.2.0"
36
+ "mocha": "^10.3.0"
37
37
  },
38
38
  "bugs": {
39
39
  "url": "https://github.com/ioBroker/ioBroker.web/issues"