I started working on a Download operation extension that reuses the ExportService. I think that would be the ideal setup, but got stuck. Basically, the idea was to configure a download operation with a property that has data (from $last, or the flow object, similar to how you set it the Console operation). The config could also have a dropdown for choosing json/xml/csv.
Something like this:
if (downloadFormat === 'json') {
res.attachment(${filename}.json);
res.set('Content-Type', 'application/json');
return res.status(200).send(exportService.transform(flowData, 'json'));
}
if (downloadFormat === 'xml') {
res.attachment(`${filename}.xml`);
res.set('Content-Type', 'text/xml');
return res.status(200).send(exportService.transform(flowData.data, 'xml'));
}
if (downloadFormat === 'csv') {
res.attachment(`${fileName}.csv`);
res.set('Content-Type', 'text/csv');
return res.status(200).send(exportService.transform(flowData, 'csv'));
}