import { request } from '../../lib/http' import type { CastingBatchResult, CharacterCastingReadiness, ConfirmCastingResult, GenerateCastingCandidateInput, GenerateCastingCandidatesInput, GenerateIdentityImageInput, IdentityBatchResult, IdentityImage, SaveIdentityInput, SubjectIdentity } from './types' /** 身份接口使用正式 Subject ID,与形态 ID、角色表 ID 分开。 */ function identityPath(subjectId: string) { return `/subjects/${encodeURIComponent(subjectId)}/identity` } /** 身份文本和参考图分开操作;有费用的请求均不自动重试。 */ export const subjectIdentityApi = { get: (subjectId: string, signal?: AbortSignal) => request(identityPath(subjectId), { signal }), save: (subjectId: string, input: SaveIdentityInput) => request(identityPath(subjectId), { method: 'PUT', body: input }), generate: (subjectId: string, force: boolean) => request(`${identityPath(subjectId)}/generate`, { method: 'POST', body: { force }, timeoutMs: 0 }), generateProject: (projectId: string, input: { force: boolean; concurrency: number }) => request(`/projects/${encodeURIComponent(projectId)}/subject-identities/generate`, { method: 'POST', body: input, timeoutMs: 0 }), generateCharacters: (projectId: string, input: { force: boolean; concurrency: number }) => request(`/projects/${encodeURIComponent(projectId)}/character-identities/generate`, { method: 'POST', body: input, timeoutMs: 0 }), castingReadiness: (projectId: string, signal?: AbortSignal) => request(`/projects/${encodeURIComponent(projectId)}/character-casting/readiness`, { signal }), generateCastingCandidate: (subjectId: string, input: GenerateCastingCandidateInput) => request(`${identityPath(subjectId)}/casting-candidates`, { method: 'POST', body: input, timeoutMs: 0 }), generateCastingCandidates: (projectId: string, input: GenerateCastingCandidatesInput) => request( `/projects/${encodeURIComponent(projectId)}/character-casting/candidates/generate`, { method: 'POST', body: input, timeoutMs: 0 } ), listImages: (subjectId: string, signal?: AbortSignal) => request(`${identityPath(subjectId)}/images`, { signal }), generateImage: (subjectId: string, input: GenerateIdentityImageInput) => request(`${identityPath(subjectId)}/images`, { method: 'POST', body: input, timeoutMs: 0 }), setAnchor: (subjectId: string, imageId: string) => request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/anchor`, { method: 'PUT' }), confirmCasting: (subjectId: string, imageId: string) => request(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/casting`, { method: 'PUT' }) }