feat: 노드 기반 데이터 플로우 시스템 구현
- 노드 에디터 UI 구현 (React Flow 기반)
- TableSource, DataTransform, INSERT, UPDATE, DELETE, UPSERT 노드
- 드래그앤드롭 노드 추가 및 연결
- 속성 패널을 통한 노드 설정
- 실시간 필드 라벨 표시 (column_labels 테이블 연동)
- 데이터 변환 노드 (DataTransform) 기능
- EXPLODE: 구분자로 1개 행 → 여러 행 확장
- UPPERCASE, LOWERCASE, TRIM, CONCAT, SPLIT, REPLACE 등 12가지 변환 타입
- In-place 변환 지원 (타겟 필드 생략 시 소스 필드 덮어쓰기)
- 변환된 필드가 하위 액션 노드에 자동 전달
- 노드 플로우 실행 엔진
- 위상 정렬을 통한 노드 실행 순서 결정
- 레벨별 병렬 실행 (Promise.allSettled)
- 부분 실패 허용 (한 노드 실패 시 연결된 하위 노드만 스킵)
- 트랜잭션 기반 안전한 데이터 처리
- UPSERT 액션 로직 구현
- DB 제약 조건 없이 SELECT → UPDATE or INSERT 방식
- 복합 충돌 키 지원 (예: sales_no + product_name)
- 파라미터 인덱스 정확한 매핑
- 데이터 소스 자동 감지
- 테이블 선택 데이터 (selectedRowsData) 자동 주입
- 폼 입력 데이터 (formData) 자동 주입
- TableSource 노드가 외부 데이터 우선 사용
- 버튼 컴포넌트 통합
- 기존 관계 실행 + 새 노드 플로우 실행 하이브리드 지원
- 노드 플로우 선택 UI 추가
- API 클라이언트 통합 (Axios)
- 개발 문서 작성
- 노드 기반 제어 시스템 개선 계획
- 노드 연결 규칙 설계
- 노드 실행 엔진 설계
- 노드 구조 개선안
- 버튼 통합 분석
2025-10-02 16:22:29 +09:00
|
|
|
/**
|
|
|
|
|
* 노드 플로우 API
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { apiClient } from "./client";
|
|
|
|
|
|
|
|
|
|
export interface NodeFlow {
|
|
|
|
|
flowId: number;
|
|
|
|
|
flowName: string;
|
|
|
|
|
flowDescription: string;
|
|
|
|
|
flowData: string | any; // JSONB는 문자열 또는 객체로 반환될 수 있음
|
|
|
|
|
createdAt: string;
|
|
|
|
|
updatedAt: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ApiResponse<T> {
|
|
|
|
|
success: boolean;
|
|
|
|
|
data?: T;
|
|
|
|
|
message?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 목록 조회
|
|
|
|
|
*/
|
|
|
|
|
export async function getNodeFlows(): Promise<NodeFlow[]> {
|
|
|
|
|
const response = await apiClient.get<ApiResponse<NodeFlow[]>>("/dataflow/node-flows");
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
throw new Error(response.data.message || "플로우 목록을 불러올 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 상세 조회
|
|
|
|
|
*/
|
|
|
|
|
export async function getNodeFlow(flowId: number): Promise<NodeFlow> {
|
|
|
|
|
const response = await apiClient.get<ApiResponse<NodeFlow>>(`/dataflow/node-flows/${flowId}`);
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
throw new Error(response.data.message || "플로우를 불러올 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 저장 (신규)
|
|
|
|
|
*/
|
|
|
|
|
export async function createNodeFlow(data: {
|
|
|
|
|
flowName: string;
|
|
|
|
|
flowDescription: string;
|
|
|
|
|
flowData: string;
|
|
|
|
|
}): Promise<{ flowId: number }> {
|
|
|
|
|
const response = await apiClient.post<ApiResponse<{ flowId: number }>>("/dataflow/node-flows", data);
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
throw new Error(response.data.message || "플로우를 저장할 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 수정
|
|
|
|
|
*/
|
|
|
|
|
export async function updateNodeFlow(data: {
|
|
|
|
|
flowId: number;
|
|
|
|
|
flowName: string;
|
|
|
|
|
flowDescription: string;
|
|
|
|
|
flowData: string;
|
|
|
|
|
}): Promise<{ flowId: number }> {
|
|
|
|
|
const response = await apiClient.put<ApiResponse<{ flowId: number }>>("/dataflow/node-flows", data);
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
throw new Error(response.data.message || "플로우를 수정할 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 삭제
|
|
|
|
|
*/
|
|
|
|
|
export async function deleteNodeFlow(flowId: number): Promise<void> {
|
|
|
|
|
const response = await apiClient.delete<ApiResponse<void>>(`/dataflow/node-flows/${flowId}`);
|
|
|
|
|
if (!response.data.success) {
|
|
|
|
|
throw new Error(response.data.message || "플로우를 삭제할 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 실행
|
|
|
|
|
*/
|
|
|
|
|
export async function executeNodeFlow(flowId: number, contextData: Record<string, any>): Promise<ExecutionResult> {
|
|
|
|
|
const response = await apiClient.post<ApiResponse<ExecutionResult>>(
|
|
|
|
|
`/dataflow/node-flows/${flowId}/execute`,
|
|
|
|
|
contextData,
|
|
|
|
|
);
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
throw new Error(response.data.message || "플로우를 실행할 수 없습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 실행 결과 인터페이스
|
|
|
|
|
*/
|
|
|
|
|
export interface ExecutionResult {
|
|
|
|
|
success: boolean;
|
|
|
|
|
message: string;
|
|
|
|
|
executionTime: number;
|
|
|
|
|
nodes: NodeExecutionSummary[];
|
|
|
|
|
summary: {
|
|
|
|
|
total: number;
|
|
|
|
|
success: number;
|
|
|
|
|
failed: number;
|
|
|
|
|
skipped: number;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface NodeExecutionSummary {
|
|
|
|
|
nodeId: string;
|
|
|
|
|
nodeName: string;
|
|
|
|
|
nodeType: string;
|
|
|
|
|
status: "success" | "failed" | "skipped" | "pending";
|
|
|
|
|
duration?: number;
|
|
|
|
|
error?: string;
|
|
|
|
|
}
|
2025-12-31 10:54:07 +09:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 소스 테이블 정보 인터페이스
|
|
|
|
|
*/
|
|
|
|
|
export interface FlowSourceTableInfo {
|
|
|
|
|
sourceTable: string | null;
|
|
|
|
|
sourceNodeType: string | null;
|
|
|
|
|
sourceNodeId?: string;
|
|
|
|
|
displayName?: string;
|
|
|
|
|
message?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 플로우 소스 테이블 조회
|
|
|
|
|
* 플로우의 첫 번째 소스 노드(tableSource, externalDBSource)에서 테이블명 추출
|
|
|
|
|
*/
|
|
|
|
|
export async function getFlowSourceTable(flowId: number): Promise<FlowSourceTableInfo> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await apiClient.get<ApiResponse<FlowSourceTableInfo>>(
|
|
|
|
|
`/dataflow/node-flows/${flowId}/source-table`,
|
|
|
|
|
);
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
sourceTable: null,
|
|
|
|
|
sourceNodeType: null,
|
|
|
|
|
message: response.data.message || "소스 테이블 정보를 가져올 수 없습니다.",
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("플로우 소스 테이블 조회 실패:", error);
|
|
|
|
|
return {
|
|
|
|
|
sourceTable: null,
|
|
|
|
|
sourceNodeType: null,
|
|
|
|
|
message: "API 호출 중 오류가 발생했습니다.",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|