Files
invyone/frontend/types/flowExternalDb.ts
T

191 lines
5.3 KiB
TypeScript

/**
* 플로우 전용 외부 DB 연동 타입 정의
* (기존 제어관리 외부 DB와 별도)
*/
// ==================== 연동 타입 ====================
export type FlowIntegrationType = "internal" | "external_db" | "procedure" | "rest_api" | "webhook" | "hybrid";
// ==================== 외부 DB 연결 ====================
export interface FlowExternalDbConnection {
id: number;
name: string;
description?: string;
db_type: "postgresql" | "mysql" | "mssql" | "oracle";
host: string;
port: number;
database_name: string;
username: string;
password_encrypted: string; // 암호화된 비밀번호 (화면에는 표시하지 않음)
ssl_enabled: boolean;
connection_options?: Record<string, any>;
is_active: boolean;
created_by?: string;
updated_by?: string;
created_at: string;
updated_at: string;
}
export interface CreateFlowExternalDbConnectionRequest {
name: string;
description?: string;
db_type: "postgresql" | "mysql" | "mssql" | "oracle";
host: string;
port: number;
database_name: string;
username: string;
password: string; // 평문 비밀번호 (생성 시에만 사용)
ssl_enabled?: boolean;
connection_options?: Record<string, any>;
}
export interface UpdateFlowExternalDbConnectionRequest {
name?: string;
description?: string;
host?: string;
port?: number;
database_name?: string;
username?: string;
password?: string; // 평문 비밀번호 (변경 시에만)
ssl_enabled?: boolean;
connection_options?: Record<string, any>;
is_active?: boolean;
}
// ==================== 외부 DB 연동 설정 ====================
export interface FlowExternalDbIntegrationConfig {
type: "external_db";
connection_id: number; // 연결 ID
operation: "update" | "insert" | "delete" | "custom";
table_name: string;
update_fields?: Record<string, any>; // 업데이트할 필드
where_condition?: Record<string, any>; // WHERE 조건
custom_query?: string; // 커스텀 쿼리
}
// 프로시저 호출 파라미터 정의
export interface FlowProcedureParam {
name: string;
data_type: string;
mode: "IN" | "OUT" | "INOUT";
source: "record_field" | "static" | "step_variable";
field?: string;
value?: string;
}
// 프로시저 호출 설정
export interface FlowProcedureConfig {
type: "procedure";
db_source: "internal" | "external";
connection_id?: number;
procedure_name: string;
procedure_schema?: string;
call_type: "procedure" | "function";
parameters: FlowProcedureParam[];
}
// 프로시저/함수 목록 항목
export interface ProcedureListItem {
name: string;
schema: string;
type: "PROCEDURE" | "FUNCTION";
return_type?: string;
}
// 프로시저 파라미터 정보
export interface ProcedureParameterInfo {
name: string;
position: number;
data_type: string;
mode: "IN" | "OUT" | "INOUT";
default_value?: string;
}
// 연동 설정 통합 타입
export type FlowIntegrationConfig =
| FlowExternalDbIntegrationConfig
| FlowProcedureConfig;
// ==================== 연동 로그 ====================
export interface FlowIntegrationLog {
id: number;
flow_definition_id: number;
step_id: number;
data_id?: string;
integration_type: string;
connection_id?: number;
request_payload?: Record<string, any>;
response_payload?: Record<string, any>;
status: "success" | "failed" | "timeout" | "rollback";
error_message?: string;
execution_time_ms?: number;
executed_by?: string;
executed_at: string;
}
// ==================== API 응답 ====================
export interface FlowExternalDbConnectionListResponse {
success: boolean;
data: FlowExternalDbConnection[];
message?: string;
}
export interface FlowExternalDbConnectionResponse {
success: boolean;
data?: FlowExternalDbConnection;
message?: string;
error?: string;
}
export interface FlowExternalDbConnectionTestResponse {
success: boolean;
message: string;
}
// ==================== UI 관련 ====================
export const DB_TYPE_OPTIONS = [
{ value: "postgresql", label: "PostgreSQL" },
{ value: "mysql", label: "MySQL" },
{ value: "mssql", label: "MS SQL Server" },
{ value: "oracle", label: "Oracle" },
] as const;
export const OPERATION_OPTIONS = [
{ value: "update", label: "업데이트 (UPDATE)" },
{ value: "insert", label: "삽입 (INSERT)" },
{ value: "delete", label: "삭제 (DELETE)" },
{ value: "custom", label: "커스텀 쿼리" },
] as const;
export const INTEGRATION_TYPE_OPTIONS = [
{ value: "internal", label: "내부 DB (기본)" },
{ value: "external_db", label: "외부 DB 연동" },
{ value: "procedure", label: "프로시저/함수 호출" },
{ value: "rest_api", label: "REST API 연동" },
{ value: "webhook", label: "Webhook (추후 지원)" },
{ value: "hybrid", label: "복합 연동 (추후 지원)" },
] as const;
// ==================== 헬퍼 함수 ====================
export function getDbTypeLabel(dbType: string): string {
const option = DB_TYPE_OPTIONS.find((opt) => opt.value === dbType);
return option?.label || dbType;
}
export function getOperationLabel(operation: string): string {
const option = OPERATION_OPTIONS.find((opt) => opt.value === operation);
return option?.label || operation;
}
export function getIntegrationTypeLabel(type: string): string {
const option = INTEGRATION_TYPE_OPTIONS.find((opt) => opt.value === type);
return option?.label || type;
}