Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58857c7
chore: add hash of OpenAPI spec/config inputs to .stats.yml
stainless-app[bot] Mar 27, 2025
4c2865b
chore(client): move misc public files to new `core/` directory, depre…
stainless-app[bot] Mar 27, 2025
cb150ed
fix(client): send `X-Stainless-Timeout` in seconds (#104)
stainless-app[bot] Apr 3, 2025
f36481f
chore(internal): add aliases for Record and Array (#105)
stainless-app[bot] Apr 3, 2025
1c08b28
fix(api): improve type resolution when importing as a package (#106)
stainless-app[bot] Apr 4, 2025
dd850ba
fix(mcp): remove unused tools.ts (#107)
stainless-app[bot] Apr 5, 2025
5e49ef8
fix(client): send all configured auth headers (#108)
stainless-app[bot] Apr 8, 2025
d38a26d
chore(internal): upload builds and expand CI branch coverage
stainless-app[bot] Apr 10, 2025
48b390e
chore(internal): improve node 18 shims
stainless-app[bot] Apr 10, 2025
7914c63
chore(internal): reduce CI branch coverage
stainless-app[bot] Apr 10, 2025
f302f19
fix(internal): fix file uploads in node 18 jest
stainless-app[bot] Apr 11, 2025
c891000
chore(client): minor internal fixes
stainless-app[bot] Apr 15, 2025
48a0980
chore(perf): faster base64 decoding
stainless-app[bot] Apr 23, 2025
3dcdc68
chore(ci): add timeout thresholds for CI jobs
stainless-app[bot] Apr 23, 2025
b56b85d
chore(internal): codegen related update
stainless-app[bot] Apr 24, 2025
748b336
chore(ci): only use depot for staging repos
stainless-app[bot] Apr 24, 2025
aa0e8a1
chore(internal): refactor utils
stainless-app[bot] Apr 29, 2025
6fd06d4
docs(readme): fix typo
stainless-app[bot] May 1, 2025
f4d6644
chore(internal): codegen related update
stainless-app[bot] May 3, 2025
f54f0a0
chore(internal): share typescript helpers
stainless-app[bot] May 3, 2025
55d1f93
feat(client): add withOptions helper
stainless-app[bot] May 7, 2025
4e66fce
chore(client): drop support for EOL node versions
stainless-app[bot] May 7, 2025
e4b5cec
fix(client): always overwrite when merging headers
stainless-app[bot] May 10, 2025
ecf50ef
chore(package): remove engines
stainless-app[bot] May 13, 2025
f9403dc
release: 0.1.0-alpha.19
stainless-app[bot] May 13, 2025
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
4 changes: 1 addition & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"postCreateCommand": "yarn install",
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode"
]
"extensions": ["esbenp.prettier-vscode"]
}
}
}
50 changes: 33 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
- next
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ubuntu-latest


runs-on: ${{ github.repository == 'stainless-sdks/stainless-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Bootstrap
run: ./scripts/bootstrap
Expand All @@ -29,34 +28,51 @@ jobs:
run: ./scripts/lint

build:
timeout-minutes: 5
name: build
runs-on: ubuntu-latest


runs-on: ${{ github.repository == 'stainless-sdks/stainless-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Bootstrap
run: ./scripts/bootstrap

- name: Check build
run: ./scripts/build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/stainless-typescript'
id: github-oidc
uses: actions/github-script@v6
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/stainless-typescript'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh
test:
timeout-minutes: 10
name: test
runs-on: ubuntu-latest

runs-on: ${{ github.repository == 'stainless-sdks/stainless-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Bootstrap
run: ./scripts/bootstrap
Expand Down
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:

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.18"
".": "0.1.0-alpha.19"
}
2 changes: 2 additions & 0 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-efd1aba15824e770232eda85427ae9f27371fdf1e1b3dd734dcf70bef34815a8.yml
openapi_spec_hash: 0013a0122903f1ad80195e5c5985cd14
config_hash: ff412e7c1a43c133e4b3547f6b56e654
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## 0.1.0-alpha.19 (2025-05-13)

Full Changelog: [v0.1.0-alpha.18...v0.1.0-alpha.19](https://github.com/stainless-api/builds-node-api/compare/v0.1.0-alpha.18...v0.1.0-alpha.19)

### Features

* **client:** add withOptions helper ([55d1f93](https://github.com/stainless-api/builds-node-api/commit/55d1f9391a388db243b24241ab4caafee8a3eec7))


### Bug Fixes

* **api:** improve type resolution when importing as a package ([#106](https://github.com/stainless-api/builds-node-api/issues/106)) ([1c08b28](https://github.com/stainless-api/builds-node-api/commit/1c08b28b534391c7bd5e9d845f31f670c70b0fc4))
* **client:** always overwrite when merging headers ([e4b5cec](https://github.com/stainless-api/builds-node-api/commit/e4b5cec96d57c3c911df289ff6a5029bae7a279f))
* **client:** send `X-Stainless-Timeout` in seconds ([#104](https://github.com/stainless-api/builds-node-api/issues/104)) ([cb150ed](https://github.com/stainless-api/builds-node-api/commit/cb150edfab9daeb369dbe9de0d4e68ae79e71b03))
* **client:** send all configured auth headers ([#108](https://github.com/stainless-api/builds-node-api/issues/108)) ([5e49ef8](https://github.com/stainless-api/builds-node-api/commit/5e49ef8a6f76d97b03d7fd2f8a1e7255fb22f89d))
* **internal:** fix file uploads in node 18 jest ([f302f19](https://github.com/stainless-api/builds-node-api/commit/f302f1916a5980a7b7f1e2849ba86772bfd9c3d1))
* **mcp:** remove unused tools.ts ([#107](https://github.com/stainless-api/builds-node-api/issues/107)) ([dd850ba](https://github.com/stainless-api/builds-node-api/commit/dd850ba4b63fa1ad86c06d8e7a03d0327a695d23))


### Chores

* add hash of OpenAPI spec/config inputs to .stats.yml ([58857c7](https://github.com/stainless-api/builds-node-api/commit/58857c782d1db0e4e74e2aef34693c38e32c6e19))
* **ci:** add timeout thresholds for CI jobs ([3dcdc68](https://github.com/stainless-api/builds-node-api/commit/3dcdc6878176fe1a8b24853907f2b0303ccfa8ad))
* **ci:** only use depot for staging repos ([748b336](https://github.com/stainless-api/builds-node-api/commit/748b336e9f60c8dc82c9b95637044f081a97b7a8))
* **client:** drop support for EOL node versions ([4e66fce](https://github.com/stainless-api/builds-node-api/commit/4e66fce96130c8510e6c7ff3dcdc4268b196ca61))
* **client:** minor internal fixes ([c891000](https://github.com/stainless-api/builds-node-api/commit/c8910005be2e8a3b894b8582a9ddacd2480fe1fa))
* **client:** move misc public files to new `core/` directory, deprecate old paths ([#103](https://github.com/stainless-api/builds-node-api/issues/103)) ([4c2865b](https://github.com/stainless-api/builds-node-api/commit/4c2865bb2bf8274adeea2154fca53df79ae8f995))
* **internal:** add aliases for Record and Array ([#105](https://github.com/stainless-api/builds-node-api/issues/105)) ([f36481f](https://github.com/stainless-api/builds-node-api/commit/f36481f56128473ab5dbc454ac16261d7ea0b575))
* **internal:** codegen related update ([f4d6644](https://github.com/stainless-api/builds-node-api/commit/f4d6644c95aa3b652c445a9b326938926a831789))
* **internal:** codegen related update ([b56b85d](https://github.com/stainless-api/builds-node-api/commit/b56b85d5c5207a7c68bb435668e2542203675885))
* **internal:** improve node 18 shims ([48b390e](https://github.com/stainless-api/builds-node-api/commit/48b390ead1716cda31184ee904b496e28a05db42))
* **internal:** reduce CI branch coverage ([7914c63](https://github.com/stainless-api/builds-node-api/commit/7914c6361c7d408568972f3fbcc6e4e9a2e68219))
* **internal:** refactor utils ([aa0e8a1](https://github.com/stainless-api/builds-node-api/commit/aa0e8a18133781ffaa6edc98a1d39a9ccd4e6e6a))
* **internal:** share typescript helpers ([f54f0a0](https://github.com/stainless-api/builds-node-api/commit/f54f0a0a2cbc303b1fbbecbe7a14823e9ec8c8ae))
* **internal:** upload builds and expand CI branch coverage ([d38a26d](https://github.com/stainless-api/builds-node-api/commit/d38a26dc33aeaab25a60592af5384da1c26af5c3))
* **package:** remove engines ([ecf50ef](https://github.com/stainless-api/builds-node-api/commit/ecf50ef635b909845c7ab5e33c3ef4b433de572e))
* **perf:** faster base64 decoding ([48a0980](https://github.com/stainless-api/builds-node-api/commit/48a09805e4c5fd6cac5d1b119083c21a47684ad3))


### Documentation

* **readme:** fix typo ([6fd06d4](https://github.com/stainless-api/builds-node-api/commit/6fd06d40ea59a5cedb749a3f99bf6120abaeee13))

## 0.1.0-alpha.18 (2025-03-20)

Full Changelog: [v0.1.0-alpha.17...v0.1.0-alpha.18](https://github.com/stainless-api/builds-node-api/compare/v0.1.0-alpha.17...v0.1.0-alpha.18)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function main() {
main();
```

Error codes are as followed:
Error codes are as follows:

| Status Code | Error Type |
| ----------- | -------------------------- |
Expand Down Expand Up @@ -398,7 +398,7 @@ TypeScript >= 4.9 is supported.
The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stainless",
"version": "0.1.0-alpha.18",
"version": "0.1.0-alpha.19",
"description": "The official TypeScript library for the Stainless API",
"author": "Stainless <[email protected]>",
"types": "dist/index.d.ts",
Expand All @@ -17,7 +17,7 @@
"test": "./scripts/test",
"build": "./scripts/build",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"format": "./scripts/format",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build && ./scripts/utils/git-swap.sh; fi",
"tsn": "ts-node -r tsconfig-paths/register",
"lint": "./scripts/lint",
Expand All @@ -30,9 +30,9 @@
"@swc/jest": "^0.2.29",
"@types/jest": "^29.4.0",
"@types/node": "^20.17.6",
"typescript-eslint": "^8.24.0",
"@typescript-eslint/eslint-plugin": "^8.24.0",
"@typescript-eslint/parser": "^8.24.0",
"typescript-eslint": "8.31.1",
"@typescript-eslint/eslint-plugin": "8.31.1",
"@typescript-eslint/parser": "8.31.1",
"eslint": "^9.20.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-unused-imports": "^4.1.4",
Expand All @@ -42,9 +42,9 @@
"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.3/tsc-multi.tgz",
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.8.2"
"typescript": "5.8.3"
},
"resolutions": {
"synckit": "0.8.8"
Expand Down
5 changes: 1 addition & 4 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,5 @@
}
],
"release-type": "node",
"extra-files": [
"src/version.ts",
"README.md"
]
"extra-files": ["src/version.ts", "README.md"]
}
8 changes: 5 additions & 3 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ for file in LICENSE CHANGELOG.md; do
if [ -e "${file}" ]; then cp "${file}" dist; fi
done
if [ -e "bin/cli" ]; then
mkdir dist/bin
mkdir -p dist/bin
cp -p "bin/cli" dist/bin/;
fi
if [ -e "bin/migration-config.json" ]; then
mkdir -p dist/bin
cp -p "bin/migration-config.json" dist/bin/;
fi
# this converts the export map paths for the dist directory
# and does a few other minor things
node scripts/utils/make-dist-package-json.cjs > dist/package.json
Expand All @@ -35,8 +39,6 @@ node scripts/utils/fix-index-exports.cjs
cp tsconfig.dist-src.json dist/src/tsconfig.json
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.ts
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.mts
mkdir -p dist/internal/shims
cp src/internal/shims/*.{mjs,js,d.ts,d.mts} dist/internal/shims

node scripts/utils/postprocess-files.cjs

Expand Down
4 changes: 4 additions & 0 deletions scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ cd "$(dirname "$0")/.."

echo "==> Running eslint --fix"
./node_modules/.bin/eslint --fix .

echo "==> Running prettier --write"
# format things eslint didn't
./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
25 changes: 25 additions & 0 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -exuo pipefail

RESPONSE=$(curl -X POST "$URL" \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json")

SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url')

if [[ "$SIGNED_URL" == "null" ]]; then
echo -e "\033[31mFailed to get signed URL.\033[0m"
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
echo -e "\033[32mInstallation: npm install 'https://pkg.stainless.com/s/stainless-typescript/$SHA'\033[0m"
else
echo -e "\033[31mFailed to upload artifact.\033[0m"
exit 1
fi
94 changes: 2 additions & 92 deletions src/api-promise.ts
Original file line number Diff line number Diff line change
@@ -1,92 +1,2 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

import { type PromiseOrValue } from './internal/types';
import { APIResponseProps, defaultParseResponse } from './internal/parse';

/**
* A subclass of `Promise` providing additional helper methods
* for interacting with the SDK.
*/
export class APIPromise<T> extends Promise<T> {
private parsedPromise: Promise<T> | undefined;
#client: Stainless;

constructor(
client: Stainless,
private responsePromise: Promise<APIResponseProps>,
private parseResponse: (
client: Stainless,
props: APIResponseProps,
) => PromiseOrValue<T> = defaultParseResponse,
) {
super((resolve) => {
// this is maybe a bit weird but this has to be a no-op to not implicitly
// parse the response body; instead .then, .catch, .finally are overridden
// to parse the response
resolve(null as any);
});
this.#client = client;
}

_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U> {
return new APIPromise(this.#client, this.responsePromise, async (client, props) =>
transform(await this.parseResponse(client, props), props),
);
}

/**
* Gets the raw `Response` instance instead of parsing the response
* data.
*
* If you want to parse the response body but still get the `Response`
* instance, you can use {@link withResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
asResponse(): Promise<Response> {
return this.responsePromise.then((p) => p.response);
}

/**
* Gets the parsed response data and the raw `Response` instance.
*
* If you just want to get the raw `Response` instance without parsing it,
* you can use {@link asResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
async withResponse(): Promise<{ data: T; response: Response }> {
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
return { data, response };
}

private parse(): Promise<T> {
if (!this.parsedPromise) {
this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(this.#client, data));
}
return this.parsedPromise;
}

override then<TResult1 = T, TResult2 = never>(
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
): Promise<TResult1 | TResult2> {
return this.parse().then(onfulfilled, onrejected);
}

override catch<TResult = never>(
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
): Promise<T | TResult> {
return this.parse().catch(onrejected);
}

override finally(onfinally?: (() => void) | undefined | null): Promise<T> {
return this.parse().finally(onfinally);
}
}
/** @deprecated Import from ./core/api-promise instead */
export * from './core/api-promise';
Loading