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,20 +1,24 @@
import { describe, expect, it } from "vitest";
import { DEFAULT_CHARACTER_ID } from "@/data/constants/character";
import { ChatSendResponse } from "@/data/schemas/chat";
import {
ChatSendResponseSchema,
type ChatSendResponse,
type ChatSendResponseInput,
} from "@/data/schemas/chat";
import type { ChatState } from "@/stores/chat/chat-state";
import {
applyNetworkHistoryLoadedOutput,
applyHttpSendOutput,
applyNetworkHistoryLoadedOutput,
countLockedHistoryMessages,
localMessagesToUi,
sendResponseToUiMessage,
} from "@/stores/chat/helper";
function makeResponse(
overrides: Partial<Parameters<typeof ChatSendResponse.from>[0]> = {},
overrides: Partial<ChatSendResponseInput> = {},
): ChatSendResponse {
return ChatSendResponse.from({
return ChatSendResponseSchema.parse({
reply: "AI reply",
messageId: "msg-1",
isGuest: false,
@@ -100,9 +104,7 @@ describe("sendResponseToUiMessage", () => {
}),
);
expect(message.audioUrl).toBe(
"https://example.com/unlocked-voice.mp3",
);
expect(message.audioUrl).toBe("https://example.com/unlocked-voice.mp3");
expect(message.locked).toBe(false);
});