diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 045c08c3..bba0b921 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -62,6 +62,10 @@ service TableDefinition { // Physical column names and identities remain unchanged. rpc SetColumnPresentation(SetColumnPresentationRequest) returns (SetColumnPresentationResponse); + // Replaces the optional user-visible aliases for a fixed-option column. + // Stored values remain stable machine values and scripts never depend on labels. + rpc SetColumnOptionAliases(SetColumnOptionAliasesRequest) returns (SetColumnOptionAliasesResponse); + // Shows or hides one column in bundled data-entry forms. This is presentation // metadata only: hidden columns remain available to data APIs, scripts and // backend calculations. @@ -525,6 +529,10 @@ message ColumnBehavior { // True when bundled data-entry clients should not render this column. // This is not an authorization boundary; data APIs still expose the column. bool hidden_from_forms = 6; + + // User-selected labels for stable option values. Empty means clients display + // the canonical value. Writes may submit either value or alias. + repeated OptionValueAlias option_value_aliases = 7; } // A script that targets a specific column in a table. @@ -561,6 +569,30 @@ message SetColumnPresentationResponse { int64 row_version = 4; } +// One stable machine value and its optional user-visible/input alias. +message OptionValueAlias { + string value = 1; + string alias = 2; +} + +message SetColumnOptionAliasesRequest { + string profile_name = 1; + string table_name = 2; + int64 column_id = 3; + // Partial sets are supported; omitted values use their canonical spelling. + // An empty list removes every alias from the column. + repeated OptionValueAlias aliases = 4; + int64 expected_row_version = 5; +} + +message SetColumnOptionAliasesResponse { + bool success = 1; + string message = 2; + int64 column_id = 3; + repeated OptionValueAlias aliases = 4; + int64 row_version = 5; +} + message SetColumnFormVisibilityRequest { string profile_name = 1; string table_name = 2; diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 9d971a77..2e2427d9 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 38150198..a9e9ca17 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -524,7 +524,7 @@ pub struct TableDetail { } /// Server-owned behavior for one logical column returned in table details. #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct ColumnBehavior { /// True when the server created the column as a companion of another column. #[prost(bool, tag = "1")] @@ -545,6 +545,10 @@ pub struct ColumnBehavior { /// This is not an authorization boundary; data APIs still expose the column. #[prost(bool, tag = "6")] pub hidden_from_forms: bool, + /// User-selected labels for stable option values. Empty means clients display + /// the canonical value. Writes may submit either value or alias. + #[prost(message, repeated, tag = "7")] + pub option_value_aliases: ::prost::alloc::vec::Vec, } /// A script that targets a specific column in a table. #[derive(serde::Serialize, serde::Deserialize)] @@ -599,6 +603,45 @@ pub struct SetColumnPresentationResponse { #[prost(int64, tag = "4")] pub row_version: i64, } +/// One stable machine value and its optional user-visible/input alias. +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct OptionValueAlias { + #[prost(string, tag = "1")] + pub value: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub alias: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetColumnOptionAliasesRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub table_name: ::prost::alloc::string::String, + #[prost(int64, tag = "3")] + pub column_id: i64, + /// Partial sets are supported; omitted values use their canonical spelling. + /// An empty list removes every alias from the column. + #[prost(message, repeated, tag = "4")] + pub aliases: ::prost::alloc::vec::Vec, + #[prost(int64, tag = "5")] + pub expected_row_version: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetColumnOptionAliasesResponse { + #[prost(bool, tag = "1")] + pub success: bool, + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, + #[prost(int64, tag = "3")] + pub column_id: i64, + #[prost(message, repeated, tag = "4")] + pub aliases: ::prost::alloc::vec::Vec, + #[prost(int64, tag = "5")] + pub row_version: i64, +} #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct SetColumnFormVisibilityRequest { @@ -1391,6 +1434,37 @@ pub mod table_definition_client { ); self.inner.unary(req, path, codec).await } + /// Replaces the optional user-visible aliases for a fixed-option column. + /// Stored values remain stable machine values and scripts never depend on labels. + pub async fn set_column_option_aliases( + &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/SetColumnOptionAliases", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.table_definition.TableDefinition", + "SetColumnOptionAliases", + ), + ); + self.inner.unary(req, path, codec).await + } /// Shows or hides one column in bundled data-entry forms. This is presentation /// metadata only: hidden columns remain available to data APIs, scripts and /// backend calculations. @@ -1586,6 +1660,15 @@ pub mod table_definition_server { tonic::Response, tonic::Status, >; + /// Replaces the optional user-visible aliases for a fixed-option column. + /// Stored values remain stable machine values and scripts never depend on labels. + async fn set_column_option_aliases( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Shows or hides one column in bundled data-entry forms. This is presentation /// metadata only: hidden columns remain available to data APIs, scripts and /// backend calculations. @@ -2319,6 +2402,55 @@ pub mod table_definition_server { }; Box::pin(fut) } + "/komp_ac.table_definition.TableDefinition/SetColumnOptionAliases" => { + #[allow(non_camel_case_types)] + struct SetColumnOptionAliasesSvc(pub Arc); + impl< + T: TableDefinition, + > tonic::server::UnaryService + for SetColumnOptionAliasesSvc { + type Response = super::SetColumnOptionAliasesResponse; + 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 { + ::set_column_option_aliases( + &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 = SetColumnOptionAliasesSvc(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/SetColumnFormVisibility" => { #[allow(non_camel_case_types)] struct SetColumnFormVisibilitySvc(pub Arc); diff --git a/server b/server index bcccf825..825a5bcf 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit bcccf8253ce0c2e53d2c1e840e843a9a8ad226a7 +Subproject commit 825a5bcf321655ba3821718eae817982f1e40e5d