/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The feedback rating indicating user satisfaction */ export const ResultsRating = { ThumbsUp: "thumbs_up", ThumbsDown: "thumbs_down", } as const; /** * The feedback rating indicating user satisfaction */ export type ResultsRating = ClosedEnum; /** * Feedback object containing user ratings and comments about a chat completion or response. */ export type Results2 = { /** * The request ID that this feedback is associated with */ id: string; /** * The feedback rating indicating user satisfaction */ rating?: ResultsRating | undefined; /** * Optional detailed feedback description providing additional context or explanation (max 2000 characters) */ description?: string | undefined; /** * Timestamp when the feedback was created */ createdAt?: Date | undefined; /** * Timestamp when the feedback was last updated */ updatedAt?: Date | undefined; }; /** * Error result when the completion/response ID doesn't exist */ export type Results1 = { /** * The request ID that was queried */ id: string; /** * Error indicating the resource doesn't exist */ error: "not_found"; }; export type Results = Results1 | Results2; /** * Response containing batch feedback results. Each result is either the feedback data or a not_found error. */ export type BatchGetFeedbackResponse = { /** * Array of feedback results in the same order as the input IDs */ results: Array; }; /** @internal */ export const ResultsRating$inboundSchema: z.ZodNativeEnum< typeof ResultsRating > = z.nativeEnum(ResultsRating); /** @internal */ export const ResultsRating$outboundSchema: z.ZodNativeEnum< typeof ResultsRating > = ResultsRating$inboundSchema; /** @internal */ export const Results2$inboundSchema: z.ZodType< Results2, z.ZodTypeDef, unknown > = z.object({ id: z.string(), rating: ResultsRating$inboundSchema.optional(), description: z.string().optional(), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type Results2$Outbound = { id: string; rating?: string | undefined; description?: string | undefined; createdAt?: string | undefined; updatedAt?: string | undefined; }; /** @internal */ export const Results2$outboundSchema: z.ZodType< Results2$Outbound, z.ZodTypeDef, Results2 > = z.object({ id: z.string(), rating: ResultsRating$outboundSchema.optional(), description: z.string().optional(), createdAt: z.date().transform(v => v.toISOString()).optional(), updatedAt: z.date().transform(v => v.toISOString()).optional(), }); export function results2ToJSON(results2: Results2): string { return JSON.stringify(Results2$outboundSchema.parse(results2)); } export function results2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Results2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Results2' from JSON`, ); } /** @internal */ export const Results1$inboundSchema: z.ZodType< Results1, z.ZodTypeDef, unknown > = z.object({ id: z.string(), error: z.literal("not_found"), }); /** @internal */ export type Results1$Outbound = { id: string; error: "not_found"; }; /** @internal */ export const Results1$outboundSchema: z.ZodType< Results1$Outbound, z.ZodTypeDef, Results1 > = z.object({ id: z.string(), error: z.literal("not_found"), }); export function results1ToJSON(results1: Results1): string { return JSON.stringify(Results1$outboundSchema.parse(results1)); } export function results1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Results1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Results1' from JSON`, ); } /** @internal */ export const Results$inboundSchema: z.ZodType = z.union([ z.lazy(() => Results1$inboundSchema), z.lazy(() => Results2$inboundSchema), ]); /** @internal */ export type Results$Outbound = Results1$Outbound | Results2$Outbound; /** @internal */ export const Results$outboundSchema: z.ZodType< Results$Outbound, z.ZodTypeDef, Results > = z.union([ z.lazy(() => Results1$outboundSchema), z.lazy(() => Results2$outboundSchema), ]); export function resultsToJSON(results: Results): string { return JSON.stringify(Results$outboundSchema.parse(results)); } export function resultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Results$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Results' from JSON`, ); } /** @internal */ export const BatchGetFeedbackResponse$inboundSchema: z.ZodType< BatchGetFeedbackResponse, z.ZodTypeDef, unknown > = z.object({ results: z.array( z.union([ z.lazy(() => Results1$inboundSchema), z.lazy(() => Results2$inboundSchema), ]), ), }); /** @internal */ export type BatchGetFeedbackResponse$Outbound = { results: Array; }; /** @internal */ export const BatchGetFeedbackResponse$outboundSchema: z.ZodType< BatchGetFeedbackResponse$Outbound, z.ZodTypeDef, BatchGetFeedbackResponse > = z.object({ results: z.array( z.union([ z.lazy(() => Results1$outboundSchema), z.lazy(() => Results2$outboundSchema), ]), ), }); export function batchGetFeedbackResponseToJSON( batchGetFeedbackResponse: BatchGetFeedbackResponse, ): string { return JSON.stringify( BatchGetFeedbackResponse$outboundSchema.parse(batchGetFeedbackResponse), ); } export function batchGetFeedbackResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BatchGetFeedbackResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchGetFeedbackResponse' from JSON`, ); }