use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum EventKind {
Prompt,
System,
Command,
Warn,
Alert,
ModeChange,
}
impl EventKind {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Prompt => "prompt",
Self::System => "system",
Self::Command => "command",
Self::Warn => "warn",
Self::Alert => "alert",
Self::ModeChange => "mode_change",
}
}
#[must_use]
pub fn parse_str(s: &str) -> Option<Self> {
Some(match s {
"prompt" => Self::Prompt,
"system" => Self::System,
"command" => Self::Command,
"warn" => Self::Warn,
"alert" => Self::Alert,
"mode_change" => Self::ModeChange,
_ => return None,
})
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StoredEvent {
pub id: i64,
pub session_id: i64,
pub seq: i64,
pub at: DateTime<Utc>,
pub kind: EventKind,
pub text: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SessionRow {
pub id: i64,
pub ulid: String,
pub started_at: DateTime<Utc>,
pub ended_at: Option<DateTime<Utc>>,
pub engine_base_url: Option<String>,
pub cli_version: String,
pub parent_ulid: Option<String>,
}