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