/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 5745af9832c9
 */

import * as z from "zod/v4";
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 {
  ConversationUsageInfo,
  ConversationUsageInfo$inboundSchema,
} from "./conversationusageinfo.js";

export type ResponseDoneEvent = {
  type: "conversation.response.done";
  createdAt?: Date | undefined;
  usage: ConversationUsageInfo;
};

/** @internal */
export const ResponseDoneEvent$inboundSchema: z.ZodType<
  ResponseDoneEvent,
  unknown
> = z.object({
  type: z.literal("conversation.response.done"),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
  usage: ConversationUsageInfo$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
  });
});

export function responseDoneEventFromJSON(
  jsonString: string,
): SafeParseResult<ResponseDoneEvent, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ResponseDoneEvent$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ResponseDoneEvent' from JSON`,
  );
}
