/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The intended purpose of the file */ export const Purpose = { Assistants: "assistants", Batch: "batch", FineTune: "fine-tune", Vision: "vision", UserData: "user_data", Evals: "evals", } as const; /** * The intended purpose of the file */ export type Purpose = ClosedEnum; /** * DEPRECATED: File processing status */ export const FileStatus = { Uploaded: "uploaded", Processed: "processed", Error: "error", } as const; /** * DEPRECATED: File processing status */ export type FileStatus = ClosedEnum; export type FileT = { /** * The file identifier */ id: string; object?: "file" | undefined; /** * The size of the file in bytes */ bytes: number; /** * Unix timestamp when the file was created */ createdAt: number; /** * Unix timestamp when the file expires */ expiresAt?: number | null | undefined; /** * The name of the file */ filename: string; /** * The intended purpose of the file */ purpose: Purpose; /** * DEPRECATED: File processing status */ status?: FileStatus | undefined; /** * DEPRECATED: Details about file status */ statusDetails?: string | undefined; }; /** @internal */ export const Purpose$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Purpose); /** @internal */ export const Purpose$outboundSchema: z.ZodNativeEnum = Purpose$inboundSchema; /** @internal */ export const FileStatus$inboundSchema: z.ZodNativeEnum = z .nativeEnum(FileStatus); /** @internal */ export const FileStatus$outboundSchema: z.ZodNativeEnum = FileStatus$inboundSchema; /** @internal */ export const FileT$inboundSchema: z.ZodType = z .object({ id: z.string(), object: z.literal("file").default("file"), bytes: z.number().int(), created_at: z.number().int(), expires_at: z.nullable(z.number().int()).optional(), filename: z.string(), purpose: Purpose$inboundSchema, status: FileStatus$inboundSchema.optional(), status_details: z.string().optional(), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "expires_at": "expiresAt", "status_details": "statusDetails", }); }); /** @internal */ export type FileT$Outbound = { id: string; object: "file"; bytes: number; created_at: number; expires_at?: number | null | undefined; filename: string; purpose: string; status?: string | undefined; status_details?: string | undefined; }; /** @internal */ export const FileT$outboundSchema: z.ZodType< FileT$Outbound, z.ZodTypeDef, FileT > = z.object({ id: z.string(), object: z.literal("file").default("file" as const), bytes: z.number().int(), createdAt: z.number().int(), expiresAt: z.nullable(z.number().int()).optional(), filename: z.string(), purpose: Purpose$outboundSchema, status: FileStatus$outboundSchema.optional(), statusDetails: z.string().optional(), }).transform((v) => { return remap$(v, { createdAt: "created_at", expiresAt: "expires_at", statusDetails: "status_details", }); }); export function fileToJSON(fileT: FileT): string { return JSON.stringify(FileT$outboundSchema.parse(fileT)); } export function fileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileT' from JSON`, ); }