63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { z } from "zod"
|
|
|
|
export const gameStateEnum = z.enum([
|
|
"not_set",
|
|
"wishlisted",
|
|
"playlisted",
|
|
"playing",
|
|
"finished",
|
|
"perfected",
|
|
"abandoned",
|
|
"bad_game",
|
|
])
|
|
export type GameState = z.infer<typeof gameStateEnum>
|
|
|
|
export const gameSchema = z.object({
|
|
id: z.string(),
|
|
title: z.string(),
|
|
source: z.string(),
|
|
source_id: z.string(),
|
|
platform: z.string().default("PC"),
|
|
last_played: z.string().nullable().default(null),
|
|
playtime_hours: z.number().default(0),
|
|
url: z.string().nullable().default(null),
|
|
canonical_id: z.string().nullable().default(null),
|
|
rating: z.number().min(-1).max(10).default(-1),
|
|
game_state: gameStateEnum.default("not_set"),
|
|
is_favorite: z.boolean().default(false),
|
|
summary: z.string().nullable().default(null),
|
|
genres: z.string().nullable().default(null),
|
|
aggregated_rating: z.number().nullable().default(null),
|
|
release_date: z.string().nullable().default(null),
|
|
developers: z.string().nullable().default(null),
|
|
cover_image_id: z.string().nullable().default(null),
|
|
screenshots: z.string().nullable().default(null),
|
|
video_ids: z.string().nullable().default(null),
|
|
metadata_fetched_at: z.string().nullable().default(null),
|
|
created_at: z.string().optional(),
|
|
updated_at: z.string().optional(),
|
|
})
|
|
export type Game = z.infer<typeof gameSchema>
|
|
|
|
export const playlistSchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
is_static: z.boolean().default(false),
|
|
created_at: z.string().optional(),
|
|
})
|
|
export type Playlist = z.infer<typeof playlistSchema>
|
|
|
|
export const playlistGameSchema = z.object({
|
|
playlist_id: z.string(),
|
|
game_id: z.string(),
|
|
added_at: z.string().optional(),
|
|
})
|
|
export type PlaylistGame = z.infer<typeof playlistGameSchema>
|
|
|
|
export const configSchema = z.object({
|
|
key: z.string(),
|
|
value: z.unknown(),
|
|
updated_at: z.string().optional(),
|
|
})
|
|
export type Config = z.infer<typeof configSchema>
|