@stordata/vsphere-soapify 1.0.20250324181110 → 1.0.20250418083505

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.
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "bomFormat": "CycloneDX",
3
3
  "specVersion": "1.4",
4
- "serialNumber": "urn:uuid:7220e349-3882-4d1b-99d8-b1b9cd9eacde",
4
+ "serialNumber": "urn:uuid:fbf8a787-8339-49a0-a585-fd5787e98e4e",
5
5
  "version": 1,
6
6
  "metadata": {
7
- "timestamp": "2025-03-24T18:10:41Z",
7
+ "timestamp": "2025-04-18T08:34:56Z",
8
8
  "tools": [
9
9
  {
10
10
  "vendor": "GitLab",
11
11
  "name": "Gemnasium",
12
- "version": "5.8.8"
12
+ "version": "5.9.2"
13
13
  }
14
14
  ],
15
15
  "authors": [
@@ -146,13 +146,6 @@
146
146
  "type": "library",
147
147
  "bom-ref": "pkg:npm/@sinonjs/samsam@8.0.2"
148
148
  },
149
- {
150
- "name": "@sinonjs/text-encoding",
151
- "version": "0.7.3",
152
- "purl": "pkg:npm/@sinonjs/text-encoding@0.7.3",
153
- "type": "library",
154
- "bom-ref": "pkg:npm/@sinonjs/text-encoding@0.7.3"
155
- },
156
149
  {
157
150
  "name": "@stordata/eslint-config",
158
151
  "version": "1.0.20241128103736",
@@ -1378,13 +1371,6 @@
1378
1371
  "type": "library",
1379
1372
  "bom-ref": "pkg:npm/jsonc-parser@3.0.0"
1380
1373
  },
1381
- {
1382
- "name": "just-extend",
1383
- "version": "6.2.0",
1384
- "purl": "pkg:npm/just-extend@6.2.0",
1385
- "type": "library",
1386
- "bom-ref": "pkg:npm/just-extend@6.2.0"
1387
- },
1388
1374
  {
1389
1375
  "name": "levn",
1390
1376
  "version": "0.4.1",
@@ -1539,13 +1525,6 @@
1539
1525
  "type": "library",
1540
1526
  "bom-ref": "pkg:npm/natural-compare@1.4.0"
1541
1527
  },
1542
- {
1543
- "name": "nise",
1544
- "version": "6.1.1",
1545
- "purl": "pkg:npm/nise@6.1.1",
1546
- "type": "library",
1547
- "bom-ref": "pkg:npm/nise@6.1.1"
1548
- },
1549
1528
  {
1550
1529
  "name": "nock",
1551
1530
  "version": "13.5.6",
@@ -1693,13 +1672,6 @@
1693
1672
  "type": "library",
1694
1673
  "bom-ref": "pkg:npm/path-scurry@1.11.1"
1695
1674
  },
1696
- {
1697
- "name": "path-to-regexp",
1698
- "version": "8.1.0",
1699
- "purl": "pkg:npm/path-to-regexp@8.1.0",
1700
- "type": "library",
1701
- "bom-ref": "pkg:npm/path-to-regexp@8.1.0"
1702
- },
1703
1675
  {
1704
1676
  "name": "pathval",
1705
1677
  "version": "1.1.1",
@@ -1898,10 +1870,10 @@
1898
1870
  },
1899
1871
  {
1900
1872
  "name": "sinon",
1901
- "version": "19.0.5",
1902
- "purl": "pkg:npm/sinon@19.0.5",
1873
+ "version": "20.0.0",
1874
+ "purl": "pkg:npm/sinon@20.0.0",
1903
1875
  "type": "library",
1904
- "bom-ref": "pkg:npm/sinon@19.0.5"
1876
+ "bom-ref": "pkg:npm/sinon@20.0.0"
1905
1877
  },
1906
1878
  {
1907
1879
  "name": "sinon-chai",
package/lib/client.js CHANGED
@@ -168,7 +168,7 @@ module.exports = class Client {
168
168
  * Instance type can be an asterisk (*) to specify all instances or empty string ("") to specify aggregated statistics
169
169
  * @param {Array<String>} [properties=[]] The optional list of entity properties
170
170
  *
171
- * @returns {Promise<Array<String>>} A Promise resolving to an array of Objects { metric string and key to call }
171
+ * @returns {Promise<object[]>} A Promise resolving to an array of Objects { metric string and key to call }
172
172
  */
173
173
  async getPerfCounters(type, counters, properties = []) {
174
174
  const perfMng = await this.getPerformanceManager(), /* eslint-disable one-var */
@@ -196,21 +196,42 @@ module.exports = class Client {
196
196
  }),
197
197
  chunks = _.chunk(specs, this.features.maxQuerySpecSize / _.size(counterToId));
198
198
 
199
- return Promise.all(chunks.map(chunk => perfMng.queryPerf(chunk)))
200
- .then(_.flatten)
201
- .then(_.compact)
202
- .then(result => result.map(perf => ({
203
- entity: _.find(entities, { ref: perf.entity.ref }),
204
- sampleInfo: perf.sampleInfo,
205
- value: perf.value.filter(metric => Array.isArray(metric.value)).map(metric => ({
199
+ function toValidMetric(acc, metric) {
200
+ if (Array.isArray(metric.value)) {
201
+ acc.push({
206
202
  value: metric.value,
207
203
  id: {
208
204
  counterId: metric.id.counterId,
209
205
  counterName: idToCounter[metric.id.counterId],
210
206
  instance: metric.id.instance
211
207
  }
212
- }))
213
- })));
208
+ });
209
+ }
210
+
211
+ return acc;
212
+ }
213
+
214
+ function toValidPerfSample(acc, perf) {
215
+ if (perf.value) {
216
+ acc.push({
217
+ entity: entities.find(entity => entity.ref === perf.entity.ref),
218
+ sampleInfo: perf.sampleInfo,
219
+ value: perf.value.reduce(toValidMetric, [])
220
+ });
221
+ }
222
+
223
+ return acc;
224
+ }
225
+
226
+ function concatValidPerfResults(acc, result) {
227
+ if (result) {
228
+ return acc.concat(result.reduce(toValidPerfSample, []));
229
+ }
230
+
231
+ return acc;
232
+ }
233
+
234
+ return Promise.all(chunks.map(chunk => perfMng.queryPerf(chunk))).then(results => results.reduce(concatValidPerfResults, []));
214
235
  }
215
236
 
216
237
  login(username, password) {
@@ -17439,6 +17439,7 @@ describe('The Client class', function() {
17439
17439
  this.mockSoapOperation('5.5', 'getPerfCountersForVms/full/RetrievePropertiesEx');
17440
17440
  this.mockSoapOperation('5.5', 'getPerfCountersForVms/full_max10/QueryPerf_chunk1');
17441
17441
  this.mockSoapOperation('5.5', 'getPerfCountersForVms/full_max10/QueryPerf_chunk2');
17442
+ this.mockSoapOperation('5.5', 'getPerfCountersForVms/full_max10/QueryPerf_chunk3');
17442
17443
 
17443
17444
  return client.getPerfCounters(VirtualMachine, {
17444
17445
  'cpu.usage.none.percent': '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stordata/vsphere-soapify",
3
- "version":"1.0.20250324181110",
3
+ "version":"1.0.20250418083505",
4
4
  "description": "A NodeJS abstraction layer for the vSphere SOAP API",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,7 @@
45
45
  "mocha": "11.1.0",
46
46
  "mockdate": "3.0.5",
47
47
  "nock": "13.5.6",
48
- "sinon": "19.0.5",
48
+ "sinon": "20.0.0",
49
49
  "sinon-chai": "3.7.0"
50
50
  }
51
51
  }