import request from './request'

export interface TreeNode {
  id: number
  name: string
  type: string
  children?: TreeNode[]
  meta?: Record<string, any>
}

export interface DataColumn {
  id: number
  table_id: number
  name: string
  data_type?: string
  length?: number
  comment?: string
  is_nullable: boolean
  sample_data?: string
  created_at: string
}

export function getMetadataTree(sourceId?: number) {
  return request.get('/metadata/tree', { params: { source_id: sourceId } })
}

export function getColumns(params: { table_id?: number; keyword?: string; page?: number; page_size?: number }) {
  return request.get('/metadata/columns', { params })
}
