/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type HTTPMetadata = { /** * Raw HTTP response; suitable for custom response parsing */ response: Response; /** * Raw HTTP request; suitable for debugging */ request: Request; }; /** @internal */ export const HTTPMetadata$inboundSchema: z.ZodType< HTTPMetadata, z.ZodTypeDef, unknown > = z.object({ Response: z.instanceof(Response), Request: z.instanceof(Request), }).transform((v) => { return remap$(v, { "Response": "response", "Request": "request", }); }); /** @internal */ export type HTTPMetadata$Outbound = { Response: never; Request: never; }; /** @internal */ export const HTTPMetadata$outboundSchema: z.ZodType< HTTPMetadata$Outbound, z.ZodTypeDef, HTTPMetadata > = z.object({ response: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), request: z.instanceof(Request).transform(() => { throw new Error("Response cannot be serialized"); }), }).transform((v) => { return remap$(v, { response: "Response", request: "Request", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace HTTPMetadata$ { /** @deprecated use `HTTPMetadata$inboundSchema` instead. */ export const inboundSchema = HTTPMetadata$inboundSchema; /** @deprecated use `HTTPMetadata$outboundSchema` instead. */ export const outboundSchema = HTTPMetadata$outboundSchema; /** @deprecated use `HTTPMetadata$Outbound` instead. */ export type Outbound = HTTPMetadata$Outbound; } export function httpMetadataToJSON(httpMetadata: HTTPMetadata): string { return JSON.stringify(HTTPMetadata$outboundSchema.parse(httpMetadata)); } export function httpMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => HTTPMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'HTTPMetadata' from JSON`, ); }