From 559f6e1d951c093c46a811009daebb44e7b5cd9b Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Mon, 18 Nov 2024 21:39:16 +0100 Subject: [PATCH 1/3] Implement datatypes into sagittarius protocol --- proto/sagittarius/datatype.proto | 53 ++++++++++++++++++++++++++++++++ proto/shared/translations.proto | 10 ++++++ 2 files changed, 63 insertions(+) create mode 100644 proto/sagittarius/datatype.proto create mode 100644 proto/shared/translations.proto diff --git a/proto/sagittarius/datatype.proto b/proto/sagittarius/datatype.proto new file mode 100644 index 0000000..ecab9ee --- /dev/null +++ b/proto/sagittarius/datatype.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +import "translations.proto"; +import "google/protobuf/any.proto"; + +option ruby_package = "Tucana::Sagittarius"; + +package sagittarius; + +message DataType { + enum Variant { + UNKNOWN = 0; + PRIMITIVE = 1; + TYPE = 2; + OBJECT = 3; + DATATYPE = 4; + ARRAY = 5; + GENERIC = 6; + FUNCTION = 7; + } + + shared.Translation name = 1; + Variant variant = 2; + repeated DataTypeRule rules = 3; + repeated DataType input_types = 4; + optional DataType return_type = 5; + optional DataType parent_type = 6; +} + +message DataTypeRule { + enum Variant { + UNKNOWN = 0; + REGEX = 1; + NUMBER_RANGE = 2; + ITEM_OF_COLLECTION = 3; + CONTAINS_TYPE = 4; + CONTAINS_KEY = 5; + } + + Variant variant = 1; + map config = 2; +} + +message DataTypeUpdateRequest { + repeated DataType data_types = 1; +} + +message DataTypeUpdateResponse { + bool success = 1; +} + +service DataTypeService { + rpc Update(DataTypeUpdateRequest) returns (DataTypeUpdateResponse) {} +} diff --git a/proto/shared/translations.proto b/proto/shared/translations.proto new file mode 100644 index 0000000..11daf6c --- /dev/null +++ b/proto/shared/translations.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Shared"; + +package shared; + +message Translation { + string code = 1; + string text = 2; +} From 405a0dd5514482fa50785873885d0cfb6a69522b Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Mon, 18 Nov 2024 21:40:30 +0100 Subject: [PATCH 2/3] Adjust ruby generation for external proto files --- build/ruby/Rakefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/ruby/Rakefile b/build/ruby/Rakefile index 546f73e..8f6dfcf 100644 --- a/build/ruby/Rakefile +++ b/build/ruby/Rakefile @@ -40,7 +40,15 @@ namespace :generate_ruby do Dir["#{output_dir}/*_pb.rb"].each do |file| code = File.read(file) - code = code.gsub(/require '(\S+)_pb'/, "require_relative '\\1_pb'") + code = code.gsub(/require '(\S+)_pb'/) do |str| + match = Regexp.last_match[1] + + if File.exist?("#{output_dir}/#{match}_pb.rb") + "require_relative '#{match}_pb'" + else + str + end + end File.write(file, code) end end From e8e9b55170174a7ec10938a6962354aedd96dc2f Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Fri, 22 Nov 2024 18:40:30 +0100 Subject: [PATCH 3/3] Move messages for datatypes to shared --- proto/sagittarius/datatype.proto | 39 ++---------------------- proto/shared/datatype_definition.proto | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 37 deletions(-) create mode 100644 proto/shared/datatype_definition.proto diff --git a/proto/sagittarius/datatype.proto b/proto/sagittarius/datatype.proto index ecab9ee..5946994 100644 --- a/proto/sagittarius/datatype.proto +++ b/proto/sagittarius/datatype.proto @@ -1,47 +1,12 @@ syntax = "proto3"; -import "translations.proto"; -import "google/protobuf/any.proto"; +import "datatype_definition.proto"; option ruby_package = "Tucana::Sagittarius"; package sagittarius; -message DataType { - enum Variant { - UNKNOWN = 0; - PRIMITIVE = 1; - TYPE = 2; - OBJECT = 3; - DATATYPE = 4; - ARRAY = 5; - GENERIC = 6; - FUNCTION = 7; - } - - shared.Translation name = 1; - Variant variant = 2; - repeated DataTypeRule rules = 3; - repeated DataType input_types = 4; - optional DataType return_type = 5; - optional DataType parent_type = 6; -} - -message DataTypeRule { - enum Variant { - UNKNOWN = 0; - REGEX = 1; - NUMBER_RANGE = 2; - ITEM_OF_COLLECTION = 3; - CONTAINS_TYPE = 4; - CONTAINS_KEY = 5; - } - - Variant variant = 1; - map config = 2; -} - message DataTypeUpdateRequest { - repeated DataType data_types = 1; + repeated shared.DataType data_types = 1; } message DataTypeUpdateResponse { diff --git a/proto/shared/datatype_definition.proto b/proto/shared/datatype_definition.proto new file mode 100644 index 0000000..1ca52f2 --- /dev/null +++ b/proto/shared/datatype_definition.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; +import "google/protobuf/any.proto"; +import "translations.proto"; + +option ruby_package = "Tucana::Shared"; + +package shared; + +message DataType { + enum Variant { + UNKNOWN = 0; + PRIMITIVE = 1; + TYPE = 2; + OBJECT = 3; + DATATYPE = 4; + ARRAY = 5; + GENERIC = 6; + FUNCTION = 7; + } + + Translation name = 1; + Variant variant = 2; + repeated DataTypeRule rules = 3; + repeated DataType input_types = 4; + optional DataType return_type = 5; + optional DataType parent_type = 6; +} + +message DataTypeRule { + enum Variant { + UNKNOWN = 0; + REGEX = 1; + NUMBER_RANGE = 2; + ITEM_OF_COLLECTION = 3; + CONTAINS_TYPE = 4; + CONTAINS_KEY = 5; + } + + Variant variant = 1; + map config = 2; +}