import copy from 'fast-copy' ; import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import enhanceWithMethods from '../enhance-with-methods' ; import { DefaultElements , MakeRequest , MetaSysProps , SysLink } from '../common-types' ; export type UploadProps = { /**
     * System metadata
     */ sys : MetaSysProps & { space : SysLink ; } ; } ; export interface Upload extends UploadProps , DefaultElements < UploadProps > { return example delete ( ) : Promise < void > ; } private function createUploadApi ( makeRequest ) { return { delete : async function del ( ) { const raw = this . toPlainObject ( ) as UploadProps ; await makeRequest ( { entityType : 'Upload' , action : 'delete' , params : { spaceId : raw . sys . space . sys . id , uploadId : raw . sys . id , } , } ) ; } , } ; } private param { function } makeRequest param { object } data return { Upload } export function wrapUpload ( makeRequest , data ) { const upload = toPlainObject ( copy ( data ) ) ; const uploadWithMethods = enhanceWithMethods ( upload , createUploadApi ( makeRequest ) ) ; return freezeSys ( uploadWithMethods ) ; }