├── alexaresponse ├── alexaresponse-run.js ├── alexaresponse.js └── readme.md ├── alexarouter ├── alexarouter-run.js ├── alexarouter.js └── readme.md ├── build.js ├── callback ├── callback-run.js ├── callback.js └── readme.md ├── childprocess_exec ├── childprocess_exec-run.js └── childprocess_exec.js ├── code ├── code-run.js ├── code.js └── readme.md ├── comment ├── comment.js └── readme.md ├── console ├── console.js └── readme.md ├── count ├── count-run.js ├── count.js └── readme.md ├── counter ├── counter-run.js ├── counter.js └── readme.md ├── cron └── cron.js ├── dashboardanalytics ├── dashboardanalytics.js └── readme.md ├── dashboardgroupanalytics ├── dashboardgroupanalytics-run.js ├── dashboardgroupanalytics.js └── readme.md ├── dashboardoutput ├── dashboardoutput.js └── readme.md ├── debug ├── debug-run.js ├── debug.js └── readme.md ├── delay ├── delay-run.js ├── delay.js └── readme.md ├── device_light └── device_light.js ├── device_outlet └── device_outlet.js ├── device_switch └── device_switch.js ├── device_thermostat └── device_thermostat.js ├── duration ├── duration.js └── readme.md ├── email ├── email-run.js ├── email.js └── readme.md ├── eval ├── eval-run.js ├── eval.js └── readme.md ├── event ├── event-run.js ├── event.js └── readme.md ├── feedtodelay ├── feedtodelay-run.js ├── feedtodelay.js └── readme.md ├── fi ├── fi-run.js ├── fi.js └── readme.md ├── filereader ├── filereader.js └── readme.md ├── filewriter ├── filewriter-run.js ├── filewriter.js └── readme.md ├── flow.js ├── flowboardlight ├── flowboardlight.js └── readme.md ├── flowboardoutput ├── flowboardoutput.js └── readme.md ├── flowboardsocket ├── flowboardsocket.js └── readme.md ├── fo ├── fo.js └── readme.md ├── ftpupload ├── ftpupload-run.js ├── ftpupload.js └── readme.md ├── ftpuploadfolder ├── ftpuploadfolder-run.js ├── ftpuploadfolder.js └── readme.md ├── function ├── function-run.js ├── function.js └── readme.md ├── httpdownloader ├── httpdownloader-run.js ├── httpdownloader.js └── readme.md ├── httpgeoip ├── httpgeoip-run.js ├── httpgeoip.js └── readme.md ├── httplistener ├── httplistener-run.js ├── httplistener.js └── readme.md ├── httpreceiver ├── httpreceiver-run.js ├── httpreceiver.js └── readme.md ├── httpredirect ├── httpredirect.js └── readme.md ├── httprequest ├── httprequest-run.js ├── httprequest.js └── readme.md ├── httpresponse ├── httpresponse.js └── readme.md ├── httproute ├── httproute.js └── readme.md ├── ifttthookrequest └── ifttthookrequest.js ├── lastdata ├── lastdata-run.js ├── lastdata.js └── readme.md ├── lastusage ├── lastusage-run.js ├── lastusage.js └── readme.md ├── license.txt ├── list.js ├── list.json ├── logtodb ├── logtodb.js └── readme.md ├── megatimer ├── megatimer-run.js ├── megatimer.js └── readme.md ├── merge ├── merge-run.js ├── merge.js └── readme.md ├── mergetoobject ├── mergetoobject-run.js ├── mergetoobject.js └── readme.md ├── messengermessage ├── messengermessage-run.js ├── messengermessage.js └── readme.md ├── messengerrawdata ├── messengerrawdata-run.js ├── messengerrawdata.js └── readme.md ├── messengersender ├── messengersender-run.js ├── messengersender.js └── readme.md ├── messengerusers ├── messengerusers-run.js ├── messengerusers.js └── readme.md ├── modified ├── modified-run.js ├── modified.js └── readme.md ├── monitorconsumption ├── monitorconsumption-run.js └── monitorconsumption.js ├── monitorcpu ├── monitorcpu-run.js └── monitorcpu.js ├── monitordisk ├── monitordisk-run.js └── monitordisk.js ├── monitormemory ├── monitormemory-run.js └── monitormemory.js ├── monitornetwork ├── monitornetwork-run.js └── monitornetwork.js ├── monitorprocess ├── monitorprocess-run.js └── monitorprocess.js ├── monitorsuperadmin ├── monitorsuperadmin-run.js └── monitorsuperadmin.js ├── mosca ├── mosca.js └── readme.md ├── mqtt ├── mqtt.js └── readme.md ├── mqttpublish ├── mqttpublish.js └── readme.md ├── mqttsubscribe ├── mqttsubscribe.js └── readme.md ├── netatmo ├── netatmo.js └── readme.md ├── nosql ├── nosql.js └── readme.md ├── nosql2 └── nosql2.js ├── pagerenderer ├── pagerenderer.js └── readme.md ├── pagetemplate ├── pagetemplate.js └── readme.md ├── parser ├── parser-run.js ├── parser.js └── readme.md ├── pass ├── pass.js └── readme.md ├── range ├── range.js └── readme.md ├── readme.md ├── repository ├── readme.md ├── repository-run.js └── repository.js ├── restcors ├── readme.md └── restcors.js ├── restexecoperation ├── readme.md ├── restexecoperation-run.js └── restexecoperation.js ├── restinterpreter ├── readme.md ├── restinterpreter-run.js └── restinterpreter.js ├── restmiddleware ├── readme.md └── restmiddleware.js ├── restoperation ├── readme.md ├── restoperation-run.js └── restoperation.js ├── restproxy ├── readme.md └── restproxy.js ├── restresponse ├── readme.md └── restresponse.js ├── restroute ├── readme.md └── restroute.js ├── restschema ├── readme.md └── restschema.js ├── scheduler ├── readme.md ├── scheduler-run.js └── scheduler.js ├── schema ├── readme.md ├── schema-run.js └── schema.js ├── sms ├── readme.md ├── sms-run.js └── sms.js ├── smsgatewaymephoneinfo ├── readme.md ├── smsgatewaymephoneinfo-run.js └── smsgatewaymephoneinfo.js ├── smsgatewaymesmssend ├── readme.md ├── smsgatewaymesmssend-run.js └── smsgatewaymesmssend.js ├── smsgatewaymesmsstatus ├── readme.md ├── smsgatewaymesmsstatus-run.js └── smsgatewaymesmsstatus.js ├── split ├── readme.md ├── split-run.js └── split.js ├── switch ├── readme.md ├── switch-run.js └── switch.js ├── template ├── readme.md ├── template-run.js └── template.js ├── templates.json ├── templates4.json ├── templates5.json ├── timer ├── readme.md ├── timer-run.js └── timer.js ├── transform ├── readme.md ├── transform-run.js └── transform.js ├── trigger ├── readme.md ├── trigger-run.js └── trigger.js ├── triggertoggle ├── readme.md ├── triggertoggle-run.js └── triggertoggle.js ├── tutorial ├── readme.md ├── tutorial-run.js └── tutorial.js ├── twilio ├── readme.md ├── twilio-run.js └── twilio.js ├── uniqueinterval ├── readme.md ├── uniqueinterval-run.js └── uniqueinterval.js ├── virtualwirein ├── readme.md └── virtualwirein.js ├── virtualwireout ├── readme.md └── virtualwireout.js ├── wsclient └── wsclient.js ├── wsserver └── wsserver.js └── xlstojson ├── readme.md └── xlstojson.js /alexaresponse/alexaresponse-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({responsesmml: '\n\n', repromptsmml: '\n\n', setresponse: false, reprompt: false, endsession: false }); 38 | FLOWDATA(); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /alexaresponse/readme.md: -------------------------------------------------------------------------------- 1 | # Alexa response 2 | 3 | This component builds a response message in smml format to be sent back to the Alexa after completing an intent. 4 | 5 | A path can be used to parse a message out of an existing message or a hard-coded value can be set. 6 | 7 | See demo here: https://youtu.be/YBtN4Ky3MLo 8 | -------------------------------------------------------------------------------- /alexarouter/alexarouter-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ conditions: [{ type: 'LaunchRequest', name: "RatingIntent", index: 0 }], helpintentsmml: '\n\n', cancelintentsmml: '\n\n', stopintentsmml: '\n\n', nointentsmml: '\n\n' }); 38 | FLOWDATA('{"request": { "type": "LaunchRequest", "requestId": "amzn1.echo-api.request.36023a37-b8a5-4a4f-889c-fd583f447299", "timestamp": "2018-06-03T12:31:21Z", "locale": "en-US", "shouldLinkResultBeReturned": false }}'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /alexarouter/readme.md: -------------------------------------------------------------------------------- 1 | # Alexa router 2 | 3 | This component listens to a REST Post service based on the URL and forward Alexa requests to the appropriate intent. 4 | 5 | See demo here: https://youtu.be/YBtN4Ky3MLo 6 | 7 | __Outputs__: 8 | - LaunchRequest 9 | - AMAZON.HelpIntent (Optional) 10 | - AMAZON.CancelIntent (Optional) 11 | - AMAZON.StopIntent (Optional) 12 | - AMAZON.NoIntent (Optional) 13 | - AMAZON.FallbackIntent (Optional) 14 | - SessionEndedRequest 15 | -------------------------------------------------------------------------------- /build.js: -------------------------------------------------------------------------------- 1 | const Fs = require('fs'); 2 | require('total4'); 3 | 4 | deleteFolder('__flow'); 5 | Fs.mkdirSync(F.path.root('__flow')); 6 | 7 | U.ls('./', function callback(files, dirs) { 8 | 9 | dirs.wait(function(dir, next){ 10 | 11 | if (dir.startsWith('.') || dir.startsWith('node_modules') || dir.startsWith('__flow')) 12 | return next(); 13 | 14 | dir = dir.substring(0, dir.length - 1); 15 | 16 | var source = U.join(F.path.root(dir), dir + '.js'); 17 | var target = U.join(F.path.root('__flow'), dir + '.js'); 18 | 19 | F.path.exists(source, function callback(exists) { 20 | exists && Fs.createReadStream(source).pipe(Fs.createWriteStream(target)); 21 | next(); 22 | }); 23 | }, function(){ 24 | console.log('\nAll components have been copied to __flow directory. Copy them to `/flow` directory.\n'); 25 | }); 26 | }); 27 | 28 | function deleteFolder(path) { 29 | var files = []; 30 | if(Fs.existsSync(path)) { 31 | files = Fs.readdirSync(path); 32 | files.forEach(function(file){ 33 | var curPath = path + '/' + file; 34 | if (Fs.lstatSync(curPath).isDirectory()) 35 | deleteFolder(curPath); 36 | else 37 | Fs.unlinkSync(curPath); 38 | }); 39 | Fs.rmdirSync(path); 40 | } 41 | } -------------------------------------------------------------------------------- /callback/callback-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /callback/readme.md: -------------------------------------------------------------------------------- 1 | # Callback 2 | 3 | The component can make a callback to the target instance and repeat the cycle for new/modified data. Incoming data will be used as data to another component. -------------------------------------------------------------------------------- /childprocess_exec/childprocess_exec-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ filename: 'ping -t 3 {0}' }); 38 | FLOWDATA('www.google.com'); 39 | }); 40 | -------------------------------------------------------------------------------- /code/code-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ code: 'send(0, value.toUpperCase())' }); 38 | FLOWDATA('peter'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /code/readme.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | This component executes custom JavaScript code as it is and it doesn't contain any secure scope. 4 | 5 | ```javascript 6 | // value {Object} contains received data 7 | // send(outputIndex, newValue) sends a new value 8 | // instance {Object} a current component instance 9 | // flowdata {Object} a current flowdata 10 | // repository {Object} a current repository of flowdata 11 | // Example: 12 | 13 | // send() can be execute multiple times 14 | send(0, value); 15 | ``` -------------------------------------------------------------------------------- /comment/comment.js: -------------------------------------------------------------------------------- 1 | exports.id = 'comment'; 2 | exports.title = 'Comment'; 3 | exports.group = 'Common'; 4 | exports.color = '#704cff'; 5 | exports.author = 'Martin Smola'; 6 | exports.icon = 'comment'; 7 | exports.traffic = false; 8 | exports.version = '1.0.0'; 9 | exports.readme = '# Comment'; 10 | 11 | exports.install = function() {}; 12 | -------------------------------------------------------------------------------- /comment/readme.md: -------------------------------------------------------------------------------- 1 | # Comment -------------------------------------------------------------------------------- /console/readme.md: -------------------------------------------------------------------------------- 1 | # Console 2 | 3 | This component attachs into the Node.js `console` instance. Response is a `string` value, outputs: 4 | 5 | - `blue` is from `console.log()` and `console.info()` 6 | - `orange` is from `console.warn()` 7 | - `red` is from `console.error()` -------------------------------------------------------------------------------- /count/count-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ conditions: [ { increment: 1, initialvalue: 1} ]}); 38 | FLOWDATA('test123'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /count/count.js: -------------------------------------------------------------------------------- 1 | exports.id = 'count'; 2 | exports.title = 'Count'; 3 | exports.version = '1.0.1'; 4 | exports.author = 'John Graves'; 5 | exports.color = '#656D78'; 6 | exports.icon = 'plus-square'; 7 | exports.input = 2; 8 | exports.output = 1; 9 | exports.options = { increment: 1, initialvalue: 1 }; 10 | exports.readme = `# Counter 11 | 12 | Counter Number of times called.`; 13 | 14 | exports.html = `
15 |
@(Initial Value)
16 |
@(Increment)
17 |

Example Video

