refactor song type schema on search page
This commit is contained in:
@@ -2,18 +2,28 @@ import { z } from "zod";
|
||||
|
||||
import { AmqAnimeCategory, AmqAnimeGenre, AmqAnimeTag } from "./anime-extended";
|
||||
|
||||
export const Season = z.enum({
|
||||
export const AmqSeasonMap = {
|
||||
Winter: 0,
|
||||
Spring: 1,
|
||||
Summer: 2,
|
||||
Fall: 3,
|
||||
} as const);
|
||||
} as const;
|
||||
|
||||
export const SongLinkType = z.enum({
|
||||
export const AmqSeason = z.enum(AmqSeasonMap);
|
||||
|
||||
export const AmqSongLinkTypeMap = {
|
||||
OP: 1,
|
||||
ED: 2,
|
||||
INS: 3,
|
||||
} as const);
|
||||
} as const;
|
||||
|
||||
export const AmqSongLinkTypeMapReverse = {
|
||||
1: "OP",
|
||||
2: "ED",
|
||||
3: "INS",
|
||||
} as const;
|
||||
|
||||
export const AmqSongLinkType = z.enum(AmqSongLinkTypeMap);
|
||||
|
||||
const BooleanInt = z.enum({
|
||||
false: 0,
|
||||
@@ -23,7 +33,7 @@ const BooleanInt = z.enum({
|
||||
export const AmqSongLink = z.object({
|
||||
songId: z.int().positive(),
|
||||
number: z.int().nonnegative(),
|
||||
type: SongLinkType,
|
||||
type: AmqSongLinkType,
|
||||
annSongId: z.int().positive(),
|
||||
uploaded: BooleanInt,
|
||||
rebroadcast: BooleanInt,
|
||||
@@ -53,7 +63,7 @@ export const AmqAnimeSchema = z.object({
|
||||
}),
|
||||
),
|
||||
year: z.int().positive(),
|
||||
seasonId: Season,
|
||||
seasonId: AmqSeason,
|
||||
songLinks: z.array(AmqSongLink),
|
||||
opCount: z.int().nonnegative(),
|
||||
edCount: z.int().nonnegative(),
|
||||
|
||||
Reference in New Issue
Block a user