/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CustomFieldValue25 = string | number | boolean | { [k: string]: any; }; export type CustomFieldValue = | string | number | boolean | { [k: string]: any } | Array; export type CustomField2 = { /** * Unique identifier for the custom field. */ id?: string | null | undefined; /** * Name of the custom field. */ name: string | null; /** * Display name of the record a reference-type custom field points at. `value` carries that record's id; this carries its human-readable name, so a consumer does not need a second lookup to render it. */ refName?: string | null | undefined; /** * More information about the custom field */ description?: string | null | undefined; value?: | string | number | boolean | { [k: string]: any } | Array | null | undefined; }; export type CustomFieldValue5 = string | number | boolean | { [k: string]: any; }; export type CustomField1Value = | string | number | boolean | { [k: string]: any } | Array; export type CustomField1 = { /** * Unique identifier for the custom field. */ id: string | null; /** * Name of the custom field. */ name?: string | null | undefined; /** * Display name of the record a reference-type custom field points at. `value` carries that record's id; this carries its human-readable name, so a consumer does not need a second lookup to render it. */ refName?: string | null | undefined; /** * More information about the custom field */ description?: string | null | undefined; value?: | string | number | boolean | { [k: string]: any } | Array | null | undefined; }; export type CustomField = CustomField1 | CustomField2; /** @internal */ export const CustomFieldValue25$inboundSchema: z.ZodType< CustomFieldValue25, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]) ); /** @internal */ export type CustomFieldValue25$Outbound = string | number | boolean | { [k: string]: any; }; /** @internal */ export const CustomFieldValue25$outboundSchema: z.ZodType< CustomFieldValue25$Outbound, z.ZodTypeDef, CustomFieldValue25 > = /* @__PURE__ */ lazySchema$(() => smartUnion([z.string(), z.number(), z.boolean(), z.record(z.any())]) ); export function customFieldValue25ToJSON( customFieldValue25: CustomFieldValue25, ): string { return JSON.stringify( CustomFieldValue25$outboundSchema.parse(customFieldValue25), ); } export function customFieldValue25FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomFieldValue25$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomFieldValue25' from JSON`, ); } /** @internal */ export const CustomFieldValue$inboundSchema: z.ZodType< CustomFieldValue, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), z.array( types.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]), ), ), ]) ); /** @internal */ export type CustomFieldValue$Outbound = string | number | boolean | { [k: string]: any; } | Array; /** @internal */ export const CustomFieldValue$outboundSchema: z.ZodType< CustomFieldValue$Outbound, z.ZodTypeDef, CustomFieldValue > = /* @__PURE__ */ lazySchema$(() => smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array( z.nullable( smartUnion([z.string(), z.number(), z.boolean(), z.record(z.any())]), ), ), ]) ); export function customFieldValueToJSON( customFieldValue: CustomFieldValue, ): string { return JSON.stringify( CustomFieldValue$outboundSchema.parse(customFieldValue), ); } export function customFieldValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomFieldValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomFieldValue' from JSON`, ); } /** @internal */ export const CustomField2$inboundSchema: z.ZodType< CustomField2, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: types.nullable(types.string()), ref_name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), value: z.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), z.array( types.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]), ), ), ]), ).optional(), }).transform((v) => { return remap$(v, { "ref_name": "refName", }); }) ); /** @internal */ export type CustomField2$Outbound = { id?: string | null | undefined; name: string | null; ref_name?: string | null | undefined; description?: string | null | undefined; value?: | string | number | boolean | { [k: string]: any } | Array | null | undefined; }; /** @internal */ export const CustomField2$outboundSchema: z.ZodType< CustomField2$Outbound, z.ZodTypeDef, CustomField2 > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()).optional(), name: z.nullable(z.string()), refName: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), value: z.nullable( smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array( z.nullable( smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), ]), ), ), ]), ).optional(), }).transform((v) => { return remap$(v, { refName: "ref_name", }); }) ); export function customField2ToJSON(customField2: CustomField2): string { return JSON.stringify(CustomField2$outboundSchema.parse(customField2)); } export function customField2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomField2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomField2' from JSON`, ); } /** @internal */ export const CustomFieldValue5$inboundSchema: z.ZodType< CustomFieldValue5, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]) ); /** @internal */ export type CustomFieldValue5$Outbound = string | number | boolean | { [k: string]: any; }; /** @internal */ export const CustomFieldValue5$outboundSchema: z.ZodType< CustomFieldValue5$Outbound, z.ZodTypeDef, CustomFieldValue5 > = /* @__PURE__ */ lazySchema$(() => smartUnion([z.string(), z.number(), z.boolean(), z.record(z.any())]) ); export function customFieldValue5ToJSON( customFieldValue5: CustomFieldValue5, ): string { return JSON.stringify( CustomFieldValue5$outboundSchema.parse(customFieldValue5), ); } export function customFieldValue5FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomFieldValue5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomFieldValue5' from JSON`, ); } /** @internal */ export const CustomField1Value$inboundSchema: z.ZodType< CustomField1Value, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), z.array( types.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]), ), ), ]) ); /** @internal */ export type CustomField1Value$Outbound = string | number | boolean | { [k: string]: any; } | Array; /** @internal */ export const CustomField1Value$outboundSchema: z.ZodType< CustomField1Value$Outbound, z.ZodTypeDef, CustomField1Value > = /* @__PURE__ */ lazySchema$(() => smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array( z.nullable( smartUnion([z.string(), z.number(), z.boolean(), z.record(z.any())]), ), ), ]) ); export function customField1ValueToJSON( customField1Value: CustomField1Value, ): string { return JSON.stringify( CustomField1Value$outboundSchema.parse(customField1Value), ); } export function customField1ValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomField1Value$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomField1Value' from JSON`, ); } /** @internal */ export const CustomField1$inboundSchema: z.ZodType< CustomField1, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.nullable(types.string()), name: z.nullable(types.string()).optional(), ref_name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), value: z.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), z.array( types.nullable( smartUnion([ types.string(), types.number(), types.boolean(), z.record(z.any()), ]), ), ), ]), ).optional(), }).transform((v) => { return remap$(v, { "ref_name": "refName", }); }) ); /** @internal */ export type CustomField1$Outbound = { id: string | null; name?: string | null | undefined; ref_name?: string | null | undefined; description?: string | null | undefined; value?: | string | number | boolean | { [k: string]: any } | Array | null | undefined; }; /** @internal */ export const CustomField1$outboundSchema: z.ZodType< CustomField1$Outbound, z.ZodTypeDef, CustomField1 > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()), name: z.nullable(z.string()).optional(), refName: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), value: z.nullable( smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array( z.nullable( smartUnion([ z.string(), z.number(), z.boolean(), z.record(z.any()), ]), ), ), ]), ).optional(), }).transform((v) => { return remap$(v, { refName: "ref_name", }); }) ); export function customField1ToJSON(customField1: CustomField1): string { return JSON.stringify(CustomField1$outboundSchema.parse(customField1)); } export function customField1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomField1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomField1' from JSON`, ); } /** @internal */ export const CustomField$inboundSchema: z.ZodType< CustomField, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => smartUnion([ z.lazy(() => CustomField1$inboundSchema), z.lazy(() => CustomField2$inboundSchema), ]) ); /** @internal */ export type CustomField$Outbound = | CustomField1$Outbound | CustomField2$Outbound; /** @internal */ export const CustomField$outboundSchema: z.ZodType< CustomField$Outbound, z.ZodTypeDef, CustomField > = /* @__PURE__ */ lazySchema$(() => smartUnion([ z.lazy(() => CustomField1$outboundSchema), z.lazy(() => CustomField2$outboundSchema), ]) ); export function customFieldToJSON(customField: CustomField): string { return JSON.stringify(CustomField$outboundSchema.parse(customField)); } export function customFieldFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomField$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomField' from JSON`, ); }