/*
 * 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 { blobLikeSchema } from "../../types/blobs.js";
import * as components from "../components/index.js";

export type LibrariesDocumentsUploadV1DocumentUpload = {
  /**
   * The File object (not file name) to be uploaded.
   *
   * @remarks
   *  To upload a file and specify a custom file name you should format your request as such:
   *  ```bash
   *  file=@path/to/your/file.jsonl;filename=custom_name.jsonl
   *  ```
   *  Otherwise, you can just keep the original file name:
   *  ```bash
   *  file=@path/to/your/file.jsonl
   *  ```
   */
  file: components.FileT | Blob;
};

export type LibrariesDocumentsUploadV1Request = {
  libraryId: string;
  requestBody: LibrariesDocumentsUploadV1DocumentUpload;
};

/** @internal */
export type LibrariesDocumentsUploadV1DocumentUpload$Outbound = {
  file: components.FileT$Outbound | Blob;
};

/** @internal */
export const LibrariesDocumentsUploadV1DocumentUpload$outboundSchema: z.ZodType<
  LibrariesDocumentsUploadV1DocumentUpload$Outbound,
  z.ZodTypeDef,
  LibrariesDocumentsUploadV1DocumentUpload
> = z.object({
  file: components.FileT$outboundSchema.or(blobLikeSchema),
});

export function librariesDocumentsUploadV1DocumentUploadToJSON(
  librariesDocumentsUploadV1DocumentUpload:
    LibrariesDocumentsUploadV1DocumentUpload,
): string {
  return JSON.stringify(
    LibrariesDocumentsUploadV1DocumentUpload$outboundSchema.parse(
      librariesDocumentsUploadV1DocumentUpload,
    ),
  );
}

/** @internal */
export type LibrariesDocumentsUploadV1Request$Outbound = {
  library_id: string;
  RequestBody: LibrariesDocumentsUploadV1DocumentUpload$Outbound;
};

/** @internal */
export const LibrariesDocumentsUploadV1Request$outboundSchema: z.ZodType<
  LibrariesDocumentsUploadV1Request$Outbound,
  z.ZodTypeDef,
  LibrariesDocumentsUploadV1Request
> = z.object({
  libraryId: z.string(),
  requestBody: z.lazy(() =>
    LibrariesDocumentsUploadV1DocumentUpload$outboundSchema
  ),
}).transform((v) => {
  return remap$(v, {
    libraryId: "library_id",
    requestBody: "RequestBody",
  });
});

export function librariesDocumentsUploadV1RequestToJSON(
  librariesDocumentsUploadV1Request: LibrariesDocumentsUploadV1Request,
): string {
  return JSON.stringify(
    LibrariesDocumentsUploadV1Request$outboundSchema.parse(
      librariesDocumentsUploadV1Request,
    ),
  );
}
