/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { LobbyVisibility, LobbyVisibility$inboundSchema, } from "./lobbyvisibility.js"; import { Region, Region$inboundSchema } from "./region.js"; /** * UserId or email address for the user that created the lobby. */ export type CreatedBy = string | number; /** * A lobby object allows you to store and manage metadata for your rooms. */ export type Lobby = { shortCode: string | null; /** * JSON blob to store metadata for a room. Must be smaller than 1MB. */ state?: any | null | undefined; /** * User input to initialize the game state. Object must be smaller than 64KB. */ initialConfig?: any | undefined; /** * When the lobby was created. */ createdAt: Date; /** * UserId or email address for the user that created the lobby. */ createdBy: string | number; /** * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ local: boolean; /** * Types of lobbies a player can create. * * @remarks * * `private`: the player who created the room must share the roomId with their friends * * `public`: visible in the public lobby list, anyone can join * * `local`: for testing with a server running locally */ visibility: LobbyVisibility; region: Region; /** * Unique identifier to a game session or match. Use the default system generated ID or overwrite it with your own. * * @remarks * Note: error will be returned if `roomId` is not globally unique. */ roomId: string; /** * System generated unique identifier for an application. */ appId: string; }; /** @internal */ export const CreatedBy$inboundSchema: z.ZodType< CreatedBy, z.ZodTypeDef, unknown > = z.union([z.string(), z.number()]); export function createdByFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatedBy' from JSON`, ); } /** @internal */ export const Lobby$inboundSchema: z.ZodType = z .object({ shortCode: z.nullable(z.string()), state: z.nullable(z.any()).optional(), initialConfig: z.any().optional(), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v) ), createdBy: z.union([z.string(), z.number()]), local: z.boolean(), visibility: LobbyVisibility$inboundSchema, region: Region$inboundSchema, roomId: z.string(), appId: z.string(), }); export function lobbyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Lobby$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Lobby' from JSON`, ); }