If someone finds this and wants to typify it in someway for TypeScript, here's my approach:
export type ReportGenerationFormat = 'PPT' | 'WORD' | 'PDF';
interface ReportFileType {
extension: string;
mimeType: string;
}
/**
* File name extensions and their MIME Types.
* PPT is a proprietary format before PowerPoint 2007.
* PPTX is an open format since PowerPoint 2007.
* PDF is self-explanatory.
* DOC is a Microsoft document before Word 2007.
* DOCX is a Microsoft Word document.
*/
export const ReportFileTypes: Record<string, ReportFileType> = {
PPT: { extension: '.ppt', mimeType: 'application/vnd.ms-powerpoint' },
PPTX: { extension: '.pptx', mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' },
PDF: { extension: '.pdf', mimeType: 'application/pdf' },
DOC: { extension: '.doc', mimeType: 'application/msword' },
DOCX: { extension: '.docx', mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' },
};
And then all you have to do is import that constant and utilise it with the fileType, like so:
ReportFileTypes[fileType].mimeType