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

contentstack

Package Overview
Dependencies
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentstack - npm Package Compare versions

Comparing version 3.1.1 to 3.2.1

src/core/modules/assets.js

1

config.js

@@ -9,2 +9,3 @@ const config = {

entries: "/entries/",
assets: "/assets/",
environments: "/environments/"

@@ -11,0 +12,0 @@ }

27

dist/web/contentstack.js

@@ -1,19 +0,8 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Contentstack=t():e.Contentstack=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=29)}([function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t,n){"use strict";(function(e){function r(e){return e&&e.__esModule?e:{default:e}}function o(e){var t=void 0===e?"undefined":p(e);switch(t){case"object":t,Array.isArray(e)&&(t="array");break;default:t}return t}function i(e,t){var n=this;return function e(t,r){for(var o in r)"object"==n._type(r[o])&&n._type(t[o])==n._type(r[o])?e(t[o],r[o]):"array"==n._type(r[o])&&n._type(t[o])==n._type(r[o])?t[o]=t[o].concat(r[o]):t[o]=r[o]}(e,t),e}function u(e,t){if(e&&t)for(var n in t)e[n]=t[n];return e}function c(){return"undefined"!=typeof window&&"object"===(void 0===e?"undefined":p(e))&&"browser"===e.title}function s(e,t,n){if(e&&e.requestParams){var r=u({},e.requestParams.body?e.requestParams.body.query||{}:{});return r.environment_uid&&(delete r.environment_uid,r.environment=e.environment),r.environment=e.environment,{content_type_uid:e.content_type_uid,locale:r.locale||"en-us",query:r,entry_uid:e.entry_uid,single:t||"false",toJSON:n||"false",api_key:e.requestParams.headers?e.requestParams.headers.api_key:""}}}function a(e){try{var t=f(JSON.stringify(e)),n=[];return n.push(e.content_type_uid),n.push(e.locale),e.entry_uid&&n.push(e.entry_uid),n.push(t),n.join(".")}catch(e){}}function f(e){var t,n,r,o=0;if(0===e.length)return o;for(t=0,r=e.length;t<r;t++)n=e.charCodeAt(t),o=(o<<5)-o+n,o|=0;return o<-1?-1*o:o}function l(e){if(e&&e.entries&&void 0!==e.entries)if(e.entries&&e.entries.length)for(var t=0,n=e.entries.length;t<n;t++)e.entries[t]=(0,g.default)(e.entries[t]);else e.entries=[];else e&&void 0!==e.entry&&(e.entry=(0,g.default)(e.entry));return e}function h(e){var t=[];return e&&Object.keys(e).length&&(void 0!==e.entries&&t.push(e.entries),void 0!==e.schema&&t.push(e.schema),void 0!==e.count&&t.push(e.count),void 0!==e.entry&&(t=e.entry)),t}function y(e){var t=e.environment_uid;t?e._query.environment_uid=t:e._query.environment=e.environment;var n=v.default.defer(),r=e,o=void 0!==r.queryCachePolicy?r.queryCachePolicy:r.cachePolicy,i=void 0!==r.tojson&&r.tojson,c=!(!r.entry_uid&&!r.singleEntry),f=a(s(r,c,i));if(e&&e.requestParams&&e.requestParams.body&&e.requestParams.body.query){var y=JSON.parse(JSON.stringify(e.requestParams.body.query));"object"!==(void 0===y?"undefined":p(y))&&(y=JSON.parse(y)),delete e.requestParams.body.query,e.requestParams.body=u(e.requestParams.body,y)}var d=function(){return function(e,t){try{if(e)throw e;return i||(t=l(t)),n.resolve(h(t))}catch(e){return n.reject(e)}}},m=function(t){t&&(0,_.default)(e.requestParams).then(function(t){try{r.entry_uid=r.tojson=r.queryCachePolicy=void 0;var u={};if(e.singleEntry){if(e.singleEntry=!1,t.schema&&(u.schema=t.schema),!t.entries||!t.entries.length)return 2!==o?n.reject({error_code:141,error_message:"The requested entry doesn't exist."}):void r.provider.get(f,d());u.entry=t.entries[0]}else u=t;if(-1===o)return i||(u=l(u)),n.resolve(h(u));r.provider.set(f,u,function(e){try{if(e)throw e;return i||(u=l(u)),n.resolve(h(u))}catch(e){return n.reject(e)}})}catch(e){return n.reject({message:e.message})}}.bind(r)).catch(function(e){if(2!==o)return n.reject(e);r.provider.get(f,d())})};switch(o){case 1:r.provider.get(f,function(e,t){try{if(!e&&t)return i||(t=l(t)),n.resolve(h(t));m(!0)}catch(e){return n.reject(e)}});break;case 2:case 0:case void 0:case-1:m(!0)}return 3!==o?n.promise:{cache:function(){var e=v.default.defer();return r.provider.get(f,function(t,n){try{return t?e.reject(t):(i||(n=l(n)),e.resolve(h(n)))}catch(t){return e.reject(t)}}),e.promise}(),network:function(){return m(!0),n.promise}(),both:function(t){r.provider.get(f,function(e,n){i||(n=l(n)),t(e,h(n))}),(0,_.default)(e.requestParams).then(function(n){try{r.entry_uid=r.tojson=r.queryCachePolicy=void 0;var o={},u=null;e.singleEntry?(e.singleEntry=!1,n.schema&&(o.schema=n.schema),n.entries&&n.entries.length?o.entry=n.entries[0]:u={error_code:141,error_message:"The requested entry doesn't exist."}):o=n,i||(o=l(o)),t(u,h(o))}catch(e){t(e)}}.bind(r)).catch(function(e){t(e)})}}}Object.defineProperty(t,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t._type=o,t.mergeDeep=i,t.merge=u,t.isBrowser=c,t.parseQueryFromParams=s,t.getHash=a,t.generateHash=f,t.resultWrapper=l,t.spreadResult=h,t.sendRequest=y;var d=n(12),v=r(d),m=n(4),_=r(m),b=n(31),g=r(b)}).call(t,n(2))},function(e,t,n){"use strict";function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function u(e){if(h===clearTimeout)return clearTimeout(e);if((h===o||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function c(){v&&p&&(v=!1,p.length?d=p.concat(d):m=-1,d.length&&s())}function s(){if(!v){var e=i(c);v=!0;for(var t=d.length;t;){for(p=d,d=[];++m<t;)p&&p[m].run();m=-1,t=d.length}p=null,v=!1,u(e)}}function a(e,t){this.fun=e,this.array=t}function f(){}var l,h,y=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:r}catch(e){l=r}try{h="function"==typeof clearTimeout?clearTimeout:o}catch(e){h=o}}();var p,d=[],v=!1,m=-1;y.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new a(e,t)),1!==d.length||v||i(s)},a.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={},y.on=f,y.addListener=f,y.once=f,y.off=f,y.removeListener=f,y.removeAllListeners=f,y.emit=f,y.prependListener=f,y.prependOnceListener=f,y.listeners=function(e){return[]},y.binding=function(e){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(e){throw new Error("process.chdir is not supported")},y.umask=function(){return 0}},function(e,t,n){"use strict";(function(r){var o;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(i){void 0!==(o=function(e){var t,o="undefined"!=typeof setTimeout&&setTimeout,i=function(e,t){return setTimeout(e,t)},u=function(e){return clearTimeout(e)},c=function(e){return o(e,0)};if(function(){return void 0!==r&&"[object process]"===Object.prototype.toString.call(r)}())c=function(e){return r.nextTick(e)};else if(t=function(){return"undefined"!=typeof MutationObserver&&MutationObserver||"undefined"!=typeof WebKitMutationObserver&&WebKitMutationObserver}())c=function(e){function t(){var e=n;n=void 0,e()}var n,r=document.createTextNode("");new e(t).observe(r,{characterData:!0});var o=0;return function(e){n=e,r.data=o^=1}}(t);else if(!o){var s=n(!function(){var e=new Error('Cannot find module "vertx"');throw e.code="MODULE_NOT_FOUND",e}());i=function(e,t){return s.setTimer(t,e)},u=s.cancelTimer,c=s.runOnLoop||s.runOnContext}return{setTimer:i,clearTimer:u,asap:c}}.call(t,n,t,e))&&(e.exports=o)}(n(0))}).call(t,n(2))},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){var t=l.default.defer(),n=new a.default,r=e.url,o=e.headers;if(e.body&&"object"===u(e.body)){delete e.body._method;var i=function e(t,n){var r,o=[];for(r in t)if(t.hasOwnProperty(r)){var i=n?n+"["+r+"]":r,c=t[r];o.push(null!==c&&"object"===(void 0===c?"undefined":u(c))&&"query"!==r?e(c,i):i+"="+("query"!==r?encodeURIComponent(c):JSON.stringify(c)))}return o.join("&")}(e.body)}n.open("GET",r+"?"+i,!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.setRequestHeader("X-User-Agent","contentstack-(JS-SDK)/"+y.version);for(var c in o)n.setRequestHeader(c,o[c]);return e.body,n.send(),n.onreadystatechange=function(){if(4===n.readyState){var e,r=n.responseText;try{r=JSON.parse(r)}catch(t){e={error_code:141,message:"Could not parse the response received from the server."}}n.status>=200&&n.status<300?t.resolve(r):t.reject(r||e)}},t.promise}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=i;var c=n(1),s=(o(c),n(32)),a=r(s),f=n(12),l=r(f),h=n(34),y=o(h)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(28),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i={};i.providers=function(e){if(e)return o.default;console.error("Kindly provide valid provider.")},i.policies={IGNORE_CACHE:-1,ONLY_NETWORK:0,CACHE_ELSE_NETWORK:1,NETWORK_ELSE_CACHE:2,CACHE_THEN_NETWORK:3},t.default=i},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=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}}(),s=n(13),a=o(s),f=n(1),l=r(f),h=n(11),y=o(h),p=n(30),d=o(p),v=n(4),m=o(v),_=n(10),b=(r(_),n(5)),g=o(b),j=function(){function e(){i(this,e),this.config=a.default,this.cachePolicy=g.default.policies.IGNORE_CACHE,this.provider=g.default.providers("localstorage");for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];switch(n.length){case 1:if("object"===u(n[0])&&"string"==typeof n[0].api_key&&"string"==typeof n[0].access_token&&"string"==typeof n[0].environment)return this.headers={api_key:n[0].api_key,access_token:n[0].access_token},this.environment=n[0].environment,this;console.error("Kindly provide valid object parameters.");case 3:if("string"==typeof n[0]&&"string"==typeof n[1]&&"string"==typeof n[2])return this.headers={api_key:n[0],access_token:n[1]},this.environment=n[2],this;console.error("Kindly provide valid string parameters.");default:console.error("Kindly provide valid parameters to initialize the Built.io Contentstack javascript-SDK Stack.")}}return c(e,[{key:"setPort",value:function(e){return"number"==typeof e&&(this.config.port=e),this}},{key:"setProtocol",value:function(e){return"string"==typeof e&&~["https","http"].indexOf(e)&&(this.config.protocol=e),this}},{key:"setHost",value:function(e){return"string"==typeof e&&e&&(this.config.host=e),this}},{key:"setCachePolicy",value:function(e){return"number"==typeof e&&e>=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":u(e))&&(this.provider=e),this}},{key:"clearByQuery",value:function(){if(this.provider&&"function"==typeof this.provider.clearByQuery)return this.provider.clearByQuery.apply(this.provider,arguments)}},{key:"clearByContentType",value:function(){if(this.provider&&"function"==typeof this.provider.clearByContentType)return this.provider.clearByContentType.apply(this.provider,arguments)}},{key:"clearAll",value:function(){if(this.provider&&"function"==typeof this.provider.clearAll)return this.provider.clearAll.apply(this.provider,arguments)}},{key:"getCacheProvider",value:function(){return this.provider}},{key:"ContentType",value:function(e){return e&&"string"==typeof e&&(this.content_type_uid=e),this}},{key:"Entry",value:function(e){var t=new y.default;return e&&"string"==typeof e&&(t.entry_uid=e),l.merge(t,this)}},{key:"Query",value:function(){var e=new d.default;return l.merge(e,this)}},{key:"getLastActivities",value:function(){var e={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",only_last_activity:!0,environment:this.environment}};return(0,m.default)(e)}}]),e}();t.default=j},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){function e(t){Error.call(this),this.message=t,this.name=e.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){function e(e,n){function r(t,r,i){var u=e._defer(),c=i.length;return o({f:t,thisArg:r,args:i,params:new Array(c),i:c-1,call:n},u._handler),u}function o(t,r){if(t.i<0)return n(t.f,t.thisArg,t.params,r);e._handler(t.args[t.i]).fold(i,t,void 0,r)}function i(e,t,n){e.params[e.i]=t,e.i-=1,o(e,n)}return arguments.length<2&&(n=t),r}function t(e,t,n,r){try{r.resolve(e.apply(t,n))}catch(e){r.reject(e)}}return e.tryCatchResolve=t,e}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){function e(){return{state:"pending"}}function t(e){return{state:"rejected",reason:e}}function n(e){return{state:"fulfilled",value:e}}function r(r){var o=r.state();return 0===o?e():o>0?n(r.value):t(r.value)}return{pending:e,fulfilled:n,rejected:t,inspect:r}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";function r(e){var t=f.default.getItem(e);try{t=JSON.parse(t)}catch(e){return t}return t||null}function o(e,t){"object"===(void 0===t?"undefined":c(t))?f.default.setItem(e,JSON.stringify(t)):f.default.setItem(e,t)}function i(){return f.default||null}function u(){return f.default?Object.keys(f.default):[]}Object.defineProperty(t,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.get=r,t.set=o,t.getStorage=i,t.getKeys=u;var s=n(1),a=(function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);t.default=e}(s),n(33)),f=function(e){return e&&e.__esModule?e:{default:e}}(a)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=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}}(),u=n(1),c=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(u),s=n(6),a=(function(e){e&&e.__esModule}(s),function(e){return function(){switch(this._query[e]=this._query[e]||{},arguments.length){case 1:if(Array.isArray(arguments[0])||"string"==typeof arguments[0]){var t=this._query[e].BASE||[];return t=t.concat(arguments[0]),this._query[e].BASE=t,this}console.error("Kindly provide valid parameters");break;case 2:if("string"==typeof arguments[0]&&(Array.isArray(arguments[1])||"string"==typeof arguments[1])){var t=this._query[e][arguments[0]]||[];return t=t.concat(arguments[1]),this._query[e][arguments[0]]=t,this}console.error("Kindly provide valid parameters");break;default:console.error("Kindly provide valid parameters")}}}),f=function(){function e(){return r(this,e),this._query={},this.only=a("only"),this.except=a("except"),this}return i(e,[{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":o(e))&&(this.provider=e),this}},{key:"setCachePolicy",value:function(e){return"number"==typeof e&&e>=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"includeReference",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(Array.isArray(t)||"string"==typeof t){if(arguments.length)for(var r=0;r<arguments.length;r++)this._query.include=this._query.include||[],this._query.include=this._query.include.concat(arguments[r]);return this}console.error("Argument should be a String or an Array.")}},{key:"language",value:function(e){if(e&&"string"==typeof e)return this._query.locale=e,this;console.error("Argument should be a String.")}},{key:"addQuery",value:function(e,t){if(e&&t&&"string"==typeof e)return this._query[e]=t,this;console.error("First argument should be a String.")}},{key:"includeSchema",value:function(){return this._query.include_schema=!0,this}},{key:"includeOwner",value:function(){return this._query.include_owner=!0,this}},{key:"toJSON",value:function(){return this.tojson=!0,this}},{key:"fetch",value:function(){if(this.entry_uid)return this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries+this.entry_uid,body:{_method:"GET",query:this._query}},c.sendRequest(this);console.error("Kindly provide an entry uid. e.g. .Entry('bltsomething123')")}}]),e}();t.default=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(27),o=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=o.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={protocol:"https",host:"cdn.contentstack.io",port:443,version:"v3",urls:{content_types:"/content_types/",entries:"/entries/",environments:"/environments/"}};t.default=r},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){return n(26)({scheduler:new(n(15))(n(3).asap)})}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){function e(e){this._async=e,this._running=!1,this._queue=this,this._queueLen=0,this._afterQueue={},this._afterQueueLen=0;var t=this;this.drain=function(){t._drain()}}return e.prototype.enqueue=function(e){this._queue[this._queueLen++]=e,this.run()},e.prototype.afterQueue=function(e){this._afterQueue[this._afterQueueLen++]=e,this.run()},e.prototype.run=function(){this._running||(this._running=!0,this._async(this.drain))},e.prototype._drain=function(){for(var e=0;e<this._queueLen;++e)this._queue[e].run(),this._queue[e]=void 0;for(this._queueLen=0,this._running=!1,e=0;e<this._afterQueueLen;++e)this._afterQueue[e].run(),this._afterQueue[e]=void 0;this._afterQueueLen=0},e}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){var t=n(9),r=n(8);return function(e){function n(t){function n(e){f=null,this.resolve(e)}function r(e){this.resolved||(f.push(e),0==--a&&this.reject(f))}for(var o,i,u=e._defer(),c=u._handler,s=t.length>>>0,a=s,f=[],l=0;l<s;++l)if(void 0!==(i=t[l])||l in t){if(o=e._handler(i),o.state()>0){c.become(o),e._visitRemaining(t,l,o);break}o.visit(c,n,r)}else--a;return 0===a&&c.reject(new RangeError("any(): array must not be empty")),u}function o(t,n){function r(e){this.resolved||(f.push(e),0==--y&&(l=null,this.resolve(f)))}function o(e){this.resolved||(l.push(e),0==--i&&(f=null,this.reject(l)))}var i,u,c,s=e._defer(),a=s._handler,f=[],l=[],h=t.length>>>0,y=0;for(c=0;c<h;++c)(void 0!==(u=t[c])||c in t)&&++y;for(n=Math.max(n,0),i=y-n+1,y=Math.min(n,y),n>y?a.reject(new RangeError("some(): array must contain at least "+n+" item(s), but had "+y)):0===y&&a.resolve(f),c=0;c<h;++c)(void 0!==(u=t[c])||c in t)&&e._handler(u).visit(a,r,o,a.notify);return s}function i(t,n){return e._traverse(n,t)}function u(t,n){var r=_.call(t);return e._traverse(n,r).then(function(e){return c(r,e)})}function c(t,n){for(var r=n.length,o=new Array(r),i=0,u=0;i<r;++i)n[i]&&(o[u++]=e._handler(t[i]).value);return o.length=u,o}function s(e){return d(e.map(a))}function a(n){var r;return n instanceof e&&(r=n._handler.join()),r&&0===r.state()||!r?p(n).then(t.fulfilled,t.rejected):(r._unreport(),t.inspect(r))}function f(e,t){return arguments.length>2?v.call(e,h(t),arguments[2]):v.call(e,h(t))}function l(e,t){return arguments.length>2?m.call(e,h(t),arguments[2]):m.call(e,h(t))}function h(e){return function(t,n,r){return y(e,void 0,[t,n,r])}}var y=r(e),p=e.resolve,d=e.all,v=Array.prototype.reduce,m=Array.prototype.reduceRight,_=Array.prototype.slice;return e.any=n,e.some=o,e.settle=s,e.map=i,e.filter=u,e.reduce=f,e.reduceRight=l,e.prototype.spread=function(e){return this.then(d).then(function(t){return e.apply(this,t)})},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(i){void 0!==(r=function(){function e(){throw new TypeError("catch predicate must be a function")}function t(e,t){return n(t)?e instanceof t:t(e)}function n(e){return e===Error||null!=e&&e.prototype instanceof Error}function r(e){return("object"===(void 0===e?"undefined":o(e))||"function"==typeof e)&&null!==e}function i(e){return e}return function(n){function o(e,n){return function(r){return t(r,n)?e.call(this,r):a(r)}}function u(e,t,n,o){var i=e.call(t);return r(i)?c(i,n,o):n(o)}function c(e,t,n){return s(e).then(function(){return t(n)})}var s=n.resolve,a=n.reject,f=n.prototype.catch;return n.prototype.done=function(e,t){this._handler.visit(this._handler.receiver,e,t)},n.prototype.catch=n.prototype.otherwise=function(t){return arguments.length<2?f.call(this,t):"function"!=typeof t?this.ensure(e):f.call(this,o(arguments[1],t))},n.prototype.finally=n.prototype.ensure=function(e){return"function"!=typeof e?this:this.then(function(t){return u(e,this,i,t)},function(t){return u(e,this,a,t)})},n.prototype.else=n.prototype.orElse=function(e){return this.then(void 0,function(){return e})},n.prototype.yield=function(e){return this.then(function(){return e})},n.prototype.tap=function(e){return this.then(e).yield(this)},n}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){return function(e){return e.prototype.fold=function(t,n){var r=this._beget();return this._handler.fold(function(n,r,o){e._handler(n).fold(function(e,n,r){r.resolve(t.call(this,n,e))},r,this,o)},n,r._handler.receiver,r._handler),r},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){var t=n(9).inspect;return function(e){return e.prototype.inspect=function(){return t(e._handler(this))},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){return function(e){function t(e,t,r,o){return n(function(t){return[t,e(t)]},t,r,o)}function n(e,t,o,i){function u(i,u){return r(o(i)).then(function(){return n(e,t,o,u)})}return r(i).then(function(n){return r(t(n)).then(function(t){return t?n:r(e(n)).spread(u)})})}var r=e.resolve;return e.iterate=t,e.unfold=n,e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){return function(e){return e.prototype.progress=function(e){return this.then(void 0,void 0,e)},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){function t(e,t,n,o){return r.setTimer(function(){e(n,o,t)},t)}var r=n(3),o=n(7);return function(e){function n(e,n,r){t(i,e,n,r)}function i(e,t){t.resolve(e)}function u(e,t,n){var r=void 0===e?new o("timed out after "+n+"ms"):e;t.reject(r)}return e.prototype.delay=function(e){var t=this._beget();return this._handler.fold(n,e,void 0,t._handler),t},e.prototype.timeout=function(e,n){var o=this._beget(),i=o._handler,c=t(u,e,n,o._handler);return this._handler.visit(i,function(e){r.clearTimer(c),this.resolve(e)},function(e){r.clearTimer(c),this.reject(e)},i.notify),o},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){function t(e){throw e}function r(){}var o=n(3).setTimer,i=n(25);return function(e){function n(e){e.handled||(y.push(e),f("Potentially unhandled rejection ["+e.id+"] "+i.formatError(e.value)))}function u(e){var t=y.indexOf(e);t>=0&&(y.splice(t,1),l("Handled previous rejection ["+e.id+"] "+i.formatObject(e.value)))}function c(e,t){h.push(e,t),null===p&&(p=o(s,0))}function s(){for(p=null;h.length>0;)h.shift()(h.shift())}var a,f=r,l=r;"undefined"!=typeof console&&(a=console,f=void 0!==a.error?function(e){a.error(e)}:function(e){a.log(e)},l=void 0!==a.info?function(e){a.info(e)}:function(e){a.log(e)}),e.onPotentiallyUnhandledRejection=function(e){c(n,e)},e.onPotentiallyUnhandledRejectionHandled=function(e){c(u,e)},e.onFatalRejection=function(e){c(t,e.value)};var h=[],y=[],p=null;return e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(){return function(e){return e.prototype.with=e.prototype.withThis=function(e){var t=this._beget(),n=t._handler;return n.receiver=e,this._handler.chain(n,e),t},e}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";var r,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(i){void 0!==(r=function(){function e(e){var n="object"===(void 0===e?"undefined":o(e))&&null!==e&&(e.stack||e.message)?e.stack||e.message:t(e);return e instanceof Error?n:n+" (WARNING: non-Error used)"}function t(e){var t=String(e);return"[object Object]"===t&&"undefined"!=typeof JSON&&(t=n(e,t)),t}function n(e,t){try{return JSON.stringify(e)}catch(e){return t}}return{formatError:e,formatObject:t,tryStringify:n}}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";(function(r){var o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(u){void 0!==(o=function(){return function(e){function t(e,t){this._handler=e===j?t:n(e)}function n(e){function t(e){o.resolve(e)}function n(e){o.reject(e)}function r(e){o.notify(e)}var o=new q;try{e(t,n,r)}catch(e){n(e)}return o}function o(e){return N(e)?e:new t(j,new k(_(e)))}function u(e){return new t(j,new k(new P(e)))}function c(){return ne}function s(){return new t(j,new q)}function a(e,t){return new t(j,new q(e.receiver,e.join().context))}function f(e){return h(G,null,e)}function l(e,t){return h(B,e,t)}function h(e,n,r){function o(t,o,u){u.resolved||y(r,i,t,e(n,o,t),u)}function i(e,t,n){f[e]=t,0==--a&&n.become(new S(f))}for(var u,c="function"==typeof n?o:i,s=new q,a=r.length>>>0,f=new Array(a),l=0;l<r.length&&!s.resolved;++l)u=r[l],void 0!==u||l in r?y(r,c,l,u,s):--a;return 0===a&&s.become(new S(f)),new t(j,s)}function y(e,t,n,r,o){if(L(r)){var i=b(r),u=i.state();0===u?i.fold(t,n,void 0,o):u>0?t(n,i.value,o):(o.become(i),p(e,n+1,i))}else t(n,r,o)}function p(e,t,n){for(var r=t;r<e.length;++r)d(_(e[r]),n)}function d(e,t){if(e!==t){var n=e.state();0===n?e.visit(e,void 0,e._unreport):n<0&&e._unreport()}}function v(e){return"object"!==(void 0===e?"undefined":i(e))||null===e?u(new TypeError("non-iterable passed to race()")):0===e.length?c():1===e.length?o(e[0]):m(e)}function m(e){var n,r,o,i=new q;for(n=0;n<e.length;++n)if(void 0!==(r=e[n])||n in e){if(o=_(r),0!==o.state()){i.become(o),p(e,n+1,o);break}o.visit(i,i.resolve,i.reject)}return new t(j,i)}function _(e){return N(e)?e._handler.join():L(e)?g(e):new S(e)}function b(e){return N(e)?e._handler.join():g(e)}function g(e){try{var t=e.then;return"function"==typeof t?new O(t,e):new S(e)}catch(e){return new P(e)}}function j(){}function w(){}function q(e,n){t.createContext(this,n),this.consumers=void 0,this.receiver=e,this.handler=void 0,this.resolved=!1}function k(e){this.handler=e}function O(e,t){q.call(this),V.enqueue(new R(e,t,this))}function S(e){t.createContext(this),this.value=e}function P(e){t.createContext(this),this.id=++ee,this.value=e,this.handled=!1,this.reported=!1,this._report()}function T(e,t){this.rejection=e,this.context=t}function x(e){this.rejection=e}function E(){return new P(new TypeError("Promise cycle"))}function C(e,t){this.continuation=e,this.handler=t}function A(e,t){this.handler=t,this.value=e}function R(e,t,n){this._then=e,this.thenable=t,this.resolver=n}function M(e,t,n,r,o){try{e.call(t,n,r,o)}catch(e){r(e)}}function K(e,t,n,r){this.f=e,this.z=t,this.c=n,this.to=r,this.resolver=Z,this.receiver=this}function N(e){return e instanceof t}function L(e){return("object"===(void 0===e?"undefined":i(e))||"function"==typeof e)&&null!==e}function Q(e,n,r,o){if("function"!=typeof e)return o.become(n);t.enterContext(n),U(e,n.value,r,o),t.exitContext()}function H(e,n,r,o,i){if("function"!=typeof e)return i.become(r);t.enterContext(r),$(e,n,r.value,o,i),t.exitContext()}function J(e,n,r,o,i){if("function"!=typeof e)return i.notify(n);t.enterContext(r),I(e,n,o,i),t.exitContext()}function B(e,t,n){try{return e(t,n)}catch(e){return u(e)}}function U(e,t,n,r){try{r.become(_(e.call(n,t)))}catch(e){r.become(new P(e))}}function $(e,t,n,r,o){try{e.call(r,t,n,o)}catch(e){o.become(new P(e))}}function I(e,t,n,r){try{r.notify(e.call(n,t))}catch(e){r.notify(e)}}function D(e,t){t.prototype=Y(e.prototype),t.prototype.constructor=t}function G(e,t){return t}function F(){}function W(){if("function"==typeof CustomEvent)try{return new CustomEvent("unhandledRejection")instanceof CustomEvent}catch(e){}return!1}function z(){if("undefined"!=typeof document&&"function"==typeof document.createEvent)try{return document.createEvent("CustomEvent").initCustomEvent("eventType",!1,!0,{}),!0}catch(e){}return!1}var V=e.scheduler,X=function(){return void 0!==r&&null!==r&&"function"==typeof r.emit?function(e,t){return"unhandledRejection"===e?r.emit(e,t.value,t):r.emit(e,t)}:"undefined"!=typeof self&&W()?function(e,t){return function(n,r){var o=new t(n,{detail:{reason:r.value,key:r},bubbles:!1,cancelable:!0});return!e.dispatchEvent(o)}}(self,CustomEvent):"undefined"!=typeof self&&z()?function(e,t){return function(n,r){var o=t.createEvent("CustomEvent");return o.initCustomEvent(n,!1,!0,{reason:r.value,key:r}),!e.dispatchEvent(o)}}(self,document):F}(),Y=Object.create||function(e){function t(){}return t.prototype=e,new t};t.resolve=o,t.reject=u,t.never=c,t._defer=s,t._handler=_,t.prototype.then=function(e,t,n){var r=this._handler,o=r.join().state();if("function"!=typeof e&&o>0||"function"!=typeof t&&o<0)return new this.constructor(j,r);var i=this._beget(),u=i._handler;return r.chain(u,r.receiver,e,t,n),i},t.prototype.catch=function(e){return this.then(void 0,e)},t.prototype._beget=function(){return a(this._handler,this.constructor)},t.all=f,t.race=v,t._traverse=l,t._visitRemaining=p,j.prototype.when=j.prototype.become=j.prototype.notify=j.prototype.fail=j.prototype._unreport=j.prototype._report=F,j.prototype._state=0,j.prototype.state=function(){return this._state},j.prototype.join=function(){for(var e=this;void 0!==e.handler;)e=e.handler;return e},j.prototype.chain=function(e,t,n,r,o){this.when({resolver:e,receiver:t,fulfilled:n,rejected:r,progress:o})},j.prototype.visit=function(e,t,n,r){this.chain(Z,e,t,n,r)},j.prototype.fold=function(e,t,n,r){this.when(new K(e,t,n,r))},D(j,w),w.prototype.become=function(e){e.fail()};var Z=new w;D(j,q),q.prototype._state=0,q.prototype.resolve=function(e){this.become(_(e))},q.prototype.reject=function(e){this.resolved||this.become(new P(e))},q.prototype.join=function(){if(!this.resolved)return this;for(var e=this;void 0!==e.handler;)if((e=e.handler)===this)return this.handler=E();return e},q.prototype.run=function(){var e=this.consumers,t=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var n=0;n<e.length;++n)t.when(e[n])},q.prototype.become=function(e){this.resolved||(this.resolved=!0,this.handler=e,void 0!==this.consumers&&V.enqueue(this),void 0!==this.context&&e._report(this.context))},q.prototype.when=function(e){this.resolved?V.enqueue(new C(e,this.handler)):void 0===this.consumers?this.consumers=[e]:this.consumers.push(e)},q.prototype.notify=function(e){this.resolved||V.enqueue(new A(e,this))},q.prototype.fail=function(e){var t=void 0===e?this.context:e;this.resolved&&this.handler.join().fail(t)},q.prototype._report=function(e){this.resolved&&this.handler.join()._report(e)},q.prototype._unreport=function(){this.resolved&&this.handler.join()._unreport()},D(j,k),k.prototype.when=function(e){V.enqueue(new C(e,this))},k.prototype._report=function(e){this.join()._report(e)},k.prototype._unreport=function(){this.join()._unreport()},D(q,O),D(j,S),S.prototype._state=1,S.prototype.fold=function(e,t,n,r){H(e,t,this,n,r)},S.prototype.when=function(e){Q(e.fulfilled,this,e.receiver,e.resolver)};var ee=0;D(j,P),P.prototype._state=-1,P.prototype.fold=function(e,t,n,r){r.become(this)},P.prototype.when=function(e){"function"==typeof e.rejected&&this._unreport(),Q(e.rejected,this,e.receiver,e.resolver)},P.prototype._report=function(e){V.afterQueue(new T(this,e))},P.prototype._unreport=function(){this.handled||(this.handled=!0,V.afterQueue(new x(this)))},P.prototype.fail=function(e){this.reported=!0,X("unhandledRejection",this),t.onFatalRejection(this,void 0===e?this.context:e)},T.prototype.run=function(){this.rejection.handled||this.rejection.reported||(this.rejection.reported=!0,X("unhandledRejection",this.rejection)||t.onPotentiallyUnhandledRejection(this.rejection,this.context))},x.prototype.run=function(){this.rejection.reported&&(X("rejectionHandled",this.rejection)||t.onPotentiallyUnhandledRejectionHandled(this.rejection))},t.createContext=t.enterContext=t.exitContext=t.onPotentiallyUnhandledRejection=t.onPotentiallyUnhandledRejectionHandled=t.onFatalRejection=F;var te=new j,ne=new t(j,te);return C.prototype.run=function(){this.handler.join().when(this.continuation)},A.prototype.run=function(){var e=this.handler.consumers;if(void 0!==e)for(var t,n=0;n<e.length;++n)t=e[n],J(t.progress,this.value,this.handler,t.receiver,t.resolver)},R.prototype.run=function(){function e(e){r.resolve(e)}function t(e){r.reject(e)}function n(e){r.notify(e)}var r=this.resolver;M(this._then,this.thenable,e,t,n)},K.prototype.fulfilled=function(e){this.f.call(this.c,this.z,e,this.to)},K.prototype.rejected=function(e){this.to.reject(e)},K.prototype.progress=function(e){this.to.notify(e)},t}}.call(t,n,t,e))&&(e.exports=o)}(n(0))}).call(t,n(2))},function(e,t,n){"use strict";var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */
!function(o){void 0!==(r=function(e){function t(e,t,n,r){var o=k.resolve(e);return arguments.length<2?o:o.then(t,n,r)}function r(e){return new k(e)}function o(e){return function(){for(var t=0,n=arguments.length,r=new Array(n);t<n;++t)r[t]=arguments[t];return O(e,this,r)}}function i(e){for(var t=0,n=arguments.length-1,r=new Array(n);t<n;++t)r[t]=arguments[t+1];return O(e,this,r)}function u(){return new c}function c(){function e(e){r._handler.resolve(e)}function t(e){r._handler.reject(e)}function n(e){r._handler.notify(e)}var r=k._defer();this.promise=r,this.resolve=e,this.reject=t,this.notify=n,this.resolver={resolve:e,reject:t,notify:n}}function s(e){return e&&"function"==typeof e.then}function a(){return k.all(arguments)}function f(e){return t(e,k.all)}function l(e){return t(e,k.settle)}function h(e,n){return t(e,function(e){return k.map(e,n)})}function y(e,n){return t(e,function(e){return k.filter(e,n)})}var p=n(22),d=n(16),v=n(17),m=n(18),_=n(19),b=n(20),g=n(21),j=n(24),w=n(23),q=n(7),k=[d,v,m,b,g,_,j,p,w].reduce(function(e,t){return t(e)},n(14)),O=n(8)(k);return t.promise=r,t.resolve=k.resolve,t.reject=k.reject,t.lift=o,t.try=i,t.attempt=i,t.iterate=k.iterate,t.unfold=k.unfold,t.join=a,t.all=f,t.settle=l,t.any=o(k.any),t.some=o(k.some),t.race=o(k.race),t.map=h,t.filter=y,t.reduce=o(k.reduce),t.reduceRight=o(k.reduceRight),t.isPromiseLike=s,t.Promise=k,t.defer=u,t.TimeoutError=q,t}.call(t,n,t,e))&&(e.exports=r)}(n(0))},function(e,t,n){"use strict";function r(e,t){!t&&e&&e.length&&e.push("");var n,r=i.getKeys(),o=i.getStorage();if(e&&e.length){n=e.join(".");for(var u=0,c=r.length;u<c;u++)r[u]&&0===r[u].indexOf(n)&&delete o[r[u]]}else for(var u=0,c=r.length;u<c;u++)delete o[r[u]]}Object.defineProperty(t,"__esModule",{value:!0});var o=n(10),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(o),u={};u.get=function(e,t){try{t(null,i.get(e))}catch(e){t(e)}},u.set=function(e,t,n){try{e&&t&&i.set(e,t),n()}catch(e){n(e)}},u.clearByContentType=function(){try{if(2===arguments.length||3===arguments.length){var e=Array.prototype.slice.call(arguments),t=e.splice(-1,1).pop(),n=[];n.push.apply(n,e),r(n),t()}}catch(e){t(e)}},u.clearByQuery=function(e,t){try{for(var n=i.getKeys(),r=i.getStorage(),o=0,u=n.length;o<u;o++)n[o]&&~n[o].indexOf(e)&&delete r[n[o]];t()}catch(e){t(e)}},u.clearAll=function(e){try{r(),e()}catch(t){e(t)}},t.default=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=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}}(),u=n(6),c=r(u),s=n(5),a=r(s),f=function(){function e(){o(this,e),this.CachePolicy=a.default.policies}return i(e,[{key:"Stack",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new(Function.prototype.bind.apply(c.default,[null].concat(t)))}}]),e}();e.exports=new f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=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}}(),s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=n(4),f=(r(a),n(1)),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(f),h=n(11),y=r(h),p={compare:function(e){return function(t,n){if(t&&n&&"string"==typeof t&&void 0!==n)return this._query.query[t]=this._query.query[t]||{},this._query.query[t][e]=n,this;console.error("Kindly provide valid parameters.")}},contained:function(e){var t=e?"$in":"$nin";return function(e,n){if(e&&n&&"string"==typeof e&&Array.isArray(n))return this._query.query[e]=this._query.query[e]||{},this._query.query[e][t]=this._query.query[e][t]||[],this._query.query[e][t]=this._query.query[e][t].concat(n),this;console.error("Kindly provide valid parameters.")}},exists:function(e){return function(t){if(t&&"string"==typeof t)return this._query.query[t]=this._query.query[t]||{},this._query.query[t].$exists=e,this;console.error("Kindly provide valid parameters.")}},logical:function(e){return function(){for(var t=[],n=0,r=arguments.length;n<r;n++)arguments[n]instanceof d&&arguments[n]._query.query?t.push(arguments[n]._query.query):"object"===s(arguments[n])&&t.push(arguments[n]);return this._query.query[e]?this._query.query[e]=this._query.query[e].concat(t):this._query.query[e]=t,this}},sort:function(e){return function(t){if(t&&"string"==typeof t)return this._query[e]=t,this;console.error("Argument should be a string.")}},pagination:function(e){return function(t){if("number"==typeof t)return this._query[e]=t,this;console.error("Argument should be a number.")}}},d=function(e){function t(){o(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._query=e._query||{},e._query.query=e._query.query||{},e.lessThan=p.compare("$lt"),e.lessThanOrEqualTo=p.compare("$lte"),e.greaterThan=p.compare("$gt"),e.greaterThanOrEqualTo=p.compare("$gte"),e.notEqualTo=p.compare("$ne"),e.containedIn=p.contained(!0),e.notContainedIn=p.contained(!1),e.exists=p.exists(!0),e.notExists=p.exists(!1),e.ascending=p.sort("asc"),e.descending=p.sort("desc"),e.beforeUid=p.sort("before_uid"),e.afterUid=p.sort("after_uid"),e.skip=p.pagination("skip"),e.limit=p.pagination("limit"),e.or=p.logical("$or"),e.and=p.logical("$and"),e}return u(t,e),c(t,[{key:"equalTo",value:function(e,t){if(e&&"string"==typeof e)return this._query.query[e]=t,this;console.error("Kindly provide valid parameters.")}},{key:"where",value:function(e,t){if(e&&"string"==typeof e)return this._query.query[e]=t,this;console.error("Kindly provide valid parameters.")}},{key:"count",value:function(){return this._query.count=!0,this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries,body:{_method:"GET",query:this._query}},this}},{key:"query",value:function(e){if("object"===(void 0===e?"undefined":s(e)))return this._query.query=l.mergeDeep(this._query.query,e),this;console.error("Kindly provide valid parameters")}},{key:"tags",value:function(e){if(Array.isArray(e))return this._query.tags=e,this;console.error("Kindly provide valid parameters")}},{key:"includeCount",value:function(){return this._query.include_count=!0,this}},{key:"getQuery",value:function(){return this._query.query||{}}},{key:"regex",value:function(e,t,n){if(e&&t&&"string"==typeof e&&"string"==typeof t)return this._query.query[e]={$regex:t},n&&(this._query.query[e].$options=n),this;console.error("Kindly provide valid parameters.")}},{key:"search",value:function(e){if(e&&"string"==typeof e)return this._query.typeahead=e,this;console.error("Kindly provide valid parameters.")}},{key:"find",value:function(){return this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries,body:{_method:"GET",query:this._query}},l.sendRequest(this)}},{key:"findOne",value:function(){return this.singleEntry=!0,this._query.limit=1,this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries,body:{_method:"GET",query:this._query}},l.sendRequest(this)}}]),t}(y.default);t.default=d},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=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}}(),i=n(1),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(i),c=function(){function e(t){return r(this,e),t&&(this.object=function(){return t}),this}return o(e,[{key:"toJSON",value:function(){return this.object()?u.mergeDeep(JSON.parse(JSON.stringify({})),this.object()):null}},{key:"get",value:function(e){if(this.object()&&e){return e.split(".").reduce(function(e,t){return e[t]},this.object())}}}]),e}();e.exports=function(e){return new c(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=XMLHttpRequest},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=window.localStorage},function(e,t){e.exports={name:"contentstack",version:"3.1.1",description:"The Built.io Contentstack Javascript SDK",homepage:"https://www.built.io/products/contentstack/overview",author:{name:"Built.io Contentstack",url:"https://www.built.io/"},main:"dist/node/contentstack.js",_id:"contentstack@3.1.1",scripts:{test:"node test.js",buildnode:"webpack --config webpack/webpack.node.js",buildweb:"webpack -p --config webpack/webpack.web.js",buildreactnative:"webpack --config webpack/webpack.react-native.js","generate-docs":"node_modules/.bin/jsdoc --configure docs-config.json --verbose"},repository:{type:"git",url:"https://github.com/builtio-contentstack/contentstack-javascript.git"},_shasum:"a328ed07240476a26b31a23261355dc929e1da63",_from:"contentstack@latest",_npmVersion:"3.8.9",_nodeVersion:"6.2.0",_npmUser:{name:"mynk",email:"mayank@raweng.com"},maintainers:[{name:"hiteshbal",email:"hitesh.baldaniya@raweng.com"},{name:"mynk",email:"mayank@raweng.com"}],dist:{shasum:"a328ed07240476a26b31a23261355dc929e1da63",tarball:"https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz"},license:"MIT",directories:{},_resolved:"https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz",_npmOperationalInternal:{host:"packages-18-east.internal.npmjs.com",tmp:"tmp/contentstack-3.0.0.tgz_1477830884275_0.9869455888401717"},devDependencies:{"babel-core":"^6.24.0","babel-loader":"^6.4.1","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"^1.3.2","babel-preset-es2015":"^6.16.0","babel-preset-es2016":"^6.22.0","babel-preset-stage-1":"^6.22.0","compression-webpack-plugin":"^0.3.1","es3ify-loader":"^0.2.0",jshint:"~2.6.3","string-replace-webpack-plugin":"0.0.3","tap-json":"^0.1.1",tape:"^4.4.0",jsdoc:"^3.4.0","uglify-js":"^2.6.2",webpack:"^2.2.1","webpack-md5-hash":"^0.0.5","webpack-merge":"^0.17.0"},dependencies:{"babel-runtime":"^6.23.0",fs:"0.0.1-security",localStorage:"1.0.3",nodemailer:"4.0.1",path:"^0.12.7",q:"1.4.1",when:"3.7.8",xmlhttprequest:"1.8.0"}}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Contentstack=t():e.Contentstack=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=18)}([function(e,t,r){"use strict";(function(e){function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var t=void 0===e?"undefined":d(e);switch(t){case"object":t,Array.isArray(e)&&(t="array");break;default:t}return t}function i(e,t){var r=this;return function e(t,n){for(var o in n)"object"==r._type(n[o])&&r._type(t[o])==r._type(n[o])?e(t[o],n[o]):"array"==r._type(n[o])&&r._type(t[o])==r._type(n[o])?t[o]=t[o].concat(n[o]):t[o]=n[o]}(e,t),e}function s(e,t){if(e&&t)for(var r in t)e[r]=t[r];return e}function u(){return"undefined"!=typeof window&&"object"===(void 0===e?"undefined":d(e))&&"browser"===e.title}function a(e,t,r){if(e&&e.requestParams){var n=s({},e.requestParams.body?e.requestParams.body.query||{}:{});return n.environment_uid&&(delete n.environment_uid,n.environment=e.environment),n.environment=e.environment,{content_type_uid:e.content_type_uid,locale:n.locale||"en-us",query:n,entry_uid:e.entry_uid,asset_uid:e.asset_uid,single:t||"false",toJSON:r||"false",api_key:e.requestParams.headers?e.requestParams.headers.api_key:""}}}function c(e){try{var t=f(JSON.stringify(e)),r=[];return r.push(e.content_type_uid),r.push(e.locale),e.entry_uid&&r.push(e.entry_uid),e.asset_uid&&r.push(e.asset_uid),r.push(t),r.join(".")}catch(e){}}function f(e){var t=0,r=void 0,n=void 0,o=void 0;if(0===e.length)return t;for(r=0,o=e.length;r<o;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t<-1?-1*t:t}function l(e){if(e&&void 0!==e.entries)if(e.entries&&e.entries.length)for(var t=0,r=e.entries.length;t<r;t++)e.entries[t]=(0,m.default)(e.entries[t]);else e.entries=[];else if(e&&e.assets&&void 0!==e.assets)if(e.assets&&e.assets.length)for(var n=0,o=e.assets.length;n<o;n++)e.assets[n]=(0,m.default)(e.assets[n]);else e.assets=[];else e&&void 0!==e.entry?e.entry=(0,m.default)(e.entry):e&&void 0!==e.asset&&(e.asset=(0,m.default)(e.asset));return e}function y(e){var t=[];return e&&Object.keys(e).length&&(void 0!==e.entries&&t.push(e.entries),void 0!==e.assets&&t.push(e.assets),void 0!==e.schema&&t.push(e.schema),void 0!==e.count&&t.push(e.count),void 0!==e.entry&&(t=e.entry),void 0!==e.asset&&(t=e.asset)),t}function h(e){var t=e.environment_uid;t?e._query.environment_uid=t:e._query?e._query.environment=e.environment:(e._query={},e._query.environment=e.environment);var r=e,n=void 0!==r.queryCachePolicy?r.queryCachePolicy:r.cachePolicy,o=void 0!==r.tojson&&r.tojson,i=!!(r.entry_uid||r.singleEntry||r.asset_uid),u=c(a(r,i,o));if(e&&e.requestParams&&e.requestParams.body&&e.requestParams.body.query){var f=JSON.parse(JSON.stringify(e.requestParams.body.query));"object"!==(void 0===f?"undefined":d(f))&&(f=JSON.parse(f)),delete e.requestParams.body.query,e.requestParams.body=s(e.requestParams.body,f)}var h=function(){return function(e,t){return new Promise(function(r,n){try{if(e)throw e;o||(t=l(t)),r(y(t))}catch(e){n(e)}})}},p=function(t,i,s){t&&(0,v.default)(e.requestParams).then(function(t){try{r.entry_uid=r.asset_uid=r.tojson=r.queryCachePolicy=void 0;var a={};if(e.singleEntry)if(e.singleEntry=!1,t.schema&&(a.schema=t.schema),t.entries&&t.entries.length)a.entry=t.entries[0];else{if(!t.assets||!t.assets.length)return 2!==n?s({error_code:141,error_message:"The requested entry doesn't exist."}):void r.provider.get(u,h());a.assets=t.assets[0]}else a=t;return-1!==n?(r.provider.set(u,a,function(e){try{if(e)throw e;return o||(a=l(a)),i(y(a))}catch(e){return s(e)}}),i(y(a))):(o||(a=l(a)),i(y(a)))}catch(e){return s({message:e.message})}}.bind(r)).catch(function(e){if(2!==n)return s(e);r.provider.get(u,h())})};switch(n){case 1:return new Promise(function(e,t){r.provider.get(u,function(r,n){try{if(!r&&n)return o||(n=l(n)),e(y(n));p(!0,e,t)}catch(e){return t(e)}})});case 2:case 0:case void 0:case-1:return new Promise(function(e,t){p(!0,e,t)})}if(3===n)return{cache:function(){return new Promise(function(e,t){r.provider.get(u,function(r,n){try{r?t(r):(o||(n=l(n)),e(y(n)))}catch(e){t(e)}})})}(),network:function(){return new Promise(function(e,t){p(!0,e,t)})}(),both:function(t){r.provider.get(u,function(e,r){o||(r=l(r)),t(e,y(r))}),(0,v.default)(e.requestParams).then(function(n){try{r.entry_uid=r.tojson=r.queryCachePolicy=void 0;var i={},s=null;e.singleEntry?(e.singleEntry=!1,n.schema&&(i.schema=n.schema),n.entries&&n.entries.length?i.entry=n.entries[0]:n.assets&&n.assets.length?i.assets=n.assets[0]:s={error_code:141,error_message:"The requested entry doesn't exist."}):i=n,o||(i=l(i)),t(s,y(i))}catch(e){t(e)}}.bind(r)).catch(function(e){t(e)})}}}Object.defineProperty(t,"__esModule",{value:!0});var d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t._type=o,t.mergeDeep=i,t.merge=s,t.isBrowser=u,t.parseQueryFromParams=a,t.getHash=c,t.generateHash=f,t.resultWrapper=l,t.spreadResult=y,t.sendRequest=h;var p=r(2),v=n(p),_=r(15),m=n(_);!function(){Promise.prototype.spread||(Promise.prototype.spread=function(e,t){return t=t||function(e){},this.then(function(t){return e.apply(e,t)}).catch(function(e){t(e)})})}()}).call(t,r(4))},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(8),c=o(a),f=r(0),l=n(f),y=r(6),h=o(y),d=r(14),p=o(d),v=r(7),_=o(v),m=r(2),b=o(m),g=r(5),w=(n(g),r(3)),q=o(w),P=function(){function e(){i(this,e),this.config=c.default,this.cachePolicy=q.default.policies.IGNORE_CACHE,this.provider=q.default.providers("localstorage");for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];switch(r.length){case 1:if("object"===s(r[0])&&"string"==typeof r[0].api_key&&"string"==typeof r[0].access_token&&"string"==typeof r[0].environment)return this.headers={api_key:r[0].api_key,access_token:r[0].access_token},this.environment=r[0].environment,this;console.error("Kindly provide valid object parameters.");case 3:if("string"==typeof r[0]&&"string"==typeof r[1]&&"string"==typeof r[2])return this.headers={api_key:r[0],access_token:r[1]},this.environment=r[2],this;console.error("Kindly provide valid string parameters.");default:console.error("Kindly provide valid parameters to initialize the Built.io Contentstack javascript-SDK Stack.")}}return u(e,[{key:"setPort",value:function(e){return"number"==typeof e&&(this.config.port=e),this}},{key:"setProtocol",value:function(e){return"string"==typeof e&&~["https","http"].indexOf(e)&&(this.config.protocol=e),this}},{key:"setHost",value:function(e){return"string"==typeof e&&e&&(this.config.host=e),this}},{key:"setCachePolicy",value:function(e){return"number"==typeof e&&e>=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":s(e))&&(this.provider=e),this}},{key:"clearByQuery",value:function(){if(this.provider&&"function"==typeof this.provider.clearByQuery)return this.provider.clearByQuery.apply(this.provider,arguments)}},{key:"clearByContentType",value:function(){if(this.provider&&"function"==typeof this.provider.clearByContentType)return this.provider.clearByContentType.apply(this.provider,arguments)}},{key:"clearAll",value:function(){if(this.provider&&"function"==typeof this.provider.clearAll)return this.provider.clearAll.apply(this.provider,arguments)}},{key:"getCacheProvider",value:function(){return this.provider}},{key:"ContentType",value:function(e){return e&&"string"==typeof e&&(this.content_type_uid=e,this.type="contentType"),this}},{key:"Entry",value:function(e){var t=new h.default;return e&&"string"==typeof e&&(t.entry_uid=e),l.merge(t,this)}},{key:"Assets",value:function(e){var t=new p.default;return this.type="asset",e&&"string"==typeof e&&(t.asset_uid=e),l.merge(t,this)}},{key:"Query",value:function(){var e=new _.default;return l.merge(e,this)}},{key:"getLastActivities",value:function(){var e={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types,body:{_method:"GET",only_last_activity:!0,environment:this.environment}};return(0,b.default)(e)}}]),e}();t.default=P},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return new Promise(function(t,r){var n=void 0,o=function e(t,r){var n=[],o=void 0;for(o in t)if(t.hasOwnProperty(o)){var i=r?r+"["+o+"]":o,u=t[o];n.push(null!==u&&"object"===(void 0===u?"undefined":s(u))&&"query"!==o?e(u,i):i+"="+("query"!==o?encodeURIComponent(u):JSON.stringify(u)))}return n.join("&")},i=e.url,u=e.headers;u["Content-Type"]="application/json; charset=UTF-8",u["X-User-Agent"]="contentstack-(JS-SDK)/"+f,e.body&&"object"===s(e.body)&&(delete e.body._method,n=o(e.body)),(0,c.default)(i+"?"+n,{method:"GET",headers:u}).then(function(e){if(e.ok&&200===e.status){var n=e.json();t(n)}else r(e.statusText)}).catch(function(e){console.log("Error: ",e),r(e)})})}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=i;var u=r(0),a=(o(u),r(16)),c=n(a),f="3.2.0"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(13),i=n(o),s={};s.providers=function(e){if(e)return i.default;console.error("Kindly provide valid provider.")},s.policies={IGNORE_CACHE:-1,ONLY_NETWORK:0,CACHE_ELSE_NETWORK:1,NETWORK_ELSE_CACHE:2,CACHE_THEN_NETWORK:3},t.default=s},function(e,t,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function s(e){if(y===clearTimeout)return clearTimeout(e);if((y===o||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(e);try{return y(e)}catch(t){try{return y.call(null,e)}catch(t){return y.call(this,e)}}}function u(){v&&d&&(v=!1,d.length?p=d.concat(p):_=-1,p.length&&a())}function a(){if(!v){var e=i(u);v=!0;for(var t=p.length;t;){for(d=p,p=[];++_<t;)d&&d[_].run();_=-1,t=p.length}d=null,v=!1,s(e)}}function c(e,t){this.fun=e,this.array=t}function f(){}var l,y,h=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{y="function"==typeof clearTimeout?clearTimeout:o}catch(e){y=o}}();var d,p=[],v=!1,_=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];p.push(new c(e,t)),1!==p.length||v||i(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=f,h.addListener=f,h.once=f,h.off=f,h.removeListener=f,h.removeAllListeners=f,h.emit=f,h.prependListener=f,h.prependOnceListener=f,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){var t=y.default.getItem(e);try{t=JSON.parse(t)}catch(e){return t}return t||null}function s(e,t){"object"===(void 0===t?"undefined":c(t))?y.default.setItem(e,JSON.stringify(t)):y.default.setItem(e,t)}function u(){return y.default||null}function a(){return y.default?Object.keys(y.default):[]}Object.defineProperty(t,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.get=i,t.set=s,t.getStorage=u,t.getKeys=a;var f=r(0),l=(o(f),r(17)),y=n(l)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(0),c=o(a),f=r(1),l=(n(f),function(e){return function(){switch(this._query[e]=this._query[e]||{},arguments.length){case 1:if(Array.isArray(arguments[0])||"string"==typeof arguments[0]){var t=this._query[e].BASE||[];return t=t.concat(arguments[0]),this._query[e].BASE=t,this}console.error("Kindly provide valid parameters");break;case 2:if("string"==typeof arguments[0]&&(Array.isArray(arguments[1])||"string"==typeof arguments[1])){var r=this._query[e][arguments[0]]||[];return r=r.concat(arguments[1]),this._query[e][arguments[0]]=r,this}console.error("Kindly provide valid parameters");break;default:console.error("Kindly provide valid parameters")}}}),y=function(){function e(){return i(this,e),this._query={},this.only=l("only"),this.except=l("except"),this}return u(e,[{key:"setCacheProvider",value:function(e){return e&&"object"===(void 0===e?"undefined":s(e))&&(this.provider=e),this}},{key:"setCachePolicy",value:function(e){return"number"==typeof e&&e>=-1&&e<4?this._query?this.queryCachePolicy=e:this.cachePolicy=e:console.error("Kindly provide the valid policy"),this}},{key:"includeReference",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(Array.isArray(t)||"string"==typeof t){if(arguments.length)for(var n=0;n<arguments.length;n++)this._query.include=this._query.include||[],this._query.include=this._query.include.concat(arguments[n]);return this}console.error("Argument should be a String or an Array.")}},{key:"language",value:function(e){if(e&&"string"==typeof e)return this._query.locale=e,this;console.error("Argument should be a String.")}},{key:"addQuery",value:function(e,t){if(e&&t&&"string"==typeof e)return this._query[e]=t,this;console.error("First argument should be a String.")}},{key:"includeSchema",value:function(){return this._query.include_schema=!0,this}},{key:"includeOwner",value:function(){return this._query.include_owner=!0,this}},{key:"toJSON",value:function(){return this.tojson=!0,this}},{key:"fetch",value:function(){if(this.entry_uid)return this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries+this.entry_uid,body:{_method:"GET",query:this._query}},c.sendRequest(this);console.error("Kindly provide an entry uid. e.g. .Entry('bltsomething123')")}}]),e}();t.default=y},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=r(2),l=(o(f),r(0)),y=n(l),h=r(6),d=o(h),p={compare:function(e){return function(t,r){if(t&&r&&"string"==typeof t&&void 0!==r)return this._query.query[t]=this._query.query.file_size||{},this._query.query[t][e]=r,this;console.error("Kindly provide valid parameters.")}},contained:function(e){var t=e?"$in":"$nin";return function(e,r){if(e&&r&&"string"==typeof e&&Array.isArray(r))return this._query.query[e]=this._query.query[e]||{},this._query.query[e][t]=this._query.query[e][t]||[],this._query.query[e][t]=this._query.query[e][t].concat(r),this;console.error("Kindly provide valid parameters.")}},exists:function(e){return function(t){if(t&&"string"==typeof t)return this._query.query[t]=this._query.query[t]||{},this._query.query[t].$exists=e,this;console.error("Kindly provide valid parameters.")}},logical:function(e){return function(){for(var t=[],r=0,n=arguments.length;r<n;r++)arguments[r]instanceof v&&arguments[r]._query.query?t.push(arguments[r]._query.query):"object"===c(arguments[r])&&t.push(arguments[r]);return this._query.query[e]?this._query.query[e]=this._query.query[e].concat(t):this._query.query[e]=t,this}},sort:function(e){return function(t){if(t&&"string"==typeof t)return this._query[e]=t,this;console.error("Argument should be a string.")}},pagination:function(e){return function(t){if("number"==typeof t)return this._query[e]=t,this;console.error("Argument should be a number.")}}},v=function(e){function t(){i(this,t);var e=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._query=e._query||{},e._query.query=e._query.query||{},e.lessThan=p.compare("$lt"),e.lessThanOrEqualTo=p.compare("$lte"),e.greaterThan=p.compare("$gt"),e.greaterThanOrEqualTo=p.compare("$gte"),e.notEqualTo=p.compare("$ne"),e.containedIn=p.contained(!0),e.notContainedIn=p.contained(!1),e.exists=p.exists(!0),e.notExists=p.exists(!1),e.ascending=p.sort("asc"),e.descending=p.sort("desc"),e.beforeUid=p.sort("before_uid"),e.afterUid=p.sort("after_uid"),e.skip=p.pagination("skip"),e.limit=p.pagination("limit"),e.or=p.logical("$or"),e.and=p.logical("$and"),e}return u(t,e),a(t,[{key:"equalTo",value:function(e,t){if(e&&"string"==typeof e)return this._query.query[e]=t,this;console.error("Kindly provide valid parameters.")}},{key:"where",value:function(e,t){if(e&&"string"==typeof e)return this._query.query[e]=t,this;console.error("Kindly provide valid parameters.")}},{key:"count",value:function(){var e=this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version,t=this.type&&"asset"===this.type?e+this.config.urls.assets:e+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries;return this._query.count=!0,this.requestParams={method:"POST",headers:this.headers,url:t,body:{_method:"GET",query:this._query}},this}},{key:"query",value:function(e){if("object"===(void 0===e?"undefined":c(e)))return this._query.query=y.mergeDeep(this._query.query,e),this;console.error("Kindly provide valid parameters")}},{key:"tags",value:function(e){if(Array.isArray(e))return this._query.tags=e,this;console.error("Kindly provide valid parameters")}},{key:"includeCount",value:function(){return this._query.include_count=!0,this}},{key:"getQuery",value:function(){return this._query.query||{}}},{key:"regex",value:function(e,t,r){if(e&&t&&"string"==typeof e&&"string"==typeof t)return this._query.query[e]={$regex:t},r&&(this._query.query[e].$options=r),this;console.error("Kindly provide valid parameters.")}},{key:"search",value:function(e){if(e&&"string"==typeof e)return this._query.typeahead=e,this;console.error("Kindly provide valid parameters.")}},{key:"find",value:function(){var e=this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version,t=this.type&&"asset"===this.type?e+this.config.urls.assets:e+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries;return this.requestParams={method:"POST",headers:this.headers,url:t,body:{_method:"GET",query:this._query}},y.sendRequest(this)}},{key:"findOne",value:function(){var e=this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version,t=this.type&&"asset"===this.type?e+this.config.urls.assets:e+this.config.urls.content_types+this.content_type_uid+this.config.urls.entries;return this.singleEntry=!0,this._query.limit=1,this.requestParams={method:"POST",headers:this.headers,url:t,body:{_method:"GET",query:this._query}},y.sendRequest(this)}}]),t}(d.default);t.default=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={protocol:"https",host:"cdn.contentstack.io",port:443,version:"v3",urls:{content_types:"/content_types/",entries:"/entries/",assets:"/assets/",environments:"/environments/"}};t.default=n},function(e,t,r){"use strict";(function(n,o){var i,s,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 4.1.1
*/
!function(n,o){"object"===u(t)&&void 0!==e?e.exports=o():(i=o,void 0!==(s="function"==typeof i?i.call(t,r,t,e):i)&&(e.exports=s))}(0,function(){function e(e){var t=void 0===e?"undefined":u(e);return null!==e&&("object"===t||"function"===t)}function t(e){return"function"==typeof e}function i(e){z=e}function s(e){X=e}function a(){return function(){return n.nextTick(h)}}function c(){return void 0!==Y?function(){Y(h)}:y()}function f(){var e=0,t=new ee(h),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function l(){var e=new MessageChannel;return e.port1.onmessage=h,function(){return e.port2.postMessage(0)}}function y(){var e=setTimeout;return function(){return e(h,1)}}function h(){for(var e=0;e<W;e+=2){(0,ne[e])(ne[e+1]),ne[e]=void 0,ne[e+1]=void 0}W=0}function d(){try{var e=r(!function(){var e=new Error('Cannot find module "vertx"');throw e.code="MODULE_NOT_FOUND",e}());return Y=e.runOnLoop||e.runOnContext,c()}catch(e){return y()}}function p(e,t){var r=arguments,n=this,o=new this.constructor(_);void 0===o[ie]&&R(o);var i=n._state;return i?function(){var e=r[i-1];X(function(){return B(i,o,e,n._result)})}():E(n,o,e,t),o}function v(e){var t=this;if(e&&"object"===(void 0===e?"undefined":u(e))&&e.constructor===t)return e;var r=new t(_);return S(r,e),r}function _(){}function m(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function g(e){try{return e.then}catch(e){return ce.error=e,ce}}function w(e,t,r,n){try{e.call(t,r,n)}catch(e){return e}}function q(e,t,r){X(function(e){var n=!1,o=w(r,t,function(r){n||(n=!0,t!==r?S(e,r):A(e,r))},function(t){n||(n=!0,j(e,t))},"Settle: "+(e._label||" unknown promise"));!n&&o&&(n=!0,j(e,o))},e)}function P(e,t){t._state===ue?A(e,t._result):t._state===ae?j(e,t._result):E(t,void 0,function(t){return S(e,t)},function(t){return j(e,t)})}function O(e,r,n){r.constructor===e.constructor&&n===p&&r.constructor.resolve===v?P(e,r):n===ce?(j(e,ce.error),ce.error=null):void 0===n?A(e,r):t(n)?q(e,r,n):A(e,r)}function S(t,r){t===r?j(t,m()):e(r)?O(t,r,g(r)):A(t,r)}function T(e){e._onerror&&e._onerror(e._result),k(e)}function A(e,t){e._state===se&&(e._result=t,e._state=ue,0!==e._subscribers.length&&X(k,e))}function j(e,t){e._state===se&&(e._state=ae,e._result=t,X(T,e))}function E(e,t,r,n){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+ue]=r,o[i+ae]=n,0===i&&e._state&&X(k,e)}function k(e){var t=e._subscribers,r=e._state;if(0!==t.length){for(var n=void 0,o=void 0,i=e._result,s=0;s<t.length;s+=3)n=t[s],o=t[s+r],n?B(r,n,o,i):o(i);e._subscribers.length=0}}function x(){this.error=null}function C(e,t){try{return e(t)}catch(e){return fe.error=e,fe}}function B(e,r,n,o){var i=t(n),s=void 0,u=void 0,a=void 0,c=void 0;if(i){if(s=C(n,o),s===fe?(c=!0,u=s.error,s.error=null):a=!0,r===s)return void j(r,b())}else s=o,a=!0;r._state!==se||(i&&a?S(r,s):c?j(r,u):e===ue?A(r,s):e===ae&&j(r,s))}function M(e,t){try{t(function(t){S(e,t)},function(t){j(e,t)})}catch(t){j(e,t)}}function K(){return le++}function R(e){e[ie]=le++,e._state=void 0,e._result=void 0,e._subscribers=[]}function U(e,t){this._instanceConstructor=e,this.promise=new e(_),this.promise[ie]||R(this.promise),Q(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?A(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&A(this.promise,this._result))):j(this.promise,N())}function N(){return new Error("Array Methods must be provided an Array")}function D(e){return new U(this,e).promise}function I(e){var t=this;return new t(Q(e)?function(r,n){for(var o=e.length,i=0;i<o;i++)t.resolve(e[i]).then(r,n)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function F(e){var t=this,r=new t(_);return j(r,e),r}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function H(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function J(e){this[ie]=K(),this._result=this._state=void 0,this._subscribers=[],_!==e&&("function"!=typeof e&&L(),this instanceof J?M(this,e):H())}function G(){var e=void 0;if(void 0!==o)e=o;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var r=null;try{r=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===r&&!t.cast)return}e.Promise=J}var $=void 0;$=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var Q=$,W=0,Y=void 0,z=void 0,X=function(e,t){ne[W]=e,ne[W+1]=t,2===(W+=2)&&(z?z(h):oe())},V="undefined"!=typeof window?window:void 0,Z=V||{},ee=Z.MutationObserver||Z.WebKitMutationObserver,te="undefined"==typeof self&&void 0!==n&&"[object process]"==={}.toString.call(n),re="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ne=new Array(1e3),oe=void 0;oe=te?a():ee?f():re?l():void 0===V?d():y();var ie=Math.random().toString(36).substring(16),se=void 0,ue=1,ae=2,ce=new x,fe=new x,le=0;return U.prototype._enumerate=function(e){for(var t=0;this._state===se&&t<e.length;t++)this._eachEntry(e[t],t)},U.prototype._eachEntry=function(e,t){var r=this._instanceConstructor,n=r.resolve;if(n===v){var o=g(e);if(o===p&&e._state!==se)this._settledAt(e._state,t,e._result);else if("function"!=typeof o)this._remaining--,this._result[t]=e;else if(r===J){var i=new r(_);O(i,e,o),this._willSettleAt(i,t)}else this._willSettleAt(new r(function(t){return t(e)}),t)}else this._willSettleAt(n(e),t)},U.prototype._settledAt=function(e,t,r){var n=this.promise;n._state===se&&(this._remaining--,e===ae?j(n,r):this._result[t]=r),0===this._remaining&&A(n,this._result)},U.prototype._willSettleAt=function(e,t){var r=this;E(e,void 0,function(e){return r._settledAt(ue,t,e)},function(e){return r._settledAt(ae,t,e)})},J.all=D,J.race=I,J.resolve=v,J.reject=F,J._setScheduler=i,J._setAsap=s,J._asap=X,J.prototype={constructor:J,then:p,catch:function(e){return this.then(null,e)}},J.polyfill=G,J.Promise=J,J})}).call(t,r(4),r(11))},function(e,t,r){"use strict";r(12),e.exports=self.fetch.bind(self)},function(e,t,r){"use strict";var n,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":o(window))&&(n=window)}e.exports=n},function(e,t,r){"use strict";!function(e){function t(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function r(e){return"string"!=typeof e&&(e=String(e)),e}function n(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return _.iterable&&(t[Symbol.iterator]=function(){return t}),t}function o(e){this.map={},e instanceof o?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function i(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function s(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function u(e){var t=new FileReader,r=s(t);return t.readAsArrayBuffer(e),r}function a(e){var t=new FileReader,r=s(t);return t.readAsText(e),r}function c(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function f(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function l(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(_.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(_.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(_.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(_.arrayBuffer&&_.blob&&b(e))this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!_.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!g(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=f(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):_.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},_.blob&&(this.blob=function(){var e=i(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?i(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(u)}),this.text=function(){var e=i(this);if(e)return e;if(this._bodyBlob)return a(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(c(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},_.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function y(e){var t=e.toUpperCase();return w.indexOf(t)>-1?t:e}function h(e,t){t=t||{};var r=t.body;if(e instanceof h){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new o(e.headers)),this.method=e.method,this.mode=e.mode,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new o(t.headers)),this.method=y(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}}),t}function p(e){var t=new o;return e.split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}}),t}function v(e,t){t||(t={}),this.type="default",this.status="status"in t?t.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new o(t.headers),this.url=t.url||"",this._initBody(e)}if(!e.fetch){var _={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(_.arrayBuffer)var m=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],b=function(e){return e&&DataView.prototype.isPrototypeOf(e)},g=ArrayBuffer.isView||function(e){return e&&m.indexOf(Object.prototype.toString.call(e))>-1};o.prototype.append=function(e,n){e=t(e),n=r(n);var o=this.map[e];this.map[e]=o?o+","+n:n},o.prototype.delete=function(e){delete this.map[t(e)]},o.prototype.get=function(e){return e=t(e),this.has(e)?this.map[e]:null},o.prototype.has=function(e){return this.map.hasOwnProperty(t(e))},o.prototype.set=function(e,n){this.map[t(e)]=r(n)},o.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},o.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),n(e)},o.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),n(e)},o.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),n(e)},_.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];h.prototype.clone=function(){return new h(this,{body:this._bodyInit})},l.call(h.prototype),l.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var q=[301,302,303,307,308];v.redirect=function(e,t){if(-1===q.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=o,e.Request=h,e.Response=v,e.fetch=function(e,t){return new Promise(function(r,n){var o=new h(e,t),i=new XMLHttpRequest;i.onload=function(){var e={status:i.status,statusText:i.statusText,headers:p(i.getAllResponseHeaders()||"")};e.url="responseURL"in i?i.responseURL:e.headers.get("X-Request-URL");var t="response"in i?i.response:i.responseText;r(new v(t,e))},i.onerror=function(){n(new TypeError("Network request failed"))},i.ontimeout=function(){n(new TypeError("Network request failed"))},i.open(o.method,o.url,!0),"include"===o.credentials&&(i.withCredentials=!0),"responseType"in i&&_.blob&&(i.responseType="blob"),o.headers.forEach(function(e,t){i.setRequestHeader(t,e)}),i.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}}("undefined"!=typeof self?self:void 0)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e,t){!t&&e&&e.length&&e.push("");var r=void 0,n=s.getKeys(),o=s.getStorage();if(e&&e.length){r=e.join(".");for(var i=0,u=n.length;i<u;i++)n[i]&&0===n[i].indexOf(r)&&delete o[n[i]]}else for(var a=0,c=n.length;a<c;a++)delete o[n[a]]}Object.defineProperty(t,"__esModule",{value:!0});var i=r(5),s=n(i),u={};u.get=function(e,t){try{t(null,s.get(e))}catch(e){t(e)}},u.set=function(e,t,r){try{e&&t&&s.set(e,t),r()}catch(e){r(e)}},u.clearByContentType=function(){try{if(2===arguments.length||3===arguments.length){var e=Array.prototype.slice.call(arguments),t=e.splice(-1,1).pop(),r=[];r.push.apply(r,e),o(r),t()}}catch(e){callback(e)}},u.clearByQuery=function(e,t){try{for(var r=s.getKeys(),n=s.getStorage(),o=0,i=r.length;o<i;o++)r[o]&&~r[o].indexOf(e)&&delete n[r[o]];t()}catch(e){t(e)}},u.clearAll=function(e){try{o(),e()}catch(t){e(t)}},t.default=u},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(0),a=o(u),c=r(1),f=(n(c),r(7)),l=n(f),y=function(e){return function(){switch(this._query[e]=this._query[e]||{},arguments.length){case 1:if(Array.isArray(arguments[0])||"string"==typeof arguments[0]){var t=this._query[e].BASE||[];return t=t.concat(arguments[0]),this._query[e].BASE=t,this}console.error("Kindly provide valid parameters");break;case 2:if("string"==typeof arguments[0]&&(Array.isArray(arguments[1])||"string"==typeof arguments[1])){var r=this._query[e][arguments[0]]||[];return r=r.concat(arguments[1]),this._query[e][arguments[0]]=r,this}console.error("Kindly provide valid parameters");break;default:console.error("Kindly provide valid parameters")}}},h=function(){function e(){return i(this,e),this.only=y("only"),this}return s(e,[{key:"Query",value:function(){var e=new l.default;return a.merge(e,this)}},{key:"addQuery",value:function(e,t){if(e&&t&&"string"==typeof e)return this._query[e]=t,this;console.error("First argument should be a String.")}},{key:"toJSON",value:function(){return this.tojson=!0,this}},{key:"fetch",value:function(){if(this.asset_uid)return this.requestParams={method:"POST",headers:this.headers,url:this.config.protocol+"://"+this.config.host+":"+this.config.port+"/"+this.config.version+this.config.urls.assets+this.asset_uid,body:{_method:"GET",query:this._query}},a.sendRequest(this);console.error("Kindly provide an asset uid. e.g. .Assets('bltsomething123')")}}]),e}();t.default=h},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(0),u=n(s),a=function(){function e(t){return o(this,e),t&&(this.object=function(){return t}),this}return i(e,[{key:"toJSON",value:function(){return this.object()?u.mergeDeep(JSON.parse(JSON.stringify({})),this.object()):null}},{key:"get",value:function(e){if(this.object()&&e){return e.split(".").reduce(function(e,t){return e[t]},this.object())}}},{key:"getDownloadUrl",value:function(e){if(this.object()){var t=this.object().url?this.object().url:null,r=e&&"string"==typeof e?e:"attachment";return t?t+"?disposition="+r:null}}}]),e}();e.exports=function(e){return new a(e)}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(9),i=n(o),s=r(10),u=n(s);i.default.polyfill(),t.default=u.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=window.localStorage},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(1),u=n(s),a=r(3),c=n(a),f=function(){function e(){o(this,e),this.CachePolicy=c.default.policies}return i(e,[{key:"Stack",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(u.default,[null].concat(t)))}}]),e}();e.exports=new f}])});
{
"name": "contentstack",
"version": "3.1.1",
"description": "The Built.io Contentstack Javascript SDK",
"homepage": "https://www.built.io/products/contentstack/overview",
"version": "3.2.1",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
"name": "Built.io Contentstack",
"url": "https://www.built.io/"
"name": "Contentstack",
"url": "https://www.contentstack.com/"
},
"main": "dist/node/contentstack.js",
"browser": "dist/web/contentstack.js",
"_id": "contentstack@3.1.1",

@@ -17,2 +18,3 @@ "scripts": {

"buildreactnative": "webpack --config webpack/webpack.react-native.js",
"buildall": "npm run buildnode&npm run buildweb&npm run buildreactnative",
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose"

@@ -54,28 +56,28 @@ },

"devDependencies": {
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.3.2",
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-stage-1": "^6.22.0",
"compression-webpack-plugin": "^0.3.1",
"es3ify-loader": "^0.2.0",
"jshint": "~2.6.3",
"babel-core": "6.24.0",
"babel-loader": "6.4.1",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-env": "1.3.2",
"babel-preset-es2015": "6.16.0",
"babel-preset-es2016": "6.22.0",
"babel-preset-stage-1": "6.22.0",
"compression-webpack-plugin": "0.3.1",
"es3ify-loader": "0.2.0",
"jshint": "2.6.3",
"string-replace-webpack-plugin": "0.0.3",
"tap-json": "^0.1.1",
"tape": "^4.4.0",
"jsdoc": "^3.4.0",
"uglify-js": "^2.6.2",
"webpack": "^2.2.1",
"webpack-md5-hash": "^0.0.5",
"babel-runtime": "^6.23.0",
"webpack-merge": "^0.17.0"
"tap-json": "0.1.1",
"tape": "4.4.0",
"jsdoc": "3.4.0",
"uglify-js": "2.6.2",
"webpack": "2.2.1",
"webpack-md5-hash": "0.0.5",
"webpack-merge": "0.17.0",
"babel-runtime": "6.23.0",
"string-replace-loader": "1.3.0"
},
"dependencies": {
"localStorage": "1.0.3",
"q": "1.4.1",
"when": "3.7.8",
"xmlhttprequest": "1.8.0"
"es6-promise": "4.1.1",
"isomorphic-fetch": "2.2.1",
"localStorage": "1.0.3"
}
}

@@ -1,52 +0,172 @@

[![Built.io Contentstack](https://contentstackdocs.built.io/static/images/logo.png)](https://www.built.io/products/contentstack/overview)
# Javascript SDK for Built.io Contentstack
## Prerequisite
We recommend to use node.js version >=4.4.7 to use the Built.io Contentstack SDK.
## Installation
You might need administrator privileges to perform this installation.
```bash
$ npm install contentstack
```
To require the SDK module in your application use the following command.
```bash
$ import * as Contentstack from 'contentstack';
```
## Basic Structure
The structure followed by SDK logically resembles the "Stack" structure on Built.io Contentstack. Once you have done the basic setup explained in the Installation section, you get a Built.io Contentstack object, which can be used to initialize different modules. The initialization process for each module is explained below.
### Stack
To initialize a Stack, you need to provide the required keys and values associated with them.
```bash
const Stack = Contentstack.Stack({"api_key":<<API_KEY>>,"access_token":<<ACCESS_TOKEN>>,"environment":<<ENVIRONMENT_NAME>>});
```
Let us take an example where we try to obtain all entries of the Content Type my_content_type.
```bash
const entry = Stack.ContentType(<<CONTENT_TYPE_UID>>).Query();
entry
//add query methods here
.find()
.then(function(data){
//data will contain entries from the specified Content Type;
},function(err){
//displays a detailed error in case of failure;
});
```
Let us take another example where we try to obtain only a specific entry from the Content Type my_content_type.
```bash
const entry = Stack.ContentType(<<CONTENT_TYPE_UID>>).Entry(<<ENTRY_UID>>);
entry
//add query methods here
.fetch()
.then(function(data){
//data will contain the specified entry from the specified Content Type;
},function(err){
//displays a detailed error in case of failure;
});
```
-----
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
## JavaScript SDK for Contentstack
## Links
- [Website](https://www.built.io/products/contentstack/overview)
- [Official Documentation](https://contentstackdocs.built.io/developer/javascript/quickstart)
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
### License
Copyright © 2012-2017 [Built.io](https://www.built.io/). All Rights Reserved.
Contentstack provides JavaScript SDK to build application on top of JavaScript. Given below is the detailed guide and helpful resources to get started with our JavaScript SDK.
The JavaScript SDK can also be used to create Node.js and React native applications.
### Prerequisite
You need Node.js version 4.4.7 or later installed to use the Contentstack JavaScript SDK.
### Setup and Installation
#### For JavaScript (Browser)
To use the JavaScript SDK, download it from [here](https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest) and include it in the &lt;script&gt; tag:
<script type="text/javascript" src="/path/to/contentstack.min.js"></script>;
To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.
const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
#### For Node.js
Node.js uses the Javascript SDK to create apps. To use the JavaScript SDK, download it from [here](https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest), OR install it via npm:
npm -i contentstack
To import the SDK in your project, use the following command:
import contentstack from ‘contentstack’
To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.
const Stack = Contentstack.Stack("api_key","access_token","environment_name");
#### For React Native
React Native uses the Javascript SDK to create apps. To use the JavaScript SDK, download it from [here](https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest), OR install ist via npm:
npm -i contentstack
To import the SDK in your project, use the following command:
import contentstack from `contentstack/react-native`
To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.
const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
### Key Concepts for using Contentstack
#### Stack
A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).
#### Content Type
Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
#### Entry
An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
#### Asset
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
#### Environment
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
### Contentstack JavaScript SDK: 5-minute Quickstart
#### Initializing your SDK
You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:
const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
Once you have initialized the SDK, you can start getting content in your app.
#### Querying content from your stack
To get a single entry, you need to specify the content type as well as the ID of the entry.
const Query = Stack.ContentType('blog').Entry("blt123something");
Query.fetch()
.then(function success(entry) {
console.log(entry.get('title')); // Retrieve field value by providing a field's uid
console.log(entry.toJSON()); // Convert the entry result object to JSON
}, function error(err) {
// err object
});
To retrieve multiple entries of a content type, you need to specify the content type uid. You can also specify search parameters to filter results.
const Query = Stack.ContentType('blog').Query();
Query
.where("title", "welcome")
.includeSchema()
.includeCount()
.toJSON()
.find()
.then(function success(result) {
// result is array where -
// result[0] =&gt; entry objects
// result[result.length-1] =&gt; entry objects count included only when .includeCount() is queried.
// result[1] =&gt; schema of the content type is included when .includeSchema() is queried.
}, function error(err) {
// err object
});
#### Cache Policies
You can set a cache policy on a stack and/or query object.
##### Setting a cache policy on a stack
This option allows you to globalize a cache policy. This means the cache policy you set will be applied to all the query objects of the stack.
//Setting a cache policy on a stack
Stack.setCachePolicy(Contentstack.CachePolicy.NETWORK_ELSE_CACHE)
##### Setting a cache policy on a query object
This option allows you to set/override a cache policy on a specific query object.
// setting a cache policy on a queryobject
Query.setCachePolicy(Contentstack.CachePolicy.CACHE_THEN_NETWORK)
### Advanced Queries
You can query for content types, entries, assets and more using our JavaScript API Reference.
[JavaScript API Reference Doc](https://contentstack.com/docs/platforms/javascript-browser/api-reference)
### Working with Images
We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images.
[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
SDK functions for Image Delivery API coming soon.
### Helpful Links
- [Contentstack Website](https://www.contentstack.com)
- [Official Documentation](https://contentstack.com/docs)
- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
### The MIT License (MIT)
Copyright © 2012-2017 [Built.io](https://www.built.io/). All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -6,3 +6,3 @@ import localstorage from './localstorage';

CacheProvider.providers = function(provider) {
if(provider) {
if (provider) {
return localstorage;

@@ -9,0 +9,0 @@ } else {

import * as cache from './../cache';
var localStorage = {};
let localStorage = {};

@@ -24,7 +24,7 @@ localStorage.get = function (key, callback) {

if(!append && keyArray && keyArray.length) keyArray.push('');
var _key,
let _key,
keys = cache.getKeys(),
storage = cache.getStorage();
if(!keyArray || !keyArray.length) {
for(var i = 0, _i = keys.length; i < _i; i++) {
for(let i = 0, _i = keys.length; i < _i; i++) {
delete storage[keys[i]];

@@ -34,3 +34,3 @@ }

_key = keyArray.join('.');
for(var i = 0, _i = keys.length; i < _i; i++) {
for(let i = 0, _i = keys.length; i < _i; i++) {
if(keys[i] && keys[i].indexOf(_key) === 0) delete storage[keys[i]];

@@ -44,5 +44,5 @@ }

if(arguments.length === 2 || arguments.length === 3) {
var args = Array.prototype.slice.call(arguments);
var callback = args.splice(-1, 1).pop();
var valueArray = [];
let args = Array.prototype.slice.call(arguments);
let callback = args.splice(-1, 1).pop();
let valueArray = [];
valueArray.push.apply(valueArray, args);

@@ -59,5 +59,5 @@ clearValuesForKey(valueArray);

try {
var keys = cache.getKeys(),
let keys = cache.getKeys(),
storage = cache.getStorage();
for(var i = 0, _i = keys.length; i < _i; i++) {
for(let i = 0, _i = keys.length; i < _i; i++) {
if(keys[i] && ~keys[i].indexOf(query)) delete storage[keys[i]];

@@ -64,0 +64,0 @@ }

@@ -5,3 +5,3 @@ import * as Utils from "./lib/utils.js";

export function get(key) {
var data = storage.getItem(key);
let data = storage.getItem(key);
try {

@@ -8,0 +8,0 @@ data = JSON.parse(data);

import * as Utils from "./utils.js";
import HTTPRequest from "runtime/http.js";
import when from "runtime/when.js";
import * as Package from '../../../package.json';
import fetch from "runtime/http.js";
//JS SDK version
let version = '{{VERSION}}';
export default function Request(options) {
var serialize = function(obj, prefix) {
var str = [], p;
for(p in obj) {
if (obj.hasOwnProperty(p)) {
var k = prefix ? prefix + "[" + p + "]" : p,
v = obj[p];
str.push((v !== null && typeof v === "object" && p !== 'query') ?
serialize(v, k) :
k + "=" + (p !== 'query' ? encodeURIComponent(v) : JSON.stringify(v)));
}
}
return str.join("&");
}
var deferred = when.defer();
var xhr = new HTTPRequest(),
method = "GET",
url = options.url,
headers = options.headers;
return new Promise(function (resolve, reject) {
let queryParams;
let serialize = function(obj, prefix) {
let str = [], p;
for (p in obj) {
if (obj.hasOwnProperty(p)) {
let k = prefix ? prefix + "[" + p + "]" : p,
v = obj[p];
str.push((v !== null && typeof v === "object" && p !== 'query') ?
serialize(v, k) :
k + "=" + (p !== 'query' ? encodeURIComponent(v) : JSON.stringify(v)));
}
}
return str.join("&");
};
if(options.body && typeof options.body === 'object'){
delete options.body._method;
var queryParams = serialize(options.body);
}
//make all calls as GET instead of POST
xhr.open(method, url+'?'+queryParams, true);
// set headers
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.setRequestHeader('X-User-Agent', 'contentstack-(JS-SDK)/' + Package.version);
for (var header in headers) {
xhr.setRequestHeader(header, headers[header]);
}
let url = options.url,
headers = options.headers;
// send stringify data
if (options.body && method == "POST" || method == "PUT") {
if (typeof options.body === 'object') {
xhr.send(JSON.stringify(options.body));
} else {
xhr.send(options.body);
// setting headers
headers['Content-Type'] = 'application/json; charset=UTF-8';
headers['X-User-Agent'] = 'contentstack-(JS-SDK)/'+version;
if (options.body && typeof options.body === 'object'){
delete options.body._method;
queryParams = serialize(options.body);
}
} else {
xhr.send();
}
// collect response
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
var data = xhr.responseText,
error;
try {
data = JSON.parse(data);
} catch (e) {
error = {error_code: 141, message: 'Could not parse the response received from the server.'};
}
if (xhr.status >= 200 && xhr.status < 300) {
deferred.resolve(data);
fetch(url + '?' + queryParams, {
method: 'GET',
headers: headers
})
.then(function (response) {
if (response.ok && response.status === 200) {
let data = response.json();
resolve(data);
} else {
deferred.reject(data || error);
reject(response.statusText);
}
}
};
return deferred.promise;
}).catch(function (error) {
console.log("Error: ", error);
reject(error);
});
});
}

@@ -1,17 +0,31 @@

import when from "runtime/when.js";
import Request from './request';
import Result from '../entry/result';
import Result from '../modules/result';
/**
* @method addSpread
* @description method to add the spread.
*/
(function addSpread() {
if (Promise.prototype.spread) return;
Promise.prototype.spread = function (fn, errFunc) {
errFunc = errFunc || function (err) {};
return this.then(function (args) {
return fn.apply(fn, args);
}).catch(function (err) {
errFunc(err);
});
};
}());
export function _type(val) {
var _typeof,
__typeof = typeof val;
export function _type(val) {
let _typeof,
__typeof = typeof val;
switch (__typeof) {
case 'object':
_typeof = __typeof;
if (Array.isArray(val)) {
__typeof = 'array';
}
break;
_typeof = __typeof;
if (Array.isArray(val)) {
__typeof = 'array';
}
break;
default:
_typeof = __typeof;
_typeof = __typeof;
}

@@ -23,5 +37,5 @@ return __typeof;

export function mergeDeep(target, source) {
var self = this;
var _merge_recursive = function(target, source) {
for (var key in source) {
let self = this;
let _merge_recursive = function(target, source) {
for (let key in source) {
if (self._type(source[key]) == 'object' && self._type(target[key]) == self._type(source[key])) {

@@ -43,3 +57,3 @@ _merge_recursive(target[key], source[key])

if (target && source) {
for (var key in source) {
for (let key in source) {
target[key] = source[key];

@@ -60,3 +74,3 @@ }

if(queryObject && queryObject.requestParams) {
var _query = merge({}, ((queryObject.requestParams.body) ? queryObject.requestParams.body.query || {} : {}));
let _query = merge({}, ((queryObject.requestParams.body) ? queryObject.requestParams.body.query || {} : {}));
if(_query.environment_uid) {

@@ -72,2 +86,3 @@ delete _query.environment_uid;

entry_uid: queryObject.entry_uid,
asset_uid: queryObject.asset_uid,
single: single || "false",

@@ -83,7 +98,8 @@ toJSON: toJSON || "false",

try {
var hashValue = generateHash(JSON.stringify(query)),
keyArray = [];
let hashValue = generateHash(JSON.stringify(query)),
keyArray = [];
keyArray.push(query.content_type_uid);
keyArray.push(query.locale);
if(query.entry_uid) keyArray.push(query.entry_uid);
if(query.asset_uid) keyArray.push(query.asset_uid);
keyArray.push(hashValue);

@@ -96,3 +112,3 @@ return keyArray.join('.');

export function generateHash(str) {
var hash = 0, i, chr, len;
let hash = 0, i, chr, len;
if (str.length === 0) return hash;

@@ -109,5 +125,5 @@ for (i = 0, len = str.length; i < len; i++) {

export function resultWrapper(result) {
if(result && result.entries && typeof result.entries !== 'undefined') {
if(result.entries && result.entries.length) {
for(var i = 0, _i = result.entries.length; i < _i; i++) {
if (result && typeof result.entries !== 'undefined') {
if (result.entries && result.entries.length) {
for(let i = 0, _i = result.entries.length; i < _i; i++) {
result.entries[i] = Result(result.entries[i]);

@@ -118,5 +134,16 @@ }

}
} else if (result && result.assets && typeof result.assets !== 'undefined') {
if (result.assets && result.assets.length) {
for(let j = 0, _j = result.assets.length; j < _j; j++) {
result.assets[j] = Result(result.assets[j]);
}
} else {
result.assets = [];
}
} else if(result && typeof result.entry !== 'undefined') {
result.entry = Result(result.entry);
} else if (result && typeof result.asset !== 'undefined') {
result.asset = Result(result.asset);
}
return result;

@@ -127,8 +154,10 @@ };

export function spreadResult(result) {
var _results = [];
let _results = [];
if(result && Object.keys(result).length) {
if(typeof result.entries !== 'undefined') _results.push(result.entries);
if(typeof result.assets !== 'undefined') _results.push(result.assets);
if(typeof result.schema !== 'undefined') _results.push(result.schema);
if(typeof result.count !== 'undefined') _results.push(result.count);
if(typeof result.entry !== 'undefined') _results = result.entry;
if(typeof result.asset !== 'undefined') _results = result.asset;
}

@@ -139,21 +168,26 @@ return _results;

export function sendRequest (queryObject) {
var env_uid = queryObject.environment_uid;
let env_uid = queryObject.environment_uid;
if (env_uid) {
queryObject._query.environment_uid = env_uid;
} else {
queryObject._query.environment = queryObject.environment;
if(queryObject._query) {
queryObject._query.environment = queryObject.environment;
} else {
queryObject['_query'] = {};
queryObject._query['environment'] = queryObject.environment;
}
}
var deferred = when.defer();
var self = queryObject;
var continueFlag = false;
var cachePolicy = (typeof self.queryCachePolicy !== 'undefined') ? self.queryCachePolicy : self.cachePolicy;
var tojson = (typeof self.tojson !== 'undefined') ? self.tojson : false;
var isSingle = (self.entry_uid || self.singleEntry) ? true : false;
var hashQuery = getHash(parseQueryFromParams(self, isSingle, tojson));
//var spreadResult;
let self = queryObject;
let continueFlag = false;
let cachePolicy = (typeof self.queryCachePolicy !== 'undefined') ? self.queryCachePolicy : self.cachePolicy;
let tojson = (typeof self.tojson !== 'undefined') ? self.tojson : false;
let isSingle = (self.entry_uid || self.singleEntry || self.asset_uid) ? true : false;
let hashQuery = getHash(parseQueryFromParams(self, isSingle, tojson));
/**
for new api v3
for new api v3
*/
if(queryObject && queryObject.requestParams && queryObject.requestParams.body && queryObject.requestParams.body.query){
var cloneQueryObj = JSON.parse(JSON.stringify(queryObject.requestParams.body.query));
let cloneQueryObj = JSON.parse(JSON.stringify(queryObject.requestParams.body.query));
if(typeof cloneQueryObj !== 'object') {

@@ -166,64 +200,70 @@ cloneQueryObj = JSON.parse(cloneQueryObj);

var getCacheCallback = function () {
let getCacheCallback = function () {
return function (err, entries) {
try {
if (err) throw err;
if (!tojson) entries = resultWrapper(entries);
return deferred.resolve(spreadResult(entries));
} catch (e) {
return deferred.reject(e);
}
return new Promise(function (resolve, reject) {
try {
if (err) throw err;
if (!tojson) entries = resultWrapper(entries);
resolve(spreadResult(entries));
} catch (e) {
reject(e)
}
});
}
};
var callback = function (continueFlag) {
let callback = function (continueFlag, resolve, reject) {
if(continueFlag) {
Request(queryObject.requestParams)
.then(function (data) {
try {
self.entry_uid = self.tojson = self.queryCachePolicy = undefined;
var entries = {};
if (queryObject.singleEntry) {
queryObject.singleEntry = false;
if(data.schema) entries.schema = data.schema;
if (data.entries && data.entries.length) {
entries.entry = data.entries[0];
.then(function (data) {
try {
self.entry_uid = self.asset_uid = self.tojson = self.queryCachePolicy = undefined;
let entries = {};
if (queryObject.singleEntry) {
queryObject.singleEntry = false;
if(data.schema) entries.schema = data.schema;
if (data.entries && data.entries.length) {
entries.entry = data.entries[0];
} else if (data.assets && data.assets.length) {
entries.assets = data.assets[0];
} else {
if(cachePolicy === 2) {
self.provider.get(hashQuery, getCacheCallback());
} else {
if(cachePolicy === 2) {
self.provider.get(hashQuery, getCacheCallback());
} else {
return deferred.reject({ error_code: 141, error_message: 'The requested entry doesn\'t exist.' });
}
return;
return reject({ error_code: 141, error_message: 'The requested entry doesn\'t exist.' });
}
} else {
entries = data;
return;
}
if(cachePolicy !== -1) {
self.provider.set(hashQuery, entries, function (err) {
try {
if (err) throw err;
if(!tojson) entries = resultWrapper(entries);
return deferred.resolve(spreadResult(entries));
} catch(e) {
return deferred.reject(e);
}
});
} else {
if(!tojson) entries = resultWrapper(entries);
return deferred.resolve(spreadResult(entries));
}
} catch (e) {
return deferred.reject({
message: e.message
} else {
entries = data;
}
if(cachePolicy !== -1) {
self.provider.set(hashQuery, entries, function (err) {
try {
if (err) throw err;
if(!tojson) entries = resultWrapper(entries);
return resolve(spreadResult(entries));
} catch(e) {
return reject(e);
}
});
}
}.bind(self))
.catch(function (error) {
if(cachePolicy === 2) {
self.provider.get(hashQuery, getCacheCallback());
return resolve(spreadResult(entries));
} else {
return deferred.reject(error);
if(!tojson) entries = resultWrapper(entries);
return resolve(spreadResult(entries));
}
});
} catch (e) {
return reject({
message: e.message
});
}
}.bind(self))
.catch(function (error) {
if(cachePolicy === 2) {
self.provider.get(hashQuery, getCacheCallback());
} else {
return reject(error);
}
});
}

@@ -234,15 +274,17 @@ };

case 1:
return new Promise(function (resolve, reject) {
self.provider.get(hashQuery, function (err, _data) {
try {
if(err || !_data) {
callback(true);
callback(true, resolve, reject);
} else {
if (!tojson) _data = resultWrapper(_data);
return deferred.resolve(spreadResult(_data));
return resolve(spreadResult(_data));
}
} catch(e) {
return deferred.reject(e);
}
return reject(e);
}
});
break;
});
break;
case 2:

@@ -252,27 +294,29 @@ case 0:

case -1:
callback(true);
return new Promise(function (resolve, reject) {
callback(true, resolve, reject);
})
};
if(cachePolicy !== 3) {
return deferred.promise;
} else {
if(cachePolicy === 3) {
return {
cache: (function () {
var Defer = when.defer();
self.provider.get(hashQuery, function (err, _data) {
try {
if(err) {
return Defer.reject(err);
} else {
if (!tojson) _data = resultWrapper(_data);
return Defer.resolve(spreadResult(_data));
return new Promise( function (resolve, reject) {
self.provider.get(hashQuery, function (err, _data) {
try {
if(err) {
reject(err);
} else {
if (!tojson) _data = resultWrapper(_data);
resolve(spreadResult(_data));
}
} catch(e) {
reject(e);
}
} catch(e) {
return Defer.reject(e);
}
});
});
return Defer.promise;
}()),
network: (function () {
callback(true);
return deferred.promise;
return new Promise(function (resolve, reject) {
callback(true, resolve, reject);
});
}()),

@@ -285,26 +329,28 @@ both: function (_callback_) {

Request(queryObject.requestParams)
.then(function (data) {
try {
self.entry_uid = self.tojson = self.queryCachePolicy = undefined;
var entries = {}, error = null;
if (queryObject.singleEntry) {
queryObject.singleEntry = false;
if(data.schema) entries.schema = data.schema;
if (data.entries && data.entries.length) {
entries.entry = data.entries[0];
} else {
error = { error_code: 141, error_message: 'The requested entry doesn\'t exist.' };
}
.then(function (data) {
try {
self.entry_uid = self.tojson = self.queryCachePolicy = undefined;
let entries = {}, error = null;
if (queryObject.singleEntry) {
queryObject.singleEntry = false;
if(data.schema) entries.schema = data.schema;
if (data.entries && data.entries.length) {
entries.entry = data.entries[0];
} else if (data.assets && data.assets.length) {
entries.assets = data.assets[0];
} else {
entries = data;
error = { error_code: 141, error_message: 'The requested entry doesn\'t exist.' };
}
if(!tojson) entries = resultWrapper(entries);
_callback_(error, spreadResult(entries));
} catch (e) {
_callback_(e);
} else {
entries = data;
}
}.bind(self))
.catch(function (error) {
_callback_(error);
});
if(!tojson) entries = resultWrapper(entries);
_callback_(error, spreadResult(entries));
} catch (e) {
_callback_(e);
}
}.bind(self))
.catch(function (error) {
_callback_(error);
});
}

@@ -311,0 +357,0 @@

import config from '../../config';
import * as Utils from './lib/utils';
import Entry from './entry/entry';
import Query from './entry/query';
import Request from './lib/request';
import Entry from './modules/entry';
import Assets from './modules/assets';
import Query from './modules/query';
import Request from './lib/request';
import * as cache from './cache';

@@ -13,5 +14,5 @@ import CacheProvider from './cache-provider/index';

*/
export default class Stack{
export default class Stack {
constructor(...stack_arguments){
constructor(...stack_arguments) {
this.config = config;

@@ -55,4 +56,4 @@ this.cachePolicy = CacheProvider.policies.IGNORE_CACHE;

* */
setPort(port){
if(typeof port === "number") this.config.port = port;
setPort(port) {
if (typeof port === "number") this.config.port = port;
return this;

@@ -67,4 +68,4 @@ }

* */
setProtocol(protocol){
if(typeof protocol === "string" && ~["https", "http"].indexOf(protocol)) this.config.protocol = protocol;
setProtocol(protocol) {
if (typeof protocol === "string" && ~["https", "http"].indexOf(protocol)) this.config.protocol = protocol;
return this;

@@ -79,4 +80,4 @@ }

* */
setHost(host){
if(typeof host === "string" && host) this.config.host = host;
setHost(host) {
if (typeof host === "string" && host) this.config.host = host;
return this;

@@ -97,5 +98,5 @@ }

*/
setCachePolicy(policy){
if(typeof policy === 'number' && policy >= -1 && policy < 4) {
if(!this._query) {
setCachePolicy(policy) {
if (typeof policy === 'number' && policy >= -1 && policy < 4) {
if (!this._query) {
this.cachePolicy = policy;

@@ -126,4 +127,4 @@ } else {

*/
setCacheProvider(provider){
if(provider && typeof provider === 'object') {
setCacheProvider(provider) {
if (provider && typeof provider === 'object') {
this.provider = provider;

@@ -142,4 +143,4 @@

*/
clearByQuery(){
if(this.provider && typeof this.provider.clearByQuery === 'function') {
clearByQuery() {
if (this.provider && typeof this.provider.clearByQuery === 'function') {
return this.provider.clearByQuery.apply(this.provider, arguments);

@@ -157,4 +158,4 @@ }

*/
clearByContentType(){
if(this.provider && typeof this.provider.clearByContentType === 'function') {
clearByContentType() {
if (this.provider && typeof this.provider.clearByContentType === 'function') {
return this.provider.clearByContentType.apply(this.provider, arguments);

@@ -171,4 +172,4 @@ }

*/
clearAll(){
if(this.provider && typeof this.provider.clearAll === 'function') {
clearAll() {
if (this.provider && typeof this.provider.clearAll === 'function') {
return this.provider.clearAll.apply(this.provider, arguments);

@@ -184,3 +185,3 @@ }

*/
getCacheProvider(){
getCacheProvider() {
return this.provider;

@@ -195,5 +196,6 @@ }

*/
ContentType(uid){
ContentType(uid) {
if (uid && typeof uid === 'string') {
this.content_type_uid = uid;
this.type = "contentType";
}

@@ -210,4 +212,4 @@ return this;

*/
Entry(uid){
var entry = new Entry();
Entry(uid) {
let entry = new Entry();
if (uid && typeof uid === "string") {

@@ -220,2 +222,18 @@ entry.entry_uid = uid;

/**
* @method Assets
* @description Set the Asset Uid which you want to retrive the Asset.
* @param {String} uid - asset_uid
* @example Stack.Assets('blt1234567890abcef')
* @returns {Assets}
*/
Assets(uid) {
let asset = new Assets();
this.type = 'asset';
if (uid && typeof uid === "string") {
asset.asset_uid = uid;
}
return Utils.merge(asset, this);
}
/**
* @method Query

@@ -226,4 +244,4 @@ * @description Query instance to provide support for all search queries.

*/
Query(){
var query = new Query();
Query() {
let query = new Query();
return Utils.merge(query, this);

@@ -239,17 +257,17 @@ }

*/
getLastActivities(){
var query = {
method: 'POST',
headers: this.headers,
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types,
body: {
_method: 'GET',
only_last_activity: true,
environment:this.environment
}
};
getLastActivities() {
let query = {
method: 'POST',
headers: this.headers,
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types,
body: {
_method: 'GET',
only_last_activity: true,
environment: this.environment
}
};
return Request(query);
}
}

@@ -1,5 +0,6 @@

import * as http from 'xmlhttprequest';
import ES6Promise from 'es6-promise';
import fetch from 'isomorphic-fetch';
var HTTPRequest = http.XMLHttpRequest;
ES6Promise.polyfill();
export default HTTPRequest;
export default fetch;

@@ -1,2 +0,2 @@

export default XMLHttpRequest;
export default fetch;
import localStorage from 'localStorage';
export default localStorage;
// import {AsyncStorage} from 'react-native';
// export default class localStorage{
// constructor(){
// }
// getItem(key){
// AsyncStorage.getItem(key).then((value) => {
// return {key:value};
// });
// }
// setItem(key, data){
// return AsyncStorage.setItem(key, data);
// }
// }

@@ -1,2 +0,6 @@

export default XMLHttpRequest;
import ES6Promise from 'es6-promise';
import fetch from 'isomorphic-fetch';
ES6Promise.polyfill();
export default fetch;

@@ -1,4 +0,8 @@

var webpack = require('webpack');
var path = require('path');
'use strict';
const webpack = require('webpack');
const path = require('path');
const Package = require('./../package.json');
module.exports = function (options) {

@@ -17,6 +21,7 @@ return {

rules: [
{
test: /\.js?$/,
exclude: ['../node_modules'],
use: [{
{
test: /\.js?$/,
exclude: ['../node_modules'],
use: [
{
loader:'babel-loader',

@@ -26,5 +31,14 @@ options: {

}
}],
},
{
loader:'string-replace-loader',
query: {
search: '{{VERSION}}',
replace: Package.version
}
}
],
}
]
},

@@ -31,0 +45,0 @@

@@ -1,12 +0,14 @@

var path = require('path');
var webpackMerge = require('webpack-merge');
var commonConfig = require('./webpack.common.js');
'use strict';
const path = require('path');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
module.exports = function (options) {
return webpackMerge(commonConfig(),{
output: {
library: "Contentstack",
libraryTarget:"commonjs2",
path: path.join(__dirname, "../dist/node"),
filename: "contentstack.js"
library: "Contentstack",
libraryTarget:"commonjs2",
path: path.join(__dirname, "../dist/node"),
filename: "contentstack.js"
},

@@ -16,8 +18,8 @@ target: "node",

alias:{
runtime: path.resolve( __dirname, '../src/runtime/node')
},
runtime: path.resolve( __dirname, '../src/runtime/node')
},
modules: [
'../src',
'../src/runtimes/node',
'node_modules',
'../src',
'../src/runtimes/node',
'node_modules',
]

@@ -24,0 +26,0 @@ }

@@ -1,5 +0,8 @@

var path = require('path');
var webpackMerge = require('webpack-merge');
var commonConfig = require('./webpack.common.js');
'use strict';
const path = require('path');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
module.exports = function (options) {

@@ -13,3 +16,2 @@ return webpackMerge(commonConfig(),{

},
target: "node",
resolve: {

@@ -16,0 +18,0 @@ alias:{

@@ -1,5 +0,8 @@

var path = require('path');
var webpackMerge = require('webpack-merge');
var commonConfig = require('./webpack.common.js');
'use strict';
const path = require('path');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
module.exports = function (options) {

@@ -22,7 +25,3 @@ return webpackMerge(commonConfig(),{

]
},
node: {
fs: "empty",
child_process: 'empty'
},
}
});

@@ -29,0 +28,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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