react-erd
Version:
An easy-to-use component for rendering Entity Relationship Diagrams in React
45 lines (42 loc) • 1.65 kB
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
type DataType = "binary" | "number" | "boolean" | "text" | "datetime" | "hierarchical" | "geometric" | "money" | "other";
type ForeignKey = {
foreignSchemaName: string;
foreignTableName: string;
foreignColumnName: string;
constrained: boolean;
};
type DatabaseTableInfo = {
name: string;
primaryKey: string | string[];
columns: {
name: string;
type: DataType;
foreignKeys: ForeignKey[];
}[];
};
type DatabaseSchemaInfo = {
name: string;
tables: DatabaseTableInfo[];
};
type SpecifiedForeignKey = Omit<ForeignKey, "constrained"> & {
localSchemaName: string;
localTableName: string;
localColumnName: string;
};
type RelationshipDiagramProps = {
schemas: DatabaseSchemaInfo[];
onSchemasChange?: (newSchemas: DatabaseSchemaInfo[]) => void;
tableColors: string[];
onCreateForeignKey?: (foreignKey: SpecifiedForeignKey) => void;
onDeleteForeignKey?: (foreignKey: SpecifiedForeignKey) => void;
onAttemptToRecreateExistingRelationship?: (attemptedForeignKey: SpecifiedForeignKey) => void;
onAttemptToConnectColumnToItself?: (column: {
schemaName: string;
tableName: string;
columnName: string;
}) => void;
onAttemptToDeleteConstrainedRelationship?: (foreignKey: SpecifiedForeignKey) => void;
};
declare function RelationshipDiagramWrapper(props: RelationshipDiagramProps): react_jsx_runtime.JSX.Element;
export { type DataType, type DatabaseSchemaInfo, RelationshipDiagramWrapper as RelationshipDiagram, type RelationshipDiagramProps, type SpecifiedForeignKey };