// #region ModelTypes [C:1] [TYPE Module] [SEMANTICS types, domain, models]
// @BRIEF Core domain model interfaces for ss-tools frontend.
// @LAYER Domain

// ── Task / Job ───────────────────────────────────────────────

export interface Task {
	id: string;
	plugin_id: string;
	status: TaskStatus;
	progress?: number;
	params?: Record<string, unknown>;
	result?: Record<string, unknown>;
	error?: string;
	created_at: string;
	started_at?: string;
	finished_at?: string;
}

export type TaskStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';

export interface TaskLogEntry {
	id?: string;
	task_id: string;
	level: string;
	source: string;
	message: string;
	timestamp: string;
}

// ── Plugin ───────────────────────────────────────────────────

export interface Plugin {
	id: string;
	name: string;
	description?: string;
	enabled: boolean;
	config?: Record<string, unknown>;
}

// ── Environment / Superset ───────────────────────────────────

export interface Environment {
	id: string;
	name: string;
	superset_url?: string;
	username?: string;
	status?: 'connected' | 'error' | 'unknown';
	databases?: Database[];
}

export interface Database {
	id: string;
	name: string;
	backend?: string;
}

export interface SupersetAccount {
	id: string;
	username: string;
	email?: string;
	role?: string;
}

// ── Dashboard ────────────────────────────────────────────────

export interface Dashboard {
	id: string;
	title: string;
	env_id: string;
	url?: string;
	last_modified?: string;
	status?: string;
	thumbnail_url?: string;
	git_status?: string;
	llm_status?: string;
}

// ── Dataset ──────────────────────────────────────────────────

export interface Dataset {
	id: string;
	name: string;
	env_id: string;
	database_id?: string;
	schema?: string;
	table_name?: string;
	columns?: DatasetColumn[];
}

export interface DatasetColumn {
	name: string;
	type: string;
	is_key?: boolean;
}

// ── Validation Policy ────────────────────────────────────────

export interface ValidationPolicy {
	id: string;
	name: string;
	environment_id: string;
	is_active: boolean;
	config?: Record<string, unknown>;
	created_at?: string;
	updated_at?: string;
}

// ── Profile / User ───────────────────────────────────────────

export interface UserProfile {
	id: string;
	username: string;
	email?: string;
	role?: string;
	preferences?: Record<string, unknown>;
}

// ── Settings ─────────────────────────────────────────────────

export interface GlobalSettings {
	[key: string]: unknown;
}

export interface StorageSettings {
	provider: string;
	config?: Record<string, unknown>;
}

// ── Health ───────────────────────────────────────────────────

export interface HealthSummary {
	status: 'healthy' | 'degraded' | 'unhealthy';
	environment_id?: string;
	last_checked?: string;
	details?: Record<string, unknown>;
}
// #endregion ModelTypes
