refactor(data): replace schema classes with readonly models

This commit is contained in:
2026-07-17 13:21:40 +08:00
parent 3437312167
commit ae97366a4a
103 changed files with 1220 additions and 2117 deletions
@@ -1,14 +1,14 @@
import type { UnlockPrivateMessageInput } from "@/data/repositories/interfaces";
import {
ChatHistoryResponse,
ChatSendResponse,
SendMessageRequest,
UnlockHistoryRequest,
SendMessageRequestSchema,
UnlockHistoryRequestSchema,
UnlockHistoryResponse,
UnlockPrivateRequest,
UnlockPrivateRequestSchema,
UnlockPrivateResponse,
} from "@/data/schemas/chat";
import type { ChatApi } from "@/data/services/api";
import type { UnlockPrivateMessageInput } from "@/data/repositories/interfaces";
import { Result } from "@/utils/result";
export class ChatRemoteDataSource {
@@ -20,7 +20,7 @@ export class ChatRemoteDataSource {
options?: { image?: string; useWebSocket?: boolean },
): Promise<Result<ChatSendResponse>> {
return Result.wrap(async () => {
const request = SendMessageRequest.from({
const request = SendMessageRequestSchema.parse({
characterId,
message,
image: options?.image ?? "",
@@ -42,7 +42,7 @@ export class ChatRemoteDataSource {
input: UnlockPrivateMessageInput,
): Promise<Result<UnlockPrivateResponse>> {
return Result.wrap(() =>
this.api.unlockPrivateMessage(UnlockPrivateRequest.from(input)),
this.api.unlockPrivateMessage(UnlockPrivateRequestSchema.parse(input)),
);
}
@@ -50,7 +50,7 @@ export class ChatRemoteDataSource {
characterId: string,
): Promise<Result<UnlockHistoryResponse>> {
return Result.wrap(() =>
this.api.unlockHistory(UnlockHistoryRequest.from({ characterId })),
this.api.unlockHistory(UnlockHistoryRequestSchema.parse({ characterId })),
);
}
}