feat: complete tree shell cutover and regression coverage
This commit is contained in:
@@ -10,6 +10,7 @@ pub enum KernelNodeType {
|
||||
Page,
|
||||
Section,
|
||||
Asset,
|
||||
Table,
|
||||
Book,
|
||||
Pdf,
|
||||
Mindmap,
|
||||
@@ -48,6 +49,61 @@ pub enum KernelProjectionKind {
|
||||
RagIndex,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum KernelProjectionCapability {
|
||||
Expand,
|
||||
Open,
|
||||
Drag,
|
||||
Drop,
|
||||
Select,
|
||||
CreateChild,
|
||||
Rename,
|
||||
Archive,
|
||||
Restore,
|
||||
ContextMenu,
|
||||
Reorder,
|
||||
OpenAsset,
|
||||
Pick,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KernelProjectionRowKind {
|
||||
Document,
|
||||
Index,
|
||||
Asset,
|
||||
AssetFolder,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KernelProjectionResourceKind {
|
||||
Workspace,
|
||||
Document,
|
||||
Index,
|
||||
Asset,
|
||||
AssetFolder,
|
||||
Mindmap,
|
||||
Table,
|
||||
Book,
|
||||
Pdf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KernelProjectionAssetKind {
|
||||
File,
|
||||
Mindmap,
|
||||
Table,
|
||||
Book,
|
||||
Pdf,
|
||||
Image,
|
||||
Video,
|
||||
Audio,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KernelGraphDirection {
|
||||
@@ -255,14 +311,35 @@ pub struct KernelGraphTraversalResult {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KernelProjectionItem {
|
||||
pub row_id: String,
|
||||
pub row_kind: KernelProjectionRowKind,
|
||||
pub node_id: String,
|
||||
pub parent_node_id: Option<String>,
|
||||
pub node_type: KernelNodeType,
|
||||
pub projection_kind: KernelProjectionKind,
|
||||
pub title: Option<String>,
|
||||
pub depth: u32,
|
||||
pub position: Option<i64>,
|
||||
pub child_count: u32,
|
||||
pub expandable: bool,
|
||||
pub expanded_by_default: bool,
|
||||
#[serde(default)]
|
||||
pub capabilities: Vec<KernelProjectionCapability>,
|
||||
pub resource_meta: Option<KernelProjectionResourceMeta>,
|
||||
pub icon_hint: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KernelProjectionResourceMeta {
|
||||
pub resource_kind: Option<KernelProjectionResourceKind>,
|
||||
pub document_id: Option<String>,
|
||||
pub asset_id: Option<String>,
|
||||
pub workspace_id: Option<String>,
|
||||
pub asset_kind: Option<KernelProjectionAssetKind>,
|
||||
pub icon_hint: Option<String>,
|
||||
#[serde(default)]
|
||||
pub extra: BTreeMap<String, Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
@@ -394,4 +471,45 @@ mod tests {
|
||||
assert_eq!(value["refs"]["referenceNodeIds"], json!(["page_1"]));
|
||||
assert_eq!(value["audit"]["traceId"], json!("trace_1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kernel_projection_item_serializes_contract_fields() {
|
||||
let item = KernelProjectionItem {
|
||||
row_id: "asset:page_1".into(),
|
||||
row_kind: KernelProjectionRowKind::Asset,
|
||||
node_id: "page_1".into(),
|
||||
parent_node_id: None,
|
||||
node_type: KernelNodeType::Page,
|
||||
projection_kind: KernelProjectionKind::FileTree,
|
||||
title: Some("页面 1".into()),
|
||||
depth: 0,
|
||||
position: Some(1),
|
||||
child_count: 2,
|
||||
expandable: true,
|
||||
expanded_by_default: true,
|
||||
capabilities: vec![
|
||||
KernelProjectionCapability::Expand,
|
||||
KernelProjectionCapability::Open,
|
||||
KernelProjectionCapability::CreateChild,
|
||||
],
|
||||
resource_meta: Some(KernelProjectionResourceMeta {
|
||||
resource_kind: Some(KernelProjectionResourceKind::Document),
|
||||
document_id: Some("page_1".into()),
|
||||
asset_id: None,
|
||||
workspace_id: Some("ws_1".into()),
|
||||
asset_kind: Some(KernelProjectionAssetKind::File),
|
||||
icon_hint: Some("page".into()),
|
||||
extra: BTreeMap::new(),
|
||||
}),
|
||||
icon_hint: Some("page".into()),
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(&item).expect("projection item 应可序列化");
|
||||
assert_eq!(value["rowId"], json!("asset:page_1"));
|
||||
assert_eq!(value["rowKind"], json!("asset"));
|
||||
assert_eq!(value["projectionKind"], json!("file_tree"));
|
||||
assert_eq!(value["capabilities"], json!(["expand", "open", "create-child"]));
|
||||
assert_eq!(value["resourceMeta"]["resourceKind"], json!("document"));
|
||||
assert_eq!(value["iconHint"], json!("page"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user