2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
/** @see {@link https://docs.joinmastodon.org/entities/PreviewCard/} */
|
2024-10-13 15:25:30 -07:00
|
|
|
const previewCardSchema = v.object({
|
|
|
|
author_name: v.fallback(v.string(), ''),
|
2024-10-14 11:54:44 -07:00
|
|
|
author_url: v.fallback(v.pipe(v.string(), v.url()), ''),
|
2024-10-13 15:25:30 -07:00
|
|
|
blurhash: v.fallback(v.nullable(v.string()), null),
|
|
|
|
description: v.fallback(v.string(), ''),
|
2024-10-14 11:54:44 -07:00
|
|
|
embed_url: v.fallback(v.pipe(v.string(), v.url()), ''),
|
2024-10-13 15:25:30 -07:00
|
|
|
height: v.fallback(v.number(), 0),
|
|
|
|
html: v.fallback(v.string(), ''),
|
|
|
|
image: v.fallback(v.nullable(v.string()), null),
|
|
|
|
image_description: v.fallback(v.string(), ''),
|
|
|
|
provider_name: v.fallback(v.string(), ''),
|
2024-10-14 11:54:44 -07:00
|
|
|
provider_url: v.fallback(v.pipe(v.string(), v.url()), ''),
|
2024-10-13 15:25:30 -07:00
|
|
|
title: v.fallback(v.string(), ''),
|
2024-10-14 11:54:44 -07:00
|
|
|
type: v.fallback(v.picklist(['link', 'photo', 'video', 'rich']), 'link'),
|
|
|
|
url: v.pipe(v.string(), v.url()),
|
2024-10-13 15:25:30 -07:00
|
|
|
width: v.fallback(v.number(), 0),
|
2024-08-28 04:43:23 -07:00
|
|
|
});
|
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type PreviewCard = v.InferOutput<typeof previewCardSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { previewCardSchema, type PreviewCard };
|