diff --git a/client b/client index 0fd324c..9c8ae0b 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 0fd324cf74df78be99d25a91dea038cad3803614 +Subproject commit 9c8ae0b6fa843155195f83d4e7026996e7925edd diff --git a/common/proto/auth.proto b/common/proto/auth.proto index e7b5e7a..0842709 100644 --- a/common/proto/auth.proto +++ b/common/proto/auth.proto @@ -8,6 +8,7 @@ service AuthService { rpc Register(RegisterRequest) returns (AuthResponse); rpc Login(LoginRequest) returns (LoginResponse); rpc GetAuthorization(GetAuthorizationRequest) returns (AuthorizationSnapshot); + rpc SetTimezone(SetTimezoneRequest) returns (UserPreferences); } message RegisterRequest { @@ -38,6 +39,15 @@ message LoginResponse { string role = 5; // User's role string username = 6; AuthorizationSnapshot authorization = 7; + string timezone = 8; +} + +message SetTimezoneRequest { + string timezone = 1; // IANA timezone, for example Europe/Bratislava +} + +message UserPreferences { + string timezone = 1; } message GetAuthorizationRequest {} diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 75f802b..0a9abba 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -120,11 +120,16 @@ message ColumnDefinition { // Logical column type. Supported values (case-insensitive): // TEXT // BOOLEAN - // TIMESTAMPTZ + // INSTANT (absolute timestamp, displayed in the viewer timezone) + // USER_DATETIME (local input resolved in the user's timezone) + // RAW_DATETIME (timezone-free civil datetime) + // TIME (timezone-free time of day) // MONEY (= unconstrained NUMERIC; currency comes from the table) // INT // BIGINT // DATE + // DURATION + // PERIOD // DECIMAL(p,s) → NUMERIC(p,s) // DECIMAL args must be integers (no sign, no dot, no leading zeros); // s ≤ p and p ≥ 1. diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 39ec23c..ebcf3c9 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.auth.rs b/common/src/proto/komp_ac.auth.rs index 22bd686..c0057e1 100644 --- a/common/src/proto/komp_ac.auth.rs +++ b/common/src/proto/komp_ac.auth.rs @@ -56,6 +56,19 @@ pub struct LoginResponse { pub username: ::prost::alloc::string::String, #[prost(message, optional, tag = "7")] pub authorization: ::core::option::Option, + #[prost(string, tag = "8")] + pub timezone: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct SetTimezoneRequest { + /// IANA timezone, for example Europe/Bratislava + #[prost(string, tag = "1")] + pub timezone: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct UserPreferences { + #[prost(string, tag = "1")] + pub timezone: ::prost::alloc::string::String, } #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetAuthorizationRequest {} @@ -230,6 +243,30 @@ pub mod auth_service_client { .insert(GrpcMethod::new("komp_ac.auth.AuthService", "GetAuthorization")); self.inner.unary(req, path, codec).await } + pub async fn set_timezone( + &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.auth.AuthService/SetTimezone", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("komp_ac.auth.AuthService", "SetTimezone")); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -260,6 +297,10 @@ pub mod auth_service_server { tonic::Response, tonic::Status, >; + async fn set_timezone( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct AuthServiceServer { @@ -470,6 +511,51 @@ pub mod auth_service_server { }; Box::pin(fut) } + "/komp_ac.auth.AuthService/SetTimezone" => { + #[allow(non_camel_case_types)] + struct SetTimezoneSvc(pub Arc); + impl< + T: AuthService, + > tonic::server::UnaryService + for SetTimezoneSvc { + type Response = super::UserPreferences; + 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_timezone(&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 = SetTimezoneSvc(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) + } _ => { Box::pin(async move { let mut response = http::Response::new( diff --git a/common/src/proto/komp_ac.table_definition.rs b/common/src/proto/komp_ac.table_definition.rs index 2f3565b..78374ed 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -82,11 +82,16 @@ pub struct ColumnDefinition { /// Logical column type. Supported values (case-insensitive): /// TEXT /// BOOLEAN - /// TIMESTAMPTZ + /// INSTANT (absolute timestamp, displayed in the viewer timezone) + /// USER_DATETIME (local input resolved in the user's timezone) + /// RAW_DATETIME (timezone-free civil datetime) + /// TIME (timezone-free time of day) /// MONEY (= unconstrained NUMERIC; currency comes from the table) /// INT /// BIGINT /// DATE + /// DURATION + /// PERIOD /// DECIMAL(p,s) → NUMERIC(p,s) /// DECIMAL args must be integers (no sign, no dot, no leading zeros); /// s ≤ p and p ≥ 1. diff --git a/server b/server index 23f5fee..cbbf1ac 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 23f5feeaa175f5b9b77c95a1ed503b39d86d2df9 +Subproject commit cbbf1ac16b38e2fc00faeaefb7023ba62bfa469c