bigbuffet-rw/packages/pl-api/lib/entities/marker.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

27 lines
626 B
TypeScript

import { z } from 'zod';
import { dateSchema } from './utils';
const markerSchema = z.preprocess((marker: any) => ({
unread_count: marker.pleroma?.unread_count,
...marker,
}), 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,
};