multi-layer-dss
A npm package that builds a multi-layered Decision Support System (DSS) for Node.js.
This package makes use of three core clases: Flow, Layer, Rule; written in TypeScript and builded to JS.
- A Flow is the complete system. It contains Layers and a "resolve" function (Coded by the user) receiving all Layers results. Flow.execute receives the Object to pass the Flow.
- A Layer contains related Rules and a "resolve" function (Coded by the user) receiving all Rules of this Layer and the Object. "resolve" should call the "resolve" function of each Rule.
- A Rule contains any number of "conditions" as functions that receive the Object and should return a boolean, a "content" of any type, a number "weigth" useful in its "resolve" function, that also receives the Object.
Installation
npm install multi-layer-dss --save
Usage
Commands
- Run EsLint test:
npm run lint
- Run Mocha test (If builded):
npm run test
- Build JS:
npm run build
- Make use of 'debugFlow.js':
npm run debugFlow
- Make use of 'debugStep.js':
npm run debugStep
Code example
var mldss = ;var flow = mldssFlow;var layer = mldssLayer;var rule = mldssRule;
Step by step
See debugStep.js
'use strict';var index = ;var flow = indexFlow;var layer = indexLayer;var rule = indexRule; let rules = ;rules;rules; let layers = ;layers; let newRule = 1 'Master Skywalker' { return ovalue === 3; };layers0; let { return results0;};let actualFlow = resolveFunc;for let i = 0; i < layerslength; i++ actualFlow; let obj = value: 1 actualFlow;
JSO
See debugFlow.js
'use strict';var index = ;var flow = indexFlow; let layers = { let ret = 'Hello there'; console; for let i = 0; i < rullength; i++ if ruli ret = ruli; return ret; } rules: weigth: 1 content: 'General Kenobi' conditions: { return ovalue === 1; } weigth: 1 content: 'General Grievous' conditions: { return ovalue === 2; } ;let { return results0;}; let actualFlow = resolveFunc layers;let obj = value: 1 actualFlow;