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),
createdAt: t.String({ format: "date-time" }),
nextRefresh: t.String({ format: "date-time" }),
});

View File

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

View File

@ -1,7 +1,7 @@
import { t } from "elysia";
import { type Prettify, comment } from "~/utils";
import { madeInAbyss, registerExamples } from "../examples";
import { SeedImage } from "../utils";
import { DbMetadata, SeedImage } from "../utils";
import { Resource } from "../utils/resource";
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 const SeedExtra = t.Intersect([
t.Omit(BaseExtra, ["thumbnail", "createdAt"]),
t.Omit(BaseExtra, ["thumbnail"]),
t.Object({
slug: t.String({ format: "slug" }),
thumbnail: t.Nullable(SeedImage),

View File

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

View File

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

View File

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