Files
ui/src/entities/diagram/api.ts
Первов Артем 31add10e56 decompose structure
2026-06-20 00:51:18 +03:00

23 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getAccessToken } from '../../auth/keycloak';
import { getJson } from '../../shared/api/http';
import { diagramApiUrl } from '../../shared/config/env';
import type { DiagramPageResponse, DiagramPageSummary } from './types';
/** Выполняет запрос к diagram-service и пробрасывает Bearer-токен, если UI работает с SSO. */
async function request<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {
const token = await getAccessToken();
return getJson<T>(diagramApiUrl, path, params, {
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
});
}
/** Возвращает список страниц схем; опубликованность определяется по publishedRevision. */
export function listDiagramPages(ownerEdgeId?: string): Promise<DiagramPageSummary[]> {
return request<DiagramPageSummary[]>('/diagram/pages', { ownerEdgeId });
}
/** Загружает опубликованную версию страницы схемы. */
export function getPublishedDiagramPage(pageKey: string): Promise<DiagramPageResponse> {
return request<DiagramPageResponse>(`/diagram/pages/${encodeURIComponent(pageKey)}/published`);
}