/** * DDL 실행 관련 타입 정의 (프론트엔드) */ // 기본 웹타입 export type WebType = | "text" | "number" | "decimal" | "date" | "datetime" | "boolean" | "code" | "entity" | "textarea" | "select" | "checkbox" | "radio" | "file" | "email" | "tel"; // 컬럼 정의 인터페이스 export interface CreateColumnDefinition { /** 컬럼명 (영문자, 숫자, 언더스코어만 허용) */ name: string; /** 컬럼 라벨 (화면 표시용) */ label?: string; /** 입력타입 */ inputType: string; /** 웹타입 (레거시 호환용) */ webType?: WebType; /** NULL 허용 여부 */ nullable?: boolean; /** 컬럼 길이 (text, code 타입에서 사용) */ length?: number; /** 기본값 */ defaultValue?: string; /** 컬럼 설명 */ description?: string; /** 표시 순서 */ order?: number; /** 상세 설정 (JSON 형태) */ detailSettings?: Record; } // 테이블 생성 요청 인터페이스 export interface CreateTableRequest { /** 테이블명 */ tableName: string; /** 테이블 설명 */ description?: string; /** 컬럼 정의 목록 */ columns: CreateColumnDefinition[]; } // 컬럼 추가 요청 인터페이스 export interface AddColumnRequest { /** 컬럼 정의 */ column: CreateColumnDefinition; } // DDL 실행 결과 인터페이스 export interface DDLExecutionResult { /** 실행 성공 여부 */ success: boolean; /** 결과 메시지 */ message: string; /** 결과 데이터 */ data?: any; /** 오류 정보 */ error?: { code: string; details: string; }; } // 검증 결과 인터페이스 export interface ValidationResult { /** 검증 통과 여부 */ isValid: boolean; /** 오류 메시지 목록 */ errors: string[]; /** 경고 메시지 목록 */ warnings?: string[]; /** 검증 요약 */ summary?: string; } // DDL 실행 로그 인터페이스 export interface DDLExecutionLog { /** 로그 ID */ id: number; /** 사용자 ID */ user_id: string; /** 회사 코드 */ company_code: string; /** DDL 유형 */ ddl_type: "CREATE_TABLE" | "ADD_COLUMN" | "DROP_TABLE" | "DROP_COLUMN"; /** 테이블명 */ table_name: string; /** 실행된 DDL 쿼리 (미리보기용) */ ddl_query_preview?: string; /** 실행 성공 여부 */ success: boolean; /** 오류 메시지 (실패 시) */ error_message?: string; /** 실행 시간 */ executed_at: string; } // DDL 통계 인터페이스 export interface DDLStatistics { /** 전체 실행 횟수 */ totalExecutions: number; /** 성공 횟수 */ successfulExecutions: number; /** 실패 횟수 */ failedExecutions: number; /** DDL 타입별 통계 */ byDDLType: Record; /** 사용자별 통계 */ byUser: Record; /** 최근 실패 로그 */ recentFailures: any[]; } // 웹타입 옵션 (UI용) export interface WebTypeOption { value: WebType; label: string; description?: string; supportsLength: boolean; defaultLength?: number; } // 웹타입 옵션 목록 export const WEB_TYPE_OPTIONS: WebTypeOption[] = [ { value: "text", label: "텍스트", description: "일반 텍스트 입력", supportsLength: true, defaultLength: 255, }, { value: "number", label: "숫자", description: "정수 입력", supportsLength: false, }, { value: "decimal", label: "소수", description: "소수점 숫자 입력", supportsLength: false, }, { value: "date", label: "날짜", description: "날짜 선택", supportsLength: false, }, { value: "datetime", label: "날짜시간", description: "날짜와 시간 선택", supportsLength: false, }, { value: "boolean", label: "불린", description: "참/거짓 값", supportsLength: false, }, { value: "code", label: "코드", description: "공통코드 선택", supportsLength: true, defaultLength: 100, }, { value: "entity", label: "엔티티", description: "다른 테이블 참조", supportsLength: false, }, { value: "textarea", label: "긴 텍스트", description: "여러 줄 텍스트 입력", supportsLength: false, }, { value: "select", label: "선택박스", description: "드롭다운 선택", supportsLength: true, defaultLength: 100, }, { value: "checkbox", label: "체크박스", description: "체크박스 입력", supportsLength: false, }, { value: "radio", label: "라디오버튼", description: "단일 선택 라디오버튼", supportsLength: true, defaultLength: 100, }, { value: "file", label: "파일", description: "파일 업로드", supportsLength: false, }, { value: "email", label: "이메일", description: "이메일 주소 입력", supportsLength: true, defaultLength: 255, }, { value: "tel", label: "전화번호", description: "전화번호 입력", supportsLength: true, defaultLength: 50, }, ]; // 컬럼 정의 테이블 속성 export interface ColumnDefinitionTableProps { columns: CreateColumnDefinition[]; onChange: (columns: CreateColumnDefinition[]) => void; disabled?: boolean; } // 테이블 생성 모달 속성 export interface CreateTableModalProps { isOpen: boolean; onClose: () => void; onSuccess: (result: DDLExecutionResult) => void; } // 컬럼 추가 모달 속성 export interface AddColumnModalProps { isOpen: boolean; onClose: () => void; tableName: string; onSuccess: (result: DDLExecutionResult) => void; } // DDL 로그 뷰어 속성 export interface DDLLogViewerProps { isOpen: boolean; onClose: () => void; } // 유효성 검사 규칙 export const VALIDATION_RULES = { tableName: { pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, minLength: 2, maxLength: 63, errorMessage: "테이블명은 영문자로 시작하고, 영문자/숫자/언더스코어만 사용 가능합니다 (2-63자)", }, columnName: { pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, minLength: 2, maxLength: 63, errorMessage: "컬럼명은 영문자로 시작하고, 영문자/숫자/언더스코어만 사용 가능합니다 (2-63자)", }, columnLength: { min: 1, max: 65535, errorMessage: "컬럼 길이는 1 이상 65535 이하여야 합니다", }, } as const; // 시스템 테이블 목록 (보호 대상) export const SYSTEM_TABLES = [ "user_info", "company_mng", "menu_info", "auth_group", "table_labels", "column_labels", "screen_definitions", "screen_layouts", "common_code", "multi_lang_key_master", "multi_lang_text", "button_action_standards", "ddl_execution_log", ] as const; // 예약어 목록 export const RESERVED_WORDS = [ "user", "order", "group", "table", "column", "index", "select", "insert", "update", "delete", "from", "where", "join", "on", "as", "and", "or", "not", "null", "true", "false", "create", "alter", "drop", "primary", "key", "foreign", "references", "constraint", "default", "unique", "check", "view", "procedure", "function", ] as const; // 예약된 컬럼명 목록 (자동 추가되는 기본 컬럼들) export const RESERVED_COLUMNS = ["id", "created_date", "updated_date", "company_code"] as const;