@@ -60,17 +60,15 @@ const projectPath = (projectId: string, suffix = ""): string => `/projects/${enc
6060
6161const decodeProjectResponse = ( payload : JsonValue ) => {
6262 const object = asObject ( payload )
63- return object === null
64- ? decodeProjectDetails ( payload )
65- : decodeProjectDetails ( object [ "project" ] ?? payload )
63+ return decodeProjectDetails ( object === null ? payload : object [ "project" ] ?? payload )
6664}
6765
6866const decodeProjectsResponse = < A > (
6967 payload : JsonValue ,
7068 decode : ( value : JsonValue ) => A | null
7169) : ReadonlyArray < A > => {
7270 const object = asObject ( payload )
73- const items = object === null ? asArray ( payload ) : asArray ( object [ "projects" ] )
71+ const items = asArray ( object === null ? payload : object [ "projects" ] )
7472 return items
7573 . map ( ( item ) => decode ( item ) )
7674 . filter ( ( value ) : value is A => value !== null )
@@ -93,8 +91,8 @@ const createProjectAsync = (
9391 resolvedPaths : ResolvedCreateRequestPaths
9492) =>
9593 Effect . gen ( function * ( _ ) {
96- const createRequest = buildCreateProjectRequest ( command , resolvedPaths , { async : true } )
97- const payload = yield * _ ( request ( "POST" , "/projects" , createRequest ) )
94+ const requestBody = buildCreateProjectRequest ( command , resolvedPaths , { async : true } )
95+ const payload = yield * _ ( request ( "POST" , "/projects" , requestBody ) )
9896 const accepted = decodeCreateProjectAccepted ( payload )
9997 if ( accepted === null ) {
10098 return yield * _ ( Effect . fail ( invalidCreateAcceptedResponse ( ) ) )
@@ -141,8 +139,8 @@ const createProjectWithResolvedPaths = (
141139 return yield * _ ( createProjectAsync ( command , resolvedPaths ) )
142140 }
143141
144- const createRequest = buildCreateProjectRequest ( command , resolvedPaths )
145- const projectId = asString ( createRequest . outDir )
142+ const requestBody = buildCreateProjectRequest ( command , resolvedPaths )
143+ const projectId = asString ( requestBody . outDir )
146144 const initialCursor = projectId === null
147145 ? null
148146 : yield * _ (
@@ -153,13 +151,12 @@ const createProjectWithResolvedPaths = (
153151 const eventPolling = projectId === null || initialCursor === null
154152 ? null
155153 : yield * _ ( startProjectEventPolling ( projectId , initialCursor ) )
154+ const ensureStopped = eventPolling === null
155+ ? Effect . void
156+ : stopProjectEventPolling ( eventPolling )
156157 const payload = yield * _ (
157- request ( "POST" , "/projects" , createRequest ) . pipe (
158- Effect . ensuring (
159- eventPolling === null
160- ? Effect . void
161- : stopProjectEventPolling ( eventPolling )
162- )
158+ request ( "POST" , "/projects" , requestBody ) . pipe (
159+ Effect . ensuring ( ensureStopped )
163160 )
164161 )
165162 return decodeProjectResponse ( payload )
@@ -176,10 +173,9 @@ const withProjectEventPolling = <A, E, R>(
176173 )
177174 )
178175 const eventPolling = yield * _ ( startProjectEventPolling ( projectId , initialCursor ) )
176+ const ensureStopped = stopProjectEventPolling ( eventPolling )
179177 return yield * _ (
180- effect . pipe (
181- Effect . ensuring ( stopProjectEventPolling ( eventPolling ) )
182- )
178+ effect . pipe ( Effect . ensuring ( ensureStopped ) )
183179 )
184180 } )
185181
@@ -236,8 +232,8 @@ export const readProjectLogs = (projectId: string) =>
236232 Effect . map ( ( payload ) => readProjectOutput ( payload ) )
237233 )
238234
239- export const readContainerTaskSnapshot = ( projectId : string , includeDefault : boolean ) =>
240- request ( "GET" , projectPath ( projectId , `/tasks${ includeDefault ? "?includeDefault=true" : "" } ` ) ) . pipe (
235+ export const readContainerTaskSnapshot = ( projectId : string , shouldIncludeDefault : boolean ) =>
236+ request ( "GET" , projectPath ( projectId , `/tasks${ shouldIncludeDefault ? "?includeDefault=true" : "" } ` ) ) . pipe (
241237 Effect . map ( ( payload ) => decodeContainerTaskSnapshot ( payload ) )
242238 )
243239
@@ -275,7 +271,8 @@ export const createAuthTerminalSession = (
275271
276272export const deleteTerminalSessionByPath = ( path : string ) => requestVoid ( "DELETE" , path )
277273
278- export const applyAllProjects = ( activeOnly : boolean ) => requestVoid ( "POST" , "/projects/apply-all" , { activeOnly } )
274+ export const applyAllProjects = ( isActiveOnly : boolean ) =>
275+ requestVoid ( "POST" , "/projects/apply-all" , { activeOnly : isActiveOnly } )
279276
280277export const downAllProjects = ( ) => requestVoid ( "POST" , "/projects/down-all" )
281278
0 commit comments