/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 0ad125d7ba0c */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatFileMetadata, ChatFileMetadata$inboundSchema, ChatFileMetadata$Outbound, ChatFileMetadata$outboundSchema, } from "./chatfilemetadata.js"; /** * Structure for file uploaded by a user for Chat. */ export type ChatFile = { /** * Unique identifier of the file. */ id?: string | undefined; /** * Url of the file. */ url?: string | undefined; /** * Name of the uploaded file. */ name?: string | undefined; /** * Metadata of a file uploaded by a user for Chat. */ metadata?: ChatFileMetadata | undefined; }; /** @internal */ export const ChatFile$inboundSchema: z.ZodType< ChatFile, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), url: z.string().optional(), name: z.string().optional(), metadata: ChatFileMetadata$inboundSchema.optional(), }); /** @internal */ export type ChatFile$Outbound = { id?: string | undefined; url?: string | undefined; name?: string | undefined; metadata?: ChatFileMetadata$Outbound | undefined; }; /** @internal */ export const ChatFile$outboundSchema: z.ZodType< ChatFile$Outbound, z.ZodTypeDef, ChatFile > = z.object({ id: z.string().optional(), url: z.string().optional(), name: z.string().optional(), metadata: ChatFileMetadata$outboundSchema.optional(), }); export function chatFileToJSON(chatFile: ChatFile): string { return JSON.stringify(ChatFile$outboundSchema.parse(chatFile)); } export function chatFileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatFile' from JSON`, ); }