bigbuffet-rw/packages/pl-api/lib/entities/marker.ts
marcin mikołajczak 1c9f819bee pl-fe is officially woke
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-09-06 00:16:43 +02:00

27 lines
642 B
TypeScript

import { z } from 'zod';
import { dateSchema } from './utils';
const markerSchema = z.preprocess((marker: any) => marker ? ({
unread_count: marker.pleroma?.unread_count,
...marker,
}) : null, z.object({
last_read_id: z.string(),
version: z.number().int(),
updated_at: dateSchema,
unread_count: z.number().int().optional().catch(undefined),
}));
/** @see {@link https://docs.joinmastodon.org/entities/Marker/} */
type Marker = z.infer<typeof markerSchema>;
const markersSchema = z.record(markerSchema);
type Markers = z.infer<typeof markersSchema>;
export {
markerSchema,
markersSchema,
type Marker,
type Markers,
};