2025-11-21 08:31:02 +01:00
|
|
|
|
import { z } from "zod";
|
2025-02-05 22:49:07 +01:00
|
|
|
|
import { Account } from "./account.ts";
|
|
|
|
|
|
|
2025-03-24 15:25:40 +01:00
|
|
|
|
export const PreviewCardAuthor = z
|
|
|
|
|
|
.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
|
name: z.string().meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
|
description: "The original resource author’s name.",
|
|
|
|
|
|
example: "The Doubleclicks",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-03-24 15:25:40 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCardAuthor/#name",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
url: z.url().meta({
|
|
|
|
|
|
description: "A link to the author of the original resource.",
|
|
|
|
|
|
example: "https://www.youtube.com/user/thedoubleclicks",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCardAuthor/#url",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
account: Account.nullable().meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
|
description: "The fediverse account of the author.",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCardAuthor/#account",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
|
|
|
|
|
id: "PreviewCardAuthor",
|
2025-03-29 03:30:06 +01:00
|
|
|
|
});
|
2025-02-05 22:49:07 +01:00
|
|
|
|
|
2025-02-12 23:04:44 +01:00
|
|
|
|
export const PreviewCard = z
|
|
|
|
|
|
.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
|
url: z.url().meta({
|
|
|
|
|
|
description: "Location of linked resource.",
|
|
|
|
|
|
example: "https://www.youtube.com/watch?v=OMv_EPMED8Y",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#url",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-02-12 23:04:44 +01:00
|
|
|
|
title: z
|
|
|
|
|
|
.string()
|
|
|
|
|
|
.min(1)
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "Title of linked resource.",
|
|
|
|
|
|
example: "♪ Brand New Friend (Christmas Song!)",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#title",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
description: z.string().meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "Description of preview.",
|
|
|
|
|
|
example: "",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-02-12 23:04:44 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#description",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
type: z.enum(["link", "photo", "video"]).meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "The type of the preview card.",
|
|
|
|
|
|
example: "video",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-02-12 23:04:44 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#type",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
authors: z.array(PreviewCardAuthor).meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description:
|
|
|
|
|
|
"Fediverse account of the authors of the original resource.",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-02-12 23:04:44 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#authors",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
provider_name: z.string().meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "The provider of the original resource.",
|
|
|
|
|
|
example: "YouTube",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-02-12 23:04:44 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#provider_name",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
provider_url: z.url().meta({
|
|
|
|
|
|
description: "A link to the provider of the original resource.",
|
|
|
|
|
|
example: "https://www.youtube.com/",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#provider_url",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
html: z.string().meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "HTML to be used for generating the preview card.",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
example:
|
2025-02-12 23:04:44 +01:00
|
|
|
|
'<iframe width="480" height="270" src="https://www.youtube.com/embed/OMv_EPMED8Y?feature=oembed" frameborder="0" allowfullscreen=""></iframe>',
|
2025-02-05 22:49:07 +01:00
|
|
|
|
externalDocs: {
|
2025-02-12 23:04:44 +01:00
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#html",
|
2025-02-05 22:49:07 +01:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-02-12 23:04:44 +01:00
|
|
|
|
width: z
|
|
|
|
|
|
.number()
|
|
|
|
|
|
.int()
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "Width of preview, in pixels.",
|
|
|
|
|
|
example: 480,
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#width",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
height: z
|
|
|
|
|
|
.number()
|
|
|
|
|
|
.int()
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "Height of preview, in pixels.",
|
|
|
|
|
|
example: 270,
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#height",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
image: z
|
|
|
|
|
|
.url()
|
|
|
|
|
|
.nullable()
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description: "Preview thumbnail.",
|
|
|
|
|
|
example:
|
|
|
|
|
|
"https://cdn.versia.social/preview_cards/images/014/179/145/original/9cf4b7cf5567b569.jpeg",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#image",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
|
embed_url: z.url().meta({
|
|
|
|
|
|
description: "Used for photo embeds, instead of custom html.",
|
|
|
|
|
|
example:
|
|
|
|
|
|
"https://live.staticflickr.com/65535/49088768431_6a4322b3bb_b.jpg",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#embed_url",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-02-12 23:04:44 +01:00
|
|
|
|
blurhash: z
|
|
|
|
|
|
.string()
|
|
|
|
|
|
.nullable()
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description:
|
|
|
|
|
|
"A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet.",
|
|
|
|
|
|
example: "UvK0HNkV,:s9xBR%njog0fo2W=WBS5ozofV@",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard/#blurhash",
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
|
description:
|
|
|
|
|
|
"Represents a rich preview card that is generated using OpenGraph tags from a URL.",
|
|
|
|
|
|
externalDocs: {
|
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/PreviewCard",
|
|
|
|
|
|
},
|
2025-07-07 03:42:35 +02:00
|
|
|
|
id: "PreviewCard",
|
2025-02-12 23:04:44 +01:00
|
|
|
|
});
|