/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; import { PrivacyLevel, PrivacyLevel$inboundSchema, PrivacyLevel$outboundSchema, } from "./privacylevel.js"; import { SelectOption, SelectOption$inboundSchema, SelectOption$Outbound, SelectOption$outboundSchema, } from "./selectoption.js"; export type Field = { order?: number | undefined; name?: string | null | undefined; label?: string | null | undefined; unit?: string | null | undefined; helpText?: string | null | undefined; helpTextWarning?: string | null | undefined; helpLink?: string | null | undefined; value?: any | null | undefined; type?: string | null | undefined; advanced?: boolean | undefined; selectOptions?: Array | null | undefined; selectOptionsProviderAction?: string | null | undefined; section?: string | null | undefined; hidden?: string | null | undefined; privacy?: PrivacyLevel | undefined; placeholder?: string | null | undefined; isFloat?: boolean | undefined; }; /** @internal */ export const Field$inboundSchema: z.ZodType = z .object({ order: z.number().int().optional(), name: z.nullable(z.string()).optional(), label: z.nullable(z.string()).optional(), unit: z.nullable(z.string()).optional(), helpText: z.nullable(z.string()).optional(), helpTextWarning: z.nullable(z.string()).optional(), helpLink: z.nullable(z.string()).optional(), value: z.nullable(z.any()).optional(), type: z.nullable(z.string()).optional(), advanced: z.boolean().optional(), selectOptions: z.nullable(z.array(SelectOption$inboundSchema)).optional(), selectOptionsProviderAction: z.nullable(z.string()).optional(), section: z.nullable(z.string()).optional(), hidden: z.nullable(z.string()).optional(), privacy: PrivacyLevel$inboundSchema.optional(), placeholder: z.nullable(z.string()).optional(), isFloat: z.boolean().optional(), }); /** @internal */ export type Field$Outbound = { order?: number | undefined; name?: string | null | undefined; label?: string | null | undefined; unit?: string | null | undefined; helpText?: string | null | undefined; helpTextWarning?: string | null | undefined; helpLink?: string | null | undefined; value?: any | null | undefined; type?: string | null | undefined; advanced?: boolean | undefined; selectOptions?: Array | null | undefined; selectOptionsProviderAction?: string | null | undefined; section?: string | null | undefined; hidden?: string | null | undefined; privacy?: string | undefined; placeholder?: string | null | undefined; isFloat?: boolean | undefined; }; /** @internal */ export const Field$outboundSchema: z.ZodType< Field$Outbound, z.ZodTypeDef, Field > = z.object({ order: z.number().int().optional(), name: z.nullable(z.string()).optional(), label: z.nullable(z.string()).optional(), unit: z.nullable(z.string()).optional(), helpText: z.nullable(z.string()).optional(), helpTextWarning: z.nullable(z.string()).optional(), helpLink: z.nullable(z.string()).optional(), value: z.nullable(z.any()).optional(), type: z.nullable(z.string()).optional(), advanced: z.boolean().optional(), selectOptions: z.nullable(z.array(SelectOption$outboundSchema)).optional(), selectOptionsProviderAction: z.nullable(z.string()).optional(), section: z.nullable(z.string()).optional(), hidden: z.nullable(z.string()).optional(), privacy: PrivacyLevel$outboundSchema.optional(), placeholder: z.nullable(z.string()).optional(), isFloat: z.boolean().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Field$ { /** @deprecated use `Field$inboundSchema` instead. */ export const inboundSchema = Field$inboundSchema; /** @deprecated use `Field$outboundSchema` instead. */ export const outboundSchema = Field$outboundSchema; /** @deprecated use `Field$Outbound` instead. */ export type Outbound = Field$Outbound; } export function fieldToJSON(field: Field): string { return JSON.stringify(Field$outboundSchema.parse(field)); } export function fieldFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Field$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Field' from JSON`, ); }