/* * 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"; export type Annotation = { type: string; text: string; start: number; end: number; }; export type ResponseOutputTextAnnotationAddedEvent = { type: "response.output_text.annotation.added"; sequenceNumber: number; itemId: string; outputIndex: number; contentIndex: number; annotationIndex: number; annotation: Annotation; }; /** @internal */ export const Annotation$inboundSchema: z.ZodType< Annotation, z.ZodTypeDef, unknown > = z.object({ type: z.string(), text: z.string(), start: z.number().int(), end: z.number().int(), }); /** @internal */ export type Annotation$Outbound = { type: string; text: string; start: number; end: number; }; /** @internal */ export const Annotation$outboundSchema: z.ZodType< Annotation$Outbound, z.ZodTypeDef, Annotation > = z.object({ type: z.string(), text: z.string(), start: z.number().int(), end: z.number().int(), }); export function annotationToJSON(annotation: Annotation): string { return JSON.stringify(Annotation$outboundSchema.parse(annotation)); } export function annotationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Annotation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Annotation' from JSON`, ); } /** @internal */ export const ResponseOutputTextAnnotationAddedEvent$inboundSchema: z.ZodType< ResponseOutputTextAnnotationAddedEvent, z.ZodTypeDef, unknown > = z.object({ type: z.literal("response.output_text.annotation.added"), sequence_number: z.number().int(), item_id: z.string(), output_index: z.number().int(), content_index: z.number().int(), annotation_index: z.number().int(), annotation: z.lazy(() => Annotation$inboundSchema), }).transform((v) => { return remap$(v, { "sequence_number": "sequenceNumber", "item_id": "itemId", "output_index": "outputIndex", "content_index": "contentIndex", "annotation_index": "annotationIndex", }); }); /** @internal */ export type ResponseOutputTextAnnotationAddedEvent$Outbound = { type: "response.output_text.annotation.added"; sequence_number: number; item_id: string; output_index: number; content_index: number; annotation_index: number; annotation: Annotation$Outbound; }; /** @internal */ export const ResponseOutputTextAnnotationAddedEvent$outboundSchema: z.ZodType< ResponseOutputTextAnnotationAddedEvent$Outbound, z.ZodTypeDef, ResponseOutputTextAnnotationAddedEvent > = z.object({ type: z.literal("response.output_text.annotation.added"), sequenceNumber: z.number().int(), itemId: z.string(), outputIndex: z.number().int(), contentIndex: z.number().int(), annotationIndex: z.number().int(), annotation: z.lazy(() => Annotation$outboundSchema), }).transform((v) => { return remap$(v, { sequenceNumber: "sequence_number", itemId: "item_id", outputIndex: "output_index", contentIndex: "content_index", annotationIndex: "annotation_index", }); }); export function responseOutputTextAnnotationAddedEventToJSON( responseOutputTextAnnotationAddedEvent: ResponseOutputTextAnnotationAddedEvent, ): string { return JSON.stringify( ResponseOutputTextAnnotationAddedEvent$outboundSchema.parse( responseOutputTextAnnotationAddedEvent, ), ); } export function responseOutputTextAnnotationAddedEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseOutputTextAnnotationAddedEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseOutputTextAnnotationAddedEvent' from JSON`, ); }