using System.ComponentModel.DataAnnotations;

namespace StellaOps.Authority.Bootstrap;

internal sealed record BootstrapUserRequest
{
    public string? Provider { get; init; }

    public string? InviteToken { get; init; }

    [Required]
    public string Username { get; init; } = string.Empty;

    [Required]
    public string Password { get; init; } = string.Empty;

    public string? DisplayName { get; init; }

    public string? Email { get; init; }

    public bool RequirePasswordReset { get; init; }

    public IReadOnlyCollection<string>? Roles { get; init; }

    public IReadOnlyDictionary<string, string?>? Attributes { get; init; }
}

internal sealed record BootstrapClientRequest
{
    public string? Provider { get; init; }

    public string? InviteToken { get; init; }

    [Required]
    public string ClientId { get; init; } = string.Empty;

    public bool Confidential { get; init; } = true;

    public string? DisplayName { get; init; }

    public string? ClientSecret { get; init; }

    public IReadOnlyCollection<string>? AllowedGrantTypes { get; init; }

    public IReadOnlyCollection<string>? AllowedScopes { get; init; }

    public IReadOnlyCollection<string>? RedirectUris { get; init; }

    public IReadOnlyCollection<string>? PostLogoutRedirectUris { get; init; }

    public IReadOnlyDictionary<string, string?>? Properties { get; init; }
}

internal sealed record BootstrapInviteRequest
{
    public string Type { get; init; } = BootstrapInviteTypes.User;

    public string? Token { get; init; }

    public string? Provider { get; init; }

    public string? Target { get; init; }

    public DateTimeOffset? ExpiresAt { get; init; }

    public string? IssuedBy { get; init; }

    public IReadOnlyDictionary<string, string?>? Metadata { get; init; }
}

internal static class BootstrapInviteTypes
{
    public const string User = "user";
    public const string Client = "client";
}
