import { request } from '../../lib/http' import type { EpisodeDirections, EpisodeVisualStates, PromptBatchResult, ShotPromptResult, ShotReferences, StoryboardBatchInput, StoryboardBatchResult, StoryboardShotRegenerationResult, VisualStateBatchInput } from './types' import type { ShotGenerationSpec } from './generation-spec.types' /** 项目路径编码集中处理,所有 storyboard 接口以 /api 为前缀。 */ function projectPath(id: string) { return `/projects/${encodeURIComponent(id)}` } /** 正式 Shot ID 必须来自数据库 GET,不使用 checkpoint 中的编号替代。 */ function shotPath(id: string) { return `/storyboard-shots/${encodeURIComponent(id)}` } /** Storyboard 正式路由契约;测试路由不暴露为前端生产入口。 */ export const storyboardApi = { /** 强制重生成指定单集的镜头拆解;后端校验通过后才覆盖正式 Storyboard。 */ regenerateEpisodeShots: (id: string, episodeNo: number) => request(`${projectPath(id)}/storyboard-shots/regenerate`, { method: 'POST', body: { episodeNo }, timeoutMs: 0 }), directions: (id: string, episodeNo: number, signal?: AbortSignal) => request(`${projectPath(id)}/storyboard-directions?episodeNo=${episodeNo}`, { signal }), visualStates: (id: string, episodeNo: number, signal?: AbortSignal) => request(`${projectPath(id)}/storyboard-visual-states?episodeNo=${episodeNo}`, { signal }), generateDirections: (id: string, input: StoryboardBatchInput) => request(`${projectPath(id)}/storyboard-directions/generate`, { method: 'POST', body: input, timeoutMs: 0 }), generateVisualStates: (id: string, input: VisualStateBatchInput) => request(`${projectPath(id)}/storyboard-visual-states/generate`, { method: 'POST', body: input, timeoutMs: 0 }), references: (id: string, signal?: AbortSignal) => request(`${shotPath(id)}/references`, { signal }), generationSpec: (id: string, signal?: AbortSignal) => request(`${shotPath(id)}/generation-spec`, { signal }), /** 只读获取已保存的视频提示词,不要求首帧已就绪。 */ videoPrompt: (id: string, signal?: AbortSignal) => request(`${shotPath(id)}/video-prompt`, { signal }), generatePrompt: (id: string, force: boolean) => request(`${shotPath(id)}/video-prompt`, { method: 'POST', body: { force }, timeoutMs: 0 }), generatePrompts: (id: string, input: StoryboardBatchInput) => request(`${projectPath(id)}/video-prompts/generate`, { method: 'POST', body: input, timeoutMs: 0 }) }