2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-20 03:53:12 -07:00
|
|
|
import { accountSchema } from './account';
|
|
|
|
import { statusSchema } from './status';
|
2024-08-28 04:43:23 -07:00
|
|
|
import { filteredArray } from './utils';
|
|
|
|
|
2024-10-29 14:26:53 -07:00
|
|
|
/**
|
|
|
|
* @category Schemas
|
|
|
|
* @see {@link https://docs.joinmastodon.org/entities/Conversation}
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
const conversationSchema = v.object({
|
|
|
|
id: v.string(),
|
|
|
|
unread: v.fallback(v.boolean(), false),
|
2024-08-28 04:43:23 -07:00
|
|
|
accounts: filteredArray(accountSchema),
|
2024-10-13 15:25:30 -07:00
|
|
|
last_status: v.fallback(v.nullable(statusSchema), null),
|
2024-08-28 04:43:23 -07:00
|
|
|
});
|
|
|
|
|
2024-11-29 07:01:54 -08:00
|
|
|
/**
|
|
|
|
* @category Entity types
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
type Conversation = v.InferOutput<typeof conversationSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { conversationSchema, type Conversation };
|