using System;
using System.Collections.Generic;
using NodePipeline.Abstractions.Interfaces;
using NodePipeline.Abstractions.Interfaces.Nodes;
using NodePipeline.Configuration.Abstractions.Models.Execute;
using NodePipeline.Engine.Abstractions.Validation;

namespace NodePipeline.Engine.Abstractions;

public interface INodeFactory
{
    IPipelineLocalizationProvider PipelineLocalizationProvider { get; set; }
    Dictionary<string, Func<INode>> NodeFactories { get; set; }
    INode CreateNode(string pipelineId, NodeConfig config);
    IEnumerable<string> GetParameterCodes(string nodeType);

    /// <summary>
    ///     Fetch all node ports
    /// </summary>
    /// <param name="pipelineId">Current pipeline Id</param>
    /// <param name="nodeTypes">Node types</param>
    /// <param name="nodeList">Node ids by node type</param>
    /// <returns></returns>
    Dictionary<NodePortKey, NodePortInfo> GetAllPorts(string pipelineId, HashSet<string> nodeTypes,
        Dictionary<string, IEnumerable<string>> nodeList);

    IEnumerable<NodePortInfo> GetNodeInputPorts(string pipelineId, string nodeType, string nodeId);

    object? ReadParameterValue(string pipelineId, string nodeId, string nodeType, string parameterName,
        string valueString);

    object? GetParameterDefaultValue(string nodeType, string parameterName);

    void SetNodeParametersValues<TNode>(string pipelineId, TNode node, string nodeId,
        Dictionary<string, object?> parameters) where TNode : INode;

    void ConnectPorts<TNode>(string pipelineId, TNode node, string nodeId, Dictionary<string, InputSource> inputs,
        IReadOnlyDictionary<string, INode> createdNodes) where TNode : INode;
}