using ScadaLink.CentralUI.ScriptAnalysis;

namespace ScadaLink.CentralUI.Components.Shared;

/// <summary>
/// Parses the parameter-definitions JSON Schema written by SchemaBuilder and
/// returns the declared parameter names (and shapes). Used by script-edit
/// pages to feed the Monaco editor's Parameters["..."] context.
/// </summary>
public static class ScriptParameterNames
{
    public static IReadOnlyList<string> Parse(string? json) =>
        JsonSchemaShapeParser.ParseParameters(json)
            .Select(p => p.Name)
            .Where(s => !string.IsNullOrEmpty(s))
            .ToList();

    public static IReadOnlyList<ParameterShape> ParseShapes(string? json) =>
        JsonSchemaShapeParser.ParseParameters(json);
}
