import type { Metadata } from 'next'; import { AdminTitle, Bool, JsonPre, Mono } from '@/components/admin/ui'; import { HBars } from '@/components/charts/charts'; import { DataTable, EmptyRow, Td, Th } from '@/components/ui/data-table'; import { KeyValue } from '@/components/ui/key-value'; import { Unavailable } from '@/components/ui/unavailable'; import { adminApi, load, requireAdmin } from '@/lib/admin/admin-api'; import { fmtBytes, fmtDuration, fmtInt, num } from '@/lib/format'; export const metadata: Metadata = { title: 'Infrastructure', robots: { index: false, follow: false } }; export const dynamic = 'force-dynamic'; export default async function AdminInfrastructurePage() { await requireAdmin(); const res = await load(adminApi.infrastructure()); if (!res.ok) { return ( <> ); } const i = res.data; const db = i.database; const tables = [...(db?.tables ?? [])].sort((a, b) => (num(b.total_bytes) ?? 0) - (num(a.total_bytes) ?? 0)); const hb = Object.entries(i.heartbeats ?? {}); return ( <> {i.hostname} : undefined} />

API process

{i.hostname ?? '—'} }, { key: 'env', label: 'Environment', raw: i.env }, { key: 'python', label: 'Python', raw: i.python }, { key: 'platform', label: 'Platform', raw: i.platform }, { key: 'uptime', label: 'API uptime', raw: num(i.api_uptime_s) === null ? null : fmtDuration(i.api_uptime_s) }, { key: 'data_dir', label: 'Data dir', value: }, ]} />

Archive

{i.archive ? ( {fmtBytes(i.archive.raw_bytes)} · {fmtInt(i.archive.raw_files)} files }, { key: 'text', label: 'Text', value: {fmtBytes(i.archive.text_bytes)} · {fmtInt(i.archive.text_files)} files }, ]} /> ) : (

Archive size unavailable.

)}

Heartbeats

{hb.length === 0 ?

None reported.

: }

Database

{db ? ( {db.database ?? '—'} }, { key: 'size', label: 'Size', raw: fmtBytes(db.db_bytes) }, { key: 'pg', label: 'Server', raw: db.pg_version?.split(',')[0] ?? db.pg_version }, { key: 'conn', label: 'Connections', value: {fmtInt(db.connections)} / {fmtInt(db.max_connections)} }, ]} /> ) : (

Database metrics unavailable.

)}

Table sizes

({ label: t.table, value: num(t.total_bytes) ?? 0, sub: `${fmtInt(t.rows_estimate)} rows` }))} format={(v) => fmtBytes(v)} />
Table Total Data Rows (est.) {tables.length === 0 && No table statistics.} {tables.map((t) => ( {t.table} {fmtBytes(t.total_bytes)} {fmtBytes(t.data_bytes)} {fmtInt(t.rows_estimate)} ))}
); }