mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Seed movie schema
This commit is contained in:
parent
b8b536632d
commit
361c07ce53
@ -5,13 +5,15 @@ import {
|
||||
Image,
|
||||
Language,
|
||||
Resource,
|
||||
SeedImage,
|
||||
} from "./utils";
|
||||
import { Video } from "./video";
|
||||
import { SeedVideo } from "./video";
|
||||
import { bubble, registerExamples } from "./examples";
|
||||
|
||||
export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]);
|
||||
export type MovieStatus = typeof MovieStatus.static;
|
||||
|
||||
export const BaseMovie = t.Object({
|
||||
const BaseMovie = t.Object({
|
||||
genres: t.Array(Genre),
|
||||
rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })),
|
||||
status: MovieStatus,
|
||||
@ -31,8 +33,6 @@ export const BaseMovie = t.Object({
|
||||
|
||||
externalId: ExternalId,
|
||||
});
|
||||
export type BaseMovie = typeof BaseMovie.static;
|
||||
|
||||
export const MovieTranslation = t.Object({
|
||||
name: t.String(),
|
||||
description: t.Nullable(t.String()),
|
||||
@ -48,23 +48,31 @@ export const MovieTranslation = t.Object({
|
||||
});
|
||||
export type MovieTranslation = typeof MovieTranslation.static;
|
||||
|
||||
export const Movie = t.Intersect([
|
||||
Resource,
|
||||
BaseMovie,
|
||||
t.Ref(MovieTranslation),
|
||||
]);
|
||||
export const Movie = t.Intersect([Resource, MovieTranslation, BaseMovie]);
|
||||
export type Movie = typeof Movie.static;
|
||||
|
||||
export const SeedMovie = t.Intersect([
|
||||
BaseMovie,
|
||||
t.Omit(BaseMovie, ["createdAt", "nextRefresh"]),
|
||||
t.Object({
|
||||
slug: t.String({ format: "slug" }),
|
||||
image: t.Ref("image"),
|
||||
toto: t.Ref("mt"),
|
||||
translations: t.Record(t.String(), t.Ref("mt"), {
|
||||
minProperties: 1,
|
||||
}),
|
||||
videos: t.Optional(t.Array(t.Ref(Video))),
|
||||
translations: t.Record(
|
||||
Language(),
|
||||
t.Intersect([
|
||||
t.Omit(MovieTranslation, ["poster", "thumbnail", "banner", "logo"]),
|
||||
t.Object({
|
||||
poster: t.Nullable(SeedImage),
|
||||
thumbnail: t.Nullable(SeedImage),
|
||||
banner: t.Nullable(SeedImage),
|
||||
logo: t.Nullable(SeedImage),
|
||||
}),
|
||||
]),
|
||||
{
|
||||
minProperties: 1,
|
||||
},
|
||||
),
|
||||
videos: t.Optional(t.Array(SeedVideo)),
|
||||
}),
|
||||
]);
|
||||
export type SeedMovie = typeof SeedMovie.static;
|
||||
|
||||
registerExamples(SeedMovie, bubble);
|
||||
|
@ -6,3 +6,5 @@ export const Image = t.Object({
|
||||
blurhash: t.String(),
|
||||
});
|
||||
export type Image = typeof Image.static;
|
||||
|
||||
export const SeedImage = t.String({ format: "uri" });
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { FormatRegistry } from "@sinclair/typebox";
|
||||
import { t } from "elysia";
|
||||
|
||||
export const slugPattern = "^[a-z0-9-]+$";
|
||||
|
||||
FormatRegistry.Set("slug", (slug) => {
|
||||
return /^[a-z0-9-]+$/g.test(slug);
|
||||
});
|
||||
|
@ -1,11 +1,9 @@
|
||||
import { t } from "elysia";
|
||||
import { comment } from "../utils";
|
||||
import { bubble, registerExamples } from "./examples";
|
||||
import { Movie } from "./movie";
|
||||
|
||||
export const Video = t.Object({
|
||||
id: t.String({ format: "uuid" }),
|
||||
slug: t.String(),
|
||||
slug: t.String({ format: "slug" }),
|
||||
path: t.String(),
|
||||
rendering: t.String({
|
||||
description: comment`
|
||||
@ -36,4 +34,7 @@ export const Video = t.Object({
|
||||
|
||||
export type Video = typeof Video.static;
|
||||
|
||||
registerExamples(Video, ...bubble.videos);
|
||||
export const SeedVideo = t.Union([
|
||||
t.Omit(Video, ["id", "slug", "createdAt"]),
|
||||
t.String({ format: "uuid" }),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user