@@ -8,6 +8,23 @@ import { PageCursorURL, type PageCursorURLParams } from '../../pagination';
88import { type Response } from '../../_shims/index' ;
99
1010export class Files extends APIResource {
11+ /**
12+ * [BETA] Create a new file, project val or directory
13+ */
14+ create (
15+ projectId : string ,
16+ path : string ,
17+ params : FileCreateParams ,
18+ options ?: Core . RequestOptions ,
19+ ) : Core . APIPromise < FileCreateResponse > {
20+ const { branch_id, ...body } = params ;
21+ return this . _client . post ( `/v1/projects/${ projectId } /files/${ path } ` , {
22+ query : { branch_id } ,
23+ body,
24+ ...options ,
25+ } ) ;
26+ }
27+
1128 /**
1229 * Get metadata for files and directories in a project at the specified path
1330 */
@@ -80,6 +97,52 @@ export class Files extends APIResource {
8097
8198export class FileListResponsesPageCursorURL extends PageCursorURL < FileListResponse > { }
8299
100+ /**
101+ * A File or Directory's Metadata
102+ */
103+ export interface FileCreateResponse {
104+ /**
105+ * The id of the resource
106+ */
107+ id : string ;
108+
109+ links : FileCreateResponse . Links ;
110+
111+ name : string ;
112+
113+ path : string ;
114+
115+ type : 'directory' | 'file' | 'interval' | 'http' | 'email' | 'script' ;
116+
117+ updatedAt : string ;
118+
119+ version : number ;
120+ }
121+
122+ export namespace FileCreateResponse {
123+ export interface Links {
124+ /**
125+ * The URL of this resource on Val Town
126+ */
127+ html : string ;
128+
129+ /**
130+ * The URL of this resource's source code as a module
131+ */
132+ module : string ;
133+
134+ /**
135+ * The URL of this resource on this API
136+ */
137+ self : string ;
138+
139+ /**
140+ * This resource's web endpoint, where it serves a website or API
141+ */
142+ endpoint ?: string ;
143+ }
144+ }
145+
83146/**
84147 * A paginated result set
85148 */
@@ -186,6 +249,48 @@ export namespace FileListResponse {
186249 }
187250}
188251
252+ export type FileCreateParams = FileCreateParams . Variant0 | FileCreateParams . Variant1 ;
253+
254+ export declare namespace FileCreateParams {
255+ export interface Variant0 {
256+ /**
257+ * Body param:
258+ */
259+ type : 'directory' ;
260+
261+ /**
262+ * Query param: Id of the branch to create the file on. Defaults to main if not
263+ * provided.
264+ */
265+ branch_id ?: string ;
266+
267+ /**
268+ * Body param:
269+ */
270+ content ?: null ;
271+ }
272+
273+ export interface Variant1 {
274+ /**
275+ * Body param: Project file and val content. Null or an empty string will create an
276+ * empty file. When creating a directory, you can send null, an empty string, or
277+ * omit the content field entirely.
278+ */
279+ content : string ;
280+
281+ /**
282+ * Body param:
283+ */
284+ type : 'file' | 'interval' | 'http' | 'email' | 'script' ;
285+
286+ /**
287+ * Query param: Id of the branch to create the file on. Defaults to main if not
288+ * provided.
289+ */
290+ branch_id ?: string ;
291+ }
292+ }
293+
189294export interface FileRetrieveParams {
190295 /**
191296 * Maximum items to return in each paginated response
@@ -266,9 +371,11 @@ Files.FileListResponsesPageCursorURL = FileListResponsesPageCursorURL;
266371
267372export declare namespace Files {
268373 export {
374+ type FileCreateResponse as FileCreateResponse ,
269375 type FileRetrieveResponse as FileRetrieveResponse ,
270376 type FileListResponse as FileListResponse ,
271377 FileListResponsesPageCursorURL as FileListResponsesPageCursorURL ,
378+ type FileCreateParams as FileCreateParams ,
272379 type FileRetrieveParams as FileRetrieveParams ,
273380 type FileListParams as FileListParams ,
274381 type FileContentParams as FileContentParams ,
0 commit comments