62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import apiClient from './client';
|
|
|
|
export interface GenerationTaskItem {
|
|
id: string;
|
|
workspace_id: string;
|
|
project_id: string;
|
|
asset_library_id: string;
|
|
strategy_id?: string | null;
|
|
voice_library_id?: string | null;
|
|
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
progress: number;
|
|
result_count: number;
|
|
error_message?: string | null;
|
|
}
|
|
|
|
export interface GeneratedVideoItem {
|
|
id: string;
|
|
workspace_id: string;
|
|
project_id: string;
|
|
generation_task_id: string;
|
|
name: string;
|
|
file_url: string;
|
|
file_size: number;
|
|
duration: number;
|
|
thumbnail_url?: string | null;
|
|
width: number;
|
|
height: number;
|
|
fps: number;
|
|
}
|
|
|
|
export const createGenerationTask = async (data: {
|
|
workspace_id: string;
|
|
project_id: string;
|
|
asset_library_id: string;
|
|
strategy_id?: string;
|
|
voice_library_id?: string;
|
|
created_by_user_id?: string;
|
|
}): Promise<GenerationTaskItem> => {
|
|
const response = await apiClient.post('/generation/tasks', data);
|
|
return response.data;
|
|
};
|
|
|
|
export const getGenerationTask = async (taskId: string): Promise<GenerationTaskItem> => {
|
|
const response = await apiClient.get(`/generation/tasks/${taskId}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const getGenerationResults = async (taskId: string): Promise<GeneratedVideoItem[]> => {
|
|
const response = await apiClient.get(`/generation/tasks/${taskId}/results`);
|
|
return response.data.items;
|
|
};
|
|
|
|
export const getGeneratedVideos = async (projectId: string): Promise<GeneratedVideoItem[]> => {
|
|
const response = await apiClient.get('/generated-videos', { params: { project_id: projectId } });
|
|
return response.data.items;
|
|
};
|
|
|
|
export const getGeneratedVideoDownloadUrl = async (videoId: string): Promise<string> => {
|
|
const response = await apiClient.get(`/generated-videos/${videoId}/download-url`);
|
|
return response.data.download_url;
|
|
};
|