mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add grid struct
This commit is contained in:
parent
5549cff177
commit
4187e99433
@ -77,7 +77,7 @@ class CreateBlockParams 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)
|
||||
..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')
|
||||
..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revId')
|
||||
..aInt64(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'baseRevId')
|
||||
@ -86,14 +86,14 @@ class BlockInfo extends $pb.GeneratedMessage {
|
||||
|
||||
BlockInfo._() : super();
|
||||
factory BlockInfo({
|
||||
$core.String? docId,
|
||||
$core.String? blockId,
|
||||
$core.String? text,
|
||||
$fixnum.Int64? revId,
|
||||
$fixnum.Int64? baseRevId,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (docId != null) {
|
||||
_result.docId = docId;
|
||||
if (blockId != null) {
|
||||
_result.blockId = blockId;
|
||||
}
|
||||
if (text != null) {
|
||||
_result.text = text;
|
||||
@ -128,13 +128,13 @@ class BlockInfo extends $pb.GeneratedMessage {
|
||||
static BlockInfo? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get docId => $_getSZ(0);
|
||||
$core.String get blockId => $_getSZ(0);
|
||||
@$pb.TagNumber(1)
|
||||
set docId($core.String v) { $_setString(0, v); }
|
||||
set blockId($core.String v) { $_setString(0, v); }
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool hasDocId() => $_has(0);
|
||||
$core.bool hasBlockId() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearDocId() => clearField(1);
|
||||
void clearBlockId() => clearField(1);
|
||||
|
||||
@$pb.TagNumber(2)
|
||||
$core.String get text => $_getSZ(1);
|
||||
@ -164,56 +164,56 @@ class BlockInfo extends $pb.GeneratedMessage {
|
||||
void clearBaseRevId() => clearField(4);
|
||||
}
|
||||
|
||||
class ResetDocumentParams extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ResetDocumentParams', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId')
|
||||
class ResetBlockParams extends $pb.GeneratedMessage {
|
||||
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') ? '' : 'blockId')
|
||||
..aOM<$0.RepeatedRevision>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revisions', subBuilder: $0.RepeatedRevision.create)
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
ResetDocumentParams._() : super();
|
||||
factory ResetDocumentParams({
|
||||
$core.String? docId,
|
||||
ResetBlockParams._() : super();
|
||||
factory ResetBlockParams({
|
||||
$core.String? blockId,
|
||||
$0.RepeatedRevision? revisions,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (docId != null) {
|
||||
_result.docId = docId;
|
||||
if (blockId != null) {
|
||||
_result.blockId = blockId;
|
||||
}
|
||||
if (revisions != null) {
|
||||
_result.revisions = revisions;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory ResetDocumentParams.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.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory ResetBlockParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
||||
'Will be removed in next major version')
|
||||
ResetDocumentParams clone() => ResetDocumentParams()..mergeFromMessage(this);
|
||||
ResetBlockParams clone() => ResetBlockParams()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'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;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static ResetDocumentParams create() => ResetDocumentParams._();
|
||||
ResetDocumentParams createEmptyInstance() => create();
|
||||
static $pb.PbList<ResetDocumentParams> createRepeated() => $pb.PbList<ResetDocumentParams>();
|
||||
static ResetBlockParams create() => ResetBlockParams._();
|
||||
ResetBlockParams createEmptyInstance() => create();
|
||||
static $pb.PbList<ResetBlockParams> createRepeated() => $pb.PbList<ResetBlockParams>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static ResetDocumentParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ResetDocumentParams>(create);
|
||||
static ResetDocumentParams? _defaultInstance;
|
||||
static ResetBlockParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ResetBlockParams>(create);
|
||||
static ResetBlockParams? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get docId => $_getSZ(0);
|
||||
$core.String get blockId => $_getSZ(0);
|
||||
@$pb.TagNumber(1)
|
||||
set docId($core.String v) { $_setString(0, v); }
|
||||
set blockId($core.String v) { $_setString(0, v); }
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool hasDocId() => $_has(0);
|
||||
$core.bool hasBlockId() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearDocId() => clearField(1);
|
||||
void clearBlockId() => clearField(1);
|
||||
|
||||
@$pb.TagNumber(2)
|
||||
$0.RepeatedRevision get revisions => $_getN(1);
|
||||
|
@ -23,7 +23,7 @@ final $typed_data.Uint8List createBlockParamsDescriptor = $convert.base64Decode(
|
||||
const BlockInfo$json = const {
|
||||
'1': 'BlockInfo',
|
||||
'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': 'rev_id', '3': 3, '4': 1, '5': 3, '10': 'revId'},
|
||||
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`.
|
||||
final $typed_data.Uint8List blockInfoDescriptor = $convert.base64Decode('CglCbG9ja0luZm8SFQoGZG9jX2lkGAEgASgJUgVkb2NJZBISCgR0ZXh0GAIgASgJUgR0ZXh0EhUKBnJldl9pZBgDIAEoA1IFcmV2SWQSHgoLYmFzZV9yZXZfaWQYBCABKANSCWJhc2VSZXZJZA==');
|
||||
@$core.Deprecated('Use resetDocumentParamsDescriptor instead')
|
||||
const ResetDocumentParams$json = const {
|
||||
'1': 'ResetDocumentParams',
|
||||
final $typed_data.Uint8List blockInfoDescriptor = $convert.base64Decode('CglCbG9ja0luZm8SGQoIYmxvY2tfaWQYASABKAlSB2Jsb2NrSWQSEgoEdGV4dBgCIAEoCVIEdGV4dBIVCgZyZXZfaWQYAyABKANSBXJldklkEh4KC2Jhc2VfcmV2X2lkGAQgASgDUgliYXNlUmV2SWQ=');
|
||||
@$core.Deprecated('Use resetBlockParamsDescriptor instead')
|
||||
const ResetBlockParams$json = const {
|
||||
'1': 'ResetBlockParams',
|
||||
'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'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `ResetDocumentParams`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List resetDocumentParamsDescriptor = $convert.base64Decode('ChNSZXNldERvY3VtZW50UGFyYW1zEhUKBmRvY19pZBgBIAEoCVIFZG9jSWQSLwoJcmV2aXNpb25zGAIgASgLMhEuUmVwZWF0ZWRSZXZpc2lvblIJcmV2aXNpb25z');
|
||||
/// Descriptor for `ResetBlockParams`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List resetBlockParamsDescriptor = $convert.base64Decode('ChBSZXNldEJsb2NrUGFyYW1zEhkKCGJsb2NrX2lkGAEgASgJUgdibG9ja0lkEi8KCXJldmlzaW9ucxgCIAEoCzIRLlJlcGVhdGVkUmV2aXNpb25SCXJldmlzaW9ucw==');
|
||||
@$core.Deprecated('Use blockDeltaDescriptor instead')
|
||||
const BlockDelta$json = const {
|
||||
'1': 'BlockDelta',
|
||||
|
@ -225,7 +225,7 @@ impl RevisionObjectBuilder for BlockInfoBuilder {
|
||||
correct_delta(&mut delta);
|
||||
|
||||
Result::<BlockInfo, FlowyError>::Ok(BlockInfo {
|
||||
doc_id: object_id.to_owned(),
|
||||
block_id: object_id.to_owned(),
|
||||
text: delta.to_delta_json(),
|
||||
rev_id,
|
||||
base_rev_id,
|
||||
|
@ -11,7 +11,7 @@ pub mod errors {
|
||||
pub const DOCUMENT_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
|
||||
|
||||
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;
|
||||
|
||||
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 update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError>;
|
||||
fn update_block(&self, token: &str, params: ResetBlockParams) -> FutureResult<(), FlowyError>;
|
||||
}
|
||||
|
@ -162,8 +162,14 @@ impl RevisionCloudService for BlockRevisionCloudService {
|
||||
Some(doc) => {
|
||||
let delta_data = Bytes::from(doc.text.clone());
|
||||
let doc_md5 = md5(&delta_data);
|
||||
let revision =
|
||||
Revision::new(&doc.doc_id, doc.base_rev_id, doc.rev_id, delta_data, &user_id, doc_md5);
|
||||
let revision = Revision::new(
|
||||
&doc.block_id,
|
||||
doc.base_rev_id,
|
||||
doc.rev_id,
|
||||
delta_data,
|
||||
&user_id,
|
||||
doc_md5,
|
||||
);
|
||||
Ok(vec![revision])
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
configuration::*,
|
||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||
};
|
||||
use flowy_block::BlockCloudService;
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams};
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams};
|
||||
use flowy_document::BlockCloudService;
|
||||
use flowy_error::FlowyError;
|
||||
use http_flowy::response::FlowyResponse;
|
||||
use lazy_static::lazy_static;
|
||||
@ -33,7 +33,7 @@ impl BlockCloudService for BlockHttpCloudService {
|
||||
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 url = self.config.doc_url();
|
||||
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)
|
||||
}
|
||||
|
||||
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()
|
||||
.patch(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
|
@ -4,7 +4,7 @@ use bytes::Bytes;
|
||||
use flowy_collaboration::{
|
||||
client_document::default::initial_delta_string,
|
||||
entities::{
|
||||
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams},
|
||||
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams},
|
||||
ws_data::{ClientRevisionWSData, ClientRevisionWSDataType},
|
||||
},
|
||||
errors::CollaborateError,
|
||||
@ -416,7 +416,7 @@ impl BlockCloudService for LocalServer {
|
||||
|
||||
fn read_block(&self, _token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> {
|
||||
let doc = BlockInfo {
|
||||
doc_id: params.value,
|
||||
block_id: params.value,
|
||||
text: initial_delta_string(),
|
||||
rev_id: 0,
|
||||
base_rev_id: 0,
|
||||
@ -424,7 +424,7 @@ impl BlockCloudService for LocalServer {
|
||||
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(()) })
|
||||
}
|
||||
}
|
||||
|
10
shared-lib/Cargo.lock
generated
10
shared-lib/Cargo.lock
generated
@ -478,6 +478,16 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-grid-data-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"flowy-derive",
|
||||
"lib-infra",
|
||||
"protobuf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-user-data-model"
|
||||
version = "0.1.0"
|
||||
|
@ -9,6 +9,7 @@ members = [
|
||||
"flowy-derive",
|
||||
"flowy-ast",
|
||||
"flowy-error-code",
|
||||
"flowy-grid-data-model",
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
|
@ -17,7 +17,7 @@ pub struct CreateBlockParams {
|
||||
#[derive(ProtoBuf, Default, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct BlockInfo {
|
||||
#[pb(index = 1)]
|
||||
pub doc_id: String,
|
||||
pub block_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub text: String,
|
||||
@ -49,7 +49,7 @@ impl std::convert::TryFrom<Revision> for BlockInfo {
|
||||
let doc_json = delta.to_delta_json();
|
||||
|
||||
Ok(BlockInfo {
|
||||
doc_id: revision.object_id,
|
||||
block_id: revision.object_id,
|
||||
text: doc_json,
|
||||
rev_id: revision.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)]
|
||||
pub struct ResetDocumentParams {
|
||||
pub struct ResetBlockParams {
|
||||
#[pb(index = 1)]
|
||||
pub doc_id: String,
|
||||
pub block_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub revisions: RepeatedRevision,
|
||||
|
@ -242,7 +242,7 @@ impl ::protobuf::reflect::ProtobufValue for CreateBlockParams {
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct BlockInfo {
|
||||
// message fields
|
||||
pub doc_id: ::std::string::String,
|
||||
pub block_id: ::std::string::String,
|
||||
pub text: ::std::string::String,
|
||||
pub rev_id: i64,
|
||||
pub base_rev_id: i64,
|
||||
@ -262,30 +262,30 @@ impl BlockInfo {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
// string doc_id = 1;
|
||||
// string block_id = 1;
|
||||
|
||||
|
||||
pub fn get_doc_id(&self) -> &str {
|
||||
&self.doc_id
|
||||
pub fn get_block_id(&self) -> &str {
|
||||
&self.block_id
|
||||
}
|
||||
pub fn clear_doc_id(&mut self) {
|
||||
self.doc_id.clear();
|
||||
pub fn clear_block_id(&mut self) {
|
||||
self.block_id.clear();
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_doc_id(&mut self, v: ::std::string::String) {
|
||||
self.doc_id = v;
|
||||
pub fn set_block_id(&mut self, v: ::std::string::String) {
|
||||
self.block_id = v;
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_doc_id(&mut self) -> &mut ::std::string::String {
|
||||
&mut self.doc_id
|
||||
pub fn mut_block_id(&mut self) -> &mut ::std::string::String {
|
||||
&mut self.block_id
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_doc_id(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.doc_id, ::std::string::String::new())
|
||||
pub fn take_block_id(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.block_id, ::std::string::String::new())
|
||||
}
|
||||
|
||||
// string text = 2;
|
||||
@ -355,7 +355,7 @@ impl ::protobuf::Message for BlockInfo {
|
||||
let (field_number, wire_type) = is.read_tag_unpack()?;
|
||||
match field_number {
|
||||
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 => {
|
||||
::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)]
|
||||
fn compute_size(&self) -> u32 {
|
||||
let mut my_size = 0;
|
||||
if !self.doc_id.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(1, &self.doc_id);
|
||||
if !self.block_id.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(1, &self.block_id);
|
||||
}
|
||||
if !self.text.is_empty() {
|
||||
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<()> {
|
||||
if !self.doc_id.is_empty() {
|
||||
os.write_string(1, &self.doc_id)?;
|
||||
if !self.block_id.is_empty() {
|
||||
os.write_string(1, &self.block_id)?;
|
||||
}
|
||||
if !self.text.is_empty() {
|
||||
os.write_string(2, &self.text)?;
|
||||
@ -455,9 +455,9 @@ impl ::protobuf::Message for BlockInfo {
|
||||
descriptor.get(|| {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"doc_id",
|
||||
|m: &BlockInfo| { &m.doc_id },
|
||||
|m: &mut BlockInfo| { &mut m.doc_id },
|
||||
"block_id",
|
||||
|m: &BlockInfo| { &m.block_id },
|
||||
|m: &mut BlockInfo| { &mut m.block_id },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"text",
|
||||
@ -490,7 +490,7 @@ impl ::protobuf::Message for BlockInfo {
|
||||
|
||||
impl ::protobuf::Clear for BlockInfo {
|
||||
fn clear(&mut self) {
|
||||
self.doc_id.clear();
|
||||
self.block_id.clear();
|
||||
self.text.clear();
|
||||
self.rev_id = 0;
|
||||
self.base_rev_id = 0;
|
||||
@ -511,50 +511,50 @@ impl ::protobuf::reflect::ProtobufValue for BlockInfo {
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct ResetDocumentParams {
|
||||
pub struct ResetBlockParams {
|
||||
// message fields
|
||||
pub doc_id: ::std::string::String,
|
||||
pub block_id: ::std::string::String,
|
||||
pub revisions: ::protobuf::SingularPtrField<super::revision::RepeatedRevision>,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a ResetDocumentParams {
|
||||
fn default() -> &'a ResetDocumentParams {
|
||||
<ResetDocumentParams as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a ResetBlockParams {
|
||||
fn default() -> &'a ResetBlockParams {
|
||||
<ResetBlockParams as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl ResetDocumentParams {
|
||||
pub fn new() -> ResetDocumentParams {
|
||||
impl ResetBlockParams {
|
||||
pub fn new() -> ResetBlockParams {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
// string doc_id = 1;
|
||||
// string block_id = 1;
|
||||
|
||||
|
||||
pub fn get_doc_id(&self) -> &str {
|
||||
&self.doc_id
|
||||
pub fn get_block_id(&self) -> &str {
|
||||
&self.block_id
|
||||
}
|
||||
pub fn clear_doc_id(&mut self) {
|
||||
self.doc_id.clear();
|
||||
pub fn clear_block_id(&mut self) {
|
||||
self.block_id.clear();
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_doc_id(&mut self, v: ::std::string::String) {
|
||||
self.doc_id = v;
|
||||
pub fn set_block_id(&mut self, v: ::std::string::String) {
|
||||
self.block_id = v;
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_doc_id(&mut self) -> &mut ::std::string::String {
|
||||
&mut self.doc_id
|
||||
pub fn mut_block_id(&mut self) -> &mut ::std::string::String {
|
||||
&mut self.block_id
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_doc_id(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.doc_id, ::std::string::String::new())
|
||||
pub fn take_block_id(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.block_id, ::std::string::String::new())
|
||||
}
|
||||
|
||||
// .RepeatedRevision revisions = 2;
|
||||
@ -591,7 +591,7 @@ impl ResetDocumentParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for ResetDocumentParams {
|
||||
impl ::protobuf::Message for ResetBlockParams {
|
||||
fn is_initialized(&self) -> bool {
|
||||
for v in &self.revisions {
|
||||
if !v.is_initialized() {
|
||||
@ -606,7 +606,7 @@ impl ::protobuf::Message for ResetDocumentParams {
|
||||
let (field_number, wire_type) = is.read_tag_unpack()?;
|
||||
match field_number {
|
||||
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 => {
|
||||
::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.revisions)?;
|
||||
@ -623,8 +623,8 @@ impl ::protobuf::Message for ResetDocumentParams {
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u32 {
|
||||
let mut my_size = 0;
|
||||
if !self.doc_id.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(1, &self.doc_id);
|
||||
if !self.block_id.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(1, &self.block_id);
|
||||
}
|
||||
if let Some(ref v) = self.revisions.as_ref() {
|
||||
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<()> {
|
||||
if !self.doc_id.is_empty() {
|
||||
os.write_string(1, &self.doc_id)?;
|
||||
if !self.block_id.is_empty() {
|
||||
os.write_string(1, &self.block_id)?;
|
||||
}
|
||||
if let Some(ref v) = self.revisions.as_ref() {
|
||||
os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?;
|
||||
@ -674,8 +674,8 @@ impl ::protobuf::Message for ResetDocumentParams {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> ResetDocumentParams {
|
||||
ResetDocumentParams::new()
|
||||
fn new() -> ResetBlockParams {
|
||||
ResetBlockParams::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -683,44 +683,44 @@ impl ::protobuf::Message for ResetDocumentParams {
|
||||
descriptor.get(|| {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"doc_id",
|
||||
|m: &ResetDocumentParams| { &m.doc_id },
|
||||
|m: &mut ResetDocumentParams| { &mut m.doc_id },
|
||||
"block_id",
|
||||
|m: &ResetBlockParams| { &m.block_id },
|
||||
|m: &mut ResetBlockParams| { &mut m.block_id },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<super::revision::RepeatedRevision>>(
|
||||
"revisions",
|
||||
|m: &ResetDocumentParams| { &m.revisions },
|
||||
|m: &mut ResetDocumentParams| { &mut m.revisions },
|
||||
|m: &ResetBlockParams| { &m.revisions },
|
||||
|m: &mut ResetBlockParams| { &mut m.revisions },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<ResetDocumentParams>(
|
||||
"ResetDocumentParams",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<ResetBlockParams>(
|
||||
"ResetBlockParams",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static ResetDocumentParams {
|
||||
static instance: ::protobuf::rt::LazyV2<ResetDocumentParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(ResetDocumentParams::new)
|
||||
fn default_instance() -> &'static ResetBlockParams {
|
||||
static instance: ::protobuf::rt::LazyV2<ResetBlockParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(ResetBlockParams::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for ResetDocumentParams {
|
||||
impl ::protobuf::Clear for ResetBlockParams {
|
||||
fn clear(&mut self) {
|
||||
self.doc_id.clear();
|
||||
self.block_id.clear();
|
||||
self.revisions.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 {
|
||||
::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 {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
@ -1325,17 +1325,18 @@ impl ::protobuf::reflect::ProtobufValue for BlockId {
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\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\
|
||||
\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"m\n\tBlockInfo\x12\x15\
|
||||
\n\x06doc_id\x18\x01\x20\x01(\tR\x05docId\x12\x12\n\x04text\x18\x02\x20\
|
||||
\x01(\tR\x04text\x12\x15\n\x06rev_id\x18\x03\x20\x01(\x03R\x05revId\x12\
|
||||
\x1e\n\x0bbase_rev_id\x18\x04\x20\x01(\x03R\tbaseRevId\"]\n\x13ResetDocu\
|
||||
mentParams\x12\x15\n\x06doc_id\x18\x01\x20\x01(\tR\x05docId\x12/\n\trevi\
|
||||
sions\x18\x02\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"F\n\nBlock\
|
||||
Delta\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\x1d\n\nde\
|
||||
lta_json\x18\x02\x20\x01(\tR\tdeltaJson\"S\n\nNewDocUser\x12\x17\n\x07us\
|
||||
er_id\x18\x01\x20\x01(\tR\x06userId\x12\x15\n\x06rev_id\x18\x02\x20\x01(\
|
||||
\x03R\x05revId\x12\x15\n\x06doc_id\x18\x03\x20\x01(\tR\x05docId\"\x1f\n\
|
||||
\x07BlockId\x12\x14\n\x05value\x18\x01\x20\x01(\tR\x05valueb\x06proto3\
|
||||
\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"q\n\tBlockInfo\x12\x19\
|
||||
\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\x12\n\x04text\x18\x02\
|
||||
\x20\x01(\tR\x04text\x12\x15\n\x06rev_id\x18\x03\x20\x01(\x03R\x05revId\
|
||||
\x12\x1e\n\x0bbase_rev_id\x18\x04\x20\x01(\x03R\tbaseRevId\"^\n\x10Reset\
|
||||
BlockParams\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12/\n\
|
||||
\trevisions\x18\x02\x20\x01(\x0b2\x11.RepeatedRevisionR\trevisions\"F\n\
|
||||
\nBlockDelta\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12\
|
||||
\x1d\n\ndelta_json\x18\x02\x20\x01(\tR\tdeltaJson\"S\n\nNewDocUser\x12\
|
||||
\x17\n\x07user_id\x18\x01\x20\x01(\tR\x06userId\x12\x15\n\x06rev_id\x18\
|
||||
\x02\x20\x01(\x03R\x05revId\x12\x15\n\x06doc_id\x18\x03\x20\x01(\tR\x05d\
|
||||
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;
|
||||
|
@ -6,13 +6,13 @@ message CreateBlockParams {
|
||||
RepeatedRevision revisions = 2;
|
||||
}
|
||||
message BlockInfo {
|
||||
string doc_id = 1;
|
||||
string block_id = 1;
|
||||
string text = 2;
|
||||
int64 rev_id = 3;
|
||||
int64 base_rev_id = 4;
|
||||
}
|
||||
message ResetDocumentParams {
|
||||
string doc_id = 1;
|
||||
message ResetBlockParams {
|
||||
string block_id = 1;
|
||||
RepeatedRevision revisions = 2;
|
||||
}
|
||||
message BlockDelta {
|
||||
|
@ -206,7 +206,7 @@ struct OpenDocumentHandler {
|
||||
|
||||
impl OpenDocumentHandler {
|
||||
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 users = DashMap::new();
|
||||
|
||||
@ -214,7 +214,7 @@ impl OpenDocumentHandler {
|
||||
let sync_object = ServerDocument::from_delta(&doc_id, delta);
|
||||
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());
|
||||
Ok(Self { doc_id, sender, users })
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ pub fn make_document_info_pb_from_revisions_pb(
|
||||
|
||||
let text = document_delta.to_delta_json();
|
||||
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_base_rev_id(base_rev_id);
|
||||
block_info.set_rev_id(rev_id);
|
||||
|
@ -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 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! {
|
||||
let mut m: std::collections::HashMap<String, #ty> = std::collections::HashMap::new();
|
||||
pb.#take_ident().into_iter().for_each(|(k,v)| {
|
||||
|
@ -89,7 +89,7 @@ fn gen_token_stream(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type, is_option
|
||||
}
|
||||
}?;
|
||||
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::Str => {
|
||||
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>
|
||||
fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Option<TokenStream> {
|
||||
// The key of the hashmap must be string
|
||||
let flowy_protobuf = format_ident!("flowy_protobuf");
|
||||
let ty_info = match parse_ty(ctxt, ty) {
|
||||
Ok(ty_info) => ty_info,
|
||||
Err(e) => {
|
||||
@ -157,27 +156,21 @@ fn token_stream_for_map(ctxt: &Ctxt, member: &syn::Member, ty: &syn::Type) -> Op
|
||||
panic!();
|
||||
}
|
||||
}?;
|
||||
let value_ty = ty_info.ty;
|
||||
match ident_category(ty_info.ident) {
|
||||
TypeCategory::Protobuf => {
|
||||
let value_type = ty_info.ident;
|
||||
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.try_into().unwrap());
|
||||
});
|
||||
pb.#member = m;
|
||||
})
|
||||
}
|
||||
|
||||
_ => {
|
||||
let value_type = ty_info.ident;
|
||||
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;
|
||||
})
|
||||
}
|
||||
TypeCategory::Protobuf => Some(quote! {
|
||||
let mut m: std::collections::HashMap<String, crate::protobuf::#value_ty> = std::collections::HashMap::new();
|
||||
self.#member.into_iter().for_each(|(k,v)| {
|
||||
m.insert(k.clone(), v.try_into().unwrap());
|
||||
});
|
||||
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());
|
||||
});
|
||||
pb.#member = m;
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
20
shared-lib/flowy-grid-data-model/Cargo.toml
Normal file
20
shared-lib/flowy-grid-data-model/Cargo.toml
Normal 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"]
|
3
shared-lib/flowy-grid-data-model/Flowy.toml
Normal file
3
shared-lib/flowy-grid-data-model/Flowy.toml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
proto_crates = ["src/entities",]
|
||||
event_files = []
|
5
shared-lib/flowy-grid-data-model/build.rs
Normal file
5
shared-lib/flowy-grid-data-model/build.rs
Normal file
@ -0,0 +1,5 @@
|
||||
use lib_infra::code_gen;
|
||||
|
||||
fn main() {
|
||||
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"), "./src/protobuf/proto");
|
||||
}
|
148
shared-lib/flowy-grid-data-model/src/entities/grid.rs
Normal file
148
shared-lib/flowy-grid-data-model/src/entities/grid.rs
Normal 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,
|
||||
}
|
3
shared-lib/flowy-grid-data-model/src/entities/mod.rs
Normal file
3
shared-lib/flowy-grid-data-model/src/entities/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod grid;
|
||||
|
||||
pub use grid::*;
|
2
shared-lib/flowy-grid-data-model/src/lib.rs
Normal file
2
shared-lib/flowy-grid-data-model/src/lib.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod entities;
|
||||
pub mod protobuf;
|
4
shared-lib/flowy-grid-data-model/src/protobuf/mod.rs
Normal file
4
shared-lib/flowy-grid-data-model/src/protobuf/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
// Auto-generated, do not edit
|
||||
mod model;
|
||||
pub use model::*;
|
2811
shared-lib/flowy-grid-data-model/src/protobuf/model/grid.rs
Normal file
2811
shared-lib/flowy-grid-data-model/src/protobuf/model/grid.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
// Auto-generated, do not edit
|
||||
|
||||
mod grid;
|
||||
pub use grid::*;
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user