Skip to content

Commit 434dc67

Browse files
chore(internal): codegen related update
1 parent f7be25c commit 434dc67

File tree

6 files changed

+42
-58
lines changed

6 files changed

+42
-58
lines changed

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ const client = new Stainless({
3030
apiKey: process.env['STAINLESS_V0_API_KEY'], // This is the default and can be omitted
3131
});
3232

33-
async function main() {
34-
const buildObject = await client.builds.create({ revision: 'string' });
33+
const buildObject = await client.builds.create({ revision: 'string' });
3534

36-
console.log(buildObject.id);
37-
}
38-
39-
main();
35+
console.log(buildObject.id);
4036
```
4137

4238
### Request & Response types
@@ -52,12 +48,8 @@ const client = new Stainless({
5248
apiKey: process.env['STAINLESS_V0_API_KEY'], // This is the default and can be omitted
5349
});
5450

55-
async function main() {
56-
const params: Stainless.BuildCreateParams = { revision: 'string' };
57-
const buildObject: Stainless.BuildObject = await client.builds.create(params);
58-
}
59-
60-
main();
51+
const params: Stainless.BuildCreateParams = { revision: 'string' };
52+
const buildObject: Stainless.BuildObject = await client.builds.create(params);
6153
```
6254

6355
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -70,19 +62,15 @@ a subclass of `APIError` will be thrown:
7062

7163
<!-- prettier-ignore -->
7264
```ts
73-
async function main() {
74-
const buildObject = await client.builds.create({ revision: 'string' }).catch(async (err) => {
75-
if (err instanceof Stainless.APIError) {
76-
console.log(err.status); // 400
77-
console.log(err.name); // BadRequestError
78-
console.log(err.headers); // {server: 'nginx', ...}
79-
} else {
80-
throw err;
81-
}
82-
});
83-
}
84-
85-
main();
65+
const buildObject = await client.builds.create({ revision: 'string' }).catch(async (err) => {
66+
if (err instanceof Stainless.APIError) {
67+
console.log(err.status); // 400
68+
console.log(err.name); // BadRequestError
69+
console.log(err.headers); // {server: 'nginx', ...}
70+
} else {
71+
throw err;
72+
}
73+
});
8674
```
8775

8876
Error codes are as follows:

scripts/build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ npm exec tsc-multi
3737
# when building .mjs
3838
node scripts/utils/fix-index-exports.cjs
3939
cp tsconfig.dist-src.json dist/src/tsconfig.json
40-
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.ts
41-
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.mts
4240

4341
node scripts/utils/postprocess-files.cjs
4442

src/internal/shim-types.d.ts

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

src/internal/shim-types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
/**
4+
* Shims for types that we can't always rely on being available globally.
5+
*
6+
* Note: these only exist at the type-level, there is no corresponding runtime
7+
* version for any of these symbols.
8+
*/
9+
10+
type NeverToAny<T> = T extends never ? any : T;
11+
12+
/** @ts-ignore */
13+
type _DOMReadableStream<R = any> = globalThis.ReadableStream<R>;
14+
15+
/** @ts-ignore */
16+
type _NodeReadableStream<R = any> = import('stream/web').ReadableStream<R>;
17+
18+
type _ConditionalNodeReadableStream<R = any> =
19+
typeof globalThis extends { ReadableStream: any } ? never : _NodeReadableStream<R>;
20+
21+
type _ReadableStream<R = any> = NeverToAny<
22+
| ([0] extends [1 & _DOMReadableStream<R>] ? never : _DOMReadableStream<R>)
23+
| ([0] extends [1 & _ConditionalNodeReadableStream<R>] ? never : _ConditionalNodeReadableStream<R>)
24+
>;
25+
26+
export type { _ReadableStream as ReadableStream };

src/internal/shims.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* messages in cases where an environment isn't fully supported.
88
*/
99

10-
import { type Fetch } from './builtin-types';
11-
import { type ReadableStream } from './shim-types';
10+
import type { Fetch } from './builtin-types';
11+
import type { ReadableStream } from './shim-types';
1212

1313
export function getDefaultFetch(): Fetch {
1414
if (typeof fetch !== 'undefined') {

src/internal/uploads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const createForm = async <T = Record<string, unknown>>(
138138

139139
// We check for Blob not File because Bun.File doesn't inherit from File,
140140
// but they both inherit from Blob and have a `name` property at runtime.
141-
const isNamedBlob = (value: object) => value instanceof Blob && 'name' in value;
141+
const isNamedBlob = (value: unknown) => value instanceof Blob && 'name' in value;
142142

143143
const isUploadable = (value: unknown) =>
144144
typeof value === 'object' &&

0 commit comments

Comments
 (0)