Files
EvoBGP/apps/web/src/queries/monitoring.ts
T
DenozordecandCursor c144b49acf
CI / changes (push) Successful in 17s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 26s
CI / web (push) Successful in 46s
CI / go (push) Successful in 1m1s
CI / bird2 (push) Successful in 17s
CI / release (push) Failing after 2m22s
feat!(web): migrate UI from SvelteKit to React + shadcn/ui + ReUI
Web UI полностью переведён с SvelteKit на новый стек: React 19,
TanStack Router/Query/Table/Virtual, shadcn/ui (base-nova) и ReUI
enterprise-компоненты (data-grid, filters, autocomplete). Новый код
разложен по слоям: packages/ui (shadcn-примитивы), apps/web
(роуты, shared-обёртки, ReUI-адаптации).

BREAKING CHANGE: меняется структура и инструментинг фронтенда.

- apps/web/ — новый Vite + React-проект (@evobgp/web), file-based
  роуты TanStack Router; экраны dashboard, modules, monitoring,
  network, operations, schedule, settings, tenant-settings, access,
  directories.
- packages/ui/ — shadcn/ui-примитивы (@evobgp/ui) с общими стилями
  globals.css и cn-утилитой; CLI shadcn запускается из apps/web.
- apps/web/src/components/reui/ — enterprise-паттерны ReUI.
- pnpm workspace (pnpm-workspace.yaml, pnpm-lock.yaml, tsconfig.base.json)
  заменяет npm-проект в web/.
- web/ переименован в web-legacy-svelte/ (архив-референс для миграции);
  импорты оттуда запрещены правилом WEB-22.
- CI (.gitea/workflows/ci.yaml): job web переведён на Node 22 + pnpm 10
  (typecheck/lint/build через pnpm --filter @evobgp/web); пути триггеров
  обновлены под apps/web|packages/ui.
- deploy/docker/evobgp-web/Dockerfile: сборка из корня репозитория,
  pnpm install --frozen-lockfile, выход dist из apps/web/dist.
- .cursor/rules/web-shadcn.mdc, context7-stack.mdc, engineering.mdc,
  AGENTS.md — обновлены под React-стек (WEB-01..WEB-22, DOC-SYNC-06/07).

Проверки WEB-19 локально: typecheck, lint, build — exit 0.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 17:59:59 +07:00

72 lines
1.9 KiB
TypeScript

import { queryOptions } from '@tanstack/react-query'
import { apiFetch, apiJSON, apiMutate } from '@/lib/api-client'
export interface HealthStatus {
ok: boolean
status?: string
error?: string
}
export interface ReadyStatus {
status?: string
checks?: Record<string, boolean | { ok?: boolean; error?: string }>
}
export interface VersionInfo {
version?: string
app?: string
git_sha?: string
build_time?: string
}
export const monitoringKeys = {
all: ['monitoring'] as const,
health: () => [...monitoringKeys.all, 'health'] as const,
ready: () => [...monitoringKeys.all, 'ready'] as const,
version: () => [...monitoringKeys.all, 'version'] as const,
}
async function fetchHealth(): Promise<HealthStatus> {
const res = await apiFetch('/v1/health', { method: 'GET' })
let body: { status?: string } = {}
try {
body = (await res.json()) as { status?: string }
} catch {
/* ignore */
}
return { ok: res.ok, status: body.status, error: res.ok ? undefined : `HTTP ${res.status}` }
}
export function monitoringHealthQueryOptions() {
return queryOptions<HealthStatus>({
queryKey: monitoringKeys.health(),
queryFn: fetchHealth,
staleTime: 15_000,
})
}
export function monitoringReadyQueryOptions() {
return queryOptions<ReadyStatus>({
queryKey: monitoringKeys.ready(),
queryFn: () => apiJSON<ReadyStatus>('/v1/ready'),
staleTime: 15_000,
})
}
export function monitoringVersionQueryOptions() {
return queryOptions<VersionInfo>({
queryKey: monitoringKeys.version(),
queryFn: () => apiJSON<VersionInfo>('/v1/version'),
staleTime: 60_000,
})
}
export async function fetchLog(endpoint: string): Promise<string> {
const res = await apiFetch(endpoint, { method: 'GET' })
return await res.text()
}
export async function clearLog(endpoint: string): Promise<void> {
await apiMutate(endpoint, 'DELETE', {})
}