feat(federation): Port to Versia 0.6

This commit is contained in:
Jesse Wierzbinski 2026-02-25 02:34:27 +01:00
parent de69f27877
commit fca30b4dad
No known key found for this signature in database
62 changed files with 1614 additions and 2008 deletions

View file

@ -1,7 +1,7 @@
import type { z } from "zod";
import { DislikeSchema, LikeSchema } from "../../schemas/extensions/likes.ts";
import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts";
import { Entity, Reference } from "../entity.ts";
export class Like extends Entity {
public static override name = "pub.versia:likes/Like";
@ -10,6 +10,14 @@ export class Like extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get liked(): Reference {
return Reference.fromString(this.data.liked);
}
public static override fromJSON(json: JSONObject): Promise<Like> {
return LikeSchema.parseAsync(json).then((u) => new Like(u));
}
@ -22,6 +30,14 @@ export class Dislike extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get disliked(): Reference {
return Reference.fromString(this.data.disliked);
}
public static override fromJSON(json: JSONObject): Promise<Dislike> {
return DislikeSchema.parseAsync(json).then((u) => new Dislike(u));
}

View file

@ -1,7 +1,7 @@
import type { z } from "zod";
import { VoteSchema } from "../../schemas/extensions/polls.ts";
import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts";
import { Entity, Reference } from "../entity.ts";
export class Vote extends Entity {
public static override name = "pub.versia:polls/Vote";
@ -10,6 +10,14 @@ export class Vote extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get poll(): Reference {
return Reference.fromString(this.data.poll);
}
public static override fromJSON(json: JSONObject): Promise<Vote> {
return VoteSchema.parseAsync(json).then((u) => new Vote(u));
}

View file

@ -1,7 +1,7 @@
import type { z } from "zod";
import { ReactionSchema } from "../../schemas/extensions/reactions.ts";
import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts";
import { Entity, Reference } from "../entity.ts";
export class Reaction extends Entity {
public static override name = "pub.versia:reactions/Reaction";
@ -10,6 +10,14 @@ export class Reaction extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get object(): Reference {
return Reference.fromString(this.data.object);
}
public static override fromJSON(json: JSONObject): Promise<Reaction> {
return ReactionSchema.parseAsync(json).then((u) => new Reaction(u));
}

View file

@ -1,7 +1,7 @@
import type { z } from "zod";
import { ReportSchema } from "../../schemas/extensions/reports.ts";
import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts";
import { Entity, Reference } from "../entity.ts";
export class Report extends Entity {
public static override name = "pub.versia:reports/Report";
@ -10,6 +10,14 @@ export class Report extends Entity {
super(data);
}
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));
}
public static override fromJSON(json: JSONObject): Promise<Report> {
return ReportSchema.parseAsync(json).then((u) => new Report(u));
}

View file

@ -1,7 +1,7 @@
import type { z } from "zod";
import { ShareSchema } from "../../schemas/extensions/share.ts";
import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts";
import { Entity, Reference } from "../entity.ts";
export class Share extends Entity {
public static override name = "pub.versia:share/Share";
@ -10,6 +10,14 @@ export class Share extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get shared(): Reference {
return Reference.fromString(this.data.shared);
}
public static override fromJSON(json: JSONObject): Promise<Share> {
return ShareSchema.parseAsync(json).then((u) => new Share(u));
}