mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 16:38:20 +01:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
/**
|
|
* Custom emojis extension.
|
|
* @module federation/schemas/extensions/custom_emojis
|
|
* @see module:federation/schemas/base
|
|
* @see https://lysand.org/extensions/custom-emojis
|
|
*/
|
|
import { z } from "zod";
|
|
import { ContentFormat } from "../content_format";
|
|
import { emojiRegex } from "../regex";
|
|
|
|
/**
|
|
* @description Used to validate the properties the extension's custom field
|
|
* @see https://lysand.org/extensions/custom-emojis
|
|
* @example
|
|
* {
|
|
* // ...
|
|
* "extensions": {
|
|
* "org.lysand:custom_emojis": {
|
|
* "emojis": [
|
|
* {
|
|
* "name": "happy_face",
|
|
* "url": {
|
|
* "image/png": {
|
|
* "content": "https://cdn.example.com/emojis/happy_face.png",
|
|
* "content_type": "image/png"
|
|
* }
|
|
* }
|
|
* },
|
|
* // ...
|
|
* ]
|
|
* }
|
|
* }
|
|
* // ...
|
|
* }
|
|
*/
|
|
export const CustomEmojiExtension = z.object({
|
|
emojis: z.array(
|
|
z.object({
|
|
name: z
|
|
.string()
|
|
.min(1)
|
|
.max(256)
|
|
.regex(
|
|
emojiRegex,
|
|
"Emoji name must be alphanumeric, underscores, or dashes.",
|
|
),
|
|
url: ContentFormat,
|
|
}),
|
|
),
|
|
});
|