/** * 用户统计响应 * 原始 Dart: UserStatsResponse (lib/data/models/user/user_stats_response.dart) */ import { z } from "zod"; import { PersonalityTraits, PERSONALITY_TRAITS_DEFAULTS, PersonalityTraitsSchema, } from "./personality_traits"; import { RecentMemory, RecentMemorySchema } from "./recent_memory"; export const UserStatsResponseSchema = z.object({ userId: z.string(), username: z.string(), platform: z.string(), intimacy: z.number(), relationshipStage: z.string(), dolBalance: z.number(), totalMessages: z.number(), lastMessageAt: z.string().default(""), accountCreatedAt: z.string().default(""), currentMood: z.string().default(""), personalityTraits: PersonalityTraitsSchema.default( PERSONALITY_TRAITS_DEFAULTS ), recentMemories: z.array(RecentMemorySchema).default([]), promptTokensTotal: z.number().default(0), completionTokensTotal: z.number().default(0), cacheHitTokensTotal: z.number().default(0), tokensTotal: z.number().default(0), }); export type UserStatsResponseInput = z.input; export type UserStatsResponseData = z.output; export class UserStatsResponse { declare readonly userId: string; declare readonly username: string; declare readonly platform: string; declare readonly intimacy: number; declare readonly relationshipStage: string; declare readonly dolBalance: number; declare readonly totalMessages: number; declare readonly lastMessageAt: string; declare readonly accountCreatedAt: string; declare readonly currentMood: string; declare readonly personalityTraits: PersonalityTraits; declare readonly recentMemories: RecentMemory[]; declare readonly promptTokensTotal: number; declare readonly completionTokensTotal: number; declare readonly cacheHitTokensTotal: number; declare readonly tokensTotal: number; private constructor(data: UserStatsResponseData) { Object.assign(this, data); Object.freeze(this); } static from(input: UserStatsResponseInput): UserStatsResponse { return new UserStatsResponse(UserStatsResponseSchema.parse(input)); } static fromJson(json: unknown): UserStatsResponse { return UserStatsResponse.from(json as UserStatsResponseInput); } toJson(): UserStatsResponseData { return UserStatsResponseSchema.parse(this); } }