/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 CreateStreamResponse = { /** * HTTP response content type for this operation */ contentType: string; /** * HTTP response status code for this operation */ statusCode: number; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse: Response; /** * Success */ stream?: components.Stream | undefined; /** * Error */ error?: components.ErrorT | undefined; }; /** @internal */ export const CreateStreamResponse$inboundSchema: z.ZodType< CreateStreamResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), stream: components.Stream$inboundSchema.optional(), error: components.ErrorT$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", }); }); /** @internal */ export type CreateStreamResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; stream?: components.Stream$Outbound | undefined; error?: components.ErrorT$Outbound | undefined; }; /** @internal */ export const CreateStreamResponse$outboundSchema: z.ZodType< CreateStreamResponse$Outbound, z.ZodTypeDef, CreateStreamResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), stream: components.Stream$outboundSchema.optional(), error: components.ErrorT$outboundSchema.optional(), }).transform((v) => { return remap$(v, { contentType: "ContentType", statusCode: "StatusCode", rawResponse: "RawResponse", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateStreamResponse$ { /** @deprecated use `CreateStreamResponse$inboundSchema` instead. */ export const inboundSchema = CreateStreamResponse$inboundSchema; /** @deprecated use `CreateStreamResponse$outboundSchema` instead. */ export const outboundSchema = CreateStreamResponse$outboundSchema; /** @deprecated use `CreateStreamResponse$Outbound` instead. */ export type Outbound = CreateStreamResponse$Outbound; } export function createStreamResponseToJSON( createStreamResponse: CreateStreamResponse, ): string { return JSON.stringify( CreateStreamResponse$outboundSchema.parse(createStreamResponse), ); } export function createStreamResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateStreamResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateStreamResponse' from JSON`, ); }