Skip to content

Commit 1a1ff44

Browse files
authored
Merge pull request #42 from zeroentropy-ai/release-please--branches--main--changes--next--components--zeroentropy
release: 0.1.0-alpha.5
2 parents 9eba1f2 + cf8fb1f commit 1a1ff44

File tree

14 files changed

+121
-27
lines changed

14 files changed

+121
-27
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ on:
77
- 'integrated/**'
88
- 'stl-preview-head/**'
99
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
1014

1115
jobs:
1216
lint:
1317
timeout-minutes: 10
1418
name: lint
1519
runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
1621
steps:
1722
- uses: actions/checkout@v4
1823

@@ -31,6 +36,7 @@ jobs:
3136
timeout-minutes: 5
3237
name: build
3338
runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
39+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
3440
permissions:
3541
contents: read
3642
id-token: write
@@ -66,6 +72,7 @@ jobs:
6672
timeout-minutes: 10
6773
name: test
6874
runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
75+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
6976
steps:
7077
- uses: actions/checkout@v4
7178

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.4"
2+
".": "0.1.0-alpha.5"
33
}

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## 0.1.0-alpha.5 (2025-07-03)
4+
5+
Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)
6+
7+
### Features
8+
9+
* **client:** add support for endpoint-specific base URLs ([d1d1ca4](https://github.com/zeroentropy-ai/zeroentropy-node/commit/d1d1ca45010ab9488fac671571058a392ef714bf))
10+
11+
12+
### Bug Fixes
13+
14+
* **ci:** release-doctor — report correct token name ([788b21c](https://github.com/zeroentropy-ai/zeroentropy-node/commit/788b21cc597d7b5418bf7c083b754c36dd3f974b))
15+
* **client:** don't send `Content-Type` for bodyless methods ([4bb4a5a](https://github.com/zeroentropy-ai/zeroentropy-node/commit/4bb4a5a1e672951deb536029a8fb18399b7e07c5))
16+
* publish script — handle NPM errors correctly ([8a29d6f](https://github.com/zeroentropy-ai/zeroentropy-node/commit/8a29d6f7d4c8b261ffc6fbef0e06f8c802626084))
17+
18+
19+
### Chores
20+
21+
* **ci:** enable for pull requests ([2fd06f7](https://github.com/zeroentropy-ai/zeroentropy-node/commit/2fd06f79640749b62e4f12f4219491ea64563ded))
22+
* **ci:** only run for pushes and fork pull requests ([156d50f](https://github.com/zeroentropy-ai/zeroentropy-node/commit/156d50f38ab3fbbe766d1a12950c81bfa19bf80d))
23+
* **internal:** make base APIResource abstract ([b8f4193](https://github.com/zeroentropy-ai/zeroentropy-node/commit/b8f41937546e81c3fa61848998da2b7d0d9cf51f))
24+
* mention unit type in timeout docs ([0d8d06b](https://github.com/zeroentropy-ai/zeroentropy-node/commit/0d8d06bf1945f6f1bade796240bdf0535b5043cf))
25+
26+
27+
### Refactors
28+
29+
* **types:** replace Record with mapped types ([fc1894a](https://github.com/zeroentropy-ai/zeroentropy-node/commit/fc1894a426c7472145d97703ec02b485996e9710))
30+
331
## 0.1.0-alpha.4 (2025-06-04)
432

533
Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)

bin/check-release-environment

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
errors=()
44

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

99
lenErrors=${#errors[@]}

bin/publish-npm

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,35 @@ npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
77
yarn build
88
cd dist
99

10+
# Get package name and version from package.json
11+
PACKAGE_NAME="$(jq -r -e '.name' ./package.json)"
12+
VERSION="$(jq -r -e '.version' ./package.json)"
13+
1014
# Get latest version from npm
1115
#
12-
# If the package doesn't exist, yarn will return
13-
# {"type":"error","data":"Received invalid response from npm."}
14-
# where .data.version doesn't exist so LAST_VERSION will be an empty string.
15-
LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')"
16-
17-
# Get current version from package.json
18-
VERSION="$(node -p "require('./package.json').version")"
16+
# If the package doesn't exist, npm will return:
17+
# {
18+
# "error": {
19+
# "code": "E404",
20+
# "summary": "Unpublished on 2025-06-05T09:54:53.528Z",
21+
# "detail": "'the_package' is not in this registry..."
22+
# }
23+
# }
24+
NPM_INFO="$(npm view "$PACKAGE_NAME" version --json 2>/dev/null || true)"
25+
26+
# Check if we got an E404 error
27+
if echo "$NPM_INFO" | jq -e '.error.code == "E404"' > /dev/null 2>&1; then
28+
# Package doesn't exist yet, no last version
29+
LAST_VERSION=""
30+
elif echo "$NPM_INFO" | jq -e '.error' > /dev/null 2>&1; then
31+
# Report other errors
32+
echo "ERROR: npm returned unexpected data:"
33+
echo "$NPM_INFO"
34+
exit 1
35+
else
36+
# Success - get the version
37+
LAST_VERSION=$(echo "$NPM_INFO" | jq -r '.') # strip quotes
38+
fi
1939

2040
# Check if current version is pre-release (e.g. alpha / beta / rc)
2141
CURRENT_IS_PRERELEASE=false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zeroentropy",
3-
"version": "0.1.0-alpha.4",
3+
"version": "0.1.0-alpha.5",
44
"description": "The official TypeScript library for the ZeroEntropy API",
55
"author": "ZeroEntropy <founders@zeroentropy.dev>",
66
"types": "dist/index.d.ts",

scripts/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
node scripts/utils/make-dist-package-json.cjs > dist/package.json
2929

3030
# build to .js/.mjs/.d.ts files
31-
npm exec tsc-multi
31+
./node_modules/.bin/tsc-multi
3232
# copy over handwritten .js/.mjs/.d.ts files
3333
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
3434
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto

src/core.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
170170

171171
export abstract class APIClient {
172172
baseURL: string;
173+
#baseURLOverridden: boolean;
173174
maxRetries: number;
174175
timeout: number;
175176
httpAgent: Agent | undefined;
@@ -179,18 +180,21 @@ export abstract class APIClient {
179180

180181
constructor({
181182
baseURL,
183+
baseURLOverridden,
182184
maxRetries = 2,
183185
timeout = 60000, // 1 minute
184186
httpAgent,
185187
fetch: overriddenFetch,
186188
}: {
187189
baseURL: string;
190+
baseURLOverridden: boolean;
188191
maxRetries?: number | undefined;
189192
timeout: number | undefined;
190193
httpAgent: Agent | undefined;
191194
fetch: Fetch | undefined;
192195
}) {
193196
this.baseURL = baseURL;
197+
this.#baseURLOverridden = baseURLOverridden;
194198
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
195199
this.timeout = validatePositiveInteger('timeout', timeout);
196200
this.httpAgent = httpAgent;
@@ -213,7 +217,7 @@ export abstract class APIClient {
213217
protected defaultHeaders(opts: FinalRequestOptions): Headers {
214218
return {
215219
Accept: 'application/json',
216-
'Content-Type': 'application/json',
220+
...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),
217221
'User-Agent': this.getUserAgent(),
218222
...getPlatformHeaders(),
219223
...this.authHeaders(opts),
@@ -300,7 +304,7 @@ export abstract class APIClient {
300304
{ retryCount = 0 }: { retryCount?: number } = {},
301305
): { req: RequestInit; url: string; timeout: number } {
302306
const options = { ...inputOptions };
303-
const { method, path, query, headers: headers = {} } = options;
307+
const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
304308

305309
const body =
306310
ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
@@ -310,7 +314,7 @@ export abstract class APIClient {
310314
: null;
311315
const contentLength = this.calculateContentLength(body);
312316

313-
const url = this.buildURL(path!, query);
317+
const url = this.buildURL(path!, query, defaultBaseURL);
314318
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
315319
options.timeout = options.timeout ?? this.timeout;
316320
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
@@ -503,11 +507,12 @@ export abstract class APIClient {
503507
return new PagePromise<PageClass, Item>(this, request, Page);
504508
}
505509

506-
buildURL<Req>(path: string, query: Req | null | undefined): string {
510+
buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
511+
const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
507512
const url =
508513
isAbsoluteURL(path) ?
509514
new URL(path)
510-
: new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
515+
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
511516

512517
const defaultQuery = this.defaultQuery();
513518
if (!isEmptyObj(defaultQuery)) {
@@ -792,6 +797,7 @@ export type RequestOptions<
792797
query?: Req | undefined;
793798
body?: Req | null | undefined;
794799
headers?: Headers | undefined;
800+
defaultBaseURL?: string | undefined;
795801

796802
maxRetries?: number;
797803
stream?: boolean | undefined;
@@ -813,6 +819,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
813819
query: true,
814820
body: true,
815821
headers: true,
822+
defaultBaseURL: true,
816823

817824
maxRetries: true,
818825
stream: true,

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export interface ClientOptions {
6464
*
6565
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
6666
* much longer than this timeout before the promise succeeds or fails.
67+
*
68+
* @unit milliseconds
6769
*/
6870
timeout?: number | undefined;
6971

@@ -147,6 +149,7 @@ export class ZeroEntropy extends Core.APIClient {
147149

148150
super({
149151
baseURL: options.baseURL!,
152+
baseURLOverridden: baseURL ? baseURL !== 'https://api.zeroentropy.dev/v1' : false,
150153
timeout: options.timeout ?? 60000 /* 1 minute */,
151154
httpAgent: options.httpAgent,
152155
maxRetries: options.maxRetries,
@@ -165,6 +168,13 @@ export class ZeroEntropy extends Core.APIClient {
165168
queries: API.Queries = new API.Queries(this);
166169
parsers: API.Parsers = new API.Parsers(this);
167170

171+
/**
172+
* Check whether the base URL is set to its default.
173+
*/
174+
#baseURLOverridden(): boolean {
175+
return this.baseURL !== 'https://api.zeroentropy.dev/v1';
176+
}
177+
168178
protected override defaultQuery(): Core.DefaultQuery | undefined {
169179
return this._options.defaultQuery;
170180
}

src/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type { ZeroEntropy } from './index';
44

5-
export class APIResource {
5+
export abstract class APIResource {
66
protected _client: ZeroEntropy;
77

88
constructor(client: ZeroEntropy) {

0 commit comments

Comments
 (0)