344 lines
7.8 KiB
TypeScript
344 lines
7.8 KiB
TypeScript
|
|
/**
|
||
|
|
* 🎯 통합 타입 시스템 Index
|
||
|
|
*
|
||
|
|
* 모든 타입 정의를 중앙에서 관리하고 re-export합니다.
|
||
|
|
* 이 파일을 통해 모든 타입에 일관성 있게 접근할 수 있습니다.
|
||
|
|
*/
|
||
|
|
|
||
|
|
// ===== 핵심 공통 타입들 =====
|
||
|
|
export * from "./unified-core";
|
||
|
|
|
||
|
|
// ===== 시스템별 전용 타입들 =====
|
||
|
|
export * from "./screen-management";
|
||
|
|
export * from "./control-management";
|
||
|
|
export * from "./table-management";
|
||
|
|
|
||
|
|
// ===== 기존 호환성을 위한 re-export =====
|
||
|
|
|
||
|
|
// unified-core에서 제공하는 주요 타입들을 직접 export
|
||
|
|
export type {
|
||
|
|
// 핵심 타입들
|
||
|
|
WebType,
|
||
|
|
DynamicWebType,
|
||
|
|
ButtonActionType,
|
||
|
|
ComponentType,
|
||
|
|
Position,
|
||
|
|
Size,
|
||
|
|
CommonStyle,
|
||
|
|
ValidationRule,
|
||
|
|
ConditionOperator,
|
||
|
|
|
||
|
|
// API 관련
|
||
|
|
BaseApiResponse,
|
||
|
|
PaginatedResponse,
|
||
|
|
|
||
|
|
// 공통 필드들
|
||
|
|
CompanyCode,
|
||
|
|
ActiveStatus,
|
||
|
|
TimestampFields,
|
||
|
|
AuditFields,
|
||
|
|
|
||
|
|
// 이벤트 타입들
|
||
|
|
WebTypeEvent,
|
||
|
|
ComponentEvent,
|
||
|
|
} from "./unified-core";
|
||
|
|
|
||
|
|
// screen-management에서 제공하는 주요 타입들
|
||
|
|
export type {
|
||
|
|
// 컴포넌트 타입들
|
||
|
|
ComponentData,
|
||
|
|
BaseComponent,
|
||
|
|
WidgetComponent,
|
||
|
|
ContainerComponent,
|
||
|
|
GroupComponent,
|
||
|
|
DataTableComponent,
|
||
|
|
FileComponent,
|
||
|
|
|
||
|
|
// 웹타입 설정들
|
||
|
|
WebTypeConfig,
|
||
|
|
DateTypeConfig,
|
||
|
|
NumberTypeConfig,
|
||
|
|
SelectTypeConfig,
|
||
|
|
TextTypeConfig,
|
||
|
|
FileTypeConfig,
|
||
|
|
EntityTypeConfig,
|
||
|
|
ButtonTypeConfig,
|
||
|
|
|
||
|
|
// 화면 관련
|
||
|
|
ScreenDefinition,
|
||
|
|
CreateScreenRequest,
|
||
|
|
UpdateScreenRequest,
|
||
|
|
LayoutData,
|
||
|
|
GridSettings,
|
||
|
|
ScreenTemplate,
|
||
|
|
ScreenResolution,
|
||
|
|
GroupState,
|
||
|
|
|
||
|
|
// 화면 해상도 상수
|
||
|
|
SCREEN_RESOLUTIONS,
|
||
|
|
|
||
|
|
// 데이터 테이블
|
||
|
|
DataTableColumn,
|
||
|
|
DataTableFilter,
|
||
|
|
|
||
|
|
// 파일 업로드
|
||
|
|
UploadedFile,
|
||
|
|
} from "./screen-management";
|
||
|
|
|
||
|
|
// control-management에서 제공하는 주요 타입들
|
||
|
|
export type {
|
||
|
|
// 버튼 제어
|
||
|
|
ExtendedButtonTypeConfig,
|
||
|
|
ButtonDataflowConfig,
|
||
|
|
ControlDataSource,
|
||
|
|
|
||
|
|
// 데이터플로우
|
||
|
|
DataflowCondition,
|
||
|
|
DataflowAction,
|
||
|
|
ActionType,
|
||
|
|
DatabaseOperation,
|
||
|
|
NotificationType,
|
||
|
|
|
||
|
|
// 트랜잭션 관리
|
||
|
|
TransactionGroup,
|
||
|
|
RollbackStrategy,
|
||
|
|
FailureHandling,
|
||
|
|
ConditionalExecutionPlan,
|
||
|
|
ExecutionCondition,
|
||
|
|
|
||
|
|
// 실행 결과
|
||
|
|
ActionExecutionResult,
|
||
|
|
TransactionExecutionState,
|
||
|
|
DataflowExecutionResult,
|
||
|
|
|
||
|
|
// 컨텍스트
|
||
|
|
ExtendedControlContext,
|
||
|
|
QuickValidationResult,
|
||
|
|
|
||
|
|
// 버튼 액션 표준
|
||
|
|
ButtonActionStandard,
|
||
|
|
ButtonActionFormData,
|
||
|
|
} from "./control-management";
|
||
|
|
|
||
|
|
// table-management에서 제공하는 주요 타입들
|
||
|
|
export type {
|
||
|
|
// 테이블 정보
|
||
|
|
TableInfo,
|
||
|
|
UnifiedColumnInfo,
|
||
|
|
ColumnTypeInfo,
|
||
|
|
ColumnSettings,
|
||
|
|
|
||
|
|
// 웹타입 표준
|
||
|
|
WebTypeStandard,
|
||
|
|
WebTypeDefinition,
|
||
|
|
|
||
|
|
// 라벨 관리
|
||
|
|
TableLabels,
|
||
|
|
ColumnLabels,
|
||
|
|
|
||
|
|
// 엔티티 조인
|
||
|
|
EntityJoinConfig,
|
||
|
|
EntityJoinResponse,
|
||
|
|
BatchLookupRequest,
|
||
|
|
BatchLookupResponse,
|
||
|
|
|
||
|
|
// 테이블 관계
|
||
|
|
TableRelationship,
|
||
|
|
DataRelationshipBridge,
|
||
|
|
|
||
|
|
// 컬럼 웹타입 설정
|
||
|
|
ColumnWebTypeSetting,
|
||
|
|
|
||
|
|
// API 응답들
|
||
|
|
TableListResponse,
|
||
|
|
ColumnListResponse,
|
||
|
|
ColumnTypeInfoResponse,
|
||
|
|
WebTypeStandardListResponse,
|
||
|
|
TableDataResponse,
|
||
|
|
} from "./table-management";
|
||
|
|
|
||
|
|
// ===== 타입 가드 함수들 통합 export =====
|
||
|
|
|
||
|
|
// unified-core 타입 가드들
|
||
|
|
export { isWebType, isButtonActionType, isComponentType, ynToBoolean, booleanToYN } from "./unified-core";
|
||
|
|
|
||
|
|
// screen-management 타입 가드들
|
||
|
|
export {
|
||
|
|
isWidgetComponent,
|
||
|
|
isContainerComponent,
|
||
|
|
isGroupComponent,
|
||
|
|
isDataTableComponent,
|
||
|
|
isFileComponent,
|
||
|
|
asWidgetComponent,
|
||
|
|
asContainerComponent,
|
||
|
|
asGroupComponent,
|
||
|
|
asDataTableComponent,
|
||
|
|
asFileComponent,
|
||
|
|
} from "./screen-management";
|
||
|
|
|
||
|
|
// control-management 타입 가드들
|
||
|
|
export {
|
||
|
|
isSingleCondition,
|
||
|
|
isGroupCondition,
|
||
|
|
isDatabaseAction,
|
||
|
|
isApiAction,
|
||
|
|
isActionSuccess,
|
||
|
|
isTransactionCompleted,
|
||
|
|
} from "./control-management";
|
||
|
|
|
||
|
|
// table-management 타입 가드들
|
||
|
|
export {
|
||
|
|
isReferenceWebType,
|
||
|
|
isNumericWebType,
|
||
|
|
isDateWebType,
|
||
|
|
isSelectWebType,
|
||
|
|
isRequiredColumn,
|
||
|
|
isSystemColumn,
|
||
|
|
mapWebTypeStandardToDefinition,
|
||
|
|
mapColumnTypeInfoToUnified,
|
||
|
|
mapUnifiedToColumnTypeInfo,
|
||
|
|
} from "./table-management";
|
||
|
|
|
||
|
|
// ===== 상수들 통합 export =====
|
||
|
|
|
||
|
|
// table-management 상수들
|
||
|
|
export { WEB_TYPE_OPTIONS } from "./table-management";
|
||
|
|
|
||
|
|
// ===== 타입 별칭 (기존 호환성) =====
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @deprecated screen.ts에서 이전하세요. unified-core.ts의 WebType을 사용하세요.
|
||
|
|
*/
|
||
|
|
export type LegacyWebType = WebType;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @deprecated screen.ts에서 이전하세요. unified-core.ts의 ButtonActionType을 사용하세요.
|
||
|
|
*/
|
||
|
|
export type LegacyButtonActionType = ButtonActionType;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @deprecated screen.ts에서 이전하세요. screen-management.ts의 ComponentData를 사용하세요.
|
||
|
|
*/
|
||
|
|
export type LegacyComponentData = ComponentData;
|
||
|
|
|
||
|
|
// ===== 유틸리티 타입들 =====
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 컴포넌트 업데이트를 위한 부분 타입
|
||
|
|
*/
|
||
|
|
export type ComponentUpdate<T extends ComponentData> = Partial<Omit<T, "id" | "type">> & {
|
||
|
|
id: string;
|
||
|
|
type: T["type"];
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* API 요청을 위한 기본 파라미터
|
||
|
|
*/
|
||
|
|
export interface BaseRequestParams {
|
||
|
|
companyCode?: CompanyCode;
|
||
|
|
page?: number;
|
||
|
|
size?: number;
|
||
|
|
sortBy?: string;
|
||
|
|
sortDirection?: "asc" | "desc";
|
||
|
|
searchTerm?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 폼 데이터 타입 (모든 시스템에서 공통 사용)
|
||
|
|
*/
|
||
|
|
export type FormData = Record<string, unknown>;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 선택된 행 데이터 타입
|
||
|
|
*/
|
||
|
|
export type SelectedRowData = Record<string, unknown>;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 테이블 데이터 타입
|
||
|
|
*/
|
||
|
|
export type TableData = Record<string, unknown>[];
|
||
|
|
|
||
|
|
// ===== 마이그레이션 도우미 =====
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 기존 screen.ts 타입을 새로운 통합 타입으로 마이그레이션하는 도우미
|
||
|
|
*/
|
||
|
|
export namespace Migration {
|
||
|
|
/**
|
||
|
|
* 기존 screen.ts의 WebType을 새로운 WebType으로 변환
|
||
|
|
*/
|
||
|
|
export const migrateWebType = (oldWebType: string): WebType => {
|
||
|
|
// 기존 타입이 새로운 WebType에 포함되어 있는지 확인
|
||
|
|
if (isWebType(oldWebType)) {
|
||
|
|
return oldWebType as WebType;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 호환되지 않는 타입의 경우 기본값 반환
|
||
|
|
console.warn(`Unknown WebType: ${oldWebType}, defaulting to 'text'`);
|
||
|
|
return "text";
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 기존 ButtonActionType을 새로운 ButtonActionType으로 변환
|
||
|
|
*/
|
||
|
|
export const migrateButtonActionType = (oldActionType: string): ButtonActionType => {
|
||
|
|
if (isButtonActionType(oldActionType)) {
|
||
|
|
return oldActionType as ButtonActionType;
|
||
|
|
}
|
||
|
|
|
||
|
|
console.warn(`Unknown ButtonActionType: ${oldActionType}, defaulting to 'submit'`);
|
||
|
|
return "submit";
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Y/N 문자열을 boolean으로 변환 (DB 호환성)
|
||
|
|
*/
|
||
|
|
export const migrateYNToBoolean = (value: string | undefined): boolean => {
|
||
|
|
return value === "Y";
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* boolean을 Y/N 문자열로 변환 (DB 호환성)
|
||
|
|
*/
|
||
|
|
export const migrateBooleanToYN = (value: boolean): string => {
|
||
|
|
return value ? "Y" : "N";
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// ===== 타입 검증 도우미 =====
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 런타임에서 타입 안전성을 보장하는 검증 함수들
|
||
|
|
*/
|
||
|
|
export namespace TypeValidation {
|
||
|
|
/**
|
||
|
|
* 객체가 BaseComponent 인터페이스를 만족하는지 검증
|
||
|
|
*/
|
||
|
|
export const validateBaseComponent = (obj: unknown): obj is BaseComponent => {
|
||
|
|
if (typeof obj !== "object" || obj === null) return false;
|
||
|
|
|
||
|
|
const component = obj as Record<string, unknown>;
|
||
|
|
return (
|
||
|
|
typeof component.id === "string" &&
|
||
|
|
typeof component.type === "string" &&
|
||
|
|
isComponentType(component.type as string) &&
|
||
|
|
typeof component.position === "object" &&
|
||
|
|
typeof component.size === "object"
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 객체가 WebTypeConfig를 만족하는지 검증
|
||
|
|
*/
|
||
|
|
export const validateWebTypeConfig = (obj: unknown): obj is WebTypeConfig => {
|
||
|
|
return typeof obj === "object" && obj !== null;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 문자열이 유효한 CompanyCode인지 검증
|
||
|
|
*/
|
||
|
|
export const validateCompanyCode = (code: unknown): code is CompanyCode => {
|
||
|
|
return typeof code === "string" && code.length > 0;
|
||
|
|
};
|
||
|
|
}
|