阶段六:完成生成契约迁移并永久关闭旁路

This commit is contained in:
Christ committed 2026-08-20 03:48:33 +08:00
1 parent 5675f60e52
commit 76f4e2e87d
117 files changed
+5833 -2204

No files matched your search

@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,AccountTaskSettingsResponse } from '../../../shared/api-contract/accounts';
import type { AccountDetail,AccountTaskSettingsResponse } from './api';
import { getAccountTaskSettings,runAccountTask,updateAccountTaskSettings } from './accountAutomationApi';
import { useAccountAutomation } from './accountAutomationHooks';
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { AccountDetail } from '../../../shared/api-contract/accounts';
import type { AccountDetail } from './api';
import { buildAccountTaskDefaults,canStartAccountTask,isCurrentAccountTaskRequest } from './accountAutomationState';
// accountFixture 是覆盖任务默认值和账号禁用边界的最小账号数据。
+5 -5
View File
@@ -13,11 +13,11 @@ NotificationChannelResponse,
NotificationEventType,
OperationResponse,
QRLoginGenerateResponse,QRLoginStatusResponse,QRLoginVerificationResponse
} from '../../../shared/api-contract/accounts';
} from './models';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { type RequestControlOptions } from '../../../shared/http/client';
import { collectionFrom,objectFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/accounts';
export type * from './models';
// QRLoginStatusResult 描述账号 feature 消费的非敏感二维码状态字段。
export type QRLoginStatusResult = Pick<
@@ -88,15 +88,15 @@ export const getAccountDetails = async (options?: RequestControlOptions): Promis
// getAccountTaskSettings 读取账号计划任务设置。
export const getAccountTaskSettings = async (id: string, options?: RequestControlOptions): Promise<AccountTaskSettingsResponse> =>
runContractRequest(/* signal 控制账号计划任务读取的取消和超时。 */ signal => contractClient.GET('/api/v1/account-tasks/{cid}', { params: { path: { cid: id } }, signal }), options) as unknown as Promise<AccountTaskSettingsResponse>;
runContractRequest(/* signal 控制账号计划任务读取的取消和超时。 */ signal => contractClient.GET('/api/v1/account-tasks/{cid}', { params: { path: { cid: id } }, signal }), options);
// updateAccountTaskSettings 更新账号计划任务设置。
export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings, options?: RequestControlOptions): Promise<AccountTaskSettingsResponse> =>
runContractRequest(/* signal 控制账号计划任务更新的取消和超时。 */ signal => contractClient.PUT('/api/v1/account-tasks/{cid}', { params: { path: { cid: id } }, body: settings as never, signal }), options) as unknown as Promise<AccountTaskSettingsResponse>;
runContractRequest(/* signal 控制账号计划任务更新的取消和超时。 */ signal => contractClient.PUT('/api/v1/account-tasks/{cid}', { params: { path: { cid: id } }, body: settings, signal }), options);
// runAccountTask 立即执行账号计划任务。
export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish', options?: RequestControlOptions): Promise<AccountTaskRunResponseEnvelope> =>
runContractRequest(/* signal 控制账号计划任务立即执行的取消和长超时。 */ signal => contractClient.POST('/api/v1/account-tasks/{cid}/run', { params: { path: { cid: id } }, body: { task_type: taskType } as never, signal }), { timeoutMs: 120_000, ...options }) as unknown as Promise<AccountTaskRunResponseEnvelope>;
runContractRequest(/* signal 控制账号计划任务立即执行的取消和长超时。 */ signal => contractClient.POST('/api/v1/account-tasks/{cid}/run', { params: { path: { cid: id } }, body: { task_type: taskType }, signal }), { timeoutMs: 120_000, ...options });
export interface AccountRuntimeStatus {
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { cleanup,fireEvent,render,screen } from '@testing-library/react';
import { afterEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,AIReplySettings } from '../../../../shared/api-contract/accounts';
import type { AccountDetail,AIReplySettings } from '../api';
import { AccountAISettingsModal } from './AccountAISettingsModal';
import { AccountCard } from './AccountCard';
import { AccountDeleteDialog } from './AccountDeleteDialog';
@@ -2,7 +2,7 @@
import { renderHook,waitFor } from '@testing-library/react';
import { act } from 'react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail } from '../../../shared/api-contract/accounts';
import type { AccountDetail } from './api';
import { getAccountDetails,getAccountRuntimeStatuses,getAllAISettings } from './api';
import { useAccountsData } from './hooks';
+430
View File
@@ -0,0 +1,430 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 AccountDetail UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountDetail {
/** 闲鱼账号稳定标识。 */
id: string;
/** 账号是否已配置平台凭证;摘要接口只返回状态,不返回 Cookie 明文。 */
cookie_configured?: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 用户为账号设置的备注。 */
remark?: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration?: number;
/** 暂停结束时间的 Unix 秒。 */
paused_until?: number;
/** 当前是否处于暂停状态。 */
paused?: boolean;
// 登录信息
/** 用于密码登录的闲鱼用户名。 */
username?: string;
/** 是否已保存密码登录秘密;摘要接口只返回状态,不返回密码明文。 */
login_password_configured?: boolean;
/** 是否在密码登录时显示浏览器。 */
show_browser?: boolean;
// Frontend helpers
/** 平台账号昵称。 */
nickname?: string;
/** 平台账号头像地址。 */
avatar_url?: string;
/** 资料刷新失败时的说明。 */
profile_error?: string;
/** 当前账号运行状态。 */
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'runtime_conflict' | 'error' | 'stopped' | 'disabled';
/** 当前运行状态的用户可见说明。 */
runtime_message?: string;
/** 当前运行实例是否已连接。 */
runtime_connected?: boolean;
/** 运行状态快照的更新时间。 */
runtime_updated_at?: string;
// AI设置
/** 是否启用账号 AI 回复。 */
ai_enabled?: boolean;
/** 允许的最大折扣比例。 */
max_discount_percent?: number;
/** 允许的最大折扣金额。 */
max_discount_amount?: number;
/** 允许的最大砍价轮次。 */
max_bargain_rounds?: number;
/** 账号自定义提示词。 */
custom_prompts?: 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;
}
/** 由当前 feature adapter 归一后的 AccountTaskSettings UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountTaskSettings {
/** 账号稳定标识。 */
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;
}
/** 由当前 feature adapter 归一后的 AccountTaskSummary UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountTaskSummary {
/** 任务类型。 */
task_type: 'auto_rate' | 'auto_polish';
/** 发现的任务数量。 */
found: number;
/** 成功处理的任务数量。 */
success: number;
/** 处理失败的任务数量。 */
failed: number;
/** 跳过的任务数量。 */
skipped: number;
/** 批量处理结果说明。 */
message?: string;
}
/** 由当前 feature adapter 归一后的 AIReplySettings UI 模型;不直接暴露 HTTP DTO。 */
export interface AIReplySettings {
/** 是否启用账号 AI 回复。 */
ai_enabled: boolean;
/** 最大折扣比例。 */
max_discount_percent: number;
/** 最大折扣金额。 */
max_discount_amount?: number;
/** 最大砍价轮次。 */
max_bargain_rounds: number;
/** 自定义提示词。 */
custom_prompts: string;
}
/** 由当前 feature adapter 归一后的 NotificationChannelType UI 模型;不直接暴露 HTTP DTO。 */
export type NotificationChannelType = 'dingtalk' | 'feishu' | 'bark' | 'webhook' | 'wechat' | 'telegram' | 'email';
/** 由当前 feature adapter 归一后的 NotificationEventType UI 模型;不直接暴露 HTTP DTO。 */
export type NotificationEventType =
| 'account_offline'
| 'account_recovered'
| 'account_disabled'
| 'security_verification'
| 'token_renewal'
| 'delivery_result'
| 'system_error';
/** 由当前 feature adapter 归一后的 NotificationChannel UI 模型;不直接暴露 HTTP DTO。 */
export interface NotificationChannel {
/** 通知渠道标识。 */
id: string;
/** 通知渠道名称。 */
name: string;
/** 通知渠道类型。 */
type: NotificationChannelType;
/** 通知渠道配置。 */
config: Record<string, unknown>;
/** 渠道绑定的事件类型。 */
event_types?: NotificationEventType[];
/** 通知渠道是否启用。 */
enabled: boolean;
/** 创建时间。 */
created_at?: string;
/** 更新时间。 */
updated_at?: string;
}
/** 账号编辑器读取的通知渠道传输结果,仅用于适配为 NotificationChannel UI 模型。 */
export interface NotificationChannelResponse {
/** 通知渠道数值标识。 */ id: number;
/** 用户可见渠道名称。 */ name: string;
/** 服务端保存的渠道类型。 */ type: string;
/** 兼容 JSON 文本的事件订阅列表。 */ event_types?: string;
/** 渠道是否参与投递。 */ enabled: boolean;
}
/** 账号列表接口返回的非敏感具名 DTO。 */
/** 由当前 feature adapter 归一后的 AccountSummaryResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountSummaryResponse {
/** 闲鱼账号稳定标识。 */
id: string;
/** 数据库中是否存在账号记录。 */
has_cookie: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 账号备注。 */
remark: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration: number;
/** 暂停结束 Unix 秒。 */
paused_until: number;
/** 当前是否仍处于暂停状态。 */
paused: boolean;
/** 密码登录用户名。 */
username: string;
/** 是否允许密码登录显示浏览器;兼容旧服务端的 0/1 字符串值。 */
show_browser: boolean | number | string;
/** 平台昵称缓存。 */
nickname: string;
/** 平台头像地址。 */
avatar_url: string;
/** 最近一次成功登录方式。 */
login_method: string;
/** 最近一次成功登录时间。 */
last_login_at: number;
/** 资料刷新错误说明。 */
profile_error: string;
/** 账号级 AI 回复开关。 */
ai_enabled: boolean;
/** 自动评价计划开关。 */
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;
}
/** 账号设置变更接口的具名成功响应。 */
/** 由当前 feature adapter 归一后的 CookieSettingsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface CookieSettingsResponse {
/** 表示设置是否保存成功。 */
success: boolean;
/** 暂停结束 Unix 秒。 */
paused_until: number;
/** 表示账号当前是否暂停。 */
paused: boolean;
}
/** 账号资料刷新接口的具名响应。 */
/** 由当前 feature adapter 归一后的 CookieProfileResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface CookieProfileResponse {
/** 表示资料刷新是否成功。 */
success: boolean;
/** 账号稳定标识。 */
id: string;
/** 平台账号昵称。 */
nickname: string;
/** 平台账号头像地址。 */
avatar_url: string;
/** 资料刷新错误说明。 */
profile_error: string;
}
/** 账号暂停时长查询接口的具名响应。 */
/** 由当前 feature adapter 归一后的 PauseDurationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface PauseDurationResponse {
/** 暂停时长,单位为分钟。 */
pause_duration: number;
/** 暂停结束 Unix 秒。 */
paused_until: number;
/** 表示账号当前是否暂停。 */
paused: boolean;
}
/** 账号 AI 回复设置接口的具名响应。 */
/** 由当前 feature adapter 归一后的 AIReplySettingsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AIReplySettingsResponse {
/** 账号稳定标识;默认配置响应可能省略。 */
cookie_id?: string;
/** AI 回复是否启用。 */
ai_enabled: boolean;
/** 最大折扣比例。 */
max_discount_percent: number;
/** 最大折扣金额。 */
max_discount_amount: number;
/** 最大砍价轮次。 */
max_bargain_rounds: number;
/** 自定义提示词。 */
custom_prompts: string;
}
/** 通知绑定列表中的单条记录。 */
/** 由当前 feature adapter 归一后的 NotificationBinding UI 模型;不直接暴露 HTTP DTO。 */
export interface NotificationBinding {
/** 账号稳定标识,列表归一化后补充。 */
cookie_id?: string;
/** 绑定记录主键。 */
id?: number;
/** 通知渠道主键。 */
channel_id: number;
/** 通知渠道名称。 */
channel_name: string;
/** 绑定是否启用。 */
enabled: boolean;
}
/** 账号通知渠道绑定查询响应。 */
/** 由当前 feature adapter 归一后的 AccountBindingsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountBindingsResponse {
/** 账号稳定标识。 */
cookie_id: string;
/** 已绑定通知渠道主键列表。 */
channel_ids: number[];
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
/** 账号任务设置响应。 */
/** 由当前 feature adapter 归一后的 AccountTaskSettingsResponse UI 模型;不直接暴露 HTTP DTO。 */
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;
}
/** 账号任务执行记录响应。 */
/** 由当前 feature adapter 归一后的 AccountTaskRunResponse UI 模型;不直接暴露 HTTP DTO。 */
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;
}
/** 账号任务执行记录列表响应。 */
/** 由当前 feature adapter 归一后的 AccountTaskRunsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountTaskRunsResponse {
/** 当前账号的任务执行记录。 */
runs: AccountTaskRunResponse[];
}
/** 手动执行账号任务的统计响应。 */
/** 由当前 feature adapter 归一后的 AccountTaskSummaryResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountTaskSummaryResponse extends AccountTaskSummary {
/** 任务结果说明。 */
message?: string;
}
/** 手动执行账号任务的成功响应。 */
/** 由当前 feature adapter 归一后的 AccountTaskRunResponseEnvelope UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountTaskRunResponseEnvelope {
/** 任务请求是否成功完成。 */
success: boolean;
/** 账号任务执行统计。 */
summary: AccountTaskSummaryResponse;
}
/** 扫码登录二维码生成响应。 */
/** 由当前 feature adapter 归一后的 QRLoginGenerateResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface QRLoginGenerateResponse {
/** 二维码是否生成成功。 */
success: boolean;
/** 扫码登录会话标识。 */
session_id: string;
/** 二维码图片地址。 */
qr_code_url: string;
/** 可选的提示文本。 */
message?: string;
}
/** 二维码登录状态响应。 */
/** 由当前 feature adapter 归一后的 QRLoginStatusResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface QRLoginStatusResponse {
/** 当前二维码会话状态。 */
status: string;
/** 风控验证页面截图地址,在人脸二维码不可用时作为展示兜底。 */
verification_screenshot?: string;
/** 闲鱼人脸风控验证二维码地址,验证页面优先展示。 */
face_qr_url?: string;
/** 扫码登录会话标识。 */
session_id?: string;
/** 持久化后的本地账号标识。 */
account_id?: string;
/** 是否新建了本地账号。 */
is_new_account?: boolean;
/** 状态提示文本。 */
message?: string;
/** 兼容上游可能扩展的非敏感状态字段。 */
[key: string]: unknown;
}
/** 二维码验证完成响应。 */
/** 由当前 feature adapter 归一后的 QRLoginVerificationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface QRLoginVerificationResponse {
/** 验证结果是否成功。 */
success: boolean;
/** 平台账号标识。 */
unb?: string;
/** 持久化后的本地账号标识。 */
account_id?: string;
/** 是否新建了本地账号。 */
is_new_account?: boolean;
}
@@ -2,7 +2,7 @@
import { cleanup,fireEvent,render,screen,waitFor } from '@testing-library/react';
import React from 'react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail } from '../../../../shared/api-contract/accounts';
import type { AccountDetail } from '../api';
// accountListMocks 保存 AccountList 页面测试使用的 API、Hook 和轮询替身。
const accountListMocks = vi.hoisted(/* accountListMockFactory 创建页面测试共享替身。 */ () => ({
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail } from '../../../shared/api-contract/accounts';
import type { AccountDetail } from './api';
// qrLoginMocks 保存二维码登录协调器测试使用的接口替身。
const qrLoginMocks = vi.hoisted(/* qrLoginMockFactory 创建二维码登录 API 替身。 */ () => ({
@@ -1,5 +1,5 @@
import { describe,expect,test } from 'vitest';
import type { AccountDetail } from '../../../shared/api-contract/accounts';
import type { AccountDetail } from './api';
import { accountRuntimePresentation,isOlderStatus,mergeAccountRuntimeStatuses } from './runtime';
// account 创建运行状态测试使用的最小账号对象。
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { AccountDetail } from '../../../shared/api-contract/accounts';
import type { AccountDetail } from './api';
import {
buildAccountLoginInfoUpdate,
isCurrentAccountRequest,
@@ -2,7 +2,7 @@
import { act,renderHook } from '@testing-library/react';
import type { Dispatch,SetStateAction } from 'react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,AIReplySettings } from '../../../shared/api-contract/accounts';
import type { AccountDetail,AIReplySettings } from './api';
import {
cancelPasswordLogin,
checkPasswordLoginStatus,
+20 -10
View File
@@ -3,11 +3,11 @@ Card,
CardAppendResponse,
CardBatchResponse,
MutationIDResponse,OperationResponse
} from '../../../shared/api-contract/cards';
} from './models';
import { type RequestControlOptions } from '../../../shared/http/client';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { contractClient, contractMultipartBody, runContractRequest } from '../../../shared/api-contract/client';
import { collectionFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/cards';
export type * from './models';
// Cards
// normalizeCard 归一化卡密数据。
const normalizeCard = (item: any): Card => {
@@ -24,9 +24,19 @@ const normalizeCard = (item: any): Card => {
};
// cardPayload 卡密请求载荷,用于当前 API 处理流程。
const cardPayload = (data: Partial<Card>): Record<string, unknown> => ({
...data,
const cardPayload = (data: Partial<Card>) => ({
name: data.name,
type: data.type,
api_config: data.api_config ? JSON.stringify(data.api_config) : '',
text_content: data.text_content,
data_content: data.data_content,
image_url: data.image_url,
description: data.description,
enabled: data.enabled,
delay_seconds: data.delay_seconds,
is_multi_spec: data.is_multi_spec,
spec_name: data.spec_name,
spec_value: data.spec_value,
});
// getCards 读取卡密列表。
@@ -40,12 +50,12 @@ export const getCards = async (options?: RequestControlOptions): Promise<Card[]>
// createCard 创建卡密组。
export const createCard = async (data: Partial<Card>): Promise<MutationIDResponse> => {
return runContractRequest(/* signal 控制卡券创建请求的取消和超时。 */ signal => contractClient.POST('/api/v1/cards', { body: cardPayload(data) as never, signal })) as unknown as Promise<MutationIDResponse>;
return runContractRequest(/* signal 控制卡券创建请求的取消和超时。 */ signal => contractClient.POST('/api/v1/cards', { body: cardPayload(data), signal }));
};
// updateCard 更新卡密组。
export const updateCard = async (cardId: string | number, data: Partial<Card>): Promise<OperationResponse> => {
return runContractRequest(/* signal 控制卡券更新请求的取消和超时。 */ signal => contractClient.PUT('/api/v1/cards/{card_id}', { params: { path: { card_id: String(cardId) } }, body: cardPayload(data) as never, signal }));
return runContractRequest(/* signal 控制卡券更新请求的取消和超时。 */ signal => contractClient.PUT('/api/v1/cards/{card_id}', { params: { path: { card_id: String(cardId) } }, body: cardPayload(data), signal }));
};
// deleteCard 删除卡密组。
@@ -56,7 +66,7 @@ export const deleteCard = async (cardId: string | number): Promise<OperationResp
// getCardDetails 读取卡密组详情。
export const getCardDetails = async (cardId: string | number): Promise<Card> => {
// card 卡密详情,用于当前 API 处理流程。
const card = await runContractRequest(/* signal 控制卡券详情请求的取消和超时。 */ signal => contractClient.GET('/api/v1/cards/{card_id}/details', { params: { path: { card_id: String(cardId) } }, signal })) as unknown as Card;
const card = await runContractRequest(/* signal 控制卡券详情请求的取消和超时。 */ signal => contractClient.GET('/api/v1/cards/{card_id}/details', { params: { path: { card_id: String(cardId) } }, signal }));
return normalizeCard(card);
};
@@ -70,10 +80,10 @@ export const batchCreateCards = async (file: File, options?: RequestControlOptio
// 此处只收紧 TypeScript 响应契约。
const body = new FormData();
body.append('file', file);
return runContractRequest(/* signal 控制卡券批量上传的取消和超时。 */ signal => contractClient.POST('/api/v1/cards/batch', { body: body as never, signal }), options) as Promise<CardBatchResponse>;
return runContractRequest(/* signal 控制卡券批量上传的取消和超时。 */ signal => contractClient.POST('/api/v1/cards/batch', { body: contractMultipartBody(body), signal }), options);
};
// 往 data 类型卡密组批量追加卡密号
export const appendCardData = async (cardId: string | number, content: string, options?: RequestControlOptions): Promise<CardAppendResponse> => {
return runContractRequest(/* signal 控制卡券追加数据请求的取消和超时。 */ signal => contractClient.POST('/api/v1/cards/{card_id}/append-data', { params: { path: { card_id: String(cardId) } }, body: { content } as never, signal }), options) as Promise<CardAppendResponse>;
return runContractRequest(/* signal 控制卡券追加数据请求的取消和超时。 */ signal => contractClient.POST('/api/v1/cards/{card_id}/append-data', { params: { path: { card_id: String(cardId) } }, body: { content }, signal }), options);
};
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { Card } from '../../../shared/api-contract/cards';
import type { Card } from './api';
import { canSubmitAppend,filterCards,isCurrentCardRequest,previewAppendContent } from './batchState';
// cards 是卡密筛选测试使用的最小卡密组列表。
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { Card } from '../../../shared/api-contract/cards';
import type { Card } from './api';
import { useCardActions } from './cardActions';
// cardActionMocks 保存卡密动作 Hook 测试使用的 API 替身。
+1 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { Card } from '../../../shared/api-contract/cards';
import type { Card } from './api';
import { appendCardData,batchCreateCards,getCards } from './api';
import { useCardBatchActions,useCardsData } from './hooks';
+105
View File
@@ -0,0 +1,105 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 Card UI 模型;不直接暴露 HTTP DTO。 */
export interface Card {
/** 卡券组数值主键。 */
id: number;
/** 卡券组名称。 */
name: string;
/** 卡券组类型。 */
type: 'api' | 'text' | 'data' | 'image';
/** 卡券组说明。 */
description?: string;
/** 卡券组是否启用。 */
enabled: boolean;
// 文本类型
text_content?: string;
// 批量数据类型
data_content?: string;
// API 类型配置
api_config?: {
/** API 卡券请求地址。 */
url: string;
/** API 卡券请求方法。 */
method: 'GET' | 'POST';
/** API 请求超时时间。 */
timeout?: number;
/** API 请求头 JSON。 */
headers?: string;
/** API 请求参数 JSON。 */
params?: string;
};
// 图片类型
/** 图片卡券地址。 */
image_url?: string;
// 通用配置
/** 卡券发送延迟秒数。 */
delay_seconds?: number;
// 多规格配置
/** 是否支持多规格。 */
is_multi_spec?: boolean;
/** 规格名称。 */
spec_name?: string;
/** 规格值。 */
spec_value?: string;
}
/** 卡券批量创建接口的逐行结果。 */
/** 由当前 feature adapter 归一后的 CardBatchResult UI 模型;不直接暴露 HTTP DTO。 */
export interface CardBatchResult {
/** 表格中的原始行号。 */
row_no: number;
/** 当前行是否创建成功。 */
success: boolean;
/** 新建卡券组主键。 */
id?: number;
/** 卡券组名称。 */
name: string;
/** 卡券类型。 */
type?: string;
/** 当前行失败原因。 */
error?: string;
}
/** 卡券批量创建接口的具名响应。 */
/** 由当前 feature adapter 归一后的 CardBatchResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface CardBatchResponse {
/** 批量处理流程是否完成。 */
success: boolean;
/** 解析出的总行数。 */
total: number;
/** 创建成功行数。 */
created: number;
/** 创建失败行数。 */
failed: number;
/** 逐行处理结果。 */
rows: CardBatchResult[];
}
/** 卡券追加数据接口的具名响应。 */
/** 由当前 feature adapter 归一后的 CardAppendResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface CardAppendResponse {
/** 追加操作是否完成。 */
success: boolean;
/** 实际追加数量。 */
added: number;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { cleanup,fireEvent,render,screen,waitFor } from '@testing-library/react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { Card } from '../../../../shared/api-contract/cards';
import type { Card } from '../api';
// cardListMocks 保存卡密页面测试使用的 Hook、API 和批量弹窗替身。
const cardListMocks = vi.hoisted(/* cardListMockFactory 创建卡密页面共享替身。 */ () => ({
+2 -2
View File
@@ -3,10 +3,10 @@ AccountDetail,
ChatMessage,
ChatSession,
OperationResponse
} from '../../../shared/api-contract/chat';
} from './models';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { type RequestControlOptions } from '../../../shared/http/client';
export type * from '../../../shared/api-contract/chat';
export type * from './models';
import type { ChatReadReceipt } from './types';
/** ChatImageFormContract 描述图片发送 operation 的 multipart 字段,仅用于将原生 FormData 交给生成客户端。 */
+1 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,ChatMessage,ChatSession } from '../../../shared/api-contract/chat';
import type { AccountDetail,ChatMessage,ChatSession } from './api';
import { getAccountDetails,getAccountRuntimeStatuses,getChatMessagePage,getChatSessionPage,markChatRead,sendChatImage,sendChatMessage } from './api';
import { useChat } from './hooks';
import { publishChatConnectionState,publishChatLiveMessage } from './liveEvents';
+142
View File
@@ -0,0 +1,142 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 AccountDetail UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountDetail {
/** 闲鱼账号稳定标识。 */
id: string;
/** 账号是否已配置平台凭证;摘要接口只返回状态,不返回 Cookie 明文。 */
cookie_configured?: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 用户为账号设置的备注。 */
remark?: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration?: number;
/** 暂停结束时间的 Unix 秒。 */
paused_until?: number;
/** 当前是否处于暂停状态。 */
paused?: boolean;
// 登录信息
/** 用于密码登录的闲鱼用户名。 */
username?: string;
/** 是否已保存密码登录秘密;摘要接口只返回状态,不返回密码明文。 */
login_password_configured?: boolean;
/** 是否在密码登录时显示浏览器。 */
show_browser?: boolean;
// Frontend helpers
/** 平台账号昵称。 */
nickname?: string;
/** 平台账号头像地址。 */
avatar_url?: string;
/** 资料刷新失败时的说明。 */
profile_error?: string;
/** 当前账号运行状态。 */
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'runtime_conflict' | 'error' | 'stopped' | 'disabled';
/** 当前运行状态的用户可见说明。 */
runtime_message?: string;
/** 当前运行实例是否已连接。 */
runtime_connected?: boolean;
/** 运行状态快照的更新时间。 */
runtime_updated_at?: string;
// AI设置
/** 是否启用账号 AI 回复。 */
ai_enabled?: boolean;
/** 允许的最大折扣比例。 */
max_discount_percent?: number;
/** 允许的最大折扣金额。 */
max_discount_amount?: number;
/** 允许的最大砍价轮次。 */
max_bargain_rounds?: number;
/** 账号自定义提示词。 */
custom_prompts?: 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;
}
/** 由当前 feature adapter 归一后的 ChatSession UI 模型;不直接暴露 HTTP DTO。 */
export interface ChatSession {
/** 账号稳定标识。 */
account_id: string;
/** 会话稳定标识。 */
chat_id: string;
/** 买家平台标识。 */
buyer_id: string;
/** 买家昵称。 */
buyer_name: string;
/** 买家头像地址。 */
buyer_avatar_url?: string;
/** 会话关联商品标识。 */
item_id?: string;
/** 会话关联商品标题。 */
item_title?: string;
/** 最近一条消息内容。 */
last_message: string;
/** 最近一条消息的 Unix 秒时间戳。 */
last_message_at: number;
/** 未读消息数量。 */
unread_count: number;
}
/** 由当前 feature adapter 归一后的 ChatMessage UI 模型;不直接暴露 HTTP DTO。 */
export interface ChatMessage {
/** 消息数据库主键。 */
id: number;
/** 消息所属账号标识。 */
account_id: string;
/** 消息所属会话标识。 */
chat_id: string;
/** 平台消息去重键。 */
message_key: string;
/** 消息方向。 */
direction: 'incoming' | 'outgoing';
/** 发送者平台标识。 */
sender_id: string;
/** 发送者名称。 */
sender_name: string;
/** 消息类型,system 表示平台通知或交易卡片。 */
message_type: 'text' | 'image' | 'video' | 'system';
/** 消息正文或媒体地址。 */
content: string;
/** 消息发送状态。 */
status: 'received' | 'sending' | 'sent' | 'failed';
/** 平台已读状态;旧消息可能没有该字段。 */
read_status?: number;
/** 平台确认已读的 Unix 秒时间戳;未确认时省略。 */
read_at?: number;
/** 消息发送时间的 Unix 秒。 */
sent_at: number;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { ChatMessage,ChatSession } from '../../../shared/api-contract/chat';
import type { ChatMessage,ChatSession } from './api';
import { collectChatReadReceipts,filterChatSessions,formatClock,isChatAbortError,isCurrentChatRequest,markOutgoingMessagesReadByIncoming,mergeLiveMessage,mergeOlderMessages,messageTime,unreadBadgeClassName,unreadBadgeLabel } from './state';
// sessionFixture 是覆盖搜索、未读筛选和联系人隔离的最小会话数据。
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { ChatMessage } from '../../../shared/api-contract/chat';
import type { ChatMessage } from './api';
import { getAccountDetails,getChatSessionPage } from './api';
import { publishChatUnreadStatus } from './liveEvents';
import { formatChatNewMessageTitle,useChatTitleNotification,useChatTitleNotifier } from './titleNotification';
+2 -2
View File
@@ -1,9 +1,9 @@
import { formatLocalDate } from '../../../dateRange';
import type { DashboardStatsResponse,Item,ItemListEnvelope,Order,OrderAnalyticsResponse,OrderStatus,ValidOrderResponse,ValidOrdersResponse } from '../../../shared/api-contract/admin';
import type { DashboardStatsResponse,Item,ItemListEnvelope,Order,OrderAnalyticsResponse,OrderStatus,ValidOrderResponse,ValidOrdersResponse } from './models';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { type RequestControlOptions } from '../../../shared/http/client';
import { collectionFrom, objectFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/admin';
export type * from './models';
/** 仪表盘订单明细接口转换后的分页结果。 */
export interface ValidOrdersResult {
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { DashboardStats,Item,OrderAnalyticsResponse } from '../../../shared/api-contract/admin';
import type { DashboardStats,Item,OrderAnalyticsResponse } from './api';
import { getDashboardStats,getItems,getOrderAnalytics,getValidOrders } from './api';
import type { UseDashboardOptions } from './hooks';
import { useDashboard } from './hooks';
+270
View File
@@ -0,0 +1,270 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 OrderStatus UI 模型;不直接暴露 HTTP DTO。 */
export type OrderStatus =
| 'processing'
| 'pending_ship'
| 'shipped'
| 'completed'
| 'cancelled'
| 'refunding'
| 'unknown';
/** 由当前 feature adapter 归一后的 Order UI 模型;不直接暴露 HTTP DTO。 */
export interface Order {
/** 订单本地数据库主键。 */
id: string;
/** 平台订单标识。 */
order_id: string;
/** 订单所属账号标识。 */
cookie_id: string;
/** 订单关联商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品图片地址。 */
item_image?: string;
/** 商品价格文本。 */
item_price?: string;
/** 买家平台标识。 */
buyer_id: string;
/** 购买数量。 */
quantity: number;
/** 订单金额文本。 */
amount: string;
/** 前端归一化后的订单状态。 */
status: OrderStatus;
/** 服务端原始订单状态。 */
order_status?: OrderStatus;
/** 收货人姓名。 */
receiver_name?: string;
/** 收货人电话。 */
receiver_phone?: string;
/** 收货地址。 */
receiver_address?: string;
/** 订单创建时间。 */
created_at?: string;
/** 订单更新时间。 */
updated_at?: string;
}
/** 由当前 feature adapter 归一后的 Item UI 模型;不直接暴露 HTTP DTO。 */
export interface Item {
/** 本地商品数据库主键。 */
id: string | number;
/** 商品所属账号标识。 */
cookie_id: string;
/** 平台商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品描述。 */
item_description?: string;
/** 商品价格文本。 */
item_price?: string;
/** 商品主图地址。 */
item_image?: string; // Inferred from common usage, though not explicitly in list model sometimes
/** 商品分类标识。 */
item_category?: string;
/** 商品详情原始 JSON。 */
item_detail?: string;
/** 是否启用多规格。 */
is_multi_spec?: number | boolean;
/** 是否按数量发货。 */
multi_quantity_delivery?: number | boolean;
/** 是否启用多数量发货兼容字段。 */
is_multi_qty_ship?: number | boolean;
}
/** 仪表盘兼容历史 items 包装时使用的最小响应模型。 */
export interface ItemListEnvelope {
/** 历史包装中的商品数组。 */ items?: Item[];
}
/** 由当前 feature adapter 归一后的 AdminStats UI 模型;不直接暴露 HTTP DTO。 */
export interface AdminStats {
/** 用户总数。 */
total_users: number;
/** 账号总数。 */
total_cookies: number;
/** 启用账号数。 */
active_cookies: number;
/** 卡券组总数。 */
total_cards: number;
/** 关键词规则总数。 */
total_keywords: number;
/** 订单总数。 */
total_orders: number;
}
/** 由当前 feature adapter 归一后的 DashboardStats UI 模型;不直接暴露 HTTP DTO。 */
export interface DashboardStats {
/** 账号总数。 */
total_cookies: number;
/** 启用账号数。 */
active_cookies: number;
/** 卡券组总数。 */
total_cards: number;
/** 关键词规则总数。 */
total_keywords: number;
/** 订单总数。 */
total_orders: number;
/** 可用卡券库存量。 */
available_card_stock: number;
}
/** 由当前 feature adapter 归一后的 OrderAnalytics UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderAnalytics {
/** 收入汇总。 */
revenue_stats: {
/** 总收入金额。 */
total_amount: number;
/** 总订单数。 */
total_orders: number;
};
/** 按日期聚合的订单统计。 */
daily_stats: Array<{
/** 统计日期。 */
date: string;
/** 当日订单金额。 */
amount: number;
/** 当日订单数量。 */
order_count: number;
}>;
/** 按商品聚合的订单统计。 */
item_stats?: Array<{
/** 商品标识。 */
item_id: string;
/** 商品订单数。 */
order_count: number;
/** 商品订单总金额。 */
total_amount: number;
/** 商品订单平均金额。 */
avg_amount: number;
}>;
}
/** 管理员全局统计响应。 */
/** 由当前 feature adapter 归一后的 AdminStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AdminStatsResponse extends AdminStats {}
/** 当前用户数据概览响应。 */
/** 由当前 feature adapter 归一后的 DashboardStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface DashboardStatsResponse extends DashboardStats {}
/** 订单收益统计响应。 */
/** 由当前 feature adapter 归一后的 AnalyticsRevenueStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AnalyticsRevenueStatsResponse {
/** 统计范围内的订单数。 */
total_orders: number;
/** 统计范围内的订单总金额。 */
total_amount: number;
/** 订单平均金额。 */
avg_amount: number;
/** 买家数量。 */
unique_buyers: number;
/** 商品数量。 */
unique_items: number;
}
/** 按日期聚合的订单统计响应。 */
/** 由当前 feature adapter 归一后的 AnalyticsDailyStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AnalyticsDailyStatsResponse {
/** 用户本地日期。 */
date: string;
/** 当天订单数。 */
order_count: number;
/** 当天订单金额。 */
amount: number;
}
/** 按订单状态聚合的统计响应。 */
/** 由当前 feature adapter 归一后的 AnalyticsStatusStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AnalyticsStatusStatsResponse {
/** 归一化后的订单状态。 */
status: string;
/** 该状态订单数。 */
count: number;
/** 该状态订单金额。 */
amount: number;
}
/** 按收货城市聚合的统计响应。 */
/** 由当前 feature adapter 归一后的 AnalyticsCityStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AnalyticsCityStatsResponse {
/** 收货城市。 */
city: string;
/** 该城市订单数。 */
order_count: number;
/** 该城市订单金额。 */
total_amount: number;
}
/** 按商品聚合的统计响应。 */
/** 由当前 feature adapter 归一后的 AnalyticsItemStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AnalyticsItemStatsResponse {
/** 商品平台标识。 */
item_id: string;
/** 该商品订单数。 */
order_count: number;
/** 该商品订单金额。 */
total_amount: number;
/** 该商品订单平均金额。 */
avg_amount: number;
}
/** 订单分析接口响应。 */
/** 由当前 feature adapter 归一后的 OrderAnalyticsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderAnalyticsResponse {
/** 收益统计。 */
revenue_stats: AnalyticsRevenueStatsResponse;
/** 按日统计。 */
daily_stats: AnalyticsDailyStatsResponse[];
/** 按状态统计。 */
status_stats: AnalyticsStatusStatsResponse[];
/** 按城市统计。 */
city_stats: AnalyticsCityStatsResponse[];
/** 按商品统计。 */
item_stats: AnalyticsItemStatsResponse[];
}
/** 有效订单明细响应。 */
/** 由当前 feature adapter 归一后的 ValidOrderResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ValidOrderResponse {
/** 平台订单标识。 */
order_id: string;
/** 商品平台标识。 */
item_id: string;
/** 买家平台标识。 */
buyer_id: string;
/** 商品标题。 */
item_title: string;
/** 商品图片地址。 */
item_image: string;
/** 订单数量文本。 */
quantity: string;
/** 订单金额文本。 */
amount: string;
/** 兼容保留的订单状态。 */
order_status: string;
/** 归一化后的订单状态。 */
status: string;
/** 订单所属账号标识。 */
cookie_id: string;
/** 订单创建时间。 */
created_at: string;
}
/** 有效订单分页响应。 */
/** 由当前 feature adapter 归一后的 ValidOrdersResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ValidOrdersResponse {
/** 当前页有效订单。 */
orders: ValidOrderResponse[];
/** 符合条件的订单总数。 */
total: number;
/** 当前页码。 */
page: number;
/** 当前页大小。 */
page_size: number;
/** 是否还有未返回的订单。 */
truncated: boolean;
}
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { OrderAnalytics } from '../../../shared/api-contract/admin';
import type { OrderAnalytics } from './api';
import { buildCategoryData,buildChartData,buildItemNameMap,buildProductSalesData,buildSourceData,getMaxProductSales,getRangeLabel,getTrendPercent,isCurrentDashboardRequest } from './state';
// analyticsFixture 是覆盖趋势、商品排行和零值边界的最小分析数据。
+10 -6
View File
@@ -1,4 +1,4 @@
import type { PublishLocation } from '../../../shared/api-contract/items';
import type { PublishLocation } from './models';
import {
AccountDetail,
BatchCancelResponse,
@@ -11,11 +11,11 @@ ItemPublishBatchResponse,
ItemPublishResponse,ItemSyncResponse,
OperationResponse,
ShippingRule
} from '../../../shared/api-contract/items';
} from './models';
import { ApiError, type RequestControlOptions } from '../../../shared/http/client';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { collectionFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/items';
export type * from './models';
import { getPublishLocations as queryPublishLocations,type PublishLocationRequestOptions } from './amapLocation';
/** 商品账号筛选器读取非敏感账号摘要。 */
@@ -26,7 +26,7 @@ export const getShippingRules = async (options?: RequestControlOptions): Promise
// getPublishLocations 通过 feature API 边界读取地点,并把取消/超时控制传入地图服务。
export const getPublishLocations = (longitude: number, latitude: number, options?: PublishLocationRequestOptions): Promise<PublishLocation[]> => queryPublishLocations(longitude, latitude, options);
export type { PublishLocation } from '../../../shared/api-contract/items';
export type { PublishLocation } from './models';
// itemErrorMessage 将统一 HTTP 错误码归一为商品 feature 可执行的用户提示。
export const itemErrorMessage = (error: unknown, fallback: string): string => {
@@ -197,5 +197,9 @@ export const updateItem = async (cookieId: string, itemId: string, data: Partial
return runContractRequest(/* signal 控制商品更新请求的取消和超时。 */ signal => contractClient.PUT('/api/v1/items/{cookie_id}/{item_id}', { params: { path: { cookie_id: cookieId, item_id: itemId } }, body: data as never, signal }));
}
/** 读取指定账号与商品的详情,用于编辑器恢复表单。 */
export const getItemDetail = async (accountID: string, itemID: string): Promise<ItemDetailResponse> => runContractRequest(/* signal 控制商品详情请求的取消和超时。 */ signal => contractClient.GET('/api/v1/items/{cookie_id}/{item_id}', { params: { path: { cookie_id: accountID, item_id: itemID } }, signal })) as unknown as Promise<ItemDetailResponse>;
/** 读取指定账号与商品的详情,用于编辑器恢复表单,并将生成传输 DTO 保持在 feature adapter 边界。 */
export const getItemDetail = async (accountID: string, itemID: string): Promise<ItemDetailResponse> => {
// response 保存已由 OpenAPI 路径类型约束的商品详情传输响应。
const response = await runContractRequest(/* signal 控制商品详情请求的取消和超时。 */ signal => contractClient.GET('/api/v1/items/{cookie_id}/{item_id}', { params: { path: { cookie_id: accountID, item_id: itemID } }, signal }));
return response;
};
+1 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { BatchCancelResponse,BatchIDResponse,CategoryRecommendationResponse,ItemPublishBatchPreviewResponse,ItemPublishBatchResponse } from '../../../shared/api-contract/items';
import type { BatchCancelResponse,BatchIDResponse,CategoryRecommendationResponse,ItemPublishBatchPreviewResponse,ItemPublishBatchResponse } from './api';
import {
cancelItemPublishBatch,
deleteItemPublishBatch,
@@ -2,7 +2,7 @@
import { act,renderHook } from '@testing-library/react';
import { useState } from 'react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { Item } from '../../../shared/api-contract/items';
import type { Item } from './api';
import { createItem,deleteItem,getPublishLocations,publishItem,syncItemsFromAccount,updateItem } from './api';
import { useItemActions,type ItemActionsOptions } from './itemActions';
+457
View File
@@ -0,0 +1,457 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 PublishLocation UI 模型;不直接暴露 HTTP DTO。 */
export interface PublishLocation {
/** 行政区划展示名称。 */
area: string;
/** 城市展示名称。 */
city: string;
/** 平台使用的行政区划标识。 */
division_id: string;
/** 地点经度。 */
longitude: number;
/** 地点纬度。 */
latitude: number;
/** 平台兴趣点标识。 */
poi_id: string;
/** 平台兴趣点展示名称。 */
poi_name: string;
/** 省份展示名称。 */
province: string;
}
/** 由当前 feature adapter 归一后的 AccountDetail UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountDetail {
/** 闲鱼账号稳定标识。 */
id: string;
/** 账号是否已配置平台凭证;摘要接口只返回状态,不返回 Cookie 明文。 */
cookie_configured?: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 用户为账号设置的备注。 */
remark?: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration?: number;
/** 暂停结束时间的 Unix 秒。 */
paused_until?: number;
/** 当前是否处于暂停状态。 */
paused?: boolean;
// 登录信息
/** 用于密码登录的闲鱼用户名。 */
username?: string;
/** 是否已保存密码登录秘密;摘要接口只返回状态,不返回密码明文。 */
login_password_configured?: boolean;
/** 是否在密码登录时显示浏览器。 */
show_browser?: boolean;
// Frontend helpers
/** 平台账号昵称。 */
nickname?: string;
/** 平台账号头像地址。 */
avatar_url?: string;
/** 资料刷新失败时的说明。 */
profile_error?: string;
/** 当前账号运行状态。 */
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'runtime_conflict' | 'error' | 'stopped' | 'disabled';
/** 当前运行状态的用户可见说明。 */
runtime_message?: string;
/** 当前运行实例是否已连接。 */
runtime_connected?: boolean;
/** 运行状态快照的更新时间。 */
runtime_updated_at?: string;
// AI设置
/** 是否启用账号 AI 回复。 */
ai_enabled?: boolean;
/** 允许的最大折扣比例。 */
max_discount_percent?: number;
/** 允许的最大折扣金额。 */
max_discount_amount?: number;
/** 允许的最大砍价轮次。 */
max_bargain_rounds?: number;
/** 账号自定义提示词。 */
custom_prompts?: 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;
}
/** 由当前 feature adapter 归一后的 Item UI 模型;不直接暴露 HTTP DTO。 */
export interface Item {
/** 本地商品数据库主键。 */
id: string | number;
/** 商品所属账号标识。 */
cookie_id: string;
/** 平台商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品描述。 */
item_description?: string;
/** 商品价格文本。 */
item_price?: string;
/** 商品主图地址。 */
item_image?: string; // Inferred from common usage, though not explicitly in list model sometimes
/** 商品分类标识。 */
item_category?: string;
/** 商品详情原始 JSON。 */
item_detail?: string;
/** 是否启用多规格。 */
is_multi_spec?: number | boolean;
/** 是否按数量发货。 */
multi_quantity_delivery?: number | boolean;
/** 是否启用多数量发货兼容字段。 */
is_multi_qty_ship?: number | boolean;
}
/** 由当前 feature adapter 归一后的 AutomationTriggerType UI 模型;不直接暴露 HTTP DTO。 */
export type AutomationTriggerType = 'order_paid' | 'buyer_reviewed' | 'review_missing_timeout';
/** 由当前 feature adapter 归一后的 AutomationActionType UI 模型;不直接暴露 HTTP DTO。 */
export type AutomationActionType = 'confirm_shipment' | 'send_card' | 'send_text';
// Rules
/** 由当前 feature adapter 归一后的 ShippingRule UI 模型;不直接暴露 HTTP DTO。 */
export interface ShippingRule {
/** 规则标识。 */
id: string;
/** 规则名称。 */
name: string;
/** 规则触发类型。 */
trigger_type: AutomationTriggerType;
/** 规则匹配关键词。 */
item_keyword: string; // Legacy UI helper
/** 规则限定的账号标识。 */
cookie_id?: string;
/** 规则限定的商品标识。 */
item_id?: string;
/** 规则限定的商品标题。 */
item_title?: string;
/** 首个发卡动作使用的卡券组 ID。 */
card_group_id: number; // First send_card action card id
/** 首个发卡动作使用的卡券组名称。 */
card_group_name?: string; // UI helper
/** 规则优先级。 */
priority: number;
/** 规则是否启用。 */
enabled: boolean;
/** 规则原始配置 JSON。 */
config_json?: string;
/** 规则动作列表。 */
actions: AutomationAction[];
/** 规则规格变体列表。 */
variants: ShippingVariant[];
}
/** 由当前 feature adapter 归一后的 AutomationAction UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationAction {
/** 动作标识。 */
id?: string;
/** 动作类型。 */
action_type: AutomationActionType;
/** 动作使用的卡券组 ID。 */
card_id?: number;
/** 动作使用的卡券组名称。 */
card_name?: string;
/** 本次发放数量。 */
delivery_count?: number;
/** 文本消息模板。 */
message_template?: string;
/** 动作延迟秒数。 */
delay_seconds?: number;
/** 动作原始配置 JSON。 */
config_json?: string;
/** 动作是否启用。 */
enabled: boolean;
/** 动作排序序号。 */
sort_order?: number;
}
/** 由当前 feature adapter 归一后的 ShippingVariant UI 模型;不直接暴露 HTTP DTO。 */
export interface ShippingVariant {
/** 规格变体标识。 */
id?: string;
/** 规格名称。 */
spec_name: string;
/** 规格值。 */
spec_value: string;
/** 变体使用的卡券组 ID。 */
card_id: number;
/** 变体使用的卡券组名称。 */
card_name?: string;
/** 卡券类型。 */
card_type?: 'api' | 'text' | 'data' | 'image';
/** 变体发放数量。 */
delivery_count: number;
/** 变体是否启用。 */
enabled: boolean;
/** 是否覆盖动作级延迟。 */
delay_override?: boolean;
/** 变体延迟秒数。 */
delay_seconds?: number;
/** 变体原始配置 JSON。 */
config_json?: string;
}
/** 单个本地商品详情接口的具名响应。 */
/** 由当前 feature adapter 归一后的 ItemDetailResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemDetailResponse {
/** 商品所属账号标识。 */
cookie_id: string;
/** 平台商品标识。 */
item_id: string;
/** 商品标题。 */
item_title: string;
/** 商品描述。 */
item_description: string;
/** 商品分类标识。 */
item_category: string;
/** 商品价格文本。 */
item_price: string;
/** 商品详情原始 JSON。 */
item_detail: string;
/** 是否有多规格。 */
is_multi_spec: boolean;
/** 是否按数量发货。 */
multi_quantity_delivery: boolean;
}
/** 商品发布接口的具名成功响应。 */
/** 由当前 feature adapter 归一后的 ItemPublishResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishResponse {
/** 表示商品是否发布成功。 */
success: boolean;
/** 发布结果说明。 */
message: string;
/** 新商品的平台标识。 */
item_id: string;
/** 新商品的平台详情地址。 */
item_url: string;
/** 新商品主图地址。 */
item_image: string;
/** 新商品标题。 */
item_title: string;
/** 新商品价格文本。 */
item_price: string;
/** 新商品库存数量。 */
quantity: number;
/** 新商品分类标识。 */
category_id: string;
/** 新商品分类名称。 */
category_name: string;
}
/** 商品全集同步接口的具名响应。 */
/** 由当前 feature adapter 归一后的 ItemSyncResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemSyncResponse {
/** 表示同步是否完成。 */
success: boolean;
/** 同步结果说明。 */
message: string;
/** 平台返回的商品总数。 */
total_count: number;
/** 平台商品总页数。 */
total_pages: number;
/** 本地保存的商品数量。 */
saved_count: number;
/** 本地删除标记的商品数量。 */
deleted_count: number;
}
/** 商品分页同步接口的具名响应。 */
/** 由当前 feature adapter 归一后的 ItemPageSyncResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPageSyncResponse {
/** 表示同步是否完成。 */
success: boolean;
/** 同步结果说明。 */
message: string;
/** 当前同步页码。 */
page_number: number;
/** 当前同步页大小。 */
page_size: number;
/** 当前页商品数量。 */
current_count: number;
/** 本地保存的商品数量。 */
saved_count: number;
}
/** 商品类目推荐接口的具名响应。 */
/** 由当前 feature adapter 归一后的 CategoryRecommendationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface CategoryRecommendationResponse {
/** 类目推荐是否成功。 */
success: boolean;
/** 推荐商品类目。 */
category: {
/** 平台类目主键。 */
cat_id: string;
/** 平台类目名称。 */
cat_name: string;
/** 频道类目主键。 */
channel_cat_id: string;
/** 淘宝类目主键。 */
tb_cat_id?: string;
};
}
/** 商品批量发布预检逐行结果。 */
/** 由当前 feature adapter 归一后的 ItemPublishBatchPreviewRow UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishBatchPreviewRow {
/** 上传表格行号。 */
row_no: number;
/** 当前行是否通过预检。 */
valid: boolean;
/** 当前行校验错误列表。 */
errors?: string[];
/** 发布目标账号标识。 */
cookie_id: string;
/** 商品标题。 */
title: string;
/** 商品价格文本。 */
price: string;
/** 商品库存数量。 */
quantity: number;
/** 商品图片引用列表。 */
images: string[];
/** 商品发布类目。 */
category: CategoryRecommendationResponse['category'];
/** 发布后自动化配置。 */
automation?: Record<string, unknown>;
}
/** 商品批量发布预检响应。 */
/** 由当前 feature adapter 归一后的 ItemPublishBatchPreviewResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishBatchPreviewResponse {
/** 预检流程是否完成。 */
success: boolean;
/** 后续启动发布使用的预检批次标识。 */
preview_id: string;
/** 预检总行数。 */
total: number;
/** 通过预检行数。 */
valid: number;
/** 未通过预检行数。 */
invalid: number;
/** 逐行预检结果。 */
rows: ItemPublishBatchPreviewRow[];
}
/** 商品批量发布任务启动或重试响应。 */
/** 由当前 feature adapter 归一后的 BatchIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface BatchIDResponse {
/** 任务操作是否完成。 */
success: boolean;
/** 商品批量任务标识。 */
batch_id: string;
}
/** 商品批量发布任务取消响应。 */
/** 由当前 feature adapter 归一后的 BatchCancelResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface BatchCancelResponse {
/** 取消请求是否完成。 */
success: boolean;
/** 取消后的任务状态。 */
status: string;
}
/** 商品批量发布任务逐行详情。 */
/** 由当前 feature adapter 归一后的 ItemPublishBatchRowResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishBatchRowResponse {
/** 明细行主键。 */
id: number;
/** 导入表格行号。 */
row_no: number;
/** 发布目标账号标识。 */
cookie_id: string;
/** 商品标题。 */
title: string;
/** 商品价格文本。 */
price: string;
/** 商品库存数量。 */
quantity: number;
/** 商品图片引用列表。 */
images: string[];
/** 商品发布类目。 */
category: CategoryRecommendationResponse['category'];
/** 发布后自动化配置。 */
automation: Record<string, unknown>;
/** 明细行状态。 */
status: string;
/** 发布成功后的平台商品标识。 */
item_id: string;
/** 发布成功后的商品地址。 */
item_url: string;
/** 明细行失败原因。 */
error_message: string;
/** 明细行失败类型。 */
failure_kind: string;
}
/** 商品批量发布任务详情响应。 */
/** 由当前 feature adapter 归一后的 ItemPublishBatchResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishBatchResponse {
/** 批量任务标识。 */
id: string;
/** 批量任务状态。 */
status: string;
/** 原始上传文件名。 */
filename: string;
/** 明细行总数。 */
total: number;
/** 成功发布数量。 */
success: number;
/** 失败数量。 */
failed: number;
/** 待处理数量。 */
pending: number;
/** 运行中数量。 */
running: number;
/** 可重试数量。 */
retryable: number;
/** 明细行结果。 */
rows: ItemPublishBatchRowResponse[];
/** 批次统一发货地。 */
location?: Record<string, unknown>;
/** 最终商品发布之间的最小间隔秒数。 */
publish_interval_seconds?: number;
/** 创建时间。 */
created_at: string;
/** 更新时间。 */
updated_at: string;
}
/** 商品批量发布任务列表响应。 */
/** 由当前 feature adapter 归一后的 ItemPublishBatchListResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemPublishBatchListResponse {
/** 当前用户的批量任务列表。 */
batches: ItemPublishBatchResponse[];
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
+20 -18
View File
@@ -1,7 +1,7 @@
import type { MutationIDResponse,NotificationBinding,NotificationChannel,NotificationChannelResponse,NotificationEventType,OperationResponse,SystemSettings } from '../../../shared/api-contract/notifications';
import type { MutationIDResponse,NotificationBinding,NotificationChannel,NotificationChannelResponse,NotificationEventType,OperationResponse,SystemSettings } from './models';
import { type RequestControlOptions } from '../../../shared/http/client';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
export type * from '../../../shared/api-contract/notifications';
export type * from './models';
/** 通知渠道写入时使用的具名请求 DTO。 */
export interface NotificationChannelRequest {
@@ -50,22 +50,24 @@ const toNotificationChannel = (channel: NotificationChannelResponse): Notificati
/** 获取全部通知渠道并转换为编辑器模型。 */
export const getNotificationChannels = async (options?: RequestControlOptions): Promise<{ /** 操作是否完成。 */ success: boolean; /** 渠道列表。 */ data: NotificationChannel[] }> => {
// response 是渠道列表的原始传输响应。
const response = await runContractRequest(/* signal 控制通知渠道列表读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/channels', { signal }), options) as unknown as NotificationChannelResponse[] | { /** channels 是后端包装的渠道列表。 */ data?: NotificationChannelResponse[]; /** channels 是兼容字段。 */ channels?: NotificationChannelResponse[] };
// channels 是兼容直接数组与包装数组后的原始渠道列表。
const channels = Array.isArray(response) ? response : response.data || response.channels || [];
return { success: true, data: channels.map(toNotificationChannel) };
const response = await runContractRequest(/* signal 控制通知渠道列表读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/channels', { signal }), options);
return { success: true, data: response.map(toNotificationChannel) };
};
/** 创建通知渠道,并在传输边界序列化配置与事件。 */
export const createNotificationChannel = async (data: Required<Pick<NotificationChannelRequest, 'name' | 'type' | 'config'>> & NotificationChannelRequest, options?: RequestControlOptions): Promise<MutationIDResponse> => runContractRequest(/* signal 控制通知渠道创建请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/channels', { body: { ...data, config: JSON.stringify(data.config), event_types: stringifyNotificationEventTypes(data.event_types) } as never, signal }), options) as unknown as Promise<MutationIDResponse>;
export const createNotificationChannel = async (data: Required<Pick<NotificationChannelRequest, 'name' | 'type' | 'config'>> & NotificationChannelRequest, options?: RequestControlOptions): Promise<MutationIDResponse> => runContractRequest(/* signal 控制通知渠道创建请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/channels', { body: { name: data.name, type: data.type, config: JSON.stringify(data.config), event_types: stringifyNotificationEventTypes(data.event_types), enabled: data.enabled }, signal }), options);
/** 更新通知渠道的可编辑字段。 */
export const updateNotificationChannel = async (channelID: string, data: NotificationChannelRequest, options?: RequestControlOptions): Promise<OperationResponse> => {
// payload 是已完成配置和事件序列化的更新请求。
const payload: Record<string, unknown> = { ...data };
if ('config' in data) payload.config = JSON.stringify(data.config);
if ('event_types' in data) payload.event_types = stringifyNotificationEventTypes(data.event_types);
return runContractRequest(/* signal 控制通知渠道更新请求的取消和超时。 */ signal => contractClient.PUT('/api/v1/notifications/channels/{channel_id}', { params: { path: { channel_id: channelID } }, body: payload as never, signal }), options) as unknown as Promise<OperationResponse>;
const payload = {
name: data.name,
type: data.type,
config: data.config === undefined ? undefined : JSON.stringify(data.config),
event_types: data.event_types === undefined ? undefined : stringifyNotificationEventTypes(data.event_types),
enabled: data.enabled,
};
return runContractRequest(/* signal 控制通知渠道更新请求的取消和超时。 */ signal => contractClient.PUT('/api/v1/notifications/channels/{channel_id}', { params: { path: { channel_id: channelID } }, body: payload, signal }), options);
};
/** 删除指定通知渠道。 */
@@ -74,7 +76,7 @@ export const deleteNotificationChannel = async (channelID: string, options?: Req
/** 获取并展平按账号分组存储的消息通知绑定。 */
export const getMessageNotifications = async (): Promise<{ /** 操作是否完成。 */ success: boolean; /** 展平后的绑定列表。 */ data: NotificationBinding[] }> => {
// response 是按账号 ID 分组的通知绑定响应。
const response = await runContractRequest(/* signal 控制消息通知列表读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/messages', { signal })) as unknown as Record<string, NotificationBinding[]>;
const response = await runContractRequest(/* signal 控制消息通知列表读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/messages', { signal }));
// bindings 是供页面直接渲染的扁平绑定集合。
const bindings: NotificationBinding[] = [];
for (const /* accountID、channelBindings 是当前账号及其原始渠道绑定列表。 */ [accountID, channelBindings] of Object.entries(response || {})) {
@@ -85,7 +87,7 @@ export const getMessageNotifications = async (): Promise<{ /** 操作是否完
};
/** 设置单个账号与渠道之间的启用状态。 */
export const setMessageNotification = async (accountID: string, channelID: number, enabled: boolean): Promise<OperationResponse> => runContractRequest(/* signal 控制单账号通知开关更新请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, body: { channel_id: channelID, enabled } as never, signal }));
export const setMessageNotification = async (accountID: string, channelID: number, enabled: boolean): Promise<OperationResponse> => runContractRequest(/* signal 控制单账号通知开关更新请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, body: { channel_id: channelID, enabled }, signal }));
/** 删除单个消息通知绑定。 */
export const deleteMessageNotification = async (notificationID: string): Promise<OperationResponse> => runContractRequest(/* signal 控制单条通知删除请求的取消和超时。 */ signal => contractClient.DELETE('/api/v1/notifications/messages/{notification_id}', { params: { path: { notification_id: notificationID } }, signal }));
@@ -95,16 +97,16 @@ export const deleteAccountNotifications = async (accountID: string): Promise<Ope
/** 读取指定账号已绑定的通知渠道主键。 */
export const getAccountBindings = async (accountID: string, options?: RequestControlOptions): Promise<number[]> => {
// response 是账号渠道绑定的具名响应。
const response = await runContractRequest(/* signal 控制账号通知绑定读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, signal }), options) as unknown as { /** channelIDs 是绑定渠道主键集合。 */ channel_ids?: number[]; /** data 是兼容包装。 */ data?: { /** channelIDs 是绑定渠道主键集合。 */ channel_ids?: number[] } };
return Array.isArray(response.channel_ids) ? response.channel_ids : Array.isArray(response.data?.channel_ids) ? response.data.channel_ids : [];
// response 是由 OpenAPI 约束的账号渠道绑定响应;未绑定时后端兼容返回 null。
const response = await runContractRequest(/* signal 控制账号通知绑定读取的取消和超时。 */ signal => contractClient.GET('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, signal }), options);
return response.channel_ids ?? [];
};
/** 覆盖保存指定账号的通知渠道绑定。 */
export const setAccountBindings = async (accountID: string, channelIDs: number[]): Promise<OperationResponse> => runContractRequest(/* signal 控制账号通知绑定覆盖请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, body: { channel_ids: channelIDs } as never, signal }));
export const setAccountBindings = async (accountID: string, channelIDs: number[]): Promise<OperationResponse> => runContractRequest(/* signal 控制账号通知绑定覆盖请求的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/accounts/{cid}/bindings', { params: { path: { cid: accountID } }, body: { channel_ids: channelIDs }, signal }));
/** 向单一通知渠道发送测试投递。 */
export const testNotificationChannel = async (channelID: string, options?: RequestControlOptions): Promise<OperationResponse> => runContractRequest(/* signal 控制通知渠道测试投递的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/channels/{channel_id}/test', { params: { path: { channel_id: channelID } }, body: {} as never, signal }), options);
export const testNotificationChannel = async (channelID: string, options?: RequestControlOptions): Promise<OperationResponse> => runContractRequest(/* signal 控制通知渠道测试投递的取消和超时。 */ signal => contractClient.POST('/api/v1/notifications/channels/{channel_id}/test', { params: { path: { channel_id: channelID } }, signal }), options);
/** 将系统配置响应转换为通知 SMTP 表单使用的状态模型。 */
const normalizeSystemSettings = (settings: Record<string, unknown>): SystemSettings => {
@@ -71,21 +71,21 @@ export const NotificationSmtpSettings: React.FC<NotificationSmtpSettingsProps> =
<div className="p-2 rounded-xl bg-blue-50 text-blue-600"><Mail className="w-5 h-5" /></div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">SMTP 服务器</label><input data-field="smtp_server" type="text" value={smtp.smtp_server || ''} onChange={handleTextChange} placeholder="smtp.qq.com" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">SMTP 端口</label><input type="number" value={smtp.smtp_port || 587} onChange={handlePortChange} placeholder="587" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">SMTP 服务器</label><input data-field="smtp_server" type="text" value={typeof smtp.smtp_server === 'string' ? smtp.smtp_server : ''} onChange={handleTextChange} placeholder="smtp.qq.com" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">SMTP 端口</label><input type="number" value={typeof smtp.smtp_port === 'number' ? smtp.smtp_port : 587} onChange={handlePortChange} placeholder="587" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
</div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件邮箱</label><input data-field="smtp_user" type="email" value={smtp.smtp_user || ''} onChange={handleTextChange} placeholder="[email protected]" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件邮箱</label><input data-field="smtp_user" type="email" value={typeof smtp.smtp_user === 'string' ? smtp.smtp_user : ''} onChange={handleTextChange} placeholder="[email protected]" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2">
<label className="block text-sm font-bold text-gray-800">邮箱密码 / 授权码</label>
<div className="relative">
<input type={showPassword ? 'text' : 'password'} value={smtp.smtp_password || ''} onChange={handlePasswordChange} placeholder={smtp.smtp_password_configured ? '已配置,如需替换请输入新密码' : '输入密码或授权码'} className="w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm" />
<input type={showPassword ? 'text' : 'password'} value={typeof smtp.smtp_password === 'string' ? smtp.smtp_password : ''} onChange={handlePasswordChange} placeholder={smtp.smtp_password_configured ? '已配置,如需替换请输入新密码' : '输入密码或授权码'} className="w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm" />
<button type="button" onClick={handleTogglePassword} className="absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors">{showPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}</button>
</div>
<p className="text-xs text-gray-500">QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)</p>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件人显示名(可选)</label><input data-field="smtp_from_name" type="text" value={smtp.smtp_from_name || ''} onChange={handleTextChange} placeholder="闲鱼自动回复系统" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件邮箱地址</label><input data-field="smtp_from_address" type="email" value={smtp.smtp_from_address || smtp.smtp_user || ''} onChange={handleTextChange} placeholder="[email protected]" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件人显示名(可选)</label><input data-field="smtp_from_name" type="text" value={typeof smtp.smtp_from_name === 'string' ? smtp.smtp_from_name : ''} onChange={handleTextChange} placeholder="闲鱼自动回复系统" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
<div className="space-y-2"><label className="block text-sm font-bold text-gray-800">发件邮箱地址</label><input data-field="smtp_from_address" type="email" value={typeof smtp.smtp_from_address === 'string' ? smtp.smtp_from_address : (typeof smtp.smtp_user === 'string' ? smtp.smtp_user : '')} onChange={handleTextChange} placeholder="[email protected]" className="w-full ios-input px-4 py-3 rounded-xl text-sm" /></div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<label className="flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700"><input type="checkbox" checked={smtp.smtp_use_tls !== false} onChange={handleTlsChange} />STARTTLS(常用于 587 端口)</label>
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { NotificationChannel,SystemSettings } from '../../../shared/api-contract/notifications';
import type { NotificationChannel,SystemSettings } from './api';
import { createNotificationChannel,deleteNotificationChannel,getNotificationChannels,getSystemSettings,testNotificationChannel,updateNotificationChannel,updateSystemSettings } from './api';
import { useNotifications } from './hooks';
@@ -0,0 +1,123 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 SystemSettings UI 模型;不直接暴露 HTTP DTO。 */
export interface SystemSettings {
/** 默认 AI 模型名称。 */
ai_model?: string;
/** 全局 AI API 密钥。 */
ai_api_key?: string;
/** 全局 AI API 密钥是否已在服务端配置。 */
ai_api_key_configured?: boolean;
/** 全局 AI API 地址。 */
ai_api_url?: string;
/** 全局 AI 基础地址。 */
ai_base_url?: string;
/** 系统默认回复文案。 */
default_reply?: string;
/** 是否允许注册新用户。 */
registration_enabled?: boolean;
/** 系统 SMTP 服务器地址。 */
smtp_server?: string;
/** 系统 SMTP 密码是否已在服务端配置。 */
smtp_password_configured?: boolean;
/** 服务端日志级别。 */
log_level?: 'debug' | 'info' | 'warn' | 'error' | string;
/** 服务端日志格式。 */
log_format?: 'text' | 'json' | string;
/** 续期日志保留天数。 */
renewal_log_retention_days?: number;
/** 远程验证码服务地址。 */
'captcha.remote_service_url'?: string;
/** 远程验证码服务密钥。 */
'captcha.remote_secret_key'?: string;
/** 远程验证码服务密钥是否已在服务端配置。 */
'captcha.remote_secret_key_configured'?: boolean;
/** 远程验证码服务 Cookie 配置。 */
'captcha.remote_pass_cookies'?: boolean | string;
/** 兼容未来配置键的扩展字段。 */
/** 未知设置键只能承载服务端声明的标量值,敏感值不进入该 UI 模型。 */
[key: string]: string | number | boolean | undefined;
}
/** 由当前 feature adapter 归一后的 NotificationChannelType UI 模型;不直接暴露 HTTP DTO。 */
export type NotificationChannelType = 'dingtalk' | 'feishu' | 'bark' | 'webhook' | 'wechat' | 'telegram' | 'email';
/** 由当前 feature adapter 归一后的 NotificationEventType UI 模型;不直接暴露 HTTP DTO。 */
export type NotificationEventType =
| 'account_offline'
| 'account_recovered'
| 'account_disabled'
| 'security_verification'
| 'token_renewal'
| 'delivery_result'
| 'system_error';
/** 由当前 feature adapter 归一后的 NotificationChannel UI 模型;不直接暴露 HTTP DTO。 */
export interface NotificationChannel {
/** 通知渠道标识。 */
id: string;
/** 通知渠道名称。 */
name: string;
/** 通知渠道类型。 */
type: NotificationChannelType;
/** 通知渠道配置。 */
config: Record<string, unknown>;
/** 渠道绑定的事件类型。 */
event_types?: NotificationEventType[];
/** 通知渠道是否启用。 */
enabled: boolean;
/** 创建时间。 */
created_at?: string;
/** 更新时间。 */
updated_at?: string;
}
/** 通知绑定列表中的单条记录。 */
/** 由当前 feature adapter 归一后的 NotificationBinding UI 模型;不直接暴露 HTTP DTO。 */
export interface NotificationBinding {
/** 账号稳定标识,列表归一化后补充。 */
cookie_id?: string;
/** 绑定记录主键。 */
id?: number;
/** 通知渠道主键。 */
channel_id: number;
/** 通知渠道名称。 */
channel_name: string;
/** 绑定是否启用。 */
enabled: boolean;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
/** 通知渠道接口返回的原始具名 DTO。 */
/** 由当前 feature adapter 归一后的 NotificationChannelResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface NotificationChannelResponse {
/** 通知渠道主键。 */
id: number;
/** 通知渠道名称。 */
name: string;
/** 通知渠道类型。 */
type: string;
/** 订阅事件类型 JSON 或兼容文本。 */
event_types?: string;
/** 通知渠道是否启用。 */
enabled: boolean;
/** 所属用户主键。 */
user_id?: number;
}
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { NotificationChannel } from '../../../shared/api-contract/notifications';
import type { NotificationChannel } from './api';
import { buildNotificationPayload,emptyNotificationForm,isCurrentNotificationRequest,normalizeNotificationForm,notificationErrorMessage,notificationEventSummary,validateNotificationForm } from './state';
import type { NotificationForm } from './types';
+16 -3
View File
@@ -10,11 +10,11 @@ OrderRefreshJobCancelResponse,OrderRefreshJobStatusResponse,
OrderRefreshResponse,
OrderSingleRefreshResponse,
PaginatedResponse
} from '../../../shared/api-contract/orders';
} from './models';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { type RequestControlOptions } from '../../../shared/http/client';
import { collectionFrom, objectFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/orders';
export type * from './models';
/** 订单刷新前端最多轮询约 90 秒,超过该预算必须请求取消后端 worker。 */
const orderRefreshPollLimit = 180;
@@ -157,9 +157,22 @@ export const getOrderDetail = async (orderId: string): Promise<{ /** success 表
params: { path: { order_id: orderId } },
signal,
}));
// data 是将可选 transport 字段归一为 UI 模型稳定字符串/布尔值后的订单详情。
const data: OrderDTOResponse = {
...result.data,
spec_name: result.data.spec_name ?? '',
spec_value: result.data.spec_value ?? '',
is_bargain: result.data.is_bargain ?? 0,
system_shipped: result.data.system_shipped ?? false,
receiver_name: result.data.receiver_name ?? '',
receiver_phone: result.data.receiver_phone ?? '',
receiver_address: result.data.receiver_address ?? '',
receiver_city: result.data.receiver_city ?? '',
updated_at: result.data.updated_at ?? result.data.created_at,
};
return {
success: true,
data: result.data
data
};
};
+1 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,Item } from '../../../shared/api-contract/orders';
import type { AccountDetail,Item } from './api';
import { getAccountDetails,getItems,getOrders,importOrders } from './api';
import { useOrderImport,useOrderQuery } from './hooks';
+426
View File
@@ -0,0 +1,426 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 PaginatedResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface PaginatedResponse<T> {
/** 表示查询是否成功。 */
success: boolean;
/** 当前页数据。 */
data: T[];
/** 符合条件的总记录数。 */
total: number;
/** 当前页码。 */
page: number;
/** 每页记录数。 */
page_size: number;
/** 总页数。 */
total_pages: number;
/** 各触发类型的规则计数。 */
trigger_counts?: Record<string, number>;
}
/** 由当前 feature adapter 归一后的 AccountDetail UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountDetail {
/** 闲鱼账号稳定标识。 */
id: string;
/** 账号是否已配置平台凭证;摘要接口只返回状态,不返回 Cookie 明文。 */
cookie_configured?: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 用户为账号设置的备注。 */
remark?: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration?: number;
/** 暂停结束时间的 Unix 秒。 */
paused_until?: number;
/** 当前是否处于暂停状态。 */
paused?: boolean;
// 登录信息
/** 用于密码登录的闲鱼用户名。 */
username?: string;
/** 是否已保存密码登录秘密;摘要接口只返回状态,不返回密码明文。 */
login_password_configured?: boolean;
/** 是否在密码登录时显示浏览器。 */
show_browser?: boolean;
// Frontend helpers
/** 平台账号昵称。 */
nickname?: string;
/** 平台账号头像地址。 */
avatar_url?: string;
/** 资料刷新失败时的说明。 */
profile_error?: string;
/** 当前账号运行状态。 */
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'runtime_conflict' | 'error' | 'stopped' | 'disabled';
/** 当前运行状态的用户可见说明。 */
runtime_message?: string;
/** 当前运行实例是否已连接。 */
runtime_connected?: boolean;
/** 运行状态快照的更新时间。 */
runtime_updated_at?: string;
// AI设置
/** 是否启用账号 AI 回复。 */
ai_enabled?: boolean;
/** 允许的最大折扣比例。 */
max_discount_percent?: number;
/** 允许的最大折扣金额。 */
max_discount_amount?: number;
/** 允许的最大砍价轮次。 */
max_bargain_rounds?: number;
/** 账号自定义提示词。 */
custom_prompts?: 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;
}
/** 由当前 feature adapter 归一后的 OrderStatus UI 模型;不直接暴露 HTTP DTO。 */
export type OrderStatus =
| 'processing'
| 'pending_ship'
| 'shipped'
| 'completed'
| 'cancelled'
| 'refunding'
| 'unknown';
/** 由当前 feature adapter 归一后的 Order UI 模型;不直接暴露 HTTP DTO。 */
export interface Order {
/** 订单本地数据库主键。 */
id: string;
/** 平台订单标识。 */
order_id: string;
/** 订单所属账号标识。 */
cookie_id: string;
/** 订单关联商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品图片地址。 */
item_image?: string;
/** 商品价格文本。 */
item_price?: string;
/** 买家平台标识。 */
buyer_id: string;
/** 购买数量。 */
quantity: number;
/** 订单金额文本。 */
amount: string;
/** 前端归一化后的订单状态。 */
status: OrderStatus;
/** 服务端原始订单状态。 */
order_status?: OrderStatus;
/** 收货人姓名。 */
receiver_name?: string;
/** 收货人电话。 */
receiver_phone?: string;
/** 收货地址。 */
receiver_address?: string;
/** 订单创建时间。 */
created_at?: string;
/** 订单更新时间。 */
updated_at?: string;
}
/** 由当前 feature adapter 归一后的 Item UI 模型;不直接暴露 HTTP DTO。 */
export interface Item {
/** 本地商品数据库主键。 */
id: string | number;
/** 商品所属账号标识。 */
cookie_id: string;
/** 平台商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品描述。 */
item_description?: string;
/** 商品价格文本。 */
item_price?: string;
/** 商品主图地址。 */
item_image?: string; // Inferred from common usage, though not explicitly in list model sometimes
/** 商品分类标识。 */
item_category?: string;
/** 商品详情原始 JSON。 */
item_detail?: string;
/** 是否启用多规格。 */
is_multi_spec?: number | boolean;
/** 是否按数量发货。 */
multi_quantity_delivery?: number | boolean;
/** 是否启用多数量发货兼容字段。 */
is_multi_qty_ship?: number | boolean;
}
/** 订单详情接口返回的原始具名订单 DTO。 */
/** 由当前 feature adapter 归一后的 OrderDTOResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderDTOResponse {
/** 平台订单标识。 */
order_id: string;
/** 关联商品标识。 */
item_id: string;
/** 关联商品标题。 */
item_title: string;
/** 关联商品图片地址。 */
item_image: string;
/** 买家平台标识。 */
buyer_id: string;
/** 商品规格名称。 */
spec_name: string;
/** 商品规格值。 */
spec_value: string;
/** 购买数量文本。 */
quantity: string;
/** 实付金额文本。 */
amount: string;
/** 归一化订单状态。 */
order_status: string;
/** 兼容前端使用的订单状态别名。 */
status: string;
/** 所属账号标识。 */
cookie_id: string;
/** 是否议价订单。 */
is_bargain: number;
/** 是否系统发货。 */
system_shipped: boolean;
/** 收货人姓名。 */
receiver_name: string;
/** 收货人电话。 */
receiver_phone: string;
/** 收货地址。 */
receiver_address: string;
/** 收货城市。 */
receiver_city: string;
/** 创建时间。 */
created_at: string;
/** 更新时间。 */
updated_at: string;
}
/** 订单详情接口的具名响应。 */
/** 由当前 feature adapter 归一后的 OrderDetailResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderDetailResponse extends OrderDTOResponse {
/** 表示查询是否完成。 */
success: boolean;
/** 新版客户端读取的订单对象。 */
data: OrderDTOResponse;
}
/** 订单单条刷新返回的远端详情。 */
/** 由当前 feature adapter 归一后的 OrderRefreshDetailResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshDetailResponse {
/** 购买数量文本。 */
quantity: string;
/** 商品规格名称。 */
spec_name: string;
/** 商品规格值。 */
spec_value: string;
/** 归一化订单状态。 */
order_status: string;
/** 实付金额文本。 */
amount: string;
}
/** 订单单条刷新接口的具名响应。 */
/** 由当前 feature adapter 归一后的 OrderSingleRefreshResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderSingleRefreshResponse {
/** 表示刷新是否完成。 */
success: boolean;
/** 刷新结果说明。 */
message: string;
/** 刷新后的订单详情。 */
order: OrderRefreshDetailResponse;
}
/** 订单批量变更接口的具名响应。 */
/** 由当前 feature adapter 归一后的 OrderBatchResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderBatchResponse {
/** 表示批量操作是否存在部分失败。 */
partial_failure: boolean;
/** 批量操作结果说明。 */
message: string;
/** 订单总数,导入接口提供。 */
total?: number;
/** 成功处理数量。 */
success_count: number;
/** 失败处理数量。 */
failed_count: number;
/** 逐订单兼容结果行。 */
results: OrderBatchResult[];
}
/** 订单批量接口的逐订单结果行。 */
/** 由当前 feature adapter 归一后的 OrderBatchResult UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderBatchResult {
/** 订单平台标识。 */
order_id?: string;
/** 订单动作状态:failed、succeeded 或 reconciliation_required。 */
status?: 'failed' | 'succeeded' | 'reconciliation_required';
/** 表示该订单是否处理成功。 */
success?: boolean;
/** 该订单处理结果说明。 */
message: string;
/** 兼容接口可能返回的账号标识。 */
cookie_id?: string;
/** 待补偿记录标识。 */
reconciliation_id?: string;
/** 本地状态或补偿记录写入警告。 */
reconciliation_warning?: string;
/** 兼容接口可能返回的处理阶段。 */
stage?: string;
/** 允许后端保留尚未结构化的扩展字段。 */
[key: string]: unknown;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
/** 管理员全局统计响应。 */
/** 由当前 feature adapter 归一后的 AdminStats UI 模型;不直接暴露 HTTP DTO。 */
export interface AdminStats {
/** 管理员可见的用户总数。 */ total_users: number;
/** 当前用户拥有的账号总数。 */ total_cookies: number;
/** 已启用账号数量。 */ active_cookies: number;
/** 卡券组总数。 */ total_cards: number;
/** 关键词规则总数。 */ total_keywords: number;
/** 订单总数。 */ total_orders: number;
}
/** 订单域兼容页面使用的数据概览字段。 */
export interface DashboardStats {
/** 当前用户的账号总数。 */ total_cookies: number;
/** 已启用账号数量。 */ active_cookies: number;
/** 卡券组总数。 */ total_cards: number;
/** 关键词规则总数。 */ total_keywords: number;
/** 订单总数。 */ total_orders: number;
/** 可用卡券库存。 */ available_card_stock: number;
}
/** 管理员全局统计响应。 */
/** 由当前 feature adapter 归一后的 AdminStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AdminStatsResponse extends AdminStats {}
/** 当前用户数据概览响应。 */
/** 由当前 feature adapter 归一后的 DashboardStatsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface DashboardStatsResponse extends DashboardStats {}
/** 订单列表刷新逐项结果。 */
/** 由当前 feature adapter 归一后的 OrderRefreshResultResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshResultResponse {
/** 结果所属账号标识。 */
cookie_id?: string;
/** 当前处理阶段。 */
stage?: string;
/** 当前项是否处理成功。 */
success: boolean;
/** 结果说明。 */
message?: string;
/** 发现的新订单数量。 */
discovered?: number;
/** 更新的订单数量。 */
updated?: number;
/** 标记删除的订单数量。 */
/** soft_deleted 表示该订单是否已被本次刷新标记为软删除。 */
soft_deleted?: boolean;
/** 订单平台标识。 */
order_id?: string;
/** 结果错误说明。 */
error?: string;
}
/** 订单列表刷新统计摘要。 */
/** 由当前 feature adapter 归一后的 OrderRefreshSummaryResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshSummaryResponse {
/** 发现的新订单数量。 */
discovered: number;
/** 订单列表更新数量。 */
list_updated: number;
/** 标记删除数量。 */
soft_deleted: number;
/** 需要补全详情的订单数量。 */
detail_total: number;
/** 本次处理订单总数。 */
total: number;
/** 状态发生变化数量。 */
updated: number;
/** 状态未变化数量。 */
no_change: number;
/** 刷新失败数量。 */
failed: number;
}
/** 订单列表刷新响应。 */
/** 由当前 feature adapter 归一后的 OrderRefreshResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshResponse {
/** 是否存在部分失败。 */
partial_failure: boolean;
/** 刷新结果说明。 */
message: string;
/** 刷新统计摘要。 */
summary: OrderRefreshSummaryResponse;
/** 逐项兼容结果。 */
results: OrderRefreshResultResponse[];
}
/** 创建订单刷新后台任务的响应。 */
/** 由当前 feature adapter 归一后的 OrderRefreshJobStartResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshJobStartResponse {
/** 任务是否创建成功。 */
success: boolean;
/** 后台任务标识。 */
job_id: string;
/** 任务当前状态。 */
status: 'queued' | 'running';
}
/** 查询订单刷新后台任务的响应。 */
/** 由当前 feature adapter 归一后的 OrderRefreshJobStatusResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshJobStatusResponse {
/** 查询是否成功。 */
success: boolean;
/** 后台任务标识。 */
job_id: string;
/** 任务当前状态。 */
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
/** 任务失败原因。 */
error_message?: string;
/** 任务成功后的订单刷新结果。 */
result?: OrderRefreshResponse;
}
/** 取消订单刷新后台任务的响应。 */
/** 由当前 feature adapter 归一后的 OrderRefreshJobCancelResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OrderRefreshJobCancelResponse {
/** 取消命令是否成功应用。 */
success: boolean;
/** 被取消的任务标识。 */
job_id: string;
/** 取消后的任务状态。 */
status: 'cancelled';
}
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { Order,OrderRefreshResponse } from '../../../shared/api-contract/orders';
import type { Order,OrderRefreshResponse } from './api';
import { useOrderActions } from './orderActions';
// orderActionMocks 保存订单动作 Hook 测试使用的 API 替身。
@@ -2,7 +2,7 @@
import { cleanup,fireEvent,render,screen,waitFor } from '@testing-library/react';
import React from 'react';
import { afterEach,beforeEach,describe,expect,test,vi } from 'vitest';
import type { Order } from '../../../../shared/api-contract/orders';
import type { Order } from '../api';
// orderListMocks 保存订单页面测试使用的 Hook、API 和子组件替身。
const orderListMocks = vi.hoisted(/* orderListMockFactory 创建订单页面共享替身。 */ () => ({
@@ -1,6 +1,7 @@
import ReactDOMServer from 'react-dom/server';
import { describe,expect,test } from 'vitest';
import type { NotificationChannel,SystemSettings } from '../../shared/api-contract/common';
import type { NotificationChannel } from './notifications/api';
import type { SystemSettings } from './settings/api';
import { CardIcon } from './cards/components/CardIcon';
import { BatchPhaseIndicator } from './items/components/BatchPhaseIndicator';
import { NotificationChannelList } from './notifications/components/NotificationChannelList';
+2 -2
View File
@@ -14,11 +14,11 @@ MutationIDResponse,OperationResponse,
PaginatedResponse,
ReplyRule,
ShippingRule
} from '../../../shared/api-contract/automation';
} from './models';
import { type RequestControlOptions } from '../../../shared/http/client';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { collectionFrom,objectFrom } from '../../../shared/http/contract';
export type * from '../../../shared/api-contract/automation';
export type * from './models';
/** 自动化规则筛选器读取非敏感账号摘要。 */
export const getAccountDetails = async (options?: RequestControlOptions): Promise<AccountDetail[]> => runContractRequest(/* signal 控制规则页账号摘要读取的取消和超时。 */ signal => contractClient.GET('/api/v1/accounts/details', { signal }), options);
+1 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { AccountDetail,Card,DefaultReply,Item,ReplyRule,ShippingRule } from '../../../shared/api-contract/automation';
import type { AccountDetail,Card,DefaultReply,Item,ReplyRule,ShippingRule } from './api';
import {
getAccountDetails,
getAutomationIssues,
+461
View File
@@ -0,0 +1,461 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 PaginatedResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface PaginatedResponse<T> {
/** 表示查询是否成功。 */
success: boolean;
/** 当前页数据。 */
data: T[];
/** 符合条件的总记录数。 */
total: number;
/** 当前页码。 */
page: number;
/** 每页记录数。 */
page_size: number;
/** 总页数。 */
total_pages: number;
/** 各触发类型的规则计数。 */
trigger_counts?: Record<string, number>;
}
/** 由当前 feature adapter 归一后的 AccountDetail UI 模型;不直接暴露 HTTP DTO。 */
export interface AccountDetail {
/** 闲鱼账号稳定标识。 */
id: string;
/** 账号是否已配置平台凭证;摘要接口只返回状态,不返回 Cookie 明文。 */
cookie_configured?: boolean;
/** 账号是否允许运行。 */
enabled: boolean;
/** 是否自动确认订单。 */
auto_confirm: boolean;
/** 用户为账号设置的备注。 */
remark?: string;
/** 自动回复暂停时长,单位为分钟。 */
pause_duration?: number;
/** 暂停结束时间的 Unix 秒。 */
paused_until?: number;
/** 当前是否处于暂停状态。 */
paused?: boolean;
// 登录信息
/** 用于密码登录的闲鱼用户名。 */
username?: string;
/** 是否已保存密码登录秘密;摘要接口只返回状态,不返回密码明文。 */
login_password_configured?: boolean;
/** 是否在密码登录时显示浏览器。 */
show_browser?: boolean;
// Frontend helpers
/** 平台账号昵称。 */
nickname?: string;
/** 平台账号头像地址。 */
avatar_url?: string;
/** 资料刷新失败时的说明。 */
profile_error?: string;
/** 当前账号运行状态。 */
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'runtime_conflict' | 'error' | 'stopped' | 'disabled';
/** 当前运行状态的用户可见说明。 */
runtime_message?: string;
/** 当前运行实例是否已连接。 */
runtime_connected?: boolean;
/** 运行状态快照的更新时间。 */
runtime_updated_at?: string;
// AI设置
/** 是否启用账号 AI 回复。 */
ai_enabled?: boolean;
/** 允许的最大折扣比例。 */
max_discount_percent?: number;
/** 允许的最大折扣金额。 */
max_discount_amount?: number;
/** 允许的最大砍价轮次。 */
max_bargain_rounds?: number;
/** 账号自定义提示词。 */
custom_prompts?: 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;
}
/** 由当前 feature adapter 归一后的 Card UI 模型;不直接暴露 HTTP DTO。 */
export interface Card {
/** 卡券组数值主键。 */
id: number;
/** 卡券组名称。 */
name: string;
/** 卡券组类型。 */
type: 'api' | 'text' | 'data' | 'image';
/** 卡券组说明。 */
description?: string;
/** 卡券组是否启用。 */
enabled: boolean;
// 文本类型
text_content?: string;
// 批量数据类型
data_content?: string;
// API 类型配置
api_config?: {
/** API 卡券请求地址。 */
url: string;
/** API 卡券请求方法。 */
method: 'GET' | 'POST';
/** API 请求超时时间。 */
timeout?: number;
/** API 请求头 JSON。 */
headers?: string;
/** API 请求参数 JSON。 */
params?: string;
};
// 图片类型
/** 图片卡券地址。 */
image_url?: string;
// 通用配置
/** 卡券发送延迟秒数。 */
delay_seconds?: number;
// 多规格配置
/** 是否支持多规格。 */
is_multi_spec?: boolean;
/** 规格名称。 */
spec_name?: string;
/** 规格值。 */
spec_value?: string;
}
/** 由当前 feature adapter 归一后的 Item UI 模型;不直接暴露 HTTP DTO。 */
export interface Item {
/** 本地商品数据库主键。 */
id: string | number;
/** 商品所属账号标识。 */
cookie_id: string;
/** 平台商品标识。 */
item_id: string;
/** 商品标题。 */
item_title?: string;
/** 商品描述。 */
item_description?: string;
/** 商品价格文本。 */
item_price?: string;
/** 商品主图地址。 */
item_image?: string; // Inferred from common usage, though not explicitly in list model sometimes
/** 商品分类标识。 */
item_category?: string;
/** 商品详情原始 JSON。 */
item_detail?: string;
/** 是否启用多规格。 */
is_multi_spec?: number | boolean;
/** 是否按数量发货。 */
multi_quantity_delivery?: number | boolean;
/** 是否启用多数量发货兼容字段。 */
is_multi_qty_ship?: number | boolean;
}
/** 由当前 feature adapter 归一后的 AutomationTriggerType UI 模型;不直接暴露 HTTP DTO。 */
export type AutomationTriggerType = 'order_paid' | 'buyer_reviewed' | 'review_missing_timeout';
/** 由当前 feature adapter 归一后的 AutomationActionType UI 模型;不直接暴露 HTTP DTO。 */
export type AutomationActionType = 'confirm_shipment' | 'send_card' | 'send_text';
// Rules
/** 由当前 feature adapter 归一后的 ShippingRule UI 模型;不直接暴露 HTTP DTO。 */
export interface ShippingRule {
/** 规则标识。 */
id: string;
/** 规则名称。 */
name: string;
/** 规则触发类型。 */
trigger_type: AutomationTriggerType;
/** 规则匹配关键词。 */
item_keyword: string; // Legacy UI helper
/** 规则限定的账号标识。 */
cookie_id?: string;
/** 规则限定的商品标识。 */
item_id?: string;
/** 规则限定的商品标题。 */
item_title?: string;
/** 首个发卡动作使用的卡券组 ID。 */
card_group_id: number; // First send_card action card id
/** 首个发卡动作使用的卡券组名称。 */
card_group_name?: string; // UI helper
/** 规则优先级。 */
priority: number;
/** 规则是否启用。 */
enabled: boolean;
/** 规则原始配置 JSON。 */
config_json?: string;
/** 规则动作列表。 */
actions: AutomationAction[];
/** 规则规格变体列表。 */
variants: ShippingVariant[];
}
/** 由当前 feature adapter 归一后的 AutomationAction UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationAction {
/** 动作标识。 */
id?: string;
/** 动作类型。 */
action_type: AutomationActionType;
/** 动作使用的卡券组 ID。 */
card_id?: number;
/** 动作使用的卡券组名称。 */
card_name?: string;
/** 本次发放数量。 */
delivery_count?: number;
/** 文本消息模板。 */
message_template?: string;
/** 动作延迟秒数。 */
delay_seconds?: number;
/** 动作原始配置 JSON。 */
config_json?: string;
/** 动作是否启用。 */
enabled: boolean;
/** 动作排序序号。 */
sort_order?: number;
}
/** 由当前 feature adapter 归一后的 ShippingVariant UI 模型;不直接暴露 HTTP DTO。 */
export interface ShippingVariant {
/** 规格变体标识。 */
id?: string;
/** 规格名称。 */
spec_name: string;
/** 规格值。 */
spec_value: string;
/** 变体使用的卡券组 ID。 */
card_id: number;
/** 变体使用的卡券组名称。 */
card_name?: string;
/** 卡券类型。 */
card_type?: Card['type'];
/** 变体发放数量。 */
delivery_count: number;
/** 变体是否启用。 */
enabled: boolean;
/** 是否覆盖动作级延迟。 */
delay_override?: boolean;
/** 变体延迟秒数。 */
delay_seconds?: number;
/** 变体原始配置 JSON。 */
config_json?: string;
}
/** 由当前 feature adapter 归一后的 ReplyRule UI 模型;不直接暴露 HTTP DTO。 */
export interface ReplyRule {
/** 回复规则标识。 */
id: string;
/** 触发关键词。 */
keyword: string;
/** 回复正文。 */
reply_content: string;
/** 关键词匹配方式。 */
match_type: 'exact' | 'fuzzy';
/** 规则是否启用。 */
enabled: boolean;
/** 规则限定的商品标识。 */
item_id?: string;
/** 回复类型。 */
type?: 'text' | 'image';
/** 图片回复地址。 */
image_url?: string;
}
/** 由当前 feature adapter 归一后的 DefaultReply UI 模型;不直接暴露 HTTP DTO。 */
export interface DefaultReply {
/** 账号稳定标识。 */
cookie_id: string;
/** 默认回复是否启用。 */
enabled: boolean;
/** 默认回复正文。 */
reply_content: string;
/** 是否对同一会话只回复一次。 */
reply_once: boolean;
/** 默认图片回复地址。 */
reply_image_url?: string;
}
/** 自动化规则动作的原始具名 DTO。 */
/** 由当前 feature adapter 归一后的 AutomationActionResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationActionResponse {
/** 动作稳定标识。 */
id: number;
/** 动作类型。 */
action_type: string;
/** 关联卡券组标识。 */
card_id: number;
/** 关联卡券组名称。 */
card_name: string;
/** 发送数量。 */
delivery_count: number;
/** 消息模板。 */
message_template: string;
/** 延迟秒数。 */
delay_seconds: number;
/** 扩展配置 JSON。 */
config_json: string;
/** 是否启用。 */
enabled: boolean;
/** 执行顺序。 */
sort_order: number;
}
/** 自动化规则的原始具名 DTO。 */
/** 由当前 feature adapter 归一后的 AutomationRuleResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationRuleResponse {
/** 规则稳定标识。 */
id: number;
/** 所属账号标识。 */
cookie_id: string;
/** 关联商品标识。 */
item_id: string;
/** 关联商品标题。 */
item_title: string;
/** 规则名称。 */
name: string;
/** 触发类型。 */
trigger_type: string;
/** 是否启用。 */
enabled: boolean;
/** 规则优先级。 */
priority: number;
/** 扩展配置 JSON。 */
config_json: string;
/** 规则动作列表。 */
actions: AutomationActionResponse[];
/** 创建时间。 */
created_at: string;
/** 更新时间。 */
updated_at: string;
}
/** 自动化规则分页接口的具名响应。 */
/** 由当前 feature adapter 归一后的 AutomationRulePageResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationRulePageResponse {
/** 表示查询是否完成。 */
success: boolean;
/** 当前页规则列表。 */
data: AutomationRuleResponse[];
/** 规则总数。 */
total: number;
/** 当前页码。 */
page: number;
/** 当前页大小。 */
page_size: number;
/** 总页数。 */
total_pages: number;
/** 各触发类型规则数量。 */
trigger_counts: Record<string, number>;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
/** 传统关键词列表项响应。 */
/** 由当前 feature adapter 归一后的 KeywordBasicResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface KeywordBasicResponse {
/** 匹配关键词。 */
keyword: string;
/** 文字回复内容。 */
reply: string;
}
/** 带商品范围的关键词列表项响应。 */
/** 由当前 feature adapter 归一后的 KeywordItemResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface KeywordItemResponse extends KeywordBasicResponse {
/** 限定的商品标识。 */
item_id: string;
}
/** 带类型和主键的关键词列表项响应。 */
/** 由当前 feature adapter 归一后的 KeywordTypedResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface KeywordTypedResponse extends KeywordItemResponse {
/** 关键词规则主键。 */
id: number;
/** 回复类型。 */
type: 'text' | 'image';
/** 图片回复地址。 */
image_url: string;
}
/** 指定商品回复项响应。 */
/** 由当前 feature adapter 归一后的 ItemReplyResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface ItemReplyResponse {
/** 商品平台标识。 */
item_id?: string;
/** 账号稳定标识。 */
cookie_id?: string;
/** 指定商品的回复内容。 */
reply_content: string;
}
/** 默认回复查询响应。 */
/** 由当前 feature adapter 归一后的 DefaultReplyResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface DefaultReplyResponse extends DefaultReply {
/** 账号稳定标识。 */
cookie_id: string;
}
// AutomationIssuesEnvelope 是自动化异常接口的兼容响应。
/** 由当前 feature adapter 归一后的 AutomationIssuesEnvelope UI 模型;不直接暴露 HTTP DTO。 */
export interface AutomationIssuesEnvelope {
/** runs 是待处理的自动化运行记录。 */
runs?: Array<{
/** 记录标识。 */
id: number;
/** 所属账号标识。 */
cookie_id: string;
/** 所属订单标识。 */
order_id: string;
/** 自动化触发类型。 */
trigger_type: string;
/** 外部错误说明。 */
error_message: string;
/** 异常类别。 */
issue_kind: 'external_result_unknown' | 'invalid_snapshot' | 'rule_unavailable' | 'partial_failure' | 'execution_failed';
/** 允许的处理动作。 */
allowed_resolutions: Array<'continue' | 'retry' | 'cancel'>;
/** 当前动作游标。 */
action_cursor: number;
/** 已发送数量。 */
sent_count: number;
/** 更新时间。 */
updated_at: string;
}>;
/** pending_tasks 是延迟自动化任务列表。 */
pending_tasks?: Array<{
/** 任务标识。 */
id: number;
/** 所属账号标识。 */
cookie_id: string;
/** 自动化触发类型。 */
trigger_type: string;
/** 错误说明。 */
error_message: string;
/** 当前重试次数。 */
attempt_count: number;
/** 更新时间。 */
updated_at: string;
}>;
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { describe,expect,test } from 'vitest';
import type { AccountDetail,ShippingRule } from '../../../shared/api-contract/automation';
import type { AccountDetail,ShippingRule } from './api';
import {
accentClasses,
accountLabel,
+2 -2
View File
@@ -1,6 +1,6 @@
import type { OperationResponse,SessionResponse } from '../../../shared/api-contract/session';
import type { OperationResponse,SessionResponse } from './models';
import { contractClient, runContractRequest, type ContractRequestOptions } from '../../../shared/api-contract/client';
export type * from '../../../shared/api-contract/session';
export type * from './models';
/** 会话状态接口返回的只读传输契约。 */
export interface SessionStatusResponse {
+36
View File
@@ -0,0 +1,36 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 SessionResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface SessionResponse {
/** 表示登录或初始化是否成功。 */
success: boolean;
/** 登录成功后的会话 Token。 */
token?: string;
/** 服务端返回的操作说明。 */
message?: string;
/** 当前用户 ID。 */
user_id?: number;
/** 当前用户名。 */
username?: string;
/** 当前用户是否为管理员。 */
is_admin?: boolean;
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
+2 -2
View File
@@ -1,7 +1,7 @@
import type { OperationResponse,SystemSettings } from '../../../shared/api-contract/settings';
import type { OperationResponse,SystemSettings } from './models';
import { contractClient, runContractRequest } from '../../../shared/api-contract/client';
import { type RequestControlOptions } from '../../../shared/http/client';
export type * from '../../../shared/api-contract/settings';
export type * from './models';
/** 设置页面使用的会话状态传输契约,避免跨 feature 依赖。 */
export interface SettingsSessionStatusResponse {
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act,renderHook,waitFor } from '@testing-library/react';
import { beforeEach,describe,expect,test,vi } from 'vitest';
import type { OperationResponse,SystemSettings } from '../../../shared/api-contract/settings';
import type { OperationResponse,SystemSettings } from './api';
import { fetchAIModels,getSystemSettings,updateLoginCredentials,updateSystemSettings,verifySession } from './api';
import { useSettings } from './hooks';
+80
View File
@@ -0,0 +1,80 @@
// models 保存本 feature adapter 输出的 UI 模型;这些模型不直接代表 HTTP DTO。
/** 由当前 feature adapter 归一后的 SystemSettings UI 模型;不直接暴露 HTTP DTO。 */
export interface SystemSettings {
/** 默认 AI 模型名称。 */
ai_model?: string;
/** 全局 AI API 密钥。 */
ai_api_key?: string;
/** 全局 AI API 密钥是否已在服务端配置。 */
ai_api_key_configured?: boolean;
/** 全局 AI API 地址。 */
ai_api_url?: string;
/** 全局 AI 基础地址。 */
ai_base_url?: string;
/** 系统默认回复文案。 */
default_reply?: string;
/** 是否允许注册新用户。 */
registration_enabled?: boolean;
/** 系统 SMTP 服务器地址。 */
smtp_server?: string;
/** 系统 SMTP 密码是否已在服务端配置。 */
smtp_password_configured?: boolean;
/** 服务端日志级别。 */
log_level?: 'debug' | 'info' | 'warn' | 'error' | string;
/** 服务端日志格式。 */
log_format?: 'text' | 'json' | string;
/** 续期日志保留天数。 */
renewal_log_retention_days?: number;
/** 远程验证码服务地址。 */
'captcha.remote_service_url'?: string;
/** 远程验证码服务密钥。 */
'captcha.remote_secret_key'?: string;
/** 远程验证码服务密钥是否已在服务端配置。 */
'captcha.remote_secret_key_configured'?: boolean;
/** 远程验证码服务 Cookie 配置。 */
'captcha.remote_pass_cookies'?: boolean | string;
/** 兼容未来配置键的扩展字段。 */
/** 未知设置键只能承载服务端声明的标量值,敏感值不进入该 UI 模型。 */
[key: string]: string | number | boolean | undefined;
}
/** 由当前 feature adapter 归一后的 AIReplySettings UI 模型;不直接暴露 HTTP DTO。 */
export interface AIReplySettings {
/** 是否启用账号 AI 回复。 */
ai_enabled: boolean;
/** 最大折扣比例。 */
max_discount_percent: number;
/** 最大折扣金额。 */
max_discount_amount?: number;
/** 最大砍价轮次。 */
max_bargain_rounds: number;
/** 自定义提示词。 */
custom_prompts: string;
}
/** AI 模型发现接口的具名响应。 */
/** 由当前 feature adapter 归一后的 AIModelsResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface AIModelsResponse {
/** 远端可用模型名称。 */
models: string[];
}
/** 简单资源创建接口的数值主键响应。 */
/** 由当前 feature adapter 归一后的 MutationIDResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface MutationIDResponse {
/** 资源创建是否完成。 */
success: boolean;
/** 新资源数值主键。 */
id: number;
}
/** 简单变更接口的统一成功响应。 */
/** 由当前 feature adapter 归一后的 OperationResponse UI 模型;不直接暴露 HTTP DTO。 */
export interface OperationResponse {
/** 操作是否完成。 */
success: boolean;
/** 可选的操作说明。 */
message?: string;
/** 操作完成后是否需要重新登录。 */
requires_relogin?: boolean;
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect,test } from 'vitest';
import type { SystemSettings } from '../../../shared/api-contract/settings';
import type { SystemSettings } from './api';
import { buildPersistableSettings,createCredentials,createCredentialsMessage,isCurrentSettingsRequest,validateCredentials } from './state';
// settingsFixture 是覆盖敏感字段过滤和系统配置保留字段的最小草稿。
@@ -2,7 +2,7 @@
import { cleanup,fireEvent,render,screen,waitFor } from '@testing-library/react';
import React from 'react';
import { afterEach,describe,expect,test,vi } from 'vitest';
import type { Item } from '../../shared/api-contract/common';
import type { Item } from '../features/items/api';
import type { DeliveryRuleTarget } from './AuthenticatedShell';
vi.mock('../features/dashboard/pages/Dashboard', /* dashboardMockFactory 提供仪表盘页面的轻量替身。 */ () => {
+7 -10
View File
@@ -1,10 +1,7 @@
// accounts 公开账号摘要、登录信息和账号任务相关传输契约。
/** 账号 feature 使用的 HTTP 传输 DTO;业务页面必须经 feature adapter 转为 UI model。 */
export type {
AIReplySettings, AIReplySettingsResponse, AccountBindingsResponse, AccountDetail,
AccountSummaryResponse, AccountTaskRunResponseEnvelope, AccountTaskSettings,
AccountTaskSettingsResponse, AccountTaskSummary, CookieProfileResponse,
CookieSettingsResponse, NotificationChannel, NotificationChannelResponse,
NotificationEventType, OperationResponse, QRLoginGenerateResponse,
QRLoginStatusResponse, QRLoginVerificationResponse,
} from './transport';
// accounts 只公开 OpenAPI 生成的账号传输类型;UI 模型属于 accounts feature。
import type { components } from './generated/schema';
/** AccountTransport 表示生成的非敏感账号响应,adapter 负责转换为页面模型。 */
export type AccountTransport = components['schemas']['AccountDetailResponse'];
/** QRLoginStatusTransport 表示生成的二维码风控状态响应。 */
export type QRLoginStatusTransport = components['schemas']['QRLoginStatusResponse'];
+7 -7
View File
@@ -1,7 +1,7 @@
// admin 公开管理员和统计相关传输契约。
/** 管理与仪表盘 feature 使用的 HTTP 传输 DTO。 */
export type {
DashboardStats, DashboardStatsResponse, Item, ItemListEnvelope, Order,
OrderAnalytics, OrderAnalyticsResponse, OrderStatus, ValidOrderResponse,
ValidOrdersResponse,
} from './transport';
// admin 只公开 OpenAPI 生成的管理统计传输类型;仪表盘展示模型由 feature 维护。
import type { components } from './generated/schema';
/** DashboardStatsTransport 表示生成的仪表盘概览响应。 */
export type DashboardStatsTransport = components['schemas']['DashboardStatsResponse'];
/** AnalyticsTransport 表示生成的订单分析响应。 */
export type AnalyticsTransport = components['schemas']['AnalyticsResponse'];
+5 -9
View File
@@ -1,9 +1,5 @@
// automation 公开自动化规则、动作和异常相关传输契约。
/** 自动化规则 feature 使用的 HTTP 传输 DTO。 */
export type {
AccountDetail, AutomationAction, AutomationIssuesEnvelope,
AutomationRulePageResponse, AutomationRuleResponse, AutomationTriggerType,
Card, DefaultReply, DefaultReplyResponse, Item, KeywordTypedResponse,
MutationIDResponse, OperationResponse, PaginatedResponse, ReplyRule,
ShippingRule, ShippingVariant,
} from './transport';
// automation 只公开 OpenAPI 生成的自动化传输类型;规则编辑模型属于 rules feature。
import type { components } from './generated/schema';
/** OperationTransport 表示生成的通用成功响应。 */
export type OperationTransport = components['schemas']['OperationResponse'];
+5 -3
View File
@@ -1,3 +1,5 @@
// cards 公开卡片、批量卡片和卡片追加数据相关传输契约。
/** 卡券 feature 使用的 HTTP 传输 DTO。 */
export type { Card, CardAppendResponse, CardBatchResponse, MutationIDResponse, OperationResponse } from './transport';
// cards 只公开 OpenAPI 生成的卡券传输类型;卡券展示模型属于 cards feature。
import type { components } from './generated/schema';
/** CardTransport 表示生成的卡券响应。 */
export type CardTransport = components['schemas']['CardResponse'];
+9 -3
View File
@@ -1,3 +1,9 @@
// chat 公开会话、消息和已读状态相关传输契约。
/** 聊天 feature 使用的 HTTP 传输 DTO。 */
export type { AccountDetail, ChatMessage, ChatSession, OperationResponse } from './transport';
// chat 只公开 OpenAPI 生成的聊天传输类型;聊天状态模型属于 chat feature。
import type { components } from './generated/schema';
/** ChatMessageTransport 表示生成的单条聊天消息。 */
export type ChatMessageTransport = components['schemas']['ChatMessage'];
/** ChatSessionTransport 表示生成的聊天会话摘要。 */
export type ChatSessionTransport = components['schemas']['ChatSession'];
/** ChatWebSocketTransport 表示生成的 WebSocket 事件联合。 */
export type ChatWebSocketTransport = components['schemas']['ChatWebSocketEvent'];
+6
View File
@@ -56,6 +56,12 @@ const contractBaseUrl = typeof location === 'undefined' ? 'http://localhost' : l
export const contractClient = createClient<paths>({ baseUrl: contractBaseUrl, fetch: contractFetch });
// contractMultipartBody 将原生 FormData 作为对应 OpenAPI multipart operation 的运行时载荷交给客户端。
// OpenAPI 3.1 的 binary 字段会生成 string 类型,而浏览器必须保留 FormData 边界和 File 对象;泛型仅由调用位置的生成 operation 请求体推导。
export function contractMultipartBody<T>(form: FormData): NonNullable<T> {
return form as unknown as NonNullable<T>;
}
// runContractRequest 执行类型化 operation,并恢复旧 client 的超时、取消和 ApiError 行为。
export async function runContractRequest<T>(
execute: (signal: AbortSignal) => Promise<ContractResult<T>>,
+5 -3
View File
@@ -1,3 +1,5 @@
// common 公开分页、错误和跨领域基础传输契约;具体 feature 应优先导入自己的领域模块。
/** 跨 feature 的最小 HTTP 传输 DTO,不得承载领域专有类型。 */
export type { ApiErrorResponse, Item, NotificationChannel, PaginatedResponse, SystemSettings } from './transport';
// common 只公开跨 feature 的 OpenAPI 生成传输类型。
import type { components } from './generated/schema';
/** ApiErrorResponse 表示统一错误 envelope,供共享 HTTP 运行时识别错误。 */
export type ApiErrorResponse = components['schemas']['ErrorResponse'];
+498 -88
View File
@@ -1813,6 +1813,320 @@ export interface components {
ApiResponse: {
success: boolean;
};
NotificationUncertainOutboxItem: {
id: number;
channel_id: number;
owner_user_id?: number;
event_type: string;
attempt_count: number;
uncertain_at: number;
has_error: boolean;
};
NotificationUncertainOutboxResponse: {
total: number;
items: components["schemas"]["NotificationUncertainOutboxItem"][];
};
AutomationRunIssue: {
id: number;
cookie_id: string;
order_id: string;
trigger_type: string;
error_message: string;
issue_kind: string;
allowed_resolutions: string[];
action_cursor: number;
sent_count: number;
updated_at: string;
};
DeferredAutomationIssue: {
id: number;
cookie_id: string;
trigger_type: string;
error_message: string;
attempt_count: number;
updated_at: string;
};
AutomationIssuesResponse: {
runs: components["schemas"]["AutomationRunIssue"][];
pending_tasks: components["schemas"]["DeferredAutomationIssue"][];
};
AutomationActionResponse: {
id: number;
action_type: string;
card_id: number;
card_name: string;
delivery_count: number;
message_template: string;
delay_seconds: number;
config_json: string;
enabled: boolean;
sort_order: number;
};
AutomationRuleResponse: {
id: number;
cookie_id: string;
item_id: string;
item_title: string;
name: string;
trigger_type: string;
enabled: boolean;
priority: number;
config_json: string;
actions: components["schemas"]["AutomationActionResponse"][];
created_at: string;
updated_at: string;
};
AutomationRuleListResponse: components["schemas"]["AutomationRuleResponse"][];
AutomationRulePageResponse: {
success: boolean;
data: components["schemas"]["AutomationRuleResponse"][];
total: number;
page: number;
page_size: number;
total_pages: number;
trigger_counts: {
[key: string]: number;
};
};
AutomationRulesResponse: components["schemas"]["AutomationRuleListResponse"] | components["schemas"]["AutomationRulePageResponse"];
DefaultReplyResponse: {
cookie_id?: string;
enabled: boolean;
reply_content: string;
reply_image_url?: string;
reply_once: boolean;
};
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;
};
AccountTaskSettingsUpdateRequest: {
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;
};
AccountTaskRunRequest: {
/** @enum {string} */
task_type: "auto_rate" | "auto_polish";
};
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;
};
AccountTaskRunsResponse: {
runs: components["schemas"]["AccountTaskRunResponse"][];
};
AccountTaskSummaryResponse: {
/** @enum {string} */
task_type: "auto_rate" | "auto_polish";
found: number;
success: number;
failed: number;
skipped: number;
message?: string;
};
AccountTaskRunResponseEnvelope: {
success: boolean;
summary: components["schemas"]["AccountTaskSummaryResponse"];
};
AccountBindingsResponse: {
cookie_id: string;
channel_ids: number[] | null;
};
KeywordBasicResponse: {
keyword: string;
reply: string;
};
KeywordBasicListResponse: components["schemas"]["KeywordBasicResponse"][];
KeywordItemResponse: {
keyword: string;
reply: string;
item_id: string;
};
KeywordItemListResponse: components["schemas"]["KeywordItemResponse"][];
KeywordTypedResponse: {
id: number;
keyword: string;
reply: string;
item_id: string;
type: string;
image_url: string;
};
KeywordTypedListResponse: components["schemas"]["KeywordTypedResponse"][];
DefaultReplyMapResponse: {
[key: string]: components["schemas"]["DefaultReplyResponse"];
};
DefaultReplyListResponse: components["schemas"]["DefaultReplyResponse"][] | null;
ItemReplyResponse: {
item_id?: string;
cookie_id?: string;
reply_content: string;
};
ItemReplyListResponse: components["schemas"]["ItemReplyResponse"][];
AIReplySettingsResponse: {
cookie_id?: string;
ai_enabled: boolean;
max_discount_percent: number;
max_discount_amount: number;
max_bargain_rounds: number;
custom_prompts: string;
};
AIReplySettingsMapResponse: {
[key: string]: components["schemas"]["AIReplySettingsResponse"];
};
SettingsResponse: {
[key: string]: string;
};
UserSettingResponse: {
value: string;
};
PublishCategoryResponse: {
cat_id: string;
cat_name: string;
channel_cat_id?: string;
tb_cat_id?: string;
};
PublishCardAction: {
card_id: number;
delivery_count: number;
delay_seconds: number;
};
PublishCardAutomation: {
enabled: boolean;
actions: components["schemas"]["PublishCardAction"][] | null;
};
PublishReviewRequestConfig: {
enabled: boolean;
after_shipped_hours: number;
message: string;
max_attempts: number;
delay_seconds: number;
};
PublishAutomationConfig: {
paid_delivery: components["schemas"]["PublishCardAutomation"];
review_gift: components["schemas"]["PublishCardAutomation"];
review_request: components["schemas"]["PublishReviewRequestConfig"];
};
PublishLocation: {
area?: string;
city?: string;
division_id?: string;
longitude?: number;
latitude?: number;
poi_id?: string;
poi_name?: string;
province?: string;
};
ItemPublishBatchPreviewRow: {
row_no: number;
valid: boolean;
errors?: string[];
cookie_id: string;
title: string;
price: string;
quantity: number;
images: string[];
category: components["schemas"]["PublishCategoryResponse"];
automation: components["schemas"]["PublishAutomationConfig"];
};
ItemPublishBatchPreviewResponse: {
success: boolean;
preview_id: string;
total: number;
valid: number;
invalid: number;
rows: components["schemas"]["ItemPublishBatchPreviewRow"][];
};
ItemPublishBatchRowResponse: {
id: number;
row_no: number;
cookie_id: string;
title: string;
price: string;
quantity: number;
images: string[];
category: components["schemas"]["PublishCategoryResponse"];
automation: components["schemas"]["PublishAutomationConfig"];
status: string;
item_id: string;
item_url: string;
error_message: string;
failure_kind: string;
};
ItemPublishBatchResponse: {
id: string;
status: string;
filename: string;
total: number;
success: number;
failed: number;
pending: number;
running: number;
retryable: number;
rows: components["schemas"]["ItemPublishBatchRowResponse"][];
location: components["schemas"]["PublishLocation"];
publish_interval_seconds: number;
created_at: string;
updated_at: string;
};
ItemPublishBatchListResponse: {
batches: components["schemas"]["ItemPublishBatchResponse"][];
};
BatchIDResponse: {
success: boolean;
batch_id: string;
};
BatchCancelResponse: {
success: boolean;
status: string;
};
CategoryRecommendationResponse: {
success: boolean;
category: components["schemas"]["PublishCategoryResponse"];
};
CategoryRecommendationRequest: {
cookie_id: string;
keyword: string;
};
ItemPublishBatchStartRequest: {
preview_id?: string;
batch_id?: string;
};
ItemPublishBatchPreviewRequest: {
default_cookie_id: string;
/** Format: binary */
file: string;
/** Format: binary */
images_zip?: string;
fallback_category_id?: string;
fallback_category_name?: string;
fallback_channel_category_id?: string;
fallback_tb_category_id?: string;
location?: string;
publish_interval_seconds?: number;
};
HealthResponse: {
/** @enum {string} */
status: "ok";
@@ -1828,6 +2142,47 @@ export interface components {
/** @enum {string} */
database: "unavailable";
};
CardMutationRequest: {
name?: string;
/** @enum {string} */
type?: "api" | "text" | "data" | "image";
api_config?: string;
text_content?: string;
data_content?: string;
image_url?: string;
description?: string;
enabled?: boolean;
delay_seconds?: number;
is_multi_spec?: boolean;
spec_name?: string;
spec_value?: string;
};
CardAppendRequest: {
content: string;
};
CardBatchResultResponse: {
row_no: number;
success: boolean;
id?: number;
name: string;
type?: string;
error?: string;
};
CardBatchResponse: {
success: boolean;
total: number;
created: number;
failed: number;
rows: components["schemas"]["CardBatchResultResponse"][];
};
CardAppendResponse: {
success: boolean;
added: number;
};
MutationIDResponse: {
success: boolean;
id: number;
};
CardResponse: {
id: number;
name: string;
@@ -1859,6 +2214,18 @@ export interface components {
multi_quantity_delivery: boolean;
is_multi_qty_ship: boolean;
};
ItemListArrayResponse: components["schemas"]["ItemListResponse"][];
ItemDetailResponse: {
cookie_id: string;
item_id: string;
item_title: string;
item_description: string;
item_category: string;
item_price: string;
item_detail: string;
is_multi_spec: boolean;
multi_quantity_delivery: boolean;
};
NotificationChannelResponse: {
id: number;
name: string;
@@ -1867,6 +2234,25 @@ export interface components {
enabled: boolean;
user_id?: number;
};
NotificationChannelCreateRequest: {
name: string;
type: string;
config?: string;
event_types?: string;
enabled?: boolean;
};
NotificationChannelPatchRequest: {
name?: string;
type?: string;
config?: string;
event_types?: string;
enabled?: boolean;
};
NotificationBindingRequest: {
channel_ids?: number[];
channel_id?: number;
enabled?: boolean;
};
NotificationBinding: {
id: number;
channel_id: number;
@@ -2123,21 +2509,21 @@ export interface components {
item_title: string;
item_image: string;
buyer_id: string;
spec_name: string;
spec_value: string;
spec_name?: string;
spec_value?: string;
quantity: string;
amount: string;
order_status: string;
status: string;
cookie_id: string;
is_bargain: number;
system_shipped: boolean;
receiver_name: string;
receiver_phone: string;
receiver_address: string;
receiver_city: string;
is_bargain?: number;
system_shipped?: boolean;
receiver_name?: string;
receiver_phone?: string;
receiver_address?: string;
receiver_city?: string;
created_at: string;
updated_at: string;
updated_at?: string;
};
OrderListResponse: {
success: boolean;
@@ -2405,7 +2791,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AccountTaskSettingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -2464,7 +2850,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["AccountTaskSettingsUpdateRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -2472,7 +2862,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AccountTaskSettingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -2531,7 +2921,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["AccountTaskRunRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -2539,7 +2933,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AccountTaskRunResponseEnvelope"];
};
};
/** @description 统一错误响应 */
@@ -2606,7 +3000,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AccountTaskRunsResponse"];
};
};
/** @description 统一错误响应 */
@@ -3905,7 +4299,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["AdminCookie"][];
"application/json": components["schemas"]["AdminCookie"][] | null;
};
};
/** @description 统一错误响应 */
@@ -3970,7 +4364,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["NotificationUncertainOutboxResponse"];
};
};
/** @description 统一错误响应 */
@@ -4569,7 +4963,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AutomationIssuesResponse"];
};
};
/** @description 统一错误响应 */
@@ -4708,7 +5102,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AutomationRulesResponse"];
};
};
/** @description 统一错误响应 */
@@ -5096,7 +5490,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["CardMutationRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -5104,7 +5502,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["MutationIDResponse"];
};
};
/** @description 统一错误响应 */
@@ -5171,7 +5569,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["CardResponse"];
};
};
/** @description 统一错误响应 */
@@ -5230,7 +5628,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["CardMutationRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -5364,7 +5766,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["CardAppendRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -5372,7 +5778,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["CardAppendResponse"];
};
};
/** @description 统一错误响应 */
@@ -5439,7 +5845,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["CardResponse"];
};
};
/** @description 统一错误响应 */
@@ -5496,7 +5902,14 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"multipart/form-data": {
/** Format: binary */
file: string;
};
};
};
responses: {
/** @description 成功 */
200: {
@@ -5504,7 +5917,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["CardBatchResponse"];
};
};
/** @description 统一错误响应 */
@@ -5990,7 +6403,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["DefaultReplyMapResponse"];
};
};
/** @description 统一错误响应 */
@@ -6057,7 +6470,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["DefaultReplyResponse"];
};
};
/** @description 统一错误响应 */
@@ -6323,7 +6736,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["DefaultReplyListResponse"];
};
};
/** @description 统一错误响应 */
@@ -6525,7 +6938,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemDetailResponse"];
};
};
/** @description 统一错误响应 */
@@ -6864,7 +7277,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemListArrayResponse"];
};
};
/** @description 统一错误响应 */
@@ -7126,7 +7539,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemPublishBatchListResponse"];
};
};
/** @description 统一错误响应 */
@@ -7183,7 +7596,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["ItemPublishBatchStartRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -7191,7 +7608,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["BatchIDResponse"];
};
};
/** @description 统一错误响应 */
@@ -7258,7 +7675,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemPublishBatchResponse"];
};
};
/** @description 统一错误响应 */
@@ -7325,7 +7742,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["OperationResponse"];
};
};
/** @description 统一错误响应 */
@@ -7392,7 +7809,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["BatchCancelResponse"];
};
};
/** @description 统一错误响应 */
@@ -7526,7 +7943,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["BatchIDResponse"];
};
};
/** @description 统一错误响应 */
@@ -7583,7 +8000,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"multipart/form-data": components["schemas"]["ItemPublishBatchPreviewRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -7591,7 +8012,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemPublishBatchPreviewResponse"];
};
};
/** @description 统一错误响应 */
@@ -7648,7 +8069,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["CategoryRecommendationRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -7656,7 +8081,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["CategoryRecommendationResponse"];
};
};
/** @description 统一错误响应 */
@@ -7723,7 +8148,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AccountBindingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -7782,7 +8207,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["NotificationBindingRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -7912,7 +8341,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["NotificationChannelCreateRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -7920,7 +8353,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["MutationIDResponse"];
};
};
/** @description 统一错误响应 */
@@ -7979,7 +8412,11 @@ export interface operations {
};
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
"application/json": components["schemas"]["NotificationChannelPatchRequest"];
};
};
responses: {
/** @description 成功 */
200: {
@@ -8385,7 +8822,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["NotificationUncertainOutboxResponse"];
};
};
/** @description 统一错误响应 */
@@ -9139,15 +9576,6 @@ export interface operations {
};
};
responses: {
/** @description 成功 */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
};
};
/** @description 统一错误响应 */
400: {
headers: {
@@ -9215,15 +9643,6 @@ export interface operations {
};
requestBody?: never;
responses: {
/** @description 成功 */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
};
};
/** @description 统一错误响应 */
400: {
headers: {
@@ -9291,15 +9710,6 @@ export interface operations {
};
requestBody?: never;
responses: {
/** @description 成功 */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
};
};
/** @description 统一错误响应 */
400: {
headers: {
@@ -9643,7 +10053,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["KeywordBasicListResponse"];
};
};
/** @description 统一错误响应 */
@@ -9845,7 +10255,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["KeywordItemListResponse"];
};
};
/** @description 统一错误响应 */
@@ -9979,7 +10389,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["KeywordTypedListResponse"];
};
};
/** @description 统一错误响应 */
@@ -10180,7 +10590,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemReplyListResponse"];
};
};
/** @description 统一错误响应 */
@@ -10248,7 +10658,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["ItemReplyResponse"];
};
};
/** @description 统一错误响应 */
@@ -10384,7 +10794,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["OperationResponse"];
};
};
/** @description 统一错误响应 */
@@ -10928,7 +11338,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AIReplySettingsMapResponse"];
};
};
/** @description 统一错误响应 */
@@ -10995,7 +11405,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["AIReplySettingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -11328,7 +11738,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["SettingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -11393,7 +11803,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["SettingsResponse"];
};
};
/** @description 统一错误响应 */
@@ -11460,7 +11870,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiResponse"];
"application/json": components["schemas"]["UserSettingResponse"];
};
};
/** @description 统一错误响应 */
+5 -8
View File
@@ -1,8 +1,5 @@
// items 公开商品、发布地点和批量发布相关传输契约。
/** 商品 feature 使用的 HTTP 传输 DTO。 */
export type {
AccountDetail, BatchCancelResponse, BatchIDResponse, CategoryRecommendationResponse,
Item, ItemDetailResponse, ItemPublishBatchPreviewResponse,
ItemPublishBatchResponse, ItemPublishResponse, ItemSyncResponse,
OperationResponse, PublishLocation, ShippingRule,
} from './transport';
// items 只公开 OpenAPI 生成的商品传输类型;发布和兼容模型属于 items feature。
import type { components } from './generated/schema';
/** ItemTransport 表示生成的商品列表行。 */
export type ItemTransport = components['schemas']['ItemListResponse'];
@@ -1,7 +1,7 @@
// notifications 公开通知渠道、绑定和事件相关传输契约。
/** 通知 feature 使用的 HTTP 传输 DTO。 */
export type {
MutationIDResponse, NotificationBinding, NotificationChannel,
NotificationChannelResponse, NotificationChannelType, NotificationEventType,
OperationResponse, SystemSettings,
} from './transport';
// notifications 只公开 OpenAPI 生成的通知传输类型;表单状态属于 notifications feature。
import type { components } from './generated/schema';
/** NotificationChannelTransport 表示生成的通知渠道摘要。 */
export type NotificationChannelTransport = components['schemas']['NotificationChannelResponse'];
/** NotificationBindingsTransport 表示生成的账号通知绑定映射。 */
export type NotificationBindingsTransport = components['schemas']['NotificationBindingsByAccount'];
+7 -9
View File
@@ -1,9 +1,7 @@
// orders 公开订单、发货和订单刷新相关传输契约。
/** 订单 feature 使用的 HTTP 传输 DTO。 */
export type {
AccountDetail, AdminStatsResponse, Item, OperationResponse, Order,
OrderBatchResponse, OrderDTOResponse, OrderDetailResponse,
OrderRefreshJobCancelResponse, OrderRefreshJobStartResponse,
OrderRefreshJobStatusResponse, OrderRefreshResponse, OrderSingleRefreshResponse,
OrderStatus, PaginatedResponse,
} from './transport';
// orders 只公开 OpenAPI 生成的订单传输类型;订单 UI 模型属于 orders feature。
import type { components } from './generated/schema';
/** OrderTransport 表示生成的订单行。 */
export type OrderTransport = components['schemas']['OrderDTO'];
/** OrderRefreshTransport 表示生成的订单刷新结果。 */
export type OrderRefreshTransport = components['schemas']['OrderRefreshResponse'];
+5 -3
View File
@@ -1,3 +1,5 @@
// session 公开登录、初始化和二维码会话相关传输契约。
/** 会话 feature 使用的 HTTP 传输 DTO。 */
export type { OperationResponse, SessionResponse } from './transport';
// session 只公开 OpenAPI 生成的会话传输类型;页面会话状态属于 session feature。
import type { components } from './generated/schema';
/** SessionTransport 表示生成的登录或初始化响应。 */
export type SessionTransport = components['schemas']['SessionResponse'];
+7 -3
View File
@@ -1,3 +1,7 @@
// settings 公开系统、AI 和默认回复设置相关传输契约。
/** 系统设置 feature 使用的 HTTP 传输 DTO。 */
export type { AIModelsResponse, OperationResponse, SystemSettings } from './transport';
// settings 只公开 OpenAPI 生成的设置传输类型;表单状态属于 settings feature。
import type { components } from './generated/schema';
/** SystemSettingsTransport 表示受约束动态键的设置响应。 */
export type SystemSettingsTransport = components['schemas']['SystemSettingsResponse'];
/** AIModelsTransport 表示生成的模型发现响应。 */
export type AIModelsTransport = components['schemas']['AIModelsResponse'];
File diff suppressed because it is too large. Load diff