feat: docs and pipelines (#6)

* feat: docs and pipelines

* fix: temp disable test linux aarch64
This commit is contained in:
Ivan Miletic
2023-04-03 00:10:59 +02:00
committed by GitHub
parent c5c518eeb5
commit e36fcac075
7 changed files with 772 additions and 88 deletions
+53 -53
View File
@@ -1,4 +1,4 @@
name: NodeJS Bindings
name: NodeJS
env:
WORKING_DIRECTORY: bindings/nodejs
DEBUG: 'napi:*'
@@ -281,57 +281,57 @@ jobs:
run: |
yarn lerna link
yarn test
test-linux-aarch64-gnu-binding:
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
needs:
- build
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
strategy:
fail-fast: false
matrix:
node: ['14', '16', '18']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- name: List directory
run: |
ls -la &&
pwd
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-aarch64-unknown-linux-gnu
path: artifacts
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "glibc"
yarn install --immutable --mode=skip-build
- name: Move artifacts
run: yarn artifacts
shell: bash
- name: List folder
run: ls ./
shell: bash
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }}
options: -v ${{ github.workspace }}:/workspace -w /workspace
run: |
ls -la
cd bindings/nodejs
yarn install
yarn link
yarn test
# test-linux-aarch64-gnu-binding:
# name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
# needs:
# - build
# defaults:
# run:
# working-directory: ${{ env.WORKING_DIRECTORY }}
# strategy:
# fail-fast: false
# matrix:
# node: ['14', '16', '18']
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v3
# - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
# - name: List directory
# run: |
# ls -la &&
# pwd
#
# - name: Download artifacts
# uses: actions/download-artifact@v3
# with:
# name: bindings-aarch64-unknown-linux-gnu
# path: artifacts
#
# - name: Install dependencies
# run: |
# yarn config set supportedArchitectures.cpu "arm64"
# yarn config set supportedArchitectures.libc "glibc"
# yarn install --immutable --mode=skip-build
# - name: Move artifacts
# run: yarn artifacts
# shell: bash
#
# - name: List folder
# run: ls ./
# shell: bash
#
# - name: Setup and run tests
# uses: addnab/docker-run-action@v3
# with:
# image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }}
# options: -v ${{ github.workspace }}:/workspace -w /workspace
# run: |
# ls -la
# cd bindings/nodejs
# yarn install
# yarn link
# yarn test
release:
name: Release
@@ -343,7 +343,7 @@ jobs:
- test-linux-x64-gnu-binding
- test-linux-x64-centos-7
# - test-linux-x64-musl-binding
- test-linux-aarch64-gnu-binding
# - test-linux-aarch64-gnu-binding
# - test-linux-arm-gnueabihf-binding
- test-macOS-windows-binding
steps:
+1 -1
View File
@@ -1,4 +1,4 @@
name: Python Bindings
name: Python
env:
WORKING_DIRECTORY: bindings/python
+7 -1
View File
@@ -10,6 +10,12 @@ on:
- master
tags-ignore:
- '**'
paths-ignore:
- 'bindings/**'
- '.github/workflows/python.yaml'
- '.github/workflows/python-version-bump.yaml'
- '.github/workflows/node.yaml'
- '.github/workflows/node-version-bump.yaml'
env:
RUST_BACKTRACE: 1
@@ -85,4 +91,4 @@ jobs:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update stable
- run: cargo fmt --all -- --check
- run: cargo fmt --all -- --check
+69 -25
View File
@@ -2,41 +2,72 @@
## ZEN Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/decisions) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/rules-engine/json-decision-model) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
## Usage
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications. You can find more details on the links:
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications.
It parses JDM from JSON content. It is up to you to obtain the JSON content, e.g. from file system, database or service call.
* [Rust]()
* [NodeJS]()
* [Python]()
If you are looking for a **Decision-as-a-Service** (DaaS) over REST, take a look at [GoRules Cloud](https://gorules.io).
If you are looking for a **Decision-as-a-Service** (DaaS) over REST, take a look at [GoRules Cloud](https://gorules.io/cloud).
// TODO Change API on RUST
### Rust Instalation
```rust
### Rust
```toml
[dependencies]
zen-engine = "1"
zen-engine = "0"
```
### Evaluating Decision
ZEN Engine parses JDM from JSON content. It is up to you to obtain the JSON content, e.g. from file system, database or service call.
// TODO
```rust
let mem_loader = MemoryLoader::default();
use serde_json::json;
use zen_engine::engine::DecisionEngine;
use zen_engine::model::decision::DecisionContent;
mem_loader.add(
"jdm_graph",
serde_json::from_str::<DecisionContent>(include_str!("../test_data/table.json"))
.unwrap(),
);
let graph = DecisionGraph::new(mem_loader);
let result = graph.evaluate("jdm_graph", &json!({ "input": 12 }))).await;
async fn evaluate() {
let decision_content: DecisionContent = serde_json::from_str(include_str!("jdm_graph.json")).unwrap();
let engine = DecisionEngine::default();
let decision = engine.create_decision(decision_content.into());
let result = decision.evaluate(&json!({ "input": 12 })).await;
}
```
### NodeJS
```bash
npm install @gorules/zen-engine
```
```typescript
import { ZenEngine } from "@gorules/zen-engine";
import fs from 'fs/promises';
(async () => {
// Example filesystem content, it is up to you how you obtain content
const content = await fs.readFile('./jdm_graph.json');
const engine = new ZenEngine();
const decision = engine.createDecision(content);
const result = await decision.evaluate({input: 15});
})();
```
For more advanced use cases where you want to load multiple decisions you can use loaders. To learn more please visit [NodeJS Docs](bindings/nodejs)
### Python
```bash
pip install zen-engine
```
```python
import zen
# Example filesystem content, it is up to you how you obtain content
with open("./jdm_graph.json", "r") as f:
content = f.read()
engine = zen.ZenEngine()
decision = engine.create_decision(content)
result = decision.evaluate({"input": 15})
```
For more advanced use cases where you want to load multiple decisions you can use loaders. To learn more please visit [Python Docs](bindings/python)
## JSON Decision Model (JDM)
JDM is a modeling standard for business decisions and business rules and is stored in a JSON format. Decision models are represented by graphs. Graphs are built using nodes and edges. Edges are used to pass the data from one node to another (left-side to right-side).
@@ -45,7 +76,7 @@ You can try [Free Online Editor](https://editor.gorules.io) with built in Simula
<img width="1258" alt="JSON Decision Model" src="https://user-images.githubusercontent.com/60513195/224425568-4a717e34-3d4b-4cc6-b031-8cd35f8ff459.png">
[JSON Example](https://gorules.io)
[JSON Example](test-data/credit-analysis.json)
Input node contains all data sent in the context, and Output node returns the data from the decision. Data flows from the Input Node towards Output Node evaluating all the Nodes in between and passing the data where nodes are connected.
@@ -92,7 +123,7 @@ List shows basic example of the unary tests in the Input Fields:
| | any value, even null/undefined |
| null | the value null or undefined |
Note: For the full list please visit [ZEN Expr docs]().
Note: For the full list please visit [ZEN Expression Language](https://gorules.io/docs/rules-engine/expression-language/).
**Outputs**
@@ -133,6 +164,19 @@ const handler = (input) => {
Decision is a special node whose purpose is for decision model to have an ability to call other/re-usable decision models during an execution.
## Support matrix
Arch | Rust | NodeJS | Python
:------------ |:-------------------|:-------------------| :-------------
linux-x64-gnu | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
linux-arm64-gnu | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
darvin-x64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
darvin-arm64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
win32-x64-msvc | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
We do not support linux-musl for now as we are relying on the GoogleV8 engine to run function blocks as isolates.
## Contribution
Contributions are welcome 🎉.
+164 -4
View File
@@ -1,9 +1,169 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
## ZEN Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/decisions) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
## NodeJS ZEN Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/rules-engine/json-decision-model) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
## Usage
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications. You can find more details on the links:
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications.
It parses JDM from JSON content. It is up to you to obtain the JSON content, e.g. from file system, database or service call.
If you are looking for a **Decision-as-a-Service** (DaaS) over REST, take a look at [GoRules Cloud](https://gorules.io).
### Installation
```bash
npm i @gorules/zen-engine
```
or
```bash
yarn add @gorules/zen-engine
```
### Simple Example
To execute a simple decision you can use the code below.
```typescript
import { ZenEngine } from "@gorules/zen-engine";
import fs from 'fs/promises';
(async () => {
// Example filesystem content, it is up to you how you obtain content
const content = await fs.readFile('./jdm_graph.json');
const engine = new ZenEngine();
const decision = engine.createDecision(content);
const result = await decision.evaluate({input: 15});
})();
```
### Loaders
For more advanced use cases where you want to load multiple decisions and utilise graphs you can build loaders.
```typescript
import { ZenEngine } from "../index";
import fs from 'fs/promises';
import path from 'path';
const dataRoot = path.join(__dirname, 'jdm_directory');
const loader = async (key: string) => fs.readFile(path.join(testDataRoot, key))
(async () => {
const engine = new ZenEngine({
loader
});
const result = await engine.evaluate('jdm_graph1.json', {input: 5});
})();
```
When engine.evaluate is invoked it will call loader and pass a key expecting a content of the JDM decision graph.
In the case above we will assume file `jdm_directory/jdm_graph1.json` exists.
Similar to this example you can also utilise loader to load from different places, for example from REST API, from S3, Database, etc.
## JSON Decision Model (JDM)
JDM is a modeling standard for business decisions and business rules and is stored in a JSON format. Decision models are represented by graphs. Graphs are built using nodes and edges. Edges are used to pass the data from one node to another (left-side to right-side).
You can try [Free Online Editor](https://editor.gorules.io) with built in Simulator.
<img width="1258" alt="JSON Decision Model" src="https://user-images.githubusercontent.com/60513195/224425568-4a717e34-3d4b-4cc6-b031-8cd35f8ff459.png">
[JSON Example](https://github.com/gorules/zen/blob/master/test-data/credit-analysis.json)
Input node contains all data sent in the context, and Output node returns the data from the decision. Data flows from the Input Node towards Output Node evaluating all the Nodes in between and passing the data where nodes are connected.
### Decision Tables
Decision table is a node which allows business users to easily modify and add new rules in an intuitive way using spreadsheet like interface. The structure of decision table is defined by its schema. Schema consists of inputs and outputs.
Decision tables are evaluated row by row from top to bottom, and depending on the hit policy a result is calculated.
**Inputs**
Input fields are commonly (qualified) names for example `cart.total` or `customer.country`.
```json
{
"cart": {
"total": 1000
},
"customer": {
"country": "US"
}
}
```
Inputs are using business-friendly ZEN Expression Language. The language is designed to follow these principles:
* Side-effect free
* Dynamic types
* Simple syntax for broad audiences
List shows basic example of the unary tests in the Input Fields:
| Input entry | Input Expression |
| ---------|-----------|
| "A" | the field equals "A" |
| "A", "B" | the field is either "A" or "B"
| 36 | the numeric value equals 36 |
| < 36 | a value less than 36 |
| > 36 | a value greater than 36 |
| [20..39] | a value between 20 and 39 (inclusive) |
| 20,39 | a value either 20 or 39 |
| <20, >39 | a value either less than 20 or greater than 39|
| true | the boolean value true |
| false | the boolean value false |
| | any value, even null/undefined |
| null | the value null or undefined |
Note: For the full list please visit [ZEN Expression Language](https://gorules.io/docs/rules-engine/expression-language/).
**Outputs**
The result of the decisionTableNode evaluation is:
* an object if the hit policy of the decision table is FIRST and a rule matched. The structure is defined by the output fields. Qualified field names with a dot (.) inside lead to nested objects.
* `null`/`undefined` if no rule matched in FIRST hit policy
* an array of objects if the hit policy of the decision table is COLLECT (one array item for each matching rule) or empty array if no rules match
Example:
<img width="860" alt="Screenshot 2023-03-10 at 22 57 04" src="https://user-images.githubusercontent.com/60513195/224436208-a2266cec-d0c6-42c7-8607-a4071e6a950b.png">
And the result would be:
```json
{
"flatProperty": "A",
"output": {
"nested": {
"property": "B"
},
"property": 36
}
}
```
### Functions
Function nodes are JavaScript lambdas that allow for quick and easy parsing, re-mapping or otherwise modifying the data. Inputs of the node are provided as function's arguments. Functions are executed on top of Google's V8 Engine that is built in into the ZEN Engine.
```js
const handler = (input) => {
return input;
}
```
### Decision
Decision is a special node whose purpose is for decision model to have an ability to call other/re-usable decision models during an execution.
## Support matrix
linux-x64-gnu | linux-arm64-gnu | darvin-x64 | darvin-arm64 | win32-x64-msvc
:------------ |:------------------- |:------------------- |:------------------- |:-------------------
yes | yes | yes | yes | yes
We do not support linux-musl for now as we are relying on the GoogleV8 engine to run function blocks as isolates.
+151 -4
View File
@@ -1,9 +1,156 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
## ZEN Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/decisions) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
## Python ZEN Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the [GoRules JSON Decision Model (JDM)](https://gorules.io/docs/rules-engine/json-decision-model) standard. It is written in **Rust** and provides native bindings for **NodeJS** and **Python**. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
## Usage
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications. You can find more details on the links:
ZEN Engine is built as embeddable BRE for your **Rust**, **NodeJS** or **Python** applications.
It parses JDM from JSON content. It is up to you to obtain the JSON content, e.g. from file system, database or service call.
If you are looking for a **Decision-as-a-Service** (DaaS) over REST, take a look at [GoRules Cloud](https://gorules.io).
### Installation
```bash
pip install zen-engine
```
### Usage
To execute a simple decision you can use the code below.
```python
import zen
# Example filesystem content, it is up to you how you obtain content
with open("./jdm_graph.json", "r") as f:
content = f.read()
engine = zen.ZenEngine()
decision = engine.create_decision(content)
result = decision.evaluate({"input": 15})
```
### Loaders
For more advanced use cases where you want to load multiple decisions and utilise graphs you can build loaders.
```python
import zen
def loader(key):
with open("./jdm_directory/" + key, "r") as f:
return f.read()
engine = zen.ZenEngine({"loader": loader})
result = engine.evaluate("jdm_graph1.json", {"input": 5})
```
When engine.evaluate is invoked it will call loader and pass a key expecting a content of the JDM decision graph.
In the case above we will assume file `jdm_directory/jdm_graph1.json` exists.
Similar to this example you can also utilise loader to load from different places, for example from REST API, from S3, Database, etc.
## JSON Decision Model (JDM)
JDM is a modeling standard for business decisions and business rules and is stored in a JSON format. Decision models are represented by graphs. Graphs are built using nodes and edges. Edges are used to pass the data from one node to another (left-side to right-side).
You can try [Free Online Editor](https://editor.gorules.io) with built in Simulator.
<img width="1258" alt="JSON Decision Model" src="https://user-images.githubusercontent.com/60513195/224425568-4a717e34-3d4b-4cc6-b031-8cd35f8ff459.png">
[JSON Example](https://github.com/gorules/zen/blob/master/test-data/credit-analysis.json)
Input node contains all data sent in the context, and Output node returns the data from the decision. Data flows from the Input Node towards Output Node evaluating all the Nodes in between and passing the data where nodes are connected.
### Decision Tables
Decision table is a node which allows business users to easily modify and add new rules in an intuitive way using spreadsheet like interface. The structure of decision table is defined by its schema. Schema consists of inputs and outputs.
Decision tables are evaluated row by row from top to bottom, and depending on the hit policy a result is calculated.
**Inputs**
Input fields are commonly (qualified) names for example `cart.total` or `customer.country`.
```json
{
"cart": {
"total": 1000
},
"customer": {
"country": "US"
}
}
```
Inputs are using business-friendly ZEN Expression Language. The language is designed to follow these principles:
* Side-effect free
* Dynamic types
* Simple syntax for broad audiences
List shows basic example of the unary tests in the Input Fields:
| Input entry | Input Expression |
| ---------|-----------|
| "A" | the field equals "A" |
| "A", "B" | the field is either "A" or "B"
| 36 | the numeric value equals 36 |
| < 36 | a value less than 36 |
| > 36 | a value greater than 36 |
| [20..39] | a value between 20 and 39 (inclusive) |
| 20,39 | a value either 20 or 39 |
| <20, >39 | a value either less than 20 or greater than 39|
| true | the boolean value true |
| false | the boolean value false |
| | any value, even null/undefined |
| null | the value null or undefined |
Note: For the full list please visit [ZEN Expression Language](https://gorules.io/docs/rules-engine/expression-language/).
**Outputs**
The result of the decisionTableNode evaluation is:
* an object if the hit policy of the decision table is FIRST and a rule matched. The structure is defined by the output fields. Qualified field names with a dot (.) inside lead to nested objects.
* `null`/`undefined` if no rule matched in FIRST hit policy
* an array of objects if the hit policy of the decision table is COLLECT (one array item for each matching rule) or empty array if no rules match
Example:
<img width="860" alt="Screenshot 2023-03-10 at 22 57 04" src="https://user-images.githubusercontent.com/60513195/224436208-a2266cec-d0c6-42c7-8607-a4071e6a950b.png">
And the result would be:
```json
{
"flatProperty": "A",
"output": {
"nested": {
"property": "B"
},
"property": 36
}
}
```
### Functions
Function nodes are JavaScript lambdas that allow for quick and easy parsing, re-mapping or otherwise modifying the data. Inputs of the node are provided as function's arguments. Functions are executed on top of Google's V8 Engine that is built in into the ZEN Engine.
```js
const handler = (input) => {
return input;
}
```
### Decision
Decision is a special node whose purpose is for decision model to have an ability to call other/re-usable decision models during an execution.
## Support matrix
linux-x64-gnu | linux-arm64-gnu | darvin-x64 | darvin-arm64 | win32-x64-msvc
:------------ |:------------------- |:------------------- |:------------------- |:-------------------
yes | yes | yes | yes | yes
We do not support linux-musl for now as we are relying on the GoogleV8 engine to run function blocks as isolates.
+327
View File
@@ -0,0 +1,327 @@
{
"contentType": "application/vnd.gorules.decision",
"content": {
"edges": [
{
"id": "3e749d7f-97d5-45c9-917f-20ae877c3bde",
"type": "edge",
"sourceId": "4e7e6bb9-f128-41e7-8cc5-b9d79670b96a",
"targetId": "abaaa033-5516-440c-b211-35f1d616ad9f"
},
{
"id": "d00252c1-9a54-4599-940c-c9c1c3bb6800",
"type": "edge",
"sourceId": "4e7e6bb9-f128-41e7-8cc5-b9d79670b96a",
"targetId": "46fbad36-4bbe-44ac-833f-d30e0d37d8d7"
},
{
"id": "f5be27b5-4eea-40f4-abce-31081a0caf65",
"type": "edge",
"sourceId": "4e7e6bb9-f128-41e7-8cc5-b9d79670b96a",
"targetId": "d6925cde-b3c9-4b7f-8652-7380dacea6a4"
},
{
"id": "ae341e14-2d25-4941-a42f-eb587c17f9f5",
"type": "edge",
"sourceId": "abaaa033-5516-440c-b211-35f1d616ad9f",
"targetId": "95aa8f3c-f371-4e48-beb3-0b5775d2a814"
},
{
"id": "3000e420-4846-4f86-8ed2-f595d204672e",
"type": "edge",
"sourceId": "46fbad36-4bbe-44ac-833f-d30e0d37d8d7",
"targetId": "95aa8f3c-f371-4e48-beb3-0b5775d2a814"
},
{
"id": "638c35a9-eef7-4d90-bf1e-58ba10734d98",
"type": "edge",
"sourceId": "d6925cde-b3c9-4b7f-8652-7380dacea6a4",
"targetId": "95aa8f3c-f371-4e48-beb3-0b5775d2a814"
},
{
"id": "30f2247a-140c-40f3-8160-a4e61d56da8e",
"type": "edge",
"sourceId": "af6cdac4-2019-4a0f-9715-2ecfb27e0bfc",
"targetId": "86ce04c9-b4dd-4513-ae2b-7f585ceb224a"
},
{
"id": "822d2eeb-5a9e-4670-b181-4af0ed6dd9b9",
"type": "edge",
"sourceId": "86ce04c9-b4dd-4513-ae2b-7f585ceb224a",
"targetId": "95aa8f3c-f371-4e48-beb3-0b5775d2a814"
},
{
"id": "61cc8c10-57c2-411d-a88c-90176ebb8593",
"type": "edge",
"sourceId": "d6925cde-b3c9-4b7f-8652-7380dacea6a4",
"targetId": "af6cdac4-2019-4a0f-9715-2ecfb27e0bfc"
},
{
"id": "2011fc65-fd8c-421f-8123-d1fb5f1accb3",
"type": "edge",
"sourceId": "46fbad36-4bbe-44ac-833f-d30e0d37d8d7",
"targetId": "af6cdac4-2019-4a0f-9715-2ecfb27e0bfc"
},
{
"id": "d65fb53d-0fef-47ff-aeac-b8cbac5af7be",
"type": "edge",
"sourceId": "abaaa033-5516-440c-b211-35f1d616ad9f",
"targetId": "af6cdac4-2019-4a0f-9715-2ecfb27e0bfc"
}
],
"nodes": [
{
"id": "4e7e6bb9-f128-41e7-8cc5-b9d79670b96a",
"name": "Request",
"type": "inputNode",
"position": {
"x": 70,
"y": 160
}
},
{
"id": "d6925cde-b3c9-4b7f-8652-7380dacea6a4",
"name": "Company Type",
"type": "decisionTableNode",
"content": {
"rules": [
{
"_id": "D8T0xuyYLC",
"Yi49Ln4-V_": "\"green\"",
"nd30YgUKve": "\"INC\",\"LTD\",\"LLC\""
},
{
"_id": "Ewgtm_21qr",
"Yi49Ln4-V_": "\"amber\"",
"nd30YgUKve": ""
}
],
"inputs": [
{
"id": "nd30YgUKve",
"name": "Company Type",
"type": "expression",
"field": "company.type"
}
],
"outputs": [
{
"id": "Yi49Ln4-V_",
"name": "Flag CompanyType",
"type": "expression",
"field": "flag.companyType"
}
],
"hitPolicy": "first"
},
"position": {
"x": 380,
"y": 270
}
},
{
"id": "46fbad36-4bbe-44ac-833f-d30e0d37d8d7",
"name": "Turnover",
"type": "decisionTableNode",
"content": {
"rules": [
{
"_id": "fJxWqBVUNk",
"6xj5CMIFv9": "> 1_000_000",
"rrW6s3l7vU": "\"green\""
},
{
"_id": "lqBoqkvWHA",
"6xj5CMIFv9": "[200_000..1_000_000]",
"rrW6s3l7vU": "\"amber\""
},
{
"_id": "YO3K4Q1iuU",
"6xj5CMIFv9": "< 200_000",
"rrW6s3l7vU": "\"red\""
},
{
"_id": "SY7uwJEPqS",
"6xj5CMIFv9": "",
"rrW6s3l7vU": "\"red\""
}
],
"inputs": [
{
"id": "6xj5CMIFv9",
"name": "Turnover (LY)",
"type": "expression",
"field": "company.turnover"
}
],
"outputs": [
{
"id": "rrW6s3l7vU",
"name": "Flag Turnover",
"type": "expression",
"field": "flag.turnover"
}
],
"hitPolicy": "first"
},
"position": {
"x": 380,
"y": 160
}
},
{
"id": "abaaa033-5516-440c-b211-35f1d616ad9f",
"name": "Country",
"type": "decisionTableNode",
"content": {
"rules": [
{
"_id": "TOi2qECISd",
"I493u7jDPg": "\"green\"",
"bGOSakKon0": "",
"z87lDk-Xar": "\"US\",\"IE\",\"GB\",\"CA\""
},
{
"_id": "aGPqCdh2tU",
"I493u7jDPg": "\"amber\"",
"bGOSakKon0": "true",
"z87lDk-Xar": ""
},
{
"_id": "VYiuLkrLWb",
"I493u7jDPg": "\"red\"",
"bGOSakKon0": "",
"z87lDk-Xar": ""
}
],
"inputs": [
{
"id": "z87lDk-Xar",
"name": "Company Country",
"type": "expression",
"field": "company.country"
},
{
"id": "bGOSakKon0",
"name": "Company IsEU",
"type": "expression",
"field": "company.isEu"
}
],
"outputs": [
{
"id": "I493u7jDPg",
"name": "Flag Country",
"type": "expression",
"field": "flag.country"
}
],
"hitPolicy": "first"
},
"position": {
"x": 380,
"y": 50
}
},
{
"id": "af6cdac4-2019-4a0f-9715-2ecfb27e0bfc",
"name": "Overall Mapper",
"type": "functionNode",
"content": "/**\n* @param {import('gorules').Input} input\n* @param {{\n* moment: import('dayjs')\n* env: Record<string, any>\n* }} helpers\n*/\nconst handler = (input, { moment, env }) => {\n const count = (flag) => Object.values(input?.flag || {}).reduce((acc, curr) => {\n if (curr === flag) return acc + 1;\n return acc;\n }, 0);\n\n return {\n critical: count('critical'),\n red: count('red'),\n amber: count('amber'),\n green: count('green')\n };\n}",
"position": {
"x": 630,
"y": 270
}
},
{
"id": "86ce04c9-b4dd-4513-ae2b-7f585ceb224a",
"name": "Overall",
"type": "decisionTableNode",
"content": {
"rules": [
{
"_id": "P0RQ3NFWfc",
"AczIUwvClr": "",
"KsBwLhAedP": "> 0",
"QJttqyV2FB": "",
"ek5q9WgLL9": "\"red\"",
"iFQl1CKB5S": ""
},
{
"_id": "UGrT2iHE61",
"AczIUwvClr": "> 0",
"KsBwLhAedP": "",
"QJttqyV2FB": "",
"ek5q9WgLL9": "\"red\"",
"iFQl1CKB5S": ""
},
{
"_id": "SBBO_aWujh",
"AczIUwvClr": "",
"KsBwLhAedP": "",
"QJttqyV2FB": "> 1",
"ek5q9WgLL9": "\"amber\"",
"iFQl1CKB5S": ""
},
{
"_id": "N2jO9BnXHY",
"AczIUwvClr": "",
"KsBwLhAedP": "",
"QJttqyV2FB": "",
"ek5q9WgLL9": "\"green\"",
"iFQl1CKB5S": ""
}
],
"inputs": [
{
"id": "AczIUwvClr",
"name": "Red",
"type": "expression",
"field": "red"
},
{
"id": "QJttqyV2FB",
"name": "Amber",
"type": "expression",
"field": "amber"
},
{
"id": "iFQl1CKB5S",
"name": "Green",
"type": "expression",
"field": "green"
},
{
"id": "KsBwLhAedP",
"name": "Critical",
"type": "expression",
"field": "critical"
}
],
"outputs": [
{
"id": "ek5q9WgLL9",
"name": "Overall",
"type": "expression",
"field": "overall"
}
],
"hitPolicy": "first"
},
"position": {
"x": 880,
"y": 270
}
},
{
"id": "95aa8f3c-f371-4e48-beb3-0b5775d2a814",
"name": "Response",
"type": "outputNode",
"position": {
"x": 1120,
"y": 160
}
}
]
}
}