/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TextToSpeechRequest = { /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; textToSpeechRequest: components.TextToSpeechRequest; }; export type TextToSpeechResponse = { headers: { [k: string]: Array }; result: ReadableStream; }; /** @internal */ export const TextToSpeechRequest$inboundSchema: z.ZodType< TextToSpeechRequest, z.ZodTypeDef, unknown > = z.object({ "X-On-Behalf-Of": z.string().optional(), TextToSpeechRequest: components.TextToSpeechRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "TextToSpeechRequest": "textToSpeechRequest", }); }); /** @internal */ export type TextToSpeechRequest$Outbound = { "X-On-Behalf-Of"?: string | undefined; TextToSpeechRequest: components.TextToSpeechRequest$Outbound; }; /** @internal */ export const TextToSpeechRequest$outboundSchema: z.ZodType< TextToSpeechRequest$Outbound, z.ZodTypeDef, TextToSpeechRequest > = z.object({ xOnBehalfOf: z.string().optional(), textToSpeechRequest: components.TextToSpeechRequest$outboundSchema, }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", textToSpeechRequest: "TextToSpeechRequest", }); }); export function textToSpeechRequestToJSON( textToSpeechRequest: TextToSpeechRequest, ): string { return JSON.stringify( TextToSpeechRequest$outboundSchema.parse(textToSpeechRequest), ); } export function textToSpeechRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechRequest' from JSON`, ); } /** @internal */ export const TextToSpeechResponse$inboundSchema: z.ZodType< TextToSpeechResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())).default({}), Result: z.instanceof(ReadableStream), }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); /** @internal */ export type TextToSpeechResponse$Outbound = { Headers: { [k: string]: Array }; Result: ReadableStream; }; /** @internal */ export const TextToSpeechResponse$outboundSchema: z.ZodType< TextToSpeechResponse$Outbound, z.ZodTypeDef, TextToSpeechResponse > = z.object({ headers: z.record(z.array(z.string())), result: z.instanceof(ReadableStream), }).transform((v) => { return remap$(v, { headers: "Headers", result: "Result", }); }); export function textToSpeechResponseToJSON( textToSpeechResponse: TextToSpeechResponse, ): string { return JSON.stringify( TextToSpeechResponse$outboundSchema.parse(textToSpeechResponse), ); } export function textToSpeechResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechResponse' from JSON`, ); }