diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e05a05..eecf75b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/spitch-sdk-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -35,6 +36,7 @@ jobs: timeout-minutes: 5 name: build runs-on: ${{ github.repository == 'stainless-sdks/spitch-sdk-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork permissions: contents: read id-token: write @@ -70,6 +72,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/spitch-sdk-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f0af317..c775f94 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.16.1" + ".": "1.27.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b097c7..049d736 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 1.27.0 (2025-07-30) + +Full Changelog: [v1.16.1...v1.27.0](https://github.com/spi-tch/node/compare/v1.16.1...v1.27.0) + +### Bug Fixes + +* **ci:** release-doctor — report correct token name ([eb10dd6](https://github.com/spi-tch/node/commit/eb10dd637029979f95f515ffff77ba33d7f21963)) +* **client:** don't send `Content-Type` for bodyless methods ([6caa572](https://github.com/spi-tch/node/commit/6caa572a99572156da1efb68ab6fe97778a2d8d7)) + + +### Chores + +* **ci:** only run for pushes and fork pull requests ([ce2371b](https://github.com/spi-tch/node/commit/ce2371bb0e41ea10b1fd096aa63055748734322a)) +* **internal:** remove redundant imports config ([93b909c](https://github.com/spi-tch/node/commit/93b909cd081cf79274716380bc6acd8d1743669b)) +* make some internal functions async ([892841b](https://github.com/spi-tch/node/commit/892841b8ca7440a763e2633c192de7b4280f4fbd)) +* mention unit type in timeout docs ([4c56069](https://github.com/spi-tch/node/commit/4c56069effbe1377023587b8cce3592d620701e4)) + ## 1.16.1 (2025-06-17) Full Changelog: [v1.16.0...v1.16.1](https://github.com/spi-tch/node/compare/v1.16.0...v1.16.1) diff --git a/bin/check-release-environment b/bin/check-release-environment index 55e5033..e4b6d58 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,7 +3,7 @@ errors=() if [ -z "${NPM_TOKEN}" ]; then - errors+=("The SPITCH_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/package.json b/package.json index 58803de..f8d1b1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spitch", - "version": "1.16.1", + "version": "1.27.0", "description": "The official TypeScript library for the Spitch API", "author": "Spitch ", "types": "dist/index.d.ts", @@ -58,10 +58,6 @@ "./shims/web.js", "./shims/web.mjs" ], - "imports": { - "spitch": ".", - "spitch/*": "./src/*" - }, "exports": { "./_shims/auto/*": { "deno": { diff --git a/src/core.ts b/src/core.ts index 61b9dcc..11da163 100644 --- a/src/core.ts +++ b/src/core.ts @@ -217,7 +217,7 @@ export abstract class APIClient { protected defaultHeaders(opts: FinalRequestOptions): Headers { return { Accept: 'application/json', - 'Content-Type': 'application/json', + ...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }), 'User-Agent': this.getUserAgent(), ...getPlatformHeaders(), ...this.authHeaders(opts), @@ -299,10 +299,10 @@ export abstract class APIClient { return null; } - buildRequest( + async buildRequest( inputOptions: FinalRequestOptions, { retryCount = 0 }: { retryCount?: number } = {}, - ): { req: RequestInit; url: string; timeout: number } { + ): Promise<{ req: RequestInit; url: string; timeout: number }> { const options = { ...inputOptions }; const { method, path, query, defaultBaseURL, headers: headers = {} } = options; @@ -450,7 +450,9 @@ export abstract class APIClient { await this.prepareOptions(options); - const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); + const { req, url, timeout } = await this.buildRequest(options, { + retryCount: maxRetries - retriesRemaining, + }); await this.prepareRequest(req, { url, options }); diff --git a/src/index.ts b/src/index.ts index 2c714ca..47645a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,8 @@ export interface ClientOptions { * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. + * + * @unit milliseconds */ timeout?: number | undefined; diff --git a/src/version.ts b/src/version.ts index e3c1cad..f7cc165 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.16.1'; // x-release-please-version +export const VERSION = '1.27.0'; // x-release-please-version diff --git a/tests/index.test.ts b/tests/index.test.ts index 9cc28d5..55c32b2 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -26,13 +26,13 @@ describe('instantiate client', () => { apiKey: 'My API Key', }); - test('they are used in the request', () => { - const { req } = client.buildRequest({ path: '/foo', method: 'post' }); + test('they are used in the request', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post' }); expect((req.headers as Headers)['x-my-default-header']).toEqual('2'); }); - test('can ignore `undefined` and leave the default', () => { - const { req } = client.buildRequest({ + test('can ignore `undefined` and leave the default', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', headers: { 'X-My-Default-Header': undefined }, @@ -40,8 +40,8 @@ describe('instantiate client', () => { expect((req.headers as Headers)['x-my-default-header']).toEqual('2'); }); - test('can be removed with `null`', () => { - const { req } = client.buildRequest({ + test('can be removed with `null`', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', headers: { 'X-My-Default-Header': null }, @@ -233,20 +233,20 @@ describe('request building', () => { const client = new Spitch({ apiKey: 'My API Key' }); describe('Content-Length', () => { - test('handles multi-byte characters', () => { - const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: '—' } }); + test('handles multi-byte characters', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: '—' } }); expect((req.headers as Record)['content-length']).toEqual('20'); }); - test('handles standard characters', () => { - const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' } }); + test('handles standard characters', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' } }); expect((req.headers as Record)['content-length']).toEqual('22'); }); }); describe('custom headers', () => { - test('handles undefined', () => { - const { req } = client.buildRequest({ + test('handles undefined', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' },