checkpoint before gfm ast parser design
This commit is contained in:
@@ -49,6 +49,33 @@ pub enum KernelProjectionKind {
|
||||
RagIndex,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum WorkspaceSourceKind {
|
||||
LocalFolder,
|
||||
ConvexWorkspace,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum WorkspaceSourceCapability {
|
||||
LoadSnapshot,
|
||||
Watch,
|
||||
PreflightCommand,
|
||||
ExecuteCommand,
|
||||
ResolvePageAggregate,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WorkspaceSource {
|
||||
pub source_kind: WorkspaceSourceKind,
|
||||
pub root_uri: String,
|
||||
pub workspace_id: String,
|
||||
#[serde(default)]
|
||||
pub capabilities: Vec<WorkspaceSourceCapability>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum KernelProjectionCapability {
|
||||
@@ -638,4 +665,31 @@ mod tests {
|
||||
assert_eq!(value["resourceMeta"]["resourceKind"], json!("document"));
|
||||
assert_eq!(value["iconHint"], json!("page"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn workspace_source_serializes_minimal_command_source_contract() {
|
||||
let source = WorkspaceSource {
|
||||
source_kind: WorkspaceSourceKind::ConvexWorkspace,
|
||||
root_uri: "convex://workspace/ws_1".into(),
|
||||
workspace_id: "ws_1".into(),
|
||||
capabilities: vec![
|
||||
WorkspaceSourceCapability::LoadSnapshot,
|
||||
WorkspaceSourceCapability::PreflightCommand,
|
||||
WorkspaceSourceCapability::ExecuteCommand,
|
||||
],
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(&source).expect("workspace source 应可序列化");
|
||||
assert_eq!(value["sourceKind"], json!("convex_workspace"));
|
||||
assert_eq!(value["rootUri"], json!("convex://workspace/ws_1"));
|
||||
assert_eq!(value["workspaceId"], json!("ws_1"));
|
||||
assert_eq!(
|
||||
value["capabilities"],
|
||||
json!(["load-snapshot", "preflight-command", "execute-command"])
|
||||
);
|
||||
|
||||
let decoded: WorkspaceSource =
|
||||
serde_json::from_value(value).expect("workspace source 应可反序列化");
|
||||
assert_eq!(decoded, source);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user