Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): api update #509

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 32
configured_endpoints: 35
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/val-town%2Fval-town-96c5c8e7372c1cfedb047e16fe48ce6cbf1a5c1ce242931b9347306942cc765c.yml
14 changes: 14 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ Methods:

- <code title="get /v1/alias/{username}/{val_name}">client.alias.username.valName.<a href="./src/resources/alias/username/val-name.ts">retrieve</a>(username, valName) -> ValNameRetrieveResponse</code>

### ProjectName

Types:

- <code><a href="./src/resources/alias/username/project-name.ts">ProjectNameRetrieveResponse</a></code>

Methods:

- <code title="get /v1/alias/projects/{username}/{project_name}">client.alias.username.projectName.<a href="./src/resources/alias/username/project-name.ts">retrieve</a>(username, projectName) -> ProjectNameRetrieveResponse</code>

# Me

## Profile
Expand Down Expand Up @@ -184,8 +194,12 @@ Methods:

Types:

- <code><a href="./src/resources/projects/files.ts">FileRetrieveResponse</a></code>
- <code><a href="./src/resources/projects/files.ts">FileListResponse</a></code>
- <code><a href="./src/resources/projects/files.ts">FileContentResponse</a></code>

Methods:

- <code title="get /v1/projects/{project_id}/files/{path}">client.projects.files.<a href="./src/resources/projects/files.ts">retrieve</a>(projectId, path, { ...params }) -> FileRetrieveResponse</code>
- <code title="get /v1/projects/{project_id}/files">client.projects.files.<a href="./src/resources/projects/files.ts">list</a>(projectId, { ...params }) -> FileListResponsesPageCursorURL</code>
- <code title="get /v1/projects/{project_id}/files/{path}/content">client.projects.files.<a href="./src/resources/projects/files.ts">content</a>(projectId, path, { ...params }) -> unknown</code>
1 change: 1 addition & 0 deletions src/resources/alias/username/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { ProjectName, type ProjectNameRetrieveResponse } from './project-name';
export { Username } from './username';
export { ValName, type ValNameRetrieveResponse } from './val-name';
72 changes: 72 additions & 0 deletions src/resources/alias/username/project-name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../resource';
import * as Core from '../../../core';

export class ProjectName extends APIResource {
/**
* Get a project
*/
retrieve(
username: string,
projectName: string,
options?: Core.RequestOptions,
): Core.APIPromise<ProjectNameRetrieveResponse> {
return this._client.get(`/v1/alias/projects/${username}/${projectName}`, options);
}
}

/**
* A Project
*/
export interface ProjectNameRetrieveResponse {
/**
* The id of the project
*/
id: string;

author: ProjectNameRetrieveResponse.Author;

createdAt: string;

description: string | null;

/**
* The URL of this project's image
*/
imageUrl: string | null;

links: ProjectNameRetrieveResponse.Links;

name: string;

/**
* This resource's privacy setting. Unlisted resources do not appear on profile
* pages or elsewhere, but you can link to them.
*/
privacy: 'public' | 'unlisted' | 'private';
}

export namespace ProjectNameRetrieveResponse {
export interface Author {
id: string;

username: string | null;
}

export interface Links {
/**
* The URL of this resource on Val Town
*/
html: string;

/**
* The URL of this resource on this API
*/
self: string;
}
}

export declare namespace ProjectName {
export { type ProjectNameRetrieveResponse as ProjectNameRetrieveResponse };
}
6 changes: 6 additions & 0 deletions src/resources/alias/username/username.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import { APIResource } from '../../../resource';
import * as Core from '../../../core';
import * as Shared from '../../shared';
import * as ProjectNameAPI from './project-name';
import { ProjectName, ProjectNameRetrieveResponse } from './project-name';
import * as ValNameAPI from './val-name';
import { ValName, ValNameRetrieveResponse } from './val-name';

export class Username extends APIResource {
valName: ValNameAPI.ValName = new ValNameAPI.ValName(this._client);
projectName: ProjectNameAPI.ProjectName = new ProjectNameAPI.ProjectName(this._client);

/**
* Get basic details about a user, given their username
Expand All @@ -18,7 +21,10 @@ export class Username extends APIResource {
}

Username.ValName = ValName;
Username.ProjectName = ProjectName;

export declare namespace Username {
export { ValName as ValName, type ValNameRetrieveResponse as ValNameRetrieveResponse };

export { ProjectName as ProjectName, type ProjectNameRetrieveResponse as ProjectNameRetrieveResponse };
}
180 changes: 180 additions & 0 deletions src/resources/projects/files.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as Shared from '../shared';
import { PageCursorURL, type PageCursorURLParams } from '../../pagination';

export class Files extends APIResource {
/**
* Get metadata for files and directories in a project at the specified path
*/
retrieve(
projectId: string,
path: string,
query: FileRetrieveParams,
options?: Core.RequestOptions,
): Core.APIPromise<FileRetrieveResponse> {
return this._client.get(`/v1/projects/${projectId}/files/${path}`, { query, ...options });
}

/**
* Get metadata for files and directories in a project at the root directory
*/
Expand All @@ -18,10 +32,111 @@ export class Files extends APIResource {
...options,
});
}

