All files / shared/src/types/api/routes/files-api request.ts

100% Statements 26/26
100% Branches 0/0
100% Functions 0/0
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 811x   1x         1x 1x 1x 1x 1x 1x 1x             1x 1x       1x       1x           1x             1x             1x 1x       1x       1x 1x       1x       1x 1x       1x       1x 1x      
import { z } from 'zod';
 
export const FileUploadRequestBody = z.object({
  /**
   * The File object (not file name) to be uploaded.
   * To upload a file with a specific filename, you need to wrap it in a File object or form data.
   */
  file: z.union([
    z.instanceof(File),
    z.instanceof(Blob),
    z.instanceof(ArrayBuffer),
    z.instanceof(Uint8Array),
    z.instanceof(ReadableStream),
  ]),
 
  /**
   * The intended purpose of the uploaded file.
   * Use "assistants" for Assistants and Message files, "vision" for Assistants image file inputs,
   * "batch" for Batch API, "fine-tune" for Fine-tuning.
   */
  purpose: z.enum(['assistants', 'vision', 'batch', 'fine-tune']),
});
 
export type FileUploadRequestBody = z.infer<typeof FileUploadRequestBody>;
 
export const FileListRequestBody = z.object({
  /**
   * Only return files with the given purpose.
   */
  purpose: z.enum(['assistants', 'vision', 'batch', 'fine-tune']).optional(),
 
  /**
   * A limit on the number of objects to be returned.
   * Limit can range between 1 and 10,000, and the default is 10,000.
   */
  limit: z.number().optional(),
 
  /**
   * Sort order by the created_at timestamp of the objects.
   * asc for ascending order and desc for descending order.
   * @default "desc"
   */
  order: z.enum(['asc', 'desc']).optional(),
 
  /**
   * A cursor for use in pagination. after is an object ID that defines your place in the list.
   * For instance, if you make a list request and receive 100 objects, ending with obj_foo,
   * your subsequent call can include after=obj_foo in order to fetch the next page of the list.
   */
  after: z.string().optional(),
});
 
export type FileListRequestBody = z.infer<typeof FileListRequestBody>;
 
export const FileRetrieveRequestBody = z.object({
  /**
   * The ID of the file to use for this request.
   */
  file_id: z.string(),
});
 
export type FileRetrieveRequestBody = z.infer<typeof FileRetrieveRequestBody>;
 
export const FileDeleteRequestBody = z.object({
  /**
   * The ID of the file to delete.
   */
  file_id: z.string(),
});
 
export type FileDeleteRequestBody = z.infer<typeof FileDeleteRequestBody>;
 
export const FileContentRequestBody = z.object({
  /**
   * The ID of the file to retrieve content for.
   */
  file_id: z.string(),
});
 
export type FileContentRequestBody = z.infer<typeof FileContentRequestBody>;