mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Use .Composite
for models (better swagger)
This commit is contained in:
parent
9cb9301a35
commit
7203155747
@ -45,7 +45,7 @@ export const CollectionTranslation = t.Object({
|
|||||||
logo: t.Nullable(Image),
|
logo: t.Nullable(Image),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Collection = t.Intersect([
|
export const Collection = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
CollectionTranslation,
|
CollectionTranslation,
|
||||||
BaseCollection,
|
BaseCollection,
|
||||||
@ -64,7 +64,7 @@ export const FullCollection = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type FullCollection = Prettify<typeof FullCollection.static>;
|
export type FullCollection = Prettify<typeof FullCollection.static>;
|
||||||
|
|
||||||
export const SeedCollection = t.Intersect([
|
export const SeedCollection = t.Composite([
|
||||||
t.Omit(BaseCollection, ["kind", "startAir", "endAir", "nextRefresh"]),
|
t.Omit(BaseCollection, ["kind", "startAir", "endAir", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
@ -72,7 +72,7 @@ export const SeedCollection = t.Intersect([
|
|||||||
description: "The language code this collection's items were made in.",
|
description: "The language code this collection's items were made in.",
|
||||||
}),
|
}),
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
t.Intersect([
|
t.Composite([
|
||||||
t.Omit(CollectionTranslation, [
|
t.Omit(CollectionTranslation, [
|
||||||
"poster",
|
"poster",
|
||||||
"thumbnail",
|
"thumbnail",
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { EmbeddedVideo } from "../video";
|
import { EmbeddedVideo } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseEpisode = t.Intersect([
|
export const BaseEpisode = t.Composite([
|
||||||
t.Object({
|
t.Object({
|
||||||
kind: t.Literal("episode"),
|
kind: t.Literal("episode"),
|
||||||
order: t.Number({ minimum: 1, description: "Absolute playback order." }),
|
order: t.Number({ minimum: 1, description: "Absolute playback order." }),
|
||||||
@ -23,7 +23,7 @@ export const BaseEpisode = t.Intersect([
|
|||||||
BaseEntry(),
|
BaseEntry(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const Episode = t.Intersect([
|
export const Episode = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
EntryTranslation(),
|
EntryTranslation(),
|
||||||
BaseEpisode,
|
BaseEpisode,
|
||||||
@ -35,7 +35,7 @@ export const Episode = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type Episode = Prettify<typeof Episode.static>;
|
export type Episode = Prettify<typeof Episode.static>;
|
||||||
|
|
||||||
export const SeedEpisode = t.Intersect([
|
export const SeedEpisode = t.Composite([
|
||||||
t.Omit(BaseEpisode, ["thumbnail", "nextRefresh"]),
|
t.Omit(BaseEpisode, ["thumbnail", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
thumbnail: t.Nullable(SeedImage),
|
thumbnail: t.Nullable(SeedImage),
|
||||||
|
@ -16,7 +16,7 @@ export const ExtraType = t.UnionEnum([
|
|||||||
]);
|
]);
|
||||||
export type ExtraType = typeof ExtraType.static;
|
export type ExtraType = typeof ExtraType.static;
|
||||||
|
|
||||||
export const BaseExtra = t.Intersect(
|
export const BaseExtra = t.Composite(
|
||||||
[
|
[
|
||||||
t.Object({
|
t.Object({
|
||||||
kind: ExtraType,
|
kind: ExtraType,
|
||||||
@ -32,7 +32,7 @@ export const BaseExtra = t.Intersect(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Extra = t.Intersect([
|
export const Extra = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
BaseExtra,
|
BaseExtra,
|
||||||
t.Object({
|
t.Object({
|
||||||
@ -42,7 +42,7 @@ export const Extra = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type Extra = Prettify<typeof Extra.static>;
|
export type Extra = Prettify<typeof Extra.static>;
|
||||||
|
|
||||||
export const SeedExtra = t.Intersect([
|
export const SeedExtra = t.Composite([
|
||||||
t.Omit(BaseExtra, ["thumbnail"]),
|
t.Omit(BaseExtra, ["thumbnail"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
import { EmbeddedVideo } from "../video";
|
import { EmbeddedVideo } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseMovieEntry = t.Intersect(
|
export const BaseMovieEntry = t.Composite(
|
||||||
[
|
[
|
||||||
t.Object({
|
t.Object({
|
||||||
kind: t.Literal("movie"),
|
kind: t.Literal("movie"),
|
||||||
@ -33,7 +33,7 @@ export const BaseMovieEntry = t.Intersect(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const MovieEntryTranslation = t.Intersect([
|
export const MovieEntryTranslation = t.Composite([
|
||||||
EntryTranslation(),
|
EntryTranslation(),
|
||||||
t.Object({
|
t.Object({
|
||||||
tagline: t.Nullable(t.String()),
|
tagline: t.Nullable(t.String()),
|
||||||
@ -41,7 +41,7 @@ export const MovieEntryTranslation = t.Intersect([
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const MovieEntry = t.Intersect([
|
export const MovieEntry = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
MovieEntryTranslation,
|
MovieEntryTranslation,
|
||||||
BaseMovieEntry,
|
BaseMovieEntry,
|
||||||
@ -53,7 +53,7 @@ export const MovieEntry = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type MovieEntry = Prettify<typeof MovieEntry.static>;
|
export type MovieEntry = Prettify<typeof MovieEntry.static>;
|
||||||
|
|
||||||
export const SeedMovieEntry = t.Intersect([
|
export const SeedMovieEntry = t.Composite([
|
||||||
t.Omit(BaseMovieEntry, ["thumbnail", "nextRefresh"]),
|
t.Omit(BaseMovieEntry, ["thumbnail", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.Optional(t.String({ format: "slug" })),
|
slug: t.Optional(t.String({ format: "slug" })),
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { EmbeddedVideo } from "../video";
|
import { EmbeddedVideo } from "../video";
|
||||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||||
|
|
||||||
export const BaseSpecial = t.Intersect(
|
export const BaseSpecial = t.Composite(
|
||||||
[
|
[
|
||||||
t.Object({
|
t.Object({
|
||||||
kind: t.Literal("special"),
|
kind: t.Literal("special"),
|
||||||
@ -33,7 +33,7 @@ export const BaseSpecial = t.Intersect(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Special = t.Intersect([
|
export const Special = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
EntryTranslation(),
|
EntryTranslation(),
|
||||||
BaseSpecial,
|
BaseSpecial,
|
||||||
@ -45,7 +45,7 @@ export const Special = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type Special = Prettify<typeof Special.static>;
|
export type Special = Prettify<typeof Special.static>;
|
||||||
|
|
||||||
export const SeedSpecial = t.Intersect([
|
export const SeedSpecial = t.Composite([
|
||||||
t.Omit(BaseSpecial, ["thumbnail", "nextRefresh"]),
|
t.Omit(BaseSpecial, ["thumbnail", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
thumbnail: t.Nullable(SeedImage),
|
thumbnail: t.Nullable(SeedImage),
|
||||||
|
@ -3,7 +3,6 @@ import type { Video } from "~/models/video";
|
|||||||
|
|
||||||
export const bubbleVideo: Video = {
|
export const bubbleVideo: Video = {
|
||||||
id: "3cd436ee-01ff-4f45-ba98-62aabeb22f25",
|
id: "3cd436ee-01ff-4f45-ba98-62aabeb22f25",
|
||||||
slug: "bubble",
|
|
||||||
path: "/video/Bubble/Bubble (2022).mkv",
|
path: "/video/Bubble/Bubble (2022).mkv",
|
||||||
rendering: "459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
rendering: "459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
||||||
part: null,
|
part: null,
|
||||||
|
@ -48,7 +48,7 @@ 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.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
MovieTranslation,
|
MovieTranslation,
|
||||||
BaseMovie,
|
BaseMovie,
|
||||||
@ -71,7 +71,7 @@ export const FullMovie = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type FullMovie = Prettify<typeof FullMovie.static>;
|
export type FullMovie = Prettify<typeof FullMovie.static>;
|
||||||
|
|
||||||
export const SeedMovie = t.Intersect([
|
export const SeedMovie = t.Composite([
|
||||||
t.Omit(BaseMovie, ["kind", "nextRefresh"]),
|
t.Omit(BaseMovie, ["kind", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug", examples: ["bubble"] }),
|
slug: t.String({ format: "slug", examples: ["bubble"] }),
|
||||||
@ -79,7 +79,7 @@ export const SeedMovie = t.Intersect([
|
|||||||
description: "The language code this movie was made in.",
|
description: "The language code this movie was made in.",
|
||||||
}),
|
}),
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
t.Intersect([
|
t.Composite([
|
||||||
t.Omit(MovieTranslation, ["poster", "thumbnail", "banner", "logo"]),
|
t.Omit(MovieTranslation, ["poster", "thumbnail", "banner", "logo"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
poster: t.Nullable(SeedImage),
|
poster: t.Nullable(SeedImage),
|
||||||
|
@ -27,7 +27,7 @@ export const SeasonTranslation = t.Object({
|
|||||||
});
|
});
|
||||||
export type SeasonTranslation = typeof SeasonTranslation.static;
|
export type SeasonTranslation = typeof SeasonTranslation.static;
|
||||||
|
|
||||||
export const Season = t.Intersect([
|
export const Season = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
SeasonTranslation,
|
SeasonTranslation,
|
||||||
BaseSeason,
|
BaseSeason,
|
||||||
@ -35,11 +35,11 @@ export const Season = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type Season = Prettify<typeof Season.static>;
|
export type Season = Prettify<typeof Season.static>;
|
||||||
|
|
||||||
export const SeedSeason = t.Intersect([
|
export const SeedSeason = t.Composite([
|
||||||
t.Omit(BaseSeason, ["nextRefresh"]),
|
t.Omit(BaseSeason, ["nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
t.Intersect([
|
t.Composite([
|
||||||
t.Omit(SeasonTranslation, ["poster", "thumbnail", "banner"]),
|
t.Omit(SeasonTranslation, ["poster", "thumbnail", "banner"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
poster: t.Nullable(SeedImage),
|
poster: t.Nullable(SeedImage),
|
||||||
|
@ -58,7 +58,7 @@ export const SerieTranslation = t.Object({
|
|||||||
});
|
});
|
||||||
export type SerieTranslation = typeof SerieTranslation.static;
|
export type SerieTranslation = typeof SerieTranslation.static;
|
||||||
|
|
||||||
export const Serie = t.Intersect([
|
export const Serie = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
SerieTranslation,
|
SerieTranslation,
|
||||||
BaseSerie,
|
BaseSerie,
|
||||||
@ -87,7 +87,7 @@ export const FullSerie = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type FullSerie = Prettify<typeof FullSerie.static>;
|
export type FullSerie = Prettify<typeof FullSerie.static>;
|
||||||
|
|
||||||
export const SeedSerie = t.Intersect([
|
export const SeedSerie = t.Composite([
|
||||||
t.Omit(BaseSerie, ["kind", "nextRefresh"]),
|
t.Omit(BaseSerie, ["kind", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
@ -95,7 +95,7 @@ export const SeedSerie = t.Intersect([
|
|||||||
description: "The language code this serie was made in.",
|
description: "The language code this serie was made in.",
|
||||||
}),
|
}),
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
t.Intersect([
|
t.Composite([
|
||||||
t.Omit(SerieTranslation, ["poster", "thumbnail", "banner", "logo"]),
|
t.Omit(SerieTranslation, ["poster", "thumbnail", "banner", "logo"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
poster: t.Nullable(SeedImage),
|
poster: t.Nullable(SeedImage),
|
||||||
|
@ -4,7 +4,7 @@ import { Movie } from "./movie";
|
|||||||
import { Serie } from "./serie";
|
import { Serie } from "./serie";
|
||||||
|
|
||||||
export const Show = t.Union([
|
export const Show = t.Union([
|
||||||
t.Intersect([Movie, t.Object({ kind: t.Literal("movie") })]),
|
t.Composite([t.Object({ kind: t.Literal("movie") }), Movie]),
|
||||||
t.Intersect([Serie, t.Object({ kind: t.Literal("serie") })]),
|
t.Composite([t.Object({ kind: t.Literal("serie") }), Serie]),
|
||||||
t.Intersect([Collection, t.Object({ kind: t.Literal("collection") })]),
|
t.Composite([t.Object({ kind: t.Literal("collection") }), Collection]),
|
||||||
]);
|
]);
|
||||||
|
@ -28,19 +28,19 @@ const StaffData = t.Object({
|
|||||||
image: t.Nullable(Image),
|
image: t.Nullable(Image),
|
||||||
externalId: ExternalId(),
|
externalId: ExternalId(),
|
||||||
});
|
});
|
||||||
export const Staff = t.Intersect([Resource(), StaffData, DbMetadata]);
|
export const Staff = t.Composite([Resource(), StaffData, DbMetadata]);
|
||||||
export type Staff = typeof Staff.static;
|
export type Staff = typeof Staff.static;
|
||||||
|
|
||||||
export const SeedStaff = t.Intersect([
|
export const SeedStaff = t.Composite([
|
||||||
t.Omit(Role, ["character"]),
|
t.Omit(Role, ["character"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
character: t.Intersect([
|
character: t.Composite([
|
||||||
t.Omit(Character, ["image"]),
|
t.Omit(Character, ["image"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
image: t.Nullable(SeedImage),
|
image: t.Nullable(SeedImage),
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
staff: t.Intersect([
|
staff: t.Composite([
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
image: t.Nullable(SeedImage),
|
image: t.Nullable(SeedImage),
|
||||||
|
@ -14,7 +14,7 @@ export const StudioTranslation = t.Object({
|
|||||||
});
|
});
|
||||||
export type StudioTranslation = typeof StudioTranslation.static;
|
export type StudioTranslation = typeof StudioTranslation.static;
|
||||||
|
|
||||||
export const Studio = t.Intersect([
|
export const Studio = t.Composite([
|
||||||
Resource(),
|
Resource(),
|
||||||
StudioTranslation,
|
StudioTranslation,
|
||||||
BaseStudio,
|
BaseStudio,
|
||||||
@ -22,12 +22,12 @@ export const Studio = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type Studio = Prettify<typeof Studio.static>;
|
export type Studio = Prettify<typeof Studio.static>;
|
||||||
|
|
||||||
export const SeedStudio = t.Intersect([
|
export const SeedStudio = t.Composite([
|
||||||
BaseStudio,
|
BaseStudio,
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
slug: t.String({ format: "slug" }),
|
||||||
translations: TranslationRecord(
|
translations: TranslationRecord(
|
||||||
t.Intersect([
|
t.Composite([
|
||||||
t.Omit(StudioTranslation, ["logo"]),
|
t.Omit(StudioTranslation, ["logo"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
logo: t.Nullable(SeedImage),
|
logo: t.Nullable(SeedImage),
|
||||||
|
@ -113,7 +113,7 @@ export const SeedVideo = t.Object({
|
|||||||
});
|
});
|
||||||
export type SeedVideo = Prettify<typeof SeedVideo.static>;
|
export type SeedVideo = Prettify<typeof SeedVideo.static>;
|
||||||
|
|
||||||
export const Video = t.Intersect([
|
export const Video = t.Composite([
|
||||||
t.Object({
|
t.Object({
|
||||||
id: t.String({ format: "uuid" }),
|
id: t.String({ format: "uuid" }),
|
||||||
}),
|
}),
|
||||||
@ -123,7 +123,7 @@ export const Video = t.Intersect([
|
|||||||
export type Video = Prettify<typeof Video.static>;
|
export type Video = Prettify<typeof Video.static>;
|
||||||
|
|
||||||
// type used in entry responses (the slug comes from the entryVideoJoin)
|
// type used in entry responses (the slug comes from the entryVideoJoin)
|
||||||
export const EmbeddedVideo = t.Intersect([
|
export const EmbeddedVideo = t.Composite([
|
||||||
t.Object({ slug: t.String({ format: "slug" }) }),
|
t.Object({ slug: t.String({ format: "slug" }) }),
|
||||||
t.Omit(Video, ["guess", "createdAt", "updatedAt"]),
|
t.Omit(Video, ["guess", "createdAt", "updatedAt"]),
|
||||||
]);
|
]);
|
||||||
|
@ -20,7 +20,7 @@ export const SerieWatchStatus = t.Object({
|
|||||||
});
|
});
|
||||||
export type SerieWatchStatus = typeof SerieWatchStatus.static;
|
export type SerieWatchStatus = typeof SerieWatchStatus.static;
|
||||||
|
|
||||||
export const MovieWatchStatus = t.Intersect([
|
export const MovieWatchStatus = t.Composite([
|
||||||
t.Omit(SerieWatchStatus, ["startedAt", "seenCount"]),
|
t.Omit(SerieWatchStatus, ["startedAt", "seenCount"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
percent: t.Integer({
|
percent: t.Integer({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user