refactor(data): merge DTO models into schemas
This commit is contained in:
@@ -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,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: {
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from "./user-events";
|
||||
export * from "./helper";
|
||||
export * from "./user-machine";
|
||||
export * from "./user-state";
|
||||
export * from "./user-view";
|
||||
|
||||
@@ -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,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,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,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;
|
||||
|
||||
@@ -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>;
|
||||
Reference in New Issue
Block a user