import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { BasicMetaSysProps , DefaultElements , MakeRequest } from '../common-types' ; import { wrapCollection } from '../common-utils' ; import createSpaceApi , { ContentfulSpaceAPI } from '../create-space-api' ; import enhanceWithMethods from '../enhance-with-methods' ; export type SpaceProps = { sys : BasicMetaSysProps & { organization : { sys : { id : string ; } ; } ; } ; name : string ; } ; export type Space = SpaceProps & DefaultElements < SpaceProps > & ContentfulSpaceAPI ; private param makeRequest param data return { Space } export function wrapSpace ( makeRequest , data ) { const space = toPlainObject ( copy ( data ) ) ; const spaceApi = createSpaceApi ( makeRequest ) ; const enhancedSpace = enhanceWithMethods ( space , spaceApi ) ; return freezeSys ( enhancedSpace ) ; } private export const wrapSpaceCollection = wrapCollection ( wrapSpace ) ;