@samatawy/rules
    Preparing search index...

    Class RuleRegistry

    RuleRegistry is responsible for storing all rules in the workspace and managing their salience and potential conflicts. It provides methods to add, retrieve, list, and clear rules, as well as to sort them based on their salience. If strict conflict resolution is enabled, it also checks for potential conflicts where multiple rules change the same output key and resolves them by keeping only the rule with the highest salience.

    Index

    Constructors

    Methods

    • Find a rule by its name.

      Parameters

      • name: string

        the name of the rule to find.

      Returns AbstractRule | undefined

      the rule with the given name, or undefined if no such rule exists in the registry.

    • Retrieve all rules that have a specific annotation and optional value.

      Parameters

      • annotation: string

        The annotation to filter rules by.

      • Optionalvalue: unknown

        The optional value of the annotation to match.

      Returns AbstractRule[]

      An array of rules that match the annotation and value.

    • Perform type checking on all rules in the registry using the provided type checker. This method iterates through each rule, checks its types against the type checker, and returns an array of validation results.

      N.B. Disabled rules are skipped during type checking, as they are not intended to be used in rule evaluation and may contain incomplete or invalid definitions.

      Parameters

      • checker: TypeChecker

        The type checker to use for validating rules.

      Returns ValidationResult[]

      An array of validation results for each rule.