/**
 * 视频发布模块 - 类型定义
 */

/** 平台类型 */
export type PublishPlatform = 'douyin' | 'kuaishou' | 'bilibili';

/** 发布状态 */
export type PublishStatus = 'pending' | 'uploading' | 'success' | 'failed';

/** 平台账号信息 */
export interface PlatformAccount {
  id?: number;
  userId?: number;
  platform: PublishPlatform;
  cookies: string;        // 登录 Cookie
  headers: string;        // 关键请求头（User-Agent 等）
  nickname?: string;       // 账号昵称
  avatar?: string;         // 账号头像
  isValid: boolean;       // 凭证是否有效
  expireTime?: Date;       // 过期时间
  createdAt?: Date;
  updatedAt?: Date;
}

/** 发布任务 */
export interface PublishTask {
  id?: number;
  userId?: number;
  videoProjectId: number;
  videoUrl: string;        // 视频文件路径
  platform: PublishPlatform;
  title: string;           // 视频标题
  description?: string;    // 视频描述
  tags?: string[];         // 话题标签
  coverUrl?: string;       // 封面图
  status: PublishStatus;
  errorMsg?: string;
  publishedUrl?: string;   // 发布后获得的链接
  createdAt?: Date;
  updatedAt?: Date;
}

/** 创建发布任务的请求 */
export interface CreatePublishTaskRequest {
  videoProjectId: number;
  platform: PublishPlatform;
  title: string;
  description?: string;
  tags?: string[];
  coverUrl?: string;
}

/** 抖音上传响应 */
export interface DouyinUploadResponse {
  success: boolean;
  awemeId?: string;       // 抖音作品ID
  awemeUrl?: string;       // 作品链接
  error?: string;
}

/** 抖音登录信息 */
export interface DouyinLoginInfo {
  cookies: string;
  headers: Record<string, string>;
  nickname: string;
  avatar: string;
}

/** Prisma 模型扩展类型 */
export type PlatformAccountResponse = PlatformAccount & {
  cookies: string;
  headers: string;
  tags?: string[];
}

export type PublishTaskResponse = PublishTask & {
  tags?: string[];
}
