mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 00:18:19 +01:00
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/**
|
|
* Custom emojis extension.
|
|
* @module federation/schemas/extensions/custom_emojis
|
|
* @see module:federation/schemas/base
|
|
* @see https://versia.pub/extensions/custom-emojis
|
|
*/
|
|
import { z } from "zod";
|
|
import { ImageOnlyContentFormatSchema } from "../content_format.ts";
|
|
import { emojiRegex } from "../regex.ts";
|
|
|
|
/**
|
|
* @description Used to validate the properties the extension's custom field
|
|
* @see https://versia.pub/extensions/custom-emojis
|
|
* @example
|
|
* {
|
|
* // ...
|
|
* "extensions": {
|
|
* "pub.versia:custom_emojis": {
|
|
* "emojis": [
|
|
* {
|
|
* "name": ":happy_face:",
|
|
* "url": {
|
|
* "image/png": {
|
|
* "content": "https://cdn.example.com/emojis/happy_face.png",
|
|
* "remote": true
|
|
* }
|
|
* }
|
|
* },
|
|
* // ...
|
|
* ]
|
|
* }
|
|
* }
|
|
* // ...
|
|
* }
|
|
*/
|
|
export const CustomEmojiExtensionSchema = z.object({
|
|
emojis: z.array(
|
|
z
|
|
.object({
|
|
name: z
|
|
.string()
|
|
.min(1)
|
|
.max(256)
|
|
.regex(
|
|
emojiRegex,
|
|
"Emoji name must be alphanumeric, underscores, or dashes, and surrounded by identifiers",
|
|
),
|
|
url: ImageOnlyContentFormatSchema,
|
|
})
|
|
.strict(),
|
|
),
|
|
});
|