server/packages/sdk/entities/collection.ts
Jesse Wierzbinski 709e1c6087
Some checks failed
CodeQL Scan / Analyze (push) Failing after 0s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / lint (push) Has been cancelled
Build Docker Images / check (push) Has been cancelled
Build Docker Images / tests (push) Has been cancelled
Build Docker Images / detect-circular (push) Has been cancelled
Mirror to Codeberg / Mirror (push) Has been cancelled
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been cancelled
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been cancelled
refactor(federation): Make references always have domains
2026-04-03 13:34:19 +02:00

43 lines
1.1 KiB
TypeScript

import type { z } from "zod";
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>,
instanceDomain: string,
) {
super(data, instanceDomain);
}
public static override fromJSON(
json: JSONObject,
instanceDomain: string,
): Promise<Collection> {
return CollectionSchema.parseAsync(json).then(
(u) => new Collection(u, instanceDomain),
);
}
}
export class URICollection extends Entity {
public constructor(
public override data: z.infer<typeof URICollectionSchema>,
instanceDomain: string,
) {
super(data, instanceDomain);
}
public static override fromJSON(
json: JSONObject,
instanceDomain: string,
): Promise<URICollection> {
return URICollectionSchema.parseAsync(json).then(
(u) => new URICollection(u, instanceDomain),
);
}
}