request-options.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { NullableHeaders } from "./headers.js";
  2. import type { BodyInit } from "./builtin-types.js";
  3. import { Stream } from "../core/streaming.js";
  4. import type { HTTPMethod, MergedRequestInit } from "./types.js";
  5. import { type HeadersLike } from "./headers.js";
  6. export type FinalRequestOptions = RequestOptions & {
  7. method: HTTPMethod;
  8. path: string;
  9. };
  10. export type RequestOptions = {
  11. /**
  12. * The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
  13. */
  14. method?: HTTPMethod;
  15. /**
  16. * The URL path for the request.
  17. *
  18. * @example "/v1/foo"
  19. */
  20. path?: string;
  21. /**
  22. * Query parameters to include in the request URL.
  23. */
  24. query?: object | undefined | null;
  25. /**
  26. * The request body. Can be a string, JSON object, FormData, or other supported types.
  27. */
  28. body?: unknown;
  29. /**
  30. * HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
  31. */
  32. headers?: HeadersLike;
  33. /**
  34. * The maximum number of times that the client will retry a request in case of a
  35. * temporary failure, like a network error or a 5XX error from the server.
  36. *
  37. * @default 2
  38. */
  39. maxRetries?: number;
  40. stream?: boolean | undefined;
  41. /**
  42. * The maximum amount of time (in milliseconds) that the client should wait for a response
  43. * from the server before timing out a single request.
  44. *
  45. * @unit milliseconds
  46. */
  47. timeout?: number;
  48. /**
  49. * Additional `RequestInit` options to be passed to the underlying `fetch` call.
  50. * These options will be merged with the client's default fetch options.
  51. */
  52. fetchOptions?: MergedRequestInit;
  53. /**
  54. * An AbortSignal that can be used to cancel the request.
  55. */
  56. signal?: AbortSignal | undefined | null;
  57. /**
  58. * A unique key for this request to enable idempotency.
  59. */
  60. idempotencyKey?: string;
  61. /**
  62. * Override the default base URL for this specific request.
  63. */
  64. defaultBaseURL?: string | undefined;
  65. __metadata?: Record<string, unknown>;
  66. __binaryResponse?: boolean | undefined;
  67. __streamClass?: typeof Stream;
  68. };
  69. export type EncodedContent = {
  70. bodyHeaders: HeadersLike;
  71. body: BodyInit;
  72. };
  73. export type RequestEncoder = (request: {
  74. headers: NullableHeaders;
  75. body: unknown;
  76. }) => EncodedContent;
  77. export declare const FallbackEncoder: RequestEncoder;
  78. //# sourceMappingURL=request-options.d.ts.map