Skip to content

Commit e247b5b

Browse files
chore(internal): codegen related update (#67)
1 parent e761a75 commit e247b5b

File tree

8 files changed

+51
-60
lines changed

8 files changed

+51
-60
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
33
{
4-
"name": "Debian",
5-
"build": {
6-
"dockerfile": "Dockerfile"
4+
"name": "Development",
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
6+
"features": {
7+
"ghcr.io/devcontainers/features/node:1": {}
8+
},
9+
"postCreateCommand": "yarn install",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"esbenp.prettier-vscode"
14+
]
15+
}
716
}
8-
9-
// Features to add to the dev container. More info: https://containers.dev/features.
10-
// "features": {},
11-
12-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13-
// "forwardPorts": [],
14-
15-
// Configure tool-specific properties.
16-
// "customizations": {},
17-
18-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
19-
// "remoteUser": "root"
2017
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This library provides convenient access to the RunwayML REST API from server-sid
66

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

9-
It is generated with [Stainless](https://www.stainlessapi.com/).
9+
It is generated with [Stainless](https://www.stainless.com/).
1010

1111
## Installation
1212

@@ -300,7 +300,7 @@ await client.imageToVideo.create(
300300
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
301301

302302
1. Changes that only affect static types, without breaking runtime behavior.
303-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
303+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
304304
3. Changes that we do not expect to impact the vast majority of users in practice.
305305

306306
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

SECURITY.md

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

33
## Reporting Security Issues
44

5-
This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
5+
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
66

7-
To report a security issue, please contact the Stainless team at security@stainlessapi.com.
7+
To report a security issue, please contact the Stainless team at security@stainless.com.
88

99
## Responsible Disclosure
1010

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@
107107
"default": "./dist/index.mjs"
108108
},
109109
"./*.mjs": {
110-
"types": "./dist/*.d.ts",
111-
"default": "./dist/*.mjs"
110+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
111+
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
112112
},
113113
"./*.js": {
114-
"types": "./dist/*.d.ts",
115-
"default": "./dist/*.js"
114+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
115+
"default": ["./dist/*.js", "./dist/*/index.js"]
116116
},
117117
"./*": {
118-
"types": "./dist/*.d.ts",
119-
"require": "./dist/*.js",
120-
"default": "./dist/*.mjs"
118+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
119+
"require": ["./dist/*.js", "./dist/*/index.js"],
120+
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
121121
}
122122
}
123123
}

src/core.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export abstract class APIClient {
280280
options: FinalRequestOptions<Req>,
281281
{ retryCount = 0 }: { retryCount?: number } = {},
282282
): { req: RequestInit; url: string; timeout: number } {
283+
options = { ...options };
283284
const { method, path, query, headers: headers = {} } = options;
284285

285286
const body =
@@ -292,9 +293,9 @@ export abstract class APIClient {
292293

293294
const url = this.buildURL(path!, query);
294295
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
295-
const timeout = options.timeout ?? this.timeout;
296+
options.timeout = options.timeout ?? this.timeout;
296297
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
297-
const minAgentTimeout = timeout + 1000;
298+
const minAgentTimeout = options.timeout + 1000;
298299
if (
299300
typeof (httpAgent as any)?.options?.timeout === 'number' &&
300301
minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
@@ -323,7 +324,7 @@ export abstract class APIClient {
323324
signal: options.signal ?? null,
324325
};
325326

326-
return { req, url, timeout };
327+
return { req, url, timeout: options.timeout };
327328
}
328329

329330
private buildHeaders({
@@ -351,15 +352,22 @@ export abstract class APIClient {
351352
delete reqHeaders['content-type'];
352353
}
353354

354-
// Don't set the retry count header if it was already set or removed through default headers or by the
355-
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
356-
// account for the removal case.
355+
// Don't set theses headers if they were already set or removed through default headers or by the caller.
356+
// We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
357+
// for the removal case.
357358
if (
358359
getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
359360
getHeader(headers, 'x-stainless-retry-count') === undefined
360361
) {
361362
reqHeaders['x-stainless-retry-count'] = String(retryCount);
362363
}
364+
if (
365+
getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
366+
getHeader(headers, 'x-stainless-timeout') === undefined &&
367+
options.timeout
368+
) {
369+
reqHeaders['x-stainless-timeout'] = String(options.timeout);
370+
}
363371

364372
this.validateHeaders(reqHeaders, headers);
365373

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ export interface ClientOptions {
3434
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
3535
* much longer than this timeout before the promise succeeds or fails.
3636
*/
37-
timeout?: number;
37+
timeout?: number | undefined;
3838

3939
/**
4040
* An HTTP agent used to manage HTTP(S) connections.
4141
*
4242
* If not provided, an agent will be constructed by default in the Node.js environment,
4343
* otherwise no agent is used.
4444
*/
45-
httpAgent?: Agent;
45+
httpAgent?: Agent | undefined;
4646

4747
/**
4848
* Specify a custom `fetch` function implementation.
@@ -58,23 +58,23 @@ export interface ClientOptions {
5858
*
5959
* @default 2
6060
*/
61-
maxRetries?: number;
61+
maxRetries?: number | undefined;
6262

6363
/**
6464
* Default headers to include with every request to the API.
6565
*
6666
* These can be removed in individual requests by explicitly setting the
6767
* header to `undefined` or `null` in request options.
6868
*/
69-
defaultHeaders?: Core.Headers;
69+
defaultHeaders?: Core.Headers | undefined;
7070

7171
/**
7272
* Default query parameters to include with every request to the API.
7373
*
7474
* These can be removed in individual requests by explicitly setting the
7575
* param to `undefined` in request options.
7676
*/
77-
defaultQuery?: Core.DefaultQuery;
77+
defaultQuery?: Core.DefaultQuery | undefined;
7878
}
7979

8080
/**

tests/index.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ describe('instantiate client', () => {
9696
expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true });
9797
});
9898

99+
test('explicit global fetch', async () => {
100+
// make sure the global fetch type is assignable to our Fetch type
101+
const client = new RunwayML({
102+
baseURL: 'http://localhost:5000/',
103+
apiKey: 'My API Key',
104+
fetch: defaultFetch,
105+
});
106+
});
107+
99108
test('custom signal', async () => {
100109
const client = new RunwayML({
101110
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',

0 commit comments

Comments
 (0)