1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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();
|