Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:TobikoData Sqlmesh Lineage Help

From Leeroopedia


Knowledge Sources
Domains Web_UI, Lineage_Visualization
Last Updated 2026-02-07 20:00 GMT

Overview

Utility functions for transforming adjacency lists into React Flow graph structures and calculating node dimensions.

Description

Lineage_Help provides core transformation and calculation functions for model-level lineage graphs. Key functions include getOnlySelectedNodes which filters nodes by selection state, getTransformedNodes which converts adjacency list keys into positioned graph nodes, getTransformedModelEdgesSourceTargets and getTransformedModelEdgesTargetSources which generate edges from adjacency lists in different directions, and createNode/createEdge factory functions for constructing properly typed graph elements. The module also includes dimension calculation functions for determining node heights based on footer, ceiling, floor elements and detail counts, following SQLMesh's UI layout specifications (Tailwind CSS sizing).

Usage

Use these utilities when converting raw lineage data (adjacency lists, model details) into React Flow graph structures, when filtering nodes based on selection, or when calculating dynamic node dimensions for proper layout rendering.

Code Reference

Source Location

Signature

export function getOnlySelectedNodes<...>(
  nodeMaps: LineageNodesMap<TNodeData, TNodeID>,
  selectedNodes: Set<TNodeID>
): LineageNodesMap<TNodeData, TNodeID>

export function getTransformedNodes<...>(
  adjacencyListKeys: TAdjacencyListKey[],
  lineageDetails: LineageDetails<TAdjacencyListKey, TDetailsNode>,
  transformNode: TransformNodeFn<TDetailsNode, TNodeData, TNodeID>,
  allNodesMap?: LineageNodesMap<TNodeData, TNodeID>,
): LineageNodesMap<TNodeData, TNodeID>

export function getTransformedModelEdgesSourceTargets<...>(
  adjacencyListKeys: TAdjacencyListKey[],
  lineageAdjacencyList: LineageAdjacencyList<TAdjacencyListKey>,
  transformEdge: TransformEdgeFn<...>,
): LineageEdge<...>[]

export function getTransformedModelEdgesTargetSources<...>(
  adjacencyListKeys: TAdjacencyListKey[],
  lineageAdjacencyList: LineageAdjacencyList<TAdjacencyListKey>,
  transformEdge: TransformEdgeFn<...>,
): LineageEdge<...>[]

export function createNode<...>(type: string, nodeId: TNodeID, data: TNodeData): LineageNode<...>

export function createEdge<...>(
  type: string,
  edgeId: TEdgeID,
  sourceId: TSourceID,
  targetId: TTargetID,
  sourceHandleId?: TSourceHandleID,
  targetHandleId?: TTargetHandleID,
  data?: TEdgeData,
): LineageEdge<...>

export function calculateNodeBaseHeight({
  includeNodeFooterHeight = false,
  includeCeilingHeight = false,
  includeFloorHeight = false,
}): number

export function calculateNodeDetailsHeight({
  nodeDetailsCount = 0,
}): number

Import

import {
  getOnlySelectedNodes,
  getTransformedNodes,
  getTransformedModelEdgesSourceTargets,
  getTransformedModelEdgesTargetSources,
  createNode,
  createEdge,
  calculateNodeBaseHeight,
  calculateNodeDetailsHeight,
} from '@sqlmesh-common/components/Lineage/help'

I/O Contract

Inputs

Name Type Required Description
nodeMaps LineageNodesMap Yes Map of all nodes by ID
selectedNodes Set<TNodeID> Yes Set of selected node IDs
adjacencyListKeys TAdjacencyListKey[] Yes Array of model identifiers
lineageDetails LineageDetails Yes Map of model details
lineageAdjacencyList LineageAdjacencyList Yes Adjacency list of model connections
transformNode TransformNodeFn Yes Function to create node from details
transformEdge TransformEdgeFn Yes Function to create edge from connections
includeNodeFooterHeight boolean No Include footer in height calculation
includeCeilingHeight boolean No Include ceiling in height calculation
includeFloorHeight boolean No Include floor in height calculation
nodeDetailsCount number No Number of detail items in node

Outputs

Name Type Description
nodesMap LineageNodesMap Filtered or transformed nodes map
edges LineageEdge[] Array of graph edges
node LineageNode Single graph node with default properties
edge LineageEdge Single graph edge with specified properties
height number Calculated height in pixels

Usage Examples

import {
  getTransformedNodes,
  getTransformedModelEdgesSourceTargets,
  createNode,
  createEdge,
  calculateNodeBaseHeight,
  calculateNodeDetailsHeight,
} from '@sqlmesh-common/components/Lineage/help'

// Transform adjacency list into nodes
const nodesMap = getTransformedNodes(
  ['model1', 'model2', 'model3'],
  {
    model1: { name: 'model1', type: 'table' },
    model2: { name: 'model2', type: 'view' },
  },
  (nodeId, details) => createNode('model', nodeId, details)
)

// Generate edges from adjacency list
const edges = getTransformedModelEdgesSourceTargets(
  ['model1', 'model2'],
  {
    model1: ['model2'],
    model2: []
  },
  (type, id, source, target) => createEdge(type, id, source, target)
)

// Calculate node heights
const baseHeight = calculateNodeBaseHeight({
  includeNodeFooterHeight: true,
  includeCeilingHeight: false,
  includeFloorHeight: false
})
// Returns: 52 (2 border + 28 base + 20 footer + 0 ceiling + 0 floor)

const detailsHeight = calculateNodeDetailsHeight({
  nodeDetailsCount: 5
})
// Returns: 124 (4 separators * 1px + 5 items * 24px)

// Filter selected nodes
const selectedOnly = getOnlySelectedNodes(
  nodesMap,
  new Set(['model1', 'model3'])
)
// Returns map with only model1 and model3

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment