2025-04-08 16:01:10 +02:00
|
|
|
import type { z } from "zod";
|
|
|
|
|
import { InstanceMetadataSchema } from "../schemas/instance.ts";
|
|
|
|
|
import type { JSONObject } from "../types.ts";
|
|
|
|
|
import { ImageContentFormat } from "./contentformat.ts";
|
|
|
|
|
import { Entity } from "./entity.ts";
|
|
|
|
|
|
|
|
|
|
export class InstanceMetadata extends Entity {
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override name = "InstanceMetadata";
|
2025-04-08 16:01:10 +02:00
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public constructor(
|
|
|
|
|
public override data: z.infer<typeof InstanceMetadataSchema>,
|
|
|
|
|
) {
|
2025-04-08 16:01:10 +02:00
|
|
|
super(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get logo(): ImageContentFormat | undefined {
|
|
|
|
|
return this.data.logo
|
|
|
|
|
? new ImageContentFormat(this.data.logo)
|
|
|
|
|
: undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get banner(): ImageContentFormat | undefined {
|
|
|
|
|
return this.data.banner
|
|
|
|
|
? new ImageContentFormat(this.data.banner)
|
|
|
|
|
: undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override fromJSON(
|
|
|
|
|
json: JSONObject,
|
|
|
|
|
): Promise<InstanceMetadata> {
|
2025-04-08 16:01:10 +02:00
|
|
|
return InstanceMetadataSchema.parseAsync(json).then(
|
|
|
|
|
(u) => new InstanceMetadata(u),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|