Ever since the September 2017 release, it is possible to expand/collapse all the rows of a pivot table at once; this option is found by right clicking on the object as displayed in the picture below.
I guess that this options has to be enabled somewhere in the 'support' object, just like the export and exportData options. However, I cannot find anything in the Extension API.