/**
* Download file content
*/
content(
projectId: string,
path: string,
params?: FileContentParams,
options?: Core.RequestOptions,
): Core.APIPromise<unknown>;
content(projectId: string, path: string, options?: Core.RequestOptions): Core.APIPromise<unknown>;
content(
projectId: string,
path: string,
params: FileContentParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<unknown> {
if (isRequestOptions(params)) {
return this.content(projectId, path, {}, params);
}
const {
'Cache-Control': cacheControl,
'If-Match': ifMatch,
'If-Modified-Since': ifModifiedSince,
'If-None-Match': ifNoneMatch,
'If-Unmodified-Since': ifUnmodifiedSince,
...query
} = params;
return this._client.get(`/v1/projects/${projectId}/files/${path}/content`, {
query,
...options,
headers: {
...(cacheControl != null ? { 'Cache-Control': cacheControl } : undefined),
...(ifMatch != null ? { 'If-Match': ifMatch } : undefined),
...(ifModifiedSince != null ? { 'If-Modified-Since': ifModifiedSince } : undefined),
...(ifNoneMatch != null ? { 'If-None-Match': ifNoneMatch } : undefined),
...(ifUnmodifiedSince != null ? { 'If-Unmodified-Since': ifUnmodifiedSince } : undefined),
...options?.headers,
},
});
}
}

export class FileListResponsesPageCursorURL extends PageCursorURL<FileListResponse> {}

/**
* A paginated result set
*/
export interface FileRetrieveResponse {
data: Array<FileRetrieveResponse.Data>;

/**
* Links to use for pagination
*/
links: Shared.PaginationLinks;
}

export namespace FileRetrieveResponse {
/**
* A File or Directory's Metadata
*/
export interface Data {
/**
* The id of the resource
*/
id: string;

links: Data.Links;

name: string;

path: string;

type: 'directory' | 'file' | 'interval' | 'http' | 'email' | 'script';

updatedAt: string;

version: number;
}

export namespace Data {
export interface Links {
/**
* The URL of this resource on Val Town
*/
html: string;

/**
* The URL of this resource's source code as a module
*/
module: string;

/**
* The URL of this resource on this API
*/
self: string;

/**
* This resource's web endpoint, where it serves a website or API
*/
endpoint?: string;
}
}
}

/**
* A File or Directory's Metadata
*/
Expand Down Expand Up @@ -68,6 +183,30 @@ export namespace FileListResponse {
}
}

export type FileContentResponse = unknown;

export interface FileRetrieveParams {
/**
* Maximum items to return in each paginated response
*/
limit: number;

/**
* Number of items to skip in order to deliver paginated results
*/
offset: number;

/**
* Id to query
*/
branch_id?: string;

/**
* Specific branch version to query
*/
version?: number;
}

export interface FileListParams extends PageCursorURLParams {
/**
* Id to query
Expand All @@ -85,12 +224,53 @@ export interface FileListParams extends PageCursorURLParams {
version?: number;
}

export interface FileContentParams {
/**
* Query param: Id to query
*/
branch_id?: string;

/**
* Query param: Specific branch version to query
*/
version?: number;

/**
* Header param:
*/
'Cache-Control'?: string;

/**
* Header param:
*/
'If-Match'?: string;

/**
* Header param:
*/
'If-Modified-Since'?: string;

/**
* Header param:
*/
'If-None-Match'?: string;

/**
* Header param:
*/
'If-Unmodified-Since'?: string;
}

Files.FileListResponsesPageCursorURL = FileListResponsesPageCursorURL;

export declare namespace Files {
export {
type FileRetrieveResponse as FileRetrieveResponse,
type FileListResponse as FileListResponse,
type FileContentResponse as FileContentResponse,
FileListResponsesPageCursorURL as FileListResponsesPageCursorURL,
type FileRetrieveParams as FileRetrieveParams,
type FileListParams as FileListParams,
type FileContentParams as FileContentParams,
};
}
11 changes: 10 additions & 1 deletion src/resources/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ export {
type BranchListResponse,
type BranchListParams,
} from './branches';
export { FileListResponsesPageCursorURL, Files, type FileListResponse, type FileListParams } from './files';
export {
FileListResponsesPageCursorURL,
Files,
type FileRetrieveResponse,
type FileListResponse,
type FileContentResponse,
type FileRetrieveParams,
type FileListParams,
type FileContentParams,
} from './files';
export {
ProjectListResponsesPageCursorURL,
Projects,
Expand Down
Loading