feat: add AI data validation, test data generator, index advisor, and snapshots
Four new killer features leveraging AI (Ollama) and PostgreSQL internals: - Data Validation: describe quality rules in natural language, AI generates SQL to find violations, run with pass/fail results and sample violations - Test Data Generator: right-click table to generate realistic FK-aware test data with AI, preview before inserting in a transaction - Index Advisor: analyze pg_stat tables + AI recommendations for CREATE/DROP INDEX with one-click apply - Data Snapshots: export selected tables to JSON (FK-ordered), restore from file with optional truncate in a transaction Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -394,7 +394,7 @@ export interface CloneResult {
|
||||
connection_url: string;
|
||||
}
|
||||
|
||||
export type TabType = "query" | "table" | "structure" | "roles" | "sessions" | "lookup" | "erd";
|
||||
export type TabType = "query" | "table" | "structure" | "roles" | "sessions" | "lookup" | "erd" | "validation" | "index-advisor" | "snapshots";
|
||||
|
||||
export interface Tab {
|
||||
id: string;
|
||||
@@ -409,3 +409,159 @@ export interface Tab {
|
||||
lookupColumn?: string;
|
||||
lookupValue?: string;
|
||||
}
|
||||
|
||||
// --- Wave 1: Validation ---
|
||||
|
||||
export type ValidationStatus = "pending" | "generating" | "running" | "passed" | "failed" | "error";
|
||||
|
||||
export interface ValidationRule {
|
||||
id: string;
|
||||
description: string;
|
||||
generated_sql: string;
|
||||
status: ValidationStatus;
|
||||
violation_count: number;
|
||||
sample_violations: unknown[][];
|
||||
violation_columns: string[];
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface ValidationReport {
|
||||
rules: ValidationRule[];
|
||||
total_rules: number;
|
||||
passed: number;
|
||||
failed: number;
|
||||
errors: number;
|
||||
execution_time_ms: number;
|
||||
}
|
||||
|
||||
// --- Wave 2: Data Generator ---
|
||||
|
||||
export interface GenerateDataParams {
|
||||
connection_id: string;
|
||||
schema: string;
|
||||
table: string;
|
||||
row_count: number;
|
||||
include_related: boolean;
|
||||
custom_instructions?: string;
|
||||
}
|
||||
|
||||
export interface GeneratedDataPreview {
|
||||
tables: GeneratedTableData[];
|
||||
insert_order: string[];
|
||||
total_rows: number;
|
||||
}
|
||||
|
||||
export interface GeneratedTableData {
|
||||
schema: string;
|
||||
table: string;
|
||||
columns: string[];
|
||||
rows: unknown[][];
|
||||
row_count: number;
|
||||
}
|
||||
|
||||
export interface DataGenProgress {
|
||||
gen_id: string;
|
||||
stage: string;
|
||||
percent: number;
|
||||
message: string;
|
||||
detail: string | null;
|
||||
}
|
||||
|
||||
// --- Wave 3A: Index Advisor ---
|
||||
|
||||
export interface TableStats {
|
||||
schema: string;
|
||||
table: string;
|
||||
seq_scan: number;
|
||||
idx_scan: number;
|
||||
n_live_tup: number;
|
||||
table_size: string;
|
||||
index_size: string;
|
||||
}
|
||||
|
||||
export interface IndexStatsInfo {
|
||||
schema: string;
|
||||
table: string;
|
||||
index_name: string;
|
||||
idx_scan: number;
|
||||
index_size: string;
|
||||
definition: string;
|
||||
}
|
||||
|
||||
export interface SlowQuery {
|
||||
query: string;
|
||||
calls: number;
|
||||
total_time_ms: number;
|
||||
mean_time_ms: number;
|
||||
rows: number;
|
||||
}
|
||||
|
||||
export type IndexRecommendationType = "create_index" | "drop_index" | "replace_index";
|
||||
|
||||
export interface IndexRecommendation {
|
||||
id: string;
|
||||
recommendation_type: IndexRecommendationType;
|
||||
table_schema: string;
|
||||
table_name: string;
|
||||
index_name: string | null;
|
||||
ddl: string;
|
||||
rationale: string;
|
||||
estimated_impact: string;
|
||||
priority: string;
|
||||
}
|
||||
|
||||
export interface IndexAdvisorReport {
|
||||
table_stats: TableStats[];
|
||||
index_stats: IndexStatsInfo[];
|
||||
slow_queries: SlowQuery[];
|
||||
recommendations: IndexRecommendation[];
|
||||
has_pg_stat_statements: boolean;
|
||||
}
|
||||
|
||||
// --- Wave 3B: Snapshots ---
|
||||
|
||||
export interface SnapshotMetadata {
|
||||
id: string;
|
||||
name: string;
|
||||
created_at: string;
|
||||
connection_name: string;
|
||||
database: string;
|
||||
tables: SnapshotTableMeta[];
|
||||
total_rows: number;
|
||||
file_size_bytes: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface SnapshotTableMeta {
|
||||
schema: string;
|
||||
table: string;
|
||||
row_count: number;
|
||||
columns: string[];
|
||||
column_types: string[];
|
||||
}
|
||||
|
||||
export interface SnapshotProgress {
|
||||
snapshot_id: string;
|
||||
stage: string;
|
||||
percent: number;
|
||||
message: string;
|
||||
detail: string | null;
|
||||
}
|
||||
|
||||
export interface CreateSnapshotParams {
|
||||
connection_id: string;
|
||||
tables: TableRef[];
|
||||
name: string;
|
||||
include_dependencies: boolean;
|
||||
}
|
||||
|
||||
export interface TableRef {
|
||||
schema: string;
|
||||
table: string;
|
||||
}
|
||||
|
||||
export interface RestoreSnapshotParams {
|
||||
connection_id: string;
|
||||
file_path: string;
|
||||
truncate_before_restore: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user