Skip to content

Commit f7be25c

Browse files
feat(api): add v0 project create api
1 parent 0e2a217 commit f7be25c

File tree

18 files changed

+260
-104
lines changed

18 files changed

+260
-104
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-332dd93ce7473cdf7114d71d7dcaf7a4acc1491717c5cd55fbf984475d92bad7.yml
3-
openapi_spec_hash: 15cea3398093ddc80c926606aa31d41a
4-
config_hash: 4cc7a55bc88549c1b7d1e960fa207961
1+
configured_endpoints: 16
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-4211d663fa2256cb1448cda8e8143dae51ab4c387a2a52fd8de6d588a69dcfc8.yml
3+
openapi_spec_hash: 73a5f552ba3b047363947cdbda0fd60b
4+
config_hash: b9e5923fc9792ef81d39a59cb6e2812e

README.md

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

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

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

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

51-
const params: Stainless.BuildCreateParams = { revision: 'string' };
52-
const buildObject: Stainless.BuildObject = await client.builds.create(params);
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();
5361
```
5462

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

6371
<!-- prettier-ignore -->
6472
```ts
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-
});
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();
7486
```
7587

7688
Error codes are as follows:

api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
Types:
44

5+
- <code><a href="./src/resources/projects/projects.ts">ProjectCreateResponse</a></code>
56
- <code><a href="./src/resources/projects/projects.ts">ProjectRetrieveResponse</a></code>
67
- <code><a href="./src/resources/projects/projects.ts">ProjectUpdateResponse</a></code>
78
- <code><a href="./src/resources/projects/projects.ts">ProjectListResponse</a></code>
89

910
Methods:
1011

12+
- <code title="post /v0/projects">client.projects.<a href="./src/resources/projects/projects.ts">create</a>({ ...params }) -> ProjectCreateResponse</code>
1113
- <code title="get /v0/projects/{project}">client.projects.<a href="./src/resources/projects/projects.ts">retrieve</a>({ ...params }) -> ProjectRetrieveResponse</code>
1214
- <code title="patch /v0/projects/{project}">client.projects.<a href="./src/resources/projects/projects.ts">update</a>({ ...params }) -> ProjectUpdateResponse</code>
1315
- <code title="get /v0/projects">client.projects.<a href="./src/resources/projects/projects.ts">list</a>({ ...params }) -> ProjectListResponse</code>
@@ -80,5 +82,5 @@ Types:
8082

8183
Methods:
8284

83-
- <code title="get /v0/orgs/{orgName}">client.orgs.<a href="./src/resources/orgs.ts">retrieve</a>(orgName) -> OrgRetrieveResponse</code>
85+
- <code title="get /v0/orgs/{org}">client.orgs.<a href="./src/resources/orgs.ts">retrieve</a>(org) -> OrgRetrieveResponse</code>
8486
- <code title="get /v0/orgs">client.orgs.<a href="./src/resources/orgs.ts">list</a>() -> OrgListResponse</code>

scripts/build

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

4143
node scripts/utils/postprocess-files.cjs
4244

src/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import {
3636
Builds,
3737
} from './resources/builds/builds';
3838
import {
39+
ProjectCreateParams,
40+
ProjectCreateResponse,
3941
ProjectListParams,
4042
ProjectListResponse,
4143
ProjectRetrieveParams,
@@ -727,9 +729,11 @@ export declare namespace Stainless {
727729

728730
export {
729731
Projects as Projects,
732+
type ProjectCreateResponse as ProjectCreateResponse,
730733
type ProjectRetrieveResponse as ProjectRetrieveResponse,
731734
type ProjectUpdateResponse as ProjectUpdateResponse,
732735
type ProjectListResponse as ProjectListResponse,
736+
type ProjectCreateParams as ProjectCreateParams,
733737
type ProjectRetrieveParams as ProjectRetrieveParams,
734738
type ProjectUpdateParams as ProjectUpdateParams,
735739
type ProjectListParams as ProjectListParams,

src/internal/shim-types.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
/**
11+
* In order to properly access the global `NodeJS` type, if it's available, we
12+
* need to make use of declaration shadowing. Without this, any checks for the
13+
* presence of `NodeJS.ReadableStream` will fail.
14+
*/
15+
declare namespace NodeJS {
16+
interface ReadableStream {}
17+
}
18+
19+
type HasProperties<T> = keyof T extends never ? false : true;
20+
21+
// @ts-ignore
22+
type _ReadableStream<R = any> =
23+
// @ts-ignore
24+
HasProperties<NodeJS.ReadableStream> extends true ? NodeJS.ReadableStream<R> : ReadableStream<R>;
25+
26+
// @ts-ignore
27+
declare const _ReadableStream: unknown extends typeof ReadableStream ? never : typeof ReadableStream;
28+
export { _ReadableStream as ReadableStream };

src/internal/shim-types.ts

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

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: unknown) => value instanceof Blob && 'name' in value;
141+
const isNamedBlob = (value: object) => value instanceof Blob && 'name' in value;
142142

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

src/resources/builds/builds.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export interface BuildCreateParams {
336336
export namespace BuildCreateParams {
337337
export interface unnamed_schema_with_map_parent_0 {
338338
/**
339-
* The file content
339+
* File content
340340
*/
341341
content: string;
342342
}
@@ -438,7 +438,7 @@ export namespace BuildCompareParams {
438438
export namespace Base {
439439
export interface unnamed_schema_with_map_parent_2 {
440440
/**
441-
* The file content
441+
* File content
442442
*/
443443
content: string;
444444
}
@@ -468,7 +468,7 @@ export namespace BuildCompareParams {
468468
export namespace Head {
469469
export interface unnamed_schema_with_map_parent_3 {
470470
/**
471-
* The file content
471+
* File content
472472
*/
473473
content: string;
474474
}

0 commit comments

Comments
 (0)