UNPKG

contentful-management

Version:
32 lines (29 loc) 1.16 kB
import { toPlainObject, freezeSys } from 'contentful-sdk-core'; import copy from 'fast-copy'; import { wrapCollection } from '../common-utils.js'; import createSpaceApi from '../create-space-api.js'; import enhanceWithMethods from '../enhance-with-methods.js'; /** * This method creates the API for the given space with all the methods for * reading and creating other entities. It also passes down a clone of the * http client with a space id, so the base path for requests now has the * space id already set. * @internal * @param makeRequest - function to make requests via an adapter * @param data - API response for a Space * @returns {Space} */ function wrapSpace(makeRequest, data) { const space = toPlainObject(copy(data)); const spaceApi = createSpaceApi(makeRequest); const enhancedSpace = enhanceWithMethods(space, spaceApi); return freezeSys(enhancedSpace); } /** * This method wraps each space in a collection with the space API. See wrapSpace * above for more details. * @internal */ const wrapSpaceCollection = wrapCollection(wrapSpace); export { wrapSpace, wrapSpaceCollection }; //# sourceMappingURL=space.js.map