Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chg(lexical_client): add handler for snapshot creation (#3132)

teob674381f2616
diff --git a/rust/cloud-storage/lexical_client/src/parse_markdown.rs b/rust/cloud-storage/lexical_client/src/parse_markdown.rs
index aa007bdc4f..c611de6bbb 100644
--- a/rust/cloud-storage/lexical_client/src/parse_markdown.rs
+++ b/rust/cloud-storage/lexical_client/src/parse_markdown.rs
@@ -18,6 +18,11 @@ struct LexicalResponse {
data: Vec<LexicalResponseItem>,
}
+#[derive(Debug, serde::Serialize)]
+struct MarkdownSnapshotRequest<'a> {
+ markdown: &'a str,
+}
+
impl From<LexicalResponseItem> for MarkdownParseResult {
fn from(result: LexicalResponseItem) -> MarkdownParseResult {
MarkdownParseResult {
@@ -76,6 +81,22 @@ impl LexicalClient {
self.get_json(&url).await
}
+ #[tracing::instrument(skip(self, markdown), err)]
+ pub async fn markdown_to_loro_snapshot(&self, markdown: &str) -> Result<Vec<u8>> {
+ let url = format!("{}/snapshot/markdown", self.url);
+ let response = check_response(
+ self.client
+ .post(&url)
+ .json(&MarkdownSnapshotRequest { markdown })
+ .send()
+ .await?,
+ )
+ .await?;
+
+ let bytes = response.bytes().await?;
+ Ok(bytes.to_vec())
+ }
+
async fn get_json<T: DeserializeOwned>(&self, url: &str) -> Result<T> {
let response = check_response(self.client.get(url).send().await?).await?;
response.json().await.context("unexpected response")