import copy from 'fast-copy' ; import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import enhanceWithMethods from '../enhance-with-methods' ; import { wrapCollection } from '../common-utils' ; import { DefaultElements , MetaLinkProps , BasicMetaSysProps , SysLink , MakeRequest , } from '../common-types' ; export type EnvironmentAliasProps = { /**
     * System meta data
     */ sys : BasicMetaSysProps & { space : SysLink ; } ; environment : { sys : MetaLinkProps ; } ; } ; export type CreateEnvironmentAliasProps = Omit < EnvironmentAliasProps , 'sys' > ; export interface EnvironmentAlias extends EnvironmentAliasProps , DefaultElements < EnvironmentAliasProps > { memberof func return { Promise < EnvironmentAlias > } update ( ) : Promise < EnvironmentAlias > ; memberof func return { Promise < void > } delete ( ) : Promise < void > ; } private function createEnvironmentAliasApi ( makeRequest ) { const getParams = ( alias ) => ( { spaceId : alias . sys . space . sys . id , environmentAliasId : alias . sys . id , } ) ; return { update : function ( ) { const raw = this . toPlainObject ( ) as EnvironmentAliasProps ; return makeRequest ( { entityType : 'EnvironmentAlias' , action : 'update' , params : getParams ( raw ) , payload : raw , } ) . then ( ( data ) => wrapEnvironmentAlias ( makeRequest , data ) ) ; } , delete : function ( ) { const raw = this . toPlainObject ( ) as EnvironmentAliasProps ; return makeRequest ( { entityType : 'EnvironmentAlias' , action : 'delete' , params : getParams ( raw ) , } ) . then ( ( ) => { } ) ; } , } ; } private param makeRequest param data return export function wrapEnvironmentAlias ( makeRequest , data ) { const alias = toPlainObject ( copy ( data ) ) ; const enhancedAlias = enhanceWithMethods ( alias , createEnvironmentAliasApi ( makeRequest ) ) ; return freezeSys ( enhancedAlias ) ; } private param makeRequest param data return export const wrapEnvironmentAliasCollection = wrapCollection ( wrapEnvironmentAlias ) ;