diff --git a/src/stream.ts b/src/stream.ts index 7d5cbb2..00b01a6 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -13,12 +13,14 @@ import { import { computeURI } from "./agents.js"; import * as Utils from "./utils.js"; -export type StreamOptions = Omit; +export type StreamOptions = Omit & { + opaque?: TOpaque; +}; -export function pipeline( +export function pipeline( method: HttpMethod | WebDavMethod, uri: string | URL, - options: StreamOptions = {} + options: StreamOptions = {} ): Duplex { const computedURI = computeURI(method, uri); if (typeof options.querystring !== "undefined") { @@ -41,15 +43,15 @@ export function pipeline( }, ({ body }) => body); } -export type WritableStreamCallback = ( - factory: undici.Dispatcher.StreamFactory -) => Promise; +export type WritableStreamCallback = ( + factory: undici.Dispatcher.StreamFactory +) => Promise>; -export function stream( +export function stream( method: HttpMethod | WebDavMethod, uri: string | URL, - options: StreamOptions = {} -): WritableStreamCallback { + options: StreamOptions = {} +): WritableStreamCallback { const computedURI = computeURI(method, uri); const dispatcher = options.agent ?? computedURI.agent ?? void 0; @@ -57,7 +59,7 @@ export function stream( const body = Utils.createBody(options.body, headers); return (factory) => undici - .stream( + .stream( computedURI.url, { method: method as HttpMethod, headers, body, dispatcher }, factory