refactor(data): split models into separate dto and schema modules

Reorganize the data layer by separating DTOs (Data Transfer Objects) from
Zod validation schemas into distinct directory structures. Previously,
all model types were imported from a single `@/data/models` barrel
file, mixing request/response classes with validation schemas.

Changes:
- Update API files (auth, chat, metrics, user) to import DTOs from
  specific paths under `@/data/dto/*` instead of the models barrel
- Move user schema to `@/data/schemas/user/user` for type-only imports
- Create dedicated Zod schema files under `@/data/schemas/*` for
  auth and chat domain models (e.g., AppleLoginRequestSchema,
  SendMessageRequestSchema, SyncMessageSchema, SttDataSchema)
- Improve discoverability and tree-shaking by co-locating schemas
  with their respective domain areas

This is a non-functional refactor that lays the groundwork for
clearer separation between transport-layer types and runtime
validation.
This commit is contained in:
2026-06-08 19:14:40 +08:00
parent 67a72783fe
commit 75e685d418
89 changed files with 1119 additions and 853 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
import {
GuestChatQuotaSchema,
type GuestChatQuotaData,
} from "@/data/models";
} from "@/data/schemas/chat/guest_chat_quota";
import { z } from "zod";
import { LocalStorage } from "../local_storage";
+2 -2
View File
@@ -6,13 +6,13 @@
* 对齐 Dart 端 `IChatStorage`lib/data/services/storage/chat/ichat_storage.dart):
* - 游客每日聊天配额 + 游客总配额 两个独立字段的 CRUD
*
* 注:`GuestChatQuota` 模型见 `src/data/models/chat/guest_chat_quota.ts`
* 注:`GuestChatQuota` 模型见 `src/data/dto/chat/guest_chat_quota.ts`
* 数据形态 `{ remaining: number, date: string }`。
* 跨天重置逻辑(`needsReset`)保留在 `GuestChatQuota` 类上,存储层只做读写。
*/
import type { Result } from "../result";
import type { GuestChatQuotaData } from "@/data/models";
import type { GuestChatQuotaData } from "@/data/schemas/chat/guest_chat_quota";
export interface IChatStorage {
getGuestDailyChatQuota(): Promise<Result<GuestChatQuotaData | null>>;
+2 -2
View File
@@ -7,12 +7,12 @@
* - User 对象 / userId / avatarUrl 三个独立字段的 CRUD
* - `clearUserData()` 批量清空
*
* 注:完整 User 模型见 `src/data/models/user/user.ts`,本接口允许存 JSON 字符串,
* 注:完整 User 模型见 `src/data/dto/user/user.ts`,本接口允许存 JSON 字符串,
* 具体序列化由实现层通过 Zod schema 校验后转换为 `User` 类实例。
*/
import type { Result } from "../result";
import type { UserData } from "@/data/models";
import type { UserData } from "@/data/schemas/user/user";
export interface IUserStorage {
getUser(): Promise<Result<UserData | null>>;
+1 -1
View File
@@ -15,7 +15,7 @@
* - 单例挂在 class 静态字段,HMR 复用安全
*/
import { UserSchema, type UserData } from "@/data/models";
import { UserSchema, type UserData } from "@/data/schemas/user/user";
import { LocalStorage } from "../local_storage";
import { type Result as ResultT } from "../result";
import { StorageKeys } from "../storage_keys";