wip version of the api

This commit is contained in:
lila 2026-04-05 00:33:34 +02:00
parent c24967dc74
commit 7d80b20390
8 changed files with 61 additions and 3 deletions

View file

@ -1,3 +1,5 @@
export const SUPPORTED_LANGUAGE_CODES = ["en", "it"] as const;
export const SUPPORTED_POS = ["noun"] as const;
export const GAME_ROUNDS = ["3", "10"] as const;

View file

@ -1,5 +1,11 @@
import * as z from "zod";
import {
SUPPORTED_LANGUAGE_CODES,
SUPPORTED_POS,
GAME_ROUNDS,
} from "./constants.js";
export const Term = z.object({
id: z.uuid(),
synset_id: z.string(),
@ -70,3 +76,16 @@ export const DeckTerm = z.object({
});
export type DeckTerm = z.infer<typeof DeckTerm>;
export const GameRequestSchema = z
.object({
source_language: z.enum(SUPPORTED_LANGUAGE_CODES),
target_language: z.enum(SUPPORTED_LANGUAGE_CODES),
pos: z.enum(SUPPORTED_POS),
rounds: z.enum(GAME_ROUNDS).transform(Number),
})
.refine((game) => game.target_language !== game.source_language, {
error: "source and target language must be different",
});
export type GameRequestSchema = z.infer<typeof GameRequestSchema>;