/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * type of parameter */ export const FunctionParametersType = { Object: "object", } as const; /** * type of parameter */ export type FunctionParametersType = ClosedEnum; export type Properties = { /** * The type of the property */ type?: string | undefined; /** * A description of the property */ description?: string | undefined; }; /** * The parameters the functions accepts, described as a JSON Schema object. * * @remarks * * To describe a function that accepts no parameters, provide the value `{"type": "object", "properties": {}}`. */ export type FunctionParameters = { /** * type of parameter */ type?: FunctionParametersType | undefined; /** * which one of the parameter is required */ required?: Array | undefined; /** * A map of property names to their types and descriptions. Each property is an object with 'type' and 'description' fields. */ properties?: { [k: string]: Properties } | undefined; }; /** @internal */ export const FunctionParametersType$inboundSchema: z.ZodNativeEnum< typeof FunctionParametersType > = z.nativeEnum(FunctionParametersType); /** @internal */ export const FunctionParametersType$outboundSchema: z.ZodNativeEnum< typeof FunctionParametersType > = FunctionParametersType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FunctionParametersType$ { /** @deprecated use `FunctionParametersType$inboundSchema` instead. */ export const inboundSchema = FunctionParametersType$inboundSchema; /** @deprecated use `FunctionParametersType$outboundSchema` instead. */ export const outboundSchema = FunctionParametersType$outboundSchema; } /** @internal */ export const Properties$inboundSchema: z.ZodType< Properties, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), description: z.string().optional(), }); /** @internal */ export type Properties$Outbound = { type?: string | undefined; description?: string | undefined; }; /** @internal */ export const Properties$outboundSchema: z.ZodType< Properties$Outbound, z.ZodTypeDef, Properties > = z.object({ type: z.string().optional(), description: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Properties$ { /** @deprecated use `Properties$inboundSchema` instead. */ export const inboundSchema = Properties$inboundSchema; /** @deprecated use `Properties$outboundSchema` instead. */ export const outboundSchema = Properties$outboundSchema; /** @deprecated use `Properties$Outbound` instead. */ export type Outbound = Properties$Outbound; } export function propertiesToJSON(properties: Properties): string { return JSON.stringify(Properties$outboundSchema.parse(properties)); } export function propertiesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Properties$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Properties' from JSON`, ); } /** @internal */ export const FunctionParameters$inboundSchema: z.ZodType< FunctionParameters, z.ZodTypeDef, unknown > = z.object({ type: FunctionParametersType$inboundSchema.optional(), required: z.array(z.string()).optional(), properties: z.record(z.lazy(() => Properties$inboundSchema)).optional(), }); /** @internal */ export type FunctionParameters$Outbound = { type?: string | undefined; required?: Array | undefined; properties?: { [k: string]: Properties$Outbound } | undefined; }; /** @internal */ export const FunctionParameters$outboundSchema: z.ZodType< FunctionParameters$Outbound, z.ZodTypeDef, FunctionParameters > = z.object({ type: FunctionParametersType$outboundSchema.optional(), required: z.array(z.string()).optional(), properties: z.record(z.lazy(() => Properties$outboundSchema)).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FunctionParameters$ { /** @deprecated use `FunctionParameters$inboundSchema` instead. */ export const inboundSchema = FunctionParameters$inboundSchema; /** @deprecated use `FunctionParameters$outboundSchema` instead. */ export const outboundSchema = FunctionParameters$outboundSchema; /** @deprecated use `FunctionParameters$Outbound` instead. */ export type Outbound = FunctionParameters$Outbound; } export function functionParametersToJSON( functionParameters: FunctionParameters, ): string { return JSON.stringify( FunctionParameters$outboundSchema.parse(functionParameters), ); } export function functionParametersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FunctionParameters$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FunctionParameters' from JSON`, ); }