From 4a378a5c1ec775a3cc8cb04140e4a84556de3c31 Mon Sep 17 00:00:00 2001 From: Priec Date: Tue, 8 Sep 2026 16:38:21 +0200 Subject: [PATCH] migration can gain functionality of table definition from now on2 --- client | 2 +- client-gui2 | 2 +- common/build.rs | 2 +- common/proto/document_data.proto | 115 +++- common/src/proto/descriptor.bin | Bin 255894 -> 261390 bytes common/src/proto/komp_ac.document_data.rs | 756 +++++++++++++++++----- komp-app/src/grpc.rs | 83 ++- komp-app/src/typst.rs | 8 +- server | 2 +- 9 files changed, 751 insertions(+), 219 deletions(-) diff --git a/client b/client index 7687c805..4bb6a4b0 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 7687c805242841e800cece78d04ce0a29c42819e +Subproject commit 4bb6a4b07a5f061cf1147135e87564620aab246c diff --git a/client-gui2 b/client-gui2 index 957ad911..3a7d9cd8 160000 --- a/client-gui2 +++ b/client-gui2 @@ -1 +1 @@ -Subproject commit 957ad911eb37ba3b72650e39956c1d96735dac05 +Subproject commit 3a7d9cd88120992b173b62f3fd2b8b6f289cc060 diff --git a/common/build.rs b/common/build.rs index f8bdcc54..5cf09342 100644 --- a/common/build.rs +++ b/common/build.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), Box> { .type_attribute(".komp_ac.common", serde) .type_attribute(".komp_ac.document_data", serde) .type_attribute( - ".komp_ac.document_data.TypstTemplateVersion", + ".komp_ac.document_data.DocumentTemplateVersion", "#[derive(Eq)]", ) .type_attribute(".komp_ac.ecb", serde) diff --git a/common/proto/document_data.proto b/common/proto/document_data.proto index b184c24b..79c6bdf0 100644 --- a/common/proto/document_data.proto +++ b/common/proto/document_data.proto @@ -2,15 +2,30 @@ syntax = "proto3"; package komp_ac.document_data; service DocumentDataService { - rpc RegisterTypstTemplate(RegisterTypstTemplateRequest) returns (RegisterTypstTemplateResponse); - rpc ListTypstTemplates(ListTypstTemplatesRequest) returns (ListTypstTemplatesResponse); - rpc ListEnabledTypstTemplates(ListEnabledTypstTemplatesRequest) returns (ListTypstTemplatesResponse); + rpc RegisterDocumentTemplate(RegisterDocumentTemplateRequest) returns (RegisterDocumentTemplateResponse); + rpc ListDocumentTemplates(ListDocumentTemplatesRequest) returns (ListDocumentTemplatesResponse); + rpc ListEnabledDocumentTemplates(ListEnabledDocumentTemplatesRequest) returns (ListDocumentTemplatesResponse); rpc SaveDocument(SaveDocumentRequest) returns (SaveDocumentResponse); rpc UpdateDocument(UpdateDocumentRequest) returns (UpdateDocumentResponse); + rpc RenderTextDocument(RenderTextDocumentRequest) returns (RenderTextDocumentResponse); + rpc FinalizeDocument(FinalizeDocumentRequest) returns (FinalizeDocumentResponse); + rpc GetArchivedDocument(GetArchivedDocumentRequest) returns (GetArchivedDocumentResponse); rpc GetDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc GetDocument(GetDocumentRequest) returns (GetDocumentResponse); rpc GetDocumentVersion(GetDocumentVersionRequest) returns (GetDocumentVersionResponse); - rpc GetTypstTemplateVersion(GetTypstTemplateVersionRequest) returns (GetTypstTemplateVersionResponse); + rpc GetDocumentTemplateVersion(GetDocumentTemplateVersionRequest) returns (GetDocumentTemplateVersionResponse); +} + +enum DocumentFormat { + DOCUMENT_FORMAT_UNSPECIFIED = 0; + DOCUMENT_FORMAT_TYPST = 1; + DOCUMENT_FORMAT_PLAIN_TEXT = 2; +} + +enum DocumentState { + DOCUMENT_STATE_UNSPECIFIED = 0; + DOCUMENT_STATE_DRAFT = 1; + DOCUMENT_STATE_FINALIZED = 2; } message SourceRecord { @@ -25,29 +40,32 @@ message SaveDocumentRequest { string template_name = 2; string data_json = 3; int64 expected_template_version_id = 4; + string profile_name = 5; } -message RegisterTypstTemplateRequest { +message RegisterDocumentTemplateRequest { string template_name = 1; string input_table_name = 2; - string typst_source = 3; - string typst_compiler_version = 4; + string template_source = 3; + string renderer_version = 4; + DocumentFormat format = 5; } -message RegisterTypstTemplateResponse { - TypstTemplateVersion template_version = 1; +message RegisterDocumentTemplateResponse { + DocumentTemplateVersion template_version = 1; } -message ListTypstTemplatesRequest { +message ListDocumentTemplatesRequest { string search = 1; uint32 limit = 2; + DocumentFormat format = 3; } -message ListTypstTemplatesResponse { - repeated TypstTemplateVersion templates = 1; +message ListDocumentTemplatesResponse { + repeated DocumentTemplateVersion templates = 1; } -message ListEnabledTypstTemplatesRequest { +message ListEnabledDocumentTemplatesRequest { string profile_name = 1; } @@ -62,6 +80,8 @@ message SaveDocumentResponse { message UpdateDocumentRequest { int64 document_id = 1; string data_json = 2; + string profile_name = 3; + int32 expected_version_number = 4; } message UpdateDocumentResponse { @@ -76,6 +96,7 @@ message GetDocumentsRequest { optional string template_name = 3; optional string source_profile_name = 4; optional string source_table_name = 5; + string profile_name = 6; } enum DocumentDataChangeKind { @@ -96,6 +117,9 @@ message Document { string updated_at = 9; int64 template_version_id = 10; string data_sha256 = 11; + string profile_name = 12; + DocumentState state = 13; + optional int64 archive_id = 14; } message GetDocumentsResponse { @@ -104,6 +128,7 @@ message GetDocumentsResponse { message GetDocumentRequest { int64 document_id = 1; + string profile_name = 2; } message GetDocumentResponse { @@ -113,40 +138,90 @@ message GetDocumentResponse { message GetDocumentVersionRequest { int64 document_id = 1; int32 version_number = 2; + string profile_name = 3; } message GetDocumentVersionResponse { optional Document document = 1; } -message GetTypstTemplateVersionRequest { +message GetDocumentTemplateVersionRequest { int64 template_version_id = 1; int64 document_id = 2; + string profile_name = 3; } -message TypstTemplateVersion { +message DocumentTemplateVersion { int64 id = 1; int64 template_id = 2; string template_name = 3; int32 version = 4; string source_code = 5; string source_sha256 = 6; - string typst_compiler_version = 7; + string renderer_version = 7; string created_at = 8; string input_table_name = 9; repeated string field_paths = 10; - repeated TypstTemplateFieldBinding field_bindings = 11; + repeated DocumentTemplateFieldBinding field_bindings = 11; + DocumentFormat format = 12; } // One profile-specific source mapping for an enabled template version. -message TypstTemplateFieldBinding { +message DocumentTemplateFieldBinding { string field_path = 1; string collection_path = 2; string column_name = 3; string source_table_name = 4; string source_column_name = 5; + string source_profile_name = 6; } -message GetTypstTemplateVersionResponse { - optional TypstTemplateVersion template_version = 1; +message GetDocumentTemplateVersionResponse { + optional DocumentTemplateVersion template_version = 1; +} + +message RenderTextDocumentRequest { + string profile_name = 1; + int64 document_id = 2; + int32 expected_version_number = 3; +} + +message RenderTextDocumentResponse { + string text = 1; + string renderer_version = 2; + string data_sha256 = 3; +} + +message FinalizeDocumentRequest { + string profile_name = 1; + int64 document_id = 2; + int32 expected_version_number = 3; + // Typst output is compiled by the caller with the pinned template and data. + // Plain-text output is rendered by the server; these fields must be empty. + bytes rendered_output = 4; + string renderer_version = 5; +} + +message FinalizeDocumentResponse { + int64 archive_id = 1; + string output_sha256 = 2; +} + +message GetArchivedDocumentRequest { + string profile_name = 1; + int64 archive_id = 2; +} + +message ArchivedDocument { + int64 id = 1; + Document document = 2; + DocumentTemplateVersion template_version = 3; + DocumentFormat format = 4; + bytes output = 5; + string output_sha256 = 6; + string finalized_at = 7; +} + +message GetArchivedDocumentResponse { + optional ArchivedDocument document = 1; } diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index b4a81cb00c3e84541be463019baeb825d00ef8ef..73ece6889ce6b7c7c71721d0ae617bd18b642dab 100644 GIT binary patch delta 10851 zcmbuFX>eRscE|g^e%e_?cNV0fs>*P2!C`xWMMcwvypAj(!W35So+|{nX^~v z&)rtsaWKeFh^g3PgXu1ejSLTs6~Zm07oTcYbDfFO-#*e_b%zRC*N}=!-Zi z5*X)o#RRW=f~n)kvB$C4<(eStk{@eQ`Q)tJ!r1>}7obhH`=n~e>R`GUUOCjaeX!7P zgF9)zw4iKG>7O6{+IvZr-g)fuZDD&*J~BGIb6~L0JJh$w6+UObt>aU;C}=EPKT_CH zEcCmo_YUpbv%N5?i=XPQcVZjQIxXzDNd*n1_T!EBKDOKIc)xV`@vo;(a+lVtH{M<8 z`-j(i|Kgwc;P9vF>`D6Nlk~&IL29f>>ois9lAqyL>7q^Ywc7~8jv(k8-LZRMf1!7v zzo`<{8@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ukx@Q>;My4|xyUV$o)PD6rp1K*d_aSpz_B4a)(+aSf7=DGosBt>LT# z%4{vK3IOoda?^mw#+w2Nw6)k2)U#0gk9gmo^Rc7@q66 z_<+z`$6e zx8W@DAC|M{wH_G@Fbg>ikX~Kmg>plP3uXjyrh(fso@) z9>9o>+Lh9%*Sk_0#k(t|q1AC_SIR?ByZQEr%;4@$d8E0UUmLLDxZQYdPvcS(1)z;PS}bX0j;Fi;yz!J5>dZljU-sCMkqp5* zm_|t}?jY}R*g!kjUFD7_otfZEFOmwh33r^N)iM#*qMS$;jVP?G1k zHUOZVOKFtjIj#+Cpq(?dk+H9J_Brnd!p5QD_Z-iirZ{40AE5vcj9Cx}j&Wf3KM(}t zMtXPRUO*iF^8$f1;UI+#bf_q-zCj(nS zJulEJO9gsC$W}JuUL)v^#qI+Pnw-@*<4KM84~2{u`HKR-5UnuQA3=94_8%ZVTDF4w zqQGxNONH-CcOuSO=&0C%u%;1X2?C}OC^aaHrd2 z@kIXqog!lu5_DATLO?7vOT{t-Olyn><10dT8)K{`_90=%#XbZKT`jN>0r9iT9*bAr z1tITa;ShBLR1QMvg1|e#9*Y$TsJk45(gjhaJw_$RgX>ixM^~{`K?>MODb(gw5xLS} zZ36Z#bIy=@RSd6G+p&rYI`^9Jl4Qf5x5cjsYzopZV0itDu0TKt4bUbD2)&E0K!DJ@ z=n7Pz0e)TJ9ZqQgfePrT_>=%cJKnH@`nteVoKB4kcv<+D+#~^k3+T9{e927`tl(a9 zlT;w|hQLeH9!moZ=%_TnZ-}tsti~D7OPef;_ok55n5{Ixz>Z4;{H6%)S5+`SXWtZ9 z8x5#ltIoY8yes(rBm7^QR(QT80(yD*ek;}RvXIM-DiBTqv@HTei!KZNI;403K`mSs e)ggxw;bpPxffp;Ey;Av1;6M3s<+IFxdjALT@1?K+ diff --git a/common/src/proto/komp_ac.document_data.rs b/common/src/proto/komp_ac.document_data.rs index 18ff0ed4..0f123f1e 100644 --- a/common/src/proto/komp_ac.document_data.rs +++ b/common/src/proto/komp_ac.document_data.rs @@ -22,42 +22,48 @@ pub struct SaveDocumentRequest { pub data_json: ::prost::alloc::string::String, #[prost(int64, tag = "4")] pub expected_template_version_id: i64, + #[prost(string, tag = "5")] + pub profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct RegisterTypstTemplateRequest { +pub struct RegisterDocumentTemplateRequest { #[prost(string, tag = "1")] pub template_name: ::prost::alloc::string::String, #[prost(string, tag = "2")] pub input_table_name: ::prost::alloc::string::String, #[prost(string, tag = "3")] - pub typst_source: ::prost::alloc::string::String, + pub template_source: ::prost::alloc::string::String, #[prost(string, tag = "4")] - pub typst_compiler_version: ::prost::alloc::string::String, + pub renderer_version: ::prost::alloc::string::String, + #[prost(enumeration = "DocumentFormat", tag = "5")] + pub format: i32, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct RegisterTypstTemplateResponse { +pub struct RegisterDocumentTemplateResponse { #[prost(message, optional, tag = "1")] - pub template_version: ::core::option::Option, + pub template_version: ::core::option::Option, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ListTypstTemplatesRequest { +pub struct ListDocumentTemplatesRequest { #[prost(string, tag = "1")] pub search: ::prost::alloc::string::String, #[prost(uint32, tag = "2")] pub limit: u32, + #[prost(enumeration = "DocumentFormat", tag = "3")] + pub format: i32, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListTypstTemplatesResponse { +pub struct ListDocumentTemplatesResponse { #[prost(message, repeated, tag = "1")] - pub templates: ::prost::alloc::vec::Vec, + pub templates: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ListEnabledTypstTemplatesRequest { +pub struct ListEnabledDocumentTemplatesRequest { #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, } @@ -82,6 +88,10 @@ pub struct UpdateDocumentRequest { pub document_id: i64, #[prost(string, tag = "2")] pub data_json: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub expected_version_number: i32, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] @@ -106,6 +116,8 @@ pub struct GetDocumentsRequest { pub source_profile_name: ::core::option::Option<::prost::alloc::string::String>, #[prost(string, optional, tag = "5")] pub source_table_name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "6")] + pub profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -132,6 +144,12 @@ pub struct Document { pub template_version_id: i64, #[prost(string, tag = "11")] pub data_sha256: ::prost::alloc::string::String, + #[prost(string, tag = "12")] + pub profile_name: ::prost::alloc::string::String, + #[prost(enumeration = "DocumentState", tag = "13")] + pub state: i32, + #[prost(int64, optional, tag = "14")] + pub archive_id: ::core::option::Option, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -140,10 +158,12 @@ pub struct GetDocumentsResponse { pub documents: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetDocumentRequest { #[prost(int64, tag = "1")] pub document_id: i64, + #[prost(string, tag = "2")] + pub profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -152,12 +172,14 @@ pub struct GetDocumentResponse { pub document: ::core::option::Option, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetDocumentVersionRequest { #[prost(int64, tag = "1")] pub document_id: i64, #[prost(int32, tag = "2")] pub version_number: i32, + #[prost(string, tag = "3")] + pub profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -166,17 +188,19 @@ pub struct GetDocumentVersionResponse { pub document: ::core::option::Option, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct GetTypstTemplateVersionRequest { +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetDocumentTemplateVersionRequest { #[prost(int64, tag = "1")] pub template_version_id: i64, #[prost(int64, tag = "2")] pub document_id: i64, + #[prost(string, tag = "3")] + pub profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct TypstTemplateVersion { +pub struct DocumentTemplateVersion { #[prost(int64, tag = "1")] pub id: i64, #[prost(int64, tag = "2")] @@ -190,7 +214,7 @@ pub struct TypstTemplateVersion { #[prost(string, tag = "6")] pub source_sha256: ::prost::alloc::string::String, #[prost(string, tag = "7")] - pub typst_compiler_version: ::prost::alloc::string::String, + pub renderer_version: ::prost::alloc::string::String, #[prost(string, tag = "8")] pub created_at: ::prost::alloc::string::String, #[prost(string, tag = "9")] @@ -198,12 +222,14 @@ pub struct TypstTemplateVersion { #[prost(string, repeated, tag = "10")] pub field_paths: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, #[prost(message, repeated, tag = "11")] - pub field_bindings: ::prost::alloc::vec::Vec, + pub field_bindings: ::prost::alloc::vec::Vec, + #[prost(enumeration = "DocumentFormat", tag = "12")] + pub format: i32, } /// One profile-specific source mapping for an enabled template version. #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct TypstTemplateFieldBinding { +pub struct DocumentTemplateFieldBinding { #[prost(string, tag = "1")] pub field_path: ::prost::alloc::string::String, #[prost(string, tag = "2")] @@ -214,12 +240,150 @@ pub struct TypstTemplateFieldBinding { pub source_table_name: ::prost::alloc::string::String, #[prost(string, tag = "5")] pub source_column_name: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub source_profile_name: ::prost::alloc::string::String, } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetTypstTemplateVersionResponse { +pub struct GetDocumentTemplateVersionResponse { #[prost(message, optional, tag = "1")] - pub template_version: ::core::option::Option, + pub template_version: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RenderTextDocumentRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub document_id: i64, + #[prost(int32, tag = "3")] + pub expected_version_number: i32, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RenderTextDocumentResponse { + #[prost(string, tag = "1")] + pub text: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub renderer_version: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub data_sha256: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinalizeDocumentRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub document_id: i64, + #[prost(int32, tag = "3")] + pub expected_version_number: i32, + /// Typst output is compiled by the caller with the pinned template and data. + /// Plain-text output is rendered by the server; these fields must be empty. + #[prost(bytes = "vec", tag = "4")] + pub rendered_output: ::prost::alloc::vec::Vec, + #[prost(string, tag = "5")] + pub renderer_version: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinalizeDocumentResponse { + #[prost(int64, tag = "1")] + pub archive_id: i64, + #[prost(string, tag = "2")] + pub output_sha256: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetArchivedDocumentRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub archive_id: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ArchivedDocument { + #[prost(int64, tag = "1")] + pub id: i64, + #[prost(message, optional, tag = "2")] + pub document: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub template_version: ::core::option::Option, + #[prost(enumeration = "DocumentFormat", tag = "4")] + pub format: i32, + #[prost(bytes = "vec", tag = "5")] + pub output: ::prost::alloc::vec::Vec, + #[prost(string, tag = "6")] + pub output_sha256: ::prost::alloc::string::String, + #[prost(string, tag = "7")] + pub finalized_at: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetArchivedDocumentResponse { + #[prost(message, optional, tag = "1")] + pub document: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum DocumentFormat { + Unspecified = 0, + Typst = 1, + PlainText = 2, +} +impl DocumentFormat { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DOCUMENT_FORMAT_UNSPECIFIED", + Self::Typst => "DOCUMENT_FORMAT_TYPST", + Self::PlainText => "DOCUMENT_FORMAT_PLAIN_TEXT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DOCUMENT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified), + "DOCUMENT_FORMAT_TYPST" => Some(Self::Typst), + "DOCUMENT_FORMAT_PLAIN_TEXT" => Some(Self::PlainText), + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum DocumentState { + Unspecified = 0, + Draft = 1, + Finalized = 2, +} +impl DocumentState { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DOCUMENT_STATE_UNSPECIFIED", + Self::Draft => "DOCUMENT_STATE_DRAFT", + Self::Finalized => "DOCUMENT_STATE_FINALIZED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DOCUMENT_STATE_UNSPECIFIED" => Some(Self::Unspecified), + "DOCUMENT_STATE_DRAFT" => Some(Self::Draft), + "DOCUMENT_STATE_FINALIZED" => Some(Self::Finalized), + _ => None, + } + } } #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] @@ -342,11 +506,11 @@ pub mod document_data_service_client { self.inner = self.inner.max_encoding_message_size(limit); self } - pub async fn register_typst_template( + pub async fn register_document_template( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -359,23 +523,23 @@ pub mod document_data_service_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/komp_ac.document_data.DocumentDataService/RegisterTypstTemplate", + "/komp_ac.document_data.DocumentDataService/RegisterDocumentTemplate", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "komp_ac.document_data.DocumentDataService", - "RegisterTypstTemplate", + "RegisterDocumentTemplate", ), ); self.inner.unary(req, path, codec).await } - pub async fn list_typst_templates( + pub async fn list_document_templates( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -388,23 +552,23 @@ pub mod document_data_service_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/komp_ac.document_data.DocumentDataService/ListTypstTemplates", + "/komp_ac.document_data.DocumentDataService/ListDocumentTemplates", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "komp_ac.document_data.DocumentDataService", - "ListTypstTemplates", + "ListDocumentTemplates", ), ); self.inner.unary(req, path, codec).await } - pub async fn list_enabled_typst_templates( + pub async fn list_enabled_document_templates( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -417,14 +581,14 @@ pub mod document_data_service_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/komp_ac.document_data.DocumentDataService/ListEnabledTypstTemplates", + "/komp_ac.document_data.DocumentDataService/ListEnabledDocumentTemplates", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "komp_ac.document_data.DocumentDataService", - "ListEnabledTypstTemplates", + "ListEnabledDocumentTemplates", ), ); self.inner.unary(req, path, codec).await @@ -487,6 +651,93 @@ pub mod document_data_service_client { ); self.inner.unary(req, path, codec).await } + pub async fn render_text_document( + &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/RenderTextDocument", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.document_data.DocumentDataService", + "RenderTextDocument", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn finalize_document( + &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/FinalizeDocument", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.document_data.DocumentDataService", + "FinalizeDocument", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_archived_document( + &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/GetArchivedDocument", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.document_data.DocumentDataService", + "GetArchivedDocument", + ), + ); + self.inner.unary(req, path, codec).await + } pub async fn get_documents( &mut self, request: impl tonic::IntoRequest, @@ -574,11 +825,11 @@ pub mod document_data_service_client { ); self.inner.unary(req, path, codec).await } - pub async fn get_typst_template_version( + pub async fn get_document_template_version( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -591,14 +842,14 @@ pub mod document_data_service_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/komp_ac.document_data.DocumentDataService/GetTypstTemplateVersion", + "/komp_ac.document_data.DocumentDataService/GetDocumentTemplateVersion", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "komp_ac.document_data.DocumentDataService", - "GetTypstTemplateVersion", + "GetDocumentTemplateVersion", ), ); self.inner.unary(req, path, codec).await @@ -618,25 +869,25 @@ pub mod document_data_service_server { /// Generated trait containing gRPC methods that should be implemented for use with DocumentDataServiceServer. #[async_trait] pub trait DocumentDataService: std::marker::Send + std::marker::Sync + 'static { - async fn register_typst_template( + async fn register_document_template( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; - async fn list_typst_templates( + async fn list_document_templates( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; - async fn list_enabled_typst_templates( + async fn list_enabled_document_templates( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; async fn save_document( @@ -653,6 +904,27 @@ pub mod document_data_service_server { tonic::Response, tonic::Status, >; + async fn render_text_document( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn finalize_document( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_archived_document( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_documents( &self, request: tonic::Request, @@ -674,11 +946,11 @@ pub mod document_data_service_server { tonic::Response, tonic::Status, >; - async fn get_typst_template_version( + async fn get_document_template_version( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; } @@ -758,115 +1030,16 @@ pub mod document_data_service_server { } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { - "/komp_ac.document_data.DocumentDataService/RegisterTypstTemplate" => { + "/komp_ac.document_data.DocumentDataService/RegisterDocumentTemplate" => { #[allow(non_camel_case_types)] - struct RegisterTypstTemplateSvc(pub Arc); - impl< - T: DocumentDataService, - > tonic::server::UnaryService - for RegisterTypstTemplateSvc { - type Response = super::RegisterTypstTemplateResponse; - 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 { - ::register_typst_template( - &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 = RegisterTypstTemplateSvc(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) - } - "/komp_ac.document_data.DocumentDataService/ListTypstTemplates" => { - #[allow(non_camel_case_types)] - struct ListTypstTemplatesSvc(pub Arc); - impl< - T: DocumentDataService, - > tonic::server::UnaryService - for ListTypstTemplatesSvc { - type Response = super::ListTypstTemplatesResponse; - 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 { - ::list_typst_templates( - &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 = ListTypstTemplatesSvc(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) - } - "/komp_ac.document_data.DocumentDataService/ListEnabledTypstTemplates" => { - #[allow(non_camel_case_types)] - struct ListEnabledTypstTemplatesSvc( + struct RegisterDocumentTemplateSvc( pub Arc, ); impl< T: DocumentDataService, - > tonic::server::UnaryService< - super::ListEnabledTypstTemplatesRequest, - > for ListEnabledTypstTemplatesSvc { - type Response = super::ListTypstTemplatesResponse; + > tonic::server::UnaryService + for RegisterDocumentTemplateSvc { + type Response = super::RegisterDocumentTemplateResponse; type Future = BoxFuture< tonic::Response, tonic::Status, @@ -874,12 +1047,12 @@ pub mod document_data_service_server { fn call( &mut self, request: tonic::Request< - super::ListEnabledTypstTemplatesRequest, + super::RegisterDocumentTemplateRequest, >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::list_enabled_typst_templates( + ::register_document_template( &inner, request, ) @@ -894,7 +1067,110 @@ pub mod document_data_service_server { let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { - let method = ListEnabledTypstTemplatesSvc(inner); + let method = RegisterDocumentTemplateSvc(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) + } + "/komp_ac.document_data.DocumentDataService/ListDocumentTemplates" => { + #[allow(non_camel_case_types)] + struct ListDocumentTemplatesSvc(pub Arc); + impl< + T: DocumentDataService, + > tonic::server::UnaryService + for ListDocumentTemplatesSvc { + type Response = super::ListDocumentTemplatesResponse; + 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 { + ::list_document_templates( + &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 = ListDocumentTemplatesSvc(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) + } + "/komp_ac.document_data.DocumentDataService/ListEnabledDocumentTemplates" => { + #[allow(non_camel_case_types)] + struct ListEnabledDocumentTemplatesSvc( + pub Arc, + ); + impl< + T: DocumentDataService, + > tonic::server::UnaryService< + super::ListEnabledDocumentTemplatesRequest, + > for ListEnabledDocumentTemplatesSvc { + type Response = super::ListDocumentTemplatesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::ListEnabledDocumentTemplatesRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::list_enabled_document_templates( + &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 = ListEnabledDocumentTemplatesSvc(inner); let codec = tonic_prost::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( @@ -1002,6 +1278,153 @@ pub mod document_data_service_server { }; Box::pin(fut) } + "/komp_ac.document_data.DocumentDataService/RenderTextDocument" => { + #[allow(non_camel_case_types)] + struct RenderTextDocumentSvc(pub Arc); + impl< + T: DocumentDataService, + > tonic::server::UnaryService + for RenderTextDocumentSvc { + type Response = super::RenderTextDocumentResponse; + 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 { + ::render_text_document( + &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 = RenderTextDocumentSvc(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) + } + "/komp_ac.document_data.DocumentDataService/FinalizeDocument" => { + #[allow(non_camel_case_types)] + struct FinalizeDocumentSvc(pub Arc); + impl< + T: DocumentDataService, + > tonic::server::UnaryService + for FinalizeDocumentSvc { + type Response = super::FinalizeDocumentResponse; + 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 { + ::finalize_document( + &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 = FinalizeDocumentSvc(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) + } + "/komp_ac.document_data.DocumentDataService/GetArchivedDocument" => { + #[allow(non_camel_case_types)] + struct GetArchivedDocumentSvc(pub Arc); + impl< + T: DocumentDataService, + > tonic::server::UnaryService + for GetArchivedDocumentSvc { + type Response = super::GetArchivedDocumentResponse; + 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_archived_document( + &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 = GetArchivedDocumentSvc(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) + } "/komp_ac.document_data.DocumentDataService/GetDocuments" => { #[allow(non_camel_case_types)] struct GetDocumentsSvc(pub Arc); @@ -1143,16 +1566,17 @@ pub mod document_data_service_server { }; Box::pin(fut) } - "/komp_ac.document_data.DocumentDataService/GetTypstTemplateVersion" => { + "/komp_ac.document_data.DocumentDataService/GetDocumentTemplateVersion" => { #[allow(non_camel_case_types)] - struct GetTypstTemplateVersionSvc( + struct GetDocumentTemplateVersionSvc( pub Arc, ); impl< T: DocumentDataService, - > tonic::server::UnaryService - for GetTypstTemplateVersionSvc { - type Response = super::GetTypstTemplateVersionResponse; + > tonic::server::UnaryService< + super::GetDocumentTemplateVersionRequest, + > for GetDocumentTemplateVersionSvc { + type Response = super::GetDocumentTemplateVersionResponse; type Future = BoxFuture< tonic::Response, tonic::Status, @@ -1160,12 +1584,12 @@ pub mod document_data_service_server { fn call( &mut self, request: tonic::Request< - super::GetTypstTemplateVersionRequest, + super::GetDocumentTemplateVersionRequest, >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_typst_template_version( + ::get_document_template_version( &inner, request, ) @@ -1180,7 +1604,7 @@ pub mod document_data_service_server { let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { - let method = GetTypstTemplateVersionSvc(inner); + let method = GetDocumentTemplateVersionSvc(inner); let codec = tonic_prost::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( diff --git a/komp-app/src/grpc.rs b/komp-app/src/grpc.rs index 5bfee161..f116b5d9 100644 --- a/komp-app/src/grpc.rs +++ b/komp-app/src/grpc.rs @@ -25,10 +25,10 @@ use common::proto::komp_ac::accounting::{ use common::proto::komp_ac::common::Empty; use common::proto::komp_ac::document_data::{ GetDocumentRequest, GetDocumentResponse, GetDocumentVersionRequest, GetDocumentVersionResponse, - GetDocumentsRequest, GetDocumentsResponse, GetTypstTemplateVersionRequest, - GetTypstTemplateVersionResponse, ListEnabledTypstTemplatesRequest, - ListTypstTemplatesRequest, ListTypstTemplatesResponse, RegisterTypstTemplateRequest, - RegisterTypstTemplateResponse, SaveDocumentRequest, SaveDocumentResponse, + GetDocumentsRequest, GetDocumentsResponse, GetDocumentTemplateVersionRequest, + GetDocumentTemplateVersionResponse, ListEnabledDocumentTemplatesRequest, + ListDocumentTemplatesRequest, ListDocumentTemplatesResponse, RegisterDocumentTemplateRequest, + RegisterDocumentTemplateResponse, SaveDocumentRequest, SaveDocumentResponse, UpdateDocumentRequest, UpdateDocumentResponse, document_data_service_client::DocumentDataServiceClient, }; @@ -122,7 +122,9 @@ impl GrpcClient { let table_definition_client = TableDefinitionClient::new(channel.clone()); let table_script_client = TableScriptClient::new(channel.clone()); let tables_data_client = TablesDataClient::new(channel.clone()); - let document_data_client = DocumentDataServiceClient::new(channel.clone()); + let document_data_client = DocumentDataServiceClient::new(channel.clone()) + .max_decoding_message_size(64 * 1024 * 1024) + .max_encoding_message_size(64 * 1024 * 1024); let search_client = SearchGrpc::new(channel.clone()); let table_validation_client = TableValidationServiceClient::new(channel.clone()); let accounting_client = AccountingClient::new(channel.clone()); @@ -1092,45 +1094,46 @@ impl GrpcClient { Ok(response.into_inner()) } - pub async fn list_enabled_typst_templates( + pub async fn list_enabled_document_templates( &mut self, profile_name: String, - ) -> Result { - let request = self.authenticated_request(ListEnabledTypstTemplatesRequest { + ) -> Result { + let request = self.authenticated_request(ListEnabledDocumentTemplatesRequest { profile_name, })?; let response = self .document_data_client - .list_enabled_typst_templates(request) + .list_enabled_document_templates(request) .await - .context("gRPC ListEnabledTypstTemplates call failed")?; + .context("gRPC ListEnabledDocumentTemplates call failed")?; Ok(response.into_inner()) } - pub async fn list_typst_templates( + pub async fn list_document_templates( &mut self, + format: common::proto::komp_ac::document_data::DocumentFormat, search: String, limit: u32, - ) -> Result { - let request = self.authenticated_request(ListTypstTemplatesRequest { search, limit })?; + ) -> Result { + let request = self.authenticated_request(ListDocumentTemplatesRequest { search, limit, format: format.into() })?; let response = self .document_data_client - .list_typst_templates(request) + .list_document_templates(request) .await - .context("gRPC ListTypstTemplates call failed")?; + .context("gRPC ListDocumentTemplates call failed")?; Ok(response.into_inner()) } - pub async fn register_typst_template( + pub async fn register_document_template( &mut self, - request: RegisterTypstTemplateRequest, - ) -> Result { + request: RegisterDocumentTemplateRequest, + ) -> Result { let request = self.authenticated_request(request)?; let response = self .document_data_client - .register_typst_template(request) + .register_document_template(request) .await - .context("gRPC RegisterTypstTemplate call failed")?; + .context("gRPC RegisterDocumentTemplate call failed")?; Ok(response.into_inner()) } @@ -1186,16 +1189,46 @@ impl GrpcClient { Ok(response.into_inner()) } - pub async fn get_typst_template_version( + pub async fn get_document_template_version( &mut self, - request: GetTypstTemplateVersionRequest, - ) -> Result { + request: GetDocumentTemplateVersionRequest, + ) -> Result { let request = self.authenticated_request(request)?; let response = self .document_data_client - .get_typst_template_version(request) + .get_document_template_version(request) .await - .context("gRPC GetTypstTemplateVersion call failed")?; + .context("gRPC GetDocumentTemplateVersion call failed")?; + Ok(response.into_inner()) + } + + pub async fn render_text_document( + &mut self, + request: common::proto::komp_ac::document_data::RenderTextDocumentRequest, + ) -> Result { + let request = self.authenticated_request(request)?; + let response = self.document_data_client.render_text_document(request).await + .context("gRPC render_text_document call failed")?; + Ok(response.into_inner()) + } + + pub async fn finalize_document( + &mut self, + request: common::proto::komp_ac::document_data::FinalizeDocumentRequest, + ) -> Result { + let request = self.authenticated_request(request)?; + let response = self.document_data_client.finalize_document(request).await + .context("gRPC finalize_document call failed")?; + Ok(response.into_inner()) + } + + pub async fn get_archived_document( + &mut self, + request: common::proto::komp_ac::document_data::GetArchivedDocumentRequest, + ) -> Result { + let request = self.authenticated_request(request)?; + let response = self.document_data_client.get_archived_document(request).await + .context("gRPC get_archived_document call failed")?; Ok(response.into_inner()) } diff --git a/komp-app/src/typst.rs b/komp-app/src/typst.rs index 88e2661f..fc68d5a5 100644 --- a/komp-app/src/typst.rs +++ b/komp-app/src/typst.rs @@ -1,5 +1,5 @@ pub use common::typst_contract::{TypstContract, TypstContractError}; -use common::proto::komp_ac::document_data::TypstTemplateVersion; +use common::proto::komp_ac::document_data::DocumentTemplateVersion; /// Parses the first meaningful declaration from stored Typst source for the /// admin mapping workflow. It must be the literal `komp_ac_fields` tuple; @@ -13,7 +13,7 @@ pub fn parse_contract(source: &str) -> Result /// workflows should retain `version.id` separately and send it back when they /// submit the reviewed table mapping. pub fn parse_template_version( - version: &TypstTemplateVersion, + version: &DocumentTemplateVersion, ) -> Result { parse_contract(&version.source_code) } @@ -21,7 +21,7 @@ pub fn parse_template_version( #[cfg(test)] mod tests { use super::{parse_contract, parse_template_version}; - use common::proto::komp_ac::document_data::TypstTemplateVersion; + use common::proto::komp_ac::document_data::DocumentTemplateVersion; #[test] fn exposes_typst_fields_to_client_workflows() { @@ -35,7 +35,7 @@ mod tests { ["invoice.number", "items[].quantity"] ); - let version = TypstTemplateVersion { + let version = DocumentTemplateVersion { id: 42, source_code: r#"#let komp_ac_fields = ("invoice.number",)"#.to_string(), ..Default::default() diff --git a/server b/server index f00542d0..7f652545 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit f00542d009fdb32b1f9c1426ec0522cfe52ae28e +Subproject commit 7f652545a467db5f6b889d4549195011e8b62ee8