Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jul 12, 2024
1 parent 17e093d commit d5c3451
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 95 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-e54b835d1d64d37343017f4919c60998496a1b2b5c8e0c67af82093efc613f2f.yml
configured_endpoints: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-eccf2e27a91b41489a70fdbe1253c1142da0f2f2d1e84267b037d6b6af0b26dd.yml
4 changes: 0 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ Methods:
Types:

- <code><a href="./src/resources/files.ts">File</a></code>
- <code><a href="./src/resources/files.ts">FileDeleteResponse</a></code>

Methods:

- <code title="get /v1/files/{fileId}">client.files.<a href="./src/resources/files.ts">retrieve</a>(fileId) -> File</code>
- <code title="get /v1/files">client.files.<a href="./src/resources/files.ts">list</a>({ ...params }) -> FilesCursorPage</code>
- <code title="delete /v1/files/{fileId}">client.files.<a href="./src/resources/files.ts">delete</a>(fileId) -> FileDeleteResponse</code>
- <code title="get /v1/files/{fileId}/download">client.files.<a href="./src/resources/files.ts">download</a>(fileId) -> Response</code>
- <code title="post /v1/files">client.files.<a href="./src/resources/files.ts">upload</a>({ ...params }) -> File</code>
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"@types/qs": "^6.9.7",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7",
"qs": "^6.10.3",
"web-streams-polyfill": "^3.2.1"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as qs from 'qs';
import * as Core from './core';
import * as Pagination from './pagination';
import * as API from './resources/index';
Expand Down Expand Up @@ -141,6 +142,10 @@ export class Writer extends Core.APIClient {
return { Authorization: `Bearer ${this.apiKey}` };
}

protected override stringifyQuery(query: Record<string, unknown>): string {
return qs.stringify(query, { arrayFormat: 'comma' });
}

static Writer = this;

static WriterError = Errors.WriterError;
Expand Down Expand Up @@ -218,7 +223,6 @@ export namespace Writer {

export import Files = API.Files;
export import File = API.File;
export import FileDeleteResponse = API.FileDeleteResponse;
export import FilesCursorPage = API.FilesCursorPage;
export import FileListParams = API.FileListParams;
export import FileUploadParams = API.FileUploadParams;
Expand Down
66 changes: 30 additions & 36 deletions src/resources/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@ import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as FilesAPI from './files';
import { CursorPage, type CursorPageParams } from '../pagination';
import { type BlobLike } from '../uploads';
import { type Response } from '../_shims/index';

export class Files extends APIResource {
/**
* Get metadata of a file
*/
retrieve(fileId: string, options?: Core.RequestOptions): Core.APIPromise<File> {
return this._client.get(`/v1/files/${fileId}`, options);
}

/**
* Get metadata of all files
* List files
*/
list(query?: FileListParams, options?: Core.RequestOptions): Core.PagePromise<FilesCursorPage, File>;
list(options?: Core.RequestOptions): Core.PagePromise<FilesCursorPage, File>;
Expand All @@ -31,20 +22,6 @@ export class Files extends APIResource {
return this._client.getAPIList('/v1/files', FilesCursorPage, { query, ...options });
}

/**
* Delete file
*/
delete(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileDeleteResponse> {
return this._client.delete(`/v1/files/${fileId}`, options);
}

/**
* Download a file
*/
download(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
return this._client.get(`/v1/files/${fileId}/download`, { ...options, __binaryResponse: true });
}

/**
* Upload file
*/
Expand Down Expand Up @@ -72,54 +49,71 @@ export class Files extends APIResource {
export class FilesCursorPage extends CursorPage<File> {}

export interface File {
/**
* A unique identifier of the graph.
*/
id: string;

/**
* The timestamp when the graph was created.
*/
created_at: string;

/**
* A list of graph IDs that the file is associated with.
*/
graph_ids: Array<string>;

/**
* The name of the graph.
*/
name: string;
}

export interface FileDeleteResponse {
id: string;

deleted: boolean;
}

export interface FileListParams extends CursorPageParams {
graph_id?: string;
/**
* The unique identifier of the graph to which the files belong.
*/
graph_id?: Array<string>;

/**
* Specifies the maximum number of objects returned in a page. The default value
* is 50. The minimum value is 1, and the maximum value is 100.
*/
limit?: number;

/**
* Specifies the order of the results. Valid values are asc for ascending and desc
* for descending.
*/
order?: 'asc' | 'desc';
}

export interface FileUploadParams {
/**
* Body param:
*/
content: string | ArrayBufferView | ArrayBuffer | BlobLike;
content: Core.Uploadable;

/**
* Header param:
* Header param: The disposition type of the file, typically used to indicate the
* form-data name.
*/
'Content-Disposition': string;

/**
* Header param:
* Header param: The size of the file in bytes.
*/
'Content-Length': number;

/**
* Header param:
* Header param: The MIME type of the file being uploaded.
*/
'Content-Type': string;
}

export namespace Files {
export import File = FilesAPI.File;
export import FileDeleteResponse = FilesAPI.FileDeleteResponse;
export import FilesCursorPage = FilesAPI.FilesCursorPage;
export import FileListParams = FilesAPI.FileListParams;
export import FileUploadParams = FilesAPI.FileUploadParams;
Expand Down
Loading

0 comments on commit d5c3451

Please sign in to comment.