/* * 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 { 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 ListFeedbackResponseRating = { ThumbsUp: "thumbs_up", ThumbsDown: "thumbs_down", } as const; /** * The feedback rating indicating user satisfaction */ export type ListFeedbackResponseRating = ClosedEnum< typeof ListFeedbackResponseRating >; /** * Feedback entry in a list, including the model that produced the rated output. */ export type ListFeedbackResponseData = { /** * The request ID that this feedback is associated with */ id: string; /** * The feedback rating indicating user satisfaction */ rating?: ListFeedbackResponseRating | undefined; /** * Optional detailed feedback description providing additional context or explanation */ description?: string | undefined; /** * The model that produced the rated output. */ model: string; /** * Timestamp when the underlying output was created */ createdAt: Date; /** * Timestamp when the underlying output record was last updated */ updatedAt: Date; }; /** * Paginated list object containing feedback entries with cursor-based pagination metadata. */ export type ListFeedbackResponse = { /** * The object type, always 'list' for paginated list responses. */ object: "list"; /** * Array of feedback entries ordered by creation date of the underlying request. */ data: Array; /** * The ID of the first feedback entry in the current page. Used as a reference point for pagination. */ firstId?: string | undefined; /** * The ID of the last feedback entry in the current page. Used as a cursor for fetching the next page. */ lastId?: string | undefined; /** * Indicates whether there are more feedback entries available beyond the current page. True if additional pages exist. */ hasMore: boolean; }; /** @internal */ export const ListFeedbackResponseRating$inboundSchema: z.ZodNativeEnum< typeof ListFeedbackResponseRating > = z.nativeEnum(ListFeedbackResponseRating); /** @internal */ export const ListFeedbackResponseRating$outboundSchema: z.ZodNativeEnum< typeof ListFeedbackResponseRating > = ListFeedbackResponseRating$inboundSchema; /** @internal */ export const ListFeedbackResponseData$inboundSchema: z.ZodType< ListFeedbackResponseData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), rating: ListFeedbackResponseRating$inboundSchema.optional(), description: z.string().optional(), model: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "updated_at": "updatedAt", }); }); /** @internal */ export type ListFeedbackResponseData$Outbound = { id: string; rating?: string | undefined; description?: string | undefined; model: string; created_at: string; updated_at: string; }; /** @internal */ export const ListFeedbackResponseData$outboundSchema: z.ZodType< ListFeedbackResponseData$Outbound, z.ZodTypeDef, ListFeedbackResponseData > = z.object({ id: z.string(), rating: ListFeedbackResponseRating$outboundSchema.optional(), description: z.string().optional(), model: z.string(), createdAt: z.date().transform(v => v.toISOString()), updatedAt: z.date().transform(v => v.toISOString()), }).transform((v) => { return remap$(v, { createdAt: "created_at", updatedAt: "updated_at", }); }); export function listFeedbackResponseDataToJSON( listFeedbackResponseData: ListFeedbackResponseData, ): string { return JSON.stringify( ListFeedbackResponseData$outboundSchema.parse(listFeedbackResponseData), ); } export function listFeedbackResponseDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListFeedbackResponseData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListFeedbackResponseData' from JSON`, ); } /** @internal */ export const ListFeedbackResponse$inboundSchema: z.ZodType< ListFeedbackResponse, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListFeedbackResponseData$inboundSchema)), first_id: z.string().optional(), last_id: z.string().optional(), has_more: z.boolean(), }).transform((v) => { return remap$(v, { "first_id": "firstId", "last_id": "lastId", "has_more": "hasMore", }); }); /** @internal */ export type ListFeedbackResponse$Outbound = { object: "list"; data: Array; first_id?: string | undefined; last_id?: string | undefined; has_more: boolean; }; /** @internal */ export const ListFeedbackResponse$outboundSchema: z.ZodType< ListFeedbackResponse$Outbound, z.ZodTypeDef, ListFeedbackResponse > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListFeedbackResponseData$outboundSchema)), firstId: z.string().optional(), lastId: z.string().optional(), hasMore: z.boolean(), }).transform((v) => { return remap$(v, { firstId: "first_id", lastId: "last_id", hasMore: "has_more", }); }); export function listFeedbackResponseToJSON( listFeedbackResponse: ListFeedbackResponse, ): string { return JSON.stringify( ListFeedbackResponse$outboundSchema.parse(listFeedbackResponse), ); } export function listFeedbackResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListFeedbackResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListFeedbackResponse' from JSON`, ); }