2023-04-13 10:53:51 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-04-17 02:12:04 +00:00
|
|
|
#[derive(Default, ProtoBuf)]
|
|
|
|
pub struct CreateDocumentPayloadPBV2 {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub document_id: String,
|
|
|
|
// Support customize initial data
|
|
|
|
}
|
|
|
|
|
2023-04-13 10:53:51 +00:00
|
|
|
#[derive(Default, ProtoBuf)]
|
|
|
|
pub struct CloseDocumentPayloadPBV2 {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub document_id: String,
|
|
|
|
// Support customize initial data
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
2023-04-13 10:53:51 +00:00
|
|
|
pub struct ApplyActionPayloadPBV2 {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub document_id: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
|
|
|
pub actions: Vec<BlockActionPB>,
|
|
|
|
}
|
|
|
|
|
2023-05-16 06:58:24 +00:00
|
|
|
#[derive(Default, ProtoBuf)]
|
|
|
|
pub struct GetDocumentDataPayloadPBV2 {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub document_id: String,
|
|
|
|
// Support customize initial data
|
|
|
|
}
|
|
|
|
|
2023-04-13 10:53:51 +00:00
|
|
|
#[derive(Default, ProtoBuf)]
|
|
|
|
pub struct DocumentDataPB2 {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub page_id: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
2023-04-13 12:30:28 +00:00
|
|
|
pub blocks: HashMap<String, BlockPB>,
|
2023-04-13 10:53:51 +00:00
|
|
|
|
|
|
|
#[pb(index = 3)]
|
|
|
|
pub meta: MetaPB,
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
2023-04-13 10:53:51 +00:00
|
|
|
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
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
2023-04-13 10:53:51 +00:00
|
|
|
pub struct BlockActionPB {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub action: BlockActionTypePB,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
|
|
|
pub payload: BlockActionPayloadPB,
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(Default, ProtoBuf, Debug)]
|
2023-04-13 10:53:51 +00:00
|
|
|
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>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(ProtoBuf_Enum, Debug)]
|
2023-04-13 10:53:51 +00:00
|
|
|
pub enum BlockActionTypePB {
|
|
|
|
Insert = 0,
|
|
|
|
Update = 1,
|
|
|
|
Delete = 2,
|
|
|
|
Move = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for BlockActionTypePB {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::Insert
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 02:12:04 +00:00
|
|
|
|
2023-04-24 06:25:00 +00:00
|
|
|
#[derive(ProtoBuf_Enum)]
|
|
|
|
pub enum DeltaTypePB {
|
|
|
|
Inserted = 0,
|
|
|
|
Updated = 1,
|
|
|
|
Removed = 2,
|
|
|
|
}
|
|
|
|
impl Default for DeltaTypePB {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::Inserted
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-17 02:12:04 +00:00
|
|
|
#[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)]
|
2023-04-24 06:25:00 +00:00
|
|
|
pub event: Vec<BlockEventPayloadPB>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
|
|
pub struct BlockEventPayloadPB {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub command: DeltaTypePB,
|
2023-04-17 02:12:04 +00:00
|
|
|
|
|
|
|
#[pb(index = 2)]
|
2023-04-24 06:25:00 +00:00
|
|
|
pub path: Vec<String>,
|
|
|
|
|
|
|
|
#[pb(index = 3)]
|
|
|
|
pub id: String,
|
|
|
|
|
|
|
|
#[pb(index = 4)]
|
|
|
|
pub value: String,
|
2023-04-17 02:12:04 +00:00
|
|
|
}
|