common@3.3.3
- arrayToString(arr, separator)
- as(key, operation)
- asData(data, state)
- assert(expression, errorMessage)
- chunk(array, chunkSize)
- combine(operations)
- composeNextState(state, response)
- cursor(value, options)
- dataPath(path)
- dataValue(path)
- debug(args)
- each(dataSource, operation)
- field(key, value)
- fields(fields)
- fn(func)
- fnIf(condition, operation)
- group(arrayOfObjects, keyPath, callback)
- humanProper(str)
- index()
- join(targetPath, sourcePath, targetKey)
- jsonValue(obj, path)
- lastReferenceValue(path)
- lodash()
- log(args)
- map(path, callback)
- merge(dataSource, fields)
- parseCsv(csvData, [parsingOptions], [callback])
- referencePath(path)
- scrubEmojis(text, replacementChars)
- source(path)
- sourceValue(path)
- splitKeys(obj, keys)
- toArray(arg)
- validate(schema, data)
This adaptor exports the following namespaced functions:
- util.decode(base64Data, options)
- util.encode(data, options)
- util.uuid()
- beta.each(dataSource, operation)
- dateFns.format()
- dateFns.parse()
- http.get(url, options)
- http.options(opts)
- http.post(url, data, options)
- http.request(method, url, options)
Functions
arrayToString
arrayToString(arr, separator) ⇒ string
Turns an array into a string, separated by X.
| Param | Type | Description |
|---|---|---|
| arr | array | Array of toString'able primatives. |
| separator | string | Separator string. |
Example
field("destination_string__c", function(state) {
return arrayToString(dataValue("path_of_array")(state), ', ')
})
as
as(key, operation) ⇒ Operation
Run an operation and save the result to a custom key in state instead of overwriting state.data.
| Param | Type | Description |
|---|---|---|
| key | string | The state key to assign the result of the operation to. |
| operation | function | An operation that returns a new state object with a data property |
Example: Fetch cce-data from collections and store them under state.cceData
as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));
asData
asData(data, state) ⇒ array
Simple switcher allowing other expressions to use either a JSONPath or object literals as a data source.
- JSONPath referencing a point in
state - Object Literal of the data itself.
- Function to be called with state.
| Param | Type | Description |
|---|---|---|
| data | String | object | function | |
| state | object | The current state. |
Example
asData('$.key'| key | callback)
assert
assert(expression, errorMessage) ⇒ operation
Asserts the given expression or function resolves to true, or else throws an exception. Optionally accepts and error message.
| Param | Type | Description |
|---|---|---|
| expression | any | The expression or function to be evaluated. |
| errorMessage | string | The error message thrown in case of a failed state. |
Example
assert('a' === 'b', '"a" is not equal to "b"')