2025-07-07 03:42:35 +02:00
|
|
|
import type { z } from "zod/v4";
|
2025-04-08 16:01:10 +02:00
|
|
|
import {
|
|
|
|
|
CollectionSchema,
|
|
|
|
|
URICollectionSchema,
|
|
|
|
|
} from "../schemas/collection.ts";
|
|
|
|
|
import type { JSONObject } from "../types.ts";
|
|
|
|
|
import { Entity } from "./entity.ts";
|
|
|
|
|
|
|
|
|
|
export class Collection extends Entity {
|
2025-05-23 17:29:27 +02:00
|
|
|
public constructor(public override data: z.infer<typeof CollectionSchema>) {
|
2025-04-08 16:01:10 +02:00
|
|
|
super(data);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override fromJSON(json: JSONObject): Promise<Collection> {
|
2025-04-08 16:01:10 +02:00
|
|
|
return CollectionSchema.parseAsync(json).then((u) => new Collection(u));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class URICollection extends Entity {
|
2025-05-23 17:29:27 +02:00
|
|
|
public constructor(
|
|
|
|
|
public override data: z.infer<typeof URICollectionSchema>,
|
|
|
|
|
) {
|
2025-04-08 16:01:10 +02:00
|
|
|
super(data);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 17:29:27 +02:00
|
|
|
public static override fromJSON(json: JSONObject): Promise<URICollection> {
|
2025-04-08 16:01:10 +02:00
|
|
|
return URICollectionSchema.parseAsync(json).then(
|
|
|
|
|
(u) => new URICollection(u),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|