//! Shared data types used by the archivist coordinator.
//!
//! `ArchiveMetadata` is persisted per-archive in the registry file and
//! tracks creation time, path, and the set of connectors registered in
//! the archive. `ArchiveInfo` is the display-friendly projection returned
//! from listing APIs; it extends the metadata with computed fields like
//! session count and default-archive status.

use std::path::PathBuf;

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Metadata about a single archive.
///
/// This structure contains all the information needed to track and display
/// an archive without loading its full backend instance.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArchiveMetadata {
    /// Unique name for this archive (e.g., "personal", "work", "experiments")
    pub name: String,

    /// Filesystem path to the archive root directory
    pub path: PathBuf,

    /// When this archive was first registered with the coordinator
    pub created_at: DateTime<Utc>,

    /// List of connector UIDs registered in this archive
    ///
    /// This is updated as connectors are registered/unregistered and provides
    /// a quick way to see which connectors belong to which archive.
    pub connector_uids: Vec<Uuid>,
}

/// Display-friendly information about an archive.
///
/// This struct is returned by listing operations and includes computed
/// fields like session count and default status.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArchiveInfo {
    /// Unique name for this archive
    pub name: String,

    /// Filesystem path to the archive root directory
    pub path: PathBuf,

    /// When this archive was first registered
    pub created_at: DateTime<Utc>,

    /// Total number of sessions across all connectors in this archive
    ///
    /// This is computed by counting sessions across all connectors and
    /// may be expensive for large archives.
    pub session_count: usize,

    /// Whether this is the current default archive
    pub is_default: bool,
}
