prismic-javascript
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -1249,4 +1249,4 @@ 'use strict'; | ||
var _this = this; | ||
var getDocById = function (documentId) { return _this.getApi().then(function (api) { | ||
return api.getByID(documentId); | ||
var getDocById = function (documentId, maybeOptions) { return _this.getApi().then(function (api) { | ||
return api.getByID(documentId, maybeOptions); | ||
}); }; | ||
@@ -1253,0 +1253,0 @@ return createPreviewResolver(token, documentId, getDocById); |
@@ -15,3 +15,3 @@ "use strict";var t,e=(t=require("cross-fetch"))&&"object"==typeof t&&"default"in t?t.default:t,r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},n=function(){function t(t){this.data={},this.data=t}return t.prototype.id=function(){return this.data.id},t.prototype.ref=function(){return this.data.ref},t.prototype.label=function(){return this.data.label},t}(),i=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map((function(t){return new n(t)}))}return t.prototype.id=function(){return this.data.id},t.prototype.googleId=function(){return this.data.googleId},t.prototype.name=function(){return this.data.name},t}(),o=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map((function(t){return new i(t)})),this.running=(t.running||[]).map((function(t){return new i(t)})))}return t.prototype.current=function(){return this.running.length>0?this.running[0]:null},t.prototype.refFromCookie=function(t){if(!t||""===t.trim())return null;var e=t.trim().split(" ");if(e.length<2)return null;var r=e[0],n=parseInt(e[1],10),i=this.running.filter((function(t){return t.googleId()===r&&t.variations.length>n}))[0];return i?i.variations[n].ref():null},t}(),u=function(){function t(t,e){this.id=t,this.api=e,this.fields={}}return t.prototype.set=function(t,e){return this.fields[t]=e,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){return this.set("q",t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){return console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead."),this.set("fetch",t)},t.prototype.fetchLinks=function(t){return console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead."),this.set("fetchLinks",t)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return this.set("orderings",t)},t.prototype.url=function(){var e=this;return this.api.get().then((function(r){return t.toSearchForm(e,r).url()}))},t.prototype.submit=function(e){var r=this;return this.api.get().then((function(n){return t.toSearchForm(r,n).submit(e)}))},t.toSearchForm=function(t,e){var r=e.form(t.id);if(r)return Object.keys(t.fields).reduce((function(e,r){var n=t.fields[r];return"q"===r?e.query(n):"pageSize"===r?e.pageSize(n):"fetch"===r?e.fetch(n):"fetchLinks"===r?e.fetchLinks(n):"graphQuery"===r?e.graphQuery(n):"lang"===r?e.lang(n):"page"===r?e.page(n):"after"===r?e.after(n):"orderings"===r?e.orderings(n):e.set(r,n)}),r);throw new Error("Unable to access to form "+t.id)},t}(),s=function(){function t(t,e){for(var r in this.httpClient=e,this.form=t,this.data={},t.fields)t.fields[r].default&&(this.data[r]=[t.fields[r].default])}return t.prototype.set=function(t,e){var r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);var n=""===e||void 0===e?null:e,i=this.data[t]||[];return i=r.multiple?n?i.concat([n]):i:n?[n]:i,this.data[t]=i,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){if("string"==typeof t)return this.query([t]);if(Array.isArray(t))return this.set("q","["+t.join("")+"]");throw new Error("Invalid query : "+t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetchLinks",e)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return t?this.set("orderings","["+t.join(",")+"]"):this},t.prototype.url=function(){var t=this.form.action;if(this.data){var e=t.indexOf("?")>-1?"&":"?";for(var r in this.data)if(Object.prototype.hasOwnProperty.call(this.data,r)){var n=this.data[r];if(n)for(var i=0;i<n.length;i++)t+=e+r+"="+encodeURIComponent(n[i]),e="&"}}return t},t.prototype.submit=function(t){return this.httpClient.cachedRequest(this.url()).then((function(e){return t&&t(null,e),e})).catch((function(e){throw t&&t(e),e}))},t}(),a="at",f="not",h="missing",p="has",c="any",l="in",y="fulltext",d="similar",g="number.gt",m="number.lt",v="number.inRange",w="date.before",k="date.after",b="date.between",A="date.day-of-month",q="date.day-of-month-after",B="date.day-of-month-before",I="date.day-of-week",O="date.day-of-week-after",x="date.day-of-week-before",D="date.month",S="date.month-before",U="date.month-after",R="date.year",E="date.hour",j="date.hour-before",C="date.hour-after",F="geopoint.near"; | ||
and limitations under the License. | ||
***************************************************************************** */function M(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(Array.isArray(t))return"["+t.map((function(t){return M(t)})).join(",")+"]";if("boolean"==typeof t)return t.toString();throw new Error("Unable to encode "+t+" of type "+typeof t)}var T={near:function(t,e,r,n){return"["+F+"("+t+", "+e+", "+r+", "+n+")]"}},W={before:function(t,e){return"["+w+"("+t+", "+M(e)+")]"},after:function(t,e){return"["+k+"("+t+", "+M(e)+")]"},between:function(t,e,r){return"["+b+"("+t+", "+M(e)+", "+M(r)+")]"},dayOfMonth:function(t,e){return"["+A+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+q+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+B+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+I+"("+t+", "+M(e)+")]"},dayOfWeekAfter:function(t,e){return"["+O+"("+t+", "+M(e)+")]"},dayOfWeekBefore:function(t,e){return"["+x+"("+t+", "+M(e)+")]"},month:function(t,e){return"["+D+"("+t+", "+M(e)+")]"},monthBefore:function(t,e){return"["+S+"("+t+", "+M(e)+")]"},monthAfter:function(t,e){return"["+U+"("+t+", "+M(e)+")]"},year:function(t,e){return"["+R+"("+t+", "+e+")]"},hour:function(t,e){return"["+E+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+j+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+C+"("+t+", "+e+")]"}},z={gt:function(t,e){return"["+g+"("+t+", "+e+")]"},lt:function(t,e){return"["+m+"("+t+", "+e+")]"},inRange:function(t,e,r){return"["+v+"("+t+", "+e+", "+r+")]"}},L={at:function(t,e){return"["+a+"("+t+", "+M(e)+")]"},not:function(t,e){return"["+f+"("+t+", "+M(e)+")]"},missing:function(t){return"["+h+"("+t+")]"},has:function(t){return"["+p+"("+t+")]"},any:function(t,e){return"["+c+"("+t+", "+M(e)+")]"},in:function(t,e){return"["+l+"("+t+", "+M(e)+")]"},fulltext:function(t,e){return"["+y+"("+t+", "+M(e)+")]"},similar:function(t,e){return"["+d+'("'+t+'", '+e+")]"},date:W,dateBefore:W.before,dateAfter:W.after,dateBetween:W.between,dayOfMonth:W.dayOfMonth,dayOfMonthAfter:W.dayOfMonthAfter,dayOfMonthBefore:W.dayOfMonthBefore,dayOfWeek:W.dayOfWeek,dayOfWeekAfter:W.dayOfWeekAfter,dayOfWeekBefore:W.dayOfWeekBefore,month:W.month,monthBefore:W.monthBefore,monthAfter:W.monthAfter,year:W.year,hour:W.hour,hourBefore:W.hourBefore,hourAfter:W.hourAfter,number:z,gt:z.gt,lt:z.lt,inRange:z.inRange,near:T.near,geopoint:T},P=decodeURIComponent;var _={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),o=n.decode||P;return i.forEach((function(t){var e=t.indexOf("=");if(!(e<0)){var n=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),null==r[n]&&(r[n]=function(t,e){try{return e(t)}catch(e){return t}}(i,o))}})),r}};function Q(t,e,r){return{token:t,documentId:e,resolve:function(n,i,o){return e&&r?r(e,{ref:t}).then((function(t){if(t){var e=n&&n(t)||t.url||i;return o&&o(null,e),e}return o&&o(null,i),i})):Promise.resolve(i)}}}var H=function(){function t(t,e,r){this.data=t,this.masterRef=t.refs.filter((function(t){return t.isMasterRef}))[0],this.experiments=new o(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types,this.languages=t.languages}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new s(e,this.httpClient):null},t.prototype.everything=function(){var t=this.form("everything");if(!t)throw new Error("Missing everything form");return t},t.prototype.master=function(){return this.masterRef.ref},t.prototype.ref=function(t){var e=this.data.refs.filter((function(e){return e.label===t}))[0];return e?e.ref:null},t.prototype.currentExperiment=function(){return this.experiments.current()},t.prototype.query=function(t,e,r){void 0===r&&(r=function(){});var n="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r},i=n.options,o=n.callback,u=this.everything();for(var s in i)u=u.set(s,i[s]);if(!i.ref){var a="";this.options.req?a=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(a=window.document.cookie||"");var f=_.parse(a),h=f["io.prismic.preview"],p=this.experiments.refFromCookie(f["io.prismic.experiment"]);u=u.ref(h||p||this.masterRef.ref)}return t&&u.query(t),u.submit(o)},t.prototype.queryFirst=function(t,e,r){var n="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||function(){}},i=n.options,o=n.callback;return i.page=1,i.pageSize=1,this.query(t,i).then((function(t){var e=t&&t.results&&t.results[0];return o(null,e),e})).catch((function(t){throw o(t),t}))},t.prototype.getByID=function(t,e,n){var i=e?r({},e):{};return i.lang||(i.lang="*"),this.queryFirst(L.at("document.id",t),i,n)},t.prototype.getByIDs=function(t,e,n){var i=e?r({},e):{};return i.lang||(i.lang="*"),this.query(L.in("document.id",t),i,n)},t.prototype.getByUID=function(t,e,n,i){var o=n?r({},n):{};if("*"===o.lang)throw new Error("FORBIDDEN. You can't use getByUID with *, use the predicates instead.");return o.page||(o.page=1),this.queryFirst(L.at("my."+t+".uid",e),o,i)},t.prototype.getSingle=function(t,e,n){var i=e?r({},e):{};return this.queryFirst(L.at("document.type",t),i,n)},t.prototype.getBookmark=function(t,e,r){var n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")},t.prototype.getPreviewResolver=function(t,e){return Q(t,e,this.getByID.bind(this))},t.prototype.previewSession=function(t,e,r,n){var i=this;return console.warn("previewSession function is deprecated in favor of getPreviewResolver function."),new Promise((function(o,u){i.httpClient.request(t,(function(s,a){if(s)n&&n(s),u(s);else if(a){if(a.mainDocument)return i.getByID(a.mainDocument,{ref:t}).then((function(t){if(t){var i=e&&e(t)||t.url||r;n&&n(null,i),o(i)}else n&&n(null,r),o(r)})).catch(u);n&&n(null,r),o(r)}}))}))},t}();function N(t){this.size=0,this.limit=t,this._keymap={}}N.prototype.put=function(t,e){var r={key:t,value:e};if(this._keymap[t]=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++},N.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,t.newer=t.older=void 0,delete this._keymap[t.key]),console.log("purging ",t.key),t},N.prototype.get=function(t,e){var r=this._keymap[t];if(void 0!==r)return r===this.tail||(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),e?r:r.value},N.prototype.find=function(t){return this._keymap[t]},N.prototype.set=function(t,e){var r,n=this.get(t,!0);return n?(r=n.value,n.value=e):(r=this.put(t,e))&&(r=r.value),r},N.prototype.remove=function(t){var e=this._keymap[t];if(e)return delete this._keymap[e.key],e.newer&&e.older?(e.older.newer=e.newer,e.newer.older=e.older):e.newer?(e.newer.older=void 0,this.head=e.newer):e.older?(e.older.newer=void 0,this.tail=e.older):this.head=this.tail=void 0,this.size--,e.value},N.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?N.prototype.keys=function(){return Object.keys(this._keymap)}:N.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},N.prototype.forEach=function(t,e,r){var n;if(!0===e?(r=!0,e=void 0):"object"!=typeof e&&(e=this),r)for(n=this.tail;n;)t.call(e,n.key,n.value,this),n=n.older;else for(n=this.head;n;)t.call(e,n.key,n.value,this),n=n.newer},N.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};var J=function(){function t(t){void 0===t&&(t=1e3),this.lru=function(t){return new N(t)}(t)}return t.prototype.isExpired=function(t){var e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn<Date.now())},t.prototype.get=function(t,e){var r=this.lru.get(t,!1);r&&!this.isExpired(t)?e(null,r.data):e&&e(null)},t.prototype.set=function(t,e,r,n){this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:r?Date.now()+1e3*r:0}),n&&n(null)},t.prototype.remove=function(t,e){this.lru.remove(t),e&&e(null)},t.prototype.clear=function(t){this.lru.removeAll(),t&&t(null)},t}();var K=function(){function t(t){this.options=t||{}}return t.prototype.request=function(t,r){!function(t,r,n){var i,o={headers:{Accept:"application/json"}};r&&r.proxyAgent&&(o.agent=r.proxyAgent);var u=e(t,o);(r.timeoutInMs?Promise.race([u,new Promise((function(e,n){i=setTimeout((function(){return n(new Error(t+" response timeout"))}),r.timeoutInMs)}))]):u).then((function(e){return clearTimeout(i),~~(e.status/100!=2)?e.text().then((function(){var r=new Error("Unexpected status code ["+e.status+"] on URL "+t);throw r.status=e.status,r})):e.json().then((function(t){var r=e.headers.get("cache-control"),i=r?/max-age=(\d+)/.exec(r):null,o=i?parseInt(i[1],10):void 0;n(null,t,e,o)}))})).catch((function(t){clearTimeout(i),n(t)}))}(t,this.options,r)},t}(),Y=function(){function t(t,e,r,n){this.requestHandler=t||new K({proxyAgent:r,timeoutInMs:n}),this.cache=e||new J}return t.prototype.request=function(t,e){this.requestHandler.request(t,(function(t,r,n,i){t?e&&e(t,null,n,i):r&&e&&e(null,r,n,i)}))},t.prototype.cachedRequest=function(t,e){var r=this,n=e||{};return new Promise((function(e,i){var o,u;o=function(t,r){t&&i(t),r&&e(r)},u=n.cacheKey||t,r.cache.get(u,(function(e,i){e||i?o(e,i):r.request(t,(function(t,e,i,s){if(t)o(t,null);else{var a=s||n.ttl;a&&r.cache.set(u,e,a,o),o(null,e)}}))}))}))},t}();function G(t){return t.indexOf("?")>-1?"&":"?"}var V=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var r="access_token="+this.options.accessToken;this.url+=G(t)+r}this.options.routes&&(this.url+=G(t)+"routes="+encodeURIComponent(JSON.stringify(this.options.routes))),this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new Y(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent,this.options.timeoutInMs)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then((function(r){var n=new H(r,e.httpClient,e.options);return t&&t(null,n),n})).catch((function(e){throw t&&t(e),e}))},t}(),X=function(){function t(t,e){this.api=new V(t,e)}return t.prototype.getApi=function(){return this.api.get()},t.prototype.everything=function(){return this.form("everything")},t.prototype.form=function(t){return new u(t,this.api)},t.prototype.query=function(t,e,r){return this.getApi().then((function(n){return n.query(t,e,r)}))},t.prototype.queryFirst=function(t,e,r){return this.getApi().then((function(n){return n.queryFirst(t,e,r)}))},t.prototype.getByID=function(t,e,r){return this.getApi().then((function(n){return n.getByID(t,e,r)}))},t.prototype.getByIDs=function(t,e,r){return this.getApi().then((function(n){return n.getByIDs(t,e,r)}))},t.prototype.getByUID=function(t,e,r,n){return this.getApi().then((function(i){return i.getByUID(t,e,r,n)}))},t.prototype.getSingle=function(t,e,r){return this.getApi().then((function(n){return n.getSingle(t,e,r)}))},t.prototype.getBookmark=function(t,e,r){return this.getApi().then((function(n){return n.getBookmark(t,e,r)}))},t.prototype.previewSession=function(t,e,r,n){return this.getApi().then((function(i){return i.previewSession(t,e,r,n)}))},t.prototype.getPreviewResolver=function(t,e){var r=this;return Q(t,e,(function(t){return r.getApi().then((function(e){return e.getByID(t)}))}))},t.getApi=function(t,e){return new V(t,e).get()},t}(),Z={experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Predicates:L,Experiments:o,Api:V,client:function(t,e){return new X(t,e)},getApi:$,api:function(t,e){return $(t,e)}};function $(t,e){return X.getApi(t,e)}module.exports=Z; | ||
***************************************************************************** */function M(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(Array.isArray(t))return"["+t.map((function(t){return M(t)})).join(",")+"]";if("boolean"==typeof t)return t.toString();throw new Error("Unable to encode "+t+" of type "+typeof t)}var T={near:function(t,e,r,n){return"["+F+"("+t+", "+e+", "+r+", "+n+")]"}},W={before:function(t,e){return"["+w+"("+t+", "+M(e)+")]"},after:function(t,e){return"["+k+"("+t+", "+M(e)+")]"},between:function(t,e,r){return"["+b+"("+t+", "+M(e)+", "+M(r)+")]"},dayOfMonth:function(t,e){return"["+A+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+q+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+B+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+I+"("+t+", "+M(e)+")]"},dayOfWeekAfter:function(t,e){return"["+O+"("+t+", "+M(e)+")]"},dayOfWeekBefore:function(t,e){return"["+x+"("+t+", "+M(e)+")]"},month:function(t,e){return"["+D+"("+t+", "+M(e)+")]"},monthBefore:function(t,e){return"["+S+"("+t+", "+M(e)+")]"},monthAfter:function(t,e){return"["+U+"("+t+", "+M(e)+")]"},year:function(t,e){return"["+R+"("+t+", "+e+")]"},hour:function(t,e){return"["+E+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+j+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+C+"("+t+", "+e+")]"}},z={gt:function(t,e){return"["+g+"("+t+", "+e+")]"},lt:function(t,e){return"["+m+"("+t+", "+e+")]"},inRange:function(t,e,r){return"["+v+"("+t+", "+e+", "+r+")]"}},L={at:function(t,e){return"["+a+"("+t+", "+M(e)+")]"},not:function(t,e){return"["+f+"("+t+", "+M(e)+")]"},missing:function(t){return"["+h+"("+t+")]"},has:function(t){return"["+p+"("+t+")]"},any:function(t,e){return"["+c+"("+t+", "+M(e)+")]"},in:function(t,e){return"["+l+"("+t+", "+M(e)+")]"},fulltext:function(t,e){return"["+y+"("+t+", "+M(e)+")]"},similar:function(t,e){return"["+d+'("'+t+'", '+e+")]"},date:W,dateBefore:W.before,dateAfter:W.after,dateBetween:W.between,dayOfMonth:W.dayOfMonth,dayOfMonthAfter:W.dayOfMonthAfter,dayOfMonthBefore:W.dayOfMonthBefore,dayOfWeek:W.dayOfWeek,dayOfWeekAfter:W.dayOfWeekAfter,dayOfWeekBefore:W.dayOfWeekBefore,month:W.month,monthBefore:W.monthBefore,monthAfter:W.monthAfter,year:W.year,hour:W.hour,hourBefore:W.hourBefore,hourAfter:W.hourAfter,number:z,gt:z.gt,lt:z.lt,inRange:z.inRange,near:T.near,geopoint:T},P=decodeURIComponent;var _={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),o=n.decode||P;return i.forEach((function(t){var e=t.indexOf("=");if(!(e<0)){var n=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),null==r[n]&&(r[n]=function(t,e){try{return e(t)}catch(e){return t}}(i,o))}})),r}};function Q(t,e,r){return{token:t,documentId:e,resolve:function(n,i,o){return e&&r?r(e,{ref:t}).then((function(t){if(t){var e=n&&n(t)||t.url||i;return o&&o(null,e),e}return o&&o(null,i),i})):Promise.resolve(i)}}}var H=function(){function t(t,e,r){this.data=t,this.masterRef=t.refs.filter((function(t){return t.isMasterRef}))[0],this.experiments=new o(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types,this.languages=t.languages}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new s(e,this.httpClient):null},t.prototype.everything=function(){var t=this.form("everything");if(!t)throw new Error("Missing everything form");return t},t.prototype.master=function(){return this.masterRef.ref},t.prototype.ref=function(t){var e=this.data.refs.filter((function(e){return e.label===t}))[0];return e?e.ref:null},t.prototype.currentExperiment=function(){return this.experiments.current()},t.prototype.query=function(t,e,r){void 0===r&&(r=function(){});var n="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r},i=n.options,o=n.callback,u=this.everything();for(var s in i)u=u.set(s,i[s]);if(!i.ref){var a="";this.options.req?a=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(a=window.document.cookie||"");var f=_.parse(a),h=f["io.prismic.preview"],p=this.experiments.refFromCookie(f["io.prismic.experiment"]);u=u.ref(h||p||this.masterRef.ref)}return t&&u.query(t),u.submit(o)},t.prototype.queryFirst=function(t,e,r){var n="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||function(){}},i=n.options,o=n.callback;return i.page=1,i.pageSize=1,this.query(t,i).then((function(t){var e=t&&t.results&&t.results[0];return o(null,e),e})).catch((function(t){throw o(t),t}))},t.prototype.getByID=function(t,e,n){var i=e?r({},e):{};return i.lang||(i.lang="*"),this.queryFirst(L.at("document.id",t),i,n)},t.prototype.getByIDs=function(t,e,n){var i=e?r({},e):{};return i.lang||(i.lang="*"),this.query(L.in("document.id",t),i,n)},t.prototype.getByUID=function(t,e,n,i){var o=n?r({},n):{};if("*"===o.lang)throw new Error("FORBIDDEN. You can't use getByUID with *, use the predicates instead.");return o.page||(o.page=1),this.queryFirst(L.at("my."+t+".uid",e),o,i)},t.prototype.getSingle=function(t,e,n){var i=e?r({},e):{};return this.queryFirst(L.at("document.type",t),i,n)},t.prototype.getBookmark=function(t,e,r){var n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")},t.prototype.getPreviewResolver=function(t,e){return Q(t,e,this.getByID.bind(this))},t.prototype.previewSession=function(t,e,r,n){var i=this;return console.warn("previewSession function is deprecated in favor of getPreviewResolver function."),new Promise((function(o,u){i.httpClient.request(t,(function(s,a){if(s)n&&n(s),u(s);else if(a){if(a.mainDocument)return i.getByID(a.mainDocument,{ref:t}).then((function(t){if(t){var i=e&&e(t)||t.url||r;n&&n(null,i),o(i)}else n&&n(null,r),o(r)})).catch(u);n&&n(null,r),o(r)}}))}))},t}();function N(t){this.size=0,this.limit=t,this._keymap={}}N.prototype.put=function(t,e){var r={key:t,value:e};if(this._keymap[t]=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++},N.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,t.newer=t.older=void 0,delete this._keymap[t.key]),console.log("purging ",t.key),t},N.prototype.get=function(t,e){var r=this._keymap[t];if(void 0!==r)return r===this.tail||(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),e?r:r.value},N.prototype.find=function(t){return this._keymap[t]},N.prototype.set=function(t,e){var r,n=this.get(t,!0);return n?(r=n.value,n.value=e):(r=this.put(t,e))&&(r=r.value),r},N.prototype.remove=function(t){var e=this._keymap[t];if(e)return delete this._keymap[e.key],e.newer&&e.older?(e.older.newer=e.newer,e.newer.older=e.older):e.newer?(e.newer.older=void 0,this.head=e.newer):e.older?(e.older.newer=void 0,this.tail=e.older):this.head=this.tail=void 0,this.size--,e.value},N.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?N.prototype.keys=function(){return Object.keys(this._keymap)}:N.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},N.prototype.forEach=function(t,e,r){var n;if(!0===e?(r=!0,e=void 0):"object"!=typeof e&&(e=this),r)for(n=this.tail;n;)t.call(e,n.key,n.value,this),n=n.older;else for(n=this.head;n;)t.call(e,n.key,n.value,this),n=n.newer},N.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};var J=function(){function t(t){void 0===t&&(t=1e3),this.lru=function(t){return new N(t)}(t)}return t.prototype.isExpired=function(t){var e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn<Date.now())},t.prototype.get=function(t,e){var r=this.lru.get(t,!1);r&&!this.isExpired(t)?e(null,r.data):e&&e(null)},t.prototype.set=function(t,e,r,n){this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:r?Date.now()+1e3*r:0}),n&&n(null)},t.prototype.remove=function(t,e){this.lru.remove(t),e&&e(null)},t.prototype.clear=function(t){this.lru.removeAll(),t&&t(null)},t}();var K=function(){function t(t){this.options=t||{}}return t.prototype.request=function(t,r){!function(t,r,n){var i,o={headers:{Accept:"application/json"}};r&&r.proxyAgent&&(o.agent=r.proxyAgent);var u=e(t,o);(r.timeoutInMs?Promise.race([u,new Promise((function(e,n){i=setTimeout((function(){return n(new Error(t+" response timeout"))}),r.timeoutInMs)}))]):u).then((function(e){return clearTimeout(i),~~(e.status/100!=2)?e.text().then((function(){var r=new Error("Unexpected status code ["+e.status+"] on URL "+t);throw r.status=e.status,r})):e.json().then((function(t){var r=e.headers.get("cache-control"),i=r?/max-age=(\d+)/.exec(r):null,o=i?parseInt(i[1],10):void 0;n(null,t,e,o)}))})).catch((function(t){clearTimeout(i),n(t)}))}(t,this.options,r)},t}(),Y=function(){function t(t,e,r,n){this.requestHandler=t||new K({proxyAgent:r,timeoutInMs:n}),this.cache=e||new J}return t.prototype.request=function(t,e){this.requestHandler.request(t,(function(t,r,n,i){t?e&&e(t,null,n,i):r&&e&&e(null,r,n,i)}))},t.prototype.cachedRequest=function(t,e){var r=this,n=e||{};return new Promise((function(e,i){var o,u;o=function(t,r){t&&i(t),r&&e(r)},u=n.cacheKey||t,r.cache.get(u,(function(e,i){e||i?o(e,i):r.request(t,(function(t,e,i,s){if(t)o(t,null);else{var a=s||n.ttl;a&&r.cache.set(u,e,a,o),o(null,e)}}))}))}))},t}();function G(t){return t.indexOf("?")>-1?"&":"?"}var V=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var r="access_token="+this.options.accessToken;this.url+=G(t)+r}this.options.routes&&(this.url+=G(t)+"routes="+encodeURIComponent(JSON.stringify(this.options.routes))),this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new Y(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent,this.options.timeoutInMs)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then((function(r){var n=new H(r,e.httpClient,e.options);return t&&t(null,n),n})).catch((function(e){throw t&&t(e),e}))},t}(),X=function(){function t(t,e){this.api=new V(t,e)}return t.prototype.getApi=function(){return this.api.get()},t.prototype.everything=function(){return this.form("everything")},t.prototype.form=function(t){return new u(t,this.api)},t.prototype.query=function(t,e,r){return this.getApi().then((function(n){return n.query(t,e,r)}))},t.prototype.queryFirst=function(t,e,r){return this.getApi().then((function(n){return n.queryFirst(t,e,r)}))},t.prototype.getByID=function(t,e,r){return this.getApi().then((function(n){return n.getByID(t,e,r)}))},t.prototype.getByIDs=function(t,e,r){return this.getApi().then((function(n){return n.getByIDs(t,e,r)}))},t.prototype.getByUID=function(t,e,r,n){return this.getApi().then((function(i){return i.getByUID(t,e,r,n)}))},t.prototype.getSingle=function(t,e,r){return this.getApi().then((function(n){return n.getSingle(t,e,r)}))},t.prototype.getBookmark=function(t,e,r){return this.getApi().then((function(n){return n.getBookmark(t,e,r)}))},t.prototype.previewSession=function(t,e,r,n){return this.getApi().then((function(i){return i.previewSession(t,e,r,n)}))},t.prototype.getPreviewResolver=function(t,e){var r=this;return Q(t,e,(function(t,e){return r.getApi().then((function(r){return r.getByID(t,e)}))}))},t.getApi=function(t,e){return new V(t,e).get()},t}(),Z={experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Predicates:L,Experiments:o,Api:V,client:function(t,e){return new X(t,e)},getApi:$,api:function(t,e){return $(t,e)}};function $(t,e){return X.getApi(t,e)}module.exports=Z; | ||
//# sourceMappingURL=prismic-javascript.min.js.map |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"devDependencies": { | ||
@@ -48,3 +48,4 @@ "@rollup/plugin-typescript": "^4.1.1", | ||
"test": "npm run build && mocha", | ||
"prepublish": "npm run build; npm run docs; npm run declarations", | ||
"prepare": "npm run build; npm run docs; npm run declarations", | ||
"prepublishOnly": "npm run test", | ||
"docs": "typedoc --mode file --out ./docs ./src/index.ts", | ||
@@ -51,0 +52,0 @@ "declarations": "tsc --emitDeclarationOnly --declaration --declarationDir ./types", |
@@ -1251,4 +1251,4 @@ (function (global, factory) { | ||
var _this = this; | ||
var getDocById = function (documentId) { return _this.getApi().then(function (api) { | ||
return api.getByID(documentId); | ||
var getDocById = function (documentId, maybeOptions) { return _this.getApi().then(function (api) { | ||
return api.getByID(documentId, maybeOptions); | ||
}); }; | ||
@@ -1255,0 +1255,0 @@ return createPreviewResolver(token, documentId, getDocById); |
@@ -16,3 +16,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("cross-fetch")):"function"==typeof define&&define.amd?define(["cross-fetch"],e):(t=t||self).PrismicJS=e(t.fetch)}(this,(function(t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t; | ||
***************************************************************************** */ | ||
var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},n=function(){function t(t){this.data={},this.data=t}return t.prototype.id=function(){return this.data.id},t.prototype.ref=function(){return this.data.ref},t.prototype.label=function(){return this.data.label},t}(),r=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map((function(t){return new n(t)}))}return t.prototype.id=function(){return this.data.id},t.prototype.googleId=function(){return this.data.googleId},t.prototype.name=function(){return this.data.name},t}(),i=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map((function(t){return new r(t)})),this.running=(t.running||[]).map((function(t){return new r(t)})))}return t.prototype.current=function(){return this.running.length>0?this.running[0]:null},t.prototype.refFromCookie=function(t){if(!t||""===t.trim())return null;var e=t.trim().split(" ");if(e.length<2)return null;var n=e[0],r=parseInt(e[1],10),i=this.running.filter((function(t){return t.googleId()===n&&t.variations.length>r}))[0];return i?i.variations[r].ref():null},t}(),o=function(){function t(t,e){this.id=t,this.api=e,this.fields={}}return t.prototype.set=function(t,e){return this.fields[t]=e,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){return this.set("q",t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){return console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead."),this.set("fetch",t)},t.prototype.fetchLinks=function(t){return console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead."),this.set("fetchLinks",t)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return this.set("orderings",t)},t.prototype.url=function(){var e=this;return this.api.get().then((function(n){return t.toSearchForm(e,n).url()}))},t.prototype.submit=function(e){var n=this;return this.api.get().then((function(r){return t.toSearchForm(n,r).submit(e)}))},t.toSearchForm=function(t,e){var n=e.form(t.id);if(n)return Object.keys(t.fields).reduce((function(e,n){var r=t.fields[n];return"q"===n?e.query(r):"pageSize"===n?e.pageSize(r):"fetch"===n?e.fetch(r):"fetchLinks"===n?e.fetchLinks(r):"graphQuery"===n?e.graphQuery(r):"lang"===n?e.lang(r):"page"===n?e.page(r):"after"===n?e.after(r):"orderings"===n?e.orderings(r):e.set(n,r)}),n);throw new Error("Unable to access to form "+t.id)},t}(),u=function(){function t(t,e){for(var n in this.httpClient=e,this.form=t,this.data={},t.fields)t.fields[n].default&&(this.data[n]=[t.fields[n].default])}return t.prototype.set=function(t,e){var n=this.form.fields[t];if(!n)throw new Error("Unknown field "+t);var r=""===e||void 0===e?null:e,i=this.data[t]||[];return i=n.multiple?r?i.concat([r]):i:r?[r]:i,this.data[t]=i,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){if("string"==typeof t)return this.query([t]);if(Array.isArray(t))return this.set("q","["+t.join("")+"]");throw new Error("Invalid query : "+t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetchLinks",e)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return t?this.set("orderings","["+t.join(",")+"]"):this},t.prototype.url=function(){var t=this.form.action;if(this.data){var e=t.indexOf("?")>-1?"&":"?";for(var n in this.data)if(Object.prototype.hasOwnProperty.call(this.data,n)){var r=this.data[n];if(r)for(var i=0;i<r.length;i++)t+=e+n+"="+encodeURIComponent(r[i]),e="&"}}return t},t.prototype.submit=function(t){return this.httpClient.cachedRequest(this.url()).then((function(e){return t&&t(null,e),e})).catch((function(e){throw t&&t(e),e}))},t}(),s="at",a="not",f="missing",h="has",p="any",c="in",l="fulltext",y="similar",d="number.gt",g="number.lt",m="number.inRange",v="date.before",w="date.after",k="date.between",b="date.day-of-month",A="date.day-of-month-after",q="date.day-of-month-before",O="date.day-of-week",B="date.day-of-week-after",I="date.day-of-week-before",x="date.month",D="date.month-before",S="date.month-after",U="date.year",R="date.hour",j="date.hour-before",E="date.hour-after",C="geopoint.near";function F(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(Array.isArray(t))return"["+t.map((function(t){return F(t)})).join(",")+"]";if("boolean"==typeof t)return t.toString();throw new Error("Unable to encode "+t+" of type "+typeof t)}var M={near:function(t,e,n,r){return"["+C+"("+t+", "+e+", "+n+", "+r+")]"}},P={before:function(t,e){return"["+v+"("+t+", "+F(e)+")]"},after:function(t,e){return"["+w+"("+t+", "+F(e)+")]"},between:function(t,e,n){return"["+k+"("+t+", "+F(e)+", "+F(n)+")]"},dayOfMonth:function(t,e){return"["+b+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+A+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+q+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+O+"("+t+", "+F(e)+")]"},dayOfWeekAfter:function(t,e){return"["+B+"("+t+", "+F(e)+")]"},dayOfWeekBefore:function(t,e){return"["+I+"("+t+", "+F(e)+")]"},month:function(t,e){return"["+x+"("+t+", "+F(e)+")]"},monthBefore:function(t,e){return"["+D+"("+t+", "+F(e)+")]"},monthAfter:function(t,e){return"["+S+"("+t+", "+F(e)+")]"},year:function(t,e){return"["+U+"("+t+", "+e+")]"},hour:function(t,e){return"["+R+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+j+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+E+"("+t+", "+e+")]"}},T={gt:function(t,e){return"["+d+"("+t+", "+e+")]"},lt:function(t,e){return"["+g+"("+t+", "+e+")]"},inRange:function(t,e,n){return"["+m+"("+t+", "+e+", "+n+")]"}},W={at:function(t,e){return"["+s+"("+t+", "+F(e)+")]"},not:function(t,e){return"["+a+"("+t+", "+F(e)+")]"},missing:function(t){return"["+f+"("+t+")]"},has:function(t){return"["+h+"("+t+")]"},any:function(t,e){return"["+p+"("+t+", "+F(e)+")]"},in:function(t,e){return"["+c+"("+t+", "+F(e)+")]"},fulltext:function(t,e){return"["+l+"("+t+", "+F(e)+")]"},similar:function(t,e){return"["+y+'("'+t+'", '+e+")]"},date:P,dateBefore:P.before,dateAfter:P.after,dateBetween:P.between,dayOfMonth:P.dayOfMonth,dayOfMonthAfter:P.dayOfMonthAfter,dayOfMonthBefore:P.dayOfMonthBefore,dayOfWeek:P.dayOfWeek,dayOfWeekAfter:P.dayOfWeekAfter,dayOfWeekBefore:P.dayOfWeekBefore,month:P.month,monthBefore:P.monthBefore,monthAfter:P.monthAfter,year:P.year,hour:P.hour,hourBefore:P.hourBefore,hourAfter:P.hourAfter,number:T,gt:T.gt,lt:T.lt,inRange:T.inRange,near:M.near,geopoint:M},z=decodeURIComponent;var L={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var n={},r=e||{},i=t.split(/; */),o=r.decode||z;return i.forEach((function(t){var e=t.indexOf("=");if(!(e<0)){var r=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),null==n[r]&&(n[r]=function(t,e){try{return e(t)}catch(e){return t}}(i,o))}})),n}};function _(t,e,n){return{token:t,documentId:e,resolve:function(r,i,o){return e&&n?n(e,{ref:t}).then((function(t){if(t){var e=r&&r(t)||t.url||i;return o&&o(null,e),e}return o&&o(null,i),i})):Promise.resolve(i)}}}var Q=function(){function t(t,e,n){this.data=t,this.masterRef=t.refs.filter((function(t){return t.isMasterRef}))[0],this.experiments=new i(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=n,this.refs=t.refs,this.tags=t.tags,this.types=t.types,this.languages=t.languages}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new u(e,this.httpClient):null},t.prototype.everything=function(){var t=this.form("everything");if(!t)throw new Error("Missing everything form");return t},t.prototype.master=function(){return this.masterRef.ref},t.prototype.ref=function(t){var e=this.data.refs.filter((function(e){return e.label===t}))[0];return e?e.ref:null},t.prototype.currentExperiment=function(){return this.experiments.current()},t.prototype.query=function(t,e,n){void 0===n&&(n=function(){});var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n},i=r.options,o=r.callback,u=this.everything();for(var s in i)u=u.set(s,i[s]);if(!i.ref){var a="";this.options.req?a=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(a=window.document.cookie||"");var f=L.parse(a),h=f["io.prismic.preview"],p=this.experiments.refFromCookie(f["io.prismic.experiment"]);u=u.ref(h||p||this.masterRef.ref)}return t&&u.query(t),u.submit(o)},t.prototype.queryFirst=function(t,e,n){var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n||function(){}},i=r.options,o=r.callback;return i.page=1,i.pageSize=1,this.query(t,i).then((function(t){var e=t&&t.results&&t.results[0];return o(null,e),e})).catch((function(t){throw o(t),t}))},t.prototype.getByID=function(t,n,r){var i=n?e({},n):{};return i.lang||(i.lang="*"),this.queryFirst(W.at("document.id",t),i,r)},t.prototype.getByIDs=function(t,n,r){var i=n?e({},n):{};return i.lang||(i.lang="*"),this.query(W.in("document.id",t),i,r)},t.prototype.getByUID=function(t,n,r,i){var o=r?e({},r):{};if("*"===o.lang)throw new Error("FORBIDDEN. You can't use getByUID with *, use the predicates instead.");return o.page||(o.page=1),this.queryFirst(W.at("my."+t+".uid",n),o,i)},t.prototype.getSingle=function(t,n,r){var i=n?e({},n):{};return this.queryFirst(W.at("document.type",t),i,r)},t.prototype.getBookmark=function(t,e,n){var r=this.data.bookmarks[t];return r?this.getByID(r,e,n):Promise.reject("Error retrieving bookmarked id")},t.prototype.getPreviewResolver=function(t,e){return _(t,e,this.getByID.bind(this))},t.prototype.previewSession=function(t,e,n,r){var i=this;return console.warn("previewSession function is deprecated in favor of getPreviewResolver function."),new Promise((function(o,u){i.httpClient.request(t,(function(s,a){if(s)r&&r(s),u(s);else if(a){if(a.mainDocument)return i.getByID(a.mainDocument,{ref:t}).then((function(t){if(t){var i=e&&e(t)||t.url||n;r&&r(null,i),o(i)}else r&&r(null,n),o(n)})).catch(u);r&&r(null,n),o(n)}}))}))},t}();function H(t){this.size=0,this.limit=t,this._keymap={}}H.prototype.put=function(t,e){var n={key:t,value:e};if(this._keymap[t]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit)return this.shift();this.size++},H.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,t.newer=t.older=void 0,delete this._keymap[t.key]),console.log("purging ",t.key),t},H.prototype.get=function(t,e){var n=this._keymap[t];if(void 0!==n)return n===this.tail||(n.newer&&(n===this.head&&(this.head=n.newer),n.newer.older=n.older),n.older&&(n.older.newer=n.newer),n.newer=void 0,n.older=this.tail,this.tail&&(this.tail.newer=n),this.tail=n),e?n:n.value},H.prototype.find=function(t){return this._keymap[t]},H.prototype.set=function(t,e){var n,r=this.get(t,!0);return r?(n=r.value,r.value=e):(n=this.put(t,e))&&(n=n.value),n},H.prototype.remove=function(t){var e=this._keymap[t];if(e)return delete this._keymap[e.key],e.newer&&e.older?(e.older.newer=e.newer,e.newer.older=e.older):e.newer?(e.newer.older=void 0,this.head=e.newer):e.older?(e.older.newer=void 0,this.tail=e.older):this.head=this.tail=void 0,this.size--,e.value},H.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?H.prototype.keys=function(){return Object.keys(this._keymap)}:H.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},H.prototype.forEach=function(t,e,n){var r;if(!0===e?(n=!0,e=void 0):"object"!=typeof e&&(e=this),n)for(r=this.tail;r;)t.call(e,r.key,r.value,this),r=r.older;else for(r=this.head;r;)t.call(e,r.key,r.value,this),r=r.newer},H.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};var J=function(){function t(t){void 0===t&&(t=1e3),this.lru=function(t){return new H(t)}(t)}return t.prototype.isExpired=function(t){var e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn<Date.now())},t.prototype.get=function(t,e){var n=this.lru.get(t,!1);n&&!this.isExpired(t)?e(null,n.data):e&&e(null)},t.prototype.set=function(t,e,n,r){this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:n?Date.now()+1e3*n:0}),r&&r(null)},t.prototype.remove=function(t,e){this.lru.remove(t),e&&e(null)},t.prototype.clear=function(t){this.lru.removeAll(),t&&t(null)},t}();var N=function(){function e(t){this.options=t||{}}return e.prototype.request=function(e,n){!function(e,n,r){var i,o={headers:{Accept:"application/json"}};n&&n.proxyAgent&&(o.agent=n.proxyAgent);var u=t(e,o);(n.timeoutInMs?Promise.race([u,new Promise((function(t,r){i=setTimeout((function(){return r(new Error(e+" response timeout"))}),n.timeoutInMs)}))]):u).then((function(t){return clearTimeout(i),~~(t.status/100!=2)?t.text().then((function(){var n=new Error("Unexpected status code ["+t.status+"] on URL "+e);throw n.status=t.status,n})):t.json().then((function(e){var n=t.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,o=i?parseInt(i[1],10):void 0;r(null,e,t,o)}))})).catch((function(t){clearTimeout(i),r(t)}))}(e,this.options,n)},e}(),K=function(){function t(t,e,n,r){this.requestHandler=t||new N({proxyAgent:n,timeoutInMs:r}),this.cache=e||new J}return t.prototype.request=function(t,e){this.requestHandler.request(t,(function(t,n,r,i){t?e&&e(t,null,r,i):n&&e&&e(null,n,r,i)}))},t.prototype.cachedRequest=function(t,e){var n=this,r=e||{};return new Promise((function(e,i){var o,u;o=function(t,n){t&&i(t),n&&e(n)},u=r.cacheKey||t,n.cache.get(u,(function(e,i){e||i?o(e,i):n.request(t,(function(t,e,i,s){if(t)o(t,null);else{var a=s||r.ttl;a&&n.cache.set(u,e,a,o),o(null,e)}}))}))}))},t}();function Y(t){return t.indexOf("?")>-1?"&":"?"}var G=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var n="access_token="+this.options.accessToken;this.url+=Y(t)+n}this.options.routes&&(this.url+=Y(t)+"routes="+encodeURIComponent(JSON.stringify(this.options.routes))),this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new K(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent,this.options.timeoutInMs)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then((function(n){var r=new Q(n,e.httpClient,e.options);return t&&t(null,r),r})).catch((function(e){throw t&&t(e),e}))},t}(),V=function(){function t(t,e){this.api=new G(t,e)}return t.prototype.getApi=function(){return this.api.get()},t.prototype.everything=function(){return this.form("everything")},t.prototype.form=function(t){return new o(t,this.api)},t.prototype.query=function(t,e,n){return this.getApi().then((function(r){return r.query(t,e,n)}))},t.prototype.queryFirst=function(t,e,n){return this.getApi().then((function(r){return r.queryFirst(t,e,n)}))},t.prototype.getByID=function(t,e,n){return this.getApi().then((function(r){return r.getByID(t,e,n)}))},t.prototype.getByIDs=function(t,e,n){return this.getApi().then((function(r){return r.getByIDs(t,e,n)}))},t.prototype.getByUID=function(t,e,n,r){return this.getApi().then((function(i){return i.getByUID(t,e,n,r)}))},t.prototype.getSingle=function(t,e,n){return this.getApi().then((function(r){return r.getSingle(t,e,n)}))},t.prototype.getBookmark=function(t,e,n){return this.getApi().then((function(r){return r.getBookmark(t,e,n)}))},t.prototype.previewSession=function(t,e,n,r){return this.getApi().then((function(i){return i.previewSession(t,e,n,r)}))},t.prototype.getPreviewResolver=function(t,e){var n=this;return _(t,e,(function(t){return n.getApi().then((function(e){return e.getByID(t)}))}))},t.getApi=function(t,e){return new G(t,e).get()},t}();function X(t,e){return V.getApi(t,e)}return{experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Predicates:W,Experiments:i,Api:G,client:function(t,e){return new V(t,e)},getApi:X,api:function(t,e){return X(t,e)}}})); | ||
var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},n=function(){function t(t){this.data={},this.data=t}return t.prototype.id=function(){return this.data.id},t.prototype.ref=function(){return this.data.ref},t.prototype.label=function(){return this.data.label},t}(),r=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map((function(t){return new n(t)}))}return t.prototype.id=function(){return this.data.id},t.prototype.googleId=function(){return this.data.googleId},t.prototype.name=function(){return this.data.name},t}(),i=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map((function(t){return new r(t)})),this.running=(t.running||[]).map((function(t){return new r(t)})))}return t.prototype.current=function(){return this.running.length>0?this.running[0]:null},t.prototype.refFromCookie=function(t){if(!t||""===t.trim())return null;var e=t.trim().split(" ");if(e.length<2)return null;var n=e[0],r=parseInt(e[1],10),i=this.running.filter((function(t){return t.googleId()===n&&t.variations.length>r}))[0];return i?i.variations[r].ref():null},t}(),o=function(){function t(t,e){this.id=t,this.api=e,this.fields={}}return t.prototype.set=function(t,e){return this.fields[t]=e,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){return this.set("q",t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){return console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead."),this.set("fetch",t)},t.prototype.fetchLinks=function(t){return console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead."),this.set("fetchLinks",t)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return this.set("orderings",t)},t.prototype.url=function(){var e=this;return this.api.get().then((function(n){return t.toSearchForm(e,n).url()}))},t.prototype.submit=function(e){var n=this;return this.api.get().then((function(r){return t.toSearchForm(n,r).submit(e)}))},t.toSearchForm=function(t,e){var n=e.form(t.id);if(n)return Object.keys(t.fields).reduce((function(e,n){var r=t.fields[n];return"q"===n?e.query(r):"pageSize"===n?e.pageSize(r):"fetch"===n?e.fetch(r):"fetchLinks"===n?e.fetchLinks(r):"graphQuery"===n?e.graphQuery(r):"lang"===n?e.lang(r):"page"===n?e.page(r):"after"===n?e.after(r):"orderings"===n?e.orderings(r):e.set(n,r)}),n);throw new Error("Unable to access to form "+t.id)},t}(),u=function(){function t(t,e){for(var n in this.httpClient=e,this.form=t,this.data={},t.fields)t.fields[n].default&&(this.data[n]=[t.fields[n].default])}return t.prototype.set=function(t,e){var n=this.form.fields[t];if(!n)throw new Error("Unknown field "+t);var r=""===e||void 0===e?null:e,i=this.data[t]||[];return i=n.multiple?r?i.concat([r]):i:r?[r]:i,this.data[t]=i,this},t.prototype.ref=function(t){return this.set("ref",t)},t.prototype.query=function(t){if("string"==typeof t)return this.query([t]);if(Array.isArray(t))return this.set("q","["+t.join("")+"]");throw new Error("Invalid query : "+t)},t.prototype.pageSize=function(t){return this.set("pageSize",t)},t.prototype.fetch=function(t){console.warn("Warning: Using Fetch is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){console.warn("Warning: Using FetchLinks is deprecated. Use the property `graphQuery` instead.");var e=Array.isArray(t)?t.join(","):t;return this.set("fetchLinks",e)},t.prototype.graphQuery=function(t){return this.set("graphQuery",t)},t.prototype.lang=function(t){return this.set("lang",t)},t.prototype.page=function(t){return this.set("page",t)},t.prototype.after=function(t){return this.set("after",t)},t.prototype.orderings=function(t){return t?this.set("orderings","["+t.join(",")+"]"):this},t.prototype.url=function(){var t=this.form.action;if(this.data){var e=t.indexOf("?")>-1?"&":"?";for(var n in this.data)if(Object.prototype.hasOwnProperty.call(this.data,n)){var r=this.data[n];if(r)for(var i=0;i<r.length;i++)t+=e+n+"="+encodeURIComponent(r[i]),e="&"}}return t},t.prototype.submit=function(t){return this.httpClient.cachedRequest(this.url()).then((function(e){return t&&t(null,e),e})).catch((function(e){throw t&&t(e),e}))},t}(),s="at",a="not",f="missing",h="has",p="any",c="in",l="fulltext",y="similar",d="number.gt",g="number.lt",m="number.inRange",v="date.before",w="date.after",k="date.between",b="date.day-of-month",A="date.day-of-month-after",q="date.day-of-month-before",O="date.day-of-week",B="date.day-of-week-after",I="date.day-of-week-before",x="date.month",D="date.month-before",S="date.month-after",U="date.year",R="date.hour",j="date.hour-before",E="date.hour-after",C="geopoint.near";function F(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(Array.isArray(t))return"["+t.map((function(t){return F(t)})).join(",")+"]";if("boolean"==typeof t)return t.toString();throw new Error("Unable to encode "+t+" of type "+typeof t)}var M={near:function(t,e,n,r){return"["+C+"("+t+", "+e+", "+n+", "+r+")]"}},P={before:function(t,e){return"["+v+"("+t+", "+F(e)+")]"},after:function(t,e){return"["+w+"("+t+", "+F(e)+")]"},between:function(t,e,n){return"["+k+"("+t+", "+F(e)+", "+F(n)+")]"},dayOfMonth:function(t,e){return"["+b+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+A+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+q+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+O+"("+t+", "+F(e)+")]"},dayOfWeekAfter:function(t,e){return"["+B+"("+t+", "+F(e)+")]"},dayOfWeekBefore:function(t,e){return"["+I+"("+t+", "+F(e)+")]"},month:function(t,e){return"["+x+"("+t+", "+F(e)+")]"},monthBefore:function(t,e){return"["+D+"("+t+", "+F(e)+")]"},monthAfter:function(t,e){return"["+S+"("+t+", "+F(e)+")]"},year:function(t,e){return"["+U+"("+t+", "+e+")]"},hour:function(t,e){return"["+R+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+j+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+E+"("+t+", "+e+")]"}},T={gt:function(t,e){return"["+d+"("+t+", "+e+")]"},lt:function(t,e){return"["+g+"("+t+", "+e+")]"},inRange:function(t,e,n){return"["+m+"("+t+", "+e+", "+n+")]"}},W={at:function(t,e){return"["+s+"("+t+", "+F(e)+")]"},not:function(t,e){return"["+a+"("+t+", "+F(e)+")]"},missing:function(t){return"["+f+"("+t+")]"},has:function(t){return"["+h+"("+t+")]"},any:function(t,e){return"["+p+"("+t+", "+F(e)+")]"},in:function(t,e){return"["+c+"("+t+", "+F(e)+")]"},fulltext:function(t,e){return"["+l+"("+t+", "+F(e)+")]"},similar:function(t,e){return"["+y+'("'+t+'", '+e+")]"},date:P,dateBefore:P.before,dateAfter:P.after,dateBetween:P.between,dayOfMonth:P.dayOfMonth,dayOfMonthAfter:P.dayOfMonthAfter,dayOfMonthBefore:P.dayOfMonthBefore,dayOfWeek:P.dayOfWeek,dayOfWeekAfter:P.dayOfWeekAfter,dayOfWeekBefore:P.dayOfWeekBefore,month:P.month,monthBefore:P.monthBefore,monthAfter:P.monthAfter,year:P.year,hour:P.hour,hourBefore:P.hourBefore,hourAfter:P.hourAfter,number:T,gt:T.gt,lt:T.lt,inRange:T.inRange,near:M.near,geopoint:M},z=decodeURIComponent;var L={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var n={},r=e||{},i=t.split(/; */),o=r.decode||z;return i.forEach((function(t){var e=t.indexOf("=");if(!(e<0)){var r=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),null==n[r]&&(n[r]=function(t,e){try{return e(t)}catch(e){return t}}(i,o))}})),n}};function _(t,e,n){return{token:t,documentId:e,resolve:function(r,i,o){return e&&n?n(e,{ref:t}).then((function(t){if(t){var e=r&&r(t)||t.url||i;return o&&o(null,e),e}return o&&o(null,i),i})):Promise.resolve(i)}}}var Q=function(){function t(t,e,n){this.data=t,this.masterRef=t.refs.filter((function(t){return t.isMasterRef}))[0],this.experiments=new i(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=n,this.refs=t.refs,this.tags=t.tags,this.types=t.types,this.languages=t.languages}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new u(e,this.httpClient):null},t.prototype.everything=function(){var t=this.form("everything");if(!t)throw new Error("Missing everything form");return t},t.prototype.master=function(){return this.masterRef.ref},t.prototype.ref=function(t){var e=this.data.refs.filter((function(e){return e.label===t}))[0];return e?e.ref:null},t.prototype.currentExperiment=function(){return this.experiments.current()},t.prototype.query=function(t,e,n){void 0===n&&(n=function(){});var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n},i=r.options,o=r.callback,u=this.everything();for(var s in i)u=u.set(s,i[s]);if(!i.ref){var a="";this.options.req?a=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(a=window.document.cookie||"");var f=L.parse(a),h=f["io.prismic.preview"],p=this.experiments.refFromCookie(f["io.prismic.experiment"]);u=u.ref(h||p||this.masterRef.ref)}return t&&u.query(t),u.submit(o)},t.prototype.queryFirst=function(t,e,n){var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n||function(){}},i=r.options,o=r.callback;return i.page=1,i.pageSize=1,this.query(t,i).then((function(t){var e=t&&t.results&&t.results[0];return o(null,e),e})).catch((function(t){throw o(t),t}))},t.prototype.getByID=function(t,n,r){var i=n?e({},n):{};return i.lang||(i.lang="*"),this.queryFirst(W.at("document.id",t),i,r)},t.prototype.getByIDs=function(t,n,r){var i=n?e({},n):{};return i.lang||(i.lang="*"),this.query(W.in("document.id",t),i,r)},t.prototype.getByUID=function(t,n,r,i){var o=r?e({},r):{};if("*"===o.lang)throw new Error("FORBIDDEN. You can't use getByUID with *, use the predicates instead.");return o.page||(o.page=1),this.queryFirst(W.at("my."+t+".uid",n),o,i)},t.prototype.getSingle=function(t,n,r){var i=n?e({},n):{};return this.queryFirst(W.at("document.type",t),i,r)},t.prototype.getBookmark=function(t,e,n){var r=this.data.bookmarks[t];return r?this.getByID(r,e,n):Promise.reject("Error retrieving bookmarked id")},t.prototype.getPreviewResolver=function(t,e){return _(t,e,this.getByID.bind(this))},t.prototype.previewSession=function(t,e,n,r){var i=this;return console.warn("previewSession function is deprecated in favor of getPreviewResolver function."),new Promise((function(o,u){i.httpClient.request(t,(function(s,a){if(s)r&&r(s),u(s);else if(a){if(a.mainDocument)return i.getByID(a.mainDocument,{ref:t}).then((function(t){if(t){var i=e&&e(t)||t.url||n;r&&r(null,i),o(i)}else r&&r(null,n),o(n)})).catch(u);r&&r(null,n),o(n)}}))}))},t}();function H(t){this.size=0,this.limit=t,this._keymap={}}H.prototype.put=function(t,e){var n={key:t,value:e};if(this._keymap[t]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit)return this.shift();this.size++},H.prototype.shift=function(){var t=this.head;return t&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,t.newer=t.older=void 0,delete this._keymap[t.key]),console.log("purging ",t.key),t},H.prototype.get=function(t,e){var n=this._keymap[t];if(void 0!==n)return n===this.tail||(n.newer&&(n===this.head&&(this.head=n.newer),n.newer.older=n.older),n.older&&(n.older.newer=n.newer),n.newer=void 0,n.older=this.tail,this.tail&&(this.tail.newer=n),this.tail=n),e?n:n.value},H.prototype.find=function(t){return this._keymap[t]},H.prototype.set=function(t,e){var n,r=this.get(t,!0);return r?(n=r.value,r.value=e):(n=this.put(t,e))&&(n=n.value),n},H.prototype.remove=function(t){var e=this._keymap[t];if(e)return delete this._keymap[e.key],e.newer&&e.older?(e.older.newer=e.newer,e.newer.older=e.older):e.newer?(e.newer.older=void 0,this.head=e.newer):e.older?(e.older.newer=void 0,this.tail=e.older):this.head=this.tail=void 0,this.size--,e.value},H.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?H.prototype.keys=function(){return Object.keys(this._keymap)}:H.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},H.prototype.forEach=function(t,e,n){var r;if(!0===e?(n=!0,e=void 0):"object"!=typeof e&&(e=this),n)for(r=this.tail;r;)t.call(e,r.key,r.value,this),r=r.older;else for(r=this.head;r;)t.call(e,r.key,r.value,this),r=r.newer},H.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};var J=function(){function t(t){void 0===t&&(t=1e3),this.lru=function(t){return new H(t)}(t)}return t.prototype.isExpired=function(t){var e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn<Date.now())},t.prototype.get=function(t,e){var n=this.lru.get(t,!1);n&&!this.isExpired(t)?e(null,n.data):e&&e(null)},t.prototype.set=function(t,e,n,r){this.lru.remove(t),this.lru.put(t,{data:e,expiredIn:n?Date.now()+1e3*n:0}),r&&r(null)},t.prototype.remove=function(t,e){this.lru.remove(t),e&&e(null)},t.prototype.clear=function(t){this.lru.removeAll(),t&&t(null)},t}();var N=function(){function e(t){this.options=t||{}}return e.prototype.request=function(e,n){!function(e,n,r){var i,o={headers:{Accept:"application/json"}};n&&n.proxyAgent&&(o.agent=n.proxyAgent);var u=t(e,o);(n.timeoutInMs?Promise.race([u,new Promise((function(t,r){i=setTimeout((function(){return r(new Error(e+" response timeout"))}),n.timeoutInMs)}))]):u).then((function(t){return clearTimeout(i),~~(t.status/100!=2)?t.text().then((function(){var n=new Error("Unexpected status code ["+t.status+"] on URL "+e);throw n.status=t.status,n})):t.json().then((function(e){var n=t.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,o=i?parseInt(i[1],10):void 0;r(null,e,t,o)}))})).catch((function(t){clearTimeout(i),r(t)}))}(e,this.options,n)},e}(),K=function(){function t(t,e,n,r){this.requestHandler=t||new N({proxyAgent:n,timeoutInMs:r}),this.cache=e||new J}return t.prototype.request=function(t,e){this.requestHandler.request(t,(function(t,n,r,i){t?e&&e(t,null,r,i):n&&e&&e(null,n,r,i)}))},t.prototype.cachedRequest=function(t,e){var n=this,r=e||{};return new Promise((function(e,i){var o,u;o=function(t,n){t&&i(t),n&&e(n)},u=r.cacheKey||t,n.cache.get(u,(function(e,i){e||i?o(e,i):n.request(t,(function(t,e,i,s){if(t)o(t,null);else{var a=s||r.ttl;a&&n.cache.set(u,e,a,o),o(null,e)}}))}))}))},t}();function Y(t){return t.indexOf("?")>-1?"&":"?"}var G=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var n="access_token="+this.options.accessToken;this.url+=Y(t)+n}this.options.routes&&(this.url+=Y(t)+"routes="+encodeURIComponent(JSON.stringify(this.options.routes))),this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new K(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent,this.options.timeoutInMs)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then((function(n){var r=new Q(n,e.httpClient,e.options);return t&&t(null,r),r})).catch((function(e){throw t&&t(e),e}))},t}(),V=function(){function t(t,e){this.api=new G(t,e)}return t.prototype.getApi=function(){return this.api.get()},t.prototype.everything=function(){return this.form("everything")},t.prototype.form=function(t){return new o(t,this.api)},t.prototype.query=function(t,e,n){return this.getApi().then((function(r){return r.query(t,e,n)}))},t.prototype.queryFirst=function(t,e,n){return this.getApi().then((function(r){return r.queryFirst(t,e,n)}))},t.prototype.getByID=function(t,e,n){return this.getApi().then((function(r){return r.getByID(t,e,n)}))},t.prototype.getByIDs=function(t,e,n){return this.getApi().then((function(r){return r.getByIDs(t,e,n)}))},t.prototype.getByUID=function(t,e,n,r){return this.getApi().then((function(i){return i.getByUID(t,e,n,r)}))},t.prototype.getSingle=function(t,e,n){return this.getApi().then((function(r){return r.getSingle(t,e,n)}))},t.prototype.getBookmark=function(t,e,n){return this.getApi().then((function(r){return r.getBookmark(t,e,n)}))},t.prototype.previewSession=function(t,e,n,r){return this.getApi().then((function(i){return i.previewSession(t,e,n,r)}))},t.prototype.getPreviewResolver=function(t,e){var n=this;return _(t,e,(function(t,e){return n.getApi().then((function(n){return n.getByID(t,e)}))}))},t.getApi=function(t,e){return new G(t,e).get()},t}();function X(t,e){return V.getApi(t,e)}return{experimentCookie:"io.prismic.experiment",previewCookie:"io.prismic.preview",Predicates:W,Experiments:i,Api:G,client:function(t,e){return new V(t,e)},getApi:X,api:function(t,e){return X(t,e)}}})); | ||
//# sourceMappingURL=prismic-javascript.min.js.map |
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
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
470855
1