API契约:收口回复规则与账号任务响应
This commit is contained in:
1 parent
fe6fc3adb9
commit
f76fb08cbe
9 files changed
+535
-60
No files matched your search
+14
-14
@@ -3,8 +3,8 @@ import {
|
||||
LoginResponse, AccountDetail, AccountSummaryResponse, Order, PaginatedResponse,
|
||||
AdminStats, DashboardStats, Card, SystemSettings, ApiResponse, OrderAnalytics,
|
||||
Item, AIReplySettings, ShippingRule, ReplyRule, DefaultReply, AutomationAction, AutomationTriggerType,
|
||||
NotificationChannel, NotificationEventType, AccountTaskSettings, AccountTaskSummary, ChatSession, ChatMessage,
|
||||
CookieSettingsResponse, CookieProfileResponse, ItemPublishResponse, ItemSyncResponse, OrderDTOResponse, OrderDetailResponse, OrderSingleRefreshResponse, OrderBatchResponse, AutomationRuleResponse, AutomationRulePageResponse, AIReplySettingsResponse, AIModelsResponse, UserSettingResponse, CardBatchResponse, CardAppendResponse, CategoryRecommendationResponse, ItemPublishBatchPreviewResponse, ItemPublishBatchListResponse, BatchIDResponse, ItemPublishBatchResponse, BatchCancelResponse, MutationIDResponse, OperationResponse, NotificationChannelResponse, NotificationBinding, AccountBindingsResponse, CardListResponse
|
||||
NotificationChannel, NotificationEventType, AccountTaskSettings, ChatSession, ChatMessage,
|
||||
CookieSettingsResponse, CookieProfileResponse, ItemPublishResponse, ItemSyncResponse, OrderDTOResponse, OrderDetailResponse, OrderSingleRefreshResponse, OrderBatchResponse, AutomationRuleResponse, AutomationRulePageResponse, AIReplySettingsResponse, AIModelsResponse, UserSettingResponse, CardBatchResponse, CardAppendResponse, CategoryRecommendationResponse, ItemPublishBatchPreviewResponse, ItemPublishBatchListResponse, BatchIDResponse, ItemPublishBatchResponse, BatchCancelResponse, MutationIDResponse, OperationResponse, NotificationChannelResponse, NotificationBinding, AccountBindingsResponse, CardListResponse, KeywordTypedResponse, DefaultReplyResponse, AccountTaskSettingsResponse, AccountTaskRunResponseEnvelope
|
||||
} from '../types';
|
||||
import { formatLocalDate } from '../dateRange';
|
||||
|
||||
@@ -97,13 +97,13 @@ export const getAccountDetails = async (options?: RequestControlOptions): Promis
|
||||
}));
|
||||
};
|
||||
|
||||
export const getAccountTaskSettings = async (id: string): Promise<AccountTaskSettings> =>
|
||||
export const getAccountTaskSettings = async (id: string): Promise<AccountTaskSettingsResponse> =>
|
||||
get(`/api/account-tasks/${id}`);
|
||||
|
||||
export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings): Promise<AccountTaskSettings> =>
|
||||
export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings): Promise<AccountTaskSettingsResponse> =>
|
||||
put(`/api/account-tasks/${id}`, settings);
|
||||
|
||||
export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish'): Promise<{success: boolean; summary: AccountTaskSummary}> =>
|
||||
export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish'): Promise<AccountTaskRunResponseEnvelope> =>
|
||||
post(`/api/account-tasks/${id}/run`, { task_type: taskType }, { timeoutMs: 120_000 });
|
||||
|
||||
export interface ChatSessionPage { sessions: ChatSession[]; has_more: boolean; next_cursor?: number }
|
||||
@@ -841,7 +841,7 @@ const normalizeKeywordRow = (item: any): KeywordRowPayload => ({
|
||||
});
|
||||
|
||||
const getKeywordRowsWithType = async (cookieId: string): Promise<KeywordRowPayload[]> => {
|
||||
const existing = await get<any>(`/keywords-with-type/${cookieId}`);
|
||||
const existing = await get<KeywordTypedResponse[]>(`/keywords-with-type/${cookieId}`);
|
||||
return Array.isArray(existing) ? existing.map(normalizeKeywordRow) : [];
|
||||
};
|
||||
|
||||
@@ -860,7 +860,7 @@ export const getReplyRules = async (cookieId?: string): Promise<ReplyRule[]> =>
|
||||
}));
|
||||
}
|
||||
|
||||
export const updateReplyRule = async (rule: Partial<ReplyRule>, cookieId: string): Promise<any> => {
|
||||
export const updateReplyRule = async (rule: Partial<ReplyRule>, cookieId: string): Promise<OperationResponse> => {
|
||||
const type = rule.type || 'text';
|
||||
const payload = {
|
||||
keyword: rule.keyword || '',
|
||||
@@ -874,7 +874,7 @@ export const updateReplyRule = async (rule: Partial<ReplyRule>, cookieId: string
|
||||
: post(`/keywords-with-item-id/${cookieId}`, payload);
|
||||
}
|
||||
|
||||
export const deleteReplyRule = async (id: string, cookieId: string): Promise<any> => {
|
||||
export const deleteReplyRule = async (id: string, cookieId: string): Promise<OperationResponse> => {
|
||||
return del(`/keywords-with-type/${cookieId}/${id}`);
|
||||
}
|
||||
|
||||
@@ -1025,12 +1025,12 @@ export const testNotificationChannel = async (channelId: string): Promise<Operat
|
||||
}
|
||||
|
||||
// Default Reply
|
||||
export const getDefaultReplies = async (): Promise<Record<string, DefaultReply>> => {
|
||||
return get('/api/default-replies');
|
||||
export const getDefaultReplies = async (): Promise<Record<string, DefaultReplyResponse>> => {
|
||||
return get('/api/default-replies');
|
||||
};
|
||||
|
||||
export const getDefaultReply = async (cookieId: string): Promise<DefaultReply> => {
|
||||
const result = await get<any>(`/api/default-reply/${cookieId}`);
|
||||
const result = await get<DefaultReplyResponse>(`/api/default-reply/${cookieId}`);
|
||||
return {
|
||||
cookie_id: cookieId,
|
||||
enabled: result.enabled || false,
|
||||
@@ -1040,7 +1040,7 @@ export const getDefaultReply = async (cookieId: string): Promise<DefaultReply> =
|
||||
};
|
||||
};
|
||||
|
||||
export const updateDefaultReply = async (cookieId: string, data: Partial<DefaultReply>): Promise<ApiResponse> => {
|
||||
export const updateDefaultReply = async (cookieId: string, data: Partial<DefaultReply>): Promise<OperationResponse> => {
|
||||
return put(`/api/default-reply/${cookieId}`, {
|
||||
enabled: data.enabled ?? false,
|
||||
reply_content: data.reply_content || '',
|
||||
@@ -1049,10 +1049,10 @@ export const updateDefaultReply = async (cookieId: string, data: Partial<Default
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteDefaultReply = async (cookieId: string): Promise<ApiResponse> => {
|
||||
export const deleteDefaultReply = async (cookieId: string): Promise<OperationResponse> => {
|
||||
return del(`/api/default-reply/${cookieId}`);
|
||||
};
|
||||
|
||||
export const clearDefaultReplyRecords = async (cookieId: string): Promise<ApiResponse> => {
|
||||
export const clearDefaultReplyRecords = async (cookieId: string): Promise<OperationResponse> => {
|
||||
return post(`/api/default-reply/${cookieId}/clear-records`, {});
|
||||
};
|
||||
@@ -966,3 +966,113 @@ export interface CardListResponse {
|
||||
/** 当前用户卡券列表。 */
|
||||
cards: Card[];
|
||||
}
|
||||
|
||||
/** 传统关键词列表项响应。 */
|
||||
export interface KeywordBasicResponse {
|
||||
/** 匹配关键词。 */
|
||||
keyword: string;
|
||||
/** 文字回复内容。 */
|
||||
reply: string;
|
||||
}
|
||||
|
||||
/** 带商品范围的关键词列表项响应。 */
|
||||
export interface KeywordItemResponse extends KeywordBasicResponse {
|
||||
/** 限定的商品标识。 */
|
||||
item_id: string;
|
||||
}
|
||||
|
||||
/** 带类型和主键的关键词列表项响应。 */
|
||||
export interface KeywordTypedResponse extends KeywordItemResponse {
|
||||
/** 关键词规则主键。 */
|
||||
id: number;
|
||||
/** 回复类型。 */
|
||||
type: 'text' | 'image';
|
||||
/** 图片回复地址。 */
|
||||
image_url: string;
|
||||
}
|
||||
|
||||
/** 指定商品回复项响应。 */
|
||||
export interface ItemReplyResponse {
|
||||
/** 商品平台标识。 */
|
||||
item_id?: string;
|
||||
/** 账号稳定标识。 */
|
||||
cookie_id?: string;
|
||||
/** 指定商品的回复内容。 */
|
||||
reply_content: string;
|
||||
}
|
||||
|
||||
/** 默认回复查询响应。 */
|
||||
export interface DefaultReplyResponse extends DefaultReply {
|
||||
/** 账号稳定标识。 */
|
||||
cookie_id: string;
|
||||
}
|
||||
|
||||
/** 账号任务设置响应。 */
|
||||
export interface AccountTaskSettingsResponse {
|
||||
/** 账号稳定标识。 */
|
||||
account_id: string;
|
||||
/** 是否启用自动评价。 */
|
||||
auto_rate_enabled: boolean;
|
||||
/** 自动评价文案。 */
|
||||
rate_content: string;
|
||||
/** 是否启用自动擦亮。 */
|
||||
auto_polish_enabled: boolean;
|
||||
/** 自动擦亮本地时间。 */
|
||||
polish_time: string;
|
||||
/** 最近一次评价扫描时间。 */
|
||||
last_rate_scan_at: number;
|
||||
/** 最近一次擦亮日期。 */
|
||||
last_polish_date: string;
|
||||
/** 最近一次擦亮时间。 */
|
||||
last_polish_at: number;
|
||||
}
|
||||
|
||||
/** 账号任务执行记录响应。 */
|
||||
export interface AccountTaskRunResponse {
|
||||
/** 任务执行记录主键。 */
|
||||
id: number;
|
||||
/** 任务幂等键。 */
|
||||
run_key: string;
|
||||
/** 账号稳定标识。 */
|
||||
account_id: string;
|
||||
/** 任务类型。 */
|
||||
task_type: string;
|
||||
/** 任务目标标识。 */
|
||||
target_id: string;
|
||||
/** 任务业务日期。 */
|
||||
run_date: string;
|
||||
/** 任务执行状态。 */
|
||||
status: string;
|
||||
/** 任务成功数量。 */
|
||||
success_count: number;
|
||||
/** 任务失败数量。 */
|
||||
failed_count: number;
|
||||
/** 任务失败说明。 */
|
||||
error_message: string;
|
||||
/** 下一次重试时间。 */
|
||||
next_retry_at: number;
|
||||
/** 任务开始时间。 */
|
||||
started_at: number;
|
||||
/** 任务完成时间。 */
|
||||
finished_at: number;
|
||||
}
|
||||
|
||||
/** 账号任务执行记录列表响应。 */
|
||||
export interface AccountTaskRunsResponse {
|
||||
/** 当前账号的任务执行记录。 */
|
||||
runs: AccountTaskRunResponse[];
|
||||
}
|
||||
|
||||
/** 手动执行账号任务的统计响应。 */
|
||||
export interface AccountTaskSummaryResponse extends AccountTaskSummary {
|
||||
/** 任务结果说明。 */
|
||||
message?: string;
|
||||
}
|
||||
|
||||
/** 手动执行账号任务的成功响应。 */
|
||||
export interface AccountTaskRunResponseEnvelope {
|
||||
/** 任务请求是否成功完成。 */
|
||||
success: boolean;
|
||||
/** 账号任务执行统计。 */
|
||||
summary: AccountTaskSummaryResponse;
|
||||
}
|
||||
Reference in new issue
Block a user