Files
tusk/src/types/index.ts
A.Shakhmatov e76a96deb8 feat: add unified Settings sheet, MCP indicator, and Docker host config
- Add AppSettingsSheet (gear icon in Toolbar) with MCP, Docker, and AI sections
- MCP Server: toggle on/off, port config, status badge, endpoint URL with copy
- Docker: local/remote daemon selector with remote URL input
- AI: moved Ollama settings into the unified sheet
- MCP status probes actual TCP port for reliable running detection
- Docker commands respect configurable docker host (-H flag) for remote daemons
- MCP server supports graceful shutdown via tokio watch channel
- Settings persisted to app_settings.json alongside existing config files
- StatusBar shows MCP indicator (green/gray dot) with tooltip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 09:04:12 +03:00

411 lines
8.0 KiB
TypeScript

export type DbFlavor = "postgresql" | "greenplum";
export interface ConnectResult {
version: string;
flavor: DbFlavor;
}
export interface ConnectionConfig {
id: string;
name: string;
host: string;
port: number;
user: string;
password: string;
database: string;
ssl_mode?: string;
color?: string;
environment?: string;
}
export interface QueryResult {
columns: string[];
types: string[];
rows: unknown[][];
row_count: number;
execution_time_ms: number;
}
export interface PaginatedQueryResult extends QueryResult {
total_rows: number;
page: number;
page_size: number;
}
export interface SchemaObject {
name: string;
object_type: string;
schema: string;
row_count?: number;
size_bytes?: number;
}
export interface ColumnDetail {
column_name: string;
data_type: string;
is_nullable: boolean;
column_default: string | null;
is_identity: boolean;
}
export interface ColumnInfo {
name: string;
data_type: string;
is_nullable: boolean;
column_default: string | null;
ordinal_position: number;
character_maximum_length: number | null;
is_primary_key: boolean;
comment: string | null;
}
export interface ConstraintInfo {
name: string;
constraint_type: string;
columns: string[];
referenced_schema: string | null;
referenced_table: string | null;
referenced_columns: string[] | null;
update_rule: string | null;
delete_rule: string | null;
}
export interface IndexInfo {
name: string;
definition: string;
is_unique: boolean;
is_primary: boolean;
}
export interface HistoryEntry {
id: string;
connection_id: string;
connection_name: string;
database: string;
sql: string;
status: string;
error_message?: string;
row_count?: number;
execution_time_ms: number;
executed_at: string;
}
export interface ExplainNode {
"Node Type": string;
"Relation Name"?: string;
"Schema"?: string;
"Alias"?: string;
"Startup Cost": number;
"Total Cost": number;
"Plan Rows": number;
"Plan Width": number;
"Actual Startup Time"?: number;
"Actual Total Time"?: number;
"Actual Rows"?: number;
"Actual Loops"?: number;
"Shared Hit Blocks"?: number;
"Shared Read Blocks"?: number;
"Filter"?: string;
"Join Type"?: string;
"Index Name"?: string;
"Index Cond"?: string;
"Hash Cond"?: string;
"Sort Key"?: string[];
Plans?: ExplainNode[];
[key: string]: unknown;
}
export interface ExplainResult {
Plan: ExplainNode;
"Planning Time": number;
"Execution Time": number;
}
export interface DatabaseInfo {
name: string;
owner: string;
encoding: string;
collation: string;
ctype: string;
tablespace: string;
connection_limit: number;
size: string;
description: string | null;
}
export interface CreateDatabaseParams {
name: string;
owner?: string;
template?: string;
encoding?: string;
tablespace?: string;
connection_limit?: number;
}
export interface RoleInfo {
name: string;
is_superuser: boolean;
can_login: boolean;
can_create_db: boolean;
can_create_role: boolean;
inherit: boolean;
is_replication: boolean;
connection_limit: number;
password_set: boolean;
valid_until: string | null;
member_of: string[];
members: string[];
description: string | null;
}
export interface CreateRoleParams {
name: string;
password?: string;
login: boolean;
superuser: boolean;
createdb: boolean;
createrole: boolean;
inherit: boolean;
replication: boolean;
connection_limit?: number;
valid_until?: string;
in_roles: string[];
}
export interface AlterRoleParams {
name: string;
password?: string;
login?: boolean;
superuser?: boolean;
createdb?: boolean;
createrole?: boolean;
inherit?: boolean;
replication?: boolean;
connection_limit?: number;
valid_until?: string;
rename_to?: string;
}
export interface TablePrivilege {
grantee: string;
table_schema: string;
table_name: string;
privilege_type: string;
is_grantable: boolean;
}
export interface GrantRevokeParams {
action: string;
privileges: string[];
object_type: string;
object_name: string;
role_name: string;
with_grant_option: boolean;
}
export interface RoleMembershipParams {
action: string;
role_name: string;
member_name: string;
}
export interface SessionInfo {
pid: number;
usename: string | null;
datname: string | null;
state: string | null;
query: string | null;
query_start: string | null;
wait_event_type: string | null;
wait_event: string | null;
client_addr: string | null;
}
export interface SavedQuery {
id: string;
name: string;
sql: string;
connection_id?: string;
created_at: string;
}
export type AiProvider = "ollama" | "openai" | "anthropic";
export interface AiSettings {
provider: AiProvider;
ollama_url: string;
openai_api_key?: string;
anthropic_api_key?: string;
model: string;
}
export interface OllamaModel {
name: string;
}
// Entity Lookup
export interface LookupTableMatch {
schema: string;
table: string;
column_type: string;
columns: string[];
types: string[];
rows: unknown[][];
row_count: number;
total_count: number;
}
export interface LookupDatabaseResult {
database: string;
tables: LookupTableMatch[];
error: string | null;
search_time_ms: number;
}
export interface EntityLookupResult {
column_name: string;
value: string;
databases: LookupDatabaseResult[];
total_databases_searched: number;
total_tables_matched: number;
total_rows_found: number;
total_time_ms: number;
}
export interface LookupProgress {
lookup_id: string;
database: string;
status: string;
tables_found: number;
rows_found: number;
error: string | null;
completed: number;
total: number;
}
export interface TriggerInfo {
name: string;
event: string;
timing: string;
orientation: string;
function_name: string;
is_enabled: boolean;
definition: string;
}
export interface ErdColumn {
name: string;
data_type: string;
is_nullable: boolean;
is_primary_key: boolean;
}
export interface ErdTable {
schema: string;
name: string;
columns: ErdColumn[];
}
export interface ErdRelationship {
constraint_name: string;
source_schema: string;
source_table: string;
source_columns: string[];
target_schema: string;
target_table: string;
target_columns: string[];
update_rule: string;
delete_rule: string;
}
export interface ErdData {
tables: ErdTable[];
relationships: ErdRelationship[];
}
// App Settings
export type DockerHost = "local" | "remote";
export interface McpSettings {
enabled: boolean;
port: number;
}
export interface DockerSettings {
host: DockerHost;
remote_url?: string;
}
export interface AppSettings {
mcp: McpSettings;
docker: DockerSettings;
}
export interface McpStatus {
enabled: boolean;
port: number;
running: boolean;
}
// Docker
export interface DockerStatus {
installed: boolean;
daemon_running: boolean;
version: string | null;
error: string | null;
}
export type CloneMode = "schema_only" | "full_clone" | "sample_data";
export interface CloneToDockerParams {
source_connection_id: string;
source_database: string;
container_name: string;
pg_version: string;
host_port: number | null;
clone_mode: CloneMode;
sample_rows: number | null;
postgres_password: string | null;
}
export interface CloneProgress {
clone_id: string;
stage: string;
percent: number;
message: string;
detail: string | null;
}
export interface TuskContainer {
container_id: string;
name: string;
status: string;
host_port: number;
pg_version: string;
source_database: string | null;
source_connection: string | null;
created_at: string | null;
}
export interface CloneResult {
container: TuskContainer;
connection_id: string;
connection_url: string;
}
export type TabType = "query" | "table" | "structure" | "roles" | "sessions" | "lookup" | "erd";
export interface Tab {
id: string;
type: TabType;
title: string;
connectionId: string;
database?: string;
schema?: string;
table?: string;
sql?: string;
roleName?: string;
lookupColumn?: string;
lookupValue?: string;
}