diff --git a/api/src/models/external-id.ts b/api/src/models/external-id.ts new file mode 100644 index 00000000..368c00b6 --- /dev/null +++ b/api/src/models/external-id.ts @@ -0,0 +1,11 @@ +import { t } from "elysia"; + +export const ExternalId = t.Record( + t.String(), + t.Object({ + dataId: t.String(), + link: t.Nullable(t.String({ format: "uri" })), + }), +); + +export type ExternalId = typeof ExternalId.static; diff --git a/api/src/models/image.ts b/api/src/models/image.ts new file mode 100644 index 00000000..0ff56c9e --- /dev/null +++ b/api/src/models/image.ts @@ -0,0 +1,10 @@ +import { t } from "elysia"; + +export const Image = t.Object({ + source: t.String({ format: "uri" }), + blurhash: t.String(), + low: t.String({ format: "uri" }), + medium: t.String({ format: "uri" }), + high: t.String({ format: "uri" }), +}); +export type Image = typeof Image.static; diff --git a/api/src/models/movie.ts b/api/src/models/movie.ts new file mode 100644 index 00000000..5dae3469 --- /dev/null +++ b/api/src/models/movie.ts @@ -0,0 +1,42 @@ +import { t } from "elysia"; +import { Genre, ShowStatus } from "./show"; +import { Image } from "./image"; +import { ExternalId } from "./external-id"; + +export const Movie = t.Object({ + id: t.String({ format: "uuid" }), + slug: t.String(), + name: t.String(), + description: t.Nullable(t.String()), + tagline: t.Nullable(t.String()), + aliases: t.Array(t.String()), + tags: t.Array(t.String()), + + genres: t.Array(Genre), + rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })), + status: ShowStatus, + + airDate: t.Nullable(t.Date()), + originalLanguage: t.Nullable(t.String()), + + trailerUrl: t.Nullable(t.String()), + poster: t.Nullable(Image), + thumbnail: t.Nullable(Image), + banner: t.Nullable(Image), + logo: t.Nullable(Image), + + // this is a datetime, not just a date. + createdAt: t.Date(), + nextRefresh: t.Date(), + + externalId: ExternalId, +}); + +export type Movie = typeof Movie.static; + +// Movie.examples = [{ +// slug: "bubble", +// title: "Bubble", +// tagline: "Is she a calamity or a blessing?", +// description: " In an abandoned Tokyo overrun by bubbles and gravitational abnormalities, one gifted young man has a fateful meeting with a mysterious girl. ", +// }] diff --git a/api/src/models/show.ts b/api/src/models/show.ts new file mode 100644 index 00000000..9f1c7e63 --- /dev/null +++ b/api/src/models/show.ts @@ -0,0 +1,36 @@ +import { t } from "elysia"; + +export const ShowStatus = t.UnionEnum([ + "unknown", + "finished", + "airing", + "planned", +]); +export type ShowStatus = typeof ShowStatus.static; + +export const Genre = t.UnionEnum([ + "action", + "adventure", + "animation", + "comedy", + "crime", + "documentary", + "drama", + "family", + "fantasy", + "history", + "horror", + "music", + "mystery", + "romance", + "science-fiction", + "thriller", + "war", + "western", + "kids", + "reality", + "politics", + "soap", + "talk", +]); +export type Genre = typeof Genre.static;