From 1867de513d46fa888e1ba0630334fc9ed0129910 Mon Sep 17 00:00:00 2001 From: Priec Date: Mon, 27 Apr 2026 22:01:17 +0200 Subject: [PATCH] get profile details with scripts and tables columns is now working --- Cargo.lock | 32 ++++- Cargo.toml | 2 +- canvas | 2 +- client | 2 +- common/proto/table_definition.proto | 33 +++++ common/src/proto/descriptor.bin | Bin 54721 -> 56743 bytes common/src/proto/komp_ac.table_definition.rs | 127 +++++++++++++++++++ server | 2 +- 8 files changed, 191 insertions(+), 9 deletions(-) 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 4afc01279a24f2f31e547a1ca423541bf5525689..cbbf52fc99e1ef2756ba629f83edacc71abf3ddb 100644 GIT binary patch delta 3069 zcmZWrTTC2P7~XSc*qu2mT^K0c-3ku0_OfjOiv?;aVd+wW^-3$6h6K0EK$ig9?kt$# zWvgj5T8pN~wkC!cyaZDpypZUF(Woyz8BM$-#!F(1FD5=1V@!PV`{&H;HsNi*bN=u9 z|MQ(Q|G%HTt*w2ez5DlG{_4>BKYNd8jfX{i*eTstEKKERos3h;=4V~`*Gj6n?QxOV zurunoXA1MKBg?DX>ko@?DSK+xapT<9c18E!DhE1}+fLAu5*qdQ+dgC>dc(SWa%yvI zli>MDFxf6`6u+d_K5X@ih?^_s&y?J_?n!PZ$^PTs+Q|G=VKmrp`+x~iUAMLhQ!ytX z$~;j+EsV&uk!9J_`3C<+lRtO<(e#+8-*7H#KP5_TSRZxHE;w!}*+ttMY4VfX7RMjHr8kFm%6|{s6Kgi=#Sb{39^xTOYn3Ouf85i`4Iie75(uJso~ZEJ32f zZ15z2AkopZMO;XXUw?whv-2;}Y^JH_YRV*~ZA|9MA-9qg;nwHho&J-<;2x!-3ce7Z)2 zo14W?s&d`Z(sHKnmsGlPQh1`J&CPzij`(yuA^KnzxAdXVgR*$IFE(Vv#kVBE$*d9i z@!{|HjQA2*g2aef>q!7XVx+EKd`T61?`LfNlm2^IYOF#af5v=w5dp#&+@%ZBEd6BY zVc9c~*>uvlMGQegqm<+F*@5BIxPQf1g2H%Y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+r2(yd%pI;KPDT2Hi#(4Tb^RK-Z) zs!?m6Kb@^cM}t{4onO%FTHm1~#yr-etkl7Ca|#4d&UO}|2aX)sB1 zSeA6vqIH3PK06m(3=Yz-T0-h&)p%&}w|vb=pah9pDB?)~L82Cm(|zq&>f5Zfhs&$t z#F|gg542{siw+RhuwDH?wyQ2#mqn_`@74$S+e*IoQt&9%pk(XG4Srf#$~DYOqXeNw zPp>x_2ttjxORHWxj@G$ReJ!_c=Gs!vT@M{G?RxHdG)862Rj#^Xz0bc?%dsoLAsUB* zvJud$@){qnjmNH1lwKi67qyQKeyg@TwV^`POFf+;q&Fb!V~B4+yl6-`-c)_5aen(= zhX1P#p4wF8H)~&;;pia-c@vSnV93Z!lPl*go^7hb2@=oVj3j)L-gL7sbBH0*9Lds{ zcNZl8x_pm+KQ|V;PH}qGQ}&|2#nGknr?z}Mo$zn@b~^Fjf}OGoKa(P|RRE1Qf+?y%H=uQQWGeL{i+cn7=E}&l{s%!ByV@}^00L#lL>>s* zJBa+A&UXM?RJ(k8Wp@gn0elP4BAy6t1c=xgh^+1kw+Y?Ap z1A-1LseS&c{`zTrLU3Ooy;=bfjr#)eH4uXP0{NZwcsM-Z6RT&AJD!n)t`R_eBtkL6 NLypx!`(QQm$^T7CtT+Gw 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