validation core as a dependency2

This commit is contained in:
Priec
2026-05-06 19:50:09 +02:00
parent f094346e1b
commit 3373e00dfc
13 changed files with 1152 additions and 88 deletions

Binary file not shown.

View File

@@ -206,6 +206,140 @@ pub struct ReplaceTableValidationResponse {
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValidationRuleDefinition {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub description: ::core::option::Option<::prost::alloc::string::String>,
/// Reusable rule fragment. dataKey is ignored by the server for reusable rules.
#[prost(message, optional, tag = "3")]
pub validation: ::core::option::Option<FieldValidation>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValidationSetDefinition {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub description: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, repeated, tag = "3")]
pub rule_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Server-resolved snapshot of all rules in ruleNames order.
#[prost(message, optional, tag = "4")]
pub resolved_validation: ::core::option::Option<FieldValidation>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpsertValidationRuleRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub rule: ::core::option::Option<ValidationRuleDefinition>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpsertValidationRuleResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValidationRulesRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValidationRulesResponse {
#[prost(message, repeated, tag = "1")]
pub rules: ::prost::alloc::vec::Vec<ValidationRuleDefinition>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteValidationRuleRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteValidationRuleResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpsertValidationSetRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub set: ::core::option::Option<ValidationSetDefinition>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpsertValidationSetResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValidationSetsRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValidationSetsResponse {
#[prost(message, repeated, tag = "1")]
pub sets: ::prost::alloc::vec::Vec<ValidationSetDefinition>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteValidationSetRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteValidationSetResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ApplyValidationSetRequest {
#[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 data_key: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub set_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ApplyValidationSetResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub validation: ::core::option::Option<FieldValidation>,
}
/// Character length counting mode
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
@@ -509,6 +643,212 @@ pub mod table_validation_service_client {
);
self.inner.unary(req, path, codec).await
}
/// Reusable named rule fragments.
pub async fn upsert_validation_rule(
&mut self,
request: impl tonic::IntoRequest<super::UpsertValidationRuleRequest>,
) -> std::result::Result<
tonic::Response<super::UpsertValidationRuleResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/UpsertValidationRule",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"UpsertValidationRule",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn list_validation_rules(
&mut self,
request: impl tonic::IntoRequest<super::ListValidationRulesRequest>,
) -> std::result::Result<
tonic::Response<super::ListValidationRulesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/ListValidationRules",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"ListValidationRules",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn delete_validation_rule(
&mut self,
request: impl tonic::IntoRequest<super::DeleteValidationRuleRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteValidationRuleResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/DeleteValidationRule",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"DeleteValidationRule",
),
);
self.inner.unary(req, path, codec).await
}
/// Reusable named sets composed from rules.
pub async fn upsert_validation_set(
&mut self,
request: impl tonic::IntoRequest<super::UpsertValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::UpsertValidationSetResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/UpsertValidationSet",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"UpsertValidationSet",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn list_validation_sets(
&mut self,
request: impl tonic::IntoRequest<super::ListValidationSetsRequest>,
) -> std::result::Result<
tonic::Response<super::ListValidationSetsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/ListValidationSets",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"ListValidationSets",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn delete_validation_set(
&mut self,
request: impl tonic::IntoRequest<super::DeleteValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteValidationSetResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/DeleteValidationSet",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"DeleteValidationSet",
),
);
self.inner.unary(req, path, codec).await
}
/// Snapshot a reusable set onto a concrete table field.
pub async fn apply_validation_set(
&mut self,
request: impl tonic::IntoRequest<super::ApplyValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::ApplyValidationSetResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.table_validation.TableValidationService/ApplyValidationSet",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_validation.TableValidationService",
"ApplyValidationSet",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Generated server implementations.
@@ -547,6 +887,58 @@ pub mod table_validation_service_server {
tonic::Response<super::ReplaceTableValidationResponse>,
tonic::Status,
>;
/// Reusable named rule fragments.
async fn upsert_validation_rule(
&self,
request: tonic::Request<super::UpsertValidationRuleRequest>,
) -> std::result::Result<
tonic::Response<super::UpsertValidationRuleResponse>,
tonic::Status,
>;
async fn list_validation_rules(
&self,
request: tonic::Request<super::ListValidationRulesRequest>,
) -> std::result::Result<
tonic::Response<super::ListValidationRulesResponse>,
tonic::Status,
>;
async fn delete_validation_rule(
&self,
request: tonic::Request<super::DeleteValidationRuleRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteValidationRuleResponse>,
tonic::Status,
>;
/// Reusable named sets composed from rules.
async fn upsert_validation_set(
&self,
request: tonic::Request<super::UpsertValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::UpsertValidationSetResponse>,
tonic::Status,
>;
async fn list_validation_sets(
&self,
request: tonic::Request<super::ListValidationSetsRequest>,
) -> std::result::Result<
tonic::Response<super::ListValidationSetsResponse>,
tonic::Status,
>;
async fn delete_validation_set(
&self,
request: tonic::Request<super::DeleteValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteValidationSetResponse>,
tonic::Status,
>;
/// Snapshot a reusable set onto a concrete table field.
async fn apply_validation_set(
&self,
request: tonic::Request<super::ApplyValidationSetRequest>,
) -> std::result::Result<
tonic::Response<super::ApplyValidationSetResponse>,
tonic::Status,
>;
}
/// Service for storing and fetching field-validation definitions.
#[derive(Debug)]
@@ -777,6 +1169,353 @@ pub mod table_validation_service_server {
};
Box::pin(fut)
}
"/komp_ac.table_validation.TableValidationService/UpsertValidationRule" => {
#[allow(non_camel_case_types)]
struct UpsertValidationRuleSvc<T: TableValidationService>(
pub Arc<T>,
);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::UpsertValidationRuleRequest>
for UpsertValidationRuleSvc<T> {
type Response = super::UpsertValidationRuleResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::UpsertValidationRuleRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::upsert_validation_rule(
&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 = UpsertValidationRuleSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/ListValidationRules" => {
#[allow(non_camel_case_types)]
struct ListValidationRulesSvc<T: TableValidationService>(pub Arc<T>);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::ListValidationRulesRequest>
for ListValidationRulesSvc<T> {
type Response = super::ListValidationRulesResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ListValidationRulesRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::list_validation_rules(
&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 = ListValidationRulesSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/DeleteValidationRule" => {
#[allow(non_camel_case_types)]
struct DeleteValidationRuleSvc<T: TableValidationService>(
pub Arc<T>,
);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::DeleteValidationRuleRequest>
for DeleteValidationRuleSvc<T> {
type Response = super::DeleteValidationRuleResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DeleteValidationRuleRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::delete_validation_rule(
&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 = DeleteValidationRuleSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/UpsertValidationSet" => {
#[allow(non_camel_case_types)]
struct UpsertValidationSetSvc<T: TableValidationService>(pub Arc<T>);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::UpsertValidationSetRequest>
for UpsertValidationSetSvc<T> {
type Response = super::UpsertValidationSetResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::UpsertValidationSetRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::upsert_validation_set(
&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 = UpsertValidationSetSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/ListValidationSets" => {
#[allow(non_camel_case_types)]
struct ListValidationSetsSvc<T: TableValidationService>(pub Arc<T>);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::ListValidationSetsRequest>
for ListValidationSetsSvc<T> {
type Response = super::ListValidationSetsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ListValidationSetsRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::list_validation_sets(
&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 = ListValidationSetsSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/DeleteValidationSet" => {
#[allow(non_camel_case_types)]
struct DeleteValidationSetSvc<T: TableValidationService>(pub Arc<T>);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::DeleteValidationSetRequest>
for DeleteValidationSetSvc<T> {
type Response = super::DeleteValidationSetResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DeleteValidationSetRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::delete_validation_set(
&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 = DeleteValidationSetSvc(inner);
let codec = tonic::codec::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.table_validation.TableValidationService/ApplyValidationSet" => {
#[allow(non_camel_case_types)]
struct ApplyValidationSetSvc<T: TableValidationService>(pub Arc<T>);
impl<
T: TableValidationService,
> tonic::server::UnaryService<super::ApplyValidationSetRequest>
for ApplyValidationSetSvc<T> {
type Response = super::ApplyValidationSetResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ApplyValidationSetRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableValidationService>::apply_validation_set(
&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 = ApplyValidationSetSvc(inner);
let codec = tonic::codec::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(