registration-api-shema.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { z } from "zod";
  2. import { GameShema } from "../game-shema.js";
  3. import { DbShema } from "../db-shema.js";
  4. import { PrepareGamesShema } from "../games/prepare-games-shema.js";
  5. class registrationApiShema {
  6. // /registration/get-today-bookings
  7. public ZGetTodayBookings = {
  8. res: z.object({
  9. bookings: z.array(
  10. z.object({
  11. booking_id: z.number(),
  12. customer_phone: z.string().nullable(),
  13. customer_name: z.string().nullable(),
  14. customer_email: z.string().nullable(),
  15. game_id: z.string().nullable(),
  16. size: z.number(),
  17. booking_timestamp: z.string(),
  18. game_start: z.string(),
  19. game_end: z.string(),
  20. players_number: z.number(),
  21. }),
  22. ),
  23. freeBookingsNumber: z.number(),
  24. }),
  25. };
  26. //
  27. public ZCreateSession = {
  28. req: z.object({
  29. size: z.number(),
  30. players_number: z.number(),
  31. booking_id: z.number().optional(),
  32. }),
  33. };
  34. //
  35. public ZPlayerAutocompleteByPhone = {
  36. req: z.object({
  37. playerIdx: z.number(),
  38. phone: z.string(),
  39. }),
  40. res: z
  41. .object({
  42. playerIdx: z.number(),
  43. player_id: DbShema.ZPlayers.shape.player_id,
  44. name: DbShema.ZPlayers.shape.name,
  45. phone: DbShema.ZPlayers.shape.phone,
  46. age: DbShema.ZPlayers.shape.age,
  47. })
  48. .nullable(),
  49. };
  50. //
  51. public ZRegisterPlayer = {
  52. req: z.object({
  53. player_id: z.number().nullish(),
  54. idx: z.number(),
  55. name: z.string(),
  56. phone: z.string().nullable(),
  57. age: z.number(),
  58. isLate: z.boolean(),
  59. }),
  60. };
  61. //
  62. public ZSubmitRegistration = {
  63. req: z.object({}),
  64. };
  65. //
  66. public ZGame = z.object({
  67. game_id: GameShema.Z_GAMES_TYPES,
  68. name: z.string(),
  69. active: z.boolean(),
  70. min_players_number: z.number().min(1).max(8),
  71. max_players_number: z.number().min(1).max(8),
  72. });
  73. public ZGetGames = {
  74. res: z.array(this.ZGame),
  75. };
  76. //
  77. public ZSelectNewGame = {
  78. req: z.object({
  79. gameId: GameShema.Z_GAMES_TYPES,
  80. }),
  81. };
  82. //
  83. public ZPrepareNewGameSettings = {
  84. req: z.object({
  85. gameSettings: PrepareGamesShema.ZAllGamesSettings,
  86. }),
  87. };
  88. //
  89. public ZPlayerIsReady = {
  90. req: z.object({ playerId: z.number() }),
  91. };
  92. }
  93. export const RegistrationApiShema = new registrationApiShema();