/** * insta-monitor 앱의 도메인 모델(데이터 구조)입니다. * PRD(제품 요구사항 명세서) 제6조 데이터 모델을 반영합니다. */ export type PostType = 'reel' | 'post'; // 떡상(Viral) 기준: // 릴스가 업로드 후 특정 시간(DEFAULT_VIRAL_WINDOW_HOURS) 내에 // 설정된 조회수(minViews) 또는 댓글 수(minComments)에 도달하면 떡상으로 간주합니다. export const DEFAULT_VIRAL_THRESHOLD = 1000; export const DEFAULT_VIRAL_WINDOW_HOURS = 24; export const DEFAULT_VIRAL_MIN_VIEWS = 50_000; export const DEFAULT_VIRAL_MIN_COMMENTS = 500; export interface ViralConfig { windowHours: number; minViews: number; minComments: number; } export interface Group { id: number; /** 기본 그룹명은 '미분류(uncategorized)'입니다. */ name: string; } /** * 앱에 현재 로그인된 인스타그램 계정입니다. * (아래에서 추적하는 '계정들'과는 다른 개념입니다.) * 수집기(collector)의 whoami 기능을 통해 로그인 후 획득합니다. */ export interface IgAccount { username: string; fullName: string | null; avatarUrl: string | null; } /** 추적 중인 인스타그램 계정 정보를 담는 객체 */ export interface Account { id: number; username: string; displayName: string | null; followerCount: number; postCount: number; groupId: number | null; autoCollect: boolean; /** 일일 수집 우선순위(최근 1일/7일 지표). 최대 100개 채널까지만 제한됩니다. */ priority: boolean; /** 마지막 성공적인 수집 시간(ISO-8601). */ lastCollectedAt: string | null; /** * 깊은 백필(Deep-backfill) 상태: * 'pending'(대기) -> 'done'(완료) -> 'unavailable'(연속 실패) * -> 'not_found'(계정 삭제/이름 변경) -> 'private'(비공개 계정) */ backfillState: 'pending' | 'done' | 'unavailable' | 'not_found' | 'private'; /** 마지막 '가벼운 새로고침(Light refresh)' 시도 시간. */ lastRefreshAt: string | null; /** 데이터를 성공적으로 가져온 마지막 시간. */ lastSuccessAt: string | null; /** 연속 실패 횟수 (성공 시 0으로 초기화). */ consecutiveFailures: number; /** 마지막 에러 발생 이유. */ lastError: string | null; } /** 개별 게시물(Post) 정보 */ export interface Post { id: number; accountId: number; /** 인스타그램 숏코드 (URL 주소 뒤에 붙는 고유 식별자). */ shortcode: string; type: PostType; url: string; thumbnail: string | null; caption: string | null; /** 게시물 업로드 시간(ISO-8601). */ uploadedAt: string; viewCount: number | null; isBenchmark: boolean; /** 음성에서 추출한 스크립트(STT) 데이터. 아직 추출 전이면 null. */ scriptText: string | null; } /** * 게시물별 하루 한 번의 스냅샷 데이터. * 이 시계열 데이터가 앱의 핵심 자산입니다. * 모든 성장 지표(1일/7일 증가량)는 이 데이터의 차이값에서 나옵니다. */ export interface DailyStat { postId: number; /** 로컬 날짜, 'YYYY-MM-DD'. */ date: string; commentCount: number; /** 전일 대비 댓글 증감량 (첫 데이터는 null). */ commentDelta: number | null; /** 좋아요/조회수 스냅샷 및 증감량 (데이터 숨김/불가 시 null). */ likeCount: number | null; likeDelta: number | null; viewCount: number | null; viewDelta: number | null; followerCount: number | null; followerDelta: number | null; } /** 성장 계산에 필요한 최소 필드만 담은 일일 스냅샷. */ export type CommentSnapshot = Pick;