use schemars::JsonSchema;
use serde::Serialize;
use serde_json::Value;
#[derive(Debug, Clone, PartialEq, Serialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct RecordView {
pub seq: crate::core::Seq,
pub run: String,
pub case: Option<String>,
pub step: Option<String>,
pub phase: String,
pub effect_key: Option<String>,
pub kind: String,
#[schemars(extend("x-agentplane-holds" = "The record's payload in the published record format, tagged by `kind`."))]
pub record: Value,
}
#[must_use]
pub fn record_view(r: &super::Record) -> RecordView {
RecordView {
seq: r.seq(),
run: r.body.run.to_string(),
case: r.body.case.map(|c| c.to_string()),
step: r.body.step.map(|s| s.to_string()),
phase: r.body.phase.as_str().to_owned(),
effect_key: r.effect_key().map(|k| k.to_string()),
kind: r.kind().kind_str().to_owned(),
record: serde_json::to_value(r.kind()).unwrap_or(Value::Null),
}
}