fix: fix some displays and features
This commit is contained in:
@ -1342,3 +1342,107 @@ pub fn parse_tab_id(raw: &str) -> Result<TabId, ErrorDto> {
|
||||
message: format!("invalid tab id: {raw}"),
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Skills (L12)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
use application::{CreateSkillOutput, ListSkillsOutput, UpdateSkillOutput};
|
||||
use domain::{Skill, SkillId, SkillScope};
|
||||
|
||||
/// A skill crossing the wire. [`Skill`] already serialises camelCase
|
||||
/// (`id`, `name`, `contentMd`, `scope` as `"global"`/`"project"`), so we embed
|
||||
/// it directly — the TS mirror matches this shape.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct SkillDto(pub Skill);
|
||||
|
||||
/// A list of skills (transparent array on the wire).
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct SkillListDto(pub Vec<SkillDto>);
|
||||
|
||||
impl From<ListSkillsOutput> for SkillListDto {
|
||||
fn from(out: ListSkillsOutput) -> Self {
|
||||
Self(out.skills.into_iter().map(SkillDto).collect())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CreateSkillOutput> for SkillDto {
|
||||
fn from(out: CreateSkillOutput) -> Self {
|
||||
Self(out.skill)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UpdateSkillOutput> for SkillDto {
|
||||
fn from(out: UpdateSkillOutput) -> Self {
|
||||
Self(out.skill)
|
||||
}
|
||||
}
|
||||
|
||||
/// Request DTO for `create_skill`.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateSkillRequestDto {
|
||||
/// Owning project (resolved to a root; ignored on disk for `Global`).
|
||||
pub project_id: String,
|
||||
/// Display name.
|
||||
pub name: String,
|
||||
/// Initial Markdown content.
|
||||
pub content: String,
|
||||
/// Scope the skill is created in.
|
||||
pub scope: SkillScope,
|
||||
}
|
||||
|
||||
/// Request DTO for `update_skill`.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateSkillRequestDto {
|
||||
/// Owning project (resolved to a root; ignored on disk for `Global`).
|
||||
pub project_id: String,
|
||||
/// Id of the skill to update.
|
||||
pub skill_id: String,
|
||||
/// Scope the skill lives in.
|
||||
pub scope: SkillScope,
|
||||
/// New Markdown content.
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
/// Request DTO for `assign_skill_to_agent`.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AssignSkillRequestDto {
|
||||
/// Owning project.
|
||||
pub project_id: String,
|
||||
/// Agent receiving the skill.
|
||||
pub agent_id: String,
|
||||
/// Skill to assign.
|
||||
pub skill_id: String,
|
||||
/// Scope of the skill (recorded alongside the ref).
|
||||
pub scope: SkillScope,
|
||||
}
|
||||
|
||||
/// Request DTO for `unassign_skill_from_agent`.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnassignSkillRequestDto {
|
||||
/// Owning project.
|
||||
pub project_id: String,
|
||||
/// Agent losing the skill.
|
||||
pub agent_id: String,
|
||||
/// Skill to unassign.
|
||||
pub skill_id: String,
|
||||
}
|
||||
|
||||
/// Parses a skill-id string (UUID) coming from the frontend.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] with code `INVALID` if the string is not a UUID.
|
||||
pub fn parse_skill_id(raw: &str) -> Result<SkillId, ErrorDto> {
|
||||
uuid::Uuid::parse_str(raw)
|
||||
.map(SkillId::from_uuid)
|
||||
.map_err(|_| ErrorDto {
|
||||
code: "INVALID".to_owned(),
|
||||
message: format!("invalid skill id: {raw}"),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user