/** * Remote Node API functions for fetching data from remote nodes via the proxy. * All functions route through /api/proxy/:nodeId/... when a remote node is targeted. */ import type { ProjectInfo } from "./api"; import type { ProjectHealth, Task } from "@fusion/core"; import { proxyApi } from "./api"; /** Health information for a remote node */ export interface RemoteNodeHealth { status: string; version: string; nodeId: string; } /** Fetch health information from a remote node */ export async function fetchRemoteNodeHealth(nodeId: string): Promise { return proxyApi("/health", { nodeId }); } /** Fetch all projects from a remote node */ export async function fetchRemoteNodeProjects(nodeId: string): Promise { return proxyApi("/projects", { nodeId }); } /** Fetch tasks from a specific project on a remote node */ export async function fetchRemoteNodeTasks( nodeId: string, projectId: string, searchQuery?: string, ): Promise { const params = new URLSearchParams({ projectId }); if (searchQuery && searchQuery.trim()) { params.set("q", searchQuery.trim()); } return proxyApi(`/tasks?${params.toString()}`, { nodeId }); } /** Fetch project health from a remote node */ export async function fetchRemoteNodeProjectHealth( nodeId: string, projectId: string, ): Promise { return proxyApi(`/project-health?projectId=${encodeURIComponent(projectId)}`, { nodeId, }); }