@samatawy/rules
    Preparing search index...

    Class ReteGraph

    The ReteGraph class is responsible for providing an efficient way to find rules relevant to a context. It builds a graph similar to a Rete algorithm (with modifications) and uses it to find nodes relevant to context data.

    TODO: Currently expressions are evaluated at every level. The nodes do not use parent nodes as already-calculated values since that would require a complete repition of all expression evaluation logic.

    Index

    Constructors

    Properties

    dataMap: Map<string, DataNode>
    decisionMap: Map<string, DecisionNode>
    independentRules: RuleNode[] = []

    Methods

    • Find a data node in the graph by its key. Data nodes represent top-level facts that rules depend on.

      Parameters

      • expr: Expression

        the expression of the data node to find or create.

      Returns DataNode

      the data node with the given expression.

      an error if the expression is n ot a variable expression.

    • Find a decision node in the graph by its expression. Decision nodes represent expressions that can be evaluated to find related rules.

      Parameters

      • expr: Expression

        the expression of the decision node to find or create.

      Returns DecisionNode

      the decision node with the given expression.

      an error if the expression is a variable or literal expression.

    • Add a rule to the graph based on its expression. The rule is represented as a RuleNode, and it is connected to the nodes representing its required decisions and eventually to top-level data nodes.

      Parameters

      Returns void