UNPKG

react-erd

Version:

An easy-to-use component for rendering Entity Relationship Diagrams in React

43 lines (42 loc) 1.54 kB
/// <reference types="react" /> export 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[]; }[]; }; export type DatabaseSchemaInfo = { name: string; tables: DatabaseTableInfo[]; }; export type SpecifiedForeignKey = Omit<ForeignKey, "constrained"> & { localSchemaName: string; localTableName: string; localColumnName: string; }; export 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): JSX.Element; export { RelationshipDiagramWrapper as RelationshipDiagram };