- Add search query propagation so remote nodes receive and use query filters - Update api-node.ts to accept and forward search query parameters - Add useRemoteNodeData query key dependency for proper re-fetching on filter changes - Add api-node.test.ts with tests for search query propagation - Add comprehensive tests for App component including remote data filtering - Document search query propagation pitfall in .fusion/memory.md
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
/**
|
|
* 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<RemoteNodeHealth> {
|
|
return proxyApi<RemoteNodeHealth>("/health", { nodeId });
|
|
}
|
|
|
|
/** Fetch all projects from a remote node */
|
|
export async function fetchRemoteNodeProjects(nodeId: string): Promise<ProjectInfo[]> {
|
|
return proxyApi<ProjectInfo[]>("/projects", { nodeId });
|
|
}
|
|
|
|
/** Fetch tasks from a specific project on a remote node */
|
|
export async function fetchRemoteNodeTasks(
|
|
nodeId: string,
|
|
projectId: string,
|
|
searchQuery?: string,
|
|
): Promise<Task[]> {
|
|
const params = new URLSearchParams({ projectId });
|
|
if (searchQuery && searchQuery.trim()) {
|
|
params.set("q", searchQuery.trim());
|
|
}
|
|
return proxyApi<Task[]>(`/tasks?${params.toString()}`, { nodeId });
|
|
}
|
|
|
|
/** Fetch project health from a remote node */
|
|
export async function fetchRemoteNodeProjectHealth(
|
|
nodeId: string,
|
|
projectId: string,
|
|
): Promise<ProjectHealth> {
|
|
return proxyApi<ProjectHealth>(`/project-health?projectId=${encodeURIComponent(projectId)}`, {
|
|
nodeId,
|
|
});
|
|
}
|