diff --git a/client b/client index 1d3e75b1..748a601d 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 1d3e75b1502956959ae5ea43c1514ecd23904a0b +Subproject commit 748a601d68d879121b0f7ab809e8e8717c571372 diff --git a/common/build.rs b/common/build.rs index 4b80a955..cb6dfe9f 100644 --- a/common/build.rs +++ b/common/build.rs @@ -158,8 +158,8 @@ fn main() -> Result<(), Box> { "#[derive(serde::Serialize, serde::Deserialize)]", ) .field_attribute( - ".komp_ac.table_definition.ColumnDefinition.boolean_ledger_operator", - "#[serde(default)]", + ".komp_ac.table_definition.ColumnDefinition.boolean_ledger", + "#[serde(default, alias = \"boolean_ledger_operator\")]", ) .type_attribute( ".komp_ac.table_definition.PostTableDefinitionRequest", diff --git a/common/proto/document_data.proto b/common/proto/document_data.proto index 748b4b86..4ec83210 100644 --- a/common/proto/document_data.proto +++ b/common/proto/document_data.proto @@ -7,6 +7,7 @@ service DocumentDataService { rpc GetDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc GetDocument(GetDocumentRequest) returns (GetDocumentResponse); rpc GetDocumentVersion(GetDocumentVersionRequest) returns (GetDocumentVersionResponse); + rpc GetTypstTemplateVersion(GetTypstTemplateVersionRequest) returns (GetTypstTemplateVersionResponse); } message SourceRecord { @@ -17,28 +18,24 @@ message SourceRecord { } message SaveDocumentRequest { - optional int64 schema_id = 1; - repeated SourceRecord source_records = 2; - optional string template_name = 3; - optional string template_kind = 4; - optional string template_path = 5; - string data_json = 6; + repeated SourceRecord source_records = 1; + string template_name = 2; + string typst_source = 3; + string typst_compiler_version = 4; + string data_json = 5; } message SaveDocumentResponse { int64 document_id = 1; int64 snapshot_id = 2; int32 version_number = 3; + int64 template_version_id = 4; + int32 template_version = 5; } message UpdateDocumentRequest { int64 document_id = 1; - optional int64 schema_id = 2; - repeated SourceRecord source_records = 3; - optional string template_name = 4; - optional string template_kind = 5; - optional string template_path = 6; - string data_json = 7; + string data_json = 2; } message UpdateDocumentResponse { @@ -56,16 +53,15 @@ message GetDocumentsRequest { message Document { int64 snapshot_id = 1; int64 document_id = 2; - optional int64 schema_id = 3; + int64 schema_id = 3; repeated SourceRecord source_records = 4; - optional string template_name = 5; - optional string template_kind = 6; - optional string template_path = 7; - string data_json = 8; - string change_kind = 9; - int32 version_number = 10; - string created_at = 11; - string updated_at = 12; + string data_json = 5; + string change_kind = 6; + int32 version_number = 7; + string created_at = 8; + string updated_at = 9; + int64 template_version_id = 10; + string data_sha256 = 11; } message GetDocumentsResponse { @@ -88,3 +84,23 @@ message GetDocumentVersionRequest { message GetDocumentVersionResponse { optional Document document = 1; } + +message GetTypstTemplateVersionRequest { + int64 template_version_id = 1; + int64 document_id = 2; +} + +message TypstTemplateVersion { + int64 id = 1; + int64 schema_id = 2; + string template_name = 3; + int32 version = 4; + string source_code = 5; + string source_sha256 = 6; + string typst_compiler_version = 7; + string created_at = 8; +} + +message GetTypstTemplateVersionResponse { + optional TypstTemplateVersion template_version = 1; +} diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index 3fbdfa63..9068981b 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -291,8 +291,8 @@ message ColumnDefinition { // MONEY rounding applied before a value is stored. MoneyRounding rounding = 3; - // When true, this numeric or Boolean column is server-owned and projected - // from ledger contributions. + // When true, this numeric column is server-owned and projected + // from quantity-ledger contributions. bool quantity_ledger = 4; // Canonical uppercase ISO-4217 currency code. Required for MONEY and forbidden @@ -302,9 +302,9 @@ message ColumnDefinition { // When true, the server rejects omitted or explicitly null values. bool required = 6; - // Required for Boolean ledger columns and forbidden otherwise. ANY means + // Enables a Boolean ledger on Boolean columns. ANY means // one true contribution wins; ALL means one false contribution wins. - BooleanLedgerOperator boolean_ledger_operator = 7; + BooleanLedgerOperator boolean_ledger = 7; } enum BooleanLedgerOperator { @@ -595,6 +595,8 @@ message ListColumnTypesResponse { // Whether ColumnDefinition.quantity_ledger may be set on this type. bool allows_quantity_ledger = 8; + // Whether ColumnDefinition.boolean_ledger may be set on this type. + bool allows_boolean_ledger = 11; // Optional name grouping several types a client offers behind one choice — // "temporal" for the date and time types, "gtin" for the GTIN lengths. diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 371c8cbe..d3f911c1 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.document_data.rs b/common/src/proto/komp_ac.document_data.rs index 47e150ca..58530b73 100644 --- a/common/src/proto/komp_ac.document_data.rs +++ b/common/src/proto/komp_ac.document_data.rs @@ -12,17 +12,15 @@ pub struct SourceRecord { } #[derive(Clone, PartialEq, ::prost::Message)] pub struct SaveDocumentRequest { - #[prost(int64, optional, tag = "1")] - pub schema_id: ::core::option::Option, - #[prost(message, repeated, tag = "2")] + #[prost(message, repeated, tag = "1")] pub source_records: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "3")] - pub template_name: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "4")] - pub template_kind: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "5")] - pub template_path: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, tag = "6")] + #[prost(string, tag = "2")] + pub template_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub typst_source: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub typst_compiler_version: ::prost::alloc::string::String, + #[prost(string, tag = "5")] pub data_json: ::prost::alloc::string::String, } #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] @@ -33,22 +31,16 @@ pub struct SaveDocumentResponse { pub snapshot_id: i64, #[prost(int32, tag = "3")] pub version_number: i32, + #[prost(int64, tag = "4")] + pub template_version_id: i64, + #[prost(int32, tag = "5")] + pub template_version: i32, } -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct UpdateDocumentRequest { #[prost(int64, tag = "1")] pub document_id: i64, - #[prost(int64, optional, tag = "2")] - pub schema_id: ::core::option::Option, - #[prost(message, repeated, tag = "3")] - pub source_records: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "4")] - pub template_name: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "5")] - pub template_kind: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "6")] - pub template_path: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, tag = "7")] + #[prost(string, tag = "2")] pub data_json: ::prost::alloc::string::String, } #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] @@ -75,26 +67,24 @@ pub struct Document { pub snapshot_id: i64, #[prost(int64, tag = "2")] pub document_id: i64, - #[prost(int64, optional, tag = "3")] - pub schema_id: ::core::option::Option, + #[prost(int64, tag = "3")] + pub schema_id: i64, #[prost(message, repeated, tag = "4")] pub source_records: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "5")] - pub template_name: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "6")] - pub template_kind: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "7")] - pub template_path: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, tag = "8")] + #[prost(string, tag = "5")] pub data_json: ::prost::alloc::string::String, - #[prost(string, tag = "9")] + #[prost(string, tag = "6")] pub change_kind: ::prost::alloc::string::String, - #[prost(int32, tag = "10")] + #[prost(int32, tag = "7")] pub version_number: i32, - #[prost(string, tag = "11")] + #[prost(string, tag = "8")] pub created_at: ::prost::alloc::string::String, - #[prost(string, tag = "12")] + #[prost(string, tag = "9")] pub updated_at: ::prost::alloc::string::String, + #[prost(int64, tag = "10")] + pub template_version_id: i64, + #[prost(string, tag = "11")] + pub data_sha256: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetDocumentsResponse { @@ -123,6 +113,37 @@ pub struct GetDocumentVersionResponse { #[prost(message, optional, tag = "1")] pub document: ::core::option::Option, } +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetTypstTemplateVersionRequest { + #[prost(int64, tag = "1")] + pub template_version_id: i64, + #[prost(int64, tag = "2")] + pub document_id: i64, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct TypstTemplateVersion { + #[prost(int64, tag = "1")] + pub id: i64, + #[prost(int64, tag = "2")] + pub schema_id: i64, + #[prost(string, tag = "3")] + pub template_name: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub version: i32, + #[prost(string, tag = "5")] + pub source_code: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub source_sha256: ::prost::alloc::string::String, + #[prost(string, tag = "7")] + pub typst_compiler_version: ::prost::alloc::string::String, + #[prost(string, tag = "8")] + pub created_at: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetTypstTemplateVersionResponse { + #[prost(message, optional, tag = "1")] + pub template_version: ::core::option::Option, +} /// Generated client implementations. pub mod document_data_service_client { #![allow( @@ -359,6 +380,35 @@ pub mod document_data_service_client { ); self.inner.unary(req, path, codec).await } + pub async fn get_typst_template_version( + &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.document_data.DocumentDataService/GetTypstTemplateVersion", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.document_data.DocumentDataService", + "GetTypstTemplateVersion", + ), + ); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -409,6 +459,13 @@ pub mod document_data_service_server { tonic::Response, tonic::Status, >; + async fn get_typst_template_version( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct DocumentDataServiceServer { @@ -719,6 +776,59 @@ pub mod document_data_service_server { }; Box::pin(fut) } + "/komp_ac.document_data.DocumentDataService/GetTypstTemplateVersion" => { + #[allow(non_camel_case_types)] + struct GetTypstTemplateVersionSvc( + pub Arc, + ); + impl< + T: DocumentDataService, + > tonic::server::UnaryService + for GetTypstTemplateVersionSvc { + type Response = super::GetTypstTemplateVersionResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetTypstTemplateVersionRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_typst_template_version( + &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 = GetTypstTemplateVersionSvc(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 ac0ab261..d5eb70ec 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -255,8 +255,8 @@ pub struct ColumnDefinition { /// MONEY rounding applied before a value is stored. #[prost(enumeration = "MoneyRounding", tag = "3")] pub rounding: i32, - /// When true, this numeric or Boolean column is server-owned and projected - /// from ledger contributions. + /// When true, this numeric column is server-owned and projected + /// from quantity-ledger contributions. #[prost(bool, tag = "4")] pub quantity_ledger: bool, /// Canonical uppercase ISO-4217 currency code. Required for MONEY and forbidden @@ -266,11 +266,11 @@ pub struct ColumnDefinition { /// When true, the server rejects omitted or explicitly null values. #[prost(bool, tag = "6")] pub required: bool, - /// Required for Boolean ledger columns and forbidden otherwise. ANY means + /// Enables a Boolean ledger on Boolean columns. ANY means /// one true contribution wins; ALL means one false contribution wins. #[prost(enumeration = "BooleanLedgerOperator", tag = "7")] - #[serde(default)] - pub boolean_ledger_operator: i32, + #[serde(default, alias = "boolean_ledger_operator")] + pub boolean_ledger: i32, } /// Response after table creation (success + DDL preview). #[derive(serde::Serialize, serde::Deserialize)] @@ -620,6 +620,9 @@ pub mod list_column_types_response { /// Whether ColumnDefinition.quantity_ledger may be set on this type. #[prost(bool, tag = "8")] pub allows_quantity_ledger: bool, + /// Whether ColumnDefinition.boolean_ledger may be set on this type. + #[prost(bool, tag = "11")] + pub allows_boolean_ledger: bool, /// Optional name grouping several types a client offers behind one choice — /// "temporal" for the date and time types, "gtin" for the GTIN lengths. /// Empty when the type stands on its own. diff --git a/server b/server index 554e98ec..b25dd5a9 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 554e98ec117ea09f9a856dcbc3c1c86b6768fc30 +Subproject commit b25dd5a9d3827bdc90706ad900cc37cb76df4c56 diff --git a/web/src/schema/mod.rs b/web/src/schema/mod.rs index 7483d342..17498bd2 100644 --- a/web/src/schema/mod.rs +++ b/web/src/schema/mod.rs @@ -95,6 +95,7 @@ pub(crate) struct ColumnType { /// Only choosable while the table is being created. pub creation_only: bool, pub allows_quantity_ledger: bool, + pub allows_boolean_ledger: bool, /// Groups several types behind one choice in the picker; empty when the /// type stands on its own. pub group: String, @@ -1269,6 +1270,7 @@ pub(crate) fn proto_columns(columns: &[ColumnDefinition]) -> Vec MoneyRounding::None.into(), }, quantity_ledger: column.quantity_ledger, + boolean_ledger: 0, currency: column.currency.clone(), required: column.required, }) @@ -1290,6 +1292,7 @@ pub(crate) fn column_catalog(column_types: Vec) -> ColumnCatalo requires_currency: column_type.requires_currency, creation_only: column_type.creation_only, allows_quantity_ledger: column_type.allows_quantity_ledger, + allows_boolean_ledger: column_type.allows_boolean_ledger, group: column_type.group, generated_columns: column_type .generated_columns