uploads.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { type RequestOptions } from "./request-options.js";
  2. import type { FilePropertyBag, Fetch } from "./builtin-types.js";
  3. import type { OpenAI } from "../client.js";
  4. export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
  5. type FsReadStream = AsyncIterable<Uint8Array> & {
  6. path: string | {
  7. toString(): string;
  8. };
  9. };
  10. interface BunFile extends Blob {
  11. readonly name?: string | undefined;
  12. }
  13. export declare const checkFileSupport: () => void;
  14. /**
  15. * Typically, this is a native "File" class.
  16. *
  17. * We provide the {@link toFile} utility to convert a variety of objects
  18. * into the File class.
  19. *
  20. * For convenience, you can also pass a fetch Response, or in Node,
  21. * the result of fs.createReadStream().
  22. */
  23. export type Uploadable = File | Response | FsReadStream | BunFile;
  24. /**
  25. * Construct a `File` instance. This is used to ensure a helpful error is thrown
  26. * for environments that don't define a global `File` yet.
  27. */
  28. export declare function makeFile(fileBits: BlobPart[], fileName: string | undefined, options?: FilePropertyBag): File;
  29. export declare function getName(value: any): string | undefined;
  30. export declare const isAsyncIterable: (value: any) => value is AsyncIterable<any>;
  31. /**
  32. * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
  33. * Otherwise returns the request as is.
  34. */
  35. export declare const maybeMultipartFormRequestOptions: (opts: RequestOptions, fetch: OpenAI | Fetch) => Promise<RequestOptions>;
  36. type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & {
  37. body: unknown;
  38. };
  39. export declare const multipartFormRequestOptions: (opts: MultipartFormRequestOptions, fetch: OpenAI | Fetch) => Promise<RequestOptions>;
  40. export declare const createForm: <T = Record<string, unknown>>(body: T | undefined, fetch: OpenAI | Fetch) => Promise<FormData>;
  41. export {};
  42. //# sourceMappingURL=uploads.d.ts.map