/*
 * 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 { ClosedEnum } from "../../types/enums.js";

export const DocumentURLChunkType = {
  DocumentUrl: "document_url",
} as const;
export type DocumentURLChunkType = ClosedEnum<typeof DocumentURLChunkType>;

export type DocumentURLChunk = {
  documentUrl: string;
  /**
   * The filename of the document
   */
  documentName?: string | null | undefined;
  type?: DocumentURLChunkType | undefined;
};

/** @internal */
export const DocumentURLChunkType$outboundSchema: z.ZodNativeEnum<
  typeof DocumentURLChunkType
> = z.nativeEnum(DocumentURLChunkType);

/** @internal */
export type DocumentURLChunk$Outbound = {
  document_url: string;
  document_name?: string | null | undefined;
  type: string;
};

/** @internal */
export const DocumentURLChunk$outboundSchema: z.ZodType<
  DocumentURLChunk$Outbound,
  z.ZodTypeDef,
  DocumentURLChunk
> = z.object({
  documentUrl: z.string(),
  documentName: z.nullable(z.string()).optional(),
  type: DocumentURLChunkType$outboundSchema.default("document_url"),
}).transform((v) => {
  return remap$(v, {
    documentUrl: "document_url",
    documentName: "document_name",
  });
});

export function documentURLChunkToJSON(
  documentURLChunk: DocumentURLChunk,
): string {
  return JSON.stringify(
    DocumentURLChunk$outboundSchema.parse(documentURLChunk),
  );
}
