This commit is contained in:
Priec
2026-07-12 22:08:51 +02:00
parent 96c6ed6bec
commit b73105dbda
7 changed files with 303 additions and 12 deletions

Binary file not shown.

View File

@@ -43,6 +43,16 @@ pub struct PostTableDefinitionRequest {
#[prost(string, tag = "5")]
pub profile_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PostMoneyTableDefinitionRequest {
#[prost(message, optional, tag = "1")]
pub definition: ::core::option::Option<PostTableDefinitionRequest>,
#[prost(string, tag = "2")]
pub base_currency: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
}
/// Defines append-only column additions for an existing table.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -60,6 +70,26 @@ pub struct AddTableColumnsRequest {
#[prost(string, repeated, tag = "4")]
pub indexes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AddMoneyTableColumnsRequest {
#[prost(message, optional, tag = "1")]
pub definition: ::core::option::Option<AddTableColumnsRequest>,
#[prost(message, repeated, tag = "2")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
#[prost(string, tag = "3")]
pub base_currency: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MoneyColumnOptions {
#[prost(string, tag = "1")]
pub column_name: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub immutable: bool,
#[prost(enumeration = "MoneyRounding", tag = "3")]
pub rounding: i32,
}
/// Describes one user-defined column for a table.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -70,12 +100,12 @@ pub struct ColumnDefinition {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Logical column type. Supported values (case-insensitive):
/// TEXT / STRING
/// TEXT
/// BOOLEAN
/// TIMESTAMP / TIMESTAMPTZ / TIME
/// MONEY (= NUMERIC(14,4))
/// INTEGER / INT
/// BIGINTEGER / BIGINT
/// TIMESTAMPTZ
/// MONEY (= unconstrained NUMERIC; currency comes from the table)
/// INT
/// BIGINT
/// DATE
/// DECIMAL(p,s) → NUMERIC(p,s)
/// DECIMAL args must be integers (no sign, no dot, no leading zeros);
@@ -215,6 +245,10 @@ pub struct TableDetail {
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
#[prost(message, repeated, tag = "4")]
pub scripts: ::prost::alloc::vec::Vec<ScriptInfo>,
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "6")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
}
/// A script that targets a specific column in a table.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -273,6 +307,32 @@ pub struct DeleteTableResponse {
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MoneyRounding {
None = 0,
HalfUp = 1,
}
impl MoneyRounding {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::None => "MONEY_ROUNDING_NONE",
Self::HalfUp => "MONEY_ROUNDING_HALF_UP",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MONEY_ROUNDING_NONE" => Some(Self::None),
"MONEY_ROUNDING_HALF_UP" => Some(Self::HalfUp),
_ => None,
}
}
}
/// Generated client implementations.
pub mod table_definition_client {
#![allow(
@@ -400,6 +460,36 @@ pub mod table_definition_client {
);
self.inner.unary(req, path, codec).await
}
/// Creates a table using the money-aware definition contract.
pub async fn post_money_table_definition(
&mut self,
request: impl tonic::IntoRequest<super::PostMoneyTableDefinitionRequest>,
) -> std::result::Result<
tonic::Response<super::TableDefinitionResponse>,
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/PostMoneyTableDefinition",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"PostMoneyTableDefinition",
),
);
self.inner.unary(req, path, codec).await
}
/// Appends new user-defined columns to an existing table.
/// Existing columns, links, and table logic are never changed by this call.
pub async fn add_table_columns(
@@ -431,6 +521,36 @@ pub mod table_definition_client {
);
self.inner.unary(req, path, codec).await
}
/// Adds columns using the money-aware definition contract.
pub async fn add_money_table_columns(
&mut self,
request: impl tonic::IntoRequest<super::AddMoneyTableColumnsRequest>,
) -> std::result::Result<
tonic::Response<super::TableDefinitionResponse>,
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/AddMoneyTableColumns",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"AddMoneyTableColumns",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists all profiles (schemas) and their tables with declared dependencies.
/// This provides a tree-like overview of table relationships.
pub async fn get_profile_tree(
@@ -638,6 +758,14 @@ pub mod table_definition_server {
tonic::Response<super::TableDefinitionResponse>,
tonic::Status,
>;
/// Creates a table using the money-aware definition contract.
async fn post_money_table_definition(
&self,
request: tonic::Request<super::PostMoneyTableDefinitionRequest>,
) -> std::result::Result<
tonic::Response<super::TableDefinitionResponse>,
tonic::Status,
>;
/// Appends new user-defined columns to an existing table.
/// Existing columns, links, and table logic are never changed by this call.
async fn add_table_columns(
@@ -647,6 +775,14 @@ pub mod table_definition_server {
tonic::Response<super::TableDefinitionResponse>,
tonic::Status,
>;
/// Adds columns using the money-aware definition contract.
async fn add_money_table_columns(
&self,
request: tonic::Request<super::AddMoneyTableColumnsRequest>,
) -> std::result::Result<
tonic::Response<super::TableDefinitionResponse>,
tonic::Status,
>;
/// Lists all profiles (schemas) and their tables with declared dependencies.
/// This provides a tree-like overview of table relationships.
async fn get_profile_tree(
@@ -827,6 +963,57 @@ pub mod table_definition_server {
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/PostMoneyTableDefinition" => {
#[allow(non_camel_case_types)]
struct PostMoneyTableDefinitionSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::PostMoneyTableDefinitionRequest>
for PostMoneyTableDefinitionSvc<T> {
type Response = super::TableDefinitionResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::PostMoneyTableDefinitionRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::post_money_table_definition(
&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 = PostMoneyTableDefinitionSvc(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/AddTableColumns" => {
#[allow(non_camel_case_types)]
struct AddTableColumnsSvc<T: TableDefinition>(pub Arc<T>);
@@ -873,6 +1060,55 @@ pub mod table_definition_server {
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/AddMoneyTableColumns" => {
#[allow(non_camel_case_types)]
struct AddMoneyTableColumnsSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<super::AddMoneyTableColumnsRequest>
for AddMoneyTableColumnsSvc<T> {
type Response = super::TableDefinitionResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AddMoneyTableColumnsRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::add_money_table_columns(
&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 = AddMoneyTableColumnsSvc(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/GetProfileTree" => {
#[allow(non_camel_case_types)]
struct GetProfileTreeSvc<T: TableDefinition>(pub Arc<T>);