/** * 데이터 연결/신호 상태 카탈로그 * * 사용처: DataHub signal heatmap */ import type { BadgeIntent } from '@lib/theme/variants'; export type ConnectionStatus = 'OK' | 'WARNING' | 'ERROR'; export const CONNECTION_STATUSES: Record = { OK: { i18nKey: 'connectionStatus.OK', fallback: { ko: '정상', en: 'OK' }, intent: 'success', hex: '#22c55e', }, WARNING: { i18nKey: 'connectionStatus.WARNING', fallback: { ko: '경고', en: 'Warning' }, intent: 'warning', hex: '#eab308', }, ERROR: { i18nKey: 'connectionStatus.ERROR', fallback: { ko: '오류', en: 'Error' }, intent: 'critical', hex: '#ef4444', }, }; /** 소문자 호환 (DataHub 'ok' | 'warn' | 'error') */ const LEGACY: Record = { ok: 'OK', warn: 'WARNING', warning: 'WARNING', error: 'ERROR', }; export function getConnectionStatusMeta(s: string) { if (CONNECTION_STATUSES[s as ConnectionStatus]) return CONNECTION_STATUSES[s as ConnectionStatus]; const code = LEGACY[s.toLowerCase()]; return code ? CONNECTION_STATUSES[code] : CONNECTION_STATUSES.OK; } export function getConnectionStatusHex(s: string): string { return getConnectionStatusMeta(s).hex; } export function getConnectionStatusIntent(s: string): BadgeIntent { return getConnectionStatusMeta(s).intent; }