mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
docs(federation): 📝 Update SDK documentation
This commit is contained in:
parent
f79b0bc999
commit
45e5460975
67 changed files with 332 additions and 65 deletions
29
packages/sdk/entities/note.ts
Normal file
29
packages/sdk/entities/note.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import type { z } from "zod";
|
||||
import { NoteSchema } from "../schemas/note.ts";
|
||||
import type { JSONObject } from "../types.ts";
|
||||
import { NonTextContentFormat, TextContentFormat } from "./contentformat.ts";
|
||||
import { Entity } from "./entity.ts";
|
||||
|
||||
export class Note extends Entity {
|
||||
public static name = "Note";
|
||||
|
||||
public constructor(public data: z.infer<typeof NoteSchema>) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public static fromJSON(json: JSONObject): Promise<Note> {
|
||||
return NoteSchema.parseAsync(json).then((n) => new Note(n));
|
||||
}
|
||||
|
||||
public get attachments(): NonTextContentFormat[] {
|
||||
return (
|
||||
this.data.attachments?.map((a) => new NonTextContentFormat(a)) ?? []
|
||||
);
|
||||
}
|
||||
|
||||
public get content(): TextContentFormat | undefined {
|
||||
return this.data.content
|
||||
? new TextContentFormat(this.data.content)
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue