deno-fresh-saurpc-lyrics/models.ts

41 lines
1 KiB
TypeScript
Raw Normal View History

2024-02-18 14:18:51 -06:00
import { z } from 'https://deno.land/x/zod@v3.22.4/mod.ts'
export const Identifiable = z.object({
id: z.string().uuid(),
})
export type TIdentifiable = z.infer<typeof Identifiable>
export const Verse = z.object({
content: z.string(),
})
export type TVerse = z.infer<typeof Verse>
export const Map = z.object({
verseKeys: z.array(z.string()),
})
export type TMap = z.infer<typeof Map>
export const Song = Identifiable.merge(z.object({
title: z.string(),
verses: z.record(z.string(), Verse),
maps: z.record(z.string(), Map),
}))
export type TSong = z.infer<typeof Song>
export const PlaylistEntry = z.object({
songKey: z.string().uuid(),
mapKey: z.string(),
})
export type TPlaylistEntry = z.infer<typeof PlaylistEntry>
export const Playlist = Identifiable.merge(z.object({
entries: z.array(PlaylistEntry),
}))
export type TPlaylist = z.infer<typeof Playlist>
export const Display = Identifiable.merge(z.object({
playlistKey: z.string().uuid(),
songKeyIndex: z.number(),
}))
export type TDisplay = z.infer<typeof Display>