fiftyone.pipeline.core 4.4.7 → 4.4.9

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/elementData.js CHANGED
@@ -21,7 +21,7 @@
21
21
  * ********************************************************************* */
22
22
 
23
23
  const util = require('util');
24
- const errorMessages = require('./errorMessages')
24
+ const errorMessages = require('./errorMessages');
25
25
 
26
26
  /**
27
27
  * @typedef {import('./flowElement')} FlowElement
@@ -32,7 +32,6 @@ const errorMessages = require('./errorMessages')
32
32
  * Stored in flowData
33
33
  */
34
34
  class ElementData {
35
-
36
35
  /**
37
36
  * Constructor for elementData
38
37
  *
@@ -54,18 +53,18 @@ class ElementData {
54
53
  // This proxy can end up getting called by anything that tries
55
54
  // to access methods & properties on the object.
56
55
  // This can include things like the inspector if you do something like
57
- // console.log(flowData.location)
58
- // In future, this mechanism will be superseded by a less problematic
56
+ // console.log(flowData.location)
57
+ // In future, this mechanism will be superseded by a less problematic
59
58
  // approach. For now, we work around this by only passing string keys
60
59
  // to the data getters.
61
- if (typeof(key) === 'string' || key == Symbol.iterator) {
60
+ if (typeof (key) === 'string' || key === Symbol.iterator) {
62
61
  try {
63
62
  return data[key] || data.get(key);
64
- } catch(e) {
65
- // If the key was 'inspect' and an error was thrown then we
63
+ } catch (e) {
64
+ // If the key was 'inspect' and an error was thrown then we
66
65
  // can ignore it. Otherwise, throw the error back up the stack.
67
- if(key != 'inspect') {
68
- throw(e);
66
+ if (key !== 'inspect') {
67
+ throw (e);
69
68
  }
70
69
  }
71
70
  }
@@ -92,10 +91,12 @@ class ElementData {
92
91
  * @returns {mixed} value
93
92
  */
94
93
  get (key) {
95
- let value = this.getInternal(key);
94
+ const value = this.getInternal(key);
96
95
  if (typeof value === 'undefined') {
97
- throw util.format(errorMessages.genericMissingProperties, key) +
98
- (typeof this.flowElement === 'undefined' ? '' : ' in data for element "' +
96
+ throw util.format(errorMessages.genericMissingProperties, key) +
97
+ (typeof this.flowElement === 'undefined'
98
+ ? ''
99
+ : ' in data for element "' +
99
100
  this.flowElement.dataKey) + '".' +
100
101
  util.format(errorMessages.noReasonUnknown);
101
102
  }
package/errorMessages.js CHANGED
@@ -26,4 +26,4 @@ module.exports = {
26
26
  genericMissingProperties: 'Property "%s" not found',
27
27
  noReasonUnknown: ' Please check that the element and property names ' +
28
28
  'are correct.'
29
- }
29
+ };
@@ -48,7 +48,7 @@ const testExample = function ({ file, portNumber }) {
48
48
 
49
49
  code += serverClose;
50
50
 
51
- () => jest.fn(eval(code));
51
+ () => jest.fn(eval(code)); // eslint-disable-line
52
52
  };
53
53
 
54
54
  test('pipeline functionality example', () => {
@@ -52,7 +52,7 @@ class Async extends FlowElement {
52
52
  const contents = { string: 'hello' };
53
53
 
54
54
  const data = new ElementDataDictionary(
55
- { flowElement: flowElement, contents: contents }
55
+ { flowElement, contents }
56
56
  );
57
57
 
58
58
  flowData.setElementData(data);
@@ -63,7 +63,7 @@ class Sync extends FlowElement {
63
63
  }
64
64
 
65
65
  const data = new ElementDataDictionary(
66
- { flowElement: this, contents: contents }
66
+ { flowElement: this, contents }
67
67
  );
68
68
 
69
69
  flowData.setElementData(data);
package/flowData.js CHANGED
@@ -69,12 +69,11 @@ class FlowData {
69
69
  // to the data getters.
70
70
  if (typeof key === 'string' || key === Symbol.iterator) {
71
71
  try {
72
- let value = data[key];
72
+ let value = data[key];
73
73
  if (typeof value === 'undefined') {
74
74
  value = data.get(key);
75
75
  }
76
76
  return value;
77
-
78
77
  } catch (e) {
79
78
  // If the key was 'then' and an error was thrown then we
80
79
  // can ignore it. Otherwise, throw the error back up the stack.
@@ -142,14 +141,13 @@ class FlowData {
142
141
 
143
142
  this.errors[errorKey] = error;
144
143
 
145
- let logMessage = "Error occurred during processing";
144
+ let logMessage = 'Error occurred during processing';
146
145
 
147
146
  if (errorKey !== undefined) {
148
- logMessage = logMessage + " of " + errorKey + ". '" + error + "'";
147
+ logMessage = logMessage + ' of ' + errorKey + ". '" + error + "'";
149
148
  }
150
149
 
151
150
  this.pipeline.log('error', logMessage);
152
-
153
151
  }
154
152
 
155
153
  /**
@@ -187,7 +185,7 @@ class FlowData {
187
185
 
188
186
  const elementData = this.data[flowElementDataKey];
189
187
  if (typeof elementData === 'undefined') {
190
- var message = util.format(errorMessages.noElementData,
188
+ const message = util.format(errorMessages.noElementData,
191
189
  flowElementDataKey, Object.keys(this.data).join(', '));
192
190
  throw message;
193
191
  }
package/flowElement.js CHANGED
@@ -89,6 +89,7 @@ class FlowElement {
89
89
  /**
90
90
  * Function called to check if a FlowElement is ready
91
91
  * Used when there are asynchronous initialisation steps
92
+ *
92
93
  * @returns {Promise}
93
94
  * */
94
95
  ready () {
@@ -148,11 +149,11 @@ class FlowElement {
148
149
  return this.properties;
149
150
  }
150
151
 
151
- _log(type, message) {
152
+ _log (type, message) {
152
153
  if (this.pipelines) {
153
154
  this.pipelines.forEach(pipeline => {
154
155
  pipeline.log(type, message);
155
- })
156
+ });
156
157
  }
157
158
  }
158
159
  }
package/helpers.js CHANGED
@@ -21,22 +21,24 @@
21
21
  * ********************************************************************* */
22
22
 
23
23
  class Helpers {
24
-
25
- /**
26
- * Set response headers in the response object (e.g. Accept-CH)
27
- * @param response: The response to set the headers in.
28
- * @param flowData: A processed FlowData instance to get the response header values
29
- * from.
30
- */
31
- static setResponseHeaders(response, flowData) {
32
- for (const [key, value] of Object.entries(flowData['set-headers']['responseheadersdictionary'])) {
33
- if (response.hasHeader(key)) {
34
- response.setHeader(key, `${response.getHeader(key)},${value}`);
35
- } else {
36
- response.setHeader(key, value);
37
- }
38
- }
24
+ /**
25
+ * Set response headers in the response object (e.g. Accept-CH)
26
+ *
27
+ * @param response: The response to set the headers in.
28
+ * @param flowData: A processed FlowData instance to get the response header values
29
+ * from.
30
+ * @param response
31
+ * @param flowData
32
+ */
33
+ static setResponseHeaders (response, flowData) {
34
+ for (const [key, value] of Object.entries(flowData['set-headers'].responseheadersdictionary)) {
35
+ if (response.hasHeader(key)) {
36
+ response.setHeader(key, `${response.getHeader(key)},${value}`);
37
+ } else {
38
+ response.setHeader(key, value);
39
+ }
39
40
  }
41
+ }
40
42
  }
41
43
 
42
- module.exports = Helpers;
44
+ module.exports = Helpers;
@@ -32,7 +32,7 @@ const template = fs.readFileSync(
32
32
  const FlowElement = require('./flowElement.js');
33
33
  const EvidenceKeyFilter = require('./evidenceKeyFilter.js');
34
34
  const ElementDataDictionary = require('./elementDataDictionary.js');
35
- var uglifyJS = require('uglify-js');
35
+ const uglifyJS = require('uglify-js');
36
36
 
37
37
  /**
38
38
  * An instance of EvidenceKeyFilter which removes all but header
@@ -86,12 +86,12 @@ class JavaScriptBuilderElement extends FlowElement {
86
86
  super(...arguments);
87
87
 
88
88
  this.settings = {
89
- objName: objName,
90
- protocol: protocol,
91
- host: host,
92
- endPoint: endPoint,
93
- enableCookies: enableCookies,
94
- minify: minify
89
+ objName,
90
+ protocol,
91
+ host,
92
+ endPoint,
93
+ enableCookies,
94
+ minify
95
95
  };
96
96
 
97
97
  this.dataKey = 'javascriptbuilder';
package/jsonbundler.js CHANGED
@@ -24,8 +24,7 @@ const FlowElement = require('./flowElement.js');
24
24
  const ElementDataDictionary = require('./elementDataDictionary.js');
25
25
  const BasicListEvidenceKeyFilter = require('./basicListEvidenceKeyFilter.js');
26
26
 
27
- const elementBlacklist = [ 'jsonbundler', 'javascriptbuilder', 'sequence', 'set-headers'];
28
-
27
+ const elementBlacklist = ['jsonbundler', 'javascriptbuilder', 'sequence', 'set-headers'];
29
28
 
30
29
  /**
31
30
  * The JSONBundler aggregates all properties from FlowElements
@@ -121,7 +120,7 @@ class JSONBundlerElement extends FlowElement {
121
120
  }
122
121
 
123
122
  this.propertyCache[flowElement.dataKey] = {
124
- delayExecutionList: delayExecutionList,
123
+ delayExecutionList,
125
124
  evidenceProperties: delayedEvidenceProperties
126
125
  };
127
126
  }
@@ -182,7 +181,7 @@ class JSONBundlerElement extends FlowElement {
182
181
  !flowData.evidence.get('query.sequence') ||
183
182
  flowData.evidence.get('query.sequence') < 10
184
183
  ) {
185
- var type =
184
+ const type =
186
185
  propertyObject[
187
186
  Object.keys(propertyObject).find(
188
187
  (key) => key.toLowerCase() === 'type'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiftyone.pipeline.core",
3
- "version": "4.4.7",
3
+ "version": "4.4.9",
4
4
  "description": "Core library for the 51Degrees Pipeline API",
5
5
  "directories": {
6
6
  "test": "tests"
@@ -12,21 +12,21 @@
12
12
  },
13
13
  "author": "51Degrees <support@51Degrees.com>",
14
14
  "dependencies": {
15
- "mustache": "^4.0.1",
16
- "uglify-js": "^3.8.1"
15
+ "mustache": "^4.2.0",
16
+ "uglify-js": "^3.17.4"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/node": "^15.12.2",
19
+ "@types/node": "^15.14.9",
20
20
  "eslint": "^6.8.0",
21
21
  "eslint-config-standard": "^14.1.1",
22
- "eslint-plugin-import": "^2.20.2",
23
- "eslint-plugin-jsdoc": "^25.4.0",
22
+ "eslint-plugin-import": "^2.27.5",
23
+ "eslint-plugin-jsdoc": "^25.4.3",
24
24
  "eslint-plugin-node": "^11.1.0",
25
- "eslint-plugin-promise": "^4.2.1",
26
- "eslint-plugin-standard": "^4.0.1",
27
- "jest": "^27.0.6",
28
- "jest-each": "^27.0.6",
29
- "node-mocks-http": "^1.10.1"
25
+ "eslint-plugin-promise": "^4.3.1",
26
+ "eslint-plugin-standard": "^4.1.0",
27
+ "jest": "^27.5.1",
28
+ "jest-each": "^27.5.1",
29
+ "node-mocks-http": "^1.12.2"
30
30
  },
31
31
  "contributors": [
32
32
  "Filip Hnízdo <filip@octophin.com> (https://octophindigital.com/)",
package/pipeline.js CHANGED
@@ -38,8 +38,9 @@ class Pipeline {
38
38
  *
39
39
  * @param {FlowElement[]} flowElements list of FlowElements to
40
40
  * add to the Pipeline
41
- * @param {Boolean} suppressProcessExceptions If true then pipeline
41
+ * @param {boolean} suppressProcessExceptions If true then pipeline
42
42
  * will suppress exceptions added to FlowData.
43
+ * @param dataFileUpdateService
43
44
  */
44
45
  constructor (flowElements = [], suppressProcessExceptions = false, dataFileUpdateService = null) {
45
46
  const pipeline = this;
@@ -137,10 +138,10 @@ class Pipeline {
137
138
  })
138
139
  .catch(setError);
139
140
 
140
- if (flowData.errors !== undefined && Object.entries(flowData.errors).length !== 0 && !pipeline.suppressProcessExceptions) {
141
- throw Object.values(flowData.errors)[0];
141
+ if (flowData.errors !== undefined && Object.entries(flowData.errors).length !== 0 && !pipeline.suppressProcessExceptions) {
142
+ throw Object.values(flowData.errors)[0];
142
143
  }
143
- });
144
+ });
144
145
  };
145
146
  };
146
147
 
@@ -217,8 +218,8 @@ class Pipeline {
217
218
  }
218
219
 
219
220
  /**
220
- *
221
- * @param {FlowElement} flowElement
221
+ *
222
+ * @param {FlowElement} flowElement
222
223
  * @returns {void}
223
224
  */
224
225
  updatePropertyDataBaseForElement (flowElement) {
@@ -267,7 +268,7 @@ class Pipeline {
267
268
  }
268
269
 
269
270
  pipeline.propertyDatabase[metaKey][metaValue][propertyKey] = {
270
- propertyName: propertyName,
271
+ propertyName,
271
272
  flowElementKey: flowElementDataKey
272
273
  };
273
274
  });
@@ -61,7 +61,7 @@ class PipelineBuilder {
61
61
 
62
62
  if (settings.dataFileUpdateService) {
63
63
  this.dataFileUpdateService = settings.dataFileUpdateService;
64
- }
64
+ }
65
65
 
66
66
  if (typeof settings.addJavaScriptBuilder !== 'undefined') {
67
67
  this.addJavaScriptBuilder = settings.addJavaScriptBuilder;
@@ -131,7 +131,7 @@ class PipelineBuilder {
131
131
  return new Pipeline(flowElements, false, this.dataFileUpdateService);
132
132
  }
133
133
 
134
- addRequiredElements(flowElements) {
134
+ addRequiredElements (flowElements) {
135
135
  return flowElements
136
136
  .concat(this.getJavaScriptElements())
137
137
  .concat(this.getHttpElements());
@@ -178,7 +178,7 @@ class PipelineBuilder {
178
178
  * @returns {FlowElement[]} list of HTTP related
179
179
  * FlowElements
180
180
  */
181
- getHttpElements () {
181
+ getHttpElements () {
182
182
  const flowElements = [];
183
183
 
184
184
  if (this.useSetHeaderProperties) {