Browse Source

чистка мусора

Vadim 10 months ago
parent
commit
b83b576aa6

+ 0 - 86
global/api/game-session-api-shema.ts

@@ -1,86 +0,0 @@
-import { z } from "zod";
-import { ZGameSessionShema, ZSpecificGame } from "../game-session-shema.js";
-import { DbShema } from "../db-shema.js";
-import { GameShema } from "../game-shema.js";
-
-class GameSessionApiShema {
-  //
-
-  // z.object({
-  //   sessionId: ZGameSessionShema.shape.sessionId,
-  //   players: ZGameSessionShema.shape.players,
-  //   sessionStart: z.string(),
-  //   sessionPlanEnd: z.string(),
-  //   sessionStage: ZGameSessionShema.shape.sessionStage,
-
-  //   currentGameIdx: ZGameSessionShema.shape.currentGameIdx,
-  //   games: ZGameSessionShema.shape.games,
-  // });
-  public ZMediaControlCommand = z.enum([
-    "play",
-    "pause",
-    "mute",
-    "unMute",
-    "restart",
-  ]);
-
-  public ZSessionSubscribe = {
-    res: z.object({
-      isUnfinishedSession: z.boolean().optional(),
-
-      session: ZGameSessionShema.nullish(),
-      currentGame: ZSpecificGame.optional(),
-      timer: z.number().nullish(),
-
-      mediaControl: z
-        .object({
-          meidaPlayerId: z.string(),
-          command: this.ZMediaControlCommand,
-          currentTime: z.number().optional(),
-        })
-        .optional(),
-    }),
-  };
-
-  public ZHistorySubscribe = {
-    res: z.object({
-      history: z.array(
-        z.object({
-          note_id: DbShema.ZHistoryNotes.shape.note_id,
-          timestamp: DbShema.ZHistoryNotes.shape.timestamp,
-          text: DbShema.ZHistoryNotes.shape.text,
-        }),
-      ),
-    }),
-  };
-
-  public ZUpdatePlayerLate = {
-    req: z.object({
-      playerIdx: z.number(),
-      newVal: z.boolean(),
-    }),
-  };
-
-  public ZMediaControl = {
-    req: z.object({
-      meidaPlayerId: z.string(),
-      command: this.ZMediaControlCommand,
-      currentTime: z.number().optional(),
-    }),
-  };
-
-  public ZChangeSessionStage = {
-    req: z.object({
-      stage: ZGameSessionShema.shape.sessionStage,
-    }),
-  };
-
-  public ZChangeGameStage = {
-    req: z.object({
-      gameId: GameShema.Z_GAMES_TYPES,
-      gameStage: GameShema.ZGame.shape.gameStage,
-    }),
-  };
-}
-
-export default new GameSessionApiShema();

+ 0 - 77
global/api/games/sigame-api-shema.ts

@@ -1,77 +0,0 @@
-import { z } from "zod";
-import { DbShema } from "../../db-shema.js";
-
-class sigameApiShema {
-  public ZSelectQuestion = {
-    req: z.object({
-      questionIdx: z.number(),
-      categoryIdx: z.number(),
-    }),
-  };
-
-  public ZPlayerAnswer = {
-    req: z.object({
-      isRightAnswer: z.boolean(),
-    }),
-  };
-
-  public ZTypePlayerAnswer = {
-    req: z.object({
-      isRightAnswer: z.boolean(),
-    }),
-  };
-
-  public ZCatSelectPlayer = {
-    req: z.object({
-      playerIdx: z.number(),
-    }),
-  };
-
-  public ZAuctionPlayerBet = {
-    req: z.object({
-      bet: z.union([z.number().min(1), z.literal("AllIn"), z.literal("check")]),
-    }),
-  };
-
-  public ZRemoveFinalCategory = {
-    req: z.object({
-      categoryId: DbShema.ZCategories.shape.category_id,
-    }),
-  };
-
-  public ZGodChangePlayerScore = {
-    req: z.object({
-      playerIdx: z.number(),
-      newScore: z.number(),
-    }),
-  };
-
-  public ZFinalPlayerBet = {
-    req: z.object({
-      playerIdx: z.number(),
-      bet: z.number(),
-    }),
-  };
-
-  public ZFinalPlayerAnswer = {
-    req: z.object({
-      playerIdx: z.number(),
-      newVal: z.string(),
-    }),
-  };
-
-  public ZFinalPlayerEvaluation = {
-    req: z.object({
-      playerIdx: z.number(),
-      isRight: z.boolean(),
-    }),
-  };
-
-  public ZPLayerButtonIsPressed = {
-    req: z.object({
-      consoleIdx: z.number(),
-    }),
-  };
-}
-
-export const SigameApiShema = new sigameApiShema();

+ 0 - 69
global/api/questions-api-shema.ts

