Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

597 B
Raw Blame
import type { TableMetadata } from "@/types/proto-es/v1/database_service_pb";
import type { ForeignKey } from "../../types";

export const isFocusedForeignTable = (
  table: TableMetadata,
  focusedTables: Set<TableMetadata>,
  foreignKeys: ForeignKey[]
): boolean => {
  const fks = foreignKeys.filter(
    (fk) => fk.from.table === table || fk.to.table === table
  );
  return fks.some((fk) => {
    if (fk.from.table === table) {
      return focusedTables.has(fk.to.table);
    }
    if (fk.to.table === table) {
      return focusedTables.has(fk.from.table);
    }
    return false;
  });
};