using NodePipeline.Configuration.Abstractions;
using NodePipeline.Configuration.Abstractions.Interfaces;
using NodePipeline.Configuration.Abstractions.Models.Execute;

namespace NodePipeline.Configuration.Yaml.Loader;

public class YamlGraphLoader(IEditorPipelineConfigLoader? editorPipelineConfigLoader = null) : IPipelineConfigLoader
{
    private readonly IEditorPipelineConfigLoader _editorPipelineConfigLoader = editorPipelineConfigLoader
                                                                               ?? new YamlEditorConfigLoader();

    public PipelineConfig Load(Stream stream)
    {
        var editorConfig = _editorPipelineConfigLoader.Load(stream);
        var config = EditorToRuntimePipelineConverter.ToRuntime(editorConfig);
        return config;
    }
}