阶段四:完成 React Feature 化和异步状态修复
This commit is contained in:
1 parent
4227e3dd56
commit
e92549da48
176 files changed
+849
-650
No files matched your search
@@ -0,0 +1,10 @@
|
||||
// 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';
|
||||
@@ -0,0 +1,7 @@
|
||||
// admin 公开管理员和统计相关传输契约。
|
||||
/** 管理与仪表盘 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type {
|
||||
DashboardStats, DashboardStatsResponse, Item, ItemListEnvelope, Order,
|
||||
OrderAnalytics, OrderAnalyticsResponse, OrderStatus, ValidOrderResponse,
|
||||
ValidOrdersResponse,
|
||||
} from './transport';
|
||||
@@ -0,0 +1,9 @@
|
||||
// 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';
|
||||
@@ -0,0 +1,3 @@
|
||||
// cards 公开卡片、批量卡片和卡片追加数据相关传输契约。
|
||||
/** 卡券 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type { Card, CardAppendResponse, CardBatchResponse, MutationIDResponse, OperationResponse } from './transport';
|
||||
@@ -0,0 +1,3 @@
|
||||
// chat 公开会话、消息和已读状态相关传输契约。
|
||||
/** 聊天 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type { AccountDetail, ChatMessage, ChatSession, OperationResponse } from './transport';
|
||||
@@ -0,0 +1,3 @@
|
||||
// common 公开分页、错误和跨领域基础传输契约;具体 feature 应优先导入自己的领域模块。
|
||||
/** 跨 feature 的最小 HTTP 传输 DTO,不得承载领域专有类型。 */
|
||||
export type { ApiErrorResponse, Item, NotificationChannel, PaginatedResponse, SystemSettings } from './transport';
|
||||
@@ -0,0 +1,8 @@
|
||||
// items 公开商品、发布地点和批量发布相关传输契约。
|
||||
/** 商品 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type {
|
||||
AccountDetail, BatchCancelResponse, BatchIDResponse, CategoryRecommendationResponse,
|
||||
Item, ItemDetailResponse, ItemPublishBatchPreviewResponse,
|
||||
ItemPublishBatchResponse, ItemPublishResponse, ItemSyncResponse,
|
||||
OperationResponse, PublishLocation, ShippingRule,
|
||||
} from './transport';
|
||||
@@ -0,0 +1,7 @@
|
||||
// notifications 公开通知渠道、绑定和事件相关传输契约。
|
||||
/** 通知 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type {
|
||||
MutationIDResponse, NotificationBinding, NotificationChannel,
|
||||
NotificationChannelResponse, NotificationChannelType, NotificationEventType,
|
||||
OperationResponse, SystemSettings,
|
||||
} from './transport';
|
||||
@@ -0,0 +1,9 @@
|
||||
// orders 公开订单、发货和订单刷新相关传输契约。
|
||||
/** 订单 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type {
|
||||
AccountDetail, AdminStatsResponse, Item, OperationResponse, Order,
|
||||
OrderBatchResponse, OrderDTOResponse, OrderDetailResponse,
|
||||
OrderRefreshJobCancelResponse, OrderRefreshJobStartResponse,
|
||||
OrderRefreshJobStatusResponse, OrderRefreshResponse, OrderSingleRefreshResponse,
|
||||
OrderStatus, PaginatedResponse,
|
||||
} from './transport';
|
||||
@@ -0,0 +1,3 @@
|
||||
// session 公开登录、初始化和二维码会话相关传输契约。
|
||||
/** 会话 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type { OperationResponse, SessionResponse } from './transport';
|
||||
@@ -0,0 +1,3 @@
|
||||
// settings 公开系统、AI 和默认回复设置相关传输契约。
|
||||
/** 系统设置 feature 使用的 HTTP 传输 DTO。 */
|
||||
export type { AIModelsResponse, OperationResponse, SystemSettings } from './transport';
|
||||
File renamed without changes.
@@ -59,7 +59,7 @@ describe('request helpers', () => {
|
||||
await get('/bad');
|
||||
} catch (error /* error 是普通 JSON 请求必须保留结构化 envelope 的异常。 */) {
|
||||
expect(error).toBeInstanceOf(ApiError);
|
||||
expect(error).toMatchObject({ status: 400, code: 'bad_request', requestId: 'req-1', details: { field: 'title' }, payload });
|
||||
expect(error).toMatchObject({ status: 400, code: 'bad_request', requestId: 'req-1', request_id: 'req-1', details: { field: 'title' }, payload });
|
||||
}
|
||||
} /* 测试回调验证:surfaces unified backend errors。 */);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiErrorResponse } from '../api-contract';
|
||||
import type { ApiErrorResponse } from '../api-contract/common';
|
||||
|
||||
type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
|
||||
@@ -35,6 +35,8 @@ export class ApiError extends Error {
|
||||
readonly code: string;
|
||||
// requestId 是服务端请求追踪标识,用户反馈问题时可安全提供给运维。
|
||||
readonly requestId?: string;
|
||||
// request_id 保持服务端错误契约的原始字段名,供需要透传原始 HTTP 语义的 feature adapter 使用。
|
||||
readonly request_id?: string;
|
||||
// details 是服务端提供的结构化恢复或审计信息,不包含客户端主动拼接的兼容字段。
|
||||
readonly details?: Record<string, unknown>;
|
||||
// payload 是保留给既有上传流程和诊断代码的原始响应载荷。
|
||||
@@ -47,6 +49,7 @@ export class ApiError extends Error {
|
||||
this.status = status;
|
||||
this.code = isApiErrorResponse(payload) ? payload.code : `http_${status}`;
|
||||
this.requestId = isApiErrorResponse(payload) ? payload.request_id : undefined;
|
||||
this.request_id = this.requestId;
|
||||
this.details = isApiErrorResponse(payload) ? payload.details : undefined;
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import YdisksLogo, { YdisksBrandIcon } from './YdisksLogo';
|
||||
|
||||
Reference in new issue
Block a user