-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathcollab.rs
More file actions
232 lines (232 loc) · 8.36 KB
/
collab.rs
File metadata and controls
232 lines (232 loc) · 8.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/// Originating from an AppFlowy Client.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClientOrigin {
/// User id.
#[prost(int64, tag = "1")]
pub uid: i64,
/// Device id.
#[prost(string, tag = "2")]
pub device_id: ::prost::alloc::string::String,
}
/// Unknown origin.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmptyOrigin {}
/// Originating from the AppFlowy Server.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerOrigin {}
/// Origin of a collab message.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollabOrigin {
#[prost(oneof = "collab_origin::Origin", tags = "1, 2, 3")]
pub origin: ::core::option::Option<collab_origin::Origin>,
}
/// Nested message and enum types in `CollabOrigin`.
pub mod collab_origin {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Origin {
#[prost(message, tag = "1")]
Empty(super::EmptyOrigin),
#[prost(message, tag = "2")]
Client(super::ClientOrigin),
#[prost(message, tag = "3")]
Server(super::ServerOrigin),
}
}
/// Collab Type.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CollabType {
Unknown = 0,
Document = 1,
Database = 2,
WorkspaceDatabase = 3,
Folder = 4,
DatabaseRow = 5,
UserAwareness = 6,
}
impl CollabType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
CollabType::Unknown => "COLLAB_TYPE_UNKNOWN",
CollabType::Document => "COLLAB_TYPE_DOCUMENT",
CollabType::Database => "COLLAB_TYPE_DATABASE",
CollabType::WorkspaceDatabase => "COLLAB_TYPE_WORKSPACE_DATABASE",
CollabType::Folder => "COLLAB_TYPE_FOLDER",
CollabType::DatabaseRow => "COLLAB_TYPE_DATABASE_ROW",
CollabType::UserAwareness => "COLLAB_TYPE_USER_AWARENESS",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"COLLAB_TYPE_UNKNOWN" => Some(Self::Unknown),
"COLLAB_TYPE_DOCUMENT" => Some(Self::Document),
"COLLAB_TYPE_DATABASE" => Some(Self::Database),
"COLLAB_TYPE_WORKSPACE_DATABASE" => Some(Self::WorkspaceDatabase),
"COLLAB_TYPE_FOLDER" => Some(Self::Folder),
"COLLAB_TYPE_DATABASE_ROW" => Some(Self::DatabaseRow),
"COLLAB_TYPE_USER_AWARENESS" => Some(Self::UserAwareness),
_ => None,
}
}
}
/// Encoded collaborative document.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EncodedCollab {
/// yrs state vector
#[prost(bytes = "vec", tag = "1")]
pub state_vector: ::prost::alloc::vec::Vec<u8>,
/// yrs document state
#[prost(bytes = "vec", tag = "2")]
pub doc_state: ::prost::alloc::vec::Vec<u8>,
/// yrs encoder version used for the state vector and doc state
#[prost(enumeration = "EncoderVersion", tag = "3")]
pub encoder_version: i32,
}
/// yrs encoder version.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EncoderVersion {
Unknown = 0,
V1 = 1,
V2 = 2,
}
impl EncoderVersion {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
EncoderVersion::Unknown => "ENCODER_VERSION_UNKNOWN",
EncoderVersion::V1 => "ENCODER_VERSION_V1",
EncoderVersion::V2 => "ENCODER_VERSION_V2",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ENCODER_VERSION_UNKNOWN" => Some(Self::Unknown),
"ENCODER_VERSION_V1" => Some(Self::V1),
"ENCODER_VERSION_V2" => Some(Self::V2),
_ => None,
}
}
}
/// Embeddings and the associated collab metadata.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollabEmbeddingsParams {
/// Fragment id.
#[prost(string, tag = "1")]
pub fragment_id: ::prost::alloc::string::String,
/// Collab object id.
#[prost(string, tag = "2")]
pub object_id: ::prost::alloc::string::String,
/// Collab type.
#[prost(enumeration = "CollabType", tag = "3")]
pub collab_type: i32,
/// Embedding content type.
#[prost(enumeration = "EmbeddingContentType", tag = "4")]
pub content_type: i32,
/// Embedding content as string.
#[prost(string, tag = "5")]
pub content: ::prost::alloc::string::String,
/// Embedding as float array.
#[prost(float, repeated, tag = "6")]
pub embedding: ::prost::alloc::vec::Vec<f32>,
}
/// Wrapper over a collection of embeddings, together with metadata associated on the collection level.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollabEmbeddings {
/// OpenAPI tokens consumed.
#[prost(uint32, tag = "1")]
pub tokens_consumed: u32,
/// List of embeddings.
#[prost(message, repeated, tag = "2")]
pub embeddings: ::prost::alloc::vec::Vec<CollabEmbeddingsParams>,
}
/// Payload for sending and receive collab over http.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollabParams {
#[prost(string, tag = "1")]
pub object_id: ::prost::alloc::string::String,
/// Serialized EncodedCollab object, which could either be in bincode or protobuf serialization format.
#[prost(bytes = "vec", tag = "2")]
pub encoded_collab: ::prost::alloc::vec::Vec<u8>,
/// Collab type.
#[prost(enumeration = "CollabType", tag = "3")]
pub collab_type: i32,
/// Document embeddings.
#[prost(message, optional, tag = "4")]
pub embeddings: ::core::option::Option<CollabEmbeddings>,
}
/// Payload for creating batch of collab over http.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCreateCollabParams {
/// Workspace id.
#[prost(string, tag = "1")]
pub workspace_id: ::prost::alloc::string::String,
/// List of collab params.
#[prost(message, repeated, tag = "2")]
pub params_list: ::prost::alloc::vec::Vec<CollabParams>,
}
/// Payload for creating new collab or update existing collab over http.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateCollabParams {
/// Workspace id.
#[prost(string, tag = "1")]
pub workspace_id: ::prost::alloc::string::String,
/// Object id.
#[prost(string, tag = "2")]
pub object_id: ::prost::alloc::string::String,
/// Serialized EncodedCollab object, which could either be in bincode or protobuf serialization format.
#[prost(bytes = "vec", tag = "3")]
pub encoded_collab: ::prost::alloc::vec::Vec<u8>,
/// Collab type.
#[prost(enumeration = "CollabType", tag = "4")]
pub collab_type: i32,
}
/// Types of embeddings content.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EmbeddingContentType {
/// Unknown content type.
Unknown = 0,
/// Plain text
PlainText = 1,
}
impl EmbeddingContentType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
EmbeddingContentType::Unknown => "EMBEDDING_CONTENT_TYPE_UNKNOWN",
EmbeddingContentType::PlainText => "EMBEDDING_CONTENT_TYPE_PLAIN_TEXT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"EMBEDDING_CONTENT_TYPE_UNKNOWN" => Some(Self::Unknown),
"EMBEDDING_CONTENT_TYPE_PLAIN_TEXT" => Some(Self::PlainText),
_ => None,
}
}
}