// ActionExecutor.js

import { Runtime } from './runtime.js';

export class ActionExecutor {

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

        for (const action of actions) {

            switch (action.action_type) {

                case 'set_field':

                    data[action.target_field] =
                        action.action_value;

                    break;

                case 'notify':

                    Runtime.bus.emit(
                        'notification',
                        {
                            target: action.target_field,
                            message: action.action_value
                        }
                    );

                    break;
            }
        }

        return data;
    }
}
