All Projects → EdgeVerve → feel

EdgeVerve / feel

Licence: MIT License
Expression Language for creating and executing business rules in decision table based on DMN 1.1 specification for conformance level 3

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to feel

Easy Rules
The simple, stupid rules engine for Java
Stars: ✭ 3,522 (+4534.21%)
Mutual labels:  expression-language, business-rules
activiti-examples
Alfresco Process Services powered by Activiti Examples.
Stars: ✭ 58 (-23.68%)
Mutual labels:  dmn, business-rules
dmn-eval-js
Evaluation of DMN 1.1 decision tables, limited to S-FEEL (Simple Friendly Enough Expression Language)
Stars: ✭ 18 (-76.32%)
Mutual labels:  dmn, feel
powerflows-dmn
Power Flows DMN - Powerful decisions and rules engine
Stars: ✭ 46 (-39.47%)
Mutual labels:  dmn, feel
Rulette
A pragmatic business rule management system
Stars: ✭ 91 (+19.74%)
Mutual labels:  business-rules
latex-utensils
A LaTeX parser and utilities.
Stars: ✭ 33 (-56.58%)
Mutual labels:  pegjs
businessautomation-cop
All examples related to business automation processes such as jbpm, drools, dmn, optaplanner, cloud native kogito(quarkus), quickstart, pipelines, runtimes, etc.
Stars: ✭ 50 (-34.21%)
Mutual labels:  dmn
awesome-camunda
a curated list of awesome Camunda BPM projects, libraries, tools, documentations, forum posts, etc.
Stars: ✭ 93 (+22.37%)
Mutual labels:  dmn
tweakflow
Safe embeddable scripting for the JVM
Stars: ✭ 21 (-72.37%)
Mutual labels:  expression-language
Plastic
This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.
Stars: ✭ 30 (-60.53%)
Mutual labels:  business-rules
corebos
core Business Operating System. An OPEN SOURCE business application that helps small and medium business handle all the day to day tasks.
Stars: ✭ 128 (+68.42%)
Mutual labels:  dmn
peggy
Peggy: Parser generator for JavaScript
Stars: ✭ 444 (+484.21%)
Mutual labels:  pegjs
JitCat
A C++17 library for parsing and executing expressions. Allows easy exposure of variables and functions from C++ through built-in reflection functionality.
Stars: ✭ 16 (-78.95%)
Mutual labels:  expression-language
micronaut-camunda-bpm
Integration between Micronaut and Camunda (Workflow Engine). We configure Camunda with sensible defaults, so that you can get started with minimum configuration: simply add a dependency in your Micronaut project to embed the workflow engine!
Stars: ✭ 73 (-3.95%)
Mutual labels:  dmn
go-el
Expression language(EL) to navigate/manipulate in golang structure data
Stars: ✭ 42 (-44.74%)
Mutual labels:  expression-language
dmn-ui
UI for Dynamic Memory Networks
Stars: ✭ 15 (-80.26%)
Mutual labels:  dmn
tck
Decision Model and Notation Technology Compatibility Kit
Stars: ✭ 43 (-43.42%)
Mutual labels:  dmn
rpgdice
A generic RPG dice roller syntax and library.
Stars: ✭ 24 (-68.42%)
Mutual labels:  pegjs
SandboxJS
Safe eval runtime
Stars: ✭ 18 (-76.32%)
Mutual labels:  expression-language
ruledesigner
Rule Designer is the Eclipse-based development environment for ODM developers.
Stars: ✭ 14 (-81.58%)
Mutual labels:  business-rules

Build Status Coverage Status License: MIT npm

NPM

About

FEEL is an expression language based on DMN specification conformance level 3. Written using PEG.js - JavaScript Parser Generator. FEEL is a very powerful language built with the purpose of defining rules in Business Rule Engines. FEEL also offers an API to implement and execute Decision Table defined in excel (.xlsx)

Getting Started

FEEL is a completely flexible library which can be used with any project to add support for Decision Table. It also comes with a powerful expression language termed FEEL built-in to define a multitude of decision rules.

Installation

Development

# npm install
npm install js-feel --save

Contribution

# clone repo
git clone https://github.com/EdgeVerve/feel.git

# or fork repo

# install dependencies
npm install

# run test cases
npm test

# watch for changes in source and grammar
gulp watch

# generate parser from grammar
gulp generate

# lint source files
npm run lint

# lint-fix source files
npm run lintfix

Usage

Using Decision Table

