\r\n

51Degrees Pipeline Node.js  4.4

51Degrees Pipeline for Node.js

CloudRequestEngine Class Reference

Inheritance diagram for CloudRequestEngine:

[legend]

Collaboration diagram for CloudRequestEngine:

[legend]

Public Member Functions

 constructor ({ resourceKey, licenseKey, baseURL, cloudRequestOrigin, requestClient })
Constructor for CloudRequestEngine. More...
get  keysAndPropertiesFetched ()
Check if the keys and properties have been fetched. More...
 fetchEvidenceKeysAndProperties (resolveCallback, rejectCallback)
Fetches evidence keys and properties data. More...
 ready ()
Function for testing if the cloud engine is ready Checks to see if properties and evidence keys have been fetched. More...
 processInternal (flowData)
Internal process for cloud engine Returns raw JSON as a "cloud" property in "cloud". More...
 getErrorMessages (responseBody)
Typically, cloud will return errors as JSON. More...
 getErrorsFromResponse (response)
Used to handle errors from http requests. More...
 fetchProperties ()
Internal process to fetch all the properties available under a resourcekey. More...
 propertiesTransform (properties)
 metaPropertyTransform (key, value)
 getData (flowData)
Internal function to get data from cloud service. More...
 getEvidenceKeys ()
Internal function to get evidenceKeys used by cloud resourcekey. More...
 getContent (flowData)
Generate the Content to send in the POST request. More...
 addQueryData (flowData, queryData, allEvidence, evidence)
Add query data to the evidence. More...
 getSelectedEvidence (evidence, type)
Get evidence with specified prefix. More...
 hasKeyPrefix (itemKey, prefix)
Check that the key of a KeyValuePair has the given prefix. More...

Public Member Functions inherited from Engine

 constructor ({ cache, restrictedProperties, dataFile }={})
Constructor for an Engine. More...
 inCache (flowData)
Checks cache and returns cached result if found. More...
 process (flowData)
An engine's process function checks cache for an item (calling inCache) If found it returns the cached object If not found it runs the standard processInternal function and adds it to the cache (if a cache is present) More...
 refresh ()
Callback which runs when an attached DataFile is updated Needs to be overriden by a specific engine to do anything. More...
 registerDataFile (dataFile)
Function to attach a DataFile to the engine and register it with a DataFileUpdateService if needed. More...

Public Member Functions inherited from FlowElement

 constructor ({ processInternal, dataKey, properties={}, evidenceKeyFilter }={})
Constructor for flowElement class. More...
 onRegistration (pipeline, flowElement)
Internal function to be called when a FlowElement is added to pipeline, runs through any registrationCallbacks on the FlowElement. More...
 ready ()
Function called to check if a FlowElement is ready Used when there are asynchronous initialisation steps. More...
 processInternal (flowData)
Internal process function for a particular flowElement called (via the flowElement.process() method) when flowData generated by a pipleline is processsed. More...
 process (flowData)
To allow actions to take place before and after a FlowElement's processInternal function runs, a process wrapper is run first. More...
 updateProperties ()
Call this function to update the properties meta database in all the pipelines this flowElement has been added to. More...
 getProperties ()
Get a flowElement's properties. More...
 _log (type, message)

Member Function Documentation

◆ addQueryData()

CloudRequestEngine::addQueryData (   flowData,
  queryData,
  allEvidence,
  evidence  
)
inline

Add query data to the evidence.

Parameters
flowData -
{object} - queryData The destination dictionary to add query data to.
{Evidence} - allEvidence All evidence in the flow data. This is used to report which evidence keys are conflicting.
{object} - evidence Evidence to add to the query Data.

◆ constructor()

CloudRequestEngine::constructor (   { resourceKey, licenseKey, baseURL, cloudRequestOrigin, requestClient } )
inline

Constructor for CloudRequestEngine.

