Skip to content

release: 0.1.0-alpha.9 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/benchify-typescript' && '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 @@ -31,6 +36,7 @@ jobs:
timeout-minutes: 5
name: build
runs-on: ${{ github.repository == 'stainless-sdks/benchify-typescript' && '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 @@ -66,6 +72,7 @@ jobs:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/benchify-typescript' && '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
32 changes: 0 additions & 32 deletions .github/workflows/publish-npm.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
NPM_TOKEN: ${{ secrets.BENCHIFY_NPM_TOKEN || secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.8"
".": "0.1.0-alpha.9"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 4
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/benchify%2Fbenchify-50586df1da3b10628a116e0fb715d8532b42770894cae61457bb0f3adda09eaa.yml
openapi_spec_hash: 294fef3e39aad6cc556a384c29338209
config_hash: 2afb88bbbb00432985b2ddef3606e31f
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/benchify%2Fbenchify-95bca5e6605b10dd772e9c4f427f42906ef3fc4896766c4b7bc56c77115daaf5.yml
openapi_spec_hash: 03dcf2ae632242d1ca3bcc703394126c
config_hash: ef420532aaed7b0fa0a90bafe7fe30b4
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 0.1.0-alpha.9 (2025-06-28)

Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/Benchify/benchify-sdk/compare/v0.1.0-alpha.8...v0.1.0-alpha.9)

### Features

* **api:** update via SDK Studio ([d1d5ef2](https://github.com/Benchify/benchify-sdk/commit/d1d5ef2b542598d72e66797bcbba13a133c05eb1))
* **api:** update via SDK Studio ([51be479](https://github.com/Benchify/benchify-sdk/commit/51be479c14d5d017535b86e80bfda76c4d5ccec5))
* **client:** add support for endpoint-specific base URLs ([820aefe](https://github.com/Benchify/benchify-sdk/commit/820aefe43a5dd6eac6964c05a1fa5a9556a9c635))


### Bug Fixes

* **client:** explicitly copy fetch in withOptions ([7d8d7f5](https://github.com/Benchify/benchify-sdk/commit/7d8d7f5bf972fc819a1142c120660a5e335a0529))
* **client:** get fetchOptions type more reliably ([305cb10](https://github.com/Benchify/benchify-sdk/commit/305cb104da21d9a20e3046f78456b1d8a54f9fe8))
* publish script — handle NPM errors correctly ([10a431e](https://github.com/Benchify/benchify-sdk/commit/10a431e87c0d0fff4929fb718c644b6155d366df))


### Chores

* **ci:** enable for pull requests ([8436707](https://github.com/Benchify/benchify-sdk/commit/8436707738d155cd4c68cd09d0d8ad0e9473cbf8))
* **ci:** only run for pushes and fork pull requests ([5ea291f](https://github.com/Benchify/benchify-sdk/commit/5ea291f95f5cce884512696c74e654d29e12e69d))
* **client:** refactor imports ([9989b61](https://github.com/Benchify/benchify-sdk/commit/9989b611583237731492db178c98ead86616619c))
* **internal:** add pure annotations, make base APIResource abstract ([108304c](https://github.com/Benchify/benchify-sdk/commit/108304c7d840656dd01abe1736c7b53d081ed351))
* **readme:** update badges ([98d0091](https://github.com/Benchify/benchify-sdk/commit/98d009114a18882cd354e0fd0f3c9cc675405d60))
* **readme:** use better example snippet for undocumented params ([a61a28b](https://github.com/Benchify/benchify-sdk/commit/a61a28bf5f6139e43d755abca442426c53adbb5c))
* update SDK settings ([3884f3d](https://github.com/Benchify/benchify-sdk/commit/3884f3d9a119ed45ca54d1cb0aeba8823aa843de))

## 0.1.0-alpha.8 (2025-06-13)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/Benchify/benchify-sdk/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)
Expand Down
14 changes: 0 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,3 @@ To format and fix all lint issues automatically:
```sh
$ yarn fix
```

## Publishing and releases

Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
the changes aren't made through the automated pipeline, you may want to make releases manually.

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/Benchify/benchify-sdk/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
the environment.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Benchify TypeScript API Library

[![NPM version](https://img.shields.io/npm/v/benchify.svg)](https://npmjs.org/package/benchify) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/benchify)
[![NPM version](<https://img.shields.io/npm/v/benchify.svg?label=npm%20(stable)>)](https://npmjs.org/package/benchify) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/benchify)

This library provides convenient access to the Benchify REST API from server-side TypeScript or JavaScript.

Expand All @@ -11,9 +11,12 @@ It is generated with [Stainless](https://www.stainless.com/).
## Installation

```sh
npm install benchify
npm install git+ssh://[email protected]:Benchify/benchify-sdk.git
```

> [!NOTE]
> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npm install benchify`

## Usage

The full API of this library can be found in [api.md](api.md).
Expand Down Expand Up @@ -284,9 +287,8 @@ parameter. This library doesn't validate at runtime that the request matches the
send will be sent as-is.

```ts
client.foo.create({
foo: 'my_param',
bar: 12,
client.fixer.run({
// ...
// @ts-expect-error baz is not yet public
baz: 'undocumented option',
});
Expand Down
4 changes: 0 additions & 4 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

errors=()

if [ -z "${NPM_TOKEN}" ]; then
errors+=("The BENCHIFY_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
Expand Down
32 changes: 26 additions & 6 deletions bin/publish-npm
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,35 @@ npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
yarn build
cd dist

# Get package name and version from package.json
PACKAGE_NAME="$(jq -r -e '.name' ./package.json)"
VERSION="$(jq -r -e '.version' ./package.json)"

# Get latest version from npm
#
# If the package doesn't exist, yarn will return
# {"type":"error","data":"Received invalid response from npm."}
# where .data.version doesn't exist so LAST_VERSION will be an empty string.
LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')"
# If the package doesn't exist, npm will return:
# {
# "error": {
# "code": "E404",
# "summary": "Unpublished on 2025-06-05T09:54:53.528Z",
# "detail": "'the_package' is not in this registry..."
# }
# }
NPM_INFO="$(npm view "$PACKAGE_NAME" version --json 2>/dev/null || true)"

# Get current version from package.json
VERSION="$(node -p "require('./package.json').version")"
# Check if we got an E404 error
if echo "$NPM_INFO" | jq -e '.error.code == "E404"' > /dev/null 2>&1; then
# Package doesn't exist yet, no last version
LAST_VERSION=""
elif echo "$NPM_INFO" | jq -e '.error' > /dev/null 2>&1; then
# Report other errors
echo "ERROR: npm returned unexpected data:"
echo "$NPM_INFO"
exit 1
else
# Success - get the version
LAST_VERSION=$(echo "$NPM_INFO" | jq -r '.') # strip quotes
fi

# Check if current version is pre-release (e.g. alpha / beta / rc)
CURRENT_IS_PRERELEASE=false
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "benchify",
"version": "0.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"description": "The official TypeScript library for the Benchify API",
"author": "Benchify <>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -42,7 +42,7 @@
"publint": "^0.2.12",
"ts-jest": "^29.1.0",
"ts-node": "^10.5.0",
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz",
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz",
"tsconfig-paths": "^4.0.0",
"typescript": "5.8.3"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fi
node scripts/utils/make-dist-package-json.cjs > dist/package.json

# build to .js/.mjs/.d.ts files
npm exec tsc-multi
./node_modules/.bin/tsc-multi
# we need to patch index.js so that `new module.exports()` works for cjs backwards
# compat. No way to get that from index.ts because it would cause compile errors
# when building .mjs
Expand Down
36 changes: 27 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestIni
import { uuid4 } from './internal/utils/uuid';
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values';
import { sleep } from './internal/utils/sleep';
import { type Logger, type LogLevel, parseLogLevel } from './internal/utils/log';
export type { Logger, LogLevel } from './internal/utils/log';
import { castToError, isAbortError } from './internal/errors';
import type { APIResponseProps } from './internal/parse';
Expand All @@ -17,9 +16,6 @@ import * as Errors from './core/error';
import * as Uploads from './core/uploads';
import * as API from './resources/index';
import { APIPromise } from './core/api-promise';
import { type Fetch } from './internal/builtin-types';
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
import {
DiagnosticRunParams,
DiagnosticRunResponse,
Expand All @@ -37,8 +33,17 @@ import {
ValidateSqlValidateParams,
ValidateSqlValidateResponse,
} from './resources/validate-sql';
import { type Fetch } from './internal/builtin-types';
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
import { readEnv } from './internal/utils/env';
import { formatRequestDetails, loggerFor } from './internal/utils/log';
import {
type LogLevel,
type Logger,
formatRequestDetails,
loggerFor,
parseLogLevel,
} from './internal/utils/log';
import { isEmptyObj } from './internal/utils/values';

export interface ClientOptions {
Expand Down Expand Up @@ -192,12 +197,20 @@ export class Benchify {
timeout: this.timeout,
logger: this.logger,
logLevel: this.logLevel,
fetch: this.fetch,
fetchOptions: this.fetchOptions,
apiKey: this.apiKey,
...options,
});
}

/**
* Check whether the base URL is set to its default.
*/
#baseURLOverridden(): boolean {
return this.baseURL !== 'https://api.benchify.com';
}

protected defaultQuery(): Record<string, string | undefined> | undefined {
return this._options.defaultQuery;
}
Expand Down Expand Up @@ -247,11 +260,16 @@ export class Benchify {
return Errors.APIError.generate(status, error, message, headers);
}

buildURL(path: string, query: Record<string, unknown> | null | undefined): string {
buildURL(
path: string,
query: Record<string, unknown> | null | undefined,
defaultBaseURL?: string | undefined,
): string {
const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
const url =
isAbsoluteURL(path) ?
new URL(path)
: new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));

const defaultQuery = this.defaultQuery();
if (!isEmptyObj(defaultQuery)) {
Expand Down Expand Up @@ -592,9 +610,9 @@ export class Benchify {
{ retryCount = 0 }: { retryCount?: number } = {},
): { req: FinalizedRequestInit; url: string; timeout: number } {
const options = { ...inputOptions };
const { method, path, query } = options;
const { method, path, query, defaultBaseURL } = options;

const url = this.buildURL(path!, query as Record<string, unknown>);
const url = this.buildURL(path!, query as Record<string, unknown>, defaultBaseURL);
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
options.timeout = options.timeout ?? this.timeout;
const { bodyHeaders, body } = this.buildBody({ options });
Expand Down
2 changes: 1 addition & 1 deletion src/core/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import type { Benchify } from '../client';

export class APIResource {
export abstract class APIResource {
protected _client: Benchify;

constructor(client: Benchify) {
Expand Down
10 changes: 5 additions & 5 deletions src/internal/headers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { isReadonlyArray } from './utils/values';

type HeaderValue = string | undefined | null;
export type HeadersLike =
| Headers
Expand All @@ -9,7 +11,7 @@ export type HeadersLike =
| null
| NullableHeaders;

const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');

/**
* @internal
Expand All @@ -25,8 +27,6 @@ export type NullableHeaders = {
nulls: Set<string>;
};

const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];

function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
if (!headers) return;

Expand All @@ -43,7 +43,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
let iter: Iterable<readonly (HeaderValue | readonly HeaderValue[])[]>;
if (headers instanceof Headers) {
iter = headers.entries();
} else if (isArray(headers)) {
} else if (isReadonlyArray(headers)) {
iter = headers;
} else {
shouldClear = true;
Expand All @@ -52,7 +52,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
for (let row of iter) {
const name = row[0];
if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
const values = isArray(row[1]) ? row[1] : [row[1]];
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
let didClear = false;
for (const value of values) {
if (value === undefined) continue;
Expand Down
1 change: 1 addition & 0 deletions src/internal/request-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type RequestOptions = {
fetchOptions?: MergedRequestInit;
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;
defaultBaseURL?: string | undefined;

__binaryResponse?: boolean | undefined;
};
Expand Down
Loading