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

import * as z from "zod/v4";
import { blobLikeSchema } from "../../types/blobs.js";
import { ClosedEnum } from "../../types/enums.js";
import * as components from "../components/index.js";

export const FileVisibility = {
  Workspace: "workspace",
  User: "user",
} as const;
export type FileVisibility = ClosedEnum<typeof FileVisibility>;

export type MultiPartBodyParams = {
  expiry?: number | null | undefined;
  visibility?: FileVisibility | undefined;
  purpose?: components.FilePurpose | undefined;
  /**
   * 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;
};

/** @internal */
export const FileVisibility$outboundSchema: z.ZodEnum<typeof FileVisibility> = z
  .enum(FileVisibility);

/** @internal */
export type MultiPartBodyParams$Outbound = {
  expiry?: number | null | undefined;
  visibility: string;
  purpose?: string | undefined;
  file: components.FileT$Outbound | Blob;
};

/** @internal */
export const MultiPartBodyParams$outboundSchema: z.ZodType<
  MultiPartBodyParams$Outbound,
  MultiPartBodyParams
> = z.object({
  expiry: z.nullable(z.int()).optional(),
  visibility: FileVisibility$outboundSchema.default("workspace"),
  purpose: components.FilePurpose$outboundSchema.optional(),
  file: components.FileT$outboundSchema.or(blobLikeSchema),
});

export function multiPartBodyParamsToJSON(
  multiPartBodyParams: MultiPartBodyParams,
): string {
  return JSON.stringify(
    MultiPartBodyParams$outboundSchema.parse(multiPartBodyParams),
  );
}
