using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace StellaOps.Scanner.Sbomer.BuildXPlugin.Manifest;

/// <summary>
/// Canonical manifest describing a buildx generator plug-in.
/// </summary>
public sealed record BuildxPluginManifest
{
    public const string CurrentSchemaVersion = "1.0";

    [JsonPropertyName("schemaVersion")]
    public string SchemaVersion { get; init; } = CurrentSchemaVersion;

    [JsonPropertyName("id")]
    public string Id { get; init; } = string.Empty;

    [JsonPropertyName("displayName")]
    public string DisplayName { get; init; } = string.Empty;

    [JsonPropertyName("version")]
    public string Version { get; init; } = string.Empty;

    [JsonPropertyName("entryPoint")]
    public BuildxPluginEntryPoint EntryPoint { get; init; } = new();

    [JsonPropertyName("requiresRestart")]
    public bool RequiresRestart { get; init; } = true;

    [JsonPropertyName("capabilities")]
    public IReadOnlyList<string> Capabilities { get; init; } = Array.Empty<string>();

    [JsonPropertyName("cas")]
    public BuildxPluginCas Cas { get; init; } = new();

    [JsonPropertyName("image")]
    public BuildxPluginImage? Image { get; init; }

    [JsonPropertyName("metadata")]
    public IReadOnlyDictionary<string, string>? Metadata { get; init; }

    [JsonIgnore]
    public string? SourcePath { get; init; }

    [JsonIgnore]
    public string? SourceDirectory { get; init; }
}
