/* * 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"; /** * Item reference item: A pointer to another response item by ID. */ export type ItemReferenceWithId = { type?: "item_reference" | undefined; /** * The unique ID of the message. */ id: string; /** * The ID of the response that created this item, if any. */ responseId?: string | null | undefined; /** * Metadata from the response that created this item, if any. */ metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const ItemReferenceWithId$inboundSchema: z.ZodType< ItemReferenceWithId, z.ZodTypeDef, unknown > = z.object({ type: z.literal("item_reference").default("item_reference"), id: z.string(), response_id: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "response_id": "responseId", }); }); /** @internal */ export type ItemReferenceWithId$Outbound = { type: "item_reference"; id: string; response_id?: string | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const ItemReferenceWithId$outboundSchema: z.ZodType< ItemReferenceWithId$Outbound, z.ZodTypeDef, ItemReferenceWithId > = z.object({ type: z.literal("item_reference").default("item_reference" as const), id: z.string(), responseId: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { responseId: "response_id", }); }); export function itemReferenceWithIdToJSON( itemReferenceWithId: ItemReferenceWithId, ): string { return JSON.stringify( ItemReferenceWithId$outboundSchema.parse(itemReferenceWithId), ); } export function itemReferenceWithIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ItemReferenceWithId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ItemReferenceWithId' from JSON`, ); }