@itentialopensource/adapter-utils 4.48.0 → 4.48.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 +20 -0
- package/lib/connectorRest.js +91 -58
- package/lib/propertyUtil.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.48.2 [10-04-2022]
|
|
3
|
+
|
|
4
|
+
* Changes to have token data passed in url instead of body
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2404
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!239
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 4.48.1 [09-22-2022]
|
|
13
|
+
|
|
14
|
+
* Add capability to send base64 and buffer in formData
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2380
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!238
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
2
22
|
## 4.48.0 [08-16-2022]
|
|
3
23
|
|
|
4
24
|
* Changes to support entitypath object with multiple paths
|
package/lib/connectorRest.js
CHANGED
|
@@ -255,11 +255,11 @@ function matchMock(uriPath, method, type, mockresponses, respDatatype) {
|
|
|
255
255
|
for (let p = 0; p < mockresponses.length; p += 1) {
|
|
256
256
|
// is this the mock data for this call
|
|
257
257
|
if (Object.hasOwnProperty.call(mockresponses[p], 'name')
|
|
258
|
-
|
|
258
|
+
&& uriPath === mockresponses[p].name) {
|
|
259
259
|
if (Object.hasOwnProperty.call(mockresponses[p], 'method')
|
|
260
|
-
|
|
260
|
+
&& method.toUpperCase() === mockresponses[p].method.toUpperCase()) {
|
|
261
261
|
if (Object.hasOwnProperty.call(mockresponses[p], 'type')
|
|
262
|
-
|
|
262
|
+
&& type.toUpperCase() === mockresponses[p].type.toUpperCase()) {
|
|
263
263
|
// This is the mock data we really want as it best matches the request
|
|
264
264
|
const specificResp = {
|
|
265
265
|
status: 'success',
|
|
@@ -270,7 +270,7 @@ function matchMock(uriPath, method, type, mockresponses, respDatatype) {
|
|
|
270
270
|
if (Object.hasOwnProperty.call(mockresponses[p], 'response')) {
|
|
271
271
|
// if a status is defined in the response, use it
|
|
272
272
|
if (Object.hasOwnProperty.call(mockresponses[p].response, 'response')
|
|
273
|
-
|
|
273
|
+
&& Object.hasOwnProperty.call(mockresponses[p].response, 'status')) {
|
|
274
274
|
specificResp.code = mockresponses[p].response.status;
|
|
275
275
|
|
|
276
276
|
if (respDatatype && respDatatype.toUpperCase() === 'XML2JSON') {
|
|
@@ -396,7 +396,7 @@ function returnStub(request, entitySchema, callProperties) {
|
|
|
396
396
|
|
|
397
397
|
// if there is a request body, see if there is something that matches a specific input
|
|
398
398
|
if (reqBody && (!entitySchema || !entitySchema.requestDatatype
|
|
399
|
-
|
|
399
|
+
|| entitySchema.requestDatatype.toUpperCase() === 'JSON' || entitySchema.requestDatatype.toUpperCase() === 'URLENCODE')) {
|
|
400
400
|
let reqBdObj = null;
|
|
401
401
|
if (entitySchema && entitySchema.requestDatatype && entitySchema.requestDatatype.toUpperCase() === 'URLENCODE') {
|
|
402
402
|
reqBdObj = querystring.parse(reqBody.trim());
|
|
@@ -661,38 +661,60 @@ function makeRequest(request, entitySchema, callProperties, startTrip, attempt,
|
|
|
661
661
|
}
|
|
662
662
|
// add the data for each field into the form
|
|
663
663
|
const mykeys = Object.keys(mybody);
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
664
|
+
if (mykeys.length === 2 && mykeys[0] === 'file' && mykeys[1] === 'convertBase64ToBuffer') {
|
|
665
|
+
const filePart = mybody[mykeys[0]].split(';');
|
|
666
|
+
let fileName = null;
|
|
667
|
+
// see if we have a filename that we should add to the formdata
|
|
668
|
+
for (let p = 1; p < filePart.length; p += 1) {
|
|
669
|
+
if (filePart[p].indexOf('name=') === 0) {
|
|
670
|
+
fileName = filePart[p].substring(5);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (mybody.convertBase64ToBuffer === true) {
|
|
674
|
+
let fileBuffer = filePart[filePart.length - 1];
|
|
675
|
+
if (filePart[filePart.length - 1].startsWith('base64')) {
|
|
676
|
+
fileBuffer = Buffer.from(filePart[filePart.length - 1].substring(7), 'base64');
|
|
677
|
+
}
|
|
678
|
+
log.debug(`APPENDING: ${mykeys[0]}, WITH VALUE ${fileBuffer}, AND NAME ${fileName}`);
|
|
679
|
+
formData.append(mykeys[0], fileBuffer, fileName);
|
|
680
|
+
} else {
|
|
681
|
+
log.debug(`APPENDING: ${mykeys[0]}, WITH VALUE ${filePart[filePart.length - 1]}, AND NAME ${fileName}`);
|
|
682
|
+
formData.append(mykeys[0], filePart[filePart.length - 1], fileName);
|
|
683
|
+
}
|
|
684
|
+
} else {
|
|
685
|
+
for (let k = 0; k < mykeys.length; k += 1) {
|
|
686
|
+
if (mykeys[k] === 'file') {
|
|
687
|
+
let fileVal = mybody[mykeys[k]];
|
|
688
|
+
if (fileVal.indexOf('@') === 0) {
|
|
689
|
+
// if there are multiple parts - first part is file, other part can be name
|
|
690
|
+
const filePart = fileVal.split(';');
|
|
691
|
+
let fileName = null;
|
|
692
|
+
fileVal = fs.readFileSync(`node_modules/@itentialopensource/adapter-forwardnetworks/uploads/${filePart[0].substring(1)}`);
|
|
693
|
+
|
|
694
|
+
// see if we have a filename that we should add to the formdata
|
|
695
|
+
for (let p = 1; p < filePart.length; p += 1) {
|
|
696
|
+
if (filePart[p].indexOf('name=') === 0) {
|
|
697
|
+
fileName = filePart[p].substring(5);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (fileName) {
|
|
701
|
+
// with filename
|
|
702
|
+
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${fileVal}, AND NAME ${fileName}`);
|
|
703
|
+
formData.append(mykeys[k], fileVal, fileName);
|
|
704
|
+
} else {
|
|
705
|
+
// with read in file but no file name
|
|
706
|
+
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${fileVal}`);
|
|
707
|
+
formData.append(mykeys[k], fileVal);
|
|
677
708
|
}
|
|
678
|
-
}
|
|
679
|
-
if (fileName) {
|
|
680
|
-
// with filename
|
|
681
|
-
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${fileVal}, AND NAME ${fileName}`);
|
|
682
|
-
formData.append(mykeys[k], fileVal, fileName);
|
|
683
709
|
} else {
|
|
684
|
-
//
|
|
710
|
+
// no file or file name just contents - original
|
|
685
711
|
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${fileVal}`);
|
|
686
712
|
formData.append(mykeys[k], fileVal);
|
|
687
713
|
}
|
|
688
714
|
} else {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
formData.append(mykeys[k], fileVal);
|
|
715
|
+
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${mybody[mykeys[k]]}`);
|
|
716
|
+
formData.append(mykeys[k], mybody[mykeys[k]]);
|
|
692
717
|
}
|
|
693
|
-
} else {
|
|
694
|
-
log.debug(`APPENDING: ${mykeys[k]}, WITH VALUE ${mybody[mykeys[k]]}`);
|
|
695
|
-
formData.append(mykeys[k], mybody[mykeys[k]]);
|
|
696
718
|
}
|
|
697
719
|
}
|
|
698
720
|
// get the new headers
|
|
@@ -888,7 +910,7 @@ function makeRequest(request, entitySchema, callProperties, startTrip, attempt,
|
|
|
888
910
|
|
|
889
911
|
// write to the http request data to the body if not a get (gets do not have data in the body)
|
|
890
912
|
if ((request.header.method !== 'GET' || entitySchema.sendGetBody)
|
|
891
|
-
|
|
913
|
+
&& ((typeof request.body === 'object' && Object.keys(request.body).length > 0)
|
|
892
914
|
|| (typeof request.body === 'string' && request.body !== '{}') || entitySchema.sendEmpty)) {
|
|
893
915
|
if (entitySchema.requestDatatype.toUpperCase() === 'FORM') {
|
|
894
916
|
// pass the formData to the request
|
|
@@ -1205,7 +1227,7 @@ function getToken(reqPath, options, tokenSchema, bodyString, callProperties, cal
|
|
|
1205
1227
|
|
|
1206
1228
|
// process primary token from header
|
|
1207
1229
|
if (tokenSchema.responseSchema && tokenSchema.responseSchema.properties && tokenSchema.responseSchema.properties.token
|
|
1208
|
-
|
|
1230
|
+
&& tokenSchema.responseSchema.properties.token.placement && tokenSchema.responseSchema.properties.token.placement.toUpperCase() === 'HEADER') {
|
|
1209
1231
|
if (!tokenSchema.responseSchema.properties.token.external_name) {
|
|
1210
1232
|
const errorObj = transUtilInst.formatErrorObject(origin, 'Unable To Get Primary Token', ['Primary Token', result.code], null, null, null);
|
|
1211
1233
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
@@ -1794,7 +1816,7 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1794
1816
|
|
|
1795
1817
|
// only add global options if there are global options to add
|
|
1796
1818
|
if (globalRequest && globalRequest.uriOptions
|
|
1797
|
-
|
|
1819
|
+
&& Object.keys(globalRequest.uriOptions).length > 0) {
|
|
1798
1820
|
const optionString = querystring.stringify(globalRequest.uriOptions);
|
|
1799
1821
|
|
|
1800
1822
|
// if no query paramters yet - start with ?
|
|
@@ -1966,6 +1988,17 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1966
1988
|
bodyString = JSON.stringify(tokenEntity);
|
|
1967
1989
|
} else if (tokenSchema.requestDatatype && tokenSchema.requestDatatype.toUpperCase() === 'URLENCODE') {
|
|
1968
1990
|
bodyString = querystring.stringify(tokenEntity);
|
|
1991
|
+
} else if (tokenSchema.requestDatatype && tokenSchema.requestDatatype.toUpperCase() === 'URLQUERY') {
|
|
1992
|
+
// if the datatype is URLQUERY need to put into the query on the request
|
|
1993
|
+
bodyString = querystring.stringify(tokenEntity);
|
|
1994
|
+
|
|
1995
|
+
// append to the path
|
|
1996
|
+
if (options.path.indexOf('?') < 0) {
|
|
1997
|
+
options.path = `${options.path}?${bodyString}`;
|
|
1998
|
+
} else {
|
|
1999
|
+
options.path = `${options.path}&${bodyString}`;
|
|
2000
|
+
}
|
|
2001
|
+
bodyString = '{}';
|
|
1969
2002
|
}
|
|
1970
2003
|
|
|
1971
2004
|
// if there is a body, set the content length of the body and add it to
|
|
@@ -2106,7 +2139,7 @@ function validToken(user, reqBody, invalidToken, callback) {
|
|
|
2106
2139
|
// if the token expired (or will expire within a minute),
|
|
2107
2140
|
// or it is invalid (failed) remove it from the token list
|
|
2108
2141
|
if (tokenList[i].expire < expireCheck
|
|
2109
|
-
|
|
2142
|
+
|| tokenList[i].token.token === invalidToken) {
|
|
2110
2143
|
tokenList.splice(i, 1);
|
|
2111
2144
|
break;
|
|
2112
2145
|
}
|
|
@@ -2820,7 +2853,7 @@ function handleEndThrottleResponse(request, myTransTime, claimedLic, makeResp, r
|
|
|
2820
2853
|
|
|
2821
2854
|
// If the request was successful
|
|
2822
2855
|
if (makeResp !== null && makeResp.code !== undefined
|
|
2823
|
-
|
|
2856
|
+
&& Number(makeResp.code) >= 200 && Number(makeResp.code) <= 299) {
|
|
2824
2857
|
const newResp = {
|
|
2825
2858
|
icode: `AD.${makeResp.code}`,
|
|
2826
2859
|
response: makeResp.response,
|
|
@@ -2919,7 +2952,7 @@ function retryInvalidResponse(request, callProperties, myTransTime, claimedLic,
|
|
|
2919
2952
|
let retries = numRetries;
|
|
2920
2953
|
if (callProperties && callProperties.request && callProperties.request.limit_retry_error) {
|
|
2921
2954
|
if (typeof callProperties.request.limit_retry_error === 'number'
|
|
2922
|
-
|
|
2955
|
+
|| typeof callProperties.request.limit_retry_error === 'string') {
|
|
2923
2956
|
retryError = [Number(callProperties.request.limit_retry_error)];
|
|
2924
2957
|
} else if (Array.isArray(callProperties.request.limit_retry_error)) {
|
|
2925
2958
|
retryError = [];
|
|
@@ -2927,10 +2960,10 @@ function retryInvalidResponse(request, callProperties, myTransTime, claimedLic,
|
|
|
2927
2960
|
if (typeof callProperties.request.limit_retry_error[l] === 'number') {
|
|
2928
2961
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
2929
2962
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
2930
|
-
|
|
2963
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') < 0) {
|
|
2931
2964
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
2932
2965
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
2933
|
-
|
|
2966
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') >= 0) {
|
|
2934
2967
|
const srange = Number(callProperties.request.limit_retry_error[l].split('-')[0]);
|
|
2935
2968
|
const erange = Number(callProperties.request.limit_retry_error[l].split('-')[1]);
|
|
2936
2969
|
for (let r = srange; r <= erange; r += 1) {
|
|
@@ -2947,7 +2980,7 @@ function retryInvalidResponse(request, callProperties, myTransTime, claimedLic,
|
|
|
2947
2980
|
// if the response is valid - good data or legitimate data error
|
|
2948
2981
|
// stop trying if we have tried enough
|
|
2949
2982
|
if (numTries > retries || (mres !== null && mres.code !== undefined && !retryError.includes(Number(mres.code))
|
|
2950
|
-
|
|
2983
|
+
&& (authMethod !== 'request_token' || Number(mres.code) !== Number(tokenError)))) {
|
|
2951
2984
|
const newresp = mres;
|
|
2952
2985
|
newresp.retries = numTries;
|
|
2953
2986
|
|
|
@@ -3083,7 +3116,7 @@ function noQueueRequest(request, callProperties, overallTime, entitySchema, call
|
|
|
3083
3116
|
let retries = numRetries;
|
|
3084
3117
|
if (callProperties && callProperties.request && callProperties.request.limit_retry_error) {
|
|
3085
3118
|
if (typeof callProperties.request.limit_retry_error === 'number'
|
|
3086
|
-
|
|
3119
|
+
|| typeof callProperties.request.limit_retry_error === 'string') {
|
|
3087
3120
|
retryError = [Number(callProperties.request.limit_retry_error)];
|
|
3088
3121
|
} else if (Array.isArray(callProperties.request.limit_retry_error)) {
|
|
3089
3122
|
retryError = [];
|
|
@@ -3091,10 +3124,10 @@ function noQueueRequest(request, callProperties, overallTime, entitySchema, call
|
|
|
3091
3124
|
if (typeof callProperties.request.limit_retry_error[l] === 'number') {
|
|
3092
3125
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
3093
3126
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
3094
|
-
|
|
3127
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') < 0) {
|
|
3095
3128
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
3096
3129
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
3097
|
-
|
|
3130
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') >= 0) {
|
|
3098
3131
|
const srange = Number(callProperties.request.limit_retry_error[l].split('-')[0]);
|
|
3099
3132
|
const erange = Number(callProperties.request.limit_retry_error[l].split('-')[1]);
|
|
3100
3133
|
for (let r = srange; r <= erange; r += 1) {
|
|
@@ -3110,14 +3143,14 @@ function noQueueRequest(request, callProperties, overallTime, entitySchema, call
|
|
|
3110
3143
|
|
|
3111
3144
|
// if invalid token, handle that and retry
|
|
3112
3145
|
if (mres !== null && mres.code !== undefined && Number(mres.code) === Number(tokenError)
|
|
3113
|
-
|
|
3146
|
+
&& authMethod === 'request_token') {
|
|
3114
3147
|
// if we took an invalid token - try one more time
|
|
3115
3148
|
return handleInvalidToken(request, callProperties, 0, { request_id: 0 }, mres, overallTime, overallTime, 0, 1, entitySchema, callback);
|
|
3116
3149
|
}
|
|
3117
3150
|
|
|
3118
3151
|
// if the response is valid - good data or legitimate data error
|
|
3119
3152
|
if (retries < 1 || (mres !== null && mres.code !== undefined && !retryError.includes(Number(mres.code))
|
|
3120
|
-
|
|
3153
|
+
&& (authMethod !== 'request_token' || Number(mres.code) !== Number(tokenError)))) {
|
|
3121
3154
|
return handleEndResponse(request, mres, overallTime, callback);
|
|
3122
3155
|
}
|
|
3123
3156
|
|
|
@@ -3182,7 +3215,7 @@ function queueThrottleRequest(request, callProperties, myRequestId, myTransTime,
|
|
|
3182
3215
|
let retries = numRetries;
|
|
3183
3216
|
if (callProperties && callProperties.request && callProperties.request.limit_retry_error) {
|
|
3184
3217
|
if (typeof callProperties.request.limit_retry_error === 'number'
|
|
3185
|
-
|
|
3218
|
+
|| typeof callProperties.request.limit_retry_error === 'string') {
|
|
3186
3219
|
retryError = [Number(callProperties.request.limit_retry_error)];
|
|
3187
3220
|
} else if (Array.isArray(callProperties.request.limit_retry_error)) {
|
|
3188
3221
|
retryError = [];
|
|
@@ -3190,10 +3223,10 @@ function queueThrottleRequest(request, callProperties, myRequestId, myTransTime,
|
|
|
3190
3223
|
if (typeof callProperties.request.limit_retry_error[l] === 'number') {
|
|
3191
3224
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
3192
3225
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
3193
|
-
|
|
3226
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') < 0) {
|
|
3194
3227
|
retryError.push(Number(callProperties.request.limit_retry_error[l]));
|
|
3195
3228
|
} else if (typeof callProperties.request.limit_retry_error[l] === 'string'
|
|
3196
|
-
|
|
3229
|
+
&& callProperties.request.limit_retry_error[l].indexOf('-') >= 0) {
|
|
3197
3230
|
const srange = Number(callProperties.request.limit_retry_error[l].split('-')[0]);
|
|
3198
3231
|
const erange = Number(callProperties.request.limit_retry_error[l].split('-')[1]);
|
|
3199
3232
|
for (let r = srange; r <= erange; r += 1) {
|
|
@@ -3209,14 +3242,14 @@ function queueThrottleRequest(request, callProperties, myRequestId, myTransTime,
|
|
|
3209
3242
|
|
|
3210
3243
|
// if invalid token, handle that and retry
|
|
3211
3244
|
if (mres !== null && mres.code !== undefined && Number(mres.code) === Number(tokenError)
|
|
3212
|
-
|
|
3245
|
+
&& authMethod === 'request_token') {
|
|
3213
3246
|
// if we took an invalid token - try one more time
|
|
3214
3247
|
return handleInvalidToken(request, callProperties, myTransTime, claimedLic, mres, reqTime, overallTime, waitEnd, 1, entitySchema, callback);
|
|
3215
3248
|
}
|
|
3216
3249
|
|
|
3217
3250
|
// if the response is valid - good data or legitimate data error
|
|
3218
3251
|
if (retries < 1 || (mres !== null && mres.code !== undefined && !retryError.includes(Number(mres.code))
|
|
3219
|
-
|
|
3252
|
+
&& (authMethod !== 'request_token' || Number(mres.code) !== Number(tokenError)))) {
|
|
3220
3253
|
return handleEndThrottleResponse(request, myTransTime, claimedLic, mres, reqTime, overallTime, waitEnd, callback);
|
|
3221
3254
|
}
|
|
3222
3255
|
|
|
@@ -3366,13 +3399,13 @@ class ConnectorRest {
|
|
|
3366
3399
|
|
|
3367
3400
|
// set the invalid token error (optional - default is null)
|
|
3368
3401
|
if (typeof props.authentication.invalid_token_error === 'number'
|
|
3369
|
-
|
|
3402
|
+
|| typeof props.authentication.invalid_token_error === 'string') {
|
|
3370
3403
|
tokenError = Number(props.authentication.invalid_token_error);
|
|
3371
3404
|
}
|
|
3372
3405
|
|
|
3373
3406
|
// set the token timeout (optional - default is null)
|
|
3374
3407
|
if (typeof props.authentication.token_timeout === 'number'
|
|
3375
|
-
|
|
3408
|
+
|| typeof props.authentication.token_timeout === 'string') {
|
|
3376
3409
|
tokenTimeout = Number(props.authentication.token_timeout);
|
|
3377
3410
|
}
|
|
3378
3411
|
|
|
@@ -3453,19 +3486,19 @@ class ConnectorRest {
|
|
|
3453
3486
|
if (props.request) {
|
|
3454
3487
|
// set the number of redirects (optional - default is 0)
|
|
3455
3488
|
if (typeof props.request.number_redirects === 'number'
|
|
3456
|
-
|
|
3489
|
+
|| typeof props.request.number_redirects === 'string') {
|
|
3457
3490
|
numRedirects = Number(props.request.number_redirects);
|
|
3458
3491
|
}
|
|
3459
3492
|
|
|
3460
3493
|
// set the number of retries (optional - default is 3)
|
|
3461
3494
|
if (typeof props.request.number_retries === 'number'
|
|
3462
|
-
|
|
3495
|
+
|| typeof props.request.number_retries === 'string') {
|
|
3463
3496
|
numRetries = Number(props.request.number_retries);
|
|
3464
3497
|
}
|
|
3465
3498
|
|
|
3466
3499
|
// set the request retry error (optional - default is 0)
|
|
3467
3500
|
if (typeof props.request.limit_retry_error === 'number'
|
|
3468
|
-
|
|
3501
|
+
|| typeof props.request.limit_retry_error === 'string') {
|
|
3469
3502
|
limitRetryError = [Number(props.request.limit_retry_error)];
|
|
3470
3503
|
} else if (Array.isArray(props.request.limit_retry_error)) {
|
|
3471
3504
|
limitRetryError = [];
|
|
@@ -3473,10 +3506,10 @@ class ConnectorRest {
|
|
|
3473
3506
|
if (typeof props.request.limit_retry_error[l] === 'number') {
|
|
3474
3507
|
limitRetryError.push(Number(props.request.limit_retry_error[l]));
|
|
3475
3508
|
} else if (typeof props.request.limit_retry_error[l] === 'string'
|
|
3476
|
-
|
|
3509
|
+
&& props.request.limit_retry_error[l].indexOf('-') < 0) {
|
|
3477
3510
|
limitRetryError.push(Number(props.request.limit_retry_error[l]));
|
|
3478
3511
|
} else if (typeof props.request.limit_retry_error[l] === 'string'
|
|
3479
|
-
|
|
3512
|
+
&& props.request.limit_retry_error[l].indexOf('-') >= 0) {
|
|
3480
3513
|
const srange = Number(props.request.limit_retry_error[l].split('-')[0]);
|
|
3481
3514
|
const erange = Number(props.request.limit_retry_error[l].split('-')[1]);
|
|
3482
3515
|
for (let r = srange; r <= erange; r += 1) {
|
|
@@ -3488,7 +3521,7 @@ class ConnectorRest {
|
|
|
3488
3521
|
|
|
3489
3522
|
// set the request attempt timeout (optional - default is 5000)
|
|
3490
3523
|
if (typeof props.request.attempt_timeout === 'number'
|
|
3491
|
-
|
|
3524
|
+
|| typeof props.request.attempt_timeout === 'string') {
|
|
3492
3525
|
attemptTimeout = Number(props.request.attempt_timeout);
|
|
3493
3526
|
}
|
|
3494
3527
|
|
|
@@ -3910,7 +3943,7 @@ class ConnectorRest {
|
|
|
3910
3943
|
}
|
|
3911
3944
|
|
|
3912
3945
|
if (pres !== null && pres.code !== undefined
|
|
3913
|
-
|
|
3946
|
+
&& (Number(pres.code) < 200 || Number(pres.code) > 299)) {
|
|
3914
3947
|
let errorObj = null;
|
|
3915
3948
|
|
|
3916
3949
|
if (pres.code === -2) {
|
package/lib/propertyUtil.js
CHANGED
|
@@ -326,8 +326,8 @@ class AdapterPropertyUtil {
|
|
|
326
326
|
|
|
327
327
|
// need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
|
|
328
328
|
if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
|
|
329
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== '
|
|
330
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
329
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
|
|
330
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
331
331
|
entitySchema.requestDatatype = 'PLAIN';
|
|
332
332
|
}
|
|
333
333
|
if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
|
|
@@ -761,8 +761,8 @@ class AdapterPropertyUtil {
|
|
|
761
761
|
|
|
762
762
|
// need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
|
|
763
763
|
if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
|
|
764
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== '
|
|
765
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
764
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
|
|
765
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
766
766
|
entitySchema.requestDatatype = 'PLAIN';
|
|
767
767
|
}
|
|
768
768
|
if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
|