/* * 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 { ExposedPort, ExposedPort$inboundSchema } from "./exposedport.js"; import { ProcessStatus, ProcessStatus$inboundSchema } from "./processstatus.js"; import { Region, Region$inboundSchema } from "./region.js"; import { TransportType, TransportType$inboundSchema } from "./transporttype.js"; /** * Connection details for an active process. */ export type ProcessV2ExposedPort = { /** * Transport type specifies the underlying communication protocol to the exposed port. */ transportType: TransportType; port: number; host: string; name: string; }; export type ProcessV2 = { status: ProcessStatus; /** * Tracks the number of rooms that have been allocated to the process. */ roomsAllocated: number; /** * When the process has been terminated. */ terminatedAt: Date | null; /** * When the process is issued to stop. We use this to determine when we should stop billing. */ stoppingAt: Date | null; /** * When the process bound to the specified port. We use this to determine when we should start billing. */ startedAt: Date | null; /** * When the process started being provisioned. */ createdAt: Date; /** * Governs how many [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) can be scheduled in a process. */ roomsPerProcess: number; additionalExposedPorts: Array; exposedPort: ProcessV2ExposedPort | null; region: Region; /** * System generated unique identifier to a runtime instance of your game server. */ processId: string; /** * System generated id for a deployment. Increments by 1. */ deploymentId: number; /** * System generated unique identifier for an application. */ appId: string; }; /** @internal */ export const ProcessV2ExposedPort$inboundSchema: z.ZodType< ProcessV2ExposedPort, z.ZodTypeDef, unknown > = z.object({ transportType: TransportType$inboundSchema, port: z.number().int(), host: z.string(), name: z.string(), }); export function processV2ExposedPortFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProcessV2ExposedPort$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProcessV2ExposedPort' from JSON`, ); } /** @internal */ export const ProcessV2$inboundSchema: z.ZodType< ProcessV2, z.ZodTypeDef, unknown > = z.object({ status: ProcessStatus$inboundSchema, roomsAllocated: z.number().int(), terminatedAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), stoppingAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), startedAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)), roomsPerProcess: z.number().int(), additionalExposedPorts: z.array(ExposedPort$inboundSchema), exposedPort: z.nullable(z.lazy(() => ProcessV2ExposedPort$inboundSchema)), region: Region$inboundSchema, processId: z.string(), deploymentId: z.number().int(), appId: z.string(), }); export function processV2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProcessV2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProcessV2' from JSON`, ); }