/* * 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 TextToSpeechStreamingRequest = { /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; textToSpeechStreamingRequest: components.TextToSpeechStreamingRequest; }; export type TextToSpeechStreamingResponseResult = | ReadableStream | ReadableStream; export type TextToSpeechStreamingResponse = { headers: { [k: string]: Array }; result: ReadableStream | ReadableStream; }; /** @internal */ export const TextToSpeechStreamingRequest$inboundSchema: z.ZodType< TextToSpeechStreamingRequest, z.ZodTypeDef, unknown > = z.object({ "X-On-Behalf-Of": z.string().optional(), TextToSpeechStreamingRequest: components.TextToSpeechStreamingRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "TextToSpeechStreamingRequest": "textToSpeechStreamingRequest", }); }); /** @internal */ export type TextToSpeechStreamingRequest$Outbound = { "X-On-Behalf-Of"?: string | undefined; TextToSpeechStreamingRequest: components.TextToSpeechStreamingRequest$Outbound; }; /** @internal */ export const TextToSpeechStreamingRequest$outboundSchema: z.ZodType< TextToSpeechStreamingRequest$Outbound, z.ZodTypeDef, TextToSpeechStreamingRequest > = z.object({ xOnBehalfOf: z.string().optional(), textToSpeechStreamingRequest: components.TextToSpeechStreamingRequest$outboundSchema, }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", textToSpeechStreamingRequest: "TextToSpeechStreamingRequest", }); }); export function textToSpeechStreamingRequestToJSON( textToSpeechStreamingRequest: TextToSpeechStreamingRequest, ): string { return JSON.stringify( TextToSpeechStreamingRequest$outboundSchema.parse( textToSpeechStreamingRequest, ), ); } export function textToSpeechStreamingRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechStreamingRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechStreamingRequest' from JSON`, ); } /** @internal */ export const TextToSpeechStreamingResponseResult$inboundSchema: z.ZodType< TextToSpeechStreamingResponseResult, z.ZodTypeDef, unknown > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** @internal */ export type TextToSpeechStreamingResponseResult$Outbound = | ReadableStream | ReadableStream; /** @internal */ export const TextToSpeechStreamingResponseResult$outboundSchema: z.ZodType< TextToSpeechStreamingResponseResult$Outbound, z.ZodTypeDef, TextToSpeechStreamingResponseResult > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); export function textToSpeechStreamingResponseResultToJSON( textToSpeechStreamingResponseResult: TextToSpeechStreamingResponseResult, ): string { return JSON.stringify( TextToSpeechStreamingResponseResult$outboundSchema.parse( textToSpeechStreamingResponseResult, ), ); } export function textToSpeechStreamingResponseResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechStreamingResponseResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechStreamingResponseResult' from JSON`, ); } /** @internal */ export const TextToSpeechStreamingResponse$inboundSchema: z.ZodType< TextToSpeechStreamingResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())).default({}), Result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); /** @internal */ export type TextToSpeechStreamingResponse$Outbound = { Headers: { [k: string]: Array }; Result: ReadableStream | ReadableStream; }; /** @internal */ export const TextToSpeechStreamingResponse$outboundSchema: z.ZodType< TextToSpeechStreamingResponse$Outbound, z.ZodTypeDef, TextToSpeechStreamingResponse > = z.object({ headers: z.record(z.array(z.string())), result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { headers: "Headers", result: "Result", }); }); export function textToSpeechStreamingResponseToJSON( textToSpeechStreamingResponse: TextToSpeechStreamingResponse, ): string { return JSON.stringify( TextToSpeechStreamingResponse$outboundSchema.parse( textToSpeechStreamingResponse, ), ); } export function textToSpeechStreamingResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechStreamingResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechStreamingResponse' from JSON`, ); }