custom ecb is dynamic table and not system table from now on2

This commit is contained in:
Priec
2026-08-17 20:22:39 +02:00
parent 4bab6bcbf1
commit e13447e3d6
6 changed files with 131 additions and 9 deletions

2
client

Submodule client updated: 42f163beae...bfe8d72e32

View File

@@ -14,6 +14,10 @@ service TableDefinition {
// Also inserts metadata and default validation rules. Entirely transactional. // Also inserts metadata and default validation rules. Entirely transactional.
rpc PostTableDefinition(PostTableDefinitionRequest) returns (TableDefinitionResponse); rpc PostTableDefinition(PostTableDefinitionRequest) returns (TableDefinitionResponse);
// Explicitly creates the optional administrator-managed exchange-rate table
// in an existing profile. The server owns its core shape and constraints.
rpc CreateCustomExchangeRatesTable(CreateCustomExchangeRatesTableRequest) returns (CreateCustomExchangeRatesTableResponse);
// Creates a regular user-table bundle from the restricted komp_ac_fields // Creates a regular user-table bundle from the restricted komp_ac_fields
// contract embedded in a Typst invoice template. This is invoked explicitly // contract embedded in a Typst invoice template. This is invoked explicitly
// by the user; templates do not provision tables merely by existing. // by the user; templates do not provision tables merely by existing.
@@ -53,14 +57,23 @@ service TableDefinition {
rpc DeleteTable(DeleteTableRequest) returns (DeleteTableResponse); rpc DeleteTable(DeleteTableRequest) returns (DeleteTableResponse);
} }
message CreateCustomExchangeRatesTableRequest {
string profile_name = 1;
}
message CreateCustomExchangeRatesTableResponse {
int64 table_definition_id = 1;
bool created = 2;
}
// Defines the input for creating a new table definition. // Defines the input for creating a new table definition.
message PostTableDefinitionRequest { message PostTableDefinitionRequest {
// Table name to create inside the target profile. // Table name to create inside the target profile.
// Must be lowercase, alphanumeric with underscores, // Must be lowercase, alphanumeric with underscores,
// start with a letter, and be <= 63 chars. // start with a letter, and be <= 63 chars.
// Forbidden names: "id", "deleted", "created_at", "row_revision" -- the // Forbidden names include the system columns and tables owned by dedicated
// system columns, which share one namespace with table names wherever the // server operations, such as "custom_exchange_rates". The "_id" suffix is
// two are named side by side. The "_id" suffix is allowed. // allowed.
string table_name = 1; string table_name = 1;
// The table's columns, including its links and stored linked projections. // The table's columns, including its links and stored linked projections.

Binary file not shown.

View File

@@ -1,4 +1,16 @@
// This file is @generated by prost-build. // This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateCustomExchangeRatesTableRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateCustomExchangeRatesTableResponse {
#[prost(int64, tag = "1")]
pub table_definition_id: i64,
#[prost(bool, tag = "2")]
pub created: bool,
}
/// Defines the input for creating a new table definition. /// Defines the input for creating a new table definition.
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
@@ -6,9 +18,9 @@ pub struct PostTableDefinitionRequest {
/// Table name to create inside the target profile. /// Table name to create inside the target profile.
/// Must be lowercase, alphanumeric with underscores, /// Must be lowercase, alphanumeric with underscores,
/// start with a letter, and be \<= 63 chars. /// start with a letter, and be \<= 63 chars.
/// Forbidden names: "id", "deleted", "created_at", "row_revision" -- the /// Forbidden names include the system columns and tables owned by dedicated
/// system columns, which share one namespace with table names wherever the /// server operations, such as "custom_exchange_rates". The "\_id" suffix is
/// two are named side by side. The "\_id" suffix is allowed. /// allowed.
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
pub table_name: ::prost::alloc::string::String, pub table_name: ::prost::alloc::string::String,
/// The table's columns, including its links and stored linked projections. /// The table's columns, including its links and stored linked projections.
@@ -778,6 +790,39 @@ pub mod table_definition_client {
); );
self.inner.unary(req, path, codec).await self.inner.unary(req, path, codec).await
} }
/// Explicitly creates the optional administrator-managed exchange-rate table
/// in an existing profile. The server owns its core shape and constraints.
pub async fn create_custom_exchange_rates_table(
&mut self,
request: impl tonic::IntoRequest<
super::CreateCustomExchangeRatesTableRequest,
>,
) -> std::result::Result<
tonic::Response<super::CreateCustomExchangeRatesTableResponse>,
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/CreateCustomExchangeRatesTable",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"CreateCustomExchangeRatesTable",
),
);
self.inner.unary(req, path, codec).await
}
/// Creates a regular user-table bundle from the restricted komp_ac_fields /// Creates a regular user-table bundle from the restricted komp_ac_fields
/// contract embedded in a Typst invoice template. This is invoked explicitly /// contract embedded in a Typst invoice template. This is invoked explicitly
/// by the user; templates do not provision tables merely by existing. /// by the user; templates do not provision tables merely by existing.
@@ -1111,6 +1156,15 @@ pub mod table_definition_server {
tonic::Response<super::TableDefinitionResponse>, tonic::Response<super::TableDefinitionResponse>,
tonic::Status, tonic::Status,
>; >;
/// Explicitly creates the optional administrator-managed exchange-rate table
/// in an existing profile. The server owns its core shape and constraints.
async fn create_custom_exchange_rates_table(
&self,
request: tonic::Request<super::CreateCustomExchangeRatesTableRequest>,
) -> std::result::Result<
tonic::Response<super::CreateCustomExchangeRatesTableResponse>,
tonic::Status,
>;
/// Creates a regular user-table bundle from the restricted komp_ac_fields /// Creates a regular user-table bundle from the restricted komp_ac_fields
/// contract embedded in a Typst invoice template. This is invoked explicitly /// contract embedded in a Typst invoice template. This is invoked explicitly
/// by the user; templates do not provision tables merely by existing. /// by the user; templates do not provision tables merely by existing.
@@ -1329,6 +1383,60 @@ pub mod table_definition_server {
}; };
Box::pin(fut) Box::pin(fut)
} }
"/komp_ac.table_definition.TableDefinition/CreateCustomExchangeRatesTable" => {
#[allow(non_camel_case_types)]
struct CreateCustomExchangeRatesTableSvc<T: TableDefinition>(
pub Arc<T>,
);
impl<
T: TableDefinition,
> tonic::server::UnaryService<
super::CreateCustomExchangeRatesTableRequest,
> for CreateCustomExchangeRatesTableSvc<T> {
type Response = super::CreateCustomExchangeRatesTableResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::CreateCustomExchangeRatesTableRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::create_custom_exchange_rates_table(
&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 = CreateCustomExchangeRatesTableSvc(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/CreateInvoiceTemplateTable" => { "/komp_ac.table_definition.TableDefinition/CreateInvoiceTemplateTable" => {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct CreateInvoiceTemplateTableSvc<T: TableDefinition>(pub Arc<T>); struct CreateInvoiceTemplateTableSvc<T: TableDefinition>(pub Arc<T>);

2
server

Submodule server updated: 2cec55d9e9...4fa445ccf8

View File

@@ -1235,11 +1235,12 @@ pub(crate) const MAX_TABLE_NAME_LENGTH: usize = MAX_IDENTIFIER_LENGTH
/// constants of three server modules rather than anything the catalog carries. /// constants of three server modules rather than anything the catalog carries.
/// A name the server adds to that set is a name this list will not know about /// A name the server adds to that set is a name this list will not know about
/// until it is added here as well. /// until it is added here as well.
pub(crate) const RESERVED_TABLE_NAMES: [&str; 4] = [ pub(crate) const RESERVED_TABLE_NAMES: [&str; 5] = [
"general_ledger", "general_ledger",
"journal_lines", "journal_lines",
"quantity_ledger", "quantity_ledger",
LEDGER_ACCOUNTS_TABLE, LEDGER_ACCOUNTS_TABLE,
"custom_exchange_rates",
]; ];
/// The identifier rules, plus the two a table name alone is held to. /// The identifier rules, plus the two a table name alone is held to.