Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful

Package Overview
Dependencies
Maintainers
5
Versions
452
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

2

dist/contentful.min.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.contentful = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function createClient(e){return new Client(e||{})}function isParseableResource(e){return e&&e.sys&&e.sys.type in parseableResourceTypes}function parseResource(e){var t=parseableResourceTypes[e.sys.type];return t.parse(e)}function makeSearchResultParser(e){return function(t){walkMutate(t,isParseableResource,parseResource);var n=e.resolveLinks?(0,_contentfulResolveResponse2["default"])(t):t.items;return Object.defineProperties(n,{limit:{value:t.limit,enumerable:!1},skip:{value:t.skip,enumerable:!1},total:{value:t.total,enumerable:!1}}),n}}function stringifyArrayValues(e){return keys(e).reduce(function(t,n){var r=e[n];return t[n]=Array.isArray(r)?r.join(","):r,t},{})}function walkMutate(e,t,n){if(t(e))return n(e);if(e&&"object"==typeof e)for(var r in e)e[r]=walkMutate(e[r],t,n);return e}function nodeify(e,t){return t?e.then(function(e){return t(null,e),e})["catch"](function(e){throw t(e),e}):e}Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function e(e,t){var n=[],r=!0,s=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(o){s=!0,i=o}finally{try{!r&&u["return"]&&u["return"]()}finally{if(s)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();exports.createClient=createClient;var _axios=require("axios"),_axios2=_interopRequireDefault(_axios),_contentfulResolveResponse=require("contentful-resolve-response"),_contentfulResolveResponse2=_interopRequireDefault(_contentfulResolveResponse),_querystring=require("querystring"),_querystring2=_interopRequireDefault(_querystring),Client=function(){function e(t){var n=t.accessToken,r=t.space,s=t.secure,i=t.host,a=t.headers,u=t.agent;if(_classCallCheck(this,e),!n)throw new TypeError("Expected property accessToken");if(!r)throw new TypeError("Expected property space");var o=s===!1,l=i&&i.split(":")||[],c=_slicedToArray(l,2),y=c[0],f=c[1];y=y||"cdn.contentful.com",f=f||(o?80:443),this.options={baseUrl:(o?"http":"https")+"://"+y+":"+f+"/spaces/"+r,accessToken:n,headers:a||{},resolveLinks:!0},this.agent=u}return _createClass(e,[{key:"_request",value:function(e,t){t||(t={}),t.access_token=this.options.accessToken;var n={headers:this.options.headers,method:"get",url:""+this.options.baseUrl+e+"?"+_querystring2["default"].stringify(t)};return this.agent&&(n.agent=this.agent),n.headers["Content-Type"]="application/vnd.contentful.delivery.v1+json",(0,_axios2["default"])(n).then(function(e){return e.data})["catch"](function(e){throw e.data})}},{key:"asset",value:function(e,t){return nodeify(this._request("/assets/"+e).then(parseResource),t)}},{key:"assets",value:function(e,t){var n=new Query(e),r=this._request("/assets",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"contentType",value:function(e,t){var n=this._request("/content_types/"+e).then(ContentType.parse);return nodeify(n,t)}},{key:"contentTypes",value:function(e,t){var n=new Query(e),r=this._request("/content_types",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"entry",value:function(e,t){var n=this._request("/entries/"+e).then(Entry.parse);return nodeify(n,t)}},{key:"entries",value:function(e,t){var n=new Query(e),r=this._request("/entries",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"space",value:function(e){return nodeify(this._request(""),e)}},{key:"_pagedSync",value:function(e){var t=this;return this._request("/sync",e.query).then(function(n){return e.append(n),e.done?{items:e.items,nextSyncToken:e.nextSyncToken}:t._pagedSync(e)})}},{key:"sync",value:function(e,t){if(!e||!e.initial&&!e.nextSyncToken)throw new Error("Please provide either the initial flag or a nextSyncToken for syncing");e.nextSyncToken&&(e.sync_token=e.nextSyncToken,delete e.initial,delete e.nextSyncToken);var n=new Query(e),r=makeSearchResultParser({resolveLinks:!1}),s=this._pagedSync(new Sync(n)).then(function(e){return e.items=r(e),e});return nodeify(s,t)}}]),e}(),Asset=function(){function e(t){var n=t.sys,r=t.fields;_classCallCheck(this,e),this.sys=new Sys(n),this.fields=r}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Entry=function(){function e(t){var n=t.sys,r=t.fields;_classCallCheck(this,e),this.sys=new Sys(n),this.fields=r}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),ContentType=function(){function e(t){var n=t.sys,r=t.fields,s=t.name,i=t.displayField;_classCallCheck(this,e),this.sys=new Sys(n),this.name=s,this.displayField=i,this.fields=r&&r.map(Field.parse)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Field=function(){function e(t){_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Query=function(){function e(t){_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,[{key:"toQueryString",value:function(){return _querystring2["default"].stringify(this)}}],[{key:"parse",value:function(t){return new e(stringifyArrayValues(t))}}]),e}(),Space=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Sys=function(){function e(t){var n=t.id,r=t.revision,s=t.type,i=t.locale,a=t.contentType,u=t.createdAt,o=(t.linkType,t.updatedAt),l=t.space;_classCallCheck(this,e),this.id=n,this.revision=r,this.type=s,this.locale=i,this.space=l&&Link.parse(l),this.contentType=a&&new Link(a),this.createdAt=u&&new Date(u),this.updatedAt=o&&new Date(o)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Link=function(){function e(t){var n=t.sys;_classCallCheck(this,e),this.sys=new Sys(n)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Sync=function(){function e(t){_classCallCheck(this,e),this.query=t,this.items=[],this.done=!1}return _createClass(e,[{key:"append",value:function(e){var t=this;if(this.items=this.items.concat(e.items),e.nextPageUrl){var n=e.nextPageUrl.split("?");this.query=Object.keys(this.query).reduce(function(e,n){return"initial"!==n&&"type"!==n&&"sync_token"!==n&&(e[n]=t.query[n]),e},{}),this.query.sync_token=_querystring2["default"].parse(n[1]).sync_token}else if(e.nextSyncUrl){var r=e.nextSyncUrl.split("?");this.nextSyncToken=_querystring2["default"].parse(r[1]).sync_token,this.done=!0}}}]),e}(),parseableResourceTypes={Asset:Asset,ContentType:ContentType,Entry:Entry,Space:Space};
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function createClient(e){return new Client(e||{})}function isParseableResource(e){return e&&e.sys&&e.sys.type in parseableResourceTypes}function parseResource(e){var t=parseableResourceTypes[e.sys.type];return t.parse(e)}function makeSearchResultParser(e){return function(t){walkMutate(t,isParseableResource,parseResource);var n=e.resolveLinks?(0,_contentfulResolveResponse2["default"])(t):t.items;return Object.defineProperties(n,{limit:{value:t.limit,enumerable:!1},skip:{value:t.skip,enumerable:!1},total:{value:t.total,enumerable:!1}}),n}}function stringifyArrayValues(e){return keys(e).reduce(function(t,n){var r=e[n];return t[n]=Array.isArray(r)?r.join(","):r,t},{})}function walkMutate(e,t,n){if(t(e))return n(e);if(e&&"object"==typeof e)for(var r in e)e[r]=walkMutate(e[r],t,n);return e}function nodeify(e,t){return t?e.then(function(e){return t(null,e),e})["catch"](function(e){throw t(e),e}):e}Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function e(e,t){var n=[],r=!0,s=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(o){s=!0,i=o}finally{try{!r&&u["return"]&&u["return"]()}finally{if(s)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();exports.createClient=createClient;var _axios=require("axios"),_axios2=_interopRequireDefault(_axios),_contentfulResolveResponse=require("contentful-resolve-response"),_contentfulResolveResponse2=_interopRequireDefault(_contentfulResolveResponse),_querystring=require("querystring"),_querystring2=_interopRequireDefault(_querystring),Client=function(){function e(t){var n=t.accessToken,r=t.space,s=t.secure,i=t.host,a=t.headers,u=t.agent;if(_classCallCheck(this,e),!n)throw new TypeError("Expected property accessToken");if(!r)throw new TypeError("Expected property space");var o=s===!1,l=i&&i.split(":")||[],c=_slicedToArray(l,2),y=c[0],f=c[1];y=y||"cdn.contentful.com",f=f||(o?80:443),this.options={baseUrl:(o?"http":"https")+"://"+y+":"+f+"/spaces/"+r,accessToken:n,headers:a||{},resolveLinks:!0},this.agent=u}return _createClass(e,[{key:"_request",value:function(e,t){t||(t={}),t.access_token=this.options.accessToken;var n={headers:this.options.headers,method:"get",url:""+this.options.baseUrl+e+"?"+_querystring2["default"].stringify(t)};return this.agent&&(n.agent=this.agent),n.headers["Content-Type"]="application/vnd.contentful.delivery.v1+json",n.headers["User-Agent"]="contentful.js/2.x",(0,_axios2["default"])(n).then(function(e){return e.data})["catch"](function(e){throw e.data})}},{key:"asset",value:function(e,t){return nodeify(this._request("/assets/"+e).then(parseResource),t)}},{key:"assets",value:function(e,t){var n=new Query(e),r=this._request("/assets",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"contentType",value:function(e,t){var n=this._request("/content_types/"+e).then(ContentType.parse);return nodeify(n,t)}},{key:"contentTypes",value:function(e,t){var n=new Query(e),r=this._request("/content_types",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"entry",value:function(e,t){var n=this._request("/entries/"+e).then(Entry.parse);return nodeify(n,t)}},{key:"entries",value:function(e,t){var n=new Query(e),r=this._request("/entries",n).then(makeSearchResultParser({resolveLinks:this.options.resolveLinks}));return nodeify(r,t)}},{key:"space",value:function(e){return nodeify(this._request(""),e)}},{key:"_pagedSync",value:function(e){var t=this;return this._request("/sync",e.query).then(function(n){return e.append(n),e.done?{items:e.items,nextSyncToken:e.nextSyncToken}:t._pagedSync(e)})}},{key:"sync",value:function(e,t){if(!e||!e.initial&&!e.nextSyncToken)throw new Error("Please provide either the initial flag or a nextSyncToken for syncing");e.nextSyncToken&&(e.sync_token=e.nextSyncToken,delete e.initial,delete e.nextSyncToken);var n=new Query(e),r=makeSearchResultParser({resolveLinks:!1}),s=this._pagedSync(new Sync(n)).then(function(e){return e.items=r(e),e});return nodeify(s,t)}}]),e}(),Asset=function(){function e(t){var n=t.sys,r=t.fields;_classCallCheck(this,e),this.sys=new Sys(n),this.fields=r}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Entry=function(){function e(t){var n=t.sys,r=t.fields;_classCallCheck(this,e),this.sys=new Sys(n),this.fields=r}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),ContentType=function(){function e(t){var n=t.sys,r=t.fields,s=t.name,i=t.displayField;_classCallCheck(this,e),this.sys=new Sys(n),this.name=s,this.displayField=i,this.fields=r&&r.map(Field.parse)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Field=function(){function e(t){_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Query=function(){function e(t){_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,[{key:"toQueryString",value:function(){return _querystring2["default"].stringify(this)}}],[{key:"parse",value:function(t){return new e(stringifyArrayValues(t))}}]),e}(),Space=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];_classCallCheck(this,e);for(var n in t)this[n]=t[n]}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Sys=function(){function e(t){var n=t.id,r=t.revision,s=t.type,i=t.locale,a=t.contentType,u=t.createdAt,o=(t.linkType,t.updatedAt),l=t.space;_classCallCheck(this,e),this.id=n,this.revision=r,this.type=s,this.locale=i,this.space=l&&Link.parse(l),this.contentType=a&&new Link(a),this.createdAt=u&&new Date(u),this.updatedAt=o&&new Date(o)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Link=function(){function e(t){var n=t.sys;_classCallCheck(this,e),this.sys=new Sys(n)}return _createClass(e,null,[{key:"parse",value:function(t){return new e(t)}}]),e}(),Sync=function(){function e(t){_classCallCheck(this,e),this.query=t,this.items=[],this.done=!1}return _createClass(e,[{key:"append",value:function(e){var t=this;if(this.items=this.items.concat(e.items),e.nextPageUrl){var n=e.nextPageUrl.split("?");this.query=Object.keys(this.query).reduce(function(e,n){return"initial"!==n&&"type"!==n&&"sync_token"!==n&&(e[n]=t.query[n]),e},{}),this.query.sync_token=_querystring2["default"].parse(n[1]).sync_token}else if(e.nextSyncUrl){var r=e.nextSyncUrl.split("?");this.nextSyncToken=_querystring2["default"].parse(r[1]).sync_token,this.done=!0}}}]),e}(),parseableResourceTypes={Asset:Asset,ContentType:ContentType,Entry:Entry,Space:Space};

@@ -4,0 +4,0 @@

@@ -88,2 +88,3 @@ "use strict";

params.headers["Content-Type"] = "application/vnd.contentful.delivery.v1+json";
params.headers["User-Agent"] = "contentful.js/2.x";

@@ -90,0 +91,0 @@ return axios(params).then(function (response) {

@@ -53,2 +53,3 @@ 'use strict';

params.headers['Content-Type'] = 'application/vnd.contentful.delivery.v1+json';
params.headers['User-Agent'] = 'contentful.js/2.x';

@@ -55,0 +56,0 @@ return axios(params)

{
"name": "contentful",
"description": "Client for Contentful's Content Delivery API",
"version": "2.1.0",
"version": "2.1.1",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",

@@ -6,0 +6,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc