Skip to content

Commit 4d40acc

Browse files
release: 1.7.0 (#129)
* fix: publish script — handle NPM errors correctly * chore(internal): make base APIResource abstract * feat(client): add support for endpoint-specific base URLs * chore(ci): enable for pull requests * feat: allow optional parameters to be nullable (#130) * release: 1.7.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Sergio Serrano <[email protected]>
1 parent ea49cde commit 4d40acc

File tree

12 files changed

+98
-17
lines changed

12 files changed

+98
-17
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ 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:

.release-please-manifest.json

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

CHANGELOG.md

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

3+
## 1.7.0 (2025-06-17)
4+
5+
Full Changelog: [v1.6.1...v1.7.0](https://github.com/ArcadeAI/arcade-js/compare/v1.6.1...v1.7.0)
6+
7+
### Features
8+
9+
* allow optional parameters to be nullable ([#130](https://github.com/ArcadeAI/arcade-js/issues/130)) ([25b7585](https://github.com/ArcadeAI/arcade-js/commit/25b7585fc4fd78765ac88355fa7d2fb5aedb7e3b))
10+
* **client:** add support for endpoint-specific base URLs ([179f047](https://github.com/ArcadeAI/arcade-js/commit/179f047e5ad5f382fc6761bd47595469e5dc717f))
11+
12+
13+
### Bug Fixes
14+
15+
* publish script — handle NPM errors correctly ([a6ca79b](https://github.com/ArcadeAI/arcade-js/commit/a6ca79b7df5c7a702df035b250d6228ef64bf5b7))
16+
17+
18+
### Chores
19+
20+
* **ci:** enable for pull requests ([710a188](https://github.com/ArcadeAI/arcade-js/commit/710a188d531ead70247a9a1c3e5cb4c81016c77b))
21+
* **internal:** make base APIResource abstract ([3c03f6b](https://github.com/ArcadeAI/arcade-js/commit/3c03f6bd10e84064d3e5665b1bc432875a821e5a))
22+
323
## 1.6.1 (2025-06-04)
424

525
Full Changelog: [v1.6.0...v1.6.1](https://github.com/ArcadeAI/arcade-js/compare/v1.6.0...v1.6.1)

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": "@arcadeai/arcadejs",
3-
"version": "1.6.1",
3+
"version": "1.7.0",
44
"description": "The official TypeScript library for the Arcade API",
55
"author": "Arcade <[email protected]>",
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: 11 additions & 4 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;
@@ -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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export class Arcade extends Core.APIClient {
141141

142142
super({
143143
baseURL: options.baseURL!,
144+
baseURLOverridden: baseURL ? baseURL !== 'https://api.arcade.dev' : false,
144145
timeout: options.timeout ?? 60000 /* 1 minute */,
145146
httpAgent: options.httpAgent,
146147
maxRetries: options.maxRetries,
@@ -159,6 +160,13 @@ export class Arcade extends Core.APIClient {
159160
tools: API.Tools = new API.Tools(this);
160161
workers: API.Workers = new API.Workers(this);
161162

163+
/**
164+
* Check whether the base URL is set to its default.
165+
*/
166+
#baseURLOverridden(): boolean {
167+
return this.baseURL !== 'https://api.arcade.dev';
168+
}
169+
162170
protected override defaultQuery(): Core.DefaultQuery | undefined {
163171
return this._options.defaultQuery;
164172
}

src/lib/zod/zod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function convertParametersToZodSchema(parameters: ToolDefinition.Input):
3737
let zodType = convertValueSchemaToZod(value_schema);
3838

3939
if (!required) {
40-
zodType = zodType.optional();
40+
zodType = zodType.nullable().optional();
4141
}
4242

4343
schemaObj[name] = zodType;

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 { Arcade } from './index';
44

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

88
constructor(client: Arcade) {

0 commit comments

Comments
 (0)