import copy from 'fast-copy' ; import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import enhanceWithMethods from '../enhance-with-methods' ; import createEnvironmentApi , { ContentfulEnvironmentAPI } from '../create-environment-api' ; import { wrapCollection } from '../common-utils' ; import { DefaultElements , SysLink , BasicMetaSysProps , MakeRequest } from '../common-types' ; type EnvironmentMetaSys = BasicMetaSysProps & { status : SysLink ; space : SysLink ; aliases ? : Array < SysLink > ; aliasedEnvironment ? : SysLink ; } ; export type EnvironmentProps = { /**
     * System metadata
     */ sys : EnvironmentMetaSys ; /**
     * Name of the environment
     */ name : string ; } ; export type CreateEnvironmentProps = Partial < Omit < EnvironmentProps , 'sys' > > ; export type Environment = ContentfulEnvironmentAPI & EnvironmentProps & DefaultElements < EnvironmentProps > ; private param makeRequest param data return export function wrapEnvironment ( makeRequest , data ) { const environment = toPlainObject ( copy ( data ) ) ; const environmentApi = createEnvironmentApi ( makeRequest ) ; const enhancedEnvironment = enhanceWithMethods ( environment , environmentApi ) ; return freezeSys ( enhancedEnvironment ) ; } private export const wrapEnvironmentCollection = wrapCollection ( wrapEnvironment ) ;