diff --git a/client-gui2 b/client-gui2 index fb0322b7..e3798fc8 160000 --- a/client-gui2 +++ b/client-gui2 @@ -1 +1 @@ -Subproject commit fb0322b75f12f94e8ecbbcf65e0b2dc4192ecd56 +Subproject commit e3798fc82f87a8e1fb27c09ba04a9a912a3c3fcd diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 2eba3457..da27436c 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -9,6 +9,9 @@ import "common.proto"; // logical "profiles" (schemas). Each table has stored structure, links, and // validation rules. service TableDefinition { + // Creates a profile with default modules and managed structures, without a user table. + rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse); + rpc GetModuleConfiguration(GetModuleConfigurationRequest) returns (ModuleConfiguration); rpc SetModuleConfiguration(SetModuleConfigurationRequest) returns (ModuleConfiguration); @@ -108,6 +111,16 @@ service TableDefinition { rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse); } +message CreateProfileRequest { + string profile_name = 1; + // Omit to leave the bookkeeping currency unconfigured. + optional string accounting_currency = 2; +} + +message CreateProfileResponse { + int64 profile_id = 1; +} + message ModuleScope { oneof target { komp_ac.common.Empty defaults = 1; diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 361635aa..2bad5de8 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 403ac8b2..3dbd3048 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -1,6 +1,21 @@ // This file is @generated by prost-build. #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CreateProfileRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + /// Omit to leave the bookkeeping currency unconfigured. + #[prost(string, optional, tag = "2")] + pub accounting_currency: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CreateProfileResponse { + #[prost(int64, tag = "1")] + pub profile_id: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ModuleScope { #[prost(oneof = "module_scope::Target", tags = "1, 2")] pub target: ::core::option::Option, @@ -1470,6 +1485,36 @@ pub mod table_definition_client { self.inner = self.inner.max_encoding_message_size(limit); self } + /// Creates a profile with default modules and managed structures, without a user table. + pub async fn create_profile( + &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/CreateProfile", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.table_definition.TableDefinition", + "CreateProfile", + ), + ); + self.inner.unary(req, path, codec).await + } pub async fn get_module_configuration( &mut self, request: impl tonic::IntoRequest, @@ -2288,6 +2333,14 @@ pub mod table_definition_server { /// Generated trait containing gRPC methods that should be implemented for use with TableDefinitionServer. #[async_trait] pub trait TableDefinition: std::marker::Send + std::marker::Sync + 'static { + /// Creates a profile with default modules and managed structures, without a user table. + async fn create_profile( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_module_configuration( &self, request: tonic::Request, @@ -2598,6 +2651,52 @@ pub mod table_definition_server { } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { + "/komp_ac.table_definition.TableDefinition/CreateProfile" => { + #[allow(non_camel_case_types)] + struct CreateProfileSvc(pub Arc); + impl< + T: TableDefinition, + > tonic::server::UnaryService + for CreateProfileSvc { + type Response = super::CreateProfileResponse; + 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 { + ::create_profile(&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 = CreateProfileSvc(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/GetModuleConfiguration" => { #[allow(non_camel_case_types)] struct GetModuleConfigurationSvc(pub Arc); diff --git a/komp-app/src/grpc.rs b/komp-app/src/grpc.rs index f116b5d9..05690c8d 100644 --- a/komp-app/src/grpc.rs +++ b/komp-app/src/grpc.rs @@ -1405,6 +1405,19 @@ impl GrpcClient { .into_inner()) } + pub async fn create_profile( + &mut self, + req: common::proto::komp_ac::table_definition::CreateProfileRequest, + ) -> Result { + let request = self.authenticated_request(req)?; + Ok(self + .table_definition_client + .create_profile(request) + .await + .context("gRPC CreateProfile call failed")? + .into_inner()) + } + pub async fn copy_profile( &mut self, request: common::proto::komp_ac::table_definition::CopyProfileRequest, diff --git a/server b/server index 395cfd16..de6f24fd 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 395cfd164415ac1c44b568289d6fdc2da6594161 +Subproject commit de6f24fdbdb416dae1a79bd4dc67585f8a6f90e8