syntax = "proto3";

message GridMeta {
    string grid_id = 1;
    repeated FieldMeta fields = 2;
    repeated GridBlock blocks = 3;
}
message GridBlock {
    string id = 1;
    int32 start_row_index = 2;
    int32 row_count = 3;
}
message GridBlockMeta {
    string block_id = 1;
    repeated RowMeta rows = 2;
}
message FieldMeta {
    string id = 1;
    string name = 2;
    string desc = 3;
    FieldType field_type = 4;
    bool frozen = 5;
    bool visibility = 6;
    int32 width = 7;
    string type_options = 8;
}
message FieldChangeset {
    string field_id = 1;
    oneof one_of_name { string name = 2; };
    oneof one_of_desc { string desc = 3; };
    oneof one_of_field_type { FieldType field_type = 4; };
    oneof one_of_frozen { bool frozen = 5; };
    oneof one_of_visibility { bool visibility = 6; };
    oneof one_of_width { int32 width = 7; };
    oneof one_of_type_options { string type_options = 8; };
}
message AnyData {
    string type_id = 1;
    bytes value = 2;
}
message RowMeta {
    string id = 1;
    string block_id = 2;
    map<string, CellMeta> cell_by_field_id = 3;
    int32 height = 4;
    bool visibility = 5;
}
message RowMetaChangeset {
    string row_id = 1;
    oneof one_of_height { int32 height = 2; };
    oneof one_of_visibility { bool visibility = 3; };
    map<string, CellMeta> cell_by_field_id = 4;
}
message CellMeta {
    string field_id = 1;
    string data = 2;
}
message CellMetaChangeset {
    string grid_id = 1;
    string row_id = 2;
    string field_id = 3;
    oneof one_of_data { string data = 4; };
}
message BuildGridContext {
    repeated FieldMeta field_metas = 1;
    GridBlock grid_block = 2;
    GridBlockMeta grid_block_meta = 3;
}
enum FieldType {
    RichText = 0;
    Number = 1;
    DateTime = 2;
    SingleSelect = 3;
    MultiSelect = 4;
    Checkbox = 5;
}
