Type guess info in db schema

This commit is contained in:
Zoe Roux 2025-03-08 15:23:23 +01:00
parent 6b0e3e7577
commit b69cb05088
No known key found for this signature in database
2 changed files with 39 additions and 37 deletions

View File

@ -9,6 +9,7 @@ import {
uuid,
varchar,
} from "drizzle-orm/pg-core";
import type { Guess } from "~/models/video";
import { entries } from "./entries";
import { schema } from "./utils";
@ -21,7 +22,7 @@ export const videos = schema.table(
rendering: text().notNull(),
part: integer(),
version: integer().notNull().default(1),
guess: jsonb().notNull().default({}),
guess: jsonb().$type<Guess>().notNull(),
createdAt: timestamp({ withTimezone: true, mode: "string" })
.notNull()

View File

@ -3,34 +3,7 @@ import { type Prettify, comment } from "~/utils";
import { bubbleVideo, registerExamples } from "./examples";
import { DbMetadata, Resource } from "./utils";
export const SeedVideo = t.Object({
path: t.String(),
rendering: t.String({
description: comment`
Sha of the path except \`part\` & \`version\`.
If there are multiples files for the same entry, it can be used to know if each
file is the same content or if it's unrelated (like long-version vs short-version, monochrome vs colored etc)
`,
}),
part: t.Nullable(
t.Integer({
minimum: 0,
description: comment`
If the episode/movie is split into multiples files, the \`part\` field can be used to order them.
The \`rendering\` field is used to know if two parts are in the same group or
if it's another unrelated video file of the same entry.
`,
}),
),
version: t.Integer({
minimum: 0,
default: 1,
description:
"Kyoo will prefer playing back the highest `version` number if there are multiples rendering.",
}),
guess: t.Optional(
t.Recursive((Self) =>
export const Guess = t.Recursive((Self) =>
t.Object(
{
title: t.String(),
@ -63,8 +36,36 @@ export const SeedVideo = t.Object({
`,
},
),
);
export type Guess = typeof Guess.static;
export const SeedVideo = t.Object({
path: t.String(),
rendering: t.String({
description: comment`
Sha of the path except \`part\` & \`version\`.
If there are multiples files for the same entry, it can be used to know if each
file is the same content or if it's unrelated (like long-version vs short-version, monochrome vs colored etc)
`,
}),
part: t.Nullable(
t.Integer({
minimum: 0,
description: comment`
If the episode/movie is split into multiples files, the \`part\` field can be used to order them.
The \`rendering\` field is used to know if two parts are in the same group or
if it's another unrelated video file of the same entry.
`,
}),
),
),
version: t.Integer({
minimum: 0,
default: 1,
description:
"Kyoo will prefer playing back the highest `version` number if there are multiples rendering.",
}),
guess: t.Optional(Guess),
});
export type SeedVideo = typeof SeedVideo.static;