123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- import { z } from "zod";
- import { GameShema } from "../game-shema.js";
- import { DbShema } from "../db-shema.js";
- import { PrepareGamesShema } from "../games/prepare-games-shema.js";
- class registrationApiShema {
- // /registration/get-today-bookings
- public ZGetTodayBookings = {
- res: z.object({
- bookings: z.array(
- z.object({
- booking_id: z.number(),
- customer_phone: z.string().nullable(),
- customer_name: z.string().nullable(),
- customer_email: z.string().nullable(),
- game_id: z.string().nullable(),
- size: z.number(),
- booking_timestamp: z.string(),
- game_start: z.string(),
- game_end: z.string(),
- players_number: z.number(),
- }),
- ),
- freeBookingsNumber: z.number(),
- }),
- };
- //
- public ZCreateSession = {
- req: z.object({
- size: z.number(),
- players_number: z.number(),
- booking_id: z.number().optional(),
- }),
- };
- //
- public ZPlayerAutocompleteByPhone = {
- req: z.object({
- playerIdx: z.number(),
- phone: z.string(),
- }),
- res: z
- .object({
- playerIdx: z.number(),
- player_id: DbShema.ZPlayers.shape.player_id,
- name: DbShema.ZPlayers.shape.name,
- phone: DbShema.ZPlayers.shape.phone,
- age: DbShema.ZPlayers.shape.age,
- })
- .nullable(),
- };
- //
- public ZRegisterPlayer = {
- req: z.object({
- player_id: z.number().nullish(),
- idx: z.number(),
- name: z.string(),
- phone: z.string().nullable(),
- age: z.number(),
- isLate: z.boolean(),
- }),
- };
- //
- public ZSubmitRegistration = {
- req: z.object({}),
- };
- //
- public ZGame = z.object({
- game_id: GameShema.Z_GAMES_TYPES,
- name: z.string(),
- active: z.boolean(),
- min_players_number: z.number().min(1).max(8),
- max_players_number: z.number().min(1).max(8),
- });
- public ZGetGames = {
- res: z.array(this.ZGame),
- };
- //
- public ZSelectNewGame = {
- req: z.object({
- gameId: GameShema.Z_GAMES_TYPES,
- }),
- };
- //
- public ZPrepareNewGameSettings = {
- req: z.object({
- gameSettings: PrepareGamesShema.ZAllGamesSettings,
- }),
- };
- //
- public ZPlayerIsReady = {
- req: z.object({ playerId: z.number() }),
- };
- }
- export const RegistrationApiShema = new registrationApiShema();
|