Skip to content

Commit

Permalink
feat: Update protobufs to latest models
Browse files Browse the repository at this point in the history
  • Loading branch information
cvauclair committed Jan 9, 2025
1 parent 250b523 commit 42e770b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 87 deletions.
4 changes: 1 addition & 3 deletions sdk/proto/geo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,11 @@ message GeoOutput {
repeated GeoPersonalSpaceAdminPluginCreated personal_plugins_created = 12;
repeated MemberRemoved members_removed = 13;
repeated EditorRemoved editors_removed = 14;

repeated PublishEditProposalCreated edits = 15;

repeated AddMemberProposalCreated proposed_added_members = 16;
repeated RemoveMemberProposalCreated proposed_removed_members = 17;
repeated AddEditorProposalCreated proposed_added_editors = 18;
repeated RemoveEditorProposalCreated proposed_removed_editors = 19;
repeated AddSubspaceProposalCreated proposed_added_subspaces = 20;
repeated RemoveSubspaceProposalCreated proposed_removed_subspaces = 21;
}
}
64 changes: 31 additions & 33 deletions sdk/proto/ipfs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ message IpfsMetadata {
// independently of other proposal types.
string version = 1;
ActionType type = 2;
string id = 3;
string name = 4;
}

message Edit {
Expand All @@ -28,16 +26,19 @@ message ImportEdit {
string name = 4;
repeated Op ops = 5;
repeated string authors = 6;
string createdBy = 7;
string createdAt = 8;
string blockHash = 9;
string blockNumber = 10;
string transactionHash = 11;
string created_by = 7;
string created_at = 8;
string block_hash = 9;
string block_number = 10;
string transaction_hash = 11;
}

message Op {
OpType type = 1;
Triple triple = 2;
Entity entity = 3;
Relation relation = 4;
repeated Triple triples = 5;
}

message Triple {
Expand All @@ -51,14 +52,31 @@ message Value {
string value = 2;
}

message Relation {
string id = 1;
string type = 2;
string from_entity = 3;
string to_entity = 4;
string index = 5;
}

message Entity {
string id = 1;
repeated string types = 2;
}

enum OpType {
NONE = 0;
OP_TYPE_UNKNOWN = 0;
SET_TRIPLE = 1;
DELETE_TRIPLE = 2;
SET_TRIPLE_BATCH = 3;
DELETE_ENTITY = 4;
CREATE_RELATION = 5;
DELETE_RELATION = 6;
}

enum ValueType {
UNKNOWN = 0;
VALUE_TYPE_UNKNOWN = 0;
TEXT = 1;
NUMBER = 2;
CHECKBOX = 3;
Expand All @@ -67,44 +85,24 @@ enum ValueType {
POINT = 6;
}

message Membership {
ActionType type = 1;
string name = 2;
string version = 3;
string id = 4;
string user = 5;
}

message Subspace {
ActionType type = 1;
string name = 2;
string version = 3;
string id = 4;
string subspace = 5;
}

enum ActionType {
EMPTY = 0;
ACTION_TYPE_UNKNOWN = 0;
ADD_EDIT = 1;
ADD_SUBSPACE = 2;
REMOVE_SUBSPACE = 3;
IMPORT_SPACE = 4;
ARCHIVE_SPACE = 5;
ADD_EDITOR = 6;
REMOVE_EDITOR = 7;
ADD_MEMBER = 8;
REMOVE_MEMBER = 9;
}

message Import {
string version = 1;
ActionType type = 2;
string previousNetwork = 3;
string previousContractAddress = 4;
string previous_network = 3;
string previous_contract_address = 4;
repeated string edits = 5;
}

message Options {
string format = 1;
string crop = 2;
}
}
14 changes: 4 additions & 10 deletions sdk/src/models/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,22 @@ use super::BlockMetadata;
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ProposalType {
AddEdit,
ImportSpace,
AddSubspace,
RemoveSubspace,
AddEditor,
RemoveEditor,
AddMember,
RemoveMember,
ImportSpace,
ArchiveSpace,
}

impl TryFrom<pb::ipfs::ActionType> for ProposalType {
type Error = String;

fn try_from(action_type: pb::ipfs::ActionType) -> Result<Self, Self::Error> {
match action_type {
pb::ipfs::ActionType::AddMember => Ok(Self::AddMember),
pb::ipfs::ActionType::RemoveMember => Ok(Self::RemoveMember),
pb::ipfs::ActionType::AddEditor => Ok(Self::AddEditor),
pb::ipfs::ActionType::RemoveEditor => Ok(Self::RemoveEditor),
pb::ipfs::ActionType::AddEdit => Ok(Self::AddEdit),
pb::ipfs::ActionType::AddSubspace => Ok(Self::AddSubspace),
pb::ipfs::ActionType::RemoveSubspace => Ok(Self::RemoveSubspace),
pb::ipfs::ActionType::AddEdit => Ok(Self::AddEdit),
pb::ipfs::ActionType::ImportSpace => Ok(Self::ImportSpace),
pb::ipfs::ActionType::ArchiveSpace => Ok(Self::ArchiveSpace),
_ => Err(format!("Invalid action type: {:?}", action_type)),
}
}
Expand Down
78 changes: 37 additions & 41 deletions sdk/src/pb/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ pub struct IpfsMetadata {
pub version: ::prost::alloc::string::String,
#[prost(enumeration="ActionType", tag="2")]
pub r#type: i32,
#[prost(string, tag="3")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -64,6 +60,12 @@ pub struct Op {
pub r#type: i32,
#[prost(message, optional, tag="2")]
pub triple: ::core::option::Option<Triple>,
#[prost(message, optional, tag="3")]
pub entity: ::core::option::Option<Entity>,
#[prost(message, optional, tag="4")]
pub relation: ::core::option::Option<Relation>,
#[prost(message, repeated, tag="5")]
pub triples: ::prost::alloc::vec::Vec<Triple>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -85,31 +87,25 @@ pub struct Value {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Membership {
#[prost(enumeration="ActionType", tag="1")]
pub r#type: i32,
pub struct Relation {
#[prost(string, tag="1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
pub r#type: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub version: ::prost::alloc::string::String,
pub from_entity: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub id: ::prost::alloc::string::String,
pub to_entity: ::prost::alloc::string::String,
#[prost(string, tag="5")]
pub user: ::prost::alloc::string::String,
pub index: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Subspace {
#[prost(enumeration="ActionType", tag="1")]
pub r#type: i32,
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub version: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub struct Entity {
#[prost(string, tag="1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag="5")]
pub subspace: ::prost::alloc::string::String,
#[prost(string, repeated, tag="2")]
pub types: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -136,9 +132,13 @@ pub struct Options {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OpType {
None = 0,
Unknown = 0,
SetTriple = 1,
DeleteTriple = 2,
SetTripleBatch = 3,
DeleteEntity = 4,
CreateRelation = 5,
DeleteRelation = 6,
}
impl OpType {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -147,17 +147,25 @@ impl OpType {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
OpType::None => "NONE",
OpType::Unknown => "OP_TYPE_UNKNOWN",
OpType::SetTriple => "SET_TRIPLE",
OpType::DeleteTriple => "DELETE_TRIPLE",
OpType::SetTripleBatch => "SET_TRIPLE_BATCH",
OpType::DeleteEntity => "DELETE_ENTITY",
OpType::CreateRelation => "CREATE_RELATION",
OpType::DeleteRelation => "DELETE_RELATION",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"NONE" => Some(Self::None),
"OP_TYPE_UNKNOWN" => Some(Self::Unknown),
"SET_TRIPLE" => Some(Self::SetTriple),
"DELETE_TRIPLE" => Some(Self::DeleteTriple),
"SET_TRIPLE_BATCH" => Some(Self::SetTripleBatch),
"DELETE_ENTITY" => Some(Self::DeleteEntity),
"CREATE_RELATION" => Some(Self::CreateRelation),
"DELETE_RELATION" => Some(Self::DeleteRelation),
_ => None,
}
}
Expand All @@ -180,7 +188,7 @@ impl ValueType {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ValueType::Unknown => "UNKNOWN",
ValueType::Unknown => "VALUE_TYPE_UNKNOWN",
ValueType::Text => "TEXT",
ValueType::Number => "NUMBER",
ValueType::Checkbox => "CHECKBOX",
Expand All @@ -192,7 +200,7 @@ impl ValueType {
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"VALUE_TYPE_UNKNOWN" => Some(Self::Unknown),
"TEXT" => Some(Self::Text),
"NUMBER" => Some(Self::Number),
"CHECKBOX" => Some(Self::Checkbox),
Expand All @@ -206,16 +214,12 @@ impl ValueType {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ActionType {
Empty = 0,
Unknown = 0,
AddEdit = 1,
AddSubspace = 2,
RemoveSubspace = 3,
ImportSpace = 4,
ArchiveSpace = 5,
AddEditor = 6,
RemoveEditor = 7,
AddMember = 8,
RemoveMember = 9,
}
impl ActionType {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -224,31 +228,23 @@ impl ActionType {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ActionType::Empty => "EMPTY",
ActionType::Unknown => "ACTION_TYPE_UNKNOWN",
ActionType::AddEdit => "ADD_EDIT",
ActionType::AddSubspace => "ADD_SUBSPACE",
ActionType::RemoveSubspace => "REMOVE_SUBSPACE",
ActionType::ImportSpace => "IMPORT_SPACE",
ActionType::ArchiveSpace => "ARCHIVE_SPACE",
ActionType::AddEditor => "ADD_EDITOR",
ActionType::RemoveEditor => "REMOVE_EDITOR",
ActionType::AddMember => "ADD_MEMBER",
ActionType::RemoveMember => "REMOVE_MEMBER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"EMPTY" => Some(Self::Empty),
"ACTION_TYPE_UNKNOWN" => Some(Self::Unknown),
"ADD_EDIT" => Some(Self::AddEdit),
"ADD_SUBSPACE" => Some(Self::AddSubspace),
"REMOVE_SUBSPACE" => Some(Self::RemoveSubspace),
"IMPORT_SPACE" => Some(Self::ImportSpace),
"ARCHIVE_SPACE" => Some(Self::ArchiveSpace),
"ADD_EDITOR" => Some(Self::AddEditor),
"REMOVE_EDITOR" => Some(Self::RemoveEditor),
"ADD_MEMBER" => Some(Self::AddMember),
"REMOVE_MEMBER" => Some(Self::RemoveMember),
_ => None,
}
}
Expand Down

0 comments on commit 42e770b

Please sign in to comment.