task-23: 拆分 image-video / brand / permission / digital-human 模块 API 至 types/modules/,旧文件转 re-export 存根
This commit is contained in:
@@ -22,6 +22,10 @@ export * from "./types/modules/shop-match.ts";
|
||||
export * from "./types/modules/query-asin.ts";
|
||||
export * from "./types/modules/withdraw.ts";
|
||||
export * from "./types/modules/collect-data.ts";
|
||||
export * from "./types/modules/image-video.ts";
|
||||
export * from "./types/modules/brand.ts";
|
||||
export * from "./types/modules/permission.ts";
|
||||
export * from "./types/modules/digital-human.ts";
|
||||
import type {
|
||||
ProductRiskCandidateVo,
|
||||
ProductRiskDashboardVo,
|
||||
@@ -166,274 +170,6 @@ export async function uploadTempFileToJava(
|
||||
}
|
||||
|
||||
|
||||
// ========== 视频复刻 / 图生视频 ==========
|
||||
|
||||
export interface ImageVideoDouyinCopyVo {
|
||||
recognizedContent?: string;
|
||||
scriptDraft?: string;
|
||||
executeId?: string;
|
||||
debugUrl?: string;
|
||||
}
|
||||
|
||||
export interface ImageVideoDouyinCopyPayload {
|
||||
url: string;
|
||||
api_key?: string;
|
||||
t8_key?: string;
|
||||
duration?: number;
|
||||
proc_info?: {
|
||||
type: string;
|
||||
name: string;
|
||||
proc_image: string[];
|
||||
properties: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ImageVideoSecretStatusVo {
|
||||
userId?: number;
|
||||
configured?: boolean;
|
||||
valid?: boolean;
|
||||
expired?: boolean;
|
||||
hasCopyApiKey?: boolean;
|
||||
hasT8Key?: boolean;
|
||||
hasT8VideoKey?: boolean;
|
||||
hasVoiceApiKey?: boolean;
|
||||
hasVoiceGroupId?: boolean;
|
||||
copyApiKeyMasked?: string;
|
||||
t8KeyMasked?: string;
|
||||
t8VideoKeyMasked?: string;
|
||||
voiceApiKeyMasked?: string;
|
||||
voiceGroupIdMasked?: string;
|
||||
expireDays?: number;
|
||||
expiresAt?: string;
|
||||
}
|
||||
|
||||
export interface ImageVideoSecretSavePayload {
|
||||
copyApiKey?: string;
|
||||
t8Key?: string;
|
||||
t8VideoKey?: string;
|
||||
voiceApiKey?: string;
|
||||
voiceGroupId?: string;
|
||||
expireDays: number;
|
||||
}
|
||||
|
||||
export interface ImageVideoWorkflowParameters {
|
||||
api_key_info: {
|
||||
t8star_key: string;
|
||||
t8_video_key: string;
|
||||
ai_conductor_key: string;
|
||||
};
|
||||
bg_info: {
|
||||
type: number;
|
||||
prompt: string;
|
||||
bg_image: string;
|
||||
};
|
||||
face_info: {
|
||||
type: number;
|
||||
model_figure: string;
|
||||
model_image: string[];
|
||||
};
|
||||
proc_info: {
|
||||
type: string;
|
||||
name: string;
|
||||
proc_image: string[];
|
||||
properties: string;
|
||||
};
|
||||
text_info: {
|
||||
type: number;
|
||||
language: string;
|
||||
text: string;
|
||||
file_url: string;
|
||||
};
|
||||
audio_info: {
|
||||
audio_url: string;
|
||||
type: number;
|
||||
bgm_url: string;
|
||||
mode: number;
|
||||
voice_name: string;
|
||||
};
|
||||
video_info: {
|
||||
video_url: string;
|
||||
share_url: string;
|
||||
ref_video_mode: string;
|
||||
mode: string;
|
||||
draft: boolean;
|
||||
model: string;
|
||||
prompt: string;
|
||||
ratio: string;
|
||||
resolution: string;
|
||||
duration: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ImageVideoWorkflowResponse {
|
||||
code?: number;
|
||||
msg?: string;
|
||||
data?: string;
|
||||
execute_id?: string;
|
||||
debug_url?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export type ImageVideoAsyncTaskStatus = 'PENDING' | 'RUNNING' | 'WAITING' | 'POLLING' | 'SUCCESS' | 'FAILED'
|
||||
|
||||
export interface ImageVideoAsyncTaskVo {
|
||||
taskId: number;
|
||||
taskType: string;
|
||||
status: ImageVideoAsyncTaskStatus;
|
||||
cozeExecuteId?: string;
|
||||
cozeStatus?: string;
|
||||
debugUrl?: string;
|
||||
result?: unknown;
|
||||
errorMessage?: string;
|
||||
submittedAt?: string;
|
||||
completedAt?: string;
|
||||
}
|
||||
|
||||
export interface ImageVideoMediaUploadVo {
|
||||
url: string;
|
||||
objectKey: string;
|
||||
originalFilename: string;
|
||||
mediaType: "image" | "video" | "audio" | string;
|
||||
}
|
||||
|
||||
export interface ImageVideoVoiceWorkflowResponse {
|
||||
code?: number;
|
||||
msg?: string;
|
||||
data?: unknown;
|
||||
execute_id?: string;
|
||||
debug_url?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ImageVideoWorkflowRunRequest {
|
||||
userId: number;
|
||||
parameters: ImageVideoWorkflowParameters;
|
||||
}
|
||||
|
||||
export interface ImageVideoWorkflowResultRequest {
|
||||
userId: number;
|
||||
executeId: string;
|
||||
}
|
||||
|
||||
export function getImageVideoSecretStatus() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ImageVideoSecretStatusVo>>(
|
||||
`${JAVA_API_PREFIX}/image-video/secrets`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function saveImageVideoSecrets(payload: ImageVideoSecretSavePayload) {
|
||||
return unwrapJavaResponse(
|
||||
put<JavaApiResponse<ImageVideoSecretStatusVo>, ImageVideoSecretSavePayload & { userId: number }>(
|
||||
`${JAVA_API_PREFIX}/image-video/secrets`,
|
||||
{ ...payload, userId: getCurrentUserId() },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function runImageVideoDouyinCopy(payload: ImageVideoDouyinCopyPayload) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, ImageVideoDouyinCopyPayload & { userId: number }>(
|
||||
`${JAVA_API_PREFIX}/image-video/douyin-copy`,
|
||||
{ userId: getCurrentUserId(), ...payload },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function runImageVideoWorkflow(parameters: ImageVideoWorkflowParameters) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, ImageVideoWorkflowRunRequest>(
|
||||
`${JAVA_API_PREFIX}/image-video/workflow/run`,
|
||||
{ userId: getCurrentUserId(), parameters },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getImageVideoWorkflowResult(executeId: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, ImageVideoWorkflowResultRequest>(
|
||||
`${JAVA_API_PREFIX}/image-video/workflow/result`,
|
||||
{ userId: getCurrentUserId(), executeId },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getImageVideoAsyncTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ImageVideoAsyncTaskVo>>(
|
||||
`${JAVA_API_PREFIX}/image-video/tasks/${taskId}`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function uploadImageVideoMedia(file: File) {
|
||||
const response = await uploadTempFileToJava(file, {
|
||||
uploadToOss: true,
|
||||
moduleType: "IMAGE_VIDEO",
|
||||
});
|
||||
if (!response.success) {
|
||||
throw new Error(response.message || "请求失败");
|
||||
}
|
||||
const data = response.data;
|
||||
if (!data?.url || !data.objectKey) {
|
||||
throw new Error("OSS 上传未返回有效 URL");
|
||||
}
|
||||
return {
|
||||
url: data.url,
|
||||
objectKey: data.objectKey,
|
||||
originalFilename: data.originalFilename || file.name,
|
||||
mediaType: data.mediaType || resolveImageVideoMediaType(file),
|
||||
} as ImageVideoMediaUploadVo;
|
||||
}
|
||||
|
||||
function resolveImageVideoMediaType(file: File) {
|
||||
const type = (file.type || "").toLowerCase();
|
||||
const name = (file.name || "").toLowerCase();
|
||||
if (type.startsWith("image/") || /\.(png|jpe?g|webp|gif|bmp|svg)$/.test(name)) return "image";
|
||||
if (type.startsWith("video/") || /\.(mp4|mov|webm|m4v|ogg|avi|mkv)$/.test(name)) return "video";
|
||||
if (type.startsWith("audio/") || /\.(mp3|wav|m4a|aac|flac)$/.test(name)) return "audio";
|
||||
return "file";
|
||||
}
|
||||
|
||||
export function listImageVideoVoices(name = "") {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, { userId: number; name: string }>(
|
||||
`${JAVA_API_PREFIX}/image-video/voice/list`,
|
||||
{ userId: getCurrentUserId(), name },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteImageVideoVoice(voiceId: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, { userId: number; voiceId: string }>(
|
||||
`${JAVA_API_PREFIX}/image-video/voice/delete`,
|
||||
{ userId: getCurrentUserId(), voiceId },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function cloneImageVideoVoice(payload: { name?: string; audioUrl?: string; videoUrl?: string }) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, { userId: number; name?: string; audioUrl?: string; videoUrl?: string }>(
|
||||
`${JAVA_API_PREFIX}/image-video/voice/clone`,
|
||||
{ userId: getCurrentUserId(), ...payload },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function synthesizeImageVideoVoice(payload: { text: string; voiceId: string }) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ImageVideoAsyncTaskVo>, { userId: number; text: string; voiceId: string }>(
|
||||
`${JAVA_API_PREFIX}/image-video/voice/synthesis`,
|
||||
{ userId: getCurrentUserId(), ...payload },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getJavaDownloadUrl(path: string) {
|
||||
let raw =
|
||||
path.startsWith("http://") || path.startsWith("https://")
|
||||
|
||||
Reference in New Issue
Block a user