The US and Japan have agreed a trade deal days ahead of the latest tariff deadline set by Donald Trump.