import { defineStore } from 'pinia' import { ref } from 'vue' import type { GraphView, GraphNode, ScanResult } from '@/shared/types/api' import * as graphApi from '../api' export const useGraphStore = defineStore('graph', () => { const graphView = ref(null) const selectedNode = ref(null) const scanResult = ref(null) const loading = ref(false) async function loadGraph(projectId: string) { loading.value = true try { scanResult.value = await graphApi.triggerScan(projectId) graphView.value = await graphApi.getGraph(projectId) } finally { loading.value = false } } function selectNode(node: GraphNode | null) { selectedNode.value = node } async function loadNeighbors(projectId: string, nodeId: string) { loading.value = true try { graphView.value = await graphApi.getNodeNeighbors(projectId, nodeId) } finally { loading.value = false } } function clearSelection() { selectedNode.value = null } return { graphView, selectedNode, scanResult, loading, loadGraph, selectNode, loadNeighbors, clearSelection } })