Skip to content

Commit 5990b47

Browse files
feat(api): manual updates (#63)
1 parent 1b14893 commit 5990b47

File tree

20 files changed

+123
-123
lines changed

20 files changed

+123
-123
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2025 Stainless 2
189+
Copyright 2025 Stainless
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Stainless 2 TypeScript API Library
1+
# Stainless TypeScript API Library
22

33
[![NPM version](https://img.shields.io/npm/v/stainless.svg)](https://npmjs.org/package/stainless) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/stainless)
44

5-
This library provides convenient access to the Stainless 2 REST API from server-side TypeScript or JavaScript.
5+
This library provides convenient access to the Stainless REST API from server-side TypeScript or JavaScript.
66

77
The REST API documentation can be found on [app.stainlessapi.com](https://app.stainlessapi.com/docs). The full API of this library can be found in [api.md](api.md).
88

@@ -23,9 +23,9 @@ The full API of this library can be found in [api.md](api.md).
2323

2424
<!-- prettier-ignore -->
2525
```js
26-
import Stainless2 from 'stainless';
26+
import Stainless from 'stainless';
2727

28-
const client = new Stainless2({
28+
const client = new Stainless({
2929
apiKey: process.env['API_KEY'], // This is the default and can be omitted
3030
});
3131

@@ -44,15 +44,15 @@ This library includes TypeScript definitions for all request params and response
4444

4545
<!-- prettier-ignore -->
4646
```ts
47-
import Stainless2 from 'stainless';
47+
import Stainless from 'stainless';
4848

49-
const client = new Stainless2({
49+
const client = new Stainless({
5050
apiKey: process.env['API_KEY'], // This is the default and can be omitted
5151
});
5252

5353
async function main() {
54-
const params: Stainless2.Builds.OutputRetrieveParams = { target: 'node' };
55-
const output: Stainless2.Builds.OutputRetrieveResponse = await client.builds.outputs.retrieve(
54+
const params: Stainless.Builds.OutputRetrieveParams = { target: 'node' };
55+
const output: Stainless.Builds.OutputRetrieveResponse = await client.builds.outputs.retrieve(
5656
'bui_123',
5757
params,
5858
);
@@ -73,7 +73,7 @@ a subclass of `APIError` will be thrown:
7373
```ts
7474
async function main() {
7575
const output = await client.builds.outputs.retrieve('bui_123', { target: 'node' }).catch(async (err) => {
76-
if (err instanceof Stainless2.APIError) {
76+
if (err instanceof Stainless.APIError) {
7777
console.log(err.status); // 400
7878
console.log(err.name); // BadRequestError
7979
console.log(err.headers); // {server: 'nginx', ...}
@@ -110,7 +110,7 @@ You can use the `maxRetries` option to configure or disable this:
110110
<!-- prettier-ignore -->
111111
```js
112112
// Configure the default for all requests:
113-
const client = new Stainless2({
113+
const client = new Stainless({
114114
maxRetries: 0, // default is 2
115115
});
116116

@@ -127,7 +127,7 @@ Requests time out after 1 minute by default. You can configure this with a `time
127127
<!-- prettier-ignore -->
128128
```ts
129129
// Configure the default for all requests:
130-
const client = new Stainless2({
130+
const client = new Stainless({
131131
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
132132
});
133133

@@ -151,7 +151,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
151151

152152
<!-- prettier-ignore -->
153153
```ts
154-
const client = new Stainless2();
154+
const client = new Stainless();
155155

156156
const response = await client.builds.outputs.retrieve('bui_123', { target: 'node' }).asResponse();
157157
console.log(response.headers.get('X-My-Header'));
@@ -225,7 +225,7 @@ Or pass it to the client:
225225
```ts
226226
import fetch from 'my-fetch';
227227

228-
const client = new Stainless2({ fetch });
228+
const client = new Stainless({ fetch });
229229
```
230230

231231
### Logging and middleware
@@ -235,9 +235,9 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
235235

236236
```ts
237237
import { fetch } from 'undici'; // as one example
238-
import Stainless2 from 'stainless';
238+
import Stainless from 'stainless';
239239

240-
const client = new Stainless2({
240+
const client = new Stainless({
241241
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
242242
console.log('About to make a request', url, init);
243243
const response = await fetch(url, init);
@@ -247,17 +247,17 @@ const client = new Stainless2({
247247
});
248248
```
249249

250-
Note that if given a `STAINLESS_2_LOG=debug` environment variable, this library will log all requests and responses automatically.
250+
Note that if given a `STAINLESS_LOG=debug` environment variable, this library will log all requests and responses automatically.
251251
This is intended for debugging purposes only and may change in the future without notice.
252252

253253
### Fetch options
254254

255255
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
256256

257257
```ts
258-
import Stainless2 from 'stainless';
258+
import Stainless from 'stainless';
259259

260-
const client = new Stainless2({
260+
const client = new Stainless({
261261
fetchOptions: {
262262
// `RequestInit` options
263263
},
@@ -272,11 +272,11 @@ options to requests:
272272
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
273273

274274
```ts
275-
import Stainless2 from 'stainless';
275+
import Stainless from 'stainless';
276276
import * as undici from 'undici';
277277

278278
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
279-
const client = new Stainless2({
279+
const client = new Stainless({
280280
fetchOptions: {
281281
dispatcher: proxyAgent,
282282
},
@@ -286,9 +286,9 @@ const client = new Stainless2({
286286
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
287287

288288
```ts
289-
import Stainless2 from 'stainless';
289+
import Stainless from 'stainless';
290290

291-
const client = new Stainless2({
291+
const client = new Stainless({
292292
fetchOptions: {
293293
proxy: 'http://localhost:8888',
294294
},
@@ -298,10 +298,10 @@ const client = new Stainless2({
298298
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
299299

300300
```ts
301-
import Stainless2 from 'npm:stainless';
301+
import Stainless from 'npm:stainless';
302302

303303
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
304-
const client = new Stainless2({
304+
const client = new Stainless({
305305
fetchOptions: {
306306
client: httpClient,
307307
},

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ before making any information public.
1616
## Reporting Non-SDK Related Security Issues
1717

1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
19-
or products provided by Stainless 2 please follow the respective company's security reporting guidelines.
19+
or products provided by Stainless please follow the respective company's security reporting guidelines.
2020

21-
### Stainless 2 Terms and Policies
21+
### Stainless Terms and Policies
2222

2323
Please contact [email protected] for any questions or concerns regarding security of our services.
2424

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "stainless",
33
"version": "0.1.0-alpha.16",
4-
"description": "The official TypeScript library for the Stainless 2 API",
5-
"author": "Stainless 2 <[email protected]>",
4+
"description": "The official TypeScript library for the Stainless API",
5+
"author": "Stainless <[email protected]>",
66
"types": "dist/index.d.ts",
77
"main": "dist/index.js",
88
"type": "commonjs",

scripts/build

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

2929
# build to .js/.mjs/.d.ts files
3030
npm exec tsc-multi
31-
# we need to add exports = module.exports = Stainless2 to index.js;
31+
# we need to add exports = module.exports = Stainless to index.js;
3232
# No way to get that from index.ts because it would cause compile errors
3333
# when building .mjs
3434
node scripts/utils/fix-index-exports.cjs

src/api-promise.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { type Stainless2 } from './client';
3+
import { type Stainless } from './client';
44

55
import { type PromiseOrValue } from './internal/types';
66
import { APIResponseProps, defaultParseResponse } from './internal/parse';
@@ -11,13 +11,13 @@ import { APIResponseProps, defaultParseResponse } from './internal/parse';
1111
*/
1212
export class APIPromise<T> extends Promise<T> {
1313
private parsedPromise: Promise<T> | undefined;
14-
#client: Stainless2;
14+
#client: Stainless;
1515

1616
constructor(
17-
client: Stainless2,
17+
client: Stainless,
1818
private responsePromise: Promise<APIResponseProps>,
1919
private parseResponse: (
20-
client: Stainless2,
20+
client: Stainless,
2121
props: APIResponseProps,
2222
) => PromiseOrValue<T> = defaultParseResponse,
2323
) {

src/client.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface ClientOptions {
6565
/**
6666
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
6767
*
68-
* Defaults to process.env['STAINLESS_2_BASE_URL'].
68+
* Defaults to process.env['STAINLESS_BASE_URL'].
6969
*/
7070
baseURL?: string | null | undefined;
7171

@@ -117,7 +117,7 @@ export interface ClientOptions {
117117
/**
118118
* Set the log level.
119119
*
120-
* Defaults to process.env['STAINLESS_2_LOG'].
120+
* Defaults to process.env['STAINLESS_LOG'].
121121
*/
122122
logLevel?: LogLevel | undefined | null;
123123

@@ -132,9 +132,9 @@ export interface ClientOptions {
132132
type FinalizedRequestInit = RequestInit & { headers: Headers };
133133

134134
/**
135-
* API Client for interfacing with the Stainless 2 API.
135+
* API Client for interfacing with the Stainless API.
136136
*/
137-
export class Stainless2 {
137+
export class Stainless {
138138
apiKey: string;
139139

140140
baseURL: string;
@@ -150,10 +150,10 @@ export class Stainless2 {
150150
private _options: ClientOptions;
151151

152152
/**
153-
* API Client for interfacing with the Stainless 2 API.
153+
* API Client for interfacing with the Stainless API.
154154
*
155155
* @param {string | undefined} [opts.apiKey=process.env['API_KEY'] ?? undefined]
156-
* @param {string} [opts.baseURL=process.env['STAINLESS_2_BASE_URL'] ?? https://api.stainlessapi.com] - Override the default base URL for the API.
156+
* @param {string} [opts.baseURL=process.env['STAINLESS_BASE_URL'] ?? https://api.stainlessapi.com] - Override the default base URL for the API.
157157
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
158158
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
159159
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -162,13 +162,13 @@ export class Stainless2 {
162162
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
163163
*/
164164
constructor({
165-
baseURL = readEnv('STAINLESS_2_BASE_URL'),
165+
baseURL = readEnv('STAINLESS_BASE_URL'),
166166
apiKey = readEnv('API_KEY'),
167167
...opts
168168
}: ClientOptions = {}) {
169169
if (apiKey === undefined) {
170-
throw new Errors.Stainless2Error(
171-
"The API_KEY environment variable is missing or empty; either provide it, or instantiate the Stainless2 client with an apiKey option, like new Stainless2({ apiKey: 'My API Key' }).",
170+
throw new Errors.StainlessError(
171+
"The API_KEY environment variable is missing or empty; either provide it, or instantiate the Stainless client with an apiKey option, like new Stainless({ apiKey: 'My API Key' }).",
172172
);
173173
}
174174

@@ -179,12 +179,12 @@ export class Stainless2 {
179179
};
180180

181181
this.baseURL = options.baseURL!;
182-
this.timeout = options.timeout ?? Stainless2.DEFAULT_TIMEOUT /* 1 minute */;
182+
this.timeout = options.timeout ?? Stainless.DEFAULT_TIMEOUT /* 1 minute */;
183183
this.logger = options.logger ?? console;
184184
if (options.logLevel != null) {
185185
this.logLevel = options.logLevel;
186186
} else {
187-
const envLevel = readEnv('STAINLESS_2_LOG');
187+
const envLevel = readEnv('STAINLESS_LOG');
188188
if (isLogLevel(envLevel)) {
189189
this.logLevel = envLevel;
190190
}
@@ -224,7 +224,7 @@ export class Stainless2 {
224224
if (value === null) {
225225
return `${encodeURIComponent(key)}=`;
226226
}
227-
throw new Errors.Stainless2Error(
227+
throw new Errors.StainlessError(
228228
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
229229
);
230230
})
@@ -612,10 +612,10 @@ export class Stainless2 {
612612
}
613613
}
614614

615-
static Stainless2 = this;
615+
static Stainless = this;
616616
static DEFAULT_TIMEOUT = 60000; // 1 minute
617617

618-
static Stainless2Error = Errors.Stainless2Error;
618+
static StainlessError = Errors.StainlessError;
619619
static APIError = Errors.APIError;
620620
static APIConnectionError = Errors.APIConnectionError;
621621
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
@@ -633,8 +633,8 @@ export class Stainless2 {
633633

634634
builds: API.Builds = new API.Builds(this);
635635
}
636-
Stainless2.Builds = Builds;
637-
export declare namespace Stainless2 {
636+
Stainless.Builds = Builds;
637+
export declare namespace Stainless {
638638
export type RequestOptions = Opts.RequestOptions;
639639

640640
export {

src/error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import { castToError } from './internal/errors';
44

5-
export class Stainless2Error extends Error {}
5+
export class StainlessError extends Error {}
66

77
export class APIError<
88
TStatus extends number | undefined = number | undefined,
99
THeaders extends Headers | undefined = Headers | undefined,
1010
TError extends Object | undefined = Object | undefined,
11-
> extends Stainless2Error {
11+
> extends StainlessError {
1212
/** HTTP status for the response that caused the error */
1313
readonly status: TStatus;
1414
/** HTTP headers for the response that caused the error */

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export { Stainless2 as default } from './client';
3+
export { Stainless as default } from './client';
44

55
export { type Uploadable, toFile } from './uploads';
66
export { APIPromise } from './api-promise';
7-
export { Stainless2, type ClientOptions } from './client';
7+
export { Stainless, type ClientOptions } from './client';
88
export {
9-
Stainless2Error,
9+
StainlessError,
1010
APIError,
1111
APIConnectionError,
1212
APIConnectionTimeoutError,

src/internal/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import type { FinalRequestOptions } from './request-options';
4-
import { type Stainless2 } from '../client';
4+
import { type Stainless } from '../client';
55
import { logger } from './utils/log';
66

77
export type APIResponseProps = {
@@ -10,7 +10,7 @@ export type APIResponseProps = {
1010
controller: AbortController;
1111
};
1212

13-
export async function defaultParseResponse<T>(client: Stainless2, props: APIResponseProps): Promise<T> {
13+
export async function defaultParseResponse<T>(client: Stainless, props: APIResponseProps): Promise<T> {
1414
const { response } = props;
1515

1616
// fetch refuses to read the body when the status code is 204.

0 commit comments

Comments
 (0)