Source: entities/content-type.js

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.wrapContentType = wrapContentType;
  6. exports.wrapContentTypeCollection = wrapContentTypeCollection;
  7. var _cloneDeep = require('lodash/cloneDeep');
  8. var _cloneDeep2 = _interopRequireDefault(_cloneDeep);
  9. var _toPlainObject = require('contentful-sdk-core/mixins/to-plain-object');
  10. var _toPlainObject2 = _interopRequireDefault(_toPlainObject);
  11. var _freezeSys = require('contentful-sdk-core/freeze-sys');
  12. var _freezeSys2 = _interopRequireDefault(_freezeSys);
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. /**
  15. * @memberof Entities
  16. * @typedef ContentType
  17. * @prop {Entities.Sys} sys - System metadata
  18. * @prop {string} name
  19. * @prop {string} description
  20. * @prop {string} displayField - Field used as the main display field for Entries
  21. * @prop {string} Array<Field> - All the fields contained in this Content Type
  22. * @prop {function(): Object} toPlainObject() - Returns this Content Type as a plain JS object
  23. */
  24. /**
  25. * @private
  26. * @param {Object} data - Raw content type data
  27. * @return {ContentType} Wrapped content type data
  28. */
  29. function wrapContentType(data) {
  30. return (0, _freezeSys2.default)((0, _toPlainObject2.default)((0, _cloneDeep2.default)(data)));
  31. }
  32. /**
  33. * @memberof Entities
  34. * @typedef ContentTypeCollection
  35. * @prop {number} total
  36. * @prop {number} skip
  37. * @prop {number} limit
  38. * @prop {Array<Entities.ContentType>} items
  39. * @prop {function(): Object} toPlainObject() - Returns this Content Type collection as a plain JS object
  40. */
  41. /**
  42. * @private
  43. * @param {Object} data - Raw content type collection data
  44. * @return {ContentTypeCollection} Wrapped content type collection data
  45. */
  46. function wrapContentTypeCollection(data) {
  47. return (0, _freezeSys2.default)((0, _toPlainObject2.default)((0, _cloneDeep2.default)(data)));
  48. }