refactor(data): merge DTO models into schemas

This commit is contained in:
2026-07-17 12:47:18 +08:00
parent 2796010971
commit eac3d8f0a7
274 changed files with 1466 additions and 1956 deletions
@@ -1,7 +1,7 @@
import { vi } from "vitest";
import { fromPromise } from "xstate";
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
import { userMachine } from "@/stores/user/user-machine";
import type { UserFetchData } from "@/stores/user/machine/actors/profile";
import type { InitData } from "@/stores/user/machine/actors/session";
+1 -1
View File
@@ -1,4 +1,4 @@
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
import type { UserEntitlementSnapshotData } from "@/data/schemas/user";
export function toView(u: {
+1
View File
@@ -5,3 +5,4 @@ export * from "./user-events";
export * from "./helper";
export * from "./user-machine";
export * from "./user-state";
export * from "./user-view";
+1 -1
View File
@@ -1,6 +1,6 @@
import { fromPromise } from "xstate";
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
import { getUserRepository } from "@/data/repositories/user_repository";
import type { UserEntitlementSnapshotData } from "@/data/schemas/user";
import { UserStorage } from "@/data/storage/user/user_storage";
+1 -1
View File
@@ -1,6 +1,6 @@
import { fromPromise } from "xstate";
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
import { getAuthRepository } from "@/data/repositories/auth_repository";
import type { UserEntitlementSnapshotData } from "@/data/schemas/user";
import { UserStorage } from "@/data/storage/user/user_storage";
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* User 状态机:事件联合
*/
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
export type UserEvent =
| { type: "UserInit" }
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* User 状态机:State 形状 + 初始值
*/
import type { UserView } from "@/data/dto/user";
import type { UserView } from "@/stores/user/user-view";
export interface UserState {
currentUser: UserView | null;
+15
View File
@@ -0,0 +1,15 @@
import { z } from "zod";
export const UserViewSchema = z.object({
id: z.string(),
username: z.string(),
countryCode: z.string(),
creditBalance: z.number(),
dailyFreeChatLimit: z.number(),
dailyFreeChatRemaining: z.number(),
dailyFreePrivateLimit: z.number(),
dailyFreePrivateRemaining: z.number(),
isVip: z.boolean(),
});
export type UserView = z.infer<typeof UserViewSchema>;