site-api-shema.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { z } from "zod";
  2. import { GameShema } from "../game-shema.js";
  3. class siteApiShema {
  4. // /bookings/get-today-bookings
  5. public ZGetTodayBookings = {
  6. res: z.array(
  7. z.object({
  8. booking_id: z.number(),
  9. customer_phone: z.string().nullable(),
  10. customer_name: z.string().nullable(),
  11. customer_email: z.string().nullable(),
  12. game_id: z.string().nullable(),
  13. size: z.number(),
  14. booking_timestamp: z.string(),
  15. game_start: z.string(),
  16. game_end: z.string(),
  17. players_number: z.number(),
  18. }),
  19. ),
  20. };
  21. // /bookings/get-booking
  22. public ZGetBooking = {
  23. req: z.object({ booking_id: z.number() }),
  24. res: z.object({
  25. booking_id: z.number(),
  26. customer_phone: z.string().nullable(),
  27. customer_name: z.string().nullable(),
  28. customer_email: z.string().nullable(),
  29. game_id: GameShema.Z_GAMES_TYPES.nullable(),
  30. size: z.number(),
  31. booking_timestamp: z.string(),
  32. game_start: z.string(),
  33. game_end: z.string(),
  34. players_number: z.number(),
  35. }),
  36. };
  37. // /booking/change-booking
  38. public ZChangeBooking = {
  39. req: z.object({
  40. booking_id: z.number(),
  41. size: z.number(),
  42. }),
  43. res: z.object({
  44. booking_id: z.number(),
  45. game_id: GameShema.Z_GAMES_TYPES,
  46. size: z.number(),
  47. game_start: z.string(),
  48. game_end: z.string(),
  49. }),
  50. };
  51. // booking/book
  52. public ZBook = {
  53. req: z.object({
  54. gameStart: z.string(),
  55. size: z.number(),
  56. playersNumber: z.number(),
  57. isHotBooking: z.boolean().optional(),
  58. }),
  59. res: z.object({
  60. code: z.enum(["occupied", "sucsess", "error"]),
  61. booking: z
  62. .object({
  63. booking_id: z.number(),
  64. size: z.number(),
  65. game_start: z.string(),
  66. game_end: z.string(),
  67. players_number: z.number(),
  68. })
  69. .optional(),
  70. }),
  71. };
  72. //
  73. public ZGetGames = {
  74. res: z.array(
  75. z.object({
  76. game_id: GameShema.Z_GAMES_TYPES,
  77. name: z.string(),
  78. active: z.boolean(),
  79. min_players_number: z.number().min(1).max(8),
  80. max_players_number: z.number().min(1).max(8),
  81. }),
  82. ),
  83. };
  84. }
  85. export default new siteApiShema();