using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using NodaTime;
namespace DysonNetwork.Common.Models;
///
/// Represents a connection between an account and an authentication provider
///
public class AccountConnection
{
///
/// Unique identifier for the connection
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; } = null!;
///
/// The account ID this connection is associated with
///
public string? AccountId { get; set; }
///
/// The authentication provider (e.g., "google", "github")
///
[Required]
[MaxLength(50)]
public string Provider { get; set; } = null!;
///
/// The unique identifier for the user from the provider
///
[Required]
[MaxLength(256)]
public string ProvidedIdentifier { get; set; } = null!;
///
/// Display name for the connection
///
[MaxLength(100)]
public string? DisplayName { get; set; }
///
/// OAuth access token from the provider
///
public string? AccessToken { get; set; }
///
/// OAuth refresh token from the provider (if available)
///
public string? RefreshToken { get; set; }
///
/// When the access token expires (if available)
///
public Instant? ExpiresAt { get; set; }
///
/// When the connection was first established
///
public Instant CreatedAt { get; set; }
///
/// When the connection was last used
///
public Instant? LastUsedAt { get; set; }
///
/// Additional metadata about the connection
///
[Column(TypeName = "jsonb")]
public Dictionary? Meta { get; set; }
///
/// Navigation property for the associated account
///
[ForeignKey(nameof(AccountId))]
public virtual Account? Account { get; set; }
}