@itentialopensource/adapter-utils 5.0.3 → 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 +8 -0
- package/lib/connectorRest.js +23 -0
- package/lib/propertyUtil.js +22 -15
- package/package.json +1 -1
- package/refs?service=git-upload-pack +0 -0
package/CHANGELOG.md
CHANGED
package/lib/connectorRest.js
CHANGED
|
@@ -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
|
package/lib/propertyUtil.js
CHANGED
|
@@ -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
|
-
|
|
331
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
772
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1018
|
-
|
|
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
|
-
|
|
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
|
}
|
package/package.json
CHANGED
|
Binary file
|