prismic-javascript
Advanced tools
Comparing version 1.5.0-beta.4 to 1.5.0-beta.5
@@ -7,9 +7,8 @@ export interface Document { | ||
tags: string[]; | ||
slug: string; | ||
slugs: string[]; | ||
lang?: string; | ||
alternateLanguages: string[]; | ||
firstPublicationDate: Date | null; | ||
lastPublicationDate: Date | null; | ||
alternate_languages: string[]; | ||
first_publication_date: string | null; | ||
last_publication_date: string | null; | ||
data: any; | ||
} |
@@ -9,7 +9,7 @@ import { Experiments as PrismicExperiment } from './experiments'; | ||
const Predicates: { | ||
at(fragment: string, value: string | string[]): string; | ||
not(fragment: string, value: string): string; | ||
at(fragment: string, value: string | number | Date | (string | number | Date)[]): string; | ||
not(fragment: string, value: string | number | Date | (string | number | Date)[]): string; | ||
missing(fragment: string): string; | ||
has(fragment: string): string; | ||
any(fragment: string, values: string[]): string; | ||
any(fragment: string, values: (string | number | Date)[]): string; | ||
in(fragment: string, values: string[]): string; | ||
@@ -19,11 +19,11 @@ fulltext(fragment: string, value: string): string; | ||
date: { | ||
before(fragment: string, before: Date): string; | ||
after(fragment: string, after: Date): string; | ||
between(fragment: string, before: Date, after: Date): string; | ||
before(fragment: string, before: string | number | Date): string; | ||
after(fragment: string, after: string | number | Date): string; | ||
between(fragment: string, before: string | number | Date, after: string | number | Date): string; | ||
dayOfMonth(fragment: string, day: number): string; | ||
dayOfMonthAfter(fragment: string, day: number): string; | ||
dayOfMonthBefore(fragment: string, day: number): string; | ||
dayOfWeek(fragment: string, day: number): string; | ||
dayOfWeekAfter(fragment: string, day: number): string; | ||
dayOfWeekBefore(fragment: string, day: number): string; | ||
dayOfWeek(fragment: string, day: string | number): string; | ||
dayOfWeekAfter(fragment: string, day: string | number): string; | ||
dayOfWeekBefore(fragment: string, day: string | number): string; | ||
month(fragment: string, month: string | number): string; | ||
@@ -37,11 +37,11 @@ monthBefore(fragment: string, month: string | number): string; | ||
}; | ||
dateBefore: (fragment: string, before: Date) => string; | ||
dateAfter: (fragment: string, after: Date) => string; | ||
dateBetween: (fragment: string, before: Date, after: Date) => string; | ||
dateBefore: (fragment: string, before: string | number | Date) => string; | ||
dateAfter: (fragment: string, after: string | number | Date) => string; | ||
dateBetween: (fragment: string, before: string | number | Date, after: string | number | Date) => string; | ||
dayOfMonth: (fragment: string, day: number) => string; | ||
dayOfMonthAfter: (fragment: string, day: number) => string; | ||
dayOfMonthBefore: (fragment: string, day: number) => string; | ||
dayOfWeek: (fragment: string, day: number) => string; | ||
dayOfWeekAfter: (fragment: string, day: number) => string; | ||
dayOfWeekBefore: (fragment: string, day: number) => string; | ||
dayOfWeek: (fragment: string, day: string | number) => string; | ||
dayOfWeekAfter: (fragment: string, day: string | number) => string; | ||
dayOfWeekBefore: (fragment: string, day: string | number) => string; | ||
month: (fragment: string, month: string | number) => string; | ||
@@ -48,0 +48,0 @@ monthBefore: (fragment: string, month: string | number) => string; |
declare const _default: { | ||
at(fragment: string, value: string | string[]): string; | ||
not(fragment: string, value: string): string; | ||
at(fragment: string, value: string | number | Date | (string | number | Date)[]): string; | ||
not(fragment: string, value: string | number | Date | (string | number | Date)[]): string; | ||
missing(fragment: string): string; | ||
has(fragment: string): string; | ||
any(fragment: string, values: string[]): string; | ||
any(fragment: string, values: (string | number | Date)[]): string; | ||
in(fragment: string, values: string[]): string; | ||
@@ -11,11 +11,11 @@ fulltext(fragment: string, value: string): string; | ||
date: { | ||
before(fragment: string, before: Date): string; | ||
after(fragment: string, after: Date): string; | ||
between(fragment: string, before: Date, after: Date): string; | ||
before(fragment: string, before: string | number | Date): string; | ||
after(fragment: string, after: string | number | Date): string; | ||
between(fragment: string, before: string | number | Date, after: string | number | Date): string; | ||
dayOfMonth(fragment: string, day: number): string; | ||
dayOfMonthAfter(fragment: string, day: number): string; | ||
dayOfMonthBefore(fragment: string, day: number): string; | ||
dayOfWeek(fragment: string, day: number): string; | ||
dayOfWeekAfter(fragment: string, day: number): string; | ||
dayOfWeekBefore(fragment: string, day: number): string; | ||
dayOfWeek(fragment: string, day: string | number): string; | ||
dayOfWeekAfter(fragment: string, day: string | number): string; | ||
dayOfWeekBefore(fragment: string, day: string | number): string; | ||
month(fragment: string, month: string | number): string; | ||
@@ -29,11 +29,11 @@ monthBefore(fragment: string, month: string | number): string; | ||
}; | ||
dateBefore: (fragment: string, before: Date) => string; | ||
dateAfter: (fragment: string, after: Date) => string; | ||
dateBetween: (fragment: string, before: Date, after: Date) => string; | ||
dateBefore: (fragment: string, before: string | number | Date) => string; | ||
dateAfter: (fragment: string, after: string | number | Date) => string; | ||
dateBetween: (fragment: string, before: string | number | Date, after: string | number | Date) => string; | ||
dayOfMonth: (fragment: string, day: number) => string; | ||
dayOfMonthAfter: (fragment: string, day: number) => string; | ||
dayOfMonthBefore: (fragment: string, day: number) => string; | ||
dayOfWeek: (fragment: string, day: number) => string; | ||
dayOfWeekAfter: (fragment: string, day: number) => string; | ||
dayOfWeekBefore: (fragment: string, day: number) => string; | ||
dayOfWeek: (fragment: string, day: string | number) => string; | ||
dayOfWeekAfter: (fragment: string, day: string | number) => string; | ||
dayOfWeekBefore: (fragment: string, day: string | number) => string; | ||
month: (fragment: string, month: string | number) => string; | ||
@@ -40,0 +40,0 @@ monthBefore: (fragment: string, month: string | number) => string; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("fetch-everywhere")):"function"==typeof define&&define.amd?define("PrismicJS",["fetch-everywhere"],e):"object"==typeof exports?exports.PrismicJS=e(require("fetch-everywhere")):t.PrismicJS=e(t["fetch-everywhere"])}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,n){"use strict";function r(t){return"string"==typeof t?'"'+t+'"':t instanceof Array?"["+t.map(function(t){return r(t)}).join(",")+"]":"number"==typeof t?t:null}e.__esModule=!0;var o={at:"at",not:"not",missing:"missing",has:"has",any:"any",in:"in",fulltext:"fulltext",similar:"similar",numberGt:"number.gt",numberLt:"number.lt",numberInRange:"number.inRange",dateBefore:"date.before",dateAfter:"date.after",dateBetween:"date.between",dateDayOfMonth:"date.day-of-month",dateDayOfMonthAfter:"date.day-of-month-after",dateDayOfMonthBefore:"date.day-of-month-before",dateDayOfWeek:"date.day-of-week",dateDayOfWeekAfter:"date.day-of-week-after",dateDayOfWeekBefore:"date.day-of-week-before",dateMonth:"date.month",dateMonthBefore:"date.month-before",dateMonthAfter:"date.month-after",dateYear:"date.year",dateHour:"date.hour",dateHourBefore:"date.hour-before",dateHourAfter:"date.hour-after",GeopointNear:"geopoint.near"},i={near:function(t,e,n,r){return"["+o.GeopointNear+"("+t+", "+e+", "+n+", "+r+")]"}},u={before:function(t,e){return"["+o.dateBefore+"("+t+", "+e.getTime()+")]"},after:function(t,e){return"["+o.dateAfter+"("+t+", "+e.getTime()+")]"},between:function(t,e,n){return"["+o.dateBetween+"("+t+", "+e.getTime()+", "+n.getTime()+")]"},dayOfMonth:function(t,e){return"["+o.dateDayOfMonth+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+o.dateDayOfMonthAfter+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+o.dateDayOfMonthBefore+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+o.dateDayOfWeek+"("+t+", "+e+")]"},dayOfWeekAfter:function(t,e){return"["+o.dateDayOfWeekAfter+"("+t+", "+e+")]"},dayOfWeekBefore:function(t,e){return"["+o.dateDayOfWeekBefore+"("+t+", "+e+")]"},month:function(t,e){return"number"==typeof e?"["+o.dateMonth+"("+t+", "+e+")]":"["+o.dateMonth+"("+t+', "'+e+'")]'},monthBefore:function(t,e){return"number"==typeof e?"["+o.dateMonthBefore+"("+t+", "+e+")]":"["+o.dateMonthBefore+"("+t+', "'+e+'")]'},monthAfter:function(t,e){return"number"==typeof e?"["+o.dateMonthAfter+"("+t+", "+e+")]":"["+o.dateMonthAfter+"("+t+', "'+e+'")]'},year:function(t,e){return"["+o.dateYear+"("+t+", "+e+")]"},hour:function(t,e){return"["+o.dateHour+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+o.dateHourBefore+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+o.dateHourAfter+"("+t+", "+e+")]"}},a={gt:function(t,e){return"["+o.numberGt+"("+t+", "+e+")]"},lt:function(t,e){return"["+o.numberLt+"("+t+", "+e+")]"},inRange:function(t,e,n){return"["+o.numberInRange+"("+t+", "+e+", "+n+")]"}};e.default={at:function(t,e){return"["+o.at+"("+t+", "+r(e)+")]"},not:function(t,e){return"["+o.not+"("+t+", "+r(e)+")]"},missing:function(t){return"["+o.missing+"("+t+")]"},has:function(t){return"["+o.has+"("+t+")]"},any:function(t,e){return"["+o.any+"("+t+", "+r(e)+")]"},in:function(t,e){return"["+o.in+"("+t+", "+r(e)+")]"},fulltext:function(t,e){return"["+o.fulltext+"("+t+", "+r(e)+")]"},similar:function(t,e){return"["+o.similar+'("'+t+'", '+e+")]"},date:u,dateBefore:u.before,dateAfter:u.after,dateBetween:u.between,dayOfMonth:u.dayOfMonth,dayOfMonthAfter:u.dayOfMonthAfter,dayOfMonthBefore:u.dayOfMonthBefore,dayOfWeek:u.dayOfWeek,dayOfWeekAfter:u.dayOfWeekAfter,dayOfWeekBefore:u.dayOfWeekBefore,month:u.month,monthBefore:u.monthBefore,monthAfter:u.monthAfter,year:u.year,hour:u.hour,hourBefore:u.hourBefore,hourAfter:u.hourAfter,number:a,gt:a.gt,lt:a.lt,inRange:a.inRange,near:i.near,geopoint:i}},function(t,e,n){"use strict";e.__esModule=!0;var r=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}();e.Variation=r;var o=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(function(t){return new r(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}();e.Experiment=o;var i=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map(function(t){return new o(t)}),this.running=(t.running||[]).map(function(t){return new o(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),o=this.running.filter(function(t){return t.googleId()===n&&t.variations.length>r})[0];return o?o.variations[r].ref():null},t}();e.Experiments=i},function(t,e,n){"use strict";e.__esModule=!0;var r=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 this.set("fetch",t)},t.prototype.fetchLinks=function(t){return this.set("fetchLinks",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):"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}();e.LazySearchForm=r;var o=function(){function t(t,e){this.httpClient=e,this.form=t,this.data={};for(var n in 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,o=this.data[t]||[];return o=n.multiple?r?o.concat([r]):o:r?[r]:o,this.data[t]=o,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(t instanceof Array)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){var e=t instanceof Array?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){var e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)},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(this.data.hasOwnProperty(n)){var r=this.data[n];if(r)for(var o=0;o<r.length;o++)t+=e+n+"="+encodeURIComponent(r[o]),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}();e.SearchForm=o},function(t,e,n){"use strict";e.__esModule=!0;var r=n(4),o=n(10),i=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var n="access_token="+this.options.accessToken;this.url+=(t.indexOf("?")>-1?"&":"?")+n}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new o.default(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(function(n){var o=new r.default(n,e.httpClient,e.options);return t&&t(null,o),o}).catch(function(e){throw t&&t(e),e})},t}();e.default=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(1),o=n(2),i=n(0),u=n(9);e.PREVIEW_COOKIE="io.prismic.preview",e.EXPERIMENT_COOKIE="io.prismic.experiment";var a=function(){function t(t,e,n){this.data=t,this.masterRef=t.refs.filter(function(t){return t.isMasterRef})[0],this.experiments=new r.Experiments(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=n,this.refs=t.refs,this.tags=t.tags,this.types=t.types}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new o.SearchForm(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,n,r){void 0===r&&(r=function(){});var o="function"==typeof n?{options:{},callback:n}:{options:n||{},callback:r},i=o.options,a=o.callback,f=this.everything();for(var s in i)f=f.set(s,i[s]);if(!i.ref){var c="";this.options.req?c=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(c=window.document.cookie||"");var h=u.default.parse(c),p=h[e.PREVIEW_COOKIE],l=this.experiments.refFromCookie(h[e.EXPERIMENT_COOKIE]);f=f.ref(p||l||this.masterRef.ref)}return t&&f.query(t),f.submit(a)},t.prototype.queryFirst=function(t,e,n){var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n||function(){}},o=r.options,i=r.callback;return o.page=1,o.pageSize=1,this.query(t,o).then(function(t){var e=t&&t.results&&t.results[0];return i(null,e),e}).catch(function(t){throw i(t),t})},t.prototype.getByID=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.queryFirst(i.default.at("document.id",t),r,n)},t.prototype.getByIDs=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.query(i.default.in("document.id",t),r,n)},t.prototype.getByUID=function(t,e,n,r){var o=n||{};return o.lang||(o.lang="*"),this.queryFirst(i.default.at("my."+t+".uid",e),o,r)},t.prototype.getSingle=function(t,e,n){var r=e||{};return this.queryFirst(i.default.at("document.type",t),r,n)},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.previewSession=function(t,e,n,r){var o=this;return this.httpClient.request(t).then(function(i){return i.mainDocument?o.getByID(i.mainDocument,{ref:t}).then(function(t){if(t){var o=e(t);return r&&r(null,o),o}return r&&r(null,n),n}):(r&&r(null,n),Promise.resolve(n))}).catch(function(t){throw r&&r(t),t})},t}();e.default=a},function(t,e,n){n(6),t.exports=n(7)},function(e,n){e.exports=t},function(t,e,n){"use strict";var r,o=n(0),i=n(1),u=n(8),a=n(3),f=n(4);!function(t){function e(t,e){return new u.DefaultClient(t,e)}function n(t,e){return u.DefaultClient.getApi(t,e)}function r(t,e){return n(t,e)}t.experimentCookie=f.EXPERIMENT_COOKIE,t.previewCookie=f.PREVIEW_COOKIE,t.Predicates=o.default,t.Experiments=i.Experiments,t.Api=a.default,t.client=e,t.getApi=n,t.api=r}(r||(r={})),t.exports=r},function(t,e,n){"use strict";e.__esModule=!0;var r=n(2),o=n(3),i=function(){function t(t,e){this.api=new o.default(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 r.LazySearchForm(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(o){return o.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(o){return o.previewSession(t,e,n,r)})},t.getApi=function(t,e){return new o.default(t,e).get()},t}();e.DefaultClient=i},function(t,e,n){"use strict";function r(t,e){try{return e(t)}catch(e){return t}}function o(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var n={},o=e||{},u=o.decode||i;return t.split(/; */).forEach(function(t){var e=t.indexOf("=");if(!(e<0)){var o=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),void 0==n[o]&&(n[o]=r(i,u))}}),n}e.__esModule=!0;var i=decodeURIComponent;e.default={parse:o}},function(t,e,n){"use strict";e.__esModule=!0;var r=n(11),o=n(13),i=function(){function t(t,e,n){this.requestHandler=t||new o.DefaultRequestHandler({proxyAgent:n}),this.cache=e||new r.DefaultApiCache}return t.prototype.request=function(t,e){var n=this;return new Promise(function(r,o){n.requestHandler.request(t,function(t,n,i,u){t?(o(t),e&&e(t,null,i,u)):n&&(r(n),e&&e(null,n,i,u))})})},t.prototype.cachedRequest=function(t,e){var n=this,r=e||{},o=function(e){var o=r.cacheKey||t;n.cache.get(o,function(i,u){i||u?e(i,u):n.request(t,function(t,i,u,a){if(t)e(t,null);else{var f=a||r.ttl;f&&n.cache.set(o,i,f,e),e(null,i)}})})};return new Promise(function(t,e){o(function(n,r){n&&e(n),r&&t(r)})})},t}();e.default=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(12),o=function(){function t(t){void 0===t&&(t=1e3),this.lru=r.MakeLRUCache(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}();e.DefaultApiCache=o},function(t,e,n){"use strict";function r(t){return new o(t)}function o(t){this.size=0,this.limit=t,this._keymap={}}e.__esModule=!0,e.MakeLRUCache=r,o.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++},o.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},o.prototype.get=function(t,e){var n=this._keymap[t];if(void 0!==n)return n===this.tail?e?n:n.value:(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)},o.prototype.find=function(t){return this._keymap[t]},o.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},o.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},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 t=[];for(var e in this._keymap)t.push(e);return t},o.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},o.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t}},function(t,e,n){"use strict";function r(t,e,n){var r={headers:{Accept:"application/json"}};e&&e.proxyAgent&&(r.agent=e.proxyAgent),fetch(t,r).then(function(e){if(~~(e.status/100!=2)){var r=new Error("Unexpected status code ["+e.status+"] on URL "+t);throw r.status=e.status,r}return e.json().then(function(t){var r=e.headers.get("cache-control"),o=r?/max-age=(\d+)/.exec(r):null,i=o?parseInt(o[1],10):void 0;n(null,t,e,i)})}).catch(n)}function o(t){if(a.length>0&&u<i){u++;var e=a.shift();e&&r(e.url,t,function(n,r,i,a){u--,e.callback(n,r,i,a),o(t)})}}e.__esModule=!0;var i=20,u=0,a=[],f=function(){function t(t){this.options=t||{}}return t.prototype.request=function(t,e){a.push({url:t,callback:e}),o(this.options)},t}();e.DefaultRequestHandler=f}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("fetch-everywhere")):"function"==typeof define&&define.amd?define("PrismicJS",["fetch-everywhere"],e):"object"==typeof exports?exports.PrismicJS=e(require("fetch-everywhere")):t.PrismicJS=e(t["fetch-everywhere"])}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,n){"use strict";function r(t){if("string"==typeof t)return'"'+t+'"';if("number"==typeof t)return t.toString();if(t instanceof Date)return t.getTime().toString();if(t instanceof Array)return"["+t.map(function(t){return r(t)}).join(",")+"]";throw new Error("Unable to encode "+t+" of type "+typeof t)}e.__esModule=!0;var o={at:"at",not:"not",missing:"missing",has:"has",any:"any",in:"in",fulltext:"fulltext",similar:"similar",numberGt:"number.gt",numberLt:"number.lt",numberInRange:"number.inRange",dateBefore:"date.before",dateAfter:"date.after",dateBetween:"date.between",dateDayOfMonth:"date.day-of-month",dateDayOfMonthAfter:"date.day-of-month-after",dateDayOfMonthBefore:"date.day-of-month-before",dateDayOfWeek:"date.day-of-week",dateDayOfWeekAfter:"date.day-of-week-after",dateDayOfWeekBefore:"date.day-of-week-before",dateMonth:"date.month",dateMonthBefore:"date.month-before",dateMonthAfter:"date.month-after",dateYear:"date.year",dateHour:"date.hour",dateHourBefore:"date.hour-before",dateHourAfter:"date.hour-after",GeopointNear:"geopoint.near"},i={near:function(t,e,n,r){return"["+o.GeopointNear+"("+t+", "+e+", "+n+", "+r+")]"}},u={before:function(t,e){return"["+o.dateBefore+"("+t+", "+r(e)+")]"},after:function(t,e){return"["+o.dateAfter+"("+t+", "+r(e)+")]"},between:function(t,e,n){return"["+o.dateBetween+"("+t+", "+r(e)+", "+r(n)+")]"},dayOfMonth:function(t,e){return"["+o.dateDayOfMonth+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+o.dateDayOfMonthAfter+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+o.dateDayOfMonthBefore+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+o.dateDayOfWeek+"("+t+", "+r(e)+")]"},dayOfWeekAfter:function(t,e){return"["+o.dateDayOfWeekAfter+"("+t+", "+r(e)+")]"},dayOfWeekBefore:function(t,e){return"["+o.dateDayOfWeekBefore+"("+t+", "+r(e)+")]"},month:function(t,e){return"["+o.dateMonth+"("+t+", "+r(e)+")]"},monthBefore:function(t,e){return"["+o.dateMonthBefore+"("+t+", "+r(e)+")]"},monthAfter:function(t,e){return"["+o.dateMonthAfter+"("+t+", "+r(e)+")]"},year:function(t,e){return"["+o.dateYear+"("+t+", "+e+")]"},hour:function(t,e){return"["+o.dateHour+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+o.dateHourBefore+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+o.dateHourAfter+"("+t+", "+e+")]"}},a={gt:function(t,e){return"["+o.numberGt+"("+t+", "+e+")]"},lt:function(t,e){return"["+o.numberLt+"("+t+", "+e+")]"},inRange:function(t,e,n){return"["+o.numberInRange+"("+t+", "+e+", "+n+")]"}};e.default={at:function(t,e){return"["+o.at+"("+t+", "+r(e)+")]"},not:function(t,e){return"["+o.not+"("+t+", "+r(e)+")]"},missing:function(t){return"["+o.missing+"("+t+")]"},has:function(t){return"["+o.has+"("+t+")]"},any:function(t,e){return"["+o.any+"("+t+", "+r(e)+")]"},in:function(t,e){return"["+o.in+"("+t+", "+r(e)+")]"},fulltext:function(t,e){return"["+o.fulltext+"("+t+", "+r(e)+")]"},similar:function(t,e){return"["+o.similar+'("'+t+'", '+e+")]"},date:u,dateBefore:u.before,dateAfter:u.after,dateBetween:u.between,dayOfMonth:u.dayOfMonth,dayOfMonthAfter:u.dayOfMonthAfter,dayOfMonthBefore:u.dayOfMonthBefore,dayOfWeek:u.dayOfWeek,dayOfWeekAfter:u.dayOfWeekAfter,dayOfWeekBefore:u.dayOfWeekBefore,month:u.month,monthBefore:u.monthBefore,monthAfter:u.monthAfter,year:u.year,hour:u.hour,hourBefore:u.hourBefore,hourAfter:u.hourAfter,number:a,gt:a.gt,lt:a.lt,inRange:a.inRange,near:i.near,geopoint:i}},function(t,e,n){"use strict";e.__esModule=!0;var r=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}();e.Variation=r;var o=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(function(t){return new r(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}();e.Experiment=o;var i=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map(function(t){return new o(t)}),this.running=(t.running||[]).map(function(t){return new o(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),o=this.running.filter(function(t){return t.googleId()===n&&t.variations.length>r})[0];return o?o.variations[r].ref():null},t}();e.Experiments=i},function(t,e,n){"use strict";e.__esModule=!0;var r=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 this.set("fetch",t)},t.prototype.fetchLinks=function(t){return this.set("fetchLinks",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):"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}();e.LazySearchForm=r;var o=function(){function t(t,e){this.httpClient=e,this.form=t,this.data={};for(var n in 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,o=this.data[t]||[];return o=n.multiple?r?o.concat([r]):o:r?[r]:o,this.data[t]=o,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(t instanceof Array)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){var e=t instanceof Array?t.join(","):t;return this.set("fetch",e)},t.prototype.fetchLinks=function(t){var e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)},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(this.data.hasOwnProperty(n)){var r=this.data[n];if(r)for(var o=0;o<r.length;o++)t+=e+n+"="+encodeURIComponent(r[o]),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}();e.SearchForm=o},function(t,e,n){"use strict";e.__esModule=!0;var r=n(4),o=n(10),i=function(){function t(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){var n="access_token="+this.options.accessToken;this.url+=(t.indexOf("?")>-1?"&":"?")+n}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new o.default(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}return t.prototype.get=function(t){var e=this;return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(function(n){var o=new r.default(n,e.httpClient,e.options);return t&&t(null,o),o}).catch(function(e){throw t&&t(e),e})},t}();e.default=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(1),o=n(2),i=n(0),u=n(9);e.PREVIEW_COOKIE="io.prismic.preview",e.EXPERIMENT_COOKIE="io.prismic.experiment";var a=function(){function t(t,e,n){this.data=t,this.masterRef=t.refs.filter(function(t){return t.isMasterRef})[0],this.experiments=new r.Experiments(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=n,this.refs=t.refs,this.tags=t.tags,this.types=t.types}return t.prototype.form=function(t){var e=this.data.forms[t];return e?new o.SearchForm(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,n,r){void 0===r&&(r=function(){});var o="function"==typeof n?{options:{},callback:n}:{options:n||{},callback:r},i=o.options,a=o.callback,f=this.everything();for(var s in i)f=f.set(s,i[s]);if(!i.ref){var c="";this.options.req?c=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(c=window.document.cookie||"");var h=u.default.parse(c),p=h[e.PREVIEW_COOKIE],l=this.experiments.refFromCookie(h[e.EXPERIMENT_COOKIE]);f=f.ref(p||l||this.masterRef.ref)}return t&&f.query(t),f.submit(a)},t.prototype.queryFirst=function(t,e,n){var r="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:n||function(){}},o=r.options,i=r.callback;return o.page=1,o.pageSize=1,this.query(t,o).then(function(t){var e=t&&t.results&&t.results[0];return i(null,e),e}).catch(function(t){throw i(t),t})},t.prototype.getByID=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.queryFirst(i.default.at("document.id",t),r,n)},t.prototype.getByIDs=function(t,e,n){var r=e||{};return r.lang||(r.lang="*"),this.query(i.default.in("document.id",t),r,n)},t.prototype.getByUID=function(t,e,n,r){var o=n||{};return o.lang||(o.lang="*"),this.queryFirst(i.default.at("my."+t+".uid",e),o,r)},t.prototype.getSingle=function(t,e,n){var r=e||{};return this.queryFirst(i.default.at("document.type",t),r,n)},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.previewSession=function(t,e,n,r){var o=this;return this.httpClient.request(t).then(function(i){return i.mainDocument?o.getByID(i.mainDocument,{ref:t}).then(function(t){if(t){var o=e(t);return r&&r(null,o),o}return r&&r(null,n),n}):(r&&r(null,n),Promise.resolve(n))}).catch(function(t){throw r&&r(t),t})},t}();e.default=a},function(t,e,n){n(6),t.exports=n(7)},function(e,n){e.exports=t},function(t,e,n){"use strict";var r,o=n(0),i=n(1),u=n(8),a=n(3),f=n(4);!function(t){function e(t,e){return new u.DefaultClient(t,e)}function n(t,e){return u.DefaultClient.getApi(t,e)}function r(t,e){return n(t,e)}t.experimentCookie=f.EXPERIMENT_COOKIE,t.previewCookie=f.PREVIEW_COOKIE,t.Predicates=o.default,t.Experiments=i.Experiments,t.Api=a.default,t.client=e,t.getApi=n,t.api=r}(r||(r={})),t.exports=r},function(t,e,n){"use strict";e.__esModule=!0;var r=n(2),o=n(3),i=function(){function t(t,e){this.api=new o.default(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 r.LazySearchForm(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(o){return o.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(o){return o.previewSession(t,e,n,r)})},t.getApi=function(t,e){return new o.default(t,e).get()},t}();e.DefaultClient=i},function(t,e,n){"use strict";function r(t,e){try{return e(t)}catch(e){return t}}function o(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var n={},o=e||{},u=o.decode||i;return t.split(/; */).forEach(function(t){var e=t.indexOf("=");if(!(e<0)){var o=t.substr(0,e).trim(),i=t.substr(++e,t.length).trim();'"'==i[0]&&(i=i.slice(1,-1)),void 0==n[o]&&(n[o]=r(i,u))}}),n}e.__esModule=!0;var i=decodeURIComponent;e.default={parse:o}},function(t,e,n){"use strict";e.__esModule=!0;var r=n(11),o=n(13),i=function(){function t(t,e,n){this.requestHandler=t||new o.DefaultRequestHandler({proxyAgent:n}),this.cache=e||new r.DefaultApiCache}return t.prototype.request=function(t,e){var n=this;return new Promise(function(r,o){n.requestHandler.request(t,function(t,n,i,u){t?(o(t),e&&e(t,null,i,u)):n&&(r(n),e&&e(null,n,i,u))})})},t.prototype.cachedRequest=function(t,e){var n=this,r=e||{},o=function(e){var o=r.cacheKey||t;n.cache.get(o,function(i,u){i||u?e(i,u):n.request(t,function(t,i,u,a){if(t)e(t,null);else{var f=a||r.ttl;f&&n.cache.set(o,i,f,e),e(null,i)}})})};return new Promise(function(t,e){o(function(n,r){n&&e(n),r&&t(r)})})},t}();e.default=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(12),o=function(){function t(t){void 0===t&&(t=1e3),this.lru=r.MakeLRUCache(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}();e.DefaultApiCache=o},function(t,e,n){"use strict";function r(t){return new o(t)}function o(t){this.size=0,this.limit=t,this._keymap={}}e.__esModule=!0,e.MakeLRUCache=r,o.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++},o.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},o.prototype.get=function(t,e){var n=this._keymap[t];if(void 0!==n)return n===this.tail?e?n:n.value:(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)},o.prototype.find=function(t){return this._keymap[t]},o.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},o.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},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 t=[];for(var e in this._keymap)t.push(e);return t},o.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},o.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t}},function(t,e,n){"use strict";function r(t,e,n){var r={headers:{Accept:"application/json"}};e&&e.proxyAgent&&(r.agent=e.proxyAgent),fetch(t,r).then(function(e){if(~~(e.status/100!=2)){var r=new Error("Unexpected status code ["+e.status+"] on URL "+t);throw r.status=e.status,r}return e.json().then(function(t){var r=e.headers.get("cache-control"),o=r?/max-age=(\d+)/.exec(r):null,i=o?parseInt(o[1],10):void 0;n(null,t,e,i)})}).catch(n)}function o(t){if(a.length>0&&u<i){u++;var e=a.shift();e&&r(e.url,t,function(n,r,i,a){u--,e.callback(n,r,i,a),o(t)})}}e.__esModule=!0;var i=20,u=0,a=[],f=function(){function t(t){this.options=t||{}}return t.prototype.request=function(t,e){a.push({url:t,callback:e}),o(this.options)},t}();e.DefaultRequestHandler=f}])}); |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.5.0-beta.4", | ||
"version": "1.5.0-beta.5", | ||
"devDependencies": { | ||
@@ -16,0 +16,0 @@ "chai": "^4.1.1", |
@@ -7,9 +7,8 @@ export interface Document { | ||
tags: string[]; | ||
slug: string; | ||
slugs: string[]; | ||
lang ?: string; | ||
alternateLanguages: string[]; | ||
firstPublicationDate: Date | null; | ||
lastPublicationDate: Date | null; | ||
alternate_languages: string[]; | ||
first_publication_date: string | null; | ||
last_publication_date: string | null; | ||
data: any; | ||
} |
@@ -32,11 +32,15 @@ const OPERATOR = { | ||
function encode(value: string | string[]): string | null { | ||
type PredicateValue = string | number | Date; | ||
function encode(value: PredicateValue | PredicateValue[]): string { | ||
if (typeof value === 'string') { | ||
return `"${value}"`; | ||
} else if (typeof value === 'number') { | ||
return value.toString(); | ||
} else if (value instanceof Date) { | ||
return value.getTime().toString(); | ||
} else if (value instanceof Array) { | ||
return `[${value.map(v => encode(v)).join(',')}]`; | ||
} else if (typeof value === 'number') { | ||
return value; | ||
} else { | ||
return null; | ||
throw new Error(`Unable to encode ${value} of type ${typeof value}`); | ||
} | ||
@@ -53,12 +57,12 @@ } | ||
before(fragment: string, before: Date): string { | ||
return `[${OPERATOR.dateBefore}(${fragment}, ${before.getTime()})]`; | ||
before(fragment: string, before: PredicateValue): string { | ||
return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; | ||
}, | ||
after(fragment: string, after: Date): string { | ||
return `[${OPERATOR.dateAfter}(${fragment}, ${after.getTime()})]`; | ||
after(fragment: string, after: PredicateValue): string { | ||
return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; | ||
}, | ||
between(fragment: string, before: Date, after: Date): string { | ||
return `[${OPERATOR.dateBetween}(${fragment}, ${before.getTime()}, ${after.getTime()})]`; | ||
between(fragment: string, before: PredicateValue, after: PredicateValue): string { | ||
return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; | ||
}, | ||
@@ -78,36 +82,24 @@ | ||
dayOfWeek(fragment: string, day: number): string { | ||
return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${day})]`; | ||
dayOfWeek(fragment: string, day: number | string): string { | ||
return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; | ||
}, | ||
dayOfWeekAfter(fragment: string, day: number): string { | ||
return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${day})]`; | ||
dayOfWeekAfter(fragment: string, day: number | string): string { | ||
return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; | ||
}, | ||
dayOfWeekBefore(fragment: string, day: number): string { | ||
return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${day})]`; | ||
dayOfWeekBefore(fragment: string, day: number | string): string { | ||
return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; | ||
}, | ||
month(fragment: string, month: number | string): string { | ||
if (typeof month === 'number') { | ||
return `[${OPERATOR.dateMonth}(${fragment}, ${month})]`; | ||
} else { | ||
return `[${OPERATOR.dateMonth}(${fragment}, "${month}")]`; | ||
} | ||
return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; | ||
}, | ||
monthBefore(fragment: string, month: number | string): string { | ||
if (typeof month === 'number') { | ||
return `[${OPERATOR.dateMonthBefore}(${fragment}, ${month})]`; | ||
} else { | ||
return `[${OPERATOR.dateMonthBefore}(${fragment}, "${month}")]`; | ||
} | ||
return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; | ||
}, | ||
monthAfter(fragment: string, month: number | string): string { | ||
if (typeof month === 'number') { | ||
return `[${OPERATOR.dateMonthAfter}(${fragment}, ${month})]`; | ||
} else { | ||
return `[${OPERATOR.dateMonthAfter}(${fragment}, "${month}")]`; | ||
} | ||
return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; | ||
}, | ||
@@ -147,7 +139,7 @@ | ||
export default { | ||
at(fragment: string, value: string | string[]): string { | ||
at(fragment: string, value: PredicateValue | PredicateValue[]): string { | ||
return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; | ||
}, | ||
not(fragment: string, value: string): string { | ||
not(fragment: string, value: PredicateValue | PredicateValue[]): string { | ||
return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; | ||
@@ -164,3 +156,3 @@ }, | ||
any(fragment: string, values: string[]): string { | ||
any(fragment: string, values: PredicateValue[]): string { | ||
return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; | ||
@@ -167,0 +159,0 @@ }, |
@@ -205,3 +205,3 @@ var path = require('path'); | ||
getApi().then(function(api) { | ||
return api.getByUID('how-to-query-the-api').then(function(document) { | ||
return api.getByUID('product', 'how-to-query-the-api').then(function(document) { | ||
assert.strictEqual(document.id, 'WW4bKScAAMAqmluX'); | ||
@@ -208,0 +208,0 @@ |
@@ -8,3 +8,3 @@ var path = require('path'); | ||
it('should build at query with string value', function() { | ||
it('should build at query with number value', function() { | ||
assert.strictEqual( | ||
@@ -16,4 +16,35 @@ Prismic.Predicates.at('my.product.price', 10), | ||
it('should build at query with number value', function() { | ||
it('should build at query with date value', function() { | ||
var date = new Date(); | ||
assert.strictEqual( | ||
Prismic.Predicates.at('my.product.date', date), | ||
'[at(my.product.date, ' + date.getTime() + ')]' | ||
); | ||
}); | ||
it('should build at query with date values', function() { | ||
var dateA = new Date(); | ||
var dateB = new Date(); | ||
assert.strictEqual( | ||
Prismic.Predicates.at('my.product.date', [dateA, dateB]), | ||
'[at(my.product.date, [' + dateA.getTime() + ',' + dateB.getTime() + '])]' | ||
); | ||
}); | ||
it('should build at query with number values', function() { | ||
assert.strictEqual( | ||
Prismic.Predicates.at('my.product.price', [10, 11]), | ||
'[at(my.product.price, [10,11])]' | ||
); | ||
}); | ||
it('should build at query with string values', function() { | ||
assert.strictEqual( | ||
Prismic.Predicates.at('document.tags', ['tagA', 'tagB']), | ||
'[at(document.tags, ["tagA","tagB"])]' | ||
); | ||
}); | ||
it('should build at query with string value', function() { | ||
assert.strictEqual( | ||
Prismic.Predicates.at('my.product.type', 'chair'), | ||
@@ -111,5 +142,33 @@ '[at(my.product.type, "chair")]' | ||
it('should build date.before query', function() { | ||
it('should build date.before query with timestamp value', function() { | ||
var date = new Date(); | ||
var timestamp = date.getTime(); | ||
assert.strictEqual( | ||
Prismic.Predicates.date.before('my.product.date', timestamp), | ||
'[date.before(my.product.date, ' + timestamp + ')]' | ||
); | ||
assert.strictEqual( | ||
Prismic.Predicates.dateBefore('my.product.date', timestamp), | ||
'[date.before(my.product.date, ' + timestamp + ')]' | ||
); | ||
}); | ||
it('should build date.before query with string value', function() { | ||
assert.strictEqual( | ||
Prismic.Predicates.date.before('my.product.date', '2017-08-24'), | ||
'[date.before(my.product.date, "2017-08-24")]' | ||
); | ||
assert.strictEqual( | ||
Prismic.Predicates.dateBefore('my.product.date', '2017-08-24'), | ||
'[date.before(my.product.date, "2017-08-24")]' | ||
); | ||
}); | ||
it('should build date.before query with Date value', function() { | ||
var date = new Date(); | ||
assert.strictEqual( | ||
Prismic.Predicates.date.before('my.product.date', date), | ||
@@ -195,2 +254,7 @@ '[date.before(my.product.date, ' + date.getTime() + ')]' | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeek('my.product.date', 'monday'), | ||
'[date.day-of-week(my.product.date, "monday")]' | ||
); | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeek('my.product.date', 2), | ||
@@ -208,2 +272,7 @@ '[date.day-of-week(my.product.date, 2)]' | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeekAfter('my.product.date', 'monday'), | ||
'[date.day-of-week-after(my.product.date, "monday")]' | ||
); | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeekAfter('my.product.date', 2), | ||
@@ -221,2 +290,7 @@ '[date.day-of-week-after(my.product.date, 2)]' | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeekBefore('my.product.date', 'monday'), | ||
'[date.day-of-week-before(my.product.date, "monday")]' | ||
); | ||
assert.strictEqual( | ||
Prismic.Predicates.dayOfWeekBefore('my.product.date', 2), | ||
@@ -223,0 +297,0 @@ '[date.day-of-week-before(my.product.date, 2)]' |
@@ -70,3 +70,3 @@ var path = require('path'); | ||
it('should query one document by uid', function(done) { | ||
client.getByUID('how-to-query-the-api').then(function(document) { | ||
client.getByUID('product', 'how-to-query-the-api').then(function(document) { | ||
assert.strictEqual(document.id, 'WW4bKScAAMAqmluX'); | ||
@@ -73,0 +73,0 @@ done(); |
@@ -9,3 +9,3 @@ { | ||
"module": "commonjs", | ||
"lib": ["es5", "dom", "es2015.promise"], | ||
"lib": ["es5", "dom", "es2015.promise", "es2015.symbol", "es2015.symbol.wellknown"], | ||
"strictNullChecks": true, | ||
@@ -12,0 +12,0 @@ "baseUrl": "." |
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
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
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1604225
9750