/* * 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"; import { MetadataWithMultipleEntities, MetadataWithMultipleEntities$inboundSchema, } from "./metadatawithmultipleentities.js"; import { MetadataWithOneEntity, MetadataWithOneEntity$inboundSchema, } from "./metadatawithoneentity.js"; /** * Contains relevant data to identify the resource in question when applicable. For example, to identify an entity `entity_type` and `entity_uuid` will be provided. */ export type Metadata = MetadataWithMultipleEntities | MetadataWithOneEntity; export type EntityErrorObject = { /** * Specifies where the error occurs. Typically this key identifies the attribute/parameter related to the error. */ errorKey: string; /** * Specifies the type of error. The category provides error groupings and can be used to build custom error handling in your integration. If category is `nested_errors`, the object will contain a nested `errors` property with entity errors. */ category: string; /** * Provides details about the error - generally this message can be surfaced to an end user. */ message?: string | undefined; /** * Contains relevant data to identify the resource in question when applicable. For example, to identify an entity `entity_type` and `entity_uuid` will be provided. */ metadata?: MetadataWithMultipleEntities | MetadataWithOneEntity | undefined; /** * Will only exist if category is `nested_errors`. It is possible to have multiple levels of nested errors. */ errors?: Array | undefined; }; /** @internal */ export const Metadata$inboundSchema: z.ZodType< Metadata, z.ZodTypeDef, unknown > = z.union([ MetadataWithMultipleEntities$inboundSchema, MetadataWithOneEntity$inboundSchema, ]); export function metadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Metadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Metadata' from JSON`, ); } /** @internal */ export const EntityErrorObject$inboundSchema: z.ZodType< EntityErrorObject, z.ZodTypeDef, unknown > = z.object({ error_key: z.string(), category: z.string(), message: z.string().optional(), metadata: z.union([ MetadataWithMultipleEntities$inboundSchema, MetadataWithOneEntity$inboundSchema, ]).optional(), errors: z.array(z.lazy(() => EntityErrorObject$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "error_key": "errorKey", }); }); export function entityErrorObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EntityErrorObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EntityErrorObject' from JSON`, ); }