import { EntityBase , EntityType } from "../entity" ; export interface AttachmentReference extends EntityBase < EntityType . AttachmentReference , AttachmentID > { mimeType : AttachmentMIMEType ; } TJS-type TJS-pattern export type AttachmentID = string & { __attachmentIDOpaqueType : never ; } ; export enum AttachmentMIMEType { PNG = "image/png" , JPEG = "image/jpeg" , SVG = "image/svg+xml" } export function getFileExtensionForAttachmentMIMEType ( attachmentMimeType ) ; export function getFileExtensionForAttachmentMIMEType ( attachmentMimeType ) ; export function getFileExtensionForAttachmentMIMEType ( attachmentMimeType ) { switch ( attachmentMimeType ) { case AttachmentMIMEType . JPEG : return "jpg" ; case AttachmentMIMEType . PNG : return "png" ; case AttachmentMIMEType . SVG : return "svg" ; default : return null ; } } export function getAttachmentMIMETypeForFilename ( filename ) { const uppercaseFilename = filename . toUpperCase ( ) ; if ( uppercaseFilename . endsWith ( ".PNG" ) ) { return AttachmentMIMEType . PNG ; } else if ( uppercaseFilename . endsWith ( ".JPG" ) || uppercaseFilename . endsWith ( ".JPEG" ) ) { return AttachmentMIMEType . JPEG ; } else if ( uppercaseFilename . endsWith ( ".SVG" ) ) { return AttachmentMIMEType . SVG ; } else { return null ; } }