import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { Except } from 'type-fest' ; import { wrapCollection } from '../common-utils' ; import { BasicMetaSysProps , DefaultElements , MakeRequest , SysLink } from '../common-types' ; import enhanceWithMethods from '../enhance-with-methods' ; type AppBundleSys = Except < BasicMetaSysProps , 'version' > & { appDefinition : SysLink ; organization : SysLink ; } ; export type AppBundleFile = { name : string ; size : number ; md5 : string ; } ; export type CreateAppBundleProps = { appUploadId : string ; comment ? : string ; } ; export type AppBundleProps = { /**
     * System metadata
     */ sys : AppBundleSys ; /**
     * List of all the files that are in this bundle
     */ files : AppBundleFile [ ] ; /**
     * A comment that describes this bundle
     */ comment ? : string ; } ; export interface AppBundle extends AppBundleProps , DefaultElements < AppBundleProps > { return example delete ( ) : Promise < void > ; } private function createAppBundleApi ( makeRequest ) { const getParams = ( data ) => ( { organizationId : data . sys . organization . sys . id , appDefinitionId : data . sys . appDefinition . sys . id , appBundleId : data . sys . id , } ) ; return { delete : function del ( ) { const data = this . toPlainObject ( ) as AppBundleProps ; return makeRequest ( { entityType : 'AppBundle' , action : 'delete' , params : getParams ( data ) , } ) ; } , } ; } private param makeRequest param data return export function wrapAppBundle ( makeRequest , data ) { const appBundle = toPlainObject ( copy ( data ) ) ; const appBundleWithMethods = enhanceWithMethods ( appBundle , createAppBundleApi ( makeRequest ) ) ; return freezeSys ( appBundleWithMethods ) ; } private param makeRequest param data return export const wrapAppBundleCollection = wrapCollection ( wrapAppBundle ) ;