Export your spreadsheet as a CSV file. The rules for formatting the csv are the same as they are for the csvtojson library. That's what Trool uses internally to convert the csv to a JSON object.

You must follow the format closely for setting up a decision-table. Trool may throw errors if you do not set things up correctly. The guide contains all the details for setting up a decision-table. You can look at the screen-shot above if you want a quick glimpse on what decision-tables look like.

A Fact is an instance-object or array of instance-objects, which you want to update based on conditions that may change over time. Create at least one decision-table on the spreadsheet so you can update a fact.

The facts and the imports must be wrapped in holder objects, with the key being the name of the fact/import to use in the spreadsheet and the value being the actual fact or import. The imports param is optional because you may only want to use ones specified in the spreadsheet or have no need for any.

init() has two optional params showLogs and imports . If you want access to the decision-tables for some reason after init() is called, there is the decisionTables getter on the trool instance.

To use Trool you must call two methods init() and applyRules() . The first one takes in your facts array and the path to the CSV file. init() is asynchronous so make sure to use async/await with it. applyRules() returns the update facts and must be called after init() .

Important! When you setup your decision-tables and imports there are some rules to follow the in order for your tables/imports to be properly loaded into memory. Strict formatting is enforced for readability purposes.

Decision-Tables:

All decision-tables must start with a cell containing the text Table: "Fact Name" . A table without a fact name or with a fact name that does not exist on the facts-holder will throw an error. If you create 2 tables that have the same fact-name, the second table will overwrite all the changes from the first.

A table will end when it reaches an empty row, the end of the file, or the start of a new table or import. For readability, you should terminate all tables with an empty row.

The first 2 rows on a decision-table are for specifying the conditions and the actions. If all conditions are true, then the actions will execute. After the start cell (the cell with Table: "Fact Name" ) you must specify at least 1 condition and 1 action.

Specifying Condition and Action columns must be done by putting 'Condition' or 'Action' , at the top of each column. These are case sensitive so make sure to capitalize the values. All conditions must come before all actions and you cannot have anything other than 'Condition' or 'Action' at the top of your table columns.

The condition must be a statement which evaluates to true or false . The left side of the statement must be a method or getter on the fact's instance-object and the right side must be $param . The operator must be an existing JavaScript comparator such as == or <= . The values in the rows below will replace $param . For example, suppose I want to get the age of a visitor for an app which calculates ticket prices. I would need to create a TypeScript getter ( get age(): number {} ) or a method like getAge() {} to fetch the visitor's age and compare it to the parameter value.

Actions are methods on a fact which will execute if all the conditions evaluate to true. Unlike conditions, you can have multiple params passed in. The action must be a method or a TypeScript setter function on the fact or else Trool will throw an error. The number of params in the action columns' cells below must match the number or $param strings or else Trool will throw an error.

All rows on a decision-table, except for the first 2, are referred to as rules. A rule works by evaluating a list of conditions against cell values which, if they all evaluate to true, will execute the specified actions. A rule must start with a rule name and can be anything but cannot be blank.

For each cell on the rule, if it is a condition column, the cell value will replace the $param value and evaluate the cell as true or false . An empty cell will automatically be evaluated as true . If any cell evaluates to false , that rule will fail and the decision-table will go on the next rule.

While on a rule's action column, each param specified must be separated by a comma. If no params are specified (the cell is blank), the rule will skip that action column.