/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ 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 { SearchActionSource, SearchActionSource$inboundSchema, SearchActionSource$Outbound, SearchActionSource$outboundSchema, } from "./searchactionsource.js"; export type SearchAction = { type: "search"; query: string; sources?: Array | undefined; }; /** @internal */ export const SearchAction$inboundSchema: z.ZodType< SearchAction, z.ZodTypeDef, unknown > = z.object({ type: z.literal("search"), query: z.string(), sources: z.array(SearchActionSource$inboundSchema).optional(), }); /** @internal */ export type SearchAction$Outbound = { type: "search"; query: string; sources?: Array | undefined; }; /** @internal */ export const SearchAction$outboundSchema: z.ZodType< SearchAction$Outbound, z.ZodTypeDef, SearchAction > = z.object({ type: z.literal("search"), query: z.string(), sources: z.array(SearchActionSource$outboundSchema).optional(), }); export function searchActionToJSON(searchAction: SearchAction): string { return JSON.stringify(SearchAction$outboundSchema.parse(searchAction)); } export function searchActionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SearchAction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchAction' from JSON`, ); }