import { checkExceptions , createWaiter , WaiterConfiguration , WaiterResult , WaiterState } from "@aws-sdk/util-waiter" ; import { GetUserCommand , GetUserCommandInput } from "../commands/GetUserCommand" ; import { IAMClient } from "../IAMClient" ; const checkState = async ( client , input ) : Promise < WaiterResult > => { let reason ; try { const result = await client . send ( new GetUserCommand ( input ) ) ; reason = result ; return { state : WaiterState . SUCCESS , reason } ; } catch ( exception ) { reason = exception ; if ( exception . name && exception . name == "NoSuchEntity" ) { return { state : WaiterState . RETRY , reason } ; } } return { state : WaiterState . RETRY , reason } ; } ; deprecated export const waitForUserExists = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 1 , maxDelay : 120 } ; return createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; } ; param params param input export const waitUntilUserExists = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 1 , maxDelay : 120 } ; const result = await createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; return checkExceptions ( result ) ; } ;