2025-11-21 08:31:02 +01:00
|
|
|
import type { z } from "zod";
|
2025-04-08 16:01:10 +02:00
|
|
|
import { ReportSchema } from "../../schemas/extensions/reports.ts";
|
|
|
|
|
import type { JSONObject } from "../../types.ts";
|
2026-02-25 02:34:27 +01:00
|
|
|
import { Entity, Reference } from "../entity.ts";
|
2025-04-08 16:01:10 +02:00
|
|
|
|
|
|
|
|
export class Report extends Entity {
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override name = "pub.versia:reports/Report";
|
2025-04-08 16:01:10 +02:00
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public constructor(public override data: z.infer<typeof ReportSchema>) {
|
2025-04-08 16:01:10 +02:00
|
|
|
super(data);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 02:34:27 +01:00
|
|
|
public get author(): Reference | null {
|
|
|
|
|
return this.data.author ? Reference.fromString(this.data.author) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get reported(): Reference[] {
|
|
|
|
|
return this.data.reported.map((r) => Reference.fromString(r));
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override fromJSON(json: JSONObject): Promise<Report> {
|
2025-04-08 16:01:10 +02:00
|
|
|
return ReportSchema.parseAsync(json).then((u) => new Report(u));
|
|
|
|
|
}
|
|
|
|
|
}
|