Files
cozsweet-frontend-nextjs/src/data/services/dto/chat/sync_message.ts
T
admin 661e417619 refactor(data): consolidate data layer under services namespace
- Move src/data/{api,dto,schemas} directories to src/data/services/*
- Update all relative imports across the codebase to reference new paths
- Use CSS color tokens for splash button gradient in splash-button.module.css
- Add responsive sizes attribute to splash background image
- Add JSDoc documentation to splash-background component referencing original Dart implementation
2026-06-09 16:44:05 +08:00

33 lines
746 B
TypeScript

/**
* 待同步的单条消息 DTO
*/
import {
SyncMessageSchema,
type SyncMessageInput,
type SyncMessageData,
} from "@/data/services/schemas/chat/sync_message";
export class SyncMessage {
declare readonly role: string;
declare readonly content: string;
declare readonly timestamp: string;
private constructor(input: SyncMessageInput) {
const data = SyncMessageSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: SyncMessageInput): SyncMessage {
return new SyncMessage(input);
}
static fromJson(json: unknown): SyncMessage {
return SyncMessage.from(json as SyncMessageInput);
}
toJson(): SyncMessageData {
return SyncMessageSchema.parse(this);
}
}