import type { DbFlavor } from "@/types";

export interface DbCapabilities {
  /** Direct row edit / insert / delete via the table viewer. */
  rowEdit: boolean;
  /** Multiple schemas inside one database. */
  multipleSchemas: boolean;
  /** Foreign-key constraints, triggers, sequences, indexes. */
  pgObjects: boolean;
  /** Default port for the engine when creating a new connection. */
  defaultPort: number;
  /** Display name for the engine. */
  label: string;
}

const CAPABILITIES: Record<DbFlavor, DbCapabilities> = {
  postgresql: {
    rowEdit: true,
    multipleSchemas: true,
    pgObjects: true,
    defaultPort: 5432,
    label: "PostgreSQL",
  },
  greenplum: {
    rowEdit: true,
    multipleSchemas: true,
    pgObjects: true,
    defaultPort: 5432,
    label: "Greenplum",
  },
  clickhouse: {
    rowEdit: false,
    multipleSchemas: false,
    pgObjects: false,
    defaultPort: 8123,
    label: "ClickHouse",
  },
};

export function capsFor(flavor: DbFlavor | undefined): DbCapabilities {
  return CAPABILITIES[flavor ?? "postgresql"];
}
