/**
 * 消息同步响应 DTO
 */
import {
  ChatSyncDataSchema,
  type ChatSyncDataInput,
  type ChatSyncDataData,
} from "@/data/schemas/chat/chat_sync_data";

export class ChatSyncData {
  declare readonly syncedCount: number;
  declare readonly totalHistory: number;

  private constructor(input: ChatSyncDataInput) {
    const data = ChatSyncDataSchema.parse(input);
    Object.assign(this, data);
    Object.freeze(this);
  }

  static from(input: ChatSyncDataInput): ChatSyncData {
    return new ChatSyncData(input);
  }

  static fromJson(json: unknown): ChatSyncData {
    return ChatSyncData.from(json as ChatSyncDataInput);
  }

  toJson(): ChatSyncDataData {
    return ChatSyncDataSchema.parse(this);
  }
}
