mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* refactor: delete user model * refactor: delete user model crate * refactor: rm flowy-server-sync crate * refactor: rm flowy-database and flowy-folder * refactor: rm folder-model * refactor: rm database model * refactor: rm flowy-sync * refactor: rm document-model * refactor: rm flowy-document * refactor: rm flowy-client-sync * refactor: rm ws-model * refactor: rm flowy-revisoin * refactor: rm revision-model * refactor: rm flowy-folder * refactor: rm flowy-client-ws * refactor: move crates * chore: move configuration file * ci: fix tauri build' * ci: fix flutter build * ci: rust test script * ci: tauri pnpm version conflict * ci: tauri build
206 lines
3.6 KiB
Rust
206 lines
3.6 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct OpenDocumentPayloadPBV2 {
|
|
#[pb(index = 1)]
|
|
pub document_id: String,
|
|
// Support customize initial data
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct CreateDocumentPayloadPBV2 {
|
|
#[pb(index = 1)]
|
|
pub document_id: String,
|
|
// Support customize initial data
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct CloseDocumentPayloadPBV2 {
|
|
#[pb(index = 1)]
|
|
pub document_id: String,
|
|
// Support customize initial data
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
|
pub struct ApplyActionPayloadPBV2 {
|
|
#[pb(index = 1)]
|
|
pub document_id: String,
|
|
|
|
#[pb(index = 2)]
|
|
pub actions: Vec<BlockActionPB>,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct GetDocumentDataPayloadPBV2 {
|
|
#[pb(index = 1)]
|
|
pub document_id: String,
|
|
// Support customize initial data
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct DocumentDataPB2 {
|
|
#[pb(index = 1)]
|
|
pub page_id: String,
|
|
|
|
#[pb(index = 2)]
|
|
pub blocks: HashMap<String, BlockPB>,
|
|
|
|
#[pb(index = 3)]
|
|
pub meta: MetaPB,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
|
pub struct BlockPB {
|
|
#[pb(index = 1)]
|
|
pub id: String,
|
|
|
|
#[pb(index = 2)]
|
|
pub ty: String,
|
|
|
|
#[pb(index = 3)]
|
|
pub data: String,
|
|
|
|
#[pb(index = 4)]
|
|
pub parent_id: String,
|
|
|
|
#[pb(index = 5)]
|
|
pub children_id: String,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct MetaPB {
|
|
#[pb(index = 1)]
|
|
pub children_map: HashMap<String, ChildrenPB>,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct ChildrenPB {
|
|
#[pb(index = 1)]
|
|
pub children: Vec<String>,
|
|
}
|
|
// Actions
|
|
#[derive(Default, ProtoBuf, Debug)]
|
|
pub struct BlockActionPB {
|
|
#[pb(index = 1)]
|
|
pub action: BlockActionTypePB,
|
|
|
|
#[pb(index = 2)]
|
|
pub payload: BlockActionPayloadPB,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
|
pub struct BlockActionPayloadPB {
|
|
#[pb(index = 1)]
|
|
pub block: BlockPB,
|
|
|
|
#[pb(index = 2, one_of)]
|
|
pub prev_id: Option<String>,
|
|
|
|
#[pb(index = 3, one_of)]
|
|
pub parent_id: Option<String>,
|
|
}
|
|
|
|
#[derive(ProtoBuf_Enum, Debug)]
|
|
pub enum BlockActionTypePB {
|
|
Insert = 0,
|
|
Update = 1,
|
|
Delete = 2,
|
|
Move = 3,
|
|
}
|
|
|
|
impl Default for BlockActionTypePB {
|
|
fn default() -> Self {
|
|
Self::Insert
|
|
}
|
|
}
|
|
|
|
#[derive(ProtoBuf_Enum)]
|
|
pub enum DeltaTypePB {
|
|
Inserted = 0,
|
|
Updated = 1,
|
|
Removed = 2,
|
|
}
|
|
impl Default for DeltaTypePB {
|
|
fn default() -> Self {
|
|
Self::Inserted
|
|
}
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct DocEventPB {
|
|
#[pb(index = 1)]
|
|
pub events: Vec<BlockEventPB>,
|
|
|
|
#[pb(index = 2)]
|
|
pub is_remote: bool,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct BlockEventPB {
|
|
#[pb(index = 1)]
|
|
pub event: Vec<BlockEventPayloadPB>,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct BlockEventPayloadPB {
|
|
#[pb(index = 1)]
|
|
pub command: DeltaTypePB,
|
|
|
|
#[pb(index = 2)]
|
|
pub path: Vec<String>,
|
|
|
|
#[pb(index = 3)]
|
|
pub id: String,
|
|
|
|
#[pb(index = 4)]
|
|
pub value: String,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, ProtoBuf_Enum, Clone)]
|
|
pub enum ExportType {
|
|
Text = 0,
|
|
Markdown = 1,
|
|
Link = 2,
|
|
}
|
|
|
|
impl Default for ExportType {
|
|
fn default() -> Self {
|
|
ExportType::Text
|
|
}
|
|
}
|
|
|
|
impl From<i32> for ExportType {
|
|
fn from(val: i32) -> Self {
|
|
match val {
|
|
0 => ExportType::Text,
|
|
1 => ExportType::Markdown,
|
|
2 => ExportType::Link,
|
|
_ => {
|
|
tracing::error!("Invalid export type: {}", val);
|
|
ExportType::Text
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct EditPayloadPB {
|
|
#[pb(index = 1)]
|
|
pub doc_id: String,
|
|
|
|
// Encode in JSON format
|
|
#[pb(index = 2)]
|
|
pub operations: String,
|
|
}
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct ExportDataPB {
|
|
#[pb(index = 1)]
|
|
pub data: String,
|
|
|
|
#[pb(index = 2)]
|
|
pub export_type: ExportType,
|
|
}
|