import type { PlatformType } from './platform.js';

/**
 * 发布任务状态
 */
export type PublishTaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';

/**
 * 发布结果状态
 */
export type PublishResultStatus = 'success' | 'failed';

/**
 * 平台差异化配置
 */
export interface PlatformPublishConfig {
  platform: PlatformType;
  title?: string;
  description?: string;
  tags?: string[];
  coverPath?: string;
  // 平台特有配置
  extra?: Record<string, unknown>;
}

/**
 * 发布任务
 */
export interface PublishTask {
  id: number;
  userId: number;
  videoPath: string;
  videoFilename: string;
  title: string;
  description: string | null;
  coverPath: string | null;
  tags: string[];
  targetAccounts: number[];
  platformConfigs: PlatformPublishConfig[];
  status: PublishTaskStatus;
  scheduledAt: string | null;
  publishedAt: string | null;
  createdAt: string;
  updatedAt: string;
}

/**
 * 发布结果
 */
export interface PublishResult {
  id: number;
  taskId: number;
  accountId: number;
  platform: PlatformType;
  status: PublishResultStatus;
  videoUrl: string | null;
  platformVideoId: string | null;
  errorMessage: string | null;
  publishedAt: string | null;
}

/**
 * 创建发布任务请求
 */
export interface CreatePublishTaskRequest {
  videoPath: string;
  title: string;
  description?: string;
  coverPath?: string;
  tags?: string[];
  targetAccounts: number[];
  platformConfigs?: PlatformPublishConfig[];
  scheduledAt?: string;
}

/**
 * 发布任务详情（包含结果）
 */
export interface PublishTaskDetail extends PublishTask {
  results: PublishResult[];
}

/**
 * 发布进度
 */
export interface PublishProgress {
  taskId: number;
  accountId: number;
  platform: PlatformType;
  status: 'uploading' | 'processing' | 'success' | 'failed';
  progress: number; // 0-100
  message?: string;
}
