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
82
packages/sdk/entities/contentformat.ts
Normal file
82
packages/sdk/entities/contentformat.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import type { z } from "zod";
|
||||
import {
|
||||
AudioContentFormatSchema,
|
||||
ContentFormatSchema,
|
||||
ImageContentFormatSchema,
|
||||
NonTextContentFormatSchema,
|
||||
TextContentFormatSchema,
|
||||
VideoContentFormatSchema,
|
||||
} from "../schemas/contentformat.ts";
|
||||
import type { JSONObject } from "../types.ts";
|
||||
|
||||
export class ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<ContentFormat> {
|
||||
return ContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new ContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(public data: z.infer<typeof ContentFormatSchema>) {}
|
||||
}
|
||||
|
||||
export class TextContentFormat extends ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<TextContentFormat> {
|
||||
return TextContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new TextContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(public data: z.infer<typeof TextContentFormatSchema>) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
||||
export class NonTextContentFormat extends ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<NonTextContentFormat> {
|
||||
return NonTextContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new NonTextContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(
|
||||
public data: z.infer<typeof NonTextContentFormatSchema>,
|
||||
) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
||||
export class ImageContentFormat extends ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<ImageContentFormat> {
|
||||
return ImageContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new ImageContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(public data: z.infer<typeof ImageContentFormatSchema>) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
||||
export class VideoContentFormat extends ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<VideoContentFormat> {
|
||||
return VideoContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new VideoContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(public data: z.infer<typeof VideoContentFormatSchema>) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
||||
export class AudioContentFormat extends ContentFormat {
|
||||
public static fromJSON(data: JSONObject): Promise<AudioContentFormat> {
|
||||
return AudioContentFormatSchema.parseAsync(data).then(
|
||||
(d) => new AudioContentFormat(d),
|
||||
);
|
||||
}
|
||||
|
||||
public constructor(public data: z.infer<typeof AudioContentFormatSchema>) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue