From 2b62732d4414f72715911e07d017b0297b1e896c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:47:51 +0000 Subject: [PATCH 1/2] chore(internal): codegen related update (#94) --- 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 55b478dc..fe4853f4 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 5ee8c1ab..f45c1b08 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 Openlayer({ + 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 Openlayer({ baseURL: 'http://localhost:5000/custom/path/', apiKey: 'My API Key' }); From ce7752c41a0a0c2a71a30ac5889811d95c7b8431 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:48:08 +0000 Subject: [PATCH 2/2] release: 0.10.1 --- .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 7d9b009d..30b6d45a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.10.0" + ".": "0.10.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c97d3f..82237845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.10.1 (2024-12-20) + +Full Changelog: [v0.10.0...v0.10.1](https://github.com/openlayer-ai/openlayer-ts/compare/v0.10.0...v0.10.1) + +### Chores + +* **internal:** codegen related update ([#94](https://github.com/openlayer-ai/openlayer-ts/issues/94)) ([2b62732](https://github.com/openlayer-ai/openlayer-ts/commit/2b62732d4414f72715911e07d017b0297b1e896c)) + ## 0.10.0 (2024-12-18) Full Changelog: [v0.9.4...v0.10.0](https://github.com/openlayer-ai/openlayer-ts/compare/v0.9.4...v0.10.0) diff --git a/package.json b/package.json index 7771aa65..29c2b3cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openlayer", - "version": "0.10.0", + "version": "0.10.1", "description": "The official TypeScript library for the Openlayer API", "author": "Openlayer ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index c2e5b969..92897943 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.10.0'; // x-release-please-version +export const VERSION = '0.10.1'; // x-release-please-version