/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. */ export type Any = { /** * The type of the serialized message. */ atType?: string | undefined; additionalProperties?: { [k: string]: any }; }; /** @internal */ export const Any$inboundSchema: z.ZodType = collectExtraKeys$( z.object({ "@type": z.string().optional(), }).catchall(z.any()), "additionalProperties", true, ).transform((v) => { return remap$(v, { "@type": "atType", }); }); /** @internal */ export type Any$Outbound = { "@type"?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const Any$outboundSchema: z.ZodType = z .object({ atType: z.string().optional(), additionalProperties: z.record(z.any()), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { atType: "@type", additionalProperties: null, }), }; }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Any$ { /** @deprecated use `Any$inboundSchema` instead. */ export const inboundSchema = Any$inboundSchema; /** @deprecated use `Any$outboundSchema` instead. */ export const outboundSchema = Any$outboundSchema; /** @deprecated use `Any$Outbound` instead. */ export type Outbound = Any$Outbound; } export function anyToJSON(any: Any): string { return JSON.stringify(Any$outboundSchema.parse(any)); } export function anyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Any$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Any' from JSON`, ); }