ForcePilot/web/src/apis/graph_api.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

import { apiGet } from './base'
export const graphApi = {
getGraphs: async () => {
return await apiGet('/api/graph/list', {}, true)
},
2025-07-22 17:29:38 +08:00
getSubgraph: async (params) => {
const { db_id, node_label = '*', max_depth = 2, max_nodes = 100 } = params
2025-07-22 17:29:38 +08:00
if (!db_id) {
throw new Error('db_id is required')
}
2025-07-22 17:29:38 +08:00
const queryParams = new URLSearchParams({
db_id,
node_label,
2025-07-22 17:29:38 +08:00
max_depth: max_depth.toString(),
max_nodes: max_nodes.toString()
})
return await apiGet(`/api/graph/subgraph?${queryParams.toString()}`, {}, true)
2025-07-22 17:29:38 +08:00
},
getStats: async (db_id) => {
2025-07-22 17:29:38 +08:00
if (!db_id) {
throw new Error('db_id is required')
}
const queryParams = new URLSearchParams({ db_id })
return await apiGet(`/api/graph/stats?${queryParams.toString()}`, {}, true)
2025-07-22 17:29:38 +08:00
},
getLabels: async (db_id) => {
2025-07-22 17:29:38 +08:00
if (!db_id) {
throw new Error('db_id is required')
}
const queryParams = new URLSearchParams({ db_id })
return await apiGet(`/api/graph/labels?${queryParams.toString()}`, {}, true)
}
}
export const unifiedApi = graphApi