import apiFetch from "@wordpress/api-fetch"; import type {} from "../env"; import type { ConversationSummary, ConversationDetail, UsageInfo, } from "./types"; function getApiUrl(endpoint: string): string { return `${window.flexibleChatHistory.apiUrl}${endpoint}`; } export function fetchConversations(): Promise { return apiFetch({ url: getApiUrl("/conversations"), cache: "no-store", }); } export function fetchConversation(id: string): Promise { return apiFetch({ url: getApiUrl(`/conversations/${encodeURIComponent(id)}`), cache: "no-store", }); } export function fetchUsage(): Promise { return apiFetch({ url: getApiUrl("/usage"), cache: "no-store", }); }