bigbuffet-rw/packages/pl-api/lib/entities/scrobble.ts
marcin mikołajczak c43178fc09 Display scrobbles
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-09-01 14:57:59 +02:00

21 lines
596 B
TypeScript

import { z } from 'zod';
import { accountSchema } from './account';
const scrobbleSchema = z.preprocess((scrobble: any) => scrobble ? {
external_link: scrobble.externalLink,
...scrobble,
} : null, z.object({
id: z.coerce.string(),
account: accountSchema,
created_at: z.string().datetime({ offset: true }),
title: z.string(),
artist: z.string().catch(''),
album: z.string().catch(''),
external_link: z.string().nullable().catch(null),
length: z.number().nullable().catch(null),
}));
type Scrobble = z.infer<typeof scrobbleSchema>;
export { scrobbleSchema, type Scrobble };