import { checkExceptions , createWaiter , WaiterConfiguration , WaiterResult , WaiterState } from "@aws-sdk/util-waiter" ; import { DescribeFlowCommand , DescribeFlowCommandInput } from "../commands/DescribeFlowCommand" ; import { MediaConnectClient } from "../MediaConnectClient" ; const checkState = async ( client , input ) : Promise < WaiterResult > => { let reason ; try { const result = await client . send ( new DescribeFlowCommand ( input ) ) ; reason = result ; try { const returnComparator = ( ) => { return result . Flow . Status ; } ; if ( returnComparator ( ) === "STANDBY" ) { return { state : WaiterState . SUCCESS , reason } ; } } catch ( e ) { } try { const returnComparator = ( ) => { return result . Flow . Status ; } ; if ( returnComparator ( ) === "STOPPING" ) { return { state : WaiterState . RETRY , reason } ; } } catch ( e ) { } try { const returnComparator = ( ) => { return result . Flow . Status ; } ; if ( returnComparator ( ) === "ERROR" ) { return { state : WaiterState . FAILURE , reason } ; } } catch ( e ) { } } catch ( exception ) { reason = exception ; if ( exception . name && exception . name == "InternalServerErrorException" ) { return { state : WaiterState . RETRY , reason } ; } if ( exception . name && exception . name == "ServiceUnavailableException" ) { return { state : WaiterState . RETRY , reason } ; } } return { state : WaiterState . RETRY , reason } ; } ; deprecated export const waitForFlowStandby = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 3 , maxDelay : 120 } ; return createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; } ; param params param input export const waitUntilFlowStandby = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 3 , maxDelay : 120 } ; const result = await createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; return checkExceptions ( result ) ; } ;