import * as Either from 'fp-ts/lib/Either' ; import * as TaskEither from 'fp-ts/lib/TaskEither' ; import { ElasticsearchClient } from '../../../elasticsearch' ; import { catchRetryableEsClientErrors , RetryableEsClientError , } from './catch_retryable_es_client_errors' ; internal export interface ClosePitParams { client : ElasticsearchClient ; pitId : string ; } export const closePit = ( { client , pitId } ) : TaskEither . TaskEither < RetryableEsClientError , { } > => ( ) => { return client . closePointInTime ( { body : { id : pitId } , } ) . then ( ( response ) => { if ( ! response . body . succeeded ) { throw new Error ( `Failed to close PointInTime with id: ${ pitId }` ) ; } return Either . right ( { } ) ; } ) . catch ( catchRetryableEsClientErrors ) ; } ;