This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compositeActuator.json
18 lines (18 loc) · 1.91 KB
/
compositeActuator.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"name": "compositeActuator",
"version": "1.0.8",
"type": "actuator",
"script": "const actuationArray = options.requiredProperties.actuationArray\nconst actuator = options.requiredProperties.actuator\nconst resource = options.node.RESOURCE\n\nif (!actuationArray || !actuator) {\n send(new Error('Missing property'))\n}\n\nif (!resource) {\n send(new Error('Resource not configured')) \n}\n\nconst actuatorP = function (properties) {\n console.log('properties', properties)\n return waylay.actuators.execute(actuator, 'latest', { properties, resource })\n}\n\nlet actuations\ntry {\n actuations = JSON.parse(actuationArray).map((props) => actuatorP(props))\n} catch (err) {\n send(new Error('Error while parsing actuationArray: ' + err))\n}\n\nPromise.all(actuations)\n .then(() => send())\n .catch((err) => send(new Error(err)))\n",
"metadata": {
"author": "",
"category": "",
"description": "<h4>compositeActuator Actuator</h4>\n<br>\nComposite actuator, it will send as many actions \nas there are objects in the actuationArray list.\n<br><br>\n<b>Properties</b>\n<ul>\n <li>\n actuator: The actuator you want to execute.\n </li>\n <li>\n actuationArray: list of objetcts containing the properties that are needed to execute the actuator\n </li>\n</ul>\n\n<br>\n<b>Example</b>\nactuationArray = \n<pre>\n[{ \n \"from\": \"[email protected]\",\n \"to\" : \"hello@world\",\n \"message\" : \"hi\",\n \"subject\" : \"test1\", \n \"MANDRILL_KEY\": \"${vault.MANDRILL_KEY}\"\n },\n { \n \"from\": \"[email protected]\",\n \"to\" : \"hello@world\",\n \"message\" : \"hello\",\n \"subject\" : \"test2\", \n \"MANDRILL_KEY\": \"${vault.MANDRILL_KEY}\"\n }]\n</pre>\n\nactuator= <code>mandrilMail</code>\n\n",
"iconURL": "https://static.waylay.io/plugs/icons/box_out.png",
"supportedStates": [],
"requiredProperties": [
"actuator",
"actuationArray"
],
"requiredRawData": []
}
}