Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.16.1"
".": "1.27.0"
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <dev@spitch.app>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -58,10 +58,6 @@
"./shims/web.js",
"./shims/web.mjs"
],
"imports": {
"spitch": ".",
"spitch/*": "./src/*"
},
"exports": {
"./_shims/auto/*": {
"deno": {
Expand Down
10 changes: 6 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -299,10 +299,10 @@ export abstract class APIClient {
return null;
}

buildRequest<Req>(
async buildRequest<Req>(
inputOptions: FinalRequestOptions<Req>,
{ 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;

Expand Down Expand Up @@ -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 });

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.16.1'; // x-release-please-version
export const VERSION = '1.27.0'; // x-release-please-version
24 changes: 12 additions & 12 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ 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 },
});
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 },
Expand Down Expand Up @@ -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<string, string>)['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<string, string>)['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' },
Expand Down
Loading