prismic-javascript
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -5,5 +5,5 @@ export interface Cookie { | ||
} | ||
declare var _default: { | ||
declare const _default: { | ||
parse: (str: string, options?: any) => Cookie; | ||
}; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
declare var _default: { | ||
declare const _default: { | ||
at(fragment: string, value: string | string[]): string; | ||
@@ -3,0 +3,0 @@ not(fragment: string, value: string): string; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("fetch-everywhere")):"function"==typeof define&&define.amd?define("PrismicJS",["fetch-everywhere"],t):"object"==typeof exports?exports.PrismicJS=t(require("fetch-everywhere")):e.PrismicJS=t(e["fetch-everywhere"])}(this,function(e){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=9)}([function(e,t,r){"use strict";t.__esModule=!0;var n=function(){function e(e){this.data={},this.data=e}return e.prototype.id=function(){return this.data.id},e.prototype.ref=function(){return this.data.ref},e.prototype.label=function(){return this.data.label},e}();t.Variation=n;var o=function(){function e(e){this.data={},this.data=e,this.variations=(e.variations||[]).map(function(e){return new n(e)})}return e.prototype.id=function(){return this.data.id},e.prototype.googleId=function(){return this.data.googleId},e.prototype.name=function(){return this.data.name},e}();t.Experiment=o;var i=function(){function e(e){e&&(this.drafts=(e.drafts||[]).map(function(e){return new o(e)}),this.running=(e.running||[]).map(function(e){return new o(e)}))}return e.prototype.current=function(){return this.running.length>0?this.running[0]:null},e.prototype.refFromCookie=function(e){if(!e||""===e.trim())return null;var t=e.trim().split(" ");if(t.length<2)return null;var r=t[0],n=parseInt(t[1],10),o=this.running.filter(function(e){return e.googleId()==r&&e.variations.length>n})[0];return o?o.variations[n].ref():null},e}();t.Experiments=i},function(e,t,r){"use strict";function n(e){return"string"==typeof e?'"'+e+'"':e instanceof Array?"["+e.map(function(e){return n(e)}).join(",")+"]":"number"==typeof e?e:null}t.__esModule=!0;var o={at:"at",not:"not",missing:"missing",has:"has",any:"any",in:"in",fulltext:"fulltext",similar:"similar","number.gt":"number.gt","number.lt":"number.lt","number.inRange":"number.inRange","date.before":"date.before","date.after":"date.after","date.between":"date.between","date.day-of-month":"date.day-of-month","date.day-of-month-after":"date.day-of-month-after","date.day-of-month-before":"date.day-of-month-before","date.day-of-week":"date.day-of-week","date.day-of-week-after":"date.day-of-week-after","date.day-of-week-before":"date.day-of-week-before","date.month":"date.month","date.month-before":"date.month-before","date.month-after":"date.month-after","date.year":"date.year","date.hour":"date.hour","date.hour-before":"date.hour-before","date.hour-after":"date.hour-after","geopoint.near":"geopoint.near"},i={near:function(e,t,r,n){return"["+o["geopoint.near"]+"("+e+", "+t+", "+r+", "+n+")]"}},a={before:function(e,t){return"["+o["date.before"]+"("+e+", "+t.getTime()+")]"},after:function(e,t){return"["+o["date.after"]+"("+e+", "+t.getTime()+")]"},between:function(e,t,r){return"["+o["date.between"]+"("+e+", "+t.getTime()+", "+r.getTime()+")]"},dayOfMonth:function(e,t){return"["+o["date.day-of-month"]+"("+e+", "+t+")]"},dayOfMonthAfter:function(e,t){return"["+o["date.day-of-month-after"]+"("+e+", "+t+")]"},dayOfMonthBefore:function(e,t){return"["+o["date.day-of-month-before"]+"("+e+", "+t+")]"},dayOfWeek:function(e,t){return"["+o["date.day-of-week"]+"("+e+", "+t+")]"},dayOfWeekAfter:function(e,t){return"["+o["date.day-of-week-after"]+"("+e+", "+t+")]"},dayOfWeekBefore:function(e,t){return"["+o["date.day-of-week-before"]+"("+e+", "+t+")]"},month:function(e,t){return"number"==typeof t?"["+o["date.month"]+"("+e+", "+t+")]":"["+o["date.month"]+"("+e+', "'+t+'")]'},monthBefore:function(e,t){return"number"==typeof t?"["+o["date.month-before"]+"("+e+", "+t+")]":"["+o["date.month-before"]+"("+e+', "'+t+'")]'},monthAfter:function(e,t){return"number"==typeof t?"["+o["date.month-after"]+"("+e+", "+t+")]":"["+o["date.month-after"]+"("+e+', "'+t+'")]'},year:function(e,t){return"["+o["date.year"]+"("+e+", "+t+")]"},hour:function(e,t){return"["+o["date.hour"]+"("+e+", "+t+")]"},hourBefore:function(e,t){return"["+o["date.hour-before"]+"("+e+", "+t+")]"},hourAfter:function(e,t){return"["+o["date.hour-after"]+"("+e+", "+t+")]"}},u={gt:function(e,t){return"["+o["number.gt"]+"("+e+", "+t+")]"},lt:function(e,t){return"["+o["number.lt"]+"("+e+", "+t+")]"},inRange:function(e,t,r){return"["+o["number.inRange"]+"("+e+", "+t+", "+r+")]"}};t.default={at:function(e,t){return"["+o.at+"("+e+", "+n(t)+")]"},not:function(e,t){return"["+o.not+"("+e+", "+n(t)+")]"},missing:function(e){return"["+o.missing+"("+e+")]"},has:function(e){return"["+o.has+"("+e+")]"},any:function(e,t){return"["+o.any+"("+e+", "+n(t)+")]"},in:function(e,t){return"["+o.in+"("+e+", "+n(t)+")]"},fulltext:function(e,t){return"["+o.fulltext+"("+e+", "+n(t)+")]"},similar:function(e,t){return"["+o.similar+'("'+e+'", '+t+")]"},date:a,dateBefore:a.before,dateAfter:a.after,dateBetween:a.between,dayOfMonth:a.dayOfMonth,dayOfMonthAfter:a.dayOfMonthAfter,dayOfMonthBefore:a.dayOfMonthBefore,dayOfWeek:a.dayOfWeek,dayOfWeekAfter:a.dayOfWeekAfter,dayOfWeekBefore:a.dayOfWeekBefore,month:a.month,monthBefore:a.monthBefore,monthAfter:a.monthAfter,year:a.year,hour:a.hour,hourBefore:a.hourBefore,hourAfter:a.hourAfter,number:u,gt:u.gt,lt:u.lt,inRange:u.inRange,near:i.near,geopoint:i}},function(e,t,r){"use strict";function n(e,t){var r=t||{},n=new a.Api(e,r);return new Promise(function(e,t){var o=function(n,o){r.complete&&r.complete(n,o),n?t(n):e(o)};return n.get(function(e,t){!e&&t&&(n.data=t,n.refs=t.refs,n.tags=t.tags,n.types=t.types,n.forms=t.forms,n.bookmarks=t.bookmarks,n.experiments=new i.Experiments(t.experiments)),o(e,n)}),n})}t.__esModule=!0;var o=r(1),i=r(0),a=r(4);e.exports={experimentCookie:a.ExperimentCookie,previewCookie:a.PreviewCookie,Predicates:o.default,Experiments:i.Experiments,api:n,Api:a.Api,getApi:n}},function(t,r){t.exports=e},function(e,t,r){"use strict";t.__esModule=!0;var n=r(1),o=r(0),i=r(8),a=r(5),u=r(6);t.PreviewCookie="io.prismic.preview",t.ExperimentCookie="io.prismic.experiment";var s=function(){function e(e,t,r){this.api=e,this.form=t,this.data=r||{};for(var n in t.fields)t.fields[n].default&&(this.data[n]=[t.fields[n].default])}return e.prototype.set=function(e,t){var r=this.form.fields[e];if(!r)throw new Error("Unknown field "+e);var n=""===t||void 0===t?null:t,o=this.data[e]||[];return o=r.multiple?n?o.concat([n]):o:n?[n]:o,this.data[e]=o,this},e.prototype.ref=function(e){return this.set("ref",e)},e.prototype.query=function(e){if("string"==typeof e)return this.query([e]);if(e instanceof Array)return this.set("q","["+e.join("")+"]");throw new Error("Invalid query : "+e)},e.prototype.pageSize=function(e){return this.set("pageSize",e)},e.prototype.fetch=function(e){var t=e instanceof Array?e.join(","):e;return this.set("fetch",t)},e.prototype.fetchLinks=function(e){var t=e instanceof Array?e.join(","):e;return this.set("fetchLinks",t)},e.prototype.lang=function(e){return this.set("lang",e)},e.prototype.page=function(e){return this.set("page",e)},e.prototype.after=function(e){return this.set("after",e)},e.prototype.orderings=function(e){return e?this.set("orderings","["+e.join(",")+"]"):this},e.prototype.url=function(){var e=this.form.action;if(this.data){var t=e.indexOf("?")>-1?"&":"?";for(var r in this.data)if(this.data.hasOwnProperty(r)){var n=this.data[r];if(n)for(var o=0;o<n.length;o++)e+=t+r+"="+encodeURIComponent(n[o]),t="&"}}return e},e.prototype.submit=function(e){return this.api.request(this.url(),e)},e}();t.SearchForm=s;var f=function(){function e(e,t){var r=t||{};return this.accessToken=r.accessToken,this.url=e+(this.accessToken?(e.indexOf("?")>-1?"&":"?")+"access_token="+this.accessToken:""),this.req=r.req,this.apiCache=r.apiCache||new a.DefaultApiCache,this.requestHandler=r.requestHandler||new i.DefaultRequestHandler({proxyAgent:r.proxyAgent}),this.apiCacheKey=this.url+(this.accessToken?"#"+this.accessToken:""),this.apiDataTTL=r.apiDataTTL||5,this}return e.prototype.get=function(e){var t=this,r=this.apiCacheKey;return new Promise(function(n,o){var i=function(t,r,i,a){e&&e(t,r,i,a),r&&n(r),t&&o(t)};t.apiCache.get(r,function(e,n){if(e||n)return void i(e,n);t.requestHandler.request(t.url,function(e,n,o,a){if(e)return void i(e,null,o,a);var u=t.parse(n);a=a||t.apiDataTTL,t.apiCache.set(r,u,a,function(e){i(e,u,o,a)})})})})},e.prototype.refresh=function(e){var t=this.apiCacheKey;return new Promise(function(r,n){var i=this,a=function(t,o,i){e&&e(t,o,i),o&&r(o),t&&n(t)};this.apiCache.remove(t,function(e){if(e)return void a(e);i.get(function(e,t){if(e)return void a(e);i.data=t,i.bookmarks=t.bookmarks,i.experiments=new o.Experiments(t.experiments),a()})})})},e.prototype.parse=function(e){var t=this,r=Object.keys(e.forms||[]).reduce(function(r,n,o){if(e.forms.hasOwnProperty(n)){var i=e.forms[n];return t.accessToken&&(i.fields.access_token={},i.fields.access_token.type="string",i.fields.access_token.default=t.accessToken),r[n]=i,r}return r},{}),n=e.refs||[],o=n.filter(function(e){return e.isMasterRef})[0],i=e.types,a=e.tags;if(!o)throw"No master ref.";return{bookmarks:e.bookmarks||{},refs:n,forms:r,master:o,types:i,tags:a,experiments:e.experiments,oauthInitiate:e.oauth_initiate,oauthToken:e.oauth_token,quickRoutes:e.quickRoutes}},e.prototype.form=function(e){var t=this.data.forms[e];return t?new s(this,t,{}):null},e.prototype.everything=function(){var e=this.form("everything");if(!e)throw new Error("Missing everything form");return e},e.prototype.master=function(){return this.data.master.ref},e.prototype.ref=function(e){for(var t=0;t<this.data.refs.length;t++)if(this.data.refs[t].label==e)return this.data.refs[t].ref;return null},e.prototype.currentExperiment=function(){return this.experiments.current()},e.prototype.quickRoutesEnabled=function(){return this.data.quickRoutes.enabled},e.prototype.getQuickRoutes=function(e){var t=this;return new Promise(function(r,n){t.requestHandler.request(t.data.quickRoutes.url,function(t,o,i){e&&e(t,o,i),t&&n(t),o&&r(o)})})},e.prototype.query=function(e,r,n){var o="function"==typeof r?{options:{},callback:r}:{options:r||{},callback:n},i=o.options,a=o.callback,s=i,f=this.everything();for(var c in s)f=f.set(c,s[c]);if(!s.ref){var h="";this.req?h=this.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(h=window.document.cookie||"");var d=u.default.parse(h),p=d[t.PreviewCookie],l=this.experiments.refFromCookie(d[t.ExperimentCookie]);f=f.ref(p||l||this.master())}return e&&f.query(e),f.submit(a)},e.prototype.queryFirst=function(e,t,r){var n="function"==typeof t?{options:{},callback:t}:{options:t||{},callback:r},o=n.options,i=n.callback,a=o;return a.page=1,a.pageSize=1,this.query(e,a,function(e,t){if(i){var r=t&&t.results&&t.results[0];i(e,r)}}).then(function(e){return e&&e.results&&e.results[0]}).catch(function(e){console.log(e)})},e.prototype.getByID=function(e,t,r){return t=t||{},t.lang||(t.lang="*"),this.queryFirst(n.default.at("document.id",e),t,r)},e.prototype.getByIDs=function(e,t,r){return t=t||{},t.lang||(t.lang="*"),this.query(n.default.in("document.id",e),t,r)},e.prototype.getByUID=function(e,t,r,o){return r=r||{},r.lang||(r.lang="*"),this.queryFirst(n.default.at("my."+e+".uid",t),r,o)},e.prototype.getSingle=function(e,t,r){return this.queryFirst(n.default.at("document.type",e),t,r)},e.prototype.getBookmark=function(e,t,r){var n=this;return new Promise(function(t,o){var i=n.bookmarks[e];if(i)t(i);else{var a=new Error("Error retrieving bookmarked id");r&&r(a),o(a)}}).then(function(e){return n.getByID(e,t,r)})},e.prototype.previewSession=function(e,t,r,o){var i=this;return new Promise(function(a,u){var s=function(e,t,r){o&&o(e,t,r),e?u(e):a(t)};i.requestHandler.request(e,function(o,a,u){if(o)return void s(o,r,u);try{var f=a.mainDocument;f?i.everything().query(n.default.at("document.id",f)).ref(e).lang("*").submit(function(e,n){e&&s(e);try{0===n.results.length?s(null,r,u):s(null,t(n.results[0]),u)}catch(e){s(e)}}):s(null,r,u)}catch(e){s(e,r,u)}})})},e.prototype.request=function(e,t){function r(t){i.get(o,function(r,a){if(r||a)return void t(r,a);n.requestHandler.request(e,function(e,r,n,a){if(e)return void t(e,null,n);a?i.set(o,r,a,function(e){t(e,r)}):t(null,r)})})}var n=this,o=e+(this.accessToken?"#"+this.accessToken:""),i=this.apiCache;return new Promise(function(e,n){r(function(r,o,i){t&&t(r,o,i),r&&n(r),o&&e(o)})})},e.prototype.getNextPage=function(e,t){return this.request(e+(this.accessToken?"&access_token="+this.accessToken:""),t)},e}();t.Api=f},function(e,t,r){"use strict";t.__esModule=!0;var n=r(7),o=function(){function e(e){this.lru=n.MakeLRUCache(e)}return e.prototype.isExpired=function(e){var t=this.lru.get(e,!1);return!!t&&0!==t.expiredIn&&t.expiredIn<Date.now()},e.prototype.get=function(e,t){var r=this.lru.get(e,!1);r&&!this.isExpired(e)?t(null,r.data):t()},e.prototype.set=function(e,t,r,n){this.lru.remove(e),this.lru.put(e,{data:t,expiredIn:r?Date.now()+1e3*r:0}),n()},e.prototype.remove=function(e,t){this.lru.remove(e),t()},e.prototype.clear=function(e){this.lru.removeAll(),e()},e}();t.DefaultApiCache=o},function(e,t,r){"use strict";function n(e,t){try{return t(e)}catch(t){return e}}function o(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var r={},o=t||{},a=o.decode||i;return e.split(/; */).forEach(function(e){var t=e.indexOf("=");if(!(t<0)){var o=e.substr(0,t).trim(),i=e.substr(++t,e.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),void 0==r[o]&&(r[o]=n(i,a))}}),r}t.__esModule=!0;var i=decodeURIComponent;t.default={parse:o}},function(e,t,r){"use strict";function n(e){return new o(e)}function o(e){this.size=0,this.limit=e,this._keymap={}}t.__esModule=!0,t.MakeLRUCache=n,o.prototype.put=function(e,t){var r={key:e,value:t};if(this._keymap[e]=r,this.tail?(this.tail.newer=r,r.older=this.tail):this.head=r,this.tail=r,this.size===this.limit)return this.shift();this.size++},o.prototype.shift=function(){var e=this.head;return e&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,e.newer=e.older=void 0,delete this._keymap[e.key]),console.log("purging ",e.key),e},o.prototype.get=function(e,t){var r=this._keymap[e];if(void 0!==r)return r===this.tail?t?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,t?r:r.value)},o.prototype.find=function(e){return this._keymap[e]},o.prototype.set=function(e,t){var r,n=this.get(e,!0);return n?(r=n.value,n.value=t):(r=this.put(e,t))&&(r=r.value),r},o.prototype.remove=function(e){var t=this._keymap[e];if(t)return delete this._keymap[t.key],t.newer&&t.older?(t.older.newer=t.newer,t.newer.older=t.older):t.newer?(t.newer.older=void 0,this.head=t.newer):t.older?(t.older.newer=void 0,this.tail=t.older):this.head=this.tail=void 0,this.size--,t.value},o.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?o.prototype.keys=function(){return Object.keys(this._keymap)}:o.prototype.keys=function(){var e=[];for(var t in this._keymap)e.push(t);return e},o.prototype.forEach=function(e,t,r){var n;if(!0===t?(r=!0,t=void 0):"object"!=typeof t&&(t=this),r)for(n=this.tail;n;)e.call(t,n.key,n.value,this),n=n.older;else for(n=this.head;n;)e.call(t,n.key,n.value,this),n=n.newer},o.prototype.toString=function(){for(var e="",t=this.head;t;)e+=String(t.key)+":"+t.value,(t=t.newer)&&(e+=" < ");return e}},function(e,t,r){"use strict";function n(e,t){return{message:t,status:e,name:"prismic-request-error"}}function o(e,t,r,o){var i={headers:{Accept:"application/json"}};return o&&o.proxyAgent&&(i.agent=o.proxyAgent),fetch(e,i).then(function(t){if(~~(t.status/100!=2))throw n(t.status,"Unexpected status code ["+t.status+"] on URL "+e);return t.json().then(function(e){return{response:t,json:e}})}).then(function(e){var r=e.response,n=e.json,o=r.headers.get("cache-control"),i=o?/max-age=(\d+)/.exec(o):null,a=i?parseInt(i[1],10):void 0;t({result:n,xhr:r,ttl:a})}).catch(function(e){r({error:e})})}function i(e){if(!(0===s.length||u>=a)){u++;var t=s.shift();o(t.url,function(r){var n=r.result,o=r.xhr,a=r.ttl;u--,t.callback(null,n,o,a),i(e)},function(r){var n=r.error;t.callback(n),i(e)},e)}}t.__esModule=!0;var a=20,u=0,s=[],f=function(){function e(e){this.options=e}return e.prototype.request=function(e,t){s.push({url:e,callback:t}),i(this.options)},e}();t.DefaultRequestHandler=f},function(e,t,r){r(3),e.exports=r(2)}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("fetch-everywhere")):"function"==typeof define&&define.amd?define("PrismicJS",["fetch-everywhere"],t):"object"==typeof exports?exports.PrismicJS=t(require("fetch-everywhere")):e.PrismicJS=t(e["fetch-everywhere"])}(this,function(e){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.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=2)}([function(e,t,r){"use strict";function n(e){return"string"==typeof e?'"'+e+'"':e instanceof Array?"["+e.map(function(e){return n(e)}).join(",")+"]":"number"==typeof e?e:null}t.__esModule=!0;var o={at:"at",not:"not",missing:"missing",has:"has",any:"any",in:"in",fulltext:"fulltext",similar:"similar","number.gt":"number.gt","number.lt":"number.lt","number.inRange":"number.inRange","date.before":"date.before","date.after":"date.after","date.between":"date.between","date.day-of-month":"date.day-of-month","date.day-of-month-after":"date.day-of-month-after","date.day-of-month-before":"date.day-of-month-before","date.day-of-week":"date.day-of-week","date.day-of-week-after":"date.day-of-week-after","date.day-of-week-before":"date.day-of-week-before","date.month":"date.month","date.month-before":"date.month-before","date.month-after":"date.month-after","date.year":"date.year","date.hour":"date.hour","date.hour-before":"date.hour-before","date.hour-after":"date.hour-after","geopoint.near":"geopoint.near"},i={near:function(e,t,r,n){return"["+o["geopoint.near"]+"("+e+", "+t+", "+r+", "+n+")]"}},a={before:function(e,t){return"["+o["date.before"]+"("+e+", "+t.getTime()+")]"},after:function(e,t){return"["+o["date.after"]+"("+e+", "+t.getTime()+")]"},between:function(e,t,r){return"["+o["date.between"]+"("+e+", "+t.getTime()+", "+r.getTime()+")]"},dayOfMonth:function(e,t){return"["+o["date.day-of-month"]+"("+e+", "+t+")]"},dayOfMonthAfter:function(e,t){return"["+o["date.day-of-month-after"]+"("+e+", "+t+")]"},dayOfMonthBefore:function(e,t){return"["+o["date.day-of-month-before"]+"("+e+", "+t+")]"},dayOfWeek:function(e,t){return"["+o["date.day-of-week"]+"("+e+", "+t+")]"},dayOfWeekAfter:function(e,t){return"["+o["date.day-of-week-after"]+"("+e+", "+t+")]"},dayOfWeekBefore:function(e,t){return"["+o["date.day-of-week-before"]+"("+e+", "+t+")]"},month:function(e,t){return"number"==typeof t?"["+o["date.month"]+"("+e+", "+t+")]":"["+o["date.month"]+"("+e+', "'+t+'")]'},monthBefore:function(e,t){return"number"==typeof t?"["+o["date.month-before"]+"("+e+", "+t+")]":"["+o["date.month-before"]+"("+e+', "'+t+'")]'},monthAfter:function(e,t){return"number"==typeof t?"["+o["date.month-after"]+"("+e+", "+t+")]":"["+o["date.month-after"]+"("+e+', "'+t+'")]'},year:function(e,t){return"["+o["date.year"]+"("+e+", "+t+")]"},hour:function(e,t){return"["+o["date.hour"]+"("+e+", "+t+")]"},hourBefore:function(e,t){return"["+o["date.hour-before"]+"("+e+", "+t+")]"},hourAfter:function(e,t){return"["+o["date.hour-after"]+"("+e+", "+t+")]"}},u={gt:function(e,t){return"["+o["number.gt"]+"("+e+", "+t+")]"},lt:function(e,t){return"["+o["number.lt"]+"("+e+", "+t+")]"},inRange:function(e,t,r){return"["+o["number.inRange"]+"("+e+", "+t+", "+r+")]"}};t.default={at:function(e,t){return"["+o.at+"("+e+", "+n(t)+")]"},not:function(e,t){return"["+o.not+"("+e+", "+n(t)+")]"},missing:function(e){return"["+o.missing+"("+e+")]"},has:function(e){return"["+o.has+"("+e+")]"},any:function(e,t){return"["+o.any+"("+e+", "+n(t)+")]"},in:function(e,t){return"["+o.in+"("+e+", "+n(t)+")]"},fulltext:function(e,t){return"["+o.fulltext+"("+e+", "+n(t)+")]"},similar:function(e,t){return"["+o.similar+'("'+e+'", '+t+")]"},date:a,dateBefore:a.before,dateAfter:a.after,dateBetween:a.between,dayOfMonth:a.dayOfMonth,dayOfMonthAfter:a.dayOfMonthAfter,dayOfMonthBefore:a.dayOfMonthBefore,dayOfWeek:a.dayOfWeek,dayOfWeekAfter:a.dayOfWeekAfter,dayOfWeekBefore:a.dayOfWeekBefore,month:a.month,monthBefore:a.monthBefore,monthAfter:a.monthAfter,year:a.year,hour:a.hour,hourBefore:a.hourBefore,hourAfter:a.hourAfter,number:u,gt:u.gt,lt:u.lt,inRange:u.inRange,near:i.near,geopoint:i}},function(e,t,r){"use strict";t.__esModule=!0;var n=function(){function e(e){this.data={},this.data=e}return e.prototype.id=function(){return this.data.id},e.prototype.ref=function(){return this.data.ref},e.prototype.label=function(){return this.data.label},e}();t.Variation=n;var o=function(){function e(e){this.data={},this.data=e,this.variations=(e.variations||[]).map(function(e){return new n(e)})}return e.prototype.id=function(){return this.data.id},e.prototype.googleId=function(){return this.data.googleId},e.prototype.name=function(){return this.data.name},e}();t.Experiment=o;var i=function(){function e(e){e&&(this.drafts=(e.drafts||[]).map(function(e){return new o(e)}),this.running=(e.running||[]).map(function(e){return new o(e)}))}return e.prototype.current=function(){return this.running.length>0?this.running[0]:null},e.prototype.refFromCookie=function(e){if(!e||""===e.trim())return null;var t=e.trim().split(" ");if(t.length<2)return null;var r=t[0],n=parseInt(t[1],10),o=this.running.filter(function(e){return e.googleId()==r&&e.variations.length>n})[0];return o?o.variations[n].ref():null},e}();t.Experiments=i},function(e,t,r){r(3),e.exports=r(4)},function(t,r){t.exports=e},function(e,t,r){"use strict";var n,o=r(0),i=r(1),a=r(5);!function(e){function t(t,r){var n=r||{},o=new a.Api(t,n);return new Promise(function(t,r){var i=function(e,o){n.complete&&n.complete(e,o),e?r(e):t(o)};return o.get(function(t,r){!t&&r&&(o.data=r,o.refs=r.refs,o.tags=r.tags,o.types=r.types,o.forms=r.forms,o.bookmarks=r.bookmarks,o.experiments=new e.Experiments(r.experiments)),i(t,o)}),o})}function r(e,r){return t(e,r)}e.experimentCookie=a.ExperimentCookie,e.previewCookie=a.PreviewCookie,e.Predicates=o.default,e.Experiments=i.Experiments,e.Api=a.Api,e.getApi=t,e.api=r}(n||(n={})),e.exports=n},function(e,t,r){"use strict";t.__esModule=!0;var n=r(0),o=r(1),i=r(6),a=r(7),u=r(9);t.PreviewCookie="io.prismic.preview",t.ExperimentCookie="io.prismic.experiment";var s=function(){function e(e,t,r){this.api=e,this.form=t,this.data=r||{};for(var n in t.fields)t.fields[n].default&&(this.data[n]=[t.fields[n].default])}return e.prototype.set=function(e,t){var r=this.form.fields[e];if(!r)throw new Error("Unknown field "+e);var n=""===t||void 0===t?null:t,o=this.data[e]||[];return o=r.multiple?n?o.concat([n]):o:n?[n]:o,this.data[e]=o,this},e.prototype.ref=function(e){return this.set("ref",e)},e.prototype.query=function(e){if("string"==typeof e)return this.query([e]);if(e instanceof Array)return this.set("q","["+e.join("")+"]");throw new Error("Invalid query : "+e)},e.prototype.pageSize=function(e){return this.set("pageSize",e)},e.prototype.fetch=function(e){var t=e instanceof Array?e.join(","):e;return this.set("fetch",t)},e.prototype.fetchLinks=function(e){var t=e instanceof Array?e.join(","):e;return this.set("fetchLinks",t)},e.prototype.lang=function(e){return this.set("lang",e)},e.prototype.page=function(e){return this.set("page",e)},e.prototype.after=function(e){return this.set("after",e)},e.prototype.orderings=function(e){return e?this.set("orderings","["+e.join(",")+"]"):this},e.prototype.url=function(){var e=this.form.action;if(this.data){var t=e.indexOf("?")>-1?"&":"?";for(var r in this.data)if(this.data.hasOwnProperty(r)){var n=this.data[r];if(n)for(var o=0;o<n.length;o++)e+=t+r+"="+encodeURIComponent(n[o]),t="&"}}return e},e.prototype.submit=function(e){return this.api.request(this.url(),e)},e}();t.SearchForm=s;var f=function(){function e(e,t){var r=t||{};return this.accessToken=r.accessToken,this.url=e+(this.accessToken?(e.indexOf("?")>-1?"&":"?")+"access_token="+this.accessToken:""),this.req=r.req,this.apiCache=r.apiCache||new a.DefaultApiCache,this.requestHandler=r.requestHandler||new i.DefaultRequestHandler({proxyAgent:r.proxyAgent}),this.apiCacheKey=this.url+(this.accessToken?"#"+this.accessToken:""),this.apiDataTTL=r.apiDataTTL||5,this}return e.prototype.get=function(e){var t=this,r=this.apiCacheKey;return new Promise(function(n,o){var i=function(t,r,i,a){e&&e(t,r,i,a),r&&n(r),t&&o(t)};t.apiCache.get(r,function(e,n){if(e||n)return void i(e,n);t.requestHandler.request(t.url,function(e,n,o,a){if(e)return void i(e,null,o,a);var u=t.parse(n);a=a||t.apiDataTTL,t.apiCache.set(r,u,a,function(e){i(e,u,o,a)})})})})},e.prototype.refresh=function(e){var t=this.apiCacheKey;return new Promise(function(r,n){var i=this,a=function(t,o,i){e&&e(t,o,i),o&&r(o),t&&n(t)};this.apiCache.remove(t,function(e){if(e)return void a(e);i.get(function(e,t){if(e)return void a(e);i.data=t,i.bookmarks=t.bookmarks,i.experiments=new o.Experiments(t.experiments),a()})})})},e.prototype.parse=function(e){var t=this,r=Object.keys(e.forms||[]).reduce(function(r,n,o){if(e.forms.hasOwnProperty(n)){var i=e.forms[n];return t.accessToken&&(i.fields.access_token={},i.fields.access_token.type="string",i.fields.access_token.default=t.accessToken),r[n]=i,r}return r},{}),n=e.refs||[],o=n.filter(function(e){return e.isMasterRef})[0],i=e.types,a=e.tags;if(!o)throw"No master ref.";return{bookmarks:e.bookmarks||{},refs:n,forms:r,master:o,types:i,tags:a,experiments:e.experiments,oauthInitiate:e.oauth_initiate,oauthToken:e.oauth_token,quickRoutes:e.quickRoutes}},e.prototype.form=function(e){var t=this.data.forms[e];return t?new s(this,t,{}):null},e.prototype.everything=function(){var e=this.form("everything");if(!e)throw new Error("Missing everything form");return e},e.prototype.master=function(){return this.data.master.ref},e.prototype.ref=function(e){for(var t=0;t<this.data.refs.length;t++)if(this.data.refs[t].label==e)return this.data.refs[t].ref;return null},e.prototype.currentExperiment=function(){return this.experiments.current()},e.prototype.quickRoutesEnabled=function(){return this.data.quickRoutes.enabled},e.prototype.getQuickRoutes=function(e){var t=this;return new Promise(function(r,n){t.requestHandler.request(t.data.quickRoutes.url,function(t,o,i){e&&e(t,o,i),t&&n(t),o&&r(o)})})},e.prototype.query=function(e,r,n){var o="function"==typeof r?{options:{},callback:r}:{options:r||{},callback:n},i=o.options,a=o.callback,s=i,f=this.everything();for(var c in s)f=f.set(c,s[c]);if(!s.ref){var h="";this.req?h=this.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(h=window.document.cookie||"");var d=u.default.parse(h),p=d[t.PreviewCookie],l=this.experiments.refFromCookie(d[t.ExperimentCookie]);f=f.ref(p||l||this.master())}return e&&f.query(e),f.submit(a)},e.prototype.queryFirst=function(e,t,r){var n="function"==typeof t?{options:{},callback:t}:{options:t||{},callback:r},o=n.options,i=n.callback,a=o;return a.page=1,a.pageSize=1,this.query(e,a,function(e,t){if(i){var r=t&&t.results&&t.results[0];i(e,r)}}).then(function(e){return e&&e.results&&e.results[0]}).catch(function(e){console.log(e)})},e.prototype.getByID=function(e,t,r){return t=t||{},t.lang||(t.lang="*"),this.queryFirst(n.default.at("document.id",e),t,r)},e.prototype.getByIDs=function(e,t,r){return t=t||{},t.lang||(t.lang="*"),this.query(n.default.in("document.id",e),t,r)},e.prototype.getByUID=function(e,t,r,o){return r=r||{},r.lang||(r.lang="*"),this.queryFirst(n.default.at("my."+e+".uid",t),r,o)},e.prototype.getSingle=function(e,t,r){return this.queryFirst(n.default.at("document.type",e),t,r)},e.prototype.getBookmark=function(e,t,r){var n=this;return new Promise(function(t,o){var i=n.bookmarks[e];if(i)t(i);else{var a=new Error("Error retrieving bookmarked id");r&&r(a),o(a)}}).then(function(e){return n.getByID(e,t,r)})},e.prototype.previewSession=function(e,t,r,o){var i=this;return new Promise(function(a,u){var s=function(e,t,r){o&&o(e,t,r),e?u(e):a(t)};i.requestHandler.request(e,function(o,a,u){if(o)return void s(o,r,u);try{var f=a.mainDocument;f?i.everything().query(n.default.at("document.id",f)).ref(e).lang("*").submit(function(e,n){e&&s(e);try{0===n.results.length?s(null,r,u):s(null,t(n.results[0]),u)}catch(e){s(e)}}):s(null,r,u)}catch(e){s(e,r,u)}})})},e.prototype.request=function(e,t){function r(t){i.get(o,function(r,a){if(r||a)return void t(r,a);n.requestHandler.request(e,function(e,r,n,a){if(e)return void t(e,null,n);a?i.set(o,r,a,function(e){t(e,r)}):t(null,r)})})}var n=this,o=e+(this.accessToken?"#"+this.accessToken:""),i=this.apiCache;return new Promise(function(e,n){r(function(r,o,i){t&&t(r,o,i),r&&n(r),o&&e(o)})})},e.prototype.getNextPage=function(e,t){return this.request(e+(this.accessToken?"&access_token="+this.accessToken:""),t)},e}();t.Api=f},function(e,t,r){"use strict";function n(e,t){return{message:t,status:e,name:"prismic-request-error"}}function o(e,t,r,o){var i={headers:{Accept:"application/json"}};return o&&o.proxyAgent&&(i.agent=o.proxyAgent),fetch(e,i).then(function(t){if(~~(t.status/100!=2))throw n(t.status,"Unexpected status code ["+t.status+"] on URL "+e);return t.json().then(function(e){return{response:t,json:e}})}).then(function(e){var r=e.response,n=e.json,o=r.headers.get("cache-control"),i=o?/max-age=(\d+)/.exec(o):null,a=i?parseInt(i[1],10):void 0;t({result:n,xhr:r,ttl:a})}).catch(function(e){r({error:e})})}function i(e){if(!(0===s.length||u>=a)){u++;var t=s.shift();o(t.url,function(r){var n=r.result,o=r.xhr,a=r.ttl;u--,t.callback(null,n,o,a),i(e)},function(r){var n=r.error;t.callback(n),i(e)},e)}}t.__esModule=!0;var a=20,u=0,s=[],f=function(){function e(e){this.options=e}return e.prototype.request=function(e,t){s.push({url:e,callback:t}),i(this.options)},e}();t.DefaultRequestHandler=f},function(e,t,r){"use strict";t.__esModule=!0;var n=r(8),o=function(){function e(e){this.lru=n.MakeLRUCache(e)}return e.prototype.isExpired=function(e){var t=this.lru.get(e,!1);return!!t&&0!==t.expiredIn&&t.expiredIn<Date.now()},e.prototype.get=function(e,t){var r=this.lru.get(e,!1);r&&!this.isExpired(e)?t(null,r.data):t()},e.prototype.set=function(e,t,r,n){this.lru.remove(e),this.lru.put(e,{data:t,expiredIn:r?Date.now()+1e3*r:0}),n()},e.prototype.remove=function(e,t){this.lru.remove(e),t()},e.prototype.clear=function(e){this.lru.removeAll(),e()},e}();t.DefaultApiCache=o},function(e,t,r){"use strict";function n(e){return new o(e)}function o(e){this.size=0,this.limit=e,this._keymap={}}t.__esModule=!0,t.MakeLRUCache=n,o.prototype.put=function(e,t){var r={key:e,value:t};if(this._keymap[e]=r,this.tail?(this.tail.newer=r,r.older=this.tail):this.head=r,this.tail=r,this.size===this.limit)return this.shift();this.size++},o.prototype.shift=function(){var e=this.head;return e&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,e.newer=e.older=void 0,delete this._keymap[e.key]),console.log("purging ",e.key),e},o.prototype.get=function(e,t){var r=this._keymap[e];if(void 0!==r)return r===this.tail?t?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,t?r:r.value)},o.prototype.find=function(e){return this._keymap[e]},o.prototype.set=function(e,t){var r,n=this.get(e,!0);return n?(r=n.value,n.value=t):(r=this.put(e,t))&&(r=r.value),r},o.prototype.remove=function(e){var t=this._keymap[e];if(t)return delete this._keymap[t.key],t.newer&&t.older?(t.older.newer=t.newer,t.newer.older=t.older):t.newer?(t.newer.older=void 0,this.head=t.newer):t.older?(t.older.newer=void 0,this.tail=t.older):this.head=this.tail=void 0,this.size--,t.value},o.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?o.prototype.keys=function(){return Object.keys(this._keymap)}:o.prototype.keys=function(){var e=[];for(var t in this._keymap)e.push(t);return e},o.prototype.forEach=function(e,t,r){var n;if(!0===t?(r=!0,t=void 0):"object"!=typeof t&&(t=this),r)for(n=this.tail;n;)e.call(t,n.key,n.value,this),n=n.older;else for(n=this.head;n;)e.call(t,n.key,n.value,this),n=n.newer},o.prototype.toString=function(){for(var e="",t=this.head;t;)e+=String(t.key)+":"+t.value,(t=t.newer)&&(e+=" < ");return e}},function(e,t,r){"use strict";function n(e,t){try{return t(e)}catch(t){return e}}function o(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var r={},o=t||{},a=o.decode||i;return e.split(/; */).forEach(function(e){var t=e.indexOf("=");if(!(t<0)){var o=e.substr(0,t).trim(),i=e.substr(++t,e.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),void 0==r[o]&&(r[o]=n(i,a))}}),r}t.__esModule=!0;var i=decodeURIComponent;t.default={parse:o}}])}); |
var typedoc = typedoc || {}; | ||
typedoc.search = typedoc.search || {}; | ||
typedoc.search.data = {"kinds":{"64":"Function","65536":"Type literal"},"rows":[{"id":0,"kind":65536,"name":"__type","url":"classes/api.html#bookmarks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Api.bookmarks"},{"id":1,"kind":64,"name":"getApi","url":"globals.html#getapi","classes":"tsd-kind-function tsd-is-not-exported"}]}; | ||
typedoc.search.data = {"kinds":{"2":"Module","32":"Variable","64":"Function","65536":"Type literal"},"rows":[{"id":0,"kind":65536,"name":"__type","url":"classes/api.html#bookmarks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Api.bookmarks"},{"id":1,"kind":2,"name":"Prismic","url":"modules/prismic.html","classes":"tsd-kind-module"},{"id":2,"kind":32,"name":"experimentCookie","url":"modules/prismic.html#experimentcookie","classes":"tsd-kind-variable tsd-parent-kind-module","parent":"Prismic"},{"id":3,"kind":32,"name":"previewCookie","url":"modules/prismic.html#previewcookie","classes":"tsd-kind-variable tsd-parent-kind-module","parent":"Prismic"},{"id":4,"kind":32,"name":"Predicates","url":"modules/prismic.html#predicates","classes":"tsd-kind-variable tsd-parent-kind-module","parent":"Prismic"},{"id":5,"kind":65536,"name":"__type","url":"modules/prismic.html#predicates.__type","classes":"tsd-kind-type-literal tsd-parent-kind-variable","parent":"Prismic.Predicates"},{"id":6,"kind":64,"name":"at","url":"modules/prismic.html#predicates.__type.at","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":7,"kind":64,"name":"not","url":"modules/prismic.html#predicates.__type.not","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":8,"kind":64,"name":"missing","url":"modules/prismic.html#predicates.__type.missing","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":9,"kind":64,"name":"has","url":"modules/prismic.html#predicates.__type.has","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":10,"kind":64,"name":"any","url":"modules/prismic.html#predicates.__type.any","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":11,"kind":64,"name":"in","url":"modules/prismic.html#predicates.__type.in","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":12,"kind":64,"name":"fulltext","url":"modules/prismic.html#predicates.__type.fulltext","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":13,"kind":64,"name":"similar","url":"modules/prismic.html#predicates.__type.similar","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":14,"kind":32,"name":"date","url":"modules/prismic.html#predicates.__type.date","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":15,"kind":65536,"name":"__type","url":"modules/prismic.html#predicates.__type.date.__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-variable","parent":"Prismic.Predicates.__type.date"},{"id":16,"kind":64,"name":"before","url":"modules/prismic.html#predicates.__type.date.__type-1.before","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":17,"kind":64,"name":"after","url":"modules/prismic.html#predicates.__type.date.__type-1.after","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":18,"kind":64,"name":"between","url":"modules/prismic.html#predicates.__type.date.__type-1.between","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":19,"kind":64,"name":"dayOfMonth","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofmonth","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":20,"kind":64,"name":"dayOfMonthAfter","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofmonthafter","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":21,"kind":64,"name":"dayOfMonthBefore","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofmonthbefore","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":22,"kind":64,"name":"dayOfWeek","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofweek","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":23,"kind":64,"name":"dayOfWeekAfter","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofweekafter","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":24,"kind":64,"name":"dayOfWeekBefore","url":"modules/prismic.html#predicates.__type.date.__type-1.dayofweekbefore","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":25,"kind":64,"name":"month","url":"modules/prismic.html#predicates.__type.date.__type-1.month","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":26,"kind":64,"name":"monthBefore","url":"modules/prismic.html#predicates.__type.date.__type-1.monthbefore","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":27,"kind":64,"name":"monthAfter","url":"modules/prismic.html#predicates.__type.date.__type-1.monthafter","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":28,"kind":64,"name":"year","url":"modules/prismic.html#predicates.__type.date.__type-1.year","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":29,"kind":64,"name":"hour","url":"modules/prismic.html#predicates.__type.date.__type-1.hour","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":30,"kind":64,"name":"hourBefore","url":"modules/prismic.html#predicates.__type.date.__type-1.hourbefore","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":31,"kind":64,"name":"hourAfter","url":"modules/prismic.html#predicates.__type.date.__type-1.hourafter","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.date.__type"},{"id":32,"kind":32,"name":"dateBefore","url":"modules/prismic.html#predicates.__type.datebefore","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":33,"kind":32,"name":"dateAfter","url":"modules/prismic.html#predicates.__type.dateafter","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":34,"kind":32,"name":"dateBetween","url":"modules/prismic.html#predicates.__type.datebetween","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":35,"kind":32,"name":"dayOfMonth","url":"modules/prismic.html#predicates.__type.dayofmonth-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":36,"kind":32,"name":"dayOfMonthAfter","url":"modules/prismic.html#predicates.__type.dayofmonthafter-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":37,"kind":32,"name":"dayOfMonthBefore","url":"modules/prismic.html#predicates.__type.dayofmonthbefore-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":38,"kind":32,"name":"dayOfWeek","url":"modules/prismic.html#predicates.__type.dayofweek-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":39,"kind":32,"name":"dayOfWeekAfter","url":"modules/prismic.html#predicates.__type.dayofweekafter-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":40,"kind":32,"name":"dayOfWeekBefore","url":"modules/prismic.html#predicates.__type.dayofweekbefore-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":41,"kind":32,"name":"month","url":"modules/prismic.html#predicates.__type.month-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":42,"kind":32,"name":"monthBefore","url":"modules/prismic.html#predicates.__type.monthbefore-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":43,"kind":32,"name":"monthAfter","url":"modules/prismic.html#predicates.__type.monthafter-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":44,"kind":32,"name":"year","url":"modules/prismic.html#predicates.__type.year-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":45,"kind":32,"name":"hour","url":"modules/prismic.html#predicates.__type.hour-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":46,"kind":32,"name":"hourBefore","url":"modules/prismic.html#predicates.__type.hourbefore-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":47,"kind":32,"name":"hourAfter","url":"modules/prismic.html#predicates.__type.hourafter-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":48,"kind":32,"name":"number","url":"modules/prismic.html#predicates.__type.number","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":49,"kind":65536,"name":"__type","url":"modules/prismic.html#predicates.__type.number.__type-3","classes":"tsd-kind-type-literal tsd-parent-kind-variable","parent":"Prismic.Predicates.__type.number"},{"id":50,"kind":64,"name":"gt","url":"modules/prismic.html#predicates.__type.number.__type-3.gt-1","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.number.__type"},{"id":51,"kind":64,"name":"lt","url":"modules/prismic.html#predicates.__type.number.__type-3.lt-1","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.number.__type"},{"id":52,"kind":64,"name":"inRange","url":"modules/prismic.html#predicates.__type.number.__type-3.inrange-1","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.number.__type"},{"id":53,"kind":32,"name":"gt","url":"modules/prismic.html#predicates.__type.gt","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":54,"kind":32,"name":"lt","url":"modules/prismic.html#predicates.__type.lt","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":55,"kind":32,"name":"inRange","url":"modules/prismic.html#predicates.__type.inrange","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":56,"kind":32,"name":"near","url":"modules/prismic.html#predicates.__type.near-1","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":57,"kind":32,"name":"geopoint","url":"modules/prismic.html#predicates.__type.geopoint","classes":"tsd-kind-variable tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type"},{"id":58,"kind":65536,"name":"__type","url":"modules/prismic.html#predicates.__type.geopoint.__type-2","classes":"tsd-kind-type-literal tsd-parent-kind-variable","parent":"Prismic.Predicates.__type.geopoint"},{"id":59,"kind":64,"name":"near","url":"modules/prismic.html#predicates.__type.geopoint.__type-2.near","classes":"tsd-kind-function tsd-parent-kind-type-literal","parent":"Prismic.Predicates.__type.geopoint.__type"},{"id":60,"kind":32,"name":"Experiments","url":"modules/prismic.html#experiments","classes":"tsd-kind-variable tsd-parent-kind-module","parent":"Prismic"},{"id":61,"kind":32,"name":"Api","url":"modules/prismic.html#api","classes":"tsd-kind-variable tsd-parent-kind-module","parent":"Prismic"},{"id":62,"kind":64,"name":"getApi","url":"modules/prismic.html#getapi","classes":"tsd-kind-function tsd-parent-kind-module","parent":"Prismic"},{"id":63,"kind":64,"name":"api","url":"modules/prismic.html#api-1","classes":"tsd-kind-function tsd-parent-kind-module","parent":"Prismic"}]}; |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"devDependencies": { | ||
@@ -32,2 +32,3 @@ "chai": "^4.1.1", | ||
"main": "dist/prismic-javascript.min.js", | ||
"types": "./d.ts/index.d.ts", | ||
"scripts": { | ||
@@ -34,0 +35,0 @@ "build": "webpack -p", |
@@ -1,51 +0,54 @@ | ||
import Predicates from './predicates'; | ||
import { DefaultRequestHandler } from './request'; | ||
import { Experiments } from './experiments'; | ||
import PrismicPredicates from './predicates'; | ||
import { Experiments as PrismicExperiment } from './experiments'; | ||
import { | ||
ApiOptions, | ||
Api, | ||
Api as PrismicApi, | ||
ExperimentCookie, | ||
PreviewCookie, | ||
} from "./api"; | ||
} from './api'; | ||
function getApi(url: string, options: ApiOptions | null): Promise<Api> { | ||
const safeOptions = options || {} as ApiOptions; | ||
var api = new Api(url, safeOptions); | ||
//Use cached api data if available | ||
return new Promise(function(resolve, reject) { | ||
var cb = function(err: Error | null, api?: any) { | ||
if (safeOptions.complete) safeOptions.complete(err, api); | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(api); | ||
} | ||
}; | ||
api.get(function (err: Error, data: any) { | ||
if (!err && data) { | ||
api.data = data; | ||
api.refs = data.refs; | ||
api.tags = data.tags; | ||
api.types = data.types; | ||
api.forms = data.forms; | ||
api.bookmarks = data.bookmarks; | ||
api.experiments = new Experiments(data.experiments); | ||
} | ||
namespace Prismic { | ||
cb(err, api); | ||
export const experimentCookie = ExperimentCookie; | ||
export const previewCookie = PreviewCookie; | ||
export const Predicates = PrismicPredicates; | ||
export const Experiments = PrismicExperiment; | ||
export const Api = PrismicApi; | ||
export function getApi(url: string, options: ApiOptions | null): Promise<PrismicApi> { | ||
const safeOptions = options || {} as ApiOptions; | ||
const api = new PrismicApi(url, safeOptions); | ||
return new Promise((resolve, reject) => { | ||
const cb = (err: Error | null, api?: any) => { | ||
if (safeOptions.complete) safeOptions.complete(err, api); | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(api); | ||
} | ||
}; | ||
api.get((err: Error, data: any) => { | ||
if (!err && data) { | ||
api.data = data; | ||
api.refs = data.refs; | ||
api.tags = data.tags; | ||
api.types = data.types; | ||
api.forms = data.forms; | ||
api.bookmarks = data.bookmarks; | ||
api.experiments = new Experiments(data.experiments); | ||
} | ||
cb(err, api); | ||
}); | ||
return api; | ||
}); | ||
} | ||
return api; | ||
}); | ||
export function api(url: string, options: ApiOptions | null): Promise<PrismicApi> { | ||
return getApi(url, options); | ||
} | ||
} | ||
module.exports = { | ||
experimentCookie: ExperimentCookie, | ||
previewCookie: PreviewCookie, | ||
Predicates, | ||
Experiments, | ||
api: getApi, | ||
Api, | ||
getApi | ||
}; | ||
export = Prismic; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1650549
70
13299
16