/*
 * 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 { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { FilePurpose, FilePurpose$inboundSchema } from "./filepurpose.js";
import { SampleType, SampleType$inboundSchema } from "./sampletype.js";
import { Source, Source$inboundSchema } from "./source.js";

export type UploadFileOut = {
  /**
   * The unique identifier of the file.
   */
  id: string;
  /**
   * The object type, which is always "file".
   */
  object: string;
  /**
   * The size of the file, in bytes.
   */
  sizeBytes: number;
  /**
   * The UNIX timestamp (in seconds) of the event.
   */
  createdAt: number;
  /**
   * The name of the uploaded file.
   */
  filename: string;
  purpose: FilePurpose;
  sampleType: SampleType;
  numLines?: number | null | undefined;
  mimetype?: string | null | undefined;
  source: Source;
  signature?: string | null | undefined;
};

/** @internal */
export const UploadFileOut$inboundSchema: z.ZodType<
  UploadFileOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  object: z.string(),
  bytes: z.number().int(),
  created_at: z.number().int(),
  filename: z.string(),
  purpose: FilePurpose$inboundSchema,
  sample_type: SampleType$inboundSchema,
  num_lines: z.nullable(z.number().int()).optional(),
  mimetype: z.nullable(z.string()).optional(),
  source: Source$inboundSchema,
  signature: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "bytes": "sizeBytes",
    "created_at": "createdAt",
    "sample_type": "sampleType",
    "num_lines": "numLines",
  });
});

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