task-16: 拆分 appearance-patent 模块 API 至 types/modules/appearance-patent.ts,java-modules.ts re-export
- parseAppearancePatent/getAppearancePatentParsedPayload/getAppearancePatentQueuePayload/getAppearancePatentDashboard/getAppearancePatentHistory/getAppearancePatentTaskProgressBatch/activateAppearancePatentTask/deleteAppearancePatentTask/deleteAppearancePatentHistory/getAppearancePatentResultDownloadUrl - appearance-patent 全套类型随模块迁移;progressBatch 内联缓存+超时实现 - 9 个测试:parse/parsedPayload/queuePayload/progressBatch/activate/dashboard/history/delete/download/export compat
This commit is contained in:
@@ -15,6 +15,7 @@ export * from "./types/modules/split.ts";
|
||||
export * from "./types/modules/convert.ts";
|
||||
export * from "./types/modules/publish.ts";
|
||||
export * from "./types/modules/similar-asin.ts";
|
||||
export * from "./types/modules/appearance-patent.ts";
|
||||
|
||||
const JAVA_API_PREFIX = "/newApi/api";
|
||||
|
||||
@@ -1668,204 +1669,6 @@ export function deleteWithdrawHistory(resultId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
// ========== 外观专利检测 ==========
|
||||
|
||||
export interface AppearancePatentParsedRow {
|
||||
rowIndex: number;
|
||||
sourceFileKey?: string;
|
||||
sourceFilename?: string;
|
||||
sourceId: string;
|
||||
displayId: string;
|
||||
rowToken?: string;
|
||||
groupKey?: string;
|
||||
asin: string;
|
||||
country: string;
|
||||
price?: string;
|
||||
sku?: string;
|
||||
url?: string;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface AppearancePatentParsedGroup {
|
||||
sourceFileKey?: string;
|
||||
sourceFilename?: string;
|
||||
groupKey?: string;
|
||||
baseId?: string;
|
||||
displayId?: string;
|
||||
itemCount?: number;
|
||||
items: AppearancePatentParsedRow[];
|
||||
}
|
||||
|
||||
export interface AppearancePatentParseVo {
|
||||
taskId: number;
|
||||
sourceFilename?: string;
|
||||
sourceFileCount?: number;
|
||||
totalRows: number;
|
||||
acceptedRows: number;
|
||||
droppedRows: number;
|
||||
groupCount?: number;
|
||||
aiPrompt?: string;
|
||||
items: AppearancePatentParsedRow[];
|
||||
groups?: AppearancePatentParsedGroup[];
|
||||
}
|
||||
|
||||
export interface AppearancePatentParsedPayloadDto {
|
||||
aiPrompt?: string;
|
||||
apiKey?: string;
|
||||
patentToken?: string;
|
||||
sourceFiles?: UploadedFileRef[];
|
||||
headers?: string[];
|
||||
items?: AppearancePatentParsedRow[];
|
||||
groups?: AppearancePatentParsedGroup[];
|
||||
allItems?: AppearancePatentParsedRow[];
|
||||
}
|
||||
|
||||
export interface AppearancePatentDashboardVo {
|
||||
pendingTaskCount: number;
|
||||
processedTaskCount: number;
|
||||
successTaskCount: number;
|
||||
failedTaskCount: number;
|
||||
}
|
||||
|
||||
export interface AppearancePatentHistoryItem {
|
||||
resultId?: number;
|
||||
taskId?: number;
|
||||
sourceFilename?: string;
|
||||
resultFilename?: string;
|
||||
downloadUrl?: string;
|
||||
fileJobId?: number;
|
||||
fileStatus?: string;
|
||||
fileError?: string;
|
||||
fileReady?: boolean;
|
||||
fileProgressPercent?: number;
|
||||
fileProgressCurrent?: number;
|
||||
fileProgressTotal?: number;
|
||||
fileProgressMessage?: string;
|
||||
taskStatus?: string;
|
||||
success?: boolean;
|
||||
error?: string;
|
||||
rowCount?: number;
|
||||
createdAt?: string;
|
||||
startedAt?: string;
|
||||
finishedAt?: string;
|
||||
}
|
||||
|
||||
export interface AppearancePatentHistoryVo {
|
||||
items: AppearancePatentHistoryItem[];
|
||||
}
|
||||
|
||||
export interface AppearancePatentTaskSummary {
|
||||
id?: number;
|
||||
taskNo?: string;
|
||||
status?: string;
|
||||
errorMessage?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
finishedAt?: string;
|
||||
}
|
||||
|
||||
export interface AppearancePatentTaskDetailVo {
|
||||
task?: AppearancePatentTaskSummary;
|
||||
items?: AppearancePatentHistoryItem[];
|
||||
}
|
||||
|
||||
export interface AppearancePatentTaskBatchVo {
|
||||
items: AppearancePatentTaskDetailVo[];
|
||||
missingTaskIds?: number[];
|
||||
}
|
||||
|
||||
export function parseAppearancePatent(files: UploadedFileRef[], aiPrompt: string, apiKey?: string, patentToken?: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<
|
||||
JavaApiResponse<AppearancePatentParseVo>,
|
||||
{ user_id: number; files: UploadedFileRef[]; ai_prompt: string; api_key?: string; patent_token?: string }
|
||||
>(`${JAVA_API_PREFIX}/appearance-patent/parse`, {
|
||||
user_id: getCurrentUserId(),
|
||||
files,
|
||||
ai_prompt: aiPrompt,
|
||||
api_key: apiKey,
|
||||
patent_token: patentToken,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentParsedPayload(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<AppearancePatentParsedPayloadDto>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/tasks/${taskId}/parsed-payload`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentQueuePayload(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<AppearancePatentParsedPayloadDto>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/tasks/${taskId}/queue-payload`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentDashboard() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<AppearancePatentDashboardVo>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/dashboard`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentHistory() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<AppearancePatentHistoryVo>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/history`,
|
||||
{ params: { user_id: getCurrentUserId(), limit: 50 } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentTaskProgressBatch(
|
||||
taskIds: number[],
|
||||
options: TaskProgressBatchOptions = {},
|
||||
) {
|
||||
return postTaskProgressBatch<AppearancePatentTaskBatchVo>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/tasks/progress/batch`,
|
||||
taskIds,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
export function activateAppearancePatentTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<null>, undefined>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/tasks/${taskId}/activate?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
||||
undefined,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteAppearancePatentTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/appearance-patent/tasks/${taskId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteAppearancePatentHistory(resultId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/history/${resultId}`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getAppearancePatentResultDownloadUrl(resultId: number) {
|
||||
return getJavaDownloadUrl(`/appearance-patent/results/${resultId}/download`);
|
||||
}
|
||||
|
||||
// ========== 跟价 ==========
|
||||
|
||||
export interface PriceTrackCandidateVo {
|
||||
|
||||
Reference in New Issue
Block a user