diff --git a/.gitignore b/.gitignore index 3c838ef..6ad69b4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ steel_decimal/tests/property_tests.proptest-regressions .direnv/ canvas/*.toml .aider* +.codex diff --git a/client b/client index 6a32d8c..8138995 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 6a32d8cb3a27860d9600bc2006b4a480b8b22be9 +Subproject commit 8138995272f49e19810a3d0df9fbea6032fe5744 diff --git a/common/proto/table_structure.proto b/common/proto/table_structure.proto index 3c559d9..6cf493e 100644 --- a/common/proto/table_structure.proto +++ b/common/proto/table_structure.proto @@ -4,40 +4,45 @@ package komp_ac.table_structure; import "common.proto"; -// Introspects the physical PostgreSQL table for a given logical table -// (defined in table_definitions) and returns its column structure. +// Introspects the physical PostgreSQL tables for one or more logical tables +// (defined in table_definitions) and returns their column structures. // The server validates that: // - The profile (schema) exists in `schemas` -// - The table is defined for that profile in `table_definitions` -// It then queries information_schema for the physical table and returns -// normalized column metadata. If the physical table is missing despite -// a definition, the response may contain an empty `columns` list. +// - Every table is defined for that profile in `table_definitions` +// It then queries information_schema for the physical tables and returns +// normalized column metadata. service TableStructureService { // Return the physical column list (name, normalized data_type, - // nullability, primary key flag) for a table in a profile. + // nullability, primary key flag) for one or more tables in a profile. // // Behavior: // - NOT_FOUND if profile doesn't exist in `schemas` - // - NOT_FOUND if table not defined for that profile in `table_definitions` + // - NOT_FOUND if any table is not defined for that profile in `table_definitions` // - Queries information_schema.columns ordered by ordinal position // - Normalizes data_type text (details under TableColumn.data_type) - // - Returns an empty list if the table is validated but has no visible - // columns in information_schema (e.g., physical table missing) - rpc GetTableStructure(GetTableStructureRequest) returns (TableStructureResponse); + // - Returns an error if any validated table has no visible columns in + // information_schema (e.g., physical table missing) + rpc GetTableStructure(GetTableStructureRequest) returns (GetTableStructureResponse); } -// Request identifying the profile (schema) and table to inspect. +// Request identifying the profile (schema) and tables to inspect. message GetTableStructureRequest { // Required. Profile (PostgreSQL schema) name. Must exist in `schemas`. string profile_name = 1; - // Required. Table name within the profile. Must exist in `table_definitions` - // for the given profile. The physical table is then introspected via - // information_schema. - string table_name = 2; + // Required. Table names within the profile. Each must exist in + // `table_definitions` for the given profile. The physical tables are then + // introspected via information_schema. + repeated string table_names = 2; } -// Response with the ordered list of columns (by ordinal position). +// Batched response keyed by table name. +message GetTableStructureResponse { + // Per-table physical column lists keyed by requested table name. + map table_structures = 1; +} + +// Response with the ordered list of columns (by ordinal position) for one table. message TableStructureResponse { // Columns of the physical table, including system columns (id, deleted, // created_at), user-defined columns, and any foreign-key columns such as diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 740da50..4a88a03 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_structure.rs b/common/src/proto/komp_ac.table_structure.rs index 1e48052..b460079 100644 --- a/common/src/proto/komp_ac.table_structure.rs +++ b/common/src/proto/komp_ac.table_structure.rs @@ -1,17 +1,27 @@ // This file is @generated by prost-build. -/// Request identifying the profile (schema) and table to inspect. +/// Request identifying the profile (schema) and tables to inspect. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetTableStructureRequest { /// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`. #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, - /// Required. Table name within the profile. Must exist in `table_definitions` - /// for the given profile. The physical table is then introspected via - /// information_schema. - #[prost(string, tag = "2")] - pub table_name: ::prost::alloc::string::String, + /// Required. Table names within the profile. Each must exist in + /// `table_definitions` for the given profile. The physical tables are then + /// introspected via information_schema. + #[prost(string, repeated, tag = "2")] + pub table_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -/// Response with the ordered list of columns (by ordinal position). +/// Batched response keyed by table name. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTableStructureResponse { + /// Per-table physical column lists keyed by requested table name. + #[prost(map = "string, message", tag = "1")] + pub table_structures: ::std::collections::HashMap< + ::prost::alloc::string::String, + TableStructureResponse, + >, +} +/// Response with the ordered list of columns (by ordinal position) for one table. #[derive(Clone, PartialEq, ::prost::Message)] pub struct TableStructureResponse { /// Columns of the physical table, including system columns (id, deleted, @@ -55,14 +65,13 @@ pub mod table_structure_service_client { )] use tonic::codegen::*; use tonic::codegen::http::Uri; - /// Introspects the physical PostgreSQL table for a given logical table - /// (defined in table_definitions) and returns its column structure. + /// Introspects the physical PostgreSQL tables for one or more logical tables + /// (defined in table_definitions) and returns their column structures. /// The server validates that: /// - The profile (schema) exists in `schemas` - /// - The table is defined for that profile in `table_definitions` - /// It then queries information_schema for the physical table and returns - /// normalized column metadata. If the physical table is missing despite - /// a definition, the response may contain an empty `columns` list. + /// - Every table is defined for that profile in `table_definitions` + /// It then queries information_schema for the physical tables and returns + /// normalized column metadata. #[derive(Debug, Clone)] pub struct TableStructureServiceClient { inner: tonic::client::Grpc, @@ -144,20 +153,20 @@ pub mod table_structure_service_client { self } /// Return the physical column list (name, normalized data_type, - /// nullability, primary key flag) for a table in a profile. + /// nullability, primary key flag) for one or more tables in a profile. /// /// Behavior: /// - NOT_FOUND if profile doesn't exist in `schemas` - /// - NOT_FOUND if table not defined for that profile in `table_definitions` + /// - NOT_FOUND if any table is not defined for that profile in `table_definitions` /// - Queries information_schema.columns ordered by ordinal position /// - Normalizes data_type text (details under TableColumn.data_type) - /// - Returns an empty list if the table is validated but has no visible - /// columns in information_schema (e.g., physical table missing) + /// - Returns an error if any validated table has no visible columns in + /// information_schema (e.g., physical table missing) pub async fn get_table_structure( &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -198,31 +207,30 @@ pub mod table_structure_service_server { #[async_trait] pub trait TableStructureService: std::marker::Send + std::marker::Sync + 'static { /// Return the physical column list (name, normalized data_type, - /// nullability, primary key flag) for a table in a profile. + /// nullability, primary key flag) for one or more tables in a profile. /// /// Behavior: /// - NOT_FOUND if profile doesn't exist in `schemas` - /// - NOT_FOUND if table not defined for that profile in `table_definitions` + /// - NOT_FOUND if any table is not defined for that profile in `table_definitions` /// - Queries information_schema.columns ordered by ordinal position /// - Normalizes data_type text (details under TableColumn.data_type) - /// - Returns an empty list if the table is validated but has no visible - /// columns in information_schema (e.g., physical table missing) + /// - Returns an error if any validated table has no visible columns in + /// information_schema (e.g., physical table missing) async fn get_table_structure( &self, request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; } - /// Introspects the physical PostgreSQL table for a given logical table - /// (defined in table_definitions) and returns its column structure. + /// Introspects the physical PostgreSQL tables for one or more logical tables + /// (defined in table_definitions) and returns their column structures. /// The server validates that: /// - The profile (schema) exists in `schemas` - /// - The table is defined for that profile in `table_definitions` - /// It then queries information_schema for the physical table and returns - /// normalized column metadata. If the physical table is missing despite - /// a definition, the response may contain an empty `columns` list. + /// - Every table is defined for that profile in `table_definitions` + /// It then queries information_schema for the physical tables and returns + /// normalized column metadata. #[derive(Debug)] pub struct TableStructureServiceServer { inner: Arc, @@ -307,7 +315,7 @@ pub mod table_structure_service_server { T: TableStructureService, > tonic::server::UnaryService for GetTableStructureSvc { - type Response = super::TableStructureResponse; + type Response = super::GetTableStructureResponse; type Future = BoxFuture< tonic::Response, tonic::Status, diff --git a/server b/server index 82df1de..51f3eca 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 82df1dea822ddf18fd3724b2d1cc413fd7fd0bde +Subproject commit 51f3eca615b59e9e12bc172f8c8646c75b6da55a