The UN General Assembly has agreed on a deal to better manage the international flow of migrants and protect human rights.