@samatawy/rules
    Preparing search index...

    Class GeneralFileReader

    Reader class for parsing general files that can contain constants, types, rules, and functions to be used within the rule engine. You should use this class to read content from a text file or stream, where each line (or block) defines a constant, type, rule, or function. The reader will parse the file content and return an object containing the successfully parsed elements as well as any errors encountered during parsing. The reader supports both line-by-line and block-by-block reading, allowing for flexible formatting of the file. It also includes error handling for invalid syntax and duplicate keys, ensuring that the resulting objects are valid and usable within the rule engine.

    N.B. Declarations do not need to be in order, although that is still recommended.

    N.B. This is a transactional safe reader. If you provide a workspace and select the option accept: 'all', then that workplace will not be affected if any errors are encountered.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    options: Partial<GeneralFileReaderOptions>
    ruleParser: RuleParser
    functionParser: FunctionParser
    typeParser: TypeParser
    workspace: Workspace

    The workspace instance to which the parsed rules, functions, types, and constants will be added. This allows for components to recognize earlier declared components.

    blocks: string[]

    Methods

    • Parse the content of a functions file and return the result, including the successfully parsed components and any errors encountered during parsing. A general file can read types, constants, rules, and functions.

      Parameters

      • fileContent: string

        The content of the file to parse.

      Returns GeneralReaderResult

      The result of parsing, including the successfully parsed constants, functions, types, rules, and any errors encountered.