table definition column types is shared

This commit is contained in:
Priec
2026-08-06 12:32:52 +02:00
parent 0109d70494
commit 3c6aa56e27
6 changed files with 130 additions and 3 deletions

View File

@@ -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;
}

Binary file not shown.

View File

@@ -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<list_column_types_response::ColumnType>,
}
/// 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<super::super::common::Empty>,
) -> std::result::Result<
tonic::Response<super::ListColumnTypesResponse>,
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<super::ProfileTreeResponse>,
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<super::super::common::Empty>,
) -> std::result::Result<
tonic::Response<super::ListColumnTypesResponse>,
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<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::super::common::Empty>
for ListColumnTypesSvc<T> {
type Response = super::ListColumnTypesResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::super::common::Empty>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::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<T: TableDefinition>(pub Arc<T>);