@@ -1,69 +0,0 @@
-import { z } from "zod";
-import { DbShema } from "../db-shema.js";
-
-class QuestionsApiShema {
-  public ZCreateNewQuestion = {
-    req: {
-      data: z.object({
-        text: DbShema.ZQuestions.shape.q_text,
-        answers: DbShema.ZQuestions.shape.answers,
-        difficulty: DbShema.ZQuestions.shape.difficulty,
-        categories: z.array(DbShema.ZCategories.shape.category_id),
-      }),
-      questionId: z.number().optional(),
-    },
-  };
-
-  //
-  public ZCategory = z.object({
-    category_id: DbShema.ZCategories.shape.category_id,
-    name: DbShema.ZCategories.shape.name,
-    description: DbShema.ZCategories.shape.description,
-
-    category_questions_count:
-      DbShema.ZRemainingCategoryQuestions.shape.category_questions_count,
-    max_used_category_questions:
-      DbShema.ZRemainingCategoryQuestions.shape.max_used_category_questions,
-    questions_remained:
-      DbShema.ZRemainingCategoryQuestions.shape.questions_remained,
-    is_shortage: z.boolean(),
-  });
-
-  public ZGetCategories = {
-    res: z.array(this.ZCategory),
-  };
-  //
-
-  public ZCreateNewCategory = {
-    req: z.object({
-      name: DbShema.ZCategories.shape.name,
-      description: DbShema.ZCategories.shape.description,
-    }),
-  };
-
-  public ZGetQuestionsByCategory = {
-    req: z.object({
-      categoryId: DbShema.ZCategories.shape.category_id,
-    }),
-    res: z.object({
-      questions: z.array(DbShema.ZQuestions),
-    }),
-  };
-
-  public ZGetQuestionCategories = {
-    req: z.object({
-      questionId: DbShema.ZQuestions.shape.question_id,
-    }),
-    res: z.object({
-      categories: z.array(z.number()),
-    }),
-  };
-
-  public ZDeleteQuestion = {
-    req: z.object({
-      questionId: DbShema.ZQuestions.shape.question_id,
-    }),
-  };
-}
-
-export default new QuestionsApiShema();

+ 0 - 108
global/api/registration-api-shema.ts

@@ -1,108 +0,0 @@
-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();

+ 0 - 33
global/api/session-api-shema.ts

@@ -1,33 +0,0 @@
-import { z } from "zod";
-import { DbShema } from "../db-shema.js";
-
-class sessionApiShema {
-  // /session/add-user
-  public ZAddUser = {
-    req: z.object({
-      username: DbShema.ZUsers.shape.username,
-      password: DbShema.ZUsers.shape.password,
-    }),
-  };
-
-  // /session/login
-  public ZLogin = {
-    req: z.object({
-      username: DbShema.ZUsers.shape.username,
-      password: DbShema.ZUsers.shape.password,
-    }),
-    res: z.object({
-      accessToken: z.string(),
-      refreshToken: z.string(),
-      userData: z.object({
-        username: DbShema.ZUsers.shape.username,
-        userId: DbShema.ZUsers.shape.user_id,
-      }),
-    }),
-  };
-
-  // /session/refresh
-  public ZRefresh = { res: this.ZLogin.res };
-}
-
-export default new sessionApiShema();

+ 0 - 93
global/api/site-api-shema.ts

@@ -1,93 +0,0 @@
-import { z } from "zod";
-import { GameShema } from "../game-shema.js";
-
-class siteApiShema {
-  // /bookings/get-today-bookings
-  public ZGetTodayBookings = {
-    res: 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(),
-      }),
-    ),
-  };
-  // /bookings/get-booking
-  public ZGetBooking = {
-    req: z.object({ booking_id: z.number() }),
-    res: z.object({
-      booking_id: z.number(),
-      customer_phone: z.string().nullable(),
-      customer_name: z.string().nullable(),
-      customer_email: z.string().nullable(),
-      game_id: GameShema.Z_GAMES_TYPES.nullable(),
-      size: z.number(),
-      booking_timestamp: z.string(),
-      game_start: z.string(),
-      game_end: z.string(),
-      players_number: z.number(),
-    }),
-  };
-
-  // /booking/change-booking
-  public ZChangeBooking = {
-    req: z.object({
-      booking_id: z.number(),
-      size: z.number(),
-    }),
-
-    res: z.object({
-      booking_id: z.number(),
-      game_id: GameShema.Z_GAMES_TYPES,
-      size: z.number(),
-      game_start: z.string(),
-      game_end: z.string(),
-    }),
-  };
-
-  // booking/book
-  public ZBook = {
-    req: z.object({
-      gameStart: z.string(),
-      size: z.number(),
-      playersNumber: z.number(),
-      isHotBooking: z.boolean().optional(),
-    }),
-
-    res: z.object({
-      code: z.enum(["occupied", "sucsess", "error"]),
-      booking: z
-        .object({
-          booking_id: z.number(),
-          size: z.number(),
-          game_start: z.string(),
-          game_end: z.string(),
-          players_number: z.number(),
-        })
-        .optional(),
-    }),
-  };
-
-  //
-
-  public ZGetGames = {
-    res: z.array(
-      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),
-      }),
-    ),
-  };
-}
-
-export default new siteApiShema();

+ 0 - 18
global/games/prepare-games-shema.ts

