// RuleEngine.js

import { ConditionEvaluator }
    from './ConditionEvaluator.js';

import { ActionExecutor }
    from './ActionExecutor.js';

export class RuleEngine {

    static async execute(rules = [], data = {}) {

        for (const rule of rules) {

            const matched =
                ConditionEvaluator.check(
                    rule.conditions,
                    data
                );

            if (!matched) {

                continue;
            }

            await ActionExecutor.execute(
                rule.actions,
                data
            );
        }
    }
}
