@itentialopensource/adapter-utils 5.3.0 → 5.3.2

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/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ ## 5.3.2 [11-27-2023]
3
+
4
+ * fix proxy issue resulting from npm change
5
+
6
+ See merge request itentialopensource/adapter-utils!281
7
+
8
+ ---
9
+
10
+ ## 5.3.1 [11-17-2023]
11
+
12
+ * logic to convert object to array when specified
13
+
14
+ Closes ADAPT-2943
15
+
16
+ See merge request itentialopensource/adapter-utils!280
17
+
18
+ ---
19
+
2
20
  ## 5.3.0 [10-19-2023]
3
21
 
4
22
  * ADAPT-485: AWS Auth
@@ -28,8 +28,8 @@ const cookieHandler = require('cookie');
28
28
  const jsonQuery = require('json-query');
29
29
  const xml2js = require('xml2js');
30
30
  const querystring = require('querystring');
31
- const HttpsProxyAgent = require('https-proxy-agent');
32
- const SocksProxyAgent = require('socks-proxy-agent');
31
+ const { HttpsProxyAgent } = require('https-proxy-agent');
32
+ const { SocksProxyAgent } = require('socks-proxy-agent');
33
33
  const AsyncLockCl = require('async-lock');
34
34
  const FormData = require('form-data');
35
35
 
@@ -25,6 +25,7 @@ let encodeUri = true;
25
25
  let stripEscapes = false;
26
26
  let returnResponseHeaders = true;
27
27
  let healthcheckHeaders = null;
28
+ let xmlArrayKeys = null;
28
29
  // INTERNAL FUNCTIONS
29
30
  /*
30
31
  * INTERNAL FUNCTION: Get the best match for the mock data response
@@ -105,6 +106,24 @@ function checkBodyData(uriPath, method, reqBdObj, mockresponses) {
105
106
  return specificResp;
106
107
  }
107
108
 
109
+ /*
110
+ * INTERNAL FUNCTION: recursively convert objects to array at keys specified in keys array
111
+ */
112
+ function setArrays(obj, keys) {
113
+ const currentObj = obj;
114
+ if (typeof currentObj === 'object') {
115
+ Object.keys(currentObj).forEach((key) => {
116
+ if (keys.includes(key)) {
117
+ if (!Array.isArray(currentObj[key])) {
118
+ currentObj[key] = [currentObj[key]];
119
+ }
120
+ }
121
+ // Recurse for nested keys
122
+ setArrays(currentObj[key], keys);
123
+ });
124
+ }
125
+ }
126
+
108
127
  /**
109
128
  * INTERNAL FUNCTION
110
129
  *
@@ -405,6 +424,10 @@ function handleRestRequest(request, entityId, entitySchema, callProperties, filt
405
424
  log.warn(`${origin}: Unable to parse xml to json ${error}`);
406
425
  return callback(retObject);
407
426
  }
427
+ // Logic to convert keys specified to array if object
428
+ if (xmlArrayKeys) {
429
+ setArrays(result, xmlArrayKeys);
430
+ }
408
431
  retObject.response = result;
409
432
  return callback(retObject);
410
433
  });
@@ -1063,6 +1086,10 @@ class RestHandler {
1063
1086
  if (properties.healthcheck && typeof properties.healthcheck.addlHeaders === 'object') {
1064
1087
  healthcheckHeaders = properties.healthcheck.addlHeaders;
1065
1088
  }
1089
+
1090
+ if (properties.xmlArrayKeys && typeof properties.xmlArrayKeys === 'object') {
1091
+ xmlArrayKeys = properties.xmlArrayKeys;
1092
+ }
1066
1093
  }
1067
1094
 
1068
1095
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",
Binary file