ERP-node/frontend/types/index.ts

344 lines
7.8 KiB
TypeScript
Raw Normal View History

/**
* 🎯 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;
};
}