node-scenarios
A simple way to manage scenarios, with customizable triggers/conditions/actions
Installation
$ npm install node-scenarios
Features
- create triggers (detected presence, called url, crons, etc...)
- create scenarios, with complex routes
- create customizable conditions with given data
- create customizable actions (email, url call, GPIO, etc...)
Doc
node-scenarios
static class abstract
abstract class to extend -> MyClass extends "node-scenarios".abstractstatic init() : return Promise instance => then(node-containerpattern container)
initialize database and return a node-containerpattern instancestatic release() : return Promise instance
close database connectionstatic delete() : return Promise instance
release & delete database file
node-containerpattern instance
- see node-containerpattern documentation
- db : an instance of sqlite3.Database object (see sqlite3 documentation)
- triggers, scenarios, actionstypes, actions, conditionstypes, conditions : see the following documentations
global documentation for all contained objets
-
static formate(object model)
formate data -
last() : return Promise instance => then(object model)
return the last insterted data -
search(object model) : return Promise instance => then(array model)
return all the object concerned by the research -
searchOne(object model) : return Promise instance => then(object model)
execute "search" and return the first -
add(object model) : return Promise instance => then(object model)
add the object -
edit(object model) : return Promise instance => then(object model)
edit the registered object -
delete(object model) : return Promise instance
delete the registered object
triggers
-
linkToAction(object action, object trigger) : return Promise instance
link a action and a trigger -
unlinkToAction(object action, object trigger) : return Promise instance
unlink a action and a trigger -
linkToScenario(object scenario, object trigger) : return Promise instance
link a scenario and a trigger -
unlinkToScenario(object scenario, object trigger) : return Promise instance
unlink a scenario and a trigger -
execute(object trigger, object externaldata) : return Promise instance
execute all the linked scenarios
scenarios
-
linkToTrigger(object scenario, object trigger) : return Promise instance
link a scenario and a trigger -
unlinkToTrigger(object scenario, object trigger) : return Promise instance
unlink a scenario and a trigger -
linkStartAction(object scenario, object action) : return Promise instance => then(object scenario)
unlinkStart && link an action to the scenario -
linkStartCondition(object scenario, object condition) : return Promise instance => then(object scenario)
unlinkStart && link a condition to the scenario -
unlinkStart(object scenario) : return Promise instance => then(object scenario)
unlink the action or condition linked to the scenario -
execute(object scenario, object externaldata) : return Promise instance
execute the scenario
actions
-
linkToTrigger(object action, object trigger) : return Promise instance
link a action and a trigger -
unlinkToTrigger(object action, object trigger) : return Promise instance
unlink a action and a trigger -
linkAfterAction(object action, object linkedaction) : return Promise instance => then(object action)
unlinkAfter && link an action to the action -
linkAfterCondition(object action, object linkedcondition) : return Promise instance => then(object action)
unlinkAfter && link a condition to the action -
unlinkAfter(object action) : return Promise instance => then(object action)
unlink the action or condition linked to the action -
bindExecuter(object actiontype, function executer) : return Promise instance
link an action type to a callback function -
execute(object action, object externaldata) : return Promise instance
execute the callback function of the action's action type -
NOTE : the callback function MUST return a promise instance
conditions
-
linkOnYesAction(object condition, object linkedaction) : return Promise instance => then(object condition)
unlinkOnYes && link an action to the condition for a "true" resolution -
linkOnYesCondition(object condition, object linkedcondition) : return Promise instance => then(object condition)
unlinkOnYes && link a condition to the condition for a "true" resolution -
unlinkOnYes(object condition) : return Promise instance => then(object condition)
unlink the action or condition linked to the condition -
linkOnNoAction(object condition, object linkedaction) : return Promise instance => then(object condition)
unlinkOnNo && link an action to the condition for a "false" resolution -
linkOnNoCondition(object condition, object linkedcondition) : return Promise instance => then(object condition)
unlinkOnNo && link a condition to the condition for a "false" resolution -
unlinkOnNo(object condition) : return Promise instance => then(object condition)
unlink the action or condition linked to the condition -
bindExecuter(object conditiontype, function executer) : return Promise instance
link a condition type to a callback function -
execute(object condition, object externaldata) : return Promise instance
execute the callback function of the condition's condition type -
NOTE : the callback functions MUST return a promise instance
Examples
const scenarios = ; scenarios;
Tests
$ gulp
License
[ISC](LICENSE)