Decision tables are defined in excel (.xlsx). Please check Sample Rules. Each cell in the body of the decision table has to be a valid FEEL expression. The following make use of FEEL parser to parse and execute expressions and hence the decision logic.

Excel to Decision Table

const { decisionTable } = require('feel')();

const csv = decisionTable.xls_to_csv('./test/StudentFinancialPackageEligibility.xlsx');
const decision_table = decisionTable.csv_to_decision_table(csv[0]);

Execute Decision Table

The Decision Table (decision_table) created in the previous step can be executed using; decisionTable.execute_decision_table

const payload = {"Student GPA" : 3.6,"Student Extra-Curricular Activities Count" : 4,"Student National Honor Society Membership" : "Yes"};
decisionTable.execute_decision_table("StudentFinancialPackageEligibility", decision_table,payload, (results)=> {
    console.log(results)
});

Using FEEL Standalone

const {feel} = require('feel')();

const rule = 'a + b - c';
const context = {
    a: 10,
    b: 20,
    c: 5
};

const parsedGrammar = feel.parse(rule);
parsedGrammar.build(context).then(result => {
    console.log(result);
}).catch(err => console.error(err));

Sample FEEL Expressions

Some valid FEEL expressions (logically categorized):

Arithmetic

  • a + b - c
  • ((a + b)/c - (d + e*2))**f
  • 1-(1+rate/12)**-term
  • (a + b)**-c
  • date("2012-12-25") + date("2012-12-24")
  • time("T13:10:06") - time("T13:10:05")
  • date and time("2012-12-24T23:59:00") + duration("P1Y")

Comparision

  • 5 in (<= 5)
  • 5 in ((5..10])
  • 5 in ([5..10])
  • 5 in (4,5,6)
  • 5 in (<5,>5)
  • (a + 5) >= (7 + g)
  • (a+b) between (c + d) and (e - f)
  • date("2012-12-25") > date("2012-12-24")
  • date and time("2012-12-24T23:59:00") < date and time("2012-12-25T00:00:00")

Conjunction

  • a or b
  • a and b
  • ((a or b) and (b or c)) or (a and d)
  • ((a > b) and (a > c)) and (b > c)
  • ((a + b) > (c - d)) and (a > b)
  • a or b or a > b
  • (x(i, j) = y) and (a > b)
  • (a + b) > (c - d) and (a > b)

For

  • for a in [1,2,3] return a * a
  • for age in [18..40], name in ["george", "mike", "bob"] return status

Function Definition

  • function(age) age < 21
  • function(rate, term, amount) (amount*rate/12)/(1-(1+rate/12)**-term)

If

  • if applicant.maritalStatus in ("M", "S") then "valid" else "not valid"
  • if Pre-Bureau Risk Category = "DECLINE" or Installment Affordable = false or Age < 18 or Monthly Income < 100 then "INELIGIBLE" else "ELIGIBLE"
  • if "Pre-Bureau Risk Category" = "DECLINE" or "Installment Affordable" = false or Age < 18 or "Monthly Income" < 100 then "INELIGIBLE" else "ELIGIBLE"

Quantified

  • some ch in credit history satisfies ch.event = "bankruptcy"

Date Time Semantics

  • time("13:10:05@Etc/UTC").hour
  • time("13:10:05@Etc/UTC").minute
  • time("13:01:05+05:30").second
  • date and time("2012-12-24T23:59:00").year
  • date("2017-06-10").month
  • date("2017-06-10").day
  • duration("P13M").years
  • duration("P1Y11M").months
  • duration("P5DT12H10M").days
  • duration("P5DT12H10M").hours
  • duration("P5DT12H10M").minutes
  • duration("P5DT12H10M25S").seconds

Date Time Conversion and Equality

  • date("2012-12-25") – date("2012-12-24") = duration("P1D")
  • date and time("2012-12-24T23:59:00") + duration("PT1M") = date and time("2012-12-25T00:00:00")
  • time("23:59:00z") + duration("PT2M") = time("00:01:00@Etc/UTC")
  • date and time("2012-12-24T23:59:00") - date and time("2012-12-22T03:45:00") = duration("P2DT20H14M")
  • duration("P2Y2M") = duration("P26M")

Please note: This is not a complete list of FEEL Expressions. Please refer DMN Specification Document for detailed documentation on FEEL grammar.

Sample Rules

Validation.xlsx

PostBureauRiskCategory.xlsx

ElectricityBill.xlsx

Reference

For comprehensive set of documentation on DMN, you can refer to :

DMN Specification Document

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].