Reasoner
Functions
- main(script, event, callback)
- getJson()
Extracts the message from the pubsub event
- publish(topic, message)
publish a message into the leverege platform
- filterBuildRecipients(users, defaultAccessor, filter, recipientKey) ⇒
Object
This method builds a list of contact information given a list of users, a method for accessing and filtering users, and a key to put the user info on in a final object
- sendToTargets(msg, targets, targets[i, options, defaultUserAccessor, topic, allowedRecipientKeys, recipientOverride) ⇒
Promise
- email(msg, targets, options)
- sms(msg, targets, options)
- setDeviceData(pathValueArray, oMsg, options)
- message(msg, route, options)
- send(topic, msg, route)
send a message into the leverege system
main(script, event, callback)
Kind: global function
Param | Type | Description |
---|---|---|
script | object | the export of a script file |
event | object | Pubsub message that triggered reasoner execution |
callback | function | function to be run after the script has been executed |
getJson()
Extracts the message from the pubsub event
publish(topic, message)
publish a message into the leverege platform
Kind: global function
Param | Type | Description |
---|---|---|
topic | string | the topic that the message will be published to |
message | Message | acceptable messages can be found in the @leverege/messages library |
Object
filterBuildRecipients(users, defaultAccessor, filter, recipientKey) ⇒ This method builds a list of contact information given a list of users, a method for accessing and filtering users, and a key to put the user info on in a final object
Kind: global function
Returns: Object
- the recipients built from the user list
Param | Type | Description |
---|---|---|
users | * | a list of user objects, generally including metadata |
defaultAccessor | * | a default way to get relevant user contact info out |
filter | * | an accessor for how to filter users out of selection and get the relevant field |
recipientKey | * | the key to use in object creation |
Promise
sendToTargets(msg, targets, targets[i, options, defaultUserAccessor, topic, allowedRecipientKeys, recipientOverride) ⇒ Kind: global function
Param | Type | Description | |
---|---|---|---|
msg | Object | the message to send to either emailer or messenger | |
targets | Array | the targets | |
targets[i | Object \ | string | a target. if object see below, if string and string is 'device', use context to get the device that came from the reason trigger and send to that, if string and string is 'system', do the same but for the system |
targets[i].type | Object | 'device' | 'system' |
targets[i].filter | function \ | string | a way of telling whether a user should be messaged or not. If a function, returning true will contact the user in a default manner, returning a string or array will contact a user using the string or list of strings returned, returning anything else will filter the user. If a string, path is used to the same effect |
targets[i].id | string | the id of the target to get | |
options | * | an object passed in through closure by the reason script | |
defaultUserAccessor | * | a default way to get the contact string for a user | |
topic | * | the topic to ultimately send the message to | |
allowedRecipientKeys | * | a set of keys we can modify along the way getting recipients | |
recipientOverride | * | (optional) if specified, forces targeting to a specific key |
email(msg, targets, options)
Kind: global function
Param | Type | Description |
---|---|---|
msg | object | an email message as detailed in @leverege/messages |
targets | array | recipients of the email |
options | object |
sms(msg, targets, options)
Kind: global function
Param | Type | Description |
---|---|---|
msg | object | a detailed description of supported messages can be found in @leverege/messages library |
targets | array | recipients of the sms |
options | object |
setDeviceData(pathValueArray, oMsg, options)
Kind: global function
Param | Type | Description |
---|---|---|
pathValueArray | array | array of objects with a path key and a value key |
oMsg | object | device, system, blueprint and project ids |
options | object |
message(msg, route, options)
Kind: global function
Param | Type | Description |
---|---|---|
msg | Message | a detailed description of supported messages can be found in @leverege/messages library |
route | * | GCP route to send the message on |
options | object |
send(topic, msg, route)
send a message into the leverege system
Kind: global function
Param | Type | Description |
---|---|---|
topic | string | the topic that the message should be published to |
msg | Message | a detailed description of supported messages can be found in @leverege/messages library |
route | * | GCP route to send the message on |