mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
32 lines
896 B
TypeScript
32 lines
896 B
TypeScript
import type { z } from "zod/v4";
|
|
import {
|
|
CollectionSchema,
|
|
URICollectionSchema,
|
|
} from "../schemas/collection.ts";
|
|
import type { JSONObject } from "../types.ts";
|
|
import { Entity } from "./entity.ts";
|
|
|
|
export class Collection extends Entity {
|
|
public constructor(public override data: z.infer<typeof CollectionSchema>) {
|
|
super(data);
|
|
}
|
|
|
|
public static override fromJSON(json: JSONObject): Promise<Collection> {
|
|
return CollectionSchema.parseAsync(json).then((u) => new Collection(u));
|
|
}
|
|
}
|
|
|
|
export class URICollection extends Entity {
|
|
public constructor(
|
|
public override data: z.infer<typeof URICollectionSchema>,
|
|
) {
|
|
super(data);
|
|
}
|
|
|
|
public static override fromJSON(json: JSONObject): Promise<URICollection> {
|
|
return URICollectionSchema.parseAsync(json).then(
|
|
(u) => new URICollection(u),
|
|
);
|
|
}
|
|
}
|