pleroma/packages/pl-api/lib/entities/scrobble.ts
marcin mikołajczak a6bc160caa pl-api: Do some blind search and replace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-14 00:25:30 +02:00

21 lines
633 B
TypeScript

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