fiftyone.pipeline.core
Advanced tools
Comparing version 4.2.2 to 4.3.0
@@ -24,5 +24,9 @@ /* ********************************************************************* | ||
const util = require('util'); | ||
const errorMessages = require('../fiftyone.pipeline.engines/errorMessages') | ||
const errorMessages = require('./errorMessages') | ||
/** | ||
* @typedef {import('./flowElement')} FlowElement | ||
*/ | ||
/** | ||
* Stores information created by a flowElement based on flowData. | ||
@@ -32,2 +36,3 @@ * Stored in flowData | ||
class ElementData { | ||
/** | ||
@@ -37,3 +42,3 @@ * Constructor for elementData | ||
* @param {object} options the options object | ||
* @param {flowElement} options.flowElement the FlowElement this data | ||
* @param {FlowElement} options.flowElement the FlowElement this data | ||
* is part of | ||
@@ -121,3 +126,3 @@ */ | ||
* @param {string} key the key to retreive a property value for | ||
* @returns {float} value | ||
* @returns {number} value | ||
*/ | ||
@@ -136,3 +141,3 @@ getAsFloat (key) { | ||
* @param {string} key the key to retreive a property value for | ||
* @returns {int} value | ||
* @returns {number} value | ||
*/ | ||
@@ -139,0 +144,0 @@ getAsInteger (key) { |
@@ -26,2 +26,6 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./flowElement')} FlowElement | ||
*/ | ||
/** | ||
* A basic extension of elementData with dictionary object storage / lookup | ||
@@ -36,3 +40,3 @@ **/ | ||
* added to | ||
* @param {contents} options.contents // key value dictionary | ||
* @param {object} options.contents // key value dictionary | ||
*/ | ||
@@ -55,3 +59,3 @@ constructor ({ flowElement, contents }) { | ||
* @param {string} key the property key to retrieve | ||
* @returns {int} value | ||
* @returns {number} integer value | ||
*/ | ||
@@ -58,0 +62,0 @@ getInternal (key) { |
@@ -25,3 +25,6 @@ /* ********************************************************************* | ||
noElementData: 'There is no element data for "%s" against this flow ' + | ||
'data. Available element data keys are: %s.' | ||
'data. Available element data keys are: %s.', | ||
genericMissingProperties: 'Property "%s" not found', | ||
noReasonUnknown: ' Please check that the element and property names ' + | ||
'are correct.' | ||
} |
@@ -26,2 +26,6 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./flowData')} FlowData | ||
*/ | ||
/** | ||
* Storage of evidence on a flowData object | ||
@@ -28,0 +32,0 @@ */ |
@@ -28,2 +28,8 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./pipeline')} Pipeline | ||
* @typedef {import('./flowElement')} FlowElement | ||
* @typedef {import('./elementData')} ElementData | ||
*/ | ||
/** | ||
* FlowData is created by a specific pipeline | ||
@@ -30,0 +36,0 @@ * It collects evidence set by the user |
@@ -26,2 +26,7 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./flowData')} FlowData | ||
* @typedef {import('./pipeline')} Pipeline | ||
*/ | ||
/** | ||
* A FlowElement is placed inside a pipeline | ||
@@ -42,3 +47,3 @@ * It receives Evidence via a FlowData object | ||
* @param {object} options.properties list of properties including metadata | ||
* @param {{EvidenceKeyFilter}} options.evidenceKeyFilter an instance of | ||
* @param {EvidenceKeyFilter} options.evidenceKeyFilter an instance of | ||
* an EvidenceKeyFilter to filter evidence added to the Pipeline | ||
@@ -45,0 +50,0 @@ */ |
@@ -27,2 +27,3 @@ /* ********************************************************************* | ||
ElementDataDictionary: require('./elementDataDictionary'), | ||
ErrorMessages: require('./errorMessages'), | ||
Evidence: require('./evidence'), | ||
@@ -37,3 +38,5 @@ EvidenceKeyFilter: require('./evidenceKeyFilter'), | ||
JavascriptBuilder: require('./javascriptbuilder'), | ||
SequenceElement: require('./sequenceElement') | ||
SequenceElement: require('./sequenceElement'), | ||
SetHeadersElement: require('./setHeadersElement'), | ||
Helpers: require('./helpers') | ||
}; |
@@ -27,2 +27,5 @@ /* ********************************************************************* | ||
const elementBlacklist = [ 'jsonbundler', 'javascriptbuilder', 'sequence', 'set-headers']; | ||
/** | ||
@@ -71,7 +74,9 @@ * The JSONBundler aggregates all properties from FlowElements | ||
for (const flowElement in flowData.pipeline.flowElements) { | ||
if ( | ||
flowElement === 'jsonbundler' || | ||
flowElement === 'javascriptbuilder' || | ||
flowElement === 'sequence' | ||
) { | ||
let blacklisted = false; | ||
elementBlacklist.forEach(name => { | ||
if (name === flowElement) { | ||
blacklisted = true; | ||
} | ||
}); | ||
if (blacklisted) { | ||
continue; | ||
@@ -78,0 +83,0 @@ } |
{ | ||
"name": "fiftyone.pipeline.core", | ||
"version": "4.2.2", | ||
"version": "4.3.0", | ||
"description": "Core library for the 51Degrees Pipeline API", | ||
@@ -9,2 +9,3 @@ "directories": { | ||
"main": "index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
@@ -19,2 +20,3 @@ "test": "jest" | ||
"devDependencies": { | ||
"@types/node": "^15.12.2", | ||
"eslint": "^6.8.0", | ||
@@ -27,3 +29,5 @@ "eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"jest": "^24.9.0" | ||
"jest": "^24.9.0", | ||
"jest-each": "^26.6.2", | ||
"node-mocks-http": "^1.10.1" | ||
}, | ||
@@ -30,0 +34,0 @@ "contributors": [ |
@@ -27,2 +27,6 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./flowElement')} FlowElement | ||
*/ | ||
/** | ||
* Pipeline holding a list of flowElements for processing, can create | ||
@@ -36,3 +40,3 @@ * flowData that will be passed through these, collecting elementData | ||
* | ||
* @param {FlowElements[]} flowElements list of FlowElements to | ||
* @param {FlowElement[]} flowElements list of FlowElements to | ||
* add to the Pipeline | ||
@@ -203,2 +207,7 @@ */ | ||
/** | ||
* | ||
* @param {FlowElement} flowElement | ||
* @returns {void} | ||
*/ | ||
updatePropertyDataBaseForElement (flowElement) { | ||
@@ -205,0 +214,0 @@ const pipeline = this; |
@@ -29,2 +29,6 @@ /* ********************************************************************* | ||
/** | ||
* @typedef {import('./flowElement')} FlowElement | ||
*/ | ||
/** | ||
* A PipelineBuilder generates a Pipeline object | ||
@@ -46,6 +50,13 @@ * Before construction of the Pipeline, FlowElements are added to it | ||
* true by default. | ||
* @param {object} settings.javascriptBuilderSettings The settings | ||
* @param {boolean} settings.useSetHeaderProperties Whether to | ||
* automatically add the SetHeadersElement needed to request additional | ||
* HTTP headers from the client side. This is true by default. | ||
* @param {typeof import('./javascriptbuilder').prototype.settings} | ||
* settings.javascriptBuilderSettings The settings | ||
* to pass to the JavaScriptBuilder. See JavaScriptBuilder class for details. | ||
*/ | ||
constructor (settings = {}) { | ||
/** | ||
* @type {FlowElement[]} | ||
*/ | ||
this.flowElements = []; | ||
@@ -62,2 +73,8 @@ | ||
} | ||
if (typeof settings.useSetHeaderProperties !== 'undefined') { | ||
this.useSetHeaderProperties = settings.useSetHeaderProperties; | ||
} else { | ||
this.useSetHeaderProperties = true; | ||
} | ||
} | ||
@@ -150,2 +167,24 @@ | ||
/** | ||
* Internal function used to first check if the | ||
* HTTP elements should be added to the pipeline | ||
* and add them if requested. | ||
* | ||
* @returns {FlowElement[]} list of HTTP related | ||
* FlowElements | ||
*/ | ||
getHttpElements () { | ||
const flowElements = []; | ||
if (this.useSetHeaderProperties) { | ||
// Add HTTP elements | ||
const SetHeadersElement = require('./setHeadersElement'); | ||
flowElements.push(new SetHeadersElement()); | ||
} | ||
return flowElements; | ||
} | ||
/** | ||
* Add a single flowElement to be executed in series | ||
@@ -182,3 +221,5 @@ * | ||
build () { | ||
this.flowElements = this.flowElements.concat(this.getJavaScriptElements()); | ||
this.flowElements = this.flowElements | ||
.concat(this.getJavaScriptElements()) | ||
.concat(this.getHttpElements()); | ||
@@ -185,0 +226,0 @@ return new Pipeline(this.flowElements); |
@@ -87,3 +87,3 @@ /* ********************************************************************* | ||
errorMessages.noElementData, | ||
'invalid', 'async, sync, jsonbundler, javascriptbuilder')) !== -1) | ||
'invalid', 'async, sync, jsonbundler, javascriptbuilder, set-headers')) !== -1) | ||
.toBe(true); | ||
@@ -90,0 +90,0 @@ |
@@ -120,3 +120,22 @@ /* ********************************************************************* | ||
} | ||
}), | ||
device: new FlowElement({ | ||
dataKey: 'device', | ||
additionalValues: {}, | ||
processInternal: function (flowData) { | ||
const data = new ElementDataDictionary({ | ||
flowElement: this, | ||
contents: { | ||
yes: new AspectPropertyValue(null, 'success'), | ||
no: new AspectPropertyValue('Value missing') | ||
} | ||
} | ||
); | ||
for (const [key, value] of Object.entries(this.additionalValues)) { | ||
data.contents[key] = value; | ||
} | ||
flowData.setElementData(data); | ||
} | ||
}) | ||
}; |
@@ -25,3 +25,3 @@ /* ********************************************************************* | ||
const errorMessages = require(__dirname + | ||
'/../../fiftyone.pipeline.engines/errorMessages'); | ||
'/../errorMessages'); | ||
const Engine = require(__dirname + '/../../fiftyone.pipeline.engines/engine'); | ||
@@ -28,0 +28,0 @@ const PipelineBuilder = require( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
194452
58
4586
11
21