Files
pipeline/frontend/lib/api/centralForwarder.ts
T
chpark 4c1dc4082e
Build and Push Images / build-and-push (push) Has been cancelled
feat: Fleet/Collector/엣지 배포 관련 누적 작업 일괄 커밋
이전 세션들에서 작업된 아래 범위를 모두 포함:

Fleet 서브시스템 (src/fleet/)
- fleetDeviceService / fleetCommandService / fleetDeploymentService / fleetReleaseService
- fleetMetricsService, fleetScriptService, fleetEdgeConfigService
- Edge 디바이스 관리, 커맨드 발행, 배포/릴리스, 스크립트 동기화

Collector 확장
- centralMqttForwarder / centralForwarderConfigService
- equipmentStateService, pythonHookRunner, scriptCache
- Modbus/OPC-UA/S7/XGT 프로토콜 클라이언트
- targetDbIntrospection (저장 DB 조회)

Routes / API
- automationDashboardRoutes, centralForwarderRoutes, equipmentStateRoutes

DB
- importEdgeConfig (Python cached config → Pipeline DB)
- seedDataSources (external_db_connections 초기 시드)

엣지 배포 리소스
- docker/edge/Dockerfile.backend.prod, Dockerfile.frontend.prod
- docker/edge/docker-compose.edge.yml

프론트엔드
- admin/automaticMng (centralForwarder, dashboard, equipmentState)
- admin/fleet (commands, devices, deployments, releases, scripts, alerts)
- admin/pipeline-device 개선 (저장 DB 드롭다운, 태그 매핑 등)
- ExternalDbConnectionModal, ScriptsManagerDialog 등 신규 컴포넌트
- lib/api: automationDashboard, centralForwarder, equipmentState, fleet

docs/
- EDGE_SERVER_STRUCTURE, FLEET_COMPLETE, FLEET_EDGE_INTEGRATION, FLEET_HOOK_INTEGRATION

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 20:00:06 +09:00

89 lines
2.4 KiB
TypeScript

// Central MQTT Forwarder 관리 API 클라이언트
import { apiClient } from "./client";
export interface CentralForwarderConfig {
id?: number;
config_name: string;
company_code?: string;
company_id: string;
edge_id: string;
broker_host: string;
broker_port: number;
username?: string;
password?: string;
use_tls?: string;
client_id_prefix?: string;
topic_pattern?: string;
status_topic_pattern?: string;
batch_size?: number;
batch_timeout_ms?: number;
heartbeat_interval_sec?: number;
qos?: number;
is_enabled?: string;
description?: string;
created_date?: string;
updated_date?: string;
}
export interface ForwarderRuntimeStatus {
config_id: number;
config_name: string;
company_code: string;
edge_id: string;
broker: string;
connected: boolean;
buffered: number;
messagesForwarded: number;
messagesFailed: number;
messagesDropped: number;
batchesSent: number;
lastPublishedAt: string | null;
startedAt: string;
isConnected: boolean;
reconnectAttempts: number;
lastError: string | null;
lastErrorAt: string | null;
}
const BASE = "/api/central-forwarder";
export const CentralForwarderAPI = {
async list(companyCode?: string): Promise<CentralForwarderConfig[]> {
const url = companyCode ? `${BASE}?company_code=${companyCode}` : BASE;
const r = await apiClient.get<{ success: boolean; data: CentralForwarderConfig[] }>(url);
return r.data.data || [];
},
async get(id: number): Promise<CentralForwarderConfig> {
const r = await apiClient.get<{ success: boolean; data: CentralForwarderConfig }>(
`${BASE}/${id}`
);
return r.data.data;
},
async create(input: CentralForwarderConfig): Promise<{ id: number }> {
const r = await apiClient.post<{ success: boolean; data: { id: number } }>(BASE, input);
return r.data.data;
},
async update(id: number, input: Partial<CentralForwarderConfig>): Promise<void> {
await apiClient.put(`${BASE}/${id}`, input);
},
async delete(id: number): Promise<void> {
await apiClient.delete(`${BASE}/${id}`);
},
async toggle(id: number, enabled: boolean): Promise<void> {
await apiClient.post(`${BASE}/${id}/toggle`, { enabled });
},
async runtimeStatus(): Promise<ForwarderRuntimeStatus[]> {
const r = await apiClient.get<{ success: boolean; data: ForwarderRuntimeStatus[] }>(
`${BASE}/runtime/status`
);
return r.data.data || [];
},
};