President Donald Trump will be allowed to deport Venezuelan migrants under an 18th-century wartime law, the Supreme Court has said – under one condition.