90305551cc
- Add feature flags: hi-fidelity-tables, hi-fidelity-styles, hi-fidelity-lists, hi-fidelity-sections - Tables: inject true w:gridSpan/w:vMerge and w:tblGrid widths via post-build XML when enabled - Styles: ensure TableHeader style in styles.xml; tag first row when headers present - Lists: robust numbering.xml for ordered/unordered with multi-level definitions - Sections: write tail w:sectPr with page size/orientation/margins - Tools: expose new operations (sections, list items, images, hyperlinks, props, redaction, storage) - Converters: add preference-aware methods for hi-fidelity export paths; HTML export tool - Tests: add golden XML assertions gated by feature flags; keep default build green This enables high-fidelity DOCX output while keeping pure-Rust paths by default.
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
use serde::{Serialize, Deserialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum ToolOutcome {
|
|
Ok { message: Option<String> },
|
|
Created { document_id: String, message: Option<String> },
|
|
Text { text: String },
|
|
Metadata { metadata: serde_json::Value },
|
|
Documents { documents: serde_json::Value },
|
|
Images { images: Vec<String>, message: Option<String> },
|
|
Security { security: serde_json::Value },
|
|
Storage { storage: serde_json::Value },
|
|
Statistics { statistics: serde_json::Value },
|
|
Structure { structure: serde_json::Value },
|
|
Error { code: ErrorCode, error: String, hint: Option<String> },
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
|
pub enum ErrorCode {
|
|
DocNotFound,
|
|
ValidationError,
|
|
SecurityDenied,
|
|
LimitExceeded,
|
|
UnknownTool,
|
|
InternalError,
|
|
}
|
|
|
|
impl ToolOutcome {
|
|
pub fn success(&self) -> bool {
|
|
!matches!(self, ToolOutcome::Error { .. })
|
|
}
|
|
|
|
pub fn into_json(self) -> serde_json::Value {
|
|
serde_json::to_value(self).unwrap_or_else(|e| serde_json::json!({
|
|
"type": "error",
|
|
"code": ErrorCode::InternalError,
|
|
"error": format!("serialization failed: {}", e),
|
|
}))
|
|
}
|
|
}
|