2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-09-01 05:57:41 -07:00
|
|
|
|
|
|
|
import { accountSchema } from './account';
|
|
|
|
|
2024-10-15 16:08:56 -07:00
|
|
|
const scrobbleSchema = v.pipe(
|
|
|
|
v.any(),
|
|
|
|
v.transform((scrobble: any) => scrobble ? {
|
|
|
|
external_link: scrobble.externalLink,
|
|
|
|
...scrobble,
|
|
|
|
} : null),
|
|
|
|
v.object({
|
|
|
|
id: v.pipe(v.unknown(), v.transform(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),
|
|
|
|
}),
|
|
|
|
);
|
2024-09-01 05:57:41 -07:00
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type Scrobble = v.InferOutput<typeof scrobbleSchema>;
|
2024-09-01 05:57:41 -07:00
|
|
|
|
|
|
|
export { scrobbleSchema, type Scrobble };
|