Skip to content

Commit 7ac8c7d

Browse files
authored
Merge pull request #3 from elasticio/added-integr-tests
added integration tests
2 parents 9f71428 + 0ceaab9 commit 7ac8c7d

File tree

8 files changed

+443
-19
lines changed

8 files changed

+443
-19
lines changed

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,64 @@
11
# configuration-component
22

33
## Description
4-
elastic.io configuration component which allows to separate the modification of configurable values from the modification of the flow.
4+
elastic.io configuration component which allows separating the modification of configurable values from the modification of the flow.
55

66
### How works. API version / SDK version
77
Configuration component has a credential which is a text field with some valid JSON. (JSON must be valid in order for credentials to be verified).
88
It emits a message with an object equivalent to the JSON in the config. So any data which is used in the flow and is repeated in multiple places can be configured (or later changed) in the single step. After that new values are used where it is needed.
99

1010
## Credentials
1111
Configuration data should be specified as credentials of a JSON format.
12-
JSON must be valid in order for credentials to be verified. Credentials verification will fail otherwise.
12+
JSON must be valid in order for credentials to be verified (except arrays, see *Known limitations* below). Credentials verification will fail otherwise.
1313
Input data example:
1414
![Data sample](https://user-images.githubusercontent.com/8449044/48360400-d3138980-e6a7-11e8-8b79-87932eec66c1.png)
1515
## Actions
1616
### Emit data
1717
The only action. Emits configuration data (must be a valid JSON object) as a message.
1818
#### Output json schema location
1919
Very simple schema. Output JSON could be of **any** complexity.
20+
2021
[lib/schemas/emitConfig.out.json](lib/schemas/emitConfig.out.json)
22+
23+
## Known limitations
24+
Despite naked arrays are valid JSON, there are some platform limitations, which do not allow to access the data in such arrays, that has been emitted from a component, from the next step. This is why naked arrays should not be passed to the component directly.
25+
So instead of
26+
```json
27+
[
28+
{
29+
"Product Name": "Bowler Hat",
30+
"ProductID": 858383,
31+
"SKU": "0406654608",
32+
"Description": {
33+
"Colour": "Purple",
34+
"Width": 300,
35+
"Height": 200,
36+
"Depth": 210,
37+
"Weight": 0.75
38+
},
39+
"Price": 34.45,
40+
"Quantity": 2
41+
}
42+
]
43+
```
44+
use something like:
45+
```json
46+
{
47+
"Product": [
48+
{
49+
"Product Name": "Bowler Hat",
50+
"ProductID": 858383,
51+
"SKU": "0406654608",
52+
"Description": {
53+
"Colour": "Purple",
54+
"Width": 300,
55+
"Height": 200,
56+
"Depth": 210,
57+
"Weight": 0.75
58+
},
59+
"Price": 34.45,
60+
"Quantity": 2
61+
}
62+
]
63+
}
64+
```

component.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"emitConfig": {
1515
"main": "./lib/actions/emitConfig.js",
1616
"title": "Emit data",
17+
"description": "Emits configuration data (must be a valid JSON object) as a message",
1718
"metadata": {
1819
"out": "./lib/schemas/emitConfig.out.json"
1920
}

lib/actions/emitConfig.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"use strict";
21
const {messages} = require('elasticio-node');
32

43
exports.process = processAction;
@@ -10,9 +9,7 @@ function processAction(msg, cfg) {
109

1110
// Access the configuration data from the field defined in credentials section of component.json
1211
const configData = cfg.configData;
13-
1412
const jsonConfigData = JSON.parse(configData);
15-
console.log(`cfg data: ${JSON.stringify(jsonConfigData)}`);
1613

1714
if (!configData) {
1815
throw new Error('Config data is required.');

0 commit comments

Comments
 (0)