import type { DataSourceOption } from '@/app/components/rag-pipeline/components/panel/test-run/types' import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types' import type { Node } from '@/app/components/workflow/types' import { useMemo } from 'react' import { BlockEnum } from '@/app/components/workflow/types' /** * Hook for getting datasource options from pipeline nodes */ export const useDatasourceOptions = (pipelineNodes: Node[]) => { const datasourceNodes = pipelineNodes.filter(node => node.data.type === BlockEnum.DataSource) const options = useMemo(() => { const options: DataSourceOption[] = [] datasourceNodes.forEach((node) => { const label = node.data.title options.push({ label, value: node.id, data: node.data, }) }) return options }, [datasourceNodes]) return options }