/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type WakeResponseRequestBody = { input: string; }; export type WakeResponseRequest = { responseId: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; requestBody: WakeResponseRequestBody; }; export const ObjectT = { ResponseSleepWake: "response.sleep_wake", } as const; export type ObjectT = ClosedEnum; /** * The sleeping response was signalled to wake. */ export type WakeResponseResponseBody = { object: ObjectT; responseId: string; createdAt: Date; }; /** @internal */ export const WakeResponseRequestBody$inboundSchema: z.ZodType< WakeResponseRequestBody, z.ZodTypeDef, unknown > = z.object({ input: z.string(), }); /** @internal */ export type WakeResponseRequestBody$Outbound = { input: string; }; /** @internal */ export const WakeResponseRequestBody$outboundSchema: z.ZodType< WakeResponseRequestBody$Outbound, z.ZodTypeDef, WakeResponseRequestBody > = z.object({ input: z.string(), }); export function wakeResponseRequestBodyToJSON( wakeResponseRequestBody: WakeResponseRequestBody, ): string { return JSON.stringify( WakeResponseRequestBody$outboundSchema.parse(wakeResponseRequestBody), ); } export function wakeResponseRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WakeResponseRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WakeResponseRequestBody' from JSON`, ); } /** @internal */ export const WakeResponseRequest$inboundSchema: z.ZodType< WakeResponseRequest, z.ZodTypeDef, unknown > = z.object({ response_id: z.string(), "X-On-Behalf-Of": z.string().optional(), RequestBody: z.lazy(() => WakeResponseRequestBody$inboundSchema), }).transform((v) => { return remap$(v, { "response_id": "responseId", "X-On-Behalf-Of": "xOnBehalfOf", "RequestBody": "requestBody", }); }); /** @internal */ export type WakeResponseRequest$Outbound = { response_id: string; "X-On-Behalf-Of"?: string | undefined; RequestBody: WakeResponseRequestBody$Outbound; }; /** @internal */ export const WakeResponseRequest$outboundSchema: z.ZodType< WakeResponseRequest$Outbound, z.ZodTypeDef, WakeResponseRequest > = z.object({ responseId: z.string(), xOnBehalfOf: z.string().optional(), requestBody: z.lazy(() => WakeResponseRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { responseId: "response_id", xOnBehalfOf: "X-On-Behalf-Of", requestBody: "RequestBody", }); }); export function wakeResponseRequestToJSON( wakeResponseRequest: WakeResponseRequest, ): string { return JSON.stringify( WakeResponseRequest$outboundSchema.parse(wakeResponseRequest), ); } export function wakeResponseRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WakeResponseRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WakeResponseRequest' from JSON`, ); } /** @internal */ export const ObjectT$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ObjectT); /** @internal */ export const ObjectT$outboundSchema: z.ZodNativeEnum = ObjectT$inboundSchema; /** @internal */ export const WakeResponseResponseBody$inboundSchema: z.ZodType< WakeResponseResponseBody, z.ZodTypeDef, unknown > = z.object({ object: ObjectT$inboundSchema, response_id: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "response_id": "responseId", "created_at": "createdAt", }); }); /** @internal */ export type WakeResponseResponseBody$Outbound = { object: string; response_id: string; created_at: string; }; /** @internal */ export const WakeResponseResponseBody$outboundSchema: z.ZodType< WakeResponseResponseBody$Outbound, z.ZodTypeDef, WakeResponseResponseBody > = z.object({ object: ObjectT$outboundSchema, responseId: z.string(), createdAt: z.date().transform(v => v.toISOString()), }).transform((v) => { return remap$(v, { responseId: "response_id", createdAt: "created_at", }); }); export function wakeResponseResponseBodyToJSON( wakeResponseResponseBody: WakeResponseResponseBody, ): string { return JSON.stringify( WakeResponseResponseBody$outboundSchema.parse(wakeResponseResponseBody), ); } export function wakeResponseResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WakeResponseResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WakeResponseResponseBody' from JSON`, ); }