From b34ecbb8490f73b869d87ba732ac9d40f7efd303 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:56:20 +0000 Subject: [PATCH 1/2] fix(client): normalize method (#57) --- src/core.ts | 12 +++++++++++- tests/index.test.ts | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index c28f00c..8ffec0b 100644 --- a/src/core.ts +++ b/src/core.ts @@ -522,9 +522,19 @@ export abstract class APIClient { const timeout = setTimeout(() => controller.abort(), ms); + const fetchOptions = { + signal: controller.signal as any, + ...options, + }; + if (fetchOptions.method) { + // Custom methods like 'patch' need to be uppercased + // See https://github.com/nodejs/undici/issues/2294 + fetchOptions.method = fetchOptions.method.toUpperCase(); + } + return ( // use undefined this binding; fetch errors if bound to something else in browser/cloudflare - this.fetch.call(undefined, url, { signal: controller.signal as any, ...options }).finally(() => { + this.fetch.call(undefined, url, fetchOptions).finally(() => { clearTimeout(timeout); }) ); diff --git a/tests/index.test.ts b/tests/index.test.ts index d26d141..594c8cb 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -122,6 +122,23 @@ describe('instantiate client', () => { expect(spy).toHaveBeenCalledTimes(1); }); + test('normalized method', async () => { + let capturedRequest: RequestInit | undefined; + const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise => { + capturedRequest = init; + return new Response(JSON.stringify({}), { headers: { 'Content-Type': 'application/json' } }); + }; + + const client = new RunwayML({ + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: testFetch, + }); + + await client.patch('/foo'); + expect(capturedRequest?.method).toEqual('PATCH'); + }); + describe('baseUrl', () => { test('trailing slash', () => { const client = new RunwayML({ baseURL: 'http://localhost:5000/custom/path/', apiKey: 'My API Key' }); From 35380e76558482bb1a3dd17f019a1f7becb7d64b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:56:37 +0000 Subject: [PATCH 2/2] release: 1.4.6 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 266f637..a468742 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.4.5" + ".": "1.4.6" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3bbaf..3f326a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.4.6 (2024-12-20) + +Full Changelog: [v1.4.5...v1.4.6](https://github.com/runwayml/sdk-node/compare/v1.4.5...v1.4.6) + +### Bug Fixes + +* **client:** normalize method ([#57](https://github.com/runwayml/sdk-node/issues/57)) ([b34ecbb](https://github.com/runwayml/sdk-node/commit/b34ecbb8490f73b869d87ba732ac9d40f7efd303)) + ## 1.4.5 (2024-12-18) Full Changelog: [v1.4.4...v1.4.5](https://github.com/runwayml/sdk-node/compare/v1.4.4...v1.4.5) diff --git a/package.json b/package.json index 604b898..f70857c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@runwayml/sdk", - "version": "1.4.5", + "version": "1.4.6", "description": "The official TypeScript library for the RunwayML API", "author": "RunwayML ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index b6d6271..a3bcb09 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.4.5'; // x-release-please-version +export const VERSION = '1.4.6'; // x-release-please-version