use lgwks_std::json::serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(crate = "lgwks_std::json::serde")]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
pub enum AttributionKind {
User,
Widget,
Ml,
System,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(crate = "lgwks_std::json::serde")]
#[non_exhaustive]
pub struct Attribution {
kind: AttributionKind,
source_id: String,
model_version: Option<String>,
confidence: Option<f64>,
}
impl Attribution {
#[must_use]
pub fn new(
kind: AttributionKind,
source_id: String,
model_version: Option<String>,
confidence: Option<f64>,
) -> Self {
Self {
kind,
source_id,
model_version,
confidence,
}
}
#[must_use]
pub const fn kind(&self) -> AttributionKind {
self.kind
}
#[must_use]
pub fn source_id(&self) -> &str {
&self.source_id
}
#[must_use]
pub const fn model_version(&self) -> Option<&String> {
self.model_version.as_ref()
}
#[must_use]
pub const fn confidence(&self) -> Option<f64> {
self.confidence
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(crate = "lgwks_std::json::serde")]
#[non_exhaustive]
pub struct GovernanceEntry {
entry_id: String,
session_id: String,
work_object_id: String,
signal_id: String,
event_type: String,
description: String,
attribution: Attribution,
recorded_at: String,
#[serde(default)]
tenant_id: String,
}
impl GovernanceEntry {
#[must_use]
pub fn new(
session_id: String,
entry_id: String,
work_object_id: String,
signal_id: String,
event_type: String,
description: String,
attribution: Attribution,
) -> Self {
Self {
session_id,
entry_id,
work_object_id,
signal_id,
event_type,
description,
attribution,
recorded_at: String::new(),
tenant_id: String::new(),
}
}
pub fn set_recorded_at(&mut self, recorded_at: String) {
self.recorded_at = recorded_at;
}
pub fn set_tenant_id(&mut self, tenant_id: String) {
self.tenant_id = tenant_id;
}
#[must_use]
pub fn tenant_id(&self) -> &str {
&self.tenant_id
}
#[must_use]
pub fn entry_id(&self) -> &str {
&self.entry_id
}
#[must_use]
pub fn session_id(&self) -> &str {
&self.session_id
}
#[must_use]
pub fn work_object_id(&self) -> &str {
&self.work_object_id
}
#[must_use]
pub fn signal_id(&self) -> &str {
&self.signal_id
}
#[must_use]
pub fn event_type(&self) -> &str {
&self.event_type
}
#[must_use]
pub fn description(&self) -> &str {
&self.description
}
#[must_use]
pub const fn attribution(&self) -> &Attribution {
&self.attribution
}
#[must_use]
pub fn recorded_at(&self) -> &str {
&self.recorded_at
}
}