UNPKG

rhombic

Version:

SQL parsing, lineage extraction and manipulation

96 lines 3.29 kB
import { Edge, EdgeType, Lineage, Table, Column } from "./Lineage"; /** * Reduced interface of "Table" only including the properties required to uniquely identify a table in the lineage graph */ interface TableId { type: "table"; id: string; } /** * Reduced interface of "ColumnReference" only including the properties required to uniquely identify a column in the lineage graph */ interface ColumnId { type: "column"; tableId: string; column: { id: string; }; } /** * Reduced interface of "Edge" only including the properties required to uniquely identify an edge in the lineage graph */ interface EdgeId { type: "edge"; /** * Table/column that is depended on. If `columnId` is undefined then it is a table. Otherwise it is * a column inside the table. */ source: { tableId: string; columnId?: string; }; /** * Dependent table/column. If `columnId` is undefined then it is a table. Otherwise it is * a column inside the table. */ target: { tableId: string; columnId?: string; }; /** Edge type. See #EdgeType */ edgeType?: EdgeType; } /** * A specific element in the lineage graph */ export declare type ElementId = TableId | ColumnId | EdgeId; /** * Reference to a column * Includes the id of the table it is part of */ export interface ColumnReference<ColumnData> { type: "column"; tableId: string; column: Column<ColumnData>; } export declare type LineageGraphElement<TableData, ColumnData> = Table<TableData, ColumnData> | ColumnReference<ColumnData> | Edge; export interface ConnectedElements<TableData, ColumnData> { tables: Table<TableData, ColumnData>[]; columns: ColumnReference<ColumnData>[]; edges: Edge[]; } /** * "up" => upstream dependencies * "down" => downstream dependencies */ export declare type Direction = "up" | "down"; /** * Lineage Helper provides useful functions to work with an extracted lineage graph */ export declare const LineageHelper: <TableData, ColumnData>(lineage: Lineage<TableData, ColumnData>) => { /** * Finds an element (table, column, edge) in the lineage graph */ findElement: (elementId: ElementId) => LineageGraphElement<TableData, ColumnData> | undefined; /** * Finds all edges originating at a specific source table or column */ findEdgesFromSource: (elementId: TableId | ColumnId) => Edge[]; /** * Finds all edges targeting a specific source table or column */ findEdgesToTarget: (elementId: TableId | ColumnId) => Edge[]; /** * Finds all elements connected via the graph to a focused element */ findConnectedElements: (elementId: ElementId) => { elements: ConnectedElements<TableData, ColumnData>; findElement: (elementId: ElementId) => Edge | Table<TableData, ColumnData> | ColumnReference<ColumnData> | undefined; }; }; export declare const ConnectedElementsHelper: <TableData, ColumnData>(elements: ConnectedElements<TableData, ColumnData>) => { elements: ConnectedElements<TableData, ColumnData>; findElement: (elementId: ElementId) => Edge | Table<TableData, ColumnData> | ColumnReference<ColumnData> | undefined; }; export {}; //# sourceMappingURL=LineageHelper.d.ts.map