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