mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Prettify entry types
This commit is contained in:
parent
c730d47cd9
commit
c70e11d36a
@ -1,4 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import type { Prettify } from "~/utils";
|
||||
import { EpisodeId, Resource, SeedImage, TranslationRecord } from "../utils";
|
||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||
|
||||
@ -14,7 +15,7 @@ export const BaseEpisode = t.Intersect([
|
||||
]);
|
||||
|
||||
export const Episode = t.Intersect([Resource(), BaseEpisode, EntryTranslation]);
|
||||
export type Episode = typeof Episode.static;
|
||||
export type Episode = Prettify<typeof Episode.static>;
|
||||
|
||||
export const SeedEpisode = t.Intersect([
|
||||
t.Omit(BaseEpisode, ["thumbnail", "createdAt", "nextRefresh"]),
|
||||
@ -24,4 +25,4 @@ export const SeedEpisode = t.Intersect([
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
export type SeedEpisode = typeof SeedEpisode.static;
|
||||
export type SeedEpisode = Prettify<typeof SeedEpisode.static>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import { comment } from "~/utils";
|
||||
import { type Prettify, comment } from "~/utils";
|
||||
import { SeedImage } from "../utils";
|
||||
import { Resource } from "../utils/resource";
|
||||
import { BaseEntry } from "./base-entry";
|
||||
@ -31,7 +31,7 @@ export const BaseExtra = t.Intersect(
|
||||
);
|
||||
|
||||
export const Extra = t.Intersect([Resource(), BaseExtra]);
|
||||
export type Extra = typeof Extra.static;
|
||||
export type Extra = Prettify<typeof Extra.static>;
|
||||
|
||||
export const SeedExtra = t.Intersect([
|
||||
t.Omit(BaseExtra, ["thumbnail", "createdAt"]),
|
||||
@ -41,4 +41,4 @@ export const SeedExtra = t.Intersect([
|
||||
video: t.String({ format: "uuid" }),
|
||||
}),
|
||||
]);
|
||||
export type SeedExtra = typeof SeedExtra.static;
|
||||
export type SeedExtra = Prettify<typeof SeedExtra.static>;
|
||||
|
@ -9,10 +9,10 @@ import {
|
||||
} from "../entry";
|
||||
|
||||
export const Entry = t.Union([Episode, MovieEntry, Special]);
|
||||
export type Entry = typeof Entry.static;
|
||||
export type Entry = Episode | MovieEntry | Special;
|
||||
|
||||
export const SeedEntry = t.Union([SeedEpisode, SeedMovieEntry, SeedSpecial]);
|
||||
export type SeedEntry = typeof SeedEntry.static;
|
||||
export type SeedEntry = SeedEpisode | SeedMovieEntry | SeedSpecial;
|
||||
|
||||
export * from "./episode";
|
||||
export * from "./movie-entry";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import { comment } from "../../utils";
|
||||
import { comment, Prettify } from "../../utils";
|
||||
import {
|
||||
ExternalId,
|
||||
Image,
|
||||
@ -42,7 +42,7 @@ export const MovieEntry = t.Intersect([
|
||||
BaseMovieEntry,
|
||||
MovieEntryTranslation,
|
||||
]);
|
||||
export type MovieEntry = typeof MovieEntry.static;
|
||||
export type MovieEntry = Prettify<typeof MovieEntry.static>;
|
||||
|
||||
export const SeedMovieEntry = t.Intersect([
|
||||
t.Omit(BaseMovieEntry, ["thumbnail", "createdAt", "nextRefresh"]),
|
||||
@ -58,4 +58,4 @@ export const SeedMovieEntry = t.Intersect([
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
export type SeedMovieEntry = typeof SeedMovieEntry.static;
|
||||
export type SeedMovieEntry = Prettify<typeof SeedMovieEntry.static>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import { comment } from "../../utils";
|
||||
import { type Prettify, comment } from "~/utils";
|
||||
import { EpisodeId, Resource, SeedImage, TranslationRecord } from "../utils";
|
||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||
|
||||
@ -25,7 +25,7 @@ export const BaseSpecial = t.Intersect(
|
||||
);
|
||||
|
||||
export const Special = t.Intersect([Resource(), BaseSpecial, EntryTranslation]);
|
||||
export type Special = typeof Special.static;
|
||||
export type Special = Prettify<typeof Special.static>;
|
||||
|
||||
export const SeedSpecial = t.Intersect([
|
||||
t.Omit(BaseSpecial, ["thumbnail", "createdAt", "nextRefresh"]),
|
||||
@ -35,4 +35,4 @@ export const SeedSpecial = t.Intersect([
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
export type SeedSpecial = typeof SeedSpecial.static;
|
||||
export type SeedSpecial = Prettify<typeof SeedSpecial.static>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import { comment } from "../../utils";
|
||||
import { type Prettify, comment } from "~/utils";
|
||||
import { Resource } from "../utils/resource";
|
||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||
|
||||
@ -27,4 +27,4 @@ export const UnknownEntry = t.Intersect([
|
||||
BaseUnknownEntry,
|
||||
UnknownEntryTranslation,
|
||||
]);
|
||||
export type UnknownEntry = typeof UnknownEntry.static;
|
||||
export type UnknownEntry = Prettify<typeof UnknownEntry.static>;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { t } from "elysia";
|
||||
import type { Prettify } from "~/utils";
|
||||
import { bubble, registerExamples } from "./examples";
|
||||
import { bubbleImages } from "./examples/bubble";
|
||||
import {
|
||||
@ -57,7 +58,7 @@ export const Movie = t.Intersect([
|
||||
BaseMovie,
|
||||
t.Object({ isAvailable: t.Boolean() }),
|
||||
]);
|
||||
export type Movie = typeof Movie.static;
|
||||
export type Movie = Prettify<typeof Movie.static>;
|
||||
|
||||
export const FullMovie = t.Intersect([
|
||||
Movie,
|
||||
@ -86,7 +87,7 @@ export const SeedMovie = t.Intersect([
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
export type SeedMovie = typeof SeedMovie.static;
|
||||
export type SeedMovie = Prettify<typeof SeedMovie.static>;
|
||||
|
||||
registerExamples(Movie, {
|
||||
...bubble,
|
||||
|
@ -10,3 +10,7 @@ export const comment = (str: TemplateStringsArray, ...values: any[]) =>
|
||||
export function getYear(date: string) {
|
||||
return new Date(date).getUTCFullYear();
|
||||
}
|
||||
|
||||
export type Prettify<T> = {
|
||||
[K in keyof T]: Prettify<T[K]>;
|
||||
} & {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user