diff --git a/Cargo.lock b/Cargo.lock index 37ef5de..bb36121 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,7 +493,7 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "canvas" -version = "0.6.0" +version = "0.6.2" dependencies = [ "anyhow", "async-trait", @@ -585,7 +585,7 @@ dependencies = [ [[package]] name = "client" -version = "0.6.0" +version = "0.6.2" dependencies = [ "anyhow", "async-trait", @@ -596,6 +596,7 @@ dependencies = [ "dotenvy", "futures", "lazy_static", + "nucleo", "prost 0.13.5", "prost-types 0.13.5", "ratatui", @@ -640,7 +641,7 @@ dependencies = [ [[package]] name = "common" -version = "0.6.0" +version = "0.6.2" dependencies = [ "prost 0.13.5", "prost-build 0.14.1", @@ -2103,6 +2104,27 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "nucleo" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5262af4c94921c2646c5ac6ff7900c2af9cbb08dc26a797e18130a7019c039d4" +dependencies = [ + "nucleo-matcher", + "parking_lot", + "rayon", +] + +[[package]] +name = "nucleo-matcher" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf33f538733d1a5a3494b836ba913207f14d9d4a1d3cd67030c5061bdd2cac85" +dependencies = [ + "memchr", + "unicode-segmentation", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -3094,7 +3116,7 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "search" -version = "0.6.0" +version = "0.6.2" dependencies = [ "anyhow", "common", @@ -3193,7 +3215,7 @@ dependencies = [ [[package]] name = "server" -version = "0.6.0" +version = "0.6.2" dependencies = [ "anyhow", "bcrypt", diff --git a/Cargo.toml b/Cargo.toml index fc6ffea..57358d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] # TODO: idk how to do the name, fix later # name = "komp_ac" -version = "0.6.2" +version = "0.6.3" edition = "2021" license = "GPL-3.0-or-later" authors = ["Filip Priečinský "] diff --git a/canvas b/canvas index 812ac2a..abbda5b 160000 --- a/canvas +++ b/canvas @@ -1 +1 @@ -Subproject commit 812ac2a428479298461c03fe1c1d1ae862e58725 +Subproject commit abbda5b7a98e070651edd6adca9796f09791f32c diff --git a/client b/client index 2494066..6a32d8c 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 24940661408fbe49a144f468c4f2c958d02c1d16 +Subproject commit 6a32d8cb3a27860d9600bc2006b4a480b8b22be9 diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 1131d63..6503e71 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -18,6 +18,10 @@ service TableDefinition { // This provides a tree-like overview of table relationships. rpc GetProfileTree(komp_ac.common.Empty) returns (ProfileTreeResponse); + // Fetches all tables with their columns and scripts for a specific profile. + // Pure data retrieval - no business logic. + rpc GetProfileDetails(GetProfileDetailsRequest) returns (GetProfileDetailsResponse); + // Drops a table and its metadata, then deletes the profile if it becomes empty. rpc DeleteTable(DeleteTableRequest) returns (DeleteTableResponse); } @@ -119,6 +123,35 @@ message ProfileTreeResponse { repeated Profile profiles = 1; } +// Request to fetch all tables, columns and scripts for a profile. +message GetProfileDetailsRequest { + // Profile (schema) name to fetch details for. + string profile_name = 1; +} + +// Response with all tables, columns and scripts for a profile. +message GetProfileDetailsResponse { + string profile_name = 1; + repeated TableDetail tables = 2; +} + +// Describes a table with its columns and associated scripts. +message TableDetail { + string name = 1; + int64 id = 2; + repeated ColumnDefinition columns = 3; + repeated ScriptInfo scripts = 4; +} + +// A script that targets a specific column in a table. +message ScriptInfo { + int64 script_id = 1; + string target_column = 2; + string target_column_type = 3; + string script = 4; + string description = 5; +} + // Request to delete one table definition entirely. message DeleteTableRequest { // Profile (schema) name owning the table (must exist). diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 4afc012..cbbf52f 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 e90dd30..e99f3a7 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -110,6 +110,47 @@ pub mod profile_tree_response { pub tables: ::prost::alloc::vec::Vec, } } +/// Request to fetch all tables, columns and scripts for a profile. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetProfileDetailsRequest { + /// Profile (schema) name to fetch details for. + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, +} +/// Response with all tables, columns and scripts for a profile. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetProfileDetailsResponse { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub tables: ::prost::alloc::vec::Vec, +} +/// Describes a table with its columns and associated scripts. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TableDetail { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub id: i64, + #[prost(message, repeated, tag = "3")] + pub columns: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "4")] + pub scripts: ::prost::alloc::vec::Vec, +} +/// A script that targets a specific column in a table. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ScriptInfo { + #[prost(int64, tag = "1")] + pub script_id: i64, + #[prost(string, tag = "2")] + pub target_column: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub target_column_type: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub script: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub description: ::prost::alloc::string::String, +} /// Request to delete one table definition entirely. #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteTableRequest { @@ -289,6 +330,37 @@ pub mod table_definition_client { ); 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( + &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::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/komp_ac.table_definition.TableDefinition/GetProfileDetails", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.table_definition.TableDefinition", + "GetProfileDetails", + ), + ); + self.inner.unary(req, path, codec).await + } /// Drops a table and its metadata, then deletes the profile if it becomes empty. pub async fn delete_table( &mut self, @@ -353,6 +425,15 @@ pub mod table_definition_server { tonic::Response, 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( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Drops a table and its metadata, then deletes the profile if it becomes empty. async fn delete_table( &self, @@ -537,6 +618,52 @@ pub mod table_definition_server { }; Box::pin(fut) } + "/komp_ac.table_definition.TableDefinition/GetProfileDetails" => { + #[allow(non_camel_case_types)] + struct GetProfileDetailsSvc(pub Arc); + impl< + T: TableDefinition, + > tonic::server::UnaryService + for GetProfileDetailsSvc { + type Response = super::GetProfileDetailsResponse; + 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 { + ::get_profile_details(&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 = GetProfileDetailsSvc(inner); + let codec = tonic::codec::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/DeleteTable" => { #[allow(non_camel_case_types)] struct DeleteTableSvc(pub Arc); diff --git a/server b/server index 6b0c3e6..db54c07 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 6b0c3e63b48fd2164f7ae31087948d62dd06cb96 +Subproject commit db54c073582fb836d6db9a2353205308716a094d