add translation for tags

This commit is contained in:
Первов Артем
2026-06-17 11:22:24 +03:00
parent 2c4aef1185
commit 6b6e0abe40
6 changed files with 118 additions and 15 deletions

View File

@@ -67,6 +67,21 @@ export type HistoryResponse = {
valueMode?: 'raw' | 'avg' | 'last' | 'first' | 'min' | 'max';
};
export type TagTranslationItem = {
edge: string;
tag: string;
locale: string;
displayName: string;
source: string | null;
updatedAt: string;
};
export type TagTranslationResponse = {
edge: string;
locale: string;
items: TagTranslationItem[];
};
/** Выполняет типизированный GET-запрос к cloud-v2 и централизованно обрабатывает ошибки HTTP. */
async function request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T> {
const url = new URL(path, API_URL);
@@ -133,3 +148,16 @@ export function getHistory(params: {
valueMode: params.valueMode,
});
}
/** Загружает русскоязычный справочник названий тегов для выбранного edge. */
export function getTagTranslations(params: {
edge: string;
locale?: string;
tags?: string[];
}): Promise<TagTranslationResponse> {
return request<TagTranslationResponse>('/tag-translations', {
edge: params.edge,
locale: params.locale ?? 'ru',
tags: params.tags?.join(','),
});
}