fiftyone.pipeline.cloudrequestengine 4.4.92 → 4.4.94
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/cloudRequestEngine.js +8 -7
- package/package.json +1 -1
- package/requestClient.js +3 -4
- package/tests/cloudResponse.test.js +3 -2
package/cloudRequestEngine.js
CHANGED
|
@@ -52,7 +52,7 @@ class CloudRequestEngine extends Engine {
|
|
|
52
52
|
* made from a origin matching those allowed by the resource key.
|
|
53
53
|
* For more detail, see the 'Request Headers' section in the
|
|
54
54
|
* <a href="https://cloud.51degrees.com/api-docs/index.html">cloud documentation</a>.
|
|
55
|
-
* @param options.requestClient
|
|
55
|
+
* @param {RequestClient} options.requestClient Set predefined RequestClient.
|
|
56
56
|
*/
|
|
57
57
|
constructor (
|
|
58
58
|
{
|
|
@@ -176,8 +176,7 @@ class CloudRequestEngine extends Engine {
|
|
|
176
176
|
* However, transport level errors or other failures can result in
|
|
177
177
|
* responses that are plain text. This function handles these cases.
|
|
178
178
|
*
|
|
179
|
-
* @param {string}
|
|
180
|
-
* @param responseBody
|
|
179
|
+
* @param {string} responseBody the response data to process
|
|
181
180
|
* @returns {Array} The error messages
|
|
182
181
|
*/
|
|
183
182
|
getErrorMessages (responseBody) {
|
|
@@ -196,7 +195,8 @@ class CloudRequestEngine extends Engine {
|
|
|
196
195
|
/**
|
|
197
196
|
* Used to handle errors from http requests
|
|
198
197
|
*
|
|
199
|
-
* @param response
|
|
198
|
+
* @param {http.ServerResponse} response Responce to get errors from
|
|
199
|
+
* @returns {Array<CloudRequestError>} Array of CloudRequestError from response
|
|
200
200
|
*/
|
|
201
201
|
getErrorsFromResponse (response) {
|
|
202
202
|
let content = response;
|
|
@@ -370,7 +370,7 @@ class CloudRequestEngine extends Engine {
|
|
|
370
370
|
* If there are evidence keys other than 'query.' that conflict then
|
|
371
371
|
* this is unexpected so a warning will be logged.
|
|
372
372
|
*
|
|
373
|
-
* @param {FlowData} flowData
|
|
373
|
+
* @param {FlowData} flowData FlowData to get evidence from
|
|
374
374
|
* @returns {Evidence} Evidence Dictionary
|
|
375
375
|
*/
|
|
376
376
|
getContent (flowData) {
|
|
@@ -393,7 +393,7 @@ class CloudRequestEngine extends Engine {
|
|
|
393
393
|
/**
|
|
394
394
|
* Add query data to the evidence.
|
|
395
395
|
*
|
|
396
|
-
* @param flowData
|
|
396
|
+
* @param {FlowData} flowData FlowData for logging
|
|
397
397
|
* @param {object} queryData The destination dictionary to add query data to.
|
|
398
398
|
* @param {Evidence} allEvidence All evidence in the flow data. This is used to
|
|
399
399
|
* report which evidence keys are conflicting.
|
|
@@ -449,6 +449,7 @@ class CloudRequestEngine extends Engine {
|
|
|
449
449
|
*
|
|
450
450
|
* @param {Evidence} evidence All evidence in the flow data.
|
|
451
451
|
* @param {stirng} type Required evidence key prefix
|
|
452
|
+
* @returns {Evidence} Selected evidence
|
|
452
453
|
*/
|
|
453
454
|
getSelectedEvidence (evidence, type) {
|
|
454
455
|
let selectedEvidence = {};
|
|
@@ -483,7 +484,7 @@ class CloudRequestEngine extends Engine {
|
|
|
483
484
|
*
|
|
484
485
|
* @param {string} itemKey Key to check
|
|
485
486
|
* @param {string} prefix The prefix to check for.
|
|
486
|
-
* @returns True if the key has the prefix.
|
|
487
|
+
* @returns {boolean} True if the key has the prefix.
|
|
487
488
|
*/
|
|
488
489
|
hasKeyPrefix (itemKey, prefix) {
|
|
489
490
|
return itemKey.startsWith(prefix + '.');
|
package/package.json
CHANGED
package/requestClient.js
CHANGED
|
@@ -28,7 +28,7 @@ class RequestClient {
|
|
|
28
28
|
* @param {*} data The data to send in the body of the request
|
|
29
29
|
* @param {*} origin The value to use for the Origin header when
|
|
30
30
|
* making the request
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns {Promise} The resolve function will be passed the content
|
|
32
32
|
* from the response and the reject function will be passed
|
|
33
33
|
* an object with 3 properties:
|
|
34
34
|
* headers = HTTP headers in the response
|
|
@@ -43,9 +43,8 @@ class RequestClient {
|
|
|
43
43
|
} else {
|
|
44
44
|
httpModule = require('http');
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
let requestData = '';
|
|
47
47
|
if (data) {
|
|
48
|
-
var requestData = '';
|
|
49
48
|
const keys = Object.keys(data);
|
|
50
49
|
for (let i = 0; i < keys.length; i++) {
|
|
51
50
|
requestData += encodeURIComponent(keys[i]) + '=' + encodeURIComponent(data[keys[i]]);
|
|
@@ -104,7 +103,7 @@ class RequestClient {
|
|
|
104
103
|
* @param {*} url The url to send a request to
|
|
105
104
|
* @param {*} origin The value to use for the Origin header when
|
|
106
105
|
* making the request
|
|
107
|
-
* @returns
|
|
106
|
+
* @returns {Promise} The resolve function will be passed the content
|
|
108
107
|
* from the response and the reject function will be passed
|
|
109
108
|
* an object with 3 properties:
|
|
110
109
|
* headers = HTTP headers in the response
|
|
@@ -215,9 +215,10 @@ test('validate case when cloud unavailable', (done) => {
|
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
+
* Check if Properties contains name
|
|
218
219
|
*
|
|
219
|
-
* @param properties
|
|
220
|
-
* @param name
|
|
220
|
+
* @param {object} properties Object of properties
|
|
221
|
+
* @param {string} name Name of the property
|
|
221
222
|
*/
|
|
222
223
|
function propertiesContainName (properties, name) {
|
|
223
224
|
expect(properties[name.toLowerCase()]).not.toBeUndefined();
|