@@ -10,15 +10,15 @@ export type { ApplyProjectRequest, ProjectResourceLimitRequest } from "../shared
1010type CreateProjectRequestDraft = CreateProjectDraft & ProjectResourceLimitRequest
1111
1212const optionalProjectResourceFields = ( request : ProjectResourceLimitRequest ) => ( {
13- ...( request . playwrightCpuLimit === undefined ? { } : { playwrightCpuLimit : request . playwrightCpuLimit } ) ,
14- ...( request . playwrightRamLimit === undefined ? { } : { playwrightRamLimit : request . playwrightRamLimit } )
13+ ...( request . playwrightCpuLimit !== undefined && { playwrightCpuLimit : request . playwrightCpuLimit } ) ,
14+ ...( request . playwrightRamLimit !== undefined && { playwrightRamLimit : request . playwrightRamLimit } )
1515} )
1616
1717const applyProjectBody = ( request : ApplyProjectRequest | undefined ) => ( {
18- ...( request ?. cpuLimit === undefined ? { } : { cpuLimit : request . cpuLimit } ) ,
19- ...( request ?. gpu === undefined ? { } : { gpu : request . gpu } ) ,
20- ...( request ?. ramLimit === undefined ? { } : { ramLimit : request . ramLimit } ) ,
21- ...( request === undefined ? { } : optionalProjectResourceFields ( request ) )
18+ ...( request ?. cpuLimit !== undefined && { cpuLimit : request . cpuLimit } ) ,
19+ ...( request ?. gpu !== undefined && { gpu : request . gpu } ) ,
20+ ...( request ?. ramLimit !== undefined && { ramLimit : request . ramLimit } ) ,
21+ ...( request !== undefined && optionalProjectResourceFields ( request ) )
2222} )
2323
2424const createProjectBody = ( draft : CreateProjectRequestDraft ) => ( {
@@ -38,62 +38,70 @@ const createProjectBody = (draft: CreateProjectRequestDraft) => ({
3838} )
3939
4040export const loadProjectDetails = ( projectId : string ) =>
41- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . GET ( "/projects/{projectId}" , {
42- params : { path : { projectId } }
43- } ) ) . pipe (
44- Effect . map ( ( response ) => response . project )
45- )
41+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
42+ client . GET ( "/projects/{projectId}" , {
43+ params : { path : { projectId } }
44+ } ) ) . pipe (
45+ Effect . map ( ( response ) => response . project )
46+ )
4647
4748export const loadProjectPs = ( projectId : string ) =>
48- openApiJsonSchema ( OutputResponseSchema , ( client ) => client . GET ( "/projects/{projectId}/ps" , {
49- params : { path : { projectId } }
50- } ) ) . pipe (
51- Effect . map ( ( response ) => response . output )
52- )
49+ openApiJsonSchema ( OutputResponseSchema , ( client ) =>
50+ client . GET ( "/projects/{projectId}/ps" , {
51+ params : { path : { projectId } }
52+ } ) ) . pipe (
53+ Effect . map ( ( response ) => response . output )
54+ )
5355
5456export const loadProjectLogs = ( projectId : string ) =>
55- openApiJsonSchema ( OutputResponseSchema , ( client ) => client . GET ( "/projects/{projectId}/logs" , {
56- params : { path : { projectId } }
57- } ) ) . pipe (
58- Effect . map ( ( response ) => response . output )
59- )
57+ openApiJsonSchema ( OutputResponseSchema , ( client ) =>
58+ client . GET ( "/projects/{projectId}/logs" , {
59+ params : { path : { projectId } }
60+ } ) ) . pipe (
61+ Effect . map ( ( response ) => response . output )
62+ )
6063
6164export const applyProject = (
6265 projectId : string ,
6366 request ?: ApplyProjectRequest
6467) =>
65- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . POST ( "/projects/{projectId}/apply" , {
66- body : applyProjectBody ( request ) ,
67- params : { path : { projectId } }
68- } ) ) . pipe (
69- Effect . map ( ( response ) => response . project )
70- )
68+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
69+ client . POST ( "/projects/{projectId}/apply" , {
70+ body : applyProjectBody ( request ) ,
71+ params : { path : { projectId } }
72+ } ) ) . pipe (
73+ Effect . map ( ( response ) => response . project )
74+ )
7175
7276export const createProject = ( draft : CreateProjectRequestDraft ) =>
73- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . POST ( "/projects" , {
74- body : createProjectBody ( draft )
75- } ) ) . pipe (
76- Effect . map ( ( response ) => response . project )
77- )
77+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
78+ client . POST ( "/projects" , {
79+ body : createProjectBody ( draft )
80+ } ) ) . pipe (
81+ Effect . map ( ( response ) => response . project )
82+ )
7883
7984export const upProject = ( projectId : string ) =>
80- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . POST ( "/projects/{projectId}/up" , {
81- body : { useManagedAuthorizedKeys : true } ,
82- params : { path : { projectId } }
83- } ) ) . pipe (
84- Effect . map ( ( response ) => response . project )
85- )
85+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
86+ client . POST ( "/projects/{projectId}/up" , {
87+ body : { useManagedAuthorizedKeys : true } ,
88+ params : { path : { projectId } }
89+ } ) ) . pipe (
90+ Effect . map ( ( response ) => response . project )
91+ )
8692
8793export const resumeProject = ( projectId : string ) =>
88- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . POST ( "/projects/{projectId}/resume" , {
89- params : { path : { projectId } }
90- } ) ) . pipe (
91- Effect . map ( ( response ) => response . project )
92- )
94+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
95+ client . POST ( "/projects/{projectId}/resume" , {
96+ params : { path : { projectId } }
97+ } ) ) . pipe (
98+ Effect . map ( ( response ) => response . project )
99+ )
93100
94101export const suspendProject = ( projectId : string ) =>
95- openApiJsonSchema ( ProjectResponseSchema , ( client ) => client . POST ( "/projects/{projectId}/suspend" , {
96- params : { path : { projectId } }
97- } ) ) . pipe (
98- Effect . map ( ( response ) => response . project )
99- )
102+ openApiJsonSchema ( ProjectResponseSchema , ( client ) =>
103+ client . POST ( "/projects/{projectId}/suspend" , {
104+ params : { path : { projectId } }
105+ } ) ) . pipe (
106+ Effect . map ( ( response ) => response . project )
107+ )
0 commit comments