refactor(api): remove unused network endpoints

This commit is contained in:
2026-07-07 16:29:21 +08:00
parent ab9b227969
commit b5bf81de59
47 changed files with 1 additions and 971 deletions
-45
View File
@@ -11,15 +11,11 @@ export class ApiPath {
// ============ 功能模块分组 ============
private static readonly _auth = `${ApiPath._baseUrl}/auth`;
private static readonly _verify = `${ApiPath._baseUrl}/verify`;
private static readonly _user = `${ApiPath._baseUrl}/user`;
private static readonly _payment = `${ApiPath._baseUrl}/payment`;
private static readonly _chat = `${ApiPath._baseUrl}/chat`;
// ============ 认证相关 ============
/** 发送验证码 */
static readonly sendCode = `${ApiPath._verify}/send`;
/** 邮箱密码登录 */
static readonly emailLogin = `${ApiPath._auth}/login`;
@@ -29,9 +25,6 @@ export class ApiPath {
/** 设备自动登录 */
static readonly guestLogin = `${ApiPath._auth}/guest`;
/** Apple 登录 */
static readonly appleLogin = `${ApiPath._auth}/login/apple`;
/** Google 登录 */
static readonly googleLogin = `${ApiPath._auth}/login/google`;
@@ -51,24 +44,9 @@ export class ApiPath {
static readonly getCurrentUser = `${ApiPath._auth}/me`;
// ============ 用户相关 ============
/** 获取用户统计信息 */
static readonly userStats = `${ApiPath._user}/stats`;
/** 获取个人信息(与 /auth/me 等价) */
static readonly userProfile = `${ApiPath._user}/profile`;
/** 更新个人信息 */
static readonly updateProfile = `${ApiPath._user}/profile`;
/** 上传头像 */
static readonly userAvatar = `${ApiPath._user}/avatar`;
/** 查询积分余额 */
static readonly userCredits = `${ApiPath._user}/credits`;
/** 查询积分操作历史 */
static readonly userCreditsHistory = `${ApiPath._user}/credits/history`;
/** 获取当前用户权益快照 */
static readonly userEntitlements = `${ApiPath._user}/entitlements`;
@@ -82,20 +60,6 @@ export class ApiPath {
/** 获取商品套餐列表 */
static readonly paymentPlans = `${ApiPath._payment}/plans`;
/** 查询当前用户 VIP 状态 */
static readonly paymentVipStatus = `${ApiPath._payment}/vip-status`;
/** @deprecated PAYWALL_API 使用 paymentPlans。 */
static readonly paymentProducts = ApiPath.paymentPlans;
/** 申请退款 */
static readonly paymentRefund = `${ApiPath._payment}/refund`;
/** 获取商品详情路径 */
static getPaymentProductDetail(productId: string): string {
return `${ApiPath.paymentProducts}/${productId}`;
}
// ============ 聊天相关 ============
/** 发送消息 */
static readonly chatSend = `${ApiPath._chat}/send`;
@@ -103,15 +67,6 @@ export class ApiPath {
/** 获取聊天历史 */
static readonly chatHistory = `${ApiPath._chat}/history`;
/** 语音转文字(STT */
static readonly chatStt = `${ApiPath._chat}/stt`;
/** 同步游客消息 */
static readonly chatSync = `${ApiPath._chat}/sync`;
/** 上传图片 */
static readonly chatUploadImage = `${ApiPath._chat}/upload-image`;
/** 解锁私密消息 */
static readonly chatUnlockPrivate = `${ApiPath._chat}/unlock-private`;
+1 -24
View File
@@ -10,7 +10,6 @@ import { httpClient } from "./http_client";
import { ApiPath } from "./api_path";
import { ApiEnvelope, unwrap } from "./response_helper";
import {
AppleLoginRequest,
FacebookLoginRequest,
FbIdLoginRequest,
GoogleLoginRequest,
@@ -21,7 +20,6 @@ import {
RefreshTokenRequest,
RefreshTokenResponse,
RegisterRequest,
SendCodeRequest,
} from "@/data/dto/auth";
import { User } from "@/data/dto/user";
import type { UserData } from "@/data/schemas/user/user";
@@ -30,16 +28,6 @@ import { Logger } from "@/utils";
const log = new Logger("DataServicesApiAuthApi");
export class AuthApi {
/**
* 发送验证码
*/
async sendCode(body: SendCodeRequest): Promise<void> {
await httpClient<ApiEnvelope<unknown>>(ApiPath.sendCode, {
method: "POST",
body: body.toJson(),
});
}
/**
* 邮箱密码登录
*/
@@ -61,17 +49,6 @@ export class AuthApi {
});
}
/**
* Apple 登录
*/
async appleLogin(body: AppleLoginRequest): Promise<LoginResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.appleLogin, {
method: "POST",
body: body.toJson(),
});
return LoginResponse.fromJson(unwrap(env) as Record<string, unknown>);
}
/**
* Google 登录
*/
@@ -112,7 +89,7 @@ export class AuthApi {
* 不要再用 `unwrap` + `LogoutResponse.fromJson` 解析 —— Zod schema 是 z.object
* 对 null 会抛 ZodError "Invalid input: expected object, received null"。
*
* 对齐 `register` / `sendCode` 的写法:调通就完事,不解析响应体。
* 对齐 `register` 的写法:调通就完事,不解析响应体。
*/
async logout(): Promise<void> {
await httpClient<ApiEnvelope<unknown>>(ApiPath.logout, {
-45
View File
@@ -10,12 +10,7 @@ import { ApiEnvelope, unwrap } from "./response_helper";
import {
ChatHistoryResponse,
ChatSendResponse,
ChatSyncData,
ChatSyncRequest,
ImageUploadResponse,
SendMessageRequest,
SttData,
SyncMessage,
UnlockHistoryResponse,
UnlockPrivateRequest,
UnlockPrivateResponse,
@@ -45,46 +40,6 @@ export class ChatApi {
);
}
/**
* 语音转文字(multipart 上传)
*/
async speechToText(audio: Blob | File): Promise<SttData> {
const formData = new FormData();
formData.append("audio", audio);
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.chatStt, {
method: "POST",
body: formData,
});
return SttData.fromJson(unwrap(env) as Record<string, unknown>);
}
/**
* 同步游客消息
*/
async syncMessages(messages: SyncMessage[]): Promise<ChatSyncData> {
const body = ChatSyncRequest.from({ messages });
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.chatSync, {
method: "POST",
body: body.toJson(),
});
return ChatSyncData.fromJson(unwrap(env) as Record<string, unknown>);
}
/**
* 上传图片
*/
async uploadImage(image: Blob | File): Promise<ImageUploadResponse> {
const formData = new FormData();
formData.append("image", image);
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.chatUploadImage,
{ method: "POST", body: formData }
);
return ImageUploadResponse.fromJson(
unwrap(env) as Record<string, unknown>
);
}
/**
* 解锁单条历史付费 / 私密消息
*/
-12
View File
@@ -8,7 +8,6 @@ import {
CreatePaymentOrderResponse,
PaymentOrderStatusResponse,
PaymentPlansResponse,
PaymentVipStatusResponse,
} from "@/data/dto/payment";
import { ApiPath } from "./api_path";
@@ -61,17 +60,6 @@ export class PaymentApi {
);
}
/**
* 查询当前用户 VIP 状态
*/
async getVipStatus(): Promise<PaymentVipStatusResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.paymentVipStatus,
);
return PaymentVipStatusResponse.fromJson(
unwrap(env) as Record<string, unknown>,
);
}
}
/**
-49
View File
@@ -8,26 +8,12 @@ import { httpClient } from "./http_client";
import { ApiPath } from "./api_path";
import { ApiEnvelope, unwrap } from "./response_helper";
import {
CreditsData,
CreditsHistoryData,
UpdateProfileRequest,
User,
UserEntitlements,
UserStatsResponse,
} from "@/data/dto/user";
import type { UserData } from "@/data/schemas/user/user";
export class UserApi {
/**
* 获取用户统计信息
*/
async getUserStats(): Promise<UserStatsResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.userStats);
return UserStatsResponse.fromJson(
unwrap(env) as Record<string, unknown>
);
}
/**
* 获取个人信息
*/
@@ -36,41 +22,6 @@ export class UserApi {
return User.fromJson(unwrap(env) as UserData);
}
/**
* 更新个人资料
*/
async updateProfile(body: UpdateProfileRequest): Promise<User> {
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.updateProfile, {
method: "PUT",
body: body.toJson(),
});
return User.fromJson(unwrap(env) as UserData);
}
/**
* 查询积分余额
*/
async getCredits(): Promise<CreditsData> {
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.userCredits);
return CreditsData.fromJson(unwrap(env) as Record<string, unknown>);
}
/**
* 查询积分操作历史
*/
async getCreditsHistory(
limit = 50,
offset = 0
): Promise<CreditsHistoryData> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.userCreditsHistory,
{ query: { limit, offset } }
);
return CreditsHistoryData.fromJson(
unwrap(env) as Record<string, unknown>
);
}
/**
* 获取当前用户权益快照
*/