import 'server-only'; import { request } from './api'; import type { MultiSeriesResponse } from './types'; import type { ChangesFeedResponse, IndicatorResponse, IndicatorsResponse, MethodologyResponse, RegionResponse, RegionsResponse, SourceResponse, SourcesResponse, TrendResponse, } from './types-explore'; /** * Server-side endpoints for the indicators / regions / explore / changes / sources / methodology pages. * Same conventions as `lib/api.ts` (`request` → ApiError, ISR 900 s). Kept in its own file because two * agents extend the API surface concurrently. */ export const apiExplore = { indicators: (q: { topic?: string; q?: string; featured?: boolean; source?: string; with_data?: boolean } = {}) => request('/indicators', q), indicator: (slug: string) => request(`/indicators/${encodeURIComponent(slug)}`), indicatorTrend: (slug: string, group = 'world', q: { from?: number; to?: number; min_n?: number } = {}) => request(`/indicators/${encodeURIComponent(slug)}/trend`, { group, ...q }), /** `/series?country=A,B&indicator=x,y` bundle (max 20 countries × 12 indicators). */ seriesBundle: (countries: string[], indicators: string[], q: { from?: number; to?: number; include_forecast?: boolean } = {}) => request('/series', { country: countries.join(','), indicator: indicators.join(','), ...q }), regions: (kind?: string) => request('/regions', { kind }), region: (slug: string, q: { indicator?: string; sort?: 'asc' | 'desc' } = {}) => request(`/regions/${encodeURIComponent(slug)}`, q), changes: (q: { limit?: number; offset?: number; kind?: string; indicator?: string; country?: string; topic?: string; min_severity?: number } = {}) => request('/changes', q), sources: () => request('/sources'), source: (id: string, runsLimit = 30) => request(`/sources/${encodeURIComponent(id)}`, { runs_limit: runsLimit }), methodology: () => request('/methodology', undefined, { revalidate: 3600 }), }; export type ApiExplore = typeof apiExplore;