mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(federation): ♻️ Rewrite federation SDK
This commit is contained in:
parent
ad1dc13a51
commit
d638610361
72 changed files with 2137 additions and 738 deletions
28
packages/federation/entities/extensions/likes.ts
Normal file
28
packages/federation/entities/extensions/likes.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import type { z } from "zod";
|
||||
import { DislikeSchema, LikeSchema } from "../../schemas/extensions/likes.ts";
|
||||
import type { JSONObject } from "../../types.ts";
|
||||
import { Entity } from "../entity.ts";
|
||||
|
||||
export class Like extends Entity {
|
||||
public static name = "pub.versia:likes/Like";
|
||||
|
||||
public constructor(public data: z.infer<typeof LikeSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Like> {
|
||||
return LikeSchema.parseAsync(json).then((u) => new Like(u));
|
||||
}
|
||||
}
|
||||
|
||||
export class Dislike extends Entity {
|
||||
public static name = "pub.versia:likes/Dislike";
|
||||
|
||||
public constructor(public data: z.infer<typeof DislikeSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Dislike> {
|
||||
return DislikeSchema.parseAsync(json).then((u) => new Dislike(u));
|
||||
}
|
||||
}
|
||||
16
packages/federation/entities/extensions/polls.ts
Normal file
16
packages/federation/entities/extensions/polls.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import type { z } from "zod";
|
||||
import { VoteSchema } from "../../schemas/extensions/polls.ts";
|
||||
import type { JSONObject } from "../../types.ts";
|
||||
import { Entity } from "../entity.ts";
|
||||
|
||||
export class Vote extends Entity {
|
||||
public static name = "pub.versia:polls/Vote";
|
||||
|
||||
public constructor(public data: z.infer<typeof VoteSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Vote> {
|
||||
return VoteSchema.parseAsync(json).then((u) => new Vote(u));
|
||||
}
|
||||
}
|
||||
16
packages/federation/entities/extensions/reactions.ts
Normal file
16
packages/federation/entities/extensions/reactions.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import type { z } from "zod";
|
||||
import { ReactionSchema } from "../../schemas/extensions/reactions.ts";
|
||||
import type { JSONObject } from "../../types.ts";
|
||||
import { Entity } from "../entity.ts";
|
||||
|
||||
export class Reaction extends Entity {
|
||||
public static name = "pub.versia:reactions/Reaction";
|
||||
|
||||
public constructor(public data: z.infer<typeof ReactionSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Reaction> {
|
||||
return ReactionSchema.parseAsync(json).then((u) => new Reaction(u));
|
||||
}
|
||||
}
|
||||
16
packages/federation/entities/extensions/reports.ts
Normal file
16
packages/federation/entities/extensions/reports.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import type { z } from "zod";
|
||||
import { ReportSchema } from "../../schemas/extensions/reports.ts";
|
||||
import type { JSONObject } from "../../types.ts";
|
||||
import { Entity } from "../entity.ts";
|
||||
|
||||
export class Report extends Entity {
|
||||
public static name = "pub.versia:reports/Report";
|
||||
|
||||
public constructor(public data: z.infer<typeof ReportSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Report> {
|
||||
return ReportSchema.parseAsync(json).then((u) => new Report(u));
|
||||
}
|
||||
}
|
||||
16
packages/federation/entities/extensions/share.ts
Normal file
16
packages/federation/entities/extensions/share.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import type { z } from "zod";
|
||||
import { ShareSchema } from "../../schemas/extensions/share.ts";
|
||||
import type { JSONObject } from "../../types.ts";
|
||||
import { Entity } from "../entity.ts";
|
||||
|
||||
export class Share extends Entity {
|
||||
public static name = "pub.versia:share/Share";
|
||||
|
||||
public constructor(public data: z.infer<typeof ShareSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Share> {
|
||||
return ShareSchema.parseAsync(json).then((u) => new Share(u));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue