Compare commits
2 Commits
492f1f1e55
...
monorepo-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ec1fa1761 | ||
|
|
11185282c4 |
@@ -12,6 +12,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
".komp_ac.table_validation.CharacterLimits",
|
||||
"#[derive(serde::Serialize, serde::Deserialize)]",
|
||||
)
|
||||
.type_attribute(
|
||||
".komp_ac.table_validation.DisplayMask",
|
||||
"#[derive(serde::Serialize, serde::Deserialize)]",
|
||||
)
|
||||
.type_attribute(
|
||||
".komp_ac.table_validation.TableValidationResponse",
|
||||
"#[derive(serde::Serialize, serde::Deserialize)]",
|
||||
|
||||
@@ -23,9 +23,10 @@ message FieldValidation {
|
||||
CharacterLimits limits = 10;
|
||||
// Future expansion:
|
||||
// PatternRules pattern = 11;
|
||||
// DisplayMask mask = 12;
|
||||
DisplayMask mask = 3;
|
||||
// ExternalValidation external = 13;
|
||||
// CustomFormatter formatter = 14;
|
||||
bool required = 4;
|
||||
}
|
||||
|
||||
// Character length counting mode
|
||||
@@ -49,6 +50,13 @@ message CharacterLimits {
|
||||
CountMode countMode = 4; // defaults to CHARS if unspecified
|
||||
}
|
||||
|
||||
// Mask for pretty display
|
||||
message DisplayMask {
|
||||
string pattern = 1; // e.g., "(###) ###-####" or "####-##-##"
|
||||
string input_char = 2; // e.g., "#"
|
||||
optional string template_char = 3; // e.g., "_"
|
||||
}
|
||||
|
||||
// Service to fetch validations for a table
|
||||
service TableValidationService {
|
||||
rpc GetTableValidation(GetTableValidationRequest)
|
||||
|
||||
Binary file not shown.
@@ -23,14 +23,16 @@ pub struct FieldValidation {
|
||||
#[prost(string, tag = "1")]
|
||||
pub data_key: ::prost::alloc::string::String,
|
||||
/// Current: only CharacterLimits. More rules can be added later.
|
||||
///
|
||||
/// Future expansion:
|
||||
/// PatternRules pattern = 11;
|
||||
/// DisplayMask mask = 12;
|
||||
/// ExternalValidation external = 13;
|
||||
/// CustomFormatter formatter = 14;
|
||||
#[prost(message, optional, tag = "10")]
|
||||
pub limits: ::core::option::Option<CharacterLimits>,
|
||||
/// Future expansion:
|
||||
/// PatternRules pattern = 11;
|
||||
#[prost(message, optional, tag = "3")]
|
||||
pub mask: ::core::option::Option<DisplayMask>,
|
||||
/// ExternalValidation external = 13;
|
||||
/// CustomFormatter formatter = 14;
|
||||
#[prost(bool, tag = "4")]
|
||||
pub required: bool,
|
||||
}
|
||||
/// Character limit validation (Validation 1)
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
@@ -49,6 +51,20 @@ pub struct CharacterLimits {
|
||||
#[prost(enumeration = "CountMode", tag = "4")]
|
||||
pub count_mode: i32,
|
||||
}
|
||||
/// Mask for pretty display
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct DisplayMask {
|
||||
/// e.g., "(###) ###-####" or "####-##-##"
|
||||
#[prost(string, tag = "1")]
|
||||
pub pattern: ::prost::alloc::string::String,
|
||||
/// e.g., "#"
|
||||
#[prost(string, tag = "2")]
|
||||
pub input_char: ::prost::alloc::string::String,
|
||||
/// e.g., "_"
|
||||
#[prost(string, optional, tag = "3")]
|
||||
pub template_char: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct UpdateFieldValidationRequest {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// src/server/services/table_validation_service.rs
|
||||
|
||||
use tonic::transport::Server;
|
||||
use sqlx::PgPool;
|
||||
|
||||
use common::proto::komp_ac::table_validation::table_validation_service_server::TableValidationServiceServer;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
use tonic::Status;
|
||||
use sqlx::{PgPool, Transaction, Postgres};
|
||||
use serde_json::json;
|
||||
use common::proto::komp_ac::table_definition::{PostTableDefinitionRequest, TableDefinitionResponse};
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use crate::table_definition::models::map_field_type;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::collections::HashMap;
|
||||
use tonic::Status;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use serde_json::Value;
|
||||
|
||||
/// Represents the state of a node during dependency graph traversal.
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
|
||||
@@ -40,12 +40,16 @@ impl TableValidationService for TableValidationSvc {
|
||||
// Set the data_key from the database row
|
||||
fv.data_key = r.data_key;
|
||||
|
||||
// Skip if limits are all zero
|
||||
if let Some(lims) = &fv.limits {
|
||||
if lims.min == 0 && lims.max == 0 && lims.warn_at.is_none() {
|
||||
// Keep entries that have either meaningful limits or a mask
|
||||
let has_meaningful_limits = fv
|
||||
.limits
|
||||
.as_ref()
|
||||
.map_or(false, |l| l.min > 0 || l.max > 0 || l.warn_at.is_some());
|
||||
let has_mask = fv.mask.is_some();
|
||||
if !has_meaningful_limits && !has_mask {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fields_out.push(fv);
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -5,7 +5,6 @@ use server::table_script::handlers::post_table_script::post_table_script; // Fi
|
||||
use common::proto::komp_ac::table_script::PostTableScriptRequest;
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use rstest::*;
|
||||
use serde_json::json;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Helper function to create a test table with specified columns
|
||||
|
||||
@@ -5,7 +5,6 @@ use server::table_script::handlers::post_table_script::post_table_script; // Fi
|
||||
use common::proto::komp_ac::table_script::PostTableScriptRequest;
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use rstest::*;
|
||||
use serde_json::json;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Helper function to create a test table with specified columns
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::common::setup_isolated_db;
|
||||
use server::table_script::handlers::post_table_script::post_table_script;
|
||||
use common::proto::komp_ac::table_script::{PostTableScriptRequest, TableScriptResponse};
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use serde_json::json;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Test utilities for table script integration testing - moved to top level for shared access
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::common::setup_isolated_db;
|
||||
use server::table_script::handlers::post_table_script::post_table_script;
|
||||
use common::proto::komp_ac::table_script::PostTableScriptRequest;
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use serde_json::json;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Helper function to create a test table with specified columns
|
||||
|
||||
@@ -5,7 +5,6 @@ use server::table_script::handlers::post_table_script::post_table_script;
|
||||
use common::proto::komp_ac::table_script::PostTableScriptRequest;
|
||||
use common::proto::komp_ac::table_definition::ColumnDefinition;
|
||||
use rstest::*;
|
||||
use serde_json::json;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Test fixture for allowed mathematical types
|
||||
|
||||
@@ -5,7 +5,6 @@ use sqlx::{PgPool, Row};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
use serde_json::json;
|
||||
use chrono::Utc;
|
||||
use futures::future::join_all;
|
||||
use prost_types::{value::Kind, Value};
|
||||
@@ -17,7 +16,7 @@ use common::proto::komp_ac::table_definition::{
|
||||
PostTableDefinitionRequest, ColumnDefinition as TableColumnDefinition, TableLink,
|
||||
};
|
||||
use common::proto::komp_ac::tables_data::{
|
||||
DeleteTableDataRequest, DeleteTableDataResponse, PostTableDataRequest, PutTableDataRequest,
|
||||
DeleteTableDataRequest, PostTableDataRequest, PutTableDataRequest,
|
||||
};
|
||||
use server::indexer::IndexCommand;
|
||||
use server::table_definition::handlers::post_table_definition;
|
||||
|
||||
@@ -8,7 +8,6 @@ use server::table_definition::handlers::post_table_definition;
|
||||
use server::tables_data::handlers::get_table_data_by_position;
|
||||
use crate::common::setup_test_db;
|
||||
use chrono::Utc;
|
||||
use serde_json::json;
|
||||
|
||||
#[fixture]
|
||||
async fn pool() -> PgPool {
|
||||
|
||||
@@ -5,14 +5,12 @@ use common::proto::komp_ac::tables_data::GetTableDataRequest;
|
||||
use crate::common::setup_test_db;
|
||||
use sqlx::{PgPool, Row};
|
||||
use tonic;
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono::Utc;
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use futures::future::join_all;
|
||||
use rand::distr::Alphanumeric;
|
||||
use rand::Rng;
|
||||
use rust_decimal::Decimal;
|
||||
use rust_decimal_macros::dec;
|
||||
use server::table_definition::handlers::post_table_definition;
|
||||
use server::tables_data::handlers::post_table_data;
|
||||
use common::proto::komp_ac::table_definition::{
|
||||
@@ -22,7 +20,6 @@ use common::proto::komp_ac::tables_data::PostTableDataRequest;
|
||||
use prost_types::Value;
|
||||
use prost_types::value::Kind;
|
||||
use tokio::sync::mpsc;
|
||||
use server::indexer::IndexCommand;
|
||||
|
||||
#[fixture]
|
||||
async fn pool() -> PgPool {
|
||||
|
||||
@@ -795,7 +795,7 @@ async fn test_retrieve_from_nonexistent_schema() {
|
||||
#[rstest]
|
||||
#[tokio::test]
|
||||
async fn test_retrieve_with_database_connection_error() {
|
||||
let mut closed_pool = setup_test_db().await;
|
||||
let closed_pool = setup_test_db().await;
|
||||
closed_pool.close().await;
|
||||
|
||||
let request = GetTableDataRequest {
|
||||
|
||||
@@ -20,7 +20,6 @@ use server::indexer::IndexCommand;
|
||||
use sqlx::Row;
|
||||
use rand::distr::Alphanumeric;
|
||||
use rand::Rng;
|
||||
use rust_decimal::prelude::FromPrimitive;
|
||||
|
||||
// Helper function to generate unique identifiers for test isolation
|
||||
fn generate_unique_id() -> String {
|
||||
@@ -154,7 +153,7 @@ async fn test_context() -> TestContext {
|
||||
|
||||
#[fixture]
|
||||
async fn closed_test_context() -> TestContext {
|
||||
let mut context = test_context().await;
|
||||
let context = test_context().await;
|
||||
context.pool.close().await;
|
||||
context
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// ========================================================================
|
||||
|
||||
// Additional imports needed for these tests
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono::Utc;
|
||||
use rust_decimal::Decimal;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// This is needed for the database error test.
|
||||
#[fixture]
|
||||
async fn closed_test_context() -> TestContext {
|
||||
let mut context = test_context().await;
|
||||
let context = test_context().await;
|
||||
context.pool.close().await;
|
||||
context
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user