fiftyone.pipeline.core
Advanced tools
Comparing version 4.1.0-beta.9 to 4.1.0-beta.15
@@ -33,4 +33,2 @@ /* ********************************************************************* | ||
console.log(process.env.directory); | ||
const FiftyOnePipelineCore = require((process.env.directory || __dirname) + "/../../"); | ||
@@ -69,14 +67,35 @@ | ||
//! [class] | ||
//! [constructor] | ||
// Astrology flowElement | ||
let astrology = new FiftyOnePipelineCore.flowElement({ | ||
dataKey: "astrology", // datakey used to categorise data coming back from this flowElement in a pipeline | ||
evidenceKeyFilter: new FiftyOnePipelineCore.basicListEvidenceKeyFilter(["user.dateOfBirth"]), // A filter (in this case a basic list) stating which evidence the flowElement is interested in | ||
class astrology extends FiftyOnePipelineCore.flowElement { | ||
// The processInternal function is the core working of a flowElement. It takes flowData, reads evidence and returns data. | ||
processInternal: function (flowData) { | ||
constructor() { | ||
super(...arguments); | ||
// datakey used to categorise data coming back from this flowElement in a pipeline | ||
this.dataKey = "astrology"; | ||
// A filter (in this case a basic list) stating which evidence the | ||
// flowElement is interested in, in this case a query string | ||
this.evidenceKeyFilter = new FiftyOnePipelineCore.basicListEvidenceKeyFilter(["query.dateOfBirth"]); | ||
// The properties list includes extra information about the properties available from a flowElement | ||
this.properties = { | ||
starSign: { | ||
type: "string", | ||
description: "the user's starsign" | ||
} | ||
}; | ||
} | ||
//! [constructor] | ||
// Internal processing function | ||
processInternal(flowData) { | ||
let result = {}; | ||
// Get the date of birth from the query string (submitted through a form on the client side) | ||
let dateOfBirth = flowData.evidence.get("user.dateOfBirth"); | ||
let dateOfBirth = flowData.evidence.get("query.dateOfBirth"); | ||
@@ -102,15 +121,13 @@ if (dateOfBirth) { | ||
}, | ||
// The properties list includes extra information about the properties available from a flowElement | ||
properties: { | ||
starSign: { | ||
type: "string", | ||
description: "the user's starsign" | ||
} | ||
} | ||
}); | ||
} | ||
//! [class] | ||
//! [usage] | ||
let element = new astrology(); | ||
// Create the pipeline and add the astrology flowElement | ||
let pipeline = new FiftyOnePipelineCore.pipelineBuilder() | ||
.add(astrology) | ||
.add(element) | ||
.build(); | ||
@@ -122,3 +139,3 @@ | ||
// Add the date of birth evidence | ||
flowData.evidence.add("user.dateOfBirth", "2019-09-26"); | ||
flowData.evidence.add("query.dateOfBirth", "2019-09-26"); | ||
@@ -134,1 +151,2 @@ // Process the flowData | ||
//! [usage] |
@@ -65,9 +65,33 @@ /* ********************************************************************* | ||
//! [class] | ||
//! [constructor] | ||
// Astrology flowElement | ||
let astrology = new FiftyOnePipelineCore.flowElement({ | ||
dataKey: "astrology", // datakey used to categorise data coming back from this flowElement in a pipeline | ||
evidenceKeyFilter: new FiftyOnePipelineCore.basicListEvidenceKeyFilter(["cookie.latitude", "query.dateOfBirth"]), // A filter (in this case a basic list) stating which evidence the flowElement is interested in | ||
class astrology extends FiftyOnePipelineCore.flowElement { | ||
constructor() { | ||
super(...arguments); | ||
// datakey used to categorise data coming back from this flowElement in a pipeline | ||
this.dataKey = "astrology"; | ||
// A filter (in this case a basic list) stating which evidence the flowElement is interested in | ||
this.evidenceKeyFilter = new FiftyOnePipelineCore.basicListEvidenceKeyFilter(["cookie.latitude", "query.dateOfBirth"]); | ||
// The properties list includes extra information about the properties available from a flowElement | ||
this.properties = { | ||
starSign: { | ||
type: "string", | ||
description: "the user's starsign" | ||
}, | ||
getLatitude: { | ||
type: "javascript", | ||
description: "JavaScript used to get a user's latitude" | ||
} | ||
}; | ||
} | ||
//! [constructor] | ||
// The processInternal function is the core working of a flowElement. It takes flowData, reads evidence and returns data. | ||
processInternal: function (flowData) { | ||
processInternal(flowData) { | ||
@@ -115,21 +139,14 @@ let result = {}; | ||
}, | ||
// The properties list includes extra information about the properties available from a flowElement | ||
properties: { | ||
starSign: { | ||
type: "string", | ||
description: "the user's starsign" | ||
}, | ||
getLatitude: { | ||
type: "javascript", | ||
description: "JavaScript used to get a user's latitude" | ||
} | ||
} | ||
}); | ||
} | ||
//! [class] | ||
//! [usage] | ||
let element = new astrology(); | ||
const http = require('http'); | ||
let pipeline = new FiftyOnePipelineCore.pipelineBuilder() | ||
.add(astrology) | ||
.add(element) | ||
.build(); | ||
@@ -183,1 +200,2 @@ | ||
server.listen(portNum); | ||
//! [usage] |
{ | ||
"name": "fiftyone.pipeline.core", | ||
"version": "4.1.0-beta.9", | ||
"version": "4.1.0-beta.15", | ||
"description": "Core library for the 51Degrees Pipeline API", | ||
@@ -5,0 +5,0 @@ "directories": { |
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
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
75030
1686
11