/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Attributes = string | boolean | number; export type FileSearchResult = { attributes?: { [k: string]: string | boolean | number } | undefined; fileId?: string | undefined; filename?: string | undefined; score?: number | undefined; text?: string | undefined; }; /** @internal */ export const Attributes$inboundSchema: z.ZodType< Attributes, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type Attributes$Outbound = string | boolean | number; /** @internal */ export const Attributes$outboundSchema: z.ZodType< Attributes$Outbound, z.ZodTypeDef, Attributes > = z.union([z.string(), z.boolean(), z.number()]); export function attributesToJSON(attributes: Attributes): string { return JSON.stringify(Attributes$outboundSchema.parse(attributes)); } export function attributesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Attributes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Attributes' from JSON`, ); } /** @internal */ export const FileSearchResult$inboundSchema: z.ZodType< FileSearchResult, z.ZodTypeDef, unknown > = z.object({ attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), file_id: z.string().optional(), filename: z.string().optional(), score: z.number().optional(), text: z.string().optional(), }).transform((v) => { return remap$(v, { "file_id": "fileId", }); }); /** @internal */ export type FileSearchResult$Outbound = { attributes?: { [k: string]: string | boolean | number } | undefined; file_id?: string | undefined; filename?: string | undefined; score?: number | undefined; text?: string | undefined; }; /** @internal */ export const FileSearchResult$outboundSchema: z.ZodType< FileSearchResult$Outbound, z.ZodTypeDef, FileSearchResult > = z.object({ attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), fileId: z.string().optional(), filename: z.string().optional(), score: z.number().optional(), text: z.string().optional(), }).transform((v) => { return remap$(v, { fileId: "file_id", }); }); export function fileSearchResultToJSON( fileSearchResult: FileSearchResult, ): string { return JSON.stringify( FileSearchResult$outboundSchema.parse(fileSearchResult), ); } export function fileSearchResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileSearchResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileSearchResult' from JSON`, ); }