외부 db노드 설정

This commit is contained in:
kjs
2025-10-02 16:43:40 +09:00
parent 0743786f9b
commit 37e018b33c
6 changed files with 782 additions and 74 deletions

View File

@@ -7,6 +7,12 @@ import { Connection, Edge, EdgeChange, Node, NodeChange, addEdge, applyNodeChang
import type { FlowNode, FlowEdge, NodeType, ValidationResult } from "@/types/node-editor";
import { createNodeFlow, updateNodeFlow } from "../api/nodeFlows";
// 🔥 외부 커넥션 캐시 타입
interface ExternalConnectionCache {
data: any[];
timestamp: number;
}
interface FlowEditorState {
// 노드 및 엣지
nodes: FlowNode[];
@@ -30,6 +36,9 @@ interface FlowEditorState {
// 검증 결과
validationResult: ValidationResult | null;
// 🔥 외부 커넥션 캐시 (전역 캐싱)
externalConnectionsCache: ExternalConnectionCache | null;
// ========================================================================
// 노드 관리
// ========================================================================
@@ -41,6 +50,14 @@ interface FlowEditorState {
removeNode: (id: string) => void;
removeNodes: (ids: string[]) => void;
// ========================================================================
// 🔥 외부 커넥션 캐시 관리
// ========================================================================
setExternalConnectionsCache: (data: any[]) => void;
clearExternalConnectionsCache: () => void;
getExternalConnectionsCache: () => any[] | null;
// ========================================================================
// 엣지 관리
// ========================================================================
@@ -110,6 +127,7 @@ export const useFlowEditorStore = create<FlowEditorState>((set, get) => ({
showValidationPanel: false,
showPropertiesPanel: true,
validationResult: null,
externalConnectionsCache: null, // 🔥 캐시 초기화
// ========================================================================
// 노드 관리
@@ -380,6 +398,39 @@ export const useFlowEditorStore = create<FlowEditorState>((set, get) => ({
return { incoming, outgoing };
},
// ========================================================================
// 🔥 외부 커넥션 캐시 관리
// ========================================================================
setExternalConnectionsCache: (data) => {
set({
externalConnectionsCache: {
data,
timestamp: Date.now(),
},
});
},
clearExternalConnectionsCache: () => {
set({ externalConnectionsCache: null });
},
getExternalConnectionsCache: () => {
const cache = get().externalConnectionsCache;
if (!cache) return null;
// 🔥 5분 후 캐시 만료
const CACHE_DURATION = 5 * 60 * 1000; // 5분
const isExpired = Date.now() - cache.timestamp > CACHE_DURATION;
if (isExpired) {
set({ externalConnectionsCache: null });
return null;
}
return cache.data;
},
}));
// ============================================================================