@itentialopensource/adapter-utils 5.0.2 → 5.0.4

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,20 @@
1
1
 
2
+ ## 5.0.4 [07-18-2023]
3
+
4
+ * Missing token fields oop change logic and key bug fix
5
+
6
+ See merge request itentialopensource/adapter-utils!264
7
+
8
+ ---
9
+
10
+ ## 5.0.3 [07-18-2023]
11
+
12
+ * fix bad return
13
+
14
+ See merge request itentialopensource/adapter-utils!263
15
+
16
+ ---
17
+
2
18
  ## 5.0.2 [07-17-2023]
3
19
 
4
20
  * remove ds files and fix to expanded generic
@@ -1577,6 +1577,29 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
1577
1577
  tokenSchema = null;
1578
1578
  } else {
1579
1579
  log.debug(`${origin}: Using action and schema for token information`);
1580
+ // If token info included in service config, override schema value
1581
+ if (tokenUserField !== 'username') {
1582
+ log.debug('Reading token user field from service configuration.');
1583
+ tokenSchema.requestSchema.properties.username.external_name = tokenUserField;
1584
+ }
1585
+
1586
+ if (tokenPwdField !== 'password') {
1587
+ log.debug('Reading token password field from service configuration.');
1588
+ tokenSchema.requestSchema.properties.password.external_name = tokenPwdField;
1589
+ }
1590
+
1591
+ if (tokenResField !== 'token') {
1592
+ log.debug('Reading token response field from service configuration.');
1593
+ tokenSchema.responseSchema.properties.token.external_name = tokenResField;
1594
+ }
1595
+
1596
+ if (tokenPath) {
1597
+ log.debug('Reading token request URI path from service configuration.');
1598
+ tokenSchema.entitypath = tokenPath;
1599
+ if (tokenSchema.mockresponses && tokenSchema.mockresponses[0] && tokenSchema.mockresponses[0].name) {
1600
+ tokenSchema.mockresponses[0].name = tokenPath;
1601
+ }
1602
+ }
1580
1603
  }
1581
1604
 
1582
1605
  // prepare the additional headers we received
@@ -327,12 +327,12 @@ class AdapterPropertyUtil {
327
327
 
328
328
  // need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
329
329
  if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
330
- && entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
331
- && entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
330
+ && entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
331
+ && entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
332
332
  entitySchema.requestDatatype = 'PLAIN';
333
333
  }
334
334
  if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
335
- && entitySchema.responseDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.responseDatatype.toUpperCase() !== 'XML2JSON') {
335
+ && entitySchema.responseDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.responseDatatype.toUpperCase() !== 'XML2JSON') {
336
336
  entitySchema.responseDatatype = 'PLAIN';
337
337
  }
338
338
 
@@ -367,7 +367,7 @@ class AdapterPropertyUtil {
367
367
  mockResponse.response = 'mock file empty!';
368
368
  }
369
369
  } else if (entitySchema.responseDatatype && (entitySchema.responseDatatype.toUpperCase() === 'XML'
370
- || entitySchema.responseDatatype.toUpperCase() === 'XML2JSON')) {
370
+ || entitySchema.responseDatatype.toUpperCase() === 'XML2JSON')) {
371
371
  // read the mock date from the file system
372
372
  mockResponse.response = fs.readFileSync(mockFileName, 'utf-8');
373
373
  if (!mockResponse.response) {
@@ -719,7 +719,7 @@ class AdapterPropertyUtil {
719
719
  }
720
720
  }
721
721
  } else {
722
- // add the specific pieces of the error object
722
+ // add the specific pieces of the error object
723
723
  errorObj.type = 'Invalid Action File';
724
724
  errorObj.vars = ['missing entity path', entityName];
725
725
 
@@ -768,12 +768,12 @@ class AdapterPropertyUtil {
768
768
 
769
769
  // need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
770
770
  if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
771
- && entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
772
- && entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
771
+ && entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
772
+ && entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
773
773
  entitySchema.requestDatatype = 'PLAIN';
774
774
  }
775
775
  if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
776
- && entitySchema.responseDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.responseDatatype.toUpperCase() !== 'XML2JSON') {
776
+ && entitySchema.responseDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.responseDatatype.toUpperCase() !== 'XML2JSON') {
777
777
  entitySchema.responseDatatype = 'PLAIN';
778
778
  }
779
779
 
@@ -807,7 +807,7 @@ class AdapterPropertyUtil {
807
807
  // read the mock date from the file system
808
808
  mockResponse.response = mockResp;
809
809
  } else if (entitySchema.responseDatatype && (entitySchema.responseDatatype.toUpperCase() === 'XML'
810
- || entitySchema.responseDatatype.toUpperCase() === 'XML2JSON')) {
810
+ || entitySchema.responseDatatype.toUpperCase() === 'XML2JSON')) {
811
811
  // read the mock date from the file system
812
812
  mockResponse.response = mockResp;
813
813
  } else {
@@ -1011,16 +1011,23 @@ class AdapterPropertyUtil {
1011
1011
  }
1012
1012
 
1013
1013
  // start what we return
1014
- let retData = `${dataParts[0]}?`;
1015
1014
  let count = 0;
1016
-
1017
- // query format - key=value& or key=value{end of url}
1018
- const queryData = dataParts[1].split('&');
1015
+ let retData = '';
1016
+ let queryData;
1017
+ // If there is query daya
1018
+ if (actualData.indexOf('?') > -1) {
1019
+ retData = `${dataParts[0]}?`;
1020
+ // query format - key=value& or key=value{end of url}
1021
+ queryData = dataParts[1].split('&');
1022
+ } else {
1023
+ // If its a urlencode body
1024
+ queryData = dataParts[0].split('&');
1025
+ }
1019
1026
 
1020
1027
  // analyze the query fields
1021
1028
  for (let i = 0; i < queryData.length; i += 1) {
1022
1029
  // key of the query field
1023
- const key = queryData[i].split('=');
1030
+ const key = queryData[i].split('=')[0];
1024
1031
  let found = false;
1025
1032
 
1026
1033
  // add any & to separate query params
@@ -1113,7 +1120,7 @@ class AdapterPropertyUtil {
1113
1120
  // recursive call with primary and secondary object
1114
1121
  combinedProps[propKeys[k]] = this.mergeProperties(thisProp, combinedProps[propKeys[k]]);
1115
1122
  } else if ((thisProp !== undefined && thisProp !== null && thisProp !== '')
1116
- || (combinedProps[propKeys[k]] === undefined || combinedProps[propKeys[k]] === null || combinedProps[propKeys[k]] === '')) {
1123
+ || (combinedProps[propKeys[k]] === undefined || combinedProps[propKeys[k]] === null || combinedProps[propKeys[k]] === '')) {
1117
1124
  // if no secondary or primary has value merge it - overriding the secondary
1118
1125
  combinedProps[propKeys[k]] = thisProp;
1119
1126
  }
@@ -1313,7 +1313,7 @@ class RequestHandler {
1313
1313
  }
1314
1314
 
1315
1315
  // validate the action files for the adapter
1316
- return callback(this.connector.makeTokenRequest('/none/token/path', useUser, reqBody, null, callProperties, callback));
1316
+ return this.connector.makeTokenRequest('/none/token/path', useUser, reqBody, null, callProperties, callback);
1317
1317
  } catch (e) {
1318
1318
  // handle any exception
1319
1319
  const errorObj = this.transUtil.checkAndReturn(e, origin, 'Issue getting token');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",
Binary file