mirror of
https://github.com/versia-pub/server.git
synced 2026-04-28 13:19:16 +02:00
refactor(api): ♻️ Move all client schema code to new package
This commit is contained in:
parent
52602c3da7
commit
3fe07a79b8
128 changed files with 3904 additions and 169 deletions
95
packages/client/schemas/emoji.ts
Normal file
95
packages/client/schemas/emoji.ts
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import { emojiValidator } from "@/api.ts";
|
||||
import { z } from "@hono/zod-openapi";
|
||||
import { config } from "~/config.ts";
|
||||
import { Id, zBoolean } from "./common.ts";
|
||||
|
||||
export const CustomEmoji = z
|
||||
.object({
|
||||
/* Versia Server API extension */
|
||||
id: Id.openapi({
|
||||
description: "ID of the custom emoji in the database.",
|
||||
example: "af9ccd29-c689-477f-aa27-d7d95fd8fb05",
|
||||
}),
|
||||
shortcode: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(config.validation.emojis.max_shortcode_characters)
|
||||
.regex(
|
||||
emojiValidator,
|
||||
"Shortcode must only contain letters (any case), numbers, dashes or underscores.",
|
||||
)
|
||||
.openapi({
|
||||
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({
|
||||
description:
|
||||
"Whether this Emoji should be visible in the picker or unlisted.",
|
||||
example: true,
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#visible_in_picker",
|
||||
},
|
||||
}),
|
||||
category: z
|
||||
.string()
|
||||
.trim()
|
||||
.max(64)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description: "Used for sorting custom emoji in the picker.",
|
||||
example: "Blobs",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#category",
|
||||
},
|
||||
}),
|
||||
/* Versia Server API extension */
|
||||
global: zBoolean.openapi({
|
||||
description: "Whether this emoji is visible to all users.",
|
||||
example: false,
|
||||
}),
|
||||
/* Versia Server API extension */
|
||||
description: z
|
||||
.string()
|
||||
.max(config.validation.emojis.max_description_characters)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description:
|
||||
"Emoji description for users using screen readers.",
|
||||
example: "A cute blob.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#description",
|
||||
},
|
||||
}),
|
||||
})
|
||||
.openapi({
|
||||
description: "Represents a custom emoji.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji",
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue