diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 8df16a08..705caedd 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -27,6 +27,10 @@ service TableDefinition { // This provides a tree-like overview of table relationships. rpc GetProfileTree(komp_ac.common.Empty) returns (ProfileTreeResponse); + // Lists every column type a table may declare, along with the SQL type it + // maps to. Pure data retrieval - no business logic. + rpc ListColumnTypes(komp_ac.common.Empty) returns (ListColumnTypesResponse); + // Fetches all tables with their columns and scripts for a specific profile. // Pure data retrieval - no business logic. rpc GetProfileDetails(GetProfileDetailsRequest) returns (GetProfileDetailsResponse); @@ -357,3 +361,19 @@ message DeleteTableResponse { // Human-readable summary of what was removed. string message = 2; } + +// Response listing every column type a table may declare. +message ListColumnTypesResponse { + // One declared column type and the SQL type it maps to. + message ColumnType { + // Logical column type (e.g. "money", "instant"). Passed to the server as + // ColumnDefinition.field_type. + string name = 1; + + // Underlying PostgreSQL type the logical type maps to (e.g. "NUMERIC"). + string sql_type = 2; + } + + // All declared column types. + repeated ColumnType column_types = 1; +} diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 0cb612c9..0f2d9828 100644 Binary files a/common/src/proto/descriptor.bin and b/common/src/proto/descriptor.bin differ diff --git a/common/src/proto/komp_ac.table_definition.rs b/common/src/proto/komp_ac.table_definition.rs index 2500097c..9fb8e351 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -389,6 +389,27 @@ pub struct DeleteTableResponse { #[prost(string, tag = "2")] pub message: ::prost::alloc::string::String, } +/// Response listing every column type a table may declare. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListColumnTypesResponse { + /// All declared column types. + #[prost(message, repeated, tag = "1")] + pub column_types: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ListColumnTypesResponse`. +pub mod list_column_types_response { + /// One declared column type and the SQL type it maps to. + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] + pub struct ColumnType { + /// Logical column type (e.g. "money", "instant"). Passed to the server as + /// ColumnDefinition.field_type. + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + /// Underlying PostgreSQL type the logical type maps to (e.g. "NUMERIC"). + #[prost(string, tag = "2")] + pub sql_type: ::prost::alloc::string::String, + } +} #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum MoneyRounding { @@ -636,6 +657,37 @@ pub mod table_definition_client { ); self.inner.unary(req, path, codec).await } + /// Lists every column type a table may declare, along with the SQL type it + /// maps to. Pure data retrieval - no business logic. + pub async fn list_column_types( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic_prost::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/komp_ac.table_definition.TableDefinition/ListColumnTypes", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.table_definition.TableDefinition", + "ListColumnTypes", + ), + ); + self.inner.unary(req, path, codec).await + } /// Fetches all tables with their columns and scripts for a specific profile. /// Pure data retrieval - no business logic. pub async fn get_profile_details( @@ -840,6 +892,15 @@ pub mod table_definition_server { tonic::Response, tonic::Status, >; + /// Lists every column type a table may declare, along with the SQL type it + /// maps to. Pure data retrieval - no business logic. + async fn list_column_types( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Fetches all tables with their columns and scripts for a specific profile. /// Pure data retrieval - no business logic. async fn get_profile_details( @@ -1155,6 +1216,52 @@ pub mod table_definition_server { }; Box::pin(fut) } + "/komp_ac.table_definition.TableDefinition/ListColumnTypes" => { + #[allow(non_camel_case_types)] + struct ListColumnTypesSvc(pub Arc); + impl< + T: TableDefinition, + > tonic::server::UnaryService + for ListColumnTypesSvc { + type Response = super::ListColumnTypesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::list_column_types(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = ListColumnTypesSvc(inner); + let codec = tonic_prost::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } "/komp_ac.table_definition.TableDefinition/GetProfileDetails" => { #[allow(non_camel_case_types)] struct GetProfileDetailsSvc(pub Arc); diff --git a/server b/server index 976e859b..0a685313 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 976e859bf00c3863482c5c269f2553700d90a795 +Subproject commit 0a685313f4b134a6b86d864b7e54a9c3e4041565 diff --git a/tui-canvas b/tui-canvas index 5f354874..eca3d629 160000 --- a/tui-canvas +++ b/tui-canvas @@ -1 +1 @@ -Subproject commit 5f3548747c071ff59b1ce34763be4e7023da15fa +Subproject commit eca3d6294feb8a08cd1946b134f93ff05de4722e diff --git a/tui-pages b/tui-pages index afbbb218..1a33d6d8 160000 --- a/tui-pages +++ b/tui-pages @@ -1 +1 @@ -Subproject commit afbbb218c3fb801db188f5fe80b57d97028bfaa5 +Subproject commit 1a33d6d8dff878c0d882c01484b9e66c8c1a8a6a