templates are per profile from the global table
This commit is contained in:
@@ -2,6 +2,9 @@ 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 SaveDocument(SaveDocumentRequest) returns (SaveDocumentResponse);
|
||||
rpc UpdateDocument(UpdateDocumentRequest) returns (UpdateDocumentResponse);
|
||||
rpc GetDocuments(GetDocumentsRequest) returns (GetDocumentsResponse);
|
||||
@@ -20,9 +23,31 @@ message SourceRecord {
|
||||
message SaveDocumentRequest {
|
||||
repeated SourceRecord source_records = 1;
|
||||
string template_name = 2;
|
||||
string data_json = 3;
|
||||
}
|
||||
|
||||
message RegisterTypstTemplateRequest {
|
||||
string template_name = 1;
|
||||
string input_table_name = 2;
|
||||
string typst_source = 3;
|
||||
string typst_compiler_version = 4;
|
||||
string data_json = 5;
|
||||
}
|
||||
|
||||
message RegisterTypstTemplateResponse {
|
||||
TypstTemplateVersion template_version = 1;
|
||||
}
|
||||
|
||||
message ListTypstTemplatesRequest {
|
||||
string search = 1;
|
||||
uint32 limit = 2;
|
||||
}
|
||||
|
||||
message ListTypstTemplatesResponse {
|
||||
repeated TypstTemplateVersion templates = 1;
|
||||
}
|
||||
|
||||
message ListEnabledTypstTemplatesRequest {
|
||||
string profile_name = 1;
|
||||
}
|
||||
|
||||
message SaveDocumentResponse {
|
||||
@@ -92,13 +117,14 @@ message GetTypstTemplateVersionRequest {
|
||||
|
||||
message TypstTemplateVersion {
|
||||
int64 id = 1;
|
||||
int64 schema_id = 2;
|
||||
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 created_at = 8;
|
||||
string input_table_name = 9;
|
||||
}
|
||||
|
||||
message GetTypstTemplateVersionResponse {
|
||||
|
||||
@@ -157,23 +157,12 @@ message GeneratedColumnAlias {
|
||||
}
|
||||
|
||||
// Defines the input for explicitly creating tables backed by one invoice
|
||||
// template. typst_source must contain exactly one field declaration:
|
||||
//
|
||||
// #let komp_ac_fields = (
|
||||
// "sidlo.nazov",
|
||||
// "people[].name",
|
||||
// "people[].requested_quantity",
|
||||
// )
|
||||
//
|
||||
// A path matching an existing profile table and column becomes a reference to
|
||||
// that table. Otherwise its final segment becomes a local TEXT column for an
|
||||
// administrator to refine later. Every [] creates a child table with a required
|
||||
// FK to its immediate generated parent.
|
||||
// Enables a stored global Typst template for one profile and immediately
|
||||
// creates the input-table family declared by that template.
|
||||
message CreateInvoiceTemplateTableRequest {
|
||||
string profile_name = 1;
|
||||
string table_name = 2;
|
||||
string typst_source = 3;
|
||||
repeated string row_display_columns = 5;
|
||||
string template_name = 2;
|
||||
repeated string row_display_columns = 3;
|
||||
}
|
||||
|
||||
// One physical dynamic table created for an invoice template scope. The root
|
||||
|
||||
Binary file not shown.
@@ -17,11 +17,40 @@ pub struct SaveDocumentRequest {
|
||||
#[prost(string, tag = "2")]
|
||||
pub template_name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub data_json: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct RegisterTypstTemplateRequest {
|
||||
#[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,
|
||||
#[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, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct RegisterTypstTemplateResponse {
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub template_version: ::core::option::Option<TypstTemplateVersion>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct ListTypstTemplatesRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub search: ::prost::alloc::string::String,
|
||||
#[prost(uint32, tag = "2")]
|
||||
pub limit: u32,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ListTypstTemplatesResponse {
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub templates: ::prost::alloc::vec::Vec<TypstTemplateVersion>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct ListEnabledTypstTemplatesRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct SaveDocumentResponse {
|
||||
@@ -125,7 +154,7 @@ pub struct TypstTemplateVersion {
|
||||
#[prost(int64, tag = "1")]
|
||||
pub id: i64,
|
||||
#[prost(int64, tag = "2")]
|
||||
pub schema_id: i64,
|
||||
pub template_id: i64,
|
||||
#[prost(string, tag = "3")]
|
||||
pub template_name: ::prost::alloc::string::String,
|
||||
#[prost(int32, tag = "4")]
|
||||
@@ -138,6 +167,8 @@ pub struct TypstTemplateVersion {
|
||||
pub typst_compiler_version: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "8")]
|
||||
pub created_at: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "9")]
|
||||
pub input_table_name: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct GetTypstTemplateVersionResponse {
|
||||
@@ -235,6 +266,93 @@ pub mod document_data_service_client {
|
||||
self.inner = self.inner.max_encoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
pub async fn register_typst_template(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::RegisterTypstTemplateRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::RegisterTypstTemplateResponse>,
|
||||
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/RegisterTypstTemplate",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new(
|
||||
"komp_ac.document_data.DocumentDataService",
|
||||
"RegisterTypstTemplate",
|
||||
),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn list_typst_templates(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ListTypstTemplatesRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListTypstTemplatesResponse>,
|
||||
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/ListTypstTemplates",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new(
|
||||
"komp_ac.document_data.DocumentDataService",
|
||||
"ListTypstTemplates",
|
||||
),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn list_enabled_typst_templates(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ListEnabledTypstTemplatesRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListTypstTemplatesResponse>,
|
||||
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/ListEnabledTypstTemplates",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new(
|
||||
"komp_ac.document_data.DocumentDataService",
|
||||
"ListEnabledTypstTemplates",
|
||||
),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn save_document(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::SaveDocumentRequest>,
|
||||
@@ -424,6 +542,27 @@ 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(
|
||||
&self,
|
||||
request: tonic::Request<super::RegisterTypstTemplateRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::RegisterTypstTemplateResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
async fn list_typst_templates(
|
||||
&self,
|
||||
request: tonic::Request<super::ListTypstTemplatesRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListTypstTemplatesResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
async fn list_enabled_typst_templates(
|
||||
&self,
|
||||
request: tonic::Request<super::ListEnabledTypstTemplatesRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListTypstTemplatesResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
async fn save_document(
|
||||
&self,
|
||||
request: tonic::Request<super::SaveDocumentRequest>,
|
||||
@@ -543,6 +682,158 @@ pub mod document_data_service_server {
|
||||
}
|
||||
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||
match req.uri().path() {
|
||||
"/komp_ac.document_data.DocumentDataService/RegisterTypstTemplate" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct RegisterTypstTemplateSvc<T: DocumentDataService>(pub Arc<T>);
|
||||
impl<
|
||||
T: DocumentDataService,
|
||||
> tonic::server::UnaryService<super::RegisterTypstTemplateRequest>
|
||||
for RegisterTypstTemplateSvc<T> {
|
||||
type Response = super::RegisterTypstTemplateResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::RegisterTypstTemplateRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as DocumentDataService>::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<T: DocumentDataService>(pub Arc<T>);
|
||||
impl<
|
||||
T: DocumentDataService,
|
||||
> tonic::server::UnaryService<super::ListTypstTemplatesRequest>
|
||||
for ListTypstTemplatesSvc<T> {
|
||||
type Response = super::ListTypstTemplatesResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::ListTypstTemplatesRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as DocumentDataService>::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<T: DocumentDataService>(
|
||||
pub Arc<T>,
|
||||
);
|
||||
impl<
|
||||
T: DocumentDataService,
|
||||
> tonic::server::UnaryService<
|
||||
super::ListEnabledTypstTemplatesRequest,
|
||||
> for ListEnabledTypstTemplatesSvc<T> {
|
||||
type Response = super::ListTypstTemplatesResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<
|
||||
super::ListEnabledTypstTemplatesRequest,
|
||||
>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as DocumentDataService>::list_enabled_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 = ListEnabledTypstTemplatesSvc(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/SaveDocument" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct SaveDocumentSvc<T: DocumentDataService>(pub Arc<T>);
|
||||
|
||||
@@ -100,28 +100,16 @@ pub struct GeneratedColumnAlias {
|
||||
pub alias: ::prost::alloc::string::String,
|
||||
}
|
||||
/// Defines the input for explicitly creating tables backed by one invoice
|
||||
/// template. typst_source must contain exactly one field declaration:
|
||||
///
|
||||
/// \#let komp_ac_fields = (
|
||||
/// "sidlo.nazov",
|
||||
/// "people\[\].name",
|
||||
/// "people\[\].requested_quantity",
|
||||
/// )
|
||||
///
|
||||
/// A path matching an existing profile table and column becomes a reference to
|
||||
/// that table. Otherwise its final segment becomes a local TEXT column for an
|
||||
/// administrator to refine later. Every \[\] creates a child table with a required
|
||||
/// FK to its immediate generated parent.
|
||||
/// Enables a stored global Typst template for one profile and immediately
|
||||
/// creates the input-table family declared by that template.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct CreateInvoiceTemplateTableRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub typst_source: ::prost::alloc::string::String,
|
||||
#[prost(string, repeated, tag = "5")]
|
||||
pub template_name: ::prost::alloc::string::String,
|
||||
#[prost(string, repeated, tag = "3")]
|
||||
pub row_display_columns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||
}
|
||||
/// One physical dynamic table created for an invoice template scope. The root
|
||||
|
||||
Reference in New Issue
Block a user