mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-12-26 23:00:26 -05:00
75 lines
1.6 KiB
TypeScript
75 lines
1.6 KiB
TypeScript
import { t } from "elysia";
|
|
import { bubbleImages, madeInAbyss, registerExamples } from "./examples";
|
|
import { DbMetadata, ExternalId, Image, Resource, SeedImage } from "./utils";
|
|
|
|
export const Character = t.Object({
|
|
name: t.String(),
|
|
latinName: t.Nullable(t.String()),
|
|
image: t.Nullable(Image),
|
|
});
|
|
export type Character = typeof Character.static;
|
|
|
|
export const Role = t.Object({
|
|
kind: t.UnionEnum([
|
|
"actor",
|
|
"director",
|
|
"writter",
|
|
"producer",
|
|
"music",
|
|
"other",
|
|
]),
|
|
character: t.Nullable(Character),
|
|
});
|
|
export type Role = typeof Role.static;
|
|
|
|
const StaffData = t.Object({
|
|
name: t.String(),
|
|
latinName: t.Nullable(t.String()),
|
|
image: t.Nullable(Image),
|
|
externalId: ExternalId(),
|
|
});
|
|
export const Staff = t.Intersect([Resource(), StaffData, DbMetadata]);
|
|
export type Staff = typeof Staff.static;
|
|
|
|
export const SeedStaff = t.Intersect([
|
|
t.Omit(Role, ["character"]),
|
|
t.Object({
|
|
character: t.Intersect([
|
|
t.Omit(Character, ["image"]),
|
|
t.Object({
|
|
image: t.Nullable(SeedImage),
|
|
}),
|
|
]),
|
|
staff: t.Intersect([
|
|
t.Object({
|
|
slug: t.String({ format: "slug" }),
|
|
image: t.Nullable(SeedImage),
|
|
}),
|
|
t.Omit(StaffData, ["image"]),
|
|
]),
|
|
}),
|
|
]);
|
|
export type SeedStaff = typeof SeedStaff.static;
|
|
|
|
const role = madeInAbyss.staff[0];
|
|
registerExamples(SeedStaff, role);
|
|
registerExamples(Staff, {
|
|
...role.staff,
|
|
image: {
|
|
id: bubbleImages.poster.id,
|
|
source: role.staff.image,
|
|
blurhash: bubbleImages.poster.blurhash,
|
|
},
|
|
});
|
|
registerExamples(Role, {
|
|
...role,
|
|
character: {
|
|
...role.character,
|
|
image: {
|
|
id: bubbleImages.poster.id,
|
|
source: role.character.image,
|
|
blurhash: bubbleImages.poster.blurhash,
|
|
},
|
|
},
|
|
});
|