2024-09-15 00:02:17 +08:00
|
|
|
use collab::entity::EncodedCollab;
|
2023-07-29 09:46:24 +08:00
|
|
|
pub use collab_document::blocks::DocumentData;
|
|
|
|
|
2023-11-05 14:00:24 +08:00
|
|
|
use flowy_error::FlowyError;
|
2024-08-18 05:16:42 +02:00
|
|
|
use lib_infra::async_trait::async_trait;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
|
|
|
/// A trait for document cloud service.
|
|
|
|
/// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of
|
|
|
|
/// [flowy-server] crate for more information.
|
2024-08-18 05:16:42 +02:00
|
|
|
#[async_trait]
|
2023-07-29 09:46:24 +08:00
|
|
|
pub trait DocumentCloudService: Send + Sync + 'static {
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_document_doc_state(
|
2023-10-23 11:43:31 +08:00
|
|
|
&self,
|
|
|
|
document_id: &str,
|
|
|
|
workspace_id: &str,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<Vec<u8>, FlowyError>;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_document_snapshots(
|
2023-07-29 09:46:24 +08:00
|
|
|
&self,
|
|
|
|
document_id: &str,
|
2023-08-17 23:46:39 +08:00
|
|
|
limit: usize,
|
2023-10-23 11:43:31 +08:00
|
|
|
workspace_id: &str,
|
2024-10-26 11:20:16 +08:00
|
|
|
) -> Result<Vec<DocumentSnapshot>, FlowyError>;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_document_data(
|
2023-10-23 11:43:31 +08:00
|
|
|
&self,
|
|
|
|
document_id: &str,
|
|
|
|
workspace_id: &str,
|
2024-10-26 11:20:16 +08:00
|
|
|
) -> Result<Option<DocumentData>, FlowyError>;
|
2024-09-15 00:02:17 +08:00
|
|
|
|
|
|
|
async fn create_document_collab(
|
|
|
|
&self,
|
|
|
|
workspace_id: &str,
|
|
|
|
document_id: &str,
|
|
|
|
encoded_collab: EncodedCollab,
|
2024-10-26 11:20:16 +08:00
|
|
|
) -> Result<(), FlowyError>;
|
2023-07-29 09:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct DocumentSnapshot {
|
|
|
|
pub snapshot_id: i64,
|
|
|
|
pub document_id: String,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
pub created_at: i64,
|
|
|
|
}
|