Skip to content

Commit ee2d5f2

Browse files
committed
Documentations added
1 parent ffac874 commit ee2d5f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+483
-4
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
1-
# json-rule-editor
2-
Json based decision editor
1+
## json-rule-editor
2+
3+
### Getting Started
4+
5+
Json rule editor is an unornamented web interface tool to manage your business rules and decision outcomes. A single page application to effortlesly upload / create business rules via json files. Since the lightweight libraries are the new normal in web applications, possessing logics in json file will be a effective way to manage the application code. Having said that redudancy can be detoured by discarding the other business rule file format such as xml or excel, which is often hectic to parse and adding complications to developer.
6+
7+
Process to implement json rule file in your application follows
8+
9+
- Generate rule file using json rule editor
10+
- Place the generated file in your application folder,
11+
- and pass the relative path of file and input parameters into json rules engine to get the output.
12+
13+
Facinating feature it implies is, we can validate the business decisions instantly once after rules are added. Thus, ensuring expected outcome is returned from the rule sheet before generates the file. Consequently it eliminates issues at first place when rules are being created instead of identifing at later stage of development or testing.
14+
15+
### Usage:
16+
17+
To launch the json rule editor tool, you can do either of the below
18+
1. Click [json rule editor](https://www.json-rule-editor.com)
19+
2. or install it locally via npm `npm install json-rule-editor`
20+
21+
The detailed steps to create json rule file using this tool in [next section](https://vinzdeveloper.github.io/json-rule-editor/docs/create-rules.html).
22+
23+
### Thanks to json-rules-engine:
24+
25+
In principle, json rules engine is an integral backbone library should be added into your application to process the business rules created from this rule editor. It is highly recommended to go through the json rules engine concepts and explore the features it offers.
26+
27+
Install json rules engine in your application using the steps mentioned in the [npm](https://www.npmjs.com/package/json-rules-engine)
28+
29+
This documentation explains the steps to create / manage rules in json rule editor tool.
30+
31+
This documentation covers,
32+
33+
1. [Why Rule Engine?](https://vinzdeveloper.github.io/json-rule-editor/docs/rule-engine.html)
34+
2. [Create Business Decisions using Json Rule Editor](https://vinzdeveloper.github.io/json-rule-editor/docs/create-rules.html)
35+
3. [Implementation of rules in application](https://vinzdeveloper.github.io/json-rule-editor/docs/implementation.html)
36+
4. [Manage existing rule](https://vinzdeveloper.github.io/json-rule-editor/docs/manage-rules.html)
37+
5. [More examples in Decisions](https://vinzdeveloper.github.io/json-rule-editor/docs/decisions.html)
38+
6. [Advanced examples](https://vinzdeveloper.github.io/json-rule-editor/docs/advanced.html)
39+
40+

docs/advanced.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## json-rule-editor
2+
3+
### Advanced concepts of json-rules-engine
4+
5+
json rules engine provides other feature to load the input fact value aynchronously from remote system via api.
6+
Go through the advance concepts explained in detail [here](https://github.com/CacheControl/json-rules-engine) to understand better.
7+
8+
We will take the same example *"Employee-Salary"* to handle path parameter. Lets assume, `designation`, `experience` and `type` fact values are coming via api.
9+
10+
Step by Step process explained below to add path parameter along with facts in decisions
11+
12+
***Step1: Add object reference***
13+
14+
1. Go to Facts tab
15+
2. Click **Add icon** at right corner of tool bar.
16+
3. Specify the fact object name and select **object** as type
17+
4. Click **Add facts** button
18+
19+
![create path fact](https://vinzdeveloper.github.io/json-rule-editor/docs/images/path-fact.png)
20+
21+
***Step2: Add path parameter reference***
22+
23+
1. Go to Decisions tab
24+
2. Click **Add icon** at right corner of tool bar.
25+
3. Select all / any in **"Step 1: Add Toplevel"**
26+
4. Select Add facts menu in **"Step 2: Add / Remove facts"**
27+
5. Select **Add path** icon at top right corner of panel.
28+
6. Give fact object name, operator, value along with path parameter as below
29+
30+
![create path decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/path-decisions1.png)
31+
32+
7. Add other facts with path parameter
33+
34+
![create path decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/path-decisions2.png)
35+
36+
8. Click **Add Rulecase** button
37+
38+
***Caution***
39+
40+
> You can’t validate such path parameter decisions in our rule editor though, because these values are coming from real time api,
41+
> so its not possible to retrieve and validate such decisions in this tool.
42+
43+
### Add more parameters in output
44+
45+
Sometimes, it would make sense to add more values along with output value. In order to add extra values, you can click ***‘Add Params’*** icon in output panel. You can add any number of key value pairs along with the output type.
46+
47+
![create path decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/output-params.png)
48+
49+
Feel free to raise issues or concerns in [github](https://github.com/vinzdeveloper/json-rule-editor/issues) or contact here <vinzdeveloper@gmail.com>. Happy to look into your concerns!!
50+
51+
[Go back to previous page](https://vinzdeveloper.github.io/json-rule-editor/docs/decisions.html)
52+
53+
[Go Home](https://vinzdeveloper.github.io/json-rule-editor/)

docs/create-rules.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
## json-rule-editor
2+
3+
### Create Decisions
4+
5+
Primarily, we are going to deal with two factors 1) Facts and 2) Decisions across this tool.
6+
7+
***Facts***
8+
9+
Its an entity or attribute helps to build your business decisions. It supports four data types such as number, string, array and object - inline with json rules engine.
10+
11+
***Decisions***
12+
13+
It is actually business rule conditions which contains the possible facts values and associated outcome type. Here you can define any number of business decision outcomes under single rule.
14+
15+
*Note:*
16+
17+
> Its good practise to separate your business rules into different ruleset files based on the use cases.
18+
19+
Lets see the step by step process starting from creating facts to generating the ruleset file.
20+
21+
***Step1: Create new ruleset file***
22+
23+
1. Launch [json rule editor](www.json-rule-editor.com) or install locally via npm
24+
2. Click **Create button** (Note: Upload functioanlity is explained in next section)
25+
26+
![create new rule](https://vinzdeveloper.github.io/json-rule-editor/docs/images/create-upload.png)
27+
28+
***Step2: Specify rule name***
29+
30+
1. Specify rule name and click **Create button**
31+
32+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/create.png)
33+
34+
***Step3: Add new fact***
35+
36+
1. Click **Create Facts** button at information message panel
37+
38+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/facts1.png)
39+
40+
2. Give fact name and data type such as string, number or array
41+
42+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/facts2.png)
43+
44+
3. Add as many as fact you need to build your decisions
45+
46+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/fact3.png)
47+
48+
49+
***Step4: Add new decisions***
50+
51+
Go to Decisions tab
52+
53+
1. Click **Create Decisions** button at information message panel
54+
55+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision1.png)
56+
57+
2. Select all / any in **"Step 1: Add Toplevel"**
58+
59+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision2.png)
60+
61+
3. Select Add facts menu in **"Step 2: Add / Remove facts"**
62+
63+
4. Select the fact, operator and value
64+
65+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision3.png)
66+
67+
5. Add necessary facts and you will see something as below
68+
69+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision4.png)
70+
71+
6. Select the Add Outcome in **"Step 3: Add outcome""** and specify the type value.
72+
73+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision5.png)
74+
75+
7. Click **Add Rulecase** button.
76+
77+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/decision6.png)
78+
79+
***Step5: Validate decisions***
80+
81+
Go to Validate tab
82+
83+
1. Specify the values against facts
84+
2. Click Validate Ruleset button
85+
86+
87+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/validate.png)
88+
89+
*Note: Please keep in mind when adding facts and value*
90+
> Incase expected values are not getting displayed, go to Decisions tab and cross check the values.
91+
> Values are case sensitive and perform strict equality comparison ( === ).
92+
93+
94+
***Step5: Generate rule sheet***
95+
96+
Go to Generate tab
97+
98+
1. Click generate button if all required decisions are added.
99+
100+
![rule name](https://vinzdeveloper.github.io/json-rule-editor/docs/images/generate.png)
101+
102+
*Note:*
103+
104+
> Json rule file will be generated at your default browser download folder.
105+
106+
107+
108+
109+
[Next section - Implementation of Json rules in application](https://vinzdeveloper.github.io/json-rule-editor/docs/implementation.html)
110+
111+
[Go back to previous page](https://vinzdeveloper.github.io/json-rule-editor/docs/rule-engine.html)
112+
113+
[Go Home](https://vinzdeveloper.github.io/json-rule-editor/)

docs/decisions.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## json-rule-editor
2+
3+
### More examples in Decisions
4+
5+
We have seen simple rule structure example before which has just one top node *"all"*. However, Json rules engine offers many features which will be really useful to manage business decisions effectively.
6+
7+
***Nested ‘all’ or ‘any’***
8+
9+
You can configure the decisions with nested all or any combination as mentioned below
10+
11+
We will use the same rule file Employee-Salary created before for this section.
12+
13+
Previously, we have configured facts such as designation, type and experience to derive *salary* for just one designation **Manager** for simplicity. However, in real time, we might have other designation roles and facts to consider. Lets see a example below to understand much better
14+
15+
For ex:
16+
17+
We get new requirement to add *"Architect"* role with the same salary as *"Manager"* role. To handle this scenario, we can do either of the below
18+
19+
1. Create a new decision with same salary.
20+
21+
![create new decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions1.png)
22+
23+
2. Or You can modify the existing decision by nesting with **any** condition as below
24+
25+
![create another decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions2.png)
26+
27+
28+
First solution is same as we discussed before. Please refer [previous section](https://vinzdeveloper.github.io/json-rule-editor/docs/create-rules.html) incase any queries,
29+
30+
Lets explore the second solution to understand how nested conditions can be created.
31+
32+
*Step 1: Add new decision with two facts experience and type*
33+
34+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions3.png)
35+
36+
*Step 2: Select "Add Any" menu in **"Step 2: Add / Remove facts"** - you will get something as below*
37+
38+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions4.png)
39+
40+
*Step 3: Click "any" node as highlighted below to add facts under this node*
41+
42+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions5.png)
43+
44+
*Step 4: Select "Add Facts" menu in **"Step 2: Add / Remove facts"** and click Add button*
45+
46+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions6.png)
47+
48+
**After added:**
49+
50+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions7.png)
51+
52+
*Step 5: Select "Add Facts" menu in **"Step 2: Add / Remove facts"** and click Add button to add another role "Architect"*
53+
54+
![create nested decision](https://vinzdeveloper.github.io/json-rule-editor/docs/images/more-decisions8.png)
55+
56+
*Step 6: Select "Add outcome" menu in **"Step 3: Add outcome"** and give value*
57+
58+
*Step 7: Click Add rulecase button*
59+
60+
That's it!!!
61+
62+
Likewise, you can add any number of nested nodes under single conditions. Both solution 1 and solution 2 are doing same thing, depends on business requirement and number of facts, decide the pattern whichver it suits better.
63+
64+
[Next section - Advanced examples](https://vinzdeveloper.github.io/json-rule-editor/docs/advanced.html)
65+
66+
[Go back to previous page](https://vinzdeveloper.github.io/json-rule-editor/docs/manage-rules.html)
67+
68+
[Go Home](https://vinzdeveloper.github.io/json-rule-editor/)
69+
70+
71+

docs/images/create-upload.png

67.7 KB
Loading

docs/images/create.png

59.7 KB
Loading

docs/images/decision1.png

74.4 KB
Loading

docs/images/decision2.png

132 KB
Loading

docs/images/decision3.png

192 KB
Loading

docs/images/decision4.png

149 KB
Loading

0 commit comments

Comments
 (0)