feat(video): add name and providerId fields to video types

Add required name and providerId fields to video interfaces and update all related implementations including mock data and hook usage. This ensures consistent video object structure across the application.
This commit is contained in:
icarus 2025-10-13 14:24:45 +08:00
parent 41041fa296
commit b68a0ffaba
3 changed files with 33 additions and 11 deletions

View File

@ -14,6 +14,8 @@ export const mockVideos: Video[] = [
prompt: 'A beautiful sunset over the ocean with waves crashing', prompt: 'A beautiful sunset over the ocean with waves crashing',
thumbnail: 'https://picsum.photos/200/200?random=1', thumbnail: 'https://picsum.photos/200/200?random=1',
fileId: 'file-001', fileId: 'file-001',
providerId: 'openai',
name: 'video-001',
metadata: { metadata: {
id: 'video-001', id: 'video-001',
object: 'video', object: 'video',
@ -35,6 +37,8 @@ export const mockVideos: Video[] = [
status: 'in_progress', status: 'in_progress',
prompt: 'A cat playing with a ball of yarn in slow motion', prompt: 'A cat playing with a ball of yarn in slow motion',
progress: 65, progress: 65,
providerId: 'openai',
name: 'video-002',
metadata: { metadata: {
id: 'video-002', id: 'video-002',
object: 'video', object: 'video',
@ -55,6 +59,8 @@ export const mockVideos: Video[] = [
type: 'openai', type: 'openai',
status: 'queued', status: 'queued',
prompt: 'Time-lapse of flowers blooming in a garden', prompt: 'Time-lapse of flowers blooming in a garden',
providerId: 'openai',
name: 'video-003',
metadata: { metadata: {
id: 'video-003', id: 'video-003',
object: 'video', object: 'video',
@ -77,6 +83,8 @@ export const mockVideos: Video[] = [
status: 'downloading', status: 'downloading',
progress: 80, progress: 80,
thumbnail: 'https://picsum.photos/200/200?random=4', thumbnail: 'https://picsum.photos/200/200?random=4',
providerId: 'openai',
name: 'video-004',
metadata: { metadata: {
id: 'video-004', id: 'video-004',
object: 'video', object: 'video',
@ -98,6 +106,8 @@ export const mockVideos: Video[] = [
status: 'failed', status: 'failed',
error: { code: '400', message: 'Video generation failed' }, error: { code: '400', message: 'Video generation failed' },
prompt: 'Mountain landscape with snow peaks and forest', prompt: 'Mountain landscape with snow peaks and forest',
providerId: 'openai',
name: 'video-005',
metadata: { metadata: {
id: 'video-005', id: 'video-005',
object: 'video', object: 'video',
@ -119,6 +129,8 @@ export const mockVideos: Video[] = [
status: 'completed', status: 'completed',
thumbnail: 'https://picsum.photos/200/200?random=6', thumbnail: 'https://picsum.photos/200/200?random=6',
prompt: 'City street at night with neon lights reflecting on wet pavement', prompt: 'City street at night with neon lights reflecting on wet pavement',
providerId: 'openai',
name: 'video-006',
metadata: { metadata: {
id: 'video-006', id: 'video-006',
object: 'video', object: 'video',

View File

@ -12,6 +12,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
case 'queued': case 'queued':
addVideo({ addVideo({
id: video.id, id: video.id,
name: video.id,
providerId,
status: video.status, status: video.status,
type: 'openai', type: 'openai',
metadata: video, metadata: video,
@ -21,6 +23,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
case 'in_progress': case 'in_progress':
addVideo({ addVideo({
id: video.id, id: video.id,
name: video.id,
providerId,
status: 'in_progress', status: 'in_progress',
type: 'openai', type: 'openai',
progress: video.progress, progress: video.progress,
@ -31,6 +35,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
case 'completed': case 'completed':
addVideo({ addVideo({
id: video.id, id: video.id,
name: video.id,
providerId,
status: 'completed', status: 'completed',
type: 'openai', type: 'openai',
metadata: video, metadata: video,
@ -41,6 +47,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
case 'failed': case 'failed':
addVideo({ addVideo({
id: video.id, id: video.id,
name: video.id,
providerId,
status: 'failed', status: 'failed',
type: 'openai', type: 'openai',
error: video.error, error: video.error,

View File

@ -7,8 +7,11 @@ export type VideoEndpointType = 'openai'
export type VideoStatus = 'queued' | 'in_progress' | 'completed' | 'downloading' | 'downloaded' | 'failed' export type VideoStatus = 'queued' | 'in_progress' | 'completed' | 'downloading' | 'downloaded' | 'failed'
interface VideoBase { interface VideoBase {
id: string readonly id: string
type: VideoEndpointType readonly type: VideoEndpointType
name: string
readonly providerId: string
prompt: string
/** /**
* Represents the possible states of a video generation or download process. * Represents the possible states of a video generation or download process.
* *
@ -19,45 +22,44 @@ interface VideoBase {
* - `downloaded`: The video has been fully downloaded and is available locally. * - `downloaded`: The video has been fully downloaded and is available locally.
* - `failed`: The video task encountered an error and could not be completed. * - `failed`: The video task encountered an error and could not be completed.
*/ */
status: VideoStatus readonly status: VideoStatus
prompt: string
} }
interface OpenAIVideoBase { interface OpenAIVideoBase {
type: 'openai' readonly type: 'openai'
metadata: OpenAI.Videos.Video metadata: OpenAI.Videos.Video
} }
export interface VideoQueued extends VideoBase { export interface VideoQueued extends VideoBase {
status: 'queued' readonly status: 'queued'
} }
export interface VideoInProgress extends VideoBase { export interface VideoInProgress extends VideoBase {
status: 'in_progress' readonly status: 'in_progress'
/** integer percent */ /** integer percent */
progress: number progress: number
} }
export interface VideoCompleted extends VideoBase { export interface VideoCompleted extends VideoBase {
status: 'completed' readonly status: 'completed'
/** When generation completed, firstly try to retrieve thumbnail. */ /** When generation completed, firstly try to retrieve thumbnail. */
thumbnail: string | null thumbnail: string | null
} }
export interface VideoDownloading extends VideoBase { export interface VideoDownloading extends VideoBase {
status: 'downloading' readonly status: 'downloading'
thumbnail: string thumbnail: string
/** integer percent */ /** integer percent */
progress: number progress: number
} }
export interface VideoDownloaded extends VideoBase { export interface VideoDownloaded extends VideoBase {
status: 'downloaded' readonly status: 'downloaded'
thumbnail: string thumbnail: string
/** Managed by fileManager */ /** Managed by fileManager */
fileId: string fileId: string
} }
export interface VideoFailedBase extends VideoBase { export interface VideoFailedBase extends VideoBase {
status: 'failed' readonly status: 'failed'
error: unknown error: unknown
} }