-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresources.proto
375 lines (336 loc) · 8.63 KB
/
resources.proto
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/*
* Copyright 2022 The Yorkie Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package yorkie.v1;
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
option go_package = ".;v1";
option java_multiple_files = true;
option java_package = "dev.yorkie.api.v1";
/////////////////////////////////////////
// Messages for Snapshot //
/////////////////////////////////////////
message Snapshot {
JSONElement root = 1;
map<string, Presence> presences = 2;
}
/////////////////////////////////////////
// Messages for ChangePack //
/////////////////////////////////////////
// ChangePack is a message that contains all changes that occurred in a document.
// It is used to synchronize changes between clients and servers.
message ChangePack {
string document_key = 1;
Checkpoint checkpoint = 2;
bytes snapshot = 3;
repeated Change changes = 4;
TimeTicket min_synced_ticket = 5;
bool is_removed = 6;
}
message Change {
ChangeID id = 1;
string message = 2;
repeated Operation operations = 3;
PresenceChange presence_change = 4;
}
message ChangeID {
uint32 client_seq = 1;
int64 server_seq = 2 [jstype = JS_STRING];
int64 lamport = 3 [jstype = JS_STRING];
bytes actor_id = 4;
}
message Operation {
message Set {
TimeTicket parent_created_at = 1;
string key = 2;
JSONElementSimple value = 3;
TimeTicket executed_at = 4;
}
message Add {
TimeTicket parent_created_at = 1;
TimeTicket prev_created_at = 2;
JSONElementSimple value = 3;
TimeTicket executed_at = 4;
}
message Move {
TimeTicket parent_created_at = 1;
TimeTicket prev_created_at = 2;
TimeTicket created_at = 3;
TimeTicket executed_at = 4;
}
message Remove {
TimeTicket parent_created_at = 1;
TimeTicket created_at = 2;
TimeTicket executed_at = 3;
}
message Edit {
TimeTicket parent_created_at = 1;
TextNodePos from = 2;
TextNodePos to = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
string content = 5;
TimeTicket executed_at = 6;
map<string, string> attributes = 7;
}
// NOTE(hackerwins): Select Operation is not used in the current version.
// In the previous version, it was used to represent selection of Text.
// However, it has been replaced by Presence now. It is retained for backward
// compatibility purposes.
message Select {
TimeTicket parent_created_at = 1;
TextNodePos from = 2;
TextNodePos to = 3;
TimeTicket executed_at = 4;
}
message Style {
TimeTicket parent_created_at = 1;
TextNodePos from = 2;
TextNodePos to = 3;
map<string, string> attributes = 4;
TimeTicket executed_at = 5;
map<string, TimeTicket> created_at_map_by_actor = 6;
}
message Increase {
TimeTicket parent_created_at = 1;
JSONElementSimple value = 2;
TimeTicket executed_at = 3;
}
message TreeEdit {
TimeTicket parent_created_at = 1;
TreePos from = 2;
TreePos to = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
repeated TreeNodes contents = 5;
int32 split_level = 7;
TimeTicket executed_at = 6;
}
message TreeStyle {
TimeTicket parent_created_at = 1;
TreePos from = 2;
TreePos to = 3;
map<string, string> attributes = 4;
TimeTicket executed_at = 5;
repeated string attributes_to_remove = 6;
}
oneof body {
Set set = 1;
Add add = 2;
Move move = 3;
Remove remove = 4;
Edit edit = 5;
Select select = 6;
Style style = 7;
Increase increase = 8;
TreeEdit tree_edit = 9;
TreeStyle tree_style = 10;
}
}
message JSONElementSimple {
TimeTicket created_at = 1;
TimeTicket moved_at = 2;
TimeTicket removed_at = 3;
ValueType type = 4;
bytes value = 5;
}
/////////////////////////////////////////
// Messages for JSON //
/////////////////////////////////////////
message JSONElement {
message JSONObject {
repeated RHTNode nodes = 1;
TimeTicket created_at = 2;
TimeTicket moved_at = 3;
TimeTicket removed_at = 4;
}
message JSONArray {
repeated RGANode nodes = 1;
TimeTicket created_at = 2;
TimeTicket moved_at = 3;
TimeTicket removed_at = 4;
}
message Primitive {
ValueType type = 1;
bytes value = 2;
TimeTicket created_at = 3;
TimeTicket moved_at = 4;
TimeTicket removed_at = 5;
}
message Text {
repeated TextNode nodes = 1;
TimeTicket created_at = 2;
TimeTicket moved_at = 3;
TimeTicket removed_at = 4;
}
message Counter {
ValueType type = 1;
bytes value = 2;
TimeTicket created_at = 3;
TimeTicket moved_at = 4;
TimeTicket removed_at = 5;
}
message Tree {
repeated TreeNode nodes = 1;
TimeTicket created_at = 2;
TimeTicket moved_at = 3;
TimeTicket removed_at = 4;
}
oneof body {
JSONObject json_object = 1;
JSONArray json_array = 2;
Primitive primitive = 3;
Text text = 5;
Counter counter = 6;
Tree tree = 7;
}
}
message RHTNode {
string key = 1;
JSONElement element = 2;
}
message RGANode {
RGANode next = 1;
JSONElement element = 2;
}
message NodeAttr {
string value = 1;
TimeTicket updated_at = 2;
}
message TextNode {
TextNodeID id = 1;
string value = 2;
TimeTicket removed_at = 3;
TextNodeID ins_prev_id = 4;
map<string, NodeAttr> attributes = 5;
}
message TextNodeID {
TimeTicket created_at = 1;
int32 offset = 2;
}
message TreeNode {
TreeNodeID id = 1;
string type = 2;
string value = 3;
TimeTicket removed_at = 4;
TreeNodeID ins_prev_id = 5;
TreeNodeID ins_next_id = 6;
int32 depth = 7;
map<string, NodeAttr> attributes = 8;
}
message TreeNodes {
repeated TreeNode content = 1;
}
message TreeNodeID {
TimeTicket created_at = 1;
int32 offset = 2;
}
message TreePos {
TreeNodeID parent_id = 1;
TreeNodeID left_sibling_id = 2;
}
/////////////////////////////////////////
// Messages for Common //
/////////////////////////////////////////
message User {
string id = 1;
string username = 2;
google.protobuf.Timestamp created_at = 3;
}
message Project {
string id = 1;
string name = 2;
string public_key = 3;
string secret_key = 4;
string auth_webhook_url = 5;
repeated string auth_webhook_methods = 6;
string client_deactivate_threshold = 7;
google.protobuf.Timestamp created_at = 8;
google.protobuf.Timestamp updated_at = 9;
}
message UpdatableProjectFields {
message AuthWebhookMethods {
repeated string methods = 1;
}
google.protobuf.StringValue name = 1;
google.protobuf.StringValue auth_webhook_url = 2;
AuthWebhookMethods auth_webhook_methods = 3;
google.protobuf.StringValue client_deactivate_threshold = 4;
}
message DocumentSummary {
string id = 1;
string key = 2;
string snapshot = 3;
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp accessed_at = 5;
google.protobuf.Timestamp updated_at = 6;
}
message PresenceChange {
enum ChangeType {
CHANGE_TYPE_UNSPECIFIED = 0;
CHANGE_TYPE_PUT = 1;
CHANGE_TYPE_DELETE = 2;
CHANGE_TYPE_CLEAR = 3;
}
ChangeType type = 1;
Presence presence = 2;
}
message Presence {
map<string, string> data = 1;
}
message Checkpoint {
int64 server_seq = 1 [jstype = JS_STRING];
uint32 client_seq = 2;
}
message TextNodePos {
TimeTicket created_at = 1;
int32 offset = 2;
int32 relative_offset = 3;
}
message TimeTicket {
int64 lamport = 1 [jstype = JS_STRING];
uint32 delimiter = 2;
bytes actor_id = 3;
}
enum ValueType {
VALUE_TYPE_NULL = 0;
VALUE_TYPE_BOOLEAN = 1;
VALUE_TYPE_INTEGER = 2;
VALUE_TYPE_LONG = 3;
VALUE_TYPE_DOUBLE = 4;
VALUE_TYPE_STRING = 5;
VALUE_TYPE_BYTES = 6;
VALUE_TYPE_DATE = 7;
VALUE_TYPE_JSON_OBJECT = 8;
VALUE_TYPE_JSON_ARRAY = 9;
VALUE_TYPE_TEXT = 10;
VALUE_TYPE_INTEGER_CNT = 11;
VALUE_TYPE_LONG_CNT = 12;
VALUE_TYPE_TREE = 13;
}
enum DocEventType {
DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0;
DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1;
DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2;
DOC_EVENT_TYPE_DOCUMENT_BROADCAST = 3;
}
message DocEventBody {
string topic = 1;
bytes payload = 2;
}
message DocEvent {
DocEventType type = 1;
string publisher = 2;
DocEventBody body = 3;
}