import type { FlowStatsDto, TrafficFlowOverlayResult, TrafficFlowSettingsDto, TrafficFlowSettingsPatch, } from "@mmapp/contracts/traffic-flow" import { requestJson } from "@/shared/api/http-client" export async function getTrafficFlowSettings(baseUrl: string): Promise { return requestJson(baseUrl, "/api/traffic/flow/settings") } export async function putTrafficFlowSettings( baseUrl: string, patch: TrafficFlowSettingsPatch, ): Promise<{ ok: boolean; settings: TrafficFlowSettingsDto }> { return requestJson(baseUrl, "/api/traffic/flow/settings", { method: "PUT", body: JSON.stringify(patch), }) } export async function generateTrafficFlowKeys(baseUrl: string): Promise<{ ok: boolean created: boolean publicKey: string settings: TrafficFlowSettingsDto }> { return requestJson(baseUrl, "/api/traffic/flow/settings/generate-keys", { method: "POST" }) } export type { TrafficFlowHostFile } from "@mmapp/contracts/traffic-flow" export async function getTrafficFlowHostFiles(baseUrl: string): Promise<{ files: TrafficFlowHostFile[] }> { return requestJson(baseUrl, "/api/traffic/flow/host-files") } export async function applyTrafficFlowOverlay( baseUrl: string, serverId: string | number, publicEndpoint?: string, ): Promise { return requestJson(baseUrl, "/api/traffic/flow-overlay", { method: "POST", body: JSON.stringify({ serverId, publicEndpoint }), }) } export async function getTrafficFlows(baseUrl: string, range = "5m"): Promise { return requestJson(baseUrl, `/api/traffic/flows?range=${encodeURIComponent(range)}`) }