Use db metadata on entries

This commit is contained in:
Zoe Roux 2025-03-02 23:05:05 +01:00
parent 710675180c
commit 2301e48321
No known key found for this signature in database
6 changed files with 27 additions and 12 deletions

View File

@ -12,7 +12,6 @@ export const BaseEntry = () =>
), ),
thumbnail: t.Nullable(Image), thumbnail: t.Nullable(Image),
createdAt: t.String({ format: "date-time" }),
nextRefresh: t.String({ format: "date-time" }), nextRefresh: t.String({ format: "date-time" }),
}); });

View File

@ -1,7 +1,13 @@
import { t } from "elysia"; import { t } from "elysia";
import type { Prettify } from "~/utils"; import type { Prettify } from "~/utils";
import { bubbleImages, madeInAbyss, registerExamples } from "../examples"; import { bubbleImages, madeInAbyss, registerExamples } from "../examples";
import { EpisodeId, Resource, SeedImage, TranslationRecord } from "../utils"; import {
DbMetadata,
EpisodeId,
Resource,
SeedImage,
TranslationRecord,
} from "../utils";
import { BaseEntry, EntryTranslation } from "./base-entry"; import { BaseEntry, EntryTranslation } from "./base-entry";
export const BaseEpisode = t.Intersect([ export const BaseEpisode = t.Intersect([
@ -19,11 +25,12 @@ export const Episode = t.Intersect([
Resource(), Resource(),
EntryTranslation(), EntryTranslation(),
BaseEpisode, BaseEpisode,
DbMetadata,
]); ]);
export type Episode = Prettify<typeof Episode.static>; export type Episode = Prettify<typeof Episode.static>;
export const SeedEpisode = t.Intersect([ export const SeedEpisode = t.Intersect([
t.Omit(BaseEpisode, ["thumbnail", "createdAt", "nextRefresh"]), t.Omit(BaseEpisode, ["thumbnail", "nextRefresh"]),
t.Object({ t.Object({
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),
translations: TranslationRecord(EntryTranslation()), translations: TranslationRecord(EntryTranslation()),

View File

@ -1,7 +1,7 @@
import { t } from "elysia"; import { t } from "elysia";
import { type Prettify, comment } from "~/utils"; import { type Prettify, comment } from "~/utils";
import { madeInAbyss, registerExamples } from "../examples"; import { madeInAbyss, registerExamples } from "../examples";
import { SeedImage } from "../utils"; import { DbMetadata, SeedImage } from "../utils";
import { Resource } from "../utils/resource"; import { Resource } from "../utils/resource";
import { BaseEntry } from "./base-entry"; import { BaseEntry } from "./base-entry";
@ -31,11 +31,11 @@ export const BaseExtra = t.Intersect(
}, },
); );
export const Extra = t.Intersect([Resource(), BaseExtra]); export const Extra = t.Intersect([Resource(), BaseExtra, DbMetadata]);
export type Extra = Prettify<typeof Extra.static>; export type Extra = Prettify<typeof Extra.static>;
export const SeedExtra = t.Intersect([ export const SeedExtra = t.Intersect([
t.Omit(BaseExtra, ["thumbnail", "createdAt"]), t.Omit(BaseExtra, ["thumbnail"]),
t.Object({ t.Object({
slug: t.String({ format: "slug" }), slug: t.String({ format: "slug" }),
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),

View File

@ -2,6 +2,7 @@ import { t } from "elysia";
import { type Prettify, comment } from "~/utils"; import { type Prettify, comment } from "~/utils";
import { bubbleImages, madeInAbyss, registerExamples } from "../examples"; import { bubbleImages, madeInAbyss, registerExamples } from "../examples";
import { import {
DbMetadata,
ExternalId, ExternalId,
Image, Image,
Resource, Resource,
@ -42,11 +43,12 @@ export const MovieEntry = t.Intersect([
Resource(), Resource(),
MovieEntryTranslation, MovieEntryTranslation,
BaseMovieEntry, BaseMovieEntry,
DbMetadata,
]); ]);
export type MovieEntry = Prettify<typeof MovieEntry.static>; export type MovieEntry = Prettify<typeof MovieEntry.static>;
export const SeedMovieEntry = t.Intersect([ export const SeedMovieEntry = t.Intersect([
t.Omit(BaseMovieEntry, ["thumbnail", "createdAt", "nextRefresh"]), t.Omit(BaseMovieEntry, ["thumbnail", "nextRefresh"]),
t.Object({ t.Object({
slug: t.Optional(t.String({ format: "slug" })), slug: t.Optional(t.String({ format: "slug" })),
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),

View File

@ -1,7 +1,13 @@
import { t } from "elysia"; import { t } from "elysia";
import { type Prettify, comment } from "~/utils"; import { type Prettify, comment } from "~/utils";
import { bubbleImages, madeInAbyss, registerExamples } from "../examples"; import { bubbleImages, madeInAbyss, registerExamples } from "../examples";
import { EpisodeId, Resource, SeedImage, TranslationRecord } from "../utils"; import {
DbMetadata,
EpisodeId,
Resource,
SeedImage,
TranslationRecord,
} from "../utils";
import { BaseEntry, EntryTranslation } from "./base-entry"; import { BaseEntry, EntryTranslation } from "./base-entry";
export const BaseSpecial = t.Intersect( export const BaseSpecial = t.Intersect(
@ -29,11 +35,12 @@ export const Special = t.Intersect([
Resource(), Resource(),
EntryTranslation(), EntryTranslation(),
BaseSpecial, BaseSpecial,
DbMetadata,
]); ]);
export type Special = Prettify<typeof Special.static>; export type Special = Prettify<typeof Special.static>;
export const SeedSpecial = t.Intersect([ export const SeedSpecial = t.Intersect([
t.Omit(BaseSpecial, ["thumbnail", "createdAt", "nextRefresh"]), t.Omit(BaseSpecial, ["thumbnail", "nextRefresh"]),
t.Object({ t.Object({
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),
translations: TranslationRecord(EntryTranslation()), translations: TranslationRecord(EntryTranslation()),

View File

@ -1,8 +1,7 @@
import { t } from "elysia"; import { t } from "elysia";
import { type Prettify, comment } from "~/utils"; import { type Prettify, comment } from "~/utils";
import { bubbleImages, registerExamples } from "../examples"; import { bubbleImages, registerExamples, youtubeExample } from "../examples";
import { youtubeExample } from "../examples/others"; import { DbMetadata, Resource } from "../utils";
import { Resource } from "../utils/resource";
import { BaseEntry, EntryTranslation } from "./base-entry"; import { BaseEntry, EntryTranslation } from "./base-entry";
export const BaseUnknownEntry = t.Intersect( export const BaseUnknownEntry = t.Intersect(
@ -28,6 +27,7 @@ export const UnknownEntry = t.Intersect([
Resource(), Resource(),
UnknownEntryTranslation, UnknownEntryTranslation,
BaseUnknownEntry, BaseUnknownEntry,
DbMetadata,
]); ]);
export type UnknownEntry = Prettify<typeof UnknownEntry.static>; export type UnknownEntry = Prettify<typeof UnknownEntry.static>;