Parameters
{object} - options options object
{string} - options.resourceKey resourcekey for cloud service
{string} - options.licenseKey licensekey for cloud service
{string} - options.baseURL url the cloud service is located at if overriding default
{string} - options.cloudRequestOrigin The value to set for the Origin header when making requests to the cloud service. This is used by the cloud service to check that the request is being made from a origin matching those allowed by the resource key. For more detail, see the 'Request Headers' section in the cloud documentation.
options.requestClient -

◆ fetchEvidenceKeysAndProperties()

CloudRequestEngine::fetchEvidenceKeysAndProperties (   resolveCallback,
  rejectCallback  
)
inline

Fetches evidence keys and properties data.

This method asynchronously fetches evidence keys and properties required for the operation. It uses Promises to handle data retrieval and provides callback functions for success and failure scenarios.

Parameters
{Function} - resolveCallback - A callback function to be called when the data is successfully fetched. It will receive the current instance as a parameter.
{Function} - rejectCallback - A callback function to be called when an error occurs during data retrieval. It will receive the error information as a parameter.

◆ fetchProperties()

CloudRequestEngine::fetchProperties ( )
inline

Internal process to fetch all the properties available under a resourcekey.

Returns
{Promise} properties from the cloud server

◆ getContent()

CloudRequestEngine::getContent (   flowData )
inline

Generate the Content to send in the POST request.

The evidence keys e.g. 'query.' and 'header.' have an order of precedence. These are added to the evidence in reverse order, if there is conflict then the queryData value is overwritten. 'query.' evidence should take precedence over all other evidence. If there are evidence keys other than 'query.' that conflict then this is unexpected so a warning will be logged.

Parameters
{FlowData} - flowData
Returns
{Evidence} Evidence Dictionary

◆ getData()

CloudRequestEngine::getData (   flowData )
inline

Internal function to get data from cloud service.

Parameters
{FlowData} - flowData FlowData used to extract evidence and send to cloud service for processing
Returns
{Promise} result of processing

◆ getErrorMessages()

CloudRequestEngine::getErrorMessages (   responseBody )
inline

Typically, cloud will return errors as JSON.

However, transport level errors or other failures can result in responses that are plain text. This function handles these cases.

Parameters
{string} - response the response data to process
responseBody -
Returns
{Array} The error messages

◆ getErrorsFromResponse()

CloudRequestEngine::getErrorsFromResponse (   response )
inline

Used to handle errors from http requests.

Parameters
response -

◆ getEvidenceKeys()

CloudRequestEngine::getEvidenceKeys ( )
inline

Internal function to get evidenceKeys used by cloud resourcekey.

Returns
{Array} evidence key list

◆ getSelectedEvidence()

CloudRequestEngine::getSelectedEvidence (   evidence,
  type  
)
inline

Get evidence with specified prefix.

Parameters
{Evidence} - evidence All evidence in the flow data.
{stirng} - type Required evidence key prefix

◆ hasKeyPrefix()

CloudRequestEngine::hasKeyPrefix (   itemKey,
  prefix  
)
inline

Check that the key of a KeyValuePair has the given prefix.

Parameters
{string} - itemKey Key to check
{string} - prefix The prefix to check for.
Returns
True if the key has the prefix.

◆ keysAndPropertiesFetched()

get CloudRequestEngine::keysAndPropertiesFetched ( )
inline

Check if the keys and properties have been fetched.

This computed property determines whether the keys of a 'flowElementProperties' object and the 'evidenceKeyFilter' array both have elements, indicating that the necessary data has been fetched and is ready for use.

Returns
{boolean} True if the keys and properties are fetched and ready; otherwise, false.

◆ processInternal()

CloudRequestEngine::processInternal (   flowData )
inline

Internal process for cloud engine Returns raw JSON as a "cloud" property in "cloud".

Parameters
{FlowData} - flowData flowData to process
Returns
{Promise} data from cloud service

◆ ready()

CloudRequestEngine::ready ( )
inline

Function for testing if the cloud engine is ready Checks to see if properties and evidence keys have been fetched.

Returns
{Promise} whether ready
On This Page