41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {
|
|
PrivateRoomMomentSchema,
|
|
type PrivateRoomMomentData,
|
|
type PrivateRoomMomentInput,
|
|
} from "@/data/schemas/private-room";
|
|
|
|
export class PrivateRoomMoment {
|
|
declare readonly momentId: string;
|
|
declare readonly author: PrivateRoomMomentData["author"];
|
|
declare readonly publishedAt: string | null;
|
|
declare readonly timeText: string;
|
|
declare readonly title: string;
|
|
declare readonly content: string | null;
|
|
declare readonly text: string | null;
|
|
declare readonly textPreview: string;
|
|
declare readonly mediaCount: number;
|
|
declare readonly images: PrivateRoomMomentData["images"];
|
|
declare readonly locked: boolean;
|
|
declare readonly unlockCost: number;
|
|
|
|
protected constructor(input: PrivateRoomMomentInput, freeze = true) {
|
|
const data = PrivateRoomMomentSchema.parse(input);
|
|
Object.assign(this, data);
|
|
if (freeze) Object.freeze(this);
|
|
}
|
|
|
|
static from(input: PrivateRoomMomentInput): PrivateRoomMoment {
|
|
return new PrivateRoomMoment(input);
|
|
}
|
|
|
|
static fromJson(json: unknown): PrivateRoomMoment {
|
|
return PrivateRoomMoment.from(json as PrivateRoomMomentInput);
|
|
}
|
|
|
|
toJson(): PrivateRoomMomentData {
|
|
return PrivateRoomMomentSchema.parse(this);
|
|
}
|
|
}
|
|
|
|
export type PrivateRoomProfile = import("@/data/schemas/private-room").PrivateRoomProfileData;
|