//! Raw contact: a single source's view of a person.
//!
//! In v1, aggregation is 1:1 — every `RawContact` has exactly one `Contact`.
//! The schema is shaped so that v2 can add real cross-source aggregation
//! without touching consumers.

#[ derive( Debug, Clone, PartialEq, Eq ) ]
pub struct RawContact
{
	pub id: i64,
	pub contact_id: i64,
	pub account_name: Option<String>,
	pub account_type: Option<String>,
	pub display_name: Option<String>,
	pub deleted: bool,
	pub dirty: bool,
	pub version: i64,
	pub sourceid: Option<String>,
	pub created_at: i64,
	pub updated_at: i64,
}

/// Fields accepted when creating a new raw_contact.
///
/// `display_name` is optional; if absent it will be recomputed from
/// associated `…/name` data rows by the aggregator.
#[ derive( Debug, Clone, Default ) ]
pub struct NewRawContact
{
	pub account_name: Option<String>,
	pub account_type: Option<String>,
	pub display_name: Option<String>,
	pub sourceid: Option<String>,
}

/// Partial update with tri-state semantics — same shape as
/// `crate::model::data_item::DataPatch`:
///
/// - `None`               → column unchanged.
/// - `Some( None )`       → column set to NULL.
/// - `Some( Some( v ) )`  → column set to `v`.
#[ derive( Debug, Clone, Default ) ]
pub struct RawContactPatch
{
	pub account_name: Option<Option<String>>,
	pub account_type: Option<Option<String>>,
	pub display_name: Option<Option<String>>,
	pub sourceid: Option<Option<String>>,
}
