Add season model

This commit is contained in:
Zoe Roux 2024-11-09 16:29:09 +01:00
parent ed19413576
commit 0b0ae9abd3
No known key found for this signature in database
2 changed files with 39 additions and 1 deletions

23
api/src/models/season.ts Normal file
View File

@ -0,0 +1,23 @@
import { t } from "elysia";
import { Image } from "./utils/image";
import { SeasonId } from "./utils/external-id";
export const Season = t.Object({
id: t.String({ format: "uuid" }),
slug: t.String(),
seasonNumber: t.Number({ minimum: 1 }),
name: t.Nullable(t.String()),
description: t.Nullable(t.String()),
poster: t.Nullable(Image),
thumbnail: t.Nullable(Image),
banner: t.Nullable(Image),
logo: t.Nullable(Image),
trailerUrl: t.Nullable(t.String()),
createdAt: t.String({ format: "date-time" }),
nextRefresh: t.String({ format: "date-time" }),
externalId: SeasonId,
});
export type Season = typeof Season.static;

View File

@ -8,7 +8,6 @@ export const ExternalId = t.Record(
link: t.Nullable(t.String({ format: "uri" })),
}),
);
export type ExternalId = typeof ExternalId.static;
export const EpisodeId = t.Record(
@ -29,3 +28,19 @@ export const EpisodeId = t.Record(
link: t.Nullable(t.String({ format: "uri" })),
}),
);
export type EpisodeId = typeof EpisodeId.static;
export const SeasonId = t.Record(
t.String(),
t.Object({
serieId: t.String({
descrpition: comment`
Id on the external website.
We store the serie's id because episode id are rarely stable.
`,
}),
season: t.Number(),
link: t.Nullable(t.String({ format: "uri" })),
}),
);
export type SeasonId = typeof SeasonId.static;