mirror of
https://github.com/versia-pub/server.git
synced 2026-04-28 13:19:16 +02:00
refactor: ⬆️ Upgrade to Zod v4 and hono-openapi 0.5.0
This commit is contained in:
parent
add2429606
commit
24d4150da4
209 changed files with 1331 additions and 1622 deletions
|
|
@ -1,97 +1,88 @@
|
|||
import { z } from "zod";
|
||||
import { z } from "zod/v4";
|
||||
import { Account } from "./account.ts";
|
||||
|
||||
export const PreviewCardAuthor = z
|
||||
.object({
|
||||
name: z.string().openapi({
|
||||
name: z.string().meta({
|
||||
description: "The original resource author’s name.",
|
||||
example: "The Doubleclicks",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCardAuthor/#name",
|
||||
},
|
||||
}),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
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().openapi({
|
||||
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({
|
||||
description: "The fediverse account of the author.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCardAuthor/#account",
|
||||
},
|
||||
}),
|
||||
})
|
||||
.openapi({
|
||||
ref: "PreviewCardAuthor",
|
||||
.meta({
|
||||
id: "PreviewCardAuthor",
|
||||
});
|
||||
|
||||
export const PreviewCard = z
|
||||
.object({
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
description: "Location of linked resource.",
|
||||
example: "https://www.youtube.com/watch?v=OMv_EPMED8Y",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#url",
|
||||
},
|
||||
}),
|
||||
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",
|
||||
},
|
||||
}),
|
||||
title: z
|
||||
.string()
|
||||
.min(1)
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Title of linked resource.",
|
||||
example: "♪ Brand New Friend (Christmas Song!)",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#title",
|
||||
},
|
||||
}),
|
||||
description: z.string().openapi({
|
||||
description: z.string().meta({
|
||||
description: "Description of preview.",
|
||||
example: "",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#description",
|
||||
},
|
||||
}),
|
||||
type: z.enum(["link", "photo", "video"]).openapi({
|
||||
type: z.enum(["link", "photo", "video"]).meta({
|
||||
description: "The type of the preview card.",
|
||||
example: "video",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#type",
|
||||
},
|
||||
}),
|
||||
authors: z.array(PreviewCardAuthor).openapi({
|
||||
authors: z.array(PreviewCardAuthor).meta({
|
||||
description:
|
||||
"Fediverse account of the authors of the original resource.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#authors",
|
||||
},
|
||||
}),
|
||||
provider_name: z.string().openapi({
|
||||
provider_name: z.string().meta({
|
||||
description: "The provider of the original resource.",
|
||||
example: "YouTube",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#provider_name",
|
||||
},
|
||||
}),
|
||||
provider_url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
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().openapi({
|
||||
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({
|
||||
description: "HTML to be used for generating the preview card.",
|
||||
example:
|
||||
'<iframe width="480" height="270" src="https://www.youtube.com/embed/OMv_EPMED8Y?feature=oembed" frameborder="0" allowfullscreen=""></iframe>',
|
||||
|
|
@ -102,7 +93,7 @@ export const PreviewCard = z
|
|||
width: z
|
||||
.number()
|
||||
.int()
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Width of preview, in pixels.",
|
||||
example: 480,
|
||||
externalDocs: {
|
||||
|
|
@ -112,7 +103,7 @@ export const PreviewCard = z
|
|||
height: z
|
||||
.number()
|
||||
.int()
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Height of preview, in pixels.",
|
||||
example: 270,
|
||||
externalDocs: {
|
||||
|
|
@ -120,10 +111,9 @@ export const PreviewCard = z
|
|||
},
|
||||
}),
|
||||
image: z
|
||||
.string()
|
||||
.url()
|
||||
.nullable()
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Preview thumbnail.",
|
||||
example:
|
||||
"https://cdn.versia.social/preview_cards/images/014/179/145/original/9cf4b7cf5567b569.jpeg",
|
||||
|
|
@ -131,21 +121,18 @@ export const PreviewCard = z
|
|||
url: "https://docs.joinmastodon.org/entities/PreviewCard/#image",
|
||||
},
|
||||
}),
|
||||
embed_url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
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",
|
||||
},
|
||||
}),
|
||||
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",
|
||||
},
|
||||
}),
|
||||
blurhash: z
|
||||
.string()
|
||||
.nullable()
|
||||
.openapi({
|
||||
.meta({
|
||||
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@",
|
||||
|
|
@ -154,11 +141,11 @@ export const PreviewCard = z
|
|||
},
|
||||
}),
|
||||
})
|
||||
.openapi({
|
||||
.meta({
|
||||
description:
|
||||
"Represents a rich preview card that is generated using OpenGraph tags from a URL.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/PreviewCard",
|
||||
},
|
||||
ref: "PreviewCard",
|
||||
id: "PreviewCard",
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue