/* * 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 { RoomAllocation, RoomAllocation$inboundSchema, } from "./roomallocation.js"; import { RoomStatus, RoomStatus$inboundSchema } from "./roomstatus.js"; /** * Metadata on an allocated instance of a room. */ export type CurrentAllocation = { unscheduledAt: Date | null; scheduledAt: Date; /** * System generated unique identifier to a runtime instance of your game server. */ processId: string; /** * System generated unique identifier to an allocated instance of a room. */ roomAllocationId: string; }; /** * A room object represents a game session or match. */ export type Room = { currentAllocation: CurrentAllocation | null; /** * The allocation status of a room. * * @remarks * * `scheduling`: a process is not allocated yet and the room is waiting to be scheduled * * `active`: ready to accept connections * * `destroyed`: all associated metadata is deleted */ status: RoomStatus; allocations: Array; roomConfig?: string | null | undefined; /** * 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 CurrentAllocation$inboundSchema: z.ZodType< CurrentAllocation, z.ZodTypeDef, unknown > = z.object({ unscheduledAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), scheduledAt: z.string().datetime({ offset: true }).transform(v => new Date(v) ), processId: z.string(), roomAllocationId: z.string(), }); export function currentAllocationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CurrentAllocation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CurrentAllocation' from JSON`, ); } /** @internal */ export const Room$inboundSchema: z.ZodType = z .object({ currentAllocation: z.nullable( z.lazy(() => CurrentAllocation$inboundSchema), ), status: RoomStatus$inboundSchema, allocations: z.array(RoomAllocation$inboundSchema), roomConfig: z.nullable(z.string()).optional(), roomId: z.string(), appId: z.string(), }); export function roomFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Room$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Room' from JSON`, ); }