@@ -1,18 +0,0 @@
-import { z } from "zod";
-
-class prepareGamesShema {
-  public ZSigameSettings = z.object({
-    categoryIds: z.array(z.number()),
-  });
-
-  public ZMafiaSettings = z.object({
-    test: z.string(),
-  });
-
-  public ZAllGamesSettings = z.union([
-    this.ZSigameSettings,
-    this.ZMafiaSettings,
-  ]);
-}
-
-export const PrepareGamesShema = new prepareGamesShema();

+ 0 - 124
global/games/sigame-shema.ts

@@ -1,124 +0,0 @@
-import { z } from "zod";
-import { DbShema } from "../db-shema.js";
-import { GameShema } from "../game-shema.js";
-
-export const SigameShema = new (class SigameShema {
-  public ZSigameQuestion = z.object({
-    question_id: DbShema.ZQuestions.shape.question_id,
-
-    q_text: DbShema.ZQuestions.shape.q_text,
-    q_media_filename: DbShema.ZQuestions.shape.q_media_filename,
-    difficulty: DbShema.ZQuestions.shape.difficulty,
-    answers: DbShema.ZQuestions.shape.answers,
-    q_media_type: DbShema.ZQuestions.shape.q_media_type,
-    a_media_filename: DbShema.ZQuestions.shape.a_media_filename,
-    a_media_type: DbShema.ZQuestions.shape.a_media_type,
-
-    price: z.union([
-      z.literal(100),
-      z.literal(200),
-      z.literal(300),
-      z.literal(400),
-      z.literal(500),
-    ]),
-
-    isPassed: z.boolean(),
-    isEnabledOptions: z.boolean(),
-    type: z.enum(["cat", "auction"]).optional(),
-  });
-
-  public sigameStages = [
-    "guide", // ролик с правилами игры
-    "players-questions-before-game", //вопросы игроков
-    "question-selection", // игрок выбирает вопрос
-    "reading-question", // ведущий зачитывает вопрос
-    "question-timer", // игроки нажимают на кнопку
-    "player-answer", // игрок отвесает на вопрос
-    "answer-discussion", // показ правильного ответа
-
-    "cat-select", // кот в мешке выбор игрока
-    "auction-betting", // аукцион ставки
-    "type-player-answer", // ответ игрока для типового вопроса
-
-    "final-intro", // интро перед финалом
-    "final-category-select", // выбор категории для финала
-    "final-betting", // ставки игроков
-    "final-reading-question", // ведущий читает вопрос
-    "final-game", // игроки отвечают на вопрос
-    "final-answer", // ведущий выставляет правильные ответы
-    "extra-questions", // перестрелка на случай нескольких победителей
-    "outro", // результаты
-  ] as const;
-
-  private ZSigameStages = z.enum(this.sigameStages);
-
-  public ZSigame = GameShema.ZGame.extend({
-    categories: z
-      .array(
-        z.object({
-          category_id: DbShema.ZCategories.shape.category_id,
-          name: DbShema.ZCategories.shape.name,
-
-          questions: z.array(this.ZSigameQuestion),
-
-          finalQuestion: z.object({
-            question_id: DbShema.ZQuestions.shape.question_id,
-
-            q_text: DbShema.ZQuestions.shape.q_text,
-            q_media_filename: DbShema.ZQuestions.shape.q_media_filename,
-            difficulty: DbShema.ZQuestions.shape.difficulty,
-            answers: DbShema.ZQuestions.shape.answers,
-            q_media_type: DbShema.ZQuestions.shape.q_media_type,
-            a_media_filename: DbShema.ZQuestions.shape.q_media_filename,
-            a_media_type: DbShema.ZQuestions.shape.q_media_type,
-          }),
-
-          extraQuestions: z.array(this.ZSigameQuestion).nullable(),
-        }),
-      )
-      .min(1),
-
-    categoryBlocks: z.array(z.array(z.number())).min(1),
-    currentBlockIdx: z.number(),
-
-    gameStage: this.ZSigameStages,
-
-    currentPlayerIdx: z.number().nullable(),
-    playersScore: z.array(z.number()).min(1),
-
-    currentQuestion: z
-      .object({
-        categoryIdx: z.number(),
-        questionIdx: z.number(),
-      })
-      .nullable(),
-    answeringPlayerIdx: z.number().nullable(),
-
-    auctionBets: z.array(
-      z
-        .object({
-          bet: z.number(),
-          isAllIn: z.boolean(),
-        })
-        .nullable(),
-    ),
-
-    finalCategoriesIds: z.array(z.number()).min(1),
-    excludedFinalCategoriesIds: z.array(z.number()),
-
-    finalPlayersIdxs: z.array(
-      z.object({
-        answer: z.string(),
-        isReady: z.boolean(),
-        bet: z.number(),
-        isRight: z.boolean().nullable(),
-      }),
-    ),
-
-    finalCategoryId: z.number().nullable(),
-    winnerIdx: z.number().nullable(),
-
-    extraCategoryId: z.number(),
-    extraPlayersIdxs: z.array(z.number()),
-  });
-})();