diff --git a/api/src/models/season.ts b/api/src/models/season.ts new file mode 100644 index 00000000..b40f2e7f --- /dev/null +++ b/api/src/models/season.ts @@ -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; diff --git a/api/src/models/utils/external-id.ts b/api/src/models/utils/external-id.ts index cbcac6fa..5f8f5b1d 100644 --- a/api/src/models/utils/external-id.ts +++ b/api/src/models/utils/external-id.ts @@ -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;