import { SqlEngineInfo } from '../api/api.types'; export interface SqlServerSettings { engine: SqlEngineInfo; host: string; port: number | null; database: string; user: string; password: string; } /** What the UI shows for a connection; never the password. */ export function describeSqlServer(settings: SqlServerSettings): string { const port = settings.port ?? settings.engine.default_port; return `${settings.database} · ${settings.user ? `${settings.user}@` : ''}${settings.host}:${port}`; } /** Credential-free label for a raw connection string (`scheme://user:pass@host/db` -> `db · host`). */ export function describeSqlUrl(url: string): string { const match = /^([^:]+):\/\/(?:[^@/]*@)?([^/?#]*)\/?([^?#]*)/.exec(url.trim()); if (!match) return 'Base de datos'; const [, , host, database] = match; return database ? `${decodeURIComponent(database)} · ${host}` : host || 'Base de datos'; }