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,11 +1,11 @@
|
|||
import { z } from "zod";
|
||||
import { z } from "zod/v4";
|
||||
import { emojiRegex } from "../regex.ts";
|
||||
import { Id, zBoolean } from "./common.ts";
|
||||
|
||||
export const CustomEmoji = z
|
||||
.object({
|
||||
/* Versia Server API extension */
|
||||
id: Id.openapi({
|
||||
id: Id.meta({
|
||||
description: "ID of the custom emoji in the database.",
|
||||
example: "af9ccd29-c689-477f-aa27-d7d95fd8fb05",
|
||||
}),
|
||||
|
|
@ -17,36 +17,30 @@ export const CustomEmoji = z
|
|||
emojiRegex,
|
||||
"Shortcode must only contain letters (any case), numbers, dashes or underscores.",
|
||||
)
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "The name of the custom emoji.",
|
||||
example: "blobaww",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#shortcode",
|
||||
},
|
||||
}),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
description: "A link to the custom emoji.",
|
||||
example:
|
||||
"https://cdn.versia.social/emojis/images/000/011/739/original/blobaww.png",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#url",
|
||||
},
|
||||
}),
|
||||
static_url: z
|
||||
.string()
|
||||
.url()
|
||||
.openapi({
|
||||
description: "A link to a static copy of the custom emoji.",
|
||||
example:
|
||||
"https://cdn.versia.social/emojis/images/000/011/739/static/blobaww.png",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#static_url",
|
||||
},
|
||||
}),
|
||||
visible_in_picker: z.boolean().openapi({
|
||||
url: z.url().meta({
|
||||
description: "A link to the custom emoji.",
|
||||
example:
|
||||
"https://cdn.versia.social/emojis/images/000/011/739/original/blobaww.png",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#url",
|
||||
},
|
||||
}),
|
||||
static_url: z.url().meta({
|
||||
description: "A link to a static copy of the custom emoji.",
|
||||
example:
|
||||
"https://cdn.versia.social/emojis/images/000/011/739/static/blobaww.png",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#static_url",
|
||||
},
|
||||
}),
|
||||
visible_in_picker: z.boolean().meta({
|
||||
description:
|
||||
"Whether this Emoji should be visible in the picker or unlisted.",
|
||||
example: true,
|
||||
|
|
@ -59,7 +53,7 @@ export const CustomEmoji = z
|
|||
.trim()
|
||||
.max(64)
|
||||
.nullable()
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Used for sorting custom emoji in the picker.",
|
||||
example: "Blobs",
|
||||
externalDocs: {
|
||||
|
|
@ -67,7 +61,7 @@ export const CustomEmoji = z
|
|||
},
|
||||
}),
|
||||
/* Versia Server API extension */
|
||||
global: zBoolean.openapi({
|
||||
global: zBoolean.meta({
|
||||
description: "Whether this emoji is visible to all users.",
|
||||
example: false,
|
||||
}),
|
||||
|
|
@ -75,7 +69,7 @@ export const CustomEmoji = z
|
|||
description: z
|
||||
.string()
|
||||
.nullable()
|
||||
.openapi({
|
||||
.meta({
|
||||
description:
|
||||
"Emoji description for users using screen readers.",
|
||||
example: "A cute blob.",
|
||||
|
|
@ -84,10 +78,10 @@ export const CustomEmoji = z
|
|||
},
|
||||
}),
|
||||
})
|
||||
.openapi({
|
||||
.meta({
|
||||
description: "Represents a custom emoji.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji",
|
||||
},
|
||||
ref: "CustomEmoji",
|
||||
id: "CustomEmoji",
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue