diff --git a/README.md b/README.md index ab3e0fa8f..c034e311c 100644 --- a/README.md +++ b/README.md @@ -245,35 +245,36 @@ const { data: app } = await requestWithAuth( - options.mediaType.format + options.method String - Media type param, such as `raw`, `html`, or `full`. See Media Types. + Any supported http verb, case insensitive. Defaults to Get. - options.mediaType.previews + options.mediaType.format - Array of strings + String - Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See API Previews. + Media type param, such as `raw`, `html`, or `full`. See Media Types. - options.method + options.mediaType.previews - String + Array of strings - Any supported http verb, case insensitive. Defaults to Get. + Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See GraphQL Schema Previews. + Note that these only apply to GraphQL requests and have no effect on REST routes. @@ -299,18 +300,7 @@ const { data: app } = await requestWithAuth( Set request body directly instead of setting it to JSON based on additional parameters. See "The `data` parameter" below. - - - - options.request.agent - - - http(s).Agent instance - - - Node only. Useful for custom proxy, certificate, or dns lookup. - - + options.request.fetch diff --git a/package-lock.json b/package-lock.json index e88623399..e720632ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@octokit/endpoint": "^8.0.1", "@octokit/request-error": "^4.0.1", - "@octokit/types": "^10.0.0", + "@octokit/types": "^11.0.0", "is-plain-object": "^5.0.0", "universal-user-agent": "^6.0.0" }, @@ -2000,6 +2000,14 @@ "node": ">= 18" } }, + "node_modules/@octokit/endpoint/node_modules/@octokit/types": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-10.0.0.tgz", + "integrity": "sha512-Vm8IddVmhCgU1fxC1eyinpwqzXPEYu0NrYzD3YZjlGjyftdLBTeqNblRC0jmJmgxbJIsQlyogVeGnrNaaMVzIg==", + "dependencies": { + "@octokit/openapi-types": "^18.0.0" + } + }, "node_modules/@octokit/oauth-authorization-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-5.0.0.tgz", @@ -2083,6 +2091,14 @@ "node": ">= 18" } }, + "node_modules/@octokit/request-error/node_modules/@octokit/types": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-10.0.0.tgz", + "integrity": "sha512-Vm8IddVmhCgU1fxC1eyinpwqzXPEYu0NrYzD3YZjlGjyftdLBTeqNblRC0jmJmgxbJIsQlyogVeGnrNaaMVzIg==", + "dependencies": { + "@octokit/openapi-types": "^18.0.0" + } + }, "node_modules/@octokit/request/node_modules/@octokit/endpoint": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.6.tgz", @@ -2113,9 +2129,9 @@ "dev": true }, "node_modules/@octokit/types": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-10.0.0.tgz", - "integrity": "sha512-Vm8IddVmhCgU1fxC1eyinpwqzXPEYu0NrYzD3YZjlGjyftdLBTeqNblRC0jmJmgxbJIsQlyogVeGnrNaaMVzIg==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.0.0.tgz", + "integrity": "sha512-h4iyfMpQUdub1itwTn6y7z2a3EtPuer1paKfsIbZErv0LBbZYGq6haiPUPJys/LetPqgcX3ft33O16XuS03Anw==", "dependencies": { "@octokit/openapi-types": "^18.0.0" } diff --git a/package.json b/package.json index 47ad9a5de..97bc727e6 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dependencies": { "@octokit/endpoint": "^8.0.1", "@octokit/request-error": "^4.0.1", - "@octokit/types": "^10.0.0", + "@octokit/types": "^11.0.0", "is-plain-object": "^5.0.0", "universal-user-agent": "^6.0.0" }, diff --git a/src/fetch-wrapper.ts b/src/fetch-wrapper.ts index 61e0cac48..edcfd0f69 100644 --- a/src/fetch-wrapper.ts +++ b/src/fetch-wrapper.ts @@ -36,23 +36,16 @@ export default function fetchWrapper( ); } - return fetch( - requestOptions.url, - Object.assign( - { - method: requestOptions.method, - body: requestOptions.body, - headers: requestOptions.headers as HeadersInit, - redirect: requestOptions.redirect, - // duplex must be set if request.body is ReadableStream or Async Iterables. - // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. - ...(requestOptions.body && { duplex: "half" }), - }, - // `requestOptions.request.agent` type is incompatible - // see https://github.com/octokit/types.ts/pull/264 - requestOptions.request as any, - ), - ) + return fetch(requestOptions.url, { + method: requestOptions.method, + body: requestOptions.body, + headers: requestOptions.headers as HeadersInit, + signal: (requestOptions as any).signal, + data: (requestOptions as any).data, + // duplex must be set if request.body is ReadableStream or Async Iterables. + // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. + ...(requestOptions.body && { duplex: "half" }), + }) .then(async (response) => { url = response.url; status = response.status; diff --git a/test/request.test.ts b/test/request.test.ts index f43415104..59263941b 100644 --- a/test/request.test.ts +++ b/test/request.test.ts @@ -561,25 +561,6 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w== ); }); - it("options.request.signal is passed as option to fetch", function () { - return request("/", { - request: { - // We pass a value that is not an `AbortSignal`, and expect `fetch` to - // throw an exception complaining about the value - signal: "funk", - }, - }) - .then(() => { - throw new Error("Should not resolve"); - }) - - .catch((error) => { - // We can't match on the entire string because the message differs between - // Node versions. - expect(error.message).toMatch(/AbortSignal/); - }); - }); - it("options.request.fetch", function () { return request("/", { request: {