feat: add grid struct

This commit is contained in:
appflowy 2022-03-02 21:12:21 +08:00
parent 5549cff177
commit 4187e99433
26 changed files with 3233 additions and 158 deletions

View File

@ -77,7 +77,7 @@ class CreateBlockParams extends $pb.GeneratedMessage {
class BlockInfo extends $pb.GeneratedMessage { class BlockInfo extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BlockInfo', createEmptyInstance: create) static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BlockInfo', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId') ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blockId')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'text') ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'text')
..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revId') ..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revId')
..aInt64(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'baseRevId') ..aInt64(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'baseRevId')
@ -86,14 +86,14 @@ class BlockInfo extends $pb.GeneratedMessage {
BlockInfo._() : super(); BlockInfo._() : super();
factory BlockInfo({ factory BlockInfo({
$core.String? docId, $core.String? blockId,
$core.String? text, $core.String? text,
$fixnum.Int64? revId, $fixnum.Int64? revId,
$fixnum.Int64? baseRevId, $fixnum.Int64? baseRevId,
}) { }) {
final _result = create(); final _result = create();
if (docId != null) { if (blockId != null) {
_result.docId = docId; _result.blockId = blockId;
} }
if (text != null) { if (text != null) {
_result.text = text; _result.text = text;
@ -128,13 +128,13 @@ class BlockInfo extends $pb.GeneratedMessage {
static BlockInfo? _defaultInstance; static BlockInfo? _defaultInstance;
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.String get docId => $_getSZ(0); $core.String get blockId => $_getSZ(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
set docId($core.String v) { $_setString(0, v); } set blockId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.bool hasDocId() => $_has(0); $core.bool hasBlockId() => $_has(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
void clearDocId() => clearField(1); void clearBlockId() => clearField(1);
@$pb.TagNumber(2) @$pb.TagNumber(2)
$core.String get text => $_getSZ(1); $core.String get text => $_getSZ(1);
@ -164,56 +164,56 @@ class BlockInfo extends $pb.GeneratedMessage {
void clearBaseRevId() => clearField(4); void clearBaseRevId() => clearField(4);
} }
class ResetDocumentParams extends $pb.GeneratedMessage { class ResetBlockParams extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ResetDocumentParams', createEmptyInstance: create) static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ResetBlockParams', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId') ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blockId')
..aOM<$0.RepeatedRevision>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revisions', subBuilder: $0.RepeatedRevision.create) ..aOM<$0.RepeatedRevision>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revisions', subBuilder: $0.RepeatedRevision.create)
..hasRequiredFields = false ..hasRequiredFields = false
; ;
ResetDocumentParams._() : super(); ResetBlockParams._() : super();
factory ResetDocumentParams({ factory ResetBlockParams({
$core.String? docId, $core.String? blockId,
$0.RepeatedRevision? revisions, $0.RepeatedRevision? revisions,
}) { }) {
final _result = create(); final _result = create();
if (docId != null) { if (blockId != null) {
_result.docId = docId; _result.blockId = blockId;
} }
if (revisions != null) { if (revisions != null) {
_result.revisions = revisions; _result.revisions = revisions;
} }
return _result; return _result;
} }
factory ResetDocumentParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ResetBlockParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory ResetDocumentParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); factory ResetBlockParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated( @$core.Deprecated(
'Using this can add significant overhead to your binary. ' 'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version') 'Will be removed in next major version')
ResetDocumentParams clone() => ResetDocumentParams()..mergeFromMessage(this); ResetBlockParams clone() => ResetBlockParams()..mergeFromMessage(this);
@$core.Deprecated( @$core.Deprecated(
'Using this can add significant overhead to your binary. ' 'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version') 'Will be removed in next major version')
ResetDocumentParams copyWith(void Function(ResetDocumentParams) updates) => super.copyWith((message) => updates(message as ResetDocumentParams)) as ResetDocumentParams; // ignore: deprecated_member_use ResetBlockParams copyWith(void Function(ResetBlockParams) updates) => super.copyWith((message) => updates(message as ResetBlockParams)) as ResetBlockParams; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i; $pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline') @$core.pragma('dart2js:noInline')
static ResetDocumentParams create() => ResetDocumentParams._(); static ResetBlockParams create() => ResetBlockParams._();
ResetDocumentParams createEmptyInstance() => create(); ResetBlockParams createEmptyInstance() => create();
static $pb.PbList<ResetDocumentParams> createRepeated() => $pb.PbList<ResetDocumentParams>(); static $pb.PbList<ResetBlockParams> createRepeated() => $pb.PbList<ResetBlockParams>();
@$core.pragma('dart2js:noInline') @$core.pragma('dart2js:noInline')
static ResetDocumentParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ResetDocumentParams>(create); static ResetBlockParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ResetBlockParams>(create);
static ResetDocumentParams? _defaultInstance; static ResetBlockParams? _defaultInstance;
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.String get docId => $_getSZ(0); $core.String get blockId => $_getSZ(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
set docId($core.String v) { $_setString(0, v); } set blockId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.bool hasDocId() => $_has(0); $core.bool hasBlockId() => $_has(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
void clearDocId() => clearField(1); void clearBlockId() => clearField(1);
@$pb.TagNumber(2) @$pb.TagNumber(2)
$0.RepeatedRevision get revisions => $_getN(1); $0.RepeatedRevision get revisions => $_getN(1);

View File

@ -23,7 +23,7 @@ final $typed_data.Uint8List createBlockParamsDescriptor = $convert.base64Decode(
const BlockInfo$json = const { const BlockInfo$json = const {
'1': 'BlockInfo', '1': 'BlockInfo',
'2': const [ '2': const [
const {'1': 'doc_id', '3': 1, '4': 1, '5': 9, '10': 'docId'}, const {'1': 'block_id', '3': 1, '4': 1, '5': 9, '10': 'blockId'},
const {'1': 'text', '3': 2, '4': 1, '5': 9, '10': 'text'}, const {'1': 'text', '3': 2, '4': 1, '5': 9, '10': 'text'},
const {'1': 'rev_id', '3': 3, '4': 1, '5': 3, '10': 'revId'}, const {'1': 'rev_id', '3': 3, '4': 1, '5': 3, '10': 'revId'},
const {'1': 'base_rev_id', '3': 4, '4': 1, '5': 3, '10': 'baseRevId'}, const {'1': 'base_rev_id', '3': 4, '4': 1, '5': 3, '10': 'baseRevId'},
@ -31,18 +31,18 @@ const BlockInfo$json = const {
}; };
/// Descriptor for `BlockInfo`. Decode as a `google.protobuf.DescriptorProto`. /// Descriptor for `BlockInfo`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List blockInfoDescriptor = $convert.base64Decode('CglCbG9ja0luZm8SFQoGZG9jX2lkGAEgASgJUgVkb2NJZBISCgR0ZXh0GAIgASgJUgR0ZXh0EhUKBnJldl9pZBgDIAEoA1IFcmV2SWQSHgoLYmFzZV9yZXZfaWQYBCABKANSCWJhc2VSZXZJZA=='); final $typed_data.Uint8List blockInfoDescriptor = $convert.base64Decode('CglCbG9ja0luZm8SGQoIYmxvY2tfaWQYASABKAlSB2Jsb2NrSWQSEgoEdGV4dBgCIAEoCVIEdGV4dBIVCgZyZXZfaWQYAyABKANSBXJldklkEh4KC2Jhc2VfcmV2X2lkGAQgASgDUgliYXNlUmV2SWQ=');
@$core.Deprecated('Use resetDocumentParamsDescriptor instead') @$core.Deprecated('Use resetBlockParamsDescriptor instead')
const ResetDocumentParams$json = const { const ResetBlockParams$json = const {
'1': 'ResetDocumentParams', '1': 'ResetBlockParams',
'2': const [ '2': const [
const {'1': 'doc_id', '3': 1, '4': 1, '5': 9, '10': 'docId'}, const {'1': 'block_id', '3': 1, '4': 1, '5': 9, '10': 'blockId'},
const {'1': 'revisions', '3': 2, '4': 1, '5': 11, '6': '.RepeatedRevision', '10': 'revisions'}, const {'1': 'revisions', '3': 2, '4': 1, '5': 11, '6': '.RepeatedRevision', '10': 'revisions'},
], ],
}; };
/// Descriptor for `ResetDocumentParams`. Decode as a `google.protobuf.DescriptorProto`. /// Descriptor for `ResetBlockParams`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List resetDocumentParamsDescriptor = $convert.base64Decode('ChNSZXNldERvY3VtZW50UGFyYW1zEhUKBmRvY19pZBgBIAEoCVIFZG9jSWQSLwoJcmV2aXNpb25zGAIgASgLMhEuUmVwZWF0ZWRSZXZpc2lvblIJcmV2aXNpb25z'); final $typed_data.Uint8List resetBlockParamsDescriptor = $convert.base64Decode('ChBSZXNldEJsb2NrUGFyYW1zEhkKCGJsb2NrX2lkGAEgASgJUgdibG9ja0lkEi8KCXJldmlzaW9ucxgCIAEoCzIRLlJlcGVhdGVkUmV2aXNpb25SCXJldmlzaW9ucw==');
@$core.Deprecated('Use blockDeltaDescriptor instead') @$core.Deprecated('Use blockDeltaDescriptor instead')
const BlockDelta$json = const { const BlockDelta$json = const {
'1': 'BlockDelta', '1': 'BlockDelta',

View File

@ -225,7 +225,7 @@ impl RevisionObjectBuilder for BlockInfoBuilder {
correct_delta(&mut delta); correct_delta(&mut delta);
Result::<BlockInfo, FlowyError>::Ok(BlockInfo { Result::<BlockInfo, FlowyError>::Ok(BlockInfo {
doc_id: object_id.to_owned(), block_id: object_id.to_owned(),
text: delta.to_delta_json(), text: delta.to_delta_json(),
rev_id, rev_id,
base_rev_id, base_rev_id,

View File

@ -11,7 +11,7 @@ pub mod errors {
pub const DOCUMENT_SYNC_INTERVAL_IN_MILLIS: u64 = 1000; pub const DOCUMENT_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
use crate::errors::FlowyError; use crate::errors::FlowyError;
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams}; use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams};
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
pub trait BlockCloudService: Send + Sync { pub trait BlockCloudService: Send + Sync {
@ -19,5 +19,5 @@ pub trait BlockCloudService: Send + Sync {
fn read_block(&self, token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError>; fn read_block(&self, token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError>;
fn update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError>; fn update_block(&self, token: &str, params: ResetBlockParams) -> FutureResult<(), FlowyError>;
} }

View File

@ -162,8 +162,14 @@ impl RevisionCloudService for BlockRevisionCloudService {
Some(doc) => { Some(doc) => {
let delta_data = Bytes::from(doc.text.clone()); let delta_data = Bytes::from(doc.text.clone());
let doc_md5 = md5(&delta_data); let doc_md5 = md5(&delta_data);
let revision = let revision = Revision::new(
Revision::new(&doc.doc_id, doc.base_rev_id, doc.rev_id, delta_data, &user_id, doc_md5); &doc.block_id,
doc.base_rev_id,
doc.rev_id,
delta_data,
&user_id,
doc_md5,
);
Ok(vec![revision]) Ok(vec![revision])
} }
} }

View File

@ -2,8 +2,8 @@ use crate::{
configuration::*, configuration::*,
request::{HttpRequestBuilder, ResponseMiddleware}, request::{HttpRequestBuilder, ResponseMiddleware},
}; };
use flowy_block::BlockCloudService; use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams};
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams}; use flowy_document::BlockCloudService;
use flowy_error::FlowyError; use flowy_error::FlowyError;
use http_flowy::response::FlowyResponse; use http_flowy::response::FlowyResponse;
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -33,7 +33,7 @@ impl BlockCloudService for BlockHttpCloudService {
FutureResult::new(async move { read_document_request(&token, params, &url).await }) FutureResult::new(async move { read_document_request(&token, params, &url).await })
} }
fn update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError> { fn update_block(&self, token: &str, params: ResetBlockParams) -> FutureResult<(), FlowyError> {
let token = token.to_owned(); let token = token.to_owned();
let url = self.config.doc_url(); let url = self.config.doc_url();
FutureResult::new(async move { reset_doc_request(&token, params, &url).await }) FutureResult::new(async move { reset_doc_request(&token, params, &url).await })
@ -61,7 +61,7 @@ pub async fn read_document_request(token: &str, params: BlockId, url: &str) -> R
Ok(doc) Ok(doc)
} }
pub async fn reset_doc_request(token: &str, params: ResetDocumentParams, url: &str) -> Result<(), FlowyError> { pub async fn reset_doc_request(token: &str, params: ResetBlockParams, url: &str) -> Result<(), FlowyError> {
let _ = request_builder() let _ = request_builder()
.patch(&url.to_owned()) .patch(&url.to_owned())
.header(HEADER_TOKEN, token) .header(HEADER_TOKEN, token)

View File

@ -4,7 +4,7 @@ use bytes::Bytes;
use flowy_collaboration::{ use flowy_collaboration::{
client_document::default::initial_delta_string, client_document::default::initial_delta_string,
entities::{ entities::{
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams}, document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams},
ws_data::{ClientRevisionWSData, ClientRevisionWSDataType}, ws_data::{ClientRevisionWSData, ClientRevisionWSDataType},
}, },
errors::CollaborateError, errors::CollaborateError,
@ -416,7 +416,7 @@ impl BlockCloudService for LocalServer {
fn read_block(&self, _token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> { fn read_block(&self, _token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> {
let doc = BlockInfo { let doc = BlockInfo {
doc_id: params.value, block_id: params.value,
text: initial_delta_string(), text: initial_delta_string(),
rev_id: 0, rev_id: 0,
base_rev_id: 0, base_rev_id: 0,
@ -424,7 +424,7 @@ impl BlockCloudService for LocalServer {
FutureResult::new(async { Ok(Some(doc)) }) FutureResult::new(async { Ok(Some(doc)) })
} }
fn update_block(&self, _token: &str, _params: ResetDocumentParams) -> FutureResult<(), FlowyError> { fn update_block(&self, _token: &str, _params: ResetBlockParams) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) }) FutureResult::new(async { Ok(()) })
} }
} }

10
shared-lib/Cargo.lock generated
View File

@ -478,6 +478,16 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "flowy-grid-data-model"
version = "0.1.0"
dependencies = [
"bytes",
"flowy-derive",
"lib-infra",
"protobuf",
]
[[package]] [[package]]
name = "flowy-user-data-model" name = "flowy-user-data-model"
version = "0.1.0" version = "0.1.0"

View File

@ -9,6 +9,7 @@ members = [
"flowy-derive", "flowy-derive",
"flowy-ast", "flowy-ast",
"flowy-error-code", "flowy-error-code",
"flowy-grid-data-model",
] ]
[profile.dev] [profile.dev]

View File

@ -17,7 +17,7 @@ pub struct CreateBlockParams {
#[derive(ProtoBuf, Default, Debug, Clone, Eq, PartialEq)] #[derive(ProtoBuf, Default, Debug, Clone, Eq, PartialEq)]
pub struct BlockInfo { pub struct BlockInfo {
#[pb(index = 1)] #[pb(index = 1)]
pub doc_id: String, pub block_id: String,
#[pb(index = 2)] #[pb(index = 2)]
pub text: String, pub text: String,
@ -49,7 +49,7 @@ impl std::convert::TryFrom<Revision> for BlockInfo {
let doc_json = delta.to_delta_json(); let doc_json = delta.to_delta_json();
Ok(BlockInfo { Ok(BlockInfo {
doc_id: revision.object_id, block_id: revision.object_id,
text: doc_json, text: doc_json,
rev_id: revision.rev_id, rev_id: revision.rev_id,
base_rev_id: revision.base_rev_id, base_rev_id: revision.base_rev_id,
@ -58,9 +58,9 @@ impl std::convert::TryFrom<Revision> for BlockInfo {
} }
#[derive(ProtoBuf, Default, Debug, Clone)] #[derive(ProtoBuf, Default, Debug, Clone)]
pub struct ResetDocumentParams { pub struct ResetBlockParams {
#[pb(index = 1)] #[pb(index = 1)]
pub doc_id: String, pub block_id: String,
#[pb(index = 2)] #[pb(index = 2)]
pub revisions: RepeatedRevision, pub revisions: RepeatedRevision,

View File

@ -242,7 +242,7 @@ impl ::protobuf::reflect::ProtobufValue for CreateBlockParams {
#[derive(PartialEq,Clone,Default)] #[derive(PartialEq,Clone,Default)]
pub struct BlockInfo { pub struct BlockInfo {
// message fields // message fields
pub doc_id: ::std::string::String, pub block_id: ::std::string::String,
pub text: ::std::string::String, pub text: ::std::string::String,
pub rev_id: i64, pub rev_id: i64,
pub base_rev_id: i64, pub base_rev_id: i64,
@ -262,30 +262,30 @@ impl BlockInfo {
::std::default::Default::default() ::std::default::Default::default()
} }
// string doc_id = 1; // string block_id = 1;
pub fn get_doc_id(&self) -> &str { pub fn get_block_id(&self) -> &str {
&self.doc_id &self.block_id
} }
pub fn clear_doc_id(&mut self) { pub fn clear_block_id(&mut self) {
self.doc_id.clear(); self.block_id.clear();
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_doc_id(&mut self, v: ::std::string::String) { pub fn set_block_id(&mut self, v: ::std::string::String) {
self.doc_id = v; self.block_id = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first. // If field is not initialized, it is initialized with default value first.
pub fn mut_doc_id(&mut self) -> &mut ::std::string::String { pub fn mut_block_id(&mut self) -> &mut ::std::string::String {
&mut self.doc_id &mut self.block_id
} }
// Take field // Take field
pub fn take_doc_id(&mut self) -> ::std::string::String { pub fn take_block_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.doc_id, ::std::string::String::new()) ::std::mem::replace(&mut self.block_id, ::std::string::String::new())
} }
// string text = 2; // string text = 2;
@ -355,7 +355,7 @@ impl ::protobuf::Message for BlockInfo {
let (field_number, wire_type) = is.read_tag_unpack()?; let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number { match field_number {
1 => { 1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc_id)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.block_id)?;
}, },
2 => { 2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?;
@ -386,8 +386,8 @@ impl ::protobuf::Message for BlockInfo {
#[allow(unused_variables)] #[allow(unused_variables)]
fn compute_size(&self) -> u32 { fn compute_size(&self) -> u32 {
let mut my_size = 0; let mut my_size = 0;
if !self.doc_id.is_empty() { if !self.block_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.doc_id); my_size += ::protobuf::rt::string_size(1, &self.block_id);
} }
if !self.text.is_empty() { if !self.text.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.text); my_size += ::protobuf::rt::string_size(2, &self.text);
@ -404,8 +404,8 @@ impl ::protobuf::Message for BlockInfo {
} }
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.doc_id.is_empty() { if !self.block_id.is_empty() {
os.write_string(1, &self.doc_id)?; os.write_string(1, &self.block_id)?;
} }
if !self.text.is_empty() { if !self.text.is_empty() {
os.write_string(2, &self.text)?; os.write_string(2, &self.text)?;
@ -455,9 +455,9 @@ impl ::protobuf::Message for BlockInfo {
descriptor.get(|| { descriptor.get(|| {
let mut fields = ::std::vec::Vec::new(); let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"doc_id", "block_id",
|m: &BlockInfo| { &m.doc_id }, |m: &BlockInfo| { &m.block_id },
|m: &mut BlockInfo| { &mut m.doc_id }, |m: &mut BlockInfo| { &mut m.block_id },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"text", "text",
@ -490,7 +490,7 @@ impl ::protobuf::Message for BlockInfo {
impl ::protobuf::Clear for BlockInfo { impl ::protobuf::Clear for BlockInfo {
fn clear(&mut self) { fn clear(&mut self) {
self.doc_id.clear(); self.block_id.clear();
self.text.clear(); self.text.clear();
self.rev_id = 0; self.rev_id = 0;
self.base_rev_id = 0; self.base_rev_id = 0;
@ -511,50 +511,50 @@ impl ::protobuf::reflect::ProtobufValue for BlockInfo {
} }
#[derive(PartialEq,Clone,Default)] #[derive(PartialEq,Clone,Default)]
pub struct ResetDocumentParams { pub struct ResetBlockParams {
// message fields // message fields
pub doc_id: ::std::string::String, pub block_id: ::std::string::String,
pub revisions: ::protobuf::SingularPtrField<super::revision::RepeatedRevision>, pub revisions: ::protobuf::SingularPtrField<super::revision::RepeatedRevision>,
// special fields // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize, pub cached_size: ::protobuf::CachedSize,
} }
impl<'a> ::std::default::Default for &'a ResetDocumentParams { impl<'a> ::std::default::Default for &'a ResetBlockParams {
fn default() -> &'a ResetDocumentParams { fn default() -> &'a ResetBlockParams {
<ResetDocumentParams as ::protobuf::Message>::default_instance() <ResetBlockParams as ::protobuf::Message>::default_instance()
} }
} }
impl ResetDocumentParams { impl ResetBlockParams {
pub fn new() -> ResetDocumentParams { pub fn new() -> ResetBlockParams {
::std::default::Default::default() ::std::default::Default::default()
} }
// string doc_id = 1; // string block_id = 1;
pub fn get_doc_id(&self) -> &str { pub fn get_block_id(&self) -> &str {
&self.doc_id &self.block_id
} }
pub fn clear_doc_id(&mut self) { pub fn clear_block_id(&mut self) {
self.doc_id.clear(); self.block_id.clear();
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_doc_id(&mut self, v: ::std::string::String) { pub fn set_block_id(&mut self, v: ::std::string::String) {
self.doc_id = v; self.block_id = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first. // If field is not initialized, it is initialized with default value first.
pub fn mut_doc_id(&mut self) -> &mut ::std::string::String { pub fn mut_block_id(&mut self) -> &mut ::std::string::String {
&mut self.doc_id &mut self.block_id
} }
// Take field // Take field
pub fn take_doc_id(&mut self) -> ::std::string::String { pub fn take_block_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.doc_id, ::std::string::String::new()) ::std::mem::replace(&mut self.block_id, ::std::string::String::new())
} }
// .RepeatedRevision revisions = 2; // .RepeatedRevision revisions = 2;
@ -591,7 +591,7 @@ impl ResetDocumentParams {
} }
} }
impl ::protobuf::Message for ResetDocumentParams { impl ::protobuf::Message for ResetBlockParams {
fn is_initialized(&self) -> bool { fn is_initialized(&self) -> bool {
for v in &self.revisions { for v in &self.revisions {
if !v.is_initialized() { if !v.is_initialized() {
@ -606,7 +606,7 @@ impl ::protobuf::Message for ResetDocumentParams {
let (field_number, wire_type) = is.read_tag_unpack()?; let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number { match field_number {
1 => { 1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc_id)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.block_id)?;
}, },
2 => { 2 => {
::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.revisions)?; ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.revisions)?;
@ -623,8 +623,8 @@ impl ::protobuf::Message for ResetDocumentParams {
#[allow(unused_variables)] #[allow(unused_variables)]
fn compute_size(&self) -> u32 { fn compute_size(&self) -> u32 {
let mut my_size = 0; let mut my_size = 0;
if !self.doc_id.is_empty() { if !self.block_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.doc_id); my_size += ::protobuf::rt::string_size(1, &self.block_id);
} }
if let Some(ref v) = self.revisions.as_ref() { if let Some(ref v) = self.revisions.as_ref() {
let len = v.compute_size(); let len = v.compute_size();
@ -636,8 +636,8 @@ impl ::protobuf::Message for ResetDocumentParams {
} }
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.doc_id.is_empty() { if !self.block_id.is_empty() {
os.write_string(1, &self.doc_id)?; os.write_string(1, &self.block_id)?;
} }
if let Some(ref v) = self.revisions.as_ref() { if let Some(ref v) = self.revisions.as_ref() {
os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?;
@ -674,8 +674,8 @@ impl ::protobuf::Message for ResetDocumentParams {
Self::descriptor_static() Self::descriptor_static()
} }
fn new() -> ResetDocumentParams { fn new() -> ResetBlockParams {
ResetDocumentParams::new() ResetBlockParams::new()
} }
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
@ -683,44 +683,44 @@ impl ::protobuf::Message for ResetDocumentParams {
descriptor.get(|| { descriptor.get(|| {
let mut fields = ::std::vec::Vec::new(); let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"doc_id", "block_id",
|m: &ResetDocumentParams| { &m.doc_id }, |m: &ResetBlockParams| { &m.block_id },
|m: &mut ResetDocumentParams| { &mut m.doc_id }, |m: &mut ResetBlockParams| { &mut m.block_id },
)); ));
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<super::revision::RepeatedRevision>>( fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<super::revision::RepeatedRevision>>(
"revisions", "revisions",
|m: &ResetDocumentParams| { &m.revisions }, |m: &ResetBlockParams| { &m.revisions },
|m: &mut ResetDocumentParams| { &mut m.revisions }, |m: &mut ResetBlockParams| { &mut m.revisions },
)); ));
::protobuf::reflect::MessageDescriptor::new_pb_name::<ResetDocumentParams>( ::protobuf::reflect::MessageDescriptor::new_pb_name::<ResetBlockParams>(
"ResetDocumentParams", "ResetBlockParams",
fields, fields,
file_descriptor_proto() file_descriptor_proto()
) )
}) })
} }
fn default_instance() -> &'static ResetDocumentParams { fn default_instance() -> &'static ResetBlockParams {
static instance: ::protobuf::rt::LazyV2<ResetDocumentParams> = ::protobuf::rt::LazyV2::INIT; static instance: ::protobuf::rt::LazyV2<ResetBlockParams> = ::protobuf::rt::LazyV2::INIT;
instance.get(ResetDocumentParams::new) instance.get(ResetBlockParams::new)
} }
} }
impl ::protobuf::Clear for ResetDocumentParams { impl ::protobuf::Clear for ResetBlockParams {
fn clear(&mut self) { fn clear(&mut self) {
self.doc_id.clear(); self.block_id.clear();
self.revisions.clear(); self.revisions.clear();
self.unknown_fields.clear(); self.unknown_fields.clear();
} }
} }
impl ::std::fmt::Debug for ResetDocumentParams { impl ::std::fmt::Debug for ResetBlockParams {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f) ::protobuf::text_format::fmt(self, f)
} }
} }
impl ::protobuf::reflect::ProtobufValue for ResetDocumentParams { impl ::protobuf::reflect::ProtobufValue for ResetBlockParams {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self) ::protobuf::reflect::ReflectValueRef::Message(self)
} }
@ -1325,17 +1325,18 @@ impl ::protobuf::reflect::ProtobufValue for BlockId {
static file_descriptor_proto_data: &'static [u8] = b"\ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x13document_info.proto\x1a\x0erevision.proto\"T\n\x11CreateBlockParam\ \n\x13document_info.proto\x1a\x0erevision.proto\"T\n\x11CreateBlockParam\
s\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12/\n\trevisions\x18\x02\ s\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12/\n\trevisions\x18\x02\
\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"m\n\tBlockInfo\x12\x15\ \x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"q\n\tBlockInfo\x12\x19\
\n\x06doc_id\x18\x01\x20\x01(\tR\x05docId\x12\x12\n\x04text\x18\x02\x20\ \n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\x12\n\x04text\x18\x02\
\x01(\tR\x04text\x12\x15\n\x06rev_id\x18\x03\x20\x01(\x03R\x05revId\x12\ \x20\x01(\tR\x04text\x12\x15\n\x06rev_id\x18\x03\x20\x01(\x03R\x05revId\
\x1e\n\x0bbase_rev_id\x18\x04\x20\x01(\x03R\tbaseRevId\"]\n\x13ResetDocu\ \x12\x1e\n\x0bbase_rev_id\x18\x04\x20\x01(\x03R\tbaseRevId\"^\n\x10Reset\
mentParams\x12\x15\n\x06doc_id\x18\x01\x20\x01(\tR\x05docId\x12/\n\trevi\ BlockParams\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12/\n\
sions\x18\x02\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"F\n\nBlock\ \trevisions\x18\x02\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"F\n\
Delta\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\x1d\n\nde\ \nBlockDelta\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\
lta_json\x18\x02\x20\x01(\tR\tdeltaJson\"S\n\nNewDocUser\x12\x17\n\x07us\ \x1d\n\ndelta_json\x18\x02\x20\x01(\tR\tdeltaJson\"S\n\nNewDocUser\x12\
er_id\x18\x01\x20\x01(\tR\x06userId\x12\x15\n\x06rev_id\x18\x02\x20\x01(\ \x17\n\x07user_id\x18\x01\x20\x01(\tR\x06userId\x12\x15\n\x06rev_id\x18\
\x03R\x05revId\x12\x15\n\x06doc_id\x18\x03\x20\x01(\tR\x05docId\"\x1f\n\ \x02\x20\x01(\x03R\x05revId\x12\x15\n\x06doc_id\x18\x03\x20\x01(\tR\x05d\
\x07BlockId\x12\x14\n\x05value\x18\x01\x20\x01(\tR\x05valueb\x06proto3\ ocId\"\x1f\n\x07BlockId\x12\x14\n\x05value\x18\x01\x20\x01(\tR\x05valueb\
\x06proto3\
"; ";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -6,13 +6,13 @@ message CreateBlockParams {
RepeatedRevision revisions = 2; RepeatedRevision revisions = 2;
} }
message BlockInfo { message BlockInfo {
string doc_id = 1; string block_id = 1;
string text = 2; string text = 2;
int64 rev_id = 3; int64 rev_id = 3;
int64 base_rev_id = 4; int64 base_rev_id = 4;
} }
message ResetDocumentParams { message ResetBlockParams {
string doc_id = 1; string block_id = 1;
RepeatedRevision revisions = 2; RepeatedRevision revisions = 2;
} }
message BlockDelta { message BlockDelta {

View File

@ -206,7 +206,7 @@ struct OpenDocumentHandler {
impl OpenDocumentHandler { impl OpenDocumentHandler {
fn new(doc: BlockInfo, persistence: Arc<dyn DocumentCloudPersistence>) -> Result<Self, CollaborateError> { fn new(doc: BlockInfo, persistence: Arc<dyn DocumentCloudPersistence>) -> Result<Self, CollaborateError> {
let doc_id = doc.doc_id.clone(); let doc_id = doc.block_id.clone();
let (sender, receiver) = mpsc::channel(1000); let (sender, receiver) = mpsc::channel(1000);
let users = DashMap::new(); let users = DashMap::new();
@ -214,7 +214,7 @@ impl OpenDocumentHandler {
let sync_object = ServerDocument::from_delta(&doc_id, delta); let sync_object = ServerDocument::from_delta(&doc_id, delta);
let synchronizer = Arc::new(DocumentRevisionSynchronizer::new(doc.rev_id, sync_object, persistence)); let synchronizer = Arc::new(DocumentRevisionSynchronizer::new(doc.rev_id, sync_object, persistence));
let queue = DocumentCommandRunner::new(&doc.doc_id, receiver, synchronizer); let queue = DocumentCommandRunner::new(&doc.block_id, receiver, synchronizer);
tokio::task::spawn(queue.run()); tokio::task::spawn(queue.run());
Ok(Self { doc_id, sender, users }) Ok(Self { doc_id, sender, users })
} }

View File

@ -239,7 +239,7 @@ pub fn make_document_info_pb_from_revisions_pb(
let text = document_delta.to_delta_json(); let text = document_delta.to_delta_json();
let mut block_info = BlockInfoPB::new(); let mut block_info = BlockInfoPB::new();
block_info.set_doc_id(doc_id.to_owned()); block_info.set_block_id(doc_id.to_owned());
block_info.set_text(text); block_info.set_text(text);
block_info.set_base_rev_id(base_rev_id); block_info.set_base_rev_id(base_rev_id);
block_info.set_rev_id(rev_id); block_info.set_rev_id(rev_id);

View File

@ -207,13 +207,12 @@ fn token_stream_for_vec(ctxt: &Ctxt, member: &syn::Member, bracketed_type: &TyIn
} }
} }
fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, bracketed_type: &TyInfo) -> Option<TokenStream> { fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty_info: &TyInfo) -> Option<TokenStream> {
let ident = get_member_ident(ctxt, member)?; let ident = get_member_ident(ctxt, member)?;
let take_ident = format_ident!("take_{}", ident.to_string()); let take_ident = format_ident!("take_{}", ident.to_string());
let ty = bracketed_type.ty; let ty = ty_info.ty;
match ident_category(bracketed_type.ident) { match ident_category(ty_info.ident) {
TypeCategory::Protobuf => Some(quote! { TypeCategory::Protobuf => Some(quote! {
let mut m: std::collections::HashMap<String, #ty> = std::collections::HashMap::new(); let mut m: std::collections::HashMap<String, #ty> = std::collections::HashMap::new();
pb.#take_ident().into_iter().for_each(|(k,v)| { pb.#take_ident().into_iter().for_each(|(k,v)| {

View File

@ -89,7 +89,7 @@ fn gen_token_stream(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type, is_option
} }
}?; }?;
match ident_category(ty_info.ident) { match ident_category(ty_info.ident) {
TypeCategory::Array => token_stream_for_vec(ctxt, member, ty_info.ty), TypeCategory::Array => token_stream_for_vec(ctxt, member, ty_info.bracket_ty_info.unwrap().ty),
TypeCategory::Map => token_stream_for_map(ctxt, member, ty_info.bracket_ty_info.unwrap().ty), TypeCategory::Map => token_stream_for_map(ctxt, member, ty_info.bracket_ty_info.unwrap().ty),
TypeCategory::Str => { TypeCategory::Str => {
if is_option { if is_option {
@ -149,7 +149,6 @@ fn token_stream_for_vec(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Op
// e.g. pub cells: HashMap<xx, xx> // e.g. pub cells: HashMap<xx, xx>
fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Option<TokenStream> { fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Option<TokenStream> {
// The key of the hashmap must be string // The key of the hashmap must be string
let flowy_protobuf = format_ident!("flowy_protobuf");
let ty_info = match parse_ty(ctxt, ty) { let ty_info = match parse_ty(ctxt, ty) {
Ok(ty_info) => ty_info, Ok(ty_info) => ty_info,
Err(e) => { Err(e) => {
@ -157,27 +156,21 @@ fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Op
panic!(); panic!();
} }
}?; }?;
let value_ty = ty_info.ty;
match ident_category(ty_info.ident) { match ident_category(ty_info.ident) {
TypeCategory::Protobuf => { TypeCategory::Protobuf => Some(quote! {
let value_type = ty_info.ident; let mut m: std::collections::HashMap<String, crate::protobuf::#value_ty> = std::collections::HashMap::new();
Some(quote! { self.#member.into_iter().for_each(|(k,v)| {
let mut m: std::collections::HashMap<String, #flowy_protobuf::#value_type> = std::collections::HashMap::new(); m.insert(k.clone(), v.try_into().unwrap());
self.#member.iter().for_each(|(k,v)| { });
m.insert(k.clone(), v.try_into().unwrap()); pb.#member = m;
}); }),
pb.#member = m; _ => Some(quote! {
}) let mut m: std::collections::HashMap<String, #value_ty> = std::collections::HashMap::new();
} self.#member.iter().for_each(|(k,v)| {
m.insert(k.clone(), v.clone());
_ => { });
let value_type = ty_info.ident; pb.#member = m;
Some(quote! { }),
let mut m: std::collections::HashMap<String, #flowy_protobuf::#value_type> = std::collections::HashMap::new();
self.#member.iter().for_each(|(k,v)| {
m.insert(k.clone(), v.clone());
});
pb.#member = m;
})
}
} }
} }

View File

@ -0,0 +1,20 @@
[package]
name = "flowy-grid-data-model"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
flowy-derive = { path = "../flowy-derive" }
protobuf = {version = "2.18.0"}
bytes = "1.0"
[build-dependencies]
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
[features]
default = []
backend = []
frontend = []
dart = ["lib-infra/dart"]

View File

@ -0,0 +1,3 @@
proto_crates = ["src/entities",]
event_files = []

View File

@ -0,0 +1,5 @@
use lib_infra::code_gen;
fn main() {
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"), "./src/protobuf/proto");
}

View File

@ -0,0 +1,148 @@
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use std::collections::HashMap;
#[derive(Debug, Default, ProtoBuf)]
pub struct Grid {
#[pb(index = 1)]
pub grid_id: String,
#[pb(index = 2)]
pub filters: RepeatedGridFilter,
#[pb(index = 3)]
pub field_orders: RepeatedFieldOrder,
#[pb(index = 4)]
pub row_orders: RepeatedRowOrder,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct GridFilter {
#[pb(index = 1)]
pub id: String,
#[pb(index = 2)]
pub name: String,
#[pb(index = 3)]
pub desc: String,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct RepeatedGridFilter {
#[pb(index = 1)]
pub items: Vec<GridFilter>,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct FieldOrder {
#[pb(index = 1)]
pub field_id: String,
#[pb(index = 2)]
pub visibility: bool,
#[pb(index = 3)]
pub width: i32,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct RepeatedFieldOrder {
#[pb(index = 1)]
pub items: Vec<FieldOrder>,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct Field {
#[pb(index = 1)]
pub id: String,
#[pb(index = 2)]
pub name: String,
#[pb(index = 3)]
pub desc: String,
#[pb(index = 4)]
pub field_type: FieldType,
#[pb(index = 5)]
pub frozen: bool,
#[pb(index = 6)]
pub type_options: AnyData,
}
#[derive(Debug, ProtoBuf_Enum)]
pub enum FieldType {
RichText = 0,
Number = 1,
DateTime = 2,
SingleSelect = 3,
MultiSelect = 4,
Checkbox = 5,
}
impl std::default::Default for FieldType {
fn default() -> Self {
FieldType::RichText
}
}
#[derive(Debug, Default, ProtoBuf)]
pub struct AnyData {
#[pb(index = 1)]
pub type_url: String,
#[pb(index = 2)]
pub value: Vec<u8>,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct RowOrder {
#[pb(index = 1)]
pub grid_id: String,
#[pb(index = 2)]
pub row_id: String,
#[pb(index = 3)]
pub visibility: bool,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct RepeatedRowOrder {
#[pb(index = 1)]
pub items: Vec<RowOrder>,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct Row {
#[pb(index = 1)]
pub id: String,
#[pb(index = 2)]
pub grid_id: String,
#[pb(index = 3)]
pub modified_time: i64,
#[pb(index = 4)]
pub cell_by_field_id: HashMap<String, Cell>,
}
#[derive(Debug, Default, ProtoBuf)]
pub struct Cell {
#[pb(index = 1)]
pub id: String,
#[pb(index = 2)]
pub row_id: String,
#[pb(index = 3)]
pub field_id: String,
#[pb(index = 4)]
pub data: AnyData,
}

View File

@ -0,0 +1,3 @@
mod grid;
pub use grid::*;

View File

@ -0,0 +1,2 @@
pub mod entities;
pub mod protobuf;

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod grid;
pub use grid::*;

View File

@ -0,0 +1,64 @@
syntax = "proto3";
message Grid {
string grid_id = 1;
RepeatedGridFilter filters = 2;
RepeatedFieldOrder field_orders = 3;
RepeatedRowOrder row_orders = 4;
}
message GridFilter {
string id = 1;
string name = 2;
string desc = 3;
}
message RepeatedGridFilter {
repeated GridFilter items = 1;
}
message FieldOrder {
string field_id = 1;
bool visibility = 2;
int32 width = 3;
}
message RepeatedFieldOrder {
repeated FieldOrder items = 1;
}
message Field {
string id = 1;
string name = 2;
string desc = 3;
FieldType field_type = 4;
bool frozen = 5;
AnyData type_options = 6;
}
message AnyData {
string type_url = 1;
bytes value = 2;
}
message RowOrder {
string grid_id = 1;
string row_id = 2;
bool visibility = 3;
}
message RepeatedRowOrder {
repeated RowOrder items = 1;
}
message Row {
string id = 1;
string grid_id = 2;
int64 modified_time = 3;
map<string, Cell> cell_by_field_id = 4;
}
message Cell {
string id = 1;
string row_id = 2;
string field_id = 3;
AnyData data = 4;
}
enum FieldType {
RichText = 0;
Number = 1;
DateTime = 2;
SingleSelect = 3;
MultiSelect = 4;
Checkbox = 5;
}