using ScadaLink.Commons.Types;

namespace ScadaLink.CentralUI.ScriptAnalysis;

/// <summary>
/// Globals type seen by inbound API method scripts during analysis. Mirrors
/// the surface the runtime exposes (see ScadaLink.InboundAPI.InboundScriptContext
/// and RouteHelper). The methods here are never invoked — Roslyn only reads
/// their signatures to type-check API method scripts and offer completions.
/// </summary>
public class InboundScriptHost
{
    public ScriptParameters Parameters { get; init; } = new();

    public RouteHelper Route { get; } = new();

    public System.Threading.CancellationToken CancellationToken { get; }

    /// <summary>Editor mirror of ScadaLink.InboundAPI.RouteHelper.</summary>
    public class RouteHelper
    {
        public RouteTarget To(string instanceCode) => new();
    }

    /// <summary>Editor mirror of ScadaLink.InboundAPI.RouteTarget.</summary>
    public class RouteTarget
    {
        public System.Threading.Tasks.Task<object?> Call(
            string scriptName,
            object? parameters = null,
            System.Threading.CancellationToken cancellationToken = default) =>
            System.Threading.Tasks.Task.FromResult<object?>(null);

        public System.Threading.Tasks.Task<object?> GetAttribute(
            string attributeName,
            System.Threading.CancellationToken cancellationToken = default) =>
            System.Threading.Tasks.Task.FromResult<object?>(null);

        public System.Threading.Tasks.Task<IReadOnlyDictionary<string, object?>> GetAttributes(
            IEnumerable<string> attributeNames,
            System.Threading.CancellationToken cancellationToken = default) =>
            System.Threading.Tasks.Task.FromResult<IReadOnlyDictionary<string, object?>>(
                new Dictionary<string, object?>());

        public System.Threading.Tasks.Task SetAttribute(
            string attributeName,
            string value,
            System.Threading.CancellationToken cancellationToken = default) =>
            System.Threading.Tasks.Task.CompletedTask;

        public System.Threading.Tasks.Task SetAttributes(
            IReadOnlyDictionary<string, string> attributeValues,
            System.Threading.CancellationToken cancellationToken = default) =>
            System.Threading.Tasks.Task.CompletedTask;
    }
}
