bigbuffet-rw/packages/pl-api/lib/entities/status-edit.ts
marcin mikołajczak a521c9044d make pl-api compile
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-16 17:03:27 +02:00

26 lines
918 B
TypeScript

import * as v from 'valibot';
import { accountSchema } from './account';
import { customEmojiSchema } from './custom-emoji';
import { mediaAttachmentSchema } from './media-attachment';
import { datetimeSchema, filteredArray } from './utils';
/** @see {@link https://docs.joinmastodon.org/entities/StatusEdit/} */
const statusEditSchema = v.object({
content: v.fallback(v.string(), ''),
spoiler_text: v.fallback(v.string(), ''),
sensitive: v.pipe(v.unknown(), v.transform(Boolean)),
created_at: v.fallback(datetimeSchema, new Date().toISOString()),
account: accountSchema,
poll: v.fallback(v.nullable(v.object({
options: v.array(v.object({
title: v.string(),
})),
})), null),
media_attachments: filteredArray(mediaAttachmentSchema),
emojis: filteredArray(customEmojiSchema),
});
type StatusEdit = v.InferOutput<typeof statusEditSchema>;
export { statusEditSchema, type StatusEdit };