75e685d418
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.
28 lines
952 B
TypeScript
28 lines
952 B
TypeScript
/**
|
|
* 用户模型
|
|
* 原始 Dart: User (lib/data/models/user/user.dart)
|
|
*/
|
|
import { z } from "zod";
|
|
import { PersonalityTraitsSchema, PERSONALITY_TRAITS_DEFAULTS } from "./personality_traits";
|
|
|
|
export const UserSchema = z.object({
|
|
id: z.string(),
|
|
username: z.string(),
|
|
email: z.string().default(""),
|
|
platform: z.string().default("web"),
|
|
intimacy: z.number().default(0),
|
|
dolBalance: z.number().default(0),
|
|
relationshipStage: z.string().default("密友"),
|
|
currentMood: z.string().default("happy"),
|
|
personalityTraits: PersonalityTraitsSchema.default(PERSONALITY_TRAITS_DEFAULTS),
|
|
preferredLanguage: z.string().default(""),
|
|
createdAt: z.string().default(""),
|
|
lastMessageAt: z.string().default(""),
|
|
avatarUrl: z.string().default(""),
|
|
loginProvider: z.string().default("email"),
|
|
isGuest: z.boolean().default(false),
|
|
});
|
|
|
|
export type UserInput = z.input<typeof UserSchema>;
|
|
export type UserData = z.output<typeof UserSchema>;
|