2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
import { accountSchema } from './account';
|
|
|
|
import { customEmojiSchema } from './custom-emoji';
|
|
|
|
import { mediaAttachmentSchema } from './media-attachment';
|
2024-10-16 08:03:27 -07:00
|
|
|
import { datetimeSchema, filteredArray } from './utils';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-29 14:44:28 -07:00
|
|
|
/**
|
|
|
|
* @category Schemas
|
|
|
|
* @see {@link https://docs.joinmastodon.org/entities/StatusEdit/}
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
const statusEditSchema = v.object({
|
|
|
|
content: v.fallback(v.string(), ''),
|
|
|
|
spoiler_text: v.fallback(v.string(), ''),
|
2024-10-14 13:50:34 -07:00
|
|
|
sensitive: v.pipe(v.unknown(), v.transform(Boolean)),
|
2024-10-16 08:03:27 -07:00
|
|
|
created_at: v.fallback(datetimeSchema, new Date().toISOString()),
|
2024-08-28 04:43:23 -07:00
|
|
|
account: accountSchema,
|
2024-10-14 13:50:34 -07:00
|
|
|
poll: v.fallback(v.nullable(v.object({
|
|
|
|
options: v.array(v.object({
|
2024-10-13 15:25:30 -07:00
|
|
|
title: v.string(),
|
2024-08-28 04:43:23 -07:00
|
|
|
})),
|
2024-10-14 13:50:34 -07:00
|
|
|
})), null),
|
2024-08-28 04:43:23 -07:00
|
|
|
media_attachments: filteredArray(mediaAttachmentSchema),
|
|
|
|
emojis: filteredArray(customEmojiSchema),
|
|
|
|
});
|
|
|
|
|
2024-11-29 07:01:54 -08:00
|
|
|
/**
|
|
|
|
* @category Entity types
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
type StatusEdit = v.InferOutput<typeof statusEditSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { statusEditSchema, type StatusEdit };
|