18 |
`; 19 | 20 | exports.readme = `# Count 21 | 22 | This component counts the number of messages received. 23 | 24 | __Response:__ 25 | 26 | Integer value based on the initial value and increment settings. 27 | 28 | __Arguments:__ 29 | - Initial Value: What number should be output on the receipt of the first message. 30 | - Increment: What should the increment be for each following message received.`; 31 | 32 | exports.install = function(instance) { 33 | 34 | var count = 0; 35 | var initialCall = true; 36 | 37 | instance.on('data', function(flowdata) { 38 | var index = flowdata.index; 39 | if (index) { 40 | instance.debug('Reset Count.'); 41 | count = instance.options.initialvalue; 42 | initialCall = true; 43 | } else { 44 | // If this is the first time, set the value to 'initial value' 45 | if(initialCall) { 46 | initialCall = false; 47 | count = instance.options.initialvalue; 48 | } else 49 | count = count+instance.options.increment; 50 | instance.status('Count:' + count); 51 | instance.send2(count); 52 | } 53 | }); 54 | 55 | instance.on('options', function() { 56 | count = instance.options.initialvalue; 57 | initialCall = true; 58 | }); 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /count/readme.md: -------------------------------------------------------------------------------- 1 | exports.readme = `# Count 2 | 3 | This component counts the number of messages received. 4 | 5 | __Response:__ 6 | 7 | Integer value based on the initial value and increment settings. 8 | 9 | __Arguments:__ 10 | - Initial Value: What number should be output on the receipt of the first message. 11 | - Increment: What should the increment be for each following message received. 12 | -------------------------------------------------------------------------------- /counter/counter-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWDATA(1); 38 | FLOWDATA(1); 39 | FLOWDATA(1); 40 | FLOWCLOSE(); 41 | }); 42 | -------------------------------------------------------------------------------- /counter/counter.js: -------------------------------------------------------------------------------- 1 | const ID = 'flowcounter'; 2 | 3 | exports.id = 'counter'; 4 | exports.title = 'Counter'; 5 | exports.version = '1.0.1'; 6 | exports.author = 'Peter Širka'; 7 | exports.color = '#656D78'; 8 | exports.icon = 'dashboard'; 9 | exports.input = true; 10 | exports.output = 1; 11 | exports.options = { enabled: true }; 12 | exports.readme = `# Counter 13 | 14 | Counter counts all received data by months.`; 15 | 16 | exports.html = `
17 |
@(Counter for last 12 months)
18 |
19 |
20 | `.format(ID); 23 | 24 | exports.install = function(instance) { 25 | 26 | var count = 0; 27 | 28 | instance.on('data', function() { 29 | count++; 30 | 31 | if (F.is4) 32 | COUNTER(ID).hit(instance.id, 1); 33 | else 34 | NOSQL(ID).counter.hit(instance.id, 1); 35 | 36 | instance.custom.status(); 37 | }); 38 | 39 | instance.custom.stats = function(callback) { 40 | if (F.is4) 41 | COUNTER(ID).monthly(instance.id, callback); 42 | else 43 | NOSQL(ID).counter.monthly(instance.id, callback); 44 | }; 45 | 46 | instance.custom.reset = function(callback) { 47 | if (F.is4) 48 | COUNTER(ID).clear(callback); 49 | else 50 | NOSQL(ID).counter.clear(callback); 51 | }; 52 | 53 | instance.custom.status = function() { 54 | setTimeout2(instance.id, function() { 55 | instance.status(count.format(0)); 56 | instance.send2(count); 57 | }, 100); 58 | }; 59 | 60 | var cb = function(err, response) { 61 | count = response || 0; 62 | }; 63 | 64 | if (F.is4) 65 | COUNTER(ID).count(instance.id, cb); 66 | else 67 | NOSQL(ID).counter.count(instance.id, cb); 68 | }; 69 | 70 | FLOW.trigger(ID, function(next, data) { 71 | 72 | var cb = function(err, response) { 73 | next(response); 74 | }; 75 | 76 | if (F.is4) 77 | COUNTER(ID).monthly(data.id, cb); 78 | else 79 | NOSQL(ID).counter.monthly(data.id, cb); 80 | }); 81 | 82 | exports.uninstall = function() { 83 | FLOW.trigger(ID, null); 84 | }; 85 | -------------------------------------------------------------------------------- /counter/readme.md: -------------------------------------------------------------------------------- 1 | # Counter 2 | 3 | Counter counts all received data by months. __Output is number.__ -------------------------------------------------------------------------------- /dashboardanalytics/readme.md: -------------------------------------------------------------------------------- 1 | # Dashboard Analytics 2 | 3 | Creates analytics automatically according a value. The value must be a number. The output is `Object`: 4 | 5 | ```javascript 6 | { 7 | count: 2, // {Number} count of analyzed values in the hour 8 | decimals: 0, // {Number} count of decimals 9 | format: '{0} °C', // {String} custom defined format, "{0}" will be a value 10 | period: 'hourly' // {String} period "hourly" or "daily" 11 | previous: 15, // {Number} previous calculated value 12 | raw: 32.3 // {Number} last raw value 13 | type: 'max', // {String} type of analytics 14 | value: 32.3, // {Number} last calculated value 15 | } 16 | ``` 17 | 18 | This components sends to Dashboard two types of data: 19 | - `laststate` with the last know state 20 | - `stats` with stats -------------------------------------------------------------------------------- /dashboardgroupanalytics/readme.md: -------------------------------------------------------------------------------- 1 | # Dashboard Group Analytics (NOT COMPLETE) 2 | 3 | Creates a group analytics automatically according a value and group. The value must be a `Number` and group must be a `String`. The output is `Object`: 4 | 5 | ```javascript 6 | { 7 | Audi: { 8 | count: 4, // {Number} count of analyzed values in the hour 9 | decimals: 0, // {Number} count of decimals 10 | format: '{0}x', // {String} custom defined format, "{0}" will be a value 11 | period: 'hourly' // {String} period "hourly" or "daily" 12 | previous: 45, // {Number} previous calculated value 13 | raw: 50, // {Number} last raw value 14 | type: 'sum', // {String} type of analytics 15 | value: 50, // {Number} last calculated value 16 | }, 17 | BMW: { 18 | count: 2, // {Number} count of analyzed values in the hour 19 | decimals: 0, // {Number} count of decimals 20 | format: '{0}x', // {String} custom defined format, "{0}" will be a value 21 | period: 'hourly' // {String} period "hourly" or "daily" 22 | previous: 15, // {Number} previous calculated value 23 | raw: 30, // {Number} last raw value 24 | type: 'sum', // {String} type of analytics 25 | value: 30, // {Number} last calculated value 26 | } 27 | } 28 | ``` -------------------------------------------------------------------------------- /dashboardoutput/dashboardoutput.js: -------------------------------------------------------------------------------- 1 | exports.id = 'dashboardoutput'; 2 | exports.title = 'Output'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Peter Širka'; 5 | exports.group = 'Dashboard'; 6 | exports.color = '#5CB36D'; 7 | exports.icon = 'font'; 8 | exports.input = true; 9 | exports.output = 0; 10 | exports.readme = `# Dashboard Output 11 | 12 | This component shows the content as it is in Total.js Dashboard.`; 13 | 14 | exports.install = function(instance) { 15 | 16 | var lastdata = null; 17 | 18 | instance.on('data', function(response) { 19 | instance.lastdata = lastdata = response.data; 20 | instance.dashboard && instance.dashboard('laststate', lastdata); 21 | }); 22 | 23 | instance.on('dashboard', function(type) { 24 | switch (type) { 25 | case 'laststate': 26 | instance.dashboard && instance.dashboard(type, lastdata); 27 | break; 28 | } 29 | }); 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /dashboardoutput/readme.md: -------------------------------------------------------------------------------- 1 | # Dashboard Output 2 | 3 | This component shows the content as it is in Total.js Dashboard. -------------------------------------------------------------------------------- /debug/debug-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWCLOSE(); 38 | }); 39 | -------------------------------------------------------------------------------- /debug/readme.md: -------------------------------------------------------------------------------- 1 | # Debug 2 | 3 | Writes data to the debug tab 4 | 5 | ## Config 6 | 7 | - enabled `->` enable/disable output to the debug tab -------------------------------------------------------------------------------- /delay/delay-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ delay: 1000 }); 38 | FLOWDATA('Delay 1 seconds'); 39 | FLOWDATA('Delay 1 seconds'); 40 | FLOWDATA('Delay 1 seconds'); 41 | FLOWDATA('Delay 1 seconds'); 42 | FLOWDATA('Delay 1 seconds'); 43 | FLOWDATA('Delay 1 seconds'); 44 | FLOWDATA('Delay 1 seconds'); 45 | FLOWDATA('Delay 1 seconds'); 46 | FLOWDATA('Delay 1 seconds'); 47 | }); 48 | -------------------------------------------------------------------------------- /delay/delay.js: -------------------------------------------------------------------------------- 1 | exports.id = 'delay'; 2 | exports.title = 'Delay'; 3 | exports.color = '#656D78'; 4 | exports.icon = 'clock-o'; 5 | exports.group = 'Time'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.0'; 9 | exports.author = 'Peter Širka'; 10 | exports.options = { delay: 1000 }; 11 | 12 | exports.html = `
13 |
14 |
15 |
@(Delay)
16 |
17 |
18 |
`; 19 | 20 | exports.readme = `# Delay 21 | 22 | This component creates a delay between receiving and sending data.`; 23 | 24 | exports.install = function(instance) { 25 | 26 | var queue = []; 27 | var timeout; 28 | 29 | instance.on('data', function(response) { 30 | queue.push(response); 31 | instance.custom.send(); 32 | }); 33 | 34 | instance.custom.send = function() { 35 | if (timeout) 36 | return; 37 | var item = queue.shift(); 38 | item && (timeout = setTimeout(function() { 39 | timeout = null; 40 | instance.send2(item); 41 | instance.custom.send(); 42 | if (queue.length) 43 | instance.status(queue.length + 'x pending', 'red'); 44 | else 45 | instance.status(''); 46 | }, instance.options.delay || 1000)); 47 | }; 48 | 49 | instance.on('close', () => timeout && clearTimeout(timeout)); 50 | }; -------------------------------------------------------------------------------- /delay/readme.md: -------------------------------------------------------------------------------- 1 | # Delay 2 | 3 | This component creates a delay between receiving and sending data. -------------------------------------------------------------------------------- /device_outlet/device_outlet.js: -------------------------------------------------------------------------------- 1 | exports.id = 'device_outlet'; 2 | exports.title = 'Outlet'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Martin Smola'; 5 | exports.group = 'Devices'; 6 | exports.icon = 'plug'; 7 | exports.dashboard = true; 8 | exports.flowboard = true; 9 | exports.color = '#5CB36D'; 10 | exports.input = 1; 11 | exports.output = 1; 12 | exports.click = true; 13 | exports.options = { default: false }; 14 | exports.readme = `# Device - Outlet 15 | ### input 16 | Bellow data will toggle on and anything else off 17 | - true 18 | - 1 19 | - 'on' 20 | 21 | ### Output 22 | \`\`\`javascript 23 | { 24 | name: 'Outlet name', 25 | id: 'xxxxxxx', 26 | type: 'OUTLET', 27 | on: true // or false 28 | } 29 | \`\`\` 30 | `; 31 | 32 | exports.html = `
33 |

The label you specify above will apear in DashBoard component's settings form.

34 |
35 |
36 |
Default value
37 |
38 |
39 |
`; 40 | 41 | exports.install = function(instance) { 42 | 43 | var onVals = [true, 1, 'on']; 44 | 45 | var device = { 46 | name: 'Outlet', 47 | id: '', 48 | type: 'OUTLET', 49 | on: false 50 | }; 51 | 52 | var status = () => { 53 | instance.status('Outlet is: ' + (device.on ? 'On' : 'Off')); 54 | instance.dashboard('status', device); 55 | instance.flowboard('status', device); 56 | }; 57 | 58 | function toggle() { 59 | device.on = !device.on; 60 | send(); 61 | } 62 | 63 | function send(){ 64 | instance.send2(device); 65 | status(); 66 | } 67 | 68 | function reconfigure(init) { 69 | if (init === true) 70 | device.on = instance.options.default; 71 | 72 | device.name = instance.name; 73 | device.id = instance.id; 74 | status(); 75 | } 76 | 77 | instance.on('dashboard', dashboardflowboard); 78 | instance.on('flowboard', dashboardflowboard); 79 | 80 | function dashboardflowboard(type) { 81 | type === 'click' && toggle(); 82 | type === 'status' && status(); 83 | } 84 | 85 | instance.on('data', function(flowdata) { 86 | device.on = onVals.includes(flowdata.data); 87 | send(); 88 | }); 89 | 90 | instance.on('click', toggle); 91 | instance.on('options', reconfigure); 92 | 93 | reconfigure(true); 94 | }; 95 | -------------------------------------------------------------------------------- /duration/duration.js: -------------------------------------------------------------------------------- 1 | exports.id = 'duration'; 2 | exports.title = 'Duration'; 3 | exports.group = 'Time'; 4 | exports.color = '#656D78'; 5 | exports.output = 1; 6 | exports.input = 2; 7 | exports.cloning = false; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'clock-o'; 10 | exports.version = '1.0.0'; 11 | 12 | exports.readme = `# Duration 13 | 14 | This component measures a duration of Flow processing for same message id. 15 | 16 | - first input: starting component 17 | - second input: final component 18 | - output contains \`Number\` of __seconds__`; 19 | 20 | exports.install = function(instance) { 21 | 22 | var keys = {}; 23 | 24 | instance.on('0', function(response) { 25 | if (keys[response.id]) { 26 | var sec = ((new Date() - keys[response.id]) / 1000).floor(2); 27 | instance.send2(sec); 28 | instance.status(sec + ' sec.'); 29 | delete keys[response.id]; 30 | } else 31 | keys[response.id] = new Date(); 32 | }); 33 | 34 | instance.on('1', function(response) { 35 | if (keys[response.id]) { 36 | var sec = ((new Date() - keys[response.id]) / 1000).floor(2); 37 | instance.send2(sec); 38 | instance.status(sec + ' sec.'); 39 | delete keys[response.id]; 40 | } else 41 | keys[response.id] = new Date(); 42 | }); 43 | 44 | instance.on('close', () => keys = null); 45 | }; -------------------------------------------------------------------------------- /duration/readme.md: -------------------------------------------------------------------------------- 1 | # Duration 2 | 3 | This component measures a duration of Flow processing for same message id. 4 | 5 | - first input: staring component 6 | - second input: final component 7 | - output contains \`Number\` of __seconds__ -------------------------------------------------------------------------------- /email/email-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ smtp: '...', user: '...', password: '...', port: 25, subject: 'Hello from FLOW!', from: 'info@totaljs.com', target: 'petersirka@gmail.com' }); 38 | FLOWDATA('Hello world!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /email/readme.md: -------------------------------------------------------------------------------- 1 | # Email sender 2 | 3 | You need to configure this component. 4 | 5 | __Outputs__: 6 | - `green` message has been sent successfully 7 | - `red` an error while sending 8 | 9 | __Dynamic arguments__: 10 | Are performed via FlowData repository and can be used for subject, from/to addresses or attachments. Use `repository` component for creating of dynamic arguments. Examples: 11 | 12 | - subject `{name}` 13 | - from address e.g. `{from}` 14 | - to address e.g. `{to}` 15 | 16 | __Attachments__: 17 | `FlowData` repository needs to contain `attachments` key with user-defined array in the form: 18 | 19 | ```javascript 20 | [ 21 | { filename: '/absolute/path/to/some/file.pdf', name: 'report.pdf' }, 22 | { filename: '/or/absolute/path/to/package.zip' } 23 | ]``` -------------------------------------------------------------------------------- /eval/eval-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ code: 'console.log("IT WORKS")' }); 38 | }); 39 | -------------------------------------------------------------------------------- /eval/eval.js: -------------------------------------------------------------------------------- 1 | exports.id = 'eval'; 2 | exports.title = 'Eval'; 3 | exports.group = 'Common'; 4 | exports.color = '#656D78'; 5 | exports.input = false; 6 | exports.output = false; 7 | exports.author = 'Peter Širka'; 8 | exports.icon = 'code'; 9 | exports.version = '1.0.0'; 10 | exports.options = { code: '// NOSQLSTORAGE(\'database\').mapreduce(\'count\', (doc, R) => { R.count = (R.count || 0) + 1; });' }; 11 | 12 | exports.html = `
13 |
@(Code)
14 |
`; 15 | 16 | exports.readme = `# Eval 17 | 18 | This component executes custom JavaScript code as it is when you change a code or after Flow is restarted.`; 19 | 20 | exports.install = function(instance) { 21 | instance.reconfigure = function() { 22 | try { 23 | instance.options.code && (new Function(instance.options.code)()); 24 | } catch (e) { 25 | instance.error('Code: ' + e.message); 26 | } 27 | }; 28 | instance.on('options', instance.reconfigure); 29 | instance.reconfigure(); 30 | }; -------------------------------------------------------------------------------- /eval/readme.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | This component executes custom JavaScript code as it is and it doesn't contain any secure scope. 4 | 5 | ```javascript 6 | // value {Object} contains received data 7 | // send(outputIndex, newValue) sends a new value 8 | // instance {Object} a current component instance 9 | // flowdata {Object} a current flowdata 10 | // repository {Object} a current repository of flowdata 11 | // Example: 12 | 13 | // send() can be execute multiple times 14 | send(0, value); 15 | ``` -------------------------------------------------------------------------------- /event/event-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ name: 'test', fn: 'function(a, b) { console.log(a, b); }' }); 38 | EMIT('test', '1', '2'); 39 | 40 | setTimeout(function() { 41 | FLOWOPTIONS({ name: null, fn: null }); 42 | EMIT('test', '1', '2'); 43 | FLOWCLOSE(); 44 | }, 100); 45 | }); 46 | -------------------------------------------------------------------------------- /event/event.js: -------------------------------------------------------------------------------- 1 | exports.id = 'event'; 2 | exports.version = '1.0.0'; 3 | exports.title = 'Event'; 4 | exports.group = 'Inputs'; 5 | exports.color = '#F6BB42'; 6 | exports.input = false; 7 | exports.output = 1; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'bullhorn'; 10 | exports.options = { fn: `function(a, b) { 11 | // your code 12 | // this === component instance 13 | // this.send(data); 14 | }` }; 15 | 16 | exports.html = `
17 |
@(Event name)
18 |
@(Event function)
19 |
`; 20 | 21 | exports.readme = `# Event capturing 22 | 23 | This component can capture Total.js framework event.`; 24 | 25 | exports.install = function(instance) { 26 | 27 | var e = { name: '', fn: null }; 28 | 29 | instance.reconfigure = function() { 30 | 31 | var options = instance.options; 32 | 33 | e.name && OFF(e.name, e.process); 34 | 35 | if (options.name && options.fn) { 36 | e.name = options.name; 37 | try { 38 | e.fn = eval('(' + options.fn + ')'); 39 | } catch (e) { 40 | e.fn = null; 41 | } 42 | } else { 43 | e.fn = null; 44 | e.process = null; 45 | e.name = ''; 46 | } 47 | 48 | if (e.fn) { 49 | 50 | e.process = function(a, b, c, d) { 51 | e.fn.call(instance, a, b, c, d); 52 | }; 53 | 54 | ON(e.name, e.process); 55 | instance.status(''); 56 | } 57 | else 58 | instance.status('Not configured', 'red'); 59 | }; 60 | 61 | instance.on('options', instance.reconfigure); 62 | instance.reconfigure(); 63 | }; -------------------------------------------------------------------------------- /event/readme.md: -------------------------------------------------------------------------------- 1 | # Event capturing 2 | 3 | This component can capture Total.js framework event. -------------------------------------------------------------------------------- /feedtodelay/feedtodelay-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ timeout: 3 }); 38 | FLOWDATA(''); // nothing is sent while recieving new data 39 | FLOWDATA(''); // nothing is sent while recieving new data 40 | FLOWDATA(''); // nothing is sent while recieving new data 41 | // 3s later the last data are sent forward 42 | }); 43 | -------------------------------------------------------------------------------- /feedtodelay/feedtodelay.js: -------------------------------------------------------------------------------- 1 | exports.id = 'feedtodelay'; 2 | exports.title = 'Feed to delay'; 3 | exports.color = '#656D78'; 4 | exports.icon = 'clock-o'; 5 | exports.group = 'Time'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.0'; 9 | exports.author = 'Martin Smola'; 10 | exports.options = { timeout: 30 }; 11 | 12 | exports.html = `
13 |
14 |
15 |
@(Timeout)
16 |
17 |
18 |
`; 19 | 20 | exports.readme = `# Feed to delay 21 | It will only send data if it doesn't recieve anything in past x seconds. 22 | So if it keeps getting new data before the timeout it will never send anything.`; 23 | 24 | exports.install = function(instance) { 25 | 26 | var waiting = false; 27 | var timeout; 28 | 29 | instance.on('data', function(flowdata) { 30 | 31 | if (waiting) 32 | clearTimeout(timeout); 33 | else 34 | waiting = true; 35 | 36 | timeout = setTimeout(function(){ 37 | instance.send2(flowdata); 38 | waiting = false; 39 | }, instance.options.timeout * 1000); 40 | }); 41 | 42 | instance.on('close', () => timeout && clearTimeout(timeout)); 43 | }; -------------------------------------------------------------------------------- /feedtodelay/readme.md: -------------------------------------------------------------------------------- 1 | # Feed to delay 2 | 3 | It will only send data if it doesn't recieve anything in past x seconds. -------------------------------------------------------------------------------- /fi/fi-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWDATA('1'); 38 | }); 39 | -------------------------------------------------------------------------------- /fi/readme.md: -------------------------------------------------------------------------------- 1 | # First in 2 | 3 | This component is a part of FIFO stack. -------------------------------------------------------------------------------- /filereader/readme.md: -------------------------------------------------------------------------------- 1 | # File Reader 2 | 3 | This component reads a file from file system. 4 | 5 | ## Input 6 | If incomming object has a path property then filename option is ignored. 7 | 8 | Example of incomming object 9 | \`\`\`javascript 10 | { 11 | path: '/public/robots.txt', 12 | type: 'text', // optional, default text 13 | encoding: 'utf8' // optional, default utf8 14 | } 15 | \`\`\` 16 | -------------------------------------------------------------------------------- /filewriter/filewriter-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ filename: 'output.txt', append: true, delimiter: '\\n' }); 38 | FLOWDATA('LINE1'); 39 | FLOWDATA('LINE2'); 40 | FLOWDATA('LINE3'); 41 | FLOWDATA('LINE4'); 42 | FLOWDATA('LINE5'); 43 | FLOWCLOSE(); 44 | }); 45 | -------------------------------------------------------------------------------- /filewriter/readme.md: -------------------------------------------------------------------------------- 1 | # File Writer 2 | 3 | This component writes data into the file. -------------------------------------------------------------------------------- /flowboardlight/flowboardlight.js: -------------------------------------------------------------------------------- 1 | exports.id = 'flowboardlight'; 2 | exports.title = 'Light'; 3 | exports.group = 'Flowboard'; 4 | exports.color = '#AC92EC'; 5 | exports.icon = 'lightbulb-o'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.0'; 9 | exports.author = 'Peter Širka'; 10 | exports.readme = `# Flowboard: Light 11 | 12 | - input \`0 = OFF\` and \`1 = ON\` 13 | - output \`0 = OFF\` and \`1 = ON\``; 14 | 15 | exports.install = function(instance) { 16 | 17 | var arr = ['Off', 'On']; 18 | 19 | instance.reconfigure = function() { 20 | instance.status(global.FLOWBOARD ? arr[instance.get('state') || 0] : 'Flowboard not found.', global.FLOWBOARD ? null : 'red'); 21 | }; 22 | 23 | instance.on('data', function(response) { 24 | instance.set('state', response.data); 25 | instance.flowboard && instance.flowboard('laststate', response.data); 26 | instance.status(arr[response.data]); 27 | instance.send2(response.data); 28 | }); 29 | 30 | instance.on('options', instance.reconfigure); 31 | instance.reconfigure(); 32 | 33 | instance.on('flowboard', function(type, data) { 34 | switch (type) { 35 | 36 | case 'laststate': 37 | // Sends last know state 38 | var state = instance.get('state'); 39 | state !== undefined && instance.flowboard && instance.flowboard('laststate', state); 40 | break; 41 | 42 | case 'switch': 43 | 44 | // data === {Number} 45 | // 0: off, 1: on 46 | 47 | // Sends data to device 48 | instance.send2(data); 49 | 50 | // Change status and last know state 51 | instance.status(arr[data]); 52 | instance.set('state', data); 53 | 54 | // Send the last state to Flowboard 55 | instance.flowboard && instance.flowboard('laststate', data); 56 | break; 57 | } 58 | }); 59 | }; 60 | -------------------------------------------------------------------------------- /flowboardlight/readme.md: -------------------------------------------------------------------------------- 1 | # Flowboard: Light 2 | 3 | - [Flowboard website](https://www.totaljs.com/flowboard/) 4 | 5 | --- 6 | 7 | - input `0 = OFF` and `1 = ON` 8 | - output `0 = OFF` and `1 = ON` -------------------------------------------------------------------------------- /flowboardoutput/flowboardoutput.js: -------------------------------------------------------------------------------- 1 | exports.id = 'flowboardoutput'; 2 | exports.title = 'Output'; 3 | exports.group = 'Flowboard'; 4 | exports.color = '#AC92EC'; 5 | exports.icon = 'commenting-o'; 6 | exports.input = true; 7 | exports.output = 0; 8 | exports.version = '1.0.0'; 9 | exports.author = 'Peter Širka'; 10 | exports.readme = `# Flowboard: Output 11 | 12 | This component shows data as they are. Output can be __HTML__ and can contain __Font-Awesome icons__, colors, etc..`; 13 | 14 | exports.install = function(instance) { 15 | 16 | instance.reconfigure = function() { 17 | instance.status(global.FLOWBOARD ? '' : 'Flowboard not found.', global.FLOWBOARD ? null : 'red'); 18 | }; 19 | 20 | instance.on('data', function(response) { 21 | instance.set('state', response.data); 22 | instance.flowboard && instance.flowboard('laststate', response.data); 23 | }); 24 | 25 | instance.on('options', instance.reconfigure); 26 | instance.reconfigure(); 27 | 28 | instance.on('flowboard', function(type, data) { 29 | switch (type) { 30 | case 'laststate': 31 | var data = instance.get('state'); 32 | data !== undefined && instance.flowboard && instance.flowboard('laststate', data); 33 | break; 34 | } 35 | }); 36 | }; 37 | -------------------------------------------------------------------------------- /flowboardoutput/readme.md: -------------------------------------------------------------------------------- 1 | # Flowboard: Output 2 | 3 | - [Flowboard website](https://www.totaljs.com/flowboard/) 4 | 5 | This component shows data as they are. Output can be __HTML__ and can contain __Font-Awesome icons__, colors, etc.. -------------------------------------------------------------------------------- /flowboardsocket/flowboardsocket.js: -------------------------------------------------------------------------------- 1 | exports.id = 'flowboardsocket'; 2 | exports.title = 'Socket'; 3 | exports.group = 'Flowboard'; 4 | exports.color = '#AC92EC'; 5 | exports.icon = 'plug-o'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.0'; 9 | exports.author = 'Peter Širka'; 10 | exports.readme = `# Flowboard: Socket 11 | 12 | - input \`0 = OFF\` and \`1 = ON\` 13 | - output \`0 = OFF\` and \`1 = ON\``; 14 | 15 | exports.install = function(instance) { 16 | 17 | var arr = ['Off', 'On']; 18 | 19 | instance.reconfigure = function() { 20 | instance.status(global.FLOWBOARD ? arr[instance.get('state') || 0] : 'Flowboard not found.', global.FLOWBOARD ? null : 'red'); 21 | }; 22 | 23 | instance.on('data', function(response) { 24 | instance.set('state', response.data); 25 | instance.flowboard && instance.flowboard('laststate', response.data); 26 | instance.status(arr[response.data]); 27 | }); 28 | 29 | instance.on('options', instance.reconfigure); 30 | instance.reconfigure(); 31 | 32 | instance.on('flowboard', function(type, data) { 33 | switch (type) { 34 | 35 | case 'laststate': 36 | // Sends last know state 37 | var state = instance.get('state'); 38 | state !== undefined && instance.flowboard && instance.flowboard('laststate', state); 39 | break; 40 | 41 | case 'switch': 42 | 43 | // data === {Number} 44 | // 0: off, 1: on 45 | 46 | // Sends data to device 47 | instance.send2(data); 48 | 49 | // Change status and last know state 50 | instance.status(arr[data]); 51 | instance.set('state', data); 52 | 53 | // Send the last state to Flowboard 54 | instance.flowboard && instance.flowboard('laststate', data); 55 | break; 56 | } 57 | }); 58 | }; 59 | -------------------------------------------------------------------------------- /flowboardsocket/readme.md: -------------------------------------------------------------------------------- 1 | # Flowboard: Socket 2 | 3 | - [Flowboard website](https://www.totaljs.com/flowboard/) 4 | 5 | --- 6 | 7 | - input `0 = OFF` and `1 = ON` 8 | - output `0 = OFF` and `1 = ON` -------------------------------------------------------------------------------- /fo/fo.js: -------------------------------------------------------------------------------- 1 | exports.id = 'fo'; 2 | exports.version = '1.0.0'; 3 | exports.title = 'First Out'; 4 | exports.group = 'Common'; 5 | exports.color = '#F6BB42'; 6 | exports.input = 1; 7 | exports.output = 1; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'minus'; 10 | exports.readme = `# First Out 11 | 12 | This component is a part of FI__FO__ stack. __IMPORTANT__ message can't changed repository because this component needs a reference to \`First In\` component.`; 13 | 14 | exports.install = function(instance) { 15 | instance.on('data', function(data) { 16 | var fifo = data.repository.fifo; 17 | if (fifo && fifo.instance) { 18 | fifo.instance.custom.done(fifo.index); 19 | data.repository.fifo = undefined; 20 | instance.send2(data); 21 | } 22 | }); 23 | }; -------------------------------------------------------------------------------- /fo/readme.md: -------------------------------------------------------------------------------- 1 | # First Out 2 | 3 | This component is a part of FI__FO__ stack. __IMPORTANT__ message can't changed repository because this component needs a reference to `First In` component. -------------------------------------------------------------------------------- /ftpupload/ftpupload-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ url: 'ftp://petersirka:123456@host2.bakop.com' }); 38 | 39 | setTimeout(function() { 40 | FLOWDATA({ filename: '/users/petersirka/desktop/logo.pdf', target: 'logo.pdf' }); 41 | FLOWCLOSE(); 42 | }, 100); 43 | }); 44 | -------------------------------------------------------------------------------- /ftpupload/readme.md: -------------------------------------------------------------------------------- 1 | # FTP Upload 2 | 3 | __INPUT__: 4 | 5 | 6 | ```javascript 7 | { 8 | // Optional, default is FTP used in configuration 9 | url: 'FTP address with credentials', 10 | 11 | // SINGLE UPLOAD 12 | filename: 'filename to upload (absoute path)', 13 | target: 'FTP path', 14 | 15 | // OR MULTIPLE UPLOAD 16 | files: [ 17 | { 18 | filename: '', 19 | target: '' 20 | } 21 | ] 22 | } 23 | ``` 24 | 25 | __OUTPUT__: 26 | 27 | ```javascript 28 | { success: true } 29 | ``` -------------------------------------------------------------------------------- /ftpuploadfolder/ftpuploadfolder-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ type: 'ftp', port: 21, hostname: '', user: '', password: '', localpath: '/www/uploads/', interval: 3000 }); 38 | 39 | setTimeout(function() { 40 | FLOWCLOSE(); 41 | }, 15000); 42 | }); 43 | -------------------------------------------------------------------------------- /ftpuploadfolder/readme.md: -------------------------------------------------------------------------------- 1 | # FTP Upload Folder 2 | 3 | This component uploads a folder to FTP or SFTP server. __IMPORTANT__: this component uses terminal \`lftp\` command. 4 | 5 | __OUTPUT__: 6 | 7 | ```javascript 8 | { success: true } 9 | ``` -------------------------------------------------------------------------------- /function/function-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ code: 'next(\'Hello world\');' }); 38 | FLOWDATA(''); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /function/readme.md: -------------------------------------------------------------------------------- 1 | # Function 2 | 3 | Allows you to do sync operation on data 4 | 5 | If `send` function isn't called the data flow will not continue. 6 | 7 | __Custom function__: 8 | 9 | ```javascript 10 | data; // recieved data 11 | send; // send data to next component, optionaly specify output index -> send(0, data); 12 | instance; // ref to value.instance, available methods get, set, rem for storing temporary data related to this instance of Function component and debug, status and error for sending data to designer 13 | global; // ref to value.global, available methods get, set, rem for storing persistent data globally accessible in any component 14 | flowdata; // ref to value.flowdata, instance of FlowData - available methods get, set, rem for storing temporary data related to current flow 15 | flowdata.data; // user defined data recieved from previous component 16 | 17 | // Example: 18 | send('Hello world.'); // sends data to all outputs 19 | send(0, 'Hello world.'); // sends data only to first output 20 | 21 | // Calling send without any argument will pass incomming data to next components 22 | send(); 23 | ``` -------------------------------------------------------------------------------- /httpdownloader/httpdownloader-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | // FLOWDATA({ url: 'https://www.w3schools.com/xml/cd_catalog.xml' }); 38 | // or ... 39 | FLOWDATA('https://www.w3schools.com/xml/cd_catalog.xml'); 40 | FLOWCLOSE(); 41 | }); 42 | -------------------------------------------------------------------------------- /httpdownloader/httpdownloader.js: -------------------------------------------------------------------------------- 1 | exports.id = 'httpdownloader'; 2 | exports.title = 'HTTP Downloader'; 3 | exports.group = 'HTTP'; 4 | exports.color = '#5D9CEC'; 5 | exports.icon = 'cloud-download'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.1'; 9 | exports.author = 'Peter Širka'; 10 | exports.readme = `# A content downloader 11 | 12 | This component downloads a buffer in chunks. Input of this component expects object in the form \`{ url: 'URL address' }\` or \`String\` as URL address.`; 13 | 14 | exports.install = function(instance) { 15 | const FLAGS = ['get']; 16 | instance.on('data', function(response) { 17 | var url; 18 | if (typeof(response.data) === 'string') 19 | url = response.data; 20 | else if (response.data && response.data.url) 21 | url = response.data.url; 22 | if (url) { 23 | if (F.is4) { 24 | var opt = {}; 25 | opt.url = url; 26 | opt.method = 'GET'; 27 | opt.custom = true; 28 | opt.callback = function(err, response) { 29 | response.stream.on('data', chunk => instance.send2(chunk)); 30 | }; 31 | REQUEST(opt); 32 | } else { 33 | U.download(url, FLAGS, function(err, response) { 34 | response.on('data', chunk => instance.send2(chunk)); 35 | }); 36 | } 37 | } 38 | }); 39 | }; 40 | -------------------------------------------------------------------------------- /httpdownloader/readme.md: -------------------------------------------------------------------------------- 1 | # A content downloader 2 | 3 | - expects `Object` in the form `{ url: 'https://www.w3schools.com/Xml/cd_catalog.xml' }` 4 | - or `String` with a valid URL `https://www.w3schools.com/Xml/cd_catalog.xml` -------------------------------------------------------------------------------- /httpgeoip/httpgeoip-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWDATA({ ip: '62.168.127.195' }); 38 | }); 39 | -------------------------------------------------------------------------------- /httpgeoip/httpgeoip.js: -------------------------------------------------------------------------------- 1 | exports.id = 'httpgeoip'; 2 | exports.title = 'HTTP GeoIP'; 3 | exports.group = 'HTTP'; 4 | exports.color = '#5D9CEC'; 5 | exports.icon = 'map-marker'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.version = '1.0.1'; 9 | exports.author = 'Peter Širka'; 10 | exports.readme = `# HTTP GeoIP 11 | 12 | The component obtains locality according to the IP address. Received data has to contain \`data.ip\` field with IP address. If the component will obtain Geo informations then it extends a current data object about a new field \`geoip\` and sends all data next. 13 | 14 | \`\`\`javascript 15 | response.geoip; // Object { country_code: 'SK', country_name: 'Slovakia', city: '', region_code: '', region_name: '', zip_code: '', time_zone: '', latitude: 51.2993, longitude: 9.491 } 16 | \`\`\``; 17 | 18 | exports.install = function(instance) { 19 | 20 | const FLAGS = ['dnscache', 'get']; 21 | var cache = {}; 22 | 23 | instance.on('data', function(response) { 24 | 25 | if (!response.data) 26 | return; 27 | 28 | var ip = response.data.ip; 29 | 30 | if (cache[ip]) { 31 | response.data.geoip = cache[ip]; 32 | instance.send2(response.data); 33 | return; 34 | } 35 | 36 | if (F.is4) { 37 | 38 | RESTBuilder.GET('http://freegeoip.net/json/' + ip).callback(function(err, data, meta) { 39 | 40 | if (err) { 41 | instance.error(err); 42 | return; 43 | } 44 | 45 | if (meta.status !== 200) 46 | return; 47 | 48 | if (data) { 49 | response.data.geoip = cache[ip] = data; 50 | instance.send2(data); 51 | } 52 | }); 53 | 54 | } else { 55 | U.request('http://freegeoip.net/json/' + ip, FLAGS, function(err, res, status) { 56 | 57 | if (err) { 58 | instance.error(err); 59 | return; 60 | } 61 | 62 | if (status !== 200) 63 | return; 64 | 65 | var data = res.parseJSON(); 66 | if (data) { 67 | response.data.geoip = cache[ip] = data; 68 | instance.send2(response.data); 69 | } 70 | }); 71 | } 72 | }); 73 | 74 | instance.on('service', counter => counter % 30 === 0 && (cache = {})); 75 | }; -------------------------------------------------------------------------------- /httpgeoip/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP GeoIP 2 | 3 | The component obtains locality according to the IP address. Received data has to contain `data.ip` field with IP address. If the component will obtain Geo informations then it extends a current data object about a new field `geoip` and sends all data next. 4 | 5 | ```javascript 6 | response.geoip; // Object { country_code: 'SK', country_name: 'Slovakia', city: '', region_code: '', region_name: '', zip_code: '', time_zone: '', latitude: 51.2993, longitude: 9.491 } 7 | ``` -------------------------------------------------------------------------------- /httplistener/httplistener-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ staticfiles: true }); 38 | }); 39 | -------------------------------------------------------------------------------- /httplistener/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP Listener 2 | 3 | Can capture all received requests. 4 | 5 | ```javascript 6 | response.body; // Request body (POST/PUT/DELETE) 7 | response.files; // Uploaded files 8 | response.id; // Record ID (if exists) 9 | response.ip; // Current IP 10 | response.method; // String 11 | response.path; // Splitted path 12 | response.query; // Query string arguments 13 | response.session; // Session instance (if exists) 14 | response.url; // Current URL 15 | response.user; // User instance (if exists) 16 | response.file; // Is a static file? 17 | response.extension; // File extension 18 | ``` -------------------------------------------------------------------------------- /httpreceiver/httpreceiver-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ route: 0 }); 38 | }); 39 | -------------------------------------------------------------------------------- /httpreceiver/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP Receiver 2 | 3 | This component can receive all data from this web application. Choose which route data you want to receive and everything will work automatically. __Response__ is an object: 4 | 5 | ```javascript 6 | response.body; // (Object) Request body (POST/PUT/DELETE) 7 | response.files; // (Object Array) Uploaded files 8 | response.id; // (String/Number) Record ID (if exists) 9 | response.ip; // (String) Current IP 10 | response.method; // (String) HTTP method 11 | response.path; // (Array) Splitted path 12 | response.query; // (Object) Query string arguments 13 | response.session; // (Object) Session instance (if exists) 14 | response.url; // (String) Current URL 15 | response.user; // (Object) User instance (if exists) 16 | ``` -------------------------------------------------------------------------------- /httpredirect/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP Redirect 2 | 3 | Creates a Total.js redirect for GET requests. __IMPORTANT__: data are sent only while the request is redirected on a relative URL address. 4 | 5 | ```javascript 6 | { 7 | query: { msg: 'Hello' }, // parsed query string, e.g. /test/1?msg=Hello 8 | headers: {}, // Header keys 9 | uri: {}, // Parsed URL, 10 | url: '' // Relative URL 11 | } 12 | ``` -------------------------------------------------------------------------------- /httprequest/httprequest-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ url: 'https://www.totaljs.com', method: 'GET', stringify: 'raw' }); 38 | FLOWDATA(''); 39 | }); 40 | -------------------------------------------------------------------------------- /httprequest/readme.md: -------------------------------------------------------------------------------- 1 | # Request 2 | 3 | This component creates a request with received data. 4 | 5 | __Response:__ 6 | 7 | ```javascript 8 | { 9 | data: String, 10 | headers: Object, 11 | status: Number, 12 | host: String 13 | } 14 | ``` 15 | 16 | __Dynamic arguments__: 17 | 18 | Are performed via FlowData repository and can be used for URL address or for custom headers/cookies/auth. Use `repository` component for creating of dynamic arguments. Examples: 19 | 20 | - url address can be in this form `https://hostname.com/{key}/` 21 | - headers values e.g. `{token}` 22 | - cookies values e.g. `{token}` 23 | -------------------------------------------------------------------------------- /httpresponse/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP response 2 | 3 | HTTP response will respond with data recieved using data-type set in Settings form or plain text if not set. Output is the message duration `Number` in seconds. -------------------------------------------------------------------------------- /httproute/readme.md: -------------------------------------------------------------------------------- 1 | # HTTP route 2 | When a request comes in bellow object is available at `flowdata.data`: 3 | ```javascript 4 | { 5 | params: { id: '1' }, // params for dynamic routes, e.g. /test/{id} 6 | query: { msg: 'Hello' }, // parsed query string, e.g. /test/1?msg=Hello 7 | body: { test: 'OK' }, // object if json requests otherwise string 8 | session: {}, // sesion data 9 | user: {}, // user 10 | files: [] // files 11 | } 12 | ``` 13 | 14 | See documentation for flags [here](https://docs.totaljs.com/latest/en.html#api~HttpRouteOptionsFlags~unauthorize) 15 | Method flags are set automatically e.g. `get, post, put or delete` 16 | 17 | `id:ROUTE_ID` flag cannot be used since it's already used by this component internally 18 | -------------------------------------------------------------------------------- /lastdata/lastdata-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ count: 5 }); 38 | var indexer = 1; 39 | var interval = setInterval(function() { 40 | FLOWDATA(indexer++); 41 | indexer > 15 && clearInterval(interval); 42 | }, 1000); 43 | FLOWDATA([100, 101, 102, 103]); 44 | }); 45 | -------------------------------------------------------------------------------- /lastdata/lastdata.js: -------------------------------------------------------------------------------- 1 | exports.id = 'lastdata'; 2 | exports.title = 'Last Data'; 3 | exports.group = 'Common'; 4 | exports.color = '#656D78'; 5 | exports.version = '1.0.0'; 6 | exports.input = true; 7 | exports.click = true; 8 | exports.output = 1; 9 | exports.options = { count: 10 }; 10 | exports.author = 'Peter Širka'; 11 | exports.icon = 'list'; 12 | 13 | exports.html = `
14 |
15 |
16 |
@(Count)
17 |
@(Count of data)
18 |
19 |
20 |
`; 21 | 22 | exports.readme = `# Last Data 23 | 24 | This component keeps last a count of data and still returns \`Array\` of raw data. Nullable data won't be added.`; 25 | 26 | exports.install = function(instance) { 27 | 28 | var data = []; 29 | 30 | instance.on('data', function(response) { 31 | var is = false; 32 | if (response.data instanceof Array) { 33 | for (var i = 0, length = response.data.length; i < length; i++) { 34 | var item = response.data[i]; 35 | if (item != null) { 36 | data.unshift(item); 37 | data.length > instance.options.count && data.pop(); 38 | is = true; 39 | } 40 | } 41 | } else if (response.data != null) { 42 | data.unshift(response.data); 43 | data.length > instance.options.count && data.pop(); 44 | is = true; 45 | } 46 | is && instance.send2(data); 47 | }); 48 | 49 | instance.on('click', function() { 50 | data && data.length && instance.send2(data); 51 | }); 52 | }; -------------------------------------------------------------------------------- /lastdata/readme.md: -------------------------------------------------------------------------------- 1 | # Last Data 2 | 3 | This component keeps last a count of data and still returns `Array` of raw data. Nullable data won't be added. -------------------------------------------------------------------------------- /lastusage/lastusage-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ format: 'yyyy-MM-dd' }); 38 | FLOWDATA(); 39 | }); 40 | -------------------------------------------------------------------------------- /lastusage/lastusage.js: -------------------------------------------------------------------------------- 1 | exports.id = 'lastusage'; 2 | exports.title = 'Last Usage'; 3 | exports.version = '1.1.1'; 4 | exports.author = 'Peter Širka'; 5 | exports.color = '#656D78'; 6 | exports.input = true; 7 | exports.icon = 'calendar'; 8 | exports.options = { format: 'dd.MM.yyyy HH:mm:ss' }; 9 | exports.dateupdated = '2018-01-19T11:57:00.000Z'; 10 | exports.traffic = false; 11 | exports.readme = `# Last Usage 12 | 13 | This component remembers date and time of last received data. The component keeps stats of usage in NoSQL embedded DB.`; 14 | 15 | exports.html = `
16 |
17 |
18 |
@(Date format)
19 |
20 |
21 |
`; 22 | 23 | exports.install = function(instance) { 24 | 25 | var lastusage = null; 26 | 27 | instance.on('data', function() { 28 | 29 | lastusage = new Date(); 30 | instance.custom.status(); 31 | 32 | // Internal stats 33 | if (F.is4) { 34 | COUNTER('flowlastusage').hit(instance.id, 1); 35 | } else { 36 | NOSQL('flowlastusage').counter.hit(instance.id, 1); 37 | } 38 | }); 39 | 40 | instance.custom.status = function(skip) { 41 | lastusage && setTimeout2(instance.id, function() { 42 | 43 | instance.status(lastusage.format(instance.options.format)); 44 | 45 | if (skip) 46 | return; 47 | 48 | var data = {}; 49 | data.id = instance.id; 50 | data.date = lastusage; 51 | data.name = instance.name; 52 | NOSQL('flowlastusage').update(data, data).where('id', data.id); 53 | }, 1000); 54 | }; 55 | 56 | instance.on('options', instance.custom.status); 57 | 58 | NOSQL('flowlastusage').one().where('id', instance.id).callback(function(err, response) { 59 | if (response) { 60 | lastusage = response.date; 61 | instance.custom.status(true); 62 | } 63 | }); 64 | }; -------------------------------------------------------------------------------- /lastusage/readme.md: -------------------------------------------------------------------------------- 1 | # Last Usage 2 | 3 | This component remembers date and time of last received data. The component keeps stats of usage in NoSQL embedded DB. -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | Copyright 2012-2020 (c) Peter Širka 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a 5 | copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to permit 9 | persons to whom the Software is furnished to do so, subject to the 10 | following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 18 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 19 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 | USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /list.js: -------------------------------------------------------------------------------- 1 | var version = parseInt(process.argv[2] || '6'); 2 | if (!version) 3 | version = 6; 4 | 5 | const Fs = require('fs'); 6 | require('total4'); 7 | 8 | var templates = {}; 9 | var giturl = 'https://cdn.totaljs.com/flow/{1}.js'; 10 | 11 | var count = 0; 12 | var countgroup = 0; 13 | 14 | function parseValue(name, file) { 15 | var index = file.indexOf('exports.' + name); 16 | if (index > -1) { 17 | index = file.indexOf('\'', index) || file.indexOf('"', index); 18 | var i2 = file.indexOf('\';', index) || file.indexOf('"', index); 19 | return file.substring(index + 1, i2); 20 | } 21 | return ''; 22 | } 23 | 24 | U.ls('./', function callback(files,dirs) { 25 | 26 | dirs.wait(function(dir, next){ 27 | 28 | if (dir.startsWith('.') || dir.startsWith('node_modules') || dir.startsWith('__flow')) 29 | return next(); 30 | 31 | count++; 32 | 33 | if (dir[dir.length - 1] === '/') 34 | dir = dir.substring(0, dir.length - 1); 35 | 36 | var filename = U.join(F.path.root(dir), dir + '.js'); 37 | var url = giturl.format('master', dir); 38 | 39 | if (filename.indexOf('tutorial') !== -1) { 40 | next(); 41 | return; 42 | } 43 | 44 | var file = Fs.readFileSync(filename, 'utf8'); 45 | var groupname = parseValue('group', file); 46 | var ver = parseValue('version', file); 47 | 48 | if (!ver) { 49 | console.log('WARNING: "' + file + '" doesn\'t contain version.'); 50 | return next(); 51 | } 52 | 53 | if (version >= 6) 54 | url = { url: url, version: ver }; 55 | 56 | getGroup(groupname || 'Common').items.push(url); 57 | 58 | next(); 59 | }, function(){ 60 | 61 | var arr = []; 62 | Object.keys(templates).forEach(i => arr.push(templates[i])); 63 | Fs.writeFileSync((version === 6 ? './list' : ('./templates' + version)) + '.json', JSON.stringify(arr, null, '\t')); 64 | 65 | console.log('\nCount of components:' + count); 66 | console.log('Count of groups:' + countgroup++); 67 | console.log('Template file `templates' + version + '.json` created.'); 68 | }); 69 | }); 70 | 71 | function getGroup(group) { 72 | if (!templates[group]){ 73 | countgroup++; 74 | templates[group] = {}; 75 | templates[group].name = group; 76 | templates[group].items = []; 77 | } 78 | return templates[group]; 79 | } -------------------------------------------------------------------------------- /logtodb/logtodb.js: -------------------------------------------------------------------------------- 1 | exports.id = 'logtodb'; 2 | exports.title = 'Log to DB'; 3 | exports.group = 'Databases'; 4 | exports.color = '#B0C4DE'; 5 | exports.author = 'Martin Smola'; 6 | exports.icon = 'database'; 7 | exports.version = '1.0.0'; 8 | exports.input = true; 9 | exports.output = true; 10 | exports.options = { dbname: '', template: ''}; 11 | exports.html = `
12 |
13 |
14 |
@(DB name)
15 |
16 |
17 |
@(Template)
18 |
19 |
20 |
`; 21 | exports.readme = `# Log to DB 22 | 23 | Logs a string into a DB (NoSQL embedded). 24 | Time stamp is added automaticaly. 25 | 26 | Incoming data are passed to output. 27 | 28 | Template uses Total.js framework view syntax. 29 | 30 | Incomming object is available as \`@{model}\` 31 | 32 | \`@{repository.time}\` inserts \`new Date().getTime()\` 33 | 34 | ## Template example 35 | Data: 36 | \`\`\`javascript 37 | { 38 | name: 'some process', 39 | exec: 'restart' 40 | } 41 | \`\`\` 42 | Template: 43 | \`A process "@{model.propname}" executed "@{model.exec}" \` 44 | Output: 45 | *A process "some process" executed "restart"*`; 46 | 47 | exports.install = function(instance) { 48 | 49 | instance.custom.reconfigure = function() { 50 | if (!instance.options.dbname || !instance.options.template) 51 | return instance.status('Not configured', 'red'); 52 | instance.status(''); 53 | }; 54 | 55 | instance.on('data', function(flowdata) { 56 | instance.send(flowdata); 57 | if (!instance.options.dbname || !instance.options.template) 58 | return; 59 | var str = F.viewCompile(instance.options.template, flowdata.data, '', { time: new Date().getTime() }); 60 | NOSQL(instance.options.dbname).insert({ dt: new Date().getTime(), body: str }); 61 | }); 62 | 63 | instance.on('options', instance.custom.reconfigure); 64 | instance.custom.reconfigure(); 65 | }; 66 | -------------------------------------------------------------------------------- /logtodb/readme.md: -------------------------------------------------------------------------------- 1 | # Log to DB 2 | 3 | Logs a string into a DB (NoSQL embedded). 4 | 5 | Incoming data are passed to output. 6 | 7 | Template uses Total.js framework view syntax. 8 | 9 | `@{repository.time}` inserts `new Date().getTime()` -------------------------------------------------------------------------------- /megatimer/readme.md: -------------------------------------------------------------------------------- 1 | # Timer 2 | 3 | Timer will trigger flow at the given times and dates. You can optionally define a data-type of the output and the data. 4 | 5 | -------------------------------------------------------------------------------- /merge/merge-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ count: 5 }); 38 | var indexer = 1; 39 | var interval = setInterval(function() { 40 | FLOWDATA(indexer++); 41 | indexer > 15 && clearInterval(interval); 42 | }, 1000); 43 | }); 44 | -------------------------------------------------------------------------------- /merge/readme.md: -------------------------------------------------------------------------------- 1 | # Merge 2 | 3 | This component merges all received data into the `Array`. Clicking on the button will empty the queue. -------------------------------------------------------------------------------- /mergetoobject/mergetoobject-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({props: ['products', 'posts']}); 38 | 39 | FLOWDATA({item: 'tv'}, 0); 40 | FLOWDATA({post: 'Hello world!'}, 1); 41 | }); 42 | -------------------------------------------------------------------------------- /mergetoobject/readme.md: -------------------------------------------------------------------------------- 1 | # Merge to object 2 | 3 | This component merges received data into an `Object`. Clicking on the button will empty any previously recieved data. Defined properties in order will be as inputs and the component waits for all inputs. If all inputs will have received data then the component sends the merged object next. -------------------------------------------------------------------------------- /messengermessage/messengermessage-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /messengermessage/messengermessage.js: -------------------------------------------------------------------------------- 1 | exports.id = 'messengermessage'; 2 | exports.title = 'Messenger: Message'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Peter Širka'; 5 | exports.group = 'Total.js Messenger'; 6 | exports.color = '#F6BB42'; 7 | exports.output = 1; 8 | exports.icon = 'comments-o'; 9 | exports.readme = `# Total.js Messenger: Message 10 | 11 | This component evaluates data when is created a new message in Total.js messenger. 12 | 13 | - message repository contains \`client\` and \`controller\` instance, 14 | - output contains a raw data of message: 15 | \`\`\`javascript 16 | { 17 | body: 'MARKDOWN', 18 | type: 'channel', // or "user" 19 | target: { id: 'String', name: 'String', linker: 'String' } // "channel" or "user" instance 20 | from: { id: 'String', name: 'String', email: 'String', picture: 'String', ... }, 21 | mobile: false, // Is message from a mobile device? 22 | robot: false, // Is message from a robot? (A message created manually on the server) 23 | edited: false, // Is message edited? 24 | users: ['IDUSER A', 'IDUSER B', '...'], // Users tagged in the message 25 | files: [{ name: 'My photo.jpg', url: '/download/3498349839843934.jpg' }] // Uploaded files 26 | } 27 | \`\`\``; 28 | 29 | exports.install = function(instance) { 30 | 31 | var can; 32 | 33 | instance.custom.message = function(controller, client, message) { 34 | message = U.clone(message); 35 | message.from = client.user; 36 | message.type = client.threadtype; 37 | message.target = message.type === 'channel' ? F.global.channels.findItem('id', client.threadid) : F.global.users.findItem('id', client.threadid); 38 | 39 | if (message.type === 'channel') { 40 | message.channel = message.target.name; 41 | message.user = ''; 42 | } else { 43 | message.channel = ''; 44 | message.user = message.target.name; 45 | } 46 | 47 | instance.send(message).set('client', client).set('controller', controller); 48 | }; 49 | 50 | instance.on('close', () => OFF('messenger.message', instance.custom.message)); 51 | ON('messenger.message', instance.custom.message); 52 | 53 | instance.reconfigure = function() { 54 | can = F.global.sendmessage ? true : false; 55 | instance.status(can ? '' : 'Messenger not found', can ? undefined : 'red'); 56 | }; 57 | 58 | instance.on('options', instance.reconfigure); 59 | instance.reconfigure(); 60 | }; -------------------------------------------------------------------------------- /messengermessage/readme.md: -------------------------------------------------------------------------------- 1 | # Total.js Messenger: Message 2 | 3 | This component evaluates data when is created a new message in Total.js messenger. 4 | 5 | - message repository contains `client` and `controller` instance, 6 | - output contains a raw data of message: 7 | ```javascript 8 | { 9 | body: 'MARKDOWN', 10 | type: 'channel', // or "user" 11 | target: { id: 'String', name: 'String', linker: 'String' } // "channel" or "user" instance 12 | from: { id: 'String', name: 'String', email: 'String', picture: 'String', ... }, 13 | mobile: false, // Is message from a mobile device? 14 | robot: false, // Is message from a robot? (A message created manually on the server) 15 | edited: false, // Is message edited? 16 | users: ['IDUSER A', 'IDUSER B', '...'], // Users tagged in the message 17 | files: [{ name: 'My photo.jpg', url: '/download/3498349839843934.jpg' }] // Uploaded files 18 | } 19 | ``` -------------------------------------------------------------------------------- /messengerrawdata/messengerrawdata-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /messengerrawdata/messengerrawdata.js: -------------------------------------------------------------------------------- 1 | exports.id = 'messengerrawdata'; 2 | exports.title = 'Messenger: Raw Data'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Peter Širka'; 5 | exports.group = 'Total.js Messenger'; 6 | exports.color = '#F6BB42'; 7 | exports.output = 1; 8 | exports.icon = 'braille'; 9 | exports.readme = `# Total.js Messenger: Raw Data 10 | 11 | This component evaluates data when is created a new message in Total.js messenger. 12 | 13 | - message repository contains \`client\` and \`controller\` instance, 14 | - output contains a raw data of message \`Object\``; 15 | 16 | exports.install = function(instance) { 17 | 18 | var can; 19 | 20 | instance.custom.message = function(controller, client, message) { 21 | instance.send(message).set('client', client).set('controller', controller); 22 | }; 23 | 24 | instance.on('close', () => OFF('messenger.data', instance.custom.message)); 25 | ON('messenger.data', instance.custom.message); 26 | 27 | instance.reconfigure = function() { 28 | can = F.global.sendmessage ? true : false; 29 | instance.status(can ? '' : 'Messenger not found', can ? undefined : 'red'); 30 | }; 31 | 32 | instance.on('options', instance.reconfigure); 33 | instance.reconfigure(); 34 | }; -------------------------------------------------------------------------------- /messengerrawdata/readme.md: -------------------------------------------------------------------------------- 1 | # Total.js Messenger: Raw Data 2 | 3 | This component evaluates data when is created a new message in Total.js messenger. 4 | 5 | - message repository contains `client` and `controller` instance, 6 | - output contains a raw data of message `Object` -------------------------------------------------------------------------------- /messengersender/messengersender-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /messengersender/readme.md: -------------------------------------------------------------------------------- 1 | # Total.js Messenger: Sender 2 | 3 | This component can send message. 4 | 5 | - input has to be a Markdown content -------------------------------------------------------------------------------- /messengerusers/messengerusers-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /messengerusers/messengerusers.js: -------------------------------------------------------------------------------- 1 | exports.id = 'messengerusers'; 2 | exports.title = 'Messenger: Users'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Peter Širka'; 5 | exports.group = 'Total.js Messenger'; 6 | exports.color = '#F6BB42'; 7 | exports.output = ['#8CC152', '#DA4453']; 8 | exports.icon = 'users'; 9 | exports.readme = `# Total.js Messenger: Users 10 | 11 | This component evaluates user data when the user is online (green output) / offline (red output). 12 | 13 | - output contains a raw data of the user 14 | - supports websocket client via \`message.get('client')\` 15 | - supports websocket controller via \`message.get('controller')\` 16 | 17 | __Data Example__: 18 | 19 | \`\`\`javascript 20 | { 21 | id: 'IDENTIFICATOR' 22 | name: 'Peter Širka', 23 | online: true, 24 | datecreated: Date, 25 | datelogged: Date, 26 | position: 'Web Developer', 27 | department: 'IT department', 28 | picture: 'IDENTIFICATOR', // needs to be formated like this /photos/{ID}.jpg 29 | linker: 'peter-sirka', 30 | email: 'petersirka@gmail.com', 31 | status: 'My work is my hobby', 32 | notifications: true, 33 | unreadcount: 3, // how many messages is unread? 34 | unread: {}, // key === ID 35 | channels: {}, // key === ID 36 | lastmessages: {}, // key === ID of user or channel 37 | mobile: false, // is from mobile device? 38 | sa: true // is super admin? 39 | } 40 | \`\`\``; 41 | 42 | exports.install = function(instance) { 43 | 44 | var can; 45 | 46 | instance.custom.online = function(controller, client) { 47 | instance.send(0, client.user).set('client', client).set('controller', controller); 48 | }; 49 | 50 | instance.custom.offline = function(controller, client) { 51 | instance.send(1, client.user).set('client', client).set('controller', controller); 52 | }; 53 | 54 | instance.on('close', function() { 55 | OFF('messenger.open', instance.custom.online); 56 | OFF('messenger.close', instance.custom.offline); 57 | }); 58 | 59 | ON('messenger.open', instance.custom.online); 60 | ON('messenger.close', instance.custom.offline); 61 | 62 | instance.reconfigure = function() { 63 | can = F.global.sendmessage ? true : false; 64 | instance.status(can ? '' : 'Messenger not found', can ? undefined : 'red'); 65 | }; 66 | 67 | instance.on('options', instance.reconfigure); 68 | instance.reconfigure(); 69 | }; -------------------------------------------------------------------------------- /messengerusers/readme.md: -------------------------------------------------------------------------------- 1 | # Total.js Messenger: Users 2 | 3 | This component evaluates user data when the user is online (green output) / offline (red output). 4 | 5 | - output contains a raw data of the user 6 | - supports websocket client via `message.get('client')` 7 | - supports websocket controller via `message.get('controller')` 8 | 9 | __Data Example__: 10 | 11 | ```javascript 12 | { 13 | id: 'IDENTIFICATOR' 14 | name: 'Peter Širka', 15 | online: true, 16 | datecreated: Date, 17 | datelogged: Date, 18 | position: 'Web Developer', 19 | department: 'IT department', 20 | picture: 'IDENTIFICATOR', // needs to be formated like this /photos/{ID}.jpg 21 | linker: 'peter-sirka', 22 | email: 'petersirka@gmail.com', 23 | status: 'My work is my hobby', 24 | notifications: true, 25 | unreadcount: 3, // how many messages is unread? 26 | unread: {}, // key === ID 27 | channels: {}, // key === ID 28 | lastmessages: {}, // key === ID of user or channel 29 | mobile: false, // is from mobile device? 30 | sa: true // is super admin? 31 | } 32 | ``` -------------------------------------------------------------------------------- /modified/modified-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWDATA('TEST'); 38 | FLOWDATA('TEST'); 39 | FLOWDATA('TEST'); 40 | FLOWDATA(2); 41 | FLOWDATA(3); 42 | FLOWDATA(Buffer.alloc(5)); 43 | FLOWDATA(Buffer.alloc(5)); 44 | var dt = new Date(); 45 | FLOWDATA(dt); 46 | FLOWDATA(dt); 47 | FLOWCLOSE(); 48 | }); 49 | -------------------------------------------------------------------------------- /modified/modified.js: -------------------------------------------------------------------------------- 1 | exports.id = 'modified'; 2 | exports.title = 'Modified'; 3 | exports.group = 'Common'; 4 | exports.color = '#656D78'; 5 | exports.version = '1.0.0'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'refresh'; 10 | exports.readme = `# Modified 11 | 12 | This component compares a new value with a previous value. If the values are different then sends new data to next component.`; 13 | 14 | exports.install = function(instance) { 15 | var backup = undefined; 16 | var counter = 0; 17 | instance.on('data', function(response) { 18 | var data = response.data; 19 | if (data instanceof Buffer) 20 | data = data.toString('base64'); 21 | else if (typeof(data) === 'object' || data instanceof Date) 22 | data = JSON.stringify(data); 23 | if (backup !== data) { 24 | backup = data; 25 | instance.send2(response); 26 | } else { 27 | counter++; 28 | instance.status('Not modified: {0}x'.format(counter)); 29 | } 30 | }); 31 | }; -------------------------------------------------------------------------------- /modified/readme.md: -------------------------------------------------------------------------------- 1 | # Modified 2 | 3 | This component compares a new value with a previous value. If the values are different then sends new data to next component. -------------------------------------------------------------------------------- /monitorconsumption/monitorconsumption-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitorcpu/monitorcpu-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitordisk/monitordisk-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitormemory/monitormemory-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitornetwork/monitornetwork-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitorprocess/monitorprocess-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /monitorsuperadmin/monitorsuperadmin-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /mosca/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # MQTT Broker 3 | 4 | 5 | -------------------------------------------------------------------------------- /mqtt/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # MQTT Broker 3 | 4 | 5 | -------------------------------------------------------------------------------- /mqttpublish/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # MQTT publish 3 | 4 | If the topic field is left empty and the data object does not have a 'topic' property then nothing is send. 5 | -------------------------------------------------------------------------------- /mqttsubscribe/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # MQTT subscribe 3 | -------------------------------------------------------------------------------- /netatmo/readme.md: -------------------------------------------------------------------------------- 1 | # Netatmo 2 | 3 | Receives data from __Netatmo Weather Station__. Each station has to be authorized first. __IMPORTANT__: `input` has to be MAC address from your Netatmo station. 4 | 5 | ### How to obtain MAC address? 6 | 7 | Open https://my.netatmo.com/app/station and click on the settings. There is your MAC address. For example `70:ee:50:12:95:f2`. 8 | 9 | ### Output example 10 | 11 | ```json 12 | [ 13 | { 14 | "altitude": 362, 15 | "lat": 19.158087, 16 | "lng": 48.728146, 17 | "name": "mSirkovci", 18 | "humidity": 51, 19 | "co2": 1671, 20 | "temperature": 23.3, 21 | "temperaturetrend": "stable", 22 | "noise": 43, 23 | "pressure": 1017, 24 | "pressuretrend": "up", 25 | "indoor": [], 26 | "outdoor": [ 27 | { 28 | "temperaturetrend": "up", 29 | "temperature": 3.8, 30 | "humidity": 89, 31 | "temperaturemin": 3.4, 32 | "temperaturemax": 15.2, 33 | "battery": 72, 34 | "name": "Module" 35 | } 36 | ] 37 | } 38 | ] 39 | ``` -------------------------------------------------------------------------------- /nosql/readme.md: -------------------------------------------------------------------------------- 1 | # NoSQL 2 | 3 | ## Outputs 4 | 5 | First output is response from nosql engine and second is the data passed in. 6 | 7 | ## Collection 8 | 9 | if the collection field is left empty, then we try to look at `flowdata.get('collection')`, to set this value you need to use `flowdata.set('collection', '')` in previous component (currently only `function` can be used) 10 | 11 | ## Insert 12 | 13 | - will insert recieved data 14 | - expects data to be an Object 15 | - returns error, success, id 16 | 17 | ## Read 18 | 19 | - will read a document by id 20 | - expects data to be an Object with an `id` property 21 | - returns error, response 22 | 23 | ## Update 24 | 25 | - will update document by id 26 | - expects data to be an Object with `id` property and all the props to be updated 27 | - returns error, response 28 | - if response is 0 then update failed 29 | 30 | ## Remove 31 | 32 | - will remove document by id 33 | - expects data to be an Object with an `id` property 34 | - returns error, response 35 | - if response is 0 then remove failed 36 | 37 | ## Query 38 | 39 | - will query DB 40 | - expects data to be an Array as shown bellow 41 | - returns error, response 42 | 43 | ```javascript 44 | [ 45 | ['where', 'sensor', 'temp'], // builder.where('sensor', 'temp'); 46 | ['limit', 2] // builder.limit(2); 47 | ] 48 | ``` 49 | -------------------------------------------------------------------------------- /pagerenderer/readme.md: -------------------------------------------------------------------------------- 1 | # Page renderer 2 | Renders data into selected layout and template. 3 | 4 | Incoming data are available in the templates as \`model\` 5 | 6 | Data: 7 | ```javascript 8 | { 9 | id: 123, 10 | title: 'Homepage' 11 | } 12 | ``` 13 | 14 | Template: 15 | ```html 16 |

@{model.title}

17 | ``` -------------------------------------------------------------------------------- /pagetemplate/pagetemplate.js: -------------------------------------------------------------------------------- 1 | exports.id = 'pagetemplate'; 2 | exports.title = 'Page template'; 3 | exports.group = 'Website'; 4 | exports.color = '#4a7d2c'; 5 | exports.input = false; 6 | exports.output = false; 7 | exports.version = '1.0.1'; 8 | exports.author = 'Martin Smola'; 9 | exports.icon = 'code'; 10 | exports.traffic = false; 11 | exports.options = { template: '

Hello @{model.firstname}

', layout: false }; 12 | 13 | exports.html = `
14 |
@(Template name)
15 |
@(Is this template a layout?)
16 |
@(Layout should contain html, head and body tags and any other templates will be injected into this layout.)
17 |
@(Template)
18 |
`; 19 | 20 | exports.readme = `# Template 21 | 22 | ### Layout 23 | 24 | Use \`@{body}\` placeholder to insert other template, only works for layout 25 | 26 | Incoming data are available in the templates or layouts as \`model\` 27 | 28 | Data: 29 | \`\`\`javascript 30 | { 31 | id: 123, 32 | title: 'Homepage' 33 | } 34 | \`\`\` 35 | 36 | Template: 37 | \`\`\`html 38 |

@{model.title}

39 | \`\`\` 40 | `; 41 | 42 | exports.install = function(instance) { 43 | 44 | instance.custom.reconfigure = function() { 45 | var can = instance.options.template ? true : false; 46 | instance.status(can ? '' : 'Not configured', can ? undefined : 'red'); 47 | templates = templates.remove('id', instance.id); 48 | templates.push({ id: instance.id, name: instance.options.name }); 49 | }; 50 | 51 | instance.on('options', instance.custom.reconfigure); 52 | instance.custom.reconfigure(); 53 | }; 54 | 55 | var templates = exports.templates = []; 56 | 57 | FLOW.trigger('pagetemplates', function(next) { 58 | var tmps = []; 59 | templates.forEach(t => tmps.push({id: t.id, name: t.name})); 60 | next(tmps); 61 | }); -------------------------------------------------------------------------------- /pagetemplate/readme.md: -------------------------------------------------------------------------------- 1 | # Template 2 | 3 | ### Layout 4 | Use `@{body}` placeholder to insert other template, only works for layout 5 | 6 | Incoming data are available in the templates or layouts as `model` 7 | 8 | Data: 9 | ```javascript 10 | { 11 | id: 123, 12 | title: 'Homepage' 13 | } 14 | ``` 15 | 16 | Template: 17 | ```html 18 |

@{model.title}

19 | ``` -------------------------------------------------------------------------------- /parser/parser-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ parser: 'xml', begin: '', end: '' }); 38 | FLOWDATA(Buffer.from('ABCD')); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /parser/parser.js: -------------------------------------------------------------------------------- 1 | exports.id = 'parser'; 2 | exports.title = 'Data Parser'; 3 | exports.group = 'Parsers'; 4 | exports.color = '#37BC9B'; 5 | exports.input = true; 6 | exports.output = 1; 7 | exports.version = '1.0.0'; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'code'; 10 | 11 | exports.html = `
12 |
@(Parser type)
13 |
14 |
15 |
16 | 17 |
18 |
19 |
20 |
@(Begin phrase)
21 |
22 |
23 |
@(End phrase)
24 |
25 |
26 |
27 |
28 |
`; 29 | 30 | exports.readme = `# XML/Newline parser (CSV) parser 31 | 32 | - expects \`Buffer\``; 33 | 34 | exports.install = function(instance) { 35 | var streamer; 36 | instance.on('data', response => streamer && streamer(response.data)); 37 | instance.reconfigure = function() { 38 | var options = instance.options; 39 | switch (options.parser) { 40 | case 'beginend': 41 | streamer = U.streamer(options.begin, options.end, (data) => instance.send2(data)); 42 | break; 43 | case 'newline': 44 | streamer = U.streamer('\n', (data) => instance.send2(data)); 45 | break; 46 | default: 47 | streamer = null; 48 | break; 49 | } 50 | }; 51 | instance.on('options', instance.reconfigure); 52 | instance.reconfigure(); 53 | }; -------------------------------------------------------------------------------- /parser/readme.md: -------------------------------------------------------------------------------- 1 | # XML/Newline parser (CSV) parser 2 | 3 | - expects `Buffer` -------------------------------------------------------------------------------- /pass/readme.md: -------------------------------------------------------------------------------- 1 | # Pass 2 | ### Inputs 3 | - first input is for the data 4 | - all other inputs can enable/disable the component so data either pass through or not 5 | - true values => true , 1 or 'on' 6 | - false values => anything that is not one of the above 7 | 8 | ### Outputs 9 | - the data from first input will pass only if the component is enabled 10 | - if the checkbox 'Pass data from all inputs to output?' in Settings form is checked and the component is enabled then the data will be passed to output. -------------------------------------------------------------------------------- /range/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Range 3 | 4 | 5 | -------------------------------------------------------------------------------- /repository/readme.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | This component executes custom JavaScript code as it is and it doesn't contain any secure scope. 4 | 5 | ```javascript 6 | // value {Object} contains received data 7 | // send(outputIndex, newValue) sends a new value 8 | // instance {Object} a current component instance 9 | // flowdata {Object} a current flowdata 10 | // Example: 11 | 12 | // send() can be execute multiple times 13 | send(0, value); 14 | ``` -------------------------------------------------------------------------------- /repository/repository-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ code: 'set(\'name\', \'value\');\nsend()' }); 38 | FLOWDATA('peter'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /repository/repository.js: -------------------------------------------------------------------------------- 1 | exports.id = 'repository'; 2 | exports.title = 'Repository'; 3 | exports.group = 'Common'; 4 | exports.color = '#656D78'; 5 | exports.input = true; 6 | exports.output = 1; 7 | exports.author = 'Peter Širka'; 8 | exports.icon = 'suitcase'; 9 | exports.version = '1.0.0'; 10 | exports.cloning = false; 11 | exports.options = { code: 'set(\'token\', \'123456\');\nsend();' }; 12 | exports.readme = `# Repository 13 | 14 | This component can write/read data from \`FlowData\` message repository or from \`Flow\` instance. 15 | 16 | \`\`\`javascript 17 | // value {Object} contains received data 18 | // flowdata {Object} a current flowdata 19 | 20 | // set(key, value); sets a key/value 21 | // get(key); gets a value according to the key 22 | // set2(key, value); sets a key/value in Flow instance 23 | // get2(key); gets a value according to the key from Flow instance 24 | 25 | // Sends data next 26 | send(); 27 | \`\`\``; 28 | 29 | exports.html = `
30 |
@(Code)
31 |
`; 32 | 33 | exports.install = function(instance) { 34 | 35 | var fn; 36 | 37 | instance.on('data', function(response) { 38 | fn && fn(response.data, instance, response); 39 | }); 40 | 41 | instance.reconfigure = function() { 42 | try { 43 | if (instance.options.code) { 44 | instance.status(''); 45 | var code = `var set = (key, value) => flowdata.set(key, value); 46 | var get = key => flowdata.get(key); 47 | var rem = key => flowdata.rem(key); 48 | var set2 = (key, value) => FLOW.set(key, value); 49 | var get2 = key => FLOW.get(key); 50 | var rem2 = key => FLOW.rem(key); 51 | var send = next = () => instance.send2(flowdata);` + instance.options.code; 52 | fn = new Function('value', 'instance', 'flowdata', code); 53 | } else { 54 | instance.status('Not configured', 'red'); 55 | fn = null; 56 | } 57 | } catch (e) { 58 | fn = null; 59 | instance.error('Repository: ' + e.message); 60 | } 61 | }; 62 | 63 | instance.on('options', instance.reconfigure); 64 | instance.reconfigure(); 65 | }; -------------------------------------------------------------------------------- /restcors/readme.md: -------------------------------------------------------------------------------- 1 | # REST: CORS 2 | 3 | Enables CORS for 3rd party client-side applications. __Our recommendation:__ is to use wildcard for the entire API. -------------------------------------------------------------------------------- /restcors/restcors.js: -------------------------------------------------------------------------------- 1 | exports.id = 'restcors'; 2 | exports.title = 'CORS'; 3 | exports.group = 'REST'; 4 | exports.color = '#6B9CE6'; 5 | exports.input = false; 6 | exports.output = false; 7 | exports.traffic = false; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'globe'; 10 | exports.version = '1.1.0'; 11 | 12 | exports.options = { 13 | methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], 14 | url: '/api/*', 15 | credentials: true 16 | }; 17 | 18 | exports.html = `
19 |
@(URL address)
20 |
@(URL address can contain * as wildcard routing.)
21 |
@(Allowed methods)
22 |
23 |
@(Enable credentials)
24 |
25 | `.format(exports.id); 30 | 31 | exports.readme = `# REST: CORS 32 | 33 | Enables CORS for 3rd party client-side applications. __Our recommendation:__ is to use wildcard for the entire API.`; 34 | 35 | exports.install = function(instance) { 36 | 37 | var old; 38 | 39 | instance.on('close', () => old && UNINSTALL('cors', 'id:' + instance.id)); 40 | instance.reconfigure = function() { 41 | var options = instance.options; 42 | old && UNINSTALL('cors', 'id:' + instance.id); 43 | old = true; 44 | var flags = options.methods.slice(0); 45 | flags.push('id:' + instance.id); 46 | CORS(options.url, flags, options.credentials); 47 | }; 48 | 49 | instance.on('options', instance.reconfigure); 50 | instance.reconfigure(); 51 | }; 52 | -------------------------------------------------------------------------------- /restexecoperation/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Operation 2 | 3 | This component evaluates some registered Total.js operation. 4 | 5 | - first output error 6 | - second output processed data 7 | - third output duration `Number` in seconds -------------------------------------------------------------------------------- /restexecoperation/restexecoperation-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | NEWOPERATION('test', function($) { 37 | $.callback($.value.toUpperCase()); 38 | }); 39 | 40 | ON('flow.ready', function() { 41 | FLOWOPTIONS({ name: 'test' }); 42 | FLOWDATA('peter'); 43 | FLOWCLOSE(); 44 | }); 45 | -------------------------------------------------------------------------------- /restinterpreter/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Interpreter 2 | 3 | The component is input component and it listens on a specific \`channel\`. It registers a global method \`INTERPRET(channel, data)\` and developer needs to execute this method directly in the code. The component can interpret some events or behaviour of Total.js application from code directly. -------------------------------------------------------------------------------- /restinterpreter/restinterpreter-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | NEWOPERATION('test', function($) { 37 | $.callback($.value.toUpperCase()); 38 | }); 39 | 40 | ON('flow.ready', function() { 41 | 42 | FLOWOPTIONS({ channel: 'testchannel'}); 43 | 44 | setTimeout(function() { 45 | INTERPRET('testchannel', { hello: 'world!' }); 46 | }, 1000); 47 | 48 | setTimeout(function() { 49 | FLOWCLOSE(); 50 | }, 2000); 51 | 52 | }); 53 | -------------------------------------------------------------------------------- /restmiddleware/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Middleware 2 | 3 | This component creates user-defined Total.js middleware. 4 | 5 | - output is a duration `Number` in seconds -------------------------------------------------------------------------------- /restoperation/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Operation 2 | 3 | This component creates user-defined Total.js operation. -------------------------------------------------------------------------------- /restoperation/restoperation-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ name: 'test', code: '$.success(100)' }); 38 | setTimeout(function() { 39 | OPERATION('test', function() { 40 | console.log(arguments); 41 | }); 42 | }, 100); 43 | }); 44 | -------------------------------------------------------------------------------- /restproxy/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Proxy 2 | 3 | This component creates a REST proxy between local endpoint and external API. Proxy supports dynamic arguments between URL addresses via \`{key}\` markup (keys must be same). 4 | 5 | __Outputs__: 6 | 7 | - first output contains a __response__ 8 | - second output contains received data 9 | - third output contains a average time of duration `Number` -------------------------------------------------------------------------------- /restresponse/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Response 2 | 3 | This component responds with JSON automatically. Output is the message duration `Number` in seconds. -------------------------------------------------------------------------------- /restresponse/restresponse.js: -------------------------------------------------------------------------------- 1 | exports.id = 'restresponse'; 2 | exports.title = 'Response'; 3 | exports.group = 'REST'; 4 | exports.color = '#B0331B'; 5 | exports.input = 1; 6 | exports.output = ['#666D76']; 7 | exports.author = 'Peter Širka'; 8 | exports.icon = 'globe'; 9 | exports.version = '1.0.0'; 10 | exports.options = {}; 11 | exports.html = ''; 12 | 13 | exports.readme = `# REST: Response 14 | 15 | This component responds with JSON automatically. Output is the message duration \`Number\` in seconds.`; 16 | 17 | exports.install = function(instance) { 18 | 19 | var dursum = 0; 20 | var durcount = 0; 21 | 22 | instance.on('data', function(response) { 23 | if (response.repository.controller) { 24 | var ctrl = response.repository.controller; 25 | ctrl.$flowdata = response; 26 | ctrl.json(response.data); 27 | durcount++; 28 | dursum += ((new Date() - response.begin) / 1000).floor(2); 29 | setTimeout2(instance.id, instance.custom.duration, 500, 10); 30 | } 31 | }); 32 | 33 | instance.on('service', function() { 34 | dursum = 0; 35 | durcount = 0; 36 | }); 37 | 38 | instance.custom.duration = function() { 39 | var avg = (dursum / durcount).floor(2); 40 | instance.status(avg + ' sec.'); 41 | instance.send2(0, avg); 42 | }; 43 | }; -------------------------------------------------------------------------------- /restroute/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Route 2 | 3 | This component creates a REST endpoint/route (Total.js route) for receiving data. It handles errors automatically. 4 | 5 | __Outputs__: 6 | 7 | - first output contains a __response__ 8 | - second output contains received data 9 | - third output contains a average time of duration `Number` -------------------------------------------------------------------------------- /restschema/readme.md: -------------------------------------------------------------------------------- 1 | # REST: Schema 2 | 3 | This component creates user-defined Total.js schema. -------------------------------------------------------------------------------- /scheduler/readme.md: -------------------------------------------------------------------------------- 1 | # Scheduler 2 | 3 | Scheduler will trigger flow at the given time and date. You can optionally define a data-type of the output and the data. 4 | 5 | In Frequency and Start fields following can be used: 6 | - second(s) 7 | - minute(s) 8 | - hour(s) 9 | - day(s) 10 | - month(s) 11 | - year(s) 12 | - week(s) -------------------------------------------------------------------------------- /scheduler/scheduler-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ data: 'Peter je kráľ', datatype: 'string', repeat: '1 day', time: '12:00' }); 38 | }); -------------------------------------------------------------------------------- /schema/readme.md: -------------------------------------------------------------------------------- 1 | # Schema 2 | 3 | Prepares data according to the schema. 4 | 5 | - `green` without error 6 | - `red` with error -------------------------------------------------------------------------------- /schema/schema-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ key: '...', secret: '...', sender: 'Total.js', target: '+421903163302' }); 38 | FLOWDATA('Hello World!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /sms/readme.md: -------------------------------------------------------------------------------- 1 | # SMS sender 2 | 3 | The component has to be configured. Sender uses [NEXMO API provider](https://www.nexmo.com). Raw data will be send as a SMS message. -------------------------------------------------------------------------------- /sms/sms-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ key: '...', secret: '...', sender: 'Total.js', target: '+421903163302' }); 38 | FLOWDATA('Hello World!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /smsgatewaymephoneinfo/readme.md: -------------------------------------------------------------------------------- 1 | # SMSGatewayMe Phone Info 2 | 3 | The component has to be configured. You need the api token and the phone number(id) -------------------------------------------------------------------------------- /smsgatewaymephoneinfo/smsgatewaymephoneinfo-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ }); 38 | FLOWDATA('Hello World!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /smsgatewaymephoneinfo/smsgatewaymephoneinfo.js: -------------------------------------------------------------------------------- 1 | exports.version = '0.0.1'; // the component version 2 | exports.dateupdated = '2019-05-12'; // the version date (format: 'yyyy-MM-dd HH:mm') 3 | exports.id = 'smsgatewaymephoneinfo'; // the component id 4 | exports.title = 'SMS Phone Info'; // the human readable block 5 | exports.color = '#1ba58b'; // the color of the block 6 | exports.input = ['green']; // color of inputs, will be 1 input 7 | exports.output = ['green']; // color of outputs, will have 1 output 8 | exports.group = 'SMSGatewayME'; // The group name 9 | exports.author = 'Thecoolpeople'; // The author 10 | exports.icon = 'commenting-o'; // The visible icon 11 | exports.status = ''; // the status text 12 | exports.npm = []; // npm dependencies 13 | 14 | exports.cloning = false; // Disables data cloning 15 | exports.traffic = false; // hides stats under component box in designer UI 16 | exports.options = {}; // pre defined options 17 | 18 | exports.install = function(component) { 19 | component.on('data', function(response) { 20 | var apikey = component.options.apikey; 21 | var phoneid = component.options.phoneid; 22 | 23 | if(response.index == 0 && apikey && phoneid){ 24 | //request status of phone 25 | var https = require('https'); 26 | var options = { 27 | host: 'smsgateway.me', 28 | port: 443, 29 | path: '/api/v4/device/'+phoneid, 30 | method: 'GET', 31 | headers: { 'Authorization': apikey } 32 | }; 33 | var req = https.request(options, function(res) { 34 | res.on('data', function(d) { 35 | var response = d.toString('utf8'); 36 | component.send2(0, response); 37 | }); 38 | }); 39 | 40 | req.end(); 41 | } 42 | }); 43 | 44 | }; 45 | 46 | exports.html = ` 47 |
48 |
@(ID of the phone)
49 |
@(API Key)
50 |
`; 51 | -------------------------------------------------------------------------------- /smsgatewaymesmssend/readme.md: -------------------------------------------------------------------------------- 1 | # SMSGatewayMe SMS Send 2 | 3 | The component has to be configured. You need the api token and the phone number(id) -------------------------------------------------------------------------------- /smsgatewaymesmssend/smsgatewaymesmssend-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ }); 38 | FLOWDATA('Hello World!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /smsgatewaymesmsstatus/readme.md: -------------------------------------------------------------------------------- 1 | # SMSGatewayMe SMS Status 2 | 3 | The component has to be configured. You need the api token and the phone number(id) -------------------------------------------------------------------------------- /smsgatewaymesmsstatus/smsgatewaymesmsstatus-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ }); 38 | FLOWDATA('Hello World!'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /smsgatewaymesmsstatus/smsgatewaymesmsstatus.js: -------------------------------------------------------------------------------- 1 | exports.version = '0.0.1'; // the component version 2 | exports.dateupdated = '2019-05-12'; // the version date (format: 'yyyy-MM-dd HH:mm') 3 | exports.id = 'smsgatewaymesmstatus'; // the component id 4 | exports.title = 'SMS Status'; // the human readable block 5 | exports.color = '#1ba58b'; // the color of the block 6 | exports.click = true; 7 | exports.input = ['green']; // color of inputs, will be 2 inputs 8 | exports.output = ['green']; // color of outputs, will have 1 output 9 | exports.group = 'SMSGatewayME'; // The group name 10 | exports.author = 'Thecoolpeople'; // The author 11 | exports.icon = 'commenting-o'; // The visible icon 12 | exports.status = ''; // the status text 13 | exports.npm = []; // npm dependencies 14 | 15 | exports.cloning = false; // Disables data cloning 16 | exports.traffic = false; // hides stats under component box in designer UI 17 | exports.options = {}; // pre defined options 18 | 19 | exports.install = function(component) { 20 | component.on('data', function(response) { 21 | var apikey = component.options.apikey; 22 | var phoneid = component.options.phoneid; 23 | 24 | if(response.index == 0 && apikey && phoneid){ 25 | var messageid = response.data; 26 | 27 | //request status of phone 28 | var https = require('https'); 29 | var options = { 30 | host: 'smsgateway.me', 31 | port: 443, 32 | path: '/api/v4/message/'+messageid, 33 | method: 'GET', 34 | headers: { 'Authorization': apikey} 35 | }; 36 | var req = https.request(options, function(res) { 37 | res.on('data', function(d) { 38 | var response = d.toString('utf8'); 39 | component.send2(0, response); 40 | }); 41 | }); 42 | req.end(); 43 | } 44 | }); 45 | }; 46 | 47 | exports.html = ` 48 |
49 |
@(ID of the phone)
50 |
@(API Key)
51 |
`; 52 | -------------------------------------------------------------------------------- /split/readme.md: -------------------------------------------------------------------------------- 1 | # Split 2 | 3 | This component iterates over the received data and sends every item separately. -------------------------------------------------------------------------------- /split/split-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWDATA([1, 2, null, 3, 4]); 38 | FLOWDATA(null); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /split/split.js: -------------------------------------------------------------------------------- 1 | exports.id = 'split'; 2 | exports.title = 'Split'; 3 | exports.group = 'Common'; 4 | exports.version = '1.1.1'; 5 | exports.color = '#656D78'; 6 | exports.input = true; 7 | exports.output = 1; 8 | exports.options = {}; 9 | exports.author = 'Jiří Travěnec'; 10 | exports.icon = 'code-fork'; 11 | exports.readme = `# Split 12 | 13 | This component iterates over the received data and sends every item separately.`; 14 | 15 | exports.install = function(instance) { 16 | instance.on('data', function (response) { 17 | var data = response.data; 18 | if (data instanceof Array) { 19 | for (var i = 0; i < data.length; i++) { 20 | if (data[i] != null) { 21 | var msg = instance.make(data[i], 0); 22 | msg.repository = response.repository; 23 | instance.send2(msg); 24 | } 25 | } 26 | } 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /switch/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Switch 3 | 4 | - set property of the data object to be used in condition 5 | - 6 | 7 | ### Regex 8 | Uses 'test' method e.g. if value is `/he/g` then it will be tested like this `/he/g.test()` which returns true/false 9 | 10 | -------------------------------------------------------------------------------- /switch/switch-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ conditions: [ { operator: 'Regex', datatype: 'String', value: '/L/i'}, { operator: '>', datatype: 'Number', value: 5} ]}); 38 | FLOWDATA('hello'); 39 | FLOWDATA(6); 40 | FLOWCLOSE(); 41 | }); 42 | -------------------------------------------------------------------------------- /template/readme.md: -------------------------------------------------------------------------------- 1 | # Template 2 | 3 | Template can create formatted string. It uses Total.js View engine. Data have to be JavaScript Object. 4 | 5 | - __Response__ is always `String` -------------------------------------------------------------------------------- /template/template-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ template: '@{model.name}' }); 38 | FLOWDATA({ name: 'Hello World!' }); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /template/template.js: -------------------------------------------------------------------------------- 1 | exports.id = 'template'; 2 | exports.title = 'Template'; 3 | exports.group = 'Parsers'; 4 | exports.color = '#37BC9B'; 5 | exports.input = true; 6 | exports.output = 1; 7 | exports.version = '1.0.1'; 8 | exports.author = 'Peter Širka'; 9 | exports.icon = 'code'; 10 | exports.options = { template: '

Hello @{model.firstname}

' }; 11 | 12 | exports.html = `
13 |
@(Template)
14 |
`; 15 | 16 | exports.readme = `# Template 17 | 18 | Template can create formatted string. It uses Total.js View engine. Data have to be JavaScript Object. 19 | 20 | - __Response__ is always \`String\``; 21 | 22 | exports.install = function(instance) { 23 | 24 | var can = false; 25 | 26 | instance.on('data', function(response) { 27 | if (can) { 28 | try { 29 | response.data = F.is4 ? VIEWCOMPILE('@{nocompress all}\n' + instance.options.template, response.data, '', response.parent) : F.viewCompile('@{nocompress all}\n' + instance.options.template, response.data, '', response.parent); 30 | instance.send2(response); 31 | } catch (e) {} 32 | } 33 | }); 34 | 35 | instance.reconfigure = function() { 36 | can = instance.options.template ? true : false; 37 | instance.status(can ? '' : 'Not configured', can ? undefined : 'red'); 38 | }; 39 | 40 | instance.on('options', instance.reconfigure); 41 | instance.reconfigure(); 42 | }; -------------------------------------------------------------------------------- /timer/readme.md: -------------------------------------------------------------------------------- 1 | # Timer 2 | 3 | Timer will trigger flow in the given interval (in milliseconds). You can optionally define a data-type of the output and the data. -------------------------------------------------------------------------------- /timer/timer-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ data: 'Peter je kráľ', datatype: 'string', interval: 1000 }); 38 | setTimeout(function() { 39 | FLOWOPTIONS({ data: '1000', datatype: 'integer', interval: 1000 }); 40 | setTimeout(function() { 41 | FLOWOPTIONS({ data: 'Sun Mar 05 2017 22:02:34 GMT+0100 (CET)', datatype: 'date', interval: 1000 }); 42 | setTimeout(function() { 43 | FLOWOPTIONS({ data: 'MTIzNDU2', datatype: 'buffer', interval: 1000 }); 44 | setTimeout(function() { 45 | FLOWCLOSE(); 46 | }, 2000); 47 | }, 2000); 48 | }, 2000); 49 | }, 2000); 50 | }); -------------------------------------------------------------------------------- /transform/readme.md: -------------------------------------------------------------------------------- 1 | # Data transformation 2 | 3 | This component tries to transform `string` to `object` with except "custom parser". 4 | 5 | __Custom function__: 6 | 7 | ```javascript 8 | // value {Object} contains received data 9 | // next(newValue) returns transformed value (IMPORTANT) 10 | // Example: 11 | 12 | var lines = value.split('\n'); 13 | var obj = {}; 14 | obj.name = lines[0]; 15 | obj.price = lines[1]; 16 | 17 | next(obj); 18 | ``` -------------------------------------------------------------------------------- /transform/transform-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ parser: 'xml' }); 38 | FLOWDATA('A10.00') 39 | FLOWOPTIONS({ parser: 'json' }); 40 | FLOWDATA('{"title":"A","price":10.00}'); 41 | FLOWOPTIONS({ parser: 'custom', fn: 'next(value.toLowerCase())' }); 42 | FLOWDATA('VALUE'); 43 | FLOWCLOSE(); 44 | }); 45 | -------------------------------------------------------------------------------- /trigger/readme.md: -------------------------------------------------------------------------------- 1 | # Trigger 2 | 3 | - Clicking on the component starts the chain 4 | - Settings allows to set a data-type and a value -------------------------------------------------------------------------------- /trigger/trigger-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ datatype: 'integer', data: '1984' }); 38 | FLOWCLICK(); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /triggertoggle/readme.md: -------------------------------------------------------------------------------- 1 | # Toggle Trigger 2 | 3 | - Clicking on the component starts the chain 4 | - Settings allows to set a data-type and a value -------------------------------------------------------------------------------- /triggertoggle/triggertoggle-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ datatypeA: 'integer', dataA: 1, datatypeB: 'integer', dataB: 2 }); 38 | FLOWCLICK(); 39 | FLOWCLICK(); 40 | FLOWCLICK(); 41 | FLOWCLICK(); 42 | FLOWCLOSE(); 43 | }); 44 | -------------------------------------------------------------------------------- /tutorial/readme.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2 | 3 | This component is targeted for learning and testing. Please open source-code: `tutorial.js`. 4 | 5 | - `tutorial.js` is a Flow component 6 | - `tutorial-run.js` simulates Flow and tries to send a message and update configuration 7 | 8 | ## How to run test? 9 | 10 | - open this directory in terminal / command-line `$ cd tutorial` 11 | - then run `$ node tutorial-run.js` 12 | 13 | ## How to add this component to the Flow designer? 14 | 15 | - open Flow designer 16 | - open Components 17 | - drag & drop `tutorial.js` to the form or click on the `Upload component` -------------------------------------------------------------------------------- /tutorial/tutorial-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total4'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data, [index]) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | 38 | // Updates configuration 39 | FLOWOPTIONS({ delay: 1500 }); 40 | 41 | // Simulates click 42 | FLOWCLICK(); 43 | 44 | setTimeout(function() { 45 | 46 | FLOWDATA('Hello Tutorial!', 0); 47 | 48 | }, 1000); 49 | 50 | setTimeout(function() { 51 | // Close the component 52 | FLOWCLOSE(); 53 | }, 5000); 54 | }); 55 | -------------------------------------------------------------------------------- /tutorial/tutorial.js: -------------------------------------------------------------------------------- 1 | exports.id = 'tutorial'; // must be unique and in lower-case 2 | exports.version = '1.0.0'; // version 3 | exports.title = 'Tutorial'; // readable name 4 | exports.group = 'Common'; // optional, a group for the component (you can group multiple components) 5 | exports.color = '#F6BB42'; // optional, color 6 | exports.click = true; // enables a small button on the component in the Flow designer 7 | exports.output = 1; // enables one output 8 | exports.input = 1; // enables one input 9 | exports.author = 'Peter Širka'; // author of the component 10 | exports.icon = 'play'; // font-awesome free icon without (https://fontawesome.com/icons?m=free) 11 | exports.optoins = { delay: 1000 }; // a custom options 12 | 13 | exports.html = `
14 |
Delay
15 |
`; 16 | 17 | exports.readme = `# Tutorial 18 | 19 | This is my first component.`; 20 | 21 | exports.install = function(instance) { 22 | 23 | // instance.options {Object} 24 | // instance.send([output_index], message); 25 | 26 | // '' event is triggered if something sends a message to this component 27 | instance.on('0', function(message) { 28 | 29 | // @message {Message} 30 | 31 | var data = message.data; 32 | 33 | console.log('---> Received data:', data); 34 | 35 | setTimeout(function() { 36 | 37 | // Sends message next to 0 (zero) output 38 | instance.send(0, message); 39 | 40 | }, instance.options.delay); 41 | 42 | }); 43 | 44 | // exports.click = true; {Boolean} shows a small button on the component in the Flow designer 45 | // 'click' event is triggered if the user clicks on the button 46 | instance.on('click', function() { 47 | 48 | // The method below sends a message to 0 (zero) output 49 | instance.send(0, 'Hello world!'); 50 | 51 | }); 52 | 53 | // 'options' event is triggered if someone changes component's options 54 | instance.on('options', function() { 55 | 56 | // instance.options {Object} 57 | 58 | }); 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /twilio/readme.md: -------------------------------------------------------------------------------- 1 | # SMS sender (Twilio) 2 | 3 | The component has to be configured. Sender uses [Twilio API provider](https://www.twilio.com). Raw data will be send as a SMS message. -------------------------------------------------------------------------------- /twilio/twilio-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ key: '...', secret: '...', sender: '... ', target: '...' }); 38 | FLOWDATA('Test Message'); 39 | FLOWCLOSE(); 40 | }); 41 | -------------------------------------------------------------------------------- /uniqueinterval/readme.md: -------------------------------------------------------------------------------- 1 | # Unique in interval 2 | 3 | This component filters unique data according to the unique data `key` (can be string, number or object) for a `interval`. Click on the instance will release an internal cache. -------------------------------------------------------------------------------- /uniqueinterval/uniqueinterval-run.js: -------------------------------------------------------------------------------- 1 | // TEST INTERFACE FOR TOTAL.JS FLOW COMPONENT 2 | require('total.js'); 3 | require('../flow'); 4 | FLOWINIT(require('./' + U.getName(process.argv[1].replace(/-run\.js$/, '')))); 5 | 6 | // `assert` is a global variable 7 | 8 | // ==================== 9 | // GLOBAL METHODS 10 | // ==================== 11 | 12 | // FLOWDATA(data) - sends data to component 13 | // FLOWCLICK() - performs click event 14 | // FLOWSIGNAL([data]) - sends signal to component 15 | // FLOWEMIT(event, [data]) - emits an event 16 | // FLOWOPTIONS(options) - simulates a change of options 17 | // FLOWCLOSE([callback]) - simulates closing 18 | // FLOWTRIGGER(name, [data]) - simulates trigger 19 | // FLOWDEBUG(true/false) - enables internal output from console (default: true) 20 | // FLOWUNINSTALL() - uninstalls component 21 | // FLOWINSTANCE - a component instance 22 | 23 | // ==================== 24 | // EVENTS FOR UNIT-TEST 25 | // ==================== 26 | 27 | // ON('flow.ready') - triggered when the flow system is ready 28 | // ON('flow.data', fn(data)) - triggered when FLOWDATA() is executed 29 | // ON('flow.send', fn(index, data)) - triggered when the component performs `component.send()` 30 | // ON('flow.options', fn(options)) - triggered when FLOWPTIONS() is executed 31 | // ON('flow.signal', fn(index, data)) - triggered when FLOWSIGNAL() is executed 32 | // ON('flow.status', fn(text, style)) - triggered when the component performs `component.status()` 33 | // ON('flow.debug', fn(data, style)) - triggered when the component performs `component.debug()` 34 | // ON('flow.close') - triggered when the component is closed 35 | 36 | ON('flow.ready', function() { 37 | FLOWOPTIONS({ fn: 'next(value.country)', interval: '2 seconds' }); 38 | FLOWDATA({ country: 'SK' }); 39 | FLOWDATA({ country: 'SK' }); 40 | FLOWDATA({ country: 'SK' }); 41 | FLOWDATA({ country: 'SK' }); 42 | 43 | setTimeout(function() { 44 | FLOWDATA({ country: 'SK' }); 45 | }, 5000); 46 | }); 47 | -------------------------------------------------------------------------------- /virtualwirein/readme.md: -------------------------------------------------------------------------------- 1 | # Virtual wire in 2 | 3 | After creating `Virtual wire out` make sure to hit Apply button otherwise it will not appear in setting of this component. 4 | 5 | -------------------------------------------------------------------------------- /virtualwirein/virtualwirein.js: -------------------------------------------------------------------------------- 1 | exports.id = 'virtualwirein'; 2 | exports.title = 'Virtual wire in'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Martin Smola'; 5 | exports.color = '#303E4D'; 6 | exports.icon = 'sign-in'; 7 | exports.input = false; 8 | exports.output = 1; 9 | exports.options = {}; 10 | exports.readme = `# Virtual wire in 11 | 12 | When the wires between the components are mess it's time to use Virtual wire.`; 13 | 14 | exports.html = `
15 |
@(Wire name)
16 |
17 | `; 26 | 27 | exports.install = function(instance) { 28 | 29 | instance.custom.reconfigure = function(){ 30 | if (instance.options.wirename) { 31 | instance.status(instance.options.wirename); 32 | } else 33 | instance.status('Not configured', 'red'); 34 | }; 35 | 36 | ON('virtualwire', function(wirename, flowdata){ 37 | if (instance.options.wirename && instance.options.wirename === wirename) 38 | instance.send(flowdata); 39 | }); 40 | 41 | instance.on('options', instance.custom.reconfigure); 42 | instance.custom.reconfigure(); 43 | }; 44 | -------------------------------------------------------------------------------- /virtualwireout/readme.md: -------------------------------------------------------------------------------- 1 | # Virtual wire out 2 | 3 | When the wires between the components are mess it's time to use Virtual wire. 4 | 5 | After creating new `Virtual wire out` make sure to hit Apply button, otherwise it will not appear in `Virtual wire in`s settings. 6 | -------------------------------------------------------------------------------- /virtualwireout/virtualwireout.js: -------------------------------------------------------------------------------- 1 | exports.id = 'virtualwireout'; 2 | exports.title = 'Virtual wire out'; 3 | exports.version = '1.0.0'; 4 | exports.author = 'Martin Smola'; 5 | exports.color = '#303E4D'; 6 | exports.icon = 'sign-out'; 7 | exports.input = true; 8 | exports.options = {}; 9 | exports.readme = `# Virtual wire out 10 | 11 | When the wires between the components are mess it's time to use Virtual wire.`; 12 | 13 | exports.html = `
14 |
@(Wire name)
15 |
16 | `; 25 | 26 | exports.install = function(instance) { 27 | 28 | instance.custom.reconfigure = function(){ 29 | if (instance.options.wirename) { 30 | instance.status(instance.options.wirename); 31 | } else 32 | instance.status('Not configured', 'red'); 33 | }; 34 | 35 | instance.on('data', function(flowdata) { 36 | EMIT('virtualwire', instance.options.wirename, flowdata); 37 | }); 38 | 39 | instance.on('options', instance.custom.reconfigure); 40 | instance.custom.reconfigure(); 41 | }; 42 | -------------------------------------------------------------------------------- /xlstojson/readme.md: -------------------------------------------------------------------------------- 1 | # XLS to JSON 2 | 3 | This component tries to transform \`Excell spreadsheet\` to \`json\`. 4 | 5 | If there's a buffer property in an incomming data then filename option is ignored. 6 | 7 | ## options 8 | - filename relative to the application root 9 | -------------------------------------------------------------------------------- /xlstojson/xlstojson.js: -------------------------------------------------------------------------------- 1 | exports.id = 'xlstojson'; 2 | exports.title = 'XLS to JSON'; 3 | exports.group = 'Parsers'; 4 | exports.color = '#37BC9B'; 5 | exports.input = true; 6 | exports.output = 1; 7 | exports.version = '1.0.1'; 8 | exports.author = 'Martin Smola'; 9 | exports.icon = 'random'; 10 | exports.options = { }; 11 | exports.npm = ['xlsx']; 12 | 13 | exports.html = `
14 |
15 |
16 |
@(Filename) (@(optional))
17 |
@(Ignored if a 'buffer' property is in the incomming object.)
18 |
19 |
20 |
21 |
22 |
@(Sheet name) (@(optional, default sheet at index 0))
23 |
24 |
25 |
26 |
27 |
@(Range) (@(optional))
28 |
@(Use number to set start row or string like A3:B6.)
29 |
30 |
31 |
`; 32 | 33 | exports.readme = `# XLS to JSON 34 | 35 | This component tries to transform \`Excell spreadsheet\` to \`json\`. If there's a buffer property in an incomming data then filename option is ignored. 36 | 37 | ## Options 38 | 39 | - filename relative to the application root`; 40 | 41 | exports.install = function(instance) { 42 | 43 | const XLSX = require('xlsx'); 44 | const Fs = require('fs'); 45 | 46 | instance.custom.process = function(err, buf) { 47 | 48 | var wb = XLSX.read(buf, {type:'buffer'}); 49 | var ws = wb.Sheets[instance.options.sheetname || wb.SheetNames[0]]; 50 | 51 | var opts = {}; 52 | 53 | var r = instance.options.range; 54 | if (r) 55 | opts.range = isNaN(r) ? r : parseInt(r); 56 | 57 | var arr = XLSX.utils.sheet_to_json(ws, opts); 58 | 59 | instance.send2(arr); 60 | }; 61 | 62 | instance.on('data', function(flowdata) { 63 | 64 | if (flowdata.data && flowdata.data.buffer) { 65 | instance.custom.process(null, flowdata.data.buffer); 66 | } else if (instance.options.filename) { 67 | Fs.readFile(F.path.root(instance.options.filename), instance.custom.process); 68 | } 69 | 70 | }); 71 | }; 72 | --------------------------------------------------------------------------------