@stordata/vsphere-soapify 1.0.20250324212333 → 1.0.20250422080853

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:e0cbc523-36a3-4933-96b7-db3777aa371c",
4
+ "serialNumber": "urn:uuid:2f3b3ab7-6efb-4ece-b8f7-44c9042dc617",
5
5
  "version": 1,
6
6
  "metadata": {
7
- "timestamp": "2025-03-24T21:23:07Z",
7
+ "timestamp": "2025-04-22T08:08:43Z",
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": [
@@ -330,10 +330,10 @@
330
330
  },
331
331
  {
332
332
  "name": "axios-ntlm",
333
- "version": "1.4.3",
334
- "purl": "pkg:npm/axios-ntlm@1.4.3",
333
+ "version": "1.4.4",
334
+ "purl": "pkg:npm/axios-ntlm@1.4.4",
335
335
  "type": "library",
336
- "bom-ref": "pkg:npm/axios-ntlm@1.4.3"
336
+ "bom-ref": "pkg:npm/axios-ntlm@1.4.4"
337
337
  },
338
338
  {
339
339
  "name": "balanced-match",
@@ -1884,10 +1884,10 @@
1884
1884
  },
1885
1885
  {
1886
1886
  "name": "soap",
1887
- "version": "1.1.10",
1888
- "purl": "pkg:npm/soap@1.1.10",
1887
+ "version": "1.1.11",
1888
+ "purl": "pkg:npm/soap@1.1.11",
1889
1889
  "type": "library",
1890
- "bom-ref": "pkg:npm/soap@1.1.10"
1890
+ "bom-ref": "pkg:npm/soap@1.1.11"
1891
1891
  },
1892
1892
  {
1893
1893
  "name": "string-width",
@@ -2199,10 +2199,10 @@
2199
2199
  },
2200
2200
  {
2201
2201
  "name": "xml-crypto",
2202
- "version": "6.0.1",
2203
- "purl": "pkg:npm/xml-crypto@6.0.1",
2202
+ "version": "6.1.1",
2203
+ "purl": "pkg:npm/xml-crypto@6.1.1",
2204
2204
  "type": "library",
2205
- "bom-ref": "pkg:npm/xml-crypto@6.0.1"
2205
+ "bom-ref": "pkg:npm/xml-crypto@6.1.1"
2206
2206
  },
2207
2207
  {
2208
2208
  "name": "xpath",
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.20250324212333",
3
+ "version":"1.0.20250422080853",
4
4
  "description": "A NodeJS abstraction layer for the vSphere SOAP API",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "axios": "1.8.4",
31
31
  "debug": "4.4.0",
32
32
  "lodash": "4.17.21",
33
- "soap": "1.1.10",
33
+ "soap": "1.1.11",
34
34
  "tough-cookie": "5.1.2"
35
35
  },
36
36
  "devDependencies": {